~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/asm-ppc/byteorder.h

Version: ~ [ linux-6.2-rc3 ] ~ [ linux-6.1.5 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.87 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.162 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.228 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.269 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.302 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef _PPC_BYTEORDER_H
  2 #define _PPC_BYTEORDER_H
  3 
  4 #include <asm/types.h>
  5 #include <linux/compiler.h>
  6 
  7 #ifdef __GNUC__
  8 #ifdef __KERNEL__
  9 
 10 extern __inline__ unsigned ld_le16(const volatile unsigned short *addr)
 11 {
 12         unsigned val;
 13 
 14         __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
 15         return val;
 16 }
 17 
 18 extern __inline__ void st_le16(volatile unsigned short *addr, const unsigned val)
 19 {
 20         __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
 21 }
 22 
 23 extern __inline__ unsigned ld_le32(const volatile unsigned *addr)
 24 {
 25         unsigned val;
 26 
 27         __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
 28         return val;
 29 }
 30 
 31 extern __inline__ void st_le32(volatile unsigned *addr, const unsigned val)
 32 {
 33         __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
 34 }
 35 
 36 extern __inline__ unsigned long long ld_le64(const volatile unsigned long long *addr)
 37 {
 38         unsigned char *taddr = (unsigned char *) addr;
 39         unsigned long long val;
 40 
 41         __asm__ __volatile__ ("lwbrx %L0,0,%1" : "=r" (val) : "r" (taddr),   "m" (*addr));
 42         __asm__ __volatile__ ("lwbrx  %0,0,%1" : "=r" (val) : "r" (taddr+4), "m" (*addr), "" (val));
 43         return val;
 44 }
 45 
 46 extern __inline__ void st_le64(volatile unsigned long long *addr, const unsigned long long val)
 47 {
 48         unsigned char *taddr = (unsigned char *) addr;
 49 
 50         __asm__ __volatile__ ("stwbrx %L1,0,%2" : "=m" (*addr) : "r" (val), "r" (taddr));
 51         __asm__ __volatile__ ("stwbrx  %1,0,%2" : "=m" (*addr) : "r" (val), "r" (taddr+4));
 52 }
 53 
 54 static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 value)
 55 {
 56         __u16 result;
 57 
 58         __asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "" (value >> 8), "r" (value));
 59         return result;
 60 }
 61 
 62 static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 value)
 63 {
 64         __u32 result;
 65 
 66         __asm__("rlwimi %0,%2,24,16,23" : "=&r" (result) : "" (value>>24), "r" (value));
 67         __asm__("rlwimi %0,%2,8,8,15"   : "=&r" (result) : "" (result),    "r" (value));
 68         __asm__("rlwimi %0,%2,24,0,7"   : "=&r" (result) : "" (result),    "r" (value));
 69 
 70         return result;
 71 }
 72 #define __arch__swab32(x) ___arch__swab32(x)
 73 #define __arch__swab16(x) ___arch__swab16(x)
 74 
 75 /* The same, but returns converted value from the location pointer by addr. */
 76 #define __arch__swab16p(addr) ld_le16(addr)
 77 #define __arch__swab32p(addr) ld_le32(addr)
 78 #define __arch__swab64p(addr) ld_le64(addr)
 79 
 80 /* The same, but do the conversion in situ, ie. put the value back to addr. */
 81 #define __arch__swab16s(addr) st_le16(addr,*addr)
 82 #define __arch__swab32s(addr) st_le32(addr,*addr)
 83 #define __arch__swab64s(addr) st_le64(addr,*addr)
 84 
 85 #endif /* __KERNEL__ */
 86 
 87 #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
 88 #  define __BYTEORDER_HAS_U64__
 89 #  define __SWAB_64_THRU_32__
 90 #endif
 91 
 92 #endif /* __GNUC__ */
 93 
 94 #include <linux/byteorder/big_endian.h>
 95 
 96 #endif /* _PPC_BYTEORDER_H */
 97 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp