📄 ide.c
字号:
if (s[0] != 'i' || s[1] != 'd' || s[2] != 'e') goto bad_option; /* * Look for bus speed option: "idebus=" */ if (s[3] == 'b' && s[4] == 'u' && s[5] == 's') { if (match_parm(&s[6], NULL, vals, 1) != 1) goto bad_option; if (vals[0] >= 20 && vals[0] <= 66) { idebus_parameter = vals[0]; } else printk(" -- BAD BUS SPEED! Expected value from 20 to 66"); goto done; } /* * Look for interface options: "idex=" */ if (s[3] >= '0' && s[3] <= max_hwif) { /* * Be VERY CAREFUL changing this: note hardcoded indexes below * (-8, -9, -10) are reserved to ease the hardcoding. */ static const char *ide_words[] = { "noprobe", "serialize", "minus3", "minus4", "reset", "minus6", "ata66", "minus8", "minus9", "minus10", "four", "qd65xx", "ht6560b", "cmd640_vlb", "dtc2278", "umc8672", "ali14xx", NULL }; hw_regs_t hwregs; hw = s[3] - '0'; hwif = &ide_hwifs[hw]; i = match_parm(&s[4], ide_words, vals, 3); /* * Cryptic check to ensure chipset not already set for hwif. * Note: we can't depend on hwif->chipset here. */ if ((i >= -18 && i <= -11) || (i > 0 && i <= 3)) { /* chipset already specified */ if (is_chipset_set[hw]) goto bad_option; if (i > -18 && i <= -11) { /* these drivers are for "ide0=" only */ if (hw != 0) goto bad_hwif; /* chipset already specified for 2nd port */ if (is_chipset_set[hw+1]) goto bad_option; } is_chipset_set[hw] = 1; printk("\n"); } switch (i) {#ifdef CONFIG_BLK_DEV_ALI14XX case -17: /* "ali14xx" */ probe_ali14xx = 1; goto done;#endif#ifdef CONFIG_BLK_DEV_UMC8672 case -16: /* "umc8672" */ probe_umc8672 = 1; goto done;#endif#ifdef CONFIG_BLK_DEV_DTC2278 case -15: /* "dtc2278" */ probe_dtc2278 = 1; goto done;#endif#ifdef CONFIG_BLK_DEV_CMD640 case -14: /* "cmd640_vlb" */ { extern int cmd640_vlb; /* flag for cmd640.c */ cmd640_vlb = 1; goto done; }#endif#ifdef CONFIG_BLK_DEV_HT6560B case -13: /* "ht6560b" */ probe_ht6560b = 1; goto done;#endif#ifdef CONFIG_BLK_DEV_QD65XX case -12: /* "qd65xx" */ probe_qd65xx = 1; goto done;#endif#ifdef CONFIG_BLK_DEV_4DRIVES case -11: /* "four" drives on one set of ports */ { ide_hwif_t *mate = &ide_hwifs[hw^1]; mate->drives[0].select.all ^= 0x20; mate->drives[1].select.all ^= 0x20; hwif->chipset = mate->chipset = ide_4drives; mate->irq = hwif->irq; memcpy(mate->io_ports, hwif->io_ports, sizeof(hwif->io_ports)); hwif->mate = mate; mate->mate = hwif; hwif->serialized = mate->serialized = 1; goto obsolete_option; }#endif /* CONFIG_BLK_DEV_4DRIVES */ case -10: /* minus10 */ case -9: /* minus9 */ case -8: /* minus8 */ case -6: case -4: case -3: goto bad_option; case -7: /* ata66 */#ifdef CONFIG_BLK_DEV_IDEPCI /* * Use ATA_CBL_PATA40_SHORT so drive side * cable detection is also overriden. */ hwif->cbl = ATA_CBL_PATA40_SHORT; goto obsolete_option;#else goto bad_hwif;#endif case -5: /* "reset" */ hwif->reset = 1; goto obsolete_option; case -2: /* "serialize" */ hwif->mate = &ide_hwifs[hw^1]; hwif->mate->mate = hwif; hwif->serialized = hwif->mate->serialized = 1; goto obsolete_option; case -1: /* "noprobe" */ hwif->noprobe = 1; goto done; case 1: /* base */ vals[1] = vals[0] + 0x206; /* default ctl */ case 2: /* base,ctl */ vals[2] = 0; /* default irq = probe for it */ case 3: /* base,ctl,irq */ memset(&hwregs, 0, sizeof(hwregs)); ide_init_hwif_ports(&hwregs, vals[0], vals[1], &hwif->irq); memcpy(hwif->io_ports, hwregs.io_ports, sizeof(hwif->io_ports)); hwif->irq = vals[2]; hwif->noprobe = 0; hwif->chipset = ide_forced; goto obsolete_option; case 0: goto bad_option; default: printk(" -- SUPPORT NOT CONFIGURED IN THIS KERNEL\n"); return 1; } }bad_option: printk(" -- BAD OPTION\n"); return 1;obsolete_option: printk(" -- OBSOLETE OPTION, WILL BE REMOVED SOON!\n"); return 1;bad_hwif: printk("-- NOT SUPPORTED ON ide%d", hw);done: printk("\n"); return 1;}extern void __init pnpide_init(void);extern void __exit pnpide_exit(void);extern void __init h8300_ide_init(void);/* * probe_for_hwifs() finds/initializes "known" IDE interfaces */static void __init probe_for_hwifs (void){#ifdef CONFIG_IDEPCI_PCIBUS_ORDER ide_scan_pcibus(ide_scan_direction);#endif#ifdef CONFIG_ETRAX_IDE { extern void init_e100_ide(void); init_e100_ide(); }#endif /* CONFIG_ETRAX_IDE */#ifdef CONFIG_BLK_DEV_CMD640 { extern void ide_probe_for_cmd640x(void); ide_probe_for_cmd640x(); }#endif /* CONFIG_BLK_DEV_CMD640 */#ifdef CONFIG_BLK_DEV_IDE_PMAC { extern int pmac_ide_probe(void); (void)pmac_ide_probe(); }#endif /* CONFIG_BLK_DEV_IDE_PMAC */#ifdef CONFIG_BLK_DEV_GAYLE { extern void gayle_init(void); gayle_init(); }#endif /* CONFIG_BLK_DEV_GAYLE */#ifdef CONFIG_BLK_DEV_FALCON_IDE { extern void falconide_init(void); falconide_init(); }#endif /* CONFIG_BLK_DEV_FALCON_IDE */#ifdef CONFIG_BLK_DEV_MAC_IDE { extern void macide_init(void); macide_init(); }#endif /* CONFIG_BLK_DEV_MAC_IDE */#ifdef CONFIG_BLK_DEV_Q40IDE { extern void q40ide_init(void); q40ide_init(); }#endif /* CONFIG_BLK_DEV_Q40IDE */#ifdef CONFIG_BLK_DEV_BUDDHA { extern void buddha_init(void); buddha_init(); }#endif /* CONFIG_BLK_DEV_BUDDHA */#ifdef CONFIG_BLK_DEV_IDEPNP pnpide_init();#endif#ifdef CONFIG_H8300 h8300_ide_init();#endif}/* * Probe module */EXPORT_SYMBOL(ide_lock);static int ide_bus_match(struct device *dev, struct device_driver *drv){ return 1;}static char *media_string(ide_drive_t *drive){ switch (drive->media) { case ide_disk: return "disk"; case ide_cdrom: return "cdrom"; case ide_tape: return "tape"; case ide_floppy: return "floppy"; case ide_optical: return "optical"; default: return "UNKNOWN"; }}static ssize_t media_show(struct device *dev, struct device_attribute *attr, char *buf){ ide_drive_t *drive = to_ide_device(dev); return sprintf(buf, "%s\n", media_string(drive));}static ssize_t drivename_show(struct device *dev, struct device_attribute *attr, char *buf){ ide_drive_t *drive = to_ide_device(dev); return sprintf(buf, "%s\n", drive->name);}static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf){ ide_drive_t *drive = to_ide_device(dev); return sprintf(buf, "ide:m-%s\n", media_string(drive));}static ssize_t model_show(struct device *dev, struct device_attribute *attr, char *buf){ ide_drive_t *drive = to_ide_device(dev); return sprintf(buf, "%s\n", drive->id->model);}static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, char *buf){ ide_drive_t *drive = to_ide_device(dev); return sprintf(buf, "%s\n", drive->id->fw_rev);}static ssize_t serial_show(struct device *dev, struct device_attribute *attr, char *buf){ ide_drive_t *drive = to_ide_device(dev); return sprintf(buf, "%s\n", drive->id->serial_no);}static struct device_attribute ide_dev_attrs[] = { __ATTR_RO(media), __ATTR_RO(drivename), __ATTR_RO(modalias), __ATTR_RO(model), __ATTR_RO(firmware), __ATTR(serial, 0400, serial_show, NULL), __ATTR_NULL};static int ide_uevent(struct device *dev, struct kobj_uevent_env *env){ ide_drive_t *drive = to_ide_device(dev); add_uevent_var(env, "MEDIA=%s", media_string(drive)); add_uevent_var(env, "DRIVENAME=%s", drive->name); add_uevent_var(env, "MODALIAS=ide:m-%s", media_string(drive)); return 0;}static int generic_ide_probe(struct device *dev){ ide_drive_t *drive = to_ide_device(dev); ide_driver_t *drv = to_ide_driver(dev->driver); return drv->probe ? drv->probe(drive) : -ENODEV;}static int generic_ide_remove(struct device *dev){ ide_drive_t *drive = to_ide_device(dev); ide_driver_t *drv = to_ide_driver(dev->driver); if (drv->remove) drv->remove(drive); return 0;}static void generic_ide_shutdown(struct device *dev){ ide_drive_t *drive = to_ide_device(dev); ide_driver_t *drv = to_ide_driver(dev->driver); if (dev->driver && drv->shutdown) drv->shutdown(drive);}struct bus_type ide_bus_type = { .name = "ide", .match = ide_bus_match, .uevent = ide_uevent, .probe = generic_ide_probe, .remove = generic_ide_remove, .shutdown = generic_ide_shutdown, .dev_attrs = ide_dev_attrs, .suspend = generic_ide_suspend, .resume = generic_ide_resume,};EXPORT_SYMBOL_GPL(ide_bus_type);/* * This is gets invoked once during initialization, to set *everything* up */static int __init ide_init(void){ int ret; printk(KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n"); system_bus_speed = ide_system_bus_speed(); ret = bus_register(&ide_bus_type); if (ret < 0) { printk(KERN_WARNING "IDE: bus_register error: %d\n", ret); return ret; } init_ide_data(); proc_ide_create();#ifdef CONFIG_BLK_DEV_ALI14XX if (probe_ali14xx) (void)ali14xx_init();#endif#ifdef CONFIG_BLK_DEV_UMC8672 if (probe_umc8672) (void)umc8672_init();#endif#ifdef CONFIG_BLK_DEV_DTC2278 if (probe_dtc2278) (void)dtc2278_init();#endif#ifdef CONFIG_BLK_DEV_HT6560B if (probe_ht6560b) (void)ht6560b_init();#endif#ifdef CONFIG_BLK_DEV_QD65XX if (probe_qd65xx) (void)qd65xx_init();#endif /* Probe for special PCI and other "known" interface chipsets. */ probe_for_hwifs(); return 0;}#ifdef MODULEstatic char *options = NULL;module_param(options, charp, 0);MODULE_LICENSE("GPL");static void __init parse_options (char *line){ char *next = line; if (line == NULL || !*line) return; while ((line = next) != NULL) { if ((next = strchr(line,' ')) != NULL) *next++ = 0; if (!ide_setup(line)) printk (KERN_INFO "Unknown option '%s'\n", line); }}int __init init_module (void){ parse_options(options); return ide_init();}void __exit cleanup_module (void){ int index; for (index = 0; index < MAX_HWIFS; ++index) ide_unregister(index);#ifdef CONFIG_BLK_DEV_IDEPNP pnpide_exit();#endif proc_ide_destroy(); bus_unregister(&ide_bus_type);}#else /* !MODULE */__setup("", ide_setup);module_init(ide_init);#endif /* MODULE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -