1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 5 * 2 of the License, or (at your option) any later version. 6 */ 7 #ifndef _ASM_POWERPC_SWAB_H 8 #define _ASM_POWERPC_SWAB_H 9 10 #include <uapi/asm/swab.h> 11 12 static __inline__ __u16 ld_le16(const volatile __u16 *addr) 13 { 14 __u16 val; 15 16 __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr)); 17 return val; 18 } 19 20 static __inline__ void st_le16(volatile __u16 *addr, const __u16 val) 21 { 22 __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr)); 23 } 24 25 static __inline__ __u32 ld_le32(const volatile __u32 *addr) 26 { 27 __u32 val; 28 29 __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr)); 30 return val; 31 } 32 33 static __inline__ void st_le32(volatile __u32 *addr, const __u32 val) 34 { 35 __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr)); 36 } 37 38 #endif /* _ASM_POWERPC_SWAB_H */ 39