26 } __attribute__((packed)) bits;
48 asm volatile(
"mov %cr0, %eax; or $0x80000000, %eax; mov %eax, %cr0");
50 asm volatile(
"mov %cr0, %eax; and $0x7FFFFFFF, %eax; mov %eax, %cr0");
59 asm volatile(
"mov %%cr0, %0" :
"=r" (cr0));
72 asm volatile(
"invlpg (%0)" : :
"r" (vaddr) :
"memory");
81 uint32_t fault_address;
83 asm volatile(
"mov %%cr2, %0" :
"=r" (fault_address));
84 println(
"%4apage fault caused by the virtual address %08x\n" 85 "(%s while %s %s%s%s)%a", fault_address,
86 error.
bits.
pr ?
"protection violation" :
"non-present page",
87 error.
bits.
rw ?
"writing" :
"reading",
88 error.
bits.
user ?
"in user space" :
"in the kernel",
90 error.
bits.
_if ?
", instruction fetch" :
"");
91 panic(
"%4aEX%02x (EIP=%08x)", cpu->
intr, cpu->
eip);
void mmu_load_page_directory(page_directory_t *page_directory)
Loads a page directory into the CR3 register.
void mmu_flush_tlb(void *vaddr)
Flushes the Translation Lookaside Buffer for the given page.
static page_directory_t * page_directory
the current page directory
uint8_t _if
instruction flag fetch
The CPU's state when an interrupt occurs.
uint8_t mmu_get_paging()
Returns whether paging is enabled or disabled.
uint32_t eip
the instruction to return to after the interrupt
#define ISR_EXCEPTION(ex)
the interrupt vector for an exception
void isr_register_handler(size_t intr, isr_handler_t handler)
Registers a handler to call whenever a given interrupt is fired.
struct mmu_page_fault_error_t::@10 bits
bit field
An entry in a page directory.
uint8_t reserved
reserved write flag
static cpu_state_t * mmu_handle_page_fault(cpu_state_t *cpu)
Handles page faults.
uint32_t error
hold an error code if an error occured, otherwise 0
uint32_t intr
the interrupt vector of the fired interrupt
void mmu_init()
Initializes the MMU.
page fault error information
void mmu_enable_paging(page_directory_t *page_directory)
Loads a page directory and enables paging.