Changeset fd85ae5 in mainline
- Timestamp:
- 2006-09-04T19:11:23Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fadd381
- Parents:
- cfa70add
- Location:
- kernel
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/Makefile.inc
rcfa70add rfd85ae5 96 96 arch/$(ARCH)/src/proc/scheduler.c \ 97 97 arch/$(ARCH)/src/proc/thread.c \ 98 arch/$(ARCH)/src/trap/mmu.S \ 98 99 arch/$(ARCH)/src/trap/trap_table.S \ 99 100 arch/$(ARCH)/src/trap/trap.c \ -
kernel/arch/sparc64/include/asm.h
rcfa70add rfd85ae5 322 322 } 323 323 324 /** Switch to nucleus by setting TL to 1. */ 325 static inline void nucleus_enter(void) 326 { 327 __asm__ volatile ("wrpr %g0, 1, %tl\n"); 328 } 329 330 /** Switch from nucleus by setting TL to 0. */ 331 static inline void nucleus_leave(void) 332 { 333 __asm__ volatile ("wrpr %g0, %g0, %tl\n"); 334 } 335 324 336 extern void cpu_halt(void); 325 337 extern void cpu_sleep(void); -
kernel/arch/sparc64/include/trap/mmu.h
rcfa70add rfd85ae5 122 122 .endm 123 123 124 .macro MEM_ADDRESS_NOT_ALIGNED_HANDLER 125 ba mem_address_not_aligned_handler 126 nop 127 .endm 128 124 129 /* 125 130 * Macro used to lower TL when a MMU trap is caused by -
kernel/arch/sparc64/src/asm.S
rcfa70add rfd85ae5 27 27 # 28 28 29 #include <arch/arch.h> 29 30 #include <arch/stack.h> 30 31 #include <arch/regdef.h> … … 33 34 .text 34 35 36 .register %g2, #scratch 37 .register %g3, #scratch 38 39 /* 40 * This is the assembly language version of our _memcpy() generated by gcc. 41 */ 35 42 .global memcpy 36 .global memcpy_from_uspace37 .global memcpy_to_uspace38 .global memcpy_from_uspace_failover_address39 .global memcpy_to_uspace_failover_address40 .global memsetb41 42 43 43 memcpy: 44 memcpy_from_uspace:45 memcpy_to_uspace:46 .register %g2, #scratch47 .register %g3, #scratch48 44 add %o1, 7, %g1 49 45 and %g1, -8, %g1 … … 100 96 mov %o1, %o0 101 97 98 /* 99 * Almost the same as memcpy() except the loads are from userspace. 100 */ 101 .global memcpy_from_uspace 102 memcpy_from_uspace: 103 add %o1, 7, %g1 104 and %g1, -8, %g1 105 cmp %o1, %g1 106 be,pn %xcc, 3f 107 add %o0, 7, %g1 108 mov 0, %g3 109 0: 110 brz,pn %o2, 2f 111 mov 0, %g2 112 1: 113 lduba [%g3 + %o1] ASI_AIUS, %g1 114 add %g2, 1, %g2 115 cmp %o2, %g2 116 stb %g1, [%g3 + %o0] 117 bne,pt %xcc, 1b 118 mov %g2, %g3 119 2: 120 jmp %o7 + 8 ! exit point 121 mov %o1, %o0 122 3: 123 and %g1, -8, %g1 124 cmp %o0, %g1 125 bne,pt %xcc, 0b 126 mov 0, %g3 127 srlx %o2, 3, %g4 128 brz,pn %g4, 5f 129 mov 0, %g5 130 4: 131 sllx %g3, 3, %g2 132 add %g5, 1, %g3 133 ldxa [%o1 + %g2] ASI_AIUS, %g1 134 mov %g3, %g5 135 cmp %g4, %g3 136 bne,pt %xcc, 4b 137 stx %g1, [%o0 + %g2] 138 5: 139 and %o2, 7, %o2 140 brz,pn %o2, 2b 141 sllx %g4, 3, %g1 142 mov 0, %g2 143 add %g1, %o0, %o0 144 add %g1, %o1, %g4 145 mov 0, %g3 146 6: 147 lduba [%g2 + %g4] ASI_AIUS, %g1 148 stb %g1, [%g2 + %o0] 149 add %g3, 1, %g2 150 cmp %o2, %g2 151 bne,pt %xcc, 6b 152 mov %g2, %g3 153 154 jmp %o7 + 8 ! exit point 155 mov %o1, %o0 156 157 /* 158 * Almost the same as memcpy() except the stores are to userspace. 159 */ 160 .global memcpy_to_uspace 161 memcpy_to_uspace: 162 add %o1, 7, %g1 163 and %g1, -8, %g1 164 cmp %o1, %g1 165 be,pn %xcc, 3f 166 add %o0, 7, %g1 167 mov 0, %g3 168 0: 169 brz,pn %o2, 2f 170 mov 0, %g2 171 1: 172 ldub [%g3 + %o1], %g1 173 add %g2, 1, %g2 174 cmp %o2, %g2 175 stba %g1, [%g3 + %o0] ASI_AIUS 176 bne,pt %xcc, 1b 177 mov %g2, %g3 178 2: 179 jmp %o7 + 8 ! exit point 180 mov %o1, %o0 181 3: 182 and %g1, -8, %g1 183 cmp %o0, %g1 184 bne,pt %xcc, 0b 185 mov 0, %g3 186 srlx %o2, 3, %g4 187 brz,pn %g4, 5f 188 mov 0, %g5 189 4: 190 sllx %g3, 3, %g2 191 add %g5, 1, %g3 192 ldx [%o1 + %g2], %g1 193 mov %g3, %g5 194 cmp %g4, %g3 195 bne,pt %xcc, 4b 196 stxa %g1, [%o0 + %g2] ASI_AIUS 197 5: 198 and %o2, 7, %o2 199 brz,pn %o2, 2b 200 sllx %g4, 3, %g1 201 mov 0, %g2 202 add %g1, %o0, %o0 203 add %g1, %o1, %g4 204 mov 0, %g3 205 6: 206 ldub [%g2 + %g4], %g1 207 stba %g1, [%g2 + %o0] ASI_AIUS 208 add %g3, 1, %g2 209 cmp %o2, %g2 210 bne,pt %xcc, 6b 211 mov %g2, %g3 212 213 jmp %o7 + 8 ! exit point 214 mov %o1, %o0 215 216 .global memcpy_from_uspace_failover_address 217 .global memcpy_to_uspace_failover_address 102 218 memcpy_from_uspace_failover_address: 103 219 memcpy_to_uspace_failover_address: … … 105 221 mov %g0, %o0 ! return 0 on failure 106 222 223 .global memsetb 107 224 memsetb: 108 225 b _memsetb … … 155 272 .global switch_to_userspace 156 273 switch_to_userspace: 274 save %o1, -STACK_WINDOW_SAVE_AREA_SIZE, %sp 157 275 flushw 158 276 wrpr %g0, 0, %cleanwin ! avoid information leak 159 save %o1, -STACK_WINDOW_SAVE_AREA_SIZE, %sp160 277 161 278 mov %i3, %o0 ! uarg -
kernel/arch/sparc64/src/mm/tlb.c
rcfa70add rfd85ae5 53 53 static void dtlb_pte_copy(pte_t *t, bool ro); 54 54 static void itlb_pte_copy(pte_t *t); 55 static void do_fast_data_access_mmu_miss_fault(istate_t *istate, const char *str);56 55 static void do_fast_instruction_access_mmu_miss_fault(istate_t *istate, const char *str); 57 static void do_fast_data_access_protection_fault(istate_t *istate, const char *str); 56 static void do_fast_data_access_mmu_miss_fault(istate_t *istate, tlb_tag_access_reg_t tag, const char *str); 57 static void do_fast_data_access_protection_fault(istate_t *istate, tlb_tag_access_reg_t tag, const char *str); 58 58 59 59 char *context_encoding[] = { … … 214 214 215 215 tag.value = dtlb_tag_access_read(); 216 va = tag.vpn * PAGE_SIZE; 216 va = tag.vpn << PAGE_WIDTH; 217 217 218 if (tag.context == ASID_KERNEL) { 218 219 if (!tag.vpn) { 219 220 /* NULL access in kernel */ 220 do_fast_data_access_mmu_miss_fault(istate, __FUNCTION__);221 } 222 do_fast_data_access_mmu_miss_fault(istate, "Unexpected kernel page fault.");221 do_fast_data_access_mmu_miss_fault(istate, tag, __FUNCTION__); 222 } 223 do_fast_data_access_mmu_miss_fault(istate, tag, "Unexpected kernel page fault."); 223 224 } 224 225 … … 239 240 page_table_unlock(AS, true); 240 241 if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { 241 do_fast_data_access_mmu_miss_fault(istate, __FUNCTION__);242 do_fast_data_access_mmu_miss_fault(istate, tag, __FUNCTION__); 242 243 } 243 244 } … … 252 253 253 254 tag.value = dtlb_tag_access_read(); 254 va = tag.vpn * PAGE_SIZE;255 va = tag.vpn << PAGE_WIDTH; 255 256 256 257 page_table_lock(AS, true); … … 272 273 page_table_unlock(AS, true); 273 274 if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) { 274 do_fast_data_access_protection_fault(istate, __FUNCTION__);275 do_fast_data_access_protection_fault(istate, tag, __FUNCTION__); 275 276 } 276 277 } … … 312 313 } 313 314 314 void do_fast_data_access_mmu_miss_fault(istate_t *istate, const char *str) 315 { 316 tlb_tag_access_reg_t tag; 315 void do_fast_data_access_mmu_miss_fault(istate_t *istate, tlb_tag_access_reg_t tag, const char *str) 316 { 317 317 uintptr_t va; 318 318 char *tpc_str = get_symtab_entry(istate->tpc); 319 319 320 tag.value = dtlb_tag_access_read(); 321 va = tag.vpn * PAGE_SIZE; 320 va = tag.vpn << PAGE_WIDTH; 322 321 323 322 printf("Faulting page: %p, ASID=%d\n", va, tag.context); … … 326 325 } 327 326 328 void do_fast_data_access_protection_fault(istate_t *istate, const char *str) 329 { 330 tlb_tag_access_reg_t tag; 327 void do_fast_data_access_protection_fault(istate_t *istate, tlb_tag_access_reg_t tag, const char *str) 328 { 331 329 uintptr_t va; 332 330 char *tpc_str = get_symtab_entry(istate->tpc); 333 331 334 tag.value = dtlb_tag_access_read(); 335 va = tag.vpn * PAGE_SIZE; 332 va = tag.vpn << PAGE_WIDTH; 336 333 337 334 printf("Faulting page: %p, ASID=%d\n", va, tag.context); … … 375 372 void tlb_invalidate_asid(asid_t asid) 376 373 { 377 tlb_context_reg_t sc_save, ctx; 378 379 ctx.v = sc_save.v = mmu_secondary_context_read(); 374 tlb_context_reg_t pc_save, ctx; 375 376 /* switch to nucleus because we are mapped by the primary context */ 377 nucleus_enter(); 378 379 ctx.v = pc_save.v = mmu_primary_context_read(); 380 380 ctx.context = asid; 381 mmu_secondary_context_write(ctx.v); 382 383 itlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_SECONDARY, 0); 384 dtlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_SECONDARY, 0); 385 386 mmu_secondary_context_write(sc_save.v); 381 mmu_primary_context_write(ctx.v); 382 383 itlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_PRIMARY, 0); 384 dtlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_PRIMARY, 0); 385 386 mmu_primary_context_write(pc_save.v); 387 388 nucleus_leave(); 387 389 } 388 390 … … 396 398 { 397 399 int i; 398 tlb_context_reg_t sc_save, ctx; 399 400 ctx.v = sc_save.v = mmu_secondary_context_read(); 400 tlb_context_reg_t pc_save, ctx; 401 402 /* switch to nucleus because we are mapped by the primary context */ 403 nucleus_enter(); 404 405 ctx.v = pc_save.v = mmu_primary_context_read(); 401 406 ctx.context = asid; 402 mmu_ secondary_context_write(ctx.v);407 mmu_primary_context_write(ctx.v); 403 408 404 409 for (i = 0; i < cnt; i++) { 405 itlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_SECONDARY, page + i * PAGE_SIZE); 406 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_SECONDARY, page + i * PAGE_SIZE); 407 } 408 409 mmu_secondary_context_write(sc_save.v); 410 itlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_PRIMARY, page + i * PAGE_SIZE); 411 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_PRIMARY, page + i * PAGE_SIZE); 412 } 413 414 mmu_primary_context_write(pc_save.v); 415 416 nucleus_leave(); 410 417 } 411 418 -
kernel/arch/sparc64/src/trap/trap_table.S
rcfa70add rfd85ae5 28 28 29 29 /** 30 * This file contains kernel trap table. 30 * @file 31 * @brief This file contains kernel trap table. 31 32 */ 32 33 … … 85 86 .global mem_address_not_aligned 86 87 mem_address_not_aligned: 87 PREEMPTIBLE_HANDLER do_mem_address_not_aligned88 MEM_ADDRESS_NOT_ALIGNED_HANDLER 88 89 89 90 /* TT = 0x41, TL = 0, interrupt_level_1 handler */ … … 461 462 .global mem_address_not_aligned_high 462 463 mem_address_not_aligned_high: 463 PREEMPTIBLE_HANDLER do_mem_address_not_aligned464 MEM_ADDRESS_NOT_ALIGNED_HANDLER 464 465 465 466 /* TT = 0x64, TL > 0, fast_instruction_access_MMU_miss */ … … 525 526 */ 526 527 .macro PREEMPTIBLE_HANDLER_TEMPLATE is_syscall 528 /* 529 * ASSERT(%tl == 1) 530 */ 531 rdpr %tl, %g3 532 cmp %g3, 1 533 be 1f 534 nop 535 0: ba 0b ! this for debugging, if we ever get here 536 nop ! it will be easy to find 537 538 1: 527 539 .if NOT(\is_syscall) 528 540 rdpr %tstate, %g3 … … 536 548 wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(2), %wstate 537 549 550 wrpr %g0, NWINDOW - 1, %cleanwin ! prevent unnecessary clean_window exceptions 551 538 552 /* 539 553 * Switch to kernel stack. The old stack is … … 555 569 /* 556 570 * Mark the CANRESTORE windows as OTHER windows. 557 * Set CLEANWIN to NWINDOW-1 so that clean_window traps do not occur.558 571 */ 559 572 rdpr %canrestore, %l0 560 573 wrpr %l0, %otherwin 561 574 wrpr %g0, %canrestore 562 wrpr %g0, NWINDOW - 1, %cleanwin563 575 564 576 /* … … 727 739 ldxa [VA_SECONDARY_CONTEXT_REG] %asi, %g1 728 740 stxa %g1, [VA_PRIMARY_CONTEXT_REG] %asi 729 flush %o7 741 rd %pc, %g1 742 flush %g1 730 743 731 744 rdpr %cwp, %g1 -
kernel/generic/include/adt/hash_table.h
rcfa70add rfd85ae5 27 27 */ 28 28 29 29 /** @addtogroup genericadt 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef __HASH_TABLE_H__36 #define __HASH_TABLE_H__35 #ifndef KERN_HASH_TABLE_H_ 36 #define KERN_HASH_TABLE_H_ 37 37 38 38 #include <adt/list.h> … … 82 82 #endif 83 83 84 84 /** @} 85 85 */ 86
Note:
See TracChangeset
for help on using the changeset viewer.