Changeset 13c94f7 in mainline
- Timestamp:
- 2013-10-15T17:54:23Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d783145
- Parents:
- e76fed9
- Location:
- kernel/arch/sparc32
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc32/include/arch/exception.h
re76fed9 r13c94f7 67 67 extern void data_store_error(int n, istate_t *istate); 68 68 extern void mem_address_not_aligned(int n, istate_t *istate); 69 extern void syscall(sysarg_t a1, sysarg_t a2, sysarg_t a3, sysarg_t a4, sysarg_t a5, sysarg_t a6, sysarg_t id); 69 70 70 71 #endif /* !__ASM__ */ -
kernel/arch/sparc32/src/exception.c
re76fed9 r13c94f7 39 39 #include <arch/istate.h> 40 40 #include <arch/exception.h> 41 #include <syscall/syscall.h> 41 42 #include <interrupt.h> 42 43 #include <arch/asm.h> … … 139 140 } 140 141 142 void syscall(sysarg_t a1, sysarg_t a2, sysarg_t a3, sysarg_t a4, sysarg_t a5, sysarg_t a6, sysarg_t id) 143 { 144 printf("syscall %d\n", id); 145 syscall_handler(a1, a2, a3, a4, a5, a6, id); 146 } 147 141 148 /** @} 142 149 */ -
kernel/arch/sparc32/src/mm/page.c
re76fed9 r13c94f7 87 87 uintptr_t fault_address = asi_u32_read(ASI_MMUREGS, MMU_FAULT_ADDRESS); 88 88 mmu_fault_status_t *fault = (mmu_fault_status_t *)&fault_status; 89 mmu_fault_type_t type = (mmu_fault_type_t)fault-> ft;89 mmu_fault_type_t type = (mmu_fault_type_t)fault->at; 90 90 91 printf("page fault on address 0x%08x, status 0x%08x \n", fault_address, fault_status);91 printf("page fault on address 0x%08x, status 0x%08x, type %d\n", fault_address, fault_status, type); 92 92 93 if (type == FAULT_TYPE_LOAD_USER_DATA )93 if (type == FAULT_TYPE_LOAD_USER_DATA || type == FAULT_TYPE_LOAD_SUPERVISOR_DATA) 94 94 as_page_fault(fault_address, PF_ACCESS_READ, istate); 95 95 96 if (type == FAULT_TYPE_EXECUTE_USER )96 if (type == FAULT_TYPE_EXECUTE_USER || type == FAULT_TYPE_EXECUTE_SUPERVISOR) 97 97 as_page_fault(fault_address, PF_ACCESS_EXEC, istate); 98 98 99 if (type == FAULT_TYPE_STORE_USER_DATA || type == FAULT_TYPE_STORE_USER_INSTRUCTION )99 if (type == FAULT_TYPE_STORE_USER_DATA || type == FAULT_TYPE_STORE_USER_INSTRUCTION || type == FAULT_TYPE_STORE_SUPERVISOR_INSTRUCTION) 100 100 as_page_fault(fault_address, PF_ACCESS_WRITE, istate); 101 101 } -
kernel/arch/sparc32/src/trap_table.S
re76fed9 r13c94f7 34 34 .global reset_trap 35 35 .global preemptible_trap 36 .global syscall_trap 36 37 .global window_overflow_trap 37 38 .global window_underflow_trap … … 44 45 45 46 window_overflow_trap: 46 /* rotate WIM on bit right, we have 8 windows */ 47 mov %wim,%l3 48 sll %l3,7,%l4 49 srl %l3,1,%l3 50 or %l3,%l4,%l3 51 and %l3,0xff,%l3 52 53 /* disable WIM traps */ 54 mov %g0,%wim 55 nop; nop; nop 56 57 /* point to correct window */ 58 save 59 60 /* dump registers to stack */ 61 std %l0, [%sp + 0] 62 std %l2, [%sp + 8] 63 std %l4, [%sp + 16] 64 std %l6, [%sp + 24] 65 std %i0, [%sp + 32] 66 std %i2, [%sp + 40] 67 std %i4, [%sp + 48] 68 std %i6, [%sp + 56] 69 70 /* back to where we should be */ 71 restore 72 73 /* set new value of window */ 74 mov %l3,%wim 75 nop; nop; nop 76 77 /* go home */ 78 jmp %l1 79 rett %l2 47 /* rotate WIM on bit right, we have 8 windows */ 48 mov %wim, %l3 49 sll %l3, 7, %l4 50 srl %l3, 1, %l3 51 or %l3, %l4, %l3 52 and %l3, 0xff, %l3 53 54 /* disable WIM traps */ 55 mov %g0,%wim 56 nop; nop; nop 57 58 /* Check whether previous mode was usermode */ 59 mov %psr, %l0 60 and %l0, (1 << 6), %l0 61 cmp %l0, 0 62 beq 1f 63 nop 64 65 /* dump registers to stack */ 66 save 67 std %l0, [%sp + 0] 68 std %l2, [%sp + 8] 69 std %l4, [%sp + 16] 70 std %l6, [%sp + 24] 71 std %i0, [%sp + 32] 72 std %i2, [%sp + 40] 73 std %i4, [%sp + 48] 74 std %i6, [%sp + 56] 75 b 2f 76 nop 77 78 /* dump registers to uwb */ 79 1: save 80 set uspace_wbuf, %g2 81 ld [%g1], %g1 82 std %l0, [%g1 + 0] 83 std %l2, [%g1 + 8] 84 std %l4, [%g1 + 16] 85 std %l6, [%g1 + 24] 86 std %i0, [%g1 + 32] 87 std %i2, [%g1 + 40] 88 std %i4, [%g1 + 48] 89 std %i6, [%g1 + 56] 90 add %g1, 64, %g1 91 st %g1, [%g2] 92 93 /* back to where we should be */ 94 2: restore 95 96 /* set new value of window */ 97 mov %l3,%wim 98 nop; nop; nop 99 100 /* go home */ 101 jmp %l1 102 rett %l2 80 103 81 104 window_underflow_trap: … … 91 114 nop; nop; nop 92 115 93 /* point to correct window */ 94 restore 95 restore 96 97 /* dump registers to stack */ 116 /* Check whether previous mode was usermode */ 117 mov %psr, %l0 118 and %l0, (1 << 6), %l0 119 cmp %l0, 0 120 beq 1f 121 nop 122 123 /* load registers from stack */ 124 restore 125 restore 98 126 ldd [%sp + 0], %l0 99 127 ldd [%sp + 8], %l2 … … 104 132 ldd [%sp + 48], %i4 105 133 ldd [%sp + 56], %i6 134 b 2f 135 nop 136 137 /* load registers from uwb */ 138 1: restore 139 restore 140 set uspace_wbuf, %g2 141 ld [%g2], %g1 142 ldd [%g1 + 0], %l0 143 ldd [%g1 + 8], %l2 144 ldd [%g1 + 16], %l4 145 ldd [%g1 + 24], %l6 146 ldd [%g1 + 32], %i0 147 ldd [%g1 + 40], %i2 148 ldd [%g1 + 48], %i4 149 ldd [%g1 + 56], %i6 150 sub %g1, 64, %g1 151 st %g1, [%g2] 106 152 107 153 /* back to where we should be */ 108 109 154 2: save 155 save 110 156 111 157 /* set new value of window */ … … 118 164 119 165 preemptible_trap: 120 /* Enable traps */ 121 mov %psr, %l0 122 or %l0, (1 << 5), %l0 123 mov %l0, %psr 166 mov %psr, %l0 124 167 125 168 /* Check whether previous mode was usermode */ … … 136 179 137 180 /* Save trap data on stack */ 181 mov %psr, %l0 138 182 st %l1, [%fp - 4] 139 183 st %l2, [%fp - 8] 140 184 st %l0, [%fp - 12] 141 185 186 /* Enable traps */ 187 mov %psr, %l0 188 or %l0, (1 << 5), %l0 189 mov %l0, %psr 190 nop 191 nop 192 nop 193 nop 194 142 195 /* Jump to actual subroutine */ 143 mov 1, %o0144 jmp%g1196 mov %g2, %o0 197 call %g1 145 198 sub %fp, 12, %o1 146 199 … … 148 201 ld [%fp - 4], %l1 149 202 ld [%fp - 8], %l2 203 ld [%fp - 12], %l0 204 mov %l0, %psr 205 nop 206 nop 207 nop 208 nop 209 nop 150 210 jmp %l1 151 211 rett %l2 212 213 syscall_trap: 214 mov %psr, %l0 215 216 /* Set up stack */ 217 set kernel_sp, %l4 218 ld [%l4], %sp 219 mov %sp, %fp 220 sub %sp, 112, %sp 221 222 /* Save trap data on stack */ 223 mov %psr, %l0 224 st %l1, [%fp - 4] 225 st %l2, [%fp - 8] 226 st %l0, [%fp - 12] 227 228 /* Enable traps */ 229 mov %psr, %l0 230 or %l0, (1 << 5), %l0 231 mov %l0, %psr 232 nop 233 nop 234 nop 235 nop 236 237 /* Jump to actual subroutine */ 238 sub %g2, 0x80, %g2 239 st %g2, [ %sp + 92 ] 240 mov %i0, %o1 241 mov %i1, %o1 242 mov %i2, %o2 243 mov %i3, %o3 244 mov %i4, %o4 245 call syscall 246 mov %i5, %o5 247 248 /* Return from handler */ 249 ld [%fp - 4], %l1 250 ld [%fp - 8], %l2 251 ld [%fp - 12], %l0 252 mov %l0, %psr 253 nop 254 nop 255 nop 256 nop 257 nop 258 jmp %l2 259 rett %l2 + 4 152 260 153 261 #define STRAP(_vector, _handler) \ … … 160 268 #define TRAP(_vector, _handler) \ 161 269 .org trap_table + _vector * TRAP_ENTRY_SIZE; \ 270 set _vector, %g2 ; \ 162 271 sethi %hi(_handler), %g1 ; \ 163 272 b preemptible_trap ; \ 164 273 or %g1, %lo(_handler), %g1 ; 274 275 #define SYSCALL(_vector) \ 276 .org trap_table + _vector * TRAP_ENTRY_SIZE; \ 277 set _vector, %g2 ; \ 278 b syscall_trap ; \ 279 nop ; 165 280 166 281 #define INTERRUPT(_vector, _priority) \ … … 304 419 BADTRAP(0x7e) 305 420 BADTRAP(0x7f) 306 421 SYSCALL(0x80) 422 SYSCALL(0x81) 423 SYSCALL(0x82) 424 SYSCALL(0x83) 425 SYSCALL(0x84) 426 SYSCALL(0x85) 427 SYSCALL(0x86) 428 SYSCALL(0x87) 429 SYSCALL(0x88) 430 SYSCALL(0x89) 431 SYSCALL(0x8a) 432 SYSCALL(0x8b) 433 SYSCALL(0x8c) 434 SYSCALL(0x8d) 435 SYSCALL(0x8e) 436 SYSCALL(0x8f) 437 SYSCALL(0x90) 438 SYSCALL(0x91) 439 SYSCALL(0x92) 440 SYSCALL(0x93) 441 SYSCALL(0x94) 442 SYSCALL(0x95) 443 SYSCALL(0x96) 444 SYSCALL(0x97) 445 SYSCALL(0x98) 446 SYSCALL(0x99) 447 SYSCALL(0x9a) 448 SYSCALL(0x9b) 449 SYSCALL(0x9c) 450 SYSCALL(0x9d) 451 SYSCALL(0x9e) 452 SYSCALL(0x9f) 453 SYSCALL(0xa0) 454 SYSCALL(0xa1) 455 SYSCALL(0xa2) 456 SYSCALL(0xa3) 457 SYSCALL(0xa4) 458 SYSCALL(0xa5) 459 SYSCALL(0xa6) 460 SYSCALL(0xa7) 461 SYSCALL(0xa8) 462 SYSCALL(0xa9) -
kernel/arch/sparc32/src/userspace.c
re76fed9 r13c94f7 53 53 asm volatile ( 54 54 "mov %[stack], %%sp\n" 55 "mov %[psr], %%psr\n"56 "nop\n"57 55 "jmp %[entry]\n" 58 " nop\n" :: [entry] "r" (kernel_uarg->uspace_entry),56 "mov %[psr], %%psr\n" :: [entry] "r" (kernel_uarg->uspace_entry), 59 57 [psr] "r" (psr), 60 58 [stack] "r" (kernel_uarg->uspace_stack + kernel_uarg->uspace_stack_size));
Note:
See TracChangeset
for help on using the changeset viewer.