summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormycroft <mycroft@NetBSD.org>1994-03-23 03:01:50 +0000
committermycroft <mycroft@NetBSD.org>1994-03-23 03:01:50 +0000
commit4cc5b77bfa9b4eb6be491c54f2fc440f4c330f96 (patch)
tree7c15e50ff515fb21103388bf018644b6d4110d3b /sys/dev
parentb8f74df1a5fdbdfb8a3c3c87beade92654638d2e (diff)
Some stylistic cleanup, and a very minor speedup.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/com.c39
-rw-r--r--sys/dev/isa/ast.c90
-rw-r--r--sys/dev/isa/com.c39
3 files changed, 93 insertions, 75 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c
index fb7529eccc6..0ca439f9f19 100644
--- a/sys/dev/ic/com.c
+++ b/sys/dev/ic/com.c
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
- * $Id: com.c,v 1.26 1994/03/23 01:28:23 cgd Exp $
+ * $Id: com.c,v 1.27 1994/03/23 03:01:53 mycroft Exp $
*/
/*
@@ -157,13 +157,13 @@ comprobe1(iobase)
}
int
-comprobe(isa_dev)
- struct isa_device *isa_dev;
+comprobe(dev)
+ struct isa_device *dev;
{
- struct com_softc *sc = &com_softc[isa_dev->id_unit];
- u_short iobase = isa_dev->id_iobase;
+ struct com_softc *sc = &com_softc[dev->id_unit];
+ u_short iobase = dev->id_iobase;
- if (isa_dev->id_parent) {
+ if (dev->id_parent) {
if (iobase == 0) {
/*
* For multiport cards, the iobase may be left
@@ -172,15 +172,14 @@ comprobe(isa_dev)
* (parent) iobase setting and the slave port
* number (physid).
*/
- iobase = isa_dev->id_iobase
- = isa_dev->id_parent->id_iobase +
- (8 * isa_dev->id_physid);
+ iobase = dev->id_iobase =
+ dev->id_parent->id_iobase + (8 * dev->id_physid);
}
}
/* XXX HACK */
- sprintf(sc->sc_dev.dv_xname, "%s%d", comdriver.name, isa_dev->id_unit);
- sc->sc_dev.dv_unit = isa_dev->id_unit;
+ sprintf(sc->sc_dev.dv_xname, "%s%d", comdriver.name, dev->id_unit);
+ sc->sc_dev.dv_unit = dev->id_unit;
if (!comprobe1(iobase))
return 0;
@@ -189,12 +188,12 @@ comprobe(isa_dev)
}
int
-comattach(isa_dev)
- struct isa_device *isa_dev;
+comattach(dev)
+ struct isa_device *dev;
{
- int unit = isa_dev->id_unit;
+ int unit = dev->id_unit;
struct com_softc *sc = &com_softc[unit];
- u_short iobase = isa_dev->id_iobase;
+ u_short iobase = dev->id_iobase;
struct tty *tp;
if (unit == comconsole)
@@ -208,13 +207,11 @@ comattach(isa_dev)
printf("%s", sc->sc_dev.dv_xname);
#if NAST > 0
- if (isa_dev->id_parent) {
+ if (dev->id_parent) {
printf(" at 0x%x %s%d slave %d",
- isa_dev->id_iobase,
- isa_dev->id_parent->id_driver->name,
- isa_dev->id_parent->id_unit,
- isa_dev->id_physid);
- astslave(isa_dev, unit);
+ dev->id_iobase, dev->id_parent->id_driver->name,
+ dev->id_parent->id_unit, dev->id_physid);
+ astslave(dev);
sc->sc_hwflags |= COM_HW_MULTI;
}
#endif
diff --git a/sys/dev/isa/ast.c b/sys/dev/isa/ast.c
index 7101cf758b6..b70be538e59 100644
--- a/sys/dev/isa/ast.c
+++ b/sys/dev/isa/ast.c
@@ -1,13 +1,15 @@
/*
* Multi-port serial card interrupt demuxing support.
* Roland McGrath 3/20/94
+ * Charles Hannum 3/22/94
*
- * $Id: ast.c,v 1.1 1994/03/23 01:26:14 cgd Exp $
+ * $Id: ast.c,v 1.2 1994/03/23 03:01:50 mycroft Exp $
*/
#include "ast.h"
#include <sys/types.h>
+#include <sys/device.h>
#include <machine/pio.h>
#include <i386/isa/isa_device.h>
@@ -19,70 +21,92 @@ struct isa_driver astdriver = {
astprobe, astattach, "ast"
};
-struct astunit /* XXX ast_softc? */
-{
- u_short iobase;
- int alive; /* Mask of slave units attached. */
- int slaveunits[8]; /* com device unit numbers. XXX - softc ptrs */
-} astunits[NAST];
+struct ast_softc {
+ struct device sc_dev;
+ u_short sc_iobase;
+ int sc_alive; /* Mask of slave units attached. */
+ int sc_slaves[8]; /* com device unit numbers. XXX - softc ptrs */
+} ast_softc[NAST];
int
-astprobe(struct isa_device *isa_dev)
+astprobe(dev)
+ struct isa_device *dev;
{
+
/*
* Do the normal com probe for the first UART and assume
* its presence means there is a multiport board there.
* XXX needs more robustness.
*/
- return comprobe1(isa_dev->id_iobase);
+ return comprobe1(dev->id_iobase);
}
int
-astattach(struct isa_device *isa_dev)
+astattach(dev)
+ struct isa_device *dev;
{
- int unit = isa_dev->id_unit;
- u_short iobase = isa_dev->id_iobase;
+ struct ast_softc *sc = &ast_softc[dev->id_unit];
+ u_short iobase = dev->id_iobase;
unsigned int x;
-
- astunits[unit].iobase = iobase;
+
+ /* XXX HACK */
+ sprintf(sc->sc_dev.dv_xname, "%s%d", astdriver.name, dev->id_unit);
+ sc->sc_dev.dv_unit = dev->id_unit;
+
+ sc->sc_iobase = iobase;
/*
- * XXX calculation of master address is a bit hazy --
- * what if > 4 ports, etc.
+ * Enable the master interrupt.
*/
- outb (iobase | 0x1f, 0x80);
- x = inb (iobase | 0x1f);
+ outb(iobase | 0x1f, 0x80);
+ x = inb(iobase | 0x1f);
/*
* My guess is this bitmask tells you how many ports are there.
* I only have a 4-port board to try (returns 0xf). --roland
+ *
+ * It's also not clear that it would be correct to rely on this, since
+ * there might be an interrupt pending on one of the ports, and thus
+ * its bit wouldn't be set. - mycroft
*/
- printf ("ast%d: 0x%x\n", unit, x);
+ printf("%s: 0x%x\n", sc->sc_dev.dv_xname, x);
}
void
-astslave(struct isa_device *slave, int comunit)
+astslave(dev)
+ struct isa_device *dev;
{
- struct astunit *a = &astunits[slave->id_parent->id_unit];
+ struct ast_softc *sc = &ast_softc[dev->id_parent->id_unit];
- a->slaveunits[slave->id_physid] = comunit;
- a->alive |= 1 << slave->id_physid;
+ sc->sc_slaves[dev->id_physid] = dev->id_unit;
+ sc->sc_alive |= 1 << dev->id_physid;
}
int
-astintr(int unit)
+astintr(unit)
+ int unit;
{
- struct astunit *a = &astunits[unit];
- u_short iobase = a->iobase;
- int alive = a->alive;
+ struct ast_softc *sc = &ast_softc[unit];
+ u_short iobase = sc->sc_iobase;
+ int alive = sc->sc_alive;
int bits;
+ bits = inb(iobase | 0x1f) & alive;
+ if (bits == alive)
+ return 0;
+
do {
- bits = inb (iobase | 0x1f) & alive;
-#define TRY(I) ((bits & (1 << (I))) ? 0 : comintr (a->slaveunits[I]))
- TRY (0), TRY (1), TRY (2), TRY (3);
- /* XXX -- i think the next 4 are bogus, see above -- cgd */
- TRY (4), TRY (5), TRY (6), TRY (7);
-#undef TRY
+#define TRY(n) \
+ if ((bits & (1 << (n))) == 0) \
+ comintr(sc->sc_slaves[n]); /* XXX softc ptr */
+ TRY(0);
+ TRY(1);
+ TRY(2);
+ TRY(3);
+ TRY(4);
+ TRY(5);
+ TRY(6);
+ TRY(7);
+ bits = inb(iobase | 0x1f) & alive;
} while (bits != alive);
return 1;
diff --git a/sys/dev/isa/com.c b/sys/dev/isa/com.c
index fb7529eccc6..0ca439f9f19 100644
--- a/sys/dev/isa/com.c
+++ b/sys/dev/isa/com.c
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
- * $Id: com.c,v 1.26 1994/03/23 01:28:23 cgd Exp $
+ * $Id: com.c,v 1.27 1994/03/23 03:01:53 mycroft Exp $
*/
/*
@@ -157,13 +157,13 @@ comprobe1(iobase)
}
int
-comprobe(isa_dev)
- struct isa_device *isa_dev;
+comprobe(dev)
+ struct isa_device *dev;
{
- struct com_softc *sc = &com_softc[isa_dev->id_unit];
- u_short iobase = isa_dev->id_iobase;
+ struct com_softc *sc = &com_softc[dev->id_unit];
+ u_short iobase = dev->id_iobase;
- if (isa_dev->id_parent) {
+ if (dev->id_parent) {
if (iobase == 0) {
/*
* For multiport cards, the iobase may be left
@@ -172,15 +172,14 @@ comprobe(isa_dev)
* (parent) iobase setting and the slave port
* number (physid).
*/
- iobase = isa_dev->id_iobase
- = isa_dev->id_parent->id_iobase +
- (8 * isa_dev->id_physid);
+ iobase = dev->id_iobase =
+ dev->id_parent->id_iobase + (8 * dev->id_physid);
}
}
/* XXX HACK */
- sprintf(sc->sc_dev.dv_xname, "%s%d", comdriver.name, isa_dev->id_unit);
- sc->sc_dev.dv_unit = isa_dev->id_unit;
+ sprintf(sc->sc_dev.dv_xname, "%s%d", comdriver.name, dev->id_unit);
+ sc->sc_dev.dv_unit = dev->id_unit;
if (!comprobe1(iobase))
return 0;
@@ -189,12 +188,12 @@ comprobe(isa_dev)
}
int
-comattach(isa_dev)
- struct isa_device *isa_dev;
+comattach(dev)
+ struct isa_device *dev;
{
- int unit = isa_dev->id_unit;
+ int unit = dev->id_unit;
struct com_softc *sc = &com_softc[unit];
- u_short iobase = isa_dev->id_iobase;
+ u_short iobase = dev->id_iobase;
struct tty *tp;
if (unit == comconsole)
@@ -208,13 +207,11 @@ comattach(isa_dev)
printf("%s", sc->sc_dev.dv_xname);
#if NAST > 0
- if (isa_dev->id_parent) {
+ if (dev->id_parent) {
printf(" at 0x%x %s%d slave %d",
- isa_dev->id_iobase,
- isa_dev->id_parent->id_driver->name,
- isa_dev->id_parent->id_unit,
- isa_dev->id_physid);
- astslave(isa_dev, unit);
+ dev->id_iobase, dev->id_parent->id_driver->name,
+ dev->id_parent->id_unit, dev->id_physid);
+ astslave(dev);
sc->sc_hwflags |= COM_HW_MULTI;
}
#endif