1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef _ASM_CPUFEATURE_H
4 #define _ASM_CPUFEATURE_H
5 struct riscv_isa_ext_data {
6 	const unsigned int id;
7 	const char *name;
8 	const char *property;
9 	const unsigned int *subset_ext_ids;
10 	const unsigned int subset_ext_size;
11 	int (*validate)(const struct riscv_isa_ext_data *data, const unsigned long *isa_bitmap);
12 };
13 
14 #define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, _subset_exts_size, _validate) {	\
15 	.name = #_name,									\
16 	.property = #_name,								\
17 	.id = _id,									\
18 	.subset_ext_ids = _subset_exts,							\
19 	.subset_ext_size = _subset_exts_size,						\
20 	.validate = _validate								\
21 }
22 
23 #define __RISCV_ISA_EXT_DATA(_name, _id) _RISCV_ISA_EXT_DATA(_name, _id, NULL, 0, NULL)
24 #define __RISCV_ISA_EXT_DATA_VALIDATE(_name, _id, _validate) \
25 			_RISCV_ISA_EXT_DATA(_name, _id, NULL, 0, _validate)
26 
27 /* Used to declare pure "lasso" extension (Zk for instance) */
28 #define __RISCV_ISA_EXT_BUNDLE(_name, _bundled_exts) \
29 	_RISCV_ISA_EXT_DATA(_name, RISCV_ISA_EXT_INVALID, _bundled_exts, \
30 			    ARRAY_SIZE(_bundled_exts), NULL)
31 
32 /* Used to declare extensions that are a superset of other extensions (Zvbb for instance) */
33 #define __RISCV_ISA_EXT_SUPERSET(_name, _id, _sub_exts) \
34 	_RISCV_ISA_EXT_DATA(_name, _id, _sub_exts, ARRAY_SIZE(_sub_exts), NULL)
35 #define __RISCV_ISA_EXT_SUPERSET_VALIDATE(_name, _id, _sub_exts, _validate) \
36 	_RISCV_ISA_EXT_DATA(_name, _id, _sub_exts, ARRAY_SIZE(_sub_exts), _validate)
37 #endif
38