summaryrefslogtreecommitdiffstats
path: root/include/asm-sparc64/md.h
blob: 03879934e7d5a504bb793b3e669f7d667aa53a35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* $Id: md.h,v 1.2 1997/12/27 16:28:38 jj Exp $
 * md.h: High speed xor_block operation for RAID4/5 
 *            utilizing the UltraSparc Visual Instruction Set.
 *
 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
 */
 
#ifndef __ASM_MD_H
#define __ASM_MD_H

#include <asm/head.h>
#include <asm/asi.h>

#define HAVE_ARCH_XORBLOCK

#define MD_XORBLOCK_ALIGNMENT	64

/*	void __xor_block (char *dest, char *src, long len)
 *	{
 *		while (len--) *dest++ ^= *src++;
 * 	}
 *
 *	Requirements:
 *	!(((long)dest | (long)src) & (MD_XORBLOCK_ALIGNMENT - 1)) &&
 *	!(len & 127) && len >= 256
 */

static inline void __xor_block (char *dest, char *src, long len)
{
	__asm__ __volatile__ ("
	wr	%%g0, %3, %%fprs
	wr	%%g0, %4, %%asi
	membar	#LoadStore|#StoreLoad|#StoreStore
	sub	%2, 128, %2
	ldda	[%0] %4, %%f0
	ldda	[%1] %4, %%f16
1:	ldda	[%0 + 64] %%asi, %%f32
	fxor	%%f0, %%f16, %%f16
	fxor	%%f2, %%f18, %%f18
	fxor	%%f4, %%f20, %%f20
	fxor	%%f6, %%f22, %%f22
	fxor	%%f8, %%f24, %%f24
	fxor	%%f10, %%f26, %%f26
	fxor	%%f12, %%f28, %%f28
	fxor	%%f14, %%f30, %%f30
	stda	%%f16, [%0] %4
	ldda	[%1 + 64] %%asi, %%f48
	ldda	[%0 + 128] %%asi, %%f0
	fxor	%%f32, %%f48, %%f48
	fxor	%%f34, %%f50, %%f50
	add	%0, 128, %0
	fxor	%%f36, %%f52, %%f52
	add	%1, 128, %1
	fxor	%%f38, %%f54, %%f54
	subcc	%2, 128, %2
	fxor	%%f40, %%f56, %%f56
	fxor	%%f42, %%f58, %%f58
	fxor	%%f44, %%f60, %%f60
	fxor	%%f46, %%f62, %%f62
	stda	%%f48, [%0 - 64] %%asi
	bne,pt	%%xcc, 1b
	 ldda	[%1] %4, %%f16
	ldda	[%0 + 64] %%asi, %%f32
	fxor	%%f0, %%f16, %%f16
	fxor	%%f2, %%f18, %%f18
	fxor	%%f4, %%f20, %%f20
	fxor	%%f6, %%f22, %%f22
	fxor	%%f8, %%f24, %%f24
	fxor	%%f10, %%f26, %%f26
	fxor	%%f12, %%f28, %%f28
	fxor	%%f14, %%f30, %%f30
	stda	%%f16, [%0] %4
	ldda	[%1 + 64] %%asi, %%f48
	membar	#Sync
	fxor	%%f32, %%f48, %%f48
	fxor	%%f34, %%f50, %%f50
	fxor	%%f36, %%f52, %%f52
	fxor	%%f38, %%f54, %%f54
	fxor	%%f40, %%f56, %%f56
	fxor	%%f42, %%f58, %%f58
	fxor	%%f44, %%f60, %%f60
	fxor	%%f46, %%f62, %%f62
	stda	%%f48, [%0 + 64] %%asi
	membar	#Sync|#StoreStore|#StoreLoad
	wr	%%g0, 0, %%fprs
	" : :
	"r" (dest), "r" (src), "r" (len), "i" (FPRS_FEF), "i" (ASI_BLK_P) :
	"cc", "memory");
}

#endif /* __ASM_MD_H */