Fix plug and play support:

o Cut out the probed stuff.  We no longer need it since newbus implicitly
  checks for this (likely bt can be changed as well in this way).
o Add preliminary support for unload.  Untested because aha doesn't yet
  support identify and there are some interactions with PnP that I've
  not yet worked out.

With this I can boot the AHA-1542CP FW F.0.  All the aha resources
appear to be picked up via pnp now.
This commit is contained in:
imp 2000-01-24 07:08:40 +00:00
parent 385dc4c1f7
commit 739bfd2efc
4 changed files with 97 additions and 119 deletions

View File

@ -182,12 +182,12 @@ u_long aha_unit = 0;
*/
static struct aha_isa_port aha_isa_ports[] =
{
{ 0x130, 0, 4 },
{ 0x134, 0, 5 },
{ 0x230, 0, 2 },
{ 0x234, 0, 3 },
{ 0x330, 0, 0 },
{ 0x334, 0, 1 }
{ 0x130, 4 },
{ 0x134, 5 },
{ 0x230, 2 },
{ 0x234, 3 },
{ 0x330, 0 },
{ 0x334, 1 }
};
/*
@ -678,43 +678,6 @@ aha_name(struct aha_softc *aha)
return (name);
}
int
aha_check_probed_iop(u_int ioport)
{
u_int i;
for (i=0; i < AHA_NUM_ISAPORTS; i++) {
if (aha_isa_ports[i].addr == ioport) {
if (aha_isa_ports[i].probed != 0)
return (1);
else {
return (0);
}
}
}
return (1);
}
void
aha_mark_probed_bio(isa_compat_io_t port)
{
if (port < BIO_DISABLED)
aha_mark_probed_iop(aha_board_ports[port]);
}
void
aha_mark_probed_iop(u_int ioport)
{
u_int i;
for (i = 0; i < AHA_NUM_ISAPORTS; i++) {
if (ioport == aha_isa_ports[i].addr) {
aha_isa_ports[i].probed = 1;
break;
}
}
}
void
aha_find_probe_range(int ioport, int *port_index, int *max_port_index)
{
@ -1998,3 +1961,13 @@ ahatimeout(void *arg)
splx(s);
}
int
aha_detach(struct aha_softc *aha)
{
xpt_async(AC_LOST_DEVICE, aha->path, NULL);
xpt_free_path(aha->path);
xpt_bus_deregister(cam_sim_path(aha->sim));
cam_sim_free(aha->sim, /*free_devq*/TRUE);
return (0);
}

View File

@ -105,12 +105,6 @@ aha_isa_probe(device_t dev)
ioport = aha_iop_from_bio(port_index);
/*
* Ensure this port has not already been claimed already
* by another adapter.
*/
if (aha_check_probed_iop(ioport) != 0)
continue;
error = bus_set_resource(dev, SYS_RES_IOPORT, 0,
ioport, AHA_NREGS);
if (error)
@ -132,9 +126,6 @@ aha_isa_probe(device_t dev)
break;
}
/* We're going to attempt to probe it now, so mark it probed */
aha_mark_probed_bio(port_index);
/* See if there is really a card present */
if (aha_probe(aha) || aha_fetch_adapter_info(aha)) {
aha_free(aha);
@ -208,48 +199,42 @@ aha_isa_attach(device_t dev)
bus_dma_filter_t *filter;
void *filter_arg;
bus_addr_t lowaddr;
struct resource *port_res;
int port_rid;
struct resource *irq_res;
int irq_rid;
struct resource *drq_res;
int drq_rid;
void *ih;
int error;
port_rid = 0;
port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &port_rid,
aha = *sc;
aha->portrid = 0;
aha->port = bus_alloc_resource(dev, SYS_RES_IOPORT, &aha->portrid,
0, ~0, AHA_NREGS, RF_ACTIVE);
if (!port_res) {
if (!aha->port) {
device_printf(dev, "Unable to allocate I/O ports\n");
return ENOMEM;
}
irq_rid = 0;
irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &irq_rid, 0, ~0, 1,
aha->irqrid = 0;
aha->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &aha->irqrid, 0, ~0, 1,
RF_ACTIVE);
if (!irq_res) {
if (!aha->irq) {
device_printf(dev, "Unable to allocate excluse use of irq\n");
bus_release_resource(dev, SYS_RES_IOPORT, port_rid, port_res);
bus_release_resource(dev, SYS_RES_IOPORT, aha->portrid, aha->port);
return ENOMEM;
}
drq_rid = 0;
drq_res = bus_alloc_resource(dev, SYS_RES_DRQ, &drq_rid, 0, ~0, 1,
aha->drqrid = 0;
aha->drq = bus_alloc_resource(dev, SYS_RES_DRQ, &aha->drqrid, 0, ~0, 1,
RF_ACTIVE);
if (!drq_res) {
if (!aha->drq) {
device_printf(dev, "Unable to allocate drq\n");
bus_release_resource(dev, SYS_RES_IOPORT, port_rid, port_res);
bus_release_resource(dev, SYS_RES_IRQ, irq_rid, irq_res);
bus_release_resource(dev, SYS_RES_IOPORT, aha->portrid, aha->port);
bus_release_resource(dev, SYS_RES_IRQ, aha->irqrid, aha->irq);
return ENOMEM;
}
aha = *sc;
#if 0 /* is the drq ever unset? */
if (dev->id_drq != -1)
isa_dmacascade(dev->id_drq);
#endif
isa_dmacascade(rman_get_start(drq_res));
isa_dmacascade(rman_get_start(aha->drq));
/* Allocate our parent dmatag */
filter = NULL;
@ -264,18 +249,18 @@ aha_isa_attach(device_t dev)
/*maxsegsz*/BUS_SPACE_MAXSIZE_24BIT,
/*flags*/0, &aha->parent_dmat) != 0) {
aha_free(aha);
bus_release_resource(dev, SYS_RES_IOPORT, port_rid, port_res);
bus_release_resource(dev, SYS_RES_IRQ, irq_rid, irq_res);
bus_release_resource(dev, SYS_RES_DRQ, drq_rid, drq_res);
bus_release_resource(dev, SYS_RES_IOPORT, aha->portrid, aha->port);
bus_release_resource(dev, SYS_RES_IRQ, aha->irqrid, aha->irq);
bus_release_resource(dev, SYS_RES_DRQ, aha->drqrid, aha->drq);
return (ENOMEM);
}
if (aha_init(aha)) {
device_printf(dev, "init failed\n");
aha_free(aha);
bus_release_resource(dev, SYS_RES_IOPORT, port_rid, port_res);
bus_release_resource(dev, SYS_RES_IRQ, irq_rid, irq_res);
bus_release_resource(dev, SYS_RES_DRQ, drq_rid, drq_res);
bus_release_resource(dev, SYS_RES_IOPORT, aha->portrid, aha->port);
bus_release_resource(dev, SYS_RES_IRQ, aha->irqrid, aha->irq);
bus_release_resource(dev, SYS_RES_DRQ, aha->drqrid, aha->drq);
return (ENOMEM);
}
@ -283,30 +268,62 @@ aha_isa_attach(device_t dev)
if (error) {
device_printf(dev, "attach failed\n");
aha_free(aha);
bus_release_resource(dev, SYS_RES_IOPORT, port_rid, port_res);
bus_release_resource(dev, SYS_RES_IRQ, irq_rid, irq_res);
bus_release_resource(dev, SYS_RES_DRQ, drq_rid, drq_res);
bus_release_resource(dev, SYS_RES_IOPORT, aha->portrid, aha->port);
bus_release_resource(dev, SYS_RES_IRQ, aha->irqrid, aha->irq);
bus_release_resource(dev, SYS_RES_DRQ, aha->drqrid, aha->drq);
return (error);
}
error = bus_setup_intr(dev, irq_res, INTR_TYPE_CAM, aha_intr, aha,
error = bus_setup_intr(dev, aha->irq, INTR_TYPE_CAM, aha_intr, aha,
&ih);
if (error) {
device_printf(dev, "Unable to register interrupt handler\n");
aha_free(aha);
bus_release_resource(dev, SYS_RES_IOPORT, port_rid, port_res);
bus_release_resource(dev, SYS_RES_IRQ, irq_rid, irq_res);
bus_release_resource(dev, SYS_RES_DRQ, drq_rid, drq_res);
bus_release_resource(dev, SYS_RES_IOPORT, aha->portrid, aha->port);
bus_release_resource(dev, SYS_RES_IRQ, aha->irqrid, aha->irq);
bus_release_resource(dev, SYS_RES_DRQ, aha->drqrid, aha->drq);
return (error);
}
return (0);
}
static int
aha_isa_detach(device_t dev)
{
struct aha_softc *aha = *(struct aha_softc **) device_get_softc(dev);
int error;
error = bus_teardown_intr(dev, aha->irq, aha->ih);
if (error) {
device_printf(dev, "failed to unregister interrupt handler\n");
}
bus_release_resource(dev, SYS_RES_IOPORT, aha->portrid, aha->port);
bus_release_resource(dev, SYS_RES_IRQ, aha->irqrid, aha->irq);
bus_release_resource(dev, SYS_RES_DRQ, aha->drqrid, aha->drq);
error = aha_detach(aha);
if (error) {
device_printf(dev, "detach failed\n");
return (error);
}
aha_free(aha);
return (0);
}
static void
aha_isa_identify(driver_t *driver, device_t parent)
{
}
static device_method_t aha_isa_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, aha_isa_probe),
DEVMETHOD(device_attach, aha_isa_attach),
DEVMETHOD(device_detach, aha_isa_detach),
DEVMETHOD(device_identify, aha_isa_identify),
{ 0, 0 }
};

View File

@ -108,9 +108,6 @@ aha_mca_probe (device_t dev)
mca_add_drq(dev, drq);
mca_add_irq(dev, irq);
/* We're going to attempt to probe it now, so mark it probed */
aha_mark_probed_iop(iobase);
aha_unit++;
return (0);

View File

@ -216,7 +216,6 @@ typedef struct {
struct aha_isa_port {
u_int16_t addr;
u_int8_t probed;
u_int8_t bio; /* board IO offset */
};
@ -392,35 +391,34 @@ struct aha_softc {
u_int8_t fw_minor;
char model[32];
u_int8_t boardid;
struct resource *irq;
int irqrid;
struct resource *port;
int portrid;
struct resource *drq;
int drqrid;
void **ih;
};
extern struct aha_softc *aha_softcs[]; /* XXX Config should handle this */
extern u_long aha_unit;
#define AHA_TEMP_UNIT 0xFF /* Unit for probes */
struct aha_softc* aha_alloc(int unit, bus_space_tag_t tag,
bus_space_handle_t bsh);
void aha_free(struct aha_softc *aha);
int aha_probe(struct aha_softc *aha);
int aha_fetch_adapter_info(struct aha_softc *aha);
int aha_init(struct aha_softc *aha);
int aha_attach(struct aha_softc *aha);
void aha_intr(void *arg);
char * aha_name(struct aha_softc *aha);
int aha_check_probed_iop(u_int ioport);
void aha_mark_probed_bio(isa_compat_io_t port);
void aha_mark_probed_iop(u_int ioport);
void aha_find_probe_range(int ioport,
int *port_index,
int *max_port_index);
int aha_iop_from_bio(isa_compat_io_t bio_index);
struct aha_softc* aha_alloc(int, bus_space_tag_t, bus_space_handle_t);
int aha_attach(struct aha_softc *);
int aha_cmd(struct aha_softc *, aha_op_t, u_int8_t *,
u_int, u_int8_t *, u_int, u_int);
int aha_detach(struct aha_softc *);
int aha_fetch_adapter_info(struct aha_softc *);
void aha_find_probe_range(int, int *, int *);
void aha_free(struct aha_softc *);
int aha_init(struct aha_softc *);
void aha_intr(void *);
int aha_iop_from_bio(isa_compat_io_t);
char * aha_name(struct aha_softc *);
int aha_probe(struct aha_softc *);
#define DEFAULT_CMD_TIMEOUT 10000 /* 1 sec */
int aha_cmd(struct aha_softc *aha, aha_op_t opcode,
u_int8_t *params, u_int param_len,
u_int8_t *reply_data, u_int reply_len,
u_int cmd_timeout);
#define aha_inb(aha, port) \
bus_space_read_1((aha)->tag, (aha)->bsh, port)
@ -428,15 +426,8 @@ int aha_cmd(struct aha_softc *aha, aha_op_t opcode,
#define aha_outb(aha, port, value) \
bus_space_write_1((aha)->tag, (aha)->bsh, port, value)
#ifndef EXTRA_AHA
#if NPNP > 0
#define EXTRA_AHA MAX_PNP_CARDS
#else
#define EXTRA_AHA 0
#endif
#endif
/* XXX BAD */
#define EXTRA_AHA 4
#define NAHATOT (NAHA + EXTRA_AHA)
#define AHA1542_PNP 0x42159004 /* ADP1542 */