1204
|
1 ********************************************************************
|
|
2 * RBF - Random Block File Manager
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Modified for 6309 Native mode by Bill Nobel, L. Curtis Boyle & Wes Gale
|
|
7 *
|
|
8 * This also contains the patch for un-deleting files
|
|
9 *
|
|
10 * Undocumented SetStt/GetStt calls:
|
|
11 *
|
|
12 * GetStt:
|
|
13 * SS.FD ($0F) - Returns a file descriptor
|
|
14 * Entry: R$A=Path #
|
|
15 * R$B=SS.FD ($0F)
|
|
16 * R$X=Pointer to a 256 byte buffer
|
|
17 * R$Y=# bytes of FD required
|
|
18 * SS.FDInf ($20) - Directly reads a file descriptor from anywhere
|
|
19 * on drive.
|
|
20 * Entry: R$A=Path #
|
|
21 * R$B=SS.FDInf ($20)
|
|
22 * R$X=Pointer to a 256 byte buffer
|
|
23 * R$Y= MSB - Length of read
|
|
24 * LSB - MSB of logical sector #
|
|
25 * R$U= LSW of logical sector #
|
|
26 * SetStt:
|
|
27 * SS.FD ($0F) - Writes a file descriptor
|
|
28 * Entry: R$A=Path #
|
|
29 * R$B=SS.FD ($0F)
|
|
30 * R$X=Pointer to a maximum 256 byte buffer
|
|
31 * R$Y=# bytes of FD to write
|
|
32 * SS.Ticks ($10) - Set # ticks to wait for record lock release
|
|
33 * Entry: R$A=Path #
|
|
34 * R$B=SS.Ticks ($10)
|
|
35 * R$X=# Ticks to wait
|
|
36 * SS.Lock ($11) - Force Lock/Release of a file.
|
|
37 * Locks from current position to a specified size
|
|
38 * Entry: R$A=Path #
|
|
39 * R$B=SS.Lock ($11)
|
|
40 * R$X=LSW of end byte position
|
|
41 * R$U=MSW of end byte position
|
|
42 * SS.Attr ($1C) - Allows changing of file/directory attributes
|
|
43 * If changing directory attribute it scans to
|
|
44 * see if directory is empty.
|
|
45 * Entry: R$A=Path #
|
|
46 * R$B=SS.Attr ($1C)
|
|
47 * R$X= LSB - File attributes
|
|
48 * SS.RsBit ($1E) - Reserve bitmap sector (doesn't allocate)
|
|
49 * Locks the bitmap sector from other programs
|
|
50 * so they cannot allocate in it.
|
|
51 * Useful when working in allocation map.
|
|
52 * Entry: R$A=Path #
|
|
53 * R$B=SS.RsBit ($1E)
|
|
54 * R$X= LSB - Sector # of bitmap
|
|
55 *
|
|
56 * Ed. Comments Who YY/MM/DD
|
|
57 * ------------------------------------------------------------------
|
|
58 * ??? Started putting in comments from buggy 1.09 ??? 93/09/19
|
|
59 * code
|
|
60 * ??? Fixed WP error bug on file delete ??? 93/09/19
|
|
61 * Fixed FD read error bug in delete
|
|
62 * ??? Fixed long overdue LHA bug ??? 94/07/15
|
|
63 * Modified M$Exec driver calls @ L11EB to use
|
|
64 * V$DRIVEX
|
|
65 * ??? Changed L11EB to just PSHS/PULS A,X,PC ??? 94/07/27
|
|
66 * instead of D,X,PC (saves 2 cycles per
|
|
67 * driver call)
|
|
68 * Changed BRA L12C6 @ L128E to PULS PC,U,X
|
|
69 * ??? NitrOS-9 2.00 distribution ??? ??/??/??
|
|
70 * 35 Fixed FD.SEG bug GH ??/??/??
|
|
71 * Folded RBF 30 comments into this version BGP 03/04/21
|
|
72
|
|
73 nam RBF
|
|
74 ttl Random Block File Manager
|
|
75
|
|
76 ifp1
|
|
77 use defsfile
|
|
78 use rbfdefs
|
|
79 endc
|
|
80
|
|
81 rev set $01
|
|
82 ty set FlMgr
|
|
83 IFNE H6309
|
|
84 lg set Obj6309
|
|
85 ELSE
|
|
86 lg set Objct
|
|
87 ENDC
|
|
88 tylg set ty+lg
|
|
89 atrv set ReEnt+rev
|
|
90 edition set 35
|
|
91
|
|
92 org $00
|
|
93 size equ .
|
|
94
|
|
95 mod eom,name,tylg,atrv,start,size
|
|
96
|
|
97 name fcs /RBF/
|
|
98 fcb edition
|
|
99
|
|
100 L0012 fcb DRVMEM
|
|
101
|
|
102
|
|
103 ****************************
|
|
104 *
|
|
105 * Main entry point for RBF
|
|
106 *
|
|
107 * Entry: Y = Path descriptor pointer
|
|
108 * U = Register stack pointer
|
|
109
|
|
110 start bra Create
|
|
111 nop
|
|
112 lbra Open
|
|
113 lbra MakDir
|
|
114 lbra ChgDir
|
|
115 lbra Delete
|
|
116 lbra Seek
|
|
117 lbra Read
|
|
118 lbra Write
|
|
119 lbra ReadLn
|
|
120 lbra WriteLn
|
|
121 lbra GetStat
|
|
122 lbra SetStat
|
|
123 lbra Close
|
|
124
|
|
125
|
|
126 *
|
|
127 * I$Create Entry Point
|
|
128 *
|
|
129 * Entry: A = access mode desired
|
|
130 * B = file attributes
|
|
131 * X = address of the pathlist
|
|
132 *
|
|
133 * Exit: A = pathnum
|
|
134 * X = last byte of pathlist address
|
|
135 *
|
|
136 * Error: CC Carry set
|
|
137 * B = errcode
|
|
138 *
|
|
139 Create pshs y Preserve path desc ptr
|
|
140 leas -$05,s Make 5 byte buffer on stack
|
|
141 IFNE H6309
|
|
142 aim #^DIR.,R$B,u
|
|
143 ELSE
|
|
144 lda R$B,u force directory bit off
|
|
145 anda #^DIR.
|
|
146 sta R$B,u
|
|
147 ENDC
|
|
148 lbsr FindFile try & find it in directory
|
|
149 bcs Creat47 branch if doesn't exist
|
|
150
|
|
151 * File already exists
|
|
152 ldb #E$CEF else exists error
|
|
153 Creat47 cmpb #E$PNNF not found?
|
|
154 bne Creat7E
|
|
155
|
|
156 * File doesn't exist, create it
|
|
157 cmpa #PDELIM full path?
|
|
158 beq Creat7E yes, return
|
|
159 pshs x preserve filename pointer
|
|
160 ldx PD.RGS,y get register stack pointer
|
|
161 stu R$X,x save updated pathname pointer
|
|
162 * These 4 did have < in front, made 3 byte cmnds but some are 2!
|
|
163 ldb PD.SBP,y get physical sector # of segment list
|
|
164 ldx PD.SBP+1,y
|
|
165 lda PD.SSZ,y get size of segment list in bytes
|
|
166 ldu PD.SSZ+1,y
|
|
167 pshs u,x,b,a preserve it all
|
|
168 ldx PD.RGS,y get register stack pointer
|
|
169 * Calculate default file size, if enabled
|
|
170 * This sets D to 0 if bit 5 of R$A is NOT set. If bit 5 of R$A is set
|
|
171 * when called, register Y will contain a default file size
|
|
172 lda R$A,x get file mode (read/write/update)
|
|
173 clrb
|
|
174 anda #PEXEC. bit 5 set?
|
|
175 beq Creat6E no, skip ahead
|
|
176 ldd R$Y,x get default file size
|
|
177 * account for FD sector, I think.
|
|
178 * changed from addd #1, bcc, ldd #$FFFF.
|
|
179 * The INCD gets D=$0000 (and CC.Z set) if it overflows from $FFFF->$0000
|
|
180 * then if it's zero, a DECD forces it to be $FFFF
|
|
181 Creat6E addd #1 above 64k in size? (bug fix, thanks Gene K.)
|
|
182 bcc Creat75 no, skip ahead: changed from BCC
|
|
183 ldd #$FFFF force it to 64k
|
|
184 Creat75 lbsr FatScan find the space in the allocation map
|
|
185 bcc Creat83 got it, skip ahead
|
|
186 leas 6,s purge segment sizes from stack
|
|
187 * and fall through to routine which returns with an error.
|
|
188
|
|
189 Creat7C leas 2,s purge user's pathname pointer
|
|
190 Creat7E leas 5,s purge local data
|
|
191 lbra ErMemRtn return with error
|
|
192
|
|
193 * Create the file
|
|
194 Creat83 std $0B,s save segment size
|
|
195 ldb PD.SBP,y save segment physical sector # in path desc.
|
|
196 ldx PD.SBP+1,y starting LSN
|
|
197 stb $08,s on stack too
|
|
198 stx $09,s
|
|
199 puls u,x,b,a restore segment physical sector # & sizes
|
|
200 stb PD.SBP,y save it as current
|
|
201 stx PD.SBP+1,y
|
|
202 sta PD.SSZ,y
|
|
203 stu PD.SSZ+1,y
|
|
204 * Find empty slot in directory sector for new file
|
|
205 IFNE H6309
|
|
206 ldq PD.DCP,y get directory entry pointer for new file
|
|
207 stq PD.CP,y save it as current file pointer
|
|
208 ELSE
|
|
209 ldd PD.DCP,y
|
|
210 std PD.CP,y
|
|
211 ldd PD.DCP+2,y
|
|
212 std PD.CP+2,y
|
|
213 ENDC
|
|
214 lbsr L0957 move entry into sector buffer
|
|
215 bcs CreatB5
|
|
216 CreatAC tst ,x file exist here already?
|
|
217 beq CreatC7 no, found empty slot, skip ahead
|
|
218 lbsr L0942 point to next entry
|
|
219 bcc CreatAC try again
|
|
220 CreatB5 cmpb #E$EOF end of directory?
|
|
221 bne Creat7C no, return error
|
|
222 * Create the directory entry for new file
|
|
223 ldd #DIR.SZ get size of directory entry
|
|
224 lbsr Writ599 add it to size of directory
|
|
225 bcs Creat7C out of alloc?
|
|
226 lbsr MDir263 set file size in file descriptor
|
|
227 lbsr L0957 read in a directory sector
|
|
228 CreatC7 leau ,x point to directory entry
|
|
229 lbsr Creat169 clear it out
|
|
230 puls x restore pathname pointer
|
|
231 os9 F$PrsNam parse it to get filename
|
|
232 bcs Creat7E
|
|
233 cmpb #29 length of name right size?
|
|
234 bls CreatD9 yes, skip ahead
|
|
235 ldb #29 else force it to 29 chars
|
|
236 CreatD9 clra move length to Y
|
|
237 tfr d,y
|
|
238 lbsr Writ5CB move name of file to directory entry
|
|
239 tfr y,d move length of name to D
|
|
240 ldy $05,s restore PDpointer
|
|
241 decb subtract 1 off length
|
|
242 IFNE H6309
|
|
243 oim #$80,b,u set high bit on last char of name
|
|
244 ELSE
|
|
245 lda b,u
|
|
246 ora #$80
|
|
247 sta b,u
|
|
248 ENDC
|
|
249 ldb ,s get logical sector # of file desc
|
|
250 ldx $01,s
|
|
251 stb DIR.FD,u save it into directory entry
|
|
252 stx DIR.FD+1,u
|
|
253 lbsr L1205 flush sector to disk
|
|
254 bcs Creat151
|
|
255 * Setup file descriptor
|
|
256 ldu PD.BUF,y get sector buffer pointer
|
|
257 bsr Creat170 clear it out
|
|
258 lda #FDBUF get file descriptor in buffer flag
|
|
259 sta PD.SMF,y save it as current sector buffer state
|
|
260 ldx PD.RGS,y get register stack pointer
|
|
261 lda R$B,x get file attributes
|
|
262 sta FD.ATT,u save it as current attributes
|
|
263 ldx <D.Proc get process pointer
|
|
264 ldd P$User,x get user #
|
|
265 std FD.OWN,u save creation user
|
|
266 lbsr L02D1 place date & time into file descriptor
|
|
267 ldd FD.DAT,u get date last modified
|
|
268 std FD.Creat,u save it as creation date (since we just made it)
|
|
269 ldb FD.DAT+2,u
|
|
270 stb FD.Creat+2,u
|
|
271 ldb #$01 get link count
|
|
272 stb FD.LNK,u
|
|
273 ldd 3,s get segment size in sectors
|
|
274 IFNE H6309
|
|
275 decd is it 1?
|
|
276 ELSE
|
|
277 subd #$0001
|
|
278 ENDC
|
|
279 beq Creat131 yes, skip ahead
|
|
280 leax FD.SEG,u point to the start of the segment list
|
|
281 std FDSL.B,x save segment size
|
|
282 ldd 1,s get LSW of physical sector # of seg start
|
|
283 addd #1 we need to carry below, fr the adcb! (bug fix, thanks Gene K.)
|
|
284 std FDSL.A+1,x save LSW
|
|
285 ldb ,s get MSB of physical sector # of segment start
|
|
286 adcb #$00 need carry status of addd above
|
|
287 stb FDSL.A,x save MSB
|
|
288 Creat131 ldb ,s get p hysical sector # of segment start
|
|
289 ldx 1,s
|
|
290 lbsr L1207 flush file descriptor to disk
|
|
291 bcs Creat151
|
|
292 lbsr L0A90 sort out any ocnflict for this sector
|
|
293 stb PD.FD,y save file descriptor physical sector # to pd
|
|
294 stx PD.FD+1,y
|
|
295 lbsr L0A2A update file/record lock for this sector
|
|
296 leas $05,s purge sector buffer from stack
|
|
297 ldx PD.Exten,y get path extension pointer
|
|
298 lda #EofLock set the file to EOF lock
|
|
299 sta PE.Lock,x
|
|
300 bra Open1CC
|
|
301 * Error on fD write to disk
|
|
302 Creat151 puls u,x,a restore segment start & size
|
|
303 sta PD.SBP,y put it into path descriptor
|
|
304 stx PD.SBP+1,y
|
|
305 clr PD.SSZ,y
|
|
306 stu PD.SSZ+1,y
|
|
307 pshs b save error code
|
|
308 lbsr ClrFBits
|
|
309 puls b restore error code
|
|
310 RtnMemry lbra ErMemRtn return with error
|
|
311
|
|
312 * Clear out directory entry
|
|
313 * Entry: U = Directory entry pointer
|
|
314 Creat169
|
|
315 IFNE H6309
|
|
316 ldw #DIR.SZ get size of directory entry (name & LSN of FD)
|
|
317 ELSE
|
1513
|
318 ldd #DIR.SZ A = 0 so clear loop passes once +BGP+
|
1204
|
319 ENDC
|
|
320 bra Creat174 clear it out
|
|
321
|
|
322 * Clear out sector buffer
|
|
323 * Entry: U = Sector buffer pointer
|
|
324 Creat170
|
|
325 IFNE H6309
|
|
326 ldw #$0100 get size of sector buffer
|
|
327 ELSE
|
|
328 clrb
|
1209
|
329 ENDC
|
1513
|
330 lbsr SSBits +BGP+
|
1204
|
331 Creat174 pshs u,x preserve regs
|
1209
|
332 IFNE H6309
|
|
333 leax <Creat170+3,pcr point to NULL byte
|
1513
|
334 CreatL tfm x,u+ clear buffer
|
|
335 deca +BGP+
|
|
336 bpl CreatL +BGP+
|
1209
|
337 ELSE
|
1204
|
338 l1 clr ,u+
|
|
339 decb
|
|
340 bne l1
|
1513
|
341 deca +BGP+
|
|
342 bpl l1 +BGP+
|
1204
|
343 ENDC
|
|
344 puls pc,u,x restore & return
|
|
345
|
|
346
|
|
347 *
|
|
348 * I$Open Entry Point
|
|
349 *
|
|
350 * Entry: A = access mode desired
|
|
351 * X = address of the pathlist
|
|
352 *
|
|
353 * Exit: A = pathnum
|
|
354 * X = last byte of pathlist address
|
|
355 *
|
|
356 * Error: CC Carry set
|
|
357 * B = errcode
|
|
358 *
|
|
359 Open pshs y preserve path descriptor pointer
|
|
360 lbsr FindFile try & find the file in current directory
|
|
361 bcs RtnMemry couldn't find it, return error
|
|
362 ldu PD.RGS,y get register stack pointer
|
|
363 stx R$X,u save updated pathname pointer
|
|
364 ldd PD.FD+1,y do we have a file descriptor?
|
|
365 bne Open1BB
|
|
366 lda PD.FD,y
|
|
367 bne Open1BB yes, skip ahead
|
|
368 * File descriptor doesn't exist
|
|
369 ldb PD.MOD,y get current file mode
|
|
370 andb #DIR. is it a directory?
|
|
371 lbne Clos29D yes, return not accessible eror
|
|
372 std PD.SBP,y set segment physical start to 0
|
|
373 sta PD.SBP+2,y
|
|
374 std PD.SBL,y do logical as well
|
|
375 sta PD.SBL+2,y
|
|
376 ldx PD.DTB,y get pointer to drive table
|
|
377 lda DD.TOT+2,x get total # sectors on drive
|
|
378 std PD.SIZ+2,y copy it to file size (B=0)
|
|
379 sta PD.SSZ+2,y copy it to segment size as well
|
|
380 ldd DD.TOT,x
|
|
381 std PD.SIZ,y
|
|
382 std PD.SSZ,y
|
|
383 puls pc,y restore & return
|
|
384
|
|
385 Open1BB lda PD.MOD,y get file mode
|
|
386 lbsr ChkAttrs can user access file?
|
|
387 bcs RtnMemry no, return no permission error
|
|
388 bita #WRITE. open for write?
|
|
389 beq Open1CC no, skip ahead
|
|
390 lbsr L02D1 update last date modified to current
|
|
391 lbsr L11FD update file descriptor on disk
|
|
392 Open1CC puls y restore path descriptor pointer
|
|
393
|
|
394 * Update the path descriptor from the FD sector pointed to by U
|
|
395 Open1CE
|
|
396 IFNE H6309
|
|
397 clrd get a 16 bit zero value
|
|
398 ELSE
|
|
399 clra
|
|
400 clrb
|
|
401 ENDC
|
|
402 std PD.CP+2,y set seek pointer to start of file
|
|
403 std PD.CP,y
|
|
404 std PD.SBL,y set segment start
|
|
405 sta PD.SBL+2,y
|
|
406 sta PD.SSZ,y set segment size
|
|
407 lda FD.ATT,u get file attributes
|
|
408 sta PD.ATT,y put it into path descriptor
|
|
409 ldd FD.SEG,u get the file's segment start sector #
|
|
410 std PD.SBP,y
|
|
411 lda FD.SEG+2,u
|
|
412 sta PD.SBP+2,y
|
|
413 ldd FD.SEG+FDSL.B,u
|
|
414 std PD.SSZ+1,y
|
|
415 * ldq FD.SIZ,u
|
|
416 ldd FD.SIZ,u get file size
|
|
417 ldx FD.SIZ+2,u
|
|
418 ldu PD.Exten,y get path extension pointer
|
|
419 cmpu PE.Confl,u head of the conflict tree?
|
|
420 beq Open209 yes, skip ahead
|
|
421 ldu PE.Confl,u get the conflicting path ext. pointer
|
|
422 ldu PE.PDptr,u get back pointer to the PD of conflicting process
|
|
423 * ldq PD.SIZ,u
|
|
424 ldd PD.SIZ,u get his size instead
|
|
425 ldx PD.SIZ+2,u
|
|
426 * stq PD.SIZ,y
|
|
427 Open209 std PD.SIZ,y set file size in path descriptor of caller
|
|
428 stx PD.SIZ+2,y
|
|
429 clr PD.SMF,y clear the state flags
|
|
430 rts return
|
|
431
|
|
432
|
|
433 *
|
|
434 * I$MakDir Entry Point
|
|
435 *
|
|
436 * Entry: X = address of the pathlist
|
|
437 *
|
|
438 * Exit: X = last byte of pathlist address
|
|
439 *
|
|
440 * Error: CC Carry set
|
|
441 * B = errcode
|
|
442 *
|
|
443 MakDir lbsr Create create a file descriptor
|
|
444 bcs MDir261 problem, return error
|
|
445 lda PD.ATT,y get attributes
|
|
446 ora #SHARE. set shareable bit
|
|
447 lbsr ChkAttrs can user access directory?
|
|
448 bcs MDir261 no, return error
|
|
449 ldd #DIR.SZ*2 get default directory size (for '.' & '..')
|
|
450 std PD.SIZ+2,y save it in path descriptor (MSW set to 0)
|
|
451 bsr MDir273 write out file descriptor
|
|
452 bcs MDir261 error, return
|
|
453 lbsr L0C6F
|
|
454 bcs MDir261
|
|
455 lbsr RdFlDscr read in file descriptor
|
|
456 ldu PD.BUF,y get pointer to file descriptor
|
|
457 IFNE H6309
|
|
458 oim #DIR.,FD.ATT,u set directory bit in attributes
|
|
459 ELSE
|
|
460 lda FD.ATT,u
|
|
461 ora #DIR.
|
|
462 sta FD.ATT,u
|
|
463 ENDC
|
|
464 bsr MDir266
|
|
465 bcs MDir261
|
|
466 lbsr Creat170 clear out sector
|
|
467 ldd #$2EAE get directory entry name for current & parent dir
|
|
468 std ,u save parent name
|
|
469 stb DIR.SZ,u save current name
|
|
470 * This is smaller and faster than the old method
|
|
471 * ldq PD.DFD-1,y get directory FD pointer into low 24-bits of Q
|
|
472 * clra make sure high byte is zero
|
|
473 * stq DIR.FD-1,u save in the dir: '.' and '..' have <28 char names
|
|
474 lda PD.DFD,y
|
|
475 sta DIR.FD,u
|
|
476 ldd PD.DFD+1,y
|
|
477 std DIR.FD+1,u
|
|
478 * ldq PD.FD-1,y get current FD into lower 24-bits of Q
|
|
479 * clra ensure high byte is zero
|
|
480 * stq DIR.SZ+DIR.FD-1,u save in the directory
|
|
481 lda PD.FD,y
|
|
482 sta DIR.SZ+DIR.FD,u
|
|
483 ldd PD.FD+1,y
|
|
484 std DIR.SZ+DIR.FD+1,u
|
|
485
|
|
486 lbsr L1205 flush new directory ssector to disk
|
|
487 MDir261 bra Rt100Mem return to system all ok
|
|
488
|
|
489 * Set new file size in file descriptor
|
|
490 * Entry: None
|
|
491 * Exit : New file size set in file descriptor on disk
|
|
492 MDir263 lbsr RdFlDscr read in file descriptor
|
|
493 MDir266 ldx PD.BUF,y get sector pointer
|
|
494 IFNE H6309
|
|
495 ldq PD.SIZ,y get current file size
|
|
496 stq FD.SIZ,x save it in file descriptor
|
|
497 ELSE
|
|
498 ldd PD.SIZ,y
|
|
499 std FD.SIZ,x
|
|
500 ldd PD.SIZ+2,y
|
|
501 std FD.SIZ+2,x
|
|
502 ENDC
|
|
503 clr PD.SMF,y clear state flags
|
|
504 MDir273 lbra L11FD
|
|
505
|
|
506
|
|
507 *
|
|
508 * I$Close Entry Point
|
|
509 *
|
|
510 * Entry: A = path number
|
|
511 *
|
|
512 * Exit:
|
|
513 *
|
|
514 * Error: CC Carry set
|
|
515 * B = errcode
|
|
516 *
|
|
517 Close clra
|
|
518 tst PD.CNT,y any open paths?
|
|
519 bne Clos29C yes, return
|
|
520 lbsr L1237 flush current sector of needed
|
|
521 bcs Rt100Mem error, skip ahead
|
|
522 ldb PD.MOD,y get access mode
|
|
523 bitb #WRITE. is it write?
|
|
524 beq Rt100Mem no, skip ahead
|
|
525 ldd PD.FD,y
|
|
526 bne Clos290
|
|
527 lda PD.FD+2,y
|
|
528 beq Rt100Mem
|
|
529 Clos290 bsr MDir263 set new file size in file descriptor
|
|
530 lbsr Gst5E5 reached EOF?
|
|
531 bcc Rt100Mem no, skip ahead
|
|
532 lbsr L0EFE
|
|
533 bra Rt100Mem skip ahead
|
|
534 Clos29C rts return
|
|
535 * Return file not accessible error
|
|
536 Clos29D ldb #E$FNA
|
|
537 ErMemRtn coma
|
|
538 Clos2A0 puls y
|
|
539
|
|
540 * Generalized return to system
|
|
541 Rt100Mem pshs b,cc preserve error status
|
|
542 ldu PD.BUF,y get sector buffer pointer
|
|
543 beq RtMem2CF none, skip ahead
|
1513
|
544 lbsr SSize +BGP+
|
|
545 * ldd #$0100 get size of sector buffer -BGP-
|
1204
|
546 os9 F$SRtMem return the memory to system
|
|
547 ldx PD.Exten,y get path extension pointer
|
|
548 beq RtMem2CF none, return
|
|
549 lbsr L0A90 scan conflict list?
|
|
550 lda PE.PE,x return path extension to system
|
|
551 ldx <D.PthDBT
|
|
552 os9 F$Ret64
|
|
553 RtMem2CF puls pc,b,cc restore error status & return
|
|
554
|
|
555 * Place date & time into file descriptor
|
|
556 L02D1 lbsr RdFlDscr read in file descriptor sector
|
|
557 ldu PD.BUF,y get pointer to it
|
|
558 lda FD.LNK,u get link count
|
|
559 ldx <D.Proc get current process pointer
|
|
560 pshs x,a preserve 'em
|
|
561 ldx <D.SysPrc switch to system process descriptor
|
|
562 stx <D.Proc
|
|
563 leax FD.DAT,u point to date last modified
|
|
564 os9 F$Time put currenttime there
|
|
565 * Gene Heskett's STUPID "LDA #$01, STA $00FF,u" CRAP went here. DAMN DAMN DAMN
|
|
566 * He's NEVER getting the RBF source again!
|
|
567 puls x,a restore link count & current process
|
|
568 stx <D.Proc
|
|
569 sta FD.LNK,u
|
|
570 rts return
|
|
571
|
|
572
|
|
573 *
|
|
574 * I$ChgDir Entry Point
|
|
575 *
|
|
576 * Entry:
|
|
577 *
|
|
578 * Exit:
|
|
579 *
|
|
580 * Error: CC Carry set
|
|
581 * B = errcode
|
|
582 *
|
|
583 ChgDir pshs y preserve path descriptor pointer
|
|
584 IFNE H6309
|
|
585 oim #$80,PD.MOD,y ensure the directory bit is set
|
|
586 ELSE
|
|
587 lda PD.MOD,y
|
|
588 ora #$80
|
|
589 sta PD.MOD,y
|
|
590 ENDC
|
|
591 lbsr Open go open the directory
|
|
592 bcs Clos2A0 exit on error
|
|
593 ldx <D.Proc get current process pointer
|
|
594 ldu PD.FD+1,y get LSW of file descriptor sector #
|
|
595 ldb PD.MOD,y get current file mode
|
|
596 bitb #UPDAT. read or write mode?
|
|
597 beq CD30D no, skip ahead
|
|
598 * Change current data dir
|
|
599 ldb PD.FD,y
|
|
600 stb P$DIO+3,x
|
|
601 stu P$DIO+4,x
|
|
602 CD30D ldb PD.MOD,y get current file mode
|
|
603 bitb #EXEC. is it execution dir?
|
|
604 beq CD31C no, skip ahead
|
|
605 * Change current execution directory
|
|
606 ldb PD.FD,y
|
|
607 stb P$DIO+9,x
|
|
608 stu P$DIO+10,x
|
|
609 CD31C clrb clear errors
|
|
610 bra Clos2A0 return to system
|
|
611
|
|
612
|
|
613 *
|
|
614 * I$Delete Entry Point
|
|
615 *
|
|
616 * Entry:
|
|
617 *
|
|
618 * Exit:
|
|
619 *
|
|
620 * Error: CC Carry set
|
|
621 * B = errcode
|
|
622 *
|
|
623 * NOTE: Bug for write protected disk has been fixed - 93/09/19
|
|
624 *
|
|
625 Delete pshs y preserve path descriptor pointer
|
|
626 lbsr FindFile does the file exist?
|
|
627 bcs Clos2A0 no, return error
|
|
628 ldd PD.FD+1,y do we have a file descriptor?
|
|
629 bne Del332 yes, skip ahead
|
|
630 tst PD.FD,y
|
|
631 IFNE H6309
|
|
632 beq Clos29D no, return not accessible error
|
|
633 ELSE
|
|
634 lbeq Clos29D
|
|
635 ENDC
|
|
636 Del332 lda #SHARE.+WRITE. get attributes to check
|
|
637 lbsr ChkAttrs can user delete ths file?
|
|
638 lbcs Clos2A0 no, return error
|
|
639 ldu PD.RGS,y get registered stack pointer
|
|
640 stx R$X,u save updated pathname pointer
|
|
641 lbsr RdFlDscr read in file descriptor
|
|
642 * BUG FIX: Below used to read 'lbcs L03D4' which expects the file descriptor
|
|
643 * sector # & a temporary buffer to be stored on the stack but it
|
|
644 * isn't there yet. Restored back to RBF 28 error handling
|
|
645 * lbcs L02B2 error, return to system (FD read error fix)
|
|
646 lbcs Del3D4 error, rturn to system (FD read error fix)
|
|
647 ldx PD.BUF,y get pointer to the file descriptor
|
|
648 dec FD.LNK,x decrement link count
|
|
649 beq Del358 down to zero, delete the file descriptor
|
|
650 lbsr L11FD write updated file descriptor
|
|
651 pshs u,x,b
|
|
652 IFNE H6309
|
|
653 clrd
|
|
654 ELSE
|
|
655 clra
|
|
656 clrb
|
|
657 ENDC
|
|
658 std $03,s
|
|
659 bra Del39F
|
|
660
|
1209
|
661
|
|
662 * Return Sector Size bits
|
|
663 * Entry:
|
|
664 * Y = path desc ptr
|
|
665 * Exit:
|
|
666 * A = sector size (0 = 256, 1 = 512, 2 = 1024, 3 = 2048)
|
|
667 SSBits lda PD.TYP,y get type byte
|
|
668 anda #TYP.SSM mask out non-sector size bits
|
|
669 lsra shift bits into place
|
|
670 rts
|
|
671
|
|
672
|
|
673 * Sector Size mask table
|
|
674 SSTable fcb $01,$02,$04,$08
|
|
675
|
|
676
|
|
677 * Return Sector Size
|
|
678 * Entry:
|
|
679 * Y = path desc ptr
|
|
680 * Exit:
|
|
681 * D = sector size (256, 512, 1024, 2048)
|
|
682 SSize pshs x
|
|
683 leax SSTable,pc
|
|
684 bsr SSBits
|
|
685 lda a,x
|
|
686 clrb
|
|
687 puls x,pc
|
|
688
|
|
689
|
1204
|
690 * RBF30 start
|
|
691 Del358 ldb PD.FD,y get LSN of file descriptor
|
|
692 ldx PD.FD+1,y
|
|
693 pshs u,x,b preserve 'em
|
1513
|
694 bsr SSize +BGP+
|
|
695 * ldd #$0100 allocate a temporary sector buffer -BGP-
|
1204
|
696 os9 F$SRqMem
|
|
697 bcc Del36C got it, skip ahead
|
|
698 IFNE H6309
|
|
699 clrd
|
|
700 ELSE
|
|
701 clra
|
|
702 clrb
|
|
703 ENDC
|
|
704 bra Del37A return with eror
|
|
705
|
|
706 Del36C stu $03,s save pointer to sector buffer
|
|
707 ldx PD.BUF,y
|
|
708 IFNE H6309
|
|
709 ldw #$0100
|
1209
|
710 DelCpy tfm x+,u+ copy the sector
|
1513
|
711 deca +BGP+
|
|
712 bne DelCpy +BGP+
|
1204
|
713 ELSE
|
1209
|
714 clrb
|
1513
|
715 pshs a +BGP+
|
1204
|
716 DelLoop lda ,x+
|
|
717 sta ,u+
|
|
718 decb
|
|
719 bne DelLoop
|
1513
|
720 dec ,s +BGP+
|
|
721 bne DelLoop +BGP+
|
|
722 puls a +BGP+
|
1204
|
723 ENDC
|
|
724 ldd $03,s
|
|
725 Del37A std $03,s save buffer pointer to U on stack
|
|
726 * Start back into RBF28 code again
|
|
727 IFNE H6309
|
|
728 clrd
|
|
729 ELSE
|
|
730 clra
|
|
731 clrb
|
|
732 ENDC
|
|
733 std PD.SIZ,y set file size to zero
|
|
734 std PD.SIZ+2,y
|
|
735 lbsr L0EFE set the file size to PD.SIZ
|
|
736 bcs Del3EF
|
|
737 ldb PD.FD,y grab file descriptor sector number
|
|
738 ldx PD.FD+1,y
|
|
739 stb PD.SBP,y copy it to the segment beginning sector number
|
|
740 stx PD.SBP+1,y
|
|
741 ldx PD.BUF,y point to the buffer
|
|
742 * RBF34
|
|
743 * LDD $13,X : FD.SEG+3, grab the size of the FIRST segment of the file
|
|
744 * addd #$0001
|
|
745 * THEN std PD.SSZ+1,y
|
|
746 *
|
|
747 * Why? RBF automatically makes the FIRST SEGMENT of the file fill the rest
|
|
748 * of the cluster that was allocated for the file descriptor.
|
|
749 * Why not LDX PD.DTB,y LDD DD.BIT,x ???
|
|
750 *
|
|
751 * Gene H: My problem with this fix from rbf28 is in proving to me
|
|
752 * $13,x is the correct location to read! I can't seem to find
|
|
753 * the defines to match the $13,x address.
|
|
754 * ldd FD.SEG+FDSL.B,x grab the size of the first segment
|
|
755 ldd <$13,x this code is REQUIRED for multiple
|
|
756 IFNE H6309
|
|
757 incd sector/cluster operation, don't remove!
|
|
758 ELSE
|
|
759 addd #$0001 sector cluster operation, DO NOT REMOVE!
|
|
760 ENDC
|
|
761 std PD.SSZ+1,y
|
|
762 lbsr ClrFBits delete a segment
|
|
763 Del39F bcs Del3EF
|
|
764 lbsr L1237 flush the sector
|
|
765 lbsr L0A90
|
|
766 lda PD.DFD,y
|
|
767 sta PD.FD,y
|
|
768 ldd PD.DFD+1,y
|
|
769 std PD.FD+1,y
|
|
770 lbsr RdFlDscr get the file descriptor
|
|
771 bcs Del3EF
|
|
772 lbsr L0A2A
|
|
773 ldu PD.BUF,y
|
|
774 lbsr Open1CE update PD entries from FD entries
|
|
775 IFNE H6309
|
|
776 ldq PD.DCP,y get current directory entry pointer
|
|
777 stq PD.CP,y save it as current pointer
|
|
778 ELSE
|
|
779 ldd PD.DCP,y
|
|
780 std PD.CP,y
|
|
781 ldd PD.DCP+2,y
|
|
782 std PD.CP+2,y
|
|
783 ENDC
|
|
784 lbsr L0957 read in the directory sector
|
|
785 bcs Del3EF
|
|
786 clr ,x clear first byte of filename in directory entry
|
|
787 lbsr L1205 flush the sector to disk
|
|
788 * RBF30 start
|
|
789 Del3D4 ldu $03,s get temporary sector buffer pointer
|
|
790 * the patch at Del3EF-3F9 munged the stack for this one - GH
|
|
791 beq Del3F9 none allocated, return to process
|
|
792 ldb ,s get the old file descriptor logical sector #
|
|
793 ldx $01,s
|
|
794 stb PD.FD,y put it back into path descriptor
|
|
795 stx PD.FD+1,y
|
|
796 ldx PD.BUF,y get current sector buffer pointer
|
|
797 stx 1,s save it a sec
|
|
798 stu PD.BUF,y put original sector pointer into path descriptor
|
|
799 lbsr L11FD write the old file descriptor to disk
|
|
800 ldu 1,s get temporary sector pointer
|
|
801 stu PD.BUF,y save it as current
|
|
802 Del3EF pshs b,cc preserve rror status & code if any (WP bug fix - raises stack offsets+2)
|
|
803 ldu $05,s get temporary sector buffer pointer (this was a 3)
|
|
804 beq Del3F5 didn't allocate one, skip ahead (different, new label! no mem to return)
|
1513
|
805 lbsr SSize +BGP+
|
|
806 * ldd #$0100 get size of it -BGP-
|
1204
|
807 os9 F$SRtMem return the memory back to the system
|
|
808 Del3F5 puls b,cc restore error status & code (WP bug fix)
|
|
809 Del3F9 leas 5,s purge stack
|
|
810 * Start back into RBF28 code
|
|
811 lbra Clos2A0 return to system
|
|
812
|
|
813
|
|
814 *
|
|
815 * I$Seek Entry Point
|
|
816 *
|
|
817 * Entry:
|
|
818 *
|
|
819 * Exit:
|
|
820 *
|
|
821 * Error: CC Carry set
|
|
822 * B = errcode
|
|
823 *
|
|
824 Seek ldb PD.SMF,y get state flags
|
|
825 bitb #SINBUF do we have a sector in buffer?
|
|
826 beq Seek417 no, skip ahead
|
|
827 lda R$X+1,u calculate if we need a new sector
|
|
828 ldb R$U,u
|
|
829 subd PD.CP+1,y
|
|
830 bne Seek412
|
|
831 lda R$X,u
|
|
832 sbca PD.CP,y
|
|
833 beq Seek41B no need to get another sector, skip ahead
|
|
834 Seek412 lbsr L1237 flush the current sector to disk
|
|
835 bcs Seek41F
|
|
836 Seek417 ldd R$X,u get & set new file pointer
|
|
837 std PD.CP,y
|
|
838 Seek41B ldd R$U,u
|
|
839 std PD.CP+2,y
|
|
840 Seek41F rts return
|
|
841
|
|
842
|
|
843 *
|
|
844 * I$ReadLn Entry Point
|
|
845 *
|
|
846 * Entry:
|
|
847 *
|
|
848 * Exit:
|
|
849 *
|
|
850 * Error: CC Carry set
|
|
851 * B = errcode
|
|
852 *
|
|
853 ReadLn bsr RdLn463 check if record locked for amount to be read
|
|
854 beq RdLn446 zero bytes to read, return
|
|
855 bsr RdLn447
|
|
856 pshs u,y,x,b,a
|
|
857 exg x,u
|
|
858 IFNE H6309
|
|
859 tfr 0,y smaller, same speed as LDY #$0000
|
|
860 ELSE
|
|
861 ldy #$0000
|
|
862 ENDC
|
|
863 lda #$0D a carriage return
|
|
864 RdLn430 leay 1,y go up one byte
|
|
865 cmpa ,x+ is it a CR?
|
|
866 beq RdLn439 yes, we're done
|
|
867 decb count down
|
|
868 bne RdLn430 until done one sector, at least
|
|
869 RdLn439 ldx 6,s get old U
|
|
870 bsr RdLn49B move bytes from the system to user
|
|
871 sty $0A,s save Y on-stack, above calling routine????
|
|
872 puls u,y,x,b,a restore registers
|
|
873 ldd $02,s get old saved Y from above
|
|
874 * addr d,x
|
|
875 leax d,x point to how many bytes we've read
|
|
876 RdLn446 rts and exit
|
|
877
|
|
878 RdLn447 lbsr Read4D3 do reading, calling this routine back again
|
|
879 leax -1,x back up a byte
|
|
880 lbsr L097F get a byte from another task (F$LDABX)
|
|
881 cmpa #$0D is it a CR?
|
|
882 beq RdLn459 yes, skip ahead
|
|
883 ldd $02,s check data saved on-stack???
|
|
884 bne Read4D9 if not zero, skip ahead
|
|
885 RdLn459 ldu PD.RGS,y grab caller's register stack
|
|
886 ldd R$Y,u get number of bytes to read
|
|
887 subd $02,s take out data read last sector??
|
|
888 std R$Y,u save as data bytes to read
|
|
889 bra Read4C0 skip ahead
|
|
890
|
|
891 * Calculate if read will be record locked with another process
|
|
892 * Entry: U=Register stack pointer
|
|
893 RdLn463 ldd R$Y,u get requested read length
|
|
894 lbsr L0B0C record locked with somebody else?
|
|
895 bcs RdLn497 yes, return deadlock error
|
|
896 ldd R$Y,u get requested read length
|
|
897 bsr RdLn473 calculate if we will have an EOF error
|
|
898 bcs RdLn497 we did, return error
|
|
899 std R$Y,u save # bytes available
|
|
900 rts return
|
|
901
|
|
902 * Calculate if read length will overrun file length
|
|
903 * Entry: D=Requested # bytes to read from file
|
|
904 * Exit : D=# bytes available
|
|
905 RdLn473 pshs d preserve length
|
|
906 IFNE H6309
|
|
907 ldq PD.SIZ,y get current file size
|
|
908 subw PD.CP+2,y subtract off LSW of current byte pointer
|
|
909 tfr w,x save it in the old register
|
|
910 sbcd PD.CP,y subtract off current byte pointer
|
|
911 ELSE
|
|
912 ldd PD.SIZ+2,y
|
|
913 subd PD.CP+2,y
|
|
914 tfr d,x
|
|
915 ldd PD.SIZ,y
|
|
916 sbcb PD.CP+1,y
|
|
917 sbca PD.CP,y
|
|
918 ENDC
|
|
919 bcs RdLn494 it will overrun, return EOF error
|
|
920 bne RdLn491 some bytes left, return OK
|
|
921 tstb
|
|
922 bne RdLn491
|
|
923 cmpx ,s do we have enough bytes?
|
|
924 bhs RdLn491 yes, return OK
|
|
925 stx ,s save # bytes available
|
|
926 beq RdLn494 it's 0, return EOF error
|
|
927 RdLn491 clrb clear error status
|
|
928 puls pc,b,a retrieve # bytes & return
|
|
929 * Return EOF error
|
|
930 RdLn494 comb set carry for error
|
|
931 ldb #E$EOF get error code
|
|
932 RdLn497 leas $02,s purge length off stack
|
|
933 bra Read4C5 return
|
|
934
|
|
935 * Move bytes from system to user
|
|
936 * Entry: X=Source pointer
|
|
937 * Y=Byte count
|
|
938 * U=Destination pointer
|
|
939 RdLn49B pshs x
|
|
940 ldx <D.Proc get current process pointer
|
|
941 lda <D.SysTsk get source task #
|
|
942 ldb P$Task,x get destination task #
|
|
943 puls x
|
|
944 os9 F$Move move 'em
|
|
945 rts return
|
|
946
|
|
947
|
|
948 *
|
|
949 * I$Read Entry Point
|
|
950 *
|
|
951 * Entry:
|
|
952 *
|
|
953 * Exit:
|
|
954 *
|
|
955 * Error: CC Carry set
|
|
956 * B = errcode
|
|
957 *
|
|
958 Read bsr RdLn463 record locked?
|
|
959 beq Read4BB no, allow it
|
|
960 bsr Read4BC do reading
|
|
961 Read4AF pshs u,y,x,b,a save data on the stack
|
|
962 exg x,u
|
|
963 tfr d,y
|
|
964 bsr RdLn49B move bytes from system to user
|
|
965 puls u,y,x,b,a restore registers
|
|
966 * addr d,x
|
|
967 leax d,x point to end of data copied?
|
|
968 Read4BB rts
|
|
969
|
|
970 Read4BC bsr Read4D3 do some reading/writing
|
|
971 bne Read4D9 not done, continue
|
|
972 Read4C0 clrb
|
|
973 Read4C1 leas -2,s clear out crap on the stack
|
|
974 Read4C3 leas $0A,s
|
|
975 * Error processor for read & write
|
|
976 Read4C5 pshs b,cc preserve error status
|
|
977 lda PD.MOD,y get file mode
|
|
978 bita #WRITE. was it write?
|
|
979 bne Read4D0 yes, return
|
|
980 lbsr L0B02 clear lock status, and send signals
|
|
981 Read4D0 puls b,cc,pc restore & return
|
|
982
|
|
983 * do reading/writing
|
|
984 Read4D3 ldd R$X,u get caller's buffer pointer
|
|
985 ldx R$Y,u get length of read
|
|
986 pshs x,b,a preserve 'em
|
|
987 Read4D9 lda PD.SMF,y get stat flags
|
|
988 bita #SINBUF sector in buffer/
|
|
989 bne Read4F9 yes, read it
|
|
990 tst PD.CP+3,y read pointer on even sector?
|
|
991 bne Read4F4 no, skip ahead
|
|
992 tst $02,s MSB of length have anything?
|
|
993 beq Read4F4 no, skip ahead
|
|
994 leax >Writ571,pcr WritLn or ReadLn?
|
|
995 cmpx $06,s check the stack
|
|
996 bne Read4F4 skipahead
|
|
997 lbsr L1098 find a segment
|
|
998 bra Read4F7
|
|
999
|
|
1000 Read4F4 lbsr L1256
|
|
1001 Read4F7 bcs Read4C1
|
|
1002 Read4F9 ldu PD.BUF,y get sector buffer pointer
|
|
1003 clra
|
|
1004 ldb PD.CP+3,y
|
|
1005 * addr d,u
|
|
1006 leau d,u point to offset within the buffer
|
|
1007 negb get D=number of byte left to read in the sector?
|
|
1008 sbca #$FF not quite sure what this is...
|
|
1009 ldx ,s grab caller's buffer pointer
|
|
1010 cmpd $02,s check bytes left in sector against number to read
|
|
1011 bls Read50C lower, OK
|
|
1012 ldd $02,s grab number of bytes to read
|
|
1013 Read50C pshs b,a save
|
|
1014 jsr [$08,s] call our calling routine!
|
|
1015 stx $02,s save new address to write to on-stack
|
|
1016 IFNE H6309
|
|
1017 aim #^BufBusy,PD.SMF,y
|
|
1018 ELSE
|
|
1019 ldb PD.SMF,y
|
|
1020 andb #^BufBusy
|
|
1021 stb PD.SMF,y
|
|
1022 ENDC
|
|
1023 ldb $01,s get LSB of bytes read
|
|
1024 addb PD.CP+3,y add it to current pointer
|
|
1025 stb PD.CP+3,y save new file position
|
|
1026 bne Read530 didn't grab whole sector, skip ahead
|
|
1027 lbsr L1237 flush the sector
|
|
1028 inc PD.CP+2,y add
|
|
1029 bne Read52E
|
|
1030 inc PD.CP+1,y
|
|
1031 bne Read52E
|
|
1032 inc PD.CP,y
|
|
1033 Read52E bcs Read4C3
|
|
1034 Read530 ldd $04,s grab number of bytes to read/write
|
|
1035 subd ,s++ take out number we've read/written
|
|
1036 std $02,s save on-stack
|
|
1037 jmp [$04,s] go back to calling routine with D,X on-stack
|
|
1038
|
|
1039
|
|
1040 *
|
|
1041 * I$WritLn Entry Point
|
|
1042 *
|
|
1043 * Entry:
|
|
1044 *
|
|
1045 * Exit:
|
|
1046 *
|
|
1047 * Error: CC Carry set
|
|
1048 * B = errcode
|
|
1049 *
|
|
1050 WriteLn pshs y save PD pointer
|
|
1051 clrb
|
|
1052 ldy R$Y,u grab size of data to write
|
|
1053 beq WtLn55E exit if none
|
|
1054 ldx <D.Proc get process descriptor pointer
|
|
1055 ldb P$Task,x grab task number
|
|
1056 ldx R$X,u and where to get data from
|
|
1057 * ATD: Could make this quite a bit larger, and probably faster, by doing the
|
|
1058 * PipeMan-style copy 32 bytes onto the stack via F$Move, and check that.
|
|
1059 * Doing F$LDABX for a lot of data is _really_ slow. PipeMan test indicate
|
|
1060 * that it could probably double in speed...
|
|
1061 WtLn547 leay -$01,y back up one byte
|
|
1062 beq WtLn55E if done, exit
|
|
1063 os9 F$LDABX grab one byte from the user
|
|
1064 leax $01,x go up a byte
|
|
1065 cmpa #$0D is it a CR?
|
|
1066 bne WtLn547 no, keep it up until done
|
|
1067 tfr y,d get number of bytes left
|
|
1068 nega \
|
|
1069 * a negd was tried here, but may have caused runaway writes>64k
|
|
1070 negb / invert it
|
|
1071 sbca #$00
|
|
1072 addd R$Y,u add to bytes to write
|
|
1073 std R$Y,u save new number of bytes to write
|
|
1074 WtLn55E puls y restore PD pointer, and fall through to Write
|
|
1075
|
|
1076
|
|
1077 *
|
|
1078 * I$Write Entry Point
|
|
1079 *
|
|
1080 * Entry:
|
|
1081 *
|
|
1082 * Exit:
|
|
1083 *
|
|
1084 * Error: CC Carry set
|
|
1085 * B = errcode
|
|
1086 *
|
|
1087 Write ldd R$Y,u get size of write
|
|
1088 lbsr L0B0C wait for I/O lock
|
|
1089 bcs Writ598 error, return
|
|
1090 ldd R$Y,u get size again
|
|
1091 beq Writ597 zero, nothing to write so return
|
|
1092 bsr Writ599 expand the file if needed
|
|
1093 bcs Writ598 error on expand, return
|
|
1094 bsr Writ582
|
|
1095 Writ571 pshs y,b,a
|
|
1096 tfr d,y
|
|
1097 bsr Writ5CB
|
|
1098 puls y,b,a
|
|
1099 leax d,x
|
|
1100 IFNE H6309
|
|
1101 oim #(BUFMOD!SINBUF),PD.SMF,y
|
|
1102 ELSE
|
|
1103 pshs a
|
|
1104 lda PD.SMF,y
|
|
1105 ora #(BUFMOD!SINBUF)
|
|
1106 sta PD.SMF,y
|
|
1107 puls a
|
|
1108 ENDC
|
|
1109 rts
|
|
1110
|
|
1111 Writ582 lbsr Read4D3 go read stuff
|
|
1112 lbne Read4D9
|
|
1113 leas $08,s skip stuff on stack
|
|
1114 ldy PD.Exten,y
|
|
1115 lda #$01
|
|
1116 lbsr L0AD1
|
|
1117 ldy PE.PDptr,y
|
|
1118 Writ597 clrb
|
|
1119 Writ598 rts
|
|
1120
|
|
1121 * Add bytes to current file position with file length extension
|
|
1122 * Entry: D=# bytes to add
|
|
1123 Writ599 addd PD.CP+2,y add length to LSW of current pointer
|
|
1124 tfr d,x copy it
|
|
1125 ldd PD.CP,y get MSW
|
|
1126 IFNE H6309
|
|
1127 adcd #0 add in any carry from above
|
|
1128 ELSE
|
|
1129 adcb #0
|
|
1130 adca #0
|
|
1131 ENDC
|
|
1132 Writ5A3 cmpd PD.SIZ,y MSW past eof?
|
|
1133 bcs Writ597 no, return
|
|
1134 bhi Writ5AF yes, add a sector
|
|
1135 cmpx PD.SIZ+2,y LSW past eof?
|
|
1136 bls Writ597 no, return
|
|
1137 Writ5AF pshs u preserve U
|
|
1138 ldu PD.SIZ+2,y get LSW of current size
|
|
1139 stx PD.SIZ+2,y save new size
|
|
1140 ldx PD.SIZ,y get MSW of new size
|
|
1141 std PD.SIZ,y save new size
|
|
1142 * ATD: L0C6F looks like it already saves U and X, so saving them here is
|
|
1143 * unnecessary.
|
|
1144 pshs u,x preserve old size
|
|
1145 lbsr L0C6F allocate new size of file
|
|
1146 puls u,x restore old size
|
|
1147 bcc Writ5C9 no error from allocate, return
|
|
1148 stx PD.SIZ,y put old size back
|
|
1149 stu PD.SIZ+2,y
|
|
1150 Writ5C9 puls pc,u restore U & return
|
|
1151
|
|
1152 * Move bytes from user to system
|
|
1153 * Entry: X=Source pointer
|
|
1154 * Y=Byte count
|
|
1155 * U=Destination pointer
|
|
1156 Writ5CB pshs x
|
|
1157 ldx <D.Proc get source task #
|
|
1158 lda P$Task,x
|
|
1159 ldb <D.SysTsk get destination task #
|
|
1160 puls x
|
|
1161 os9 F$Move move 'em
|
|
1162 rts return
|
|
1163
|
|
1164
|
|
1165 *
|
|
1166 * I$GetStat Entry Point
|
|
1167 *
|
|
1168 * Entry:
|
|
1169 *
|
|
1170 * Exit:
|
|
1171 *
|
|
1172 * Error: CC Carry set
|
|
1173 * B = errcode
|
|
1174 *
|
|
1175 GetStat ldb R$B,u get function code
|
|
1176 beq Gst5FF it's SS.Opt, go process
|
|
1177
|
1513
|
1178 * SS.Opt
|
1204
|
1179 * Entry A=path number
|
|
1180 * B=$00
|
|
1181 * X=address to put 32 byte packet
|
|
1182 cmpb #SS.EOF EOF check?
|
|
1183 bne Gst5EB no, skip ahead
|
|
1184 clr R$B,u default to no EOF
|
|
1185 Gst5E5 clra get length & clear carry
|
|
1186 ldb #$01
|
|
1187 lbra RdLn473 go calculate EOF status & return
|
|
1188
|
|
1189 * SS.Ready
|
|
1190 * check for data avail on dev
|
|
1191 * Entry A=path number
|
|
1192 * B=$01
|
|
1193 Gst5EB cmpb #SS.Ready is it SS.Ready?
|
|
1194 bne Gst5F2 no, keep checking
|
|
1195 clr R$B,u always mark no data ready
|
|
1196 rts
|
|
1197
|
|
1198 * SS.SIZ
|
|
1199 * Entry A=path num
|
|
1200 * B=$02
|
|
1201 * Exit X=msw of files size
|
|
1202 * U=lsw of files size
|
|
1203 Gst5F2 cmpb #SS.Size is it SS.Size?
|
|
1204 bne Gst600 no, keep checking
|
|
1205 IFNE H6309
|
|
1206 * faster and smaller than 2 LDD's, PD.SIZ+2 >$0F, so we can't use short n,R
|
|
1207 ldq PD.SIZ,y get current file size
|
|
1208 Gst5F8 std R$X,u save to the user
|
|
1209 stw R$U,u save LSW
|
|
1210 ELSE
|
|
1211 ldd PD.SIZ,y
|
|
1212 std R$X,u
|
|
1213 ldd PD.SIZ+2,y
|
|
1214 std R$U,u
|
|
1215 ENDC
|
|
1216 Gst5FF rts return
|
|
1217
|
1513
|
1218 * SS.Pos
|
1204
|
1219 * Entry A=path num
|
|
1220 * B=$05
|
|
1221 * Exit X=msw of pos
|
|
1222 * U=lsw of pos
|
1513
|
1223 Gst600 cmpb #SS.Pos is it SS.Pos?
|
1204
|
1224 bne Gst60D no, keep checking
|
|
1225 IFNE H6309
|
|
1226 * use 2 LDD, STD, same size as ldq/std/stw, PD.CP+2 <$0F, we can use short n,R
|
|
1227 ldq PD.CP,y get current file pointer
|
|
1228 bra Gst5F8
|
|
1229 ELSE
|
|
1230 ldd PD.CP,y get current file pointer
|
|
1231 std R$X,u save MSW
|
|
1232 ldd PD.CP+2,y get current file pointer
|
|
1233 std R$U,u save LSW
|
|
1234 rts
|
|
1235 ENDC
|
|
1236
|
|
1237 * Getstt(SS.FD)
|
|
1238 * Entry: R$A = Path #
|
|
1239 * R$B = SS.FD ($0F)
|
|
1240 * R$X = ptr to 256 byte buffer
|
|
1241 * R$Y = # of bytes of FD required
|
|
1242 Gst60D cmpb #SS.FD is it SS.FD?
|
|
1243 bne Gst627 no, keep checking
|
|
1244 lbsr RdFlDscr go get file descriptor
|
|
1245 bcs Gst5FF exit on error
|
|
1246 ldu PD.RGS,y get register stack pointer
|
|
1247 ldd R$Y,u get # bytesof FD he wants
|
|
1248 tsta legal value?
|
|
1249 beq Gst620 yes, skip ahead
|
|
1250 ldd #$0100 get max size of FD
|
|
1251 Gst620 ldx R$X,u get pointer
|
|
1252 ldu PD.BUF,y get pointer to FD
|
|
1253 lbra Read4AF move it to user space
|
|
1254
|
|
1255 * Getstt(SS.FDInf)
|
|
1256 * Entry: R$A = Path #
|
|
1257 * R$B = SS.FDInf ($20)
|
|
1258 * R$X = ptr to 256 byte buffer
|
|
1259 * R$Y = msb - Length of read
|
|
1260 * lsb - MSB of LSN
|
|
1261 * R$U = LSW of LSN
|
|
1262 Gst627 cmpb #SS.FDInf SS.FDInf?
|
|
1263 bne Gst640 no, let driver handle it
|
|
1264 lbsr L1237 check for sector flush
|
|
1265 bcs Gst5FF
|
|
1266 ldb R$Y,u get MSB of sector #
|
|
1267 ldx R$U,u get LSW of sector #
|
|
1268 lbsr L113A read the sector
|
|
1269 bcs Gst5FF error, return
|
|
1270 ldu PD.RGS,y get register stack pointer
|
|
1271 ldd R$Y,u get length of data to move
|
|
1272 clra clear MSB
|
|
1273 bra Gst620 move it to user
|
|
1274
|
|
1275 * Let driver handle the rest
|
|
1276 Gst640 lda #D$GSTA get getstat function offset
|
|
1277 lbra L113C send it to driver
|
|
1278
|
|
1279
|
|
1280 *
|
|
1281 * I$SetStat Entry Point
|
|
1282 *
|
|
1283 * Entry:
|
|
1284 *
|
|
1285 * Exit:
|
|
1286 *
|
|
1287 * Error: CC Carry set
|
|
1288 * B = errcode
|
|
1289 *
|
|
1290 SetStat ldb R$B,u get function code
|
1513
|
1291 * TODO: remove next line since SS.Opt is 0
|
|
1292 cmpb #SS.Opt
|
|
1293 bne Sst659 not SS.Opt, skip ahead
|
1204
|
1294 ldx R$X,u get pointer to option packet
|
|
1295 leax $02,x skip device type and drive #
|
|
1296 leau PD.STP,y get pointer to start of data
|
|
1297 ldy #(PD.TFM-PD.STP) get # bytes to move (not including PD.TFM)
|
|
1298 lbra Writ5CB move 'em & return
|
|
1299
|
|
1300 * SS.Size
|
|
1301 Sst659 cmpb #SS.Size is it SS.Size?
|
|
1302 bne Sst69B
|
|
1303 ldd PD.FD+1,y is there a file descriptor?
|
|
1304 bne Sst669
|
|
1305 tst PD.FD,y
|
|
1306 lbeq Sst7A8 no, return error
|
|
1307 Sst669 lda PD.MOD,y get file mode
|
|
1308 bita #WRITE. is it write?
|
|
1309 beq Sst697 no, return error
|
|
1310 ldd R$X,u get MSW of new size
|
|
1311 ldx R$U,u get LSW of new size
|
|
1312 cmpd PD.SIZ,y
|
|
1313 bcs Sst682
|
|
1314 bne Sst67F
|
|
1315 cmpx PD.SIZ+2,y
|
|
1316 bcs Sst682
|
|
1317 * New size is larger
|
|
1318 Sst67F lbra Writ5A3 add new size to file
|
|
1319 * New size is smaller
|
|
1320 Sst682 std PD.SIZ,y
|
|
1321 stx PD.SIZ+2,y
|
|
1322 ldd PD.CP,y
|
|
1323 ldx PD.CP+2,y
|
|
1324 pshs x,b,a
|
|
1325 lbsr L0EFE delete from end of the file
|
|
1326 puls u,x
|
|
1327 stx PD.CP,y restore current position
|
|
1328 stu PD.CP+2,y
|
|
1329 rts
|
|
1330 * Return bad mode error
|
|
1331 Sst697 comb set carry
|
|
1332 ldb #E$BMode get bad mod error
|
|
1333 Sst69A rts return
|
|
1334
|
|
1335 * SetStt(SS.FD) #$0F - returns FD to disk
|
|
1336 * Entry: R$A = Path #
|
|
1337 * R$B = SS.FD ($0F)
|
|
1338 * R$X = ptr to 256 byte buffer
|
|
1339 * R$Y = # bytes to write
|
|
1340 Sst69B cmpb #SS.FD is it SS.FD?
|
|
1341 bne Sst6D9 no, keep checking
|
|
1342 lda PD.MOD,y
|
|
1343 bita #WRITE. is it write mode?
|
|
1344 beq Sst697 no, return bad mode error
|
|
1345 lbsr RdFlDscr read in file descriptor
|
|
1346 bcs Sst69A error, return
|
|
1347 pshs y preserve path descriptor pointer
|
|
1348 ldx R$X,u get pointer to caller's buffer
|
|
1349 ldu PD.BUF,y get pointer to FD
|
|
1350 ldy <D.Proc get current process pointer
|
|
1351 ldd P$User,y get user #
|
|
1352 bne Sst6BC not super user, skip ahead
|
|
1353 * Change owner of file
|
|
1354 ldd #$0102 get offset & # of bytes to move
|
|
1355 bsr Sst6CB
|
|
1356 * Change date last modified
|
|
1357 Sst6BC ldd #$0305
|
|
1358 bsr Sst6CB
|
|
1359 * Change creation date
|
|
1360 ldd #$0D03
|
|
1361 bsr Sst6CB
|
|
1362 puls y
|
|
1363 lbra L11FD
|
|
1364 * Offset into FD sector
|
|
1365 * Entry: A=# bytes to offset
|
|
1366 * B=# bytes to put
|
|
1367 Sst6CB pshs u,x
|
|
1368 leax a,x
|
|
1369 leau a,u
|
|
1370 clra
|
|
1371 tfr d,y
|
|
1372 lbsr Writ5CB
|
|
1373 puls pc,u,x
|
|
1374
|
|
1375 Sst6D9 cmpb #SS.Lock is it SS.Lock?
|
|
1376 bne Sst6F8 no, keep checking
|
|
1377 ldd R$U,u get MSW of size
|
|
1378 ldx R$X,u get LSW of size
|
|
1379 cmpx #$FFFF lock whole file?
|
|
1380 bne Sst6F5 no, skip ahead
|
|
1381 cmpx R$U,u
|
|
1382 bne Sst6F5 after this line, we're SURE that D=$FFFF
|
|
1383 ldu PD.Exten,y
|
|
1384 IFNE H6309
|
|
1385 oim #FileLock,PE.Lock,u
|
|
1386 ELSE
|
|
1387 lda PE.Lock,u
|
|
1388 ora #FileLock
|
|
1389 sta PE.Lock,u
|
|
1390 ENDC
|
|
1391 * ATD: This next line is unnecessary after the check done, above
|
|
1392 lda #$FF ?? if X=$FFFF, then D=$FFFF too.
|
|
1393 Sst6F5 lbra L0B1B
|
|
1394
|
|
1395 * SS.Ticks
|
|
1396 Sst6F8 cmpb #SS.Ticks is it SS.Ticks?
|
|
1397 bne Sst705 no, keep checking
|
|
1398 ldd R$X,u get # of ticks
|
|
1399 ldx PD.Exten,y put it into path extension
|
|
1400 std PE.TmOut,x
|
|
1401 rts return
|
|
1402
|
|
1403 * SS.RsBit
|
|
1404 Sst705 cmpb #SS.RsBit reserve bitmap sector?
|
|
1405 bne Sst715 no, keep checking
|
|
1406 ldx PD.DTB,y get drive table pointer
|
|
1407 lda R$X+1,u get sector #
|
|
1408 sta V.ResBit,x put it into drive table
|
|
1409 clr V.MapSct,x clear mapped sector
|
|
1410 Sst714 rts return
|
|
1411
|
|
1412 * SS.Attr
|
|
1413 Sst715 cmpb #SS.Attr is it SS.Attr?
|
|
1414 bne Sst784 no, keep checking
|
|
1415 lbsr RdFlDscr get the file descriptor from drive
|
|
1416 bcs Sst714 error, return
|
|
1417 ldx <D.Proc get pointer to current process
|
|
1418 * Note, should'nt this be lda? User number is 8 bits, not 16
|
|
1419 ldd P$User,x get user number
|
|
1420 beq Sst72A it's super user, skip ahead
|
|
1421 ldx PD.BUF,y get pointer to FD
|
|
1422 cmpd FD.OWN,x user # match owner of file?
|
|
1423 bne Sst780 no, return not accessible error
|
|
1424 Sst72A lda R$X+1,u get attributes from caller
|
|
1425 tfr a,b copy it
|
|
1426 ldu PD.BUF,y get pointer to FD
|
|
1427 eorb FD.ATT,u directory bit set?
|
|
1428 bpl Sst77B no, save new attributes & return
|
|
1429 tsta is user setting directory bit?
|
|
1430 bmi Sst764 yes, return directory not empty error
|
|
1431 * Directory attributes changing, check if it's root dir
|
|
1432 ldx PD.DTB,y get pointer to drive table
|
|
1433 ldd DD.DIR,x get MSW of sector # to root directory
|
|
1434 cmpd PD.FD,y match current FD sector #?
|
|
1435 bne Sst749 no, skip ahead
|
|
1436 ldb DD.DIR+2,x get LSB of sector # to root directory
|
|
1437 cmpb PD.FD+2,y match current FD sector #?
|
|
1438 beq Sst780 yes, return not accessible error
|
|
1439 * Scan directory to see if there's any files and/or directories
|
|
1440 Sst749 ldb PD.CP,y get current directory entry pointer
|
|
1441 ldx PD.CP+1,y
|
|
1442 pshs x,b preserve it
|
|
1443 * ATD: there should be a CLRD here
|
|
1444 std PD.CP,y ??? This code doesn't look correct...
|
|
1445 * ATD: should be DIR.SZ*2: so we skip '..' and '.'
|
|
1446 ldb #DIR.SZ
|
|
1447 std PD.CP+2,y
|
|
1448 Sst755 lbsr L0942 move to next filename in directory
|
|
1449 bcs Sst768 error in read, check for EOF
|
|
1450 tst ,x filename exist?
|
|
1451 beq Sst755 no, keep looking
|
|
1452 puls x,b restore current pointer
|
|
1453 stb PD.CP,y
|
|
1454 stx PD.CP+1,y
|
|
1455 * Report directory not empty error
|
|
1456 Sst764 ldb #E$DNE get directory not empty error
|
|
1457 bra Sst782 return
|
|
1458 Sst768 puls x,a restore current pointer
|
|
1459 sta PD.CP,y
|
|
1460 stx PD.CP+1,y
|
|
1461 cmpb #E$EOF at the end of directory?
|
|
1462 bne Sst782 no, some other error
|
|
1463 lbsr RdFlDscr get file descriptor from drive
|
|
1464 ldu PD.BUF,y get sector pointer
|
|
1465 ldx PD.RGS,y get register stack pointer
|
|
1466 lda R$X+1,x get attributes
|
|
1467 Sst77B sta FD.ATT,u set 'em
|
|
1468 lbra L11FD write FD to disk & return
|
|
1469 * Return file not accessible
|
|
1470 Sst780 ldb #E$FNA get file not accessible error
|
|
1471 Sst782 coma set carry
|
|
1472 rts return
|
|
1473
|
|
1474 * SetStt(SS.FSig)
|
|
1475 Sst784 cmpb #SS.FSig SS.FSig send signal on write
|
|
1476 bne Sst7A3
|
|
1477 lda PD.ATT,y
|
|
1478 bita #SHARE.
|
|
1479 lbne L0A8B
|
|
1480 ldx PD.Exten,y
|
|
1481 lda R$X+1,u
|
|
1482 sta PE.SigSg,x
|
|
1483 ldu <D.Proc
|
|
1484 lda P$ID,u was <P$ID,u
|
|
1485 sta PE.SigID,x
|
|
1486 clrb
|
|
1487 rts
|
|
1488
|
|
1489 Sst7A3 lda #D$PSTA call the driver SetStt routine
|
|
1490 lbra L113C
|
|
1491
|
|
1492 Sst7A8 comb
|
|
1493 ldb #E$UnkSvc unknown service request
|
|
1494 Sst7AB rts
|
|
1495
|
|
1496
|
|
1497 * Find a file in current data/execution directory
|
|
1498 * Called by Create/Open & Delete
|
|
1499 *
|
|
1500 * Entry: U=caller's stack reg. ptr
|
|
1501 * Y=Path dsc. ptr
|
1209
|
1502 FindFile
|
1513
|
1503 lbsr SSize +BGP+
|
|
1504 * ldd #$0100 get size of sector -BGP-
|
1204
|
1505 * Note, following line is stb PD.SMF,y in v30!
|
|
1506 stb PD.FST,y clear state flags??
|
1209
|
1507 os9 F$SRqMem request a 256 byte sector buffer
|
1204
|
1508 bcs Sst7AB couldn't get memory, return with error
|
|
1509 stu PD.BUF,y save ptr to sector buffer
|
|
1510 leau ,y point U to path descriptor
|
|
1511 ldx <D.PthDBT get ptr to path escriptor block tables
|
|
1512 os9 F$All64 allocate path descriptor
|
|
1513 exg y,u exchange pointers
|
|
1514 bcs Sst7AB couldn't get path descriptor, return error
|
|
1515 stu PD.Exten,y save pointer to path extension
|
|
1516 clr PE.SigID,u clear send signal proc. ID
|
|
1517 sty PE.PDptr,u save back pointer to path descriptor
|
|
1518 stu PE.Wait,u init waiting extension to myself
|
|
1519 ldx PD.RGS,y get register stack pointer
|
|
1520 ldx R$X,x get pointer to pathname
|
|
1521 pshs u,y,x
|
|
1522 leas -$04,s make a buffer
|
|
1523 IFNE H6309
|
|
1524 clrd
|
|
1525 ELSE
|
|
1526 clra
|
|
1527 clrb
|
|
1528 ENDC
|
|
1529 sta PD.FD,y init file descriptor logical sector #
|
|
1530 std PD.FD+1,y
|
|
1531 std PD.DSK,y init disk ID
|
|
1532 lbsr L097F get a byte from caller's X
|
|
1533 sta ,s save it
|
1209
|
1534 cmpa #PDELIM is it a device?
|
1204
|
1535 bne Sst7FB no, skip ahead
|
|
1536 lbsr GtDvcNam go parse it
|
|
1537 sta ,s save last character
|
|
1538 lbcs L090D error in parse, return
|
|
1539 leax ,y point X to last character
|
|
1540 ldy $06,s get path descriptor pointer
|
|
1541 bra Sst81E skip ahead
|
|
1542 Sst7FB anda #$7F strip high bit
|
|
1543 cmpa #PENTIR entire device flag?
|
|
1544 beq Sst81E yes, go process
|
1513
|
1545 lda #PDELIM place delimiter as last char
|
1204
|
1546 sta ,s
|
|
1547 leax -$01,x bump path pointer back 1
|
|
1548 lda PD.MOD,y get file mode
|
|
1549 ldu <D.Proc get pointer to current process
|
|
1550 leau P$DIO,u point to default data directory FD sector #
|
|
1551 bita #EXEC. does he want execution dir?
|
|
1552 beq Sst814 no, skip ahead
|
|
1553 leau $06,u point to execution dir
|
|
1554 Sst814 ldb $03,u get LSB of logical sector # of FD to dir
|
|
1555 stb PD.FD,y put it in path descriptor
|
|
1556 ldd $04,u get MSW of logical sector # of FD to dir
|
|
1557 std PD.FD+1,y
|
|
1558 Sst81E ldu PD.DEV,y get pointer to device table
|
|
1559 stu PD.DVT,y copy it for user
|
|
1560 lda PD.DRV,y get drive #
|
|
1561 ldb >L0012,pcr get sizeof drive tables
|
|
1562 * confusion reigns supreme here,
|
|
1563 * one source loaction says its number of drive tables,
|
|
1564 * and the next says its the size of the table! And a 3rd
|
|
1565 * says its D.TYP.
|
|
1566 mul calculate offset into drive tables
|
|
1567 addd V$STAT,u add start of static memory
|
|
1568 addd #DRVBEG add offset to drive tables
|
|
1569 std PD.DTB,y save pointer to drive table
|
|
1570 lda ,s get character back
|
|
1571 anda #$7F strip high bit
|
|
1572 cmpa #PENTIR was it entire flag?
|
|
1573 bne Sst83F no, keep going
|
|
1574 leax $01,x move to next character
|
|
1575 bra Sst861 go on
|
|
1576
|
|
1577 Sst83F lbsr L1110 read in LSN0
|
|
1578 lbcs L0915 error, return
|
|
1579 ldu PD.BUF,y get sector buffer pointer from the read-in sector
|
|
1580
|
|
1581 * otherwise use the pointer from PD.DTB
|
|
1582 ldd DD.DSK,u get disk ID
|
|
1583 std PD.DSK,y put it in path descriptor
|
|
1584 ldd PD.FD+1,y does it have a file descriptor?
|
|
1585 bne Sst861 yes, skip ahead
|
|
1586 lda PD.FD,y
|
|
1587 bne Sst861
|
|
1588 lda DD.DIR,u get LSN of root directory
|
|
1589 sta PD.FD,y put it in path descriptor
|
|
1590 ldd DD.DIR+1,u
|
|
1591 std PD.FD+1,y
|
|
1592 Sst861 stx $04,s save pointer to pathname
|
|
1593 stx $08,s
|
|
1594
|
|
1595 Sst865 lbsr L1237 flush sector buffer
|
|
1596 lbcs L0915 error, exit
|
|
1597 lda ,s get last character of pathname
|
|
1598 anda #$7F mask off high bit
|
|
1599 cmpa #PENTIR entire device flag?
|
|
1600 beq Sst87B yes, skip ahead
|
|
1601 lbsr RdFlDscr read in file descriptor
|
|
1602 lbcs L0915 error, return
|
|
1603 Sst87B lbsr L0A2A check if directory is busy
|
|
1604 lda ,s
|
|
1605 cmpa #PDELIM was the trailing character a slash?
|
|
1606 bne L08EF no, skip ahead
|
|
1607 clr $02,s
|
|
1608 clr $03,s
|
|
1609 lda PD.MOD,y get file mode
|
|
1610 ora #DIR. mask in directory bit
|
|
1611 lbsr ChkAttrs can user access directory?
|
|
1612 bcs L090D no, return
|
|
1613 lbsr Open1CE setup path descriptor & start scan
|
|
1614 ldx $08,s get pathname pointer
|
|
1615 leax $01,x bump to next character
|
|
1616 lbsr GtDvcNam check for valid name
|
|
1617 std ,s save length of name
|
|
1618 stx $04,s save updated name pointer
|
|
1619 sty $08,s
|
|
1620 ldy $06,s get path descriptor pointer
|
|
1621 bcs L090D error in pathname, return
|
|
1622 pshs u,y
|
|
1623 ldu PD.Exten,y get pointer to path extension
|
|
1624 leau PE.FilNm,u point to filename buffer
|
|
1625 clra clear MSB of name length
|
|
1626 tfr d,y move it to Y
|
|
1627 lbsr Writ5CB move filename to temp area
|
|
1628 puls u,y
|
|
1629 lbsr L0957 read in a directory sector
|
|
1630 bra L08C1
|
|
1631
|
|
1632 * Scan diretory for name
|
|
1633 L08BC bsr L0918 get file descriptor
|
|
1634 IFNE H6309
|
|
1635 L08BE bsr L0942 get next directory entry from drive
|
|
1636 ELSE
|
|
1637 L08BE lbsr L0942
|
|
1638 ENDC
|
|
1639 L08C1 bcs L090D error,
|
|
1640 tst ,x filename exists?
|
|
1641 beq L08BC no, get next entry
|
|
1642 clra
|
|
1643 ldb $01,s
|
|
1644 exg x,y
|
|
1645 ldx PD.Exten,x get path extension pointer
|
|
1646 leax PE.FilNm,x point to user's filename
|
|
1647 lbsr L09BF compare the names
|
|
1648 ldx $06,s get pointer to path descriptor
|
|
1649 exg x,y
|
|
1650 bcs L08BE names don't match, skip to next
|
|
1651 bsr L0926 cop this DIR file descriptor to path descriptor
|
|
1652 lda DIR.FD,x
|
|
1653 sta PD.FD,y
|
|
1654 ldd DIR.FD+1,x
|
|
1655 std PD.FD+1,y
|
|
1656 lbsr L0A90 check record lock?
|
|
1657 lbra Sst865 go try again
|
|
1658
|
|
1659 L08EF ldx $08,s
|
|
1660 tsta last character?
|
|
1661 bmi L08FC yes, skip ahead
|
|
1662 os9 F$PrsNam parse the name
|
|
1663 leax ,y go to the next part of the name
|
|
1664 ldy $06,s
|
|
1665 L08FC stx $04,s
|
|
1666 clra
|
|
1667 L08FF lda ,s
|
|
1668 leas $04,s
|
|
1669 pshs b,a,cc
|
|
1670 IFNE H6309
|
|
1671 aim #^BufBusy,PD.SMF,y
|
|
1672 ELSE
|
|
1673 lda PD.SMF,y
|
|
1674 anda #^BufBusy
|
|
1675 sta PD.SMF,y
|
|
1676 ENDC
|
|
1677 puls pc,u,y,x,b,a,cc
|
|
1678
|
|
1679 L090D cmpb #E$EOF
|
|
1680 bne L0915
|
|
1681 bsr L0918
|
|
1682 ldb #E$PNNF
|
|
1683 L0915 coma
|
|
1684 bra L08FF
|
|
1685
|
|
1686 L0918 pshs d
|
|
1687 lda $04,s
|
|
1688 cmpa #PDELIM
|
|
1689 beq L0940
|
|
1690 ldd $06,s
|
|
1691 bne L0940
|
|
1692 bra L0928 fewer clock cycles
|
|
1693 L0926 pshs d
|
|
1694 L0928 stx $06,s
|
|
1695 lda PD.FD,y
|
|
1696 sta PD.DFD,y
|
|
1697 ldd PD.FD+1,y
|
|
1698 std PD.DFD+1,y
|
|
1699 IFNE H6309
|
|
1700 ldq PD.CP,y
|
|
1701 stq PD.DCP,y
|
|
1702 ELSE
|
|
1703 ldd PD.CP,y
|
|
1704 std PD.DCP,y
|
|
1705 ldd PD.CP+2,y
|
|
1706 std PD.DCP+2,y
|
|
1707 ENDC
|
|
1708 L0940 puls pc,b,a
|
|
1709
|
|
1710 * Move to next directory entry
|
1209
|
1711 * BGP - Sector Size issue needs to be resolved here
|
1204
|
1712 L0942 ldb PD.CP+3,y get current byte pointer
|
|
1713 addb #DIR.SZ add in diretory entry size
|
|
1714 stb PD.CP+3,y save it back
|
|
1715 bcc L0957 didn't wrap, skip ahead (need new sector)
|
|
1716 lbsr L1237 check for sector flush
|
|
1717 inc PD.CP+2,y
|
|
1718 bne L0957
|
|
1719 inc PD.CP+1,y
|
|
1720 bne L0957
|
|
1721 inc PD.CP,y
|
|
1722 L0957 ldd #DIR.SZ get directory entry size
|
|
1723 lbsr RdLn473 end of directory?
|
|
1724 bcs L097E yes, return
|
|
1725 ldd #DIR.SZ get directory entry size
|
|
1726 lbsr L0B0C
|
|
1727 bcs L097E yes, return
|
|
1728 lda PD.SMF,y get state flags
|
|
1729 bita #SINBUF sector in buffer?
|
|
1730 bne L0977 yes, skip ahead
|
|
1731 lbsr L1098
|
|
1732 bcs L097E
|
|
1733 lbsr L1256
|
|
1734 bcs L097E
|
|
1735 L0977 ldb PD.CP+3,y get offset into sector
|
|
1736 lda PD.BUF,y get MSB of sector buffer pointer
|
|
1737 tfr d,x move it to X
|
|
1738 clrb clear error status
|
|
1739 L097E rts return
|
|
1740
|
|
1741 * Get a byte from other task
|
|
1742 L097F pshs u,x,b
|
|
1743 ldu <D.Proc
|
|
1744 ldb P$Task,u
|
|
1745 os9 F$LDABX
|
|
1746 puls pc,u,x,b
|
|
1747
|
|
1748 GtDvcNam os9 F$PrsNam parse the filename
|
|
1749 pshs x preserve pointer to name
|
|
1750 bcc L09B7 no error, check name length & return
|
|
1751 clrb clear a counter flag
|
|
1752 L0992 pshs a preserve last character
|
|
1753 anda #$7F clear high bit of last character
|
|
1754 cmpa #'. is it current data directory?
|
|
1755 puls a restore last character
|
|
1756 bne L09AD no, skip ahead
|
|
1757 incb flag it's a dir
|
|
1758 leax 1,x
|
|
1759 tsta is it the last character of pathname?
|
|
1760 bmi L09AD yes, skip ahead
|
|
1761 bsr L097F get next character
|
|
1762 cmpb #$03 third character of DIR?
|
|
1763 bcs L0992 no, try again
|
|
1764 lda #PDELIM
|
|
1765 decb
|
|
1766 leax -3,x
|
|
1767 L09AD tstb
|
|
1768 bne L09B5
|
|
1769 L09B0 comb
|
|
1770 ldb #E$BPNam
|
|
1771 puls pc,x
|
|
1772
|
|
1773 L09B5 leay ,x
|
|
1774 L09B7 cmpb #DIR.FD-DIR.NM past maximum size of name?
|
|
1775 bhi L09B0 yes, return error
|
|
1776 andcc #^Carry clear error status
|
|
1777 puls pc,x return
|
|
1778
|
|
1779 * Check for a match of 2 names
|
|
1780 * Entry: Y=Pointer to high bit terminated string #1
|
|
1781 * X=Pointer to string #2
|
|
1782 * B=Length of string #1
|
|
1783 L09BF pshs y,x,b,a
|
|
1784 L09C1 lda ,y+ get a byte from #2
|
|
1785 bmi L09D1 last one, skip ahead
|
|
1786 decb done length?
|
|
1787 beq L09CE yes, return no match
|
|
1788 eora ,x+
|
|
1789 anda #$DF match from #1?
|
|
1790 beq L09C1 yes, check next char
|
|
1791 L09CE comb set carry
|
|
1792 puls pc,y,x,b,a return
|
|
1793
|
|
1794 L09D1 decb decrement length
|
|
1795 bne L09CE not done, return no match
|
|
1796 eora ,x
|
|
1797 anda #$5F
|
|
1798 bne L09CE
|
|
1799 clrb clear carry for match
|
|
1800 puls pc,y,x,b,a
|
|
1801
|
|
1802 * Check if user can access file/directory
|
|
1803 * Entry: A=Attributes of file/directory to check
|
|
1804 * Exit : Carry set - User cannot access otherwise clear
|
|
1805 ChkAttrs tfr a,b copy attributes
|
|
1806 anda #(EXEC.!UPDAT.) keep only file related junk
|
|
1807 andb #(DIR.!SHARE.) ...and directory related junk
|
|
1808 pshs x,b,a preserve
|
|
1809 lbsr RdFlDscr get file descriptor
|
|
1810 bcs L0A0C error, return
|
|
1811 ldu PD.BUF,y get pointer to FD
|
|
1812 ldx <D.Proc get current process pointer
|
|
1813 ldd P$User,x get user #
|
|
1814 beq L09F5 super user, skp ahead
|
|
1815 cmpd FD.OWN,u match owner of file?
|
|
1816 L09F5 puls a restore owner attributes
|
|
1817 beq L09FC got owner, skip ahead
|
|
1818 lsla shift attributes to public area
|
|
1819 lsla
|
|
1820 lsla
|
|
1821 L09FC ora ,s merge with directory bits
|
|
1822 anda #^SHARE. strip off shareable bit
|
|
1823 pshs a save it
|
|
1824 ora #DIR. set directory bit
|
|
1825 anda FD.ATT,u keep only bits we want from attributes
|
|
1826 cmpa ,s can he access it?
|
|
1827 beq L0A15 yes, check directory bits
|
|
1828 ldb #E$FNA get error code
|
|
1829 L0A0C leas $02,s purge attributes from stack
|
|
1830 coma set carry
|
|
1831 puls pc,x restore & return
|
|
1832
|
|
1833 L0A11 ldb #E$Share,s get shareable file error
|
|
1834 bra L0A0C return
|
|
1835
|
|
1836 L0A15 ldb 1,s get directory bits
|
|
1837 orb FD.ATT,u mask in with current
|
|
1838 bitb #SHARE. shareable bit set?
|
|
1839 beq L0A28 no, return
|
|
1840 ldx PD.Exten,y get path extension
|
|
1841 cmpx PE.Confl,x conflicting with anyone?
|
|
1842 bne L0A11 yes, return error
|
|
1843 lda #FileLock
|
|
1844 sta PE.Lock,x
|
|
1845 L0A28 puls pc,x,b,a
|
|
1846
|
|
1847
|
|
1848 L0A2A pshs u,y,x
|
|
1849 IFNE H6309
|
|
1850 clrd
|
|
1851 ELSE
|
|
1852 clra
|
|
1853 clrb
|
|
1854 ENDC
|
|
1855 std PD.CP,y init current byte pointer
|
|
1856 std PD.CP+2,y smaller than STQ
|
|
1857 sta PD.SSZ,y init segment size
|
|
1858 std PD.SSZ+1,y
|
|
1859 ldb PD.FD,y get current FD sector #
|
|
1860 ldx PD.FD+1,y
|
|
1861 pshs x,b preserve it
|
|
1862 ldu PD.DTB,y get drive table pointer
|
|
1863 ldy PD.Exten,y get drive extension pointer
|
|
1864 sty PE.Confl,y make it conflict with myself
|
|
1865 leau DD.SIZ,u point to local data
|
|
1866 bra L0A51
|
|
1867 * Sort file conflict list???
|
|
1868 L0A4F ldu V.FileHd-DD.SIZ,u
|
|
1869 L0A51 ldx V.FileHd-DD.SIZ,u get open file list extension pointer
|
|
1870 beq L0A7F none, skip return
|
|
1871 ldx PE.PDptr,x get pointer to its path descriptor
|
|
1872 ldd PD.FD,x get the file descriptor LSN
|
|
1873 cmpd ,s sector lower than mine?
|
|
1874 bcs L0A4F yes, skip to next
|
|
1875 bhi L0A7F no, return
|
|
1876 ldb PD.FD+2,x
|
|
1877 cmpb 2,s
|
|
1878 blo L0A4F yes, skip to next
|
|
1879 bhi L0A7F no, return
|
|
1880 ldx PD.Exten,x get the path extension pointer
|
|
1881 IFNE H6309
|
|
1882 tim #FileLock,PE.Lock,y entire file locked?
|
|
1883 ELSE
|
|
1884 ldb PE.Lock,y
|
|
1885 bitb #FileLock
|
|
1886 ENDC
|
|
1887 bne L0A8B yes, return error
|
|
1888 sty PE.NxFil,y terminate list with pointer to myself
|
|
1889 ldd PE.Confl,x
|
|
1890 std PE.Confl,y
|
|
1891 sty PE.Confl,x
|
|
1892 bra L0A86
|
|
1893
|
|
1894 L0A7F ldx PE.NxFil,u
|
|
1895 stx PE.NxFil,y
|
|
1896 sty PE.NxFil,u
|
|
1897
|
|
1898 L0A86 clrb
|
|
1899 L0A87 leas $03,s
|
|
1900 puls pc,u,y,x
|
|
1901
|
|
1902 L0A8B comb
|
|
1903 ldb #E$Share
|
|
1904 bra L0A87
|
|
1905
|
|
1906 L0A90 pshs u,y,x,b,a
|
|
1907 ldu PD.DTB,y
|
|
1908 leau DD.SIZ,u
|
|
1909 ldx PD.Exten,y
|
|
1910 leay ,x
|
|
1911 bsr L0ACF
|
|
1912 bra L0AA5
|
|
1913 L0AA1 ldx PE.Confl,x
|
|
1914 beq L0ACA
|
|
1915 L0AA5 cmpy PE.Confl,x
|
|
1916 bne L0AA1
|
|
1917 ldd PE.Confl,y
|
|
1918 std PE.Confl,x
|
|
1919 bra L0AB2
|
|
1920 L0AB0 ldu PE.NxFil,u
|
|
1921 L0AB2 ldd PE.NxFil,u
|
|
1922 beq L0ACA end of list, store end & return
|
|
1923 cmpy PE.NxFil,u find myself/
|
|
1924 bne L0AB0 no, keep looking
|
|
1925 ldx PE.NxFil,y get next in line from me
|
|
1926 cmpy PE.Confl,y end of conflict list?
|
|
1927 beq L0AC8 yes, skip ahead
|
|
1928 ldx PE.Confl,y get conflicting path extension
|
|
1929 ldd PE.NxFil,y get next in line from me
|
|
1930 std PE.NxFil,x save it into conflicting extension
|
|
1931 L0AC8 stx PE.NxFil,u save conflicting extension as next
|
|
1932 L0ACA sty PE.Confl,y
|
|
1933 puls pc,u,y,x,b,a
|
|
1934
|
|
1935 L0ACF lda #(EofLock!FileLock!RcdLock) get all types of lockout flags
|
|
1936 L0AD1 pshs u,y,x,b,a
|
|
1937 bita PE.Lock,y anything locked?
|
|
1938 beq L0AE0 no, skip ahead
|
|
1939 coma invert lock bits
|
|
1940 anda PE.Lock,y clear 'em
|
|
1941 sta PE.Lock,y save 'em
|
|
1942 bita #FileLock is whole file locked?
|
|
1943 bne L0AFD yes, return
|
|
1944 L0AE0 leau ,y
|
|
1945 L0AE2 ldx PE.Wait,u
|
|
1946 cmpy PE.Wait,u
|
|
1947 beq L0AFA
|
|
1948 stu PE.Wait,u
|
|
1949 leau ,x
|
|
1950 lda PE.Owner,u
|
|
1951 ldb #S$Wake
|
|
1952 os9 F$Send
|
|
1953 bra L0AE2
|
|
1954 L0AFA stu PE.Wait,u
|
|
1955 L0AFD puls pc,u,y,x,b,a
|
|
1956
|
|
1957 L0AFF comb
|
|
1958 ldb #E$Share
|
|
1959 L0B02 pshs y,b,cc
|
|
1960 ldy PD.Exten,y
|
|
1961 bsr L0ACF
|
|
1962 puls pc,y,b,cc
|
|
1963
|
|
1964 L0B0C equ *
|
|
1965 IFNE H6309
|
|
1966 tfr 0,x
|
|
1967 ELSE
|
|
1968 ldx #$0000
|
|
1969 ENDC
|
|
1970 bra L0B1B
|
|
1971
|
|
1972 L0B11 ldu PD.Exten,y
|
|
1973 lda PE.Req,u
|
|
1974 sta PE.Lock,u
|
|
1975 bra L0B1D
|
|
1976
|
|
1977 * Entry: D=LSW of byte position
|
|
1978 * X=
|
|
1979 * Y=Path descriptor pointer
|
|
1980 * U=
|
|
1981 L0B1B pshs u,y,x,b,a preserve regs
|
|
1982 L0B1D ldu PD.Exten,y get pointer to path extension
|
|
1983 lda PE.Lock,u get lockout status
|
|
1984 sta PE.Req,u preserve it
|
|
1985 lda ,s get
|
|
1986 bsr L0B9F lock the record
|
|
1987 bcc L0B9D
|
|
1988 ldu <D.Proc get current proces pointer
|
|
1989 lda PE.Owner,x get owner ID of locked segment
|
|
1990 L0B30 os9 F$GProcP get a pointer to it
|
|
1991 bcs L0B42 no process left, skip ahead
|
|
1992 lda P$DeadLk,y get dominant proc ID
|
|
1993 beq L0B42 none, skip ahead
|
|
1994 cmpa P$ID,u same as current?
|
|
1995 bne L0B30 no, try again (walks down the process tree)
|
|
1996 ldb #E$DeadLk get deadlock error code
|
|
1997 bra L0B9A set carry & return
|
|
1998
|
|
1999 L0B42 lda PE.Owner,x get owner of this segment
|
|
2000 sta P$DeadLk,u save as the dominant deadlock process
|
|
2001 ldy 4,s get path descriptor pointer
|
|
2002 IFNE H6309
|
|
2003 aim #^BufBusy,PD.SMF,y
|
|
2004 ELSE
|
|
2005 lda PD.SMF,y
|
|
2006 anda #^BufBusy
|
|
2007 sta PD.SMF,y
|
|
2008 ENDC
|
|
2009 ldu PD.Exten,y get the path extension
|
|
2010 ldd PE.Wait,x
|
|
2011 stu PE.Wait,x
|
|
2012 std PE.Wait,u
|
|
2013 lbsr L0C56
|
|
2014 ldx PE.TmOut,u get timeout time to wait for release of segment
|
|
2015 os9 F$Sleep delay a bit
|
|
2016 pshs x preserve time slept
|
|
2017 leax ,u point X to path extension
|
|
2018 bra L0B6F skip ahead
|
|
2019
|
|
2020 L0B6C ldx PE.Wait,x
|
|
2021 L0B6F cmpu PE.Wait,x
|
|
2022 bne L0B6C
|
|
2023 ldd PE.Wait,u
|
|
2024 std PE.Wait,x
|
|
2025 stu PE.Wait,u
|
|
2026 puls x restore time slept
|
|
2027 ldu <D.Proc
|
|
2028 clr P$DeadLk,u
|
|
2029 lbsr L1053
|
|
2030 bcs L0B9A
|
|
2031 leax ,x X=0?
|
|
2032 bne L0B11 no,
|
|
2033 ldu PD.Exten,y get pointer to extension
|
|
2034 ldx PE.TmOut,u get timeout time
|
|
2035 lbeq L0B11 zero, go try again
|
|
2036 ldb #E$Lock get lock error code
|
|
2037 L0B9A coma set carry
|
|
2038 stb $01,s save error code
|
|
2039 L0B9D puls pc,u,y,x,b,a
|
|
2040
|
|
2041 L0B9F
|
|
2042 IFNE H6309
|
|
2043 tstd std -$02,s only to set cc.flags? 4 cycles to 1!
|
|
2044 ELSE
|
|
2045 cmpd #$0000
|
|
2046 ENDC
|
|
2047 bne L0BAA
|
|
2048 cmpx #$0000 the leax may be buggy
|
|
2049 lbeq L0B02
|
|
2050 L0BAA bsr L0BC2
|
|
2051 lbcs L0AFF
|
|
2052 pshs u,y,x
|
|
2053 ldy PD.Exten,y
|
|
2054 lda #$01
|
|
2055 lbsr L0AD1
|
|
2056 ora PE.Lock,y
|
|
2057 sta PE.Lock,y
|
|
2058 clrb
|
|
2059 puls pc,u,y,x
|
|
2060
|
|
2061 L0BC2 pshs u,y,b,a
|
|
2062 leau ,y
|
|
2063 ldy PD.Exten,y
|
|
2064 subd #$0001 NOT a DECD: does't set CC.C
|
|
2065 bcc L0BD1
|
|
2066 leax -1,x
|
|
2067 L0BD1 addd PD.CP+2,u
|
|
2068 exg d,x
|
|
2069 IFNE H6309
|
|
2070 adcd PD.CP,u oughta do same - GH
|
|
2071 ELSE
|
|
2072 adcb PD.CP+1,u
|
|
2073 adca PD.CP,u
|
|
2074 ENDC
|
|
2075 bcc L0BE0
|
|
2076 ldx #$FFFF
|
|
2077 tfr x,d
|
|
2078 L0BE0 std PE.HiLck,y
|
|
2079 stx PE.HiLck+2,y
|
|
2080 cmpd PD.SIZ,u
|
|
2081 bcs L0BF8
|
|
2082 bhi L0BF0
|
|
2083 cmpx PD.SIZ+2,u
|
|
2084 bcs L0BF8
|
|
2085 L0BF0 equ *
|
|
2086 IFNE H6309
|
|
2087 oim #EofLock,PE.Lock,y
|
|
2088 ELSE
|
|
2089 lda PE.Lock,y
|
|
2090 ora #EofLock
|
|
2091 sta PE.Lock,y
|
|
2092 ENDC
|
|
2093 bra L0C01
|
|
2094 L0BF8 lda #EofLock
|
|
2095 bita PE.Lock,y
|
|
2096 beq L0C01
|
|
2097 lbsr L0AD1
|
|
2098 L0C01 equ *
|
|
2099 IFNE H6309
|
|
2100 ldq PD.CP,u
|
|
2101 stq PE.LoLck,y
|
|
2102 ELSE
|
|
2103 ldd PD.CP,u
|
|
2104 std PE.LoLck,y
|
|
2105 ldd PD.CP+2,u
|
|
2106 std PE.LoLck+2,y
|
|
2107 ENDC
|
|
2108 lda PD.CPR,u
|
|
2109 sta PE.Owner,y
|
|
2110 leax ,y
|
|
2111 L0C10 cmpy PE.Confl,x
|
|
2112 beq L0C54
|
|
2113 ldx PE.Confl,x
|
|
2114 ldb PE.Owner,y
|
|
2115 cmpb PE.Owner,x
|
|
2116 beq L0C10
|
|
2117 lda PE.Lock,x
|
|
2118 beq L0C10
|
|
2119 ora PE.Lock,y
|
|
2120 bita #FileLock either path locked?
|
|
2121 bne L0C53 yes, skip ahead
|
|
2122 lda PE.Lock,x
|
|
2123 anda PE.Lock,y
|
|
2124 bita #EofLock both at eof?
|
|
2125 bne L0C53
|
|
2126 ldd PE.LoLck,x
|
|
2127 cmpd PE.HiLck,y
|
|
2128 bhi L0C10
|
|
2129 bcs L0C43
|
|
2130 ldd PE.LoLck+2,x
|
|
2131 cmpd PE.HiLck+2,y
|
|
2132 bhi L0C10
|
|
2133 beq L0C53
|
|
2134 L0C43 ldd PE.HiLck,x
|
|
2135 cmpd PE.LoLck,y
|
|
2136 bcs L0C10
|
|
2137 bhi L0C53
|
|
2138 ldd PE.HiLck+2,x
|
|
2139 cmpd PE.LoLck+2,y
|
|
2140 bcs L0C10
|
|
2141 L0C53 comb
|
|
2142 L0C54 puls pc,u,y,b,a
|
|
2143
|
|
2144 L0C56 pshs y,x,b,a
|
|
2145 ldx <D.Proc
|
|
2146 lda P$IOQN,x get I/O queue next ptr
|
|
2147 beq L0C6C none, exit
|
|
2148 clr P$IOQN,x set to none
|
|
2149 ldb #S$Wake
|
|
2150 os9 F$Send wake up
|
|
2151 os9 F$GProcP get process descriptor pointer
|
|
2152 clr P$IOQP,y clear its I/O queue previous pointer
|
|
2153 L0C6C clrb
|
|
2154 puls pc,y,x,b,a
|
|
2155
|
|
2156 L0C6F pshs u,x
|
|
2157 L0C71 bsr L0CD1
|
|
2158 bne L0C81
|
|
2159 cmpx PD.SSZ+1,y
|
|
2160 bcs L0CC8
|
|
2161 bne L0C81
|
|
2162 lda PD.SIZ+3,y
|
|
2163 beq L0CC8
|
|
2164 L0C81 lbsr RdFlDscr
|
|
2165 bcs L0CC5
|
|
2166 ldx PD.CP,y
|
|
2167 ldu PD.CP+2,y grab current position
|
|
2168 pshs u,x save it
|
|
2169 IFNE H6309
|
|
2170 ldq PD.SIZ,y go to the end of the file
|
|
2171 stq PD.CP,y
|
|
2172 ELSE
|
|
2173 ldd PD.SIZ,y
|
|
2174 std PD.CP,y
|
|
2175 ldd PD.SIZ+2,y
|
|
2176 std PD.CP+2,y
|
|
2177 ENDC
|
|
2178 lbsr L10B2 search ???
|
|
2179 puls u,x restore current position
|
|
2180 stx PD.CP,y and save back in PD again
|
|
2181 stu PD.CP+2,y
|
|
2182 bcc L0CC8
|
|
2183 cmpb #E$NES non-existing segment error?
|
|
2184 bne L0CC5
|
|
2185 bsr L0CD1
|
|
2186 bne L0CB1
|
|
2187 tst PD.SIZ+3,y
|
|
2188 beq L0CB4
|
|
2189 leax 1,x
|
|
2190 bne L0CB4
|
|
2191 L0CB1 ldx #$FFFF
|
|
2192 L0CB4 tfr x,d
|
|
2193 tsta
|
|
2194 bne L0CC1
|
|
2195 cmpb PD.SAS,y
|
|
2196 bcc L0CC1
|
|
2197 ldb PD.SAS,y
|
|
2198 L0CC1 bsr L0D07 go do something...
|
|
2199 bcc L0C71
|
|
2200 L0CC5 coma
|
|
2201 puls pc,u,x
|
|
2202
|
|
2203 L0CC8 lbsr L1098
|
|
2204 bcs L0CC5
|
|
2205 bsr L0CDF
|
|
2206 puls pc,u,x
|
|
2207
|
|
2208 L0CD1 ldd PD.SIZ+1,y
|
|
2209 subd PD.SBL+1,y
|
|
2210 tfr d,x
|
|
2211 ldb PD.SIZ,y
|
|
2212 sbcb PD.SBL,y
|
|
2213 rts
|
|
2214
|
|
2215 L0CDF clra
|
|
2216 ldb #$02
|
|
2217 pshs u,x
|
|
2218 ldu PD.Exten,y
|
|
2219 bra L0CFD
|
|
2220
|
|
2221 L0CE9 ldu PE.PDptr,u
|
|
2222 ldx PD.SIZ,y don't do LDQ/STQ, as A and B are used below
|
|
2223 stx PD.SIZ,u
|
|
2224 ldx PD.SIZ+2,y
|
|
2225 stx PD.SIZ+2,u
|
|
2226 bitb PD.MOD,y
|
|
2227 beq L0CFA
|
|
2228 inca
|
|
2229 L0CFA ldu PD.Exten,u
|
|
2230 L0CFD ldu PE.Confl,u
|
|
2231 cmpy PE.PDptr,u
|
|
2232 bne L0CE9
|
|
2233 tsta
|
|
2234 puls pc,u,x
|
|
2235
|
|
2236 * Update a file descriptor
|
|
2237 L0D07 pshs u,x
|
|
2238 lbsr FatScan search and allocate D sectors
|
|
2239 bcs L0D4E exit on error
|
|
2240 lbsr RdFlDscr read a FD from disk
|
|
2241 bcs L0D4E exit on error
|
|
2242 ldu PD.BUF,y grab the buffer pointer
|
|
2243 IFNE H6309
|
|
2244 clrd
|
|
2245 tfr d,w
|
|
2246 stq FD.SIZ,u set the file size to zero
|
|
2247 ELSE
|
|
2248 clra
|
|
2249 clrb
|
|
2250 std FD.SIZ,u
|
|
2251 std FD.SIZ+2,u
|
|
2252 ENDC
|
|
2253 leax FD.SEG,u point to the segment size
|
|
2254 ldd FDSL.B,x grab the segment size
|
|
2255 beq L0D96 exit if zero
|
|
2256 ldd PD.BUF,y grab the buffer pointer
|
|
2257 inca point to the end of it
|
1209
|
2258
|
|
2259 * Following 3 lines support larger sector sizes that
|
|
2260 * allow the segment list to extend beyond 48 entries.
|
|
2261 * pshs a
|
|
2262 * lbsr SSBits
|
|
2263 * adda ,s+
|
|
2264
|
1204
|
2265 pshs d save on-stack
|
|
2266 bra L0D36 skip ahead
|
|
2267
|
|
2268 L0D29 clrb
|
|
2269 ldd -$02,x grab previous segment sector size
|
|
2270 beq L0D4A zero: exit
|
|
2271 * Add in checks to see if this segment's LSN is $00000000?
|
|
2272 addd FD.SIZ+1,u add sector size to total file size
|
|
2273 std FD.SIZ+1,u
|
|
2274 bcc L0D36
|
|
2275 inc FD.SIZ,u increment file size if 24-bit overflow
|
|
2276 L0D36 leax FDSL.S,x go up one segment in the FD
|
|
2277 cmpx ,s done yet?
|
|
2278 bcs L0D29 no, continue
|
|
2279 * or do check for last segment LSN0, size 1 here?
|
|
2280 lbsr ClrFBits delete a segment?
|
|
2281 IFNE H6309
|
|
2282 clrd
|
|
2283 ELSE
|
|
2284 clra
|
|
2285 clrb
|
|
2286 ENDC
|
|
2287 sta PD.SSZ,y segment size is zero
|
|
2288 std PD.SSZ+1,y
|
|
2289 comb
|
|
2290 ldb #E$SLF segment list full error
|
|
2291
|
|
2292 L0D4A leas 2,s remove pointer to end of PD.BUF from the stack
|
|
2293 leax -FDSL.S,x back up a segment
|
|
2294 L0D4E bcs L0DB3
|
|
2295 ldd -4,x
|
|
2296 addd -2,x
|
|
2297 pshs b,a
|
|
2298 ldb -5,x
|
|
2299 adcb #$00
|
|
2300 cmpb PD.SBP,y
|
|
2301 puls d
|
|
2302 bne L0D96
|
|
2303 cmpd PD.SBP+1,y
|
|
2304 bne L0D96
|
|
2305 ldu PD.DTB,y
|
|
2306 ldd DD.BIT,u
|
|
2307 ldu PD.BUF,y
|
|
2308 subd #1
|
|
2309 coma
|
|
2310 comb comd is prolly wrong reg order!
|
|
2311 pshs d
|
|
2312 ldd -$05,x
|
|
2313 IFNE H6309
|
|
2314 eord PD.SBP,y
|
|
2315 lsrd
|
|
2316 lsrd
|
|
2317 lsrd
|
|
2318 andd ,s++
|
|
2319 tstd
|
|
2320 ELSE
|
|
2321 eora PD.SBP,y
|
|
2322 eorb PD.SBP+1,y
|
|
2323 lsra
|
|
2324 rorb
|
|
2325 lsra
|
|
2326 rorb
|
|
2327 lsra
|
|
2328 rorb
|
|
2329 anda ,s+
|
|
2330 andb ,s+
|
|
2331 cmpd #$0000
|
|
2332 ENDC
|
|
2333 bne L0D96
|
|
2334 ldd -2,x
|
|
2335 addd PD.SSZ+1,y
|
|
2336 bcs L0D96
|
|
2337 std -2,x
|
|
2338 bra L0DA5
|
|
2339
|
|
2340 L0D96 ldd PD.SBP,y
|
|
2341 std ,x
|
|
2342 lda PD.SBP+2,y
|
|
2343 sta 2,x
|
|
2344 ldd PD.SSZ+1,y
|
|
2345 std 3,x
|
|
2346 L0DA5 ldd FD.SIZ+1,u
|
|
2347 addd PD.SSZ+1,y
|
|
2348 std FD.SIZ+1,u
|
|
2349 bcc L0DB0
|
|
2350 inc FD.SIZ,u
|
|
2351
|
|
2352 L0DB0 lbsr L11FD flush a FD sector tothe disk
|
|
2353 L0DB3 puls pc,u,x
|
|
2354
|
|
2355 * Search the allocation bitmap for a number of free sectors
|
|
2356 * Entry: D = number of sectors to look for
|
|
2357 * Y = PD pointer
|
|
2358 * 0,S = number of clusters to allocate
|
|
2359 * 2,S = DD.BIT number of sectors per cluster
|
|
2360 * 4,S = DD.MAP number of bytes in the allocation bitmap
|
|
2361 * 6,S = V.MapSCT lowest reasonable bitmap sector number (current bitmap sect)
|
|
2362 * 7,S = sector number of the largest contiguous free bits found
|
|
2363 * 8,S = number of contiguous free bits found
|
|
2364 * 10,s = bit offset into the sector of the found contiguous bits
|
|
2365 * 10,s = also DD.BIT number of sectors per cluster
|
|
2366 * 12,S = number of sectors to search for (D from the calling routine)
|
|
2367 * 16,S = PD pointer (Y from the calling routine)
|
|
2368 FatScan pshs u,y,x,b,a
|
|
2369 ldb #$0C
|
|
2370 L0DB9 clr ,-s reserve 12 bytes of junk on-stack
|
|
2371 decb
|
|
2372 bne L0DB9
|
|
2373 ldx PD.DTB,y
|
|
2374 ldd DD.MAP,x number of bytes in allocation bitmap
|
|
2375 std 4,s
|
|
2376 ldd DD.BIT,x number of sectors per cluster
|
|
2377 std 2,s
|
|
2378 std 10,s
|
|
2379 ldx PD.DEV,y get pointer to device table entry
|
|
2380 ldx V$DESC,x point to descriptor
|
|
2381 leax M$DTyp,x get device type
|
|
2382 subd #1
|
|
2383 addb IT.SAS-M$DTyp,x add in one sector allocation size
|
|
2384 adca #0 make it 16-bit
|
|
2385 bra L0DDD default to greater of SAS or DD.BIT
|
|
2386
|
|
2387 L0DDB equ *
|
|
2388 IFNE H6309
|
|
2389 lsrd shift D to the right
|
|
2390 ELSE
|
|
2391 lsra
|
|
2392 rorb
|
|
2393 ENDC
|
|
2394 L0DDD lsr $0A,s shift DD.BIT to the right
|
|
2395 ror $0B,s
|
|
2396 bcc L0DDB loop until carry is set
|
|
2397 std ,s D = number of clusters to allocate
|
|
2398 ldd 2,s get old DD.BIT
|
|
2399 std $0A,s save on-stack again
|
|
2400 subd #$0001
|
|
2401 addd $0C,s add in to the number of sectors we're asked to
|
|
2402 bcc L0DF7 allocate
|
|
2403 ldd #$FFFF if larger than 64K sectors, default to 64K
|
|
2404 bra L0DF7 skip ahead
|
|
2405
|
|
2406 L0DF5 equ *
|
|
2407 IFNE H6309
|
|
2408 lsrd shift number of sectors to allocate
|
|
2409 ELSE
|
|
2410 lsra
|
|
2411 rorb
|
|
2412 ENDC
|
|
2413 L0DF7 lsr $0A,s
|
|
2414 ror $0B,s
|
|
2415 bcc L0DF5 loop, and continue
|
|
2416 * ATD: remove this code for HD's, to allow >2048 cluster segments???
|
|
2417 * It may be easier to read in the FD, and COMPACT it by looking for
|
|
2418 * LSN+SIZE=next segment LSN. But that would take 48*(30?) clock cycles,
|
|
2419 * which is a lot of time... but maybe not compared to F$All/F$Sch, and
|
|
2420 * the sector read/writes...
|
|
2421 cmpa #8 at least 256*8 bits to allocate?
|
|
2422 bcs L0E04 number of clusters is OK, skip ahead
|
|
2423 ldd #$0800 force one sector of clusters max. to be allocated
|
|
2424 L0E04 std $0C,s save as the number of clusters to allocate
|
|
2425 lbsr L1036 make us the current user of the allocation bitmap
|
|
2426 lbcs L0EF2 exit on error
|
|
2427 ldx PD.DTB,y get drive table
|
|
2428 ldd V.DiskID,x and old disk ID
|
|
2429 cmpd DD.DSK,x check against the current disk ID
|
|
2430 bne L0E26 if not the same, make us the current disk ID
|
|
2431 lda V.BMapSz,x same allocation bitmap size?
|
|
2432 cmpa DD.MAP,x
|
|
2433 bne L0E26 no, skip ahead
|
|
2434 ldb V.MapSct,x another check
|
|
2435 cmpb DD.MAP,x
|
|
2436 bcs L0E34
|
|
2437
|
|
2438 L0E26 ldd DD.DSK,x get current disk ID
|
|
2439 std V.DiskID,x make us the disk to use
|
|
2440 lda DD.MAP,x grab number of sectors in allocation bitmap
|
|
2441 sta V.BMapSz,x save for later
|
|
2442 clrb
|
|
2443 stb V.MapSct,x make this zero for now
|
|
2444 L0E34 incb account for LSN0
|
|
2445 stb 6,s lowest reasonable bitmap sector number
|
|
2446 * ATD: Is this line necessary? All calls to L0E34 set up X already
|
|
2447 ldx PD.DTB,y get drive table pointer again
|
|
2448 cmpb V.ResBit,x check B against reserved bitmap sector
|
|
2449 beq L0E70 same, skip ahead
|
|
2450 lbsr L1091 go read in a bitmap sector
|
|
2451 lbcs L0EF2
|
|
2452 ldb 6,s grab copy of V.MapSCT again
|
|
2453 cmpb 4,s check against number of sectors in allocation bitmap
|
|
2454 bls L0E51 lower, continue
|
|
2455 clra if at end of the allocation bitmap,
|
|
2456 ldb 5,s don't search it all, but just to the end of the
|
|
2457 bra L0E54 last sector in the allocation bitmap
|
|
2458
|
|
2459 * ATD: This the routine that we would fix to cache a compressed version
|
|
2460 * of the allocation bitmap. i.e. largest group of contiguous free sectors,
|
|
2461 * where 255 == 256 by definition. At 1 byte/sector, max. 256 sectors in the
|
|
2462 * allocation bitmap, max. 256 bytes. The search should be a LOT faster then,
|
|
2463 * as we'll only have to search memory and not read in all those sectors.
|
|
2464 * If we're really daring, we could build the new FD without reading the
|
|
2465 * allocation bitmap _at_all_, and just use a 'best-fit' algorithm on the
|
|
2466 * cached version, and update the bitmap later.
|
|
2467 * RBF doesn't do any other search bit calls, so this is the routine.
|
|
2468 L0E51 ldd #$0100
|
|
2469 L0E54 ldx PD.BUF,y where to start searching
|
|
2470 leau d,x where to stop searching
|
|
2471 ldy $0C,s number of bits to find
|
|
2472 * ATD: force it to be less than 1 sector here...
|
|
2473 IFNE H6309
|
|
2474 clrd at starting bit number 0
|
|
2475 ELSE
|
|
2476 clra
|
|
2477 clrb
|
|
2478 ENDC
|
|
2479 os9 F$SchBit
|
|
2480 bcc L0E9D found bits
|
|
2481 cmpy 8,s check number of found bits against our maximum
|
|
2482 bls L0E70 smaller, skip ahead
|
|
2483 sty 8,s save as new maximum
|
|
2484 std $0A,s save starting bit number
|
|
2485 lda 6,s grab current sector
|
|
2486 sta 7,s save for later
|
|
2487 L0E70 ldy <$10,s grab old PD pointer
|
|
2488 ldb 6,s grab current bitmap sector number
|
|
2489 cmpb 4,s check against highest sector number of bitmap
|
|
2490 bcs L0E81 we're OK, skip ahead
|
|
2491 bhi L0E80 we're too high, skip ahead
|
|
2492 tst 5,s check bytes in the sector
|
|
2493 bne L0E81 not zero: skip ahead
|
|
2494 L0E80 clrb
|
|
2495 L0E81 ldx PD.DTB,y get drive table pointer again
|
|
2496 cmpb V.MapSct,x check against lowest reasonable bitmap sector
|
|
2497 bne L0E34 ifnot the same, continue
|
|
2498
|
|
2499 ldb 7,s grab sector number of largest block found
|
|
2500 beq L0EF0 zero, exit with E$Full error
|
|
2501 cmpb 6,s is it the current sector?
|
|
2502 beq L0E96 yes, skip ahead
|
|
2503 stb 6,s make it the current sector
|
|
2504 lbsr L1091 go read the sector in from disk
|
|
2505
|
|
2506 L0E96 ldx PD.BUF,y point to the sector in the buffer
|
|
2507 ldd $0A,s grab starting bit number
|
|
2508 ldy 8,s and number of bits to allocate
|
|
2509 L0E9D std $0A,s save starting bit number
|
|
2510 sty 8,s and number of bits to allocate
|
|
2511 os9 F$AllBit go allocate the bits
|
|
2512 ldy $10,s grab the PD pointer again
|
|
2513 ldb $06,s and the sector number
|
|
2514 lbsr L1069 write it out to disk
|
|
2515 bcs L0EF2 exit on error
|
|
2516 * ATD: add check for segments left to allocate, if we've allocated
|
|
2517 * one entire sector's worth???
|
|
2518 * What about special-purpose code to read the allocation bitmap byte by byte
|
|
2519 * and do it that way? I dunno...
|
|
2520 * Have some routine inside L0DB5 call another routine which allocates segments
|
|
2521 * one sector at a time... have a check: got one sector?
|
|
2522 * ATD: We'll probably have to add in allocation bitmap caching for this
|
|
2523 * to work properly....
|
|
2524 ldx PD.DTB,y drive table pointer
|
|
2525 lda 6,s current sector
|
|
2526 deca decreemnt
|
|
2527 sta V.MapSct,x AHA! Last searched sector for later use
|
|
2528 clrb
|
|
2529 lsla move high bit of A into CC.C
|
|
2530 rolb move CC.C into B
|
|
2531 lsla etc.
|
|
2532 rolb cannot do a ROLD, as that would be LSB, ROLA
|
|
2533 lsla i.e. move the 3 high bits of A into low bits of B
|
|
2534 rolb and shift A by 3
|
|
2535 stb PD.SBP,y save segment beginning physical sector number
|
|
2536 ora $0A,s OR in with the start bit number
|
|
2537 ldb $0B,s grab LSB of starting bit number
|
|
2538 ldx 8,s and number of free sectors found
|
|
2539 * ATD: Is this next line really necessary?
|
|
2540 ldy $10,s get PD pointer
|
|
2541 std PD.SBP+1,y save low 2 bytes of segment beginning physical SN
|
|
2542 stx PD.SSZ+1,y and segment size in clusters
|
|
2543 ldd 2,s grab number of sectors per cluster
|
|
2544 bra L0EE6
|
|
2545
|
|
2546 L0ED7 lsl PD.SBP+2,y shift physical sector numberup
|
|
2547 rol PD.SBP+1,y to LSN, to account for cluster size
|
|
2548 rol PD.SBP,y
|
|
2549 lsl PD.SSZ+2,y
|
|
2550 rol PD.SSZ+1,y shift segment cluster size to sector size
|
|
2551 L0EE6
|
|
2552 IFNE H6309
|
|
2553 lsrd
|
|
2554 ELSE
|
|
2555 lsra
|
|
2556 rorb
|
|
2557 ENDC
|
|
2558 bcc L0ED7
|
|
2559
|
|
2560 clrb no errors
|
|
2561 ldd PD.SSZ+1,y number of sectors allocated
|
|
2562 bra L0EFA and return to the user
|
|
2563
|
|
2564 L0EF0 ldb #E$Full
|
|
2565 L0EF2 ldy $10,s get old Y off of the stack
|
|
2566 lbsr L1070 return allocation bitmap?
|
|
2567 coma
|
|
2568 L0EFA leas $0E,s skip 12-byte buffer, and D
|
|
2569 puls pc,u,y,x
|
|
2570
|
|
2571 * Set the size of a file to PD.SIZ, where PD.SIZ is SMALLER than the
|
|
2572 * current size of the file.
|
|
2573 L0EFE clra clear the carry
|
|
2574 * This code ensures that directories are never shrunk in size.
|
|
2575 lda PD.MOD,y access mode
|
|
2576 bita #DIR. directory?
|
|
2577 bne L0F6F yes (bit set), exit immediately
|
|
2578 IFNE H6309
|
|
2579 ldq PD.SIZ,y grab size of the file
|
|
2580 stq PD.CP,y make it the current position
|
|
2581 ELSE
|
|
2582 ldd PD.SIZ,y
|
|
2583 std PD.CP,y
|
|
2584 ldd PD.SIZ+2,y
|
|
2585 std PD.CP+2,y
|
|
2586 ENDC
|
|
2587 ldd #$FFFF
|
|
2588 tfr d,x
|
|
2589 lbsr L0B1B
|
|
2590 bcs L0F6E
|
|
2591 lbsr L0CDF
|
|
2592 bne L0F6F exit
|
|
2593 lbsr L10B2 find a segment
|
|
2594 bcc L0F26
|
|
2595 cmpb #E$NES non-existing segment error
|
|
2596 bra L0F67
|
|
2597
|
|
2598 L0F26 ldd PD.SBL+1,y not quite sure what's going on here...
|
|
2599 subd PD.CP+1,y
|
|
2600 addd PD.SSZ+1,y
|
|
2601 tst PD.CP+3,y on a sector boundary?
|
|
2602 beq L0F35 yes, skip ahead
|
|
2603 IFNE H6309
|
|
2604 decd ok here, carry NOT used below
|
|
2605 ELSE
|
|
2606 subd #$0001
|
|
2607 ENDC
|
|
2608 L0F35 pshs d
|
|
2609 ldu PD.DTB,y number of sectors per cluster
|
|
2610 ldd DD.BIT,u
|
|
2611 IFNE H6309
|
|
2612 decd
|
|
2613 comd
|
|
2614 andd ,s++
|
|
2615 ELSE
|
|
2616 subd #$0001
|
|
2617 coma
|
|
2618 comb
|
|
2619 anda ,s+
|
|
2620 andb ,s+
|
|
2621 ENDC
|
|
2622 ldu PD.SSZ+1,y
|
|
2623 std PD.SSZ+1,y
|
|
2624 beq L0F69
|
|
2625 tfr u,d
|
|
2626 subd PD.SSZ+1,y
|
|
2627 pshs x,b,a
|
|
2628 addd PD.SBP+1,y
|
|
2629 std PD.SBP+1,y
|
|
2630 bcc L0F5F
|
|
2631 inc PD.SBP,y
|
|
2632 L0F5F bsr ClrFBits delete a segment
|
|
2633 bcc L0F70
|
|
2634 leas 4,s
|
|
2635 cmpb #E$IBA illegal block address
|
|
2636
|
|
2637 L0F67 bne L0F6E
|
|
2638 L0F69 lbsr RdFlDscr
|
|
2639 bcc L0F79
|
|
2640 L0F6E coma
|
|
2641 L0F6F rts
|
|
2642
|
|
2643 L0F70 lbsr RdFlDscr
|
|
2644 bcs L0FC9
|
|
2645 puls x,b,a
|
|
2646 std FDSL.B,x
|
|
2647 L0F79 ldu PD.BUF,y
|
|
2648 IFNE H6309
|
|
2649 ldq PD.SIZ,y grab file size from the PD
|
|
2650 stq FD.SIZ,u save in the FD file size
|
|
2651 ELSE
|
|
2652 ldd PD.SIZ,y
|
|
2653 std FD.SIZ,u
|
|
2654 ldd PD.SIZ+2,y
|
|
2655 std FD.SIZ+2,u
|
|
2656 ENDC
|
|
2657 tfr x,d
|
|
2658 clrb
|
|
2659 inca
|
|
2660 leax FDSL.S,x go to the next segment
|
|
2661 pshs x,b,a
|
|
2662 bra L0FB4
|
|
2663 L0F8E ldd -2,x
|
|
2664 beq L0FC1
|
|
2665 std PD.SSZ+1,y
|
|
2666 ldd -FDSL.S,x grab stuff from the last segment
|
|
2667 std PD.SBP,y
|
|
2668 lda -FDSL.B,x
|
|
2669 sta PD.SBP+2,y save sector beginning physical sector number
|
|
2670 bsr ClrFBits delete a segment
|
|
2671 bcs L0FC9
|
|
2672 stx 2,s
|
|
2673 lbsr RdFlDscr
|
|
2674 bcs L0FC9
|
|
2675 ldx 2,s
|
|
2676 IFNE H6309
|
|
2677 clrd
|
|
2678 ELSE
|
|
2679 clra
|
|
2680 clrb
|
|
2681 ENDC
|
|
2682 std -$05,x clear out the segment
|
|
2683 sta -$03,x
|
|
2684 std -$02,x
|
|
2685 L0FB4 lbsr L11FD
|
|
2686 bcs L0FC9
|
|
2687 ldx 2,s
|
|
2688 leax FDSL.S,x go to the next segment
|
|
2689 cmpx ,s
|
|
2690 bcs L0F8E if not done, do another
|
|
2691 L0FC1 equ *
|
|
2692 IFNE H6309
|
|
2693 clrd
|
|
2694 ELSE
|
|
2695 clra
|
|
2696 clrb
|
|
2697 ENDC
|
|
2698 sta PD.SSZ,y
|
|
2699 std PD.SSZ+1,y segment size is zero
|
|
2700 L0FC9 leas 4,s
|
|
2701 rts
|
|
2702
|
|
2703 * de-allocate a segment
|
|
2704 ClrFBits pshs u,y,x,a get device table pointer
|
|
2705 ldx PD.DTB,y
|
|
2706
|
|
2707 * ATD: Added next few lines to ENSURE that LSN0 and the allocation bitmap
|
|
2708 * are NEVER marked as de-allocated in the allocation bitmap
|
|
2709 * ldd PD.SBP,y grab beginning segment physical LSN
|
|
2710 * bne L0FD0 skip next code if too high
|
|
2711 * ldd DD.MAP,x get number of bytes in allocation bitmap
|
|
2712 * addd #$01FF add 1 for LSN0, round up a sector: A=lowest LSN
|
|
2713 * cmpa PD.SBP+2,y check LSN0 + DD.MAP against LSN to deallocate
|
|
2714 * blo L0FD0 if PD.SBP is higher than LSN0 + DD.MAP, allow it
|
|
2715 * ldb #E$IBA illegal block address: can't deallocate LSN0
|
|
2716 * bra L1033 or the allocation bitmap sectors from the bitmap!
|
|
2717
|
|
2718 ldd DD.BIT,x
|
|
2719 IFNE H6309
|
|
2720 decd
|
|
2721 ELSE
|
|
2722 subd #$0001
|
|
2723 ENDC
|
|
2724 addd PD.SBP+1,y
|
|
2725 std PD.SBP+1,y
|
|
2726 ldd DD.BIT,x
|
|
2727 bcc L0FF4
|
|
2728 inc PD.SBP,y
|
|
2729 bra L0FF4
|
|
2730
|
|
2731 L0FE5 lsr PD.SBP,y convert sector number to cluster number
|
|
2732 ror PD.SBP+1,y
|
|
2733 ror PD.SBP+2,y
|
|
2734 lsr PD.SSZ+1,y
|
|
2735 ror PD.SSZ+2,y
|
|
2736 L0FF4 equ *
|
|
2737 IFNE H6309
|
|
2738 lsrd
|
|
2739 ELSE
|
|
2740 lsra
|
|
2741 rorb
|
|
2742 ENDC
|
|
2743 bcc L0FE5
|
|
2744
|
|
2745 clrb
|
|
2746 ldd PD.SSZ+1,y
|
|
2747 beq L1034
|
|
2748 ldd PD.SBP,y
|
|
2749 IFNE H6309
|
|
2750 lsrd
|
|
2751 lsrd
|
|
2752 lsrd get cluster byte number into D
|
|
2753 ELSE
|
|
2754 lsra
|
|
2755 rorb
|
|
2756 lsra
|
|
2757 rorb
|
|
2758 lsra
|
|
2759 rorb
|
|
2760 ENDC
|
|
2761 tfr b,a
|
|
2762 ldb #E$IBA
|
|
2763 cmpa DD.MAP,x is the LSN too high: mapped outside of the bitmap?
|
|
2764 bhi L1033 yes, error out
|
|
2765 inca
|
|
2766 sta ,s
|
|
2767 L1012 bsr L1036 flush the sector, and OWN the bitmap
|
|
2768 bcs L1012
|
|
2769 ldb ,s grab the sector number
|
|
2770 bsr L1091 go read a sector fro the allocation bitmap
|
|
2771 bcs L1033
|
|
2772 ldx PD.BUF,y where to start
|
|
2773 ldd PD.SBP+1,y bit offset to delete
|
|
2774 * ATD: keep deleting sectors until we're done!
|
|
2775 anda #$07 make sure it's within the current sector
|
|
2776 * ATD: fix segment sizes!
|
|
2777 ldy PD.SSZ+1,y number of clusters to deallocate
|
|
2778 os9 F$DelBit go delete them (no error possible)
|
|
2779 ldy 3,s
|
|
2780 ldb ,s grab bitmap sector number again
|
|
2781 bsr L1069 go write it out
|
|
2782 bcc L1034 xit on error
|
|
2783 L1033 coma
|
|
2784 L1034 puls pc,u,y,x,a
|
|
2785
|
|
2786 L1036 lbsr L1237 flush the sector to disk
|
|
2787 bra L1043 skip ahead
|
|
2788
|
|
2789 L103B lbsr L0C56 wakeup the process
|
|
2790 os9 F$IOQu queue the process
|
|
2791 bsr L1053 check for process wakeup
|
|
2792 L1043 bcs L1052 error, return
|
|
2793 ldx PD.DTB,y get drive table ptr
|
|
2794 lda V.BMB,x bitmap sector
|
|
2795 bne L103B if set, continue
|
|
2796 lda PD.CPR,y get our process number
|
|
2797 sta V.BMB,x make us the current user of the bitmap
|
|
2798 L1052 rts
|
|
2799
|
|
2800 * Wait for process to wakeup
|
|
2801 L1053 ldu <D.Proc get current process pointer
|
|
2802 ldb P$Signal,u get pending signal
|
|
2803 cmpb #S$Wake is it what we're looking for?
|
|
2804 bls L1060 yes, skip ahead
|
|
2805 cmpb #S$Intrpt is it a keyboard interrupt/
|
|
2806 bls L1067 no, return error [B]=Error code
|
|
2807 L1060 clra clear error status
|
|
2808 IFNE H6309
|
|
2809 tim #Condem,P$State,u is process dead?
|
|
2810 ELSE
|
|
2811 lda P$State,u
|
|
2812 bita #Condem
|
|
2813 ENDC
|
|
2814 beq L1068 no, skip ahead
|
|
2815 L1067 coma flag error
|
|
2816 L1068 rts return
|
|
2817
|
|
2818 * Write a file allocation bitmap sector
|
|
2819 * Entry: B=Logical sector #
|
|
2820 L1069 clra clear MSB of LSW to logical sector #
|
|
2821 tfr d,x move it to proper register
|
|
2822 clrb clear MSB of logical sector #
|
|
2823 lbsr L1207 flush the sector to drive
|
|
2824 L1070 pshs cc preserve error status from write
|
|
2825 ldx PD.DTB,y get drive table pointer
|
|
2826 lda PD.CPR,y get the current process using it
|
|
2827 cmpa V.BMB,x same as process using the bit-map sector?
|
|
2828 bne L108F no, return
|
|
2829 clr V.BMB,x clear the use flag
|
|
2830 ldx <D.Proc get current process pointer
|
|
2831 lda P$IOQN,x get next process in line for sector
|
|
2832 beq L108F none, return
|
|
2833 lbsr L0C56 wake up the process
|
|
2834 ldx #1 sleep for balance of tick
|
|
2835 os9 F$Sleep
|
|
2836 L108F puls pc,cc restore error status & return
|
|
2837
|
|
2838 * Read a sector from file allocation bit map
|
|
2839 * Entry: B=Logical sector #
|
|
2840 L1091 clra clear MSB of LSW to logical sector #
|
|
2841 tfr d,x move to proper register
|
|
2842 clrb clear MSB of logical sector #
|
|
2843 lbra L113A go read the sector
|
|
2844
|
|
2845 * Entry: Y=Path descriptor pointer
|
|
2846 L1098 ldd PD.CP+1,y
|
|
2847 subd PD.SBL+1,y
|
|
2848 tfr d,x
|
|
2849 ldb PD.CP,y
|
|
2850 sbcb PD.SBL,y
|
|
2851 cmpb PD.SSZ,y
|
|
2852 bcs L10B0
|
|
2853 bhi L10B2 yes, scan the segment list
|
|
2854 cmpx PD.SSZ+1,y
|
|
2855 bcc L10B2
|
|
2856 L10B0 clrb
|
|
2857 L10B1 rts
|
|
2858
|
|
2859 * Scan file segment list to get proper segment based on current byte position
|
|
2860 * in the file. Once found it will be placed in the path descriptor
|
|
2861 * Entry: None
|
|
2862 L10B2 pshs u preserve
|
|
2863 bsr RdFlDscr get the file descriptor
|
|
2864 bcs L110E error, return
|
|
2865 IFNE H6309 init the start point of search in path descriptor
|
|
2866 clrd
|
|
2867 ELSE
|
|
2868 clra
|
|
2869 clrb
|
|
2870 ENDC
|
|
2871 std PD.SBL,y
|
|
2872 stb PD.SBL+2,y
|
|
2873 ldu PD.BUF,y get sector buffer pointer
|
|
2874 leax FD.SEG,u point to segment list
|
|
2875 lda PD.BUF,y get MSB of sector buffer pointer
|
|
2876 ldb #$FC get size of segment table
|
|
2877 pshs b,a save as table end pointer
|
|
2878 * Scan segment list for the proper segment
|
|
2879 L10CB ldd FDSL.B,x get segment size in sectors
|
|
2880 beq L10F0 last one, exit with non existing segment error
|
|
2881 addd PD.SBL+1,y add to segment start LSN
|
|
2882 tfr d,u copy it
|
|
2883 ldb PD.SBL,y
|
|
2884 adcb #0
|
|
2885 cmpb PD.CP,y this the segment we want?
|
|
2886 bhi L10FD yes, move the segment start & size to descriptor
|
|
2887 bne L10E4 no, save this segment & keep looking
|
|
2888 cmpu PD.CP+1,y
|
|
2889 bhi L10FD
|
|
2890 L10E4 stb PD.SBL,y
|
|
2891 stu PD.SBL+1,y
|
|
2892 leax FDSL.S,x move to next segment
|
|
2893 cmpx ,s done?
|
|
2894 bcs L10CB no, keep going
|
|
2895
|
|
2896 * Return Non-Existing segment error
|
|
2897 L10F0 equ *
|
|
2898 IFNE H6309
|
|
2899 clrd
|
|
2900 ELSE
|
|
2901 clra
|
|
2902 clrb
|
|
2903 ENDC
|
|
2904 sta PD.SSZ,y zero out the segment
|
|
2905 std PD.SSZ+1,y
|
|
2906 comb set the carry
|
|
2907 ldb #E$NES non-existing segment
|
|
2908 bra L110C return
|
|
2909
|
|
2910 * Move segment to path descriptor
|
|
2911 L10FD ldd FDSL.A,x get start physical sector #
|
|
2912 std PD.SBP,y put it in path descriptor
|
|
2913 lda FDSL.A+2,x
|
|
2914 sta PD.SBP+2,y
|
|
2915 ldd FDSL.B,x get segment size
|
|
2916 std PD.SSZ+1,y put it in path descriptor
|
|
2917 L110C leas 2,s
|
|
2918 L110E puls pc,u
|
|
2919
|
|
2920 * Read LSN0 from drive
|
|
2921 * Entry: Y=Path descriptor pointer
|
|
2922 L1110 pshs x,b preserve regs used
|
|
2923 lbsr L1237 flush sector buffer
|
|
2924 bcs L111F error, return
|
|
2925 clrb get LSN
|
|
2926 ldx #$0000
|
|
2927 bsr L113A read the sector
|
|
2928 bcc L1121 no error, return
|
|
2929 L111F stb ,s save error code
|
|
2930 L1121 puls pc,x,b restore & return
|
|
2931
|
|
2932 * Read a file descriptor from disk
|
|
2933 * Entry: Y=Path descriptor pointer
|
|
2934 RdFlDscr
|
|
2935 IFNE H6309
|
|
2936 tim #FDBUF,PD.SMF,y FD already here?
|
|
2937 ELSE
|
|
2938 ldb PD.SMF,y
|
|
2939 bitb #FDBUF
|
|
2940 ENDC
|
|
2941 bne L10B0 yes, return no error
|
|
2942 lbsr L1237 flush any sector here
|
|
2943 bcs L10B1 error, return
|
|
2944 IFNE H6309
|
|
2945 oim #FDBUF,PD.SMF,y
|
|
2946 ELSE
|
|
2947 lda PD.SMF,y
|
|
2948 ora #FDBUF
|
|
2949 sta PD.SMF,y
|
|
2950 ENDC
|
|
2951 ldb PD.FD,y get MSB of logical sector
|
|
2952 ldx PD.FD+1,y get LSW of logical sector
|
|
2953 L113A lda #D$READ get read offset
|
|
2954 * Send command to device driver
|
|
2955 * Entry: A=Driver Command offset
|
|
2956 * B=MSB of logical sector #
|
|
2957 * X=LSW of logical sector #
|
|
2958 * Y=Path descriptor pointer
|
|
2959 L113C pshs u,y,x,b,a preserve it all
|
|
2960 IFNE H6309
|
|
2961 oim #InDriver,PD.SMF,y flag we're in ddriver
|
|
2962 ELSE
|
|
2963 lda PD.SMF,y
|
|
2964 ora #InDriver
|
|
2965 sta PD.SMF,y
|
|
2966 ENDC
|
|
2967 ldx <D.Proc get current process pointer
|
|
2968 lda P$Prior,x get its priority
|
|
2969 tfr a,b copy it
|
|
2970 addb #3 add 3 to it
|
|
2971 bcc L1150 didn't wrap, skip ahead
|
|
2972 ldb #$FF force it to max
|
|
2973 L1150 stb P$Prior,x save priority
|
|
2974 stb P$Age,x asage too
|
|
2975 ldx PD.Exten,y get path extension pointer
|
|
2976 sta PE.Prior,x save original priority there
|
|
2977 ldu PD.DEV,y get device table pointer
|
|
2978 ldu V$STAT,u get static mem pointer
|
|
2979 bra L1166 go execute driver
|
|
2980 * Wait for device
|
|
2981 L1160 lbsr L0C56 wakeup waiting process
|
|
2982 os9 F$IOQu queue device
|
|
2983 * Device ready, send command
|
|
2984 L1166 lda V.BUSY,u driver already busy?
|
|
2985 bne L1160 yes, queue it
|
|
2986 lda PD.CPR,y get current process #
|
|
2987 sta V.BUSY,u save it as busy
|
|
2988 ldd ,s get command & logical sector from stack
|
|
2989 ldx 2,s
|
|
2990 pshs u save static mem
|
|
2991 bsr L11EB send it to driver
|
|
2992 puls u restore static mem
|
|
2993 ldy 4,s get path descriptor pointer
|
|
2994 pshs cc preserve driver error status
|
|
2995 bcc L1181 no error, skip ahead
|
|
2996 stb 2,s save driver's error code
|
|
2997 L1181 equ *
|
|
2998 IFNE H6309
|
|
2999 aim #^InDriver,PD.SMF,y clear in driver flag
|
|
3000 ELSE
|
|
3001 lda PD.SMF,y
|
|
3002 anda #^InDriver
|
|
3003 sta PD.SMF,y
|
|
3004 ENDC
|
|
3005 clr V.BUSY,u
|
|
3006 ldx PD.Exten,y
|
|
3007 lda PE.Prior,x
|
|
3008 ldx <D.Proc
|
|
3009 sta P$Prior,x
|
|
3010 ******
|
|
3011 * this code is in v31 only
|
|
3012 lda ,s get driver error status
|
|
3013 bita #Carry was there an error?
|
|
3014 bne L11CB yes, return with it
|
|
3015 lda 1,s get the driver command
|
|
3016 cmpa #D$WRIT was it write sector?
|
|
3017 bne L11CB no, return
|
|
3018 pshs u,y,x preserve regs
|
|
3019 ldy PD.Exten,y
|
|
3020 leau ,y
|
|
3021 L11A7 ldx PE.Confl,u
|
|
3022 cmpy PE.Confl,u
|
|
3023 beq L11C9
|
|
3024 leau ,x
|
|
3025
|
|
3026 * Check for signal on data write
|
|
3027 lda PE.SigID,u anything to send signal to?
|
|
3028 beq L11A7 no, skip to next in chain
|
|
3029 ldx <D.Proc get current process
|
|
3030 cmpa P$ID,x
|
|
3031 beq L11A7
|
|
3032 clr PE.SigID,u
|
|
3033 ldb PE.SigSg,u
|
|
3034 os9 F$Send
|
|
3035 bra L11A7
|
|
3036
|
|
3037 L11C9 puls u,y,x
|
|
3038 L11CB lda P$IOQN,x any process waiting?
|
|
3039 beq L11E9 no, return
|
|
3040 lda $01,y
|
|
3041 bita #$04
|
|
3042 bne L11E9
|
|
3043 ldx PD.DTB,y get driver table pointer
|
|
3044 lda PD.CPR,y get current process ID
|
|
3045 cmpa V.BMB,x same as bitmap use process?
|
|
3046 beq L11E9 yes, return
|
|
3047 lbsr L0C56
|
|
3048 ldx #1 sleep for balance of tick
|
|
3049 os9 F$Sleep
|
|
3050 L11E9 puls pc,u,y,x,b,a,cc restore & return
|
|
3051
|
|
3052 * Execute device driver
|
|
3053 * Entry: A=Driver command offset
|
|
3054 * B=MSB of logical sector #
|
|
3055 * X=LSW of logical sector #
|
|
3056 * Y=Path descriptor pointer
|
|
3057 * U=Static memory pointer
|
|
3058 L11EB pshs pc,x,b,a
|
|
3059 ldx $03,y
|
|
3060 ldd ,x
|
|
3061 ldx ,x
|
|
3062 addd $09,x
|
|
3063 addb ,s
|
|
3064 adca #$00
|
|
3065 std $04,s
|
|
3066 puls pc,x,b,a
|
|
3067
|
|
3068 * Write file descriptor to disk
|
|
3069 * Entry: Y=Path descriptor pointer
|
|
3070 L11FD ldb PD.FD,y get MSB of LSN
|
|
3071 ldx PD.FD+1,y get LSW of LSn
|
|
3072 bra L1207 send it to disk
|
|
3073
|
|
3074
|
|
3075 * Flush sector buffer to disk
|
|
3076 * Entry: Y=Path descriptor pointer
|
|
3077 L1205 bsr L1220 calulate LSN
|
|
3078 L1207 lda #D$WRIT get driver write offset
|
|
3079 pshs x,b,a preserve that & LSN
|
|
3080 ldd PD.DSK,y get disk ID of this sector
|
|
3081 beq L1216 nothing, send it to driver
|
|
3082 ldx PD.DTB,y get drive table pointer
|
|
3083 cmpd DD.DSK,x match ID from drive?
|
|
3084 L1216 puls x,b,a restore regs
|
|
3085 lbeq L113C ID matches, send data to driver
|
|
3086 comb set carry
|
|
3087 ldb #E$DIDC get ID change error code
|
|
3088 rts return
|
|
3089
|
|
3090 * Calculate logical sector # of current sector in buffer
|
|
3091 * Exit : B=MSB of logical sector #
|
|
3092 * X=LSW of logical sector #
|
|
3093 L1220 ldd PD.CP+1,y get current logical sector loaded
|
|
3094 subd PD.SBL+1,y subtract it from segment list LSN
|
|
3095 tfr d,x copy answer
|
|
3096 ldb PD.CP,y get MSB of byte position
|
|
3097 sbcb PD.SBL,y subtract it from segment start
|
|
3098 exg d,x
|
|
3099 addd PD.SBP+1,y add in physical segment sector #
|
|
3100 exg d,x
|
|
3101 adcb PD.SBP,y now the MSB
|
|
3102 rts return
|
|
3103
|
|
3104 * Check if sector buffer needs to be flushed to disk
|
|
3105 * Entry: Y=Path descriptor pointer
|
|
3106 L1237 clrb clear carry
|
|
3107 pshs u,x preserve regs
|
|
3108 ldb PD.SMF,y get state flags
|
1214
|
3109 andb #(BufBusy!FDBUF!SINBUF) anything in buffer?
|
1204
|
3110 beq L1254 no, return
|
|
3111 tfr b,a duplicate flags
|
|
3112 eorb PD.SMF,y clear them
|
|
3113 stb PD.SMF,y save 'em
|
|
3114 andb #BUFMOD has buffer been modified?
|
|
3115 beq L1254 no, return
|
|
3116 eorb PD.SMF,y clear that bit
|
|
3117 stb PD.SMF,y save it
|
|
3118 bita #SINBUF is there even a sector in buffer?
|
|
3119 beq L1254 no, return
|
|
3120 bsr L1205 flush the sector to drive
|
|
3121 L1254 puls pc,u,x restore & return
|
|
3122
|
|
3123 L1256 pshs u,x
|
|
3124 lbsr L1098
|
|
3125 bcs L12C6
|
|
3126 bsr L1237
|
|
3127 bcs L12C6
|
|
3128 L1261 ldb PD.CP,y
|
|
3129 ldu PD.CP+1,y
|
|
3130 leax ,y
|
|
3131 ldy PD.Exten,y
|
|
3132 L126B ldx PD.Exten,x
|
|
3133 cmpy PE.Confl,x
|
|
3134 beq L12B5
|
|
3135 ldx PE.Confl,x
|
|
3136 ldx PE.PDptr,x
|
|
3137 cmpu PD.CP+1,x
|
|
3138 bne L126B
|
|
3139 cmpb PD.CP,x
|
|
3140 bne L126B
|
|
3141 lda PD.SMF,x
|
|
3142 bita #SINBUF
|
|
3143 beq L126B
|
|
3144 bita #InDriver
|
|
3145 bne L128E
|
|
3146 bita #BufBusy
|
|
3147 beq L12A0
|
|
3148 L128E lda PD.CPR,x
|
|
3149 ldy PE.PDptr,y
|
|
3150 lbsr L0C56
|
|
3151 os9 F$IOQu
|
|
3152 lbsr L1053
|
|
3153 bcc L1261
|
|
3154 puls u,x,pc
|
|
3155
|
|
3156 L12A0 ldy PE.PDptr,y
|
|
3157 ldd PD.BUF,x
|
|
3158 ldu PD.BUF,y
|
|
3159 std PD.BUF,y
|
|
3160 stu PD.BUF,x
|
|
3161 lda PD.SMF,x \ careful, don't use oim here
|
|
3162 ora #BufBusy >takes state from x and
|
|
3163 sta PD.SMF,y / stores to y, is infamous "lha" bug
|
|
3164 clr PD.SMF,x
|
|
3165 puls pc,u,x
|
|
3166
|
|
3167 L12B5 ldy PE.PDptr,y
|
|
3168 lbsr L1220
|
|
3169 lbsr L113A
|
|
3170 bcs L12C6
|
|
3171 IFNE H6309
|
|
3172 oim #(BufBusy!SINBUF),PD.SMF,y
|
|
3173 ELSE
|
|
3174 pshs a
|
|
3175 lda PD.SMF,y
|
|
3176 ora #(BufBusy!SINBUF)
|
|
3177 sta PD.SMF,y
|
|
3178 puls a
|
|
3179 ENDC
|
|
3180 L12C6 puls pc,u,x
|
|
3181
|
|
3182 emod
|
|
3183 eom equ *
|
|
3184 end
|
|
3185
|