Exemplo n.º 1
0
static int
aic_isa_probe(device_t dev)
{
	struct aic_isa_softc *sc = device_get_softc(dev);
	struct aic_softc *aic = &sc->sc_aic;
	int numports, i;
	u_int port, *ports;
	u_int8_t porta;

	if (ISA_PNP_PROBE(device_get_parent(dev), dev, aic_ids) == ENXIO)
		return (ENXIO);

	port = isa_get_port(dev);
	if (port != -1) {
		ports = &port;
		numports = 1;
	} else {
		ports = aic_isa_ports;
		numports = AIC_ISA_NUMPORTS;
	}

	for (i = 0; i < numports; i++) {
		if (bus_set_resource(dev, SYS_RES_IOPORT, 0, ports[i],
				     AIC_ISA_PORTSIZE, -1))
			continue;
		if (aic_isa_alloc_resources(dev))
			continue;
		if (!aic_probe(aic)) {
			aic_isa_release_resources(dev);
			break;
		}
		aic_isa_release_resources(dev);
	}

	if (i == numports)
		return (ENXIO);

	porta = aic_inb(aic, PORTA);
	if (isa_get_irq(dev) == -1) {
		int irq = PORTA_IRQ(porta);

		bus_set_resource(dev, SYS_RES_IRQ, 0, irq, 1,
		    machintr_intr_cpuid(irq));
	}
	if ((aic->flags & AIC_DMA_ENABLE) && isa_get_drq(dev) == -1)
		bus_set_resource(dev, SYS_RES_DRQ, 0, PORTA_DRQ(porta), 1, -1);
	device_set_desc(dev, "Adaptec 6260/6360 SCSI controller");
	return (0);
}
Exemplo n.º 2
0
static int
aic_isa_probe(struct isa_device *dev)
{
	struct aic_softc _aic, *aic = &_aic;
	int numports, i;
	u_int port, *ports;
	u_int8_t porta;

	port = dev->id_iobase;
	if (port != -1) {
		ports = &port;
		numports = 1;
	} else {
		ports = aic_isa_ports;
		numports = AIC_ISA_NUMPORTS;
	}

	for (i = 0; i < numports; i++) {
#ifdef PC98
		aic->bsh_iat = aicport_generic;
		if (AIC_TYPE98(dev->id_flags) == AIC98_NEC100) {
			/* PC-9801-100 */
			aic->bsh_iat = aicport_100;
		}
#endif
		aic->unit = aic_unit;
		aic->tag = I386_BUS_SPACE_IO;
		aic->bsh = ports[i];
		if (!aic_probe(aic))
			break;
	}

	if (i == numports)
		return (0);

	porta = aic_inb(aic, PORTA);
	if (dev->id_irq <= 0)
		dev->id_irq = 1 << PORTA_IRQ(porta);
	if ((aic->flags & AIC_DMA_ENABLE) && dev->id_drq == -1)
		dev->id_drq = PORTA_DRQ(porta);
	dev->id_iobase = aic->bsh;
	dev->id_intr = aic_isa_intr;
	dev->id_unit = aic_unit++;
#ifdef PC98
	if (AIC_TYPE98(dev->id_flags) == AIC98_NEC100)
		return (AIC_ISA_PORTSIZE * 2);
#endif
	return (AIC_ISA_PORTSIZE);
}