FreeBSD/sys/dev/advansys/adv_eisa.c
/*
 * The adv_b stuff to handle twin-channel cards will not work in its current
 * incarnation.  It tries to reuse the same softc since adv_alloc() doesn't
 * actually allocate a softc.  It also tries to reuse the same unit number
 * for both sims.  This can be re-enabled if someone fixes it properly.
 */
The adv_b stuff to handle twin-channel cards will not work in its current
incarnation.  It tries to reuse the same softc since adv_alloc() doesn't
actually allocate a softc.  It also tries to reuse the same unit number
for both sims.  This can be re-enabled if someone fixes it properly.
The adv_b stuff to handle twin - channel cards will not work in its current incarnation . It tries to reuse the same softc since adv_alloc () doesn ' t actually allocate a softc . It also tries to reuse the same unit number for both sims . This can be re - enabled if someone fixes it properly .
static int
adv_eisa_attach(device_t dev)
{
	struct adv_softc *adv;
#if 0
	struct adv_softc *adv_b;
#endif
	struct resource *io;
	struct resource *irq;
	int rid, error;
	void *ih;
#if 0
	adv_b = NULL;
#endif
	rid = 0;
	io = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
	if (!io) {
		device_printf(dev, "No I/O space?!\n");
		return ENOMEM;
	}
	rid = 0;
	irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
				     RF_SHAREABLE | RF_ACTIVE);
	if (!irq) {
		device_printf(dev, "No irq?!\n");
		bus_release_resource(dev, SYS_RES_IOPORT, 0, io);
		return ENOMEM;
	}
	switch (eisa_get_id(dev) & ~0xF) {
	case EISA_DEVICE_ID_ADVANSYS_750:
#if 0
		adv_b = adv_alloc(dev, io, ADV_EISA_OFFSET_CHAN2);
		if (adv_b == NULL)
			goto bad;
		error = bus_dma_tag_create(
				 bus_get_dma_tag(dev),
				 1,
				 0,
				 ADV_EISA_MAX_DMA_ADDR,
				 BUS_SPACE_MAXADDR,
				 NULL,
				 NULL,
				 BUS_SPACE_MAXSIZE_32BIT,
				 ~0,
				 ADV_EISA_MAX_DMA_COUNT,
				 0,
				 NULL,
				 NULL,
				&adv_b->parent_dmat);
		if (error != 0) {
			device_printf(dev, "Could not allocate DMA tag - error %d\n",
			       error);
			adv_free(adv_b);
			goto bad;
		}
		adv_b->init_level++;
#endif
	case EISA_DEVICE_ID_ADVANSYS_740:
		adv = adv_alloc(dev, io, ADV_EISA_OFFSET_CHAN1);
		if (adv == NULL) {
#if 0
			if (adv_b != NULL)
				adv_free(adv_b);
#endif
			goto bad;
		}
		error = bus_dma_tag_create(
				 bus_get_dma_tag(dev),
				 1,
				 0,
				 ADV_EISA_MAX_DMA_ADDR,
				 BUS_SPACE_MAXADDR,
				 NULL,
				 NULL,
				 BUS_SPACE_MAXSIZE_32BIT,
				 ~0,
				 ADV_EISA_MAX_DMA_COUNT,
				 0,
				 NULL,
				 NULL,
				&adv->parent_dmat);
		if (error != 0) {
			device_printf(dev, "Could not allocate DMA tag - error %d\n",
			       error);
			adv_free(adv);
			goto bad;
		}
		adv->init_level++;
		break;
	default: 
		printf("adveisaattach: Unknown device type!\n");
		goto bad;
		break;
	}
	if (overrun_buf == NULL) {
		if (bus_dma_tag_create(
				 bus_get_dma_tag(dev),
				 8,
				 0,
				 ADV_EISA_MAX_DMA_ADDR,
				 BUS_SPACE_MAXADDR,
				 NULL,
				 NULL,
				 ADV_OVERRUN_BSIZE,
				 1,
				 BUS_SPACE_MAXSIZE_32BIT,
				 0,
				 NULL,
				 NULL,
				&overrun_dmat) != 0) {
			adv_free(adv);
			goto bad;
       		}
		if (bus_dmamem_alloc(overrun_dmat,
				     &overrun_buf,
				     BUS_DMA_NOWAIT,
				     &overrun_dmamap) != 0) {
			bus_dma_tag_destroy(overrun_dmat);
			adv_free(adv);
			goto bad;
		}
		bus_dmamap_load(overrun_dmat, overrun_dmamap,
				overrun_buf, ADV_OVERRUN_BSIZE,
				adv_map, &overrun_physbase,
				0);
	}
	ADV_OUTB(adv, ADV_CHIP_CTRL, ADV_CC_HALT);
	ADV_OUTW(adv, ADV_CHIP_STATUS, 0);
	adv->chip_version = EISA_REVISION_ID(eisa_get_id(dev))
			  + ADV_CHIP_MIN_VER_EISA - 1;
	if (adv_init(adv) != 0) {
		adv_free(adv);
#if 0
		if (adv_b != NULL)
			adv_free(adv_b);
#endif
		goto bad;
	}
	adv->max_dma_count = ADV_EISA_MAX_DMA_COUNT;
	adv->max_dma_addr = ADV_EISA_MAX_DMA_ADDR;
#if 0
	if (adv_b != NULL) {
		ADV_OUTB(adv_b, ADV_CHIP_CTRL, ADV_CC_HALT);
		ADV_OUTW(adv_b, ADV_CHIP_STATUS, 0);
		adv_b->chip_version = EISA_REVISION_ID(eisa_get_id(dev))
				    + ADV_CHIP_MIN_VER_EISA - 1;
		if (adv_init(adv_b) != 0) {
			adv_free(adv_b);
		} else {
			adv_b->max_dma_count = ADV_EISA_MAX_DMA_COUNT;
			adv_b->max_dma_addr = ADV_EISA_MAX_DMA_ADDR;
		}
	}
#endif
	if (bus_setup_intr(dev, irq, INTR_TYPE_CAM|INTR_ENTROPY|INTR_MPSAFE, NULL,
	    adv_intr, adv, &ih) != 0) {
		adv_free(adv);
		goto bad;
	}
	if (adv_attach(adv) != 0) {
		adv_free(adv);
		goto bad;
	}
#if 0
	if (adv_b != NULL)
		adv_attach(adv_b);
#endif
	return 0;
 bad:
	bus_release_resource(dev, SYS_RES_IOPORT, 0, io);
	bus_release_resource(dev, SYS_RES_IRQ, 0, irq);
	return ENXIO;
}
static int adv_eisa_attach ( device_t dev ) { struct adv_softc * adv ; #if 0 struct adv_softc * adv_b ; #endif struct resource * io ; struct resource * irq ; int rid , error ; void * ih ; #if 0 adv_b = NULL ; #endif rid = 0 ; io = bus_alloc_resource_any ( dev , SYS_RES_IOPORT , & rid , RF_ACTIVE ) ; if ( ! io ) { device_printf ( dev , " \n " ) ; return ENOMEM ; } rid = 0 ; irq = bus_alloc_resource_any ( dev , SYS_RES_IRQ , & rid , RF_SHAREABLE | RF_ACTIVE ) ; if ( ! irq ) { device_printf ( dev , " \n " ) ; bus_release_resource ( dev , SYS_RES_IOPORT , 0 , io ) ; return ENOMEM ; } switch ( eisa_get_id ( dev ) & ~ 0xF ) { case EISA_DEVICE_ID_ADVANSYS_750 : #if 0 adv_b = adv_alloc ( dev , io , ADV_EISA_OFFSET_CHAN2 ) ; if ( adv_b == NULL ) goto bad ; error = bus_dma_tag_create ( bus_get_dma_tag ( dev ) , 1 , 0 , ADV_EISA_MAX_DMA_ADDR , BUS_SPACE_MAXADDR , NULL , NULL , BUS_SPACE_MAXSIZE_32BIT , ~ 0 , ADV_EISA_MAX_DMA_COUNT , 0 , NULL , NULL , & adv_b -> parent_dmat ) ; if ( error != 0 ) { device_printf ( dev , " \n " , error ) ; adv_free ( adv_b ) ; goto bad ; } adv_b -> init_level ++ ; #endif case EISA_DEVICE_ID_ADVANSYS_740 : adv = adv_alloc ( dev , io , ADV_EISA_OFFSET_CHAN1 ) ; if ( adv == NULL ) { #if 0 if ( adv_b != NULL ) adv_free ( adv_b ) ; #endif goto bad ; } error = bus_dma_tag_create ( bus_get_dma_tag ( dev ) , 1 , 0 , ADV_EISA_MAX_DMA_ADDR , BUS_SPACE_MAXADDR , NULL , NULL , BUS_SPACE_MAXSIZE_32BIT , ~ 0 , ADV_EISA_MAX_DMA_COUNT , 0 , NULL , NULL , & adv -> parent_dmat ) ; if ( error != 0 ) { device_printf ( dev , " \n " , error ) ; adv_free ( adv ) ; goto bad ; } adv -> init_level ++ ; break ; default : printf ( " \n " ) ; goto bad ; break ; } if ( overrun_buf == NULL ) { if ( bus_dma_tag_create ( bus_get_dma_tag ( dev ) , 8 , 0 , ADV_EISA_MAX_DMA_ADDR , BUS_SPACE_MAXADDR , NULL , NULL , ADV_OVERRUN_BSIZE , 1 , BUS_SPACE_MAXSIZE_32BIT , 0 , NULL , NULL , & overrun_dmat ) != 0 ) { adv_free ( adv ) ; goto bad ; } if ( bus_dmamem_alloc ( overrun_dmat , & overrun_buf , BUS_DMA_NOWAIT , & overrun_dmamap ) != 0 ) { bus_dma_tag_destroy ( overrun_dmat ) ; adv_free ( adv ) ; goto bad ; } bus_dmamap_load ( overrun_dmat , overrun_dmamap , overrun_buf , ADV_OVERRUN_BSIZE , adv_map , & overrun_physbase , 0 ) ; } ADV_OUTB ( adv , ADV_CHIP_CTRL , ADV_CC_HALT ) ; ADV_OUTW ( adv , ADV_CHIP_STATUS , 0 ) ; adv -> chip_version = EISA_REVISION_ID ( eisa_get_id ( dev ) ) + ADV_CHIP_MIN_VER_EISA - 1 ; if ( adv_init ( adv ) != 0 ) { adv_free ( adv ) ; #if 0 if ( adv_b != NULL ) adv_free ( adv_b ) ; #endif goto bad ; } adv -> max_dma_count = ADV_EISA_MAX_DMA_COUNT ; adv -> max_dma_addr = ADV_EISA_MAX_DMA_ADDR ; #if 0 if ( adv_b != NULL ) { ADV_OUTB ( adv_b , ADV_CHIP_CTRL , ADV_CC_HALT ) ; ADV_OUTW ( adv_b , ADV_CHIP_STATUS , 0 ) ; adv_b -> chip_version = EISA_REVISION_ID ( eisa_get_id ( dev ) ) + ADV_CHIP_MIN_VER_EISA - 1 ; if ( adv_init ( adv_b ) != 0 ) { adv_free ( adv_b ) ; } else { adv_b -> max_dma_count = ADV_EISA_MAX_DMA_COUNT ; adv_b -> max_dma_addr = ADV_EISA_MAX_DMA_ADDR ; } } #endif if ( bus_setup_intr ( dev , irq , INTR_TYPE_CAM | INTR_ENTROPY | INTR_MPSAFE , NULL , adv_intr , adv , & ih ) != 0 ) { adv_free ( adv ) ; goto bad ; } if ( adv_attach ( adv ) != 0 ) { adv_free ( adv ) ; goto bad ; } #if 0 if ( adv_b != NULL ) adv_attach ( adv_b ) ; #endif return 0 ; bad : bus_release_resource ( dev , SYS_RES_IOPORT , 0 , io ) ; bus_release_resource ( dev , SYS_RES_IRQ , 0 , irq ) ; return ENXIO ; }
The adv_b stuff to handle twin-channel cards will not work in its current
 incarnation.
The adv_b stuff to handle twin - channel cards will not work in its current incarnation .
/*
		 * Allocate a parent dmatag for all tags created
		 * by the MI portions of the advansys driver
		 */ /* parent	*/ /* alignment	*/ /* boundary	*/ /* lowaddr	*/ /* highaddr	*/ /* filter	*/ /* filterarg	*/ /* maxsize	*/ /* nsegments	*/ /* maxsegsz	*/ /* flags	*/ /* lockfunc	*/ /* lockarg	*/ /* FALLTHROUGH */ /*
		 * Allocate a parent dmatag for all tags created
		 * by the MI portions of the advansys driver
		 */ /* parent	*/ /* alignment	*/ /* boundary	*/ /* lowaddr	*/ /* highaddr	*/ /* filter	*/ /* filterarg	*/ /* maxsize	*/ /* nsegments	*/ /* maxsegsz	*/ /* flags	*/ /* lockfunc	*/ /* lockarg	*/ /* Need to allocate our overrun buffer */ /* parent	*/ /* alignment	*/ /* boundary	*/ /* lowaddr	*/ /* highaddr	*/ /* filter	*/ /* filterarg	*/ /* maxsize	*/ /* nsegments	*/ /* maxsegsz	*/ /* flags	*/ /* lockfunc	*/ /* lockarg	*/ /* And permanently map it in */ /*flags*/ /*
	 * Now that we know we own the resources we need, do the 
	 * card initialization.
	 */ /*
	 * Stop the chip.
	 */ /*
		 * Stop the chip.
		 */ /*
	 * Enable our interrupt handler.
	 */ /* Attach sub-devices */