summaryrefslogtreecommitdiffstats
path: root/sys/dev/ncv
diff options
context:
space:
mode:
authornon <non@FreeBSD.org>2001-02-26 12:26:29 +0000
committernon <non@FreeBSD.org>2001-02-26 12:26:29 +0000
commitde6017833f3b6211a63c635f199de7f71f9ca4df (patch)
tree9b365d2c74dba495cf4f9d3d575976d9fb1534ff /sys/dev/ncv
parent0e3a0a234c9779576c6e20d8336e9ed69bd912ff (diff)
downloadFreeBSD-src-de6017833f3b6211a63c635f199de7f71f9ca4df.zip
FreeBSD-src-de6017833f3b6211a63c635f199de7f71f9ca4df.tar.gz
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>
Diffstat (limited to 'sys/dev/ncv')
-rw-r--r--sys/dev/ncv/ncr53c500_pccard.c30
-rw-r--r--sys/dev/ncv/ncr53c500var.h2
2 files changed, 29 insertions, 3 deletions
diff --git a/sys/dev/ncv/ncr53c500_pccard.c b/sys/dev/ncv/ncr53c500_pccard.c
index a7ac712..b35d9d6 100644
--- a/sys/dev/ncv/ncr53c500_pccard.c
+++ b/sys/dev/ncv/ncr53c500_pccard.c
@@ -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);
diff --git a/sys/dev/ncv/ncr53c500var.h b/sys/dev/ncv/ncr53c500var.h
index c01bc85..f040b17 100644
--- a/sys/dev/ncv/ncr53c500var.h
+++ b/sys/dev/ncv/ncr53c500var.h
@@ -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;
OpenPOWER on IntegriCloud