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 16 #ifndef __MICROBLAZE_BYTEORDER_H__ 17 #define __MICROBLAZE_BYTEORDER_H__ 18 19 #include <asm/types.h> 20 21 #ifdef __GNUC__ 22 23 /* This is effectively a dupe of the arch-independent byteswap 24 code in include/linux/byteorder/swab.h, however we force a cast 25 of the result up to 32 bits. This in turn forces the compiler 26 to explicitly clear the high 16 bits, which it wasn't doing otherwise. 27 28 I think this is a symptom of a bug in mb-gcc. JW 20040303 29 */ 30 31 32 static __inline__ __u16 ___arch__swab16 (__u16 half_word) 33 { 34 /* 32 bit temp to cast result, forcing clearing of high word */ 35 __u32 temp; 36 37 temp = ((half_word & 0x00FFU) << 8) | ((half_word & 0xFF00U) >> 8); 38 39 return (__u16) temp; 40 } 41 42 #define __arch__swab16(x) ___arch__swab16(x) 43 44 /* Microblaze has no arch-specific endian conversion insns */ 45 46 #if !defined(__STRICT_ANSI__) || defined(__KERNEL__) 47 # define __BYTEORDER_HAS_U64__ 48 # define __SWAB_64_THRU_32__ 49 #endif 50 51 #endif /* __GNUC__ */ 52 53 #include <linux/byteorder/big_endian.h> 54 55 #endif /* __MICROBLAZE_BYTEORDER_H__ */ 56