2435
|
1 ********************************************************************
|
|
2 * RFM - Remote File Manager
|
|
3 *
|
|
4 *
|
|
5 * 1 2010/02/20 AAW
|
|
6 * first version - just send ops
|
|
7
|
2445
|
8 nam RFM
|
|
9 ttl Remote File Manager
|
2435
|
10
|
2445
|
11 ifp1
|
|
12 use defsfile
|
|
13 use rfmdefs
|
|
14 use dwdefs.d
|
|
15 endc
|
2435
|
16
|
2445
|
17 tylg set FlMgr+Objct
|
|
18 atrv set ReEnt+rev
|
|
19 rev set 0
|
|
20 edition equ 1
|
2435
|
21
|
2445
|
22 mod eom,RFMName,tylg,atrv,RFMEnt,size
|
2442
|
23
|
|
24
|
2445
|
25 size equ .
|
|
26
|
|
27
|
|
28 RFMName fcs /RFM/
|
|
29 fcb edition
|
2435
|
30
|
|
31
|
|
32
|
|
33 ******************************
|
|
34 *
|
|
35 * file manager entry point
|
|
36 *
|
|
37 * Entry: Y = Path descriptor pointer
|
|
38 * U = Callers register stack pointer
|
|
39 *
|
|
40
|
2445
|
41 RFMEnt lbra create Create path
|
|
42 lbra open Open path
|
|
43 lbra makdir Makdir
|
|
44 lbra chgdir Chgdir
|
|
45 lbra delete Delete
|
|
46 lbra seek Seek
|
|
47 lbra read Read character
|
|
48 lbra write Write character
|
|
49 lbra readln ReadLn
|
|
50 lbra writln WriteLn
|
|
51 lbra getstt Get Status
|
|
52 lbra setstt Set Status
|
|
53 lbra close Close path
|
|
54
|
|
55 create ldb #DW.create
|
|
56 bra create1
|
|
57
|
|
58
|
|
59 open ldb #DW.open
|
2447
|
60 create1
|
2453
|
61 ldx PD.DEV,y ; get ptr to our device memory
|
|
62 ldx V$STAT,x ; get ptr to our static storage
|
2450
|
63 pshs x,y,u ; save all on stack
|
|
64 stb V.DWCMD,x
|
|
65
|
2445
|
66 * TODO lets not create multiple buffers when multiple open/create on same path
|
|
67 * get system mem
|
|
68 ldd #256
|
|
69 os9 F$SRqMem ; ask for D bytes (# bytes server said is coming)
|
2450
|
70 lbcs open2
|
2445
|
71 stu V.BUF,x
|
|
72
|
2450
|
73 * use PrsNam to validate pathlist and count length
|
|
74 ldu 4,s ; get pointer to caller's registers
|
|
75 ldy R$X,u
|
|
76 sty V.PATHNAME,x
|
|
77 tfr y,x
|
|
78 prsloop os9 F$PrsNam
|
|
79 bcs open2
|
|
80 tfr y,x
|
|
81 anda #$7F
|
|
82 cmpa #PENTIR
|
|
83 bne chkdelim
|
|
84 ldb #E$BPNam
|
|
85 bra openerr
|
|
86 chkdelim cmpa #PDELIM
|
|
87 beq prsloop
|
|
88 * at this point X points to the character AFTER the last character in the name
|
|
89 * update callers R$X
|
|
90 ldu 4,s ; get caller's registers
|
|
91 stx R$X,u
|
|
92
|
|
93 * compute the length of the pathname and save it
|
|
94 tfr x,d
|
|
95 ldx ,s ; get the device memory pointer
|
|
96 subd V.PATHNAME,x
|
|
97 std V.PATHNAMELEN,x ; save the length
|
|
98
|
|
99 * put command byte & path # on stack
|
|
100 lda V.DWCMD,x
|
2456
|
101 ldy 2,s
|
2447
|
102 ldb PD.PD,y
|
|
103 pshs cc
|
2454
|
104 pshs d ; p# PD.PD Regs
|
2447
|
105
|
|
106 * put rfm op and DW op on stack
|
|
107 lda #OP_VFM
|
2454
|
108 pshs a ; DWOP RFMOP p# PD.PD Regs
|
2447
|
109
|
2445
|
110 leax ,s ; point X to stack
|
|
111 ldy #3 ; 3 bytes to send
|
|
112
|
|
113 ifgt Level-1
|
|
114 ldu <D.DWSubAddr
|
|
115 else
|
|
116 ldu >D.DWSubAddr
|
|
117 endc
|
|
118
|
2447
|
119 orcc #IntMasks
|
2445
|
120 jsr 6,u
|
2454
|
121 leas 3,s ;clean stack PD.PD Regs
|
2445
|
122
|
|
123 * now send path string
|
2450
|
124 * move from caller to our mem
|
2444
|
125
|
2450
|
126 ldx <D.Proc get calling proc desc
|
|
127 lda P$Task,x ; A = callers task # (source)
|
2445
|
128
|
2450
|
129 ldb <D.SysTsk ; B = system task # (dest)
|
2445
|
130
|
2450
|
131 ldx 1,s ; get device mem ptr
|
|
132 ldu V.BUF,x ; get destination pointer in U
|
|
133 ldy V.PATHNAMELEN,x ; get count in Y
|
|
134 ldx V.PATHNAME,x ; get source in X
|
2445
|
135
|
2450
|
136 * F$Move the bytes (seems to work)
|
|
137 os9 F$Move
|
|
138
|
|
139 bcs moverr
|
2445
|
140
|
2450
|
141 * Add carriage return
|
|
142 tfr u,x
|
|
143 tfr y,d
|
|
144 leau d,u
|
|
145 lda #C$CR
|
|
146 sta ,u
|
|
147 leay 1,y
|
2436
|
148
|
2445
|
149 * send to server
|
2450
|
150 ifgt Level-1
|
|
151 ldu <D.DWSubAddr
|
|
152 else
|
|
153 ldu >D.DWSubAddr
|
|
154 endc
|
2445
|
155 jsr 6,u
|
|
156
|
|
157 * read response from server -> B
|
2450
|
158 clr ,-s
|
2445
|
159 leax ,s
|
|
160 ldy #1
|
|
161 jsr 3,u
|
|
162
|
|
163 * pull server's response into B
|
2454
|
164 puls b ; PD.PD Regs
|
2450
|
165 moverr puls cc
|
2445
|
166 tstb
|
|
167 beq open2
|
|
168
|
2450
|
169 openerr coma ; set error
|
2452
|
170 open2 puls x,y,u,pc
|
2445
|
171
|
|
172 makdir lda #DW.makdir
|
|
173 lbra sendit
|
|
174 chgdir lda #DW.chgdir
|
|
175 lbra sendit
|
|
176 delete lda #DW.delete
|
|
177 lbra sendit
|
|
178 seek lda #DW.seek
|
|
179 lbra sendit
|
2436
|
180
|
2445
|
181 read ldb #DW.read
|
|
182 bra read1 ; join readln routine
|
|
183
|
|
184
|
|
185
|
|
186 write lda #DW.write
|
|
187 lbra sendit
|
|
188
|
|
189
|
|
190
|
|
191 readln ldb #DW.readln
|
2447
|
192 read1 ldx PD.DEV,y ; to our static storage
|
2454
|
193 ldx V$STAT,x
|
2447
|
194 pshs x,y,u
|
2445
|
195
|
|
196 * put path # on stack
|
2447
|
197 lda PD.PD,y
|
|
198 pshs cc
|
2454
|
199 pshs a ; p# PD.PD Regs
|
2445
|
200
|
|
201 * put rfm op and DW op on stack
|
|
202
|
|
203 lda #OP_VFM
|
2454
|
204 pshs d ; DWOP RFMOP p# PD.PD Regs
|
2445
|
205
|
|
206 leax ,s ; point X to stack
|
|
207 ldy #3 ; 3 bytes to send
|
|
208
|
|
209 * set U to dwsub
|
|
210 ifgt Level-1
|
|
211 ldu <D.DWSubAddr
|
|
212 else
|
|
213 ldu >D.DWSubAddr
|
|
214 endc
|
|
215
|
|
216 * send dw op, rfm op, path #
|
2447
|
217 orcc #IntMasks
|
2445
|
218 jsr 6,u
|
2454
|
219 leas 3,s ;clean stack - PD.PD Regs
|
2445
|
220
|
|
221 * put caller's Y on stack (maximum allowed bytes)
|
2447
|
222 ldx 5,s
|
2445
|
223 ldx R$Y,x
|
|
224 pshs x
|
|
225
|
|
226 * send 2 bytes from stack
|
|
227 leax ,s
|
|
228 ldy #2
|
|
229 jsr 6,u
|
|
230
|
|
231 leas 1,s ; leave 1 byte for server response in next section
|
|
232
|
|
233 * read # bytes coming (0 = eof) from server
|
|
234 leax ,s
|
|
235 ldy #1
|
|
236 jsr 3,u
|
|
237
|
|
238 * store size
|
|
239 clra
|
2454
|
240 puls b ;PD.PD Regs
|
2445
|
241
|
|
242
|
|
243 * check for 0
|
2447
|
244 tstb
|
2445
|
245 beq readln1 ; 0 bytes = EOF
|
|
246
|
|
247 * read the data from server if > 0
|
2454
|
248 go_on pshs d ;xfersz PD.PD Regs
|
2445
|
249
|
|
250 * load data from server into mem block
|
2455
|
251 ldx 3,s ; V$STAT
|
2445
|
252 ldx V.BUF,x
|
|
253 ldy ,s ;xfersz
|
|
254 jsr 3,u
|
|
255
|
|
256 * F$Move
|
|
257 * a = my task #
|
|
258 * b = caller's task #
|
|
259 * X = source ptr
|
|
260 * Y = byte count
|
|
261 * U = dest ptr
|
|
262
|
|
263 * move from our mem to caller
|
|
264
|
2454
|
265 puls y ;Y = byte count (already set?) - PD.PD Regs
|
2447
|
266 puls cc
|
2445
|
267
|
|
268 ldx 4,s
|
|
269 ldu R$X,x ; U = caller's X = dest ptr
|
2450
|
270 sty R$Y,x
|
|
271
|
2445
|
272 lda <D.SysTsk ; A = system task #
|
|
273
|
|
274 ldx <D.Proc get calling proc desc
|
|
275 ldb P$Task,x ; B = callers task #
|
|
276
|
2455
|
277 puls x ; V$STAT - PD Regs
|
2445
|
278 ldx V.BUF,x
|
|
279
|
|
280 * F$Move the bytes (seems to work)
|
|
281 os9 F$Move
|
|
282
|
|
283 * assume everything worked (not good)
|
|
284 clrb
|
|
285 *ldy xfersz,pc ; Y is supposed to be set to bytes read.. do we need to set this in the caller's regs?
|
|
286 bra readln2
|
|
287
|
2447
|
288 readln1
|
|
289 puls cc
|
|
290 comb
|
|
291 ldb #E$EOF
|
2445
|
292 leas 2,s ; clean stack down
|
2446
|
293 readln2 puls y,u,pc
|
2436
|
294
|
2445
|
295
|
|
296 writln lda #DW.writln
|
|
297 lbra sendit
|
|
298
|
|
299 *
|
|
300 * I$GetStat Entry Point
|
|
301 *
|
|
302 * Entry:
|
|
303 *
|
|
304 * Exit:
|
|
305 *
|
|
306 * Error: CC Carry set
|
|
307 * B = errcode
|
|
308 *
|
|
309 getstt
|
|
310 lda #DW.getstt
|
|
311 lbsr sendit
|
|
312
|
|
313 ldb R$B,u get function code
|
|
314 beq GstOPT
|
|
315 cmpb #SS.EOF
|
|
316 beq GstEOF
|
|
317 cmpb #SS.Ready
|
|
318 beq GstReady
|
|
319 cmpb #SS.Size
|
|
320 beq GstSize
|
|
321 cmpb #SS.Pos
|
|
322 beq GstPos
|
|
323 cmpb #SS.FD
|
|
324 beq GstFD
|
|
325 cmpb #SS.FDInf
|
|
326 beq GstFDInf
|
|
327 comb
|
|
328 ldb #E$UnkSvc
|
|
329 rts
|
|
330
|
|
331 * SS.OPT
|
|
332 * RBF does nothing here, so we do nothing
|
|
333 GstOPT
|
|
334 rts
|
|
335
|
|
336 * SS.EOF
|
|
337 * Entry A = path
|
|
338 * B = SS.EOF
|
|
339 GstEOF
|
|
340 rts
|
|
341
|
|
342 * SS.Ready - Check for data available on path
|
|
343 * Entry A = path
|
|
344 * B = SS.Ready
|
|
345 GstReady
|
|
346 clr R$B,u always mark no data ready
|
|
347 rts
|
|
348
|
|
349 * SS.Size - Return size of file opened on path
|
|
350 * Entry A = path
|
|
351 * B = SS.SIZ
|
|
352 * Exit X = msw of files size
|
|
353 * U = lsw of files size
|
|
354 GstSize
|
|
355 rts
|
|
356
|
|
357 * SS.Pos - Return the current position in the file
|
|
358 * Entry A = path
|
|
359 * B = SS.Pos
|
|
360 * Exit X = msw of pos
|
|
361 * U = lsw of pos
|
|
362 GstPOS
|
|
363 rts
|
|
364
|
|
365 * SS.FD - Return file descriptor sector
|
|
366 * Entry: A = path
|
|
367 * B = SS.FD
|
|
368 * X = ptr to 256 byte buffer
|
|
369 * Y = # of bytes of FD required
|
|
370
|
|
371 GstFD
|
|
372 rts
|
|
373
|
|
374 * SS.FDInf -
|
|
375 * Entry: A = path
|
|
376 * B = SS.FDInf
|
|
377 * X = ptr to 256 byte buffer
|
|
378 * Y = msb - Length of read
|
|
379 * lsb - MSB of LSN
|
|
380 * U = LSW of LSN
|
|
381 GstFDInf
|
|
382 rts
|
|
383
|
|
384
|
|
385
|
|
386 *
|
|
387 * I$SetStat Entry Point
|
|
388 *
|
|
389 * Entry:
|
|
390 *
|
|
391 * Exit:
|
|
392 *
|
|
393 * Error: CC Carry set
|
|
394 * B = errcode
|
|
395 *
|
2450
|
396 setstt
|
|
397 lda #DW.setstt
|
2445
|
398 lbsr sendit
|
|
399
|
|
400 ldb R$B,u
|
|
401 beq SstOpt
|
|
402 cmpb #SS.Size
|
|
403 beq SstSize
|
|
404 cmpb #SS.FD
|
|
405 beq SstFD
|
|
406 cmpb #SS.Lock
|
|
407 beq SstLock
|
|
408 cmpb #SS.RsBit
|
|
409 beq SstRsBit
|
|
410 cmpb #SS.Attr
|
|
411 beq SstAttr
|
|
412 cmpb #SS.FSig
|
|
413 beq SstFSig
|
|
414 comb
|
|
415 ldb #E$UnkSvc
|
|
416 rts
|
|
417
|
|
418 SstOpt
|
|
419 SstSize
|
|
420 SstFD
|
|
421 SstLock
|
|
422 SstRsBit
|
|
423 SstAttr
|
|
424 SstFSig
|
|
425 rts
|
|
426
|
|
427
|
2450
|
428 close
|
|
429 pshs y,u
|
2445
|
430
|
|
431 * put path # on stack
|
2450
|
432 lda PD.PD,y
|
2445
|
433 pshs a
|
|
434
|
|
435 * put rfm op and DW op on stack
|
|
436 ldb #DW.close
|
|
437 lda #OP_VFM
|
|
438 pshs d
|
|
439
|
|
440 leax ,s ; point X to stack
|
|
441 ldy #3 ; 3 bytes to send
|
|
442 ifgt Level-1
|
|
443 ldu <D.DWSubAddr
|
|
444 else
|
|
445 ldu >D.DWSubAddr
|
|
446 endc
|
|
447
|
|
448 jsr 6,u
|
|
449 leas 2,s ;clean stack (leave 1 byte)
|
|
450
|
|
451 * read server response
|
|
452 leax ,s
|
|
453 ldy #1
|
|
454 jsr 3,u
|
|
455
|
|
456 * free system mem
|
|
457 ldd #256
|
|
458 ldx 1,s ; orig Y
|
|
459 ldx PD.DEV,x
|
2454
|
460 ldx V$STAT,x
|
2445
|
461 ldu V.BUF,x
|
|
462 os9 F$SRtMem
|
|
463
|
2450
|
464 puls b ; server sends result code
|
|
465 tstb
|
2445
|
466 beq close1
|
2450
|
467 coma ; set error flag if != 0
|
|
468 close1 puls u,y,pc
|
2445
|
469
|
|
470
|
2435
|
471 * just send OP_VMF + vfmop
|
2446
|
472 sendit pshs a,x,y,u
|
2435
|
473
|
2445
|
474 lda #OP_VFM ; load command
|
|
475 pshs a ; command store on stack
|
|
476 leax ,s ; point X to stack
|
|
477 ldy #2 ; 2 byte to send
|
|
478 ifgt Level-1
|
|
479 ldu <D.DWSubAddr
|
|
480 else
|
|
481 ldu >D.DWSubAddr
|
|
482 endc
|
2435
|
483
|
2445
|
484 jsr 6,u
|
|
485 leas 2,s ;clean stack
|
|
486
|
|
487 clrb
|
2446
|
488 puls x,y,u,pc
|
2445
|
489
|
|
490 emod
|
|
491 eom equ *
|
|
492 end
|
|
493
|