5#include <sys/kconfig.h>
6#include <sys/kassert.h>
10#include <machine/amd64.h>
11#include <machine/amd64op.h>
12#include <machine/mp.h>
13#include <machine/pmap.h>
23 kprintf(
"Initializing PMAP ... ");
35 PANIC(
"Cannot allocate system page table");
44 PANIC(
"Not enough memory!");
360 for (i = 0; i < pages; i++) {
364 kprintf(
"Map failed to allocate memory!\n");
392 for (i = 0; i < pages; i++) {
396 kprintf(
"Unmap tried to allocate memory!\n");
431 for (i = 0; i < pages; i++) {
435 kprintf(
"Map failed to allocate memory!\n");
485 for (i = 0; i < lpages; i++) {
489 kprintf(
"SystemLMap failed to allocate memory!\n");
519 for (i = 0; i < pages; i++) {
523 kprintf(
"SystemMap failed to allocate memory!\n");
587 kprintf(
"Level 3: %016llx:%016llx\n",
591 if ((pte3 &
PTE_PS) == 0) {
595 kprintf(
"Level 4: %016llx:%016llx\n",
624 kprintf(
"%-18s %-18s %-5s\n",
"Virtual",
"Physical PTE",
"Flags");
646 if ((pte3 &
PTE_PS) == 0) {
651 kprintf(
"0x%016llx: 0x%016llx P%c%c%c%c%c\n",
654 (pte4 &
PTE_W) ?
'W' :
' ',
655 (pte4 &
PTE_NX) ?
' ' :
'X',
656 (pte4 &
PTE_U) ?
'U' :
' ',
657 (pte4 &
PTE_A) ?
'A' :
' ',
658 (pte4 &
PTE_D) ?
'D' :
' ');
PageEntry entries[PAGETABLE_ENTRIES]
#define PAGETABLE_ENTRIES
static INLINE void write_cr3(uint64_t val)
#define NOT_IMPLEMENTED()
int kprintf(const char *fmt,...)
#define REGISTER_DBGCMD(_NAME, _DESC, _FUNC)
void PAlloc_Release(void *pg)
void * PAlloc_AllocPage()
static uint64_t AddrFromIJKL(uint64_t i, uint64_t j, uint64_t k, uint64_t l)
static void PMapLookupEntry(AS *space, 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)
void PMap_DumpFull(AS *space)
static PageTable * PMapAllocPageTable()
bool PMap_Map(AS *as, uint64_t phys, uint64_t virt, uint64_t pages, uint64_t flags)
static void Debug_PMapDump(int argc, const char *argv[])
static void Debug_PMapDumpFull(int argc, const char *argv[])
void PMap_LoadAS(AS *space)
uintptr_t PMap_Translate(AS *space, uintptr_t va)
bool PMap_SystemUnmap(uint64_t virt, uint64_t pages)
bool PMap_Unmap(AS *as, uint64_t va, uint64_t pages)
void PMap_Dump(AS *space)
bool PMap_AllocMap(AS *as, uint64_t virt, uint64_t len, uint64_t flags)
void PMap_DestroyAS(AS *space)
void PMap_SystemLookup(uint64_t va, PageEntry **entry, int size)
#define MEM_DIRECTMAP_BASE