Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/boot_scsi.asm @ 2958:77500452de1c
bootman: Rename assembler files to .as
author | Tormod Volden <debian.tormod@gmail.com> |
---|---|
date | Sun, 09 Feb 2014 22:53:29 +0100 |
parents | 28ed72477814 |
children | e0614e08fa5e |
rev | line source |
---|---|
2590 | 1 ******************************************************************** |
2 * Boot - SCSI Boot Module | |
3 * | |
4 * $Id$ | |
5 * | |
6 * This module allows booting from a hard drive that uses HDB-DOS | |
7 * and is controlled by a TC^3, Ken-Ton or Disto 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 * Edt/Rev YYYY/MM/DD Modified by | |
16 * Comment | |
17 * ------------------------------------------------------------------ | |
18 * 1 ????/??/?? Roger Krupski | |
19 * Original Roger Krupski distribution version | |
20 * | |
21 * 1r1 1996/??/?? Boisy G. Pitre | |
22 * Added code to allow booting from any sector size hard drive | |
23 * | |
24 * 1r2 2002/05/01 Boisy G. Pitre | |
25 * Merged Ken-Ton and TC^3 module source | |
26 * | |
27 * 1r3 2002/07/22 Boisy G. Pitre | |
28 * Outputs '.' for each sector read when booting under NitrOS-9 | |
29 * | |
30 * 2 2004/07/30 Boisy G. Pitre | |
31 * SCSI ID 0-7 now modifiable at end of module as well as base address | |
32 * | |
33 * 3 2005/10/09 Boisy G. Pitre | |
34 * Fixed stupid mistake where SCSIDATA was set to base address. Now | |
35 * baseaddr is the base address set at the end of the module and SCSIDATA | |
36 * is 0 for the data offset. | |
37 * Also SCSI-3 compatible SCSI IDs (with hi-bit set) are now sent to bus which | |
38 * causes the booter to work with IBM-DPES31080 and other newer hard drives. | |
39 * Fragmented bootfiles are now supported. | |
40 * | |
41 * 4 2008/02/17 Boisy G. Pitre | |
42 * Message phase code was broken, now fixed and the booter now works. | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
43 * |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
44 * 5 2012/11/05-06 Gene Heskett |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
45 * SDMPI from defs/scsi.d is being ignored, so boot failed is the message. |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
46 * Ded the object to fix that AND the NULL bus address and this code broken. |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
47 * WhichDrv is now a zero based decimal value passed in by the makefile via ITDNS |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
48 * Thanks Boisy... |
2590 | 49 NAM Boot |
50 TTL SCSI Boot Module | |
51 | |
52 IFP1 | |
53 USE defsfile | |
54 USE rbsuper.d | |
55 USE scsi.d | |
56 ENDC | |
57 | |
58 tylg SET Systm+Objct | |
59 atrv SET ReEnt+rev | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
60 rev SET 1 |
2590 | 61 edition SET 4 |
62 | |
63 MOD eom,name,tylg,atrv,start,size | |
64 | |
65 SCSIEX EQU 1 | |
66 | |
67 * Data equates; subroutines must keep data in stack | |
68 IFNE SCSIEX | |
69 v$cmd RMB 1 | |
70 v$extra RMB 1 | |
71 v$addr0 RMB 1 | |
72 v$addr1 RMB 1 | |
73 v$addr2 RMB 1 | |
74 v$addr3 RMB 1 | |
75 v$resv RMB 1 | |
76 v$blks0 RMB 1 | |
77 v$blks1 RMB 1 | |
78 v$ctrl RMB 1 | |
79 ELSE | |
80 v$cmd RMB 1 | |
81 v$addr0 RMB 1 | |
82 v$addr1 RMB 2 | |
83 v$blks RMB 1 | |
84 v$opts RMB 1 | |
85 ENDC | |
86 seglist RMB 2 pointer to segment list | |
87 blockloc RMB 2 pointer to memory requested | |
88 blockimg RMB 2 duplicate of the above | |
89 bootloc RMB 3 sector pointer; not byte pointer | |
90 bootsize RMB 2 size in bytes | |
91 LSN0Ptr RMB 2 LSN0 pointer (used by boot_common.asm) | |
92 size EQU . | |
93 | |
94 name FCS /Boot/ | |
95 FCB edition | |
96 | |
97 * Common booter-required defines | |
98 LSN24BIT EQU 1 | |
99 FLOPPY EQU 0 | |
100 | |
101 | |
102 USE boot_common.asm | |
103 | |
104 ************************************************************ | |
105 ************************************************************ | |
106 * Hardware-Specific Booter Area * | |
107 ************************************************************ | |
108 ************************************************************ | |
109 | |
110 * HWInit - Initialize the device | |
111 * Entry: Y = hardware address | |
112 * Exit: Carry Clear = OK, Set = Error | |
113 * B = error (Carry Set) | |
114 HWInit | |
115 clr >$FF40 stop the disk motors | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
116 * IFNE D4N1+HDII ?????? |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
117 IFNE MPI |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
118 leax CntlSlot,pcr point at byte with MPI slot in it |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
119 lda ,x get it |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
120 sta MPI.Slct and set the MPI to us. |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
121 ENDC But this was NOT being done. |
2590 | 122 ldd #S$SEEK*256 |
123 ldx #0 | |
124 bsr setup | |
125 IFEQ SCSIEX | |
126 clr v$blks,u | |
127 ENDC | |
128 bra command | |
129 | |
130 * Sets up the SCSI packet to send | |
131 * Destroys B | |
132 setup sta v$cmd,u | |
133 IFNE SCSIEX | |
134 clr v$extra,u | |
135 clr v$addr0,u | |
136 stb v$addr1,u | |
137 stx v$addr2,u | |
138 clr v$resv,u | |
139 clr v$blks0,u | |
140 ldb #1 | |
141 stb v$blks1,u | |
142 clr v$ctrl,u | |
143 ELSE | |
144 stb v$addr0,u | |
145 stx v$addr1,u | |
146 ldb #1 | |
147 stb v$blks,u | |
148 clr v$opts,u | |
149 ENDC | |
150 rts | |
151 | |
2886
fea5c20fdbfe
Various whitespace fixups
Tormod Volden <debian.tormod@gmail.com>
parents:
2885
diff
changeset
|
152 * Sooooo, at end of module, the FF64XX, the XX is not a marching bit |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
153 * pattern any more. Cool but a huge gotcha needing makefile changes |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
154 * all over. And theres too many of them. |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
155 |
2590 | 156 scsival FCB $80+1,$80+2,$80+4,$80+8,$80+16,$80+32,$80+64,$80 |
157 | |
158 * SCSI Wake-Up Routine | |
159 * Destroys: X | |
160 wakeup ldx #0 load X with 0 (counter) | |
161 * Step 1: Wait for BUSY+SEL to be clear | |
162 wake lda SCSISTAT,y obtain SCSI status byte | |
163 bita #BUSY BUSY clear? | |
164 beq wake1 branch if so | |
165 leax -1,x else count down | |
166 bne wake and try again if not timed out | |
167 bra wake4 else branch to timeout | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
168 * Aha! New code! so ITDRV goes down one count |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
169 * Nice we get a notice. ChangeLog's would be nice |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
170 * But are a pain in the ass to maintain. |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
171 |
2590 | 172 * Step 2: Put our SCSI ID on the bus |
173 wake1 bsr wake3 small delay | |
174 lda WhichDrv,pcr get SCSI ID | |
175 leax <scsival,pcr point to SCSI value table | |
176 lda a,x get appropriate bitmask | |
177 sta SCSIDATA,y put on SCSI bus | |
178 bsr wake3 small delay | |
179 sta SCSISEL,y and select | |
180 ldx #0 load X with 0 (counter) | |
181 wake2 lda SCSISTAT,y obtain SCSI status byte | |
182 bita #BUSY BUSY set? | |
183 bne wake3 if so, exit without error | |
184 leax -1,x else count down | |
185 bne wake2 and try again if not timed out | |
186 wake4 comb set carry | |
187 ldb #E$NotRdy and load error | |
188 wake3 rts then return | |
189 | |
190 | |
191 * HWRead - Read a 256 byte sector from the device | |
192 * Entry: Y = hardware address | |
193 * B = bits 23-16 of LSN | |
194 * X = bits 15-0 of LSN | |
195 * blockloc,u = ptr to 256 byte sector | |
196 * Exit: X = ptr to data (i.e. ptr in blockloc,u) | |
197 HWRead lda #S$READEX | |
198 bsr setup | |
199 * SCSI Send Command Routine | |
200 command bsr wakeup tell SCSI we want the bus | |
201 bcs wake3 return immediately if error | |
202 leax v$cmd,u | |
203 bsr SCSISend | |
204 bcs command | |
205 bsr Wait4REQ | |
206 bita #CMD | |
207 bne getsta | |
208 ldx blockloc,u | |
209 bsr read | |
210 getsta bsr Wait4REQ | |
211 lda SCSIDATA,y | |
212 anda #%00001111 | |
213 pshs a | |
214 bsr Wait4REQ | |
215 clra | |
216 sta SCSIDATA,y | |
217 puls a | |
218 bita #X$BUSY | |
219 bne command | |
220 bita #X$ERROR | |
221 beq HWTerm | |
222 reterr comb | |
223 ldb #E$Unit | |
224 rts | |
225 | |
226 * HWTerm - Terminate the device | |
227 * Entry: Y = hardware address | |
228 * Exit: Carry Clear = OK, Set = Error | |
229 * B = error (Carry Set) | |
230 HWTerm clrb | |
231 rts | |
232 | |
233 SCSISend bsr Wait4REQ | |
234 bita #CMD | |
235 beq HWTerm | |
236 bita #INOUT | |
237 bne ckmsg | |
238 lda ,x+ | |
239 sta SCSIDATA,y | |
240 bra SCSISend | |
241 ckmsg bita #MSG MESSAGE IN (target->initiator) | |
242 beq HWTerm | |
243 lda SCSIDATA,y extended message? | |
244 deca | |
245 * | |
246 * MESSAGE IN phase code | |
247 * | |
248 bne SCSISend | |
249 ldb SCSIDATA,y get extended message length | |
250 l@ tst SCSIDATA,y read extended message | |
251 decb | |
252 bne l@ | |
253 bra reterr return with carry set | |
254 | |
255 Wait4REQ | |
256 loop@ lda SCSISTAT,y | |
257 bita #REQ | |
258 beq loop@ | |
259 rts | |
260 | |
261 * Patch to allow booting from sector sizes > 256 bytes - BGP 08/16/97 | |
262 * We ignore any bytes beyond byte 256, but continue to read them from | |
263 * the SCSIDATA until the CMD bit is set. | |
264 read | |
265 * next 2 lines added | |
266 clrb +++ use B as counter | |
267 read2 | |
268 bsr Wait4REQ | |
269 bita #CMD | |
270 bne HWTerm | |
271 lda SCSIDATA,y | |
272 sta ,x+ | |
273 * next line commented out and next 8 lines added | |
274 * bra read | |
275 incb +++ | |
276 bne read2 +++ | |
277 leax -256,x | |
278 read3 | |
279 bsr Wait4REQ +++ | |
280 bita #CMD +++ | |
281 bne HWTerm +++ | |
282 lda SCSIDATA,y +++ | |
283 bra read3 +++ | |
284 | |
285 | |
286 IFGT Level-1 | |
287 * Fillers to get to $1D0 | |
288 Pad FILL $39,$1D0-3-1-2-1-* | |
289 ENDC | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
290 * rev1, add selections for MPI slot and bus address of drive |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
291 * 2012\11\05 Gene Heskett |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
292 * The default SCSI ID is here, but first do MPI slot |
2885
66a8466f067c
boot_scsi.asm: Fix whitespace
Tormod Volden <debian.tormod@gmail.com>
parents:
2730
diff
changeset
|
293 IFEQ MPI-1 |
66a8466f067c
boot_scsi.asm: Fix whitespace
Tormod Volden <debian.tormod@gmail.com>
parents:
2730
diff
changeset
|
294 CntlSlot FCB SDMPI |
66a8466f067c
boot_scsi.asm: Fix whitespace
Tormod Volden <debian.tormod@gmail.com>
parents:
2730
diff
changeset
|
295 ELSE |
2887
a1296ceb6797
boot_scsi.asm: Remove misplaced # in CntrSlot FCB constant
Tormod Volden <debian.tormod@gmail.com>
parents:
2886
diff
changeset
|
296 CntrSlot FCB $FF |
2885
66a8466f067c
boot_scsi.asm: Fix whitespace
Tormod Volden <debian.tormod@gmail.com>
parents:
2730
diff
changeset
|
297 ENDC |
66a8466f067c
boot_scsi.asm: Fix whitespace
Tormod Volden <debian.tormod@gmail.com>
parents:
2730
diff
changeset
|
298 Address FDB SDAddr |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2590
diff
changeset
|
299 * So now, this can be a base zero decimal value! |
2894
23b4069ef1ab
boot_scsi.asm: Fix SCSI ID when booting, part two
Tormod Volden <debian.tormod@gmail.com>
parents:
2884
diff
changeset
|
300 IFNDEF ITDNS |
23b4069ef1ab
boot_scsi.asm: Fix SCSI ID when booting, part two
Tormod Volden <debian.tormod@gmail.com>
parents:
2884
diff
changeset
|
301 ITDNS EQU 0 |
23b4069ef1ab
boot_scsi.asm: Fix SCSI ID when booting, part two
Tormod Volden <debian.tormod@gmail.com>
parents:
2884
diff
changeset
|
302 ENDC |
2885
66a8466f067c
boot_scsi.asm: Fix whitespace
Tormod Volden <debian.tormod@gmail.com>
parents:
2730
diff
changeset
|
303 WhichDrv FCB ITDNS |
66a8466f067c
boot_scsi.asm: Fix whitespace
Tormod Volden <debian.tormod@gmail.com>
parents:
2730
diff
changeset
|
304 EMOD |
2590 | 305 eom EQU * |
2885
66a8466f067c
boot_scsi.asm: Fix whitespace
Tormod Volden <debian.tormod@gmail.com>
parents:
2730
diff
changeset
|
306 END |