1 // See LICENSE for license details.
2 #ifndef _RISCV_DEBUG_MODULE_H
3 #define _RISCV_DEBUG_MODULE_H
45 CMDERR_HALTRESUME
= 4,
57 unsigned autoexecprogbuf
;
58 unsigned autoexecdata
;
76 class debug_module_t
: public abstract_device_t
80 * If require_authentication is true, then a debugger must authenticate as
82 * 1. Read a 32-bit value from authdata:
83 * 2. Write the value that was read back, plus one, to authdata.
85 debug_module_t(sim_t
*sim
, unsigned progbufsize
, unsigned max_bus_master_bits
,
86 bool require_authentication
);
89 void add_device(bus_t
*bus
);
91 bool load(reg_t addr
, size_t len
, uint8_t* bytes
);
92 bool store(reg_t addr
, size_t len
, const uint8_t* bytes
);
94 // Debug Module Interface that the debugger (in our case through JTAG DTM)
95 // uses to access the DM.
96 // Return true for success, false for failure.
97 bool dmi_read(unsigned address
, uint32_t *value
);
98 bool dmi_write(unsigned address
, uint32_t value
);
100 // Called when one of the attached harts was reset.
101 void proc_reset(unsigned id
);
104 static const unsigned datasize
= 2;
105 // Size of program_buffer in 32-bit words, as exposed to the rest of the
107 unsigned progbufsize
;
108 // Actual size of the program buffer, which is 1 word bigger than we let on
109 // to implement the implicit ebreak at the end.
110 unsigned program_buffer_bytes
;
111 unsigned max_bus_master_bits
;
112 bool require_authentication
;
113 static const unsigned debug_data_start
= 0x380;
114 unsigned debug_progbuf_start
;
116 static const unsigned debug_abstract_size
= 5;
117 unsigned debug_abstract_start
;
119 static const unsigned hartsellen
= 10;
123 uint8_t debug_rom_whereto
[4];
124 uint8_t debug_abstract
[debug_abstract_size
* 4];
125 uint8_t *program_buffer
;
126 uint8_t dmdata
[datasize
* 4];
129 bool resumeack
[1024];
130 bool havereset
[1024];
131 uint8_t debug_rom_flags
[1024];
133 void write32(uint8_t *rom
, unsigned int index
, uint32_t value
);
134 uint32_t read32(uint8_t *rom
, unsigned int index
);
136 void sb_autoincrement();
139 unsigned sb_access_bits();
141 dmcontrol_t dmcontrol
;
143 abstractcs_t abstractcs
;
144 abstractauto_t abstractauto
;
148 uint32_t sbaddress
[4];
152 const uint32_t secret
= 1;
154 processor_t
*current_proc() const;
156 bool perform_abstract_command();