2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
5 Desc: mingw32 version of PrepareContext().
11 #include <aros/debug.h>
12 #include <exec/types.h>
13 #include <exec/execbase.h>
14 #include <exec/memory.h>
15 #include <utility/tagitem.h>
16 #include <proto/kernel.h>
17 #include <aros/kernel.h>
19 #include "exec_util.h"
20 #include "../kernel/cpucontext.h"
22 #include <aros/libcall.h>
23 #include <proto/arossupport.h>
24 #include <proto/kernel.h>
26 /* Put a value of type SP_TYPE on the stack or get it off the stack. */
27 #define _PUSH(sp,val) (*--sp = (SP_TYPE)(val))
28 #define _POP(sp) (*sp++)
32 #define GetSP(task) (*(SP_TYPE **)(&task->tc_SPReg))
34 AROS_LH4(BOOL
, PrepareContext
,
35 AROS_LHA(struct Task
*, task
, A0
),
36 AROS_LHA(APTR
, entryPoint
, A1
),
37 AROS_LHA(APTR
, fallBack
, A2
),
38 AROS_LHA(struct TagItem
*, tagList
, A3
),
39 struct ExecBase
*, SysBase
, 6, Exec
)
44 struct AROSCPUContext
*ctx
;
46 D(kprintf("[PrepareContext] preparing task \"%s\" entry: %p fallback: %p\n",task
->tc_Node
.ln_Name
,entryPoint
,fallBack
));
48 if (!(task
->tc_Flags
& TF_ETASK
) )
51 ctx
= KrnCreateContext();
52 GetIntETask (task
)->iet_Context
= ctx
;
58 switch(tagList
->ti_Tag
)
61 tagList
= (struct TagItem
*)tagList
->ti_Data
;
65 tagList
+= tagList
->ti_Data
;
72 #define HANDLEARG(x) \
73 case TASKTAG_ARG ## x: \
74 args[x - 1] = (IPTR)tagList->ti_Data; \
75 if (x > numargs) numargs = x; \
90 if (tagList
) tagList
++;
95 /* Assume C function gets all param on stack */
99 D(kprintf(" arg %i: %p\n",numargs
, args
[numargs
]));
100 _PUSH(GetSP(task
), args
[numargs
]);
105 /* First we push the return address */
106 _PUSH(GetSP(task
), fallBack
);
108 /* Then set up the context */
109 PREPARE_INITIAL_CONTEXT(ctx
, GetSP(task
), entryPoint
);
111 D(kprintf("Prepared task context: *****\n"));
112 D(PRINT_CPUCONTEXT(ctx
));