summaryrefslogtreecommitdiff
path: root/include/mercury/kernel/paging.hpp
blob: 4ba5fdf9f7fc1329d3d59d55134414eaf98ea954 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef MERCURY_KERNEL_PAGING_HPP
#define MERCURY_KERNEL_PAGING_HPP

#include <cstdint>

//in paging.asm
extern "C" [[noreturn]] void switch_to_kernel_p4(void (*and_then_jump_to)());

namespace mercury::kernel::paging {

  void mark_all_pram_used();
  void mark_all_vram_free();

  //assumes page-alignment
  void mark_pram_region_free(uint64_t start_addr, uint64_t end_addr);
  //assumes page-alignment
  void mark_vram_region_used(uint64_t start_addr, uint64_t end_addr);

  uint64_t find_unmapped_vram_region(uint64_t page_count);

  void init_kernel_page_tables(uint64_t kernel_offset);

  void map_kernel_stack();

  //assumes page-alignment
  void map_kernel_page(
    uint64_t paddr, uint64_t vaddr, bool write, bool execute);

  //maps writable and not executable
  void *map_new_kernel_pages(uint64_t count);

  uint64_t get_used_vram_page_count();
  uint64_t get_free_pram_page_count();

}

#endif