1 #include <string.h> 2 #include <sys/auxv.h> 3 4 #include <riscv/linux/api.h> 5 6 /** 7 * arch/riscv/include/uapi/asm/hwcap.h 8 * 9 * This must be kept in sync with the upstream kernel header. 10 */ 11 #define COMPAT_HWCAP_ISA_I (1 << ('I' - 'A')) 12 #define COMPAT_HWCAP_ISA_M (1 << ('M' - 'A')) 13 #define COMPAT_HWCAP_ISA_A (1 << ('A' - 'A')) 14 #define COMPAT_HWCAP_ISA_F (1 << ('F' - 'A')) 15 #define COMPAT_HWCAP_ISA_D (1 << ('D' - 'A')) 16 #define COMPAT_HWCAP_ISA_C (1 << ('C' - 'A')) 17 #define COMPAT_HWCAP_ISA_V (1 << ('V' - 'A')) 18 cpuinfo_riscv_linux_decode_isa_from_hwcap(struct cpuinfo_riscv_isa isa[restrict static1])19void cpuinfo_riscv_linux_decode_isa_from_hwcap(struct cpuinfo_riscv_isa isa[restrict static 1]) { 20 const unsigned long hwcap = getauxval(AT_HWCAP); 21 22 if (hwcap & COMPAT_HWCAP_ISA_I) { 23 isa->i = true; 24 } 25 if (hwcap & COMPAT_HWCAP_ISA_M) { 26 isa->m = true; 27 } 28 if (hwcap & COMPAT_HWCAP_ISA_A) { 29 isa->a = true; 30 } 31 if (hwcap & COMPAT_HWCAP_ISA_F) { 32 isa->f = true; 33 } 34 if (hwcap & COMPAT_HWCAP_ISA_D) { 35 isa->d = true; 36 } 37 if (hwcap & COMPAT_HWCAP_ISA_C) { 38 isa->c = true; 39 } 40 if (hwcap & COMPAT_HWCAP_ISA_V) { 41 isa->v = true; 42 } 43 } 44