Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/rbdw3.asm @ 2640:8d24c482646e
o increased timeout in atari dwread.asm module
o fixed bug in rbdw3.asm where OP_INIT wasn't being sent
o replaced constant offset jumps into dw3.sb with labels
author | Boisy Pitre <boisy.pitre@nuance.com> |
---|---|
date | Tue, 28 Feb 2012 23:09:32 -0600 |
parents | 4e5ff2c5b512 |
children | 2ebf5e737ceb |
rev | line source |
---|---|
2180 | 1 ******************************************************************** |
2 * rbdw3 - DriveWire 3 driver | |
3 * | |
4 * $Id$ | |
5 * | |
6 * This driver works in conjuction with the DriveWire Server on Linux, | |
7 * Mac or Windows, providing the CoCo with pseudo-disk access through | |
8 * the serial port. | |
9 * | |
10 * It adheres to the DriveWire Version 3 Protocol. | |
11 * | |
12 * The baud rate is set at 115200 and the communications requirements | |
13 * are set to 8-N-1. For OS-9 Level One on a CoCo 2, the baud rate | |
14 * is 57600. | |
15 * | |
16 * Edt/Rev YYYY/MM/DD Modified by | |
17 * Comment | |
18 * ------------------------------------------------------------------ | |
19 * 1 2008/02/08 Boisy G. Pitre | |
20 * Started from drivewire.asm in DriveWire 2 Product folder. | |
21 * | |
22 * 2 2008/04/22 Boisy G. Pitre | |
23 * Verified working operation on a CoCo 3 running NitrOS-9/6809 Level 1 @ 57.6Kbps | |
2194 | 24 * |
25 * 3 2009/03/09 Boisy G. Pitre | |
26 * Added checks for size after reading as noted by Darren A's email. | |
2298 | 27 * |
28 * 4 2009/12/31 Boisy G. Pitre | |
29 * Fixed a crash in Term by adding a check for DWSubAddr of $0000 | |
30 * (possible if Init fails due to subroutine module not being in | |
31 * memory and I$Detach calls Term) | |
2180 | 32 |
33 nam rbdw3 | |
34 ttl DriveWire 3 driver | |
35 | |
36 NUMRETRIES equ 8 | |
37 | |
38 ifp1 | |
39 use defsfile | |
2624 | 40 use drivewire.d |
2180 | 41 endc |
42 | |
43 NumDrvs set 4 | |
44 | |
45 tylg set Drivr+Objct | |
46 atrv set ReEnt+rev | |
47 rev set $01 | |
2298 | 48 edition set 4 |
2180 | 49 |
50 mod eom,name,tylg,atrv,start,size | |
51 | |
52 rmb DRVBEG+(DRVMEM*NumDrvs) | |
53 driveno rmb 1 | |
54 retries rmb 1 | |
55 size equ . | |
56 | |
57 fcb DIR.+SHARE.+PEXEC.+PREAD.+PWRIT.+EXEC.+UPDAT. | |
58 | |
59 name fcs /rbdw3/ | |
60 fcb edition | |
61 | |
62 start bra Init | |
63 nop | |
64 bra Read | |
65 nop | |
66 lbra Write | |
67 lbra GetStat | |
68 lbra SetStat | |
69 | |
70 * Term | |
71 * | |
72 * Entry: | |
73 * U = address of device memory area | |
74 * | |
75 * Exit: | |
76 * CC = carry set on error | |
77 * B = error code | |
78 * | |
79 Term | |
2636
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
80 clrb |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
81 pshs cc |
2180 | 82 * Send OP_TERM to the server |
2636
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
83 IFGT LEVEL-1 |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
84 ldu <D.DWSubAddr |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
85 ELSE |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
86 ldu >D.DWSubAddr |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
87 ENDC |
2298 | 88 * Fix crash in certain cases |
2636
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
89 beq no@ |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
90 ldy #$0001 |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
91 lda #OP_TERM |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
92 pshs a |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
93 leax ,s |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
94 orcc #IntMasks |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
95 jsr DW$Write,u |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
96 clrb |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
97 puls a |
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
98 no@ puls cc,pc |
2180 | 99 |
100 * Init | |
101 * | |
102 * Entry: | |
103 * Y = address of device descriptor | |
104 * U = address of device memory area | |
105 * | |
106 * Exit: | |
107 * CC = carry set on error | |
108 * B = error code | |
109 * | |
110 Init | |
2210
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
111 IFGT Level-1 |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
112 * Perform this so we can successfully do F$Link below |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
113 ldx <D.Proc |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
114 pshs a,x |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
115 ldx <D.SysPrc |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
116 stx <D.Proc |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
117 ELSE |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
118 pshs a |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
119 ENDC |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
120 |
2180 | 121 ldb #NumDrvs |
122 stb V.NDRV,u | |
123 leax DRVBEG,u | |
124 lda #$FF | |
125 Init2 sta DD.TOT,x invalidate drive tables | |
126 sta DD.TOT+1,x | |
127 sta DD.TOT+2,x | |
128 leax DRVMEM,x | |
129 decb | |
130 bne Init2 | |
131 | |
2309 | 132 * Check if subroutine module has already been linked |
133 IFGT LEVEL-1 | |
134 ldu <D.DWSubAddr | |
135 ELSE | |
136 ldu >D.DWSubAddr | |
137 ENDC | |
2535 | 138 bne InitEx |
2180 | 139 * Link to subroutine module |
140 clra | |
141 leax name+2,pcr | |
142 os9 F$Link | |
2210
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
143 bcs InitEx |
2180 | 144 tfr y,u |
145 IFGT LEVEL-1 | |
2270
07b2433f0c65
moved dwdefs.d to defs/, major changes to drivers due to new globals arrangement.
boisy
parents:
2231
diff
changeset
|
146 stu <D.DWSubAddr |
2180 | 147 ELSE |
2270
07b2433f0c65
moved dwdefs.d to defs/, major changes to drivers due to new globals arrangement.
boisy
parents:
2231
diff
changeset
|
148 stu >D.DWSubAddr |
2180 | 149 ENDC |
150 * Initialize the low level device | |
2636
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
151 jsr DW$Init,u |
2180 | 152 lda #OP_INIT |
2640
8d24c482646e
o increased timeout in atari dwread.asm module
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2636
diff
changeset
|
153 sta ,s |
2180 | 154 leax ,s |
155 ldy #$0001 | |
2636
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
156 jsr DW$Write,u |
2180 | 157 clrb |
2210
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
158 |
2211 | 159 InitEx |
2210
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
160 IFGT Level-1 |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
161 puls a,x |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
162 stx <D.Proc |
2309 | 163 InitEx2 |
2210
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
164 rts |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
165 ELSE |
2309 | 166 InitEx2 |
2180 | 167 puls a,pc |
2210
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
168 ENDC |
2180 | 169 |
170 * Read | |
171 * | |
172 * Entry: | |
173 * B = MSB of LSN | |
174 * X = LSB of LSN | |
175 * Y = address of path descriptor | |
176 * U = address of device memory area | |
177 * | |
178 * Exit: | |
179 * CC = carry set on error | |
180 * B = error code | |
181 * | |
182 Read | |
183 lda #NUMRETRIES | |
184 sta retries,u | |
185 cmpx #$0000 LSN 0? | |
186 bne ReadSect branch if not | |
187 tstb LSN 0? | |
188 bne ReadSect branch if not | |
2636
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
189 * At this point we are reading LSN0 |
2180 | 190 bsr ReadSect read the sector |
191 bcs CpyLSNEx if error, exit | |
192 leax DRVBEG,u point to start of drive table | |
193 ldb <PD.DRV,y get drive number | |
194 NextDrv beq CopyLSN0 branch if terminal count | |
195 leax <DRVMEM,x else move to next drive table entry | |
196 decb decrement counter | |
197 bra NextDrv and continue | |
198 CopyLSN0 ldb #DD.SIZ get size to copy | |
199 ldy PD.BUF,y point to buffer | |
200 CpyLSNLp lda ,y+ get byte from buffer | |
201 sta ,x+ and save in drive table | |
202 decb | |
203 bne CpyLSNLp | |
204 CpyLSNEx rts | |
205 | |
206 | |
207 ReadSect pshs cc | |
208 pshs u,y,x,b,a,cc then push CC and others on stack | |
209 * Send out op code and 3 byte LSN | |
210 lda PD.DRV,y get drive number | |
211 cmpa #NumDrvs | |
212 blo Read1 | |
213 ldb #E$Unit | |
214 bra ReadEr2 | |
215 Read1 sta driveno,u | |
216 lda #OP_READEX load A with READ opcode | |
217 | |
218 Read2 | |
219 ldb driveno,u | |
220 leax ,s | |
221 std ,x | |
222 ldy #5 | |
223 IFGT LEVEL-1 | |
2270
07b2433f0c65
moved dwdefs.d to defs/, major changes to drivers due to new globals arrangement.
boisy
parents:
2231
diff
changeset
|
224 ldu <D.DWSubAddr |
2180 | 225 ELSE |
2270
07b2433f0c65
moved dwdefs.d to defs/, major changes to drivers due to new globals arrangement.
boisy
parents:
2231
diff
changeset
|
226 ldu >D.DWSubAddr |
2180 | 227 ENDC |
228 orcc #IntMasks | |
2636
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
229 jsr DW$Write,u |
2180 | 230 |
231 * Get 256 bytes of sector data | |
232 ldx 5,s | |
233 ldx PD.BUF,x get buffer pointer into X | |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2211
diff
changeset
|
234 ldy #$0100 |
2636
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
235 jsr DW$Read,u |
2180 | 236 bcs ReadEr1 |
237 bne ReadEr1 | |
238 pshs y | |
239 leax ,s | |
240 ldy #$0002 | |
2636
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
241 jsr DW$Write,u write checksum to server |
2180 | 242 |
243 * Get error code byte | |
244 leax ,s | |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2211
diff
changeset
|
245 ldy #$0001 |
2636
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
246 jsr DW$Read,u |
2194 | 247 bcs ReadEr0 branch if we timed out |
248 bne ReadEr0 | |
2180 | 249 puls d |
250 tfr a,b transfer byte to B (in case of error) | |
251 tstb is it zero? | |
252 beq ReadEx if not, exit with error | |
253 cmpb #E$CRC | |
254 bne ReadEr2 | |
255 ldu 7,s get U from stack | |
256 dec retries,u decrement retries | |
257 beq ReadEr1 | |
258 | |
259 lda #OP_REREADEX reread opcode | |
260 bra Read2 and try getting sector again | |
2195
8b38d4f75b44
Addressed issue raised by Darren A about checking error code size
boisy
parents:
2194
diff
changeset
|
261 ReadEr0 puls d |
2180 | 262 ReadEr1 ldb #E$Read read error |
263 ReadEr2 lda 9,s | |
264 ora #Carry | |
265 sta 9,s | |
266 ReadEx leas 5,s | |
267 puls y,u | |
268 puls cc,pc | |
269 | |
270 * Write | |
271 * | |
272 * Entry: | |
273 * B = MSB of LSN | |
274 * X = LSB of LSN | |
275 * Y = address of path descriptor | |
276 * U = address of device memory area | |
277 * | |
278 * Exit: | |
279 * CC = carry set on error | |
280 * B = error code | |
281 * | |
282 Write lda #NUMRETRIES | |
283 sta retries,u | |
284 pshs cc | |
285 pshs u,y,x,b,a,cc | |
286 * Send out op code and 3 byte LSN | |
287 lda PD.DRV,y | |
288 cmpa #NumDrvs | |
289 blo Write1 | |
290 comb set Carry | |
291 ldb #E$Unit | |
292 bra WritEx | |
293 Write1 sta driveno,u | |
294 lda #OP_WRITE | |
295 Write15 | |
296 ldb driveno,u | |
297 leax ,s | |
298 std ,x | |
299 ldy #$0005 | |
300 IFGT LEVEL-1 | |
2270
07b2433f0c65
moved dwdefs.d to defs/, major changes to drivers due to new globals arrangement.
boisy
parents:
2231
diff
changeset
|
301 ldu <D.DWSubAddr |
2180 | 302 ELSE |
2270
07b2433f0c65
moved dwdefs.d to defs/, major changes to drivers due to new globals arrangement.
boisy
parents:
2231
diff
changeset
|
303 ldu >D.DWSubAddr |
2180 | 304 ENDC |
305 orcc #IntMasks | |
2636
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
306 jsr DW$Write,u |
2180 | 307 |
308 * Compute checksum on sector we just sent and send checksum to server | |
309 ldy 5,s get Y from stack | |
310 ldx PD.BUF,y point to buffer | |
311 ldy #256 | |
312 jsr 6,u | |
313 leax -256,x | |
314 bsr DoCSum | |
315 pshs d | |
316 leax ,s | |
317 ldy #$0002 | |
2636
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
318 jsr DW$Write,u |
2180 | 319 |
320 * Await acknowledgement from server on receipt of sector | |
321 leax ,s | |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2211
diff
changeset
|
322 ldy #$0001 |
2636
4e5ff2c5b512
Optimized Term routine
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2624
diff
changeset
|
323 jsr DW$Read,u read ack byte from server |
2194 | 324 bcs WritEx0 |
325 bne WritEx0 | |
2180 | 326 puls d |
327 tsta | |
328 beq WritEx yep | |
329 tfr a,b | |
330 cmpb #E$CRC checksum error? | |
331 bne WritEx2 | |
332 ldu 7,s get U from stack | |
333 dec retries,u decrement retries | |
334 beq WritEx1 exit with error if no more | |
335 lda #OP_REWRIT else resend | |
336 bra Write15 | |
2194 | 337 WritEx0 puls d |
2180 | 338 WritEx1 ldb #E$Write |
339 WritEx2 lda 9,s | |
340 ora #Carry | |
341 sta 9,s | |
342 WritEx leas 5,s | |
343 puls y,u | |
344 puls cc,pc | |
345 | |
346 use dwcheck.asm | |
347 | |
348 * SetStat | |
349 * | |
350 * Entry: | |
351 * R$B = function code | |
352 * Y = address of path descriptor | |
353 * U = address of device memory area | |
354 * | |
355 * Exit: | |
356 * CC = carry set on error | |
357 * B = error code | |
358 * | |
359 SetStat lda #OP_SETSTA | |
360 * Size optimization | |
361 fcb $8C skip next two bytes | |
362 | |
363 | |
364 * GetStat | |
365 * | |
366 * Entry: | |
367 * R$B = function code | |
368 * Y = address of path descriptor | |
369 * U = address of device memory area | |
370 * | |
371 * Exit: | |
372 * CC = carry set on error | |
373 * B = error code | |
374 * | |
375 GetStat | |
376 lda #OP_GETSTA | |
377 clrb clear Carry | |
378 pshs cc and push CC on stack | |
379 leas -3,s | |
380 sta ,s | |
381 lda PD.DRV,y get drive number | |
382 ldx PD.RGS,y | |
383 ldb R$B,x | |
384 std 1,s | |
385 leax ,s | |
386 ldy #$0003 | |
387 IFGT LEVEL-1 | |
2270
07b2433f0c65
moved dwdefs.d to defs/, major changes to drivers due to new globals arrangement.
boisy
parents:
2231
diff
changeset
|
388 ldu <D.DWSubAddr |
2180 | 389 ELSE |
2270
07b2433f0c65
moved dwdefs.d to defs/, major changes to drivers due to new globals arrangement.
boisy
parents:
2231
diff
changeset
|
390 ldu >D.DWSubAddr |
2180 | 391 ENDC |
392 jsr 6,u | |
393 leas 3,s | |
394 puls cc,pc | |
395 | |
396 emod | |
397 eom equ * | |
398 end |