1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 #ifndef _ASMRISCV_ISA_H_ 3 #define _ASMRISCV_ISA_H_ 4 5 #include <bitops.h> 6 #include <util.h> 7 #include <asm/setup.h> 8 9 /* 10 * We assume and use several extensions, such as Zicsr and Zifencei. 11 * Here we only track extensions which we don't assume and the 12 * framework may want to use. Unit tests may check for extensions 13 * by name not tracked here with cpu_has_extension_name() 14 */ 15 enum { 16 ISA_SSTC, 17 ISA_MAX, 18 }; 19 __static_assert(ISA_MAX <= __riscv_xlen, "Need to increase thread_info.isa"); 20 21 static inline bool cpu_has_extension(int cpu, int ext) 22 { 23 return test_bit(ext, cpus[cpu].isa); 24 } 25 26 bool cpu_has_extension_name(int cpu, const char *ext); 27 28 static inline bool has_ext(const char *ext) 29 { 30 return cpu_has_extension_name(current_thread_info()->cpu, ext); 31 } 32 33 void isa_init(struct thread_info *info); 34 35 #endif /* _ASMRISCV_ISA_H_ */ 36