aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@eecs.berkeley.edu>2012-08-30 17:36:30 -0700
committerAndrew Waterman <waterman@eecs.berkeley.edu>2012-08-30 17:36:30 -0700
commita1682c1ea29d5ca89fc1552fc02e91f93a1d2c3a (patch)
treefa7db8942603cd6f1a75452039cd56add41dff08
parentb3d3f82d4e38f2712d5ccf9c69051137ec5fca76 (diff)
downloadriscv-isa-sim-a1682c1ea29d5ca89fc1552fc02e91f93a1d2c3a.zip
riscv-isa-sim-a1682c1ea29d5ca89fc1552fc02e91f93a1d2c3a.tar.gz
riscv-isa-sim-a1682c1ea29d5ca89fc1552fc02e91f93a1d2c3a.tar.bz2
new tohost/fromhost semantics
-rw-r--r--riscv/htif.cc13
-rw-r--r--riscv/insns/mtpcr.h3
-rw-r--r--riscv/processor.cc3
-rw-r--r--riscv/processor.h1
4 files changed, 12 insertions, 8 deletions
diff --git a/riscv/htif.cc b/riscv/htif.cc
index 1be8d87..cffe3ba 100644
--- a/riscv/htif.cc
+++ b/riscv/htif.cc
@@ -116,17 +116,19 @@ int htif_t::wait_for_packet()
sim->mmu->store_uint64((p.addr+i)*HTIF_DATA_ALIGN, p.data[i]);
break;
case APP_CMD_READ_CONTROL_REG:
+ case APP_CMD_WRITE_CONTROL_REG:
{
assert(pcr_coreid < sim->num_cores());
assert(p.data_size == 1);
ackpacket.data_size = 1;
reg_t pcr = sim->procs[pcr_coreid]->get_pcr(pcr_reg);
+ if (pcr_reg == PCR_TOHOST)
+ sim->procs[pcr_coreid]->tohost = 0;
memcpy(ackpacket.data, &pcr, sizeof(pcr));
- break;
- }
- case APP_CMD_WRITE_CONTROL_REG:
- assert(pcr_coreid < sim->num_cores());
- assert(p.data_size == 1);
+
+ if (p.cmd == APP_CMD_READ_CONTROL_REG)
+ break;
+
if (pcr_reg == PCR_RESET)
{
reset = p.data[0] & 1;
@@ -139,6 +141,7 @@ int htif_t::wait_for_packet()
sim->procs[pcr_coreid]->set_pcr(pcr_reg, pcr);
}
break;
+ }
}
send_packet(&ackpacket);
diff --git a/riscv/insns/mtpcr.h b/riscv/insns/mtpcr.h
index 9b0beba..5cd0134 100644
--- a/riscv/insns/mtpcr.h
+++ b/riscv/insns/mtpcr.h
@@ -1,5 +1,4 @@
require_supervisor;
reg_t val = get_pcr(insn.rtype.rs1);
-if (val == 0 || insn.rtype.rs1 != PCR_TOHOST)
- set_pcr(insn.rtype.rs1, RS2);
+set_pcr(insn.rtype.rs1, RS2);
RD = val;
diff --git a/riscv/processor.cc b/riscv/processor.cc
index 070ec15..e047126 100644
--- a/riscv/processor.cc
+++ b/riscv/processor.cc
@@ -271,7 +271,8 @@ void processor_t::set_pcr(int which, reg_t val)
vecbanks_count = __builtin_popcountll(vecbanks);
break;
case PCR_TOHOST:
- tohost = val;
+ if (tohost == 0)
+ tohost = val;
break;
case PCR_FROMHOST:
fromhost = val;
diff --git a/riscv/processor.h b/riscv/processor.h
index 927f06c..e9c8be3 100644
--- a/riscv/processor.h
+++ b/riscv/processor.h
@@ -87,6 +87,7 @@ private:
friend class sim_t;
friend class mmu_t;
+ friend class htif_t;
#include "dispatch.h"
};