swab.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1996, 99, 2003 by Ralf Baechle
  7. */
  8. #ifndef _ASM_SWAB_H
  9. #define _ASM_SWAB_H
  10. #include <linux/compiler.h>
  11. #include <linux/types.h>
  12. #define __SWAB_64_THRU_32__
  13. #ifdef CONFIG_CPU_MIPSR2
  14. static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
  15. {
  16. __asm__(
  17. " wsbh %0, %1 \n"
  18. : "=r" (x)
  19. : "r" (x));
  20. return x;
  21. }
  22. #define __arch_swab16 __arch_swab16
  23. static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
  24. {
  25. __asm__(
  26. " wsbh %0, %1 \n"
  27. " rotr %0, %0, 16 \n"
  28. : "=r" (x)
  29. : "r" (x));
  30. return x;
  31. }
  32. #define __arch_swab32 __arch_swab32
  33. #ifdef CONFIG_CPU_MIPS64_R2
  34. static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
  35. {
  36. __asm__(
  37. " dsbh %0, %1\n"
  38. " dshd %0, %0"
  39. : "=r" (x)
  40. : "r" (x));
  41. return x;
  42. }
  43. #define __arch_swab64 __arch_swab64
  44. #endif /* CONFIG_CPU_MIPS64_R2 */
  45. #endif /* CONFIG_CPU_MIPSR2 */
  46. #endif /* _ASM_SWAB_H */