No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / hp300 / stand / common / autoconf.c
blobbf9efe81d7fa680127115653402f9c2e63612b6b
1 /* $NetBSD: autoconf.c,v 1.10 2006/07/21 15:14:11 tsutsui Exp $ */
3 /*
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer
9 * Science Department.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
35 * from: Utah Hdr: autoconf.c 1.16 92/05/29
37 * @(#)autoconf.c 8.1 (Berkeley) 6/10/93
40 * Copyright (c) 1988 University of Utah.
42 * This code is derived from software contributed to Berkeley by
43 * the Systems Programming Group of the University of Utah Computer
44 * Science Department.
46 * Redistribution and use in source and binary forms, with or without
47 * modification, are permitted provided that the following conditions
48 * are met:
49 * 1. Redistributions of source code must retain the above copyright
50 * notice, this list of conditions and the following disclaimer.
51 * 2. Redistributions in binary form must reproduce the above copyright
52 * notice, this list of conditions and the following disclaimer in the
53 * documentation and/or other materials provided with the distribution.
54 * 3. All advertising materials mentioning features or use of this software
55 * must display the following acknowledgement:
56 * This product includes software developed by the University of
57 * California, Berkeley and its contributors.
58 * 4. Neither the name of the University nor the names of its contributors
59 * may be used to endorse or promote products derived from this software
60 * without specific prior written permission.
62 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * SUCH DAMAGE.
74 * from: Utah Hdr: autoconf.c 1.16 92/05/29
76 * @(#)autoconf.c 8.1 (Berkeley) 6/10/93
79 #include <sys/param.h>
80 #include <sys/reboot.h>
82 #include <hp300/stand/common/samachdep.h>
83 #include <hp300/stand/common/rominfo.h>
84 #include <hp300/stand/common/device.h>
85 #include <hp300/stand/common/hpibvar.h>
86 #include <hp300/stand/common/scsireg.h>
87 #include <hp300/stand/common/scsivar.h>
89 #include <hp300/dev/dioreg.h>
90 #include <hp300/dev/grfreg.h>
91 #include <hp300/dev/intioreg.h>
94 * Mapping of ROM MSUS types to BSD major device numbers
95 * WARNING: major numbers must match bdevsw indices in hp300/conf.c.
97 static const char rom2mdev[] = {
98 0, 0, /* 0-1: none */
99 6, /* 2: network device; special */
100 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 3-13: none */
101 4, /* 14: SCSI disk */
102 0, /* 15: none */
103 2, /* 16: CS/80 device on HPIB */
104 2, /* 17: CS/80 device on HPIB */
105 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 18-31: none */
108 struct hp_hw sc_table[MAXCTLRS];
109 int cpuspeed;
111 static u_long msustobdev(void);
112 static void find_devs(void);
114 #ifdef PRINTROMINFO
115 void
116 printrominfo(void)
118 struct rominfo *rp = (struct rominfo *)ROMADDR;
120 printf("boottype %x, name %s, lowram %x, sysflag %x\n",
121 rp->boottype, rp->name, rp->lowram, rp->sysflag&0xff);
122 printf("rambase %x, ndrives %x, sysflag2 %x, msus %x\n",
123 rp->rambase, rp->ndrives, rp->sysflag2&0xff, rp->msus);
125 #endif
127 void
128 configure(void)
131 switch (machineid) {
132 case HP_320:
133 case HP_330:
134 case HP_340:
135 cpuspeed = MHZ_16;
136 break;
137 case HP_350:
138 case HP_360:
139 case HP_362:
140 cpuspeed = MHZ_25;
141 break;
142 case HP_370:
143 cpuspeed = MHZ_33;
144 break;
145 case HP_375:
146 case HP_400:
147 cpuspeed = MHZ_50;
148 break;
149 case HP_380:
150 case HP_382:
151 case HP_425:
152 cpuspeed = MHZ_25 * 2; /* XXX */
153 break;
154 case HP_385:
155 case HP_433:
156 cpuspeed = MHZ_33 * 2; /* XXX */
157 break;
158 default: /* assume the fastest (largest delay value) */
159 cpuspeed = MHZ_50;
160 break;
162 find_devs();
163 cninit();
164 #ifdef PRINTROMINFO
165 printrominfo();
166 #endif
167 hpibinit();
168 scsiinit();
169 if ((bootdev & B_MAGICMASK) != B_DEVMAGIC)
170 bootdev = msustobdev();
174 * Convert HP MSUS to a valid bootdev layout:
175 * TYPE comes from MSUS device type as mapped by rom2mdev
176 * PARTITION is set to 0 ('a')
177 * UNIT comes from MSUS unit (almost always 0)
178 * CONTROLLER comes from MSUS primary address
179 * ADAPTER comes from SCSI/HPIB driver logical unit number
180 * (passed back via unused hw_pa field)
182 static u_long
183 msustobdev(void)
185 struct rominfo *rp = (struct rominfo *) ROMADDR;
186 u_long bdev = 0;
187 struct hp_hw *hw;
188 int sc, type, ctlr, slave, punit;
190 sc = (rp->msus >> 8) & 0xFF;
191 for (hw = sc_table; hw < &sc_table[MAXCTLRS]; hw++)
192 if (hw->hw_sc == sc)
193 break;
195 type = rom2mdev[(rp->msus >> 24) & 0x1F];
196 ctlr = (int)hw->hw_pa;
197 slave = (rp->msus & 0xFF);
198 punit = ((rp->msus >> 16) & 0xFF);
200 bdev = MAKEBOOTDEV(type, ctlr, slave, punit, 0);
202 #ifdef PRINTROMINFO
203 printf("msus %x -> bdev %x\n", rp->msus, bdev);
204 #endif
205 return bdev;
209 sctoaddr(int sc)
212 if (sc == -1)
213 return INTIOBASE + FB_BASE;
214 if (sc == 7 && internalhpib)
215 return internalhpib ;
216 if (sc < 32)
217 return DIOBASE + sc * DIOCSIZE ;
218 if (sc >= DIOII_SCBASE)
219 return DIOIIBASE + (sc - DIOII_SCBASE) * DIOIICSIZE ;
220 return sc;
224 * Probe all DIO select codes (0 - 32), the internal display address,
225 * and DIO-II select codes (132 - 256).
227 * Note that we only care about displays, LANCEs, SCSIs and HP-IBs.
229 static void
230 find_devs(void)
232 short sc, sctop;
233 u_char *id_reg;
234 void *addr;
235 struct hp_hw *hw;
237 hw = sc_table;
238 sctop = DIO_SCMAX(machineid);
239 for (sc = -1; sc < sctop; sc++) {
240 if (DIO_INHOLE(sc))
241 continue;
242 addr = (void *)sctoaddr(sc);
243 if (badaddr(addr))
244 continue;
246 id_reg = (u_char *)addr;
247 hw->hw_pa = 0; /* XXX used to pass back LUN from driver */
248 if (sc >= DIOII_SCBASE)
249 hw->hw_size = DIOII_SIZE(id_reg);
250 else
251 hw->hw_size = DIOCSIZE;
252 hw->hw_kva = addr;
253 hw->hw_id = DIO_ID(id_reg);
254 hw->hw_sc = sc;
257 * Not all internal HP-IBs respond rationally to id requests
258 * so we just go by the "internal HPIB" indicator in SYSFLAG.
260 if (sc == 7 && internalhpib) {
261 hw->hw_type = C_HPIB;
262 hw++;
263 continue;
266 switch (hw->hw_id) {
267 case 5: /* 98642A */
268 case 5+128: /* 98642A remote */
269 hw->hw_type = D_COMMDCM;
270 break;
271 case 8: /* 98625B */
272 case 128: /* 98624A */
273 hw->hw_type = C_HPIB;
274 break;
275 case 21: /* LANCE */
276 hw->hw_type = D_LAN;
277 break;
278 case 57: /* Displays */
279 hw->hw_type = D_BITMAP;
280 hw->hw_secid = id_reg[0x15];
281 switch (hw->hw_secid) {
282 case 4: /* renaissance */
283 case 8: /* davinci */
284 sc++; /* occupy 2 select codes */
285 break;
287 break;
288 case 9:
289 hw->hw_type = D_KEYBOARD;
290 break;
291 case 7:
292 case 7+32:
293 case 7+64:
294 case 7+96:
295 hw->hw_type = C_SCSI;
296 break;
297 default: /* who cares */
298 hw->hw_type = D_MISC;
299 break;
301 hw++;