patch-2.4.21 linux-2.4.21/include/asm-ppc/byteorder.h
Next file: linux-2.4.21/include/asm-ppc/cache.h
Previous file: linux-2.4.21/include/asm-ppc/bugs.h
Back to the patch index
Back to the overall index
- Lines: 75
- Date:
2003-06-13 07:51:38.000000000 -0700
- Orig file:
linux-2.4.20/include/asm-ppc/byteorder.h
- Orig date:
2001-11-02 17:43:54.000000000 -0800
diff -urN linux-2.4.20/include/asm-ppc/byteorder.h linux-2.4.21/include/asm-ppc/byteorder.h
@@ -1,6 +1,3 @@
-/*
- * BK Id: SCCS/s.byteorder.h 1.8 10/11/01 13:02:49 trini
- */
#ifndef _PPC_BYTEORDER_H
#define _PPC_BYTEORDER_H
@@ -35,17 +32,29 @@
__asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
}
-/* alas, egcs sounds like it has a bug in this code that doesn't use the
- inline asm correctly, and can cause file corruption. Until I hear that
- it's fixed, I can live without the extra speed. I hope. */
-#if 0
+extern __inline__ unsigned long long ld_le64(const volatile unsigned long long *addr)
+{
+ unsigned char *taddr = (unsigned char *) addr;
+ unsigned long long val;
+
+ __asm__ __volatile__ ("lwbrx %L0,0,%1" : "=r" (val) : "r" (taddr), "m" (*addr));
+ __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (taddr+4), "m" (*addr), "0" (val));
+ return val;
+}
+
+extern __inline__ void st_le64(volatile unsigned long long *addr, const unsigned long long val)
+{
+ unsigned char *taddr = (unsigned char *) addr;
+
+ __asm__ __volatile__ ("stwbrx %L1,0,%2" : "=m" (*addr) : "r" (val), "r" (taddr));
+ __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (taddr+4));
+}
+
static __inline__ __const__ __u16 ___arch__swab16(__u16 value)
{
__u16 result;
- __asm__("rlwimi %0,%1,8,16,23"
- : "=r" (result)
- : "r" (value), "0" (value >> 8));
+ __asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "0" (value >> 8), "r" (value));
return result;
}
@@ -53,24 +62,24 @@
{
__u32 result;
- __asm__("rlwimi %0,%1,24,16,23\n\t"
- "rlwimi %0,%1,8,8,15\n\t"
- "rlwimi %0,%1,24,0,7"
- : "=r" (result)
- : "r" (value), "0" (value >> 24));
+ __asm__("rlwimi %0,%2,24,16,23" : "=&r" (result) : "0" (value>>24), "r" (value));
+ __asm__("rlwimi %0,%2,8,8,15" : "=&r" (result) : "0" (result), "r" (value));
+ __asm__("rlwimi %0,%2,24,0,7" : "=&r" (result) : "0" (result), "r" (value));
+
return result;
}
#define __arch__swab32(x) ___arch__swab32(x)
#define __arch__swab16(x) ___arch__swab16(x)
-#endif /* 0 */
/* The same, but returns converted value from the location pointer by addr. */
#define __arch__swab16p(addr) ld_le16(addr)
#define __arch__swab32p(addr) ld_le32(addr)
+#define __arch__swab64p(addr) ld_le64(addr)
/* The same, but do the conversion in situ, ie. put the value back to addr. */
#define __arch__swab16s(addr) st_le16(addr,*addr)
#define __arch__swab32s(addr) st_le32(addr,*addr)
+#define __arch__swab64s(addr) st_le64(addr,*addr)
#endif /* __KERNEL__ */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)