2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
5 Desc: Add a new Process
8 #include <dos/dosextens.h>
9 #include <utility/tagitem.h>
10 #include <proto/exec.h>
11 #include <aros/asmcall.h>
12 #include "dos_intern.h"
18 struct ExecBase
* SysBase
)
20 LONG result
= AROS_UFC3 (LONG
, initialPC
,
21 AROS_UFCA (STRPTR
, argPtr
, A0
),
22 AROS_UFCA (ULONG
, argSize
, D0
),
23 AROS_UFCA (struct ExecBase
*, SysBase
, A6
));
25 /* Place the return code in the tc_Userdata field of the Task
26 structure, so that it can be used by pr_ExitCode-
28 tc_UserData is safe to use because at this point we are out of the process'
31 FindTask(NULL
)->tc_UserData
= (APTR
)result
;
36 struct Process
*AddProcess(struct Process
*process
, STRPTR argPtr
,
37 ULONG argSize
, APTR initialPC
, APTR finalPC
,
38 struct DosLibrary
*DOSBase
)
41 struct TagItem tags
[] =
43 {TASKTAG_ARG1
, (IPTR
)argPtr
},
44 {TASKTAG_ARG2
, (IPTR
)argSize
},
45 {TASKTAG_ARG3
, (IPTR
)initialPC
},
46 {TASKTAG_ARG4
, (IPTR
)SysBase
},
50 #if AROS_STACK_GROWS_DOWNWARDS
51 process
->pr_Task
.tc_SPReg
= (STRPTR
)process
->pr_Task
.tc_SPUpper
- SP_OFFSET
;
53 process
->pr_Task
.tc_SPReg
= (STRPTR
)process
->pr_Task
.tc_SPLower
+ SP_OFFSET
;
56 process
->pr_ReturnAddr
= (APTR
*)process
->pr_Task
.tc_SPReg
- 4; /* ???? */
57 process
->pr_Task
.tc_Flags
|= TF_ETASK
;
59 addprocesstoroot(process
, DOSBase
);
61 return (struct Process
*)NewAddTask(&process
->pr_Task
, (APTR
)DosEntry
,
65 APTR
*sp
= process
->pr_Task
.tc_SPUpper
;
69 *--sp
= (APTR
)argSize
;
72 process
->pr_ReturnAddr
= sp
- 4;
74 process
->pr_Task
.tc_SPReg
= (STRPTR
)sp
- SP_OFFSET
;
75 process
->pr_Task
.tc_Flags
|= TF_ETASK
;
77 addprocesstoroot(process
, DOSBase
);
79 return (struct Process
*)AddTask(&process
->pr_Task
, (APTR
)DosEntry
,