Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __MMU_H |
| 2 | #define __MMU_H |
| 3 | |
| 4 | #include <linux/config.h> |
| 5 | #include <asm/page.h> |
| 6 | #include <asm/const.h> |
David S. Miller | 618e9ed | 2006-02-09 17:21:53 -0800 | [diff] [blame^] | 7 | #include <asm/hypervisor.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
| 9 | /* |
| 10 | * For the 8k pagesize kernel, use only 10 hw context bits to optimize some |
| 11 | * shifts in the fast tlbmiss handlers, instead of all 13 bits (specifically |
| 12 | * for vpte offset calculation). For other pagesizes, this optimization in |
| 13 | * the tlbhandlers can not be done; but still, all 13 bits can not be used |
| 14 | * because the tlb handlers use "andcc" instruction which sign extends 13 |
| 15 | * bit arguments. |
| 16 | */ |
| 17 | #if PAGE_SHIFT == 13 |
| 18 | #define CTX_NR_BITS 10 |
| 19 | #else |
| 20 | #define CTX_NR_BITS 12 |
| 21 | #endif |
| 22 | |
| 23 | #define TAG_CONTEXT_BITS ((_AC(1,UL) << CTX_NR_BITS) - _AC(1,UL)) |
| 24 | |
| 25 | /* UltraSPARC-III+ and later have a feature whereby you can |
| 26 | * select what page size the various Data-TLB instances in the |
| 27 | * chip. In order to gracefully support this, we put the version |
| 28 | * field in a spot outside of the areas of the context register |
| 29 | * where this parameter is specified. |
| 30 | */ |
| 31 | #define CTX_VERSION_SHIFT 22 |
| 32 | #define CTX_VERSION_MASK ((~0UL) << CTX_VERSION_SHIFT) |
| 33 | |
| 34 | #define CTX_PGSZ_8KB _AC(0x0,UL) |
| 35 | #define CTX_PGSZ_64KB _AC(0x1,UL) |
| 36 | #define CTX_PGSZ_512KB _AC(0x2,UL) |
| 37 | #define CTX_PGSZ_4MB _AC(0x3,UL) |
| 38 | #define CTX_PGSZ_BITS _AC(0x7,UL) |
| 39 | #define CTX_PGSZ0_NUC_SHIFT 61 |
| 40 | #define CTX_PGSZ1_NUC_SHIFT 58 |
| 41 | #define CTX_PGSZ0_SHIFT 16 |
| 42 | #define CTX_PGSZ1_SHIFT 19 |
| 43 | #define CTX_PGSZ_MASK ((CTX_PGSZ_BITS << CTX_PGSZ0_SHIFT) | \ |
| 44 | (CTX_PGSZ_BITS << CTX_PGSZ1_SHIFT)) |
| 45 | |
| 46 | #if defined(CONFIG_SPARC64_PAGE_SIZE_8KB) |
| 47 | #define CTX_PGSZ_BASE CTX_PGSZ_8KB |
| 48 | #elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB) |
| 49 | #define CTX_PGSZ_BASE CTX_PGSZ_64KB |
| 50 | #elif defined(CONFIG_SPARC64_PAGE_SIZE_512KB) |
| 51 | #define CTX_PGSZ_BASE CTX_PGSZ_512KB |
| 52 | #elif defined(CONFIG_SPARC64_PAGE_SIZE_4MB) |
| 53 | #define CTX_PGSZ_BASE CTX_PGSZ_4MB |
| 54 | #else |
| 55 | #error No page size specified in kernel configuration |
| 56 | #endif |
| 57 | |
| 58 | #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB) |
| 59 | #define CTX_PGSZ_HUGE CTX_PGSZ_4MB |
| 60 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K) |
| 61 | #define CTX_PGSZ_HUGE CTX_PGSZ_512KB |
| 62 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K) |
| 63 | #define CTX_PGSZ_HUGE CTX_PGSZ_64KB |
| 64 | #endif |
| 65 | |
| 66 | #define CTX_PGSZ_KERN CTX_PGSZ_4MB |
| 67 | |
| 68 | /* Thus, when running on UltraSPARC-III+ and later, we use the following |
| 69 | * PRIMARY_CONTEXT register values for the kernel context. |
| 70 | */ |
| 71 | #define CTX_CHEETAH_PLUS_NUC \ |
| 72 | ((CTX_PGSZ_KERN << CTX_PGSZ0_NUC_SHIFT) | \ |
| 73 | (CTX_PGSZ_BASE << CTX_PGSZ1_NUC_SHIFT)) |
| 74 | |
| 75 | #define CTX_CHEETAH_PLUS_CTX0 \ |
| 76 | ((CTX_PGSZ_KERN << CTX_PGSZ0_SHIFT) | \ |
| 77 | (CTX_PGSZ_BASE << CTX_PGSZ1_SHIFT)) |
| 78 | |
| 79 | /* If you want "the TLB context number" use CTX_NR_MASK. If you |
| 80 | * want "the bits I program into the context registers" use |
| 81 | * CTX_HW_MASK. |
| 82 | */ |
| 83 | #define CTX_NR_MASK TAG_CONTEXT_BITS |
| 84 | #define CTX_HW_MASK (CTX_NR_MASK | CTX_PGSZ_MASK) |
| 85 | |
| 86 | #define CTX_FIRST_VERSION ((_AC(1,UL) << CTX_VERSION_SHIFT) + _AC(1,UL)) |
| 87 | #define CTX_VALID(__ctx) \ |
| 88 | (!(((__ctx.sparc64_ctx_val) ^ tlb_context_cache) & CTX_VERSION_MASK)) |
| 89 | #define CTX_HWBITS(__ctx) ((__ctx.sparc64_ctx_val) & CTX_HW_MASK) |
| 90 | #define CTX_NRBITS(__ctx) ((__ctx.sparc64_ctx_val) & CTX_NR_MASK) |
| 91 | |
| 92 | #ifndef __ASSEMBLY__ |
| 93 | |
David S. Miller | 98c5584 | 2006-01-31 18:31:20 -0800 | [diff] [blame] | 94 | #define TSB_ENTRY_ALIGNMENT 16 |
| 95 | |
| 96 | struct tsb { |
| 97 | unsigned long tag; |
| 98 | unsigned long pte; |
| 99 | } __attribute__((aligned(TSB_ENTRY_ALIGNMENT))); |
| 100 | |
David S. Miller | 517af33 | 2006-02-01 15:55:21 -0800 | [diff] [blame] | 101 | extern void __tsb_insert(unsigned long ent, unsigned long tag, unsigned long pte); |
| 102 | extern void tsb_flush(unsigned long ent, unsigned long tag); |
David S. Miller | b70c0fa | 2006-01-31 18:32:04 -0800 | [diff] [blame] | 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | typedef struct { |
David S. Miller | 618e9ed | 2006-02-09 17:21:53 -0800 | [diff] [blame^] | 105 | unsigned long sparc64_ctx_val; |
| 106 | struct tsb *tsb; |
| 107 | unsigned long tsb_rss_limit; |
| 108 | unsigned long tsb_nentries; |
| 109 | unsigned long tsb_reg_val; |
| 110 | unsigned long tsb_map_vaddr; |
| 111 | unsigned long tsb_map_pte; |
| 112 | struct hv_tsb_descr tsb_descr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | } mm_context_t; |
| 114 | |
| 115 | #endif /* !__ASSEMBLY__ */ |
| 116 | |
| 117 | #endif /* __MMU_H */ |