aboutsummaryrefslogtreecommitdiffstats
path: root/arch/parisc/include
diff options
context:
space:
mode:
authorHarvey Harrison <harvey.harrison@gmail.com>2009-01-09 15:42:54 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-09 15:46:23 -0500
commite245b80c8357bf375f15c5f3b05ef8ae35e4fbc8 (patch)
tree3e54ef6db7350717cca2258c955f4d31c4cc2a3c /arch/parisc/include
parent8659c406ade32f47da2c95889094801921d6330a (diff)
parisc: introduce asm/swab.h
Fix for the linux/byteorder.h removal. Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/parisc/include')
-rw-r--r--arch/parisc/include/asm/Kbuild1
-rw-r--r--arch/parisc/include/asm/byteorder.h66
-rw-r--r--arch/parisc/include/asm/swab.h66
3 files changed, 69 insertions, 64 deletions
diff --git a/arch/parisc/include/asm/Kbuild b/arch/parisc/include/asm/Kbuild
index f88b252e419c..2121d99f8364 100644
--- a/arch/parisc/include/asm/Kbuild
+++ b/arch/parisc/include/asm/Kbuild
@@ -1,3 +1,4 @@
1include include/asm-generic/Kbuild.asm 1include include/asm-generic/Kbuild.asm
2 2
3unifdef-y += pdc.h 3unifdef-y += pdc.h
4unifdef-y += swab.h
diff --git a/arch/parisc/include/asm/byteorder.h b/arch/parisc/include/asm/byteorder.h
index 83095c5bb379..da66029c4cb2 100644
--- a/arch/parisc/include/asm/byteorder.h
+++ b/arch/parisc/include/asm/byteorder.h
@@ -1,69 +1,7 @@
1#ifndef _PARISC_BYTEORDER_H 1#ifndef _PARISC_BYTEORDER_H
2#define _PARISC_BYTEORDER_H 2#define _PARISC_BYTEORDER_H
3 3
4#include <asm/types.h> 4#include <asm/swab.h>
5#include <linux/compiler.h> 5#include <linux/byteorder/big_endian.h>
6
7#define __BIG_ENDIAN
8#define __SWAB_64_THRU_32__
9
10static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
11{
12 __asm__("dep %0, 15, 8, %0\n\t" /* deposit 00ab -> 0bab */
13 "shd %%r0, %0, 8, %0" /* shift 000000ab -> 00ba */
14 : "=r" (x)
15 : "0" (x));
16 return x;
17}
18#define __arch_swab16 __arch_swab16
19
20static inline __attribute_const__ __u32 __arch_swab24(__u32 x)
21{
22 __asm__("shd %0, %0, 8, %0\n\t" /* shift xabcxabc -> cxab */
23 "dep %0, 15, 8, %0\n\t" /* deposit cxab -> cbab */
24 "shd %%r0, %0, 8, %0" /* shift 0000cbab -> 0cba */
25 : "=r" (x)
26 : "0" (x));
27 return x;
28}
29
30static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
31{
32 unsigned int temp;
33 __asm__("shd %0, %0, 16, %1\n\t" /* shift abcdabcd -> cdab */
34 "dep %1, 15, 8, %1\n\t" /* deposit cdab -> cbab */
35 "shd %0, %1, 8, %0" /* shift abcdcbab -> dcba */
36 : "=r" (x), "=&r" (temp)
37 : "0" (x));
38 return x;
39}
40#define __arch_swab32 __arch_swab32
41
42#if BITS_PER_LONG > 32
43/*
44** From "PA-RISC 2.0 Architecture", HP Professional Books.
45** See Appendix I page 8 , "Endian Byte Swapping".
46**
47** Pretty cool algorithm: (* == zero'd bits)
48** PERMH 01234567 -> 67452301 into %0
49** HSHL 67452301 -> 7*5*3*1* into %1
50** HSHR 67452301 -> *6*4*2*0 into %0
51** OR %0 | %1 -> 76543210 into %0 (all done!)
52*/
53static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
54{
55 __u64 temp;
56 __asm__("permh,3210 %0, %0\n\t"
57 "hshl %0, 8, %1\n\t"
58 "hshr,u %0, 8, %0\n\t"
59 "or %1, %0, %0"
60 : "=r" (x), "=&r" (temp)
61 : "0" (x));
62 return x;
63}
64#define __arch_swab64 __arch_swab64
65#endif /* BITS_PER_LONG > 32 */
66
67#include <linux/byteorder.h>
68 6
69#endif /* _PARISC_BYTEORDER_H */ 7#endif /* _PARISC_BYTEORDER_H */
diff --git a/arch/parisc/include/asm/swab.h b/arch/parisc/include/asm/swab.h
new file mode 100644
index 000000000000..3ff16c5a3358
--- /dev/null
+++ b/arch/parisc/include/asm/swab.h
@@ -0,0 +1,66 @@
1#ifndef _PARISC_SWAB_H
2#define _PARISC_SWAB_H
3
4#include <asm/types.h>
5#include <linux/compiler.h>
6
7#define __SWAB_64_THRU_32__
8
9static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
10{
11 __asm__("dep %0, 15, 8, %0\n\t" /* deposit 00ab -> 0bab */
12 "shd %%r0, %0, 8, %0" /* shift 000000ab -> 00ba */
13 : "=r" (x)
14 : "0" (x));
15 return x;
16}
17#define __arch_swab16 __arch_swab16
18
19static inline __attribute_const__ __u32 __arch_swab24(__u32 x)
20{
21 __asm__("shd %0, %0, 8, %0\n\t" /* shift xabcxabc -> cxab */
22 "dep %0, 15, 8, %0\n\t" /* deposit cxab -> cbab */
23 "shd %%r0, %0, 8, %0" /* shift 0000cbab -> 0cba */
24 : "=r" (x)
25 : "0" (x));
26 return x;
27}
28
29static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
30{
31 unsigned int temp;
32 __asm__("shd %0, %0, 16, %1\n\t" /* shift abcdabcd -> cdab */
33 "dep %1, 15, 8, %1\n\t" /* deposit cdab -> cbab */
34 "shd %0, %1, 8, %0" /* shift abcdcbab -> dcba */
35 : "=r" (x), "=&r" (temp)
36 : "0" (x));
37 return x;
38}
39#define __arch_swab32 __arch_swab32
40
41#if BITS_PER_LONG > 32
42/*
43** From "PA-RISC 2.0 Architecture", HP Professional Books.
44** See Appendix I page 8 , "Endian Byte Swapping".
45**
46** Pretty cool algorithm: (* == zero'd bits)
47** PERMH 01234567 -> 67452301 into %0
48** HSHL 67452301 -> 7*5*3*1* into %1
49** HSHR 67452301 -> *6*4*2*0 into %0
50** OR %0 | %1 -> 76543210 into %0 (all done!)
51*/
52static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
53{
54 __u64 temp;
55 __asm__("permh,3210 %0, %0\n\t"
56 "hshl %0, 8, %1\n\t"
57 "hshr,u %0, 8, %0\n\t"
58 "or %1, %0, %0"
59 : "=r" (x), "=&r" (temp)
60 : "0" (x));
61 return x;
62}
63#define __arch_swab64 __arch_swab64
64#endif /* BITS_PER_LONG > 32 */
65
66#endif /* _PARISC_SWAB_H */