int wdc_isa_probe(struct device *parent, void *match, void *aux) { struct channel_softc ch; struct isa_attach_args *ia = aux; struct cfdata *cf = match; int result = 0; bzero(&ch, sizeof ch); ch.cmd_iot = ia->ia_iot; if (bus_space_map(ch.cmd_iot, ia->ia_iobase, WDC_ISA_REG_NPORTS, 0, &ch.cmd_ioh)) goto out; ch.ctl_iot = ia->ia_iot; if (bus_space_map(ch.ctl_iot, ia->ia_iobase + WDC_ISA_AUXREG_OFFSET, WDC_ISA_AUXREG_NPORTS, 0, &ch.ctl_ioh)) goto outunmap; if (cf->cf_flags & WDC_OPTION_PROBE_VERBOSE) ch.ch_flags |= WDCF_VERBOSE_PROBE; result = wdcprobe(&ch); if (result) { ia->ia_iosize = WDC_ISA_REG_NPORTS; ia->ia_msize = 0; } bus_space_unmap(ch.ctl_iot, ch.ctl_ioh, WDC_ISA_AUXREG_NPORTS); outunmap: bus_space_unmap(ch.cmd_iot, ch.cmd_ioh, WDC_ISA_REG_NPORTS); out: return (result); }
int wdc_spd_match(device_t parent, cfdata_t cf, void *aux) { struct spd_attach_args *spa = aux; struct ata_channel ch; struct wdc_softc wdc; struct wdc_regs wdr; int i, result; if (spa->spa_slot != SPD_HDD) return (0); memset(&wdc, 0, sizeof(wdc)); memset(&ch, 0, sizeof(ch)); ch.ch_atac = &wdc.sc_atac; wdc.regs = &wdr; __wdc_spd_bus_space(&ch); for (i = 0, result = 0; i < 8; i++) { /* 8 sec */ if (result == 0) result = wdcprobe(&ch); delay(1000000); } return (result); }
static int wdc_obio_probe(device_t parent, cfdata_t cfp, void *aux) { struct obio_attach_args *oa = aux; struct ata_channel ch; struct wdc_softc wdc; struct wdc_regs wdr; int result = 0; int i; if (oa->oa_nio < 1) return (0); if (oa->oa_nirq < 1) return (0); if (oa->oa_io[0].or_addr == IOBASEUNK) return (0); if (oa->oa_irq[0].or_irq == IRQUNK) return (0); memset(&wdc, 0, sizeof(wdc)); memset(&ch, 0, sizeof(ch)); ch.ch_atac = &wdc.sc_atac; wdc.regs = &wdr; wdr.cmd_iot = oa->oa_iot; if (bus_space_map(wdr.cmd_iot, oa->oa_io[0].or_addr, WDC_OBIO_REG_SIZE, 0, &wdr.cmd_baseioh)) { goto out; } for (i = 0; i < WDC_OBIO_REG_NPORTS; i++) { if (bus_space_subregion(wdr.cmd_iot, wdr.cmd_baseioh, i * 2, (i == 0) ? 2 : 1, &wdr.cmd_iohs[i])) { goto outunmap; } } wdc_init_shadow_regs(&ch); wdr.ctl_iot = oa->oa_iot; if (bus_space_map(wdr.ctl_iot, oa->oa_io[0].or_addr + WDC_OBIO_AUXREG_OFFSET, WDC_OBIO_AUXREG_SIZE, 0, &wdr.ctl_ioh)) { goto outunmap; } result = wdcprobe(&ch); if (result) { oa->oa_nio = 1; oa->oa_io[0].or_size = WDC_OBIO_REG_SIZE; oa->oa_nirq = 1; oa->oa_niomem = 0; } bus_space_unmap(wdr.ctl_iot, wdr.ctl_ioh, WDC_OBIO_AUXREG_SIZE); outunmap: bus_space_unmap(wdr.cmd_iot, wdr.cmd_baseioh, WDC_OBIO_REG_SIZE); out: return (result); }