📄 autoconf.c
字号:
addr = internalhpib; else if (sc < 32) addr = (caddr_t) (DIOBASE + sc * DIOCSIZE); else if (sc >= 132) addr = (caddr_t) (DIOIIBASE + (sc - 132) * DIOIICSIZE); else addr = 0; return(addr);}patosc(addr) register caddr_t addr;{ if (addr == (caddr_t)0x478000) return(7); if (addr >= (caddr_t)DIOBASE && addr < (caddr_t)DIOTOP) return(((unsigned)addr - DIOBASE) / DIOCSIZE); if (addr >= (caddr_t)DIOIIBASE && addr < (caddr_t)DIOIITOP) return(((unsigned)addr - DIOIIBASE) / DIOIICSIZE + 132); return((int)addr);}caddr_tsctova(sc) register int sc;{ register struct hp_hw *hw; for (hw = sc_table; hw->hw_type; hw++) if (sc == hw->hw_sc) return(hw->hw_kva); return((caddr_t)sc);}vatosc(addr) register caddr_t addr;{ register struct hp_hw *hw; for (hw = sc_table; hw->hw_type; hw++) if (addr == hw->hw_kva) return(hw->hw_sc); return((int)addr);}same_hw_device(hw, hd) struct hp_hw *hw; struct hp_device *hd;{ int found = 0; switch (hw->hw_type & ~B_MASK) { case C_HPIB: found = dr_type(hd->hp_driver, "hpib"); break; case C_SCSI: found = dr_type(hd->hp_driver, "scsi"); break; case D_BITMAP: found = dr_type(hd->hp_driver, "grf"); break; case D_LAN: found = dr_type(hd->hp_driver, "le"); break; case D_COMMDCA: found = dr_type(hd->hp_driver, "dca"); break; case D_COMMDCL: found = dr_type(hd->hp_driver, "dcl"); break; case D_COMMDCM: found = dr_type(hd->hp_driver, "dcm"); break; default: break; } return(found);}char notmappedmsg[] = "WARNING: no space to map IO card, ignored\n";/* * Scan the IO space looking for devices. */find_devs(){ short sc; u_char *id_reg; register caddr_t addr; register struct hp_hw *hw; int didmap, sctop; /* * Initialize IO resource map for iomap(). */ rminit(extiomap, (long)EIOMAPSIZE, (long)1, "extio", EIOMAPSIZE/16); hw = sc_table; /* * Probe all select codes + internal display addr */ sctop = machineid == HP_320 ? 32 : 256; for (sc = -1; sc < sctop; sc++) { /* * Invalid select codes */ if (sc >= 32 && sc < 132) continue; if (sc == -1) { hw->hw_pa = (caddr_t) GRFIADDR; addr = (caddr_t) IIOV(hw->hw_pa); didmap = 0; } else if (sc == 7 && internalhpib) { hw->hw_pa = (caddr_t) 0x478000; addr = internalhpib = (caddr_t) IIOV(hw->hw_pa); didmap = 0; } else { hw->hw_pa = sctopa(sc); addr = iomap(hw->hw_pa, NBPG); if (addr == 0) { printf(notmappedmsg); continue; } didmap = 1; } if (badaddr(addr)) { if (didmap) iounmap(addr, NBPG); continue; } id_reg = (u_char *) addr; if (sc >= 132) hw->hw_size = (id_reg[0x101] + 1) * 0x100000; else hw->hw_size = DIOCSIZE; hw->hw_kva = addr; hw->hw_id = id_reg[1]; hw->hw_sc = sc; /* * Internal HP-IB on some machines (345/375) doesn't return * consistant id info so we use the info gleaned from the * boot ROMs SYSFLAG. */ if (sc == 7 && internalhpib) { hw->hw_type = C_HPIB; hw++; continue; } /* * XXX: the following could be in a big static table */ switch (hw->hw_id) { /* Null device? */ case 0: break; /* 98644A */ case 2: case 2+128: hw->hw_type = D_COMMDCA; break; /* 98622A */ case 3: hw->hw_type = D_MISC; break; /* 98623A */ case 4: hw->hw_type = D_MISC; break; /* 98642A */ case 5: case 5+128: hw->hw_type = D_COMMDCM; break; /* 345/375 builtin parallel port */ case 6: hw->hw_type = D_PPORT; break; /* 98625A */ case 7: case 7+32: case 7+64: case 7+96: hw->hw_type = C_SCSI; break; /* 98625B */ case 8: hw->hw_type = C_HPIB; break; /* 98287A */ case 9: hw->hw_type = D_KEYBOARD; break; /* 98635A */ case 10: hw->hw_type = D_FPA; break; /* timer */ case 11: hw->hw_type = D_MISC; break; /* 98640A */ case 18: hw->hw_type = D_MISC; break; /* 98643A */ case 21: hw->hw_type = D_LAN; break; /* 98659A */ case 22: hw->hw_type = D_MISC; break; /* 237 display */ case 25: hw->hw_type = D_BITMAP; break; /* quad-wide card */ case 26: hw->hw_type = D_MISC; hw->hw_size *= 4; sc += 3; break; /* 98253A */ case 27: hw->hw_type = D_MISC; break; /* 98627A */ case 28: hw->hw_type = D_BITMAP; break; /* 98633A */ case 29: hw->hw_type = D_BITMAP; break; /* 98259A */ case 30: hw->hw_type = D_MISC; break; /* 8741 */ case 31: hw->hw_type = D_MISC; break; /* 98577A */ case 49: hw->hw_type = C_VME; if (sc < 132) { hw->hw_size *= 2; sc++; } break; /* 98628A */ case 52: case 52+128: hw->hw_type = D_COMMDCL; break; /* bitmap display */ case 57: hw->hw_type = D_BITMAP; hw->hw_secid = id_reg[0x15]; switch (hw->hw_secid) { /* 98700/98710 */ case 1: break; /* 98544-547 topcat */ case 2: break; /* 98720/721 renassiance */ case 4: if (sc < 132) { hw->hw_size *= 2; sc++; } break; /* 98548-98556 catseye */ case 5: case 6: case 7: case 9: break; /* 98730/731 davinci */ case 8: if (sc < 132) { hw->hw_size *= 2; sc++; } break; /* A1096A hyperion */ case 14: break; /* 987xx */ default: break; } break; /* 98644A */ case 66: case 66+128: hw->hw_type = D_COMMDCA; break; /* 98624A */ case 128: hw->hw_type = C_HPIB; break; default: hw->hw_type = D_MISC; break; } /* * Re-map to proper size */ if (didmap) { iounmap(addr, NBPG); addr = iomap(hw->hw_pa, hw->hw_size); if (addr == 0) { printf(notmappedmsg); continue; } hw->hw_kva = addr; } /* * Encode bus type */ if (sc >= 132) hw->hw_type |= B_DIOII; else hw->hw_type |= B_DIO; hw++; }}/* * Allocate/deallocate a cache-inhibited range of kernel virtual address * space mapping the indicated physical address range [pa - pa+size) */caddr_tiomap(pa, size) caddr_t pa; int size;{ int ix, npf; caddr_t kva;#ifdef DEBUG if (((int)pa & PGOFSET) || (size & PGOFSET)) panic("iomap: unaligned");#endif npf = btoc(size); ix = rmalloc(extiomap, npf); if (ix == 0) return(0); kva = extiobase + ctob(ix-1); physaccess(kva, pa, size, PG_RW|PG_CI); return(kva);}iounmap(kva, size) caddr_t kva; int size;{ int ix;#ifdef DEBUG if (((int)kva & PGOFSET) || (size & PGOFSET)) panic("iounmap: unaligned"); if (kva < extiobase || kva >= extiobase + ctob(EIOMAPSIZE)) panic("iounmap: bad address");#endif physunaccess(kva, size); ix = btoc(kva - extiobase) + 1; rmfree(extiomap, btoc(size), ix);}isrinit(){ register int i; for (i = 0; i < NISR; i++) isrqueue[i].isr_forw = isrqueue[i].isr_back = &isrqueue[i];}voidisrlink(isr) register struct isr *isr;{ int i = ISRIPL(isr->isr_ipl); if (i < 0 || i >= NISR) { printf("bad IPL %d\n", i); panic("configure"); } insque(isr, isrqueue[i].isr_back);}/* * Configure swap space and related parameters. */swapconf(){ register struct swdevt *swp; register int nblks; for (swp = swdevt; swp->sw_dev != NODEV; swp++) if (bdevsw[major(swp->sw_dev)].d_psize) { nblks = (*bdevsw[major(swp->sw_dev)].d_psize)(swp->sw_dev); if (nblks != -1 && (swp->sw_nblks == 0 || swp->sw_nblks > nblks)) swp->sw_nblks = nblks; } dumpconf();}#define DOSWAP /* Change swdevt and dumpdev too */u_long bootdev; /* should be dev_t, but not until 32 bits */static char devname[][2] = { 0,0, /* 0 = ct */ 0,0, /* 1 = xx */ 'r','d', /* 2 = rd */ 0,0, /* 3 = sw */ 's','d', /* 4 = rd */};#define PARTITIONMASK 0x7#define PARTITIONSHIFT 3/* * Attempt to find the device from which we were booted. * If we can do so, and not instructed not to do so, * change rootdev to correspond to the load device. */setroot(){ register struct hp_ctlr *hc; register struct hp_device *hd; int majdev, mindev, unit, part, controller, adaptor; dev_t temp, orootdev; struct swdevt *swp; if (boothowto & RB_DFLTROOT || (bootdev & B_MAGICMASK) != (u_long)B_DEVMAGIC) return; majdev = B_TYPE(bootdev); if (majdev >= sizeof(devname) / sizeof(devname[0])) return; adaptor = B_ADAPTOR(bootdev); controller = B_CONTROLLER(bootdev); part = B_PARTITION(bootdev); unit = B_UNIT(bootdev); /* * First, find the controller type which supports this device. */ for (hd = hp_dinit; hd->hp_driver; hd++) if (hd->hp_driver->d_name[0] == devname[majdev][0] && hd->hp_driver->d_name[1] == devname[majdev][1]) break; if (hd->hp_driver == 0) return; /* * Next, find the "controller" (bus adaptor) of that type * corresponding to the adaptor number. */ for (hc = hp_cinit; hc->hp_driver; hc++) if (hc->hp_alive && hc->hp_unit == adaptor && hc->hp_driver == hd->hp_cdriver) break; if (hc->hp_driver == 0) return; /* * Finally, find the "device" (controller or slave) in question * attached to that "controller". */ for (hd = hp_dinit; hd->hp_driver; hd++) if (hd->hp_alive && hd->hp_slave == controller && hd->hp_cdriver == hc->hp_driver && hd->hp_ctlr == hc->hp_unit) break; if (hd->hp_driver == 0) return; /* * XXX note that we are missing one level, the unit, here. * Most HP drives come with one controller per disk. There * are some older drives (e.g. 7946) which have two units * on the same controller but those are typically a disk as * unit 0 and a tape as unit 1. This would have to be * rethought if you ever wanted to boot from other than unit 0. */ if (unit != 0) printf("WARNING: using device at unit 0 of controller\n"); mindev = hd->hp_unit; /* * Form a new rootdev */ mindev = (mindev << PARTITIONSHIFT) + part; orootdev = rootdev; rootdev = makedev(majdev, mindev); /* * If the original rootdev is the same as the one * just calculated, don't need to adjust the swap configuration. */ if (rootdev == orootdev) return; printf("Changing root device to %c%c%d%c\n", devname[majdev][0], devname[majdev][1], mindev >> PARTITIONSHIFT, part + 'a');#ifdef DOSWAP mindev &= ~PARTITIONMASK; for (swp = swdevt; swp->sw_dev != NODEV; swp++) { if (majdev == major(swp->sw_dev) && mindev == (minor(swp->sw_dev) & ~PARTITIONMASK)) { temp = swdevt[0].sw_dev; swdevt[0].sw_dev = swp->sw_dev; swp->sw_dev = temp; break; } } if (swp->sw_dev == NODEV) return; /* * If dumpdev was the same as the old primary swap * device, move it to the new primary swap device. */ if (temp == dumpdev) dumpdev = swdevt[0].sw_dev;#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -