1 /* 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1990 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the Systems Programming Group of the University of Utah Computer 8 * Science Department. 9 * 10 * %sccs.include.redist.c% 11 * 12 * from: Utah $Hdr: autoconf.c 1.16 92/05/29$ 13 * 14 * @(#)autoconf.c 7.6 (Berkeley) 06/18/92 15 */ 16 17 #include "samachdep.h" 18 #include "rominfo.h" 19 #include "sys/param.h" 20 #include "sys/reboot.h" 21 22 #include "hp/dev/device.h" 23 #include "hp/dev/grfreg.h" 24 25 /* 26 * Mapping of ROM MSUS types to BSD major device numbers 27 * WARNING: major numbers must match bdevsw indices in hp300/conf.c. 28 */ 29 char rom2mdev[] = { 30 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0-13: none */ 31 4, /* 14: SCSI disk */ 32 0, /* 15: none */ 33 2, /* 16: CS/80 device on HPIB */ 34 2, /* 17: CS/80 device on HPIB */ 35 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 18-31: none */ 36 }; 37 38 struct hp_hw sc_table[MAXCTLRS]; 39 int cpuspeed; 40 41 extern int internalhpib; 42 43 #if 0 44 printrominfo() 45 { 46 struct rominfo *rp = (struct rominfo *)ROMADDR; 47 48 printf("boottype %x, name %s, lowram %x, sysflag %x\n", 49 rp->boottype, rp->name, rp->lowram, rp->sysflag&0xff); 50 printf("rambase %x, ndrives %x, sysflag2 %x, msus %x\n", 51 rp->rambase, rp->ndrives, rp->sysflag2&0xff, rp->msus); 52 } 53 #endif 54 55 configure() 56 { 57 u_long msustobdev(); 58 59 switch (machineid) { 60 case HP_320: 61 case HP_330: 62 case HP_340: 63 cpuspeed = MHZ_16; 64 break; 65 case HP_350: 66 case HP_360: 67 cpuspeed = MHZ_25; 68 break; 69 case HP_370: 70 cpuspeed = MHZ_33; 71 break; 72 case HP_375: 73 cpuspeed = MHZ_50; 74 break; 75 case HP_380: 76 cpuspeed = MHZ_25 * 2; /* XXX */ 77 break; 78 default: /* assume the slowest */ 79 cpuspeed = MHZ_16; 80 break; 81 } 82 find_devs(); 83 cninit(); 84 #if 0 85 printrominfo(); 86 #endif 87 hpibinit(); 88 scsiinit(); 89 if ((bootdev & B_MAGICMASK) != B_DEVMAGIC) 90 bootdev = msustobdev(); 91 } 92 93 /* 94 * Convert HP MSUS to a valid bootdev layout: 95 * TYPE comes from MSUS device type as mapped by rom2mdev 96 * PARTITION is set to 0 ('a') 97 * UNIT comes from MSUS unit (almost always 0) 98 * CONTROLLER comes from MSUS primary address 99 * ADAPTOR comes from SCSI/HPIB driver logical unit number 100 * (passed back via unused hw_pa field) 101 */ 102 u_long 103 msustobdev() 104 { 105 struct rominfo *rp = (struct rominfo *) ROMADDR; 106 u_long bdev = 0; 107 register struct hp_hw *hw; 108 int sc; 109 110 sc = (rp->msus >> 8) & 0xFF; 111 for (hw = sc_table; hw < &sc_table[MAXCTLRS]; hw++) 112 if (hw->hw_sc == sc) 113 break; 114 bdev |= rom2mdev[(rp->msus >> 24) & 0x1F] << B_TYPESHIFT; 115 bdev |= 0 << B_PARTITIONSHIFT; 116 bdev |= ((rp->msus >> 16) & 0xFF) << B_UNITSHIFT; 117 bdev |= (rp->msus & 0xFF) << B_CONTROLLERSHIFT; 118 bdev |= (int)hw->hw_pa << B_ADAPTORSHIFT; 119 bdev |= B_DEVMAGIC; 120 #if 0 121 printf("msus %x -> bdev %x\n", rp->msus, bdev); 122 #endif 123 return (bdev); 124 } 125 126 sctoaddr(sc) 127 int sc; 128 { 129 if (sc == -1) 130 return(GRFIADDR); 131 if (sc == 7 && internalhpib) 132 return(internalhpib); 133 if (sc < 32) 134 return(DIOBASE + sc * DIOCSIZE); 135 if (sc >= 132) 136 return(DIOIIBASE + (sc - 132) * DIOIICSIZE); 137 return(sc); 138 } 139 140 /* 141 * Probe all DIO select codes (0 - 32), the internal display address, 142 * and DIO-II select codes (132 - 256). 143 * 144 * Note that we only care about displays, SCSIs and HP-IBs. 145 */ 146 find_devs() 147 { 148 short sc, sctop; 149 u_char *id_reg; 150 register caddr_t addr; 151 register struct hp_hw *hw; 152 153 hw = sc_table; 154 sctop = machineid == HP_320 ? 32 : 256; 155 for (sc = -1; sc < sctop; sc++) { 156 if (sc >= 32 && sc < 132) 157 continue; 158 addr = (caddr_t) sctoaddr(sc); 159 if (badaddr(addr)) 160 continue; 161 162 id_reg = (u_char *) addr; 163 hw->hw_pa = 0; /* XXX used to pass back LUN from driver */ 164 if (sc >= 132) 165 hw->hw_size = (id_reg[0x101] + 1) * 0x100000; 166 else 167 hw->hw_size = DIOCSIZE; 168 hw->hw_kva = addr; 169 hw->hw_id = id_reg[1]; 170 hw->hw_sc = sc; 171 172 /* 173 * Not all internal HP-IBs respond rationally to id requests 174 * so we just go by the "internal HPIB" indicator in SYSFLAG. 175 */ 176 if (sc == 7 && internalhpib) { 177 hw->hw_type = C_HPIB; 178 hw++; 179 continue; 180 } 181 182 switch (hw->hw_id) { 183 case 5: /* 98642A */ 184 case 5+128: /* 98642A remote */ 185 hw->hw_type = D_COMMDCM; 186 break; 187 case 8: /* 98625B */ 188 case 128: /* 98624A */ 189 hw->hw_type = C_HPIB; 190 break; 191 case 57: /* Displays */ 192 hw->hw_type = D_BITMAP; 193 hw->hw_secid = id_reg[0x15]; 194 switch (hw->hw_secid) { 195 case 4: /* renaissance */ 196 case 8: /* davinci */ 197 sc++; /* occupy 2 select codes */ 198 break; 199 } 200 break; 201 case 9: 202 hw->hw_type = D_KEYBOARD; 203 break; 204 case 7: 205 case 7+32: 206 case 7+64: 207 case 7+96: 208 hw->hw_type = C_SCSI; 209 break; 210 default: /* who cares */ 211 hw->hw_type = D_MISC; 212 break; 213 } 214 hw++; 215 } 216 } 217