Changeset 817d939 in mainline for kernel/arch/sparc32/src/trap_table.S
- Timestamp:
- 2013-10-22T20:44:20Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e6a3bfee
- Parents:
- d783145
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc32/src/trap_table.S
rd783145 r817d939 34 34 .global reset_trap 35 35 .global preemptible_trap 36 .global interrupt_trap 36 37 .global syscall_trap 37 38 .global window_overflow_trap 38 39 .global window_underflow_trap 40 .global write_to_invalid 41 42 .macro get_wim_number reg 43 clr \reg 44 mov %wim, %g5 45 1: inc \reg 46 srl %g5, 1, %g5 47 andcc %g5, 1, %g0 48 bne 1b 49 nop 50 .endm 51 52 .macro get_cwp reg 53 mov %psr, \reg 54 and \reg, 0x7, \reg 55 .endm 56 57 .macro switch_to_invalid saved_wim, saved_psr 58 get_wim_number %g6 59 mov %wim, \saved_wim ! save WIM 60 mov %g0, %wim ! clear WIM 61 mov %psr, \saved_psr ! read PSR 62 or \saved_psr, %g6, %g6 ! set CWP 63 mov %g6, %psr ! write PSR 64 nop 65 nop 66 nop 67 nop ! wait for PSR to be effective 68 .endm 69 70 .macro switch_back wim, psr 71 mov \wim, %wim ! saved WIM 72 mov \psr, %psr ! saved PSR 73 nop 74 nop 75 nop 76 nop 77 .endm 78 79 /* Save next window to kernel stack or UWB */ 80 .macro inline_save_kernel 81 save 82 std %l0, [%sp + 0] 83 std %l2, [%sp + 8] 84 std %l4, [%sp + 16] 85 std %l6, [%sp + 24] 86 std %i0, [%sp + 32] 87 std %i2, [%sp + 40] 88 std %i4, [%sp + 48] 89 std %i6, [%sp + 56] 90 restore 91 .endm 92 93 .macro inline_save_uspace uwb 94 save 95 ld [\uwb], %g1 96 std %l0, [%g1 + 0] 97 std %l2, [%g1 + 8] 98 std %l4, [%g1 + 16] 99 std %l6, [%g1 + 24] 100 std %i0, [%g1 + 32] 101 std %i2, [%g1 + 40] 102 std %i4, [%g1 + 48] 103 std %i6, [%g1 + 56] 104 add \uwb, 64, \uwb 105 restore 106 .endm 107 108 /* Restore window from kernel stack or UWB */ 109 .macro inline_restore_kernel 110 save 111 ldd [%sp + 0], %l0 112 ldd [%sp + 8], %l2 113 ldd [%sp + 16], %l4 114 ldd [%sp + 24], %l6 115 ldd [%sp + 32], %i0 116 ldd [%sp + 40], %i2 117 ldd [%sp + 48], %i4 118 ldd [%sp + 56], %i6 119 restore 120 .endm 121 122 .macro inline_restore_uspace uwb 123 save 124 ld [\uwb], %g1 125 std %l0, [%g1 + 0] 126 std %l2, [%g1 + 8] 127 std %l4, [%g1 + 16] 128 std %l6, [%g1 + 24] 129 std %i0, [%g1 + 32] 130 std %i2, [%g1 + 40] 131 std %i4, [%g1 + 48] 132 std %i6, [%g1 + 56] 133 sub \uwb, 64, \uwb 134 restore 135 .endm 136 137 .macro if_from_kernel label 138 mov %psr, %g2 139 and %g2, (1 << 6), %g2 140 cmp %g2, 0 141 bne \label 142 nop 143 .endm 144 145 write_to_invalid: 146 mov %o0, %g5 147 mov %o1, %g6 148 mov %o2, %g7 149 switch_to_invalid %g3, %g4 150 mov %g5, %l5 151 mov %g6, %l6 152 mov %g7, %l7 153 switch_back %g3, %g4 154 retl 155 nop 39 156 40 157 reset_trap: … … 62 179 beq 1f 63 180 nop 181 182 /* Save invalid window data */ 183 mov %l5, %g5 ! kernel stack pointer 184 mov %l6, %g6 ! kernel wbuf 185 mov %l7, %g7 64 186 65 187 /* dump registers to stack */ … … 78 200 /* dump registers to uwb */ 79 201 1: save 80 s et uspace_wbuf, %g281 ld [%g1], %g182 std %l 0, [%g1 + 0]83 std %l 2, [%g1 + 8]84 std % l4, [%g1 + 16]85 std % l6, [%g1 + 24]86 std %i 0, [%g1 + 32]87 std %i 2, [%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:restore202 std %l0, [%g4 + 0] 203 std %l2, [%g4 + 8] 204 std %l4, [%g4 + 16] 205 std %l6, [%g4 + 24] 206 std %i0, [%g4 + 32] 207 std %i2, [%g4 + 40] 208 std %i4, [%g4 + 48] 209 std %i6, [%g4 + 56] 210 add %g4, 64, %g4 211 212 2: /* back to where we should be */ 213 mov %g5, %l5 214 mov %g6, %l6 215 mov %g7, %l7 216 restore 95 217 96 218 /* set new value of window */ … … 120 242 beq 1f 121 243 nop 244 245 /* Save invalid window data */ 246 mov %l5, %g5 ! kernel stack pointer 247 mov %l6, %g6 ! kernel wbuf 248 mov %l7, %g7 122 249 123 250 /* load registers from stack */ … … 151 278 st %g1, [%g2] 152 279 153 /* back to where we should be */ 154 2: save 280 2: /* back to where we should be */ 281 mov %g5, %l5 282 mov %g6, %l6 283 mov %g7, %l7 284 save 155 285 save 156 286 … … 164 294 165 295 preemptible_trap: 296 /* Check whether we landed in invalid window */ 297 get_wim_number %g6 298 get_cwp %g7 299 cmp %g6, %g7 300 bne 4f 301 nop 302 303 /* We are in invalid window. Check whether previous mode was usermode */ 304 if_from_kernel 3f 305 306 /* Kernel stack pointer is at %l5, uwb is at %l6 */ 307 inline_save_uspace %l6 308 3: inline_save_kernel 309 310 4: /* Check whether previous mode was usermode */ 311 if_from_kernel 5f 312 313 /* Load kernel stack pointer from invalid window */ 314 switch_to_invalid %g5, %g6 315 mov %l5, %g7 ! stack pointer 316 switch_back %g5, %g6 317 mov %g7, %sp 318 mov %sp, %fp 319 5: sub %sp, 112, %sp 320 321 /* Save trap data on stack */ 322 mov %psr, %l0 323 st %l1, [%fp - 4] 324 st %l2, [%fp - 8] 325 st %l0, [%fp - 12] 326 327 /* Enable traps */ 328 mov %psr, %l0 329 or %l0, (1 << 5), %l0 330 mov %l0, %psr 331 nop 332 nop 333 nop 334 nop 335 336 /* Jump to actual subroutine */ 337 call %o2 338 sub %fp, 12, %o1 339 340 /* Return from handler */ 341 ld [%fp - 4], %l1 342 ld [%fp - 8], %l2 343 ld [%fp - 12], %l0 344 mov %l0, %psr 345 nop 346 nop 347 nop 348 nop 349 nop 350 jmp %l1 351 rett %l2 352 353 interrupt_trap: 166 354 mov %psr, %l0 167 355 … … 195 383 /* Jump to actual subroutine */ 196 384 mov %g2, %o0 197 call %g1385 call exc_dispatch 198 386 sub %fp, 12, %o1 199 387 … … 268 456 #define TRAP(_vector, _handler) \ 269 457 .org trap_table + _vector * TRAP_ENTRY_SIZE; \ 270 set _vector, % g2; \271 sethi %hi(_handler), % g1; \458 set _vector, %o0 ; \ 459 sethi %hi(_handler), %o2 ; \ 272 460 b preemptible_trap ; \ 273 or % g1, %lo(_handler), %g1;461 or %o2, %lo(_handler), %o2 ; 274 462 275 463 #define SYSCALL(_vector) \ … … 283 471 mov %psr, %l0 ; \ 284 472 mov _priority, %g2 ; \ 285 call exc_dispatch; \473 b interrupt_trap ; \ 286 474 nop ; 287 475 … … 292 480 .align TRAP_TABLE_SIZE 293 481 trap_table: 294 TRAP(0x0, reset_trap)482 STRAP(0x0, reset_trap) 295 483 TRAP(0x1, instruction_access_exception) 296 484 TRAP(0x2, illegal_instruction)
Note:
See TracChangeset
for help on using the changeset viewer.