home *** CD-ROM | disk | FTP | other *** search
- /*
- (C) 1995-96 AROS - The Amiga Replacement OS
- $Id: preparecontext.c,v 1.5 1996/12/06 11:07:55 aros Exp $
- $Log: preparecontext.c,v $
- Revision 1.5 1996/12/06 11:07:55 aros
- Vector shuffle
-
- Revision 1.4 1996/12/05 15:31:00 aros
- Patches by Geert Uytterhoeven integrated
-
- Revision 1.3 1996/10/24 15:51:28 aros
- Use the official AROS macros over the __AROS versions.
-
- Revision 1.2 1996/08/01 17:41:32 digulla
- Added standard header for all files
-
- Desc:
- Lang:
- */
- #include <exec/types.h>
- #include <aros/libcall.h>
-
- /*****************************************************************************
-
- NAME */
-
- AROS_LH3I(APTR, PrepareContext,
-
- /* SYNOPSIS */
- AROS_LHA(APTR, stackPointer, A0),
- AROS_LHA(APTR, entryPoint, A1),
- AROS_LHA(APTR, fallBack, A2),
-
- /* LOCATION */
- struct ExecBase *, SysBase, 6, Exec)
-
- /* FUNCTION
- Allocates the space required to hold a new set of registers on the
- Stack given by stackPointer and clears the area except for pc which
- is set to the address given by entryPoint.
-
- INPUTS
- stackPointer - Pointer to a scpecific stack
- entryPoint - Address of the function to call when the new context
- becomes active.
- fallBack - Address to be called when the entryPoint function ended
- with an rts.
-
- RESULT
- The new Stackpointer with the underlying context.
-
- NOTES
- This function is for internal use by exec only.
-
- This function is processor dependant.
-
- EXAMPLE
-
- BUGS
-
- SEE ALSO
- SwitchTasks()
-
- INTERNALS
-
- HISTORY
-
- ******************************************************************************/
- {
- AROS_LIBFUNC_INIT
- UBYTE *sp=(UBYTE *)stackPointer;
- int i;
-
- /*
- mc68000 version. As long as no FPU is in use this works for the
- other mc680xx brands as well.
- */
-
- /* Push fallback address */
- sp-=sizeof(APTR);
- *(APTR *)sp=fallBack;
-
- /* Now push the context. Prepare a rts first (pc). */
- sp-=sizeof(APTR);
- *(APTR *)sp=entryPoint;
-
- /* Push 15 registers */
- for(i=0;i<15;i++)
- {
- sp-=sizeof(LONG);
- *(LONG *)sp=0;
- }
-
- return sp;
- AROS_LIBFUNC_EXIT
- } /* PrepareContext */
-