4 #define ASI_BP ASI_M_BYPASS
7 .globl __switch_context, __switch_context_nosave, __exit_context, halt
12 #define STACKFRAME_SZ 0x60
14 /* These are just handy. */
15 #define _SV save %sp, -STACKFRAME_SZ, %sp
18 #define FLUSH_ALL_KERNEL_WINDOWS \
19 _SV; _SV; _SV; _SV; _SV; _SV; _SV; \
20 _RS; _RS; _RS; _RS; _RS; _RS; _RS;
23 * Switch execution context
24 * This saves registers in the stack, then
25 * switches the stack, and restores everything from the new stack.
26 * This function takes no argument. New stack pointer is
27 * taken from global variable __context, and old stack pointer
28 * is also saved to __context. This way we can just jump to
29 * this routine to get back to the original context.
33 FLUSH_ALL_KERNEL_WINDOWS
34 /* Save everything in stack */
35 st %fp, [%fp + 120 -144]
71 /* ctx->return_address: Return to caller */
74 /* Interrupts are not allowed... */
76 /* Turn on Supervisor, EnableFloating, and all the PIL bits.
77 * Also puts us in register window zero with traps off.
80 set (PSR_PS | PSR_S | PSR_PIL | PSR_EF), %g2
84 /* Swap ctx pointer with %fp and jump*/
87 __switch_context_nosave:
89 /* load %fp from ctx pointer */
92 /* Load all registers */
93 /* offset 0: %g0, no need to load */
102 /* offset 32: %o0, loaded from ctx->param */
109 /* offset 60: %o7, loaded from ctx->return_addr */
128 /* ctx->return_addr */
134 /* ctx->pc, save %g1 to %y and load to %g1 */
139 /* Finally, get the new %pc from %g1 and restore %g1*/
143 FLUSH_ALL_KERNEL_WINDOWS
145 /* Get back to the original context */
146 call __switch_context
149 /* We get here if the other context attempt to switch to this
150 * dead context. This should not happen. */