📄 autoconf.c
字号:
/* * Found a match. We need to set hp_ctlr/hp_slave properly * for the init routines but we also need to remember all * the old values in case this doesn't pan out. */ if (match_s) { hd = match_s; old_c = hd->hp_ctlr; old_s = hd->hp_slave; if (hd->hp_ctlr < 0) hd->hp_ctlr = new_c; if (hd->hp_slave < 0) hd->hp_slave = new_s;#ifdef DEBUG if (acdebug) printf("looking for %s%d at slave %d...", hd->hp_driver->d_name, hd->hp_unit, hd->hp_slave);#endif if ((*hd->hp_driver->d_init)(hd)) {#ifdef DEBUG if (acdebug) printf("found\n");#endif printf("%s%d at %s%d, slave %d", hd->hp_driver->d_name, hd->hp_unit, hc->hp_driver->d_name, hd->hp_ctlr, hd->hp_slave); if (hd->hp_flags) printf(" flags 0x%x", hd->hp_flags); printf("\n"); hd->hp_alive = 1; if (hd->hp_dk && dkn < DK_NDRIVE) hd->hp_dk = dkn++; else hd->hp_dk = -1; rescan = 1; } else {#ifdef DEBUG if (acdebug) printf("not found\n");#endif hd->hp_ctlr = old_c; hd->hp_slave = old_s; } /* * XXX: This should be handled better. * Re-scan a slave. There are two reasons to do this. * 1. It is possible to have both a tape and disk * (e.g. 7946) or two disks (e.g. 9122) at the * same slave address. Here we need to rescan * looking only at entries with a different * physical unit number (hp_flags). * 2. It is possible that an init failed because the * slave was there but of the wrong type. In this * case it may still be possible to match the slave * to another ioconf entry of a different type. * Here we need to rescan looking only at entries * of different types. * In both cases we avoid looking at undesirable * ioconf entries of the same type by setting their * alive fields to -1. */ if (rescan) { for (hd = hp_dinit; hd->hp_driver; hd++) { if (hd->hp_alive) continue; if (match_s->hp_alive == 1) { /* 1 */ if (hd->hp_flags == match_s->hp_flags) hd->hp_alive = -1; } else { /* 2 */ if (hd->hp_driver == match_s->hp_driver) hd->hp_alive = -1; } } s--; continue; } } /* * Reset bogon alive fields prior to attempting next slave */ for (hd = hp_dinit; hd->hp_driver; hd++) if (hd->hp_alive == -1) hd->hp_alive = 0; }}same_hw_device(hw, hd) struct hp_hw *hw; struct hp_device *hd;{ int found = 0; switch (hw->hw_type & ~B_MASK) { case C_SCSI: found = dr_type(hd->hp_driver, "sc"); break; case D_LAN: found = dr_type(hd->hp_driver, "le"); break; case D_SIO: found = dr_type(hd->hp_driver, "sio"); break; case D_BMC: found = dr_type(hd->hp_driver, "bmc"); break; default: break; } return(found);}/* * Scan the IO space looking for devices. */#define setup_hw(hw, addr, sc, type, id) \ (hw)->hw_pa = addr; \ (hw)->hw_kva = addr; \ (hw)->hw_id = id; \ (hw)->hw_type = type; \ (hw)->hw_sc = scfind_devs(){ register struct hp_hw *hw = sc_table;#include "bmc.h"#if NBMC > 0 setup_hw(hw, (char *) 0x51000004, 0x5, D_BMC, 0x5); hw->hw_secid = 0; hw++;#endif setup_hw(hw, (char *) 0x51000000, 0x5, D_SIO, 0x5); hw->hw_secid = 0; hw++;#if NBMC == 0#if NSIO > 1 setup_hw(hw, (char *) 0x51000004, 0x5, D_SIO, 0x5); hw->hw_secid = 0; hw++;#endif #endif setup_hw(hw, (char *) 0xe1000000, 0xe, C_SCSI, 0xe); hw++; if (!badaddr((caddr_t) 0xf1000000)) { setup_hw(hw, (char *) 0xf1000000, 0xf, D_LAN, 0xf); hw++; }#if defined(LUNA2) && defined(notyet) if (machineid == LUNA_II) { setup_hw(hw, (char *) 0xe1000040, 0xe, C_SCSI, 0xe); hw++; if (!badaddr((caddr_t) 0xf1000008)) { setup_hw(hw, (char *) 0xf1000008, 0xf, D_LAN, 0xf); hw++; } }#endif}/* * 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) { printf("Wrong B_DEVMAGIC\n"); return; } majdev = B_TYPE(bootdev); if (majdev > sizeof(devname) / sizeof(devname[0])) { printf("Wrong Major Number: %d", majdev); 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) { printf("Device type mismatch: %c%c\n", devname[majdev][0], devname[majdev][1]); 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) { printf("Controller is not available\n"); 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) { printf("Device not found\n"); return; } 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}showroot(){ register int majdev, mindev; register struct swdevt *swp; majdev = major(rootdev); mindev = minor(rootdev); printf("root on %c%c%d%c ", devname[majdev][0], devname[majdev][1], mindev >> PARTITIONSHIFT, (mindev & PARTITIONMASK) + 'a'); swp = swdevt; majdev = major(swp->sw_dev); mindev = minor(swp->sw_dev); printf("swap on %c%c%d%c ", devname[majdev][0], devname[majdev][1], mindev >> PARTITIONSHIFT, (mindev & PARTITIONMASK) + 'a'); swp++; for (; swp->sw_dev != NODEV; swp++) { majdev = major(swp->sw_dev); mindev = minor(swp->sw_dev); printf("and %c%c%d%c ", devname[majdev][0], devname[majdev][1], mindev >> PARTITIONSHIFT, (mindev & PARTITIONMASK) + 'a'); } majdev = major(dumpdev); mindev = minor(dumpdev); printf(" dump on %c%c%d%c\n", devname[majdev][0], devname[majdev][1], mindev >> PARTITIONSHIFT, (mindev & PARTITIONMASK) + 'a');}strcmp(s1, s2) register char *s1, *s2;{ while (*s1 == *s2++) if (*s1++=='\0') return (0); return (*s1 - *--s2);}strncmp(s1, s2, n) register char *s1, *s2; register unsigned int n;{ if (n == 0) return (0); do { if (*s1 != *s2++) return (*(unsigned char *)s1 - *(unsigned char *)--s2); if (*s1++ == 0) break; } while (--n != 0); return (0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -