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