blob: d442113de515158f69ec6b4c7b0a3a31fc579fd0 [file] [log] [blame]
Harvey Harrisoncfcac2f2009-01-06 14:56:30 -08001#ifndef _BLACKFIN_SWAB_H
2#define _BLACKFIN_SWAB_H
3
Jaswinder Singh Rajput350eb8b2009-01-31 10:48:44 +05304#include <linux/types.h>
Mike Frysinger3d150632009-06-13 11:21:51 -04005#include <asm-generic/swab.h>
Harvey Harrisoncfcac2f2009-01-06 14:56:30 -08006
7#ifdef __GNUC__
8
9static __inline__ __attribute_const__ __u32 __arch_swahb32(__u32 xx)
10{
11 __u32 tmp;
12 __asm__("%1 = %0 >> 8 (V);\n\t"
13 "%0 = %0 << 8 (V);\n\t"
14 "%0 = %0 | %1;\n\t"
15 : "+d"(xx), "=&d"(tmp));
16 return xx;
17}
18#define __arch_swahb32 __arch_swahb32
19
20static __inline__ __attribute_const__ __u32 __arch_swahw32(__u32 xx)
21{
22 __u32 rv;
23 __asm__("%0 = PACK(%1.L, %1.H);\n\t": "=d"(rv): "d"(xx));
24 return rv;
25}
26#define __arch_swahw32 __arch_swahw32
27
28static __inline__ __attribute_const__ __u32 __arch_swab32(__u32 xx)
29{
30 return __arch_swahb32(__arch_swahw32(xx));
31}
32#define __arch_swab32 __arch_swab32
33
34static __inline__ __attribute_const__ __u16 __arch_swab16(__u16 xx)
35{
36 __u32 xw = xx;
37 __asm__("%0 <<= 8;\n %0.L = %0.L + %0.H (NS);\n": "+d"(xw));
38 return (__u16)xw;
39}
40#define __arch_swab16 __arch_swab16
41
42#endif /* __GNUC__ */
43
44#endif /* _BLACKFIN_SWAB_H */