ignore host writes to fromhost if old value not 0
authorAndrew Waterman <waterman@cs.berkeley.edu>
Tue, 26 Mar 2013 03:04:09 +0000 (20:04 -0700)
committerAndrew Waterman <waterman@cs.berkeley.edu>
Tue, 26 Mar 2013 03:04:09 +0000 (20:04 -0700)
riscv/htif.cc

index 64ef40a1fc5720ff864542db543e16143710ddbf..438d86274cdc5dd9069682fe86490fcefa2fb108 100644 (file)
@@ -65,32 +65,32 @@ void htif_isasim_t::tick_once()
 
       if (coreid == 0xFFFFF) // system control register space
       {
-        uint64_t pcr = sim->get_scr(regno);
-        send(&pcr, sizeof(pcr));
+        uint64_t scr = sim->get_scr(regno);
+        send(&scr, sizeof(scr));
         break;
       }
 
       assert(coreid < sim->num_cores());
-      uint64_t pcr = sim->procs[coreid]->get_pcr(regno);
-      send(&pcr, sizeof(pcr));
+      uint64_t old_val = sim->procs[coreid]->get_pcr(regno);
+      send(&old_val, sizeof(old_val));
 
       if (regno == PCR_TOHOST)
           sim->procs[coreid]->tohost = 0;
 
       if (hdr.cmd == HTIF_CMD_WRITE_CONTROL_REG)
       {
-        uint64_t val;
-        memcpy(&val, p.get_payload(), sizeof(val));
+        uint64_t new_val;
+        memcpy(&new_val, p.get_payload(), sizeof(new_val));
         if (regno == PCR_RESET)
         {
-          if (reset && !(val & 1))
+          if (reset && !(new_val & 1))
             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
-        {
-          sim->procs[coreid]->set_pcr(regno, val);
-        }
+          sim->procs[coreid]->set_pcr(regno, new_val);
       }
       break;
     }