annotate level1/modules/llide.asm @ 2939:011a5f26e9da

rb1773: Fix comments about 135 TPI versus 48 or 96 Some comments were wrong about 48/96/135 TPI. Some new comments have been added. There are no code changes in this commit, the assembled binary should be identical.
author Robert Gault <robert.gault@att.net>
date Sat, 25 Jan 2014 23:19:38 +0100
parents 17d43fd29ee2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2590
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1 *******************************************************************
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
2 * llide - Low-level IDE driver
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
3 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
4 * $Id$
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
5 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
6 * This low level driver works with both ATA and ATAPI devices.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
7 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
8 * The type of device (ATA or ATAPI) is automatically detected
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
9 * by the 'IOSetup' routine. Additionally, an ATA device is
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
10 * further detected as either an LBA or CHS device.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
11 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
12 * Since only two physical drives are allowed (master/slave),
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
13 * there is a two entry "per drive static storage" that indicates
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
14 * if a drive has been initialized, its type (ATAPI or ATA, LBA or
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
15 * CHS), and if ATA, its geometry.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
16 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
17 * Edt/Rev YYYY/MM/DD Modified by
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
18 * Comment
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
19 * ------------------------------------------------------------------
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
20 * 1 2004/04/08 Boisy G. Pitre
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
21 * Created.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
22 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
23 * 2 2005/07/23 Christopher R. Hawks
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
24 * Fixes for persnickity ATAPI CDROMs.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
25 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
26 * 3 2005/08/21 Christopher R. Hawks
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
27 * More fixes.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
28 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
29 * 4 2005/12/13 Boisy G. Pitre
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
30 * Moved SS.VarSect code into RBSuper for performance
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
31
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
32 NAM llide
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
33 TTL Low-level IDE driver
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
34
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
35 IFP1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
36 USE defsfile
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
37 USE rbsuper.d
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
38 USE ide.d
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
39 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
40
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
41 tylg SET Sbrtn+Objct
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
42 atrv SET ReEnt+rev
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
43 rev SET 4
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
44
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
45
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
46 RW12 SET 0 Use READ12/WRITE12 ATAPI commands (1 = yes)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
47 WAITTIME SET 10 BUSY wait time (in approximate seconds)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
48
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
49 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
50 * Status Register Flip/Mask Values
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
51 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
52 NBUSYDRDY EQU (BusyBit|DrdyBit)*256+(DrdyBit)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
53 NBUSY EQU (BusyBit)*256+$00
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
54 NBUSYDRQ EQU (BusyBit|DrqBit)*256+(DrqBit)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
55 NBUSYNDRQ EQU (BusyBit|DrqBit)*256+$00
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
56
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
57 MOD eom,name,tylg,atrv,start,0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
58
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
59 IFNE RW12
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
60 READCODE EQU A$READ2
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
61 WRITCODE EQU A$WRITE2
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
62 ELSE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
63 READCODE EQU A$READ
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
64 WRITCODE EQU A$WRITE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
65 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
66
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
67 NumRetries EQU 8
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
68
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
69 * Low-level driver static memory area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
70 ORG V.LLMem
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
71 * Master static storage
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
72 V.Master RMB 1 status byte (ATAPI or ATA (CHS or LBA))
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
73 RMB 2 Cylinders (CHS) or Bits 31-16 of LBA
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
74 RMB 1 Sides (CHS) or Bits 15-8 of LBA
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
75 RMB 2 Sectors (CHS) or Bits 7-0 of LBA
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
76 * Slave drive static storage
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
77 V.Slave RMB 1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
78 RMB 2
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
79 RMB 1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
80 RMB 2
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
81 * ATAPI Command Packet
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
82 V.ATAPICmd RMB 18
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
83 V.SnsData EQU V.ATAPICmd Sense Data is shared with ATAPI command block
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
84 * The following values are for device 0 and 1 respectively:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
85 * Bit 0 = device inited (0 = false, 1 = true)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
86 * Bit 1 = device type (0 = ATA, 1 = ATAPI)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
87 * Bit 2 = device mode (0 = CHS, 1 = LBA)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
88 V.CurStat RMB 1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
89 V.Retries RMB 1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
90 V.WhichDv RMB 1 contains devhead selection (made by IOSetup)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
91 V.PhySct RMB 3 local copy of physical sector passed (V.PhySct)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
92 V.SctCnt RMB 1 local copy of physical sector passed (V.SectCnt)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
93 V.Sectors RMB 1 number of sectors (harvested directly from drive query)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
94 V.CurDTbl RMB 2
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
95 V.ATAVct RMB 2
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
96
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
97
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
98 name FCS /llide/
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
99
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
100 start bra ll_init
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
101 nop
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
102 lbra ll_read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
103 lbra ll_write
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
104 lbra ll_getstat
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
105 lbra ll_setstat
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
106
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
107 * ll_init - Low level init routine
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
108 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
109 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
110 * Y = address of device descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
111 * U = address of low level device memory area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
112 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
113 * Exit:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
114 * CC = carry set on error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
115 * B = error code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
116 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
117 * Note: This routine is called ONCE: for the first device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
118 * IT IS NOT CALLED PER DEVICE!
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
119 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
120 ll_init
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
121 * clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
122 * rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
123
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
124
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
125 * ll_term - Low level term routine
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
126 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
127 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
128 * Y = address of device descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
129 * U = address of device memory area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
130 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
131 * Exit:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
132 * CC = carry set on error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
133 * B = error code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
134 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
135 * Note: This routine is called ONCE: for the last device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
136 * IT IS NOT CALLED PER DEVICE!
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
137 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
138 ll_term
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
139 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
140 rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
141
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
142
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
143 * Entry: Y = address of per-drive static storage
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
144 ATADSize
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
145 pshs y,x,b make room for space on stack (and save id byte)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
146 * Determine if we are dealing with LBA or CHS
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
147 bitb #$04 LBA?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
148 bne lba@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
149 * Here we pull CHS values
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
150 chs@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
151 ldd 1,y get cylinders
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
152 std 1,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
153 lda 3,y get sides
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
154 sta ,s save sides on stack (B)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
155 ldd 4,y get sectors
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
156 std 3,s save sectors/track on stack (Y)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
157 bra m@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
158 * Here we pull LBA values at words 60-61
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
159 lba@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
160 clr ,s clear flag indicating LBA mdoe (B)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
161 ldd 3,y get bits 15-0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
162 std 3,s save bits 15-0 on stack (Y)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
163 ldd 1,y get bits 31-16
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
164 std 1,s save bits 31-16 (X)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
165 m@ lda #$02 512 bytes/sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
166 ex@ puls b,x,y,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
167
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
168
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
169 * SSDSize - Get a disk medium's size
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
170 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
171 * GetStat Call SS.DSize:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
172 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
173 * Entry: B = SS.DSize
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
174 * Exit: Carry = 1; error with code in B
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
175 * Carry = 0:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
176 * IF B = 0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
177 * A = Sector Size (1 = 256, 2 = 512, 4 = 1024, 8 = 2048)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
178 * X = Number of Sectors (bits 31-16)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
179 * Y = Number of Sectors (Bits 15-0)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
180 * IF B != 0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
181 * A = Sector Size (1 = 256, 2 = 512, 4 = 1024, 8 = 2048)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
182 * X = Number of Logical Cylinders
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
183 * B = Number of Logical Sides
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
184 * Y = Number of Logical Sectors/Track
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
185 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
186 SSDSize pshs u,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
187 bsr DSize
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
188 bcs ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
189 ldu ,s get path desc in U
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
190 ldu PD.RGS,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
191 std R$D,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
192 stx R$X,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
193 sty R$Y,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
194 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
195 ex@ puls y,u,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
196
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
197 DSize lbsr IOSetup
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
198 bcs ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
199 * Determine if this device is ATAPI or ATA
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
200 bitb #$02 ATAPI?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
201 lbeq ATADSize no, it's ATA
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
202 * Note - for ATAPI version of SS.DSize, we use the obsolete
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
203 * READ CAPACITY call because it works on CD-ROMs, as opposed to
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
204 * READ FORMAT CAPACITIES.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
205 ATAPIDSize
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
206 lbsr ATAPIPreSend prepare packet
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
207 * Populate packet buffer with STOP code and Eject
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
208 * ldd #$230C ATAPI READ FORMAT CAPACITIES Code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
209 lda #$25 ATAPI READ CAPACITY Code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
210 sta V.ATAPICmd,u write it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
211 * stb V.ATAPICmd+8,u and allocation length
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
212 * Send to data port
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
213 bsr ATAPISend send command
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
214 bcs ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
215 * Read 8 bytes of format capacity data
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
216 * ldb #6
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
217 ldb #4
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
218 pshs b
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
219 leay V.SnsData,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
220 read@ lda DataReg,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
221 ldb Latch,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
222 std ,y++
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
223 dec ,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
224 bne read@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
225 puls b
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
226 ldx V.SnsData+0,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
227 ldy V.SnsData+2,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
228 leay 1,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
229 bcc b@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
230 leax 1,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
231 b@ lda V.SnsData+6,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
232 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
233 ex@ rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
234
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
235 * ldy PD.RGS,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
236 * ldd V.SnsData+0,u get bits 31-16
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
237 * std R$X,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
238 * ldd V.SnsData+2,u get bits 15-0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
239 * addd #$0001 add 1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
240 * std R$Y,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
241 * bcc b@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
242 * ldd R$X,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
243 * addd #$0001
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
244 * std R$X,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
245 *b@ lda V.SnsData+6,u get bits 15-8 of block size
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
246 * sta R$A,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
247 * clr R$B,y signal that this is LBA mode
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
248 * clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
249 *ex@ rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
250
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
251
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
252 * ll_getstat - Low level GetStat routine
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
253 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
254 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
255 * Y = address of path descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
256 * U = address of device memory area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
257 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
258 * Exit:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
259 * CC = carry set on error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
260 * B = error code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
261 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
262 ll_getstat
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
263 ldx PD.RGS,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
264 lda R$B,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
265 cmpa #SS.DSize
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
266 beq SSDSize
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
267 ldb #E$UnkSvc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
268 coma
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
269 ex1 rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
270
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
271
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
272 * StopUnit - Park a drive
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
273 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
274 * ATA Devices: This is a No-Op.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
275 * ATAPI Devices: A STOP UNIT command is issued to the device.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
276 * (ejects media on ATAPI removable devices)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
277 StopUnit lbsr IOSetup
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
278 bcs ex1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
279 * Determine if this device is ATAPI or ATA
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
280 bitb #$02 ATAPI?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
281 beq ex1 no, ignore...
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
282 lbsr ATAPIPreSend prepare packet
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
283 * Populate packet buffer with STOP code and Eject
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
284 ok@ ldd #A$STOP*256+$02 ATAPI STOP Code and Eject byte
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
285 sta V.ATAPICmd,u write it and RSV to zero
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
286 stb V.ATAPICmd+4,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
287 * Send to data port
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
288 bra ATAPISend send command
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
289
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
290
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
291 * ll_setstat - Low level SetStat routine
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
292 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
293 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
294 * Y = address of path descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
295 * U = address of device memory area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
296 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
297 * Exit:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
298 * CC = carry set on error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
299 * B = error code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
300 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
301 ll_setstat
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
302 ldx PD.RGS,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
303 lda R$B,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
304 cmpa #SS.SQD
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
305 beq StopUnit
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
306 IFNE 0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
307 cmpa #SS.DCmd
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
308 bne n@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
309 pshs x save pointer to caller registers
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
310 bsr DCmd call DCmd
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
311 puls x get pointer to caller registers
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
312 sta R$A,x save status byte in A
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
313 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
314 n@ clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
315 ssex rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
316
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
317
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
318 IFNE 0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
319 BadType comb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
320 ldb #E$BTyp
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
321 rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
322
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
323 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
324 * X = caller regs
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
325 * Y = path descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
326 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
327 * R$B = SS.DCmd
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
328 * R$X = Transfer buffer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
329 * R$Y = ATAPI command packet
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
330 DCmd
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
331 pshs y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
332 os9 F$ID get the user ID of the calling process
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
333 cmpy #$0000 is it 0 (superuser)?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
334 puls y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
335 bne noperms no, don't allow the call
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
336 lbsr IOSetup
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
337 ** SS.DCmd only works with ATAPI devices.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
338 bitb #$02 ATAPI?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
339 beq BadType branch if not
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
340 ldy R$X,x get caller's transfer buffer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
341 sty V.UTxBuf,u save off in mem for later
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
342 ldx R$Y,x get ptr to caller's command buffer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
343 IFGT Level-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
344 ldy D.Proc get current process ptr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
345 lda P$Task,y get task # for current process
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
346 ldb D.SysTsk get system task #
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
347 ldy #ATAPIPkLn max size of ATAPI command
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
348 pshs u save on stack
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
349 leau V.ATAPICmd,u point to ATAPI command buffer in our statics
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
350 os9 F$Move copy from caller to temporary task
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
351 puls u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
352 bcs ex error copying, exit
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
353 ELSE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
354 ldb #ATAPIPkLn
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
355 leay V.ATAPICmd,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
356 cl@ lda ,x+
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
357 sta ,y+
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
358 decb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
359 bne cl@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
360 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
361 ldy V.PORT-UOFFSET,u get hw address (because we overwrite Y earlier)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
362 * inc V.OS9Err,u we want real errors returned
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
363 inc V.CchDirty,u and make cache dirty
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
364 * leax retry@,pcr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
365 * stx V.RetryVct,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
366 retry@ lbsr ATAPISend
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
367 bcs ex
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
368 IFGT Level-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
369 ldx D.Proc get current process ptr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
370 ldb P$Task,x get task # for current process
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
371 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
372 ldx V.UTxBuf,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
373
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
374 msgloop@ lbsr Wait4REQ wait for REQ to be asserted
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
375 bita #CMD command phase?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
376 lbne PostXfr yes, return
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
377 io@ bita #INOUT data coming in or going out?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
378 bne in@ branch if coming in...
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
379 IFGT Level-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
380 os9 F$LDABX
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
381 leax 1,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
382 ELSE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
383 lda ,x+
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
384 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
385 sta SCSIDATA,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
386 bra msgloop@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
387 in@ lda SCSIDATA,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
388 IFGT Level-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
389 os9 F$STABX
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
390 leax 1,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
391 ELSE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
392 sta ,x+
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
393 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
394 bra msgloop@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
395 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
396
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
397 * ATAPISend - Sends the command packet to the device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
398 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
399 * Entry: X = HW address
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
400 * V.WhichDv = DevHead device selection value
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
401 * Exit: Carry = 1; error code in B
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
402 * Carry = 0; command successfully sent
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
403 ATAPISend
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
404 * First, select the device and wait for /BUSY
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
405 lda V.WhichDv,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
406 sta DevHead,x select device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
407 * ATAPI says we wait for !BUSY
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
408 ldd #NBUSYDRDY wait for NBUSY and DEVREADY too - CRH
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
409 lbsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
410 bcs timeout branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
411 lda #NumRetries get retry count
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
412 sta V.Retries,u and save
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
413 retry@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
414 clr Features,x clear feature byte
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
415 clr SectCnt,x clear TAG field
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
416 ldd #$FFFF maximum read in PIO mode
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
417 std CylLow,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
418 lda #$A0 ATAPI PACKET CODE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
419 sta Command,x write it to device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
420 * Check for error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
421 ldd #NBUSYDRQ /BUSY and DRQ
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
422 lbsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
423 bcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
424 * Send to data port
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
425 lda #6 packet size / 2
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
426 pshs a,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
427 leay V.ATAPICmd,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
428 l@ ldd ,y++
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
429 stb Latch,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
430 sta DataReg,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
431 dec ,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
432 bne l@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
433 puls a,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
434 * Added by CRH - Some drives require that we wait for much more than
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
435 * 400ns. Hence this code forces a slow-down and checks the status
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
436 * to see if things are ok.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
437 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
438 slow@ decb CRH wait for much more than 400ns
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
439 bne slow@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
440 lda Status,x CRH Sometimes error on first try
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
441 lsra
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
442 bcc ok@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
443 dec V.Retries,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
444 bne retry@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
445 * As per ATA/ATAPI-6 spec (T13/1410D Revision 3A), page 161, we wait for /BUSY
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
446 * and DRQ after sending a command
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
447 * That IS NOT the case when sending START/STOP unit commands, so we don't check
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
448 * for DRQ.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
449 ok@ ldd #NBUSY /BUSY
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
450 lbsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
451 bcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
452 lda #A$STOP CRH see above
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
453 cmpa V.ATAPICmd,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
454 beq nodata@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
455 ldd #NBUSYDRQ /BUSY and DRQ
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
456 lbsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
457 bcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
458 nodata@ lsra shift in CHECK CONDITION bit
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
459 bcc ex@ branch if ok
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
460 * Note: if the device returns error, DRQ won't be set...
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
461 err@ lbsr HandleSenseKey go check sense key
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
462 bcs ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
463 ret@ dec V.Retries,u else retry until terminal
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
464 bne retry@ continue retrying
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
465 timeout comb set carry
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
466 ldb #E$DevBsy+4 SHOULD BE AN E$TimeOut ERROR!
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
467 ex@ rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
468
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
469 * Prepare the ATAPI Packet
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
470 ATAPIPreSend
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
471 pshs x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
472 * Clear 12 byte packet.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
473 leax V.ATAPICmd,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
474 ldb #12
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
475 c@ clr ,x+
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
476 decb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
477 bne c@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
478 ex@ puls x,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
479
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
480
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
481 ** ATAPI REQUEST SENSE Command
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
482 ** Should only be called for ATAPI devices
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
483 *ReqSense
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
484 * bsr ATAPIPreSend prepare packet
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
485 ** Populate packet buffer with REQUEST SENSE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
486 * ldd #$0312 ATAPI REQUEST SENSE Code and allocation length byte
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
487 * sta V.ATAPICmd,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
488 * stb V.ATAPICmd+4,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
489 ** Send to data port
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
490 * lbsr ATAPISend send command
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
491 * lda Status,x get status code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
492 * lsra shift in CHECK CONDITION bit
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
493 * bcs ex@ branch if ok
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
494 ** Read 18 bytes of sense data
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
495 * ldb #$12
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
496 * pshs y,b
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
497 * leay V.SnsData,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
498 *read@ lda DataReg,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
499 * ldb Latch,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
500 * std ,y++
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
501 * dec ,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
502 * bne read@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
503 * puls b,y,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
504 *ex@ rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
505
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
506
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
507 * IOSetup - Sets up the device for I/O
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
508 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
509 * The device is selected (master or slave), then the device is
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
510 * checked for previous initialization.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
511 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
512 * If the device has not been initialized, it is queried for its
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
513 * mode (ATAPI/ATA, LBA or CHS) and size. That information is
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
514 * saved in the driver's static storage for later use by other
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
515 * routines.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
516 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
517 * Entry: Y = path descriptor pointer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
518 * U = static memory pointer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
519 * Exit: B = status byte for device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
520 * X = HW address
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
521 * Y = pointer to current device table
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
522 IOSetup ldx V.PORT-UOFFSET,u get hw address
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
523 lda PD.DNS,y get device ID bit
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
524 lsra shift device ID into carry
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
525 bcs slave@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
526 lda #%10100000 master byte
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
527 leay V.Master,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
528 bra t@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
529 slave@ lda #%10110000 slave byte
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
530 leay V.Slave,u else point to slave status byte
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
531 t@ sty V.CurDTbl,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
532 sta V.WhichDv,u save for later
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
533 * Select the device -- on power-up, the status register is usually 0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
534 sta DevHead,x select device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
535 * According to page 320 of the ATA/ATAPI-6 document, we must wait for BOTH
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
536 * BUSY and DRQ to be clear before proceeding. (HI2: Device_Select State)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
537 ldd #NBUSYNDRQ /BUSY and /DRQ
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
538 lbsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
539 lbcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
540 * Determine if this device has already been initialized
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
541 tst ,y test device's stat byte
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
542 lbne initdone if not zero, init already done
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
543 * Here we must initialize the device by IDENTIFYING it.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
544 * First, try sending the ATA IDENTIFY DRIVE code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
545 lda #$EC ATA identify command
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
546 sta Command,x write it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
547 ldd #NBUSY /BUSY
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
548 lbsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
549 lbcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
550 * Check if there's an error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
551 lsra shift error bit into carry
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
552 bcc ATAIdent if no error, then probably ATA
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
553 * If here, we got an error sending $EC, so try ATAPI's $A1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
554 lda #$A1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
555 sta Command,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
556 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
557 slow@ decb CRH wait for much more than 400ns
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
558 bne slow@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
559 ldd #NBUSY
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
560 lbsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
561 bcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
562 lsra shift error bit into carry
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
563 bcs timeout if not error, we're ok
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
564 ldd #NBUSYDRQ
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
565 lbsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
566 lbcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
567 * Here, we have identified an ATAPI device.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
568 ATAPIIdent
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
569 ldb #$03 ATAPI
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
570 stb ,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
571 * We flush the ATAPI data but don't reference it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
572 dread@ ldb DataReg,x CRH flush ALL bytes
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
573 * ldb Latch,x but save time by not reading latch
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
574 lda Status,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
575 anda #8
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
576 bne dread@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
577 bra initdone
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
578 * ATAIdent - process an ATA device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
579 * This routine is called by IOSetup when it deduces that the device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
580 * being queried is an ATA device. This device is called ONCE -- the
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
581 * first time the device is accessed.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
582 * This routine will set up our per-drive static storage to indicate that
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
583 * it is an ATA device. It will also determine if it is an LBA or CHS mode
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
584 * device, and save the appropriate CHS or LBA sector values.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
585 ATAIdent
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
586 ldd #NBUSYDRDY /BUSY and DRDY
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
587 lbsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
588 bcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
589 * Harvest C/H/S and LBA sector values.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
590 ldb DataReg,x ignore bytes 0-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
591 ldb DataReg,x bytes 2-3 = no. of cylinders
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
592 lda Latch,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
593 std 1,y save cylinders in our private static area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
594 ldb DataReg,x ignore bytes 4-5
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
595 ldb DataReg,x bytes 6-7 = no. of heads
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
596 lda Latch,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
597 stb 3,y save sides on stack (B)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
598 ldb DataReg,x ignore bytes 8-9
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
599 ldb DataReg,x ignore bytes 10-11
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
600 ldb DataReg,x bytes 12-13 = no. of sectors/track
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
601 lda Latch,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
602 std 4,y save sectors/track on stack (Y)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
603 * Throw away the next 42 (7-48) words
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
604 ldb #43
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
605 l@ tst DataReg,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
606 lda Latch,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
607 decb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
608 bne l@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
609 * A holds byte with LBA bit
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
610 incb B was 0, now 1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
611 anda #%00000010 LBA allowed on this drive?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
612 beq nope@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
613 orb #$04 set LBA mode
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
614 stb ,y save updated status byte
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
615 * Since we're LBA mode, get the number of LBA sectors in words 60-61
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
616 ldb #10 skip to the LBA sectors (words 60-61)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
617 more@ tst DataReg,x simply read the data register like this...
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
618 decb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
619 bne more@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
620 ldb DataReg,x get word 60
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
621 lda Latch,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
622 std 3,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
623 ldb DataReg,x and 61
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
624 lda Latch,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
625 std 1,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
626 lda #256-61 how many words we have left
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
627 bra left@ go on.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
628 nope@ stb ,y save updated status byte
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
629 * Read remaining 256-50 words
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
630 lda #256-50
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
631 left@ ldb DataReg,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
632 deca
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
633 bne left@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
634 initdone ldb ,y get status byte of drive
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
635 clra clear carry
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
636 ex@ rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
637
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
638
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
639 * ATAPI Write Routine -- Independent of ATA Read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
640 ATAPIWrite
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
641 lbsr ATAPIPreSend prepare packet
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
642 * Populate packet buffer with WRITE code and sector information
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
643 again@ ldb V.PhySct,u get bits 23-16 of sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
644 stb V.ATAPICmd+3,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
645 ldd V.PhySct+1,u get bits 15-0 of sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
646 std V.ATAPICmd+4,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
647 ldd #WRITCODE*256+$01 ATAPI WRITE Code and transfer length
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
648 sta V.ATAPICmd,u write it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
649 IFNE RW12
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
650 stb V.ATAPICmd+9,u write to byte 9
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
651 ELSE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
652 stb V.ATAPICmd+8,u write to byte 8
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
653 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
654 * Send to data port
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
655 lbsr ATAPISend send command
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
656 bcs ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
657 * Shift data from device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
658 o@ pshs d
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
659 lda V.Log2Phys,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
660 sta 1,s set up our logical sector counter
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
661 inc@ clr ,s set up our byte counter
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
662 wr@ ldd ,y++
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
663 stb Latch,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
664 sta DataReg,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
665 inc ,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
666 bpl wr@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
667 dec 1,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
668 bne inc@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
669 puls d
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
670 * Increment physical sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
671 inc V.PhySct+2,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
672 bcc go@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
673 inc V.PhySct+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
674 bcc go@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
675 inc V.PhySct,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
676 go@ dec V.SctCnt,u decrement # of hw sectors to read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
677 bne again@ if not zero, do it again
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
678 ldd #NBUSY /BUSY
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
679 lbsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
680 bcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
681 lsra error bit set?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
682 bcc ex@ yep...
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
683 bsr HandleSenseKey
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
684 ex@ puls x,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
685
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
686
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
687
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
688 * ATAPI Read Routine -- Independent of ATA Read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
689 ATAPIRead
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
690 ldy V.CchPSpot,u get pointer to spot in cache to put sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
691 lbsr ATAPIPreSend do command packet setup stuff
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
692 * Populate packet buffer with READ code and sector information
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
693 again@ ldb V.PhySct,u get,u bits 23-16 of sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
694 stb V.ATAPICmd+3,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
695 ldd V.PhySct+1,u get bits 15-0 of sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
696 std V.ATAPICmd+4,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
697 ldd #READCODE*256+$01 ATAPI Read Code and transfer length
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
698 sta V.ATAPICmd,u write it and RSV to zero
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
699 IFNE RW12
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
700 stb V.ATAPICmd+9,u write to byte 9
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
701 ELSE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
702 stb V.ATAPICmd+8,u write to byte 8
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
703 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
704 * Send to data port
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
705 lbsr ATAPISend send command
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
706 bcs ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
707 * Shift data from device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
708 o@ pshs d
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
709 lda V.Log2Phys,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
710 sta 1,s set up our logical sector counter
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
711 inc@ clr ,s set up our byte counter
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
712 read@ lda DataReg,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
713 ldb Latch,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
714 std ,y++
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
715 inc ,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
716 bpl read@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
717 dec 1,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
718 bne inc@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
719 puls d
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
720 * Increment physical sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
721 inc V.PhySct+2,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
722 bcc go@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
723 inc V.PhySct+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
724 bcc go@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
725 inc V.PhySct,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
726 go@ dec V.SctCnt,u decrement # of hw sectors to read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
727 bne again@ if not zero, do it again
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
728 ldd #NBUSY /BUSY
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
729 lbsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
730 bcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
731 lsra error bit set?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
732 bcc ex@ nope...
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
733 bsr HandleSenseKey
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
734 ex@ puls x,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
735
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
736
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
737 * Handle ATAPI Sense Key
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
738 * If the resulting error in the look-up table is zero,
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
739 * we return with carry clear
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
740 * Returns: B = 0 (carry clear, no error)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
741 * B != 1 (carry set, error)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
742 HandleSenseKey
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
743 pshs x,a
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
744 ldb ErrorReg,x get error register value
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
745 lsrb shift sense key into place
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
746 lsrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
747 lsrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
748 lsrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
749 leax SenseMap,pcr point to Sense Key Map
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
750 clra clear carry
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
751 ldb b,x get appropriate error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
752 beq ok@ if error is zero, return ok
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
753 coma set carry
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
754 ok@ puls a,x,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
755
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
756 * ll_read - Low level read routine
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
757 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
758 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
759 * Registers:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
760 * Y = address of path descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
761 * U = address of device memory area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
762 * Static Variables of interest:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
763 * V.PhySct = starting physical sector to read from
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
764 * V.SectCnt = number of physical sectors to read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
765 * V.SectSize = physical sector size (0=256,1=512,2=1024,3=2048)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
766 * V.CchPSpot = address where physical sector(s) will go
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
767 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
768 * Exit:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
769 * All registers may be modified
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
770 * Static variables may NOT be modified
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
771 ll_read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
772 pshs x make some space on the stack
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
773 lbsr IOSetup initialize the device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
774 lbcs ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
775 * Copy V.PhySct and V.SectCnt to our local copy
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
776 * since we cannot modify them.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
777 lda V.PhysSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
778 ldy V.PhysSect+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
779 sta V.PhySct,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
780 sty V.PhySct+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
781 lda V.SectCnt,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
782 sta V.SctCnt,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
783 bitb #$02 ATAPI device?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
784 lbne ATAPIRead yes, go do it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
785 * ATA Read Routine
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
786 ATARead
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
787 * stb V.CurStat,u save status of current drive
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
788 bitb #$04 LBA drive?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
789 bne lba@ branch if so
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
790 leay DoCHS,pcr else point Y to CHS routine
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
791 bra skip@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
792 lba@ leay DoLBA,pcr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
793 skip@ sty V.ATAVct,u save pointer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
794 ldy V.CchPSpot,u get pointer to spot in cache to put sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
795 loop@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
796 ldd #NBUSY /BUSY
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
797 bsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
798 bcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
799 jsr [V.ATAVct,u] do proper ATA preparation
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
800 bcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
801 cont@ lda #$01
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
802 sta SectCnt,x store it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
803 lda #S$READ
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
804 sta Command,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
805 ldd #NBUSY /BUSY
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
806 bsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
807 bcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
808 lsra error bit set?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
809 bcc w@ branch if not
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
810 lbsr ATAError
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
811 bra ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
812 w@ ldd #NBUSYDRQ /BUSY and DRQ
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
813 bsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
814 bcs ex@ branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
815 lda V.Log2Phys,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
816 sta 1,s set up our logical sector counter
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
817 inc@ clr ,s set up our byte counter
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
818 read@ lda DataReg,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
819 ldb Latch,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
820 std ,y++
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
821 inc ,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
822 bpl read@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
823 dec 1,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
824 bne inc@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
825 * Increment physical sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
826 inc V.PhySct+2,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
827 bcc go@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
828 inc V.PhySct+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
829 bcc go@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
830 inc V.PhySct,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
831 go@ dec V.SctCnt,u decrement # of hw sectors to read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
832 bne loop@ if not zero, do it again
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
833 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
834 ex@ puls x,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
835
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
836
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
837 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
838 * Convert LSN to LBA values
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
839 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
840 * Entry: V.PhySct = bits 23-0 of LSN
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
841 * X = ptr to hardware
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
842 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
843 * Exit: CHS values placed directly in HW
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
844 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
845 DoLBA lda V.WhichDv,u get devhead value populated by IOSetup (CHS mode)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
846 ora #%01000000 OR in LBA bit
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
847 sta DevHead,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
848 ldd #NBUSYNDRQ /BUSY and /DRQ
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
849 bsr StatusWait
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
850 bcs ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
851 ldb V.PhySct,u get bits 23-16 of sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
852 stb CylHigh,x store it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
853 ldd V.PhySct+1,u get bits 15-0 of sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
854 stb SectNum,x store it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
855 sta CylLow,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
856 ex@ rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
857
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
858
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
859 * Wait for a set of conditions in the status register to be TRUE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
860 * This yields a delay of about 4 seconds.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
861 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
862 * Entry: X = HW address
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
863 * A = flip (if bit set, that bit is tested)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
864 * B = mask (result must match this byte)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
865 * Exit: A = status
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
866 StatusWait
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
867 pshs y,b,a
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
868 IFEQ Level-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
869 ldb #WAITTIME/2
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
870 ldy #$0000
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
871 ELSE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
872 ldb #WAITTIME
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
873 ldy #$0000
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
874 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
875 l@ lda Status,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
876 anda ,s apply flip
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
877 cmpa 1,s compare to mask
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
878 bne dec@ branch if not equal (not what we want)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
879 clrb clear carry
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
880 bra ok@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
881 dec@ leay -1,y count down
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
882 bne l@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
883 decb decrement bits 23-16
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
884 bpl l@ if >=0, keep going
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
885 err@ comb set carry
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
886 ldb #E$DevBsy
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
887 ok@ leas 2,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
888 lda Status,x get status again
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
889 puls y,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
890
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
891 * Wait for 1 tick (1/60 second)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
892 *Delay1Tk
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
893 * pshs x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
894 * IFGT Level-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
895 * ldx D.Proc get proc descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
896 * cmpx D.SysPrc system?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
897 * beq hw@ yep, system cannot sleep
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
898 * ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
899 * ldx D.AProcQ get active proc queue
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
900 * beq hw@ if empty, do hard wait
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
901 * ldx #1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
902 * os9 F$Sleep give up worst case: 1 tick (1/60 second)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
903 * puls x,pc return to caller
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
904 ** In case we can't sleep... do a hard 1/60 second delay
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
905 *hw@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
906 * IFEQ Level-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
907 * ldx #$E52E/2 (5) (4)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
908 * ELSE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
909 * ldx #$E52E (5) (4)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
910 * ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
911 *w@ leax -1,x (4+) (4+)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
912 * bne w@ (3) (3)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
913 * puls x,pc return to caller
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
914 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
915
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
916
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
917 * ll_write - Low level write routine
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
918 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
919 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
920 * Registers:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
921 * Y = address of path descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
922 * U = address of device memory area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
923 * Static Variables of interest:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
924 * V.PhySct = starting physical sector to write to
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
925 * V.SectCnt = number of physical sectors to write
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
926 * V.SectSize = physical sector size (0=256,1=512,2=1024,3=2048)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
927 * V.CchPSpot = address of data to write to device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
928 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
929 * Exit:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
930 * All registers may be modified
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
931 * Static variables may NOT be modified
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
932 ll_write
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
933 pshs x make some space on the stack
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
934 lbsr IOSetup initialize the device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
935 lbcs ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
936 * Copy V.PhySct to our local copy
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
937 lda V.PhysSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
938 ldy V.PhysSect+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
939 sta V.PhySct,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
940 sty V.PhySct+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
941 lda V.SectCnt,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
942 sta V.SctCnt,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
943 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
944 ldy V.CchPSpot,u get pointer to spot in cache where physical sector is
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
945 bitb #$02 ATAPI device?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
946 lbne ATAPIWrite yes, go do it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
947 * ATA Write Routine
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
948 ATAWrite stb V.CurStat,u save status of current drive
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
949 loop@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
950 ldd #NBUSY /BUSY
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
951 bsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
952 bcs ex@ branch if ok
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
953 * Check for LBA mode
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
954 ldb V.CurStat,u get status of current drive
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
955 bitb #$04 LBA bit set?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
956 bne lba@ branch if so
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
957 * Here, we use CHS
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
958 bsr DoCHS
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
959 bcs ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
960 bra cont@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
961 lba@ lbsr DoLBA
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
962 cont@ lda #$01
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
963 sta SectCnt,x store it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
964 lda #S$WRITE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
965 sta Command,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
966 ldd #NBUSY /BUSY
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
967 bsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
968 bcs ex@ branch if ok
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
969 lsra error bit set?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
970 bcc g@ branch if not
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
971 lbsr ATAError
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
972 bra ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
973 g@ ldd #NBUSYDRQ /BUSY and DRQ
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
974 lbsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
975 bcs ex@ branch if ok
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
976 again@ lda V.Log2Phys,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
977 sta 1,s set up our sector counter
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
978 inc@ clr ,s set up our byte counter
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
979 wr@ ldd ,y++
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
980 stb Latch,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
981 sta DataReg,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
982 inc ,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
983 bpl wr@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
984 dec 1,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
985 bne inc@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
986 * Increment physical sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
987 inc V.PhySct+2,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
988 bcc go@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
989 inc V.PhySct+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
990 bcc go@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
991 inc V.PhySct,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
992 go@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
993 dec V.SctCnt,u decrement # of hw sectors to read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
994 bne loop@ if not zero, do it again
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
995 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
996 ex@ puls x,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
997
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
998 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
999 * Convert LSN to C/H/S values and write to IDE hardware
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1000 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1001 * Entry: V.PhySct = bits 23-0 of LSN
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1002 * X = ptr to hardware
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1003 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1004 * Exit: CHS values placed directly in HW
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1005 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1006 DoCHS
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1007 * Select device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1008 lda V.WhichDv,u get devhead value made by IOSetup (already CHS)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1009 sta DevHead,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1010 ldd #NBUSYNDRQ /BUSY and /DRQ
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1011 lbsr StatusWait wait for proper condition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1012 bcc start@ branch if ok
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1013 rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1014 * Start computation
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1015 start@ pshs y save original Y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1016 ldy V.CurDTbl,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1017 lda 3,y get device's head
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1018 ldb 5,y and sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1019 stb V.Sectors,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1020 mul multiply H*S
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1021 beq ZeroProd if zero, error out
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1022 pshs d save product of H*S
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1023 ldd V.PhySct+1,u get bits 15-0 of LSN
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1024 ldy #-1 start Y at -1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1025 inc V.PhySct,u increment physical sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1026 * Here we are doing physLSN/(H*S) to get cylinder for physLSN
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1027 a@ leay 1,y increment count to compensate
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1028 subd ,s subtract (H*S) from physLSN
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1029 bhs a@ if D>=0 then continue
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1030 dec V.PhySct,u decrement phys sector bits 23-16
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1031 bne a@ if not zero, continue divide
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1032 addd ,s++ add in (H*S) to make non-negative
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1033 pshs d D now holds cylinder, save on stack
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1034 tfr y,d Y now holds cylinder value
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1035 exg a,b swap
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1036 std CylLow,x store computed cylinder in HW
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1037 puls d restore saved cylinder
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1038 * Now we will compute the sector/head value
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1039 ldy #-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1040 b@ leay 1,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1041 subb V.Sectors,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1042 sbca #0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1043 bcc b@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1044 addb V.Sectors,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1045 incb add 1 to B, which is sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1046 stb SectNum,x store computed sector in HW
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1047 tfr y,d
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1048 orb DevHead,x OR in with value written earlier
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1049 stb DevHead,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1050 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1051 puls y,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1052 ZeroProd ldb #E$Sect
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1053 coma
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1054 puls y,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1055
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1056 * ATAError - Checks the ATA error register and maps
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1057 * to a NitrOS-9 error message.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1058 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1059 * Called if the error bit in the status register is set.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1060 ATAError
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1061 lda ErrorReg,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1062 ldb #7
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1063 l@ lsra
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1064 bcs LookUp
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1065 decb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1066 bne l@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1067 LookUp leax Errs,pcr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1068 x@ ldb b,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1069 coma
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1070 rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1071
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1072 * This is the ATAPI Sense Key -> NitrOS-9 Error Table
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1073 * The Sense Key Table is on page 50 of the ATAPI Removable
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1074 * Rewritable Specification, Revision 1.3 Proposed.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1075 * If an error number is zero, then no error is returned.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1076 SenseMap FCB 0 sense key 0 (NO SENSE)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1077 FCB 0 sense key 1 (RECOVERED ERROR)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1078 FCB E$NotRdy sense key 2 (NOT READY)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1079 FCB E$Sect sense key 3 (MEDIUM ERROR)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1080 FCB E$Unit sense key 4 (HARDWARE ERROR)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1081 FCB E$IllArg sense key 5 (ILLEGAL REQUEST)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1082 FCB 0 sense key 6 (UNIT ATTENTION)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1083 FCB E$WP sense key 7 (DATA PROTECT)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1084 FCB 0 sense key 8 (BLANK CHECK)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1085 FCB 0 sense key 9 (VENDOR SPECIFIC)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1086 FCB 0 sense key A (RESERVED)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1087 FCB 1 sense key B (ABORTED COMMAND)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1088 FCB 0 sense key C (RESERVED)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1089 FCB 0 sense key D (VOLUME OVERFLOW)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1090 FCB 0 sense key E (MISCOMPARE)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1091 FCB 0 sense key F (RESERVED)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1092
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1093 * ERROR REG Bit 0 1 2 3 4 5 6 7
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1094 Errs FCB E$Unit,E$CRC,E$UnkSvc,E$Sect,E$UnkSvc,E$DIDC,E$Seek,E$Sect
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1095
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1096 EMOD
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1097 eom EQU *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1098 END