diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-08-03 07:16:37 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-08-03 07:16:37 +0000 |
commit | c116a6c57abf4e5b0ffeb673b7fde1d7954ad4f7 (patch) | |
tree | b297eaa236c67ecd48b6e11eff4151c95c801bed /sys/arch | |
parent | 167d667956fe3ef144471dff1756e01a4e8800b1 (diff) |
Bring in last change from dev/isa/if_ed.c
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amiga/isa/if_isaed.c | 83 |
1 files changed, 44 insertions, 39 deletions
diff --git a/sys/arch/amiga/isa/if_isaed.c b/sys/arch/amiga/isa/if_isaed.c index a4ae597e151..a8c383ac7ef 100644 --- a/sys/arch/amiga/isa/if_isaed.c +++ b/sys/arch/amiga/isa/if_isaed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_isaed.c,v 1.8 1996/06/02 18:27:43 niklas Exp $ */ +/* $OpenBSD: if_isaed.c,v 1.9 1996/08/03 07:16:36 niklas Exp $ */ /* * Derived from sys/dev/isa/if_ed.c: @@ -58,7 +58,6 @@ #include <dev/isa/isareg.h> #include <dev/isa/isavar.h> -#define ED_BYTE_ORDER LITTLE_ENDIAN #include <dev/ic/dp8390reg.h> #include <dev/isa/if_edreg.h> @@ -1913,10 +1912,13 @@ ed_rint(sc) bus_chipset_tag_t bc = sc->sc_bc; bus_io_handle_t ioh = sc->sc_ioh; int nicbase = sc->nic_base; - u_char boundary, current; - u_short len; - u_char nlen; - struct ed_ring packet_hdr; + u_int8_t boundary, current; + u_int16_t len; + u_int8_t nlen; + u_int8_t next_packet; /* pointer to next packet */ + u_int8_t rsr; /* receiver status */ + u_int16_t count; /* bytes in packet (length + 4) */ + u_int8_t packet_hdr[ED_RING_HDRSZ]; int packet_ptr; loop: @@ -1950,12 +1952,15 @@ loop: * the NIC. */ if (sc->mem_shared) - ed_shared_readmem(sc, packet_ptr, (caddr_t)&packet_hdr, + ed_shared_readmem(sc, packet_ptr, packet_hdr, sizeof(packet_hdr)); else - ed_pio_readmem(sc, (long)packet_ptr, - (caddr_t)&packet_hdr, sizeof(packet_hdr)); - len = bus_to_host_2(bc, packet_hdr.count); + ed_pio_readmem(sc, (long)packet_ptr, packet_hdr, + sizeof(packet_hdr)); + rsr = packet_hdr[ED_RING_RSR]; + next_packet = packet_hdr[ED_RING_NEXT_PACKET]; + len = count = packet_hdr[ED_RING_COUNT] + + 256 * packet_hdr[ED_RING_COUNT + 1]; /* * Try do deal with old, buggy chips that sometimes duplicate @@ -1965,24 +1970,23 @@ loop: * * NOTE: sc->next_packet is pointing at the current packet. */ - if (packet_hdr.next_packet >= sc->next_packet) - nlen = (packet_hdr.next_packet - sc->next_packet); + if (next_packet >= sc->next_packet) + nlen = (next_packet - sc->next_packet); else - nlen = ((packet_hdr.next_packet - sc->rec_page_start) + + nlen = ((next_packet - sc->rec_page_start) + (sc->rec_page_stop - sc->next_packet)); --nlen; if ((len & ED_PAGE_MASK) + sizeof(packet_hdr) > ED_PAGE_SIZE) --nlen; len = (len & ED_PAGE_MASK) | (nlen << ED_PAGE_SHIFT); #ifdef DIAGNOSTIC - if (len != bus_to_host_2(bc, packet_hdr.count)) { + if (len != count) { printf("%s: length does not match next packet pointer\n", sc->sc_dev.dv_xname); printf("%s: len %04x nlen %04x start %02x first %02x curr %02x next %02x stop %02x\n", - sc->sc_dev.dv_xname, - bus_to_host_2(bc, packet_hdr.count), len, + sc->sc_dev.dv_xname, count, len, sc->rec_page_start, sc->next_packet, current, - packet_hdr.next_packet, sc->rec_page_stop); + next_packet, sc->rec_page_stop); } #endif @@ -1995,11 +1999,11 @@ loop: * figure out the length from their own length field(s). */ if (len <= MCLBYTES && - packet_hdr.next_packet >= sc->rec_page_start && - packet_hdr.next_packet < sc->rec_page_stop) { + next_packet >= sc->rec_page_start && + next_packet < sc->rec_page_stop) { /* Go get packet. */ - edread(sc, packet_ptr + sizeof(struct ed_ring), - len - sizeof(struct ed_ring)); + edread(sc, packet_ptr + ED_RING_HDRSZ, + len - ED_RING_HDRSZ); } else { /* Really BAD. The ring pointers are corrupted. */ log(LOG_ERR, @@ -2011,7 +2015,7 @@ loop: } /* Update next packet pointer. */ - sc->next_packet = packet_hdr.next_packet; + sc->next_packet = next_packet; /* * Update NIC boundary pointer - being careful to keep it one @@ -2427,8 +2431,8 @@ ed_pio_readmem(sc, src, dst, amount) ED_CR_RD0 | ED_CR_PAGE_0 | ED_CR_STA); if (sc->isa16bit) - bus_io_read_multi_2(bc, ioh, sc->asic_base + ED_NOVELL_DATA, - (u_int16_t *)dst, amount / 2); + bus_io_read_raw_multi_2(bc, ioh, + sc->asic_base + ED_NOVELL_DATA, dst, amount); else bus_io_read_multi_1(bc, ioh, sc->asic_base + ED_NOVELL_DATA, dst, amount); @@ -2470,8 +2474,8 @@ ed_pio_writemem(sc, src, dst, len) ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA); if (sc->isa16bit) - bus_io_write_multi_2(bc, ioh, sc->asic_base + ED_NOVELL_DATA, - (u_int16_t *)src, len / 2); + bus_io_write_raw_multi_2(bc, ioh, + sc->asic_base + ED_NOVELL_DATA, src, len); else bus_io_write_multi_1(bc, ioh, sc->asic_base + ED_NOVELL_DATA, src, len); @@ -2553,18 +2557,16 @@ ed_pio_write_mbufs(sc, m, dst) /* Finish the last word. */ if (wantbyte) { savebyte[1] = *data; - bus_io_write_2(bc, ioh, - asicbase + ED_NOVELL_DATA, - *(u_int16_t *)savebyte); + bus_io_write_raw_multi_2(bc, ioh, + asicbase + ED_NOVELL_DATA, savebyte, 2); data++; len--; wantbyte = 0; } /* Output contiguous words. */ if (len > 1) { - bus_io_write_multi_2(bc, ioh, - asicbase + ED_NOVELL_DATA, - (u_int16_t *)data, len >> 1); + bus_io_write_raw_multi_2(bc, ioh, + asicbase + ED_NOVELL_DATA, data, len & ~1); } /* Save last byte, if necessary. */ if (len & 1) { @@ -2576,8 +2578,8 @@ ed_pio_write_mbufs(sc, m, dst) if (wantbyte) { savebyte[1] = 0; - bus_io_write_2(bc, ioh, asicbase + ED_NOVELL_DATA, - *(u_int16_t *)savebyte); + bus_io_write_raw_multi_2(bc, ioh, + asicbase + ED_NOVELL_DATA, savebyte, 2); } } @@ -2768,6 +2770,7 @@ ed_shared_writemem(sc, from, card, len) { bus_chipset_tag_t bc = sc->sc_bc; bus_mem_handle_t memh = sc->sc_memh; + u_int16_t word; /* * For 16-bit cards, 16-bit memory access has already @@ -2777,14 +2780,14 @@ ed_shared_writemem(sc, from, card, len) */ if (sc->isa16bit) { while (len > 1) { - bus_mem_write_2(bc, memh, card, - *((u_int16_t *)from)); + word = (u_int8_t)from[0] | (u_int8_t)from[1] << 8; + bus_mem_write_2(bc, memh, card, word); from += 2; card += 2; len -= 2; } if (len == 1) - bus_mem_write_2(bc, memh, card, (u_int16_t)(*from)); + bus_mem_write_2(bc, memh, card, (u_int16_t)*from); } else { while (len--) bus_mem_write_1(bc, memh, card++, *from++); @@ -2799,14 +2802,16 @@ ed_shared_readmem(sc, card, to, len) { bus_chipset_tag_t bc = sc->sc_bc; bus_mem_handle_t memh = sc->sc_memh; + u_int16_t word; /* * 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; + word = bus_mem_read_2(bc, memh, card); + *to++ = word & 0xff; + *to++ = word >> 8 & 0xff; card += 2; len -= 2; } |