summaryrefslogtreecommitdiffstats
path: root/sys/dev/buslogic
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-04-18 15:50:35 +0000
committerpeter <peter@FreeBSD.org>1999-04-18 15:50:35 +0000
commitd31d6be6f69b97664f49ea66dc3e371f78b96da7 (patch)
tree1e02bc4ef3b26a4288796ff2f42370aa037dfed9 /sys/dev/buslogic
parentdfb16d4177a39907c05c263200214aca2caaa824 (diff)
downloadFreeBSD-src-d31d6be6f69b97664f49ea66dc3e371f78b96da7.zip
FreeBSD-src-d31d6be6f69b97664f49ea66dc3e371f78b96da7.tar.gz
Implement an EISA new-bus framework. The old driver probe mechanism
had a quirk that made a shim rather hard to implement properly and it was just easier to convert the drivers in one go. The changes to the buslogic driver go beyond just this - the whole driver was new-bus'ed including pci and isa. I have only tested the EISA part of this so far. Submitted by: Doug Rabson <dfr@nlsystems.com>
Diffstat (limited to 'sys/dev/buslogic')
-rw-r--r--sys/dev/buslogic/bt.c163
-rw-r--r--sys/dev/buslogic/bt_eisa.c356
-rw-r--r--sys/dev/buslogic/bt_isa.c195
-rw-r--r--sys/dev/buslogic/bt_pci.c181
-rw-r--r--sys/dev/buslogic/btreg.h28
5 files changed, 504 insertions, 419 deletions
diff --git a/sys/dev/buslogic/bt.c b/sys/dev/buslogic/bt.c
index 7d177c6..4c3c49b 100644
--- a/sys/dev/buslogic/bt.c
+++ b/sys/dev/buslogic/bt.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bt.c,v 1.14 1999/03/08 21:36:33 gibbs Exp $
+ * $Id: bt.c,v 1.15 1999/04/07 23:01:43 gibbs Exp $
*/
/*
@@ -46,6 +46,7 @@
#include <sys/buf.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
+#include <sys/bus.h>
/*
* XXX It appears that BusLogic PCI adapters go out to lunch if you
@@ -60,6 +61,7 @@
#include <machine/bus_pio.h>
#include <machine/bus.h>
#include <machine/clock.h>
+#include <sys/rman.h>
#include <cam/cam.h>
#include <cam/cam_ccb.h>
@@ -208,48 +210,29 @@ u_int16_t bt_board_ports[] =
};
/* Exported functions */
-struct bt_softc *
-bt_alloc(int unit, bus_space_tag_t tag, bus_space_handle_t bsh)
+void
+bt_init_softc(device_t dev, struct resource *port,
+ struct resource *irq, struct resource *drq)
{
- struct bt_softc *bt;
-
- if (unit != BT_TEMP_UNIT) {
- if (unit >= NBT) {
- printf("bt: unit number (%d) too high\n", unit);
- return NULL;
- }
-
- /*
- * Allocate a storage area for us
- */
- if (bt_softcs[unit]) {
- printf("bt%d: memory already allocated\n", unit);
- return NULL;
- }
- }
+ struct bt_softc *bt = device_get_softc(dev);
- bt = malloc(sizeof(struct bt_softc), M_DEVBUF, M_NOWAIT);
- if (!bt) {
- printf("bt%d: cannot malloc!\n", unit);
- return NULL;
- }
- bzero(bt, sizeof(struct bt_softc));
SLIST_INIT(&bt->free_bt_ccbs);
LIST_INIT(&bt->pending_ccbs);
SLIST_INIT(&bt->sg_maps);
- bt->unit = unit;
- bt->tag = tag;
- bt->bsh = bsh;
-
- if (bt->unit != BT_TEMP_UNIT) {
- bt_softcs[unit] = bt;
- }
- return (bt);
+ bt->dev = dev;
+ bt->unit = device_get_unit(dev);
+ bt->port = port;
+ bt->irq = irq;
+ bt->drq = drq;
+ bt->tag = rman_get_bustag(port);
+ bt->bsh = rman_get_bushandle(port);
}
void
-bt_free(struct bt_softc *bt)
+bt_free_softc(device_t dev)
{
+ struct bt_softc *bt = device_get_softc(dev);
+
switch (bt->init_level) {
default:
case 11:
@@ -294,20 +277,17 @@ bt_free(struct bt_softc *bt)
case 0:
break;
}
- if (bt->unit != BT_TEMP_UNIT) {
- bt_softcs[bt->unit] = NULL;
- }
- free(bt, M_DEVBUF);
}
int
-bt_port_probe(struct bt_softc *bt, struct bt_probe_info *info)
+bt_port_probe(device_t dev, struct bt_probe_info *info)
{
+ struct bt_softc *bt = device_get_softc(dev);
config_data_t config_data;
int error;
/* See if there is really a card present */
- if (bt_probe(bt) || bt_fetch_adapter_info(bt))
+ if (bt_probe(dev) || bt_fetch_adapter_info(dev))
return(1);
/*
@@ -365,8 +345,9 @@ bt_port_probe(struct bt_softc *bt, struct bt_probe_info *info)
* Probe the adapter and verify that the card is a BusLogic.
*/
int
-bt_probe(struct bt_softc* bt)
+bt_probe(device_t dev)
{
+ struct bt_softc *bt = device_get_softc(dev);
esetup_info_data_t esetup_info;
u_int status;
u_int intstat;
@@ -384,21 +365,21 @@ bt_probe(struct bt_softc* bt)
|| (status & (DIAG_ACTIVE|CMD_REG_BUSY|
STATUS_REG_RSVD|CMD_INVALID)) != 0) {
if (bootverbose)
- printf("%s: Failed Status Reg Test - %x\n", bt_name(bt),
+ device_printf(dev, "Failed Status Reg Test - %x\n",
status);
return (ENXIO);
}
intstat = bt_inb(bt, INTSTAT_REG);
if ((intstat & INTSTAT_REG_RSVD) != 0) {
- printf("%s: Failed Intstat Reg Test\n", bt_name(bt));
+ device_printf(dev, "Failed Intstat Reg Test\n");
return (ENXIO);
}
geometry = bt_inb(bt, GEOMETRY_REG);
if (geometry == 0xFF) {
if (bootverbose)
- printf("%s: Failed Geometry Reg Test\n", bt_name(bt));
+ device_printf(dev, "Failed Geometry Reg Test\n");
return (ENXIO);
}
@@ -409,7 +390,7 @@ bt_probe(struct bt_softc* bt)
*/
if ((error = btreset(bt, /*hard_reset*/TRUE)) != 0) {
if (bootverbose)
- printf("%s: Failed Reset\n", bt_name(bt));
+ device_printf(dev, "Failed Reset\n");
return (ENXIO);
}
@@ -428,8 +409,9 @@ bt_probe(struct bt_softc* bt)
* Pull the boards setup information and record it in our softc.
*/
int
-bt_fetch_adapter_info(struct bt_softc *bt)
+bt_fetch_adapter_info(device_t dev)
{
+ struct bt_softc *bt = device_get_softc(dev);
board_id_data_t board_id;
esetup_info_data_t esetup_info;
config_data_t config_data;
@@ -441,8 +423,7 @@ bt_fetch_adapter_info(struct bt_softc *bt)
(u_int8_t*)&board_id, sizeof(board_id),
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
- printf("%s: bt_fetch_adapter_info - Failed Get Board Info\n",
- bt_name(bt));
+ device_printf(dev, "bt_fetch_adapter_info - Failed Get Board Info\n");
return (error);
}
bt->firmware_ver[0] = board_id.firmware_rev_major;
@@ -460,8 +441,9 @@ bt_fetch_adapter_info(struct bt_softc *bt)
(u_int8_t*)&bt->firmware_ver[3], 1,
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
- printf("%s: bt_fetch_adapter_info - Failed Get "
- "Firmware 3rd Digit\n", bt_name(bt));
+ device_printf(dev,
+ "bt_fetch_adapter_info - Failed Get "
+ "Firmware 3rd Digit\n");
return (error);
}
if (bt->firmware_ver[3] == ' ')
@@ -475,8 +457,9 @@ bt_fetch_adapter_info(struct bt_softc *bt)
(u_int8_t*)&bt->firmware_ver[4], 1,
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
- printf("%s: bt_fetch_adapter_info - Failed Get "
- "Firmware 4th Digit\n", bt_name(bt));
+ device_printf(dev,
+ "bt_fetch_adapter_info - Failed Get "
+ "Firmware 4th Digit\n");
return (error);
}
if (bt->firmware_ver[4] == ' ')
@@ -532,8 +515,9 @@ bt_fetch_adapter_info(struct bt_softc *bt)
(u_int8_t*)&model_data, sizeof(model_data),
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
- printf("%s: bt_fetch_adapter_info - Failed Inquire "
- "Model Number\n", bt_name(bt));
+ device_printf(dev,
+ "bt_fetch_adapter_info - Failed Inquire "
+ "Model Number\n");
return (error);
}
for (i = 0; i < sizeof(model_data.ascii_model); i++) {
@@ -617,8 +601,9 @@ bt_fetch_adapter_info(struct bt_softc *bt)
sizeof(auto_scsi_data), DEFAULT_CMD_TIMEOUT);
if (error != 0) {
- printf("%s: bt_fetch_adapter_info - Failed "
- "Get Auto SCSI Info\n", bt_name(bt));
+ device_printf(dev,
+ "bt_fetch_adapter_info - Failed "
+ "Get Auto SCSI Info\n");
return (error);
}
@@ -651,8 +636,9 @@ bt_fetch_adapter_info(struct bt_softc *bt)
sizeof(setup_info), DEFAULT_CMD_TIMEOUT);
if (error != 0) {
- printf("%s: bt_fetch_adapter_info - Failed "
- "Get Setup Info\n", bt_name(bt));
+ device_printf(dev,
+ "bt_fetch_adapter_info - Failed "
+ "Get Setup Info\n");
return (error);
}
@@ -678,8 +664,8 @@ bt_fetch_adapter_info(struct bt_softc *bt)
(u_int8_t*)&config_data, sizeof(config_data),
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
- printf("%s: bt_fetch_adapter_info - Failed Get Config\n",
- bt_name(bt));
+ device_printf(dev,
+ "bt_fetch_adapter_info - Failed Get Config\n");
return (error);
}
bt->scsi_id = config_data.scsi_id;
@@ -691,11 +677,12 @@ bt_fetch_adapter_info(struct bt_softc *bt)
* Start the board, ready for normal operation
*/
int
-bt_init(struct bt_softc* bt)
+bt_init(device_t dev)
{
+ struct bt_softc *bt = device_get_softc(dev);
+
/* Announce the Adapter */
- printf("%s: BT-%s FW Rev. %s ", bt_name(bt),
- bt->model, bt->firmware_ver);
+ device_printf(dev, "BT-%s FW Rev. %s ", bt->model, bt->firmware_ver);
if (bt->ultra_scsi != 0)
printf("Ultra ");
@@ -818,8 +805,8 @@ bt_init(struct bt_softc* bt)
btallocccbs(bt);
if (bt->num_ccbs == 0) {
- printf("%s: bt_init - Unable to allocate initial ccbs\n",
- bt_name(bt));
+ device_printf(dev,
+ "bt_init - Unable to allocate initial ccbs\n");
goto error_exit;
}
@@ -834,8 +821,9 @@ error_exit:
}
int
-bt_attach(struct bt_softc *bt)
+bt_attach(device_t dev)
{
+ struct bt_softc *bt = device_get_softc(dev);
int tagged_dev_openings;
struct cam_devq *devq;
@@ -878,16 +866,12 @@ bt_attach(struct bt_softc *bt)
return (ENXIO);
}
- return (0);
-}
-
-char *
-bt_name(struct bt_softc *bt)
-{
- static char name[10];
+ /*
+ * Setup interrupt.
+ */
+ bus_setup_intr(dev, bt->irq, bt_intr, bt, &bt->ih);
- snprintf(name, sizeof(name), "bt%d", bt->unit);
- return (name);
+ return (0);
}
int
@@ -1055,7 +1039,7 @@ btgetccb(struct bt_softc *bt)
btallocccbs(bt);
bccb = SLIST_FIRST(&bt->free_bt_ccbs);
if (bccb == NULL)
- printf("%s: Can't malloc BCCB\n", bt_name(bt));
+ device_printf(bt->dev, "Can't malloc BCCB\n");
else {
SLIST_REMOVE_HEAD(&bt->free_bt_ccbs, links);
bt->active_ccbs++;
@@ -1388,8 +1372,9 @@ btexecuteccb(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
if (error != 0) {
if (error != EFBIG)
- printf("%s: Unexepected error 0x%x returned from "
- "bus_dmamap_load\n", bt_name(bt), error);
+ device_printf(bt->dev,
+ "Unexepected error 0x%x returned from "
+ "bus_dmamap_load\n", error);
if (ccb->ccb_h.status == CAM_REQ_INPROG) {
xpt_freeze_devq(ccb->ccb_h.path, /*count*/1);
ccb->ccb_h.status = CAM_REQ_TOO_BIG|CAM_DEV_QFRZN;
@@ -1470,9 +1455,10 @@ btexecuteccb(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
* hung, one of the pending transactions will
* timeout causing us to start recovery operations.
*/
- printf("%s: Encountered busy mailbox with %d out of %d "
- "commands active!!!\n", bt_name(bt), bt->active_ccbs,
- bt->max_ccbs);
+ device_printf(bt->dev,
+ "Encountered busy mailbox with %d out of %d "
+ "commands active!!!\n", bt->active_ccbs,
+ bt->max_ccbs);
untimeout(bttimeout, bccb, ccb->ccb_h.timeout_ch);
if (nseg != 0)
bus_dmamap_unload(bt->buffer_dmat, bccb->dmamap);
@@ -1531,8 +1517,9 @@ btdone(struct bt_softc *bt, struct bt_ccb *bccb, bt_mbi_comp_code_t comp_code)
csio = &bccb->ccb->csio;
if ((bccb->flags & BCCB_ACTIVE) == 0) {
- printf("%s: btdone - Attempt to free non-active BCCB %p\n",
- bt_name(bt), (void *)bccb);
+ device_printf(bt->dev,
+ "btdone - Attempt to free non-active BCCB %p\n",
+ (void *)bccb);
return;
}
@@ -1586,7 +1573,7 @@ btdone(struct bt_softc *bt, struct bt_ccb *bccb, bt_mbi_comp_code_t comp_code)
ccb_h = LIST_NEXT(ccb_h, sim_links.le);
}
}
- printf("%s: No longer in timeout\n", bt_name(bt));
+ device_printf(bt->dev, "No longer in timeout\n");
return;
}
@@ -1594,12 +1581,12 @@ btdone(struct bt_softc *bt, struct bt_ccb *bccb, bt_mbi_comp_code_t comp_code)
switch (comp_code) {
case BMBI_FREE:
- printf("%s: btdone - CCB completed with free status!\n",
- bt_name(bt));
+ device_printf(bt->dev,
+ "btdone - CCB completed with free status!\n");
break;
case BMBI_NOT_FOUND:
- printf("%s: btdone - CCB Abort failed to find CCB\n",
- bt_name(bt));
+ device_printf(bt->dev,
+ "btdone - CCB Abort failed to find CCB\n");
break;
case BMBI_ABORT:
case BMBI_ERROR:
diff --git a/sys/dev/buslogic/bt_eisa.c b/sys/dev/buslogic/bt_eisa.c
index 9272d3d..84ca778 100644
--- a/sys/dev/buslogic/bt_eisa.c
+++ b/sys/dev/buslogic/bt_eisa.c
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bt_eisa.c,v 1.2 1999/03/08 21:35:03 gibbs Exp $
+ * $Id: bt_eisa.c,v 1.3 1999/03/23 07:27:38 gibbs Exp $
*/
#include "eisa.h"
@@ -35,9 +35,13 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/bus.h>
#include <machine/bus_pio.h>
#include <machine/bus.h>
+#include <machine/resource.h>
+#include <sys/rman.h>
#include <i386/eisa/eisaconf.h>
@@ -99,20 +103,58 @@
#define AMI_MISC2_OPTIONS 0x49E
#define AMI_ENABLE_ISA_DMA 0x08
-static int bt_eisa_probe(void);
-static int bt_eisa_attach(struct eisa_device *e_dev);
+static const char *bt_match(eisa_id_t type);
-static struct eisa_driver bt_eisa_driver = {
- "bt",
- bt_eisa_probe,
- bt_eisa_attach,
- /*shutdown*/NULL,
- &bt_unit
-};
+static int
+bt_eisa_alloc_resources(device_t dev)
+{
+ struct bt_softc *bt = device_get_softc(dev);
+ int rid;
+ struct resource *port;
+ struct resource *irq;
+ int shared;
-DATA_SET (eisadriver_set, bt_eisa_driver);
+ /*
+ * XXX assumes that the iospace ranges are sorted in increasing
+ * order.
+ */
+ rid = 1;
+ port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
+ 0, ~0, 1, RF_ACTIVE);
+ if (!port)
+ return (ENOMEM);
+
+ bt_init_softc(dev, port, 0, 0);
+
+ if (eisa_get_irq(dev) != -1) {
+ shared = bt->level_trigger_ints ? RF_SHAREABLE : 0;
+ rid = 0;
+ irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
+ 0, ~0, 1, shared | RF_ACTIVE);
+ if (!irq) {
+ if (port)
+ bus_release_resource(dev, SYS_RES_IOPORT,
+ 0, port);
+ return (ENOMEM);
+ }
+ } else
+ irq = 0;
+ bt->irq = irq;
-static const char *bt_match(eisa_id_t type);
+ return (0);
+}
+
+static void
+bt_eisa_release_resources(device_t dev)
+{
+ struct bt_softc *bt = device_get_softc(dev);
+
+ if (bt->port)
+ bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->port);
+ if (bt->irq)
+ bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->irq);
+ bt_free_softc(dev);
+}
static const char*
bt_match(eisa_id_t type)
@@ -137,155 +179,119 @@ bt_match(eisa_id_t type)
}
static int
-bt_eisa_probe(void)
+bt_eisa_probe(device_t dev)
{
+ const char *desc;
u_long iobase;
- struct eisa_device *e_dev = NULL;
- int count;
-
- count = 0;
- while ((e_dev = eisa_match_dev(e_dev, bt_match))) {
- struct bt_softc *bt;
- struct bt_probe_info info;
- u_long port;
- u_long iosize;
- u_int ioconf;
-
- iobase = (e_dev->ioconf.slot * EISA_SLOT_SIZE);
- if (e_dev->id == EISA_DEVICE_ID_AMI_4801) {
- u_int ioconf1;
-
- iobase += AMI_EISA_SLOT_OFFSET;
- iosize = AMI_EISA_IOSIZE;
- ioconf1 = inb(iobase + AMI_EISA_IOCONF1);
- /* Determine "ISA" I/O port */
- switch (ioconf1 & AMI_PORTADDR) {
- case AMI_PORT_330:
- port = 0x330;
- break;
- case AMI_PORT_334:
- port = 0x334;
- break;
- case AMI_PORT_230:
- port = 0x230;
- break;
- case AMI_PORT_234:
- port = 0x234;
- break;
- case AMI_PORT_134:
- port = 0x134;
- break;
- case AMI_PORT_130:
- port = 0x130;
- break;
- default:
- /* Disabled */
- printf("bt: AMI EISA Adapter at "
- "slot %d has a disabled I/O "
- "port. Cannot attach.\n",
- e_dev->ioconf.slot);
- continue;
- }
- } else {
- iobase += BT_EISA_SLOT_OFFSET;
- iosize = BT_EISA_IOSIZE;
-
- ioconf = inb(iobase + EISA_IOCONF);
- /* Determine "ISA" I/O port */
- switch (ioconf & PORTADDR) {
- case PORT_330:
- port = 0x330;
- break;
- case PORT_334:
- port = 0x334;
- break;
- case PORT_230:
- port = 0x230;
- break;
- case PORT_234:
- port = 0x234;
- break;
- case PORT_130:
- port = 0x130;
- break;
- case PORT_134:
- port = 0x134;
- break;
- default:
- /* Disabled */
- printf("bt: Buslogic EISA Adapter at "
- "slot %d has a disabled I/O "
- "port. Cannot attach.\n",
- e_dev->ioconf.slot);
- continue;
- }
- }
- bt_mark_probed_iop(port);
-
- /* Allocate a softc for use during probing */
- bt = bt_alloc(BT_TEMP_UNIT, I386_BUS_SPACE_IO, port);
-
- if (bt == NULL) {
- printf("bt_eisa_probe: Could not allocate softc for "
- "card at slot 0x%x\n", e_dev->ioconf.slot);
- continue;
+ struct bt_probe_info info;
+ u_long port;
+ u_long iosize;
+ u_int ioconf;
+ int result;
+
+ desc = bt_match(eisa_get_id(dev));
+ if (!desc)
+ return (ENXIO);
+ device_set_desc(dev, desc);
+
+ iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE);
+ if (eisa_get_id(dev) == EISA_DEVICE_ID_AMI_4801) {
+ u_int ioconf1;
+
+ iobase += AMI_EISA_SLOT_OFFSET;
+ iosize = AMI_EISA_IOSIZE;
+ ioconf1 = inb(iobase + AMI_EISA_IOCONF1);
+ /* Determine "ISA" I/O port */
+ switch (ioconf1 & AMI_PORTADDR) {
+ case AMI_PORT_330:
+ port = 0x330;
+ break;
+ case AMI_PORT_334:
+ port = 0x334;
+ break;
+ case AMI_PORT_230:
+ port = 0x230;
+ break;
+ case AMI_PORT_234:
+ port = 0x234;
+ break;
+ case AMI_PORT_134:
+ port = 0x134;
+ break;
+ case AMI_PORT_130:
+ port = 0x130;
+ break;
+ default:
+ /* Disabled */
+ printf("bt: AMI EISA Adapter at "
+ "slot %d has a disabled I/O "
+ "port. Cannot attach.\n",
+ eisa_get_slot(dev));
+ return (ENXIO);
}
-
- if (bt_port_probe(bt, &info) != 0) {
- printf("bt_eisa_probe: Probe failed for "
- "card at slot 0x%x\n", e_dev->ioconf.slot);
- } else {
- eisa_add_iospace(e_dev, iobase, iosize, RESVADDR_NONE);
- eisa_add_iospace(e_dev, port, BT_IOSIZE, RESVADDR_NONE);
- eisa_add_intr(e_dev, info.irq);
-
- eisa_registerdev(e_dev, &bt_eisa_driver);
-
- count++;
+ } else {
+ iobase += BT_EISA_SLOT_OFFSET;
+ iosize = BT_EISA_IOSIZE;
+
+ ioconf = inb(iobase + EISA_IOCONF);
+ /* Determine "ISA" I/O port */
+ switch (ioconf & PORTADDR) {
+ case PORT_330:
+ port = 0x330;
+ break;
+ case PORT_334:
+ port = 0x334;
+ break;
+ case PORT_230:
+ port = 0x230;
+ break;
+ case PORT_234:
+ port = 0x234;
+ break;
+ case PORT_130:
+ port = 0x130;
+ break;
+ case PORT_134:
+ port = 0x134;
+ break;
+ default:
+ /* Disabled */
+ printf("bt: Buslogic EISA Adapter at "
+ "slot %d has a disabled I/O "
+ "port. Cannot attach.\n",
+ eisa_get_slot(dev));
+ return (ENXIO);
}
- bt_free(bt);
}
- return count;
+ bt_mark_probed_iop(port);
+
+ /* Tell parent where our resources are going to be */
+ eisa_add_iospace(dev, iobase, iosize, RESVADDR_NONE);
+ eisa_add_iospace(dev, port, BT_IOSIZE, RESVADDR_NONE);
+
+ /* And allocate them */
+ bt_eisa_alloc_resources(dev);
+
+ if (bt_port_probe(dev, &info) != 0) {
+ printf("bt_eisa_probe: Probe failed for "
+ "card at slot 0x%x\n", eisa_get_slot(dev));
+ result = ENXIO;
+ } else {
+ eisa_add_intr(dev, info.irq);
+ result = 0;
+ }
+ bt_eisa_release_resources(dev);
+
+ return (result);
}
static int
-bt_eisa_attach(struct eisa_device *e_dev)
+bt_eisa_attach(device_t dev)
{
- struct bt_softc *bt;
- int unit = e_dev->unit;
- int irq;
- resvaddr_t *ioport;
- resvaddr_t *eisa_ioport;
-
- if (TAILQ_FIRST(&e_dev->ioconf.irqs) == NULL)
- return (-1);
-
- irq = TAILQ_FIRST(&e_dev->ioconf.irqs)->irq_no;
-
- /*
- * The addresses are sorted in increasing order
- * so we know the port to pass to the core bt
- * driver comes first.
- */
- ioport = e_dev->ioconf.ioaddrs.lh_first;
-
- if (ioport == NULL)
- return -1;
-
- eisa_ioport = ioport->links.le_next;
-
- if (eisa_ioport == NULL)
- return -1;
-
- eisa_reg_start(e_dev);
- if (eisa_reg_iospace(e_dev, ioport))
- return -1;
-
- if (eisa_reg_iospace(e_dev, eisa_ioport))
- return -1;
+ struct bt_softc *bt = device_get_softc(dev);
- if ((bt = bt_alloc(unit, I386_BUS_SPACE_IO, ioport->addr)) == NULL)
- return -1;
+ /* 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 */
@@ -297,42 +303,42 @@ bt_eisa_attach(struct eisa_device *e_dev)
/*nsegments*/BUS_SPACE_UNRESTRICTED,
/*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
/*flags*/0, &bt->parent_dmat) != 0) {
- bt_free(bt);
- return -1;
- }
-
- if (eisa_reg_intr(e_dev, irq, bt_intr, (void *)bt, &cam_imask,
- /*shared ==*/bt->level_trigger_ints ? 1 : 0)) {
- bt_free(bt);
+ bt_eisa_release_resources(dev);
return -1;
}
- eisa_reg_end(e_dev);
/*
* Now that we know we own the resources we need, do the full
* card initialization.
*/
- if (bt_probe(bt) || bt_fetch_adapter_info(bt) || bt_init(bt)) {
- bt_free(bt);
- /*
- * The board's IRQ line will not be left enabled
- * if we can't intialize correctly, so its safe
- * to release the irq.
- */
- eisa_release_intr(e_dev, irq, bt_intr);
+ if (bt_probe(dev) || bt_fetch_adapter_info(dev) || bt_init(dev)) {
+ bt_eisa_release_resources(dev);
return -1;
}
- /* Attach sub-devices - always succeeds */
- bt_attach(bt);
-
- if (eisa_enable_intr(e_dev, irq)) {
- bt_free(bt);
- eisa_release_intr(e_dev, irq, bt_intr);
- return -1;
- }
+ /* Attach sub-devices - always succeeds (sets up intr) */
+ bt_attach(dev);
return 0;
}
+static device_method_t bt_eisa_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, bt_eisa_probe),
+ DEVMETHOD(device_attach, bt_eisa_attach),
+
+ { 0, 0 }
+};
+
+static driver_t bt_eisa_driver = {
+ "bt",
+ bt_eisa_methods,
+ DRIVER_TYPE_CAM,
+ sizeof(struct bt_softc),
+};
+
+static devclass_t bt_devclass;
+
+DRIVER_MODULE(bt, eisa, bt_eisa_driver, bt_devclass, 0, 0);
+
#endif /* NEISA > 0 */
diff --git a/sys/dev/buslogic/bt_isa.c b/sys/dev/buslogic/bt_isa.c
index edf1366..03c5c82 100644
--- a/sys/dev/buslogic/bt_isa.c
+++ b/sys/dev/buslogic/bt_isa.c
@@ -26,33 +26,90 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bt_isa.c,v 1.6 1999/03/08 21:32:59 gibbs Exp $
+ * $Id: bt_isa.c,v 1.7 1999/04/06 21:15:18 phk Exp $
*/
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/bus.h>
#include <machine/bus_pio.h>
#include <machine/bus.h>
+#include <machine/resource.h>
+#include <sys/rman.h>
-#include <i386/isa/isa_device.h>
+#include <isa/isavar.h>
+#include <i386/isa/isa_dma.h>
#include <dev/buslogic/btreg.h>
#include <cam/scsi/scsi_all.h>
-static int bt_isa_probe __P((struct isa_device *dev));
-static int bt_isa_attach __P((struct isa_device *dev));
-static void bt_isa_intr __P((void *unit));
-
static bus_dma_filter_t btvlbouncefilter;
static bus_dmamap_callback_t btmapsensebuffers;
-struct isa_driver btdriver =
+static int
+bt_isa_alloc_resources(device_t dev)
{
- bt_isa_probe,
- bt_isa_attach,
- "bt"
-};
+ int rid;
+ struct resource *port;
+ struct resource *irq;
+ struct resource *drq;
+
+ rid = 0;
+ port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
+ 0, ~0, 1, RF_ACTIVE);
+ if (!port)
+ return (ENOMEM);
+
+ if (isa_get_irq(dev) != -1) {
+ rid = 0;
+ irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
+ 0, ~0, 1, RF_ACTIVE);
+ if (!irq) {
+ if (port)
+ bus_release_resource(dev, SYS_RES_IOPORT,
+ 0, port);
+ return (ENOMEM);
+ }
+ } else
+ irq = 0;
+
+ if (isa_get_drq(dev) != -1) {
+ rid = 0;
+ drq = bus_alloc_resource(dev, SYS_RES_DRQ, &rid,
+ 0, ~0, 1, RF_ACTIVE);
+ if (!drq) {
+ if (port)
+ bus_release_resource(dev, SYS_RES_IOPORT,
+ 0, port);
+ if (irq)
+ bus_release_resource(dev, SYS_RES_IRQ,
+ 0, irq);
+ return (ENOMEM);
+ }
+ } else
+ drq = 0;
+
+ bt_init_softc(dev, port, irq, drq);
+
+ return (0);
+}
+
+static void
+bt_isa_release_resources(device_t dev)
+{
+ struct bt_softc *bt = device_get_softc(dev);
+
+ if (bt->port)
+ bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->port);
+ if (bt->irq)
+ bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->irq);
+ if (bt->drq)
+ bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->drq);
+ bt_free_softc(dev);
+}
/*
* Check if the device can be found at the port given
@@ -61,35 +118,24 @@ struct isa_driver btdriver =
* autoconf.c
*/
static int
-bt_isa_probe(dev)
- struct isa_device *dev;
+bt_isa_probe(device_t dev)
{
/*
* find unit and check we have that many defined
*/
- struct bt_softc *bt;
int port_index;
int max_port_index;
- /*
- * We ignore the unit number assigned by config to allow
- * consistant numbering between PCI/EISA/ISA devices.
- * This is a total kludge until we have a configuration
- * manager.
- */
- dev->id_unit = bt_unit;
-
- bt = NULL;
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(dev->id_iobase, &port_index, &max_port_index);
+ bt_find_probe_range(isa_get_port(dev), &port_index, &max_port_index);
if (port_index < 0)
- return 0;
+ return (ENXIO);
/* Attempt to find an adapter */
for (;port_index <= max_port_index; port_index++) {
@@ -97,6 +143,8 @@ bt_isa_probe(dev)
u_int ioport;
ioport = bt_iop_from_bio(port_index);
+ isa_set_port(dev, ioport);
+ isa_set_portsize(dev, BT_NREGS);
/*
* Ensure this port has not already been claimed already
@@ -104,52 +152,50 @@ bt_isa_probe(dev)
*/
if (bt_check_probed_iop(ioport) != 0)
continue;
- dev->id_iobase = ioport;
- if (haveseen_isadev(dev, CC_IOADDR | CC_QUIET))
- continue;
-
- /* Allocate a softc for use during probing */
- bt = bt_alloc(dev->id_unit, I386_BUS_SPACE_IO, ioport);
- if (bt == NULL)
- break;
+ /* Initialise the softc for use during probing */
+ if (bt_isa_alloc_resources(dev) != 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(bt, &info) != 0) {
+ if (bt_port_probe(dev, &info) != 0) {
printf("bt_isa_probe: Probe failed for card at 0x%x\n",
ioport);
- bt_free(bt);
+ bt_isa_release_resources(dev);
continue;
}
- dev->id_drq = info.drq;
- dev->id_irq = 0x1 << info.irq;
- dev->id_intr = bt_isa_intr;
+ bt_isa_release_resources(dev);
+
+ isa_set_drq(dev, info.drq);
+ isa_set_irq(dev, info.irq);
- bt_unit++;
- return (BT_NREGS);
+ return (0);
}
- return (0);
+ return (ENXIO);
}
/*
* Attach all the sub-devices we can find
*/
static int
-bt_isa_attach(dev)
- struct isa_device *dev;
+bt_isa_attach(device_t dev)
{
- struct bt_softc *bt;
+ struct bt_softc *bt = device_get_softc(dev);
bus_dma_filter_t *filter;
void *filter_arg;
bus_addr_t lowaddr;
+ int error;
- bt = bt_softcs[dev->id_unit];
- if (dev->id_drq != -1)
- isa_dmacascade(dev->id_drq);
+ /* Initialise softc */
+ error = bt_isa_alloc_resources(dev);
+ if (error) {
+ device_printf(dev, "can't allocate resources in bt_isa_attach\n");
+ return error;
+ }
/* Allocate our parent dmatag */
filter = NULL;
@@ -186,13 +232,13 @@ bt_isa_attach(dev)
/*nsegments*/BUS_SPACE_UNRESTRICTED,
/*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
/*flags*/0, &bt->parent_dmat) != 0) {
- bt_free(bt);
- return (-1);
+ bt_isa_release_resources(dev);
+ return (ENOMEM);
}
- if (bt_init(bt)) {
- bt_free(bt);
- return (-1);
+ if (bt_init(dev)) {
+ bt_isa_release_resources(dev);
+ return (ENOMEM);
}
if (lowaddr != BUS_SPACE_MAXADDR_32BIT) {
@@ -207,8 +253,8 @@ bt_isa_attach(dev)
/*nsegments*/1,
/*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
/*flags*/0, &bt->sense_dmat) != 0) {
- bt_free(bt);
- return (-1);
+ bt_isa_release_resources(dev);
+ return (ENOMEM);
}
bt->init_level++;
@@ -217,8 +263,8 @@ bt_isa_attach(dev)
if (bus_dmamem_alloc(bt->sense_dmat,
(void **)&bt->sense_buffers,
BUS_DMA_NOWAIT, &bt->sense_dmamap) != 0) {
- bt_free(bt);
- return (-1);
+ bt_isa_release_resources(dev);
+ return (ENOMEM);
}
bt->init_level++;
@@ -232,19 +278,13 @@ bt_isa_attach(dev)
bt->init_level++;
}
- return (bt_attach(bt));
-}
+ error = bt_attach(dev);
+ if (error) {
+ bt_isa_release_resources(dev);
+ return (error);
+ }
-/*
- * Handle an ISA interrupt.
- * XXX should go away as soon as ISA interrupt handlers
- * take a (void *) arg.
- */
-static void
-bt_isa_intr(void *unit)
-{
- struct bt_softc* arg = bt_softcs[(int)unit];
- bt_intr((void *)arg);
+ return (0);
}
#define BIOS_MAP_SIZE (16 * 1024)
@@ -273,3 +313,22 @@ btmapsensebuffers(void *arg, bus_dma_segment_t *segs, int nseg, int error)
bt = (struct bt_softc*)arg;
bt->sense_buffers_physbase = segs->ds_addr;
}
+
+static device_method_t bt_isa_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, bt_isa_probe),
+ DEVMETHOD(device_attach, bt_isa_attach),
+
+ { 0, 0 }
+};
+
+static driver_t bt_isa_driver = {
+ "bt",
+ bt_isa_methods,
+ DRIVER_TYPE_CAM,
+ sizeof(struct bt_softc),
+};
+
+static devclass_t bt_devclass;
+
+DRIVER_MODULE(bt, isa, bt_isa_driver, bt_devclass, 0, 0);
diff --git a/sys/dev/buslogic/bt_pci.c b/sys/dev/buslogic/bt_pci.c
index 3c886d8..f77e43b 100644
--- a/sys/dev/buslogic/bt_pci.c
+++ b/sys/dev/buslogic/bt_pci.c
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bt_pci.c,v 1.3 1998/11/10 06:45:14 gibbs Exp $
+ * $Id: bt_pci.c,v 1.4 1998/12/14 06:32:54 dillon Exp $
*/
#include "pci.h"
@@ -34,6 +34,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/bus.h>
#include <pci/pcireg.h>
#include <pci/pcivar.h>
@@ -41,6 +42,8 @@
#include <machine/bus_memio.h>
#include <machine/bus_pio.h>
#include <machine/bus.h>
+#include <machine/resource.h>
+#include <sys/rman.h>
#include <dev/buslogic/btreg.h>
@@ -51,72 +54,74 @@
#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140104Bul
#define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130104Bul
-static int btpcideterminebusspace(pcici_t config_id, bus_space_tag_t* tagp,
- bus_space_handle_t* bshp);
-static const char* bt_pci_probe(pcici_t tag, pcidi_t type);
-static void bt_pci_attach(pcici_t config_id, int unit);
-
-static struct pci_device bt_pci_driver = {
- "bt",
- bt_pci_probe,
- bt_pci_attach,
- &bt_unit,
- NULL
-};
-
-DATA_SET (pcidevice_set, bt_pci_driver);
-
static int
-btpcideterminebusspace(pcici_t config_id, bus_space_tag_t* tagp,
- bus_space_handle_t* bshp)
+bt_pci_alloc_resources(device_t dev)
{
- vm_offset_t vaddr;
- vm_offset_t paddr;
- u_int16_t io_port;
- int command;
-
- vaddr = 0;
- paddr = 0;
- command = pci_cfgread(config_id, PCIR_COMMAND, /*bytes*/1);
- /* XXX Memory Mapped I/O seems to cause problems */
+ int command, type = 0, rid, zero;
+ struct resource *regs = 0;
+ struct resource *irq = 0;
+
+ command = pci_read_config(dev, PCIR_COMMAND, /*bytes*/1);
#if 0
- if ((command & PCIM_CMD_MEMEN) == 0
- || (pci_map_mem(config_id, BT_PCI_MEMADDR, &vaddr, &paddr)) == 0)
+ /* XXX Memory Mapped I/O seems to cause problems */
+ if (command & PCIM_CMD_MEMEN) {
+ type = SYS_RES_MEMORY;
+ rid = BT_PCI_MEMADDR;
+ regs = bus_alloc_resource(dev, type, &rid,
+ 0, ~0, 1, RF_ACTIVE);
+ }
+#else
+ if (!regs && (command & PCIM_CMD_PORTEN)) {
+ type = SYS_RES_IOPORT;
+ rid = BT_PCI_IOADDR;
+ regs = bus_alloc_resource(dev, type, &rid,
+ 0, ~0, 1, RF_ACTIVE);
+ }
#endif
- if ((command & PCIM_CMD_PORTEN) == 0
- || (pci_map_port(config_id, BT_PCI_IOADDR, &io_port)) == 0)
- return (-1);
-
- if (vaddr != 0) {
- *tagp = I386_BUS_SPACE_MEM;
- *bshp = vaddr;
- } else {
- *tagp = I386_BUS_SPACE_IO;
- *bshp = io_port;
+ if (!regs)
+ return (ENOMEM);
+
+ zero = 0;
+ irq = bus_alloc_resource(dev, SYS_RES_IRQ, &zero,
+ 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE);
+ if (!irq) {
+ bus_release_resource(dev, type, rid, regs);
+ return (ENOMEM);
}
+ bt_init_softc(dev, regs, irq, 0);
+
return (0);
}
-static const char*
-bt_pci_probe (pcici_t config_id, pcidi_t type)
+static void
+bt_pci_release_resources(device_t dev)
{
- switch(type) {
+ struct bt_softc *bt = device_get_softc(dev);
+
+ if (bt->port)
+ /* XXX can't cope with memory registers anyway */
+ bus_release_resource(dev, SYS_RES_IOPORT,
+ BT_PCI_IOADDR, bt->port);
+ if (bt->irq)
+ bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->irq);
+ bt_free_softc(dev);
+}
+
+static int
+bt_pci_probe(device_t dev)
+{
+ switch (pci_get_devid(dev)) {
case PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER:
case PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC:
{
- struct bt_softc *bt;
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
+ struct bt_softc *bt = device_get_softc(dev);
pci_info_data_t pci_info;
int error;
- if (btpcideterminebusspace(config_id, &tag, &bsh) != 0)
- break;
-
- bt = bt_alloc(BT_TEMP_UNIT, tag, bsh);
- if (bt == NULL)
- break;
+ error = bt_pci_alloc_resources(dev);
+ if (error)
+ return (error);
/*
* Determine if an ISA compatible I/O port has been
@@ -131,7 +136,7 @@ bt_pci_probe (pcici_t config_id, pcidi_t type)
if (error == 0
&& pci_info.io_port < BIO_DISABLED) {
bt_mark_probed_bio(pci_info.io_port);
- if (bsh != bt_iop_from_bio(pci_info.io_port)) {
+ if (bt->bsh != bt_iop_from_bio(pci_info.io_port)) {
u_int8_t new_addr;
new_addr = BIO_DISABLED;
@@ -142,30 +147,30 @@ bt_pci_probe (pcici_t config_id, pcidi_t type)
DEFAULT_CMD_TIMEOUT);
}
}
- bt_free(bt);
- return ("Buslogic Multi-Master SCSI Host Adapter");
- break;
+ bt_pci_release_resources(dev);
+ device_set_desc(dev, "Buslogic Multi-Master SCSI Host Adapter");
+ return (0);
}
default:
break;
}
- return (NULL);
+ return (ENXIO);
}
-static void
-bt_pci_attach(pcici_t config_id, int unit)
+static int
+bt_pci_attach(device_t dev)
{
- struct bt_softc *bt;
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
+ struct bt_softc *bt = device_get_softc(dev);
int opri;
+ int error;
- if (btpcideterminebusspace(config_id, &tag, &bsh) != 0)
- return;
-
- if ((bt = bt_alloc(unit, tag, bsh)) == NULL)
- return; /* XXX PCI code should take return status */
+ /* Initialise 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 */
@@ -177,14 +182,10 @@ bt_pci_attach(pcici_t config_id, int unit)
/*nsegments*/BUS_SPACE_UNRESTRICTED,
/*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
/*flags*/0, &bt->parent_dmat) != 0) {
- bt_free(bt);
- return;
+ bt_pci_release_resources(dev);
+ return (ENOMEM);
}
- if ((pci_map_int(config_id, bt_intr, (void *)bt, &cam_imask)) == 0) {
- bt_free(bt);
- return;
- }
/*
* Protect ourself from spurrious interrupts during
* intialization and attach. We should really rely
@@ -195,16 +196,40 @@ bt_pci_attach(pcici_t config_id, int unit)
*/
opri = splcam();
- if (bt_probe(bt) || bt_fetch_adapter_info(bt) || bt_init(bt)) {
- bt_free(bt);
+ if (bt_probe(dev) || bt_fetch_adapter_info(dev) || bt_init(dev)) {
+ bt_pci_release_resources(dev);
splx(opri);
- return; /* XXX PCI code should take return status */
+ return (ENXIO);
}
- bt_attach(bt);
-
+ error = bt_attach(dev);
splx(opri);
- return;
+
+ if (error) {
+ bt_pci_release_resources(dev);
+ return (error);
+ }
+
+ return (0);
}
+static device_method_t bt_pci_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, bt_pci_probe),
+ DEVMETHOD(device_attach, bt_pci_attach),
+
+ { 0, 0 }
+};
+
+static driver_t bt_pci_driver = {
+ "bt",
+ bt_pci_methods,
+ DRIVER_TYPE_CAM,
+ sizeof(struct bt_softc),
+};
+
+static devclass_t bt_devclass;
+
+DRIVER_MODULE(bt, pci, bt_pci_driver, bt_devclass, 0, 0);
+
#endif /* NPCI > 0 */
diff --git a/sys/dev/buslogic/btreg.h b/sys/dev/buslogic/btreg.h
index 02ad301..2452024 100644
--- a/sys/dev/buslogic/btreg.h
+++ b/sys/dev/buslogic/btreg.h
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: btreg.h,v 1.4 1999/03/08 21:36:34 gibbs Exp $
+ * $Id: btreg.h,v 1.5 1999/04/07 23:01:43 gibbs Exp $
*/
#ifndef _BTREG_H_
@@ -595,6 +595,11 @@ struct sg_map_node {
};
struct bt_softc {
+ struct device *dev;
+ struct resource *port;
+ struct resource *irq;
+ struct resource *drq;
+ void *ih;
bus_space_tag_t tag;
bus_space_handle_t bsh;
struct cam_sim *sim;
@@ -663,17 +668,18 @@ extern struct bt_softc *bt_softcs[]; /* XXX Config should handle this */
extern u_long bt_unit;
#define BT_TEMP_UNIT 0xFF /* Unit for probes */
-struct bt_softc* bt_alloc(int unit, bus_space_tag_t tag,
- bus_space_handle_t bsh);
-void bt_free(struct bt_softc *bt);
-int bt_port_probe(struct bt_softc *bt,
+void bt_init_softc(device_t dev,
+ struct resource *port,
+ struct resource *irq,
+ struct resource *drq);
+void bt_free_softc(device_t dev);
+int bt_port_probe(device_t dev,
struct bt_probe_info *info);
-int bt_probe(struct bt_softc *bt);
-int bt_fetch_adapter_info(struct bt_softc *bt);
-int bt_init(struct bt_softc *bt);
-int bt_attach(struct bt_softc *bt);
+int bt_probe(device_t dev);
+int bt_fetch_adapter_info(device_t dev);
+int bt_init(device_t dev);
+int bt_attach(device_t dev);
void bt_intr(void *arg);
-char * bt_name(struct bt_softc *bt);
int bt_check_probed_iop(u_int ioport);
void bt_mark_probed_bio(isa_compat_io_t port);
void bt_mark_probed_iop(u_int ioport);
@@ -689,6 +695,8 @@ int bt_cmd(struct bt_softc *bt, bt_op_t opcode,
u_int8_t *reply_data, u_int reply_len,
u_int cmd_timeout);
+#define bt_name(bt) device_get_nameunit(bt->dev)
+
#define bt_inb(bt, port) \
bus_space_read_1((bt)->tag, (bt)->bsh, port)
OpenPOWER on IntegriCloud