Rev 3798 | Rev 3863 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3798 | Rev 3801 | ||
---|---|---|---|
Line 447... | Line 447... | ||
447 | 447 | ||
448 | 448 | ||
449 | /* |
449 | /* |
450 | * Spills the window at CWP + 2 to the kernel stack. This macro is to be |
450 | * Spills the window at CWP + 2 to the kernel stack. This macro is to be |
451 | * used before doing SAVE when the spill trap is undesirable. |
451 | * used before doing SAVE when the spill trap is undesirable. |
- | 452 | * |
|
- | 453 | * Parameters: |
|
- | 454 | * tmpreg1 global register to be used for scratching purposes |
|
- | 455 | * tmpreg2 global register to be used for scratching purposes |
|
452 | */ |
456 | */ |
453 | .macro INLINE_SPILL |
457 | .macro INLINE_SPILL tmpreg1, tmpreg2 |
454 | ! CWP := CWP + 2 |
458 | ! CWP := CWP + 2 |
455 | rdpr %cwp, %g3 |
459 | rdpr %cwp, \tmpreg2 |
456 | add %g3, 2, %g3 |
460 | add \tmpreg2, 2, \tmpreg1 |
457 | and %g3, NWINDOWS - 1, %g3 ! modulo NWINDOWS |
461 | and \tmpreg1, NWINDOWS - 1, \tmpreg1 ! modulo NWINDOWS |
458 | wrpr %g3, %cwp |
462 | wrpr \tmpreg1, %cwp |
459 | 463 | ||
460 | ! spill to kernel stack |
464 | ! spill to kernel stack |
461 | stx %l0, [%sp + STACK_BIAS + L0_OFFSET] |
465 | stx %l0, [%sp + STACK_BIAS + L0_OFFSET] |
462 | stx %l1, [%sp + STACK_BIAS + L1_OFFSET] |
466 | stx %l1, [%sp + STACK_BIAS + L1_OFFSET] |
463 | stx %l2, [%sp + STACK_BIAS + L2_OFFSET] |
467 | stx %l2, [%sp + STACK_BIAS + L2_OFFSET] |
Line 474... | Line 478... | ||
474 | stx %i5, [%sp + STACK_BIAS + I5_OFFSET] |
478 | stx %i5, [%sp + STACK_BIAS + I5_OFFSET] |
475 | stx %i6, [%sp + STACK_BIAS + I6_OFFSET] |
479 | stx %i6, [%sp + STACK_BIAS + I6_OFFSET] |
476 | stx %i7, [%sp + STACK_BIAS + I7_OFFSET] |
480 | stx %i7, [%sp + STACK_BIAS + I7_OFFSET] |
477 | 481 | ||
478 | ! CWP := CWP - 2 |
482 | ! CWP := CWP - 2 |
479 | add %g3, NWINDOWS - 2, %g3 |
- | |
480 | and %g3, NWINDOWS - 1, %g3 ! modulo NWINDOWS |
- | |
481 | wrpr %g3, %cwp |
483 | wrpr \tmpreg2, %cwp |
482 | 484 | ||
483 | saved |
485 | saved |
484 | .endm |
486 | .endm |
485 | 487 | ||
486 | /* |
488 | /* |
487 | * Fill the window at CWP - 1 from the kernel stack. This macro is to be |
489 | * Fill the window at CWP - 1 from the kernel stack. This macro is to be |
488 | * used before doing RESTORE when the fill trap is undesirable. |
490 | * used before doing RESTORE when the fill trap is undesirable. |
- | 491 | * |
|
- | 492 | * Parameters: |
|
- | 493 | * tmpreg1 global register to be used for scratching purposes |
|
- | 494 | * tmpreg2 global register to be used for scratching purposes |
|
489 | */ |
495 | */ |
490 | .macro INLINE_FILL |
496 | .macro INLINE_FILL tmpreg1, tmpreg2 |
491 | ! CWP := CWP - 1 |
497 | ! CWP := CWP - 1 |
492 | rdpr %cwp, %g3 |
498 | rdpr %cwp, \tmpreg2 |
493 | add %g3, NWINDOWS - 1, %g3 |
499 | add \tmpreg2, NWINDOWS - 1, \tmpreg1 |
494 | and %g3, NWINDOWS - 1, %g3 |
500 | and \tmpreg1, NWINDOWS - 1, \tmpreg1 |
495 | wrpr %g3, %cwp |
501 | wrpr \tmpreg1, %cwp |
496 | 502 | ||
497 | ! fill |
503 | ! fill from kernel stack |
498 | ldx [%sp + STACK_BIAS + L0_OFFSET], %l0 |
504 | ldx [%sp + STACK_BIAS + L0_OFFSET], %l0 |
499 | ldx [%sp + STACK_BIAS + L1_OFFSET], %l1 |
505 | ldx [%sp + STACK_BIAS + L1_OFFSET], %l1 |
500 | ldx [%sp + STACK_BIAS + L2_OFFSET], %l2 |
506 | ldx [%sp + STACK_BIAS + L2_OFFSET], %l2 |
501 | ldx [%sp + STACK_BIAS + L3_OFFSET], %l3 |
507 | ldx [%sp + STACK_BIAS + L3_OFFSET], %l3 |
502 | ldx [%sp + STACK_BIAS + L4_OFFSET], %l4 |
508 | ldx [%sp + STACK_BIAS + L4_OFFSET], %l4 |
Line 511... | Line 517... | ||
511 | ldx [%sp + STACK_BIAS + I5_OFFSET], %i5 |
517 | ldx [%sp + STACK_BIAS + I5_OFFSET], %i5 |
512 | ldx [%sp + STACK_BIAS + I6_OFFSET], %i6 |
518 | ldx [%sp + STACK_BIAS + I6_OFFSET], %i6 |
513 | ldx [%sp + STACK_BIAS + I7_OFFSET], %i7 |
519 | ldx [%sp + STACK_BIAS + I7_OFFSET], %i7 |
514 | 520 | ||
515 | ! CWP := CWP + 1 |
521 | ! CWP := CWP + 1 |
516 | add %g3, 1, %g3 |
- | |
517 | and %g3, NWINDOWS - 1, %g3 |
- | |
518 | wrpr %g3, %cwp |
522 | wrpr \tmpreg2, %cwp |
519 | 523 | ||
520 | restored |
524 | restored |
521 | .endm |
525 | .endm |
522 | 526 | ||
523 | /* |
527 | /* |
Line 538... | Line 542... | ||
538 | /* prevent unnecessary CLEANWIN exceptions */ |
542 | /* prevent unnecessary CLEANWIN exceptions */ |
539 | wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(0), %wstate |
543 | wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(0), %wstate |
540 | 1: |
544 | 1: |
541 | /* |
545 | /* |
542 | * Prevent SAVE instruction from causing a spill exception. If the |
546 | * Prevent SAVE instruction from causing a spill exception. If the |
543 | * CANSAVE register is zero, explicitly spill the current register |
547 | * CANSAVE register is zero, explicitly spill register window |
544 | * window. |
548 | * at CWP + 2. |
545 | */ |
549 | */ |
546 | 550 | ||
547 | rdpr %cansave, %g3 |
551 | rdpr %cansave, %g3 |
548 | brnz %g3, 2f |
552 | brnz %g3, 2f |
549 | nop |
553 | nop |
550 | INLINE_SPILL |
554 | INLINE_SPILL %g3, %g4 |
551 | 555 | ||
552 | 2: |
556 | 2: |
553 | /* ask for new register window */ |
557 | /* ask for new register window */ |
554 | save %sp, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp |
558 | save %sp, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp |
555 | 559 | ||
Line 578... | Line 582... | ||
578 | rd %y, %g4 |
582 | rd %y, %g4 |
579 | stx %g4, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_Y] |
583 | stx %g4, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_Y] |
580 | 584 | ||
581 | /* switch to TL = 0, explicitly enable FPU */ |
585 | /* switch to TL = 0, explicitly enable FPU */ |
582 | wrpr %g0, 0, %tl |
586 | wrpr %g0, 0, %tl |
- | 587 | wrpr %g0, 0, %gl |
|
583 | wrpr %g0, PSTATE_PRIV_BIT | PSTATE_PEF_BIT, %pstate |
588 | wrpr %g0, PSTATE_PRIV_BIT | PSTATE_PEF_BIT, %pstate |
584 | 589 | ||
585 | /* g1 -> l1, ..., g7 -> l7 */ |
590 | /* g1 -> l1, ..., g7 -> l7 */ |
586 | SAVE_GLOBALS |
591 | SAVE_GLOBALS |
587 | 592 | ||
Line 659... | Line 664... | ||
659 | ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I6], %i6 |
664 | ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I6], %i6 |
660 | ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I7], %i7 |
665 | ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I7], %i7 |
661 | 666 | ||
662 | 4: |
667 | 4: |
663 | /* |
668 | /* |
664 | * Prevent RESTORE instruction from causing a spill exception. If the |
669 | * Prevent RESTORE instruction from causing a fill exception. If the |
665 | * CANRESTORE register is zero, explicitly spill the current register |
670 | * CANRESTORE register is zero, explicitly fill register window |
666 | * window. |
671 | * at CWP - 1. |
667 | */ |
672 | */ |
668 | rdpr %canrestore, %g1 |
673 | rdpr %canrestore, %g1 |
669 | brnz %g1, 5f |
674 | brnz %g1, 5f |
670 | nop |
675 | nop |
671 | INLINE_FILL |
676 | INLINE_FILL %g3, %g4 |
672 | 677 | ||
673 | 5: |
678 | 5: |
674 | restore |
679 | restore |
675 | 680 | ||
676 | retry |
681 | retry |