2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
6 /*****************************************************************************
10 AROS_LH0(ULONG, SuperState,
13 struct ExecBase *, SysBase, 25, Exec)
16 Enter supervisor mode (like Supervisor()), but return on the user
17 stack. This will mean that the user stack variables are still there.
18 A call to UserState() will end this mode.
24 The old supervisor stack. This must be passed to UserState(). If the
25 processor was already in supervisor mode, then this function will
26 return NULL. In that case do NOT call UserState().
29 This is not a good function to use, it has limited scope, and will
30 probably be even less useful in the future.
35 You can easily cause your system to cease operating normally.
38 Supervisor(), UserState()
41 For extra details see Supervisor().
45 ******************************************************************************/
47 #include "aros/m68k/asm.h"
51 .globl AROS_SLIB_ENTRY(SuperState,Exec)
53 AROS_SLIB_ENTRY(SuperState,Exec):
55 move.l $4,%a6 // Get SysBase
57 movem.l %d0/%d1,-(%sp)
60 jmp SetSR(%a6) // %d0 will contain current state
62 and.w 0x2000,%d0 // this should test the user or superstate
65 movem.l (%sp)+,%d0/%d1 // already in superstate
69 go_on: movem.l (%sp)+,%d0/%d1 // switch to superstate
72 move.l #12,%d7 // #12 => call _sys_trap1_SuperState
74 move.l (%sp)+,%d7 // should never get here!!!
78 .globl _sys_trap1_SuperState
79 _sys_trap1_SuperState:
81 * This is how the supervisor stack looks like...
83 * 2(%ssp) PC (LONG) - contains address of instruction after
86 * And this is how the user stack looks like
87 * 0(%usp) PC (LONG) - instruction after from where the SuperState()
92 move.l %a0,-4(%sp) // save %a0 on -4(SSP)
94 move.l %a0,%ssp // load ssp with usp
96 move.l 4(%ssp),%d7 // restore d7
97 move.l (%ssp),%a0 // move the return PC to where D7 was
99 move.l %d0,%a0 // %a0 = initial ssp
100 move.l -4(%a0),%a0 // restore %a0
101 adda.l #4,%ssp // now (%ssp) is the return PC