static int bt_pci_attach(device_t dev) { struct bt_softc *bt = device_get_softc(dev); int opri; int error; /* Initialize softc */ error = bt_pci_alloc_resources(dev); if (error) { device_printf(dev, "can't allocate resources in bt_pci_attach\n"); return error; } /* Allocate a dmatag for our CCB DMA maps */ /* XXX Should be a child of the PCI bus dma tag */ if (bus_dma_tag_create( /* parent */ NULL, /* alignemnt */ 1, /* boundary */ 0, /* lowaddr */ BUS_SPACE_MAXADDR_32BIT, /* highaddr */ BUS_SPACE_MAXADDR, /* filter */ NULL, /* filterarg */ NULL, /* maxsize */ BUS_SPACE_MAXSIZE_32BIT, /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, /* lockfunc */ busdma_lock_mutex, /* lockarg */ &Giant, &bt->parent_dmat) != 0) { bt_pci_release_resources(dev); return (ENOMEM); } /* * Protect ourself from spurrious interrupts during * intialization and attach. We should really rely * on interrupts during attach, but we don't have * access to our interrupts during ISA probes, so until * that changes, we mask our interrupts during attach * too. */ opri = splcam(); if (bt_probe(dev) || bt_fetch_adapter_info(dev) || bt_init(dev)) { bt_pci_release_resources(dev); splx(opri); return (ENXIO); } error = bt_attach(dev); splx(opri); if (error) { bt_pci_release_resources(dev); return (error); } return (0); }
static int bt_pci_attach(device_t dev) { struct bt_softc *bt = device_get_softc(dev); int error; /* Initialize softc */ error = bt_pci_alloc_resources(dev); if (error) { device_printf(dev, "can't allocate resources in bt_pci_attach\n"); return error; } /* Allocate a dmatag for our CCB DMA maps */ if (bus_dma_tag_create( /* PCI parent */ bus_get_dma_tag(dev), /* alignemnt */ 1, /* boundary */ 0, /* lowaddr */ BUS_SPACE_MAXADDR_32BIT, /* highaddr */ BUS_SPACE_MAXADDR, /* filter */ NULL, /* filterarg */ NULL, /* maxsize */ BUS_SPACE_MAXSIZE_32BIT, /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, /* lockfunc */ NULL, /* lockarg */ NULL, &bt->parent_dmat) != 0) { bt_pci_release_resources(dev); return (ENOMEM); } if (bt_probe(dev) || bt_fetch_adapter_info(dev) || bt_init(dev)) { bt_pci_release_resources(dev); return (ENXIO); } error = bt_attach(dev); if (error) { bt_pci_release_resources(dev); return (error); } return (0); }
static int bt_eisa_attach(device_t dev) { struct bt_softc *bt = device_get_softc(dev); /* Allocate resources */ bt_eisa_alloc_resources(dev); /* Allocate a dmatag for our SCB DMA maps */ /* XXX Should be a child of the PCI bus dma tag */ if (bus_dma_tag_create( /* parent */ NULL, /* alignment */ 1, /* boundary */ 0, /* lowaddr */ BUS_SPACE_MAXADDR_32BIT, /* highaddr */ BUS_SPACE_MAXADDR, /* filter */ NULL, /* filterarg */ NULL, /* maxsize */ BUS_SPACE_MAXSIZE_32BIT, /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, /* lockfunc */ busdma_lock_mutex, /* lockarg, */ &Giant, &bt->parent_dmat) != 0) { bt_eisa_release_resources(dev); return -1; } /* * Now that we know we own the resources we need, do the full * card initialization. */ if (bt_probe(dev) || bt_fetch_adapter_info(dev) || bt_init(dev)) { bt_eisa_release_resources(dev); return -1; } /* Attach sub-devices - always succeeds (sets up intr) */ bt_attach(dev); return 0; }
/* * 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; /* Initialise softc */ error = bt_isa_alloc_resources(dev, 0, ~0); if (error) { device_printf(dev, "can't allocate resources in bt_isa_attach\n"); return error; } /* Program the DMA channel for external control */ if ((drq = isa_get_drq(dev)) != -1) isa_dmacascade(drq); /* Allocate our parent dmatag */ filter = NULL; filter_arg = NULL; lowaddr = BUS_SPACE_MAXADDR_24BIT; /* XXX Should be a child of the ISA bus dma tag */ if (bus_dma_tag_create(/*parent*/NULL, /*alignemnt*/1, /*boundary*/0, lowaddr, /*highaddr*/BUS_SPACE_MAXADDR, filter, filter_arg, /*maxsize*/BUS_SPACE_MAXSIZE_32BIT, /*nsegments*/BUS_SPACE_UNRESTRICTED, /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, /*flags*/0, &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) { /* DMA tag for our sense buffers */ if (bus_dma_tag_create(bt->parent_dmat, /*alignment*/1, /*boundary*/0, /*lowaddr*/BUS_SPACE_MAXADDR, /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, bt->max_ccbs * sizeof(struct scsi_sense_data), /*nsegments*/1, /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, /*flags*/0, &bt->sense_dmat) != 0) { bt_isa_release_resources(dev); return (ENOMEM); } bt->init_level++; /* Allocation of sense buffers */ 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++; /* And permanently map them */ bus_dmamap_load(bt->sense_dmat, bt->sense_dmamap, bt->sense_buffers, bt->max_ccbs * sizeof(*bt->sense_buffers), btmapsensebuffers, bt, /*flags*/0); bt->init_level++; } error = bt_attach(dev); if (error) { bt_isa_release_resources(dev); return (error); } return (0); }
static int bt_mca_attach (device_t dev) { struct bt_softc * bt = device_get_softc(dev); int error = 0; /* Allocate resources */ if ((error = bt_mca_alloc_resources(dev, BT_MCA_ATTACH))) { device_printf(dev, "Unable to allocate resources in bt_mca_attach()\n"); return (error); } isa_dmacascade(rman_get_start(bt->drq)); /* Allocate a dmatag for our CCB DMA maps */ if (bus_dma_tag_create( /* parent */ NULL, /* alignemnt */ 1, /* boundary */ 0, /* lowaddr */ BUS_SPACE_MAXADDR_24BIT, /* highaddr */ BUS_SPACE_MAXADDR, /* filter */ btvlbouncefilter, /* filterarg */ bt, /* maxsize */ BUS_SPACE_MAXSIZE_32BIT, /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, /* lockfunc */ NULL, /* lockarg */ NULL, &bt->parent_dmat) != 0) { bt_mca_release_resources(dev); return (ENOMEM); } if (bt_init(dev)) { bt_mca_release_resources(dev); return (ENOMEM); } /* DMA tag for our sense buffers */ if (bus_dma_tag_create( /* parent */ bt->parent_dmat, /* alignment */ 1, /* boundary */ 0, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ BUS_SPACE_MAXADDR, /* filter */ NULL, /* filterarg */ NULL, /* maxsize */ bt->max_ccbs * sizeof(struct scsi_sense_data), /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, /* lockfunc */ NULL, /* lockarg */ NULL, &bt->sense_dmat) != 0) { bt_mca_release_resources(dev); return (ENOMEM); } bt->init_level++; /* Allocation of sense buffers */ if (bus_dmamem_alloc(bt->sense_dmat, (void **)&bt->sense_buffers, BUS_DMA_NOWAIT, &bt->sense_dmamap) != 0) { bt_mca_release_resources(dev); return (ENOMEM); } bt->init_level++; /* And permanently map them */ bus_dmamap_load(bt->sense_dmat, bt->sense_dmamap, bt->sense_buffers, bt->max_ccbs * sizeof(*bt->sense_buffers), btmapsensebuffers, bt, /*flags*/0); bt->init_level++; if ((error = bt_attach(dev))) { bt_mca_release_resources(dev); return (error); } return (0); }
/* * 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; /* Initialise softc */ error = bt_isa_alloc_resources(dev, 0, ~0); if (error) { device_printf(dev, "can't allocate resources in bt_isa_attach\n"); return error; } /* Program the DMA channel for external control */ if ((drq = isa_get_drq(dev)) != -1) isa_dmacascade(drq); /* Allocate our parent dmatag */ filter = NULL; filter_arg = NULL; lowaddr = BUS_SPACE_MAXADDR_24BIT; if (bt->model[0] == '4') { /* * 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. */ 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; } } /* XXX Should be a child of the ISA or VL bus dma tag */ if (bus_dma_tag_create( /* parent */ bus_get_dma_tag(dev), /* alignemnt */ 1, /* boundary */ 0, /* lowaddr */ lowaddr, /* highaddr */ BUS_SPACE_MAXADDR, /* filter */ filter, /* filterarg */ filter_arg, /* maxsize */ BUS_SPACE_MAXSIZE_32BIT, /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, /* lockfunc */ NULL, /* lockarg */ 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) { /* DMA tag for our sense buffers */ if (bus_dma_tag_create( /* parent */ bt->parent_dmat, /* alignment */ 1, /* boundary */ 0, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ BUS_SPACE_MAXADDR, /* filter */ NULL, /* filterarg */ NULL, /* maxsize */ bt->max_ccbs * sizeof(struct scsi_sense_data), /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, /* lockfunc */ NULL, /* lockarg */ NULL, &bt->sense_dmat) != 0) { bt_isa_release_resources(dev); return (ENOMEM); } bt->init_level++; /* Allocation of sense buffers */ 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++; /* And permanently map them */ bus_dmamap_load(bt->sense_dmat, bt->sense_dmamap, bt->sense_buffers, bt->max_ccbs * sizeof(*bt->sense_buffers), btmapsensebuffers, bt, /*flags*/0); bt->init_level++; } error = bt_attach(dev); if (error) { bt_isa_release_resources(dev); return (error); } return (0); }