summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/amiga/isa/if_isaed.c161
1 files changed, 114 insertions, 47 deletions
diff --git a/sys/arch/amiga/isa/if_isaed.c b/sys/arch/amiga/isa/if_isaed.c
index 2071636a382..a4ae597e151 100644
--- a/sys/arch/amiga/isa/if_isaed.c
+++ b/sys/arch/amiga/isa/if_isaed.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: if_isaed.c,v 1.7 1996/05/28 09:39:39 niklas Exp $ */
+/* $OpenBSD: if_isaed.c,v 1.8 1996/06/02 18:27:43 niklas Exp $ */
/*
* Derived from sys/dev/isa/if_ed.c:
- * $NetBSD: if_ed.c,v 1.98 1996/05/07 01:55:13 thorpej Exp $
+ * $NetBSD: if_ed.c,v 1.100 1996/05/12 23:52:19 mycroft Exp $
*/
/*
@@ -467,7 +467,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;
@@ -806,25 +806,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
@@ -881,7 +903,7 @@ ed_find_3Com(sc, cf, ia)
bus_io_handle_t ioh;
bus_mem_handle_t memh;
int i;
- u_int memsize;
+ u_int memsize, memfail;
u_char isa16bit, x;
int ptr, asicbase, nicbase;
@@ -891,7 +913,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))
@@ -1111,17 +1132,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;
@@ -2718,35 +2761,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++);
+ }
}