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