paging.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. /* Re-apply the framebuffer page types (after GPU BAR mappings that cover it). */
  6. void paging_lfb_refresh(void);
  7. /* 1 when the LFB is mapped for write-combining. */
  8. int paging_lfb_wc(void);
  9. /* Physical address of the bootstrap (current) page directory. */
  10. unsigned int paging_current_cr3(void);
  11. /* Allocate a fresh page directory that clones the kernel identity map and
  12. * return its physical address (0 on out-of-memory). */
  13. unsigned int paging_new_directory(void);
  14. /* Page-table entry flags (4 KB pages). */
  15. #define PTE_PRESENT 0x001
  16. #define PTE_WRITABLE 0x002
  17. #define PTE_USER 0x004
  18. /* Map one 4 KB page (va -> phys) in page directory `cr3`, allocating a page
  19. * table if needed. Returns 1 on success, 0 on out-of-memory. */
  20. int paging_map_page(unsigned int cr3, unsigned int va, unsigned int phys,
  21. unsigned int flags);
  22. /* Clear one 4 KB page (va) in page directory `cr3` (no-op when the page
  23. * table is absent). */
  24. void paging_unmap_page(unsigned int cr3, unsigned int va);
  25. /* Identity-map an MMIO range (e.g. a GPU register aperture) uncacheable into
  26. * the current page directory. Uses 4 MB pages; the range is rounded up to a
  27. * whole number of 4 MB pages. */
  28. void paging_map_mmio(unsigned int phys_base, unsigned int size);
  29. /* Same, but into an explicit page directory (used to update per-process
  30. * directories; see process_map_mmio_all()). */
  31. void paging_map_mmio_cr3(unsigned int cr3, unsigned int phys_base,
  32. unsigned int size);
  33. #endif