Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  arch/arm/include/asm/byteorder.h
0004  *
0005  * ARM Endian-ness.  In little endian mode, the data bus is connected such
0006  * that byte accesses appear as:
0007  *  0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31
0008  * and word accesses (data or instruction) appear as:
0009  *  d0...d31
0010  *
0011  * When in big endian mode, byte accesses appear as:
0012  *  0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7
0013  * and word accesses (data or instruction) appear as:
0014  *  d0...d31
0015  */
0016 #ifndef __ASM_ARM_SWAB_H
0017 #define __ASM_ARM_SWAB_H
0018 
0019 #include <uapi/asm/swab.h>
0020 
0021 #if __LINUX_ARM_ARCH__ >= 6
0022 
0023 static inline __attribute_const__ __u32 __arch_swahb32(__u32 x)
0024 {
0025     __asm__ ("rev16 %0, %1" : "=r" (x) : "r" (x));
0026     return x;
0027 }
0028 #define __arch_swahb32 __arch_swahb32
0029 #define __arch_swab16(x) ((__u16)__arch_swahb32(x))
0030 
0031 static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
0032 {
0033     __asm__ ("rev %0, %1" : "=r" (x) : "r" (x));
0034     return x;
0035 }
0036 #define __arch_swab32 __arch_swab32
0037 
0038 #endif
0039 #endif