Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / arch / .unmaintained / m68k-emul / preparecontext.c
blobaf94cd99ad2bd749f07b41b14ccf767def18b1af
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>
9 #error "PrepareContext() has been changed. Additional tagList param, etc."
10 #error "This one here needs to be rewritten!"
12 /*****************************************************************************
14 NAME */
16 AROS_LH3I(APTR, PrepareContext,
18 /* SYNOPSIS */
19 AROS_LHA(APTR, stackPointer, A0),
20 AROS_LHA(APTR, entryPoint, A1),
21 AROS_LHA(APTR, fallBack, A2),
23 /* LOCATION */
24 struct ExecBase *, SysBase, 6, Exec)
26 /* FUNCTION
27 Allocates the space required to hold a new set of registers on the
28 Stack given by stackPointer and clears the area except for pc which
29 is set to the address given by entryPoint.
31 INPUTS
32 stackPointer - Pointer to a scpecific stack
33 entryPoint - Address of the function to call when the new context
34 becomes active.
35 fallBack - Address to be called when the entryPoint function ended
36 with an rts.
38 RESULT
39 The new Stackpointer with the underlying context.
41 NOTES
42 This function is for internal use by exec only.
44 This function is processor dependant.
46 EXAMPLE
48 BUGS
50 SEE ALSO
51 SwitchTasks()
53 INTERNALS
55 HISTORY
57 ******************************************************************************/
59 AROS_LIBFUNC_INIT
60 UBYTE *sp=(UBYTE *)stackPointer;
61 int i;
64 mc68000 version. As long as no FPU is in use this works for the
65 other mc680xx brands as well.
68 /* Push fallback address */
69 sp-=sizeof(APTR);
70 *(APTR *)sp=fallBack;
72 /* Now push the context. Prepare a rts first (pc). */
73 sp-=sizeof(APTR);
74 *(APTR *)sp=entryPoint;
76 /* Push 15 registers */
77 for(i=0;i<15;i++)
79 sp-=sizeof(LONG);
80 *(LONG *)sp=0;
83 return sp;
84 AROS_LIBFUNC_EXIT
85 } /* PrepareContext */