byteorder.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * include/asm-microblaze/byteorder.h -- Endian id and conversion ops
  3. *
  4. * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
  5. * Copyright (C) 2001 NEC Corporation
  6. * Copyright (C) 2001 Miles Bader <miles@gnu.org>
  7. *
  8. * This file is subject to the terms and conditions of the GNU General
  9. * Public License. See the file COPYING in the main directory of this
  10. * archive for more details.
  11. *
  12. * Written by Miles Bader <miles@gnu.org>
  13. * Microblaze port by John Williams
  14. */
  15. #ifndef __MICROBLAZE_BYTEORDER_H__
  16. #define __MICROBLAZE_BYTEORDER_H__
  17. #include <asm/types.h>
  18. #ifdef __GNUC__
  19. /* This is effectively a dupe of the arch-independent byteswap
  20. code in include/linux/byteorder/swab.h, however we force a cast
  21. of the result up to 32 bits. This in turn forces the compiler
  22. to explicitly clear the high 16 bits, which it wasn't doing otherwise.
  23. I think this is a symptom of a bug in mb-gcc. JW 20040303
  24. */
  25. static __inline__ __const__ __u16 ___arch__swab16 (__u16 half_word)
  26. {
  27. /* 32 bit temp to cast result, forcing clearing of high word */
  28. __u32 temp;
  29. temp = ((half_word & 0x00FFU) << 8) | ((half_word & 0xFF00U) >> 8);
  30. return (__u16) temp;
  31. }
  32. #define __arch__swab16(x) ___arch__swab16(x)
  33. /* Microblaze has no arch-specific endian conversion insns */
  34. #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
  35. # define __BYTEORDER_HAS_U64__
  36. # define __SWAB_64_THRU_32__
  37. #endif
  38. #endif /* __GNUC__ */
  39. #include <linux/byteorder/big_endian.h>
  40. #endif /* __MICROBLAZE_BYTEORDER_H__ */