Update debug_defines
[riscv-isa-sim.git] / riscv / debug_module.h
index f0d2a475ad976afea9e321cfdb8978a90b2d429c..d581be8338c5d0e23a26c758b240061bd85d0570 100644 (file)
@@ -18,6 +18,7 @@ typedef struct {
 } dmcontrol_t;
 
 typedef struct {
+  bool impebreak;
   bool allnonexistant;
   bool anynonexistant;
   bool allunavail;
@@ -31,8 +32,7 @@ typedef struct {
   bool authenticated;
   bool authbusy;
   bool cfgstrvalid;
-  unsigned versionhi;
-  unsigned versionlo;
+  unsigned version;
 } dmstatus_t;
 
 typedef enum cmderr {
@@ -47,7 +47,7 @@ typedef enum cmderr {
 typedef struct {
   bool busy;
   unsigned datacount;
-  unsigned progsize;
+  unsigned progbufsize;
   cmderr_t cmderr;
 } abstractcs_t;
 
@@ -56,10 +56,26 @@ typedef struct {
   unsigned autoexecdata;
 } abstractauto_t;
 
+typedef struct {
+  unsigned version;
+  bool readonaddr;
+  unsigned sbaccess;
+  bool autoincrement;
+  bool readondata;
+  unsigned error;
+  unsigned asize;
+  bool access128;
+  bool access64;
+  bool access32;
+  bool access16;
+  bool access8;
+} sbcs_t;
+
 class debug_module_t : public abstract_device_t
 {
   public:
-    debug_module_t(sim_t *sim);
+    debug_module_t(sim_t *sim, unsigned progbufsize);
+    ~debug_module_t();
 
     void add_device(bus_t *bus);
 
@@ -74,18 +90,25 @@ class debug_module_t : public abstract_device_t
 
   private:
     static const unsigned datasize = 2;
-    static const unsigned progsize = 16;
+    // Size of program_buffer in 32-bit words, as exposed to the rest of the
+    // world.
+    unsigned progbufsize;
+    // Actual size of the program buffer, which is 1 word bigger than we let on
+    // to implement the implicit ebreak at the end.
+    unsigned program_buffer_bytes;
     static const unsigned debug_data_start = 0x380;
-    static const unsigned debug_progbuf_start = debug_data_start - progsize*4;
+    unsigned debug_progbuf_start;
 
     static const unsigned debug_abstract_size = 2;
-    static const unsigned debug_abstract_start = debug_progbuf_start - debug_abstract_size*4;
-        
+    unsigned debug_abstract_start;
+
+    static const unsigned hartsellen = 10;
+
     sim_t *sim;
 
     uint8_t debug_rom_whereto[4];
     uint8_t debug_abstract[debug_abstract_size * 4];
-    uint8_t program_buffer[progsize * 4];
+    uint8_t *program_buffer;
     uint8_t dmdata[datasize * 4];
     
     bool halted[1024];
@@ -95,12 +118,21 @@ class debug_module_t : public abstract_device_t
     void write32(uint8_t *rom, unsigned int index, uint32_t value);
     uint32_t read32(uint8_t *rom, unsigned int index);
 
+    void sb_autoincrement();
+    void sb_read();
+    void sb_write();
+    unsigned sb_access_bits();
+
     dmcontrol_t dmcontrol;
     dmstatus_t dmstatus;
     abstractcs_t abstractcs;
     abstractauto_t abstractauto;
     uint32_t command;
 
+    sbcs_t sbcs;
+    uint32_t sbaddress[4];
+    uint32_t sbdata[4];
+
     processor_t *current_proc() const;
     void reset();
     bool perform_abstract_command();