1 /* $NetBSD: srt0.S,v 1.14 2006/07/19 19:29:02 tsutsui Exp $ */
4 * Copyright (c) 1982, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * from: Utah $Hdr: srt0.c 1.18 92/12/21$
37 * @(#)srt0.c 8.1 (Berkeley) 6/10/93
40 * Copyright (c) 1988 University of Utah.
42 * This code is derived from software contributed to Berkeley by
43 * the Systems Programming Group of the University of Utah Computer
46 * Redistribution and use in source and binary forms, with or without
47 * modification, are permitted provided that the following conditions
49 * 1. Redistributions of source code must retain the above copyright
50 * notice, this list of conditions and the following disclaimer.
51 * 2. Redistributions in binary form must reproduce the above copyright
52 * notice, this list of conditions and the following disclaimer in the
53 * documentation and/or other materials provided with the distribution.
54 * 3. All advertising materials mentioning features or use of this software
55 * must display the following acknowledgement:
56 * This product includes software developed by the University of
57 * California, Berkeley and its contributors.
58 * 4. Neither the name of the University nor the names of its contributors
59 * may be used to endorse or promote products derived from this software
60 * without specific prior written permission.
62 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
74 * from: Utah $Hdr: srt0.c 1.18 92/12/21$
76 * @(#)srt0.c 8.1 (Berkeley) 6/10/93
80 * Startup code for standalone system
83 /* For machineid and mmuid constants */
84 #include <machine/hp300spu.h>
86 /* For _C_LABEL() and friends. */
87 #include <machine/asm.h>
89 STACK = 0xfffff000 /* below the ROM page */
92 SYSFLAG = 0xfffffed2 /* system flags */
93 MSUS = 0xfffffedc /* MSUS (?) structure */
94 VECTORS = 0xfffffee0 /* beginning of jump vectors */
95 NMIRESET = 0xffffff9c /* reset vector */
99 MMUCMD = 0x005f400c /* MMU command/status register */
118 ASENTRY_NOPROFILE(begin)
120 moveq #47,%d0 /* # of vectors - 1 */
121 movl #VECTORS+2,%a0 /* addr part of first vector */
123 movl #_ASM_LABEL(__trap),%a0@ /* make it direct to __trap */
124 addql #6,%a0 /* move to next vector addr */
125 dbf %d0,1b /* go til done */
127 movl #NMIRESET,%a0 /* NMI keyboard reset addr */
128 movl #nmi,%a0@ /* catch in reset routine */
131 * Built without ITE console support; leave the ROM's NMI
132 * vector in place, so the system will still reset if a
133 * keyboard NMI is issued.
138 * Determine our SPU type and look for internal HP-IB
140 lea _C_LABEL(machineid),%a0
142 movc %d0,%cacr /* clear and disable on-chip cache(s) */
143 movl #0x200,%d0 /* data freeze bit */
144 movc %d0,%cacr /* only exists on 68030 */
145 movc %cacr,%d0 /* read it back */
147 jeq not68030 /* yes, we have 68020/68040 */
154 movc %d0,%cacr /* clear data freeze bit again */
156 movl #0x80,MMUCMD /* set magic cookie */
157 movl MMUCMD,%d0 /* read it back */
158 btst #7,%d0 /* cookie still on? */
159 jeq not370 /* no, 360, 362 or 375 */
160 movl #HP_370,%a0@ /* consider a 370 for now */
161 movl #0,MMUCMD /* clear magic cookie */
162 movl MMUCMD,%d0 /* read it back */
163 btst #7,%d0 /* still on? */
164 jeq ihpibcheck /* no, a 370 */
165 movl #HP_340,%a0@ /* yes, must be a 340 */
169 movl #HP_360,%a0@ /* type is at least a 360 */
170 movl #0,MMUCMD /* clear magic cookie2 */
171 movl MMUCMD,%d0 /* read it back */
172 btst #16,%d0 /* still on? */
173 jeq isa36x /* no, a 360 or a 362 */
174 lea _C_LABEL(mmuid),%a0
175 lsrl #MMUID_SHIFT,%d0 /* save MMU ID */
178 lea _C_LABEL(machineid),%a0
179 cmpb #MMUID_345,%d0 /* are we a 345? */
181 cmpb #MMUID_375,%d0 /* how about a 375? */
183 movl #HP_400,%a0@ /* must be a 400 */
186 movl #0x41c000,%sp@- /* check (INTIOBASE + FRODO_BASE) */
187 jbsr _C_LABEL(badaddr)
191 lea _C_LABEL(machineid),%a0
202 * End of 68030 section
206 bset #31,%d0 /* data cache enable bit */
207 movc %d0,%cacr /* only exists on 68040 */
208 movc %cacr,%d0 /* read it back */
210 beq is68020 /* yes, we have 68020 */
216 moveq #0,%d0 /* now turn it back off */
217 movec %d0,%cacr /* before we access any data */
219 .long 0x4e7b0004 /* movc %d0,%itt0 */
220 .long 0x4e7b0005 /* movc %d0,%itt1 */
221 .long 0x4e7b0006 /* movc %d0,%dtt0 */
222 .long 0x4e7b0007 /* movc %d0,%dtt1 */
223 .word 0xf4d8 /* cinva bc */
225 lea _C_LABEL(mmuid),%a0
226 movl MMUCMD,%d0 /* get MMU ID */
227 lsrl #MMUID_SHIFT,%d0
229 movl %d0,%a0@ /* save it */
230 lea _C_LABEL(machineid),%a0
231 cmpb #MMUID_425_T,%d0 /* are we a 425t? */
233 cmpb #MMUID_425_S,%d0 /* how about 425s? */
235 cmpb #MMUID_425_E,%d0 /* or maybe a 425e? */
237 cmpb #MMUID_433_T,%d0 /* or a 433t? */
239 cmpb #MMUID_433_S,%d0 /* or a 433s? */
241 cmpb #MMUID_385,%d0 /* or a 385? */
243 cmpb #MMUID_382,%d0 /* or a 382? */
245 movl #HP_380,%a0@ /* guess we are a 380 */
269 movl #HP_330,%a0@ /* consider a 330 for now */
270 movl #1,MMUCMD /* a 68020, write HP MMU location */
271 movl MMUCMD,%d0 /* read it back */
272 btst #0,%d0 /* zero? */
273 jeq ihpibcheck /* yes, a 330 */
274 movl #HP_320,%a0@ /* no, consider a 320 for now */
275 movl #0x80,MMUCMD /* set magic cookie */
276 movl MMUCMD,%d0 /* read it back */
277 btst #7,%d0 /* cookie still on? */
278 jeq ihpibcheck /* no, just a 320 */
279 movl #HP_350,%a0@ /* yes, a 350 */
286 movl #0,MMUCMD /* make sure MMU is off */
287 btst #5,SYSFLAG /* do we have an internal HP-IB? */
288 jeq boottype /* yes, continue */
289 clrl _C_LABEL(internalhpib) /* no, clear the internal address */
291 * If this is a reboot, extract howto/bootdev stored by kernel
294 cmpw #12,BOOTTYPE /* is this a reboot (REQ_REBOOT)? */
295 jne notreboot /* no, skip */
296 lea MAXADDR,%a0 /* find last page */
297 movl %a0@+,%d7 /* and extract howto, bootdev */
298 movl %a0@+,%d6 /* from where doboot() left them */
301 * At this point we do not know which logical device the MSUS select
302 * code refers to so we cannot construct bootdev. So we just punt
303 * and let configure() construct it.
306 moveq #0,%d6 /* make sure bootdev is invalid */
307 cmpw #18,BOOTTYPE /* does the user want to interact? */
308 jeq askme /* yes, go to it */
309 moveq #0,%d7 /* default to RB_AUTOBOOT */
312 moveq #3,%d7 /* default to RB_SINGLE|RB_ASKNAME */
314 movl %d6,_C_LABEL(bootdev) /* save bootdev and howto */
315 movl %d7,_C_LABEL(howto) /* globally so all can access */
316 movl LOWRAM,%d0 /* read lowram value from bootrom */
318 * Must preserve the scratch area for the BOOT ROM.
319 * Round up to the next 8k boundary.
321 addl #((2*NBPG)-1),%d0
323 movl %d0,_C_LABEL(lowram) /* stash that value */
325 movl #_C_LABEL(edata),%a2 /* start of BSS */
326 movl #_C_LABEL(end),%a3 /* end */
328 clrb %a2@+ /* clear BSS */
329 cmpl %a2,%a3 /* done? */
330 bne 1b /* no, keep going */
331 jsr _C_LABEL(configure) /* configure critical devices */
332 jsr _C_LABEL(main) /* lets go */
334 movl #3,_C_LABEL(howto) /* restarts get RB_SINGLE|RB_ASKNAME */
338 * probe a location and see if it causes a bus error
340 ENTRY_NOPROFILE(badaddr)
341 movl BUSERR,_C_LABEL(_bsave) /* save ROM bus error handler address */
342 movl %sp,_C_LABEL(_ssave) /* and current stack pointer */
343 movl #catchbad,BUSERR /* plug in our handler */
344 movl %sp@(4),%a0 /* address to probe */
345 movw %a0@,%d1 /* do it */
346 movl _C_LABEL(_bsave),BUSERR /* if we got here, it did not fault */
347 clrl %d0 /* return that this was not a bad */
352 movl _C_LABEL(_bsave),BUSERR /* got a bus error, so restore */
354 movl _C_LABEL(_ssave),%sp /* manually restore stack */
355 moveq #1,%d0 /* indicate that we got a fault */
356 rts /* return to caller of badaddr() */
365 ASENTRY_NOPROFILE(__trap)
366 moveml #0xFFFF,%sp@- /* save registers */
367 movl %sp,%sp@- /* push pointer to frame */
368 jsr _C_LABEL(trap) /* call C routine to deal with it */
376 stop #0x2700 /* stop cold */
379 ASENTRY_NOPROFILE(nmi)
380 movw #18,BOOTTYPE /* mark as system switch */
381 jsr _C_LABEL(kbdnmi) /* clear the interrupt, and */
382 /* reset the system */
383 stop #0 /* SCREEEECH! */
386 ENTRY_NOPROFILE(call_req_reboot)
387 jmp 0x1A4 /* call ROM reboot function */
388 rts /* XXX: just in case? */
390 ENTRY_NOPROFILE(romout)
391 movl %sp@(4),%d0 /* line number */
392 movl %sp@(8),%a0 /* string */
393 jsr 0x150 /* do it */
397 * _transfer(entry, howto, opendev, conscode, lowram, esym)
399 * Transfer control to the kernel. We also set up registers
400 * as older kernels expect.
402 ENTRY_NOPROFILE(_transfer)
403 movl %sp@(8),%d7 /* howto */
404 movl %sp@(12),%d6 /* opendev (compat) */
405 movl %sp@(16),%d5 /* conscode (compat) */
406 movl %sp@(20),%a5 /* lowram */
407 movl %sp@(24),%a4 /* esym (compat) */
409 movl %sp@(4),%a0 /* load entry point */