Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/boot_ide.asm @ 3063:c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
author | David Ladd <drencor-xeen@users.sf.net> |
---|---|
date | Sun, 08 Feb 2015 17:44:00 -0600 (2015-02-08) |
parents | 17d43fd29ee2 |
children | 594490949f0a |
rev | line source |
---|---|
2590 | 1 ******************************************************************** |
2 * Boot - IDE Boot Module | |
3 * | |
4 * $Id$ | |
5 * | |
6 * Edt/Rev YYYY/MM/DD Modified by | |
7 * Comment | |
8 * ------------------------------------------------------------------ | |
9 * ? 1994/06/25 Alan DeKok | |
10 * Diassembled. | |
11 * | |
12 * 6 1999/08/17 Paul T. Barton | |
13 * Redone for IDE. | |
14 * | |
15 * 7 2002/06/27 Boisy G. Pitre | |
16 * Added use of LSN bits 23-16. | |
17 * | |
18 * 7r1 2004/05/12 Boisy G. Pitre | |
19 * Optimized, made toG wait on !BUSY and DRDY, added slowdown POKE | |
20 * for Fujitsu 128MB CF (may be temporary) | |
21 * | |
22 * 8 2004/07/29 Boisy G. Pitre | |
23 * Now detects CHS/LBA mode to work with ALL IDE drives. | |
24 * | |
25 * 9 2005/10/13 Boisy G. Pitre | |
26 * Support for fragmented bootfiles added. | |
27 | |
28 NAM Boot | |
29 TTL IDE Boot Module | |
30 | |
31 IFP1 | |
32 USE defsfile | |
33 USE ide.d | |
34 ENDC | |
35 | |
36 tylg SET Systm+Objct | |
37 atrv SET ReEnt+rev | |
38 rev SET $00 | |
39 edition SET 9 | |
40 | |
41 * Disassembled 94/06/25 11:37:47 by Alan DeKok | |
42 * ReDone by Paul T. Barton 99/08/17, for IDE | |
43 | |
44 MOD eom,name,tylg,atrv,start,size | |
45 | |
46 * on-stack static storage | |
47 ORG 0 | |
48 cyls RMB 2 | |
49 sides RMB 1 | |
50 sects RMB 2 | |
51 mode RMB 1 | |
52 seglist RMB 2 pointer to segment list | |
53 blockloc RMB 2 pointer to memory requested | |
54 blockimg RMB 2 duplicate of the above | |
55 bootloc RMB 3 sector pointer; not byte pointer | |
56 bootsize RMB 2 size in bytes | |
57 LSN0Ptr RMB 2 LSN0 pointer (used by boot_common.asm) | |
3063
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
58 IFDEF DEBLOCK |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
59 HalfSect RMB 1 |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
60 ENDC |
2590 | 61 size EQU . |
62 | |
63 name FCS /Boot/ | |
64 FCB edition | |
65 | |
66 * Common booter-required defines | |
67 LSN24BIT EQU 1 | |
68 FLOPPY EQU 0 | |
69 | |
70 USE boot_common.asm | |
71 | |
72 * HWInit - Initialize the device | |
73 * Entry: Y = hardware address | |
74 * Exit: Carry Clear = OK, Set = Error | |
75 * B = error (Carry Set) | |
76 HWInit ldb Address+2,pcr | |
77 bne slave@ | |
78 lda #%10100000 | |
79 FCB $8C | |
80 slave@ lda #%10110000 | |
81 sta mode,u | |
82 stb DevHead,y select device | |
83 a@ tst Status,y wait for BSY to clear | |
84 bmi a@ | |
85 lda #$EC | |
86 sta Command,y | |
87 b@ tst Status,y | |
88 bmi b@ | |
89 * Harvest C/H/S values. | |
90 ldb DataReg,y ignore bytes 0-1 | |
91 ldb DataReg,y bytes 2-3 = no. of cylinders | |
92 lda Latch,y | |
93 std cyls,u save cylinders in our private static area | |
94 ldb DataReg,y ignore bytes 4-5 | |
95 ldb DataReg,y bytes 6-7 = no. of heads | |
96 stb sides,u save sides on stack (B) | |
97 ldb DataReg,y ignore bytes 8-9 | |
98 ldb DataReg,y ignore bytes 10-11 | |
99 ldb DataReg,y bytes 12-13 = no. of sectors/track | |
100 lda Latch,y | |
101 std sects,u save sectors/track on stack (Y) | |
102 * Throw away the next 42 (48-7) words | |
103 ldb #43 | |
104 l@ tst DataReg,y | |
105 lda Latch,y | |
106 decb | |
107 bne l@ | |
108 * A holds byte with LBA bit | |
109 anda #%00000010 LBA drive? | |
110 beq nope@ | |
111 ldb mode,u | |
112 orb #%01000000 | |
113 stb mode,u | |
114 nope@ ldb #256-50 | |
115 o@ tst DataReg,y | |
116 decb | |
117 bne o@ | |
118 HWTerm clrb | |
119 rts | |
120 | |
121 * HWRead - Read a 256 byte sector from the device | |
122 * Entry: Y = hardware address | |
123 * B = bits 23-16 of LSN | |
124 * X = bits 15-0 of LSN | |
125 * blockloc,u = ptr to 256 byte sector | |
126 * Exit: X = ptr to data (i.e. ptr in blockloc,u) | |
127 HWRead | |
128 pshs x,b | |
129 b@ tst Status,y | |
130 bmi b@ if =1 then loop | |
3063
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
131 IFDEF DEBLOCK |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
132 clra clear A so we can hold half sector flag |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
133 lsr ,s ok shift the 3 bytes on stack that |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
134 ror 1,s hold LSN to the right to create a |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
135 ror 2,s divide by 2. Then put last bit in |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
136 rola A for use as the half sector flag |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
137 sta HalfSect,u then store the flag on the stack |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
138 ENDC |
2590 | 139 lda mode,u |
140 sta DevHead,y 0L0d/0hhh device=CHS | |
141 r@ ldb Status,y is IDE ready for commands? | |
142 andb #BusyBit+DrdyBit ready ? | |
143 cmpb #DrdyBit | |
144 bne r@ loop until Drdy=1 and Busy=0 | |
145 ldb #$01 only one at a time | |
146 stb SectCnt,y only one at a time | |
147 anda #%01000000 | |
148 beq chs@ branch if mode | |
149 lda ,s get bits 23-16 | |
150 sta CylHigh,y | |
151 ldd 1,s get bits 15-0 | |
152 stb SectNum,y | |
153 sta CylLow,y | |
154 bra DoCmd | |
155 chs@ | |
156 * Compute proper C:H:S value | |
157 lda sides,u get device's head | |
158 ldb sects+1,u and sector | |
159 mul multiply H*S | |
160 * Note, there is a chance here that if the product is zero, we could loop forever | |
161 * beq ZeroProd | |
162 pshs d save product of H*S | |
163 ldd 1+2,s get bits 15-0 of LSN | |
164 ldx #-1 start Y at -1 | |
165 inc 0+2,s increment physical sector | |
166 * Here we are doing physLSN/(H*S) to get cylinder for physLSN | |
167 a@ leax 1,x increment count to compensate | |
168 subd ,s subtract (H*S) from physLSN | |
169 bhs a@ if D>=0 then continue | |
170 dec 0+2,s decrement phys sector bits 23-16 | |
171 bne a@ if not zero, continue divide | |
172 addd ,s++ add in (H*S) to make non-negative | |
173 pshs d X now holds cylinder, save D on stack | |
174 tfr x,d | |
175 exg a,b swap | |
176 std CylLow,y store computed cylinder in HW | |
177 puls d restore saved cylinder | |
178 * Now we will compute the sector/head value | |
179 ldx #-1 | |
180 c@ leax 1,x | |
181 subb sects+1,u | |
182 sbca #0 | |
183 bcc c@ | |
184 addb sects+1,u | |
185 incb add 1 to B, which is sector | |
186 stb SectNum,y store computed sector in HW | |
187 tfr x,d | |
188 orb DevHead,y OR in with value written earlier | |
189 stb DevHead,y | |
190 DoCmd lda #S$READ read one sector | |
191 sta Command,y finish process | |
192 | |
193 Blk2 lda Status,y is IDE ready to send? | |
194 anda #DrqBit DRQ, data request | |
195 beq Blk2 loop while DRQ =0 | |
196 | |
197 ldx blockloc,u | |
198 clr ,s | |
3063
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
199 IFDEF DEBLOCK |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
200 lda HalfSect,u load half sector flag |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
201 cmpa #$01 check to see which routine we |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
202 beq Blk2Lp need and branch to it. |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
203 ENDC |
2590 | 204 BlkLp |
205 lda DataReg,y A <- IDE | |
206 ldb Latch,y | |
207 std ,x++ into RAM | |
208 inc ,s | |
209 bpl BlkLp go get the rest | |
210 b@ lda DataReg,y read remaining 256 bytes | |
211 dec ,s | |
212 bne b@ | |
213 | |
3063
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
214 BlkEnx |
2590 | 215 leax -256,x |
216 stx 1,s | |
217 lda Status,y check for error-bit | |
3063
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
218 clrb |
2590 | 219 puls b,x,pc |
220 | |
3063
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
221 IFDEF DEBLOCK |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
222 Blk2Lp |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
223 lda DataReg,y A <- IDE |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
224 inc ,s Here we toss out the |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
225 bpl Blk2Lp first 256 bytes of the sector |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
226 clr ,s |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
227 b2@ |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
228 lda DataReg,y Now we read the second |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
229 ldb Latch,y half of the sector and put |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
230 std ,x++ into RAM |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
231 inc ,s |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
232 bpl b2@ go get the rest |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
233 bra BlkEnx |
c0bb75b72339
updated boot_ide.asm with deblocking code to be built with -DDEBLOCK
David Ladd <drencor-xeen@users.sf.net>
parents:
2590
diff
changeset
|
234 ENDC |
2590 | 235 |
236 * ------------------------------------------ | |
237 | |
238 *Init | |
239 * pshs d,y | |
240 * ldy <Address,pcr | |
241 * bsr ChkBusy could be spinning up... | |
242 * lda #Diagnos hits all drives | |
243 * sta Command,y ./ | |
244 * bsr ChkBusy wait 'til both done | |
245 * clrb no errors | |
246 * puls d,y,pc | |
247 | |
248 * Entry: A = number to show | |
249 * Destroys D | |
250 *Num | |
251 * tfr a,b | |
252 * lsra | |
253 * lsra | |
254 * lsra | |
255 * lsra | |
256 * bsr x@ | |
257 * andb #$0F | |
258 * tfr b,a | |
259 *x@ | |
260 * adda #'0 | |
261 * cmpa #'9 | |
262 * ble s@ | |
263 * adda #$7 | |
264 *s@ jsr <D.BtBug | |
265 * rts | |
266 | |
267 IFGT Level-1 | |
268 Pad FILL $39,$1D0-3-2-1-* | |
269 ENDC | |
270 | |
271 Address FDB SDAddr | |
272 WhchDriv FCB 0 Drive to use (0 = master, 1 = slave) | |
273 | |
274 | |
275 EMOD | |
276 eom EQU * | |
277 END | |
278 |