1 | /*
|
---|
2 | * Copyright 2022 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_RISCV_ARCH_H
|
---|
11 | # define OSSL_CRYPTO_RISCV_ARCH_H
|
---|
12 |
|
---|
13 | # include <ctype.h>
|
---|
14 | # include <stdint.h>
|
---|
15 |
|
---|
16 | # define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) +1
|
---|
17 | extern uint32_t OPENSSL_riscvcap_P[ ((
|
---|
18 | # include "riscv_arch.def"
|
---|
19 | ) + sizeof(uint32_t) - 1) / sizeof(uint32_t) ];
|
---|
20 |
|
---|
21 | # ifdef OPENSSL_RISCVCAP_IMPL
|
---|
22 | # define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) +1
|
---|
23 | uint32_t OPENSSL_riscvcap_P[ ((
|
---|
24 | # include "riscv_arch.def"
|
---|
25 | ) + sizeof(uint32_t) - 1) / sizeof(uint32_t) ];
|
---|
26 | # endif
|
---|
27 |
|
---|
28 | # define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) \
|
---|
29 | static inline int RISCV_HAS_##NAME(void) \
|
---|
30 | { \
|
---|
31 | return (OPENSSL_riscvcap_P[INDEX] & (1 << BIT_INDEX)) != 0; \
|
---|
32 | }
|
---|
33 | # include "riscv_arch.def"
|
---|
34 |
|
---|
35 | struct RISCV_capability_s {
|
---|
36 | const char *name;
|
---|
37 | size_t index;
|
---|
38 | size_t bit_offset;
|
---|
39 | };
|
---|
40 |
|
---|
41 | # define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) +1
|
---|
42 | extern const struct RISCV_capability_s RISCV_capabilities[
|
---|
43 | # include "riscv_arch.def"
|
---|
44 | ];
|
---|
45 |
|
---|
46 | # ifdef OPENSSL_RISCVCAP_IMPL
|
---|
47 | # define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) \
|
---|
48 | { #NAME, INDEX, BIT_INDEX },
|
---|
49 | const struct RISCV_capability_s RISCV_capabilities[] = {
|
---|
50 | # include "riscv_arch.def"
|
---|
51 | };
|
---|
52 | # endif
|
---|
53 |
|
---|
54 | # define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) +1
|
---|
55 | static const size_t kRISCVNumCaps =
|
---|
56 | # include "riscv_arch.def"
|
---|
57 | ;
|
---|
58 |
|
---|
59 | #endif
|
---|