sparc_arch.h 4.3 KB

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