ne2k-pci.c fix for Big-Endian processors

Patrick Lerda (LERDA@microprocess.com)
Mon, 6 Sep 1999 11:16:11 +0200


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01BEF848.7BFB5B90
Content-Type: text/plain

> --- 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 lerda@microprocess.com */
>
> /* 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);
>
>

------_=_NextPart_001_01BEF848.7BFB5B90
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
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 = lerda@microprocess.com */
 
 /* Our copyright info = must remain in the binary. */
 static const char = *version =3D
@@ -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 =3D inl(NE_BASE + = NE_DATAPORT);
+       {
+       =         unsigned long = u=3Dinl(NE_BASE + NE_DATAPORT);
+
+       =         /*PL*/ /*endian ok*/
+       =         hdr->status =3D = (u>> 0) & 0xFF;
+       =         hdr->next   =3D = (u>> 8) & 0xFF;
+       =         hdr->count  =3D = (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=3Dinw(NE_BASE + = NE_DATAPORT);
+
+       =         hdr->status =3D = (u>> 0) & 0xFF;
+       =         hdr->next   =3D = (u>> 8) & 0xFF;
+       =         hdr->count  =3D = 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 +=3D count & = ~3;
        =         if (count & 2)
-       =         =         *((u16*)buf)++ =3D = inw(NE_BASE + NE_DATAPORT);
+       =         =         *((u16*)buf)++ =3D = le16_to_cpu(inw(NE_BASE + NE_DATAPORT));
        =         if (count & 1)
        =         =         *buf =3D 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 +=3D 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);


------_=_NextPart_001_01BEF848.7BFB5B90--
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.rutgers.edu