Title: ne2k-pci.c fix for Big-Endian processors

--- linux-2.2.9-i586/drivers/net/ne2k-pci.c     Mon Jan 25 07:04:02 1999
+++ linux-2.2.9-ppc/drivers/net/ne2k-pci.c      Fri Jun 18 15:07:10 1999
@@ -21,6 +21,7 @@
        Issues remaining:
        No full-duplex support.
 */
+/* Big-Endian support added by Patrick LERDA [EMAIL PROTECTED] */
 
 /* Our copyright info must remain in the binary. */
 static const char *version =
@@ -39,6 +40,7 @@
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>
+#include <asm/byteorder.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -462,9 +464,30 @@
        outb(E8390_RREAD+E8390_START, nic_base + NE_CMD);
 
 #if defined(USE_LONGIO)
-       *(u32*)hdr = inl(NE_BASE + NE_DATAPORT);
+       {
+               unsigned long u=inl(NE_BASE + NE_DATAPORT);
+
+               /*PL*/ /*endian ok*/
+               hdr->status = (u>> 0) & 0xFF;
+               hdr->next   = (u>> 8) & 0xFF;
+               hdr->count  = (u>>16) & 0xFFFF;
+
+#ifdef DEBUG
+               printk("hdr: %02x %02x %04x\n",
+                               hdr->status,hdr->next,hdr->count);
+#endif
+       }
 #else
-       insw(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)>>1);
+       {               /*PL*/ /*endian ok*/
+               u16 u;
+               //insw(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)>>1);
+
+               u=inw(NE_BASE + NE_DATAPORT);
+
+               hdr->status = (u>> 0) & 0xFF;
+               hdr->next   = (u>> 8) & 0xFF;
+               hdr->count  = inw(NE_BASE + NE_DATAPORT);
+       }
 #endif
 
        outb(ENISR_RDC, nic_base + EN0_ISR);    /* Ack intr. */
@@ -500,10 +523,11 @@
 
 #if defined(USE_LONGIO)
        insl(NE_BASE + NE_DATAPORT, buf, count>>2);
+
        if (count & 3) {
                buf += count & ~3;
                if (count & 2)
-                       *((u16*)buf)++ = inw(NE_BASE + NE_DATAPORT);
+                       *((u16*)buf)++ = le16_to_cpu(inw(NE_BASE + NE_DATAPORT));
                if (count & 1)
                        *buf = inb(NE_BASE + NE_DATAPORT);
        }
@@ -563,10 +587,11 @@
        outb(E8390_RWRITE+E8390_START, nic_base + NE_CMD);
 #if defined(USE_LONGIO)
        outsl(NE_BASE + NE_DATAPORT, buf, count>>2);
+
        if (count & 3) {
                buf += count & ~3;
                if (count & 2)
-                       outw(*((u16*)buf)++, NE_BASE + NE_DATAPORT);
+                       outw(cpu_to_le16(*((u16*)buf)++), NE_BASE + NE_DATAPORT);
        }
 #else
        outsw(NE_BASE + NE_DATAPORT, buf, count>>1);


Reply via email to