|
AquilaOS documentation
How it works, and its code
|
Go to the source code of this file.
Functions | |
| void | pmap_init (void) |
| Takes over the boot page tables as the kernel's, at boot, and makes the page tables of the kernel's half, which every address space shares. | |
| struct pmap * | pmap_switch (struct pmap *pmap) |
| Switches this CPU to an address space's page tables. | |
| struct pmap * | pmap_create (void) |
| Makes the page tables of a new address space: an empty user half, and the kernel's half, which every address space shares. | |
| void | pmap_incref (struct pmap *pmap) |
| Adds a reference to an address space's page tables. | |
| void | pmap_decref (struct pmap *pmap) |
| Drops a reference to an address space's page tables, freeing them with the last one. | |
| int | pmap_add (struct pmap *pmap, vaddr_t va, paddr_t pa, uint32_t flags) |
| Maps a page in an address space, replacing what was mapped there. | |
| void | pmap_remove (struct pmap *pmap, vaddr_t sva, vaddr_t eva) |
| Unmaps the pages of a range of an address space, and flushes them from the TLBs that may have them. | |
| void | pmap_protect (struct pmap *pmap, vaddr_t sva, vaddr_t eva, uint32_t prot) |
| Changes the permissions of the mapped pages of a range of an address space. | |
| void | pmap_page_copy (paddr_t src, paddr_t dst) |
| Copies a page of physical memory to another. | |
| void | pmap_remove_all (struct pmap *pmap) |
| Unmaps the whole user half of an address space, and frees its page tables. | |
| int | pmap_page_read (paddr_t paddr, off_t off, size_t size, void *buf) |
| Reads from a page of physical memory, through the kernel's mapping. | |
| int | pmap_page_write (paddr_t paddr, off_t off, size_t size, void *buf) |
| Writes to a page of physical memory, through the kernel's mapping. | |
Maps a page in an address space, replacing what was mapped there.
| pmap | the page tables (an address in the kernel's half is mapped in every address space) |
| va | the virtual address, page-aligned |
| pa | the page's physical address, page-aligned |
| flags | the mapping's permissions and caching (VM_*) |
Definition at line 307 of file pmap.c.
References ARCH_DMAP_BASE, D_VALID, dmap_end, k_pmap, KERNEL_HALF, PAGE_MASK, PAGE_SIZE, PG_PRESENT, pmap_add(), pte_flags(), pte_get(), and tlb_shootdown().
Referenced by kvmem_alloc(), mm_page_map(), phys_window_map(), pmap_add(), slab_page_alloc(), window_map(), and window_map().
| struct pmap * pmap_create | ( | void | ) |
Makes the page tables of a new address space: an empty user half, and the kernel's half, which every address space shares.
Definition at line 242 of file pmap.c.
References k_pmap, KERNEL_PDE, KERNEL_PML4E, kfree(), kmalloc(), M_ZERO, pmap::map, memset(), NULL, pmap_alloc(), pmap_create(), pmap::ref, table(), and table_alloc().
Referenced by pmap_create(), and proc_new().
| void pmap_decref | ( | struct pmap * | pmap | ) |
Drops a reference to an address space's page tables, freeing them with the last one.
| pmap | the page tables |
Definition at line 271 of file pmap.c.
References pmap_decref(), pmap_release(), and pmap::ref.
Referenced by pmap_decref(), proc_fork(), proc_kill(), and proc_new().
| void pmap_incref | ( | struct pmap * | pmap | ) |
Adds a reference to an address space's page tables.
| pmap | the page tables |
Definition at line 263 of file pmap.c.
References pmap_incref(), and pmap::ref.
Referenced by pmap_incref().
| void pmap_init | ( | void | ) |
Takes over the boot page tables as the kernel's, at boot, and makes the page tables of the kernel's half, which every address space shares.
Definition at line 195 of file pmap.c.
References ARCH_BOOT_MAPPED, ARCH_DMAP_BASE, cur_pmap, D_AF, D_ATTR, D_SH_INNER, D_VALID, dmap_end, IDX, k_pmap, k_root, KERNEL_PDE, KERNEL_PML4E, kvm_space, LARGE_SIZE, LMA, pmap::map, MAX, NULL, PAGE_MASK, panic, PG_ADDR, PG_GLOBAL, PG_LARGE, PG_PRESENT, PG_WRITE, vm_space::pmap, pmap_init(), pmap_loaded(), pmap_switch(), printk(), ram_end(), read_cr3(), pmap::ref, table(), table_alloc(), table_alloc_boot(), and tlb_flush().
Referenced by arch_mm_setup(), and pmap_init().
Copies a page of physical memory to another.
| src | the physical address of the page to copy |
| dst | the physical address of the page to copy it to |
Definition at line 423 of file pmap.c.
References memcpy(), PAGE_SIZE, PHYS2VIRT, and pmap_page_copy().
Referenced by pf_anon(), pf_object(), pf_present(), and pmap_page_copy().
Reads from a page of physical memory, through the kernel's mapping.
| paddr | the page's physical address |
| off | the offset to read from, in the page |
| size | how much to read, at most what's left of the page |
| buf | where to put it |
Definition at line 440 of file pmap.c.
References memcpy(), MIN, PAGE_SIZE, PHYS2VIRT, and pmap_page_read().
Referenced by pmap_page_read().
Writes to a page of physical memory, through the kernel's mapping.
| paddr | the page's physical address |
| off | the offset to write at, in the page |
| size | how much to write, at most what's left of the page |
| buf | what to write |
Definition at line 452 of file pmap.c.
References memcpy(), MIN, PAGE_SIZE, PHYS2VIRT, and pmap_page_write().
Referenced by pmap_page_write(), sigcode_in(), vnode_page_in(), and vnode_pages_update().
Changes the permissions of the mapped pages of a range of an address space.
Pages that aren't mapped stay unmapped.
| pmap | the page tables |
| sva | the range's start, page-aligned |
| eva | its end |
| prot | the new permissions (VM_*) |
Definition at line 399 of file pmap.c.
References D_ADDR, D_VALID, k_pmap, KERNEL_HALF, MIN, PAGE_MASK, PAGE_SIZE, PG_ADDR, PG_PRESENT, pmap_protect(), pte_flags(), pte_get(), and tlb_shootdown().
Referenced by pf_present(), pf_zero(), pmap_protect(), and vm_space_fork().
Unmaps the pages of a range of an address space, and flushes them from the TLBs that may have them.
The pages lose no references.
| pmap | the page tables |
| sva | the range's start, page-aligned |
| eva | its end, page-aligned |
Definition at line 337 of file pmap.c.
References D_VALID, k_pmap, KERNEL_HALF, MIN, PAGE_MASK, PAGE_SIZE, PG_PRESENT, pmap_remove(), pte_get(), and tlb_shootdown().
Referenced by arch_page_unmap(), kvmem_unmap(), mm_page_unmap(), pf_zero(), phys_window_map(), pmap_remove(), slab_page_free(), window_map(), and window_map().
| void pmap_remove_all | ( | struct pmap * | pmap | ) |
Unmaps the whole user half of an address space, and frees its page tables.
The pages it mapped lose the reference that the page fault handler gave them (mm_page_incref()).
| pmap | the page tables |
Definition at line 382 of file pmap.c.
References D_ADDR, D_VALID, KERNEL_PDE, KERNEL_PML4E, pmap::map, mm_page_decref(), PG_ADDR, PG_PRESENT, pmap_remove_all(), table(), table_free(), tables_free(), tlb_shootdown(), and USER_STACK.
Referenced by pmap_remove_all(), and vm_space_destroy().
Switches this CPU to an address space's page tables.
| pmap | the page tables to switch to |
Definition at line 164 of file pmap.c.
References cur_pmap, isb, pmap::map, panic, pmap_loaded(), pmap_switch(), tlb_flush(), and write_sysreg.
Referenced by arch_thread_spawn(), arch_thread_switch(), init_execve(), kmain(), pmap_init(), pmap_switch(), request_do(), tlb_shootdown(), and x86_ap_start().