autoconf.c revision 1.5 1 /* $NetBSD: autoconf.c,v 1.5 1999/08/23 19:09:27 ragge Exp $ */
2 /*
3 * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed at Ludd, University of Lule}.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /* All bugs are subject to removal without further notice */
33
34
35
36 #include "sys/param.h"
37 #include "../include/mtpr.h"
38 #include "../include/sid.h"
39 #include "../include/trap.h"
40 #include "../include/frame.h"
41 #include "vaxstand.h"
42
43 int nmba=0, nuba=0, nbi=0,nsbi=0,nuda=0;
44 int *mbaaddr, *ubaaddr, *biaddr;
45 int *udaaddr, *uioaddr, tmsaddr, *bioaddr;
46
47 static int mba750[]={0xf28000,0xf2a000,0xf2c000};
48 static int uba750[]={0xf30000,0xf32000};
49 static int uio750[]={0xfc0000,0xf80000};
50 static int uda750[]={0772150};
51
52 /* 11/780's only have 4, 8600 have 8 of these. */
53 /* XXX - all of these should be bound to physical addresses */
54 static int mba780[]={0x20010000,0x20012000,0x20014000,0x20016000,
55 0x22010000,0x22012000,0x22014000,0x22016000};
56 static int uba780[]={0, 0, 0, 0x20006000,0x20008000,0x2000a000,0x2000c000, 0,
57 0, 0, 0, 0, 0, 0, 0, 0,
58 0, 0, 0, 0x22006000,0x22008000,0x2200a000,0x2200c000};
59 static int uio780[]={0, 0, 0, 0x20100000,0x20140000,0x20180000,0x201c0000, 0,
60 0, 0, 0, 0, 0, 0, 0, 0,
61 0, 0, 0, 0x22100000,0x22140000,0x22180000,0x221c0000};
62 static int bi8200[]={0x20000000, 0x22000000, 0x24000000, 0x26000000,
63 0x28000000, 0x2a000000};
64 static int bio8200[]={0x20400000};
65
66 static int uba630[]={0x20087800};
67 static int uio630[]={0x30000000};
68 #define qbdev(csr) (((csr) & 017777)-0x10000000)
69 static int uda630[]={qbdev(0772150),qbdev(0760334)};
70
71 static int uba670[]={0x20040000};
72 static int uio670[]={0x20000000};
73 static int uda670[]={0x20004030,0x20004230};
74 #define qb670dev(csr) (((csr) & 017777)+0x20000000)
75
76 /*
77 * Autoconf routine is really stupid; but it actually don't
78 * need any intelligence. We just assume that all possible
79 * devices exists on each cpu. Fast & easy.
80 */
81
82 autoconf()
83 {
84 extern int memsz;
85
86 findcpu(); /* Configures CPU variables */
87 consinit(); /* Allow us to print out things */
88 scbinit(); /* Fix interval clock etc */
89
90 switch (vax_boardtype) {
91
92 default:
93 printf("\nCPU type %d not supported by boot\n",vax_cputype);
94 printf("trying anyway...\n");
95 break;
96
97 case VAX_BTYP_780:
98 case VAX_BTYP_790:
99 memsz = 0;
100 nmba = 8;
101 nuba = 32; /* XXX */
102 nuda = 1;
103 mbaaddr = mba780;
104 ubaaddr = uba780;
105 udaaddr = uda750;
106 uioaddr = uio780;
107 tmsaddr = 0774500;
108 break;
109
110 case VAX_BTYP_750:
111 memsz = 0;
112 nmba = 3;
113 nuba = 2;
114 nuda = 1;
115 mbaaddr = mba750;
116 ubaaddr = uba750;
117 udaaddr = uda750;
118 uioaddr = uio750;
119 tmsaddr = 0774500;
120 break;
121
122 case VAX_BTYP_630: /* the same for uvaxIII */
123 case VAX_BTYP_650:
124 case VAX_BTYP_660:
125 case VAX_BTYP_670:
126 nuba = 1;
127 nuda = 2;
128 ubaaddr = uba630;
129 udaaddr = uda630;
130 uioaddr = uio630;
131 tmsaddr = qbdev(0774500);
132 break;
133
134 case VAX_BTYP_8000:
135 memsz = 0;
136 nbi = 1;
137 biaddr = bi8200;
138 bioaddr = bio8200;
139 break;
140
141 case VAX_BTYP_46:
142 case VAX_BTYP_48:
143 {int *map, i;
144
145 /* Map all 16MB of I/O space to low 16MB of memory */
146 map = (int *)0x700000; /* XXX */
147 *(int *)0x20080008 = (int)map; /* XXX */
148 for (i = 0; i < 0x8000; i++)
149 map[i] = 0x80000000 | i;
150 }break;
151
152 case VAX_BTYP_410:
153 case VAX_BTYP_420:
154 case VAX_BTYP_43:
155 case VAX_BTYP_49:
156 break;
157 }
158 }
159
160 /*
161 * Clock handling routines, needed to do timing in standalone programs.
162 */
163
164 volatile int tickcnt;
165
166 getsecs()
167 {
168 volatile int loop;
169 int todr;
170
171 return tickcnt/100;
172 }
173
174 void scb_stray(), rtimer();
175 struct ivec_dsp **scb;
176 struct ivec_dsp *scb_vec;
177
178 /*
179 * Init the SCB and set up a handler for all vectors in the lower space,
180 * to detect unwanted interrupts.
181 */
182 scbinit()
183 {
184 extern int timer;
185 int i;
186
187 /*
188 * Allocate space. We need one page for the SCB, and 128*16 == 2k
189 * for the vectors. The SCB must be on a page boundary.
190 */
191 i = alloc(VAX_NBPG * 6) + VAX_PGOFSET;
192 i &= ~VAX_PGOFSET;
193
194 mtpr(i, PR_SCBB);
195 scb = (void *)i;
196 scb_vec = (struct ivec_dsp *)(i + VAX_NBPG);
197
198 for (i = 0; i < 128; i++) {
199 scb[i] = &scb_vec[i];
200 (int)scb[i] |= 1; /* Only interrupt stack */
201 memcpy(&scb_vec[i], &idsptch, sizeof(struct ivec_dsp));
202 scb_vec[i].hoppaddr = scb_stray;
203 }
204 scb_vec[0xc0/4].hoppaddr = rtimer;
205
206 mtpr(-10000, PR_NICR); /* Load in count register */
207 mtpr(0x800000d1, PR_ICCS); /* Start clock and enable interrupt */
208
209 mtpr(20, PR_IPL);
210 }
211
212 void
213 rtimer()
214 {
215 mtpr(31, PR_IPL);
216 tickcnt++;
217 mtpr(0xc1, PR_ICCS);
218 }
219
220 asm("
221 .globl _idsptch, _eidsptch
222 _idsptch:
223 pushr $0x3f
224 pushl $1
225 .long 0x9f01fb01
226 .long 0x12345678
227 #
228 # gas do not accept this :-/ use hexcode instead
229 # nop
230 # calls $1, *$0x12345678
231 popr $0x3f
232 rei
233 _eidsptch:
234 ");
235
236 /*
237 * Stray interrupt handler.
238 * This function must _not_ save any registers (in the reg save mask).
239 */
240 void
241 scb_stray(arg)
242 int arg;
243 {
244 static struct callsframe *cf;
245 static int vector, ipl, *a;
246
247 cf = FRAMEOFFSET(arg);
248 a = &cf->ca_arg1;
249 ipl = mfpr(PR_IPL);
250 vector = ((cf->ca_pc - (u_int)scb_vec)/4) & ~3;
251 printf("stray interrupt: pc %x vector 0x%x, ipl %d\n",
252 cf->ca_pc, vector, ipl);
253 }
254
255