2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
6 #include <exec/types.h>
7 #include <aros/libcall.h>
8 #include <exec/execbase.h>
9 #include <exec/tasks.h>
10 #include <exec/memory.h>
11 #include <exec/ptrace.h>
13 #include "exec_util.h"
16 #include <aros/debug.h>
18 #error "PrepareContext() has been changed. Additional tagList param, etc."
19 #error "This one here needs to be rewritten!"
21 BOOL
PrepareContext(struct Task
*task
, APTR entryPoint
, APTR fallBack
,
22 struct TagItem
*tagList
, struct ExecBase
*SysBase
)
26 ULONG
*sp
= (ULONG
*)task
->tc_SPReg
;
30 if (!(task
->tc_Flags
& TF_ETASK
)) {
34 task
->tc_UnionETask
.tc_ETask
->et_RegFrame
= AllocTaskMem (task
, SIZEOF_ALL_REGISTERS
,
35 MEMF_PUBLIC
|MEMF_CLEAR
);
37 if (!(regs
= (struct pt_regs
*)task
->tc_UnionETask
.tc_ETask
->et_RegFrame
))
41 * Fill the registers r0-r3 with the arguments on the stack -
46 D(bug("sp=%x, task->tc_SPUpper=%x, name=%s\n",
49 task
->tc_Node
.ln_Name
));
51 if (sp
< (ULONG
*)task
->tc_SPUpper
) {
52 while (sp
< (ULONG
*)task
->tc_SPUpper
&& i
< 4) {
53 // D(bug("before: armregs=%x, sp=%x\n",armregs,sp));
58 // D(bug("after: armregs=%x, sp=%x\n",armregs,sp));
64 * Initialize initial registers. Only sp and lr_svc
65 * are important. lr_svc represents the entry point of
66 * the process plus 4. The 4 will be subtracted automatically
67 * when the process is started. It must be done that way
68 * due to how the ARM processor works when handling *interrupts*!
69 * Also set the processor for User Mode.
72 regs
->lr_svc
= (ULONG
)entryPoint
+4;
73 regs
->cpsr
= (ULONG
)0x10;
76 * Now I am not sure whether this is going to work.
77 * In the *startup* code I will need to make sure
78 * that the fallback can be executed!
79 * Note that no '4' needs to be added in this case!
81 regs
->lr
= (ULONG
)fallBack
;