o Check the size of I/O window handed by parent bus.

o Allocate memory mapped by pcic even when not used for ncv.
  This is for PC-Cards which needs offset, because I/O space should not be
  used by other devices.

Pointed-out-by: YAMAMOTO Shigeru <shigeru@iij.ad.jp>
This commit is contained in:
Noriaki Mitsunaga 2001-02-26 12:26:29 +00:00
parent 69c5c26010
commit 205274e87d
2 changed files with 29 additions and 3 deletions

View File

@ -122,6 +122,11 @@ ncv_release_resource(DEVPORT_PDEVICE dev)
sc->port_rid, sc->port_res);
}
if (sc->port_res_dmy) {
bus_release_resource(dev, SYS_RES_IOPORT,
sc->port_rid_dmy, sc->port_res_dmy);
}
if (sc->irq_res) {
bus_release_resource(dev, SYS_RES_IRQ,
sc->irq_rid, sc->irq_res);
@ -138,22 +143,41 @@ ncv_alloc_resource(DEVPORT_PDEVICE dev)
{
struct ncv_softc *sc = device_get_softc(dev);
u_int32_t flags = DEVPORT_PDEVFLAGS(dev);
u_int iobase = DEVPORT_PDEVIOBASE(dev);
u_long maddr, msize;
u_long ioaddr, iosize, maddr, msize;
int error;
bus_addr_t offset = 0;
if(flags & KME_KXLC004_01)
offset = OFFSET_KME_KXLC004_01;
error = bus_get_resource(dev, SYS_RES_IOPORT, 0, &ioaddr, &iosize);
if (error || (iosize < (offset + NCVIOSZ))) {
return(ENOMEM);
}
sc->port_rid = 0;
sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid,
iobase+offset, ~0, NCVIOSZ, RF_ACTIVE);
ioaddr+offset, ioaddr+iosize-offset,
iosize-offset, RF_ACTIVE);
if (sc->port_res == NULL) {
ncv_release_resource(dev);
return(ENOMEM);
}
if (offset != 0) {
sc->port_rid_dmy = 0;
sc->port_res_dmy = bus_alloc_resource(dev, SYS_RES_IOPORT,
&sc->port_rid_dmy,
ioaddr, ioaddr+offset, offset,
RF_ACTIVE);
if (sc->port_res_dmy == NULL) {
printf("Warning: cannot allocate IOPORT partially.\n");
}
} else {
sc->port_rid_dmy = 0;
sc->port_res_dmy = NULL;
}
sc->irq_rid = 0;
sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
0, ~0, 1, RF_ACTIVE);

View File

@ -55,9 +55,11 @@ struct ncv_softc {
struct ncv_hw sc_hw; /* hardware register images */
#if defined (__FreeBSD__) && __FreeBSD_version >= 400001
int port_rid;
int port_rid_dmy;
int irq_rid;
int mem_rid;
struct resource *port_res;
struct resource *port_res_dmy;
struct resource *irq_res;
struct resource *mem_res;
void *ncv_intrhand;