swab.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Copyright (C) 2011 Texas Instruments Incorporated
  4. * Author: Mark Salter <msalter@redhat.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef _ASM_C6X_SWAB_H
  11. #define _ASM_C6X_SWAB_H
  12. static inline __attribute_const__ __u16 __c6x_swab16(__u16 val)
  13. {
  14. asm("swap4 .l1 %0,%0\n" : "+a"(val));
  15. return val;
  16. }
  17. static inline __attribute_const__ __u32 __c6x_swab32(__u32 val)
  18. {
  19. asm("swap4 .l1 %0,%0\n"
  20. "swap2 .l1 %0,%0\n"
  21. : "+a"(val));
  22. return val;
  23. }
  24. static inline __attribute_const__ __u64 __c6x_swab64(__u64 val)
  25. {
  26. asm(" swap2 .s1 %p0,%P0\n"
  27. "|| swap2 .l1 %P0,%p0\n"
  28. " swap4 .l1 %p0,%p0\n"
  29. " swap4 .l1 %P0,%P0\n"
  30. : "+a"(val));
  31. return val;
  32. }
  33. static inline __attribute_const__ __u32 __c6x_swahw32(__u32 val)
  34. {
  35. asm("swap2 .l1 %0,%0\n" : "+a"(val));
  36. return val;
  37. }
  38. static inline __attribute_const__ __u32 __c6x_swahb32(__u32 val)
  39. {
  40. asm("swap4 .l1 %0,%0\n" : "+a"(val));
  41. return val;
  42. }
  43. #define __arch_swab16 __c6x_swab16
  44. #define __arch_swab32 __c6x_swab32
  45. #define __arch_swab64 __c6x_swab64
  46. #define __arch_swahw32 __c6x_swahw32
  47. #define __arch_swahb32 __c6x_swahb32
  48. #endif /* _ASM_C6X_SWAB_H */