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
|
2447
|
101 ldb PD.PD,y
|
|
102 pshs cc
|
2454
|
103 pshs d ; p# PD.PD Regs
|
2447
|
104
|
|
105 * put rfm op and DW op on stack
|
|
106 lda #OP_VFM
|
2454
|
107 pshs a ; DWOP RFMOP p# PD.PD Regs
|
2447
|
108
|
2445
|
109 leax ,s ; point X to stack
|
|
110 ldy #3 ; 3 bytes to send
|
|
111
|
|
112 ifgt Level-1
|
|
113 ldu <D.DWSubAddr
|
|
114 else
|
|
115 ldu >D.DWSubAddr
|
|
116 endc
|
|
117
|
2447
|
118 orcc #IntMasks
|
2445
|
119 jsr 6,u
|
2454
|
120 leas 3,s ;clean stack PD.PD Regs
|
2445
|
121
|
|
122 * now send path string
|
2450
|
123 * move from caller to our mem
|
2444
|
124
|
2450
|
125 ldx <D.Proc get calling proc desc
|
|
126 lda P$Task,x ; A = callers task # (source)
|
2445
|
127
|
2450
|
128 ldb <D.SysTsk ; B = system task # (dest)
|
2445
|
129
|
2450
|
130 ldx 1,s ; get device mem ptr
|
|
131 ldu V.BUF,x ; get destination pointer in U
|
|
132 ldy V.PATHNAMELEN,x ; get count in Y
|
|
133 ldx V.PATHNAME,x ; get source in X
|
2445
|
134
|
2450
|
135 * F$Move the bytes (seems to work)
|
|
136 os9 F$Move
|
|
137
|
|
138 bcs moverr
|
2445
|
139
|
2450
|
140 * Add carriage return
|
|
141 tfr u,x
|
|
142 tfr y,d
|
|
143 leau d,u
|
|
144 lda #C$CR
|
|
145 sta ,u
|
|
146 leay 1,y
|
2436
|
147
|
2445
|
148 * send to server
|
2450
|
149 ifgt Level-1
|
|
150 ldu <D.DWSubAddr
|
|
151 else
|
|
152 ldu >D.DWSubAddr
|
|
153 endc
|
2445
|
154 jsr 6,u
|
|
155
|
|
156 * read response from server -> B
|
2450
|
157 clr ,-s
|
2445
|
158 leax ,s
|
|
159 ldy #1
|
|
160 jsr 3,u
|
|
161
|
|
162 * pull server's response into B
|
2454
|
163 puls b ; PD.PD Regs
|
2450
|
164 moverr puls cc
|
2445
|
165 tstb
|
|
166 beq open2
|
|
167
|
2450
|
168 openerr coma ; set error
|
2452
|
169 open2 puls x,y,u,pc
|
2445
|
170
|
|
171 makdir lda #DW.makdir
|
|
172 lbra sendit
|
|
173 chgdir lda #DW.chgdir
|
|
174 lbra sendit
|
|
175 delete lda #DW.delete
|
|
176 lbra sendit
|
|
177 seek lda #DW.seek
|
|
178 lbra sendit
|
2436
|
179
|
2445
|
180 read ldb #DW.read
|
|
181 bra read1 ; join readln routine
|
|
182
|
|
183
|
|
184
|
|
185 write lda #DW.write
|
|
186 lbra sendit
|
|
187
|
|
188
|
|
189
|
|
190 readln ldb #DW.readln
|
2447
|
191 read1 ldx PD.DEV,y ; to our static storage
|
2454
|
192 ldx V$STAT,x
|
2447
|
193 pshs x,y,u
|
2445
|
194
|
|
195 * put path # on stack
|
2447
|
196 lda PD.PD,y
|
|
197 pshs cc
|
2454
|
198 pshs a ; p# PD.PD Regs
|
2445
|
199
|
|
200 * put rfm op and DW op on stack
|
|
201
|
|
202 lda #OP_VFM
|
2454
|
203 pshs d ; DWOP RFMOP p# PD.PD Regs
|
2445
|
204
|
|
205 leax ,s ; point X to stack
|
|
206 ldy #3 ; 3 bytes to send
|
|
207
|
|
208 * set U to dwsub
|
|
209 ifgt Level-1
|
|
210 ldu <D.DWSubAddr
|
|
211 else
|
|
212 ldu >D.DWSubAddr
|
|
213 endc
|
|
214
|
|
215 * send dw op, rfm op, path #
|
2447
|
216 orcc #IntMasks
|
2445
|
217 jsr 6,u
|
2454
|
218 leas 3,s ;clean stack - PD.PD Regs
|
2445
|
219
|
|
220 * put caller's Y on stack (maximum allowed bytes)
|
2447
|
221 ldx 5,s
|
2445
|
222 ldx R$Y,x
|
|
223 pshs x
|
|
224
|
|
225 * send 2 bytes from stack
|
|
226 leax ,s
|
|
227 ldy #2
|
|
228 jsr 6,u
|
|
229
|
|
230 leas 1,s ; leave 1 byte for server response in next section
|
|
231
|
|
232 * read # bytes coming (0 = eof) from server
|
|
233 leax ,s
|
|
234 ldy #1
|
|
235 jsr 3,u
|
|
236
|
|
237 * store size
|
|
238 clra
|
2454
|
239 puls b ;PD.PD Regs
|
2445
|
240
|
|
241
|
|
242 * check for 0
|
2447
|
243 tstb
|
2445
|
244 beq readln1 ; 0 bytes = EOF
|
|
245
|
|
246 * read the data from server if > 0
|
2454
|
247 go_on pshs d ;xfersz PD.PD Regs
|
2445
|
248
|
|
249 * load data from server into mem block
|
2455
|
250 ldx 3,s ; V$STAT
|
2445
|
251 ldx V.BUF,x
|
|
252 ldy ,s ;xfersz
|
|
253 jsr 3,u
|
|
254
|
|
255 * F$Move
|
|
256 * a = my task #
|
|
257 * b = caller's task #
|
|
258 * X = source ptr
|
|
259 * Y = byte count
|
|
260 * U = dest ptr
|
|
261
|
|
262 * move from our mem to caller
|
|
263
|
2454
|
264 puls y ;Y = byte count (already set?) - PD.PD Regs
|
2447
|
265 puls cc
|
2445
|
266
|
|
267 ldx 4,s
|
|
268 ldu R$X,x ; U = caller's X = dest ptr
|
2450
|
269 sty R$Y,x
|
|
270
|
2445
|
271 lda <D.SysTsk ; A = system task #
|
|
272
|
|
273 ldx <D.Proc get calling proc desc
|
|
274 ldb P$Task,x ; B = callers task #
|
|
275
|
2455
|
276 puls x ; V$STAT - PD Regs
|
2445
|
277 ldx V.BUF,x
|
|
278
|
|
279 * F$Move the bytes (seems to work)
|
|
280 os9 F$Move
|
|
281
|
|
282 * assume everything worked (not good)
|
|
283 clrb
|
|
284 *ldy xfersz,pc ; Y is supposed to be set to bytes read.. do we need to set this in the caller's regs?
|
|
285 bra readln2
|
|
286
|
2447
|
287 readln1
|
|
288 puls cc
|
|
289 comb
|
|
290 ldb #E$EOF
|
2445
|
291 leas 2,s ; clean stack down
|
2446
|
292 readln2 puls y,u,pc
|
2436
|
293
|
2445
|
294
|
|
295 writln lda #DW.writln
|
|
296 lbra sendit
|
|
297
|
|
298 *
|
|
299 * I$GetStat Entry Point
|
|
300 *
|
|
301 * Entry:
|
|
302 *
|
|
303 * Exit:
|
|
304 *
|
|
305 * Error: CC Carry set
|
|
306 * B = errcode
|
|
307 *
|
|
308 getstt
|
|
309 lda #DW.getstt
|
|
310 lbsr sendit
|
|
311
|
|
312 ldb R$B,u get function code
|
|
313 beq GstOPT
|
|
314 cmpb #SS.EOF
|
|
315 beq GstEOF
|
|
316 cmpb #SS.Ready
|
|
317 beq GstReady
|
|
318 cmpb #SS.Size
|
|
319 beq GstSize
|
|
320 cmpb #SS.Pos
|
|
321 beq GstPos
|
|
322 cmpb #SS.FD
|
|
323 beq GstFD
|
|
324 cmpb #SS.FDInf
|
|
325 beq GstFDInf
|
|
326 comb
|
|
327 ldb #E$UnkSvc
|
|
328 rts
|
|
329
|
|
330 * SS.OPT
|
|
331 * RBF does nothing here, so we do nothing
|
|
332 GstOPT
|
|
333 rts
|
|
334
|
|
335 * SS.EOF
|
|
336 * Entry A = path
|
|
337 * B = SS.EOF
|
|
338 GstEOF
|
|
339 rts
|
|
340
|
|
341 * SS.Ready - Check for data available on path
|
|
342 * Entry A = path
|
|
343 * B = SS.Ready
|
|
344 GstReady
|
|
345 clr R$B,u always mark no data ready
|
|
346 rts
|
|
347
|
|
348 * SS.Size - Return size of file opened on path
|
|
349 * Entry A = path
|
|
350 * B = SS.SIZ
|
|
351 * Exit X = msw of files size
|
|
352 * U = lsw of files size
|
|
353 GstSize
|
|
354 rts
|
|
355
|
|
356 * SS.Pos - Return the current position in the file
|
|
357 * Entry A = path
|
|
358 * B = SS.Pos
|
|
359 * Exit X = msw of pos
|
|
360 * U = lsw of pos
|
|
361 GstPOS
|
|
362 rts
|
|
363
|
|
364 * SS.FD - Return file descriptor sector
|
|
365 * Entry: A = path
|
|
366 * B = SS.FD
|
|
367 * X = ptr to 256 byte buffer
|
|
368 * Y = # of bytes of FD required
|
|
369
|
|
370 GstFD
|
|
371 rts
|
|
372
|
|
373 * SS.FDInf -
|
|
374 * Entry: A = path
|
|
375 * B = SS.FDInf
|
|
376 * X = ptr to 256 byte buffer
|
|
377 * Y = msb - Length of read
|
|
378 * lsb - MSB of LSN
|
|
379 * U = LSW of LSN
|
|
380 GstFDInf
|
|
381 rts
|
|
382
|
|
383
|
|
384
|
|
385 *
|
|
386 * I$SetStat Entry Point
|
|
387 *
|
|
388 * Entry:
|
|
389 *
|
|
390 * Exit:
|
|
391 *
|
|
392 * Error: CC Carry set
|
|
393 * B = errcode
|
|
394 *
|
2450
|
395 setstt
|
|
396 lda #DW.setstt
|
2445
|
397 lbsr sendit
|
|
398
|
|
399 ldb R$B,u
|
|
400 beq SstOpt
|
|
401 cmpb #SS.Size
|
|
402 beq SstSize
|
|
403 cmpb #SS.FD
|
|
404 beq SstFD
|
|
405 cmpb #SS.Lock
|
|
406 beq SstLock
|
|
407 cmpb #SS.RsBit
|
|
408 beq SstRsBit
|
|
409 cmpb #SS.Attr
|
|
410 beq SstAttr
|
|
411 cmpb #SS.FSig
|
|
412 beq SstFSig
|
|
413 comb
|
|
414 ldb #E$UnkSvc
|
|
415 rts
|
|
416
|
|
417 SstOpt
|
|
418 SstSize
|
|
419 SstFD
|
|
420 SstLock
|
|
421 SstRsBit
|
|
422 SstAttr
|
|
423 SstFSig
|
|
424 rts
|
|
425
|
|
426
|
2450
|
427 close
|
|
428 pshs y,u
|
2445
|
429
|
|
430 * put path # on stack
|
2450
|
431 lda PD.PD,y
|
2445
|
432 pshs a
|
|
433
|
|
434 * put rfm op and DW op on stack
|
|
435 ldb #DW.close
|
|
436 lda #OP_VFM
|
|
437 pshs d
|
|
438
|
|
439 leax ,s ; point X to stack
|
|
440 ldy #3 ; 3 bytes to send
|
|
441 ifgt Level-1
|
|
442 ldu <D.DWSubAddr
|
|
443 else
|
|
444 ldu >D.DWSubAddr
|
|
445 endc
|
|
446
|
|
447 jsr 6,u
|
|
448 leas 2,s ;clean stack (leave 1 byte)
|
|
449
|
|
450 * read server response
|
|
451 leax ,s
|
|
452 ldy #1
|
|
453 jsr 3,u
|
|
454
|
|
455 * free system mem
|
|
456 ldd #256
|
|
457 ldx 1,s ; orig Y
|
|
458 ldx PD.DEV,x
|
2454
|
459 ldx V$STAT,x
|
2445
|
460 ldu V.BUF,x
|
|
461 os9 F$SRtMem
|
|
462
|
2450
|
463 puls b ; server sends result code
|
|
464 tstb
|
2445
|
465 beq close1
|
2450
|
466 coma ; set error flag if != 0
|
|
467 close1 puls u,y,pc
|
2445
|
468
|
|
469
|
2435
|
470 * just send OP_VMF + vfmop
|
2446
|
471 sendit pshs a,x,y,u
|
2435
|
472
|
2445
|
473 lda #OP_VFM ; load command
|
|
474 pshs a ; command store on stack
|
|
475 leax ,s ; point X to stack
|
|
476 ldy #2 ; 2 byte to send
|
|
477 ifgt Level-1
|
|
478 ldu <D.DWSubAddr
|
|
479 else
|
|
480 ldu >D.DWSubAddr
|
|
481 endc
|
2435
|
482
|
2445
|
483 jsr 6,u
|
|
484 leas 2,s ;clean stack
|
|
485
|
|
486 clrb
|
2446
|
487 puls x,y,u,pc
|
2445
|
488
|
|
489 emod
|
|
490 eom equ *
|
|
491 end
|
|
492
|