summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1995-10-21 00:55:36 +0000
committerphk <phk@FreeBSD.org>1995-10-21 00:55:36 +0000
commit6d6a401f8b20e250ab7d9a640a899fae0c5a017c (patch)
treed1751df070258ce118a4222568849a39456c07d5 /sys
parent8deb9482ef65a6a3a773ac996395624316ba29cc (diff)
downloadFreeBSD-src-6d6a401f8b20e250ab7d9a640a899fae0c5a017c.zip
FreeBSD-src-6d6a401f8b20e250ab7d9a640a899fae0c5a017c.tar.gz
A mixed bag of changes, relating to getting the state in "lsdev" right,
and pccard support to work sensibly. Better by far, but still not good.
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/autoconf.c10
-rw-r--r--sys/dev/ed/if_ed.c13
-rw-r--r--sys/dev/sio/sio.c12
-rw-r--r--sys/i386/i386/autoconf.c10
-rw-r--r--sys/i386/isa/if_ed.c13
-rw-r--r--sys/i386/isa/sio.c12
-rw-r--r--sys/i386/isa/wd.c13
-rw-r--r--sys/isa/sio.c12
-rw-r--r--sys/pccard/pccard.c38
-rw-r--r--sys/pccard/pcic.c83
10 files changed, 156 insertions, 60 deletions
diff --git a/sys/amd64/amd64/autoconf.c b/sys/amd64/amd64/autoconf.c
index e3b0770..d9f4d98 100644
--- a/sys/amd64/amd64/autoconf.c
+++ b/sys/amd64/amd64/autoconf.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
- * $Id: autoconf.c,v 1.38 1995/09/09 18:09:41 davidg Exp $
+ * $Id: autoconf.c,v 1.39 1995/09/10 18:57:24 bde Exp $
*/
/*
@@ -178,6 +178,10 @@ configure(dummy)
eisa_configure();
#endif
+#if NCRD > 0
+ /* Before isa_configure to avoid ISA drivers finding our cards */
+ pccard_configure();
+#endif
#if NISA > 0
isa_configure();
@@ -187,10 +191,6 @@ configure(dummy)
pci_configure();
#endif
-#if NCRD > 0
- pccard_configure();
-#endif
-
configure_finish();
cninit_finish();
diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c
index 3e9f325..e5c1771 100644
--- a/sys/dev/ed/if_ed.c
+++ b/sys/dev/ed/if_ed.c
@@ -13,7 +13,7 @@
* the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000,
* and a variety of similar clones.
*
- * $Id: if_ed.c,v 1.77 1995/10/10 09:52:30 phk Exp $
+ * $Id: if_ed.c,v 1.78 1995/10/13 19:47:40 wollman Exp $
*/
#include "ed.h"
@@ -223,7 +223,12 @@ void
edunload(struct pccard_dev *dp)
{
struct ed_softc *sc = &ed_softc[dp->isahd.id_unit];
+ if (sc->kdc.kdc_state == DC_UNCONFIGURED) {
+ printf("ed%d: already unloaded\n", dp->isahd.id_unit);
+ return;
+ }
sc->kdc.kdc_state = DC_UNCONFIGURED;
+ sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
if_down(&sc->arpcom.ac_if);
sc->gone = 1;
printf("ed%d: unload\n", dp->isahd.id_unit);
@@ -2231,8 +2236,10 @@ ed_ioctl(ifp, command, data)
struct ifreq *ifr = (struct ifreq *) data;
int s, error = 0;
- if (sc->gone)
- return -1;
+ if (sc->gone) {
+ ifp->if_flags &= ~IFF_RUNNING;
+ return ENXIO;
+ }
s = splimp();
switch (command) {
diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c
index c811dcc..a7b48ea 100644
--- a/sys/dev/sio/sio.c
+++ b/sys/dev/sio/sio.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
- * $Id: sio.c,v 1.112 1995/09/19 12:37:41 phk Exp $
+ * $Id: sio.c,v 1.113 1995/09/24 04:59:16 davidg Exp $
*/
#include "sio.h"
@@ -358,7 +358,7 @@ static struct kern_devconf kdc_sio[NSIO] = { {
&kdc_isa0, /* parent */
0, /* parentdata */
DC_UNCONFIGURED, /* state */
- "RS-232 serial port",
+ "Serial port",
DC_CLS_SERIAL /* class */
} };
#if NCRD > 0
@@ -449,6 +449,12 @@ siounload(struct pccard_dev *dp)
int s,unit,nowhere;
com = com_addr(dp->isahd.id_unit);
+ if (!com->iobase) {
+ printf("sio%d already unloaded!\n",dp->isahd.id_unit);
+ return;
+ }
+ kdc_sio[com->unit].kdc_state = DC_UNCONFIGURED;
+ kdc_sio[com->unit].kdc_description = "Serial port";
if (com->tp && (com->tp->t_state & TS_ISOPEN)) {
com->gone = 1;
printf("sio%d: unload\n", dp->isahd.id_unit);
@@ -493,6 +499,8 @@ sioregisterdev(id)
return;
if (unit != 0)
kdc_sio[unit] = kdc_sio[0];
+ kdc_sio[unit].kdc_state = DC_UNCONFIGURED;
+ kdc_sio[unit].kdc_description = "Serial port";
kdc_sio[unit].kdc_unit = unit;
kdc_sio[unit].kdc_isa = id;
dev_attach(&kdc_sio[unit]);
diff --git a/sys/i386/i386/autoconf.c b/sys/i386/i386/autoconf.c
index e3b0770..d9f4d98 100644
--- a/sys/i386/i386/autoconf.c
+++ b/sys/i386/i386/autoconf.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
- * $Id: autoconf.c,v 1.38 1995/09/09 18:09:41 davidg Exp $
+ * $Id: autoconf.c,v 1.39 1995/09/10 18:57:24 bde Exp $
*/
/*
@@ -178,6 +178,10 @@ configure(dummy)
eisa_configure();
#endif
+#if NCRD > 0
+ /* Before isa_configure to avoid ISA drivers finding our cards */
+ pccard_configure();
+#endif
#if NISA > 0
isa_configure();
@@ -187,10 +191,6 @@ configure(dummy)
pci_configure();
#endif
-#if NCRD > 0
- pccard_configure();
-#endif
-
configure_finish();
cninit_finish();
diff --git a/sys/i386/isa/if_ed.c b/sys/i386/isa/if_ed.c
index 3e9f325..e5c1771 100644
--- a/sys/i386/isa/if_ed.c
+++ b/sys/i386/isa/if_ed.c
@@ -13,7 +13,7 @@
* the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000,
* and a variety of similar clones.
*
- * $Id: if_ed.c,v 1.77 1995/10/10 09:52:30 phk Exp $
+ * $Id: if_ed.c,v 1.78 1995/10/13 19:47:40 wollman Exp $
*/
#include "ed.h"
@@ -223,7 +223,12 @@ void
edunload(struct pccard_dev *dp)
{
struct ed_softc *sc = &ed_softc[dp->isahd.id_unit];
+ if (sc->kdc.kdc_state == DC_UNCONFIGURED) {
+ printf("ed%d: already unloaded\n", dp->isahd.id_unit);
+ return;
+ }
sc->kdc.kdc_state = DC_UNCONFIGURED;
+ sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
if_down(&sc->arpcom.ac_if);
sc->gone = 1;
printf("ed%d: unload\n", dp->isahd.id_unit);
@@ -2231,8 +2236,10 @@ ed_ioctl(ifp, command, data)
struct ifreq *ifr = (struct ifreq *) data;
int s, error = 0;
- if (sc->gone)
- return -1;
+ if (sc->gone) {
+ ifp->if_flags &= ~IFF_RUNNING;
+ return ENXIO;
+ }
s = splimp();
switch (command) {
diff --git a/sys/i386/isa/sio.c b/sys/i386/isa/sio.c
index c811dcc..a7b48ea 100644
--- a/sys/i386/isa/sio.c
+++ b/sys/i386/isa/sio.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
- * $Id: sio.c,v 1.112 1995/09/19 12:37:41 phk Exp $
+ * $Id: sio.c,v 1.113 1995/09/24 04:59:16 davidg Exp $
*/
#include "sio.h"
@@ -358,7 +358,7 @@ static struct kern_devconf kdc_sio[NSIO] = { {
&kdc_isa0, /* parent */
0, /* parentdata */
DC_UNCONFIGURED, /* state */
- "RS-232 serial port",
+ "Serial port",
DC_CLS_SERIAL /* class */
} };
#if NCRD > 0
@@ -449,6 +449,12 @@ siounload(struct pccard_dev *dp)
int s,unit,nowhere;
com = com_addr(dp->isahd.id_unit);
+ if (!com->iobase) {
+ printf("sio%d already unloaded!\n",dp->isahd.id_unit);
+ return;
+ }
+ kdc_sio[com->unit].kdc_state = DC_UNCONFIGURED;
+ kdc_sio[com->unit].kdc_description = "Serial port";
if (com->tp && (com->tp->t_state & TS_ISOPEN)) {
com->gone = 1;
printf("sio%d: unload\n", dp->isahd.id_unit);
@@ -493,6 +499,8 @@ sioregisterdev(id)
return;
if (unit != 0)
kdc_sio[unit] = kdc_sio[0];
+ kdc_sio[unit].kdc_state = DC_UNCONFIGURED;
+ kdc_sio[unit].kdc_description = "Serial port";
kdc_sio[unit].kdc_unit = unit;
kdc_sio[unit].kdc_isa = id;
dev_attach(&kdc_sio[unit]);
diff --git a/sys/i386/isa/wd.c b/sys/i386/isa/wd.c
index d3c8ec3..58f4072 100644
--- a/sys/i386/isa/wd.c
+++ b/sys/i386/isa/wd.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)wd.c 7.2 (Berkeley) 5/9/91
- * $Id: wd.c,v 1.86 1995/09/30 15:19:44 davidg Exp $
+ * $Id: wd.c,v 1.87 1995/10/14 15:41:10 davidg Exp $
*/
/* TODO:
@@ -136,11 +136,14 @@ struct kern_devconf kdc_wdc[NWDC] = { {
static inline void
wd_registerdev(int ctlr, int unit)
{
- if(unit != 0)
+ if(unit != 0) {
kdc_wd[unit] = kdc_wd[0];
+ kdc_wd[unit].kdc_state = DC_IDLE;
+ }
kdc_wd[unit].kdc_unit = unit;
kdc_wd[unit].kdc_parent = &kdc_wdc[ctlr];
+ kdc_wdc[ctlr].kdc_state = DC_BUSY;
dev_attach(&kdc_wd[unit]);
}
@@ -149,8 +152,10 @@ wdc_registerdev(struct isa_device *dvp)
{
int unit = dvp->id_unit;
- if(unit != 0)
+ if(unit != 0) {
kdc_wdc[unit] = kdc_wdc[0];
+ kdc_wdc[unit].kdc_state = DC_IDLE;
+ }
kdc_wdc[unit].kdc_unit = unit;
kdc_wdc[unit].kdc_parentdata = dvp;
@@ -1120,6 +1125,7 @@ wdopen(dev_t dev, int flags, int fmt, struct proc *p)
while (du->dk_flags & DKFL_LABELLING)
tsleep((caddr_t)&du->dk_flags, PZERO - 1, "wdopen", 1);
#if 1
+ kdc_wd[lunit].kdc_state = DC_BUSY;
wdsleep(du->dk_ctrlr, "wdopn1");
du->dk_flags |= DKFL_LABELLING;
du->dk_state = WANTOPEN;
@@ -1624,6 +1630,7 @@ int
wdclose(dev_t dev, int flags, int fmt, struct proc *p)
{
dsclose(dev, fmt, wddrives[dkunit(dev)]->dk_slices);
+ kdc_wd[wddrives[dkunit(dev)]->dk_lunit].kdc_state = DC_IDLE;
return (0);
}
diff --git a/sys/isa/sio.c b/sys/isa/sio.c
index c811dcc..a7b48ea 100644
--- a/sys/isa/sio.c
+++ b/sys/isa/sio.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
- * $Id: sio.c,v 1.112 1995/09/19 12:37:41 phk Exp $
+ * $Id: sio.c,v 1.113 1995/09/24 04:59:16 davidg Exp $
*/
#include "sio.h"
@@ -358,7 +358,7 @@ static struct kern_devconf kdc_sio[NSIO] = { {
&kdc_isa0, /* parent */
0, /* parentdata */
DC_UNCONFIGURED, /* state */
- "RS-232 serial port",
+ "Serial port",
DC_CLS_SERIAL /* class */
} };
#if NCRD > 0
@@ -449,6 +449,12 @@ siounload(struct pccard_dev *dp)
int s,unit,nowhere;
com = com_addr(dp->isahd.id_unit);
+ if (!com->iobase) {
+ printf("sio%d already unloaded!\n",dp->isahd.id_unit);
+ return;
+ }
+ kdc_sio[com->unit].kdc_state = DC_UNCONFIGURED;
+ kdc_sio[com->unit].kdc_description = "Serial port";
if (com->tp && (com->tp->t_state & TS_ISOPEN)) {
com->gone = 1;
printf("sio%d: unload\n", dp->isahd.id_unit);
@@ -493,6 +499,8 @@ sioregisterdev(id)
return;
if (unit != 0)
kdc_sio[unit] = kdc_sio[0];
+ kdc_sio[unit].kdc_state = DC_UNCONFIGURED;
+ kdc_sio[unit].kdc_description = "Serial port";
kdc_sio[unit].kdc_unit = unit;
kdc_sio[unit].kdc_isa = id;
dev_attach(&kdc_sio[unit]);
diff --git a/sys/pccard/pccard.c b/sys/pccard/pccard.c
index ae5ca49..d5dfb0c 100644
--- a/sys/pccard/pccard.c
+++ b/sys/pccard/pccard.c
@@ -46,6 +46,20 @@
#include <i386/isa/isa.h>
#include <i386/isa/isa_device.h>
#include <i386/isa/icu.h>
+#include <sys/devconf.h>
+
+extern struct kern_devconf kdc_cpu0;
+
+struct kern_devconf kdc_pccard0 = {
+ 0, 0, 0, /* filled in by dev_attach */
+ "pccard", 0, { MDDT_BUS, 0 },
+ 0, 0, 0, BUS_EXTERNALLEN,
+ &kdc_cpu0, /* parent is the CPU */
+ 0, /* no parentdata */
+ DC_UNCONFIGURED, /* until we see it */
+ "PCCARD or PCMCIA bus",
+ DC_CLS_BUS /* class */
+};
#include "apm.h"
#if NAPM > 0
@@ -121,6 +135,8 @@ pccard_configure()
struct slot_cont *cp;
struct slot *sp;
+ dev_attach(&kdc_pccard0);
+
#include "pcic.h"
#if NPCIC > 0
pcic_probe();
@@ -267,11 +283,12 @@ struct pccard_dev *devp;
* driver is accessing the device and it is removed, then
* all bets are off...
*/
- for (devp = sp->devices; devp; devp = devp->next)
- {
- devp->drv->unload(devp);
- devp->running = 0;
+ for (devp = sp->devices; devp; devp = devp->next) {
+ if (devp->running) {
+ devp->drv->unload(devp);
+ devp->running = 0;
}
+ }
/*
* Power off the slot.
*/
@@ -338,6 +355,7 @@ int slotno;
break;
if (slotno >= MAXSLOT)
return(0);
+ kdc_pccard0.kdc_state = DC_BUSY;
MALLOC(sp, struct slot *, sizeof(*sp), M_DEVBUF, M_WAITOK);
bzero(sp, sizeof(*sp));
if (cp->extra)
@@ -407,6 +425,7 @@ printf("IRQ=%d\n",irq);
if (register_intr(irq, 0, 0, hand, maskp, unit)==0)
{
printf("IRQ=%d yes!\n",irq);
+ INTREN (1 << irq);
return(irq);
}
@@ -461,9 +480,6 @@ int err, irq = 0, s;
*/
else
{
-/* XXX ED.C
-dp->imask = &net_imask;
-*/
irq = pccard_alloc_intr(drvp->irqmask,
slot_irq_handler, (int)sp, dp->imask);
if (irq < 0)
@@ -509,7 +525,6 @@ dp->imask = &net_imask;
remove_device(devp);
else
devp->running = 1;
- INTREN (1 << irq);
return(err);
}
static void
@@ -524,12 +539,17 @@ int s;
* then unregister it if no-one else is using it.
*/
s = splhigh();
- if (dp->running)
+ if (dp->running) {
dp->drv->unload(dp);
+ dp->running = 0;
+ }
if (dp->isahd.id_irq && --sp->irqref == 0)
{
sp->cinfo->mapirq(sp, 0);
+ INTRDIS(1<<sp->irq);
unregister_intr(sp->irq, slot_irq_handler);
+ if (dp->drv->imask)
+ INTRUNMASK(*dp->drv->imask,(1<<sp->irq));
sp->irq = 0;
}
splx(s);
diff --git a/sys/pccard/pcic.c b/sys/pccard/pcic.c
index 985c4bd..a5df02a 100644
--- a/sys/pccard/pcic.c
+++ b/sys/pccard/pcic.c
@@ -34,8 +34,6 @@
#include "pcic.h"
#endif
-#if NPCIC > 0
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -58,6 +56,22 @@
#include <pccard/i82365.h>
#include <pccard/card.h>
#include <pccard/slot.h>
+#include <sys/devconf.h>
+
+extern struct kern_devconf kdc_pccard0;
+
+struct kern_devconf kdc_pcic[PCIC_MAX_SLOTS] = {
+ {
+ 0, 0, 0, /* filled in by dev_attach */
+ "pcic", 0, { MDDT_BUS, 0 },
+ 0, 0, 0, BUS_EXTERNALLEN,
+ &kdc_pccard0, /* parent is the CPU */
+ 0, /* no parentdata */
+ DC_UNKNOWN,
+ "PCMCIA or PCCARD slot",
+ DC_CLS_BUS /* class */
+ }
+};
/*
* Prototypes for interrupt handler.
@@ -68,6 +82,7 @@ static int pcic_power __P((struct slot *));
static void pcic_reset __P((struct slot *));
static void pcic_disable __P((struct slot *));
static void pcic_mapirq __P((struct slot *, int));
+static void pcictimeout __P((void));
/*
* Per-slot data table.
@@ -233,11 +248,14 @@ pcic_unload()
int slot;
struct pcic_slot *cp = pcic_slots;
+ untimeout(pcictimeout);
if (pcic_irq)
{
- for (slot = 0; slot < PCIC_MAX_SLOTS; slot++, cp++)
+ for (slot = 0; slot < PCIC_MAX_SLOTS; slot++, cp++) {
if (cp->sp)
putb(cp, PCIC_STAT_INT, 0);
+ kdc_pcic[slot].kdc_state = DC_UNCONFIGURED;
+ }
unregister_intr(pcic_irq, pcicintr);
}
pccard_remove_controller(&cinfo);
@@ -535,9 +553,18 @@ unsigned char c;
*/
validslots++;
cp->slot = slot;
+ if (kdc_pcic[slot].kdc_state == DC_UNKNOWN) {
+ if (slot != 0)
+ kdc_pcic[slot] = kdc_pcic[0];
+ kdc_pcic[slot].kdc_unit = slot;
+ kdc_pcic[slot].kdc_state = DC_UNCONFIGURED;
+ kdc_pcic[slot].kdc_description = cinfo.name;
+ dev_attach(kdc_pcic+slot);
+ }
sp = pccard_alloc_slot(&cinfo);
if (sp == 0)
continue;
+ kdc_pcic[slot].kdc_state = DC_IDLE;
sp->cdata = cp;
cp->sp = sp;
/*
@@ -548,19 +575,9 @@ unsigned char c;
{
pcic_irq = pccard_alloc_intr(PCIC_INT_MASK_ALLOWED,
pcicintr, 0, &pcic_imask);
-#if 0
- for (try = 0; try < 16; try++)
- if (((1 << try) & PCIC_INT_MASK_ALLOWED) &&
- !pccard_alloc_intr(try, pcicintr, 0, &tty_imask))
- {
- pcic_irq = try;
- break;
- }
-#endif
if (pcic_irq < 0)
printf("pcic: failed to allocate IRQ\n");
}
- INTREN (1 << pcic_irq);
/*
* Check for a card in this slot.
*/
@@ -578,6 +595,8 @@ unsigned char c;
if (pcic_irq > 0)
putb(cp, PCIC_STAT_INT, (pcic_irq << 4) | 0xF);
}
+ if (validslots)
+ timeout(pcictimeout,0,hz/2);
return(validslots);
}
/*
@@ -711,6 +730,18 @@ struct pcic_slot *sp = slotp->cdata;
}
/*
+ * PCIC timer, it seems that we loose interrupts sometimes
+ * so poll just in case...
+ */
+
+static void
+pcictimeout()
+{
+ timeout(pcictimeout,0,hz/2);
+ pcicintr(0);
+}
+
+/*
* PCIC Interrupt handler.
* Check each slot in turn, and read the card status change
* register. If this is non-zero, then a change has occurred
@@ -725,18 +756,18 @@ struct pcic_slot *cp = pcic_slots;
s = splhigh();
for (slot = 0; slot < PCIC_MAX_SLOTS; slot++, cp++)
- if (cp->sp)
- if ((chg = getb(cp, PCIC_STAT_CHG)) != 0)
- if (chg & PCIC_CDTCH)
- {
- if ((getb(cp, PCIC_STATUS) & PCIC_CD) ==
- PCIC_CD)
- pccard_event(cp->sp,
- card_inserted);
- else
- pccard_event(cp->sp,
- card_removed);
- }
+ if (cp->sp && (chg = getb(cp, PCIC_STAT_CHG)) != 0)
+ if (chg & PCIC_CDTCH) {
+ if ((getb(cp, PCIC_STATUS) & PCIC_CD) ==
+ PCIC_CD) {
+ kdc_pcic[slot].kdc_state = DC_BUSY;;
+ pccard_event(cp->sp,
+ card_inserted);
+ } else {
+ pccard_event(cp->sp,
+ card_removed);
+ kdc_pcic[slot].kdc_state = DC_IDLE;;
+ }
+ }
splx(s);
}
-#endif
OpenPOWER on IntegriCloud