summaryrefslogtreecommitdiff
path: root/sys/dev/isa/if_ie.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-07 07:38:52 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-07 07:38:52 +0000
commita18dd829375e446ca22af98dc283f34da965edbc (patch)
tree0c5bbc9a1a0ce73f792bd62db356a18c8af92e32 /sys/dev/isa/if_ie.c
parentc78ff01b45ca78d491b3e8db520c2cb877a273d4 (diff)
sync with 0504 -- prototypes and bus.h
Diffstat (limited to 'sys/dev/isa/if_ie.c')
-rw-r--r--sys/dev/isa/if_ie.c94
1 files changed, 63 insertions, 31 deletions
diff --git a/sys/dev/isa/if_ie.c b/sys/dev/isa/if_ie.c
index d224f872fb1..8c2926131c8 100644
--- a/sys/dev/isa/if_ie.c
+++ b/sys/dev/isa/if_ie.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: if_ie.c,v 1.8 1996/05/05 13:38:46 mickey Exp $ */
-/* $NetBSD: if_ie.c,v 1.47 1996/04/11 22:29:27 cgd Exp $ */
+/* $OpenBSD: if_ie.c,v 1.9 1996/05/07 07:36:59 deraadt Exp $ */
+/* $NetBSD: if_ie.c,v 1.49 1996/04/30 22:21:54 thorpej Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995 Charles Hannum.
@@ -141,7 +141,8 @@ iomem, and to make 16-pointers, we subtract sc_maddr and and with 0xffff.
#include <vm/vm.h>
#include <machine/cpu.h>
-#include <machine/pio.h>
+#include <machine/pio.h> /* XXX convert this driver! */
+#include <machine/bus.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
@@ -228,8 +229,8 @@ struct ie_softc {
struct arpcom sc_arpcom;
- void (*reset_586)();
- void (*chan_attn)();
+ void (*reset_586) __P((struct ie_softc *));
+ void (*chan_attn) __P((struct ie_softc *));
enum ie_hardware hard_type;
int hard_vers;
@@ -295,6 +296,8 @@ void iememinit __P((void *, struct ie_softc *));
static int mc_setup __P((struct ie_softc *, void *));
static void mc_reset __P((struct ie_softc *));
+vm_offset_t kvtop __P((caddr_t)); /* XXX: Should not use this */
+
#ifdef IEDEBUG
void print_rbd __P((volatile struct ie_recv_buf_desc *));
@@ -302,8 +305,24 @@ int in_ierint = 0;
int in_ietint = 0;
#endif
-int ieprobe __P((struct device *, void *, void *));
-void ieattach __P((struct device *, struct device *, void *));
+int ieprobe __P((struct device *, void *, void *));
+void ieattach __P((struct device *, struct device *, void *));
+int sl_probe __P((struct ie_softc *, struct isa_attach_args *));
+int el_probe __P((struct ie_softc *, struct isa_attach_args *));
+int ee16_probe __P((struct ie_softc *, struct isa_attach_args *));
+int check_ie_present __P((struct ie_softc *, caddr_t, u_int));
+
+static __inline void ie_setup_config __P((volatile struct ie_config_cmd *,
+ int, int));
+static __inline void ie_ack __P((struct ie_softc *, u_int));
+static __inline int ether_equal __P((u_char *, u_char *));
+static __inline int check_eh __P((struct ie_softc *, struct ether_header *,
+ int *));
+static __inline int ie_buflen __P((struct ie_softc *, int));
+static __inline int ie_packet_len __P((struct ie_softc *));
+
+static void chan_attn_timeout __P((void *));
+static void run_tdr __P((struct ie_softc *, struct ie_tdr_cmd *));
struct cfattach ie_ca = {
sizeof(struct ie_softc), ieprobe, ieattach
@@ -323,7 +342,7 @@ struct cfdriver ie_cd = {
* Here are a few useful functions. We could have done these as macros, but
* since we have the inline facility, it makes sense to use that instead.
*/
-static inline void
+static __inline void
ie_setup_config(cmd, promiscuous, manchester)
volatile struct ie_config_cmd *cmd;
int promiscuous, manchester;
@@ -343,7 +362,7 @@ ie_setup_config(cmd, promiscuous, manchester)
cmd->ie_junk = 0xff;
}
-static inline void
+static __inline void
ie_ack(sc, mask)
struct ie_softc *sc;
u_int mask;
@@ -446,8 +465,10 @@ el_probe(sc, ia)
struct ie_softc *sc;
struct isa_attach_args *ia;
{
+ bus_chipset_tag_t bc = ia->ia_bc;
+ bus_io_handle_t ioh;
u_char c;
- int i;
+ int i, rval = 0;
u_char signature[] = "*3COM*";
sc->sc_iobase = ia->ia_iobase;
@@ -456,28 +477,39 @@ el_probe(sc, ia)
sc->reset_586 = el_reset_586;
sc->chan_attn = el_chan_attn;
- /* Reset and put card in CONFIG state without changing address. */
- elink_reset();
- elink_idseq(ELINK_507_POLY);
- elink_idseq(ELINK_507_POLY);
+ /*
+ * Map the Etherlink ID port for the probe sequence.
+ */
+ if (bus_io_map(bc, ELINK_ID_PORT, 1, &ioh)) {
+ printf("3c507 probe: can't map Etherlink ID port\n");
+ return 0;
+ }
+
+ /*
+ * Reset and put card in CONFIG state without changing address.
+ * XXX Indirect brokenness here!
+ */
+ elink_reset(bc, ioh, sc->sc_dev.dv_parent->dv_unit);
+ elink_idseq(bc, ioh, ELINK_507_POLY);
+ elink_idseq(bc, ioh, ELINK_507_POLY);
outb(ELINK_ID_PORT, 0xff);
/* Check for 3COM signature before proceeding. */
outb(PORT + IE507_CTRL, inb(PORT + IE507_CTRL) & 0xfc); /* XXX */
for (i = 0; i < 6; i++)
if (inb(PORT + i) != signature[i])
- return 0;
+ goto out;
c = inb(PORT + IE507_MADDR);
if (c & 0x20) {
printf("%s: can't map 3C507 RAM in high memory\n",
sc->sc_dev.dv_xname);
- return 0;
+ goto out;
}
/* Go to RUN state. */
outb(ELINK_ID_PORT, 0x00);
- elink_idseq(ELINK_507_POLY);
+ elink_idseq(bc, ioh, ELINK_507_POLY);
outb(ELINK_ID_PORT, 0x00);
/* Set bank 2 for version info and read BCD version byte. */
@@ -493,7 +525,7 @@ el_probe(sc, ia)
if (ia->ia_irq != i) {
printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
sc->sc_dev.dv_xname, ia->ia_irq, i);
- return 0;
+ goto out;
}
} else
ia->ia_irq = i;
@@ -504,7 +536,7 @@ el_probe(sc, ia)
if (ia->ia_maddr != i) {
printf("%s: maddr mismatch; kernel configured %x != board configured %x\n",
sc->sc_dev.dv_xname, ia->ia_maddr, i);
- return 0;
+ goto out;
}
} else
ia->ia_maddr = i;
@@ -520,7 +552,7 @@ el_probe(sc, ia)
if (!sc->sc_msize) {
printf("%s: can't find shared memory\n", sc->sc_dev.dv_xname);
outb(PORT + IE507_CTRL, EL_CTRL_NRST);
- return 0;
+ goto out;
}
if (!ia->ia_msize)
@@ -529,7 +561,7 @@ el_probe(sc, ia)
printf("%s: msize mismatch; kernel configured %d != board configured %d\n",
sc->sc_dev.dv_xname, ia->ia_msize, sc->sc_msize);
outb(PORT + IE507_CTRL, EL_CTRL_NRST);
- return 0;
+ goto out;
}
slel_get_address(sc);
@@ -538,7 +570,11 @@ el_probe(sc, ia)
outb(PORT + IE507_ICTRL, 1);
ia->ia_iosize = 16;
- return 1;
+ rval = 1;
+
+ out:
+ bus_io_unmap(bc, ioh, 1);
+ return rval;
}
/* Taken almost exactly from Rod's if_ix.c. */
@@ -549,12 +585,9 @@ ee16_probe(sc, ia)
struct isa_attach_args *ia;
{
int i;
- int cnt_id;
u_short board_id, id_var1, id_var2, checksum = 0;
u_short eaddrtemp, irq;
u_short pg, adjust, decode, edecode;
- u_char lock_bit;
- u_char c;
u_char bart_config;
short irq_translate[] = {0, 0x09, 0x03, 0x04, 0x05, 0x0a, 0x0b, 0};
@@ -982,7 +1015,7 @@ ietint(sc)
* Compare two Ether/802 addresses for equality, inlined and unrolled for
* speed. I'd love to have an inline assembler version of this...
*/
-static inline int
+static __inline int
ether_equal(one, two)
u_char *one, *two;
{
@@ -1005,7 +1038,7 @@ ether_equal(one, two)
* only client which will fiddle with IFF_PROMISC is BPF. This is
* probably a good assumption, but we do not make it here. (Yet.)
*/
-static inline int
+static __inline int
check_eh(sc, eh, to_bpf)
struct ie_softc *sc;
struct ether_header *eh;
@@ -1113,7 +1146,7 @@ check_eh(sc, eh, to_bpf)
* IE_RBUF_SIZE is an even power of two. If somehow the act_len exceeds
* the size of the buffer, then we are screwed anyway.
*/
-static inline int
+static __inline int
ie_buflen(sc, head)
struct ie_softc *sc;
int head;
@@ -1123,7 +1156,7 @@ ie_buflen(sc, head)
& (IE_RBUF_SIZE | (IE_RBUF_SIZE - 1)));
}
-static inline int
+static __inline int
ie_packet_len(sc)
struct ie_softc *sc;
{
@@ -1782,7 +1815,7 @@ iereset(sc)
*/
static void
chan_attn_timeout(rock)
- caddr_t rock;
+ void *rock;
{
*(int *)rock = 1;
@@ -2009,7 +2042,6 @@ ieinit(sc)
{
volatile struct ie_sys_ctl_block *scb = sc->scb;
void *ptr;
- int n;
ptr = (void *)ALIGN(scb + 1);