mem

package
v0.0.0-...-70d8496 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2019 License: BSD-3-Clause, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DMAPLEN int = 1 << 39
View Source
const PGSHIFT uint = 12
View Source
const PGSIZE int = 1 << PGSHIFT
View Source
const USERMIN int = VUSER << 39
View Source
const VDIRECT int = 0x44
View Source
const VEND int = 0x50
View Source
const VREC int = 0x42
View Source
const VUSER int = 0x59

Variables

View Source
var Kents = make([]Kent_t, 0, 5)
View Source
var Physmem = &Physmem_t{}
View Source
var Vdirect = uintptr(VDIRECT << 39)

Functions

func Dmap_init

func Dmap_init()

installs a direct map for 512G of physical memory via the recursive mapping

func Dmaplen

func Dmaplen(p Pa_t, l int) []uint8

l is length of mapping in bytes

func Dmaplen32

func Dmaplen32(p uintptr, l int) []uint32

l is length of mapping in bytes. both p and l must be multiples of 4

Types

type Bytepg_t

type Bytepg_t [PGSIZE]uint8
var Zerobpg *Bytepg_t

func Pg2bytes

func Pg2bytes(pg *Pg_t) *Bytepg_t

type Kent_t

type Kent_t struct {
	Pml4slot int
	Entry    Pa_t
}

type Mmapinfo_t

type Mmapinfo_t struct {
	Pg   *Pg_t
	Phys Pa_t
}

type Pa_t

type Pa_t uintptr
const PGMASK Pa_t = ^(PGOFFSET)
const PGOFFSET Pa_t = 0xfff
const PTE_ADDR Pa_t = PGMASK
const PTE_G Pa_t = 1 << 8
const PTE_P Pa_t = 1 << 0
const PTE_PCD Pa_t = 1 << 4
const PTE_PS Pa_t = 1 << 7
const PTE_U Pa_t = 1 << 2
const PTE_W Pa_t = 1 << 1
var P_zeropg Pa_t

type Page_i

type Page_i interface {
	Refpg_new() (*Pg_t, Pa_t, bool)
	Refpg_new_nozero() (*Pg_t, Pa_t, bool)
	Refcnt(Pa_t) int
	Dmap(Pa_t) *Pg_t
	Refup(Pa_t)
	Refdown(Pa_t) bool
}

type Pg_t

type Pg_t [512]int
var Zeropg *Pg_t

func Bytepg2pg

func Bytepg2pg(pg *Bytepg_t) *Pg_t

type Physmem_t

type Physmem_t struct {
	Pgs []Physpg_t

	sync.Mutex
	Dmapinit bool
	// contains filtered or unexported fields
}

func Phys_init

func Phys_init() *Physmem_t

func (*Physmem_t) Dec_pmap

func (phys *Physmem_t) Dec_pmap(p_pmap Pa_t)

decrease ref count of pml4, freeing it if no CPUs have it loaded into cr3.

func (*Physmem_t) Dmap

func (phys *Physmem_t) Dmap(p Pa_t) *Pg_t

returns a page-aligned virtual address for the given physical address using the direct mapping

func (*Physmem_t) Dmap8

func (phys *Physmem_t) Dmap8(p Pa_t) []uint8

returns a byte aligned virtual address for the physical address as slice of uint8s

func (*Physmem_t) Dmap_v2p

func (phys *Physmem_t) Dmap_v2p(v *Pg_t) Pa_t

func (*Physmem_t) Pgcount

func (phys *Physmem_t) Pgcount() (int, int, []int, []int)

func (*Physmem_t) Pmap_new

func (phys *Physmem_t) Pmap_new() (*Pmap_t, Pa_t, bool)

func (*Physmem_t) Refaddr

func (phys *Physmem_t) Refaddr(p_pg Pa_t) (*int32, uint32)

func (*Physmem_t) Refcnt

func (phys *Physmem_t) Refcnt(p_pg Pa_t) int

func (*Physmem_t) Refdown

func (phys *Physmem_t) Refdown(p_pg Pa_t) bool

func (*Physmem_t) Refpg_new

func (phys *Physmem_t) Refpg_new() (*Pg_t, Pa_t, bool)

refcnt of returned page is not incremented (it is usually incremented via Proc_t.page_insert). requires direct mapping.

func (*Physmem_t) Refpg_new_nozero

func (phys *Physmem_t) Refpg_new_nozero() (*Pg_t, Pa_t, bool)

func (*Physmem_t) Refup

func (phys *Physmem_t) Refup(p_pg Pa_t)

func (*Physmem_t) Tlbaddr

func (phys *Physmem_t) Tlbaddr(p_pg Pa_t) *uint64

type Physpg_t

type Physpg_t struct {
	Refcnt int32

	// Bitmask where bit n is set if CPU w/logical ID n loaded this page
	// (which is a pmap) into its cr3 register
	Cpumask uint64
	// contains filtered or unexported fields
}

can account for up to 16TB of mem

type Pmap_t

type Pmap_t [512]Pa_t
var Kpmapp *Pmap_t

func Kpmap

func Kpmap() *Pmap_t

type Unpin_i

type Unpin_i interface {
	Unpin(Pa_t)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL