Removed autodocs of arch specific variants of ROM modules.
[AROS.git] / arch / ppc-all / exec / newstackswap.c
blob2fd698cdd20789579912e4e3c651e539f8bd0771
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: NewStackSwap() - Call a function with swapped stack.
6 Lang: english
7 */
9 #define __AROS_GIMME_DEPRECATED_STACKSWAP__
11 #include <aros/debug.h>
12 #include <exec/tasks.h>
13 #include <proto/exec.h>
15 /* See rom/exec/newstackswap.c for documentation */
17 AROS_LH3(IPTR, NewStackSwap,
18 AROS_LHA(struct StackSwapStruct *, sss, A0),
19 AROS_LHA(LONG_FUNC, entry, A1),
20 AROS_LHA(struct StackSwapArgs *, args, A2),
21 struct ExecBase *, SysBase, 134, Exec)
23 AROS_LIBFUNC_INIT
25 ULONG * retptr;
26 ULONG ret;
27 register ULONG real_sp asm("r1");
28 ULONG *sp;
29 ULONG *src;
30 ULONG *dst;
32 /* Get the real stack pointer */
33 asm volatile ("mr %0,%1":"=r"(sp):"r"(real_sp));
35 /* Go one stack frame upper - now src points to the stackframe of caller */
36 src = (ULONG*)*sp;
38 /* Go one more stack frame up. Now you may copy from src to dst (src - sp) IPTR's */
39 src = (ULONG*)*src;
41 dst = (ULONG*)((IPTR)sss->stk_Upper - SP_OFFSET);
43 /* Copy the two stack frames */
44 while (src != sp)
46 *--dst = *--src;
49 sss->stk_Pointer = dst;
51 retptr = &ret;
53 D(bug("In NewStackSwap() entry=%lx, *entry=%lx\n", (IPTR)entry, (IPTR)*entry));
54 D(bug("[sss] %08x %08x %08x\n", sss->stk_Lower, sss->stk_Pointer, sss->stk_Upper));
56 StackSwap(sss);
58 D(bug("[sss] %08x %08x %08x\n", sss->stk_Lower, sss->stk_Pointer, sss->stk_Upper));
60 /* Call the function with the new stack */
61 *retptr = entry(args->Args[0], args->Args[1], args->Args[2], args->Args[3],
62 args->Args[4], args->Args[5], args->Args[6], args->Args[7]);
64 StackSwap(sss);
66 return ret;
68 AROS_LIBFUNC_EXIT
69 } /* NewStackSwap() */