mmu_64.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #ifndef __MMU_H
  2. #define __MMU_H
  3. #include <linux/const.h>
  4. #include <asm/page.h>
  5. #include <asm/hypervisor.h>
  6. #define CTX_NR_BITS 13
  7. #define TAG_CONTEXT_BITS ((_AC(1,UL) << CTX_NR_BITS) - _AC(1,UL))
  8. /* UltraSPARC-III+ and later have a feature whereby you can
  9. * select what page size the various Data-TLB instances in the
  10. * chip. In order to gracefully support this, we put the version
  11. * field in a spot outside of the areas of the context register
  12. * where this parameter is specified.
  13. */
  14. #define CTX_VERSION_SHIFT 22
  15. #define CTX_VERSION_MASK ((~0UL) << CTX_VERSION_SHIFT)
  16. #define CTX_PGSZ_8KB _AC(0x0,UL)
  17. #define CTX_PGSZ_64KB _AC(0x1,UL)
  18. #define CTX_PGSZ_512KB _AC(0x2,UL)
  19. #define CTX_PGSZ_4MB _AC(0x3,UL)
  20. #define CTX_PGSZ_BITS _AC(0x7,UL)
  21. #define CTX_PGSZ0_NUC_SHIFT 61
  22. #define CTX_PGSZ1_NUC_SHIFT 58
  23. #define CTX_PGSZ0_SHIFT 16
  24. #define CTX_PGSZ1_SHIFT 19
  25. #define CTX_PGSZ_MASK ((CTX_PGSZ_BITS << CTX_PGSZ0_SHIFT) | \
  26. (CTX_PGSZ_BITS << CTX_PGSZ1_SHIFT))
  27. #if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
  28. #define CTX_PGSZ_BASE CTX_PGSZ_8KB
  29. #elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB)
  30. #define CTX_PGSZ_BASE CTX_PGSZ_64KB
  31. #else
  32. #error No page size specified in kernel configuration
  33. #endif
  34. #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
  35. #define CTX_PGSZ_HUGE CTX_PGSZ_4MB
  36. #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K)
  37. #define CTX_PGSZ_HUGE CTX_PGSZ_512KB
  38. #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
  39. #define CTX_PGSZ_HUGE CTX_PGSZ_64KB
  40. #endif
  41. #define CTX_PGSZ_KERN CTX_PGSZ_4MB
  42. /* Thus, when running on UltraSPARC-III+ and later, we use the following
  43. * PRIMARY_CONTEXT register values for the kernel context.
  44. */
  45. #define CTX_CHEETAH_PLUS_NUC \
  46. ((CTX_PGSZ_KERN << CTX_PGSZ0_NUC_SHIFT) | \
  47. (CTX_PGSZ_BASE << CTX_PGSZ1_NUC_SHIFT))
  48. #define CTX_CHEETAH_PLUS_CTX0 \
  49. ((CTX_PGSZ_KERN << CTX_PGSZ0_SHIFT) | \
  50. (CTX_PGSZ_BASE << CTX_PGSZ1_SHIFT))
  51. /* If you want "the TLB context number" use CTX_NR_MASK. If you
  52. * want "the bits I program into the context registers" use
  53. * CTX_HW_MASK.
  54. */
  55. #define CTX_NR_MASK TAG_CONTEXT_BITS
  56. #define CTX_HW_MASK (CTX_NR_MASK | CTX_PGSZ_MASK)
  57. #define CTX_FIRST_VERSION ((_AC(1,UL) << CTX_VERSION_SHIFT) + _AC(1,UL))
  58. #define CTX_VALID(__ctx) \
  59. (!(((__ctx.sparc64_ctx_val) ^ tlb_context_cache) & CTX_VERSION_MASK))
  60. #define CTX_HWBITS(__ctx) ((__ctx.sparc64_ctx_val) & CTX_HW_MASK)
  61. #define CTX_NRBITS(__ctx) ((__ctx.sparc64_ctx_val) & CTX_NR_MASK)
  62. #ifndef __ASSEMBLY__
  63. #define TSB_ENTRY_ALIGNMENT 16
  64. struct tsb {
  65. unsigned long tag;
  66. unsigned long pte;
  67. } __attribute__((aligned(TSB_ENTRY_ALIGNMENT)));
  68. extern void __tsb_insert(unsigned long ent, unsigned long tag, unsigned long pte);
  69. extern void tsb_flush(unsigned long ent, unsigned long tag);
  70. extern void tsb_init(struct tsb *tsb, unsigned long size);
  71. struct tsb_config {
  72. struct tsb *tsb;
  73. unsigned long tsb_rss_limit;
  74. unsigned long tsb_nentries;
  75. unsigned long tsb_reg_val;
  76. unsigned long tsb_map_vaddr;
  77. unsigned long tsb_map_pte;
  78. };
  79. #define MM_TSB_BASE 0
  80. #ifdef CONFIG_HUGETLB_PAGE
  81. #define MM_TSB_HUGE 1
  82. #define MM_NUM_TSBS 2
  83. #else
  84. #define MM_NUM_TSBS 1
  85. #endif
  86. typedef struct {
  87. spinlock_t lock;
  88. unsigned long sparc64_ctx_val;
  89. unsigned long huge_pte_count;
  90. struct tsb_config tsb_block[MM_NUM_TSBS];
  91. struct hv_tsb_descr tsb_descr[MM_NUM_TSBS];
  92. } mm_context_t;
  93. #endif /* !__ASSEMBLY__ */
  94. #define TSB_CONFIG_TSB 0x00
  95. #define TSB_CONFIG_RSS_LIMIT 0x08
  96. #define TSB_CONFIG_NENTRIES 0x10
  97. #define TSB_CONFIG_REG_VAL 0x18
  98. #define TSB_CONFIG_MAP_VADDR 0x20
  99. #define TSB_CONFIG_MAP_PTE 0x28
  100. #endif /* __MMU_H */