pte.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /** @file
  2. Copyright (c) 2022 Loongson Technology Corporation Limited. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. @par Glossary:
  5. - Tlb or TLB - Translation Lookaside Buffer
  6. - HGLOBAL - Huge Global
  7. - PFN - Page Frame number
  8. - EXEC - Execute
  9. - PLV - Privilege Level
  10. - RPLV - Restricted Privilege Level
  11. - SUC - Strong-ordered UnCached
  12. - CC - Coherent Cached
  13. - WUC - Weak-ordered UnCached
  14. **/
  15. #ifndef PTE_H_
  16. #define PTE_H_
  17. /*Page table property definitions */
  18. #define PAGE_VALID_SHIFT 0
  19. #define PAGE_DIRTY_SHIFT 1
  20. #define PAGE_PLV_SHIFT 2 /* 2~3, two bits */
  21. #define CACHE_SHIFT 4 /* 4~5, two bits */
  22. #define PAGE_GLOBAL_SHIFT 6
  23. #define PAGE_HUGE_SHIFT 6 /* HUGE is a PMD bit */
  24. #define PAGE_HGLOBAL_SHIFT 12 /* HGlobal is a PMD bit */
  25. #define PAGE_PFN_SHIFT 12
  26. #define PAGE_PFN_END_SHIFT 48
  27. #define PAGE_NO_READ_SHIFT 61
  28. #define PAGE_NO_EXEC_SHIFT 62
  29. #define PAGE_RPLV_SHIFT 63
  30. /* Used by TLB hardware (placed in EntryLo*) */
  31. #define PAGE_VALID ((UINTN)(1) << PAGE_VALID_SHIFT)
  32. #define PAGE_DIRTY ((UINTN)(1) << PAGE_DIRTY_SHIFT)
  33. #define PAGE_PLV ((UINTN)(3) << PAGE_PLV_SHIFT)
  34. #define PAGE_GLOBAL ((UINTN)(1) << PAGE_GLOBAL_SHIFT)
  35. #define PAGE_HUGE ((UINTN)(1) << PAGE_HUGE_SHIFT)
  36. #define PAGE_HGLOBAL ((UINTN)(1) << PAGE_HGLOBAL_SHIFT)
  37. #define PAGE_NO_READ ((UINTN)(1) << PAGE_NO_READ_SHIFT)
  38. #define PAGE_NO_EXEC ((UINTN)(1) << PAGE_NO_EXEC_SHIFT)
  39. #define PAGE_RPLV ((UINTN)(1) << PAGE_RPLV_SHIFT)
  40. #define CACHE_MASK ((UINTN)(3) << CACHE_SHIFT)
  41. #define PFN_SHIFT (EFI_PAGE_SHIFT - 12 + PAGE_PFN_SHIFT)
  42. #define PLV_KERNEL 0
  43. #define PLV_USER 3
  44. #define PAGE_USER (PLV_USER << PAGE_PLV_SHIFT)
  45. #define PAGE_KERNEL (PLV_KERN << PAGE_PLV_SHIFT)
  46. #define CACHE_SUC (0 << CACHE_SHIFT) /* Strong-ordered UnCached */
  47. #define CACHE_CC (1 << CACHE_SHIFT) /* Coherent Cached */
  48. #define CACHE_WUC (2 << CACHE_SHIFT) /* Weak-ordered UnCached */
  49. #endif // PTE_H_