976a366e52dfccacd1e9ea1af5c4d07a8d1622d7
[AROS.git] / arch / ppc-sam440 / exec / supervisor.c
blob976a366e52dfccacd1e9ea1af5c4d07a8d1622d7
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Supervisor() - Execute some code in a privileged environment.
6 Lang: english
7 */
9 /*****************************************************************************
11 NAME */
12 #include <proto/exec.h>
13 #include <asm/amcc440.h>
15 AROS_LH1(ULONG, Supervisor,
17 /* SYNOPSIS */
18 AROS_LHA(ULONG_FUNC, userFunction, A5),
20 /* LOCATION */
21 struct ExecBase *, SysBase, 5, Exec)
23 /* FUNCTION
24 Supervisor will allow a short privileged instruction sequence to
25 be called from user mode. This has very few uses, and it is probably
26 better to use any system supplied method to do anything.
28 The function supplied will be called as if it was a system interrupt,
29 notably this means that you must *NOT* make any system calls or
30 use any system data structures, and on certain systems you must
31 use special methods to leave the code.
33 The code will not be passed any parameters.
35 INPUTS
36 userFunc - The address of the code you want called in supervisor
37 mode.
39 RESULT
40 The code will be called.
42 NOTES
43 This function has completely different effects on different
44 processors and architectures.
46 Currently defined effects are:
48 Kernel Effect
49 -------------------------------------------------------------------
50 i386 (under emulation) None
51 m68k (native) Runs the process in supervisor mode.
52 The process must end with an RTE
53 instruction. It should save any
54 registers which is uses.
55 m68k (under emulation)
57 EXAMPLE
59 BUGS
60 You can very easily make the system unusable with this function.
61 In fact it is recommended that you do not use it at all.
63 SEE ALSO
64 SuperState(), UserState()
66 INTERNALS
67 You can do what you want with this function, even ignoring it if
68 you don't think it makes any sense. But it could be quite useful
69 to make it run something under different protection levels.
71 You should trust that the programmer know what they are doing :-)
73 ******************************************************************************/
75 AROS_LIBFUNC_INIT
77 register ULONG retval;
78 register APTR stack;
80 stack = SuperState();
82 retval = (*userFunction)();
84 UserState(stack);
86 return retval;
88 AROS_LIBFUNC_EXIT
89 } /* Supervisor() */