mmu.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #ifndef __MMU_H
  2. #define __MMU_H
  3. #include <linux/config.h>
  4. #include <asm/page.h>
  5. #include <asm/const.h>
  6. /*
  7. * For the 8k pagesize kernel, use only 10 hw context bits to optimize some
  8. * shifts in the fast tlbmiss handlers, instead of all 13 bits (specifically
  9. * for vpte offset calculation). For other pagesizes, this optimization in
  10. * the tlbhandlers can not be done; but still, all 13 bits can not be used
  11. * because the tlb handlers use "andcc" instruction which sign extends 13
  12. * bit arguments.
  13. */
  14. #if PAGE_SHIFT == 13
  15. #define CTX_NR_BITS 10
  16. #else
  17. #define CTX_NR_BITS 12
  18. #endif
  19. #define TAG_CONTEXT_BITS ((_AC(1,UL) << CTX_NR_BITS) - _AC(1,UL))
  20. /* UltraSPARC-III+ and later have a feature whereby you can
  21. * select what page size the various Data-TLB instances in the
  22. * chip. In order to gracefully support this, we put the version
  23. * field in a spot outside of the areas of the context register
  24. * where this parameter is specified.
  25. */
  26. #define CTX_VERSION_SHIFT 22
  27. #define CTX_VERSION_MASK ((~0UL) << CTX_VERSION_SHIFT)
  28. #define CTX_PGSZ_8KB _AC(0x0,UL)
  29. #define CTX_PGSZ_64KB _AC(0x1,UL)
  30. #define CTX_PGSZ_512KB _AC(0x2,UL)
  31. #define CTX_PGSZ_4MB _AC(0x3,UL)
  32. #define CTX_PGSZ_BITS _AC(0x7,UL)
  33. #define CTX_PGSZ0_NUC_SHIFT 61
  34. #define CTX_PGSZ1_NUC_SHIFT 58
  35. #define CTX_PGSZ0_SHIFT 16
  36. #define CTX_PGSZ1_SHIFT 19
  37. #define CTX_PGSZ_MASK ((CTX_PGSZ_BITS << CTX_PGSZ0_SHIFT) | \
  38. (CTX_PGSZ_BITS << CTX_PGSZ1_SHIFT))
  39. #if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
  40. #define CTX_PGSZ_BASE CTX_PGSZ_8KB
  41. #elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB)
  42. #define CTX_PGSZ_BASE CTX_PGSZ_64KB
  43. #elif defined(CONFIG_SPARC64_PAGE_SIZE_512KB)
  44. #define CTX_PGSZ_BASE CTX_PGSZ_512KB
  45. #elif defined(CONFIG_SPARC64_PAGE_SIZE_4MB)
  46. #define CTX_PGSZ_BASE CTX_PGSZ_4MB
  47. #else
  48. #error No page size specified in kernel configuration
  49. #endif
  50. #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
  51. #define CTX_PGSZ_HUGE CTX_PGSZ_4MB
  52. #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K)
  53. #define CTX_PGSZ_HUGE CTX_PGSZ_512KB
  54. #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
  55. #define CTX_PGSZ_HUGE CTX_PGSZ_64KB
  56. #endif
  57. #define CTX_PGSZ_KERN CTX_PGSZ_4MB
  58. /* Thus, when running on UltraSPARC-III+ and later, we use the following
  59. * PRIMARY_CONTEXT register values for the kernel context.
  60. */
  61. #define CTX_CHEETAH_PLUS_NUC \
  62. ((CTX_PGSZ_KERN << CTX_PGSZ0_NUC_SHIFT) | \
  63. (CTX_PGSZ_BASE << CTX_PGSZ1_NUC_SHIFT))
  64. #define CTX_CHEETAH_PLUS_CTX0 \
  65. ((CTX_PGSZ_KERN << CTX_PGSZ0_SHIFT) | \
  66. (CTX_PGSZ_BASE << CTX_PGSZ1_SHIFT))
  67. /* If you want "the TLB context number" use CTX_NR_MASK. If you
  68. * want "the bits I program into the context registers" use
  69. * CTX_HW_MASK.
  70. */
  71. #define CTX_NR_MASK TAG_CONTEXT_BITS
  72. #define CTX_HW_MASK (CTX_NR_MASK | CTX_PGSZ_MASK)
  73. #define CTX_FIRST_VERSION ((_AC(1,UL) << CTX_VERSION_SHIFT) + _AC(1,UL))
  74. #define CTX_VALID(__ctx) \
  75. (!(((__ctx.sparc64_ctx_val) ^ tlb_context_cache) & CTX_VERSION_MASK))
  76. #define CTX_HWBITS(__ctx) ((__ctx.sparc64_ctx_val) & CTX_HW_MASK)
  77. #define CTX_NRBITS(__ctx) ((__ctx.sparc64_ctx_val) & CTX_NR_MASK)
  78. #ifndef __ASSEMBLY__
  79. typedef struct {
  80. unsigned long sparc64_ctx_val;
  81. } mm_context_t;
  82. #endif /* !__ASSEMBLY__ */
  83. #endif /* __MMU_H */