typo..
[AROS.git] / arch / ppc-all / exec / preparecontext.c
blob9f5e377cdb4f4bc29f3d24029704e85e439757c1
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: PrepareContext() - Prepare a task context for dispatch, PowerPC version
6 Lang: english
7 */
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) )
26 return FALSE;
28 ctx = KrnCreateContext();
29 task->tc_UnionETask.tc_ETask->et_RegFrame = ctx;
30 if (!ctx)
31 return FALSE;
33 /* Set up arguments first */
34 while(tagList)
36 switch(tagList->ti_Tag)
38 case TAG_MORE:
39 tagList = (const struct TagItem *)tagList->ti_Data;
40 continue;
42 case TAG_SKIP:
43 tagList += tagList->ti_Data;
44 break;
46 case TAG_DONE:
47 tagList = NULL;
48 break;
50 #define HANDLEARG(x) \
51 case TASKTAG_ARG ## x: \
52 ctx->gpr[3 + x - 1] = (ULONG)tagList->ti_Data; \
53 break;
55 HANDLEARG(1)
56 HANDLEARG(2)
57 HANDLEARG(3)
58 HANDLEARG(4)
59 HANDLEARG(5)
60 HANDLEARG(6)
61 HANDLEARG(7)
62 HANDLEARG(8)
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;
75 return TRUE;
76 } /* PrepareContext() */