swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "kint.h" |
| 4 | #include "registers.h" |
| 5 | |
swissChili | e0a79bb | 2021-02-22 19:54:48 -0800 | [diff] [blame] | 6 | #define VIRT_TO_PHYS(virt) ((uint)(virt) - 0xC0000000) |
swissChili | e20b79b | 2021-03-17 21:20:13 -0700 | [diff] [blame] | 7 | #define PHYS_TO_VIRT(phys) ((void *)(phys) + 0xC0000000) |
swissChili | e0a79bb | 2021-02-22 19:54:48 -0800 | [diff] [blame] | 8 | #define KERNEL_VIRTUAL_BASE 0xC0000000 |
| 9 | #define KERNEL_PAGE_NUMBER (KERNEL_VIRTUAL_BASE >> 22) |
| 10 | |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 11 | /* defined in switch_table.s */ |
| 12 | extern uint load_page_directory(uint table_address); |
| 13 | extern void enable_paging(); |
swissChili | e9289ee | 2021-03-20 21:54:28 -0700 | [diff] [blame] | 14 | extern uint kernel_page_directory[1024]; |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 15 | |
swissChili | e0a79bb | 2021-02-22 19:54:48 -0800 | [diff] [blame] | 16 | void init_paging(); |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 17 | |
swissChili | e9289ee | 2021-03-20 21:54:28 -0700 | [diff] [blame] | 18 | void map_page_to(uint *dir, void *virt, void *frame_p, bool writable, bool user); |
swissChili | e4f0199 | 2021-02-25 15:38:12 -0800 | [diff] [blame] | 19 | void alloc_frame(uint *page_table_entry, bool user, bool writable); |
swissChili | e9289ee | 2021-03-20 21:54:28 -0700 | [diff] [blame] | 20 | void alloc_page(uint *dir, uint *page); |
swissChili | e4f0199 | 2021-02-25 15:38:12 -0800 | [diff] [blame] | 21 | void alloc_kernel_page(uint *page); |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 22 | void page_fault(struct registers *regs); |