Mercurial > hg > Members > kono > nitros9-code
annotate level2/modules/kernel/ffork.asm @ 3198:734862561313
3rdparty/packages: Rename particularly cryptic folder names
author | Tormod Volden <debian.tormod@gmail.com> |
---|---|
date | Sat, 03 Jun 2017 10:34:39 +0200 |
parents | 039ddb7c8ad7 |
children |
rev | line source |
---|---|
1145 | 1 ************************************************** |
2 * System Call: F$Fork | |
3 * | |
4 * Function: Starts a new child process | |
5 * | |
6 * Input: X = Address of module or filename | |
7 * Y = Parameter area size (256 byte pages) | |
8 * U = Address of parameter area | |
9 * A = Language/Type code | |
10 * B = Optional data area size (256 byte pages) | |
11 * | |
12 * Output: X = Updated past the name string | |
13 * A = Child's process ID | |
14 * | |
15 * Error: CC = C bit set; B = error code | |
16 * | |
17 FFork pshs u preserve register stack pointer | |
18 lbsr AllPrc setup a new process descriptor | |
19 bcc GotNPrc went ok, keep going | |
20 puls u,pc restore & return with error | |
21 | |
22 * Copy user # & priority | |
23 GotNPrc pshs u save pointer to new descriptor | |
24 ldx <D.Proc get current process pointer | |
25 IFNE H6309 | |
26 ldq P$User,x Get user # & priority from forking process | |
27 std P$User,u Save user # in new process | |
28 ste P$Prior,u Save priority in new process | |
29 ELSE | |
30 ldd P$User,x | |
31 std P$User,u | |
32 lda P$Prior,x | |
33 sta P$Prior,u | |
34 ENDC | |
35 * Copy network I/O pointers to new descriptor | |
36 IFEQ Network-1 | |
3123
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
37 pshs x,u |
1145 | 38 leax >P$NIO,x point to current NIO pointers |
39 leau >P$NIO,u point to buffer for new ones | |
40 IFNE H6309 | |
41 ldw #NefIOSiz get size | |
42 tfm x+,u+ move 'em | |
43 ELSE | |
44 ldb #NefIOSiz | |
45 L0250 lda ,x+ | |
46 sta ,u+ | |
47 decb | |
48 bne L0250 | |
49 ENDC | |
50 puls x,u restore pointers to descriptors | |
51 ENDC | |
52 * Copy I/O pointers to new descriptor | |
3123
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
53 leax P$DIO,x |
1145 | 54 leau P$DIO,u |
55 IFNE H6309 | |
56 ldw #DefIOSiz | |
57 tfm x+,u+ | |
58 * Copy Standard paths to new descriptor | |
59 lde #3 get # paths | |
60 ELSE | |
61 ldb #DefIOSiz | |
62 L0261 lda ,x+ | |
63 sta ,u+ | |
64 decb | |
65 bne L0261 | |
66 ldy #3 | |
67 ENDC | |
68 | |
69 * Duplicate 1st 3 paths | |
70 GetOPth lda ,x+ get a path # | |
71 beq SveNPth don't exist, go on | |
72 os9 I$Dup dupe it | |
73 bcc SveNPth no error, go on | |
74 clra clear it | |
75 | |
76 * As std in/out/err | |
77 SveNPth sta ,u+ save new path # | |
78 IFNE H6309 | |
79 dece done? | |
80 ELSE | |
81 leay -1,y | |
82 ENDC | |
83 bne GetOPth no, keep going | |
84 * Link to new module & setup task map | |
85 ldx ,s get pointer to new descriptor | |
86 ldu 2,s get pointer to register stack | |
87 lbsr L04B1 link to module & setup register stack | |
88 bcs L02CF exit if error | |
89 pshs d | |
90 os9 F$AllTsk allocate the task & setup MMU | |
91 bcs L02CF Error, skip ahead | |
92 | |
93 * Copy parameters to new process | |
94 lda P$PagCnt,x get memory page count | |
3123
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
95 clrb |
1145 | 96 subd ,s calculate destination |
97 tfr d,u set parameter destination pointer | |
98 ldb P$Task,x get source task # | |
99 ldx <D.Proc get destination task # | |
100 lda P$Task,x | |
101 leax ,y point to parameters | |
102 puls y restore parameter count | |
103 os9 F$Move move parameters to new process | |
104 | |
105 * Setup the new stack | |
106 ldx ,s get pointer to process descriptor | |
107 lda <D.SysTsk get task # | |
108 ldu P$SP,x get new stack pointer | |
109 leax >(P$Stack-R$Size),x point to register stack | |
110 ldy #R$Size get size of register stack | |
111 os9 F$Move move the register stack over | |
112 puls u,x | |
3123
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
113 os9 F$DelTsk |
1145 | 114 ldy <D.Proc |
115 lda P$ID,x | |
116 sta R$A,u | |
117 ldb P$CID,y | |
118 sta P$CID,y | |
119 lda P$ID,y | |
120 std P$PID,x | |
121 IFNE H6309 | |
122 aim #^SysState,P$State,x switch to non-system state | |
123 ELSE | |
124 lda P$State,x | |
125 anda #^SysState | |
126 sta P$State,x | |
127 ENDC | |
128 * Put date & time of creation into descriptor | |
3123
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
129 * pshs x preserve process pointer |
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
130 * leax P$DatBeg,x point to time buffer |
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
131 * os9 F$Time put date/time into it |
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
132 * puls x restore pointer |
1145 | 133 os9 F$AProc and start the process |
134 rts return | |
135 | |
136 * Fork error goes here | |
137 L02CF puls x | |
3123
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
138 pshs b save error |
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
139 lbsr L05A5 close paths & unlink mem |
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
140 lda P$ID,x get bad ID |
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
141 lbsr L0386 delete proc desc & task # |
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
142 comb set carry |
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
143 puls pc,u,b pull error code & u & return |