2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Run a process ( invoked by dos/Runcommand() )
8 LONG RunProcess ( struct Process * proc,
9 struct StackSwapStruct * sss,
13 struct DosLibrary * DOSBase )
19 This is how the stack looks when this function is called:
30 /* .set FirstArg, 4+(2*4) / * Return-address + registers * /
34 .set argsize, argptr+4
35 .set entry, argsize+4 */
38 #define FirstArg 4+(2*4) /* Return-Address + 2 Registers */
40 #define FirstArg 4+(4*4) /* Return-Address + 4 Registers */
42 #define proc FirstArg+0
43 #define sss FirstArg+4
44 #define argptr FirstArg+8
45 #define argsize FirstArg+12
46 #define entry FirstArg+16
47 #define DOSBase FirstArg+20
51 .globl AROS_SLIB_ENTRY(RunProcess,Dos)
52 .type AROS_SLIB_ENTRY(RunProcess,Dos),@function
53 AROS_SLIB_ENTRY
(RunProcess
,Dos
):
55 movem.
l %a5-
%a6
,-(%sp
) /* Save some registers */
57 movem.
l %d2
/%a2
/%a5-
%a6
,-(%sp
) /* Save some registers */
60 move.
l sss
(%sp
),%a0
/* Fetch the arguments off the stack */
61 move.
l entry
(%sp
),%a5
/* " " " " " " */
63 /* Move upper bounds of the new stack into a1 */
64 move.
l stk_Upper
(%a0
),%a1
68 Push arguments for entry onto the stack of the new process.
69 This new stack looks like this when the new process is called:
76 move.
l argptr
(%sp
),-16(%a1
)
77 move.
l argsize
(%sp
),-12(%a1
)
79 move.
l %a0
,-4(%a1
) /* Push sss onto the new stack */
82 We need to save both argptr and argsize from the stack.
84 move.
l argptr
(%sp
),%a2
85 move.
l argsize
(%sp
),%d2
87 move.
l %a0
,-(%a1
) /* Push sss onto the new stack */
89 move.
l DOSBase
(%sp
),%a6
/* Get SysBase */
90 move.
l dl_SysBase
(%a6
),%a6
/* " " */
92 move.
l %a6
,-8(%a1
) /* Push SysBase onto the new stack */
95 move.
l %a6
,-(%a1
) /* Push SysBase onto the new stack */
97 move.
l %a1
,stk_Pointer
(%a0
) /* Store Switch Point in sss */
100 /* Push SysBase and sss on our stack */
105 jsr StackSwap
(%a6
) /* Switch stacks (a0=sss) */
108 /* Clean new stack from call to StackSwap */
112 The entry function expects to be called with:
117 move.
l %a2
,%a0
/* argptr in a0 */
118 move.
l %d2
,%d0
/* arglen in d0 */
121 jsr
(%a5
) /* Call the specified routine */
124 /* Clean (new) stack partially, leaving SysBase behind */
127 move.
l %d0
,%a5
/* Save return value */
129 /* Swap the upper two values on the new stack */
130 move.
l (%sp
)+,%a6
/* Pop SysBase */
131 move.
l (%sp
)+,%a0
/* Pop sss */
137 jsr StackSwap
(%a6
) /* Switch stacks back */
140 /* Clean old stack */
143 move.
l %a5
,%d0
/* Put result in d0 where our caller expects it */
146 movem.
l (%sp
)+,%a5-
%a6
/* Restore registers */
148 movem.
l (%sp
)+,%d2
/%a2
/%a5-
%a6
/* Restore registers */