1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright 2024 Rivos, Inc 4 */ 5 6 #ifndef _ASM_RISCV_SYS_HWPROBE_H 7 #define _ASM_RISCV_SYS_HWPROBE_H 8 9 #include <asm/cpufeature.h> 10 11 #define VENDOR_EXT_KEY(ext) \ 12 do { \ 13 if (__riscv_isa_extension_available(isainfo->isa, RISCV_ISA_VENDOR_EXT_##ext)) \ 14 pair->value |= RISCV_HWPROBE_VENDOR_EXT_##ext; \ 15 else \ 16 missing |= RISCV_HWPROBE_VENDOR_EXT_##ext; \ 17 } while (false) 18 19 /* 20 * Loop through and record extensions that 1) anyone has, and 2) anyone 21 * doesn't have. 22 * 23 * _extension_checks is an arbitrary C block to set the values of pair->value 24 * and missing. It should be filled with VENDOR_EXT_KEY expressions. 25 */ 26 #define VENDOR_EXTENSION_SUPPORTED(pair, cpus, per_hart_vendor_bitmap, _extension_checks) \ 27 do { \ 28 int cpu; \ 29 u64 missing = 0; \ 30 for_each_cpu(cpu, (cpus)) { \ 31 struct riscv_isavendorinfo *isainfo = &(per_hart_vendor_bitmap)[cpu]; \ 32 _extension_checks \ 33 } \ 34 (pair)->value &= ~missing; \ 35 } while (false) \ 36 37 #endif /* _ASM_RISCV_SYS_HWPROBE_H */ 38