2 * arch/arm/include/asm/xor.h
4 * Copyright (C) 2001 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 #include <linux/hardirq.h>
11 #include <asm-generic/xor.h>
12 #include <asm/hwcap.h>
15 #define __XOR(a1, a2) a1 ^= a2
17 #define GET_BLOCK_2(dst) \
18 __asm__("ldmia %0, {%1, %2}" \
19 : "=r" (dst), "=r" (a1), "=r" (a2) \
22 #define GET_BLOCK_4(dst) \
23 __asm__("ldmia %0, {%1, %2, %3, %4}" \
24 : "=r" (dst), "=r" (a1), "=r" (a2), "=r" (a3), "=r" (a4) \
27 #define XOR_BLOCK_2(src) \
28 __asm__("ldmia %0!, {%1, %2}" \
29 : "=r" (src), "=r" (b1), "=r" (b2) \
31 __XOR(a1, b1); __XOR(a2, b2);
33 #define XOR_BLOCK_4(src) \
34 __asm__("ldmia %0!, {%1, %2, %3, %4}" \
35 : "=r" (src), "=r" (b1), "=r" (b2), "=r" (b3), "=r" (b4) \
37 __XOR(a1, b1); __XOR(a2, b2); __XOR(a3, b3); __XOR(a4, b4)
39 #define PUT_BLOCK_2(dst) \
40 __asm__ __volatile__("stmia %0!, {%2, %3}" \
42 : "0" (dst), "r" (a1), "r" (a2))
44 #define PUT_BLOCK_4(dst) \
45 __asm__ __volatile__("stmia %0!, {%2, %3, %4, %5}" \
47 : "0" (dst), "r" (a1), "r" (a2), "r" (a3), "r" (a4))
50 xor_arm4regs_2(unsigned long bytes
, unsigned long *p1
, unsigned long *p2
)
52 unsigned int lines
= bytes
/ sizeof(unsigned long) / 4;
53 register unsigned int a1
__asm__("r4");
54 register unsigned int a2
__asm__("r5");
55 register unsigned int a3
__asm__("r6");
56 register unsigned int a4
__asm__("r7");
57 register unsigned int b1
__asm__("r8");
58 register unsigned int b2
__asm__("r9");
59 register unsigned int b3
__asm__("ip");
60 register unsigned int b4
__asm__("lr");
70 xor_arm4regs_3(unsigned long bytes
, unsigned long *p1
, unsigned long *p2
,
73 unsigned int lines
= bytes
/ sizeof(unsigned long) / 4;
74 register unsigned int a1
__asm__("r4");
75 register unsigned int a2
__asm__("r5");
76 register unsigned int a3
__asm__("r6");
77 register unsigned int a4
__asm__("r7");
78 register unsigned int b1
__asm__("r8");
79 register unsigned int b2
__asm__("r9");
80 register unsigned int b3
__asm__("ip");
81 register unsigned int b4
__asm__("lr");
92 xor_arm4regs_4(unsigned long bytes
, unsigned long *p1
, unsigned long *p2
,
93 unsigned long *p3
, unsigned long *p4
)
95 unsigned int lines
= bytes
/ sizeof(unsigned long) / 2;
96 register unsigned int a1
__asm__("r8");
97 register unsigned int a2
__asm__("r9");
98 register unsigned int b1
__asm__("ip");
99 register unsigned int b2
__asm__("lr");
111 xor_arm4regs_5(unsigned long bytes
, unsigned long *p1
, unsigned long *p2
,
112 unsigned long *p3
, unsigned long *p4
, unsigned long *p5
)
114 unsigned int lines
= bytes
/ sizeof(unsigned long) / 2;
115 register unsigned int a1
__asm__("r8");
116 register unsigned int a2
__asm__("r9");
117 register unsigned int b1
__asm__("ip");
118 register unsigned int b2
__asm__("lr");
130 static struct xor_block_template xor_block_arm4regs
= {
132 .do_2
= xor_arm4regs_2
,
133 .do_3
= xor_arm4regs_3
,
134 .do_4
= xor_arm4regs_4
,
135 .do_5
= xor_arm4regs_5
,
138 #undef XOR_TRY_TEMPLATES
139 #define XOR_TRY_TEMPLATES \
141 xor_speed(&xor_block_arm4regs); \
142 xor_speed(&xor_block_8regs); \
143 xor_speed(&xor_block_32regs); \
147 #ifdef CONFIG_KERNEL_MODE_NEON
149 extern struct xor_block_template
const xor_block_neon_inner
;
152 xor_neon_2(unsigned long bytes
, unsigned long *p1
, unsigned long *p2
)
154 if (in_interrupt()) {
155 xor_arm4regs_2(bytes
, p1
, p2
);
158 xor_block_neon_inner
.do_2(bytes
, p1
, p2
);
164 xor_neon_3(unsigned long bytes
, unsigned long *p1
, unsigned long *p2
,
167 if (in_interrupt()) {
168 xor_arm4regs_3(bytes
, p1
, p2
, p3
);
171 xor_block_neon_inner
.do_3(bytes
, p1
, p2
, p3
);
177 xor_neon_4(unsigned long bytes
, unsigned long *p1
, unsigned long *p2
,
178 unsigned long *p3
, unsigned long *p4
)
180 if (in_interrupt()) {
181 xor_arm4regs_4(bytes
, p1
, p2
, p3
, p4
);
184 xor_block_neon_inner
.do_4(bytes
, p1
, p2
, p3
, p4
);
190 xor_neon_5(unsigned long bytes
, unsigned long *p1
, unsigned long *p2
,
191 unsigned long *p3
, unsigned long *p4
, unsigned long *p5
)
193 if (in_interrupt()) {
194 xor_arm4regs_5(bytes
, p1
, p2
, p3
, p4
, p5
);
197 xor_block_neon_inner
.do_5(bytes
, p1
, p2
, p3
, p4
, p5
);
202 static struct xor_block_template xor_block_neon
= {
210 #define NEON_TEMPLATES \
211 do { if (cpu_has_neon()) xor_speed(&xor_block_neon); } while (0)
213 #define NEON_TEMPLATES