2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: PrepareContext() - Prepare a task context for dispatch, ARM version.
9 #include <exec/execbase.h>
10 #include <exec/memory.h>
11 #include <utility/tagitem.h>
12 #include <proto/arossupport.h>
13 #include <proto/kernel.h>
14 #include <aros/arm/cpucontext.h>
16 #include "exec_intern.h"
17 #include "exec_util.h"
19 BOOL
PrepareContext(struct Task
*task
, APTR entryPoint
, APTR fallBack
,
20 const struct TagItem
*tagList
, struct ExecBase
*SysBase
)
23 struct ExceptionContext
*ctx
;
26 STACKULONG
*sp
= task
->tc_SPReg
;
28 if (!(task
->tc_Flags
& TF_ETASK
) )
31 ctx
= KrnCreateContext();
32 task
->tc_UnionETask
.tc_ETask
->et_RegFrame
= ctx
;
36 /* Set up function arguments */
37 while((t
= LibNextTagItem((struct TagItem
**)&tagList
)))
42 case TASKTAG_ARG ## x: \
43 ctx->r[x - 1] = t->ti_Data; \
47 case TASKTAG_ARG ## x: \
48 args[x - 5] = t->ti_Data; \
49 if (x - 4 > numargs) \
64 /* Last four arguments are put on stack */
66 *--sp
= args
[--numargs
];
70 /* Now prepare return address */
72 ctx
->lr
= (ULONG
)fallBack
;
76 /* Then set up the frame to be used by Dispatch() */
77 ctx
->sp
= (ULONG
)task
->tc_SPReg
;
78 ctx
->pc
= (ULONG
)entryPoint
;
81 } /* PrepareContext() */