added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / arch / x86_64-pc / dos / runprocess.c
bloba60edf283657738287b1a0184102b87f7f3d07d0
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id: runprocess.c 24234 2006-03-27 20:09:51Z verhaegs $
5 Desc: RunProcess() - Run a process from an entry point with args
6 Lang: english
7 */
9 #include <aros/asmcall.h> /* LONG_FUNC */
10 #include <dos/dosextens.h>
11 #include <proto/exec.h>
12 #include <aros/debug.h>
14 #include <string.h>
17 /**************************************************************************
19 NAME */
20 LONG AROS_SLIB_ENTRY(RunProcess,Dos) (
22 /* SYNOPSIS */
23 struct Process * proc,
24 struct StackSwapStruct * sss,
25 STRPTR argptr,
26 ULONG argsize,
27 LONG_FUNC entry,
28 struct DosLibrary * DOSBase)
30 /* FUNCTION
31 Sets the stack as specified and calls the routine with the given
32 arguments.
34 INPUTS
35 proc - Process context
36 sss - New Stack
37 argptr - Pointer to argument string
38 argsize - Size of the argument string
39 entry - The entry point of the function
40 DOSBase - Pointer to dos.library structure
42 RESULT
43 The return value of (*entry)();
45 NOTES
47 EXAMPLE
49 BUGS
51 SEE ALSO
53 INTERNALS
55 **************************************************************************/
57 APTR *sp;
58 IPTR ret;
59 register IPTR *retptr = &ret;
60 APTR oldReturnAddr;
62 oldReturnAddr = proc->pr_ReturnAddr;
64 /* Compute argsize automatically */
65 if (argsize == -1)
67 argsize = strlen(argptr);
70 sss->stk_Pointer = sss->stk_Upper;
71 StackSwap(sss);
73 /* Call the function with the new stack */
75 We have to set the pr_ReturnAddr pointer to the correct value
76 before we call the entry() otherwise some startup code will
77 not work.
79 This can be done rather more easily on the m68k than elsewhere.
82 /* On x86_64 one does not need to use any UFC3R macro! */
84 *retptr = entry(argptr,argsize,SysBase);
86 StackSwap(sss);
88 proc->pr_ReturnAddr = oldReturnAddr;
90 return ret;