Merge branch 'debug-0.13' into HEAD
authorMegan Wachs <megan@sifive.com>
Mon, 15 May 2017 16:53:42 +0000 (09:53 -0700)
committerMegan Wachs <megan@sifive.com>
Mon, 15 May 2017 16:53:42 +0000 (09:53 -0700)
riscv/debug_module.cc
riscv/decode.h
riscv/processor.cc
riscv/remote_bitbang.cc

index 533b959b9d3cf487b70910189f60482229185acc..fafddf14ab3d6fdd9328b6c811eda57feac92589 100644 (file)
@@ -205,19 +205,19 @@ bool debug_module_t::dmi_read(unsigned address, uint32_t *value)
   D(fprintf(stderr, "dmi_read(0x%x) -> ", address));
   if (address >= DMI_DATA0 && address < DMI_DATA0 + abstractcs.datacount) {
     unsigned i = address - DMI_DATA0;
-    result = read32(dmdata, i);
+    result = abstractcs.busy ? -1 : read32(dmdata, i);
 
     if (abstractcs.busy && abstractcs.cmderr == CMDERR_NONE) {
       abstractcs.cmderr = CMDERR_BUSY;
     }
 
-    if ((abstractauto.autoexecdata >> i) & 1){
+    if (!abstractcs.busy && ((abstractauto.autoexecdata >> i) & 1)) {
       perform_abstract_command();
     }
   } else if (address >= DMI_PROGBUF0 && address < DMI_PROGBUF0 + progsize) {
     unsigned i = address - DMI_PROGBUF0;
-    result = read32(program_buffer, i);
-    if ((abstractauto.autoexecprogbuf >> i) & 1) {
+    result = abstractcs.busy ? -1 : read32(program_buffer, i);
+    if (!abstractcs.busy && ((abstractauto.autoexecprogbuf >> i) & 1)) {
       perform_abstract_command();
     }
 
@@ -396,13 +396,14 @@ bool debug_module_t::dmi_write(unsigned address, uint32_t value)
   D(fprintf(stderr, "dmi_write(0x%x, 0x%x)\n", address, value));
   if (address >= DMI_DATA0 && address < DMI_DATA0 + abstractcs.datacount) {
     unsigned i = address - DMI_DATA0;
-    write32(dmdata, address - DMI_DATA0, value);
+    if (!abstractcs.busy)
+      write32(dmdata, address - DMI_DATA0, value);
 
     if (abstractcs.busy && abstractcs.cmderr == CMDERR_NONE) {
       abstractcs.cmderr = CMDERR_BUSY;
     }
 
-    if ((abstractauto.autoexecdata >> i) & 1) {
+    if (!abstractcs.busy && ((abstractauto.autoexecdata >> i) & 1)) {
       perform_abstract_command();
     }
     return true;
@@ -410,9 +411,10 @@ bool debug_module_t::dmi_write(unsigned address, uint32_t value)
   } else if (address >= DMI_PROGBUF0 && address < DMI_PROGBUF0 + progsize) {
     unsigned i = address - DMI_PROGBUF0;
     
-    write32(program_buffer, i, value);
+    if (!abstractcs.busy)
+      write32(program_buffer, i, value);
 
-    if ((abstractauto.autoexecprogbuf >> i) & 1) {
+    if (!abstractcs.busy && ((abstractauto.autoexecprogbuf >> i) & 1)) {
       perform_abstract_command();
     }
     return true;
@@ -437,6 +439,9 @@ bool debug_module_t::dmi_write(unsigned address, uint32_t value)
               debug_rom_flags[dmcontrol.hartsel] |= (1 << DEBUG_ROM_FLAG_RESUME);
               resumeack[dmcontrol.hartsel] = false;
             }
+           if (dmcontrol.ndmreset) {
+             proc->reset();
+           }
           }
         }
         return true;
index a76a6e4e108ea473698aac9cae6642807c6f85c3..9dcd809eb70261e448f0deac980f1f74472b81c6 100644 (file)
@@ -144,7 +144,7 @@ private:
   })
 # define WRITE_FREG(reg, value) ({ \
     freg_t wdata = freg(value); /* value may have side effects */ \
-    STATE.log_reg_write = (commit_log_reg_t){((reg) << 1) | 1, wdata}; \
+    STATE.log_reg_write = (commit_log_reg_t){((reg) << 1) | 1, wdata.v}; \
     DO_WRITE_FREG(reg, wdata); \
   })
 #endif
index b2c2d344ec0e3db50120db13e09153d2e706d108..6f0d3a7b9008bef422a8769ec4b881e2edc81fb7 100644 (file)
@@ -189,7 +189,6 @@ void processor_t::set_privilege(reg_t prv)
 
 void processor_t::enter_debug_mode(uint8_t cause)
 {
-  fprintf(stderr, "Entering debug mode because of cause %d", cause);
   state.dcsr.cause = cause;
   state.dcsr.prv = state.prv;
   set_privilege(PRV_M);
index 75aa8fe53bcf6e564ecf9e3c816ff3683bff15c4..cff9ed765c385c6f260ed9c6bebbcc3803459bd2 100644 (file)
@@ -157,7 +157,7 @@ void remote_bitbang_t::execute_commands()
 
     if (recv_end == -1) {
       if (errno == EAGAIN) {
-        // We'll try again the next call.
+        break;
       } else {
         fprintf(stderr, "remote_bitbang failed to read on socket: %s (%d)\n",
             strerror(errno), errno);