CS350 COS
COS
|
#include <machine/amd64.h>
Go to the source code of this file.
Data Structures | |
struct | AS |
Macros | |
#define | MEM_USERSPACE_BASE 0x0000000000000000ULL |
#define | MEM_USERSPACE_LEN 0x0000800000000000ULL |
#define | MEM_USERSPACE_TOP (MEM_USERSPACE_BASE + MEM_USERSPACE_LEN) |
#define | MEM_USERSPACE_STKBASE 0x0000000070000000ULL |
#define | MEM_USERSPACE_STKLEN 0x0000000000010000ULL |
#define | MEM_USERSPACE_STKTOP (MEM_USERSPACE_STKBASE + MEM_USERSPACE_STKLEN) |
#define | MEM_DIRECTMAP_BASE 0xFFFF800000000000ULL |
#define | MEM_DIRECTMAP_LEN 0x0000010000000000ULL |
#define | MEM_XMAP_BASE 0xFFFF810000000000ULL |
#define | MEM_XMAP_LEN 0x0000002000000000ULL |
#define | PPN2DMVA(ppn) (((ppn) << PGSIZE) + MEM_DIRECTMAP_BASE) |
#define | DMVA2PPN(dmva) (((dmva) - MEM_DIRECTMAP_BASE) >> PGSIZE) |
#define | DMVA2PA(dmva) ((dmva) - MEM_DIRECTMAP_BASE) |
#define | DMPA2VA(pa) ((pa) + MEM_DIRECTMAP_BASE) |
#define | VA2PA(va) PMap_Translate(PMap_CurrentAS(), va) |
Typedefs | |
typedef struct AS | AS |
Functions | |
void | PMap_Init () |
void | PMap_InitAP () |
AS * | PMap_NewAS () |
void | PMap_DestroyAS (AS *space) |
AS * | PMap_CurrentAS () |
void | PMap_LoadAS (AS *space) |
void | PMap_Dump (AS *space) |
uintptr_t | PMap_Translate (AS *space, uintptr_t va) |
bool | PMap_Map (AS *as, uint64_t phys, uint64_t virt, uint64_t pages, uint64_t flags) |
bool | PMap_AllocMap (AS *as, uint64_t virt, uint64_t len, uint64_t flags) |
bool | PMap_Unmap (AS *as, uint64_t virt, uint64_t pages) |
void | PMap_SystemLookup (uint64_t va, PageEntry **entry, int size) |
bool | PMap_SystemLMap (uint64_t phys, uint64_t virt, uint64_t lpages, uint64_t flags) |
bool | PMap_SystemMap (uint64_t phys, uint64_t virt, uint64_t pages, uint64_t flags) |
bool | PMap_SystemUnmap (uint64_t virt, uint64_t pages) |
struct AS |
#define DMPA2VA | ( | pa | ) | ((pa) + MEM_DIRECTMAP_BASE) |
#define DMVA2PA | ( | dmva | ) | ((dmva) - MEM_DIRECTMAP_BASE) |
#define DMVA2PPN | ( | dmva | ) | (((dmva) - MEM_DIRECTMAP_BASE) >> PGSIZE) |
#define MEM_USERSPACE_STKTOP (MEM_USERSPACE_STKBASE + MEM_USERSPACE_STKLEN) |
#define MEM_USERSPACE_TOP (MEM_USERSPACE_BASE + MEM_USERSPACE_LEN) |
#define PPN2DMVA | ( | ppn | ) | (((ppn) << PGSIZE) + MEM_DIRECTMAP_BASE) |
#define VA2PA | ( | va | ) | PMap_Translate(PMap_CurrentAS(), va) |
PMap_AllocMap –
Map a virtual mapping in an address space and back it by newly allocated memory.
[in] | as | Address space. |
[in] | virt | Virtual address. |
[in] | pages | Pages to map in. |
[in] | flags | Flags to apply to the mapping. |
true | On success |
false | On failure |
Definition at line 423 of file pmap.c.
AS * PMap_CurrentAS | ( | ) |
void PMap_DestroyAS | ( | AS * | space | ) |
PMap_DestroyAS –
Destroys an address space and releases the physical pages.
[in] | space | Address space to destroy. |
Definition at line 116 of file pmap.c.
void PMap_Dump | ( | AS * | space | ) |
Definition at line 616 of file pmap.c.
void PMap_Init | ( | ) |
Definition at line 19 of file pmap.c.
void PMap_InitAP | ( | ) |
void PMap_LoadAS | ( | AS * | space | ) |
PMap_LoadAS –
Load an address space into the CPU. Reloads the CR3 register in x86-64 that points the physical page tables and flushes the TLB entries.
[in] | space | Address space to load. |
Definition at line 182 of file pmap.c.
PMap_Map –
Map a physical to virtual mapping in an address space.
[in] | as | Address space. |
[in] | phys | Physical address. |
[in] | virt | Virtual address. |
[in] | pages | Pages to map in. |
[in] | flags | Flags to apply to the mapping. |
true | On success |
false | On failure |
Definition at line 355 of file pmap.c.
AS * PMap_NewAS | ( | ) |
PMap_NewAS –
Create a new address space.
Definition at line 80 of file pmap.c.
PMap_SystemLMap –
Map a range of large (2MB) physical pages to virtual pages in the kernel address space that is shared by all processes.
[in] | phys | Physical address. |
[in] | virt | Virtual address. |
[in] | lpages | Large pages to map in. |
[in] | flags | Flags to apply to the mapping. |
true | On success |
false | On failure |
Definition at line 480 of file pmap.c.
PMap_SystemLookup –
Lookup a kernel virtual address in a page table and return a pointer to the page entry. This function allocates page tables as necessary to fill in the 4-level heirarchy.
[in] | va | Virtual address to lookup. |
[out] | entry | Pointer will point to the PageEntry. |
[in] | size | Page size we want to use. |
Definition at line 460 of file pmap.c.
PMap_SystemLMap –
Map a range of physical pages to virtual pages in the kernel address space that is shared by all processes.
[in] | phys | Physical address. |
[in] | virt | Virtual address. |
[in] | pages | Pages to map in. |
[in] | flags | Flags to apply to the mapping. |
true | On success |
false | On failure |
Definition at line 514 of file pmap.c.
PMap_SystemUnmap –
We do not currently use this!
PMap_Translate –
Translates a virtual address to physical address for a given address space.
[in] | space | Address space we wish to lookup a mapping in. |
[in] | va | Virtual address we wish to translate. |
Definition at line 220 of file pmap.c.
PMap_Unmap –
Unmap a range of addresses.
[in] | as | Address space. |
[in] | va | Virtual address. |
[in] | pages | Pages to map in. |
true | On success |
false | On failure |
Definition at line 387 of file pmap.c.