new tohost/fromhost semantics
authorAndrew Waterman <waterman@eecs.berkeley.edu>
Fri, 31 Aug 2012 00:36:30 +0000 (17:36 -0700)
committerAndrew Waterman <waterman@eecs.berkeley.edu>
Fri, 31 Aug 2012 00:36:30 +0000 (17:36 -0700)
riscv/htif.cc
riscv/insns/mtpcr.h
riscv/processor.cc
riscv/processor.h

index 1be8d87ecbcca36c16aaf52cd46c7478eb636b24..cffe3baeac521f5c2e91c6f1dd1dde74e5eabe86 100644 (file)
@@ -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);
index 9b0beba15661037b5a739d5921a3c7c2a4eda65c..5cd0134e0ba933c08df7daebe9b953354508b747 100644 (file)
@@ -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;
index 070ec15345eb568ab6b1bf49c871d52b2afc14fc..e0471269ab96c400e46602beef67996773a69ad5 100644 (file)
@@ -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;
index 927f06c74c85aaeaa55105a6ac1dda0142992276..e9c8be32850bdcfee6451a613dd1fbc6eb6ad0d8 100644 (file)
@@ -87,6 +87,7 @@ private:
 
   friend class sim_t;
   friend class mmu_t;
+  friend class htif_t;
 
   #include "dispatch.h"
 };