|
|
1.1 root 1: /*
2: * Copyright (c) 1988 University of Utah.
3: * Copyright (c) 1982, 1990 The Regents of the University of California.
4: * All rights reserved.
5: *
6: * This code is derived from software contributed to Berkeley by
7: * the Systems Programming Group of the University of Utah Computer
8: * Science Department.
9: *
10: * Redistribution and use in source and binary forms, with or without
11: * modification, are permitted provided that the following conditions
12: * are met:
13: * 1. Redistributions of source code must retain the above copyright
14: * notice, this list of conditions and the following disclaimer.
15: * 2. Redistributions in binary form must reproduce the above copyright
16: * notice, this list of conditions and the following disclaimer in the
17: * documentation and/or other materials provided with the distribution.
18: * 3. All advertising materials mentioning features or use of this software
19: * must display the following acknowledgement:
20: * This product includes software developed by the University of
21: * California, Berkeley and its contributors.
22: * 4. Neither the name of the University nor the names of its contributors
23: * may be used to endorse or promote products derived from this software
24: * without specific prior written permission.
25: *
26: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36: * SUCH DAMAGE.
37: *
38: * from: Utah $Hdr: srt0.c 1.12 91/04/25$
39: *
1.1.1.2 ! root 40: * from: @(#)srt0.c 7.4 (Berkeley) 5/7/91
! 41: * srt0.c,v 1.2 1993/05/22 07:59:25 cgd Exp
1.1 root 42: */
43:
44: /*
45: * Startup code for standalone system
46: */
47:
48: .globl begin
49: .globl _end
50: .globl _edata
51: .globl _main
52: .globl _configure
53: .globl _bootdev
54: .globl _firstopen
55: .globl __rtt
56: .globl _lowram,_howto,_devtype,_internalhpib,_machineid
57:
58: STACK = 0xfffff000 | below the ROM page
59: BOOTTYPE = 0xfffffdc0
60: LOWRAM = 0xfffffdce
61: SYSFLAG = 0xfffffed2 | system flags
62: MSUS = 0xfffffedc | MSUS (?) structure
63: VECTORS = 0xfffffee0 | beginning of jump vectors
64: NMIRESET = 0xffffff9c | reset vector
65: BUSERR = 0xfffffffc
66: MAXADDR = 0xfffff000
67: NBPG = 4096
68: MMUCMD = 0x005f400c | MMU command/status register
69:
70: .data
71: _bootdev:
72: .long 0
73: _devtype:
74: .long 0
75: _howto:
76: .long 0
77: _lowram:
78: .long 0
79: _machineid:
80: .long 0
81:
82: .text
83: begin:
84: movl #STACK,sp
85: moveq #47,d0 | # of vectors - 1
86: movl #VECTORS+2,a0 | addr part of first vector
87: vecloop:
88: movl #trap,a0@ | make it direct to trap
89: addql #6,a0 | move to next vector addr
90: dbf d0,vecloop | go til done
91: movl #NMIRESET,a0 | NMI keyboard reset addr
92: movl #nmi,a0@ | catch in reset routine
93: /*
94: * Determine our CPU type and look for internal HP-IB
95: * (really only care about detecting 320 (no DIO-II) right now).
96: */
97: lea _machineid,a0
98: movl #0x808,d0
99: movc d0,cacr | clear and disable on-chip cache(s)
100: movl #0x200,d0 | data freeze bit
101: movc d0,cacr | only exists on 68030
102: movc cacr,d0 | read it back
103: tstl d0 | zero?
104: jeq is68020 | yes, we have 68020
105: movl #0x808,d0
106: movc d0,cacr | clear data freeze bit again
107: movl #0x80,MMUCMD | set magic cookie
108: movl MMUCMD,d0 | read it back
109: btst #7,d0 | cookie still on?
110: jeq not370 | no, 360 or 375
111: movl #4,a0@ | consider a 370 for now
112: movl #0,MMUCMD | clear magic cookie
113: movl MMUCMD,d0 | read it back
114: btst #7,d0 | still on?
115: jeq ihpibcheck | no, a 370
116: movl #5,a0@ | yes, must be a 340
117: jra ihpibcheck
118: not370:
119: movl #3,a0@ | type is at least a 360
120: movl #0,MMUCMD | clear magic cookie2
121: movl MMUCMD,d0 | read it back
122: btst #16,d0 | still on?
123: jeq ihpibcheck | no, a 360
124: movl #6,a0@ | yes, must be a 345/375/400
125: jra ihpibcheck
126: is68020:
127: movl #1,a0@ | consider a 330 for now
128: movl #1,MMUCMD | a 68020, write HP MMU location
129: movl MMUCMD,d0 | read it back
130: btst #0,d0 | zero?
131: jeq ihpibcheck | yes, a 330
132: movl #0,a0@ | no, consider a 320 for now
133: movl #0x80,MMUCMD | set magic cookie
134: movl MMUCMD,d0 | read it back
135: btst #7,d0 | cookie still on?
136: jeq ihpibcheck | no, just a 320
137: movl #2,a0@ | yes, a 350
138: ihpibcheck:
139: movl #0,MMUCMD | make sure MMU is off
140: btst #5,SYSFLAG | do we have an internal HP-IB?
141: jeq boottype | yes, continue
142: clrl _internalhpib | no, clear the internal address
143: /*
144: * If this is a reboot, extract howto/devtype stored by kernel
145: */
146: boottype:
147: cmpw #12,BOOTTYPE | is this a reboot (REQ_REBOOT)?
148: jne notreboot | no, skip
149: movl #MAXADDR,a0 | find last page
150: movl a0@+,d7 | and extract howto, devtype
151: movl a0@+,d6 | from where doboot() left them
152: jra boot1
153: /*
154: * At this point we do not know which logical hpib the given select
155: * code refers to. So we just put the select code in the adaptor field
156: * where hpibinit() can replace it with the logical hpib number.
157: * Note that this may clobber the B_DEVMAGIC field but that isn't set
158: * til later anyway.
159: */
160: notreboot:
161: cmpw #18,BOOTTYPE | does the user want to interact?
162: jeq askme | yes, go to it
163: movl MSUS,d1 | no, get rom info
164: movw d1,d6 | MSUS comes with SC in upper, unit in lower
165: swap d6 | put in place
166: movw #2,d6 | assume 'a' partition of rd disk
167: moveq #0,d7 | default to RB_AUTOBOOT
168: jra boot1
169: askme:
170: moveq #7,d6 | default to HP-IB at sc7
171: lslw #8,d6 | position as adaptor number
172: swap d6 | put in place (note implied unit 0)
173: movw #2,d6 | assume 'a' partition of rd disk
174: moveq #3,d7 | default to RB_SINGLE|RB_ASKNAME
175: boot1:
176: movl d6,_devtype | save devtype and howto
177: movl d7,_howto | globally so all can access
178: movl LOWRAM,d0 | read lowram value from bootrom
179: addl #NBPG,d0 | must preserve this for bootrom to reboot
180: andl #0xfffff000,d0 | round to next page
181: movl d0,_lowram | stash that value
182: start:
183: movl #_edata,a2 | start of BSS
184: movl #_end,a3 | end
185: clr:
186: clrb a2@+ | clear BSS
187: cmpl a2,a3 | done?
188: bne clr | no, keep going
189: jsr _configure | configure critical devices
190: movl #1,_firstopen | mark this as the first open
191: jsr _main | lets go
192: __rtt:
193: movl #3,_howto | restarts get RB_SINGLE|RB_ASKNAME
194: jmp start
195:
196: /*
197: * probe a location and see if it causes a bus error
198: */
199: .globl _badaddr
200: _badaddr:
201: movl BUSERR,__bsave | save ROM bus error handler address
202: movl sp,__ssave | and current stack pointer
203: movl #catchbad,BUSERR| plug in our handler
204: movl sp@(4),a0 | address to probe
205: movw a0@,d1 | do it
206: movl __bsave,BUSERR | if we got here, it didn't fault
207: clrl d0 | return that this was not a bad addr
208: rts
209:
210: catchbad:
211: movl __bsave,BUSERR | got a bus error, so restore old handler
212: movl __ssave,sp | manually restore stack
213: moveq #1,d0 | indicate that we got a fault
214: rts | return to caller of badaddr()
215:
216: __bsave:
217: .long 0
218: __ssave:
219: .long 0
220:
221: .globl _trap
222: trap:
223: moveml #0xFFFF,sp@- | save registers
224: movl sp,sp@- | push pointer to frame
225: jsr _trap | call C routine to deal with it
226: stop #0x2700 | stop cold
227:
228: nmi:
229: movw #18,BOOTTYPE | mark as system switch
230: jsr _kbdnmi | clear the interrupt
231: jra begin | start over
232:
233: #ifdef ROMPRF
234: .globl _romout
235: _romout:
236: movl sp@(4),d0 | line number
237: movl sp@(8),a0 | string
238: jsr 0x150 | do it
239: rts
240: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.