Skip to content
Snippets Groups Projects
Commit 0ef072dc authored by Nicolas Pitre's avatar Nicolas Pitre Committed by Drew Fustini
Browse files

cbqri: quick hack to allow modifications of monitor counter values

The last 64-bit word of a 4K I/O mapping (i.e. offset = 4096 - 8) can be
written to in order to change the value of an active monitor counter.
The lower 12 bits of the written value must contain the counter's MCID
and the remainder bits the desired counter value.
parent e72230f5
No related tags found
No related merge requests found
......@@ -384,6 +384,20 @@ static void riscv_cbqri_bc_write_bw_alloc(RiscvCbqriBandwidthState *bc,
}
}
static void riscv_cbqri_bc_write_counter_quickhack(RiscvCbqriBandwidthState *bc,
uint64_t value)
{
uint32_t mcid = value & 0xfff;
if (mcid >= bc->nb_mcids) {
return;
}
if (bc->mon_counters[mcid].active) {
bc->mon_counters[mcid].ctr_val = value >> 12;
}
}
static void riscv_cbqri_bc_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
......@@ -393,6 +407,9 @@ static void riscv_cbqri_bc_write(void *opaque, hwaddr addr,
assert(size == 8);
switch (addr) {
case (4 * 1024 - 8):
riscv_cbqri_bc_write_counter_quickhack(bc, value);
break;
case A_BC_CAPABILITIES:
/* read-only register */
break;
......
......@@ -373,6 +373,19 @@ static void riscv_cbqri_cc_write_alloc_ctl(RiscvCbqriCapacityState *cc,
cc->cc_alloc_ctl = value;
}
static void riscv_cbqri_cc_write_counter_quickhack(RiscvCbqriCapacityState *cc,
uint64_t value)
{
uint32_t mcid = value & 0xfff;
if (mcid >= cc->nb_mcids) {
return;
}
if (cc->mon_counters[mcid].active) {
cc->mon_counters[mcid].ctr_val = value >> 12;
}
}
static void riscv_cbqri_cc_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
......@@ -382,6 +395,9 @@ static void riscv_cbqri_cc_write(void *opaque, hwaddr addr,
assert(size == 8);
switch (addr) {
case (4 * 1024 - 8):
riscv_cbqri_cc_write_counter_quickhack(cc, value);
break;
case A_CC_CAPABILITIES:
/* read-only register */
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment