sparc64: Avoid code duplication in crypto assembler.

Put the opcode macros in a common header

Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2012-08-31 12:11:51 -07:00
Родитель 4e71bb49f2
Коммит 7cff82f5f4
9 изменённых файлов: 117 добавлений и 125 удалений

Просмотреть файл

@ -1,61 +1,7 @@
#include <linux/linkage.h>
#include <asm/visasm.h>
#define F3F(x,y,z) (((x)<<30)|((y)<<19)|((z)<<5))
#define FPD_ENCODE(x) (((x) >> 5) | ((x) & ~(0x20)))
#define RS1(x) (FPD_ENCODE(x) << 14)
#define RS2(x) (FPD_ENCODE(x) << 0)
#define RS3(x) (FPD_ENCODE(x) << 9)
#define RD(x) (FPD_ENCODE(x) << 25)
#define IMM5(x) ((x) << 9)
#define AES_EROUND01(a,b,c,d) \
.word (F3F(2, 0x19, 0)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_EROUND23(a,b,c,d) \
.word (F3F(2, 0x19, 1)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_DROUND01(a,b,c,d) \
.word (F3F(2, 0x19, 2)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_DROUND23(a,b,c,d) \
.word (F3F(2, 0x19, 3)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_EROUND01_L(a,b,c,d) \
.word (F3F(2, 0x19, 4)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_EROUND23_L(a,b,c,d) \
.word (F3F(2, 0x19, 5)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_DROUND01_L(a,b,c,d) \
.word (F3F(2, 0x19, 6)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_DROUND23_L(a,b,c,d) \
.word (F3F(2, 0x19, 7)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_KEXPAND1(a,b,c,d) \
.word (F3F(2, 0x19, 8)|RS1(a)|RS2(b)|IMM5(c)|RD(d));
#define AES_KEXPAND0(a,b,c) \
.word (F3F(2, 0x36, 0x130)|RS1(a)|RS2(b)|RD(c));
#define AES_KEXPAND2(a,b,c) \
.word (F3F(2, 0x36, 0x131)|RS1(a)|RS2(b)|RD(c));
#define MOVXTOD_G3_F4 \
.word 0x89b02303;
#define MOVXTOD_G7_F6 \
.word 0x8db02307;
#define MOVXTOD_G3_F0 \
.word 0x81b02303;
#define MOVXTOD_G7_F2 \
.word 0x85b02307;
#define MOVXTOD_O0_F0 \
.word 0x81b02308;
#define MOVXTOD_O5_F0 \
.word 0x81b0230d;
#define MOVXTOD_O5_F2 \
.word 0x85b0230d;
#define MOVXTOD_O5_F4 \
.word 0x89b0230d;
#define MOVXTOD_O5_F6 \
.word 0x8db0230d;
#define MOVXTOD_G3_F60 \
.word 0xbbb02303;
#define MOVXTOD_G7_F62 \
.word 0xbfb02307;
#include "opcodes.h"
#define ENCRYPT_TWO_ROUNDS(KEY_BASE, I0, I1, T0, T1) \
AES_EROUND01(KEY_BASE + 0, I0, I1, T0) \

Просмотреть файл

@ -1,27 +1,7 @@
#include <linux/linkage.h>
#include <asm/visasm.h>
#define F3F(x,y,z) (((x)<<30)|((y)<<19)|((z)<<5))
#define FPD_ENCODE(x) (((x) >> 5) | ((x) & ~(0x20)))
#define RS1(x) (FPD_ENCODE(x) << 14)
#define RS2(x) (FPD_ENCODE(x) << 0)
#define RS3(x) (FPD_ENCODE(x) << 9)
#define RD(x) (FPD_ENCODE(x) << 25)
#define IMM5(x) ((x) << 0)
#define CAMELLIA_F(a,b,c,d) \
.word (F3F(2, 0x19, 0x00c)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define CAMELLIA_FL(a,b,c) \
.word (F3F(2, 0x36, 0x13c)|RS1(a)|RS2(b)|RD(c));
#define CAMELLIA_FLI(a,b,c) \
.word (F3F(2, 0x36, 0x13d)|RS1(a)|RS2(b)|RD(c));
#define MOVDTOX_F0_O4 \
.word 0x99b02200
#define MOVDTOX_F2_O5 \
.word 0x9bb02202
#include "opcodes.h"
#define CAMELLIA_6ROUNDS(KEY_BASE, I0, I1) \
CAMELLIA_F(KEY_BASE + 0, I1, I0, I1) \

Просмотреть файл

@ -2,16 +2,7 @@
#include <asm/visasm.h>
#include <asm/asi.h>
#define F3F(x,y,z) (((x)<<30)|((y)<<19)|((z)<<5))
#define FPD_ENCODE(x) (((x) >> 5) | ((x) & ~(0x20)))
#define RS1(x) (FPD_ENCODE(x) << 14)
#define RS2(x) (FPD_ENCODE(x) << 0)
#define RD(x) (FPD_ENCODE(x) << 25)
#define CRC32C(a,b,c) \
.word (F3F(2,0x36,0x147)|RS1(a)|RS2(b)|RD(c));
#include "opcodes.h"
ENTRY(crc32c_sparc64)
/* %o0=crc32p, %o1=data_ptr, %o2=len */

Просмотреть файл

@ -1,29 +1,7 @@
#include <linux/linkage.h>
#include <asm/visasm.h>
#define F3F(x,y,z) (((x)<<30)|((y)<<19)|((z)<<5))
#define FPD_ENCODE(x) (((x) >> 5) | ((x) & ~(0x20)))
#define RS1(x) (FPD_ENCODE(x) << 14)
#define RS2(x) (FPD_ENCODE(x) << 0)
#define RS3(x) (FPD_ENCODE(x) << 9)
#define RD(x) (FPD_ENCODE(x) << 25)
#define IMM5(x) ((x) << 0)
#define DES_IP(a,b) \
.word (F3F(2, 0x36, 0x134)|RS1(a)|RD(b));
#define DES_IIP(a,b) \
.word (F3F(2, 0x36, 0x135)|RS1(a)|RD(b));
#define DES_KEXPAND(a,b,c) \
.word (F3F(2, 0x36, 0x136)|RS1(a)|IMM5(b)|RD(c));
#define DES_ROUND(a,b,c,d) \
.word (F3F(2, 0x19, 0x009)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define MOVXTOD_G1_F60 \
.word 0xbbb02301
#define MOVXTOD_G1_F62 \
.word 0xbfb02301
#include "opcodes.h"
.align 32
ENTRY(des_sparc64_key_expand)

Просмотреть файл

@ -1,6 +1,8 @@
#include <linux/linkage.h>
#include <asm/visasm.h>
#include "opcodes.h"
ENTRY(md5_sparc64_transform)
/* %o0 = digest, %o1 = data, %o2 = rounds */
VISEntryHalf
@ -21,8 +23,7 @@ ENTRY(md5_sparc64_transform)
ldd [%o1 + 0x30], %f20
ldd [%o1 + 0x38], %f22
/* md5 */
.word 0x81b02800
MD5
subcc %o2, 1, %o2
bne,pt %xcc, 1b
@ -58,8 +59,7 @@ ENTRY(md5_sparc64_transform)
faligndata %f22, %f24, %f20
faligndata %f24, %f26, %f22
/* md5 */
.word 0x81b02800
MD5
subcc %o2, 1, %o2
fsrc2 %f26, %f10

Просмотреть файл

@ -0,0 +1,97 @@
#ifndef _OPCODES_H
#define _OPCODES_H
#define F3F(x,y,z) (((x)<<30)|((y)<<19)|((z)<<5))
#define FPD_ENCODE(x) (((x) >> 5) | ((x) & ~(0x20)))
#define RS1(x) (FPD_ENCODE(x) << 14)
#define RS2(x) (FPD_ENCODE(x) << 0)
#define RS3(x) (FPD_ENCODE(x) << 9)
#define RD(x) (FPD_ENCODE(x) << 25)
#define IMM5_0(x) ((x) << 0)
#define IMM5_9(x) ((x) << 9)
#define CRC32C(a,b,c) \
.word (F3F(2,0x36,0x147)|RS1(a)|RS2(b)|RD(c));
#define MD5 \
.word 0x81b02800;
#define SHA1 \
.word 0x81b02820;
#define SHA256 \
.word 0x81b02840;
#define SHA512 \
.word 0x81b02860;
#define AES_EROUND01(a,b,c,d) \
.word (F3F(2, 0x19, 0)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_EROUND23(a,b,c,d) \
.word (F3F(2, 0x19, 1)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_DROUND01(a,b,c,d) \
.word (F3F(2, 0x19, 2)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_DROUND23(a,b,c,d) \
.word (F3F(2, 0x19, 3)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_EROUND01_L(a,b,c,d) \
.word (F3F(2, 0x19, 4)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_EROUND23_L(a,b,c,d) \
.word (F3F(2, 0x19, 5)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_DROUND01_L(a,b,c,d) \
.word (F3F(2, 0x19, 6)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_DROUND23_L(a,b,c,d) \
.word (F3F(2, 0x19, 7)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define AES_KEXPAND1(a,b,c,d) \
.word (F3F(2, 0x19, 8)|RS1(a)|RS2(b)|IMM5_9(c)|RD(d));
#define AES_KEXPAND0(a,b,c) \
.word (F3F(2, 0x36, 0x130)|RS1(a)|RS2(b)|RD(c));
#define AES_KEXPAND2(a,b,c) \
.word (F3F(2, 0x36, 0x131)|RS1(a)|RS2(b)|RD(c));
#define DES_IP(a,b) \
.word (F3F(2, 0x36, 0x134)|RS1(a)|RD(b));
#define DES_IIP(a,b) \
.word (F3F(2, 0x36, 0x135)|RS1(a)|RD(b));
#define DES_KEXPAND(a,b,c) \
.word (F3F(2, 0x36, 0x136)|RS1(a)|IMM5_0(b)|RD(c));
#define DES_ROUND(a,b,c,d) \
.word (F3F(2, 0x19, 0x009)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define CAMELLIA_F(a,b,c,d) \
.word (F3F(2, 0x19, 0x00c)|RS1(a)|RS2(b)|RS3(c)|RD(d));
#define CAMELLIA_FL(a,b,c) \
.word (F3F(2, 0x36, 0x13c)|RS1(a)|RS2(b)|RD(c));
#define CAMELLIA_FLI(a,b,c) \
.word (F3F(2, 0x36, 0x13d)|RS1(a)|RS2(b)|RD(c));
#define MOVDTOX_F0_O4 \
.word 0x99b02200
#define MOVDTOX_F2_O5 \
.word 0x9bb02202
#define MOVXTOD_G1_F60 \
.word 0xbbb02301
#define MOVXTOD_G1_F62 \
.word 0xbfb02301
#define MOVXTOD_G3_F4 \
.word 0x89b02303;
#define MOVXTOD_G7_F6 \
.word 0x8db02307;
#define MOVXTOD_G3_F0 \
.word 0x81b02303;
#define MOVXTOD_G7_F2 \
.word 0x85b02307;
#define MOVXTOD_O0_F0 \
.word 0x81b02308;
#define MOVXTOD_O5_F0 \
.word 0x81b0230d;
#define MOVXTOD_O5_F2 \
.word 0x85b0230d;
#define MOVXTOD_O5_F4 \
.word 0x89b0230d;
#define MOVXTOD_O5_F6 \
.word 0x8db0230d;
#define MOVXTOD_G3_F60 \
.word 0xbbb02303;
#define MOVXTOD_G7_F62 \
.word 0xbfb02307;
#endif /* _OPCODES_H */

Просмотреть файл

@ -1,6 +1,8 @@
#include <linux/linkage.h>
#include <asm/visasm.h>
#include "opcodes.h"
ENTRY(sha1_sparc64_transform)
/* %o0 = digest, %o1 = data, %o2 = rounds */
VISEntryHalf
@ -22,8 +24,7 @@ ENTRY(sha1_sparc64_transform)
ldd [%o1 + 0x30], %f20
ldd [%o1 + 0x38], %f22
/* sha1 */
.word 0x81b02820
SHA1
subcc %o2, 1, %o2
bne,pt %xcc, 1b
@ -60,8 +61,7 @@ ENTRY(sha1_sparc64_transform)
faligndata %f22, %f24, %f20
faligndata %f24, %f26, %f22
/* sha1 */
.word 0x81b02820
SHA1
subcc %o2, 1, %o2
fsrc2 %f26, %f10

Просмотреть файл

@ -1,6 +1,8 @@
#include <linux/linkage.h>
#include <asm/visasm.h>
#include "opcodes.h"
ENTRY(sha256_sparc64_transform)
/* %o0 = digest, %o1 = data, %o2 = rounds */
VISEntryHalf
@ -25,8 +27,7 @@ ENTRY(sha256_sparc64_transform)
ldd [%o1 + 0x30], %f20
ldd [%o1 + 0x38], %f22
/* sha256 */
.word 0x81b02840
SHA256
subcc %o2, 1, %o2
bne,pt %xcc, 1b
@ -66,8 +67,7 @@ ENTRY(sha256_sparc64_transform)
faligndata %f22, %f24, %f20
faligndata %f24, %f26, %f22
/* sha256 */
.word 0x81b02840
SHA256
subcc %o2, 1, %o2
fsrc2 %f26, %f10

Просмотреть файл

@ -1,6 +1,8 @@
#include <linux/linkage.h>
#include <asm/visasm.h>
#include "opcodes.h"
ENTRY(sha512_sparc64_transform)
/* %o0 = digest, %o1 = data, %o2 = rounds */
VISEntry
@ -33,8 +35,7 @@ ENTRY(sha512_sparc64_transform)
ldd [%o1 + 0x70], %f44
ldd [%o1 + 0x78], %f46
/* sha512 */
.word 0x81b02860
SHA512
subcc %o2, 1, %o2
bne,pt %xcc, 1b
@ -90,8 +91,7 @@ ENTRY(sha512_sparc64_transform)
faligndata %f46, %f48, %f44
faligndata %f48, %f50, %f46
/* sha512 */
.word 0x81b02860
SHA512
subcc %o2, 1, %o2
fsrc2 %f50, %f18