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