oops - mmakefile changes had been reverted, so reinstate them.
[AROS.git] / test / exec / supertest.c
blob99237cbcdec638f61066d6fa510f7d77e519a724
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <exec/types.h>
8 #include <proto/exec.h>
9 #include <proto/dos.h>
10 #include <proto/kernel.h>
12 extern IPTR a(void);
13 extern IPTR b(void);
15 #ifdef __GNUC__
16 #ifdef __mc68000
17 #define HAVE_ASM_CODE
18 asm(
19 " .text\n"
20 " .balign 2\n"
21 " .globl a\n"
22 "a:\n"
23 " movew %sr,%d0\n"
24 " rts\n"
25 " .globl b\n"
26 "b:\n"
27 " movew %sp@,%d0\n"
28 " rte\n"
30 #endif
31 #ifdef __i386__
32 #define HAVE_ASM_CODE
33 __asm__(
34 " .globl a\n"
35 "a:\n"
36 " pushf\n"
37 " popl %eax\n"
38 " ret\n"
39 " .globl b\n"
40 "b:\n"
41 " movl %esp,%eax\n"
42 " iret\n"
44 #endif
45 #ifdef __x86_64__
46 #define HAVE_ASM_CODE
47 __asm__(
48 " .globl a\n"
49 "a:\n"
50 " pushf\n"
51 " popq %rax\n"
52 " ret\n"
53 " .globl b\n"
54 "b:\n"
55 " movq %rsp, %rax\n"
56 " iretq\n"
58 #endif
59 #endif
61 int __nocommandline = 1;
63 int main(void)
65 APTR KernelBase = OpenResource("kernel.resource");
66 struct Task *me = FindTask(NULL);
67 APTR ssp;
69 Printf("GetCC() : %04lx\n",GetCC());
70 Printf("SetSR() : %08lx\n",SetSR(0,0));
72 if (KernelBase)
73 Printf("KrnIsSuper() : %d\n", KrnIsSuper());
75 Printf("Task stack : 0x%p - 0x%p\n", me->tc_SPLower, me->tc_SPUpper);
76 Printf("Supervisor stack : 0x%p - 0x%p\n", SysBase->SysStkLower, SysBase->SysStkUpper);
78 ssp = SuperState();
79 if (ssp)
81 bug("Entered SuperState...\n");
83 int issuper = 0;
84 #ifdef HAVE_ASM_CODE
85 IPTR ar = a();
86 #endif
88 if (KernelBase)
89 issuper = KrnIsSuper();
91 bug("Leaving SuperState...\n");
92 UserState(ssp);
94 if (KernelBase)
95 Printf("Supervisor mode test: %d\n", issuper);
97 Printf("Saved stack : 0x%p\n", ssp);
98 #ifdef HAVE_ASM_CODE
99 Printf("Supervisor flags : 0x%p\n", ar);
100 #endif
102 else
103 Printf("!!! SuperState() failed to enter supervisor mode (returned NULL) !!!\n");
105 #ifdef HAVE_ASM_CODE
106 Printf("User flags : 0x%p\n", a());
107 Printf("Supervisor stack : 0x%p\n", Supervisor(b));
108 #endif
110 return 0;