paging.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. /* Clear one 4 KB page (va) in page directory `cr3` (no-op when the page
  19. * table is absent). */
  20. void paging_unmap_page(unsigned int cr3, unsigned int va);
  21. /* Identity-map an MMIO range (e.g. a GPU register aperture) uncacheable into
  22. * the current page directory. Uses 4 MB pages; the range is rounded up to a
  23. * whole number of 4 MB pages. */
  24. void paging_map_mmio(unsigned int phys_base, unsigned int size);
  25. /* Same, but into an explicit page directory (used to update per-process
  26. * directories; see process_map_mmio_all()). */
  27. void paging_map_mmio_cr3(unsigned int cr3, unsigned int phys_base,
  28. unsigned int size);
  29. #endif