Browse Source

ignore host writes to fromhost if old value not 0

confprec
Andrew Waterman 14 years ago
parent
commit
c0f8506da0
  1. 22
      riscv/htif.cc

22
riscv/htif.cc

@ -65,32 +65,32 @@ void htif_isasim_t::tick_once()
if (coreid == 0xFFFFF) // system control register space if (coreid == 0xFFFFF) // system control register space
{ {
uint64_t pcr = sim->get_scr(regno); uint64_t scr = sim->get_scr(regno);
send(&pcr, sizeof(pcr)); send(&scr, sizeof(scr));
break; break;
} }
assert(coreid < sim->num_cores()); assert(coreid < sim->num_cores());
uint64_t pcr = sim->procs[coreid]->get_pcr(regno); uint64_t old_val = sim->procs[coreid]->get_pcr(regno);
send(&pcr, sizeof(pcr)); send(&old_val, sizeof(old_val));
if (regno == PCR_TOHOST) if (regno == PCR_TOHOST)
sim->procs[coreid]->tohost = 0; sim->procs[coreid]->tohost = 0;
if (hdr.cmd == HTIF_CMD_WRITE_CONTROL_REG) if (hdr.cmd == HTIF_CMD_WRITE_CONTROL_REG)
{ {
uint64_t val; uint64_t new_val;
memcpy(&val, p.get_payload(), sizeof(val)); memcpy(&new_val, p.get_payload(), sizeof(new_val));
if (regno == PCR_RESET) if (regno == PCR_RESET)
{ {
if (reset && !(val & 1)) if (reset && !(new_val & 1))
reset = false; reset = false;
sim->procs[coreid]->reset(val & 1); sim->procs[coreid]->reset(new_val & 1);
} }
else if (regno == PCR_FROMHOST && old_val != 0)
; // ignore host writes to fromhost if target hasn't yet consumed
else else
{ sim->procs[coreid]->set_pcr(regno, new_val);
sim->procs[coreid]->set_pcr(regno, val);
}
} }
break; break;
} }

Loading…
Cancel
Save