xref: /openbmc/linux/arch/sparc/crypto/opcodes.h (revision 234489ac)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _OPCODES_H
3 #define _OPCODES_H
4 
5 #define SPARC_CR_OPCODE_PRIORITY	300
6 
7 #define F3F(x,y,z)	(((x)<<30)|((y)<<19)|((z)<<5))
8 
9 #define FPD_ENCODE(x)	(((x) >> 5) | ((x) & ~(0x20)))
10 
11 #define RS1(x)		(FPD_ENCODE(x) << 14)
12 #define RS2(x)		(FPD_ENCODE(x) <<  0)
13 #define RS3(x)		(FPD_ENCODE(x) <<  9)
14 #define RD(x)		(FPD_ENCODE(x) << 25)
15 #define IMM5_0(x)	((x)           <<  0)
16 #define IMM5_9(x)	((x)           <<  9)
17 
18 #define CRC32C(a,b,c)	\
19 	.word		(F3F(2,0x36,0x147)|RS1(a)|RS2(b)|RD(c));
20 
21 #define MD5		\
22 	.word	0x81b02800;
23 #define SHA1		\
24 	.word	0x81b02820;
25 #define SHA256		\
26 	.word	0x81b02840;
27 #define SHA512		\
28 	.word	0x81b02860;
29 
30 #define AES_EROUND01(a,b,c,d)	\
31 	.word	(F3F(2, 0x19, 0)|RS1(a)|RS2(b)|RS3(c)|RD(d));
32 #define AES_EROUND23(a,b,c,d)	\
33 	.word	(F3F(2, 0x19, 1)|RS1(a)|RS2(b)|RS3(c)|RD(d));
34 #define AES_DROUND01(a,b,c,d)	\
35 	.word	(F3F(2, 0x19, 2)|RS1(a)|RS2(b)|RS3(c)|RD(d));
36 #define AES_DROUND23(a,b,c,d)	\
37 	.word	(F3F(2, 0x19, 3)|RS1(a)|RS2(b)|RS3(c)|RD(d));
38 #define AES_EROUND01_L(a,b,c,d)	\
39 	.word	(F3F(2, 0x19, 4)|RS1(a)|RS2(b)|RS3(c)|RD(d));
40 #define AES_EROUND23_L(a,b,c,d)	\
41 	.word	(F3F(2, 0x19, 5)|RS1(a)|RS2(b)|RS3(c)|RD(d));
42 #define AES_DROUND01_L(a,b,c,d)	\
43 	.word	(F3F(2, 0x19, 6)|RS1(a)|RS2(b)|RS3(c)|RD(d));
44 #define AES_DROUND23_L(a,b,c,d)	\
45 	.word	(F3F(2, 0x19, 7)|RS1(a)|RS2(b)|RS3(c)|RD(d));
46 #define AES_KEXPAND1(a,b,c,d)	\
47 	.word	(F3F(2, 0x19, 8)|RS1(a)|RS2(b)|IMM5_9(c)|RD(d));
48 #define AES_KEXPAND0(a,b,c)	\
49 	.word	(F3F(2, 0x36, 0x130)|RS1(a)|RS2(b)|RD(c));
50 #define AES_KEXPAND2(a,b,c)	\
51 	.word	(F3F(2, 0x36, 0x131)|RS1(a)|RS2(b)|RD(c));
52 
53 #define DES_IP(a,b)		\
54 	.word		(F3F(2, 0x36, 0x134)|RS1(a)|RD(b));
55 #define DES_IIP(a,b)		\
56 	.word		(F3F(2, 0x36, 0x135)|RS1(a)|RD(b));
57 #define DES_KEXPAND(a,b,c)	\
58 	.word		(F3F(2, 0x36, 0x136)|RS1(a)|IMM5_0(b)|RD(c));
59 #define DES_ROUND(a,b,c,d)	\
60 	.word		(F3F(2, 0x19, 0x009)|RS1(a)|RS2(b)|RS3(c)|RD(d));
61 
62 #define CAMELLIA_F(a,b,c,d)		\
63 	.word		(F3F(2, 0x19, 0x00c)|RS1(a)|RS2(b)|RS3(c)|RD(d));
64 #define CAMELLIA_FL(a,b,c)		\
65 	.word		(F3F(2, 0x36, 0x13c)|RS1(a)|RS2(b)|RD(c));
66 #define CAMELLIA_FLI(a,b,c)		\
67 	.word		(F3F(2, 0x36, 0x13d)|RS1(a)|RS2(b)|RD(c));
68 
69 #define MOVDTOX_F0_O4		\
70 	.word	0x99b02200
71 #define MOVDTOX_F2_O5		\
72 	.word	0x9bb02202
73 #define MOVXTOD_G1_F60 		\
74 	.word	0xbbb02301
75 #define MOVXTOD_G1_F62 		\
76 	.word	0xbfb02301
77 #define MOVXTOD_G3_F4		\
78 	.word	0x89b02303;
79 #define MOVXTOD_G7_F6		\
80 	.word	0x8db02307;
81 #define MOVXTOD_G3_F0		\
82 	.word	0x81b02303;
83 #define MOVXTOD_G7_F2		\
84 	.word	0x85b02307;
85 #define MOVXTOD_O0_F0		\
86 	.word	0x81b02308;
87 #define MOVXTOD_O5_F0		\
88 	.word	0x81b0230d;
89 #define MOVXTOD_O5_F2		\
90 	.word	0x85b0230d;
91 #define MOVXTOD_O5_F4		\
92 	.word	0x89b0230d;
93 #define MOVXTOD_O5_F6		\
94 	.word	0x8db0230d;
95 #define MOVXTOD_G3_F60		\
96 	.word	0xbbb02303;
97 #define MOVXTOD_G7_F62		\
98 	.word	0xbfb02307;
99 
100 #endif /* _OPCODES_H */
101