annotate level2/modules/kernel/ffork.asm @ 1948:7010c08050b7

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