revert between 56095 -> 55830 in arch
[AROS.git] / rom / exec / superstate.c
blobe341b148f59ab2ec7c5389f8bf389ac3cb35a2a0
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: SuperState() - Switch the processor into a higher plane.
6 Lang: english
7 */
9 #include <aros/config.h>
10 #include <aros/debug.h>
12 #include "exec_intern.h"
14 /*****************************************************************************
16 NAME */
17 #include <proto/exec.h>
19 AROS_LH0(APTR, SuperState,
21 /* LOCATION */
22 struct ExecBase *, SysBase, 25, Exec)
24 /* FUNCTION
25 Enter supervisor mode (like Supervisor()), but return on the user
26 stack. This will mean that the user stack variables are still there.
27 A call to UserState() will end this mode.
29 INPUTS
30 None.
32 RESULT
33 The old supervisor stack. This must be passed to UserState(). If the
34 processor was already in supervisor mode, then this function will
35 return NULL. In that case do NOT call UserState().
37 NOTES
38 This is not a good function to use, it has limited scope, and will
39 probably be even less useful in the future.
41 EXAMPLE
43 BUGS
44 You can easily cause your system to cease operating normally.
46 SEE ALSO
47 Supervisor(), UserState()
49 INTERNALS
50 For extra details see Supervisor().
52 ******************************************************************************/
54 AROS_LIBFUNC_INIT
56 #if (AROS_FLAVOUR & AROS_FLAVOUR_STANDALONE)
58 * This part works only on native AROS.
59 * Hosted ports are running in a virtual machine with only single privilege
60 * level available, so this function will simply return NULL.
61 * cpu_SuperState() is an architecture-specific helper code written in asm.
64 int super = KrnIsSuper();
66 D(bug("[SuperState] Current supervisor mode: %d\n", super));
68 if (!super)
70 APTR ssp = (APTR)Supervisor(cpu_SuperState);
72 D(bug("[SuperState] Saved SP 0x%p\n", ssp));
73 return ssp;
75 #endif
77 return NULL;
79 AROS_LIBFUNC_EXIT
80 } /* SuperState() */