mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
target/riscv: Add support for disabling/enabling Counters
Add support for disabling/enabling the "Counters" extension. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Palmer Dabbelt <palmer@sifive.com> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
This commit is contained in:
parent
c9a73910c3
commit
0a13a5b856
3 changed files with 14 additions and 5 deletions
|
@ -56,17 +56,24 @@ static int fs(CPURISCVState *env, int csrno)
|
|||
static int ctr(CPURISCVState *env, int csrno)
|
||||
{
|
||||
#if !defined(CONFIG_USER_ONLY)
|
||||
CPUState *cs = env_cpu(env);
|
||||
RISCVCPU *cpu = RISCV_CPU(cs);
|
||||
uint32_t ctr_en = ~0u;
|
||||
|
||||
if (!cpu->cfg.ext_counters) {
|
||||
/* The Counters extensions is not enabled */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* The counters are always enabled on newer priv specs, as the CSR has
|
||||
* changed from controlling that the counters can be read to controlling
|
||||
* that the counters increment.
|
||||
* The counters are always enabled at run time on newer priv specs, as the
|
||||
* CSR has changed from controlling that the counters can be read to
|
||||
* controlling that the counters increment.
|
||||
*/
|
||||
if (env->priv_ver > PRIV_VERSION_1_09_1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t ctr_en = ~0u;
|
||||
|
||||
if (env->priv < PRV_M) {
|
||||
ctr_en &= env->mcounteren;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue