| 1 |
/* |
| 2 |
* Copyright 2012-2026 The OpenSSL Project Authors. All Rights Reserved. |
| 3 |
* |
| 4 |
* Licensed under the Apache License 2.0 (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 |
/* clang-format off */ |
| 58 |
# define SPARC_PIC_THUNK(reg) \ |
| 59 |
.align 32; \ |
| 60 |
.Lpic_thunk: \ |
| 61 |
jmp %o7 + 8; \ |
| 62 |
add %o7, reg, reg; |
| 63 |
|
| 64 |
# define SPARC_PIC_THUNK_CALL(reg) \ |
| 65 |
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), reg; \ |
| 66 |
call .Lpic_thunk; \ |
| 67 |
or reg, %lo(_GLOBAL_OFFSET_TABLE_+4), reg; |
| 68 |
|
| 69 |
# if 1 |
| 70 |
# define SPARC_SETUP_GOT_REG(reg) SPARC_PIC_THUNK_CALL(reg) |
| 71 |
# else |
| 72 |
# define SPARC_SETUP_GOT_REG(reg) \ |
| 73 |
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), reg; \ |
| 74 |
call .+8; \ |
| 75 |
or reg,%lo(_GLOBAL_OFFSET_TABLE_+4), reg; \ |
| 76 |
add %o7, reg, reg |
| 77 |
# endif |
| 78 |
/* clang-format on */ |
| 79 |
|
| 80 |
#if defined(__arch64__) |
| 81 |
|
| 82 |
/* clang-format off */ |
| 83 |
#define SPARC_LOAD_ADDRESS(SYM, reg) \ |
| 84 |
setx SYM, %o7, reg; |
| 85 |
/* clang-format on */ |
| 86 |
#define LDPTR ldx |
| 87 |
/* clang-format off */ |
| 88 |
#define SIZE_T_CC %xcc |
| 89 |
/* clang-format on */ |
| 90 |
#define STACK_FRAME 192 |
| 91 |
#define STACK_BIAS 2047 |
| 92 |
#define STACK_7thARG (STACK_BIAS + 176) |
| 93 |
|
| 94 |
#else |
| 95 |
|
| 96 |
#define SPARC_LOAD_ADDRESS(SYM, reg) \ |
| 97 |
set SYM, reg; |
| 98 |
#define LDPTR ld |
| 99 |
/* clang-format off */ |
| 100 |
#define SIZE_T_CC %icc |
| 101 |
/* clang-format on */ |
| 102 |
#define STACK_FRAME 112 |
| 103 |
#define STACK_BIAS 0 |
| 104 |
#define STACK_7thARG 92 |
| 105 |
#define SPARC_LOAD_ADDRESS_LEAF(SYM, reg, tmp) SPARC_LOAD_ADDRESS(SYM, reg) |
| 106 |
|
| 107 |
#endif |
| 108 |
|
| 109 |
/* clang-format off */ |
| 110 |
# ifdef __PIC__ |
| 111 |
# undef SPARC_LOAD_ADDRESS |
| 112 |
# undef SPARC_LOAD_ADDRESS_LEAF |
| 113 |
# define SPARC_LOAD_ADDRESS(SYM, reg) \ |
| 114 |
SPARC_SETUP_GOT_REG(reg); \ |
| 115 |
sethi %hi(SYM), %o7; \ |
| 116 |
or %o7, %lo(SYM), %o7; \ |
| 117 |
LDPTR [reg + %o7], reg; |
| 118 |
# endif |
| 119 |
|
| 120 |
# ifndef SPARC_LOAD_ADDRESS_LEAF |
| 121 |
# define SPARC_LOAD_ADDRESS_LEAF(SYM, reg, tmp) \ |
| 122 |
mov %o7, tmp; \ |
| 123 |
SPARC_LOAD_ADDRESS(SYM, reg) \ |
| 124 |
mov tmp, %o7; |
| 125 |
# endif |
| 126 |
/* clang-format on */ |
| 127 |
|
| 128 |
#ifndef __ASSEMBLER__ |
| 129 |
extern unsigned int OPENSSL_sparcv9cap_P[2]; |
| 130 |
#endif |
| 131 |
|
| 132 |
#endif /* OSSL_CRYPTO_SPARC_ARCH_H */ |