2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: PrepareContext() - Prepare a task context for dispatch, PowerPC version
9 #include <exec/execbase.h>
10 #include <exec/memory.h>
11 #include <utility/tagitem.h>
12 #include <proto/kernel.h>
13 #include <aros/ppc/cpucontext.h>
15 #include "exec_intern.h"
16 #include "exec_util.h"
18 #define _PUSH(sp, val) *--sp = (IPTR)val
20 BOOL
PrepareContext(struct Task
*task
, APTR entryPoint
, APTR fallBack
,
21 const struct TagItem
*tagList
, struct ExecBase
*SysBase
)
23 struct ExceptionContext
*ctx
;
25 if (!(task
->tc_Flags
& TF_ETASK
) )
28 ctx
= KrnCreateContext();
29 task
->tc_UnionETask
.tc_ETask
->et_RegFrame
= ctx
;
33 /* Set up arguments first */
36 switch(tagList
->ti_Tag
)
39 tagList
= (const struct TagItem
*)tagList
->ti_Data
;
43 tagList
+= tagList
->ti_Data
;
50 #define HANDLEARG(x) \
51 case TASKTAG_ARG ## x: \
52 ctx->gpr[3 + x - 1] = (ULONG)tagList->ti_Data; \
65 if (tagList
) tagList
++;
68 /* Next we set up return address */
69 ctx
->lr
= (ULONG
)fallBack
;
71 /* Then set up the frame to be used by Dispatch() */
72 ctx
->gpr
[1] = (ULONG
)task
->tc_SPReg
;
73 ctx
->ip
= (ULONG
)entryPoint
;
76 } /* PrepareContext() */