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
|
|
61 ldx PD.DEV,y ; get ptr to our static storage
|
2450
|
62 pshs x,y,u ; save all on stack
|
|
63 stb V.DWCMD,x
|
|
64
|
2445
|
65 * TODO lets not create multiple buffers when multiple open/create on same path
|
|
66 * get system mem
|
|
67 ldd #256
|
|
68 os9 F$SRqMem ; ask for D bytes (# bytes server said is coming)
|
2450
|
69 lbcs open2
|
2445
|
70 stu V.BUF,x
|
|
71
|
2450
|
72 * use PrsNam to validate pathlist and count length
|
|
73 ldu 4,s ; get pointer to caller's registers
|
|
74 ldy R$X,u
|
|
75 sty V.PATHNAME,x
|
2452
|
76 * MOVE THIS UP ONE LINE AND NO CRASH ON 'list /y0/test'
|
|
77 lbra openerr
|
2450
|
78 tfr y,x
|
|
79 prsloop os9 F$PrsNam
|
|
80 bcs open2
|
|
81 tfr y,x
|
|
82 anda #$7F
|
|
83 cmpa #PENTIR
|
|
84 bne chkdelim
|
|
85 ldb #E$BPNam
|
|
86 bra openerr
|
|
87 chkdelim cmpa #PDELIM
|
|
88 beq prsloop
|
|
89 * at this point X points to the character AFTER the last character in the name
|
|
90 * update callers R$X
|
|
91 ldu 4,s ; get caller's registers
|
|
92 stx R$X,u
|
|
93
|
|
94 * compute the length of the pathname and save it
|
|
95 tfr x,d
|
|
96 ldx ,s ; get the device memory pointer
|
|
97 subd V.PATHNAME,x
|
|
98 std V.PATHNAMELEN,x ; save the length
|
|
99
|
|
100 * put command byte & path # on stack
|
|
101 lda V.DWCMD,x
|
2447
|
102 ldb PD.PD,y
|
|
103 pshs cc
|
|
104 pshs d ; p# PD.DEV PD Regs
|
|
105
|
|
106 * put rfm op and DW op on stack
|
|
107 lda #OP_VFM
|
|
108 pshs a ; DWOP RFMOP p# PD.DEV PD Regs
|
|
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
|
|
121 leas 3,s ;clean stack PD.DEV PD Regs
|
|
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
|
|
164 puls b ; PD.DEV 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
|
|
193 pshs x,y,u
|
2445
|
194
|
|
195 * put path # on stack
|
2447
|
196 lda PD.PD,y
|
|
197 pshs cc
|
2445
|
198 pshs a ; p# PD.DEV PD Regs
|
|
199
|
|
200 * put rfm op and DW op on stack
|
|
201
|
|
202 lda #OP_VFM
|
|
203 pshs d ; DWOP RFMOP p# PD.DEV PD Regs
|
|
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
|
|
218 leas 3,s ;clean stack - PD.DEV PD Regs
|
|
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
|
|
239 puls b ;PD.DEV PD Regs
|
|
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
|
2447
|
247 go_on pshs d ;xfersz PD.DEV PD Regs
|
2445
|
248
|
|
249 * load data from server into mem block
|
2447
|
250 ldx 3,s ; pd.dev
|
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
|
|
264 puls y ;Y = byte count (already set?) - PD.DEV 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
|
|
276 puls x ; pd.dev - PD Regs
|
|
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
|
|
459 ldu V.BUF,x
|
|
460 os9 F$SRtMem
|
|
461
|
2450
|
462 puls b ; server sends result code
|
|
463 tstb
|
2445
|
464 beq close1
|
2450
|
465 coma ; set error flag if != 0
|
|
466 close1 puls u,y,pc
|
2445
|
467
|
|
468
|
2435
|
469 * just send OP_VMF + vfmop
|
2446
|
470 sendit pshs a,x,y,u
|
2435
|
471
|
2445
|
472 lda #OP_VFM ; load command
|
|
473 pshs a ; command store on stack
|
|
474 leax ,s ; point X to stack
|
|
475 ldy #2 ; 2 byte to send
|
|
476 ifgt Level-1
|
|
477 ldu <D.DWSubAddr
|
|
478 else
|
|
479 ldu >D.DWSubAddr
|
|
480 endc
|
2435
|
481
|
2445
|
482 jsr 6,u
|
|
483 leas 2,s ;clean stack
|
|
484
|
|
485 clrb
|
2446
|
486 puls x,y,u,pc
|
2445
|
487
|
|
488 emod
|
|
489 eom equ *
|
|
490 end
|
|
491
|