summaryrefslogtreecommitdiff
path: root/sys/dev/isa/if_ed.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-26 00:27:57 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-26 00:27:57 +0000
commit729a9d7ceffba9e7e741540048479eed9907601e (patch)
tree716f1614729ffc0b602e2fdfece3bc84b3e930b1 /sys/dev/isa/if_ed.c
parent8102ec86d426fccfffa292d80d3e50914c22a932 (diff)
sync 0521
Diffstat (limited to 'sys/dev/isa/if_ed.c')
-rw-r--r--sys/dev/isa/if_ed.c164
1 files changed, 116 insertions, 48 deletions
diff --git a/sys/dev/isa/if_ed.c b/sys/dev/isa/if_ed.c
index d520b509d41..cd989034f91 100644
--- a/sys/dev/isa/if_ed.c
+++ b/sys/dev/isa/if_ed.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: if_ed.c,v 1.15 1996/05/10 12:41:16 deraadt Exp $ */
-/* $NetBSD: if_ed.c,v 1.98 1996/05/07 01:55:13 thorpej Exp $ */
+/* $OpenBSD: if_ed.c,v 1.16 1996/05/26 00:27:17 deraadt Exp $ */
+/* $NetBSD: if_ed.c,v 1.100 1996/05/12 23:52:19 mycroft Exp $ */
/*
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@@ -50,6 +50,7 @@
#include <machine/cpu.h>
#include <machine/bus.h>
+#include <machine/intr.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
@@ -456,7 +457,7 @@ ed_find_WD80x3(sc, cf, ia)
bus_mem_handle_t memh;
u_int memsize;
u_char iptr, isa16bit, sum;
- int i, rv, mapped_mem = 0;
+ int i, rv, memfail, mapped_mem = 0;
int asicbase, nicbase;
bc = ia->ia_bc;
@@ -795,25 +796,47 @@ ed_find_WD80x3(sc, cf, ia)
(void) bus_io_read_1(bc, delayioh, 0);
/* Now zero memory and verify that it is clear. */
- for (i = 0; i < memsize; ++i)
- bus_mem_write_1(bc, memh, sc->mem_start + i, 0);
-
- for (i = 0; i < memsize; ++i)
- if (bus_mem_read_1(bc, memh, sc->mem_start + i)) {
- printf("%s: failed to clear shared memory at %x - check configuration\n",
- sc->sc_dev.dv_xname,
- (ia->ia_maddr + sc->mem_start + i));
+ if (isa16bit) {
+ for (i = 0; i < memsize; i += 2)
+ bus_mem_write_2(bc, memh, sc->mem_start + i, 0);
+ } else {
+ for (i = 0; i < memsize; ++i)
+ bus_mem_write_1(bc, memh, sc->mem_start + i, 0);
+ }
- /* Disable 16 bit access to shared memory. */
- bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR,
- sc->wd_msr_proto);
- if (isa16bit)
- bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR,
- sc->wd_laar_proto);
- (void) bus_io_read_1(bc, delayioh, 0);
- (void) bus_io_read_1(bc, delayioh, 0);
- goto out;
+ memfail = 0;
+ if (isa16bit) {
+ for (i = 0; i < memsize; i += 2) {
+ if (bus_mem_read_2(bc, memh, sc->mem_start + i)) {
+ memfail = 1;
+ break;
+ }
+ }
+ } else {
+ for (i = 0; i < memsize; ++i) {
+ if (bus_mem_read_1(bc, memh, sc->mem_start + i)) {
+ memfail = 1;
+ break;
+ }
}
+ }
+
+ if (memfail) {
+ printf("%s: failed to clear shared memory at %x - "
+ "check configuration\n",
+ sc->sc_dev.dv_xname,
+ (ia->ia_maddr + sc->mem_start + i));
+
+ /* Disable 16 bit access to shared memory. */
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR,
+ sc->wd_msr_proto);
+ if (isa16bit)
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR,
+ sc->wd_laar_proto);
+ (void) bus_io_read_1(bc, delayioh, 0);
+ (void) bus_io_read_1(bc, delayioh, 0);
+ goto out;
+ }
/*
* Disable 16bit access to shared memory - we leave it disabled
@@ -869,8 +892,8 @@ ed_find_3Com(sc, cf, ia)
bus_chipset_tag_t bc;
bus_io_handle_t ioh;
bus_mem_handle_t memh;
- int i;
- u_int memsize;
+ int i, rv, mapped_mem = 0;
+ u_int memsize, memfail;
u_char isa16bit, x;
int ptr, asicbase, nicbase;
@@ -880,7 +903,6 @@ ed_find_3Com(sc, cf, ia)
*/
memsize = 8192;
-
bc = ia->ia_bc;
if (bus_io_map(bc, ia->ia_iobase, ED_WD_IO_PORTS, &ioh))
@@ -1100,17 +1122,39 @@ ed_find_3Com(sc, cf, ia)
bus_io_write_1(bc, ioh, asicbase + ED_3COM_VPTR1, 0xff);
bus_io_write_1(bc, ioh, asicbase + ED_3COM_VPTR0, 0x00);
- /* Zero memory and verify that it is clear. */
- for (i = 0; i < memsize; ++i)
- bus_mem_write_1(bc, memh, sc->mem_start + i, 0);
+ /* Now zero memory and verify that it is clear. */
+ if (isa16bit) {
+ for (i = 0; i < memsize; i += 2)
+ bus_mem_write_2(bc, memh, sc->mem_start + i, 0);
+ } else {
+ for (i = 0; i < memsize; ++i)
+ bus_mem_write_1(bc, memh, sc->mem_start + i, 0);
+ }
- for (i = 0; i < memsize; ++i)
- if (bus_mem_read_1(bc, memh, sc->mem_start + i)) {
- printf("%s: failed to clear shared memory at %x - check configuration\n",
- sc->sc_dev.dv_xname,
- (ia->ia_maddr + sc->mem_start + i));
- goto out;
+ memfail = 0;
+ if (isa16bit) {
+ for (i = 0; i < memsize; i += 2) {
+ if (bus_mem_read_2(bc, memh, sc->mem_start + i)) {
+ memfail = 1;
+ break;
+ }
}
+ } else {
+ for (i = 0; i < memsize; ++i) {
+ if (bus_mem_read_1(bc, memh, sc->mem_start + i)) {
+ memfail = 1;
+ break;
+ }
+ }
+ }
+
+ if (memfail) {
+ printf("%s: failed to clear shared memory at %x - "
+ "check configuration\n",
+ sc->sc_dev.dv_xname,
+ (ia->ia_maddr + sc->mem_start + i));
+ goto out;
+ }
ia->ia_msize = memsize;
ia->ia_iosize = ED_3COM_IO_PORTS;
@@ -2706,35 +2750,59 @@ ed_getmcaf(ac, af)
}
void
-ed_shared_writemem(sc, buf, card, len)
+ed_shared_writemem(sc, from, card, len)
struct ed_softc *sc;
- caddr_t buf;
+ caddr_t from;
int card, len;
{
bus_chipset_tag_t bc = sc->sc_bc;
bus_mem_handle_t memh = sc->sc_memh;
- u_int8_t *ptr = (u_int8_t *)buf;
- int i;
- /* XXX should have bus_mem_copyout_{1,2,4,8}() */
-
- for (i = 0; i < len; ++i)
- bus_mem_write_1(bc, memh, card + i, ptr[i]);
+ /*
+ * For 16-bit cards, 16-bit memory access has already
+ * been set up. Note that some cards are really picky
+ * about enforcing 16-bit access to memory, so we
+ * have to be careful.
+ */
+ if (sc->isa16bit) {
+ while (len > 1) {
+ bus_mem_write_2(bc, memh, card,
+ *((u_int16_t *)from));
+ from += 2;
+ card += 2;
+ len -= 2;
+ }
+ if (len == 1)
+ bus_mem_write_2(bc, memh, card, (u_int16_t)(*from));
+ } else {
+ while (len--)
+ bus_mem_write_1(bc, memh, card++, *from++);
+ }
}
void
-ed_shared_readmem(sc, card, buf, len)
+ed_shared_readmem(sc, card, to, len)
struct ed_softc *sc;
- caddr_t buf;
+ caddr_t to;
int card, len;
{
bus_chipset_tag_t bc = sc->sc_bc;
bus_mem_handle_t memh = sc->sc_memh;
- u_int8_t *ptr = (u_int8_t *)buf;
- int i;
- /* XXX should have bus_mem_copyin_{1,2,4,8}() */
-
- for (i = 0; i < len; ++i)
- ptr[i] = bus_mem_read_1(bc, memh, card + i);
+ /*
+ * See comment above re. 16-bit cards.
+ */
+ if (sc->isa16bit) {
+ while (len > 1) {
+ *((u_int16_t *)to) = bus_mem_read_2(bc, memh, card);
+ to += 2;
+ card += 2;
+ len -= 2;
+ }
+ if (len == 1)
+ *to = bus_mem_read_2(bc, memh, card) & 0xff;
+ } else {
+ while (len--)
+ *to++ = bus_mem_read_1(bc, memh, card++);
+ }
}