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"
18 #if defined(__AROSEXEC_SMP__)
22 BOOL
PrepareContext(struct Task
*task
, APTR entryPoint
, APTR fallBack
,
23 const struct TagItem
*tagList
, struct ExecBase
*SysBase
)
26 struct ExceptionContext
*ctx
;
29 STACKULONG
*sp
= task
->tc_SPReg
;
31 if (!(task
->tc_Flags
& TF_ETASK
) )
34 ctx
= KrnCreateContext();
35 task
->tc_UnionETask
.tc_ETask
->et_RegFrame
= ctx
;
39 /* Set up function arguments */
40 while((t
= LibNextTagItem((struct TagItem
**)&tagList
)))
44 #if defined(__AROSEXEC_SMP__)
45 case TASKTAG_AFFINITY
:
46 IntETask(task
->tc_UnionETask
.tc_ETask
)->iet_CpuAffinity
= t
->ti_Data
;
50 case TASKTAG_ARG ## x: \
51 ctx->r[x - 1] = t->ti_Data; \
55 case TASKTAG_ARG ## x: \
56 args[x - 5] = t->ti_Data; \
57 if (x - 4 > numargs) \
72 /* Last four arguments are put on stack */
74 *--sp
= args
[--numargs
];
78 /* Now prepare return address */
80 ctx
->lr
= (ULONG
)fallBack
;
84 /* Then set up the frame to be used by Dispatch() */
85 ctx
->sp
= (ULONG
)task
->tc_SPReg
;
86 ctx
->pc
= (ULONG
)entryPoint
;
89 } /* PrepareContext() */