|
1 | 1 | #ifndef MENIOS_INCLUDE_KERNEL_PMM_H |
2 | 2 | #define MENIOS_INCLUDE_KERNEL_PMM_H |
3 | 3 |
|
4 | | -#include <stdint.h> |
| 4 | +#include <types.h> |
5 | 5 |
|
6 | 6 | // good enough for 16GB - it can be increased later |
7 | 7 | #define PAGE_BITMAP_SIZE 0x10000 |
|
16 | 16 |
|
17 | 17 | #define VADDR_UNUSED (0xffff000000000000) |
18 | 18 |
|
| 19 | +typedef struct { |
| 20 | + uint64_t error_code; // Error code pushed by the CPU |
| 21 | + uint64_t rip; // Instruction pointer at the time of the fault |
| 22 | + uint64_t cs; // Code segment at the time of the fault |
| 23 | + uint64_t rflags; // Flags register at the time of the fault |
| 24 | + uint64_t rsp; // Stack pointer at the time of the fault |
| 25 | + uint64_t faulting_address; // The address that caused the page fault (from CR2) |
| 26 | +} page_fault_info_t; |
| 27 | + |
19 | 28 | // Page Map Level 4 (PML4) Entry |
20 | 29 | typedef struct { |
21 | 30 | uint64_t present: 1; // Page present in memory |
@@ -113,17 +122,17 @@ uintptr_t read_cr3(); |
113 | 122 |
|
114 | 123 | void debug_heap(); |
115 | 124 | void pmm_init(); |
116 | | -void write_cr3(uint64_t value); |
| 125 | +void write_cr3(phys_addr_t value); |
117 | 126 |
|
118 | 127 | uint64_t get_first_free_page(); |
119 | 128 |
|
120 | | -void pml4_map(uintptr_t vaddr, pml4_map_t* map); |
| 129 | +void pml4_map(virt_addr_t vaddr, pml4_map_t* map); |
121 | 130 |
|
122 | | -uintptr_t get_first_free_virtual_address(uintptr_t offset); |
| 131 | +virt_addr_t get_first_free_virtual_address(virt_addr_t offset); |
123 | 132 |
|
124 | | -uintptr_t physical_to_virtual(uintptr_t physical_address); |
125 | | -uintptr_t virtual_to_physical(uintptr_t virtual_to_physical); |
| 133 | +virt_addr_t physical_to_virtual(phys_addr_t physical_address); |
| 134 | +phys_addr_t virtual_to_physical(virt_addr_t virtual_address); |
126 | 135 |
|
127 | | -void set_page_used(uintptr_t physical_address); |
| 136 | +void set_page_used(phys_addr_t physical_address); |
128 | 137 |
|
129 | 138 | #endif |
0 commit comments