2 Copyright © 1995-2017, 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 <aros/i386/cpucontext.h>
16 #include "exec_intern.h"
17 #include "exec_util.h"
18 #if defined(__AROSEXEC_SMP__)
22 #define _PUSH(sp, val) *--sp = (IPTR)val
24 BOOL
PrepareContext(struct Task
*task
, APTR entryPoint
, APTR fallBack
,
25 const struct TagItem
*tagList
, struct ExecBase
*SysBase
)
29 IPTR
*sp
= task
->tc_SPReg
;
31 struct ExceptionContext
*ctx
;
33 if (!(task
->tc_Flags
& TF_ETASK
) )
36 ctx
= KrnCreateContext();
37 task
->tc_UnionETask
.tc_ETask
->et_RegFrame
= ctx
;
41 while((t
= LibNextTagItem((struct TagItem
**)&tagList
)))
45 #if defined(__AROSEXEC_SMP__)
46 case TASKTAG_AFFINITY
:
47 IntETask(task
->tc_UnionETask
.tc_ETask
)->iet_CpuAffinity
= t
->ti_Data
;
51 #define HANDLEARG(x) \
52 case TASKTAG_ARG ## x: \
53 args[x - 1] = t->ti_Data; \
54 if (x > numargs) numargs = x; \
69 There is not much to do here, or at least that is how it
70 appears. Most of the work is done in the kernel_cpu.h macros.
75 /* On i386 C function gets all param on stack */
78 _PUSH(sp
, args
[numargs
]);
82 /* First we push the return address */
85 /* Then set up the frame to be used by Dispatch() */
87 ctx
->eip
= (IPTR
)entryPoint
;
90 /* We return the new stack pointer back to the caller. */
94 } /* PrepareContext() */