1 // See LICENSE for license details.
2 #ifndef _RISCV_DEBUG_MODULE_H
3 #define _RISCV_DEBUG_MODULE_H
43 CMDERR_HALTRESUME
= 4,
55 unsigned autoexecprogbuf
;
56 unsigned autoexecdata
;
74 class debug_module_t
: public abstract_device_t
77 debug_module_t(sim_t
*sim
, unsigned progbufsize
);
80 void add_device(bus_t
*bus
);
82 bool load(reg_t addr
, size_t len
, uint8_t* bytes
);
83 bool store(reg_t addr
, size_t len
, const uint8_t* bytes
);
85 // Debug Module Interface that the debugger (in our case through JTAG DTM)
86 // uses to access the DM.
87 // Return true for success, false for failure.
88 bool dmi_read(unsigned address
, uint32_t *value
);
89 bool dmi_write(unsigned address
, uint32_t value
);
92 static const unsigned datasize
= 2;
93 // Size of program_buffer in 32-bit words, as exposed to the rest of the
96 // Actual size of the program buffer, which is 1 word bigger than we let on
97 // to implement the implicit ebreak at the end.
98 unsigned program_buffer_bytes
;
99 static const unsigned debug_data_start
= 0x380;
100 unsigned debug_progbuf_start
;
102 static const unsigned debug_abstract_size
= 2;
103 unsigned debug_abstract_start
;
105 static const unsigned hartsellen
= 10;
109 uint8_t debug_rom_whereto
[4];
110 uint8_t debug_abstract
[debug_abstract_size
* 4];
111 uint8_t *program_buffer
;
112 uint8_t dmdata
[datasize
* 4];
115 bool resumeack
[1024];
116 uint8_t debug_rom_flags
[1024];
118 void write32(uint8_t *rom
, unsigned int index
, uint32_t value
);
119 uint32_t read32(uint8_t *rom
, unsigned int index
);
121 void sb_autoincrement();
124 unsigned sb_access_bits();
126 dmcontrol_t dmcontrol
;
128 abstractcs_t abstractcs
;
129 abstractauto_t abstractauto
;
133 uint32_t sbaddress
[4];
136 processor_t
*current_proc() const;
138 bool perform_abstract_command();