srt0.S revision 1.5 1 /* $NetBSD: srt0.S,v 1.5 1999/02/08 10:45:11 he 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 .text
81 ASENTRY_NOPROFILE(begin)
82 movl #STACK,sp
83 moveq #47,d0 | # of vectors - 1
84 movl #VECTORS+2,a0 | addr part of first vector
85 1:
86 movl #_ASM_LABEL(__trap),a0@ | make it direct to __trap
87 addql #6,a0 | move to next vector addr
88 dbf d0,1b | go til done
89 movl #NMIRESET,a0 | NMI keyboard reset addr
90 movl #nmi,a0@ | catch in reset routine
91
92 /*
93 * Determine our SPU type and look for internal HP-IB
94 */
95 lea _C_LABEL(machineid),a0
96 movl #0x808,d0
97 movc d0,cacr | clear and disable on-chip cache(s)
98 movl #0x200,d0 | data freeze bit
99 movc d0,cacr | only exists on 68030
100 movc cacr,d0 | read it back
101 tstl d0 | zero?
102 jeq not68030 | yes, we have 68020/68040
103
104 movl #0x808,d0
105 movc d0,cacr | clear data freeze bit again
106
107 /*
108 * 68030 models
109 */
110
111 movl #0x80,MMUCMD | set magic cookie
112 movl MMUCMD,d0 | read it back
113 btst #7,d0 | cookie still on?
114 jeq not370 | no, 360 or 375
115 movl #HP_370,a0@ | consider a 370 for now
116 movl #0,MMUCMD | clear magic cookie
117 movl MMUCMD,d0 | read it back
118 btst #7,d0 | still on?
119 jeq ihpibcheck | no, a 370
120 movl #HP_340,a0@ | yes, must be a 340
121 jra ihpibcheck
122
123 not370:
124 movl #HP_360,a0@ | type is at least a 360
125 movl #0,MMUCMD | clear magic cookie2
126 movl MMUCMD,d0 | read it back
127 btst #16,d0 | still on?
128 jeq ihpibcheck | no, a 360
129 lsrl #MMUID_SHIFT,d0 | save MMU ID
130 andl #MMUID_MASK,d0
131 cmpb #MMUID_345,d0 | are we a 345?
132 jeq isa345
133 cmpb #MMUID_375,d0 | how about a 375?
134 jeq isa375
135 movl #HP_400,a0@ | must be a 400
136 jra ihpibcheck
137 isa345:
138 movl #HP_345,a0@
139 jra ihpibcheck
140 isa375:
141 movl #HP_375,a0@
142 jra ihpibcheck
143
144 /*
145 * End of 68030 section
146 */
147
148 not68030:
149 bset #31,d0 | data cache enable bit
150 movc d0,cacr | only exists on 68040
151 movc cacr,d0 | read it back
152 tstl d0 | zero?
153 beq is68020 | yes, we have 68020
154 moveq #0,d0 | now turn it back off
155 movec d0,cacr | before we access any data
156
157 .long 0x4e7b0004 | movc d0,itt0
158 .long 0x4e7b0005 | movc d0,itt1
159 .long 0x4e7b0006 | movc d0,dtt0
160 .long 0x4e7b0007 | movc d0,dtt1
161 .word 0xf4d8 | cinva bc
162
163 /*
164 * 68040 models
165 */
166
167 movl MMUCMD,d0 | get MMU ID
168 lsrl #MMUID_SHIFT,d0
169 andl #MMUID_MASK,d0
170 cmpb #MMUID_425_T,d0 | are we a 425t?
171 jeq isa425
172 cmpb #MMUID_425_S,d0 | how about 425s?
173 jeq isa425
174 cmpb #MMUID_433_T,d0 | or a 433t?
175 jeq isa433
176 cmpb #MMUID_433_S,d0 | last chance...
177 jeq isa433
178 movl #HP_380,a0@ | guess we are a 380
179 jra ihpibcheck
180 isa425:
181 movl #HP_425,a0@
182 jra ihpibcheck
183 isa433:
184 movl #HP_433,a0@
185 jra ihpibcheck
186
187 /*
188 * End 68040 section
189 */
190
191 /*
192 * 68020 models
193 */
194
195 is68020:
196 movl #HP_330,a0@ | consider a 330 for now
197 movl #1,MMUCMD | a 68020, write HP MMU location
198 movl MMUCMD,d0 | read it back
199 btst #0,d0 | zero?
200 jeq ihpibcheck | yes, a 330
201 movl #HP_320,a0@ | no, consider a 320 for now
202 movl #0x80,MMUCMD | set magic cookie
203 movl MMUCMD,d0 | read it back
204 btst #7,d0 | cookie still on?
205 jeq ihpibcheck | no, just a 320
206 movl #HP_350,a0@ | yes, a 350
207
208 /*
209 * End 68020 section
210 */
211
212 ihpibcheck:
213 movl #0,MMUCMD | make sure MMU is off
214 btst #5,SYSFLAG | do we have an internal HP-IB?
215 jeq boottype | yes, continue
216 clrl _C_LABEL(internalhpib) | no, clear the internal address
217 /*
218 * If this is a reboot, extract howto/bootdev stored by kernel
219 */
220 boottype:
221 cmpw #12,BOOTTYPE | is this a reboot (REQ_REBOOT)?
222 jne notreboot | no, skip
223 lea MAXADDR,a0 | find last page
224 movl a0@+,d7 | and extract howto, bootdev
225 movl a0@+,d6 | from where doboot() left them
226 jra boot1
227 /*
228 * At this point we do not know which logical device the MSUS select
229 * code refers to so we cannot construct bootdev. So we just punt
230 * and let configure() construct it.
231 */
232 notreboot:
233 moveq #0,d6 | make sure bootdev is invalid
234 cmpw #18,BOOTTYPE | does the user want to interact?
235 jeq askme | yes, go to it
236 moveq #0,d7 | default to RB_AUTOBOOT
237 jra boot1
238 askme:
239 moveq #3,d7 | default to RB_SINGLE|RB_ASKNAME
240 boot1:
241 movl d6,_C_LABEL(bootdev) | save bootdev and howto
242 movl d7,_C_LABEL(howto) | globally so all can access
243 movl LOWRAM,d0 | read lowram value from bootrom
244 /*
245 * Must preserve the scratch area for the BOOT ROM.
246 * Round up to the next 8k boundary.
247 */
248 addl #((2*NBPG)-1),d0
249 andl #-(2*NBPG),d0
250 movl d0,_C_LABEL(lowram) | stash that value
251 start:
252 movl #_C_LABEL(edata),a2 | start of BSS
253 movl #_C_LABEL(end),a3 | end
254 1:
255 clrb a2@+ | clear BSS
256 cmpl a2,a3 | done?
257 bne 1b | no, keep going
258 jsr _C_LABEL(configure) | configure critical devices
259 jsr _C_LABEL(main) | lets go
260 GLOBAL(_rtt)
261 movl #3,_C_LABEL(howto) | restarts get RB_SINGLE|RB_ASKNAME
262 jmp start
263
264 /*
265 * probe a location and see if it causes a bus error
266 */
267 ENTRY_NOPROFILE(badaddr)
268 movl BUSERR,_C_LABEL(_bsave) | save ROM bus error handler address
269 movl sp,_C_LABEL(_ssave) | and current stack pointer
270 movl #catchbad,BUSERR | plug in our handler
271 movl sp@(4),a0 | address to probe
272 movw a0@,d1 | do it
273 movl _C_LABEL(_bsave),BUSERR | if we got here, it did not fault
274 clrl d0 | return that this was not a bad addr
275 rts
276
277 catchbad:
278 movl _C_LABEL(_bsave),BUSERR | got a bus error, so restore
279 | old handler
280 movl _C_LABEL(_ssave),sp | manually restore stack
281 moveq #1,d0 | indicate that we got a fault
282 rts | return to caller of badaddr()
283
284 .data
285 GLOBAL(_bsave)
286 .long 0
287
288 GLOBAL(_ssave)
289 .long 0
290
291 ASENTRY_NOPROFILE(__trap)
292 moveml #0xFFFF,sp@- | save registers
293 movl sp,sp@- | push pointer to frame
294 jsr _C_LABEL(trap) | call C routine to deal with it
295 tstl d0
296 jeq Lstop
297 addql #4,sp
298 moveml sp@+,#0x7FFF
299 addql #8,sp
300 rte
301 Lstop:
302 stop #0x2700 | stop cold
303
304 ASENTRY_NOPROFILE(nmi)
305 movw #18,BOOTTYPE | mark as system switch
306 jsr _C_LABEL(kbdnmi) | clear the interrupt, and
307 | reset the system
308 stop #0 | SCREEEECH!
309
310 ENTRY_NOPROFILE(call_req_reboot)
311 jmp 0x1A4 | call ROM reboot function
312 rts | XXX: just in case?
313
314 ENTRY_NOPROFILE(romout)
315 movl sp@(4),d0 | line number
316 movl sp@(8),a0 | string
317 jsr 0x150 | do it
318 rts
319