blob: 51cacb048b6ed6078d5c716f3112c11efacce2c3 [file] [log] [blame]
wdenk507bbe32004-04-18 21:13:41 +00001/*
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*/
30static __inline__ __const__ __u16 ___arch__swab16 (__u16 half_word)
31{
32 /* 32 bit temp to cast result, forcing clearing of high word */
33 __u32 temp;
34
35 temp = ((half_word & 0x00FFU) << 8) | ((half_word & 0xFF00U) >> 8);
36
37 return (__u16) temp;
38}
39
40#define __arch__swab16(x) ___arch__swab16(x)
41
42/* Microblaze has no arch-specific endian conversion insns */
43
44#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
45# define __BYTEORDER_HAS_U64__
46# define __SWAB_64_THRU_32__
47#endif
48
49#endif /* __GNUC__ */
50
51#include <linux/byteorder/big_endian.h>
52
53#endif /* __MICROBLAZE_BYTEORDER_H__ */