2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: PrepareContext() - Prepare a task context for dispatch, i386 version
9 #include <exec/types.h>
10 #include <exec/execbase.h>
11 #include <exec/memory.h>
12 #include <utility/tagitem.h>
13 #include <proto/alib.h>
14 #include <proto/kernel.h>
15 #include <aros/i386/cpucontext.h>
17 #include "exec_intern.h"
18 #include "exec_util.h"
20 #define _PUSH(sp, val) *--sp = (IPTR)val
22 BOOL
PrepareContext(struct Task
*task
, APTR entryPoint
, APTR fallBack
,
23 const struct TagItem
*tagList
, struct ExecBase
*SysBase
)
27 IPTR
*sp
= task
->tc_SPReg
;
29 struct ExceptionContext
*ctx
;
31 if (!(task
->tc_Flags
& TF_ETASK
) )
34 ctx
= KrnCreateContext();
35 task
->tc_UnionETask
.tc_ETask
->et_RegFrame
= ctx
;
39 while((t
= LibNextTagItem((struct TagItem
**)&tagList
)))
44 #define HANDLEARG(x) \
45 case TASKTAG_ARG ## x: \
46 args[x - 1] = t->ti_Data; \
47 if (x > numargs) numargs = x; \
62 There is not much to do here, or at least that is how it
63 appears. Most of the work is done in the kernel_cpu.h macros.
68 /* On i386 C function gets all param on stack */
71 _PUSH(sp
, args
[numargs
]);
75 /* First we push the return address */
78 /* Then set up the frame to be used by Dispatch() */
80 ctx
->eip
= (IPTR
)entryPoint
;
83 /* We return the new stack pointer back to the caller. */
87 } /* PrepareContext() */