added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / arch / .unmaintained / m68k-native / exec / preparecontext.c
blobb7673ecabd085405d3e066789ee265a9d678ab77
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
5 #include <exec/types.h>
6 #include <aros/libcall.h>
8 #error "PrepareContext() has been changed. Additional tagList param, etc."
9 #error "This one here needs to be rewritten!"
11 /*****************************************************************************
13 NAME */
15 AROS_LH3I(APTR, PrepareContext,
17 /* SYNOPSIS */
18 AROS_LHA(APTR, stackPointer, A0),
19 AROS_LHA(APTR, entryPoint, A1),
20 AROS_LHA(APTR, fallBack, A2),
22 /* LOCATION */
23 struct ExecBase *, SysBase, 9, Exec)
25 /* FUNCTION
26 Allocates the space required to hold a new set of registers on the
27 Stack given by stackPointer and clears the area except for pc which
28 is set to the address given by entryPoint.
30 INPUTS
31 stackPointer - Pointer to a scpecific stack
32 entryPoint - Address of the function to call when the new context
33 becomes active.
34 fallBack - Address to be called when the entryPoint function ended
35 with an rts.
37 RESULT
38 The new Stackpointer with the underlying context.
40 NOTES
41 This function is for internal use by exec only.
43 This function is processor dependant.
45 EXAMPLE
47 BUGS
49 SEE ALSO
50 SwitchTasks()
52 INTERNALS
54 HISTORY
56 ******************************************************************************/
58 AROS_LIBFUNC_INIT
59 UBYTE *sp=(UBYTE *)stackPointer;
60 int i;
63 mc68000 version. As long as no FPU is in use this works for the
64 other mc680xx brands as well.
67 /* Push fallback address */
68 sp-=sizeof(APTR);
69 *(APTR *)sp=fallBack;
71 /* Now push the context. First a5. */
72 sp-=sizeof(LONG);
73 *(LONG *)sp=0;
75 /* Then a reverse rte (ccr & pc). */
76 sp-=sizeof(WORD);
77 *(WORD *)sp=0;
78 sp-=sizeof(APTR);
79 *(APTR *)sp=entryPoint;
81 /* Push 14 registers */
82 for(i=0;i<14;i++)
84 sp-=sizeof(LONG);
85 *(LONG *)sp=0;
88 return sp;
89 AROS_LIBFUNC_EXIT