1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Almost make loading work. This is a checkpoint. With these change we

can almost kldload this.  More work is ncessary, but I wanted to
checkpoint this now.
This commit is contained in:
Warner Losh 2000-06-18 05:25:30 +00:00
parent b24d8193fe
commit 1e4742f217
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=61787
3 changed files with 86 additions and 44 deletions

View File

@ -64,13 +64,15 @@
#ifdef PCICDEBUG
int pcic_debug = 1;
#define DPRINTF(arg) if (pcic_debug) printf arg;
#define DEVPRINTF(arg) if (pcic_debug) device_printf arg;
#define DPRINTF(arg) if (pcic_debug) printf arg; else ;
#define DEVPRINTF(arg) if (pcic_debug) device_printf arg; else ;
#else
#define DPRINTF(arg)
#define DEVPRINTF(arg)
#endif
#define VERBOSE(arg) if (bootverbose) printf arg; else ;
#define DETACH_FORCE 0x1
#define PCIC_VENDOR_UNKNOWN 0
@ -90,7 +92,6 @@ static void pcic_init_socket(struct pcic_handle *);
static void pcic_intr_socket(struct pcic_handle *);
static void pcic_deactivate(device_t dev);
static int pcic_activate(device_t dev);
static void pcic_intr(void *arg);
@ -206,27 +207,23 @@ pcic_activate(device_t dev)
sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid,
0, ~0, PCIC_IOSIZE, RF_ACTIVE);
if (!sc->port_res) {
#ifdef PCIC_DEBUG
device_printf(dev, "Cannot allocate ioport\n");
#endif
return ENOMEM;
}
sc->irq_rid = 0;
sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
0, ~0, 1, RF_ACTIVE);
if (!sc->irq_res) {
#ifdef PCIC_DEBUG
device_printf(dev, "Cannot allocate irq\n");
#endif
pcic_deactivate(dev);
return ENOMEM;
}
sc->irq = rman_get_start(sc->irq_res);
if ((err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, pcic_intr,
sc, &sc->intrhand)) != 0) {
pcic_deactivate(dev);
return err;
if (sc->irq_res) {
sc->irq = rman_get_start(sc->irq_res);
if ((err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
pcic_intr, sc, &sc->intrhand)) != 0) {
pcic_deactivate(dev);
return err;
}
} else {
/* XXX Do polling */
return (ENXIO);
}
/* XXX This might not be needed in future, get it directly from
@ -234,10 +231,8 @@ pcic_activate(device_t dev)
sc->mem_rid = 0;
sc->mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->mem_rid,
0, ~0, 1 << 13, RF_ACTIVE);
if (!sc->mem_res) {
#ifdef PCIC_DEBUG
if (sc->mem_res == NULL) {
device_printf(dev, "Cannot allocate mem\n");
#endif
pcic_deactivate(dev);
return ENOMEM;
}
@ -250,7 +245,7 @@ pcic_activate(device_t dev)
return (0);
}
static void
void
pcic_deactivate(device_t dev)
{
struct pcic_softc *sc = device_get_softc(dev);
@ -291,12 +286,13 @@ pcic_attach(device_t dev)
/*
* this could be done with a loop, but it would violate the
* abstraction... so? --imp
* abstraction... --- unknown
* so? I don't see the abstraction... --imp
*/
count = 0;
DPRINTF(("pcic ident regs:"));
VERBOSE(("pcic ident regs:"));
sc->handle[0].sc = sc;
sc->handle[0].sock = C0SA;
@ -313,7 +309,7 @@ pcic_attach(device_t dev)
}
sc->handle[0].laststate = PCIC_LASTSTATE_EMPTY;
DPRINTF((" 0x%02x", reg));
VERBOSE((" 0x%02x", reg));
sc->handle[1].sc = sc;
sc->handle[1].sock = C0SB;
@ -330,7 +326,7 @@ pcic_attach(device_t dev)
}
sc->handle[1].laststate = PCIC_LASTSTATE_EMPTY;
DPRINTF((" 0x%02x", reg));
VERBOSE((" 0x%02x", reg));
/*
* The CL-PD6729 has only one controller and always returns 0
@ -355,7 +351,7 @@ pcic_attach(device_t dev)
}
sc->handle[2].laststate = PCIC_LASTSTATE_EMPTY;
DPRINTF((" 0x%02x", reg));
VERBOSE((" 0x%02x", reg));
sc->handle[3].sc = sc;
sc->handle[3].sock = C1SB;
@ -373,7 +369,7 @@ pcic_attach(device_t dev)
}
sc->handle[3].laststate = PCIC_LASTSTATE_EMPTY;
DPRINTF((" 0x%02x\n", reg));
VERBOSE((" 0x%02x\n", reg));
} else {
sc->handle[2].flags = 0;
sc->handle[3].flags = 0;
@ -674,9 +670,7 @@ pcic_intr_socket(struct pcic_handle *h)
/* Deactivate the card now. */
DEVPRINTF((h->dev, "detaching card\n"));
pcic_detach_card(h, DETACH_FORCE);
DEVPRINTF((h->dev,
"enqueing REMOVAL event\n"));
DEVPRINTF((h->dev,"enqueing REMOVAL event\n"));
pcic_queue_event(h, PCIC_EVENT_REMOVAL);
}
h->laststate = ((statreg & PCIC_IF_STATUS_CARDDETECT_MASK) == 0)
@ -720,7 +714,6 @@ pcic_attach_card(struct pcic_handle *h)
if (!(h->flags & PCIC_FLAG_CARDP)) {
/* call the MI attach function */
CARD_ATTACH_CARD(h->dev);
h->flags |= PCIC_FLAG_CARDP;
} else {
DPRINTF(("pcic_attach_card: already attached"));

View File

@ -60,12 +60,6 @@
* Configurable parameters.
*****************************************************************************/
#if 0
#include "opt_pcic_isa_alloc_iobase.h"
#include "opt_pcic_isa_alloc_iosize.h"
#include "opt_pcic_isa_intr_alloc_mask.h"
#endif
/*
* Default I/O allocation range. If both are set to non-zero, these
* values will be used instead. Otherwise, the code attempts to probe
@ -227,6 +221,7 @@ pcic_isa_bus_width_probe (device_t dev)
}
}
#if 0
static int
pcic_isa_check(device_t dev, u_int16_t addr)
{
@ -273,10 +268,12 @@ pcic_isa_check(device_t dev, u_int16_t addr)
return (found);
}
#endif
static void
pcic_isa_identify(driver_t *driver, device_t parent)
{
#if 0
device_t child;
u_int16_t ioaddrs[] = { 0x3e0, 0x3e2, 0x3e4, 0x3e6, 0 };
u_int16_t ioaddr;
@ -295,12 +292,17 @@ pcic_isa_identify(driver_t *driver, device_t parent)
PCIC_IOSIZE);
}
}
#endif
}
static int
pcic_isa_probe(device_t dev)
{
int error;
struct resource *res;
int rid;
int i;
u_long mem;
/* Check isapnp ids */
error = ISA_PNP_PROBE(device_get_parent(dev), dev, pcic_ids);
@ -308,17 +310,62 @@ pcic_isa_probe(device_t dev)
return (ENXIO);
/* If we had some other problem. */
if (!(error == 0 || error == ENOENT)) {
if (!(error == 0 || error == ENOENT))
return (error);
}
/* If we have the resources we need then we're good to go. */
if ((bus_get_resource_start(dev, SYS_RES_IOPORT, 0) != 0) &&
(bus_get_resource_start(dev, SYS_RES_IRQ, 0) != 0)) {
return (0);
}
if (bus_get_resource_start(dev, SYS_RES_IOPORT, 0) == 0)
return (ENXIO);
return (ENXIO);
rid = 0;
res = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, RF_ACTIVE);
if (res == NULL) {
/*
* No IRQ specified, find one. This can be due to the PnP
* data not specifying any IRQ
*/
for (i = 0; res == NULL && i < 16; i++) {
if (((1 << i) & PCIC_INTR_IRQ_VALIDMASK) == 0)
continue;
res = bus_alloc_resource(dev, SYS_RES_IRQ,
&rid, i, i, 1, RF_ACTIVE);
}
if (res == NULL)
return (ENXIO);
mem = rman_get_start(res);
bus_release_resource(dev, SYS_RES_IRQ, rid, res);
bus_set_resource(dev, SYS_RES_IRQ, 0, mem, 1);
} else {
bus_release_resource(dev, SYS_RES_IRQ, rid, res);
}
/* XXX This might not be needed in future, get it directly from
* XXX parent */
rid = 0;
res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0,
1 << 13, RF_ACTIVE);
if (res == NULL) {
/*
* We failed to get memory. Since this XXX comment above
* indicates that this is transient, we try to get a hunk
* of memory in the isa hole. Sure would be nice if there
* were some MI constants for this.
*/
res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
0xa0000, 0xdffff, 1 << 13, RF_ACTIVE);
if (res != NULL) {
mem = rman_get_start(res);
bus_release_resource(dev, SYS_RES_MEMORY, res, rid);
bus_set_resource(dev, SYS_RES_MEMORY, 0, mem, 1 << 13);
}
}
if (res == NULL) {
device_printf(dev, "Cannot allocate mem\n");
return ENOMEM;
}
bus_release_resource(dev, SYS_RES_MEMORY, rid, res);
return (0);
}
static int
@ -335,6 +382,7 @@ pcic_isa_attach(device_t dev)
static int
pcic_isa_detach(device_t dev)
{
pcic_deactivate(dev);
return 0;
}

View File

@ -176,6 +176,7 @@ int pcic_activate_resource(device_t dev, device_t child, int type, int rid,
struct resource *r);
struct resource *pcic_alloc_resource(device_t dev, device_t child, int type,
int *rid, u_long start, u_long end, u_long count, u_int flags);
void pcic_deactivate(device_t dev);
int pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
struct resource *r);
int pcic_release_resource(device_t dev, device_t child, int type, int rid,