paging.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. /* Map a physical window identity-mapped with caching enabled (4 MB pages).
  10. * Used for the stolen-VRAM alias, which is ordinary DRAM; the effective type
  11. * is whatever the MTRRs say (write-combining when we added an entry). */
  12. void paging_map_ram(unsigned int base, unsigned int size);
  13. /* Physical address of the bootstrap (current) page directory. */
  14. unsigned int paging_current_cr3(void);
  15. /* Allocate a fresh page directory that clones the kernel identity map and
  16. * return its physical address (0 on out-of-memory). */
  17. unsigned int paging_new_directory(void);
  18. /* Page-table entry flags (4 KB pages). */
  19. #define PTE_PRESENT 0x001
  20. #define PTE_WRITABLE 0x002
  21. #define PTE_USER 0x004
  22. /* Map one 4 KB page (va -> phys) in page directory `cr3`, allocating a page
  23. * table if needed. Returns 1 on success, 0 on out-of-memory. */
  24. int paging_map_page(unsigned int cr3, unsigned int va, unsigned int phys,
  25. unsigned int flags);
  26. /* Clear one 4 KB page (va) in page directory `cr3` (no-op when the page
  27. * table is absent). */
  28. void paging_unmap_page(unsigned int cr3, unsigned int va);
  29. /* Identity-map an MMIO range (e.g. a GPU register aperture) uncacheable into
  30. * the current page directory. Uses 4 MB pages; the range is rounded up to a
  31. * whole number of 4 MB pages. */
  32. void paging_map_mmio(unsigned int phys_base, unsigned int size);
  33. /* Same, but into an explicit page directory (used to update per-process
  34. * directories; see process_map_mmio_all()). */
  35. void paging_map_mmio_cr3(unsigned int cr3, unsigned int phys_base,
  36. unsigned int size);
  37. #endif