Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/rbdw3.asm @ 2231:27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
author | boisy |
---|---|
date | Sun, 12 Apr 2009 18:48:24 +0000 |
parents | 0d9a3b9b5886 |
children | 07b2433f0c65 |
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. | |
2180 | 27 |
28 nam rbdw3 | |
29 ttl DriveWire 3 driver | |
30 | |
31 NUMRETRIES equ 8 | |
32 | |
33 ifp1 | |
34 use defsfile | |
35 use dwdefs.d | |
36 endc | |
37 | |
38 NumDrvs set 4 | |
39 | |
40 tylg set Drivr+Objct | |
41 atrv set ReEnt+rev | |
42 rev set $01 | |
2194 | 43 edition set 3 |
2180 | 44 |
45 mod eom,name,tylg,atrv,start,size | |
46 | |
47 rmb DRVBEG+(DRVMEM*NumDrvs) | |
48 driveno rmb 1 | |
49 retries rmb 1 | |
50 size equ . | |
51 | |
52 fcb DIR.+SHARE.+PEXEC.+PREAD.+PWRIT.+EXEC.+UPDAT. | |
53 | |
54 name fcs /rbdw3/ | |
55 fcb edition | |
56 | |
57 start bra Init | |
58 nop | |
59 bra Read | |
60 nop | |
61 lbra Write | |
62 lbra GetStat | |
63 lbra SetStat | |
64 | |
65 * Term | |
66 * | |
67 * Entry: | |
68 * U = address of device memory area | |
69 * | |
70 * Exit: | |
71 * CC = carry set on error | |
72 * B = error code | |
73 * | |
74 Term | |
75 * Send OP_TERM to the server | |
76 clrb clear Carry | |
77 pshs a,cc then push CC on stack | |
78 lda #OP_TERM | |
79 leax 1,s | |
80 sta ,x | |
81 ldy #$0001 | |
82 IFGT LEVEL-1 | |
83 ldu <D.DWSUB | |
84 ELSE | |
85 ldu >D.DWSUB | |
86 ENDC | |
87 jsr 6,u | |
88 puls a,cc,pc | |
89 | |
90 * Init | |
91 * | |
92 * Entry: | |
93 * Y = address of device descriptor | |
94 * U = address of device memory area | |
95 * | |
96 * Exit: | |
97 * CC = carry set on error | |
98 * B = error code | |
99 * | |
100 Init | |
2210
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
101 IFGT Level-1 |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
102 * 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
|
103 ldx <D.Proc |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
104 pshs a,x |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
105 ldx <D.SysPrc |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
106 stx <D.Proc |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
107 ELSE |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
108 pshs a |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
109 ENDC |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
110 |
2180 | 111 ldb #NumDrvs |
112 stb V.NDRV,u | |
113 leax DRVBEG,u | |
114 lda #$FF | |
115 Init2 sta DD.TOT,x invalidate drive tables | |
116 sta DD.TOT+1,x | |
117 sta DD.TOT+2,x | |
118 leax DRVMEM,x | |
119 decb | |
120 bne Init2 | |
121 | |
122 * Link to subroutine module | |
123 clra | |
124 leax name+2,pcr | |
125 os9 F$Link | |
2210
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
126 bcs InitEx |
2180 | 127 tfr y,u |
128 IFGT LEVEL-1 | |
129 stu <D.DWSUB | |
130 ELSE | |
131 stu >D.DWSUB | |
132 ENDC | |
133 * Initialize the low level device | |
134 jsr ,u | |
135 lda #OP_INIT | |
136 leax ,s | |
137 ldy #$0001 | |
138 jsr 6,u | |
139 clrb | |
2210
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
140 |
2211 | 141 InitEx |
2210
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
142 IFGT Level-1 |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
143 puls a,x |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
144 stx <D.Proc |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
145 rts |
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
146 ELSE |
2180 | 147 puls a,pc |
2210
7ee1bed662f2
Fixed driver to copy D.SysPrc in Level 2 to D.Proc before link
boisy
parents:
2195
diff
changeset
|
148 ENDC |
2180 | 149 |
150 * Read | |
151 * | |
152 * Entry: | |
153 * B = MSB of LSN | |
154 * X = LSB of LSN | |
155 * Y = address of path descriptor | |
156 * U = address of device memory area | |
157 * | |
158 * Exit: | |
159 * CC = carry set on error | |
160 * B = error code | |
161 * | |
162 Read | |
163 lda #NUMRETRIES | |
164 sta retries,u | |
165 cmpx #$0000 LSN 0? | |
166 bne ReadSect branch if not | |
167 tstb LSN 0? | |
168 bne ReadSect branch if not | |
169 * At this point we're reading LSN0 | |
170 bsr ReadSect read the sector | |
171 bcs CpyLSNEx if error, exit | |
172 leax DRVBEG,u point to start of drive table | |
173 ldb <PD.DRV,y get drive number | |
174 NextDrv beq CopyLSN0 branch if terminal count | |
175 leax <DRVMEM,x else move to next drive table entry | |
176 decb decrement counter | |
177 bra NextDrv and continue | |
178 CopyLSN0 ldb #DD.SIZ get size to copy | |
179 ldy PD.BUF,y point to buffer | |
180 CpyLSNLp lda ,y+ get byte from buffer | |
181 sta ,x+ and save in drive table | |
182 decb | |
183 bne CpyLSNLp | |
184 CpyLSNEx rts | |
185 | |
186 | |
187 ReadSect pshs cc | |
188 pshs u,y,x,b,a,cc then push CC and others on stack | |
189 * Send out op code and 3 byte LSN | |
190 lda PD.DRV,y get drive number | |
191 cmpa #NumDrvs | |
192 blo Read1 | |
193 ldb #E$Unit | |
194 bra ReadEr2 | |
195 Read1 sta driveno,u | |
196 lda #OP_READEX load A with READ opcode | |
197 | |
198 Read2 | |
199 ldb driveno,u | |
200 leax ,s | |
201 std ,x | |
202 ldy #5 | |
203 IFGT LEVEL-1 | |
204 ldu <D.DWSUB | |
205 ELSE | |
206 ldu >D.DWSUB | |
207 ENDC | |
208 orcc #IntMasks | |
209 jsr 6,u | |
210 | |
211 * Get 256 bytes of sector data | |
212 ldx 5,s | |
213 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
|
214 ldy #$0100 |
2180 | 215 jsr 3,u |
216 bcs ReadEr1 | |
217 bne ReadEr1 | |
218 pshs y | |
219 leax ,s | |
220 ldy #$0002 | |
221 jsr 6,u write checksum to server | |
222 | |
223 * Get error code byte | |
224 leax ,s | |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2211
diff
changeset
|
225 ldy #$0001 |
2180 | 226 jsr 3,u |
2194 | 227 bcs ReadEr0 branch if we timed out |
228 bne ReadEr0 | |
2180 | 229 puls d |
230 tfr a,b transfer byte to B (in case of error) | |
231 tstb is it zero? | |
232 beq ReadEx if not, exit with error | |
233 cmpb #E$CRC | |
234 bne ReadEr2 | |
235 ldu 7,s get U from stack | |
236 dec retries,u decrement retries | |
237 beq ReadEr1 | |
238 | |
239 lda #OP_REREADEX reread opcode | |
240 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
|
241 ReadEr0 puls d |
2180 | 242 ReadEr1 ldb #E$Read read error |
243 ReadEr2 lda 9,s | |
244 ora #Carry | |
245 sta 9,s | |
246 ReadEx leas 5,s | |
247 puls y,u | |
248 puls cc,pc | |
249 | |
250 * Write | |
251 * | |
252 * Entry: | |
253 * B = MSB of LSN | |
254 * X = LSB of LSN | |
255 * Y = address of path descriptor | |
256 * U = address of device memory area | |
257 * | |
258 * Exit: | |
259 * CC = carry set on error | |
260 * B = error code | |
261 * | |
262 Write lda #NUMRETRIES | |
263 sta retries,u | |
264 pshs cc | |
265 pshs u,y,x,b,a,cc | |
266 * Send out op code and 3 byte LSN | |
267 lda PD.DRV,y | |
268 cmpa #NumDrvs | |
269 blo Write1 | |
270 comb set Carry | |
271 ldb #E$Unit | |
272 bra WritEx | |
273 Write1 sta driveno,u | |
274 lda #OP_WRITE | |
275 Write15 | |
276 ldb driveno,u | |
277 leax ,s | |
278 std ,x | |
279 ldy #$0005 | |
280 IFGT LEVEL-1 | |
281 ldu <D.DWSUB | |
282 ELSE | |
283 ldu >D.DWSUB | |
284 ENDC | |
285 orcc #IntMasks | |
286 jsr 6,u | |
287 | |
288 * Compute checksum on sector we just sent and send checksum to server | |
289 ldy 5,s get Y from stack | |
290 ldx PD.BUF,y point to buffer | |
291 ldy #256 | |
292 jsr 6,u | |
293 leax -256,x | |
294 bsr DoCSum | |
295 pshs d | |
296 leax ,s | |
297 ldy #$0002 | |
298 jsr 6,u | |
299 | |
300 * Await acknowledgement from server on receipt of sector | |
301 leax ,s | |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2211
diff
changeset
|
302 ldy #$0001 |
2180 | 303 jsr 3,u read ack byte from server |
2194 | 304 bcs WritEx0 |
305 bne WritEx0 | |
2180 | 306 puls d |
307 tsta | |
308 beq WritEx yep | |
309 tfr a,b | |
310 cmpb #E$CRC checksum error? | |
311 bne WritEx2 | |
312 ldu 7,s get U from stack | |
313 dec retries,u decrement retries | |
314 beq WritEx1 exit with error if no more | |
315 lda #OP_REWRIT else resend | |
316 bra Write15 | |
2194 | 317 WritEx0 puls d |
2180 | 318 WritEx1 ldb #E$Write |
319 WritEx2 lda 9,s | |
320 ora #Carry | |
321 sta 9,s | |
322 WritEx leas 5,s | |
323 puls y,u | |
324 puls cc,pc | |
325 | |
326 use dwcheck.asm | |
327 | |
328 * SetStat | |
329 * | |
330 * Entry: | |
331 * R$B = function code | |
332 * Y = address of path descriptor | |
333 * U = address of device memory area | |
334 * | |
335 * Exit: | |
336 * CC = carry set on error | |
337 * B = error code | |
338 * | |
339 SetStat lda #OP_SETSTA | |
340 * Size optimization | |
341 fcb $8C skip next two bytes | |
342 | |
343 | |
344 * GetStat | |
345 * | |
346 * Entry: | |
347 * R$B = function code | |
348 * Y = address of path descriptor | |
349 * U = address of device memory area | |
350 * | |
351 * Exit: | |
352 * CC = carry set on error | |
353 * B = error code | |
354 * | |
355 GetStat | |
356 lda #OP_GETSTA | |
357 clrb clear Carry | |
358 pshs cc and push CC on stack | |
359 leas -3,s | |
360 sta ,s | |
361 lda PD.DRV,y get drive number | |
362 ldx PD.RGS,y | |
363 ldb R$B,x | |
364 std 1,s | |
365 leax ,s | |
366 ldy #$0003 | |
367 IFGT LEVEL-1 | |
368 ldu <D.DWSUB | |
369 ELSE | |
370 ldu >D.DWSUB | |
371 ENDC | |
372 jsr 6,u | |
373 leas 3,s | |
374 puls cc,pc | |
375 | |
376 emod | |
377 eom equ * | |
378 end |