|
8 | 8 | #ifndef _ASM_RISCV_HWCAP_H |
9 | 9 | #define _ASM_RISCV_HWCAP_H |
10 | 10 |
|
11 | | -#include <asm/alternative-macros.h> |
12 | | -#include <asm/errno.h> |
13 | | -#include <linux/bits.h> |
14 | 11 | #include <uapi/asm/hwcap.h> |
15 | 12 |
|
16 | 13 | #define RISCV_ISA_EXT_a ('a' - 'a') |
|
67 | 64 | #define RISCV_ISA_EXT_SxAIA RISCV_ISA_EXT_SSAIA |
68 | 65 | #endif |
69 | 66 |
|
70 | | -#ifndef __ASSEMBLY__ |
71 | | - |
72 | | -#include <linux/jump_label.h> |
73 | | -#include <asm/cpufeature.h> |
74 | | - |
75 | | -unsigned long riscv_get_elf_hwcap(void); |
76 | | - |
77 | | -struct riscv_isa_ext_data { |
78 | | - const unsigned int id; |
79 | | - const char *name; |
80 | | - const char *property; |
81 | | -}; |
82 | | - |
83 | | -extern const struct riscv_isa_ext_data riscv_isa_ext[]; |
84 | | -extern const size_t riscv_isa_ext_count; |
85 | | -extern bool riscv_isa_fallback; |
86 | | - |
87 | | -unsigned long riscv_isa_extension_base(const unsigned long *isa_bitmap); |
88 | | - |
89 | | -#define riscv_isa_extension_mask(ext) BIT_MASK(RISCV_ISA_EXT_##ext) |
90 | | - |
91 | | -bool __riscv_isa_extension_available(const unsigned long *isa_bitmap, int bit); |
92 | | -#define riscv_isa_extension_available(isa_bitmap, ext) \ |
93 | | - __riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_##ext) |
94 | | - |
95 | | -static __always_inline bool |
96 | | -riscv_has_extension_likely(const unsigned long ext) |
97 | | -{ |
98 | | - compiletime_assert(ext < RISCV_ISA_EXT_MAX, |
99 | | - "ext must be < RISCV_ISA_EXT_MAX"); |
100 | | - |
101 | | - if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE)) { |
102 | | - asm_volatile_goto( |
103 | | - ALTERNATIVE("j %l[l_no]", "nop", 0, %[ext], 1) |
104 | | - : |
105 | | - : [ext] "i" (ext) |
106 | | - : |
107 | | - : l_no); |
108 | | - } else { |
109 | | - if (!__riscv_isa_extension_available(NULL, ext)) |
110 | | - goto l_no; |
111 | | - } |
112 | | - |
113 | | - return true; |
114 | | -l_no: |
115 | | - return false; |
116 | | -} |
117 | | - |
118 | | -static __always_inline bool |
119 | | -riscv_has_extension_unlikely(const unsigned long ext) |
120 | | -{ |
121 | | - compiletime_assert(ext < RISCV_ISA_EXT_MAX, |
122 | | - "ext must be < RISCV_ISA_EXT_MAX"); |
123 | | - |
124 | | - if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE)) { |
125 | | - asm_volatile_goto( |
126 | | - ALTERNATIVE("nop", "j %l[l_yes]", 0, %[ext], 1) |
127 | | - : |
128 | | - : [ext] "i" (ext) |
129 | | - : |
130 | | - : l_yes); |
131 | | - } else { |
132 | | - if (__riscv_isa_extension_available(NULL, ext)) |
133 | | - goto l_yes; |
134 | | - } |
135 | | - |
136 | | - return false; |
137 | | -l_yes: |
138 | | - return true; |
139 | | -} |
140 | | - |
141 | | -static __always_inline bool riscv_cpu_has_extension_likely(int cpu, const unsigned long ext) |
142 | | -{ |
143 | | - if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE) && riscv_has_extension_likely(ext)) |
144 | | - return true; |
145 | | - |
146 | | - return __riscv_isa_extension_available(hart_isa[cpu].isa, ext); |
147 | | -} |
148 | | - |
149 | | -static __always_inline bool riscv_cpu_has_extension_unlikely(int cpu, const unsigned long ext) |
150 | | -{ |
151 | | - if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE) && riscv_has_extension_unlikely(ext)) |
152 | | - return true; |
153 | | - |
154 | | - return __riscv_isa_extension_available(hart_isa[cpu].isa, ext); |
155 | | -} |
156 | | -#endif |
157 | | - |
158 | 67 | #endif /* _ASM_RISCV_HWCAP_H */ |
0 commit comments