diff options
author | Danny Holman <dholman@gymli.org> | 2024-06-21 21:48:46 -0500 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-06-21 21:50:55 -0500 |
commit | 056087596de64696f18f9b32f604b69280be079e (patch) | |
tree | 4ebdbe12197736d69898ff7437ff9e6af97940ed /arch/i386/include/kernel/paging.h | |
parent | f1a0f10f54e17803f7d7095a61117aec52fafbf0 (diff) |
arch: i386: paging: do the recursive paging trick
Map the page directory to the last page table. This allows the kernel to
access every page table on the system from the address 0xFFC00000 plus
an offset.
Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'arch/i386/include/kernel/paging.h')
-rw-r--r-- | arch/i386/include/kernel/paging.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/arch/i386/include/kernel/paging.h b/arch/i386/include/kernel/paging.h index 5999986..d8bb8f3 100644 --- a/arch/i386/include/kernel/paging.h +++ b/arch/i386/include/kernel/paging.h @@ -5,6 +5,8 @@ #include <kernel/multiboot.h> #include <stdint.h> +#define PAGE_SIZE 4096 + #define PD_PRES 0x0001 #define PD_RW 0x0002 #define PD_USR 0x0004 @@ -28,14 +30,16 @@ #define GET_PADDR(x) (((uint32_t)(x)) - 0xC0000000) #define GET_VADDR(x) (((uint32_t)(x)) + 0xC0000000) -#define GET_PDX(x) (((uintptr_t)(x) >> 22) & 0x3FF) -#define GET_PTX(x) (((uintptr_t)(x) >> 12) & 0x3FF) +#define GET_PDX(x) ((uintptr_t)(x) >> 22) +#define GET_PTX(x) (((uintptr_t)(x) >> 12) & 0x03FF) + +uintptr_t get_physaddr(void *vaddr); -uintptr_t* init_page_table(void); void paging_init(void); -void map_page(uint32_t *pd, uintptr_t paddr, uintptr_t vaddr, uint32_t flags); -void unmap_page(uint32_t *pd, uintptr_t vaddr); +uintptr_t init_page_directory(void); +void map_page(uintptr_t paddr, uintptr_t vaddr, uint32_t flags); +void unmap_page(uintptr_t vaddr); void page_fault_handler(struct isr_frame *frame); |