diff options
author | Benji Dial <benji@benjidial.net> | 2024-01-15 15:44:20 -0500 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2024-01-15 15:44:20 -0500 |
commit | c9a1266d219a83882735a3a8304f3824e0219cdb (patch) | |
tree | fea71a0b5b0de8f3a8962dc6ed417273f231e2a9 /include/hilbert/kernel/paging.hpp | |
parent | 7c6a18d77a81f232ad2e1d3a311bb21ea8f1f5b4 (diff) | |
download | hilbert-os-c9a1266d219a83882735a3a8304f3824e0219cdb.tar.gz |
redo application paging and system calls, rename mercury to hilbert
Diffstat (limited to 'include/hilbert/kernel/paging.hpp')
-rw-r--r-- | include/hilbert/kernel/paging.hpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/hilbert/kernel/paging.hpp b/include/hilbert/kernel/paging.hpp new file mode 100644 index 0000000..2cf6f5c --- /dev/null +++ b/include/hilbert/kernel/paging.hpp @@ -0,0 +1,45 @@ +#ifndef HILBERT_KERNEL_PAGING_HPP +#define HILBERT_KERNEL_PAGING_HPP + +#include <cstdint> + +//in paging.asm +extern "C" [[noreturn]] void switch_to_kernel_p4(void (*and_then_jump_to)()); + +namespace hilbert::kernel::paging { + + void mark_all_pram_used(); + void mark_all_vram_free(); + + void mark_pram_region_free(uint64_t start_addr, uint64_t end_addr); + void mark_vram_region_used(uint64_t start_addr, uint64_t end_addr); + + uint64_t find_unmapped_vram_region(uint64_t page_count); + + uint64_t encode_pte(uint64_t addr, bool user, bool write, bool execute); + + void init_kernel_page_tables(uint64_t kernel_offset); + + uint64_t take_pram_page(); + + void map_kernel_stacks(); + + void map_kernel_page( + uint64_t paddr, uint64_t vaddr, bool write, bool execute); + + void unmap_kernel_page(uint64_t vaddr); + + //maps writable and not executable + void *map_new_kernel_pages(uint64_t count); + + //maps writable and not executable + void map_new_kernel_page(uint64_t &vaddr_out, uint64_t &paddr_out); + + uint64_t get_used_vram_page_count(); + uint64_t get_free_pram_page_count(); + + extern uint64_t kernel_p4e; + +} + +#endif |