Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Fix two endian problems. rtk now works on macppc.



details:   https://anonhg.NetBSD.org/src/rev/4885fa0d7881
branches:  trunk
changeset: 485344:4885fa0d7881
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Tue Apr 25 14:16:46 2000 +0000

description:
Fix two endian problems. rtk now works on macppc.

- Use le32toh() on reading rxstat from the Rx DMA buffer.
- rl_read_eeprom() should return EEPROM values in little endian
  when caller requires byte-stream data.

bus_dma(9) fixes are still on-going.

XXX rtk on macppc seems to make tons of CRC errors...
XXX Does it work fine on i386 or others?

diffstat:

 sys/dev/ic/rtl81x9.c    |  13 ++++++++++---
 sys/dev/pci/if_rl_pci.c |   4 ++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diffs (59 lines):

diff -r 9b58b17672d0 -r 4885fa0d7881 sys/dev/ic/rtl81x9.c
--- a/sys/dev/ic/rtl81x9.c      Tue Apr 25 14:08:45 2000 +0000
+++ b/sys/dev/ic/rtl81x9.c      Tue Apr 25 14:16:46 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtl81x9.c,v 1.2 2000/04/24 15:25:00 tsutsui Exp $      */
+/*     $NetBSD: rtl81x9.c,v 1.3 2000/04/25 14:16:46 tsutsui Exp $      */
 
 /*
  * Copyright (c) 1997, 1998
@@ -122,6 +122,7 @@
 #endif
 
 #include <machine/bus.h>
+#include <machine/endian.h>
 
 #include <dev/mii/mii.h>
 #include <dev/mii/miivar.h>
@@ -272,7 +273,13 @@
                rl_eeprom_getword(sc, off + i, &word);
                ptr = (u_int16_t *)(dest + (i * 2));
                if (swap)
-                       *ptr = ntohs(word);
+               /*
+                * EEPROM stores data in little endian and
+                * rl_eeprom_getword() returns them in host's endian.
+                * If caller requires byte-stream data, we should
+                * revert them little endian.
+                */
+                       *ptr = htole16(word);
                else
                        *ptr = word;
        }
@@ -866,7 +873,7 @@
 
        while((CSR_READ_1(sc, RL_COMMAND) & RL_CMD_EMPTY_RXBUF) == 0) {
                rxbufpos = sc->rl_cdata.rl_rx_buf + cur_rx;
-               rxstat = *(u_int32_t *)rxbufpos;
+               rxstat = le32toh(*(u_int32_t *)rxbufpos);
 
                /*
                 * Here's a totally undocumented fact for you. When the
diff -r 9b58b17672d0 -r 4885fa0d7881 sys/dev/pci/if_rl_pci.c
--- a/sys/dev/pci/if_rl_pci.c   Tue Apr 25 14:08:45 2000 +0000
+++ b/sys/dev/pci/if_rl_pci.c   Tue Apr 25 14:16:46 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_rl_pci.c,v 1.3 2000/04/24 15:25:00 tsutsui Exp $ */
+/* $NetBSD: if_rl_pci.c,v 1.4 2000/04/25 14:16:47 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1997, 1998
@@ -325,7 +325,7 @@
        /*
         * Get station address from the EEPROM.
         */
-       rl_read_eeprom(sc, (caddr_t)&eaddr, RL_EE_EADDR, 3, 0);
+       rl_read_eeprom(sc, (caddr_t)&eaddr, RL_EE_EADDR, 3, 1);
 
        /*
         * A RealTek chip was detected. Inform the world.



Home | Main Index | Thread Index | Old Index