Changeset da1bafb in mainline for kernel/arch/sparc64/src
- Timestamp:
- 2010-05-24T18:57:31Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0095368
- Parents:
- 666f492
- Location:
- kernel/arch/sparc64/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/src/mm/sun4u/as.c
r666f492 rda1bafb 41 41 42 42 #ifdef CONFIG_TSB 43 43 44 #include <arch/mm/tsb.h> 44 45 #include <arch/memstr.h> … … 47 48 #include <bitops.h> 48 49 #include <macros.h> 50 49 51 #endif /* CONFIG_TSB */ 50 52 … … 58 60 } 59 61 60 int as_constructor_arch(as_t *as, int flags)62 int as_constructor_arch(as_t *as, unsigned int flags) 61 63 { 62 64 #ifdef CONFIG_TSB … … 64 66 * The order must be calculated with respect to the emulated 65 67 * 16K page size. 66 */ 67 int order = fnzb32(((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) * 68 * 69 */ 70 uint8_t order = fnzb32(((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) * 68 71 sizeof(tsb_entry_t)) >> FRAME_WIDTH); 69 72 70 73 uintptr_t tsb = (uintptr_t) frame_alloc(order, flags | FRAME_KA); 71 74 72 75 if (!tsb) 73 76 return -1; 74 77 75 78 as->arch.itsb = (tsb_entry_t *) tsb; 76 79 as->arch.dtsb = (tsb_entry_t *) (tsb + ITSB_ENTRY_COUNT * 77 80 sizeof(tsb_entry_t)); 78 81 79 82 memsetb(as->arch.itsb, 80 83 (ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) * sizeof(tsb_entry_t), 0); 81 84 #endif 85 82 86 return 0; 83 87 } … … 93 97 sizeof(tsb_entry_t)) >> FRAME_WIDTH; 94 98 frame_free(KA2PA((uintptr_t) as->arch.itsb)); 99 95 100 return cnt; 96 101 #else … … 99 104 } 100 105 101 int as_create_arch(as_t *as, int flags)106 int as_create_arch(as_t *as, unsigned int flags) 102 107 { 103 108 #ifdef CONFIG_TSB 104 109 tsb_invalidate(as, 0, (size_t) -1); 105 110 #endif 111 106 112 return 0; 107 113 } … … 123 129 * 124 130 * Moreover, the as->asid is protected by asidlock, which is being held. 131 * 125 132 */ 126 133 … … 130 137 * secondary context register from the TL=1 code just before switch to 131 138 * userspace. 139 * 132 140 */ 133 141 ctx.v = 0; 134 142 ctx.context = as->asid; 135 143 mmu_secondary_context_write(ctx.v); 136 137 #ifdef CONFIG_TSB 144 145 #ifdef CONFIG_TSB 138 146 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 139 147 140 148 ASSERT(as->arch.itsb && as->arch.dtsb); 141 149 142 150 uintptr_t tsb = (uintptr_t) as->arch.itsb; 143 151 144 152 if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 145 153 /* … … 147 155 * by the locked 4M kernel DTLB entry. We need 148 156 * to map both TSBs explicitly. 157 * 149 158 */ 150 159 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, tsb); 151 160 dtlb_insert_mapping(tsb, KA2PA(tsb), PAGESIZE_64K, true, true); 152 161 } 153 162 154 163 /* 155 164 * Setup TSB Base registers. 165 * 156 166 */ 157 167 tsb_base_reg_t tsb_base; 158 168 159 169 tsb_base.value = 0; 160 170 tsb_base.size = TSB_SIZE; 161 171 tsb_base.split = 0; 162 172 163 173 tsb_base.base = ((uintptr_t) as->arch.itsb) >> MMU_PAGE_WIDTH; 164 174 itsb_base_write(tsb_base.value); … … 175 185 * Clearing the extension registers will ensure that the value of the 176 186 * TSB Base register will be used as an address of TSB, making the code 177 * compatible with the US port. 187 * compatible with the US port. 188 * 178 189 */ 179 190 itsb_primary_extension_write(0); … … 195 206 void as_deinstall_arch(as_t *as) 196 207 { 197 198 208 /* 199 209 * Note that we don't and may not lock the address space. That's ok … … 201 211 * 202 212 * Moreover, the as->asid is protected by asidlock, which is being held. 203 */ 204 213 * 214 */ 215 205 216 #ifdef CONFIG_TSB 206 217 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 207 218 208 219 ASSERT(as->arch.itsb && as->arch.dtsb); 209 220 210 221 uintptr_t tsb = (uintptr_t) as->arch.itsb; 211 222 212 223 if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 213 224 /* -
kernel/arch/sparc64/src/mm/sun4v/as.c
r666f492 rda1bafb 44 44 45 45 #ifdef CONFIG_TSB 46 46 47 #include <arch/mm/tsb.h> 47 48 #include <arch/memstr.h> … … 50 51 #include <bitops.h> 51 52 #include <macros.h> 53 52 54 #endif /* CONFIG_TSB */ 53 55 … … 61 63 } 62 64 63 int as_constructor_arch(as_t *as, int flags)65 int as_constructor_arch(as_t *as, unsigned int flags) 64 66 { 65 67 #ifdef CONFIG_TSB 66 int order = fnzb32(68 uint8_t order = fnzb32( 67 69 (TSB_ENTRY_COUNT * sizeof(tsb_entry_t)) >> FRAME_WIDTH); 68 70 69 71 uintptr_t tsb = (uintptr_t) frame_alloc(order, flags); 70 72 71 73 if (!tsb) 72 74 return -1; 73 75 74 76 as->arch.tsb_description.page_size = PAGESIZE_8K; 75 77 as->arch.tsb_description.associativity = 1; … … 79 81 as->arch.tsb_description.reserved = 0; 80 82 as->arch.tsb_description.context = 0; 81 83 82 84 memsetb((void *) PA2KA(as->arch.tsb_description.tsb_base), 83 85 TSB_ENTRY_COUNT * sizeof(tsb_entry_t), 0); 84 86 #endif 87 85 88 return 0; 86 89 } … … 91 94 size_t cnt = (TSB_ENTRY_COUNT * sizeof(tsb_entry_t)) >> FRAME_WIDTH; 92 95 frame_free((uintptr_t) as->arch.tsb_description.tsb_base); 96 93 97 return cnt; 94 98 #else … … 97 101 } 98 102 99 int as_create_arch(as_t *as, int flags)103 int as_create_arch(as_t *as, unsigned int flags) 100 104 { 101 105 #ifdef CONFIG_TSB 102 106 tsb_invalidate(as, 0, (size_t) -1); 103 107 #endif 108 104 109 return 0; 105 110 } … … 111 116 * 112 117 * @param as Address space. 118 * 113 119 */ 114 120 void as_install_arch(as_t *as) 115 121 { 116 122 mmu_secondary_context_write(as->asid); 117 #ifdef CONFIG_TSB 123 124 #ifdef CONFIG_TSB 118 125 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 119 126 120 127 ASSERT(as->arch.tsb_description.tsb_base); 121 128 uintptr_t tsb = PA2KA(as->arch.tsb_description.tsb_base); 122 129 123 130 if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 124 131 /* … … 126 133 * by the locked 4M kernel DTLB entry. We need 127 134 * to map both TSBs explicitly. 135 * 128 136 */ 129 137 mmu_demap_page(tsb, 0, MMU_FLAG_DTLB); 130 138 dtlb_insert_mapping(tsb, KA2PA(tsb), PAGESIZE_64K, true, true); 131 139 } 132 140 133 141 __hypercall_fast2(MMU_TSB_CTXNON0, 1, KA2PA(&(as->arch.tsb_description))); 134 135 142 #endif 136 143 } … … 142 149 * 143 150 * @param as Address space. 151 * 144 152 */ 145 153 void as_deinstall_arch(as_t *as) 146 154 { 147 148 155 /* 149 156 * Note that we don't and may not lock the address space. That's ok … … 151 158 * 152 159 * Moreover, the as->asid is protected by asidlock, which is being held. 160 * 153 161 */ 154 162 155 163 #ifdef CONFIG_TSB 156 164 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 157 165 158 166 ASSERT(as->arch.tsb_description.tsb_base); 159 167 160 168 uintptr_t tsb = PA2KA(as->arch.tsb_description.tsb_base); 161 169 162 170 if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 163 171 /* … … 165 173 * by the locked 4M kernel DTLB entry. We need 166 174 * to demap the entry installed by as_install_arch(). 175 * 167 176 */ 168 177 __hypercall_fast3(MMU_UNMAP_PERM_ADDR, tsb, 0, MMU_FLAG_DTLB); -
kernel/arch/sparc64/src/trap/sun4u/interrupt.c
r666f492 rda1bafb 55 55 void interrupt(int n, istate_t *istate) 56 56 { 57 uint64_t status; 58 uint64_t intrcv; 59 uint64_t data0; 60 status = asi_u64_read(ASI_INTR_DISPATCH_STATUS, 0); 57 uint64_t status = asi_u64_read(ASI_INTR_DISPATCH_STATUS, 0); 61 58 if (status & (!INTR_DISPATCH_STATUS_BUSY)) 62 59 panic("Interrupt Dispatch Status busy bit not set\n"); 63 64 intrcv = asi_u64_read(ASI_INTR_RECEIVE, 0);60 61 uint64_t intrcv = asi_u64_read(ASI_INTR_RECEIVE, 0); 65 62 #if defined (US) 66 data0 = asi_u64_read(ASI_INTR_R, ASI_UDB_INTR_R_DATA_0);63 uint64_t data0 = asi_u64_read(ASI_INTR_R, ASI_UDB_INTR_R_DATA_0); 67 64 #elif defined (US3) 68 data0 = asi_u64_read(ASI_INTR_R, VA_INTR_R_DATA_0);65 uint64_t data0 = asi_u64_read(ASI_INTR_R, VA_INTR_R_DATA_0); 69 66 #endif 70 67 71 68 irq_t *irq = irq_dispatch_and_lock(data0); 72 69 if (irq) { … … 75 72 */ 76 73 irq->handler(irq); 74 77 75 /* 78 76 * See if there is a clear-interrupt-routine and call it. 79 77 */ 80 if (irq->cir) {78 if (irq->cir) 81 79 irq->cir(irq->cir_arg, irq->inr); 82 }83 spinlock_unlock(&irq->lock);80 81 irq_spinlock_unlock(&irq->lock, false); 84 82 } else if (data0 > config.base) { 85 83 /* … … 90 88 */ 91 89 #ifdef CONFIG_SMP 92 if (data0 == (uintptr_t) tlb_shootdown_ipi_recv) {90 if (data0 == (uintptr_t) tlb_shootdown_ipi_recv) 93 91 tlb_shootdown_ipi_recv(); 94 }95 92 #endif 96 93 } else { … … 101 98 printf("cpu%u: spurious interrupt (intrcv=%#" PRIx64 102 99 ", data0=%#" PRIx64 ")\n", CPU->id, intrcv, data0); 100 #else 101 (void) intrcv; 103 102 #endif 104 103 } 105 104 106 105 membar(); 107 106 asi_u64_write(ASI_INTR_RECEIVE, 0, 0);
Note:
See TracChangeset
for help on using the changeset viewer.