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