FreeBSD/sys/dev/buslogic/bt_isa.c
/*
 * Attach all the sub-devices we can find
 */
Attach all the sub-devices we can find
Attach all the sub - devices we can find
static int
bt_isa_attach(device_t dev)
{
	struct	bt_softc *bt = device_get_softc(dev);
	bus_dma_filter_t *filter;
	void		 *filter_arg;
	bus_addr_t	 lowaddr;
	int		 error, drq;
	error = bt_isa_alloc_resources(dev, 0, ~0);
	if (error) {
		device_printf(dev, "can't allocate resources in bt_isa_attach\n");
		return error;
	}
	if ((drq = isa_get_drq(dev)) != -1)
		isa_dmacascade(drq);
	filter = NULL;
	filter_arg = NULL;
	lowaddr = BUS_SPACE_MAXADDR_24BIT;
	if (bt->model[0] == '4') {
		if (bt->bios_addr != 0
		 && strcmp(bt->model, "445S") == 0
		 && strcmp(bt->firmware_ver, "3.37") < 0) {
			filter = btvlbouncefilter;
			filter_arg = bt;
		} else {
			lowaddr = BUS_SPACE_MAXADDR_32BIT;
		}
	}
	if (bus_dma_tag_create(	 bus_get_dma_tag(dev),
				 1,
				 0,
				 lowaddr,
				 BUS_SPACE_MAXADDR,
				 filter,
				 filter_arg,
				 BUS_SPACE_MAXSIZE_32BIT,
				 ~0,
				 BUS_SPACE_MAXSIZE_32BIT,
				 0,
				 NULL,
				 NULL,
				&bt->parent_dmat) != 0) {
		bt_isa_release_resources(dev);
                return (ENOMEM);
        }                              
        error = bt_init(dev);
        if (error) {
		bt_isa_release_resources(dev);
                return (ENOMEM);
        }
	if (lowaddr != BUS_SPACE_MAXADDR_32BIT) {
		if (bus_dma_tag_create(
				 bt->parent_dmat,
				 1,
				 0,
				 BUS_SPACE_MAXADDR,
				 BUS_SPACE_MAXADDR,
				 NULL,
				 NULL,
				 bt->max_ccbs *
						   sizeof(struct scsi_sense_data),
				 1,
				 BUS_SPACE_MAXSIZE_32BIT,
				 0,
				 NULL,
				 NULL,
				&bt->sense_dmat) != 0) {
			bt_isa_release_resources(dev);
			return (ENOMEM);
		}
		bt->init_level++;
		if (bus_dmamem_alloc(bt->sense_dmat,
				     (void **)&bt->sense_buffers,
				     BUS_DMA_NOWAIT, &bt->sense_dmamap) != 0) {
			bt_isa_release_resources(dev);
			return (ENOMEM);
		}
		bt->init_level++;
		bus_dmamap_load(bt->sense_dmat, bt->sense_dmamap,
       				bt->sense_buffers,
				bt->max_ccbs * sizeof(*bt->sense_buffers),
				btmapsensebuffers, bt, 0);
		bt->init_level++;
	}
	error = bt_attach(dev);
	if (error) {
		bt_isa_release_resources(dev);
		return (error);
	}
	return (0);
}
static int bt_isa_attach ( device_t dev ) { struct bt_softc * bt = device_get_softc ( dev ) ; bus_dma_filter_t * filter ; void * filter_arg ; bus_addr_t lowaddr ; int error , drq ; error = bt_isa_alloc_resources ( dev , 0 , ~ 0 ) ; if ( error ) { device_printf ( dev , " \n " ) ; return error ; } if ( ( drq = isa_get_drq ( dev ) ) != -1 ) isa_dmacascade ( drq ) ; filter = NULL ; filter_arg = NULL ; lowaddr = BUS_SPACE_MAXADDR_24BIT ; if ( bt -> model [ 0 ] == ' ' ) { if ( bt -> bios_addr != 0 && strcmp ( bt -> model , " " ) == 0 && strcmp ( bt -> firmware_ver , " " ) < 0 ) { filter = btvlbouncefilter ; filter_arg = bt ; } else { lowaddr = BUS_SPACE_MAXADDR_32BIT ; } } if ( bus_dma_tag_create ( bus_get_dma_tag ( dev ) , 1 , 0 , lowaddr , BUS_SPACE_MAXADDR , filter , filter_arg , BUS_SPACE_MAXSIZE_32BIT , ~ 0 , BUS_SPACE_MAXSIZE_32BIT , 0 , NULL , NULL , & bt -> parent_dmat ) != 0 ) { bt_isa_release_resources ( dev ) ; return ( ENOMEM ) ; } error = bt_init ( dev ) ; if ( error ) { bt_isa_release_resources ( dev ) ; return ( ENOMEM ) ; } if ( lowaddr != BUS_SPACE_MAXADDR_32BIT ) { if ( bus_dma_tag_create ( bt -> parent_dmat , 1 , 0 , BUS_SPACE_MAXADDR , BUS_SPACE_MAXADDR , NULL , NULL , bt -> max_ccbs * sizeof ( struct scsi_sense_data ) , 1 , BUS_SPACE_MAXSIZE_32BIT , 0 , NULL , NULL , & bt -> sense_dmat ) != 0 ) { bt_isa_release_resources ( dev ) ; return ( ENOMEM ) ; } bt -> init_level ++ ; if ( bus_dmamem_alloc ( bt -> sense_dmat , ( void * * ) & bt -> sense_buffers , BUS_DMA_NOWAIT , & bt -> sense_dmamap ) != 0 ) { bt_isa_release_resources ( dev ) ; return ( ENOMEM ) ; } bt -> init_level ++ ; bus_dmamap_load ( bt -> sense_dmat , bt -> sense_dmamap , bt -> sense_buffers , bt -> max_ccbs * sizeof ( * bt -> sense_buffers ) , btmapsensebuffers , bt , 0 ) ; bt -> init_level ++ ; } error = bt_attach ( dev ) ; if ( error ) { bt_isa_release_resources ( dev ) ; return ( error ) ; } return ( 0 ) ; }
Attach all the sub-devices we can find
Attach all the sub - devices we can find
/* Initialise softc */ /* Program the DMA channel for external control */ /* Allocate our parent dmatag */ /*
		 * This is a VL adapter.  Typically, VL devices have access
		 * to the full 32bit address space.  On BT-445S adapters
		 * prior to revision E, there is a hardware bug that causes
		 * corruption of transfers to/from addresses in the range of
		 * the BIOS modulo 16MB.  The only properly functioning
		 * BT-445S Host Adapters have firmware version 3.37.
		 * If we encounter one of these adapters and the BIOS is
		 * installed, install a filter function for our bus_dma_map
		 * that will catch these accesses and bounce them to a safe
		 * region of memory.
		 */ /* XXX Should be a child of the ISA or VL bus dma tag */ /* parent	*/ /* alignemnt	*/ /* boundary	*/ /* lowaddr	*/ /* highaddr	*/ /* filter	*/ /* filterarg	*/ /* maxsize	*/ /* nsegments	*/ /* maxsegsz	*/ /* flags	*/ /* lockfunc	*/ /* lockarg	*/ /* DMA tag for our sense buffers */ /* parent	*/ /* alignment	*/ /* boundary	*/ /* lowaddr	*/ /* highaddr	*/ /* filter	*/ /* filterarg	*/ /* maxsize	*/ /* nsegments	*/ /* maxsegsz	*/ /* flags	*/ /* lockfunc	*/ /* lockarg	*/ /* Allocation of sense buffers */ /* And permanently map them */ /*flags*/