swab.h 1005 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * arch/arm/include/asm/byteorder.h
  4. *
  5. * ARM Endian-ness. In little endian mode, the data bus is connected such
  6. * that byte accesses appear as:
  7. * 0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31
  8. * and word accesses (data or instruction) appear as:
  9. * d0...d31
  10. *
  11. * When in big endian mode, byte accesses appear as:
  12. * 0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7
  13. * and word accesses (data or instruction) appear as:
  14. * d0...d31
  15. */
  16. #ifndef __ASM_ARM_SWAB_H
  17. #define __ASM_ARM_SWAB_H
  18. #include <uapi/asm/swab.h>
  19. #if __LINUX_ARM_ARCH__ >= 6
  20. static inline __attribute_const__ __u32 __arch_swahb32(__u32 x)
  21. {
  22. __asm__ ("rev16 %0, %1" : "=r" (x) : "r" (x));
  23. return x;
  24. }
  25. #define __arch_swahb32 __arch_swahb32
  26. #define __arch_swab16(x) ((__u16)__arch_swahb32(x))
  27. static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
  28. {
  29. __asm__ ("rev %0, %1" : "=r" (x) : "r" (x));
  30. return x;
  31. }
  32. #define __arch_swab32 __arch_swab32
  33. #endif
  34. #endif