rusty_mos::memory

Module pmap

Source
Expand description

The page-memory manager model of MOS. Core functions are provided here.

Structs§

  • The only page data needed to maintain.

Constants§

Statics§

  • Current env’s page directary address.
  • The kernel heap start. Used by the buddy system.
  • The the count of all the pages available.
  • The kernel array for all pages.
  • The list of free pages.

Functions§

  • alloc 🔒
    Alloc needed memorys in kernel mode. Only use it before the page-manager is ready to use.
  • Calculate the NPAGE and validate it.
  • Alloc memories needed for the PAGES and reserve 512 * 4KB spaces for the buddy system to alloc.
  • Alloc a page. Return the page’s address or an error if no free pages available.
  • Decrease the page’s pp_ref. If all reference is removed, the page will be freed.
  • Free a page. The pp_ref shall be zero before freeing it.
  • Init all the pages. Mark the pages below the freemem as used.
  • Map the physical page to the virtual address va. The permission bits will be set to perm | PTE_C_CACHEABLE | PTE_V.
  • Look up the Page that virtual address va map to. Return the page and the page table entry together if the page is found and is valid.
  • Unmap the physical page at virtual address va.
  • Walk the current page table to find the virtual address va’s page table entry (Pte).

Type Aliases§