2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <exec/types.h>
7 #include <exec/execbase.h>
8 #include <exec/memory.h>
9 #include <utility/tagitem.h>
10 #include <asm/mpc5200b.h>
11 #include <proto/kernel.h>
13 #include "exec_intern.h"
14 #include "exec_util.h"
18 #include <aros/libcall.h>
19 #include <aros/debug.h>
21 BOOL
PrepareContext(struct Task
*task
, APTR entryPoint
, APTR fallBack
,
22 const struct TagItem
*tagList
, struct ExecBase
*SysBase
)
26 IPTR
*sp
=(IPTR
*)((IPTR
)task
->tc_SPReg
& 0xfffffff0);
32 switch(tagList
->ti_Tag
)
35 tagList
= (const struct TagItem
*)tagList
->ti_Data
;
39 tagList
+= tagList
->ti_Data
;
46 #define HANDLEARG(x) \
47 case TASKTAG_ARG ## x: \
48 args[x - 1] = (IPTR)tagList->ti_Data; \
49 if (x > numargs) numargs = x; \
64 if (tagList
) tagList
++;
67 if (!(task
->tc_Flags
& TF_ETASK
) )
70 /* Get the memory for CPU context. Alloc it with MEMF_CLEAR flag */
71 task
->tc_UnionETask
.tc_ETask
->et_RegFrame
= KrnCreateContext();
73 D(bug("[exec] PrepareContext: et_RegFrame = %012p\n", task
->tc_UnionETask
.tc_ETask
->et_RegFrame
));
75 if (!(ctx
= (context_t
*)task
->tc_UnionETask
.tc_ETask
->et_RegFrame
))
84 ctx
->cpu
.gpr
[10] = args
[7];
86 ctx
->cpu
.gpr
[9] = args
[6];
88 ctx
->cpu
.gpr
[8] = args
[5];
90 ctx
->cpu
.gpr
[7] = args
[4];
92 ctx
->cpu
.gpr
[6] = args
[3];
94 ctx
->cpu
.gpr
[5] = args
[2];
96 ctx
->cpu
.gpr
[4] = args
[1];
98 ctx
->cpu
.gpr
[3] = args
[0];
103 /* Push fallBack address */
104 ctx
->cpu
.lr
= fallBack
;
106 * Task will be started upon interrupt resume. Push entrypoint into SRR0
107 * and the MSR register into SRR1. Enable FPU at the beginning
109 ctx
->cpu
.srr0
= (IPTR
)entryPoint
;
110 ctx
->cpu
.srr1
= MSR_PR
| MSR_EE
| MSR_ME
| MSR_IS
| MSR_DS
;
111 ctx
->cpu
.srr1
|= MSR_FP
;
112 ctx
->cpu
.gpr
[1] = sp
;
119 D(bug("[exec] New context:\n[exec] SRR0=%08x, SRR1=%08x\n",ctx
->cpu
.srr0
, ctx
->cpu
.srr1
));
120 D(bug("[exec] GPR00=%08x GPR01=%08x GPR02=%08x GPR03=%08x\n",
121 ctx
->cpu
.gpr
[0],ctx
->cpu
.gpr
[1],ctx
->cpu
.gpr
[2],ctx
->cpu
.gpr
[3]));
122 D(bug("[exec] GPR04=%08x GPR05=%08x GPR06=%08x GPR07=%08x\n",
123 ctx
->cpu
.gpr
[4],ctx
->cpu
.gpr
[5],ctx
->cpu
.gpr
[6],ctx
->cpu
.gpr
[7]));
124 D(bug("[exec] GPR08=%08x GPR09=%08x GPR10=%08x GPR11=%08x\n",
125 ctx
->cpu
.gpr
[8],ctx
->cpu
.gpr
[9],ctx
->cpu
.gpr
[10],ctx
->cpu
.gpr
[11]));
126 D(bug("[exec] GPR12=%08x GPR13=%08x GPR14=%08x GPR15=%08x\n",
127 ctx
->cpu
.gpr
[12],ctx
->cpu
.gpr
[13],ctx
->cpu
.gpr
[14],ctx
->cpu
.gpr
[15]));
129 D(bug("[exec] GPR16=%08x GPR17=%08x GPR18=%08x GPR19=%08x\n",
130 ctx
->cpu
.gpr
[16],ctx
->cpu
.gpr
[17],ctx
->cpu
.gpr
[18],ctx
->cpu
.gpr
[19]));
131 D(bug("[exec] GPR20=%08x GPR21=%08x GPR22=%08x GPR23=%08x\n",
132 ctx
->cpu
.gpr
[20],ctx
->cpu
.gpr
[21],ctx
->cpu
.gpr
[22],ctx
->cpu
.gpr
[23]));
133 D(bug("[exec] GPR24=%08x GPR25=%08x GPR26=%08x GPR27=%08x\n",
134 ctx
->cpu
.gpr
[24],ctx
->cpu
.gpr
[25],ctx
->cpu
.gpr
[26],ctx
->cpu
.gpr
[27]));
135 D(bug("[exec] GPR28=%08x GPR29=%08x GPR30=%08x GPR31=%08x\n",
136 ctx
->cpu
.gpr
[28],ctx
->cpu
.gpr
[29],ctx
->cpu
.gpr
[30],ctx
->cpu
.gpr
[31]));