diff options
author | Scott Johnson <scott.johnson@arilinc.com> | 2021-03-07 23:27:43 -0800 |
---|---|---|
committer | Andrew Waterman <aswaterman@gmail.com> | 2021-09-08 07:59:02 -0700 |
commit | 7c8ae9ba4d6f2e8b5b35918d4a0ec2f0f965ca43 (patch) | |
tree | 21914cfa9df95cfd36f40245723998257dfbc80d /riscv/clint.cc | |
parent | 6aa7506e90fb6b936288504e459eec72e42f27b2 (diff) | |
download | spike-7c8ae9ba4d6f2e8b5b35918d4a0ec2f0f965ca43.zip spike-7c8ae9ba4d6f2e8b5b35918d4a0ec2f0f965ca43.tar.gz spike-7c8ae9ba4d6f2e8b5b35918d4a0ec2f0f965ca43.tar.bz2 |
Convert mip to csr_t family
This changes the commitlog of `csrw sip` so that it only logs a change
to `mip`, instead of both `mip` and `sip`. This is arguably
preferable, since there is no real `sip` register -- it is only a view
into `mip`.
It also adds proper tracing of the modification to `mip` when doing
`csrw` to `hip`, `hvip`, and `vsip`, which were all missing
previously.
Diffstat (limited to 'riscv/clint.cc')
-rw-r--r-- | riscv/clint.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/riscv/clint.cc b/riscv/clint.cc index aee995b..72d1bbe 100644 --- a/riscv/clint.cc +++ b/riscv/clint.cc @@ -33,7 +33,7 @@ bool clint_t::load(reg_t addr, size_t len, uint8_t* bytes) if (addr >= MSIP_BASE && addr + len <= MSIP_BASE + procs.size()*sizeof(msip_t)) { std::vector<msip_t> msip(procs.size()); for (size_t i = 0; i < procs.size(); ++i) - msip[i] = !!(procs[i]->state.mip & MIP_MSIP); + msip[i] = !!(procs[i]->state.mip->read() & MIP_MSIP); memcpy(bytes, (uint8_t*)&msip[0] + addr - MSIP_BASE, len); } else if (addr >= MTIMECMP_BASE && addr + len <= MTIMECMP_BASE + procs.size()*sizeof(mtimecmp_t)) { memcpy(bytes, (uint8_t*)&mtimecmp[0] + addr - MTIMECMP_BASE, len); @@ -54,9 +54,9 @@ bool clint_t::store(reg_t addr, size_t len, const uint8_t* bytes) memset((uint8_t*)&mask[0] + addr - MSIP_BASE, 0xff, len); for (size_t i = 0; i < procs.size(); ++i) { if (!(mask[i] & 0xFF)) continue; - procs[i]->state.mip &= ~MIP_MSIP; + procs[i]->state.mip->backdoor_write_with_mask(MIP_MSIP, 0); if (!!(msip[i] & 1)) - procs[i]->state.mip |= MIP_MSIP; + procs[i]->state.mip->backdoor_write_with_mask(MIP_MSIP, MIP_MSIP); } } else if (addr >= MTIMECMP_BASE && addr + len <= MTIMECMP_BASE + procs.size()*sizeof(mtimecmp_t)) { memcpy((uint8_t*)&mtimecmp[0] + addr - MTIMECMP_BASE, bytes, len); @@ -82,8 +82,8 @@ void clint_t::increment(reg_t inc) mtime += inc; } for (size_t i = 0; i < procs.size(); i++) { - procs[i]->state.mip &= ~MIP_MTIP; + procs[i]->state.mip->backdoor_write_with_mask(MIP_MTIP, 0); if (mtime >= mtimecmp[i]) - procs[i]->state.mip |= MIP_MTIP; + procs[i]->state.mip->backdoor_write_with_mask(MIP_MTIP, MIP_MTIP); } } |