Changeset ba50a34 in mainline for kernel/arch/sparc64/src/mm/sun4v/as.c
- Timestamp:
- 2009-12-06T18:29:57Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5e53e02
- Parents:
- eb79d60
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/src/mm/sun4v/as.c
reb79d60 rba50a34 61 61 { 62 62 #ifdef CONFIG_TSB 63 /* 64 * The order must be calculated with respect to the emulated 65 * 16K page size. 66 */ 67 int order = fnzb32(((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) * 68 sizeof(tsb_entry_t)) >> FRAME_WIDTH); 63 int order = fnzb32( 64 (TSB_ENTRY_COUNT * sizeof(tsb_entry_t)) >> FRAME_WIDTH); 69 65 70 uintptr_t tsb = (uintptr_t) frame_alloc(order, flags | FRAME_KA);66 uintptr_t tsb = (uintptr_t) frame_alloc(order, flags); 71 67 72 68 if (!tsb) 73 69 return -1; 74 70 75 as->arch.itsb = (tsb_entry_t *) tsb; 76 as->arch.dtsb = (tsb_entry_t *) (tsb + ITSB_ENTRY_COUNT * 77 sizeof(tsb_entry_t)); 71 as->arch.tsb_description.page_size = PAGESIZE_8K; 72 as->arch.tsb_description.associativity = 1; 73 as->arch.tsb_description.num_ttes = TSB_ENTRY_COUNT; 74 as->arch.tsb_description.pgsize_mask = 1 << PAGESIZE_8K; 75 as->arch.tsb_description.tsb_base = tsb; 76 as->arch.tsb_description.reserved = 0; 77 as->arch.tsb_description.context = 0; 78 78 79 memsetb( as->arch.itsb,80 (ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT)* sizeof(tsb_entry_t), 0);79 memsetb((void *) PA2KA(as->arch.tsb_description.tsb_base), 80 TSB_ENTRY_COUNT * sizeof(tsb_entry_t), 0); 81 81 #endif 82 82 return 0; … … 86 86 { 87 87 #ifdef CONFIG_TSB 88 /* 89 * The count must be calculated with respect to the emualted 16K page 90 * size. 91 */ 92 size_t cnt = ((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) * 93 sizeof(tsb_entry_t)) >> FRAME_WIDTH; 94 frame_free(KA2PA((uintptr_t) as->arch.itsb)); 88 count_t cnt = (TSB_ENTRY_COUNT * sizeof(tsb_entry_t)) >> FRAME_WIDTH; 89 frame_free((uintptr_t) as->arch.tsb_description.tsb_base); 95 90 return cnt; 96 91 #else … … 116 111 void as_install_arch(as_t *as) 117 112 { 118 #if 0 119 tlb_context_reg_t ctx; 120 121 /* 122 * Note that we don't and may not lock the address space. That's ok 123 * since we only read members that are currently read-only. 124 * 125 * Moreover, the as->asid is protected by asidlock, which is being held. 126 */ 127 128 /* 129 * Write ASID to secondary context register. The primary context 130 * register has to be set from TL>0 so it will be filled from the 131 * secondary context register from the TL=1 code just before switch to 132 * userspace. 133 */ 134 ctx.v = 0; 135 ctx.context = as->asid; 136 mmu_secondary_context_write(ctx.v); 137 138 #ifdef CONFIG_TSB 139 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 140 141 ASSERT(as->arch.itsb && as->arch.dtsb); 142 143 uintptr_t tsb = (uintptr_t) as->arch.itsb; 144 145 if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 146 /* 147 * TSBs were allocated from memory not covered 148 * by the locked 4M kernel DTLB entry. We need 149 * to map both TSBs explicitly. 150 */ 151 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, tsb); 152 dtlb_insert_mapping(tsb, KA2PA(tsb), PAGESIZE_64K, true, true); 153 } 154 155 /* 156 * Setup TSB Base registers. 157 */ 158 tsb_base_reg_t tsb_base; 159 160 tsb_base.value = 0; 161 tsb_base.size = TSB_SIZE; 162 tsb_base.split = 0; 163 164 tsb_base.base = ((uintptr_t) as->arch.itsb) >> MMU_PAGE_WIDTH; 165 itsb_base_write(tsb_base.value); 166 tsb_base.base = ((uintptr_t) as->arch.dtsb) >> MMU_PAGE_WIDTH; 167 dtsb_base_write(tsb_base.value); 168 169 #if defined (US3) 170 /* 171 * Clear the extension registers. 172 * In HelenOS, primary and secondary context registers contain 173 * equal values and kernel misses (context 0, ie. the nucleus context) 174 * are excluded from the TSB miss handler, so it makes no sense 175 * to have separate TSBs for primary, secondary and nucleus contexts. 176 * Clearing the extension registers will ensure that the value of the 177 * TSB Base register will be used as an address of TSB, making the code 178 * compatible with the US port. 179 */ 180 itsb_primary_extension_write(0); 181 itsb_nucleus_extension_write(0); 182 dtsb_primary_extension_write(0); 183 dtsb_secondary_extension_write(0); 184 dtsb_nucleus_extension_write(0); 185 #endif 186 #endif 187 #endif 113 mmu_secondary_context_write(as->asid); 188 114 } 189 115
Note:
See TracChangeset
for help on using the changeset viewer.