patch-2.3.18 linux/arch/sparc64/lib/PeeCeeI.c
Next file: linux/arch/sparc64/lib/debuglocks.c
Previous file: linux/arch/sparc64/kernel/ttable.S
Back to the patch index
Back to the overall index
- Lines: 264
- Date:
Wed Sep 8 11:14:32 1999
- Orig file:
v2.3.17/linux/arch/sparc64/lib/PeeCeeI.c
- Orig date:
Thu Sep 4 12:54:48 1997
diff -u --recursive --new-file v2.3.17/linux/arch/sparc64/lib/PeeCeeI.c linux/arch/sparc64/lib/PeeCeeI.c
@@ -1,4 +1,4 @@
-/* $Id: PeeCeeI.c,v 1.3 1997/08/28 23:59:52 davem Exp $
+/* $Id: PeeCeeI.c,v 1.4 1999/09/06 01:17:35 davem Exp $
* PeeCeeI.c: The emerging standard...
*
* Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
@@ -9,6 +9,7 @@
#ifdef CONFIG_PCI
#include <asm/io.h>
+#include <asm/byteorder.h>
void outsb(unsigned long addr, const void *src, unsigned long count)
{
@@ -21,25 +22,29 @@
void outsw(unsigned long addr, const void *src, unsigned long count)
{
if(count) {
- const u16 *ps = src;
- const u32 *pi;
+ u16 *ps = (u16 *)src;
+ u32 *pi;
if(((u64)src) & 0x2) {
- outw(*ps++, addr);
+ u16 val = le16_to_cpup(ps);
+ outw(val, addr);
+ ps++;
count--;
}
- pi = (const u32 *)ps;
+ pi = (u32 *)ps;
while(count >= 2) {
- u32 w;
+ u32 w = le32_to_cpup(pi);
- w = *pi++;
+ pi++;
+ outw(w >> 0, addr);
outw(w >> 16, addr);
- outw(w, addr);
count -= 2;
}
- ps = (const u16 *)pi;
- if(count)
- outw(*ps, addr);
+ ps = (u16 *)pi;
+ if(count) {
+ u16 val = le16_to_cpup(ps);
+ outw(val, addr);
+ }
}
}
@@ -47,60 +52,71 @@
{
if(count) {
if((((u64)src) & 0x3) == 0) {
- const u32 *p = src;
- while(count--)
- outl(*p++, addr);
+ u32 *p = (u32 *)src;
+ while(count--) {
+ u32 val = cpu_to_le32p(p);
+ outl(val, addr);
+ p++;
+ }
} else {
- const u8 *pb;
- const u16 *ps = src;
+ u8 *pb;
+ u16 *ps = (u16 *)src;
u32 l = 0, l2;
- const u32 *pi;
+ u32 *pi;
switch(((u64)src) & 0x3) {
case 0x2:
count -= 1;
- l = *ps++;
- pi = (const u32 *)ps;
+ l = cpu_to_le16p(ps) << 16;
+ ps++;
+ pi = (u32 *)ps;
while(count--) {
- l2 = *pi++;
- outl(((l <<16) | (l2 >> 16)), addr);
+ l2 = cpu_to_le32p(pi);
+ pi++;
+ outl(((l >> 16) | (l2 << 16)), addr);
l = l2;
}
- ps = (const u16 *)pi;
- outl(((l << 16) | (*ps >> 16)), addr);
+ ps = (u16 *)pi;
+ l2 = cpu_to_le16p(ps);
+ outl(((l >> 16) | (l2 << 16)), addr);
break;
case 0x1:
count -= 1;
- pb = src;
- l = (*pb++ << 16);
- ps = (const u16 *)pb;
- l |= *ps++;
- pi = (const u32 *)ps;
+ pb = (u8 *)src;
+ l = (*pb++ << 8);
+ ps = (u16 *)pb;
+ l2 = cpu_to_le16p(ps);
+ ps++;
+ l |= (l2 << 16);
+ pi = (u32 *)ps;
while(count--) {
- l2 = *pi++;
- outl(((l << 8) | (l2 >> 24)), addr);
+ l2 = cpu_to_le32p(pi);
+ pi++;
+ outl(((l >> 8) | (l2 << 24)), addr);
l = l2;
}
- pb = (const u8 *)pi;
- outl(((l << 8) | (*pb >> 24)), addr);
+ pb = (u8 *)pi;
+ outl(((l >> 8) | (*pb << 24)), addr);
break;
case 0x3:
count -= 1;
- pb = src;
- l = (*pb++ >> 24);
- pi = (const u32 *)pb;
- while(count--) {
- l2 = *pi++;
- outl(((l << 24) | (l2 >> 8)), addr);
+ pb = (u8 *)src;
+ l = (*pb++ << 24);
+ pi = (u32 *)pb;
+ while(count--) {
+ l2 = cpu_to_le32p(pi);
+ pi++;
+ outl(((l >> 24) | (l2 << 8)), addr);
l = l2;
}
- ps = (const u16 *)pi;
- l2 = (*ps++ << 16);
- pb = (const u8 *)ps;
- l2 |= (*pb << 8);
- outl(((l << 24) | (l2 >> 8)), addr);
+ ps = (u16 *)pi;
+ l2 = cpu_to_le16p(ps);
+ ps++;
+ pb = (u8 *)ps;
+ l2 |= (*pb << 16);
+ outl(((l >> 24) | (l2 << 8)), addr);
break;
}
}
@@ -122,7 +138,7 @@
w = (inb(addr) << 24);
w |= (inb(addr) << 16);
w |= (inb(addr) << 8);
- w |= inb(addr);
+ w |= (inb(addr) << 0);
*pi++ = w;
count -= 4;
}
@@ -139,21 +155,21 @@
u32 *pi;
if(((unsigned long)ps) & 0x2) {
- *ps++ = inw(addr);
+ *ps++ = le16_to_cpu(inw(addr));
count--;
}
pi = (u32 *)ps;
while(count >= 2) {
u32 w;
- w = (inw(addr) << 16);
- w |= inw(addr);
+ w = (le16_to_cpu(inw(addr)) << 16);
+ w |= (le16_to_cpu(inw(addr)) << 0);
*pi++ = w;
count -= 2;
}
ps = (u16 *)pi;
if(count)
- *ps = inw(addr);
+ *ps = le16_to_cpu(inw(addr));
}
}
@@ -163,7 +179,7 @@
if((((unsigned long)dst) & 0x3) == 0) {
u32 *pi = dst;
while(count--)
- *pi++ = inl(addr);
+ *pi++ = le32_to_cpu(inl(addr));
} else {
u32 l = 0, l2, *pi;
u16 *ps;
@@ -173,47 +189,48 @@
case 0x2:
ps = dst;
count -= 1;
- l = inl(addr);
- *ps++ = (l >> 16);
+ l = le32_to_cpu(inl(addr));
+ *ps++ = l;
pi = (u32 *)ps;
while(count--) {
- l2 = inl(addr);
+ l2 = le32_to_cpu(inl(addr));
*pi++ = (l << 16) | (l2 >> 16);
l = l2;
}
ps = (u16 *)pi;
- *ps = (l << 16);
+ *ps = l;
break;
case 0x1:
pb = dst;
count -= 1;
- *pb++ = (l >> 24);
+ l = le32_to_cpu(inl(addr));
+ *pb++ = l >> 24;
ps = (u16 *)pb;
- *ps++ = (l >> 8);
+ *ps++ = ((l >> 8) & 0xffff);
pi = (u32 *)ps;
while(count--) {
- l2 = inl(addr);
- *pi++ = ((l << 24) | (l2 >> 8));
+ l2 = le32_to_cpu(inl(addr));
+ *pi++ = (l << 24) | (l2 >> 8);
l = l2;
}
pb = (u8 *)pi;
- *pb = (l >> 8);
+ *pb = l;
break;
case 0x3:
pb = (u8 *)dst;
count -= 1;
- l = inl(addr);
+ l = le32_to_cpu(inl(addr));
*pb++ = l >> 24;
pi = (u32 *)pb;
while(count--) {
- l2 = inl(addr);
- *pi++ = ((l >> 24) | (l2 << 8));
+ l2 = le32_to_cpu(inl(addr));
+ *pi++ = (l << 8) | (l2 >> 24);
l = l2;
}
ps = (u16 *)pi;
- *ps++ = l >> 8;
+ *ps++ = ((l >> 8) & 0xffff);
pb = (u8 *)ps;
*pb = l;
break;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)