paging.h 794 B

123456789101112131415161718192021222324
  1. /* Paging: identity-map RAM + the VESA LFB and enable CR0.PG (4 MB pages). */
  2. #ifndef PAGING_H
  3. #define PAGING_H
  4. void paging_init(void);
  5. /* Physical address of the bootstrap (current) page directory. */
  6. unsigned int paging_current_cr3(void);
  7. /* Allocate a fresh page directory that clones the kernel identity map and
  8. * return its physical address (0 on out-of-memory). */
  9. unsigned int paging_new_directory(void);
  10. /* Page-table entry flags (4 KB pages). */
  11. #define PTE_PRESENT 0x001
  12. #define PTE_WRITABLE 0x002
  13. #define PTE_USER 0x004
  14. /* Map one 4 KB page (va -> phys) in page directory `cr3`, allocating a page
  15. * table if needed. Returns 1 on success, 0 on out-of-memory. */
  16. int paging_map_page(unsigned int cr3, unsigned int va, unsigned int phys,
  17. unsigned int flags);
  18. #endif