18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  arch/arm/include/asm/byteorder.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * ARM Endian-ness.  In little endian mode, the data bus is connected such
68c2ecf20Sopenharmony_ci * that byte accesses appear as:
78c2ecf20Sopenharmony_ci *  0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31
88c2ecf20Sopenharmony_ci * and word accesses (data or instruction) appear as:
98c2ecf20Sopenharmony_ci *  d0...d31
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * When in big endian mode, byte accesses appear as:
128c2ecf20Sopenharmony_ci *  0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7
138c2ecf20Sopenharmony_ci * and word accesses (data or instruction) appear as:
148c2ecf20Sopenharmony_ci *  d0...d31
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_ci#ifndef __ASM_ARM_SWAB_H
178c2ecf20Sopenharmony_ci#define __ASM_ARM_SWAB_H
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#include <uapi/asm/swab.h>
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#if __LINUX_ARM_ARCH__ >= 6
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_cistatic inline __attribute_const__ __u32 __arch_swahb32(__u32 x)
248c2ecf20Sopenharmony_ci{
258c2ecf20Sopenharmony_ci	__asm__ ("rev16 %0, %1" : "=r" (x) : "r" (x));
268c2ecf20Sopenharmony_ci	return x;
278c2ecf20Sopenharmony_ci}
288c2ecf20Sopenharmony_ci#define __arch_swahb32 __arch_swahb32
298c2ecf20Sopenharmony_ci#define __arch_swab16(x) ((__u16)__arch_swahb32(x))
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistatic inline __attribute_const__ __u32 __arch_swab32(__u32 x)
328c2ecf20Sopenharmony_ci{
338c2ecf20Sopenharmony_ci	__asm__ ("rev %0, %1" : "=r" (x) : "r" (x));
348c2ecf20Sopenharmony_ci	return x;
358c2ecf20Sopenharmony_ci}
368c2ecf20Sopenharmony_ci#define __arch_swab32 __arch_swab32
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#endif
398c2ecf20Sopenharmony_ci#endif
40