1 #include <exec/tasks.h>
3 #include <proto/exec.h>
7 #include <aros/debug.h>
10 #define STACK_SIZE 32768
13 #define StackSwapArgs PPCStackSwapArgs
14 #define NewStackSwap NewPPCStackSwap
17 struct StackSwapStruct sss
;
19 int __nocommandline
= 1;
21 void PrintSSS(struct StackSwapStruct
*ss
)
23 print("StackSwapStruct contents:\n");
24 print("Lower: 0x%P, Upper: 0x%P, SP: 0x%P\n", ss
->stk_Lower
, ss
->stk_Upper
, ss
->stk_Pointer
);
27 void PrintTaskStack(void)
29 struct Task
*t
= FindTask(NULL
);
31 print("Current program stack:\n");
32 print("Lower: 0x%P, Upper: 0x%P, SP: 0x%P\n", t
->tc_SPLower
, t
->tc_SPUpper
, t
->tc_SPReg
);
35 void Sub(IPTR a1
, IPTR a2
)
37 print("Stack swap done\n");
40 print("Arguments: %08lX, %08lX\n", a1
, a2
);
41 print("Coming back to original stack...\n");
46 struct StackSwapArgs args
;
48 sss
.stk_Lower
= AllocMem(STACK_SIZE
, MEMF_ANY
);
51 print("Failed to allocate new stack!\n");
56 sss
.stk_Upper
= sss
.stk_Lower
+ STACK_SIZE
;
57 sss
.stk_Pointer
= sss
.stk_Upper
;
61 print("Checking StackSwap()...\n");
64 Sub(0x12345678, 0xC001C0DE);
67 print("Came back from StackSwap()\n");
71 print("Checking NewStackSwap()...\n");
72 args
.Args
[0] = 0x1234ABCD;
73 args
.Args
[1] = 0xC0DEC001;
75 NewStackSwap(&sss
, Sub
, &args
);
76 print("Came back from NewStackSwap()\n");
80 FreeMem(sss
.stk_Lower
, STACK_SIZE
);