• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2012-2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9 
10 #ifndef OSSL_CRYPTO_SPARC_ARCH_H
11 # define OSSL_CRYPTO_SPARC_ARCH_H
12 
13 # define SPARCV9_TICK_PRIVILEGED (1<<0)
14 # define SPARCV9_PREFER_FPU      (1<<1)
15 # define SPARCV9_VIS1            (1<<2)
16 # define SPARCV9_VIS2            (1<<3)/* reserved */
17 # define SPARCV9_FMADD           (1<<4)
18 # define SPARCV9_BLK             (1<<5)/* VIS1 block copy */
19 # define SPARCV9_VIS3            (1<<6)
20 # define SPARCV9_RANDOM          (1<<7)
21 # define SPARCV9_64BIT_STACK     (1<<8)
22 # define SPARCV9_FJAESX          (1<<9)/* Fujitsu SPARC64 X AES */
23 # define SPARCV9_FJDESX          (1<<10)/* Fujitsu SPARC64 X DES, reserved */
24 # define SPARCV9_FJHPCACE        (1<<11)/* Fujitsu HPC-ACE, reserved */
25 # define SPARCV9_IMA             (1<<13)/* reserved */
26 # define SPARCV9_VIS4            (1<<14)/* reserved */
27 
28 /*
29  * OPENSSL_sparcv9cap_P[1] is copy of Compatibility Feature Register,
30  * %asr26, SPARC-T4 and later. There is no SPARCV9_CFR bit in
31  * OPENSSL_sparcv9cap_P[0], as %cfr copy is sufficient...
32  */
33 # define CFR_AES         0x00000001/* Supports AES opcodes */
34 # define CFR_DES         0x00000002/* Supports DES opcodes */
35 # define CFR_KASUMI      0x00000004/* Supports KASUMI opcodes */
36 # define CFR_CAMELLIA    0x00000008/* Supports CAMELLIA opcodes */
37 # define CFR_MD5         0x00000010/* Supports MD5 opcodes */
38 # define CFR_SHA1        0x00000020/* Supports SHA1 opcodes */
39 # define CFR_SHA256      0x00000040/* Supports SHA256 opcodes */
40 # define CFR_SHA512      0x00000080/* Supports SHA512 opcodes */
41 # define CFR_MPMUL       0x00000100/* Supports MPMUL opcodes */
42 # define CFR_MONTMUL     0x00000200/* Supports MONTMUL opcodes */
43 # define CFR_MONTSQR     0x00000400/* Supports MONTSQR opcodes */
44 # define CFR_CRC32C      0x00000800/* Supports CRC32C opcodes */
45 # define CFR_XMPMUL      0x00001000/* Supports XMPMUL opcodes */
46 # define CFR_XMONTMUL    0x00002000/* Supports XMONTMUL opcodes */
47 # define CFR_XMONTSQR    0x00004000/* Supports XMONTSQR opcodes */
48 
49 # if defined(OPENSSL_PIC) && !defined(__PIC__)
50 #  define __PIC__
51 # endif
52 
53 # if defined(__SUNPRO_C) && defined(__sparcv9) && !defined(__arch64__)
54 #  define __arch64__
55 # endif
56 
57 # define SPARC_PIC_THUNK(reg)    \
58         .align  32;             \
59 .Lpic_thunk:                    \
60         jmp     %o7 + 8;        \
61          add    %o7, reg, reg;
62 
63 # define SPARC_PIC_THUNK_CALL(reg)                       \
64         sethi   %hi(_GLOBAL_OFFSET_TABLE_-4), reg;      \
65         call    .Lpic_thunk;                            \
66          or     reg, %lo(_GLOBAL_OFFSET_TABLE_+4), reg;
67 
68 # if 1
69 #  define SPARC_SETUP_GOT_REG(reg)       SPARC_PIC_THUNK_CALL(reg)
70 # else
71 #  define SPARC_SETUP_GOT_REG(reg)       \
72         sethi   %hi(_GLOBAL_OFFSET_TABLE_-4), reg;      \
73         call    .+8;                                    \
74         or      reg,%lo(_GLOBAL_OFFSET_TABLE_+4), reg;  \
75         add     %o7, reg, reg
76 # endif
77 
78 # if defined(__arch64__)
79 
80 #  define SPARC_LOAD_ADDRESS(SYM, reg)   \
81         setx    SYM, %o7, reg;
82 #  define LDPTR          ldx
83 #  define SIZE_T_CC      %xcc
84 #  define STACK_FRAME    192
85 #  define STACK_BIAS     2047
86 #  define STACK_7thARG   (STACK_BIAS+176)
87 
88 # else
89 
90 #  define SPARC_LOAD_ADDRESS(SYM, reg)   \
91         set     SYM, reg;
92 #  define LDPTR          ld
93 #  define SIZE_T_CC      %icc
94 #  define STACK_FRAME    112
95 #  define STACK_BIAS     0
96 #  define STACK_7thARG   92
97 #  define SPARC_LOAD_ADDRESS_LEAF(SYM,reg,tmp) SPARC_LOAD_ADDRESS(SYM,reg)
98 
99 # endif
100 
101 # ifdef __PIC__
102 #  undef SPARC_LOAD_ADDRESS
103 #  undef SPARC_LOAD_ADDRESS_LEAF
104 #  define SPARC_LOAD_ADDRESS(SYM, reg)   \
105         SPARC_SETUP_GOT_REG(reg);       \
106         sethi   %hi(SYM), %o7;          \
107         or      %o7, %lo(SYM), %o7;     \
108         LDPTR   [reg + %o7], reg;
109 # endif
110 
111 # ifndef SPARC_LOAD_ADDRESS_LEAF
112 #  define SPARC_LOAD_ADDRESS_LEAF(SYM, reg, tmp) \
113         mov     %o7, tmp;                       \
114         SPARC_LOAD_ADDRESS(SYM, reg)            \
115         mov     tmp, %o7;
116 # endif
117 
118 #endif                          /* OSSL_CRYPTO_SPARC_ARCH_H */
119