Commit | Line | Data |
---|---|---|
a8fd2d0d KM |
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 | * | |
af359dea C |
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. | |
a8fd2d0d | 25 | * |
af359dea C |
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. | |
a8fd2d0d | 37 | * |
af359dea C |
38 | * from: Utah $Hdr: srt0.c 1.12 91/04/25$ |
39 | * | |
40 | * @(#)srt0.c 7.4 (Berkeley) 5/7/91 | |
a8fd2d0d KM |
41 | */ |
42 | ||
43 | /* | |
44 | * Startup code for standalone system | |
45 | */ | |
46 | ||
47 | .globl begin | |
48 | .globl _end | |
49 | .globl _edata | |
50 | .globl _main | |
51 | .globl _configure | |
af359dea C |
52 | .globl _bootdev |
53 | .globl _firstopen | |
a8fd2d0d | 54 | .globl __rtt |
af359dea | 55 | .globl _lowram,_howto,_devtype,_internalhpib,_machineid |
a8fd2d0d KM |
56 | |
57 | STACK = 0xfffff000 | below the ROM page | |
58 | BOOTTYPE = 0xfffffdc0 | |
59 | LOWRAM = 0xfffffdce | |
18239460 | 60 | SYSFLAG = 0xfffffed2 | system flags |
a8fd2d0d KM |
61 | MSUS = 0xfffffedc | MSUS (?) structure |
62 | VECTORS = 0xfffffee0 | beginning of jump vectors | |
63 | NMIRESET = 0xffffff9c | reset vector | |
64 | BUSERR = 0xfffffffc | |
65 | MAXADDR = 0xfffff000 | |
66 | NBPG = 4096 | |
af359dea | 67 | MMUCMD = 0x005f400c | MMU command/status register |
a8fd2d0d KM |
68 | |
69 | .data | |
af359dea C |
70 | _bootdev: |
71 | .long 0 | |
72 | _devtype: | |
a8fd2d0d KM |
73 | .long 0 |
74 | _howto: | |
75 | .long 0 | |
af359dea C |
76 | _lowram: |
77 | .long 0 | |
78 | _machineid: | |
a8fd2d0d KM |
79 | .long 0 |
80 | ||
81 | .text | |
82 | begin: | |
83 | movl #STACK,sp | |
84 | moveq #47,d0 | # of vectors - 1 | |
85 | movl #VECTORS+2,a0 | addr part of first vector | |
86 | vecloop: | |
87 | movl #trap,a0@ | make it direct to trap | |
88 | addql #6,a0 | move to next vector addr | |
89 | dbf d0,vecloop | go til done | |
90 | movl #NMIRESET,a0 | NMI keyboard reset addr | |
91 | movl #nmi,a0@ | catch in reset routine | |
af359dea C |
92 | /* |
93 | * Determine our CPU type and look for internal HP-IB | |
94 | * (really only care about detecting 320 (no DIO-II) right now). | |
95 | */ | |
96 | lea _machineid,a0 | |
97 | movl #0x808,d0 | |
98 | movc d0,cacr | clear and disable on-chip cache(s) | |
99 | movl #0x200,d0 | data freeze bit | |
100 | movc d0,cacr | only exists on 68030 | |
101 | movc cacr,d0 | read it back | |
102 | tstl d0 | zero? | |
103 | jeq is68020 | yes, we have 68020 | |
104 | movl #0x808,d0 | |
105 | movc d0,cacr | clear data freeze bit again | |
106 | movl #0x80,MMUCMD | set magic cookie | |
107 | movl MMUCMD,d0 | read it back | |
108 | btst #7,d0 | cookie still on? | |
109 | jeq not370 | no, 360 or 375 | |
110 | movl #4,a0@ | consider a 370 for now | |
111 | movl #0,MMUCMD | clear magic cookie | |
112 | movl MMUCMD,d0 | read it back | |
113 | btst #7,d0 | still on? | |
114 | jeq ihpibcheck | no, a 370 | |
115 | movl #5,a0@ | yes, must be a 340 | |
116 | jra ihpibcheck | |
117 | not370: | |
118 | movl #3,a0@ | type is at least a 360 | |
119 | movl #0,MMUCMD | clear magic cookie2 | |
120 | movl MMUCMD,d0 | read it back | |
121 | btst #16,d0 | still on? | |
122 | jeq ihpibcheck | no, a 360 | |
123 | movl #6,a0@ | yes, must be a 345/375/400 | |
124 | jra ihpibcheck | |
125 | is68020: | |
126 | movl #1,a0@ | consider a 330 for now | |
127 | movl #1,MMUCMD | a 68020, write HP MMU location | |
128 | movl MMUCMD,d0 | read it back | |
129 | btst #0,d0 | zero? | |
130 | jeq ihpibcheck | yes, a 330 | |
131 | movl #0,a0@ | no, consider a 320 for now | |
132 | movl #0x80,MMUCMD | set magic cookie | |
133 | movl MMUCMD,d0 | read it back | |
134 | btst #7,d0 | cookie still on? | |
135 | jeq ihpibcheck | no, just a 320 | |
136 | movl #2,a0@ | yes, a 350 | |
137 | ihpibcheck: | |
138 | movl #0,MMUCMD | make sure MMU is off | |
18239460 KM |
139 | btst #5,SYSFLAG | do we have an internal HP-IB? |
140 | jeq boottype | yes, continue | |
141 | clrl _internalhpib | no, clear the internal address | |
af359dea C |
142 | /* |
143 | * If this is a reboot, extract howto/devtype stored by kernel | |
144 | */ | |
18239460 | 145 | boottype: |
a8fd2d0d KM |
146 | cmpw #12,BOOTTYPE | is this a reboot (REQ_REBOOT)? |
147 | jne notreboot | no, skip | |
148 | movl #MAXADDR,a0 | find last page | |
149 | movl a0@+,d7 | and extract howto, devtype | |
150 | movl a0@+,d6 | from where doboot() left them | |
151 | jra boot1 | |
152 | /* | |
153 | * At this point we do not know which logical hpib the given select | |
154 | * code refers to. So we just put the select code in the adaptor field | |
155 | * where hpibinit() can replace it with the logical hpib number. | |
156 | * Note that this may clobber the B_DEVMAGIC field but that isn't set | |
157 | * til later anyway. | |
158 | */ | |
159 | notreboot: | |
160 | cmpw #18,BOOTTYPE | does the user want to interact? | |
161 | jeq askme | yes, go to it | |
162 | movl MSUS,d1 | no, get rom info | |
163 | movw d1,d6 | MSUS comes with SC in upper, unit in lower | |
164 | swap d6 | put in place | |
165 | movw #2,d6 | assume 'a' partition of rd disk | |
166 | moveq #0,d7 | default to RB_AUTOBOOT | |
167 | jra boot1 | |
168 | askme: | |
169 | moveq #7,d6 | default to HP-IB at sc7 | |
170 | lslw #8,d6 | position as adaptor number | |
171 | swap d6 | put in place (note implied unit 0) | |
172 | movw #2,d6 | assume 'a' partition of rd disk | |
173 | moveq #3,d7 | default to RB_SINGLE|RB_ASKNAME | |
174 | boot1: | |
175 | movl d6,_devtype | save devtype and howto | |
176 | movl d7,_howto | globally so all can access | |
177 | movl LOWRAM,d0 | read lowram value from bootrom | |
178 | addl #NBPG,d0 | must preserve this for bootrom to reboot | |
179 | andl #0xfffff000,d0 | round to next page | |
180 | movl d0,_lowram | stash that value | |
181 | start: | |
182 | movl #_edata,a2 | start of BSS | |
183 | movl #_end,a3 | end | |
184 | clr: | |
185 | clrb a2@+ | clear BSS | |
186 | cmpl a2,a3 | done? | |
187 | bne clr | no, keep going | |
188 | jsr _configure | configure critical devices | |
af359dea | 189 | movl #1,_firstopen | mark this as the first open |
a8fd2d0d KM |
190 | jsr _main | lets go |
191 | __rtt: | |
192 | movl #3,_howto | restarts get RB_SINGLE|RB_ASKNAME | |
193 | jmp start | |
194 | ||
195 | /* | |
196 | * probe a location and see if it causes a bus error | |
197 | */ | |
198 | .globl _badaddr | |
199 | _badaddr: | |
200 | movl BUSERR,__bsave | save ROM bus error handler address | |
201 | movl sp,__ssave | and current stack pointer | |
202 | movl #catchbad,BUSERR| plug in our handler | |
203 | movl sp@(4),a0 | address to probe | |
204 | movw a0@,d1 | do it | |
205 | movl __bsave,BUSERR | if we got here, it didn't fault | |
206 | clrl d0 | return that this was not a bad addr | |
207 | rts | |
208 | ||
209 | catchbad: | |
210 | movl __bsave,BUSERR | got a bus error, so restore old handler | |
211 | movl __ssave,sp | manually restore stack | |
212 | moveq #1,d0 | indicate that we got a fault | |
213 | rts | return to caller of badaddr() | |
214 | ||
215 | __bsave: | |
216 | .long 0 | |
217 | __ssave: | |
218 | .long 0 | |
219 | ||
220 | .globl _trap | |
221 | trap: | |
222 | moveml #0xFFFF,sp@- | save registers | |
223 | movl sp,sp@- | push pointer to frame | |
224 | jsr _trap | call C routine to deal with it | |
225 | stop #0x2700 | stop cold | |
226 | ||
227 | nmi: | |
228 | movw #18,BOOTTYPE | mark as system switch | |
229 | jsr _kbdnmi | clear the interrupt | |
230 | jra begin | start over | |
231 | ||
232 | #ifdef ROMPRF | |
233 | .globl _romout | |
234 | _romout: | |
235 | movl sp@(4),d0 | line number | |
236 | movl sp@(8),a0 | string | |
237 | jsr 0x150 | do it | |
238 | rts | |
239 | #endif |