68
|
1 ********************************************************************
|
|
2 * Boot - SCSI Boot module
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * This module allows booting from a hard drive that uses RGB-DOS
|
|
7 * and is controlled by a TC^3 or Ken-Ton SCSI controller.
|
|
8 *
|
|
9 * It was later modified to handle hard drives with sector sizes
|
|
10 * larger than 256 bytes, and works on both 256 byte and larger drives,
|
|
11 * so it should totally replace the old SCSI boot module.
|
|
12 *
|
|
13 * Instructions followed by +++ in the comment field were added for this fix.
|
|
14 *
|
|
15 * Ed. Comments Who YY/MM/DD
|
|
16 * ------------------------------------------------------------------
|
|
17 * 1 Original Roger Krupski distribution version
|
|
18 * 1b Added code to allow booting from any sector BGP 96/??/??
|
|
19 * size hard drive
|
|
20 * Merged Ken-Ton and TC^3 module source BGP 02/05/01
|
|
21
|
|
22
|
|
23 nam Boot
|
|
24 ttl SCSI Boot module
|
|
25
|
|
26 ifp1
|
|
27 use defsfile
|
|
28 endc
|
|
29
|
|
30 tylg set Systm+Objct
|
|
31 atrv set ReEnt+rev
|
|
32 rev set 2
|
|
33 edition set 1
|
|
34
|
|
35 * The default SCSI ID is here
|
|
36 scsiid equ %00000001
|
|
37
|
|
38 * Hard Disk Interface registers for the Ken-ton and RGB HDI
|
|
39 ifne Kenton
|
|
40 dataport equ $FF74
|
|
41 status equ dataport+1
|
|
42 select equ dataport+2
|
|
43 reset equ dataport+3
|
|
44 endc
|
|
45
|
|
46 ifne TC3
|
|
47 dataport equ $FF74
|
|
48 status equ dataport+1
|
|
49 select equ dataport+1
|
|
50 endc
|
|
51
|
|
52 * Status register equates
|
|
53 req equ $01
|
|
54 busy equ $02
|
|
55 msg equ $04
|
|
56 cmd equ $08
|
|
57 inout equ $10
|
|
58 ack equ $20
|
|
59 sel equ $40
|
|
60 rst equ $80
|
|
61
|
|
62 *SCSI common command set
|
|
63 c$rstr equ 1
|
|
64 c$rdet equ 3
|
|
65 c$rblk equ 8
|
|
66 c$wblk equ 10
|
|
67
|
|
68 * Optional command
|
|
69 c$ststop equ $1b park head
|
|
70
|
|
71 * misc
|
|
72 errsta equ 2
|
|
73 bsybit equ 8
|
|
74
|
|
75 ****************************************************
|
|
76 bootdrv equ 0
|
|
77 ****************************************************
|
|
78
|
|
79 mod eom,name,tylg,atrv,start,size
|
|
80
|
|
81 * Data equates; subroutines must keep data in stack
|
|
82 v$cmd rmb 1
|
|
83 v$addr0 rmb 1
|
|
84 v$addr1 rmb 2
|
|
85 v$blks rmb 1
|
|
86 v$opts rmb 1
|
|
87 v$error rmb 4
|
|
88
|
|
89 blockloc rmb 2 pointer to memory requested
|
|
90 blockimg rmb 2 duplicate of the above
|
|
91 bootloc rmb 3 sector pointer; not byte pointer
|
|
92 bootsize rmb 2 size in bytes
|
|
93 size equ .
|
|
94
|
|
95 name fcs /Boot/
|
|
96 fcb edition
|
|
97
|
|
98 start clra
|
|
99 ldb #size
|
|
100 clean pshs a
|
|
101 decb
|
|
102 bne clean
|
|
103 tfr s,u get pointer to data area
|
|
104 pshs u save pointer to data area
|
|
105
|
|
106 lda #$d0 forced interrupt; kill floppy activity
|
|
107 sta $FF48 command register
|
|
108 clrb
|
|
109 pause decb
|
|
110 bne pause
|
|
111 lda $FF48 clear controller
|
|
112 clr $FF40 make sure motors are turned off
|
|
113 ifgt Level-1
|
|
114 sta $FFD9 fast clock
|
|
115 endc
|
|
116
|
|
117 * Recalibrate hard drive
|
|
118 lbsr restore
|
|
119
|
|
120 * Request memory for LSN0
|
|
121 ldd #1
|
|
122 os9 F$SRqMem request one page of RAM
|
|
123 bcs error
|
|
124 bsr getpntr
|
|
125
|
|
126 * Get LSN0 into memory
|
|
127 clrb MSB sector
|
|
128 ldx #0 LSW sector
|
|
129 bsr mread
|
|
130 bcs error
|
|
131 ldd bootsize,u
|
|
132 beq error
|
|
133 pshs d
|
|
134
|
|
135 * Return memory
|
|
136 ldd #$100
|
|
137 ldu blockloc,u
|
|
138 os9 F$SRtMem
|
|
139 puls d
|
|
140 ifgt Level-1
|
|
141 os9 F$BtMem
|
|
142 else
|
|
143 os9 F$SRqMem
|
|
144 endc
|
|
145 bcs error
|
|
146 bsr getpntr
|
|
147 std blockimg,u
|
|
148
|
|
149 * Get os9boot into memory
|
|
150 ldd bootsize,u
|
|
151 leas -2,s same as a PSHS D
|
|
152 getboot std ,s
|
|
153 ldb bootloc,u MSB sector location
|
|
154 ldx bootloc+1,u LSW sector location
|
|
155 bsr mread
|
|
156 ldd bootloc+1,u update sector location by one to 24bit word
|
|
157 addd #1
|
|
158 std bootloc+1,u
|
|
159 ldb bootloc,u
|
|
160 adcb #0
|
|
161 stb bootloc,u
|
|
162 inc blockloc,u update memory pointer for upload
|
|
163 ldd ,s update size of file left to read
|
|
164 subd #$100 file read one sector at a time
|
|
165 bhi getboot
|
|
166
|
|
167 leas 4+size,s reset the stack same as PULS U,D
|
|
168 ldd bootsize,u
|
|
169 ldx blockimg,u pointer to start of os9boot in memory
|
|
170 andcc #^Carry clear carry
|
|
171 rts back to os9p1
|
|
172
|
|
173 error leas 2+size,s
|
|
174 ldb #E$NotRdy drive not ready
|
|
175 rts
|
|
176
|
|
177 getpntr tfr u,d save pointer to requested memory
|
|
178 ldu 2,s recover pointer to data stack
|
|
179 std blockloc,u
|
|
180 rts
|
|
181
|
|
182 mread tstb
|
|
183 bne read10
|
|
184 cmpx #0
|
|
185 bne read10
|
|
186 bsr read10
|
|
187 bcc readlsn0
|
|
188 rts
|
|
189
|
|
190 readlsn0 pshs a,x,y
|
|
191 ldy blockloc,u
|
|
192 lda DD.Bt,y os9boot pointer
|
|
193 ldx DD.Bt+1,y LSW of 24 bit address
|
|
194 sta bootloc,u
|
|
195 stx bootloc+1,u
|
|
196 ldx DD.BSZ,y os9boot size in bytes
|
|
197 stx bootsize,u
|
|
198 clrb
|
|
199 puls a,x,y,pc
|
|
200
|
|
201 * Generic read
|
|
202 read10 lda #c$rblk
|
|
203 bsr setup
|
|
204 bra command
|
|
205
|
|
206 setup pshs b
|
|
207 sta v$cmd,u
|
|
208 stb v$addr0,u
|
|
209 stx v$addr1,u
|
|
210 ldb #1
|
|
211 stb v$blks,u
|
|
212 clr v$opts,u
|
|
213 puls b,pc
|
|
214
|
|
215 wakeup ldx #0
|
|
216 wake lda status
|
|
217 bita #busy+sel
|
|
218 beq wake1
|
|
219 leax -1,x
|
|
220 bne wake
|
|
221 bra wake4
|
|
222 wake1 bsr wake3
|
|
223 lda #scsiid
|
|
224 sta dataport
|
|
225 bsr wake3
|
|
226 sta select
|
|
227 ldx #0
|
|
228 wake2 lda status
|
|
229 bita #busy
|
|
230 bne wake3
|
|
231 leax -1,x
|
|
232 bne wake2
|
|
233 wake4 leas 2,s
|
|
234 comb
|
|
235 ldb #E$NotRdy
|
|
236 wake3 rts
|
|
237
|
|
238 command bsr wakeup
|
|
239 leax v$cmd,u
|
|
240 bsr send
|
|
241 bsr waitrq
|
|
242 bita #cmd
|
|
243 bne getsta
|
|
244 ldx blockloc,u
|
|
245 bsr read
|
|
246 getsta bsr instat
|
|
247 bita #bsybit
|
|
248 bne command
|
|
249 bita #errsta
|
|
250 beq done
|
|
251 comb
|
|
252 done rts
|
|
253
|
|
254 send bsr waitrq
|
|
255 bita #cmd
|
|
256 beq done
|
|
257 bita #inout
|
|
258 bne done
|
|
259 lda ,x+
|
|
260 sta dataport
|
|
261 bra send
|
|
262
|
|
263 waitrq pshs b,x
|
|
264 wait10 lda status
|
|
265 bita #req
|
|
266 beq wait10
|
|
267 puls b,x,pc
|
|
268
|
|
269 * Patch to allow booting from sector sizes > 256 bytes - BGP 08/16/97
|
|
270 * We ignore any bytes beyond byte 256, but continue to read them from
|
|
271 * the dataport until the CMD bit is set.
|
|
272 read
|
|
273 * next 2 lines added
|
|
274 clrb +++ use B as counter
|
|
275 read2
|
|
276 bsr waitrq
|
|
277 bita #cmd
|
|
278 bne done
|
|
279 lda dataport
|
|
280 sta ,x+
|
|
281 * next line commented out and next 8 lines added
|
|
282 * bra read
|
|
283 incb +++
|
|
284 bne read2 +++
|
|
285 read3
|
|
286 bsr waitrq +++
|
|
287 bita #cmd +++
|
|
288 bne done +++
|
|
289 lda dataport +++
|
|
290 bra read3 +++
|
|
291
|
|
292 instat bsr waitrq
|
|
293 lda dataport
|
|
294 anda #%00001111
|
|
295 pshs a
|
|
296 bsr waitrq
|
|
297 clra
|
|
298 sta dataport
|
|
299 puls a,pc
|
|
300
|
|
301 restore lda #c$rstr
|
|
302 clrb
|
|
303 ldx #0
|
|
304 lbsr setup
|
|
305 clr v$blks,u
|
|
306 bra command
|
|
307
|
|
308 ifgt Level-1
|
|
309 * Fillers to get to $1D0
|
|
310 fcc /9999999999/
|
|
311 fcc /9999999999/
|
|
312 fcc /9999999999/
|
|
313 fcc /9999999999/
|
|
314 fcc /9999999999/
|
|
315 fcc /9999999999/
|
|
316 fcc /9999999999/
|
|
317 fcc /9999999999/
|
|
318 fcc /99999999/
|
|
319 endc
|
|
320
|
|
321 emod
|
|
322 eom equ *
|
|
323 end
|
|
324
|