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