4
#define ASI_BP ASI_M_BYPASS
7
.globl __switch_context, __switch_context_nosave, __exit_context, halt
11
.register %g2, #scratch
12
.register %g3, #scratch
13
.register %g6, #scratch
14
.register %g7, #scratch
17
* Switch execution context
18
* This saves registers in the stack, then
19
* switches the stack, and restores everything from the new stack.
20
* This function takes no argument. New stack pointer is
21
* taken from global variable __context, and old stack pointer
22
* is also saved to __context. This way we can just jump to
23
* this routine to get back to the original context.
27
/* make sure caller's windows are on caller's stack */
30
/* Save everything in current stack */
31
stx %g1, [%sp + 2047 - 0x500 + 0x30]
32
stx %g2, [%sp + 2047 - 0x500 + 0x38]
33
stx %g3, [%sp + 2047 - 0x500 + 0x40]
34
stx %g4, [%sp + 2047 - 0x500 + 0x48]
35
stx %g5, [%sp + 2047 - 0x500 + 0x50]
36
stx %g6, [%sp + 2047 - 0x500 + 0x58]
37
stx %g7, [%sp + 2047 - 0x500 + 0x60]
40
add %g1, 2047 - 0x500, %g1
45
stx %g2, [%g1 + 0x4d0]
47
SAVE_CPU_STATE(switch)
50
setx __context, %g2, %g3
57
__switch_context_nosave:
58
/* Interrupts are not allowed... */
59
/* make sure caller's windows are on caller's stack */
63
setx __context, %g2, %g1
67
RESTORE_CPU_STATE(switch)
72
stx %g2, [%sp + 2047 - 8]
81
/* Finally, load new %pc */
82
ldx [%g1 + 0x4d0], %g1
84
ldx [%sp + 2047 - 8], %g1
87
/* Get back to the original context */