Mercurial > hg > Members > kono > nitros9-code
annotate 3rdparty/booters/boot_burke.asm @ 657:d2ce1c213a9c
Changed boot_ktlr and boot_tc3 to add id0 for SCSI ID
author | boisy |
---|---|
date | Sat, 21 Dec 2002 15:30:11 +0000 |
parents | 3e3f1f79ba00 |
children |
rev | line source |
---|---|
393 | 1 ******************************************************************** |
2 * Boot - Burke & Burke Boot Module | |
3 * | |
4 * $Id$ | |
5 * | |
6 * Burke & Burke boot module... needs to be patched for OS9Boots that are | |
7 * far into the device. | |
8 * Track is the literal cylinder #, Cylinder would be including all heads | |
9 * of that track | |
10 * | |
11 * Ed. Comments Who YY/MM/DD | |
12 * ------------------------------------------------------------------ | |
13 | |
14 nam Boot | |
15 ttl Burke & Burke Boot Module | |
16 | |
17 org 0 | |
18 buffptr rmb 2 Pointer to sector buffer in memory | |
19 numcyl rmb 2 Number of tracks for drive geometry init | |
20 sechead rmb 2 # of logical sectors/physical sector | |
21 numhead rmb 1 # of heads (sides) | |
22 seccyl rmb 2 # of sectors/cylinder (# of heads*sectors per head) | |
23 track rmb 2 Cylinder number last calculated ($9 - $A) | |
24 head rmb 1 Drive/head number (drive always 0) | |
25 sector rmb 1 Sector number (0-63) | |
26 vars equ 13-buffptr Size of stack variables buffer | |
27 | |
28 | |
29 ifp1 | |
30 use defsfile | |
31 endc | |
32 | |
33 tylg set Systm+Objct | |
34 atrv set ReEnt+rev | |
35 rev set $02 | |
36 edition set 2 | |
37 | |
38 mod eom,name,tylg,atrv,start,size | |
39 | |
40 u0000 rmb 0 | |
41 size equ . | |
42 | |
43 name fcs /Boot/ | |
44 fcb edition | |
45 | |
46 start ldb >MPI.Slct Set up Multipak properly for us | |
47 lda #$10 | |
48 mul | |
49 ldb #$11 | |
50 mul | |
51 stb >MPI.Slct | |
52 leas -vars,s Reserve work area on stack of 13 bytes | |
53 tfr s,u U points to beginning of 13 byte buffer | |
54 pshs u,y,x,b,a Preserve registers | |
55 ldd #$0200 512 bytes for each read from XT-GEN | |
56 std numcyl,u # of cyls on drive | |
57 sta sechead+1,u # of sectors/head | |
58 sta numhead,u # of heads on drive | |
59 os9 F$SRqMem Request 512 byte buffer from OS9P1 | |
60 lbcs L00B6 Error | |
61 tfr u,d d=Starting address of 512 byte block | |
62 ldu $06,s Get back pointer to 13 byte buffer | |
63 std buffptr,u Preserve buffer pointer | |
64 | |
65 clr >$FF51 Reset controller | |
66 | |
67 clr >$FF53 Set controller mode to 0 (part of init) | |
68 lbsr drvtype Set drive geometry (type of drive) | |
69 clrb Set initial LSN to 0 | |
70 ldx #$0000 | |
71 lbsr GetSect Figure out track/head/sector for LSN0 | |
72 bcs L00B6 Error occured in read | |
73 ldy buffptr,u Get buffer pointer | |
74 ldd DD.NAM+PD.CYL,y Get real # cylinders on drive | |
75 std numcyl,u Preserve | |
76 ldd DD.NAM+PD.SCT,y Get real # sectors/track | |
77 std sechead,u Preserve | |
78 lda DD.NAM+PD.SID,y Get real # heads | |
79 sta numhead,u Preserve | |
80 leay DD.BT,y Point to OS9Boot information | |
81 ldd DD.BSZ-DD.BT,y Get size of OS9Boot | |
82 std ,s Preserve on stack | |
83 ldb DD.BT-DD.BT,y Get MSB of starting LSN of OS9Boot | |
84 ldx DD.BT-DD.BT+1,y Get LSW of starting LSN of OS9Boot | |
85 pshs x,b Push on stack | |
86 lbsr drvtype Set up drive for real drive specs | |
87 ldd #$0200 Get size of our buffer | |
88 ldu buffptr,u Get pointer to our 512 byte buffer | |
89 os9 F$SRtMem Deallocate our old sector buffer | |
90 ldd $03,s Get back size of OS9Boot | |
91 inca Increase size by 1 block (256 bytes) | |
92 ifeq Level-1 | |
93 os9 F$SRqMem | |
94 else | |
95 os9 F$BtMem Allocate memory for boot file | |
96 endc | |
97 bcs L00B0 Error | |
98 stu $05,s Preserve pointer to start of OS9boot memory | |
99 ldu $09,s Get back pointer to local variables | |
100 ldd $05,s Get pointer to start of OS9Boot memory | |
101 std buffptr,u Move disk buffer pointer to there | |
102 ldd $03,s Get size of bootfile | |
103 beq L00A9 If zero, do someting | |
104 pshs b,a Otherwise push on stack | |
105 ReadBt std ,s Store # bytes left in boot on stack | |
106 ldb $02,s Get MSB of start sector of boot | |
107 ldx $03,s Get LSW of start sector of boot | |
108 bsr GetSect Convert to track/head/sector | |
109 bcs L00B4 If an error in getting, do something | |
110 inc buffptr,u Bump up buffer pointer by a page | |
111 ldx $03,s Bump up LSW of sector number | |
112 leax $01,x | |
113 stx $03,s And put it back | |
114 bne L00A0 If no carry over needed, proceed | |
115 inc $02,s Bump up MSB of sector number | |
116 L00A0 ldd ,s Get current boot size left to do | |
117 subd #$0100 Subtract 256 from it | |
118 bhi ReadBt If not zero yet, keep reading | |
119 leas $02,s Eat our temporary size left | |
120 L00A9 leas $03,s Eat our current LSN to get | |
121 clrb Clear carry (No error) | |
122 puls b,a pull off multipak settings (?) | |
123 bra BtExit | |
124 L00B0 leas $03,s Purge stack | |
125 bra L00B6 | |
126 L00B4 leas $05,s Purge stack | |
127 | |
128 L00B6 leas $02,s Purge stack | |
129 | |
130 BtExit pshs a | |
131 lda #$FF | |
132 sta >$FF51 Reset controller | |
133 sta >MPI.Slct Reset multipak | |
134 sta >$FFD9 Double speed on | |
135 puls u,y,x,a Get exit parameters for Boot | |
136 leas vars,s Reset stack | |
137 rts Exit from Boot | |
138 | |
139 * Get 512 byte sector from controller | |
140 * Entry X:B = 24 bit Logical sector number to get | |
141 | |
142 GetSect pshs x,b Preserve registers | |
143 ldx #$FFFF (Init X so it will be 0 in loop) | |
144 | |
145 * 24 bit divide routine. Stack=LSN (3 bytes) | |
146 * Entry: u=pointer to our local variable list | |
147 | |
148 cyldiv leax $01,x # of loops through subtract | |
149 ldd $01,s Get original x (0) | |
150 subd seccyl,u Subtract # sector/cylinder | |
151 std $01,s Preserve it back | |
152 ldb ,s Continue subtract with borrow for 24 bit | |
153 sbcb #$00 | |
154 stb ,s | |
155 bcc cyldiv If not trying to borrow again, continue | |
156 stx track,u Got track # | |
157 ldd $01,s Reset value to last in loop | |
158 addd seccyl,u | |
159 clr head,u Set head # to 0? | |
160 hddiv inc head,u Increase head #? | |
161 subd sechead,u Subtract # sectors/head? | |
162 bcc hddiv Continue subtracting until it wraps | |
163 dec head,u Adjust head to not include wrap | |
164 addd sechead,u Adjust leftover to not include wrap | |
165 lsrb Divide b by 2 (256 byte sector to 512) | |
166 stb sector,u Preserve sector # | |
167 leas $03,s Clear stack of 24 bit number | |
168 | |
169 pshs cc Preserve odd sector flag (carry bit) | |
170 | |
171 bsr cmdstrt Set up controller for new command | |
172 lda #$08 Read sector command | |
173 ldb head,u Drive/head byte (Drive always 0) | |
174 bsr dblsend Send to controller | |
175 ldd track,u Get msb of track | |
176 lsra Move right 2 bits into left two for the | |
177 rora controller | |
178 rora | |
179 ora sector,u mask in the sector number into remaining 6 bits | |
180 * ldb track+1,u Get LSB of track | |
181 bsr dblsend Send to controller | |
182 ldd #$0100 1 sector to read/no error correction/3 ms step | |
183 bsr dblsend Send that to controller | |
184 ldx buffptr,u Get pointer to sector buffer | |
185 * new code is here | |
186 puls cc Get back odd sector 1/2 indicator | |
187 bcc normal Even sector, use 1st half | |
188 bsr Eat256 Odd sector, use 2nd half | |
189 bsr Read256 Read 256 bytes off of controller | |
190 lbra chkcmplt See if command is complete | |
191 normal bsr Read256 Read 1/2 of sector | |
192 bsr Eat256 Eat half of sector | |
193 lbra chkcmplt See if command is complete | |
194 | |
195 Eat256 clrb Eat 256 bytes off of controller | |
196 Eatlp lbsr nxtready Get byte from controller | |
197 decb counter | |
198 bne Eatlp Keep eating until 256 bytes done | |
199 clrb | |
200 rts | |
201 | |
202 * Read 256 bytes from controller | |
203 * Entry: X=Pointer to current position in 512 physical sector buffer | |
204 | |
205 Read256 clrb Set counter for 256 byte read | |
206 ReadLp lbsr nxtready Go get a byte from controller | |
207 sta ,x+ Put in buffer | |
208 decb keep doing until all 256 are read | |
209 bne ReadLp | |
210 | |
211 middle clrb Clear carry for no error & return | |
212 rts | |
213 | |
214 * Send 2 bytes to the controller | |
215 * Entry: a=1st byte to send | |
216 * b=2nd byte to send | |
217 | |
218 dblsend pshs b,a Preserve d for a moment | |
219 bsr sendbyte Go send what is in a to controller | |
220 tfr b,a Send what was in b to the controller | |
221 bsr sendbyte | |
222 puls pc,b,a Return with a and b intact | |
223 | |
224 * Sends a byte to the controller when it is ready for it | |
225 * Entry: a=byte to send | |
226 | |
227 sendbyte pshs a Preserve a for a moment | |
228 waitsend bsr stable Make sure status register is stable and get it | |
229 anda #%00001011 Mask out bits | |
230 cmpa #$09 Is it expecting next byte of data packet? | |
231 bne waitsend | |
232 puls a Yes, get the byte we are sending next | |
233 sta >$FF50 Store in data register | |
234 rts | |
235 | |
236 * Sends out command packet (6 bytes). Hard coded for drive 0, head 0, | |
237 * track 0, sector 0, interleave 0, no error correction, 3 ms step rate | |
238 | |
239 cmdpckt pshs a Preserve command for a moment | |
240 bsr cmdstrt Go initialize controller for command start | |
241 puls a Get back command byte | |
242 clrb 1st option byte to 0 | |
243 bsr dblsend Send both to controller | |
244 clra | |
245 bsr dblsend Send 4 more 0's to controller | |
246 bsr dblsend (sent command byte and 5 zero bytes for command | |
247 rts packet) | |
248 | |
249 cmdstrt bsr stable | |
250 anda #%00001001 Mask out all but bits 0 and 3 | |
251 bne cmdstrt If controller command is not complete or expecting | |
252 clr >$FF52 data, keep reading status register until it is ready | |
253 rts Otherwise initialize command start | |
254 | |
255 * Make sure controller's status register is stable | |
256 | |
257 stable lda >$FF51 Get status from controller | |
258 cmpa >$FF51 Keep getting until it stabilizes | |
259 bne stable | |
260 rts | |
261 | |
262 * Set the drive type (set to 512 track - may be the error) | |
263 * Using the initialize drive geometry command | |
264 * Exit: Carry set if non-recoverable error | |
265 | |
266 drvtype lda #$0C Initialize drive geometry command | |
267 bsr cmdpckt Go init | |
268 ldd numcyl,u Get # of cylinders on media | |
269 bsr dblsend Send it out (indicates drive has 512 tracks) | |
270 ldb sechead+1,u Get # of sectors/head | |
271 lda numhead,u Get # of heads on media | |
272 lsrb Divide OS9 sectors by 2 | |
273 bsr sendbyte Send out # of heads for drive geometry | |
274 lslb Multiply WD sectors by 2 to get OS9 sectors again. | |
275 mul | |
276 std seccyl,u # sectors per cylinder (all heads on a track) | |
277 ldd numcyl,u Get # of tracks back | |
278 subd #$0001 Reduce write track=last track-1 | |
279 bsr dblsend Send out reduced write track # | |
280 bsr dblsend Also use as write precomp track # | |
281 lda #$04 Maximum ECC burst length correctable=4 | |
282 bsr sendbyte Send it out | |
283 | |
284 * Make sure command has completed | |
285 * Exit: Carry set if controller reported a non-recoverable error | |
286 * Carry clear if everything went fine | |
287 | |
288 chkcmplt bsr stable When status register is stable get it | |
289 anda #%00000111 Keep checking until controller indicates that | |
290 cmpa #%00000111 command completion code is ready to be read | |
291 bne chkcmplt | |
292 lda >$FF50 Get command completion code | |
293 bita #%00000010 Was there in error in completing the command? | |
294 beq noerror Nope, everything fine setting drive geometry | |
295 lda #$03 Error, Request Sense Status from the drive | |
296 bsr cmdpckt send Request Sense Status code | |
297 bsr nxtready Go get response from controller | |
298 anda #%00111111 Mask out all but error type and error code | |
299 pshs a Preserve it for a second | |
300 bsr eat2 Go eat next 4 bytes from controller (remaining 3 | |
301 bsr eat2 from Sense Status & command completion code) | |
302 puls a Get back original error byte | |
303 tsta No error occured? | |
304 beq noerror No error; exit without error | |
305 cmpa #%00011000 Type 1, error 8 (correctable data error)? | |
306 beq noerror Yes, return without error | |
307 comb Set carry to indicate error | |
308 rts return | |
309 noerror clrb | |
310 rts | |
311 | |
312 * Reads two byte from controller without caring what they are | |
313 | |
314 eat2 bsr nxtready | |
315 | |
316 * Waits until next byte coming from controller is ready, then gets it | |
317 * Exit: a=byte from controller | |
318 | |
319 nxtready bsr stable Make sure status register is stable and get it | |
320 anda #%00001011 Controller ready to send me next byte? | |
321 cmpa #%00001011 | |
322 bne nxtready Nope, keep waiting | |
323 lda >$FF50 Yes, get byte and return | |
324 rts Padding to get $1D0 Size | |
325 * Pad to $1d0 bytes exactly | |
459
3e3f1f79ba00
Sources now use 'fill' pseudo-op to fill out for L2 modules
boisy
parents:
393
diff
changeset
|
326 Pad fill $39,$1D0-3-* |
393 | 327 |
328 emod | |
329 eom equ * | |
330 end |