d4f667660c7eaa9338b80443c28bec2c9d5b1547
[AROS.git] / arch / arm-raspi / kernel / issuper.c
blobd4f667660c7eaa9338b80443c28bec2c9d5b1547
1 /*
2 Copyright © 2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/kernel.h>
7 #include <aros/libcall.h>
9 #include <aros/arm/cpucontext.h>
11 #include <kernel_base.h>
13 /*****************************************************************************
15 NAME */
16 #include <proto/kernel.h>
18 AROS_LH0I(int, KrnIsSuper,
20 /* SYNOPSIS */
22 /* LOCATION */
23 struct KernelBase *, KernelBase, 13, Kernel)
25 /* FUNCTION
26 Determine if the caller is running in supervisor mode
28 INPUTS
29 None
31 RESULT
32 Nonzero for supervisor mode, zero for user mode
34 NOTES
35 Callers should only test the return value against zero.
36 Nonzero values may actually be different, since they
37 may carry some private implementation-dependent information
38 (like CPU privilege level, for example).
40 EXAMPLE
42 BUGS
44 SEE ALSO
46 INTERNALS
48 ******************************************************************************/
50 AROS_LIBFUNC_INIT
52 register unsigned int reg;
53 asm volatile("mrs %[reg], cpsr" : [reg] "=r" (reg) );
55 return !(((reg & CPUMODE_MASK) == CPUMODE_USER) || ((reg & CPUMODE_MASK) == CPUMODE_SYSTEM));
57 AROS_LIBFUNC_EXIT