Annotation of sys/arch/vax/vax/locore.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: locore.c,v 1.32 2006/08/27 16:55:41 miod Exp $ */
2: /* $NetBSD: locore.c,v 1.43 2000/03/26 11:39:45 ragge Exp $ */
3: /*
4: * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden.
5: * All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
15: * 3. All advertising materials mentioning features or use of this software
16: * must display the following acknowledgement:
17: * This product includes software developed at Ludd, University of Lule}.
18: * 4. The name of the author may not be used to endorse or promote products
19: * derived from this software without specific prior written permission
20: *
21: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31: */
32:
33: /* All bugs are subject to removal without further notice */
34:
35:
36: #include <sys/param.h>
37: #include <sys/reboot.h>
38: #include <sys/device.h>
39: #include <sys/systm.h>
40: #include <sys/user.h>
41:
42: #include <uvm/uvm_extern.h>
43:
44: #include <machine/cpu.h>
45: #include <machine/sid.h>
46: #include <machine/param.h>
47: #include <machine/vmparam.h>
48: #include <machine/pcb.h>
49: #include <machine/pte.h>
50: #include <machine/pmap.h>
51: #include <machine/nexus.h>
52: #include <machine/rpb.h>
53:
54: void start(struct rpb *);
55: void main(void);
56:
57: extern paddr_t avail_end;
58: paddr_t esym;
59: u_int proc0paddr;
60: char cpu_model[100];
61:
62: /*
63: * The strict cpu-dependent information is set up here, in
64: * form of a pointer to a struct that is specific for each cpu.
65: */
66: extern struct cpu_dep ka780_calls;
67: extern struct cpu_dep ka750_calls;
68: extern struct cpu_dep ka860_calls;
69: extern struct cpu_dep ka820_calls;
70: extern struct cpu_dep ka43_calls;
71: extern struct cpu_dep ka46_calls;
72: extern struct cpu_dep ka48_calls;
73: extern struct cpu_dep ka49_calls;
74: extern struct cpu_dep ka53_calls;
75: extern struct cpu_dep ka410_calls;
76: extern struct cpu_dep ka630_calls;
77: extern struct cpu_dep ka650_calls;
78: extern struct cpu_dep ka660_calls;
79: extern struct cpu_dep ka670_calls;
80: extern struct cpu_dep ka680_calls;
81: extern struct cpu_dep vxt_calls;
82:
83: /*
84: * Start is called from boot; the first routine that is called
85: * in kernel. Kernel stack is setup somewhere in a safe place;
86: * but we need to move it to a better known place. Memory
87: * management is disabled, and no interrupt system is active.
88: */
89: void
90: start(struct rpb *prpb)
91: {
92: extern void *scratch;
93:
94: mtpr(AST_NO, PR_ASTLVL); /* Turn off ASTs */
95:
96: findcpu(); /* Set up the CPU identifying variables */
97:
98: if (vax_confdata & 0x80)
99: strlcpy(cpu_model, "MicroVAX ", sizeof cpu_model);
100: else
101: strlcpy(cpu_model, "VAXstation ", sizeof cpu_model);
102:
103: switch (vax_boardtype) {
104: #if VAX780
105: case VAX_BTYP_780:
106: dep_call = &ka780_calls;
107: strlcpy(cpu_model,"VAX 11/780", sizeof cpu_model);
108: if (vax_cpudata & 0x100)
109: cpu_model[9] = '5';
110: break;
111: #endif
112: #if VAX750
113: case VAX_BTYP_750:
114: dep_call = &ka750_calls;
115: strlcpy(cpu_model, "VAX 11/750", sizeof cpu_model);
116: break;
117: #endif
118: #if VAX8600
119: case VAX_BTYP_790:
120: dep_call = &ka860_calls;
121: strlcpy(cpu_model,"VAX 8600", sizeof cpu_model);
122: if (vax_cpudata & 0x100)
123: cpu_model[6] = '5';
124: break;
125: #endif
126: #if VAX410
127: case VAX_BTYP_420: /* They are very similar */
128: dep_call = &ka410_calls;
129: strlcat(cpu_model, "3100", sizeof cpu_model);
130: switch ((vax_siedata >> 8) & 0xff) {
131: case 0x00:
132: strlcat(cpu_model, "/m{30,40}", sizeof cpu_model);
133: break;
134: case 0x01:
135: strlcat(cpu_model, "/m{38,48}", sizeof cpu_model);
136: break;
137: case 0x02:
138: strlcat(cpu_model, "/m{10,20}{,e}", sizeof cpu_model);
139: break;
140: }
141: break;
142:
143: case VAX_BTYP_410:
144: dep_call = &ka410_calls;
145: strlcat(cpu_model, "2000", sizeof cpu_model);
146: break;
147: #endif
148: #if VAX43
149: case VAX_BTYP_43:
150: dep_call = &ka43_calls;
151: strlcat(cpu_model, "3100/m76", sizeof cpu_model);
152: break;
153: #endif
154: #if VAX46
155: case VAX_BTYP_46:
156: dep_call = &ka46_calls;
157: switch(vax_siedata & 0xff) {
158: case VAX_VTYP_47:
159: strlcpy(cpu_model, "MicroVAX 3100 m80", sizeof cpu_model);
160: break;
161: case VAX_VTYP_46:
162: strlcpy(cpu_model, "VAXstation 4000/60", sizeof cpu_model);
163: break;
164: default:
165: strlcat(cpu_model, " - Unknown Mariah", sizeof cpu_model);
166: }
167: break;
168: #endif
169: #ifdef VXT
170: case VAX_BTYP_VXT:
171: dep_call = &vxt_calls;
172: strlcpy(cpu_model, "VXT2000", sizeof cpu_model);
173: break;
174: #endif
175: #if VAX48
176: case VAX_BTYP_48:
177: dep_call = &ka48_calls;
178: switch ((vax_siedata >> 8) & 0xff) {
179: case VAX_STYP_45:
180: strlcpy(cpu_model, "MicroVAX 3100/m{30,40}", sizeof cpu_model);
181: break;
182: case VAX_STYP_48:
183: strlcpy(cpu_model, "VAXstation 4000/VLC", sizeof cpu_model);
184: break;
185: default:
186: strlcat(cpu_model, " - Unknown SOC", sizeof cpu_model);
187: }
188: break;
189: #endif
190: #if VAX49
191: case VAX_BTYP_49:
192: dep_call = &ka49_calls;
193: strlcpy(cpu_model, "VAXstation 4000/90", sizeof cpu_model);
194: break;
195: #endif
196: #if VAX53
197: case VAX_BTYP_1303:
198: dep_call = &ka53_calls;
199: switch ((vax_siedata >> 8) & 0xff) {
200: case VAX_STYP_50:
201: strlcpy(cpu_model, "MicroVAX 3100 model 85 or 90", sizeof cpu_model);
202: break;
203: case VAX_STYP_51:
204: strlcpy(cpu_model, "MicroVAX 3100 model 90 or 95", sizeof cpu_model);
205: break;
206: case VAX_STYP_52:
207: strlcpy(cpu_model, "VAX 4000 100", sizeof cpu_model);
208: break;
209: case VAX_STYP_53:
210: strlcpy(cpu_model, "VAX 4000 105A", sizeof cpu_model);
211: break;
212: default:
213: strlcpy(cpu_model, "VAX - Unknown Cheetah Class", sizeof cpu_model);
214: }
215: break;
216: #endif
217: #if VAX630
218: case VAX_BTYP_630:
219: dep_call = &ka630_calls;
220: strlcpy(cpu_model,"MicroVAX II", sizeof cpu_model);
221: break;
222: #endif
223: #if VAX650
224: case VAX_BTYP_650:
225: dep_call = &ka650_calls;
226: strlcpy(cpu_model,"MicroVAX ", sizeof cpu_model);
227: switch ((vax_siedata >> 8) & 255) {
228: case VAX_SIE_KA640:
229: strlcat(cpu_model, "3300/3400", sizeof cpu_model);
230: break;
231:
232: case VAX_SIE_KA650:
233: strlcat(cpu_model, "3500/3600", sizeof cpu_model);
234: break;
235:
236: case VAX_SIE_KA655:
237: strlcat(cpu_model, "3800/3900", sizeof cpu_model);
238: break;
239:
240: default:
241: strlcat(cpu_model, "III", sizeof cpu_model);
242: break;
243: }
244: break;
245: #endif
246: #if VAX660
247: case VAX_BTYP_660:
248: dep_call = &ka660_calls;
249: strlcpy(cpu_model,"VAX 4000 200", sizeof cpu_model);
250: break;
251: #endif
252: #if VAX670
253: case VAX_BTYP_670:
254: dep_call = &ka670_calls;
255: strlcpy(cpu_model,"VAX 4000 300", sizeof cpu_model);
256: break;
257: #endif
258: #if VAX680
259: case VAX_BTYP_1301:
260: dep_call = &ka680_calls;
261: strlcpy(cpu_model,"VAX 4000 ", sizeof cpu_model);
262: switch ((vax_siedata >> 8) & 0xff) {
263: case VAX_STYP_675:
264: strlcat(cpu_model,"400", sizeof cpu_model);
265: break;
266: case VAX_STYP_680:
267: strlcat(cpu_model,"500", sizeof cpu_model);
268: break;
269: case VAX_STYP_690:
270: strlcat(cpu_model,"600", sizeof cpu_model);
271: break;
272: default:
273: strlcat(cpu_model,"- Unknown Omega Class", sizeof cpu_model);
274: }
275: break;
276: case VAX_BTYP_1305:
277: dep_call = &ka680_calls;
278: strlcpy(cpu_model,"VAX 4000 ", sizeof cpu_model);
279: switch ((vax_siedata >> 8) & 0xff) {
280: case VAX_STYP_681:
281: strlcat(cpu_model,"500A", sizeof cpu_model);
282: break;
283: case VAX_STYP_691:
284: strlcat(cpu_model,"605A", sizeof cpu_model);
285: break;
286: case VAX_STYP_694:
287: if (vax_cpudata & 0x1000)
288: strlcat(cpu_model,"705A", sizeof cpu_model);
289: else
290: strlcat(cpu_model,"700A", sizeof cpu_model);
291: break;
292: default:
293: strlcat(cpu_model,"- Unknown Legacy Class", sizeof cpu_model);
294: }
295: break;
296: #endif
297: #if VAX8200
298: case VAX_BTYP_8000:
299: mastercpu = mfpr(PR_BINID);
300: dep_call = &ka820_calls;
301: strlcpy(cpu_model, "VAX 8200", sizeof cpu_model);
302: break;
303: #endif
304: default:
305: /* CPU not supported, just give up */
306: asm("halt");
307: }
308:
309: /*
310: * Machines older than MicroVAX II have their boot blocks
311: * loaded directly or the boot program loaded from console
312: * media, so we need to figure out their memory size.
313: * This is not easily done on MicroVAXen, so we get it from
314: * VMB instead.
315: *
316: * In post-1.4 a RPB is always provided from the boot blocks.
317: */
318: #if 1 /* compat with old bootblocks */
319: if (prpb == 0) {
320: bzero((caddr_t)proc0paddr + REDZONEADDR, sizeof(struct rpb));
321: prpb = (struct rpb *)(proc0paddr + REDZONEADDR);
322: prpb->pfncnt = avail_end >> VAX_PGSHIFT;
323: prpb->rpb_base = (void *)-1; /* RPB is fake */
324: } else
325: #endif
326: bcopy(prpb, (caddr_t)proc0paddr + REDZONEADDR, sizeof(struct rpb));
327: if (prpb->pfncnt)
328: avail_end = prpb->pfncnt << VAX_PGSHIFT;
329: else
330: while (badaddr((caddr_t)avail_end, 4) == 0)
331: avail_end += VAX_NBPG * 128;
332: boothowto = prpb->rpb_bootr5;
333:
334: avail_end = TRUNC_PAGE(avail_end); /* be sure */
335:
336: proc0.p_addr = (struct user *)proc0paddr; /* XXX */
337: bzero((struct user *)proc0paddr, sizeof(struct user));
338:
339: /* Clear the used parts of the uarea except for the pcb */
340: bzero(&proc0.p_addr->u_stats, sizeof(struct user) - sizeof(struct pcb));
341:
342: pmap_bootstrap();
343:
344: /* Now running virtual. set red zone for proc0 */
345: *kvtopte((u_int)proc0.p_addr + REDZONEADDR) &= ~PG_V;
346:
347: ((struct pcb *)proc0paddr)->framep = scratch;
348:
349: /*
350: * Change mode down to userspace is done by faking a stack
351: * frame that is setup in cpu_set_kpc(). Not done by returning
352: * from main anymore.
353: */
354: main();
355: /* NOTREACHED */
356: }
CVSweb