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