4 * Copyright (c) 2016-2017 Sagar Karandikar, sagark@eecs.berkeley.edu
5 * Copyright (c) 2017-2018 SiFive, Inc.
6 * Copyright (c) 2021-2023 PLCT Lab
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2 or later, as published by the Free Software Foundation.
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef RISCV_CPU_CFG_H
22 #define RISCV_CPU_CFG_H
25 * map is a 16-bit bitmap: the most significant set bit in map is the maximum
26 * satp mode that is supported. It may be chosen by the user and must respect
27 * what qemu implements (valid_1_10_32/64) and what the hw is capable of
28 * (supported bitmap below).
30 * init is a 16-bit bitmap used to make sure the user selected a correct
31 * configuration as per the specification.
33 * supported is a 16-bit bitmap used to reflect the hw capabilities.
36 uint16_t map
, init
, supported
;
39 struct RISCVCPUConfig
{
129 /* Vendor-specific custom extensions */
134 bool ext_xtheadcondmov
;
135 bool ext_xtheadfmemidx
;
138 bool ext_xtheadmemidx
;
139 bool ext_xtheadmempair
;
141 bool ext_XVentanaCondOps
;
146 uint16_t cbom_blocksize
;
147 uint16_t cbop_blocksize
;
148 uint16_t cboz_blocksize
;
154 bool short_isa_string
;
156 #ifndef CONFIG_USER_ONLY
157 RISCVSATPMap satp_mode
;
161 typedef struct RISCVCPUConfig RISCVCPUConfig
;
163 /* Helper functions to test for extensions. */
165 static inline bool always_true_p(const RISCVCPUConfig
*cfg
__attribute__((__unused__
)))
170 static inline bool has_xthead_p(const RISCVCPUConfig
*cfg
)
172 return cfg
->ext_xtheadba
|| cfg
->ext_xtheadbb
||
173 cfg
->ext_xtheadbs
|| cfg
->ext_xtheadcmo
||
174 cfg
->ext_xtheadcondmov
||
175 cfg
->ext_xtheadfmemidx
|| cfg
->ext_xtheadfmv
||
176 cfg
->ext_xtheadmac
|| cfg
->ext_xtheadmemidx
||
177 cfg
->ext_xtheadmempair
|| cfg
->ext_xtheadsync
;
180 #define MATERIALISE_EXT_PREDICATE(ext) \
181 static inline bool has_ ## ext ## _p(const RISCVCPUConfig *cfg) \
183 return cfg->ext_ ## ext ; \
186 MATERIALISE_EXT_PREDICATE(xtheadba
)
187 MATERIALISE_EXT_PREDICATE(xtheadbb
)
188 MATERIALISE_EXT_PREDICATE(xtheadbs
)
189 MATERIALISE_EXT_PREDICATE(xtheadcmo
)
190 MATERIALISE_EXT_PREDICATE(xtheadcondmov
)
191 MATERIALISE_EXT_PREDICATE(xtheadfmemidx
)
192 MATERIALISE_EXT_PREDICATE(xtheadfmv
)
193 MATERIALISE_EXT_PREDICATE(xtheadmac
)
194 MATERIALISE_EXT_PREDICATE(xtheadmemidx
)
195 MATERIALISE_EXT_PREDICATE(xtheadmempair
)
196 MATERIALISE_EXT_PREDICATE(xtheadsync
)
197 MATERIALISE_EXT_PREDICATE(XVentanaCondOps
)