make the linux-ppc packags be in synch with other platforms
[tangerine.git] / arch / m68k-mac / exec / preparecontext.c
blobc616ad08f3f555b0b6d1bc372860000438535594
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
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>
12 #include "etask.h"
13 #include "exec_util.h"
15 //#error "PrepareContext() has been changed. Additional tagList param, etc."
16 //#error "This one here needs to be rewritten!"
18 /*****************************************************************************
20 NAME */
22 AROS_LH4(BOOL, PrepareContext,
24 /* SYNOPSIS */
25 AROS_LHA(struct Task *, task, A0),
26 AROS_LHA(APTR, entryPoint, A1),
27 AROS_LHA(APTR, fallBack, A2),
28 AROS_LHA(struct TagItem *, tagList, A3),
30 /* LOCATION */
31 struct ExecBase *, SysBase, 6, Exec)
33 /* FUNCTION
34 Allocates the space required to hold a new set of registers on the
35 Stack given by stackPointer and clears the area except for pc which
36 is set to the address given by entryPoint.
38 INPUTS
39 task - Pointer to the new task
40 entryPoint - Address of the function to call when the new context
41 becomes active.
42 fallBack - Address to be called when the entryPoint function ended
43 with an rts.
44 tagList -
46 RESULT
47 The new Stackpointer with the underlying context.
49 NOTES
50 This function is for internal use by exec only.
52 This function is processor dependant.
54 EXAMPLE
56 BUGS
58 SEE ALSO
59 SwitchTasks()
61 INTERNALS
63 HISTORY
65 ******************************************************************************/
67 AROS_LIBFUNC_INIT
69 struct pt_regs *regs;
71 UBYTE *sp = (UBYTE *)task->tc_SPReg;
73 /* Push fallBack address */
74 sp -= sizeof(APTR);
75 *(APTR *)sp = fallBack;
77 if (!(task->tc_Flags & TF_ETASK)) {
78 *(ULONG *)0x0bad0001=0;
79 return FALSE;
82 GetIntETask (task)->iet_Context = AllocTaskMem (task
83 , SIZEOF_ALL_REGISTERS
84 , MEMF_PUBLIC|MEMF_CLEAR
87 if (!(regs = (struct pt_regs *)GetIntETask(task)->iet_Context)) {
88 *(ULONG *)0x0bad0003=0;
89 return FALSE;
92 regs->usp = sp;
93 regs->pc = (ULONG)entryPoint;
95 task->tc_SPReg = sp;
97 return TRUE;
98 AROS_LIBFUNC_EXIT