Changeset a218709 in mainline for kernel/arch/sparc32/src/trap_table.S
- Timestamp:
- 2013-12-02T23:45:45Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2955bb9
- Parents:
- 3bc42bd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc32/src/trap_table.S
r3bc42bd ra218709 28 28 29 29 #include <arch/trap.h> 30 #include <arch/regwin.h> 30 31 31 32 .text … … 39 40 .global window_underflow_trap 40 41 .global write_to_invalid 42 .global read_from_invalid 43 .global flush_windows 41 44 42 45 .macro get_wim_number reg … … 231 234 nop 232 235 236 read_from_invalid: 237 ! Read value 1 238 mov %o0, %g7 239 switch_to_invalid %g3, %g4 240 st %l5, [%g7] 241 switch_back %g3, %g4 242 ! Write value 2 243 mov %o1, %g7 244 switch_to_invalid %g3, %g4 245 st %l6, [%g7] 246 switch_back %g3, %g4 247 ! Write value 3 248 mov %o2, %g7 249 switch_to_invalid %g3, %g4 250 st %l7, [%g7] 251 switch_back %g3, %g4 252 retl 253 nop 254 233 255 reset_trap: 234 256 set 0x80000100, %l0 … … 240 262 mov %g7, %l0 241 263 242 /* rotate WIM on bit right, we have 8 windows */ 264 /* Check whether previous mode was usermode */ 265 mov %psr, %l4 266 and %l4, (1 << 6), %l4 267 cmp %l4, 0 268 bne 1f 269 nop 270 271 /* userspace: */ 272 /* time to check whether desired stack page is mapped 273 * on the MMU. if so, process with saving window directly. 274 * if not, go to preemptible trap handler */ 275 mov %wim, %g5 276 mov %g0, %wim 277 save 278 mov %sp, %g4 279 restore 280 mov %g5, %wim 281 and %g4, 0xfffff000, %l4 282 lda [%l4] 0x18, %l4 283 cmp %l4, 0 284 bne 1f 285 nop 286 287 /* prepare args for preemptible handler */ 288 mov %g4, %o0 289 set preemptible_save_uspace, %o2 290 b preemptible_trap 291 nop 292 293 /* kernel: */ 294 1: /* rotate WIM on bit right, we have 8 windows */ 243 295 mov %wim, %l3 244 296 sll %l3, 7, %l4 … … 256 308 mov %l7, %g7 257 309 258 /* Check whether previous mode was usermode */ 259 mov %psr, %l4 260 and %l4, (1 << 6), %l4 261 cmp %l4, 0 262 beq 1f 263 nop 264 265 /* kernel: */ 310 266 311 /* we should check whether window needs to be saved 267 312 * to kernel stack or uwb … … 284 329 nop 285 330 286 1: /* uspace: */ 287 /* set uspace window mark */ 288 mov %psr, %g7 289 and %g7, 0x7, %g7 290 or %g7, 0x10, %g7 291 331 /* dump registers to uwb */ 292 332 2: save 293 333 std %l0, [%g6 + 0] … … 330 370 mov %g7, %l0 331 371 372 /* Check whether previous mode was usermode */ 373 mov %psr, %l4 374 and %l4, (1 << 6), %l4 375 cmp %l4, 0 376 bne 1f 377 nop 378 379 /* userspace: */ 380 /* time to check whether desired stack page is mapped 381 * on the MMU. if so, process with saving window directly. 382 * if not, go to preemptible trap handler */ 383 mov %wim, %g5 384 mov %g0, %wim 385 restore 386 restore 387 mov %sp, %g4 388 save 389 save 390 mov %g5, %wim 391 and %sp, 0xfffff000, %l4 392 lda [%l4] 0x18, %l4 393 cmp %l4, 0 394 bne 1f 395 nop 396 397 /* prepare args for preemptible handler */ 398 mov %g4, %o0 399 set preemptible_restore_uspace, %o2 400 b preemptible_trap 401 nop 402 332 403 /* rotate WIM on bit LEFT, we have 8 windows */ 333 404 1: mov %wim,%l3 334 405 srl %l3,7,%l4 335 406 sll %l3,1,%l3 … … 341 412 nop; nop; nop 342 413 343 /* Check whether previous mode was usermode */ 344 mov %psr, %l4 345 and %l4, (1 << 6), %l4 346 cmp %l4, 0 347 beq 1f 348 nop 349 414 /* kernel: */ 350 415 restore 351 416 restore … … 365 430 nop 366 431 367 1: restore368 restore369 mov %l5, %g5 ! kernel stack pointer370 mov %l6, %g6 ! kernel wbuf371 mov %l7, %g7372 sub %g6, 64, %g6373 ldd [%g6 + 0], %l0374 ldd [%g6 + 8], %l2375 ldd [%g6 + 16], %l4376 ldd [%g6 + 24], %l6377 ldd [%g6 + 32], %i0378 ldd [%g6 + 40], %i2379 ldd [%g6 + 48], %i4380 ldd [%g6 + 56], %i6381 382 432 2: /* Restore invalid window data */ 383 433 restore … … 397 447 jmp %l1 398 448 rett %l2 449 450 flush_windows: 451 mov 7, %g1 452 1: subcc %g1, 1, %g1 453 bg 1b 454 save %sp, -64, %sp 455 456 mov 7, %g1 457 1: subcc %g1, 1, %g1 458 bg 1b 459 restore 460 461 retl 462 nop 399 463 400 464 preemptible_trap: … … 470 534 /* Jump to actual subroutine */ 471 535 call %o2 472 sub %fp, 12, %o1536 add %sp, 128, %o1 473 537 474 538 /* Return from handler */ … … 487 551 switch_to_invalid %g5, %g6 488 552 clr %l7 553 mov %l5, %g2 489 554 mov %l6, %g7 490 555 switch_back %g5, %g6 491 556 mov %g7, %g1 557 558 /* If trap originated from uspace, restore all windows from UWB */ 559 /* UWB pointer is at %g1 */ 560 0: mov %g0, %wim 561 clr %g5 562 andcc %g1, UWB_ALIGNMENT - 1, %g0 563 bz 0f 564 nop 565 566 restore 567 sub %g1, 64, %g1 568 ldd [%g1 + 0], %l0 569 ldd [%g1 + 8], %l2 570 ldd [%g1 + 16], %l4 571 ldd [%g1 + 24], %l6 572 ldd [%g1 + 32], %i0 573 ldd [%g1 + 40], %i2 574 ldd [%g1 + 48], %i4 575 ldd [%g1 + 56], %i6 576 inc %g5 577 and %g5, 0x7, %g5 578 ba 0b 579 nop 580 581 /* We've restored all uspace windows. Now time to 582 * fix CWP and WIM 583 */ 584 0: restore 585 get_cwp %g7 586 clr %g5 587 inc %g5 588 sll %g5, %g7, %g5 589 590 /* Write values to invalid window and switch back */ 591 mov %g2, %l5 592 mov %g1, %l6 593 clr %l7 594 switch_back %g5, %g6 492 595 493 596 /* If next window is invalid, do inline restore */ … … 679 782 ld [%sp + 100], %l0 680 783 mov %o0, %i0 784 mov %psr, %l1 785 and %l1, 0xf, %l1 786 and %l0, 0xfffffff0, %l0 787 or %l0, %l1, %l0 681 788 mov %l0, %psr 682 789 nop … … 690 797 switch_to_invalid %g5, %g6 691 798 clr %l7 799 mov %l5, %g2 692 800 mov %l6, %g7 693 801 switch_back %g5, %g6 694 802 mov %g7, %g1 803 804 /* If trap originated from uspace, restore all windows from UWB */ 805 /* UWB pointer is at %g1 */ 806 0: mov %g0, %wim 807 clr %g5 808 andcc %g1, UWB_ALIGNMENT - 1, %g0 809 bz 0f 810 nop 811 812 restore 813 sub %g1, 64, %g1 814 ldd [%g1 + 0], %l0 815 ldd [%g1 + 8], %l2 816 ldd [%g1 + 16], %l4 817 ldd [%g1 + 24], %l6 818 ldd [%g1 + 32], %i0 819 ldd [%g1 + 40], %i2 820 ldd [%g1 + 48], %i4 821 ldd [%g1 + 56], %i6 822 inc %g5 823 and %g5, 0x7, %g5 824 ba 0b 825 nop 826 827 /* We've restored all uspace windows. Now time to 828 * fix CWP and WIM 829 */ 830 0: restore 831 get_cwp %g7 832 clr %g5 833 inc %g5 834 sll %g5, %g7, %g5 835 836 /* Write values to invalid window and switch back */ 837 mov %g2, %l5 838 mov %g1, %l6 839 clr %l7 840 switch_back %g5, %g6 695 841 696 842 /* If next window is invalid, do inline restore */ … … 929 1075 SYSCALL(0xae) 930 1076 SYSCALL(0xaf) 1077 SYSCALL(0xb0) 1078 SYSCALL(0xb1) 1079 SYSCALL(0xb2) 1080 SYSCALL(0xb3) 1081 SYSCALL(0xb4) 1082 SYSCALL(0xb5) 1083 SYSCALL(0xb6) 1084 SYSCALL(0xb7) 1085 SYSCALL(0xb8) 1086 SYSCALL(0xb9) 1087 SYSCALL(0xba) 1088 SYSCALL(0xbb) 1089 SYSCALL(0xbc) 1090 SYSCALL(0xbd) 1091 SYSCALL(0xbe) 1092 SYSCALL(0xbf) 1093 SYSCALL(0xc0) 1094 SYSCALL(0xc1) 1095 SYSCALL(0xc2) 1096 SYSCALL(0xc3) 1097 SYSCALL(0xc4) 1098 SYSCALL(0xc5) 1099 SYSCALL(0xc6) 1100 SYSCALL(0xc7) 1101 SYSCALL(0xc8) 1102 SYSCALL(0xc9) 1103 SYSCALL(0xca) 1104 SYSCALL(0xcb) 1105 SYSCALL(0xcc) 1106 SYSCALL(0xcd) 1107 SYSCALL(0xce) 1108 SYSCALL(0xcf)
Note:
See TracChangeset
for help on using the changeset viewer.