2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: i386unix version of PrepareContext().
9 #include <exec/types.h>
10 #include <exec/execbase.h>
11 #include <exec/memory.h>
12 #include <utility/tagitem.h>
15 #include "exec_util.h"
17 #include <aros/libcall.h>
19 AROS_LH4(BOOL
, PrepareContext
,
20 AROS_LHA(struct Task
*, task
, A0
),
21 AROS_LHA(APTR
, entryPoint
, A1
),
22 AROS_LHA(APTR
, fallBack
, A2
),
23 AROS_LHA(struct TagItem
*, tagList
, A3
),
24 struct ExecBase
*, SysBase
, 6, Exec
)
33 switch(tagList
->ti_Tag
)
36 tagList
= (struct TagItem
*)tagList
->ti_Data
;
40 tagList
+= tagList
->ti_Data
;
47 #define HANDLEARG(x) \
48 case TASKTAG_ARG ## x: \
49 args[x - 1] = (IPTR)tagList->ti_Data; \
50 if (x > numargs) numargs = x; \
65 if (tagList
) tagList
++;
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 sigcore.h macros.
73 if (!(task
->tc_Flags
& TF_ETASK
) )
76 GetIntETask (task
)->iet_Context
= AllocTaskMem (task
77 , SIZEOF_ALL_REGISTERS
78 , MEMF_PUBLIC
|MEMF_CLEAR
81 if (!GetIntETask (task
)->iet_Context
)
86 #ifdef PREPARE_INITIAL_ARGS
88 PREPARE_INITIAL_ARGS(task
, args
, numargs
);
92 /* Assume C function gets all param on stack */
96 _PUSH(GetSP(task
), args
[numargs
]);
102 #ifdef PREPARE_RETURN_ADDRESS
104 PREPARE_RETURN_ADDRESS(task
, fallBack
);
108 /* First we push the return address */
109 _PUSH(GetSP(task
), fallBack
);
113 /* Then set up the frame to be used by Dispatch() */
114 PREPARE_INITIAL_FRAME(GetSP(task
), entryPoint
);
115 PREPARE_INITIAL_CONTEXT(task
, entryPoint
);
117 /* We return the new stack pointer back to the caller. */