srt0.S revision 1.7 1 /* $NetBSD: srt0.S,v 1.7 1999/07/31 17:20:22 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1982, 1990, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the University of
23 * California, Berkeley and its contributors.
24 * 4. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 * from: Utah $Hdr: srt0.c 1.18 92/12/21$
41 *
42 * @(#)srt0.c 8.1 (Berkeley) 6/10/93
43 */
44
45 /*
46 * Startup code for standalone system
47 */
48
49 /* For machineid and mmuid constants */
50 #include <machine/hp300spu.h>
51
52 /* For _C_LABEL() and friends. */
53 #include <machine/asm.h>
54
55 STACK = 0xfffff000 | below the ROM page
56 BOOTTYPE = 0xfffffdc0
57 LOWRAM = 0xfffffdce
58 SYSFLAG = 0xfffffed2 | system flags
59 MSUS = 0xfffffedc | MSUS (?) structure
60 VECTORS = 0xfffffee0 | beginning of jump vectors
61 NMIRESET = 0xffffff9c | reset vector
62 BUSERR = 0xfffffffc
63 MAXADDR = 0xfffff000
64 NBPG = 4096
65 MMUCMD = 0x005f400c | MMU command/status register
66
67 .data
68 GLOBAL(bootdev)
69 .long 0
70
71 GLOBAL(howto)
72 .long 0
73
74 GLOBAL(lowram)
75 .long 0
76
77 GLOBAL(machineid)
78 .long 0
79
80 GLOBAL(mmuid)
81 .long 0
82
83 .text
84 ASENTRY_NOPROFILE(begin)
85 movl #STACK,sp
86 moveq #47,d0 | # of vectors - 1
87 movl #VECTORS+2,a0 | addr part of first vector
88 1:
89 movl #_ASM_LABEL(__trap),a0@ | make it direct to __trap
90 addql #6,a0 | move to next vector addr
91 dbf d0,1b | go til done
92 movl #NMIRESET,a0 | NMI keyboard reset addr
93 movl #nmi,a0@ | catch in reset routine
94
95 /*
96 * Determine our SPU type and look for internal HP-IB
97 */
98 lea _C_LABEL(machineid),a0
99 movl #0x808,d0
100 movc d0,cacr | clear and disable on-chip cache(s)
101 movl #0x200,d0 | data freeze bit
102 movc d0,cacr | only exists on 68030
103 movc cacr,d0 | read it back
104 tstl d0 | zero?
105 jeq not68030 | yes, we have 68020/68040
106
107 movl #0x808,d0
108 movc d0,cacr | clear data freeze bit again
109
110 /*
111 * 68030 models
112 */
113
114 movl #0x80,MMUCMD | set magic cookie
115 movl MMUCMD,d0 | read it back
116 btst #7,d0 | cookie still on?
117 jeq not370 | no, 360 or 375
118 movl #HP_370,a0@ | consider a 370 for now
119 movl #0,MMUCMD | clear magic cookie
120 movl MMUCMD,d0 | read it back
121 btst #7,d0 | still on?
122 jeq ihpibcheck | no, a 370
123 movl #HP_340,a0@ | yes, must be a 340
124 jra ihpibcheck
125
126 not370:
127 movl #HP_360,a0@ | type is at least a 360
128 movl #0,MMUCMD | clear magic cookie2
129 movl MMUCMD,d0 | read it back
130 btst #16,d0 | still on?
131 jeq ihpibcheck | no, a 360
132 lea _C_LABEL(mmuid),a0
133 lsrl #MMUID_SHIFT,d0 | save MMU ID
134 andl #MMUID_MASK,d0
135 movl d0,a0@
136 lea _C_LABEL(machineid),a0
137 cmpb #MMUID_345,d0 | are we a 345?
138 jeq isa345
139 cmpb #MMUID_375,d0 | how about a 375?
140 jeq isa375
141 movl #HP_400,a0@ | must be a 400
142 jra ihpibcheck
143 isa345:
144 movl #HP_345,a0@
145 jra ihpibcheck
146 isa375:
147 movl #HP_375,a0@
148 jra ihpibcheck
149
150 /*
151 * End of 68030 section
152 */
153
154 not68030:
155 bset #31,d0 | data cache enable bit
156 movc d0,cacr | only exists on 68040
157 movc cacr,d0 | read it back
158 tstl d0 | zero?
159 beq is68020 | yes, we have 68020
160 moveq #0,d0 | now turn it back off
161 movec d0,cacr | before we access any data
162
163 .long 0x4e7b0004 | movc d0,itt0
164 .long 0x4e7b0005 | movc d0,itt1
165 .long 0x4e7b0006 | movc d0,dtt0
166 .long 0x4e7b0007 | movc d0,dtt1
167 .word 0xf4d8 | cinva bc
168
169 /*
170 * 68040 models
171 */
172
173 lea _C_LABEL(mmuid),a0
174 movl MMUCMD,d0 | get MMU ID
175 lsrl #MMUID_SHIFT,d0
176 andl #MMUID_MASK,d0
177 movl d0,a0@ | save it
178 lea _C_LABEL(machineid),a0
179 cmpb #MMUID_425_T,d0 | are we a 425t?
180 jeq isa425
181 cmpb #MMUID_425_S,d0 | how about 425s?
182 jeq isa425
183 cmpb #MMUID_425_E,d0 | or maybe a 425e?
184 jeq isa425
185 cmpb #MMUID_433_T,d0 | or a 433t?
186 jeq isa433
187 cmpb #MMUID_433_S,d0 | or a 433s?
188 jeq isa433
189 cmpb #MMUID_385,d0 | or a 385?
190 jeq isa385
191 movl #HP_380,a0@ | guess we are a 380
192 jra ihpibcheck
193 isa425:
194 movl #HP_425,a0@
195 jra ihpibcheck
196 isa433:
197 movl #HP_433,a0@
198 jra ihpibcheck
199 isa385:
200 movl #HP_385,a0@
201 jra ihpibcheck
202
203 /*
204 * End 68040 section
205 */
206
207 /*
208 * 68020 models
209 */
210
211 is68020:
212 movl #HP_330,a0@ | consider a 330 for now
213 movl #1,MMUCMD | a 68020, write HP MMU location
214 movl MMUCMD,d0 | read it back
215 btst #0,d0 | zero?
216 jeq ihpibcheck | yes, a 330
217 movl #HP_320,a0@ | no, consider a 320 for now
218 movl #0x80,MMUCMD | set magic cookie
219 movl MMUCMD,d0 | read it back
220 btst #7,d0 | cookie still on?
221 jeq ihpibcheck | no, just a 320
222 movl #HP_350,a0@ | yes, a 350
223
224 /*
225 * End 68020 section
226 */
227
228 ihpibcheck:
229 movl #0,MMUCMD | make sure MMU is off
230 btst #5,SYSFLAG | do we have an internal HP-IB?
231 jeq boottype | yes, continue
232 clrl _C_LABEL(internalhpib) | no, clear the internal address
233 /*
234 * If this is a reboot, extract howto/bootdev stored by kernel
235 */
236 boottype:
237 cmpw #12,BOOTTYPE | is this a reboot (REQ_REBOOT)?
238 jne notreboot | no, skip
239 lea MAXADDR,a0 | find last page
240 movl a0@+,d7 | and extract howto, bootdev
241 movl a0@+,d6 | from where doboot() left them
242 jra boot1
243 /*
244 * At this point we do not know which logical device the MSUS select
245 * code refers to so we cannot construct bootdev. So we just punt
246 * and let configure() construct it.
247 */
248 notreboot:
249 moveq #0,d6 | make sure bootdev is invalid
250 cmpw #18,BOOTTYPE | does the user want to interact?
251 jeq askme | yes, go to it
252 moveq #0,d7 | default to RB_AUTOBOOT
253 jra boot1
254 askme:
255 moveq #3,d7 | default to RB_SINGLE|RB_ASKNAME
256 boot1:
257 movl d6,_C_LABEL(bootdev) | save bootdev and howto
258 movl d7,_C_LABEL(howto) | globally so all can access
259 movl LOWRAM,d0 | read lowram value from bootrom
260 /*
261 * Must preserve the scratch area for the BOOT ROM.
262 * Round up to the next 8k boundary.
263 */
264 addl #((2*NBPG)-1),d0
265 andl #-(2*NBPG),d0
266 movl d0,_C_LABEL(lowram) | stash that value
267 start:
268 movl #_C_LABEL(edata),a2 | start of BSS
269 movl #_C_LABEL(end),a3 | end
270 1:
271 clrb a2@+ | clear BSS
272 cmpl a2,a3 | done?
273 bne 1b | no, keep going
274 jsr _C_LABEL(configure) | configure critical devices
275 jsr _C_LABEL(main) | lets go
276 GLOBAL(_rtt)
277 movl #3,_C_LABEL(howto) | restarts get RB_SINGLE|RB_ASKNAME
278 jmp start
279
280 /*
281 * probe a location and see if it causes a bus error
282 */
283 ENTRY_NOPROFILE(badaddr)
284 movl BUSERR,_C_LABEL(_bsave) | save ROM bus error handler address
285 movl sp,_C_LABEL(_ssave) | and current stack pointer
286 movl #catchbad,BUSERR | plug in our handler
287 movl sp@(4),a0 | address to probe
288 movw a0@,d1 | do it
289 movl _C_LABEL(_bsave),BUSERR | if we got here, it did not fault
290 clrl d0 | return that this was not a bad addr
291 rts
292
293 catchbad:
294 movl _C_LABEL(_bsave),BUSERR | got a bus error, so restore
295 | old handler
296 movl _C_LABEL(_ssave),sp | manually restore stack
297 moveq #1,d0 | indicate that we got a fault
298 rts | return to caller of badaddr()
299
300 .data
301 GLOBAL(_bsave)
302 .long 0
303
304 GLOBAL(_ssave)
305 .long 0
306
307 ASENTRY_NOPROFILE(__trap)
308 moveml #0xFFFF,sp@- | save registers
309 movl sp,sp@- | push pointer to frame
310 jsr _C_LABEL(trap) | call C routine to deal with it
311 tstl d0
312 jeq Lstop
313 addql #4,sp
314 moveml sp@+,#0x7FFF
315 addql #8,sp
316 rte
317 Lstop:
318 stop #0x2700 | stop cold
319
320 ASENTRY_NOPROFILE(nmi)
321 movw #18,BOOTTYPE | mark as system switch
322 jsr _C_LABEL(kbdnmi) | clear the interrupt, and
323 | reset the system
324 stop #0 | SCREEEECH!
325
326 ENTRY_NOPROFILE(call_req_reboot)
327 jmp 0x1A4 | call ROM reboot function
328 rts | XXX: just in case?
329
330 ENTRY_NOPROFILE(romout)
331 movl sp@(4),d0 | line number
332 movl sp@(8),a0 | string
333 jsr 0x150 | do it
334 rts
335