static int isavga_probe(device_t dev) { video_adapter_t adp; int error; /* No pnp support */ if (isa_get_vendorid(dev)) return (ENXIO); error = vga_probe_unit(device_get_unit(dev), &adp, device_get_flags(dev)); if (error == 0) { device_set_desc(dev, "Generic ISA VGA"); bus_set_resource(dev, SYS_RES_IOPORT, 0, adp.va_io_base, adp.va_io_size); bus_set_resource(dev, SYS_RES_MEMORY, 0, adp.va_mem_base, adp.va_mem_size); #if 0 isa_set_port(dev, adp.va_io_base); isa_set_portsize(dev, adp.va_io_size); isa_set_maddr(dev, adp.va_mem_base); isa_set_msize(dev, adp.va_mem_size); #endif } return (error); }
static int scd_isa_probe (device_t dev) { struct scd_softc * sc; int error; /* No pnp support */ if (isa_get_vendorid(dev)) return (ENXIO); /* IO port must be configured. */ if (bus_get_resource_start(dev, SYS_RES_IOPORT, 0) == 0) return (ENXIO); sc = device_get_softc(dev); sc->dev = dev; sc->port_rid = 0; sc->port_type = SYS_RES_IOPORT; error = scd_alloc_resources(dev); if (error) goto fail; error = scd_probe(sc); if (error) { device_printf(dev, "Probe failed.\n"); goto fail; } device_set_desc(dev, sc->data.name); fail: scd_release_resources(dev); return (error); }
static int ata_cbus_probe(device_t dev) { struct resource *io; int rid; rman_res_t tmp; /* dont probe PnP devices */ if (isa_get_vendorid(dev)) return (ENXIO); /* allocate the ioport range */ rid = ATA_IOADDR_RID; if (!(io = bus_alloc_resource_anywhere(dev, SYS_RES_IOPORT, &rid, ATA_PC98_IOSIZE, RF_ACTIVE))) return ENOMEM; /* calculate & set the altport range */ rid = ATA_PC98_CTLADDR_RID; if (bus_get_resource(dev, SYS_RES_IOPORT, rid, &tmp, &tmp)) { bus_set_resource(dev, SYS_RES_IOPORT, rid, rman_get_start(io)+ATA_PC98_CTLOFFSET, ATA_CTLIOSIZE); } /* calculate & set the bank range */ rid = ATA_PC98_BANKADDR_RID; if (bus_get_resource(dev, SYS_RES_IOPORT, rid, &tmp, &tmp)) { bus_set_resource(dev, SYS_RES_IOPORT, rid, ATA_PC98_BANK, ATA_PC98_BANKIOSIZE); } bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io); return 0; }
static int pckbdprobe(device_t dev) { struct resource *res; int error, rid; /* Check isapnp ids */ if (isa_get_vendorid(dev)) return (ENXIO); device_set_desc(dev, "PC-98 Keyboard"); rid = 0; res = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, pckbd_iat, 2, RF_ACTIVE); if (res == NULL) return ENXIO; isa_load_resourcev(res, pckbd_iat, 2); error = pckbd_probe_unit(dev, isa_get_port(dev), (1 << isa_get_irq(dev)), device_get_flags(dev)); bus_release_resource(dev, SYS_RES_IOPORT, rid, res); return (error); }
/*---------------------------------------------------------------------------* * probe for ISA PnP cards *---------------------------------------------------------------------------*/ static int isic_pnp_probe(device_t dev) { struct isic_pnp_ids *ids; /* pnp id's */ char *string = NULL; /* the name */ u_int32_t vend_id = isa_get_vendorid(dev); /* vendor id */ /* search table of knowd id's */ for(ids = isic_pnp_ids; ids->vend_id != 0; ids++) { if(vend_id == ids->vend_id) { string = ids->id_str; break; } } if(string) /* set name if we have one */ { device_set_desc(dev, string); /* set description */ return 0; } else { return ENXIO; } }
static int dpt_isa_probe (device_t dev) { dpt_conf_t * conf; u_int32_t io_base; /* No pnp support */ if (isa_get_vendorid(dev)) return (ENXIO); if ((io_base = bus_get_resource_start(dev, SYS_RES_IOPORT, 0)) == 0) return (ENXIO); if (dpt_isa_valid_ioport(io_base)) ; conf = dpt_pio_get_conf(io_base); if (!conf) { printf("dpt: dpt_pio_get_conf() failed.\n"); return (ENXIO); } if (dpt_isa_valid_irq(conf->IRQ)) ; device_set_desc(dev, "ISA DPT SCSI controller"); bus_set_resource(dev, SYS_RES_IRQ, 0, conf->IRQ, 1); bus_set_resource(dev, SYS_RES_DRQ, 0, ((8 - conf->DMA_channel) & 7), 1); return 0; }
/*---------------------------------------------------------------------------* * probe for ISA non-PnP cards *---------------------------------------------------------------------------*/ static int isic_isa_probe(device_t dev) { int ret = ENXIO; if(isa_get_vendorid(dev)) /* no PnP probes here */ return ENXIO; switch(device_get_flags(dev)) { #ifdef TEL_S0_16 case CARD_TYPEP_16: ret = isic_probe_s016(dev); break; #endif #ifdef TEL_S0_8 case CARD_TYPEP_8: ret = isic_probe_s08(dev); break; #endif #ifdef ELSA_PCC16 case CARD_TYPEP_PCC16: ret = isic_probe_Epcc16(dev); break; #endif #ifdef TEL_S0_16_3 case CARD_TYPEP_16_3: ret = isic_probe_s0163(dev); break; #endif #ifdef AVM_A1 case CARD_TYPEP_AVMA1: ret = isic_probe_avma1(dev); break; #endif #ifdef USR_STI case CARD_TYPEP_USRTA: ret = isic_probe_usrtai(dev); break; #endif #ifdef ITKIX1 case CARD_TYPEP_ITKIX1: ret = isic_probe_itkix1(dev); break; #endif default: kprintf("isic%d: probe, unknown flag: %d\n", device_get_unit(dev), device_get_flags(dev)); break; } return(ret); }
static int sbc_probe(device_t dev) { char *s = NULL; u_int32_t lid, vid; lid = isa_get_logicalid(dev); vid = isa_get_vendorid(dev); if (lid) { if (lid == 0x01000000 && vid != 0x01009305) /* ALS0001 */ return ENXIO; /* Check pnp ids */ return ISA_PNP_PROBE(device_get_parent(dev), dev, sbc_ids); } else { int rid = 0, ver; struct resource *io; #ifdef PC98 io = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, pcm_iat, 16, RF_ACTIVE); #else io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 16, RF_ACTIVE); #endif if (!io) goto bad; #ifdef PC98 isa_load_resourcev(io, pcm_iat, 16); #endif if (sb_reset_dsp(io)) goto bad2; ver = sb_identify_board(io); if (ver == 0) goto bad2; switch ((ver & 0x00000f00) >> 8) { case 1: device_set_desc(dev, "SoundBlaster 1.0 (not supported)"); s = NULL; break; case 2: s = "SoundBlaster 2.0"; break; case 3: s = (ver & 0x0000f000)? "ESS 488" : "SoundBlaster Pro"; break; case 4: s = "SoundBlaster 16"; break; case 5: s = (ver & 0x00000008)? "ESS 688" : "ESS 1688"; break; } if (s) device_set_desc(dev, s); bad2: bus_release_resource(dev, SYS_RES_IOPORT, rid, io); bad: return s? 0 : ENXIO; } }
static int fe_isa_probe(device_t dev) { struct fe_softc * sc; int error; /* Check isapnp ids */ if (isa_get_vendorid(dev)) return (ENXIO); /* Prepare for the softc struct. */ sc = device_get_softc(dev); sc->sc_unit = device_get_unit(dev); /* Probe for supported boards. */ #ifdef PC98 if ((error = fe_probe_re1000(dev)) == 0) goto end; fe_release_resource(dev); if ((error = fe_probe_cnet9ne(dev)) == 0) goto end; fe_release_resource(dev); if ((error = fe_probe_rex(dev)) == 0) goto end; fe_release_resource(dev); #endif if ((error = fe_probe_ssi(dev)) == 0) goto end; fe_release_resource(dev); if ((error = fe_probe_jli(dev)) == 0) goto end; fe_release_resource(dev); if ((error = fe_probe_lnx(dev)) == 0) goto end; fe_release_resource(dev); if ((error = fe_probe_ubn(dev)) == 0) goto end; fe_release_resource(dev); if ((error = fe_probe_gwy(dev)) == 0) goto end; fe_release_resource(dev); end: if (error == 0) error = fe_alloc_irq(dev, 0); fe_release_resource(dev); return (error); }
static int release_resource(sc_p scp) { int i, lid, flags; device_t dev; flags = 0; if (isa_get_vendorid(scp->dev)) lid = isa_get_logicalid(scp->dev); else { lid = LOGICALID_NOPNP; flags = device_get_flags(scp->dev); } switch(lid) { case LOGICALID_PCM: case LOGICALID_NOPNP: /* XXX Non-PnP */ for (i = 0 ; i < NELEM(scp->io) ; i++) { if (scp->io[i] != NULL) { bus_release_resource(scp->dev, SYS_RES_IOPORT, scp->io_rid[i], scp->io[i]); scp->io[i] = NULL; } } if (scp->irq != NULL) { bus_release_resource(scp->dev, SYS_RES_IRQ, scp->irq_rid, scp->irq); scp->irq = NULL; } for (i = 0 ; i < NELEM(scp->drq) ; i++) { if (scp->drq[i] != NULL) { bus_release_resource(scp->dev, SYS_RES_DRQ, scp->drq_rid[i], scp->drq[i]); scp->drq[i] = NULL; } } break; case LOGICALID_OPL: if (scp->io[0] != NULL) { bus_release_resource(scp->dev, SYS_RES_IOPORT, scp->io_rid[0], scp->io[0]); scp->io[0] = NULL; } break; case LOGICALID_MIDI: if (scp->io[0] != NULL) { bus_release_resource(scp->dev, SYS_RES_IOPORT, scp->io_rid[0], scp->io[0]); scp->io[0] = NULL; } if (scp->irq != NULL) { /* The irq is shared with pcm audio. */ dev = find_masterdev(scp); if (dev == NULL) return (1); BUS_RELEASE_RESOURCE(dev, NULL, SYS_RES_IOPORT, scp->irq_rid, scp->irq); scp->irq = NULL; } break; } return (0); }
static int wds_probe(device_t dev) { struct wds *wp; int error = 0; int irq; /* No pnp support */ if (isa_get_vendorid(dev)) return (ENXIO); wp = (struct wds *) device_get_softc(dev); wp->unit = device_get_unit(dev); wp->dev = dev; wp->addr = bus_get_resource_start(dev, SYS_RES_IOPORT, 0 /*rid*/); if (wp->addr == 0 || wp->addr <0x300 || wp->addr > 0x3f8 || wp->addr & 0x7) { device_printf(dev, "invalid port address 0x%x\n", wp->addr); return (ENXIO); } if (bus_set_resource(dev, SYS_RES_IOPORT, 0, wp->addr, WDS_NPORTS) < 0) return (ENXIO); /* get the DRQ */ wp->drq = bus_get_resource_start(dev, SYS_RES_DRQ, 0 /*rid*/); if (wp->drq < 5 || wp->drq > 7) { device_printf(dev, "invalid DRQ %d\n", wp->drq); return (ENXIO); } /* get the IRQ */ irq = bus_get_resource_start(dev, SYS_RES_IRQ, 0 /*rid*/); if (irq < 3) { device_printf(dev, "invalid IRQ %d\n", irq); return (ENXIO); } wp->port_rid = 0; wp->port_r = bus_alloc_resource(dev, SYS_RES_IOPORT, &wp->port_rid, /*start*/ 0, /*end*/ ~0, /*count*/ 0, RF_ACTIVE); if (wp->port_r == NULL) return (ENXIO); error = wds_preinit(wp); /* * We cannot hold resources between probe and * attach as we may never be attached. */ wds_free_resources(wp); return (error); }
static int scprobe(device_t dev) { /* No pnp support */ if (isa_get_vendorid(dev)) return (ENXIO); device_set_desc(dev, "System console"); return sc_probe_unit(device_get_unit(dev), device_get_flags(dev)); }
static int pckbdprobe(device_t dev) { /* Check isapnp ids */ if (isa_get_vendorid(dev)) return (ENXIO); device_set_desc(dev, "PC-98 Keyboard"); return pckbd_probe_unit(device_get_unit(dev), isa_get_port(dev), (1 << isa_get_irq(dev)), device_get_flags(dev)); }
static device_t find_masterdev(sc_p scp) { int i, units; devclass_t devclass; device_t dev; devclass = device_get_devclass(scp->dev); units = devclass_get_maxunit(devclass); dev = NULL; for (i = 0 ; i < units ; i++) { dev = devclass_get_device(devclass, i); if (isa_get_vendorid(dev) == isa_get_vendorid(scp->dev) && isa_get_logicalid(dev) == LOGICALID_PCM && isa_get_serial(dev) == isa_get_serial(scp->dev)) break; } if (i == units) return (NULL); return (dev); }
static int fdc_cbus_probe(device_t dev) { int error; struct fdc_data *fdc; fdc = device_get_softc(dev); /* Check pnp ids */ if (isa_get_vendorid(dev)) return (ENXIO); /* Attempt to allocate our resources for the duration of the probe */ error = fdc_cbus_alloc_resources(dev, fdc); if (!error) error = fdc_initial_reset(fdc); fdc_release_resources(fdc); return (error); }
static int atkbdc_probe(device_t dev) { int error; int rid; struct resource *port; /* Check isapnp ids */ if (isa_get_vendorid(dev)) return (ENXIO); device_set_desc(dev, "keyboard controller (i8042)"); rid = 0; port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, IO_KBDSIZE, RF_ACTIVE); if (!port) return ENXIO; error = atkbdc_probe_unit(device_get_unit(dev), rman_get_start(port)); bus_release_resource(dev, SYS_RES_IOPORT, rid, port); return error; }
int lpt_probe(device_t dev) { #define PC98_OLD_LPT 0x40 #define PC98_IEEE_1284_FUNCTION 0x149 int rid; struct resource *res; /* Check isapnp ids */ if (isa_get_vendorid(dev)) return ENXIO; rid = 0; res = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, lpt_iat, 4, RF_ACTIVE); if (res == NULL) return ENXIO; isa_load_resourcev(res, lpt_iat, 4); if (isa_get_port(dev) == PC98_OLD_LPT) { unsigned int pc98_ieee_mode, tmp; tmp = inb(PC98_IEEE_1284_FUNCTION); pc98_ieee_mode = tmp; if ((tmp & 0x10) == 0x10) { outb(PC98_IEEE_1284_FUNCTION, tmp & ~0x10); tmp = inb(PC98_IEEE_1284_FUNCTION); if ((tmp & 0x10) != 0x10) { outb(PC98_IEEE_1284_FUNCTION, pc98_ieee_mode); bus_release_resource(dev, SYS_RES_IOPORT, rid, res); return ENXIO; } } } bus_release_resource(dev, SYS_RES_IOPORT, rid, res); return 0; }
static int gdcprobe(device_t dev) { int error; /* Check isapnp ids */ if (isa_get_vendorid(dev)) return (ENXIO); device_set_desc(dev, "Generic GDC"); error = gdc_alloc_resource(dev); if (error) return (error); error = gdc_probe_unit(device_get_unit(dev), device_get_softc(dev), device_get_flags(dev)); gdc_release_resource(dev); return (error); }
static int pnp_parse_desc(device_t dev, u_char tag, u_char *res, int len, struct isa_config *config, int ldn) { char buf[100]; u_int32_t id; u_int32_t compat_id; int temp; id = isa_get_logicalid(dev); if (PNP_RES_TYPE(tag) == 0) { /* Small resource */ switch (PNP_SRES_NUM(tag)) { case PNP_TAG_VERSION: case PNP_TAG_VENDOR: /* these descriptors are quietly ignored */ break; case PNP_TAG_LOGICAL_DEVICE: case PNP_TAG_START_DEPENDANT: case PNP_TAG_END_DEPENDANT: if (bootverbose) pnp_printf(id, "unexpected small tag %d\n", PNP_SRES_NUM(tag)); /* shouldn't happen; quit now */ return (1); case PNP_TAG_COMPAT_DEVICE: /* * Got a compatible device id resource. * Should keep a list of compat ids in the device. */ bcopy(res, &compat_id, 4); if (isa_get_compatid(dev) == 0) isa_set_compatid(dev, compat_id); break; case PNP_TAG_IRQ_FORMAT: if (config->ic_nirq == ISA_NIRQ) { pnp_printf(id, "too many irqs\n"); return (1); } if (I16(res) == 0) { /* a null descriptor */ config->ic_irqmask[config->ic_nirq] = 0; config->ic_nirq++; break; } if (bootverbose) pnp_printf(id, "adding irq mask %#02x\n", I16(res)); config->ic_irqmask[config->ic_nirq] = I16(res); config->ic_nirq++; break; case PNP_TAG_DMA_FORMAT: if (config->ic_ndrq == ISA_NDRQ) { pnp_printf(id, "too many drqs\n"); return (1); } if (res[0] == 0) { /* a null descriptor */ config->ic_drqmask[config->ic_ndrq] = 0; config->ic_ndrq++; break; } if (bootverbose) pnp_printf(id, "adding dma mask %#02x\n", res[0]); config->ic_drqmask[config->ic_ndrq] = res[0]; config->ic_ndrq++; break; case PNP_TAG_IO_RANGE: if (config->ic_nport == ISA_NPORT) { pnp_printf(id, "too many ports\n"); return (1); } if (res[6] == 0) { /* a null descriptor */ config->ic_port[config->ic_nport].ir_start = 0; config->ic_port[config->ic_nport].ir_end = 0; config->ic_port[config->ic_nport].ir_size = 0; config->ic_port[config->ic_nport].ir_align = 0; config->ic_nport++; break; } if (bootverbose) { pnp_printf(id, "adding io range " "%#x-%#x, size=%#x, " "align=%#x\n", I16(res + 1), I16(res + 3) + res[6]-1, res[6], res[5]); } config->ic_port[config->ic_nport].ir_start = I16(res + 1); config->ic_port[config->ic_nport].ir_end = I16(res + 3) + res[6] - 1; config->ic_port[config->ic_nport].ir_size = res[6]; if (res[5] == 0) { /* Make sure align is at least one */ res[5] = 1; } config->ic_port[config->ic_nport].ir_align = res[5]; config->ic_nport++; pnp_check_quirks(isa_get_vendorid(dev), isa_get_logicalid(dev), ldn, config); break; case PNP_TAG_IO_FIXED: if (config->ic_nport == ISA_NPORT) { pnp_printf(id, "too many ports\n"); return (1); } if (res[2] == 0) { /* a null descriptor */ config->ic_port[config->ic_nport].ir_start = 0; config->ic_port[config->ic_nport].ir_end = 0; config->ic_port[config->ic_nport].ir_size = 0; config->ic_port[config->ic_nport].ir_align = 0; config->ic_nport++; break; } if (bootverbose) { pnp_printf(id, "adding fixed io range " "%#x-%#x, size=%#x, " "align=%#x\n", I16(res), I16(res) + res[2] - 1, res[2], 1); } config->ic_port[config->ic_nport].ir_start = I16(res); config->ic_port[config->ic_nport].ir_end = I16(res) + res[2] - 1; config->ic_port[config->ic_nport].ir_size = res[2]; config->ic_port[config->ic_nport].ir_align = 1; config->ic_nport++; break; case PNP_TAG_END: if (bootverbose) pnp_printf(id, "end config\n"); return (1); default: /* Skip this resource */ pnp_printf(id, "unexpected small tag %d\n", PNP_SRES_NUM(tag)); break; } } else { /* Large resource */ switch (PNP_LRES_NUM(tag)) { case PNP_TAG_ID_UNICODE: case PNP_TAG_LARGE_VENDOR: /* these descriptors are quietly ignored */ break; case PNP_TAG_ID_ANSI: if (len > sizeof(buf) - 1) len = sizeof(buf) - 1; bcopy(res, buf, len); /* * Trim trailing spaces and garbage. */ while (len > 0 && buf[len - 1] <= ' ') len--; buf[len] = '\0'; device_set_desc_copy(dev, buf); break; case PNP_TAG_MEMORY_RANGE: if (config->ic_nmem == ISA_NMEM) { pnp_printf(id, "too many memory ranges\n"); return (1); } if (I16(res + 7) == 0) { /* a null descriptor */ config->ic_mem[config->ic_nmem].ir_start = 0; config->ic_mem[config->ic_nmem].ir_end = 0; config->ic_mem[config->ic_nmem].ir_size = 0; config->ic_mem[config->ic_nmem].ir_align = 0; config->ic_nmem++; break; } if (bootverbose) { temp = I16(res + 7) << 8; pnp_printf(id, "adding memory range " "%#x-%#x, size=%#x, " "align=%#x\n", I16(res + 1) << 8, (I16(res + 3) << 8) + temp - 1, temp, I16(res + 5)); } config->ic_mem[config->ic_nmem].ir_start = I16(res + 1) << 8; config->ic_mem[config->ic_nmem].ir_end = (I16(res + 3) << 8) + (I16(res + 7) << 8) - 1; config->ic_mem[config->ic_nmem].ir_size = I16(res + 7) << 8; config->ic_mem[config->ic_nmem].ir_align = I16(res + 5); if (!config->ic_mem[config->ic_nmem].ir_align) config->ic_mem[config->ic_nmem].ir_align = 0x10000; config->ic_nmem++; break; case PNP_TAG_MEMORY32_RANGE: if (config->ic_nmem == ISA_NMEM) { pnp_printf(id, "too many memory ranges\n"); return (1); } if (I32(res + 13) == 0) { /* a null descriptor */ config->ic_mem[config->ic_nmem].ir_start = 0; config->ic_mem[config->ic_nmem].ir_end = 0; config->ic_mem[config->ic_nmem].ir_size = 0; config->ic_mem[config->ic_nmem].ir_align = 0; config->ic_nmem++; break; } if (bootverbose) { pnp_printf(id, "adding memory32 range " "%#x-%#x, size=%#x, " "align=%#x\n", I32(res + 1), I32(res + 5) + I32(res + 13) - 1, I32(res + 13), I32(res + 9)); } config->ic_mem[config->ic_nmem].ir_start = I32(res + 1); config->ic_mem[config->ic_nmem].ir_end = I32(res + 5) + I32(res + 13) - 1; config->ic_mem[config->ic_nmem].ir_size = I32(res + 13); config->ic_mem[config->ic_nmem].ir_align = I32(res + 9); config->ic_nmem++; break; case PNP_TAG_MEMORY32_FIXED: if (config->ic_nmem == ISA_NMEM) { pnp_printf(id, "too many memory ranges\n"); return (1); } if (I32(res + 5) == 0) { /* a null descriptor */ config->ic_mem[config->ic_nmem].ir_start = 0; config->ic_mem[config->ic_nmem].ir_end = 0; config->ic_mem[config->ic_nmem].ir_size = 0; config->ic_mem[config->ic_nmem].ir_align = 0; break; } if (bootverbose) { pnp_printf(id, "adding fixed memory32 range " "%#x-%#x, size=%#x\n", I32(res + 1), I32(res + 1) + I32(res + 5) - 1, I32(res + 5)); } config->ic_mem[config->ic_nmem].ir_start = I32(res + 1); config->ic_mem[config->ic_nmem].ir_end = I32(res + 1) + I32(res + 5) - 1; config->ic_mem[config->ic_nmem].ir_size = I32(res + 5); config->ic_mem[config->ic_nmem].ir_align = 1; config->ic_nmem++; break; default: /* Skip this resource */ pnp_printf(id, "unexpected large tag %d\n", PNP_SRES_NUM(tag)); break; } } return (0); }
/* * Check if the device can be found at the port given * and if so, set it up ready for further work * as an argument, takes the isa_device structure from * autoconf.c */ static int bt_isa_probe(device_t dev) { /* * find unit and check we have that many defined */ int port_index; int max_port_index; /* No pnp support */ if (isa_get_vendorid(dev)) return (ENXIO); port_index = 0; max_port_index = BT_NUM_ISAPORTS - 1; /* * Bound our board search if the user has * specified an exact port. */ bt_find_probe_range(isa_get_port(dev), &port_index, &max_port_index); if (port_index < 0) return (ENXIO); /* Attempt to find an adapter */ for (;port_index <= max_port_index; port_index++) { struct bt_probe_info info; u_int ioport; ioport = bt_iop_from_bio(port_index); /* * Ensure this port has not already been claimed already * by a PCI, EISA or ISA adapter. */ if (bt_check_probed_iop(ioport) != 0) continue; /* Initialise the softc for use during probing */ if (bt_isa_alloc_resources(dev, ioport, ioport + BT_NREGS -1) != 0) continue; /* We're going to attempt to probe it now, so mark it probed */ bt_mark_probed_bio(port_index); if (bt_port_probe(dev, &info) != 0) { if (bootverbose) kprintf("bt_isa_probe: Probe failed at 0x%x\n", ioport); bt_isa_release_resources(dev); continue; } bt_isa_release_resources(dev); bus_set_resource(dev, SYS_RES_DRQ, 0, info.drq, 1, -1); bus_set_resource(dev, SYS_RES_IRQ, 0, info.irq, 1, machintr_legacy_intr_cpuid(info.irq)); return (0); } return (ENXIO); }
int lpt_probe(device_t dev) { #ifdef PC98 #define PC98_OLD_LPT 0x40 #define PC98_IEEE_1284_FUNCTION 0x149 int rid; struct resource *res; /* Check isapnp ids */ if (isa_get_vendorid(dev)) return ENXIO; rid = 0; res = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, lpt_iat, 4, RF_ACTIVE); if (res == NULL) return ENXIO; isa_load_resourcev(res, lpt_iat, 4); if (isa_get_port(dev) == PC98_OLD_LPT) { unsigned int pc98_ieee_mode, tmp; tmp = inb(PC98_IEEE_1284_FUNCTION); pc98_ieee_mode = tmp; if ((tmp & 0x10) == 0x10) { outb(PC98_IEEE_1284_FUNCTION, tmp & ~0x10); tmp = inb(PC98_IEEE_1284_FUNCTION); if ((tmp & 0x10) != 0x10) { outb(PC98_IEEE_1284_FUNCTION, pc98_ieee_mode); bus_release_resource(dev, SYS_RES_IOPORT, rid, res); return ENXIO; } } } bus_release_resource(dev, SYS_RES_IOPORT, rid, res); return 0; #else int port; static short next_bios_lpt = 0; int status; static u_char testbyte[18] = { 0x55, /* alternating zeros */ 0xaa, /* alternating ones */ 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f, /* walking zero */ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 /* walking one */ }; int i; /* * Make sure there is some way for lptopen to see that * the port is not configured * This 0 will remain if the port isn't attached */ (lpt_sc + dvp->id_unit)->sc_port = 0; status = IO_LPTSIZE; /* If port not specified, use bios list */ if(dvp->id_iobase < 0) { /* port? */ if((next_bios_lpt < BIOS_MAX_LPT) && (*(BIOS_PORTS+next_bios_lpt) != 0) ) { dvp->id_iobase = *(BIOS_PORTS+next_bios_lpt++); goto end_probe; } else return (0); } /* Port was explicitly specified */ /* This allows probing of ports unknown to the BIOS */ port = dvp->id_iobase + lpt_data; for (i = 0; i < 18; i++) { if (!lpt_port_test(port, testbyte[i], 0xff)) { status = 0; goto end_probe; } } end_probe: /* write 0's to control and data ports */ outb(dvp->id_iobase+lpt_data, 0); outb(dvp->id_iobase+lpt_control, 0); return (status); #endif }
/* * Probe for Contec C-NET(98)P2 series. * (Logitec LAN-98TP/LAN-98T25P - parhaps) */ static int fe_probe_ssi(device_t dev) { struct fe_softc *sc = device_get_softc(dev); rman_res_t iobase, irq; u_char eeprom [SSI_EEPROM_SIZE]; static struct fe_simple_probe_struct probe_table [] = { { FE_DLCR2, 0x08, 0x00 }, { FE_DLCR4, 0x08, 0x00 }, { 0 } }; static u_short const irqmap[] = { /* INT0 INT1 INT2 */ NO_IRQ, NO_IRQ, NO_IRQ, 3, NO_IRQ, 5, 6, NO_IRQ, NO_IRQ, 9, 10, NO_IRQ, 12, 13, NO_IRQ, NO_IRQ, /* INT3 INT41 INT5 INT6 */ }; /* See if the specified I/O address is possible for 78Q8377A. */ /* [0-D]3D0 are allowed. */ if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0) return ENXIO; if ((iobase & 0xFFF) != 0x3D0) return ENXIO; if (fe98_alloc_port(dev, FE_TYPE_SSI)) return ENXIO; /* Fill the softc struct with default values. */ fe_softc_defaults(sc); /* See if the card is on its address. */ if (!fe_simple_probe(sc, probe_table)) return ENXIO; /* We now have to read the config EEPROM. We should be very careful, since doing so destroys a register. (Remember, we are not yet sure we have a C-NET(98)P2 board here.) Don't remember to select BMPRs bofore reading EEPROM, since other register bank may be selected before the probe() is called. */ fe_read_eeprom_ssi(sc, eeprom); /* Make sure the Ethernet (MAC) station address is of Contec's. */ if (!fe_valid_Ether_p(eeprom + FE_SSI_EEP_ADDR, 0x00804C)) return ENXIO; bcopy(eeprom + FE_SSI_EEP_ADDR, sc->enaddr, ETHER_ADDR_LEN); /* Setup the board type. */ sc->typestr = "C-NET(98)P2"; /* Non-PnP mode, set static resource from eeprom. */ if (!isa_get_vendorid(dev)) { /* Get IRQ configuration from EEPROM. */ irq = irqmap[eeprom[FE_SSI_EEP_IRQ]]; if (irq == NO_IRQ) { fe_irq_failure(sc->typestr, sc->sc_unit, irq, "3/5/6/9/10/12/13"); return ENXIO; } bus_set_resource(dev, SYS_RES_IRQ, 0, irq, 1); } /* Get Duplex-mode configuration from EEPROM. */ sc->proto_dlcr4 |= (eeprom[FE_SSI_EEP_DUPLEX] & FE_D4_DSC); /* Fill softc struct accordingly. */ sc->mbitmap = MB_HT; sc->defmedia = MB_HT; return 0; }
/*---------------------------------------------------------------------------* * attach for ISA PnP cards *---------------------------------------------------------------------------*/ static int isic_pnp_attach(device_t dev) { u_int32_t vend_id = isa_get_vendorid(dev); /* vendor id */ unsigned int unit = device_get_unit(dev); /* get unit */ const char *name = device_get_desc(dev); /* get description */ struct l1_softc *sc = 0; /* softc */ void *ih = 0; /* a dummy */ int ret; /* see if we are out of bounds */ if(unit >= ISIC_MAXUNIT) { printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for %s\n", unit, unit, name); return ENXIO; } /* get information structure for this unit */ sc = &l1_sc[unit]; /* get io_base */ if(!(sc->sc_resources.io_base[0] = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->sc_resources.io_rid[0], 0UL, ~0UL, 1, RF_ACTIVE ) )) { printf("isic_pnp_attach: Couldn't get my io_base.\n"); return ENXIO; } /* will not be used for pnp devices */ sc->sc_port = rman_get_start(sc->sc_resources.io_base[0]); /* get irq, release io_base if we don't get it */ if(!(sc->sc_resources.irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->sc_resources.irq_rid, 0UL, ~0UL, 1, RF_ACTIVE))) { printf("isic%d: Could not get irq.\n",unit); isic_detach_common(dev); return ENXIO; } /* not needed */ sc->sc_irq = rman_get_start(sc->sc_resources.irq); /* set flag so we know what this card is */ ret = ENXIO; switch(vend_id) { #if defined(TEL_S0_16_3_P) || defined(CRTX_S0_P) || defined(COMPAQ_M610) case VID_TEL163PNP: sc->sc_cardtyp = CARD_TYPEP_163P; ret = isic_attach_Cs0P(dev); break; case VID_CREATIXPP: sc->sc_cardtyp = CARD_TYPEP_CS0P; ret = isic_attach_Cs0P(dev); break; case VID_COMPAQ_M610: sc->sc_cardtyp = CARD_TYPEP_COMPAQ_M610; ret = isic_attach_Cs0P(dev); break; #endif #ifdef DYNALINK case VID_DYNALINK: sc->sc_cardtyp = CARD_TYPEP_DYNALINK; ret = isic_attach_Dyn(dev); break; #endif #ifdef SEDLBAUER case VID_SEDLBAUER: sc->sc_cardtyp = CARD_TYPEP_SWS; ret = isic_attach_sws(dev); break; #endif #ifdef DRN_NGO case VID_NICCYGO: sc->sc_cardtyp = CARD_TYPEP_DRNNGO; ret = isic_attach_drnngo(dev); break; #endif #ifdef ELSA_QS1ISA case VID_ELSAQS1P: sc->sc_cardtyp = CARD_TYPEP_ELSAQS1ISA; ret = isic_attach_Eqs1pi(dev); break; #endif #ifdef ITKIX1 case VID_ITK0025: sc->sc_cardtyp = CARD_TYPEP_ITKIX1; ret = isic_attach_itkix1(dev); break; #endif #ifdef SIEMENS_ISURF2 case VID_SIESURF2: sc->sc_cardtyp = CARD_TYPEP_SIE_ISURF2; ret = isic_attach_siemens_isurf(dev); break; #endif #ifdef ASUSCOM_IPAC case VID_ASUSCOM_IPAC: sc->sc_cardtyp = CARD_TYPEP_ASUSCOMIPAC; ret = isic_attach_asi(dev); break; #endif #ifdef EICON_DIVA case VID_EICON_DIVA_20: sc->sc_cardtyp = CARD_TYPEP_DIVA_ISA; ret = isic_attach_diva(dev); break; case VID_EICON_DIVA_202: sc->sc_cardtyp = CARD_TYPEP_DIVA_ISA; ret = isic_attach_diva_ipac(dev); break; #endif default: printf("isic%d: Error, no driver for %s\n", unit, name); ret = ENXIO; break; } if(ret) { isic_detach_common(dev); return ENXIO; } if(isic_attach_common(dev)) { /* unset flag */ sc->sc_cardtyp = CARD_TYPEP_UNK; /* free irq here, it hasn't been attached yet */ bus_release_resource(dev,SYS_RES_IRQ,sc->sc_resources.irq_rid, sc->sc_resources.irq); sc->sc_resources.irq = 0; isic_detach_common(dev); return ENXIO; } else { /* setup intr routine */ bus_setup_intr(dev,sc->sc_resources.irq,INTR_TYPE_NET, (void(*)(void*))isicintr, sc,&ih); return 0; } }
/*---------------------------------------------------------------------------* * probe for ISA "PnP" card *---------------------------------------------------------------------------*/ int ihfc_pnp_probe(device_t dev) { u_int unit = device_get_unit(dev); /* get unit */ u_int32_t vid = isa_get_vendorid(dev); /* vendor id */ ihfc_id_t *ids = &ihfc_pnp_ids[0]; /* ids ptr */ ihfc_sc_t *sc = &ihfc_softc[unit]; /* softc */ u_char flag = 0; /* flag */ void *dummy = 0; /* a dummy */ HFC_VAR; if (unit >= IHFC_MAXUNIT) { printf("ihfc%d: Error, unit %d >= IHFC_MAXUNIT", unit, unit); return ENXIO; } if (!vid) return ihfc_isa_probe(dev); HFC_BEG; for ( ;(ids->vid); ids++) { if (ids->vid == vid) { flag = 0; bzero(sc, sizeof(ihfc_sc_t)); /* reset data structure.* * Zero is default for * * most, so calling the * * int. handler now will* * not be a problem. */ S_IOBASE[0] = bus_alloc_resource( dev, SYS_RES_IOPORT, &S_IORID[0], 0UL, ~0UL, 2, RF_ACTIVE ); S_IRQ = bus_alloc_resource( dev, SYS_RES_IRQ, &S_IRQRID, 0UL, ~0UL, 1, RF_ACTIVE ); S_DLP = IHFC_DLP; /* set D-priority */ S_HFC = ids->hfc; /* set chip type */ S_I4BFLAG = ids->flag; /* set flag */ S_NTMODE = IHFC_NTMODE; /* set mode */ S_STDEL = ids->stdel; /* set delay */ S_I4BUNIT = L0IHFCUNIT(unit); /* set "i4b" unit */ S_TRACE = TRACE_OFF; /* set trace mask */ S_UNIT = unit; /* set up unit numbers */ if (S_IOBASE[0] && S_IRQ) { if (ids->iio) { S_IIO = ids->iio; S_IIRQ = ids->iirq; } else { S_IIO = rman_get_start(S_IOBASE[0]) & 0x3ff; S_IIRQ = IIRQ3[rman_get_start(S_IRQ) & 0xf]; } /* setup interrupt routine now to avvoid stray * * interrupts. */ bus_setup_intr(dev, S_IRQ, INTR_TYPE_NET, (void(*)(void*)) HFC_INTR, sc, &dummy); flag = 1; if (!HFC_CONTROL(sc, 1)) { HFC_END; return 0; /* success */ } else { printf("ihfc%d: Chip seems corrupted. " "Please hard reboot your computer!\n", unit); } } ihfc_pnp_detach(dev, flag); } } HFC_END; return ENXIO; /* failure */ }
static int pmc_isa_probe(device_t dev) { struct pmc_isa_softc *sc = device_get_softc(dev); u_int port; u_int16_t save, tmp; #if 0 if (isa_get_vendorid(dev)) { return ENXIO; } if (device_get_unit(dev) > 0) { printf("pmc: Only one PMC driver supported.\n"); return ENXIO; } #endif port = isa_get_port(dev); if (port == -1) { port = PMC_ISA_PORT; } if (bootverbose) { device_printf(dev, "port = 0x%x\n", port); } if (bus_set_resource(dev, SYS_RES_IOPORT, 0, port, PMC_ISA_PORTSIZE)) { if (bootverbose) { device_printf(dev, "bus_set_resource failed\n"); } return ENXIO; } if (pmc_isa_alloc_resources(dev)) { if (bootverbose) { device_printf(dev, "pmc_isa_alloc_resources failed\n"); } return ENXIO; } /* Check the existence of PMC */ sc_outw(sc, 0, 0x0052); save = sc_inw(sc, 2); tmp = save & ~0x3f; sc_outw(sc, 2, tmp); if (sc_inw(sc, 2) != tmp) { if (bootverbose) { device_printf(dev, "failed to clear index(0x0052)\n"); } pmc_isa_release_resources(dev); return ENXIO; } tmp |= 0x3e; sc_outw(sc, 2, tmp); if (sc_inw(sc, 2) != tmp) { if (bootverbose) { device_printf(dev, "failed to set index(0x0052)\n"); } pmc_isa_release_resources(dev); return ENXIO; } sc_outw(sc, 2, save); pmc_isa_release_resources(dev); device_set_desc(dev, "Power Management Controller"); return 0; }
static int alloc_resource(sc_p scp) { int i, base, lid, flags; device_t dev; flags = 0; if (isa_get_vendorid(scp->dev)) lid = isa_get_logicalid(scp->dev); else { lid = LOGICALID_NOPNP; flags = device_get_flags(scp->dev); } switch(lid) { case LOGICALID_PCM: case LOGICALID_NOPNP: /* XXX Non-PnP */ if (lid == LOGICALID_NOPNP) base = isa_get_port(scp->dev); else base = 0; for (i = 0 ; i < sizeof(scp->io) / sizeof(*scp->io) ; i++) { if (scp->io[i] == NULL) { scp->io_rid[i] = i; if (base == 0) scp->io[i] = bus_alloc_resource(scp->dev, SYS_RES_IOPORT, &scp->io_rid[i], 0, ~0, io_range[i], RF_ACTIVE); else scp->io[i] = bus_alloc_resource(scp->dev, SYS_RES_IOPORT, &scp->io_rid[i], base + io_offset[i], base + io_offset[i] + io_range[i] - 1 , io_range[i], RF_ACTIVE); if (scp->io[i] == NULL) return (1); scp->io_alloced[i] = 0; } } if (scp->irq == NULL) { scp->irq_rid = 0; scp->irq = bus_alloc_resource_any(scp->dev, SYS_RES_IRQ, &scp->irq_rid, RF_ACTIVE|RF_SHAREABLE); if (scp->irq == NULL) return (1); scp->irq_alloced = 0; } for (i = 0 ; i < sizeof(scp->drq) / sizeof(*scp->drq) ; i++) { if (scp->drq[i] == NULL) { scp->drq_rid[i] = i; if (base == 0 || i == 0) scp->drq[i] = bus_alloc_resource_any( scp->dev, SYS_RES_DRQ, &scp->drq_rid[i], RF_ACTIVE); else if ((flags & DV_F_DUAL_DMA) != 0) /* XXX The secondary drq is specified in the flag. */ scp->drq[i] = bus_alloc_resource(scp->dev, SYS_RES_DRQ, &scp->drq_rid[i], flags & DV_F_DRQ_MASK, flags & DV_F_DRQ_MASK, 1, RF_ACTIVE); if (scp->drq[i] == NULL) return (1); scp->drq_alloced[i] = 0; } } break; case LOGICALID_OPL: if (scp->io[0] == NULL) { scp->io_rid[0] = 0; scp->io[0] = bus_alloc_resource(scp->dev, SYS_RES_IOPORT, &scp->io_rid[0], 0, ~0, io_range[0], RF_ACTIVE); if (scp->io[0] == NULL) return (1); scp->io_alloced[0] = 0; } break; case LOGICALID_MIDI: if (scp->io[0] == NULL) { scp->io_rid[0] = 0; scp->io[0] = bus_alloc_resource(scp->dev, SYS_RES_IOPORT, &scp->io_rid[0], 0, ~0, io_range[0], RF_ACTIVE); if (scp->io[0] == NULL) return (1); scp->io_alloced[0] = 0; } if (scp->irq == NULL) { /* The irq is shared with pcm audio. */ dev = find_masterdev(scp); if (dev == NULL) return (1); scp->irq_rid = 0; scp->irq = BUS_ALLOC_RESOURCE(dev, NULL, SYS_RES_IRQ, &scp->irq_rid, 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE); if (scp->irq == NULL) return (1); scp->irq_alloced = 0; } break; } return (0); }
static int iavc_isa_probe(device_t dev) { struct iavc_softc *sc; int ret = ENXIO; int unit = device_get_unit(dev); if(isa_get_vendorid(dev)) /* no PnP probes here */ return ENXIO; /* check max unit range */ if (unit >= IAVC_MAXUNIT) { kprintf("iavc%d: too many units\n", unit); return(ENXIO); } sc = iavc_find_sc(unit); /* get softc */ sc->sc_unit = unit; if (!(sc->sc_resources.io_base[0] = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->sc_resources.io_rid[0], 0UL, ~0UL, B1_IOLENGTH, RF_ACTIVE))) { kprintf("iavc%d: can't allocate io region\n", unit); return(ENXIO); } sc->sc_iobase = rman_get_start(sc->sc_resources.io_base[0]); switch(sc->sc_iobase) { case 0x150: case 0x250: case 0x300: case 0x340: break; default: kprintf("iavc%d: ERROR, invalid i/o base addr 0x%x configured!\n", sc->sc_unit, sc->sc_iobase); bus_release_resource(dev, SYS_RES_IOPORT, sc->sc_resources.io_rid[0], sc->sc_resources.io_base[0]); return(ENXIO); } sc->sc_io_bt = rman_get_bustag(sc->sc_resources.io_base[0]); sc->sc_io_bh = rman_get_bushandle(sc->sc_resources.io_base[0]); /* setup characteristics */ sc->sc_t1 = FALSE; sc->sc_dma = FALSE; sc->sc_capi.card_type = CARD_TYPEC_AVM_B1_ISA; sc->sc_capi.sc_nbch = 2; b1_reset(sc); DELAY(100); ret = b1_detect(sc); if(ret) { kprintf("iavc%d: no card ? b1_detect returns %0x02x\n", sc->sc_unit, ret); return(ENXIO); } DELAY(100); b1_reset(sc); DELAY(100); if(bootverbose) { kprintf("iavc%d: class = 0x%02x, rev = 0x%02x\n", sc->sc_unit, iavc_read_port(sc, B1_ANALYSE), iavc_read_port(sc, B1_REVISION)); } device_set_desc(dev, "AVM B1 ISA"); return(0); }