f0c7984f3904e49cfded4efd00df8455f29f8158
[AROS.git] / arch / arm-raspi / exec / superstate.c
blobf0c7984f3904e49cfded4efd00df8455f29f8158
1 /*
2 Copyright © 2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: SuperState() - Switch the processor into a higher plane.
6 Lang: english
7 */
9 /*****************************************************************************
11 NAME */
12 #include <proto/exec.h>
14 AROS_LH0(APTR, SuperState,
16 /* LOCATION */
17 struct ExecBase *, SysBase, 25, Exec)
19 /* FUNCTION
20 Enter supervisor mode (like Supervisor()), but return on the user
21 stack. This will mean that the user stack variables are still there.
22 A call to UserState() will end this mode.
24 INPUTS
25 None.
27 RESULT
28 The old supervisor stack. This must be passed to UserState(). If the
29 processor was already in supervisor mode, then this function will
30 return NULL. In that case do NOT call UserState().
32 NOTES
33 This is not a good function to use, it has limited scope, and will
34 probably be even less useful in the future.
36 EXAMPLE
38 BUGS
39 You can easily cause your system to cease operating normally.
41 SEE ALSO
42 Supervisor(), UserState()
44 INTERNALS
45 For extra details see Supervisor().
47 ******************************************************************************/
49 AROS_LIBFUNC_INIT
51 register unsigned int superSP;
53 asm volatile (
54 " stmfd sp!, {lr} \n"
55 " mov r1, sp \n"
56 " swi %[swi_no] \n"
57 " mov %[superSP], sp \n"
58 " mov sp, r1 \n"
59 " ldmfd sp!, {lr} \n"
60 : [superSP] "=r" (superSP)
61 : [swi_no] "I" (6 /*SC_SUPERSTATE*/) : "r1"
64 return superSP;
66 AROS_LIBFUNC_EXIT
67 } /* SuperState() */