paging.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef VDOS_PAGING_H
  2. #define VDOS_PAGING_H
  3. #ifndef VDOS_H
  4. #include "vDos.h"
  5. #endif
  6. #include "mem.h"
  7. #define MEM_PAGE_SIZE (4096)
  8. #define PFLAG_READABLE 0x1
  9. #define PFLAG_WRITEABLE 0x2
  10. class PageHandler
  11. {
  12. public:
  13. virtual ~PageHandler(void) { }
  14. virtual Bit8u readb(PhysPt addr);
  15. virtual Bit16u readw(PhysPt addr);
  16. virtual Bit32u readd(PhysPt addr);
  17. virtual void writeb(PhysPt addr, Bit8u val);
  18. virtual void writew(PhysPt addr, Bit16u val);
  19. virtual void writed(PhysPt addr, Bit32u val);
  20. virtual HostPt GetHostPt(PhysPt addr);
  21. Bit8u flags;
  22. };
  23. // Some other functions
  24. void PAGING_Enable(bool enabled);
  25. Bitu PAGING_GetDirBase(void);
  26. void PAGING_SetDirBase(Bitu cr3);
  27. void MEM_SetPageHandler(Bitu phys_page, Bitu pages, PageHandler * handler);
  28. void MEM_ResetPageHandler(Bitu phys_page, Bitu pages);
  29. struct PagingBlock {
  30. Bitu cr3;
  31. Bitu cr2;
  32. bool enabled;
  33. };
  34. extern PagingBlock paging;
  35. __forceinline bool PAGING_Enabled(void)
  36. {
  37. return paging.enabled;
  38. }
  39. __forceinline Bitu PAGING_GetDirBase(void)
  40. {
  41. return paging.cr3;
  42. }
  43. #endif