summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/conf/files1
-rw-r--r--sys/conf/files.alpha1
-rw-r--r--sys/conf/files.i3861
-rw-r--r--sys/conf/files.pc981
-rw-r--r--sys/dev/advansys/adv_eisa.c32
-rw-r--r--sys/dev/advansys/adv_isa.c125
-rw-r--r--sys/dev/advansys/adv_pci.c118
-rw-r--r--sys/dev/advansys/advansys.c32
-rw-r--r--sys/dev/advansys/advansys.h6
-rw-r--r--sys/dev/advansys/advlib.c3
-rw-r--r--sys/dev/advansys/advlib.h4
-rw-r--r--sys/dev/advansys/adwlib.c3
-rw-r--r--sys/i386/isa/isa_compat.h14
-rw-r--r--sys/pc98/pc98/isa_compat.h8
14 files changed, 169 insertions, 180 deletions
diff --git a/sys/conf/files b/sys/conf/files
index c0175c2..f4615c1 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -72,7 +72,6 @@ ddb/db_variables.c optional ddb
ddb/db_watch.c optional ddb
ddb/db_write_cmd.c optional ddb
dev/advansys/adv_eisa.c optional adv eisa
-dev/advansys/adv_isa.c optional adv isa
dev/advansys/adv_pci.c optional adv pci
dev/advansys/advansys.c optional adv
dev/advansys/advlib.c optional adv
diff --git a/sys/conf/files.alpha b/sys/conf/files.alpha
index 785a7f8..e61b7fc 100644
--- a/sys/conf/files.alpha
+++ b/sys/conf/files.alpha
@@ -133,6 +133,7 @@ alpha/pci/pci_eb64plus_intr.s optional dec_eb64plus
alpha/pci/pcibus.c optional pci
alpha/pci/tsunami.c optional dec_st6600
alpha/pci/tsunami_pci.c optional dec_st6600
+dev/advansys/adv_isa.c optional adv isa
dev/aic/aic_isa.c optional aic isa
dev/ata/ata-all.c optional ata
dev/ata/ata-disk.c optional atadisk
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index 1a67dce..c31bad1 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -60,6 +60,7 @@ trlld.o optional oltr \
contrib/dev/oltr/trlldbm.c optional oltr
contrib/dev/oltr/trlldhm.c optional oltr
contrib/dev/oltr/trlldmac.c optional oltr
+dev/advansys/adv_isa.c optional adv isa
dev/aic/aic_isa.c optional aic isa
dev/ata/ata-all.c optional ata
dev/ata/ata-disk.c optional atadisk
diff --git a/sys/conf/files.pc98 b/sys/conf/files.pc98
index 7156ba1..650a5b4 100644
--- a/sys/conf/files.pc98
+++ b/sys/conf/files.pc98
@@ -57,6 +57,7 @@ trlld.o optional oltr \
contrib/dev/oltr/trlldbm.c optional oltr
contrib/dev/oltr/trlldhm.c optional oltr
contrib/dev/oltr/trlldmac.c optional oltr
+#dev/advansys/adv_isa.c optional adv isa
dev/aic/aic_cbus.c optional aic isa
dev/ata/ata-all.c optional ata
dev/ata/ata-dma.c optional ata
diff --git a/sys/dev/advansys/adv_eisa.c b/sys/dev/advansys/adv_eisa.c
index 1e00e18..e769ca4 100644
--- a/sys/dev/advansys/adv_eisa.c
+++ b/sys/dev/advansys/adv_eisa.c
@@ -78,10 +78,8 @@ static bus_dma_tag_t overrun_dmat;
static bus_dmamap_t overrun_dmamap;
static bus_addr_t overrun_physbase;
-static const char *adveisamatch(eisa_id_t type);
-
static const char*
-adveisamatch(eisa_id_t type)
+adv_eisa_match(eisa_id_t type)
{
switch (type & ~0xF) {
case EISA_DEVICE_ID_ADVANSYS_740:
@@ -97,19 +95,18 @@ adveisamatch(eisa_id_t type)
}
static int
-adveisaprobe(device_t dev)
+adv_eisa_probe(device_t dev)
{
const char *desc;
u_int32_t iobase;
u_int8_t irq;
- desc = adveisamatch(eisa_get_id(dev));
+ desc = adv_eisa_match(eisa_get_id(dev));
if (!desc)
return (ENXIO);
device_set_desc(dev, desc);
- iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE)
- + ADV_EISA_SLOT_OFFSET;
+ iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + ADV_EISA_SLOT_OFFSET;
eisa_add_iospace(dev, iobase, ADV_EISA_IOSIZE, RESVADDR_NONE);
irq = inb(iobase + ADV_EISA_IRQ_BURST_LEN_REG);
@@ -133,13 +130,12 @@ adveisaprobe(device_t dev)
}
static int
-adveisaattach(device_t dev)
+adv_eisa_attach(device_t dev)
{
struct adv_softc *adv;
struct adv_softc *adv_b;
struct resource *io;
struct resource *irq;
- int unit = device_get_unit(dev);
int rid, error;
void *ih;
@@ -165,7 +161,7 @@ adveisaattach(device_t dev)
switch (eisa_get_id(dev) & ~0xF) {
case EISA_DEVICE_ID_ADVANSYS_750:
- adv_b = adv_alloc(unit, rman_get_bustag(io),
+ adv_b = adv_alloc(dev, rman_get_bustag(io),
rman_get_bushandle(io) + ADV_EISA_OFFSET_CHAN2);
if (adv_b == NULL)
goto bad;
@@ -197,7 +193,7 @@ adveisaattach(device_t dev)
/* FALLTHROUGH */
case EISA_DEVICE_ID_ADVANSYS_740:
- adv = adv_alloc(unit, rman_get_bustag(io),
+ adv = adv_alloc(dev, rman_get_bustag(io),
rman_get_bushandle(io) + ADV_EISA_OFFSET_CHAN1);
if (adv == NULL) {
if (adv_b != NULL)
@@ -330,18 +326,14 @@ adveisaattach(device_t dev)
static device_method_t adv_eisa_methods[] = {
/* Device interface */
- DEVMETHOD(device_probe, adveisaprobe),
- DEVMETHOD(device_attach, adveisaattach),
-
+ DEVMETHOD(device_probe, adv_eisa_probe),
+ DEVMETHOD(device_attach, adv_eisa_attach),
{ 0, 0 }
};
static driver_t adv_eisa_driver = {
- "adv",
- adv_eisa_methods,
- 1, /* unused */
+ "adv", adv_eisa_methods, sizeof(struct adv_softc)
};
-static devclass_t adv_devclass;
-
-DRIVER_MODULE(adv, eisa, adv_eisa_driver, adv_devclass, 0, 0);
+static devclass_t adv_eisa_devclass;
+DRIVER_MODULE(adv, eisa, adv_eisa_driver, adv_eisa_devclass, 0, 0);
diff --git a/sys/dev/advansys/adv_isa.c b/sys/dev/advansys/adv_isa.c
index 790933d..52cc387 100644
--- a/sys/dev/advansys/adv_isa.c
+++ b/sys/dev/advansys/adv_isa.c
@@ -49,11 +49,15 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/kernel.h>
#include <machine/bus_pio.h>
#include <machine/bus.h>
+#include <machine/resource.h>
+#include <sys/bus.h>
+#include <sys/rman.h>
-#include <i386/isa/isa_device.h>
+#include <isa/isavar.h>
#include <dev/advansys/advansys.h>
@@ -91,26 +95,21 @@ static u_int16_t adv_isa_ioports[] =
#define MAX_ISA_IOPORT_INDEX (sizeof(adv_isa_ioports)/sizeof(u_int16_t) - 1)
-static int advisaprobe(struct isa_device *id);
-static int advisaattach(struct isa_device *id);
+static int adv_isa_probe(device_t dev);
+static int adv_isa_attach(device_t dev);
static void adv_set_isapnp_wait_for_key(void);
static int adv_get_isa_dma_channel(struct adv_softc *adv);
static int adv_set_isa_dma_settings(struct adv_softc *adv);
-static void adv_isa_intr(void *unit);
-
-struct isa_driver advdriver =
-{
- advisaprobe,
- advisaattach,
- "adv"
-};
-
static int
-advisaprobe(struct isa_device *id)
+adv_isa_probe(device_t dev)
{
int port_index;
int max_port_index;
+ u_long iobase, irq;
+ int rid = 0;
+ void *ih;
+ struct resource *iores, *irqres;
/*
* Default to scanning all possible device locations.
@@ -118,19 +117,19 @@ advisaprobe(struct isa_device *id)
port_index = 0;
max_port_index = MAX_ISA_IOPORT_INDEX;
- if (id->id_iobase > 0) {
+ if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) == 0) {
for (;port_index <= max_port_index; port_index++)
- if (id->id_iobase <= adv_isa_ioports[port_index])
+ if (iobase <= adv_isa_ioports[port_index])
break;
if ((port_index > max_port_index)
- || (id->id_iobase != adv_isa_ioports[port_index])) {
- printf("adv%d: Invalid baseport of 0x%x specified. "
+ || (iobase != adv_isa_ioports[port_index])) {
+ printf("adv%d: Invalid baseport of 0x%lx specified. "
"Neerest valid baseport is 0x%x. Failing "
- "probe.\n", id->id_unit, id->id_iobase,
+ "probe.\n", device_get_unit(dev), iobase,
(port_index <= max_port_index) ?
adv_isa_ioports[port_index] :
adv_isa_ioports[max_port_index]);
- return 0;
+ return ENXIO;
}
max_port_index = port_index;
}
@@ -147,24 +146,27 @@ advisaprobe(struct isa_device *id)
if (port_addr == 0)
/* Already been attached */
continue;
- id->id_iobase = port_addr;
- if (haveseen_iobase(id, 1)) /* XXX real portsize? */
+
+ if (bus_set_resource(dev, SYS_RES_IOPORT, 0, port_addr, 1))
+ continue;
+
+ /* XXX what is the real portsize? */
+ iores = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1,
+ RF_ACTIVE);
+ if (iores == NULL)
continue;
- if (adv_find_signature(I386_BUS_SPACE_IO, port_addr)) {
+ if (adv_find_signature(rman_get_bustag(iores),
+ rman_get_bushandle(iores))) {
/*
* Got one. Now allocate our softc
* and see if we can initialize the card.
*/
struct adv_softc *adv;
- adv = adv_alloc(id->id_unit, I386_BUS_SPACE_IO,
- port_addr);
+ adv = adv_alloc(dev, rman_get_bustag(iores),
+ rman_get_bushandle(iores));
if (adv == NULL)
- return (0);
-
- adv_unit++;
-
- id->id_iobase = adv->bsh;
+ return ENXIO;
/*
* Stop the chip.
@@ -182,7 +184,7 @@ advisaprobe(struct isa_device *id)
maxsegsz = ADV_VL_MAX_DMA_COUNT;
maxsize = BUS_SPACE_MAXSIZE_32BIT;
lowaddr = ADV_VL_MAX_DMA_ADDR;
- id->id_drq = -1;
+ bus_delete_resource(dev, SYS_RES_DRQ, 0);
} else if ((adv->chip_version >= ADV_CHIP_MIN_VER_ISA)
&& (adv->chip_version <= ADV_CHIP_MAX_VER_ISA)) {
if (adv->chip_version >= ADV_CHIP_MIN_VER_ISA_PNP) {
@@ -198,7 +200,8 @@ advisaprobe(struct isa_device *id)
adv->isa_dma_speed = ADV_DEF_ISA_DMA_SPEED;
adv->isa_dma_channel =
adv_get_isa_dma_channel(adv);
- id->id_drq = adv->isa_dma_channel;
+ bus_set_resource(dev, SYS_RES_DRQ, 0,
+ adv->isa_dma_channel, 1);
} else {
panic("advisaprobe: Unknown card revision\n");
}
@@ -226,7 +229,7 @@ advisaprobe(struct isa_device *id)
printf("%s: Could not allocate DMA tag - error %d\n",
adv_name(adv), error);
adv_free(adv);
- return (0);
+ return ENXIO;
}
adv->init_level++;
@@ -246,7 +249,7 @@ advisaprobe(struct isa_device *id)
/*flags*/0,
&overrun_dmat) != 0) {
adv_free(adv);
- return (0);
+ return ENXIO;
}
if (bus_dmamem_alloc(overrun_dmat,
(void **)&overrun_buf,
@@ -254,7 +257,7 @@ advisaprobe(struct isa_device *id)
&overrun_dmamap) != 0) {
bus_dma_tag_destroy(overrun_dmat);
adv_free(adv);
- return (0);
+ return ENXIO;
}
/* And permanently map it in */
bus_dmamap_load(overrun_dmat, overrun_dmamap,
@@ -267,7 +270,7 @@ advisaprobe(struct isa_device *id)
if (adv_init(adv) != 0) {
adv_free(adv);
- return (0);
+ return ENXIO;
}
switch (adv->type) {
@@ -293,28 +296,35 @@ advisaprobe(struct isa_device *id)
}
/* Determine our IRQ */
- if (id->id_irq == 0 /* irq ? */)
- id->id_irq = 1 << adv_get_chip_irq(adv);
+ if (bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL))
+ bus_set_resource(dev, SYS_RES_IRQ, 0,
+ adv_get_chip_irq(adv), 1);
else
- adv_set_chip_irq(adv, ffs(id->id_irq) - 1);
+ adv_set_chip_irq(adv, irq);
+
+ irqres = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
+ 0, ~0, 1, RF_ACTIVE);
+ if (irqres == NULL ||
+ bus_setup_intr(dev, irqres, INTR_TYPE_CAM,
+ adv_intr, adv, &ih)) {
+ adv_free(adv);
+ return ENXIO;
+ }
- id->id_intr = adv_isa_intr;
-
/* Mark as probed */
adv_isa_ioports[port_index] = 0;
- return 1; /* XXX what is the real portsize? */
+ return 0;
}
}
- return 0;
+ return ENXIO;
}
static int
-advisaattach(struct isa_device *id)
+adv_isa_attach(device_t dev)
{
- struct adv_softc *adv;
+ struct adv_softc *adv = device_get_softc(dev);
- adv = advsoftcs[id->id_unit];
return (adv_attach(adv));
}
@@ -365,17 +375,18 @@ adv_set_isapnp_wait_for_key(void)
outb(ADV_ISA_PNP_PORT_WRITE, 0x02);
isapnp_wait_set++;
}
- return;
}
-/*
- * Handle an ISA interrupt.
- * XXX should go away as soon as ISA interrupt handlers
- * take a (void *) arg.
- */
-static void
-adv_isa_intr(void *unit)
-{
- struct adv_softc *arg = advsoftcs[(int)unit];
- adv_intr((void *)arg);
-}
+static device_method_t adv_isa_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, adv_isa_probe),
+ DEVMETHOD(device_attach, adv_isa_attach),
+ { 0, 0 }
+};
+
+static driver_t adv_isa_driver = {
+ "adv", adv_isa_methods, sizeof(struct adv_softc)
+};
+
+static devclass_t adv_isa_devclass;
+DRIVER_MODULE(adv, isa, adv_isa_driver, adv_isa_devclass, 0, 0);
diff --git a/sys/dev/advansys/adv_pci.c b/sys/dev/advansys/adv_pci.c
index 1dbd340..1a52f72 100644
--- a/sys/dev/advansys/adv_pci.c
+++ b/sys/dev/advansys/adv_pci.c
@@ -66,6 +66,9 @@
#include <machine/bus_pio.h>
#include <machine/bus.h>
+#include <machine/resource.h>
+#include <sys/bus.h>
+#include <sys/rman.h>
#include <pci/pcireg.h>
#include <pci/pcivar.h>
@@ -84,8 +87,8 @@
#define ADV_PCI_MAX_DMA_ADDR (0xFFFFFFFFL)
#define ADV_PCI_MAX_DMA_COUNT (0xFFFFFFFFL)
-static const char* advpciprobe(pcici_t tag, pcidi_t type);
-static void advpciattach(pcici_t config_id, int unit);
+static int adv_pci_probe(device_t);
+static int adv_pci_attach(device_t);
/*
* The overrun buffer shared amongst all PCI adapters.
@@ -95,55 +98,54 @@ static bus_dma_tag_t overrun_dmat;
static bus_dmamap_t overrun_dmamap;
static bus_addr_t overrun_physbase;
-static struct pci_device adv_pci_driver = {
- "adv",
- advpciprobe,
- advpciattach,
- &adv_unit,
- NULL
-};
-
-COMPAT_PCI_DRIVER (adv_pci, adv_pci_driver);
-
-static const char*
-advpciprobe(pcici_t tag, pcidi_t type)
+static int
+adv_pci_probe(device_t dev)
{
- int rev;
+ int rev = pci_get_revid(dev);
- rev = pci_conf_read(tag, PCI_CLASS_REG) & PCI_REVISION_MASK;
- switch (type) {
+ switch (pci_get_devid(dev)) {
case PCI_DEVICE_ID_ADVANSYS_1200A:
- return ("AdvanSys ASC1200A SCSI controller");
+ device_set_desc(dev, "AdvanSys ASC1200A SCSI controller");
+ return 0;
case PCI_DEVICE_ID_ADVANSYS_1200B:
- return ("AdvanSys ASC1200B SCSI controller");
+ device_set_desc(dev, "AdvanSys ASC1200B SCSI controller");
+ return 0;
case PCI_DEVICE_ID_ADVANSYS_3000:
- if (rev == PCI_DEVICE_REV_ADVANSYS_3150)
- return ("AdvanSys ASC3150 SCSI controller");
- else if (rev == PCI_DEVICE_REV_ADVANSYS_3050)
- return ("AdvanSys ASC3030/50 SCSI controller");
- else if (rev >= PCI_DEVICE_REV_ADVANSYS_3150)
- return ("Unknown AdvanSys controller");
+ if (rev == PCI_DEVICE_REV_ADVANSYS_3150) {
+ device_set_desc(dev,
+ "AdvanSys ASC3150 SCSI controller");
+ return 0;
+ } else if (rev == PCI_DEVICE_REV_ADVANSYS_3050) {
+ device_set_desc(dev,
+ "AdvanSys ASC3030/50 SCSI controller");
+ return 0;
+ } else if (rev >= PCI_DEVICE_REV_ADVANSYS_3150) {
+ device_set_desc(dev, "Unknown AdvanSys controller");
+ return 0;
+ }
break;
default:
break;
}
- return (NULL);
+ return ENXIO;
}
-static void
-advpciattach(pcici_t config_id, int unit)
+static int
+adv_pci_attach(device_t dev)
{
- u_int16_t io_port;
struct adv_softc *adv;
u_int32_t id;
u_int32_t command;
int error;
-
+ int rid = 0;
+ void *ih;
+ struct resource *iores, *irqres;
+
/*
* Determine the chip version.
*/
- id = pci_cfgread(config_id, PCI_ID_REG, /*bytes*/4);
- command = pci_cfgread(config_id, PCIR_COMMAND, /*bytes*/1);
+ id = pci_read_config(dev, PCI_ID_REG, /*bytes*/4);
+ command = pci_read_config(dev, PCIR_COMMAND, /*bytes*/1);
/*
* These cards do not allow memory mapped accesses, so we must
@@ -153,7 +155,7 @@ advpciattach(pcici_t config_id, int unit)
if ((command & (PCIM_CMD_PORTEN|PCIM_CMD_BUSMASTEREN))
!= (PCIM_CMD_PORTEN|PCIM_CMD_BUSMASTEREN)) {
command |= PCIM_CMD_PORTEN|PCIM_CMD_BUSMASTEREN;
- pci_cfgwrite(config_id, PCIR_COMMAND, command, /*bytes*/1);
+ pci_write_config(dev, PCIR_COMMAND, command, /*bytes*/1);
}
/*
@@ -161,19 +163,21 @@ advpciattach(pcici_t config_id, int unit)
*/
if (id == PCI_DEVICE_ID_ADVANSYS_1200A
|| id == PCI_DEVICE_ID_ADVANSYS_1200B) {
- pci_cfgwrite(config_id, PCIR_LATTIMER, /*value*/0, /*bytes*/1);
+ pci_write_config(dev, PCIR_LATTIMER, /*value*/0, /*bytes*/1);
}
+ iores = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1,
+ RF_ACTIVE);
+ if (iores == NULL)
+ return ENXIO;
- if (pci_map_port(config_id, PCI_BASEADR0, &io_port) == 0)
- return;
-
- if (adv_find_signature(I386_BUS_SPACE_IO, io_port) == 0)
- return;
+ if (adv_find_signature(rman_get_bustag(iores),
+ rman_get_bushandle(iores)) == 0)
+ return ENXIO;
- adv = adv_alloc(unit, I386_BUS_SPACE_IO, io_port);
+ adv = adv_alloc(dev, rman_get_bustag(iores), rman_get_bushandle(iores));
if (adv == NULL)
- return;
+ return ENXIO;
/* Allocate a dmatag for our transfer DMA maps */
/* XXX Should be a child of the PCI bus dma tag */
@@ -192,7 +196,7 @@ advpciattach(pcici_t config_id, int unit)
printf("%s: Could not allocate DMA tag - error %d\n",
adv_name(adv), error);
adv_free(adv);
- return;
+ return ENXIO;
}
adv->init_level++;
@@ -208,7 +212,7 @@ advpciattach(pcici_t config_id, int unit)
&overrun_dmat) != 0) {
bus_dma_tag_destroy(adv->parent_dmat);
adv_free(adv);
- return;
+ return ENXIO;
}
if (bus_dmamem_alloc(overrun_dmat,
(void **)&overrun_buf,
@@ -217,7 +221,7 @@ advpciattach(pcici_t config_id, int unit)
bus_dma_tag_destroy(overrun_dmat);
bus_dma_tag_destroy(adv->parent_dmat);
adv_free(adv);
- return;
+ return ENXIO;
}
/* And permanently map it in */
bus_dmamap_load(overrun_dmat, overrun_dmamap,
@@ -254,7 +258,7 @@ advpciattach(pcici_t config_id, int unit)
if (adv_init(adv) != 0) {
adv_free(adv);
- return;
+ return ENXIO;
}
adv->max_dma_count = ADV_PCI_MAX_DMA_COUNT;
@@ -277,10 +281,28 @@ advpciattach(pcici_t config_id, int unit)
adv->fix_asyn_xfer = ~0;
}
- if ((pci_map_int(config_id, adv_intr, (void *)adv, &cam_imask)) == 0) {
+ irqres = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
+ RF_SHAREABLE | RF_ACTIVE);
+ if (irqres == NULL ||
+ bus_setup_intr(dev, irqres, INTR_TYPE_CAM, adv_intr, adv, &ih)) {
adv_free(adv);
- return;
+ return ENXIO;
}
-
+
adv_attach(adv);
+ return 0;
}
+
+static device_method_t adv_pci_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, adv_pci_probe),
+ DEVMETHOD(device_attach, adv_pci_attach),
+ { 0, 0 }
+};
+
+static driver_t adv_pci_driver = {
+ "adv", adv_pci_methods, sizeof(struct adv_softc)
+};
+
+static devclass_t adv_pci_devclass;
+DRIVER_MODULE(adv, pci, adv_pci_driver, adv_pci_devclass, 0, 0);
diff --git a/sys/dev/advansys/advansys.c b/sys/dev/advansys/advansys.c
index 7541636..15cdc59 100644
--- a/sys/dev/advansys/advansys.c
+++ b/sys/dev/advansys/advansys.c
@@ -56,6 +56,9 @@
#include <machine/bus_pio.h>
#include <machine/bus.h>
#include <machine/clock.h>
+#include <machine/resource.h>
+#include <sys/bus.h>
+#include <sys/rman.h>
#include <cam/cam.h>
#include <cam/cam_ccb.h>
@@ -73,8 +76,6 @@
#include <dev/advansys/advansys.h>
-u_long adv_unit;
-
static void adv_action(struct cam_sim *sim, union ccb *ccb);
static void adv_execute_ccb(void *arg, bus_dma_segment_t *dm_segs,
int nsegments, int error);
@@ -92,8 +93,6 @@ static __inline void adv_set_state(struct adv_softc *adv, adv_state state);
static __inline void adv_clear_state(struct adv_softc *adv, union ccb* ccb);
static void adv_clear_state_really(struct adv_softc *adv, union ccb* ccb);
-struct adv_softc *advsoftcs[NADV]; /* XXX Config should handle this */
-
static __inline struct adv_ccb_info *
adv_get_ccb_info(struct adv_softc *adv)
{
@@ -729,33 +728,17 @@ adv_timeout(void *arg)
}
struct adv_softc *
-adv_alloc(int unit, bus_space_tag_t tag, bus_space_handle_t bsh)
+adv_alloc(device_t dev, bus_space_tag_t tag, bus_space_handle_t bsh)
{
- struct adv_softc *adv;
-
- if (unit >= NADV) {
- printf("adv: unit number (%d) too high\n", unit);
- return NULL;
- }
+ struct adv_softc *adv = device_get_softc(dev);
/*
* Allocate a storage area for us
*/
- if (advsoftcs[unit]) {
- printf("adv%d: memory already allocated\n", unit);
- return NULL;
- }
-
- adv = malloc(sizeof(struct adv_softc), M_DEVBUF, M_NOWAIT);
- if (!adv) {
- printf("adv%d: cannot malloc!\n", unit);
- return NULL;
- }
- bzero(adv, sizeof(struct adv_softc));
LIST_INIT(&adv->pending_ccbs);
SLIST_INIT(&adv->free_ccb_infos);
- advsoftcs[unit] = adv;
- adv->unit = unit;
+ adv->dev = dev;
+ adv->unit = device_get_unit(dev);
adv->tag = tag;
adv->bsh = bsh;
@@ -791,7 +774,6 @@ adv_free(struct adv_softc *adv)
case 0:
break;
}
- free(adv, M_DEVBUF);
}
int
diff --git a/sys/dev/advansys/advansys.h b/sys/dev/advansys/advansys.h
index 9108e2d..ab4e550 100644
--- a/sys/dev/advansys/advansys.h
+++ b/sys/dev/advansys/advansys.h
@@ -36,10 +36,9 @@
#ifndef _ADVANSYS_H_
#define _ADVANSYS_H_
-#include "adv.h"
#include <dev/advansys/advlib.h>
-struct adv_softc * adv_alloc(int unit, bus_space_tag_t tag,
+struct adv_softc * adv_alloc(device_t dev, bus_space_tag_t tag,
bus_space_handle_t bsh);
char * adv_name(struct adv_softc *adv);
void adv_map(void *arg, bus_dma_segment_t *segs,
@@ -53,7 +52,4 @@ void adv_done(struct adv_softc *adv, union ccb* ccb,
u_int scsi_stat, u_int q_no);
timeout_t adv_timeout;
-extern struct adv_softc *advsoftcs[NADV]; /* XXX Config should handle this */
-
-extern u_long adv_unit;
#endif /* _ADVANSYS_H_ */
diff --git a/sys/dev/advansys/advlib.c b/sys/dev/advansys/advlib.c
index 9bbf33d..dd0f4ccd 100644
--- a/sys/dev/advansys/advlib.c
+++ b/sys/dev/advansys/advlib.c
@@ -50,6 +50,9 @@
#include <machine/bus_pio.h>
#include <machine/bus.h>
#include <machine/clock.h>
+#include <machine/resource.h>
+#include <sys/bus.h>
+#include <sys/rman.h>
#include <cam/cam.h>
#include <cam/cam_ccb.h>
diff --git a/sys/dev/advansys/advlib.h b/sys/dev/advansys/advlib.h
index ea5a792..ba9703d 100644
--- a/sys/dev/advansys/advlib.h
+++ b/sys/dev/advansys/advlib.h
@@ -492,8 +492,8 @@ struct adv_target_transinfo {
struct adv_transinfo user;
};
-struct adv_softc
-{
+struct adv_softc {
+ device_t dev;
bus_space_tag_t tag;
bus_space_handle_t bsh;
struct cam_sim *sim;
diff --git a/sys/dev/advansys/adwlib.c b/sys/dev/advansys/adwlib.c
index b829dec..9abf933 100644
--- a/sys/dev/advansys/adwlib.c
+++ b/sys/dev/advansys/adwlib.c
@@ -54,6 +54,9 @@
#include <machine/clock.h>
#include <cam/cam.h>
+#include <cam/cam_ccb.h>
+#include <cam/cam_sim.h>
+#include <cam/cam_xpt_sim.h>
#include <cam/scsi/scsi_all.h>
#include <dev/advansys/adwlib.h>
diff --git a/sys/i386/isa/isa_compat.h b/sys/i386/isa/isa_compat.h
index 24b6771..1404535 100644
--- a/sys/i386/isa/isa_compat.h
+++ b/sys/i386/isa/isa_compat.h
@@ -27,7 +27,6 @@
*/
#include "vt.h"
-#include "adv.h"
#include "ar.h"
#include "cx.h"
#include "el.h"
@@ -79,7 +78,6 @@ struct old_isa_driver {
};
extern struct isa_driver vtdriver;
-extern struct isa_driver advdriver;
extern struct isa_driver ardriver;
extern struct isa_driver cxdriver;
extern struct isa_driver eldriver;
@@ -228,18 +226,6 @@ static struct old_isa_driver old_drivers[] = {
{ INTR_TYPE_NET, &tinadriver },
#endif
-/* CAM */
-
-#if NADV > 0
- { INTR_TYPE_CAM, &advdriver },
-#endif
-
-#ifdef PC98
-#if NBS > 0
- { INTR_TYPE_CAM, &bsdriver },
-#endif
-#endif
-
/* MISC */
#if NPAS > 0
diff --git a/sys/pc98/pc98/isa_compat.h b/sys/pc98/pc98/isa_compat.h
index fb8116c..4c4656c 100644
--- a/sys/pc98/pc98/isa_compat.h
+++ b/sys/pc98/pc98/isa_compat.h
@@ -27,7 +27,6 @@
*/
#include "vt.h"
-#include "adv.h"
#include "wdc.h"
#include "ar.h"
#include "cx.h"
@@ -85,7 +84,6 @@ struct old_isa_driver {
};
extern struct isa_driver vtdriver;
-extern struct isa_driver advdriver;
extern struct isa_driver wdcdriver;
extern struct isa_driver ardriver;
extern struct isa_driver cxdriver;
@@ -248,12 +246,6 @@ static struct old_isa_driver old_drivers[] = {
/* CAM */
-#ifndef PC98
-#if NADV > 0
- { INTR_TYPE_CAM, &advdriver },
-#endif
-#endif
-
#ifdef PC98
#if NBS > 0
{ INTR_TYPE_CAM, &bsdriver },
OpenPOWER on IntegriCloud