18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copied from arch/arm64/include/asm/hwcap.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2012 ARM Ltd.
68c2ecf20Sopenharmony_ci * Copyright (C) 2017 SiFive
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci#ifndef _ASM_RISCV_HWCAP_H
98c2ecf20Sopenharmony_ci#define _ASM_RISCV_HWCAP_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/bits.h>
128c2ecf20Sopenharmony_ci#include <uapi/asm/hwcap.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
158c2ecf20Sopenharmony_ci/*
168c2ecf20Sopenharmony_ci * This yields a mask that user programs can use to figure out what
178c2ecf20Sopenharmony_ci * instruction set this cpu supports.
188c2ecf20Sopenharmony_ci */
198c2ecf20Sopenharmony_ci#define ELF_HWCAP		(elf_hwcap)
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_cienum {
228c2ecf20Sopenharmony_ci	CAP_HWCAP = 1,
238c2ecf20Sopenharmony_ci};
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ciextern unsigned long elf_hwcap;
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define RISCV_ISA_EXT_a		('a' - 'a')
288c2ecf20Sopenharmony_ci#define RISCV_ISA_EXT_c		('c' - 'a')
298c2ecf20Sopenharmony_ci#define RISCV_ISA_EXT_d		('d' - 'a')
308c2ecf20Sopenharmony_ci#define RISCV_ISA_EXT_f		('f' - 'a')
318c2ecf20Sopenharmony_ci#define RISCV_ISA_EXT_h		('h' - 'a')
328c2ecf20Sopenharmony_ci#define RISCV_ISA_EXT_i		('i' - 'a')
338c2ecf20Sopenharmony_ci#define RISCV_ISA_EXT_m		('m' - 'a')
348c2ecf20Sopenharmony_ci#define RISCV_ISA_EXT_s		('s' - 'a')
358c2ecf20Sopenharmony_ci#define RISCV_ISA_EXT_u		('u' - 'a')
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define RISCV_ISA_EXT_MAX	64
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ciunsigned long riscv_isa_extension_base(const unsigned long *isa_bitmap);
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define riscv_isa_extension_mask(ext) BIT_MASK(RISCV_ISA_EXT_##ext)
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_cibool __riscv_isa_extension_available(const unsigned long *isa_bitmap, int bit);
448c2ecf20Sopenharmony_ci#define riscv_isa_extension_available(isa_bitmap, ext)	\
458c2ecf20Sopenharmony_ci	__riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_##ext)
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#endif
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#endif /* _ASM_RISCV_HWCAP_H */
50