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
78 * If require_authentication is true, then a debugger must authenticate as
80 * 1. Read a 32-bit value from authdata:
81 * 2. Write the value that was read back, plus one, to authdata.
83 debug_module_t(sim_t
*sim
, unsigned progbufsize
, unsigned max_bus_master_bits
,
84 bool require_authentication
);
87 void add_device(bus_t
*bus
);
89 bool load(reg_t addr
, size_t len
, uint8_t* bytes
);
90 bool store(reg_t addr
, size_t len
, const uint8_t* bytes
);
92 // Debug Module Interface that the debugger (in our case through JTAG DTM)
93 // uses to access the DM.
94 // Return true for success, false for failure.
95 bool dmi_read(unsigned address
, uint32_t *value
);
96 bool dmi_write(unsigned address
, uint32_t value
);
99 static const unsigned datasize
= 2;
100 // Size of program_buffer in 32-bit words, as exposed to the rest of the
102 unsigned progbufsize
;
103 // Actual size of the program buffer, which is 1 word bigger than we let on
104 // to implement the implicit ebreak at the end.
105 unsigned program_buffer_bytes
;
106 unsigned max_bus_master_bits
;
107 bool require_authentication
;
108 static const unsigned debug_data_start
= 0x380;
109 unsigned debug_progbuf_start
;
111 static const unsigned debug_abstract_size
= 5;
112 unsigned debug_abstract_start
;
114 static const unsigned hartsellen
= 10;
118 uint8_t debug_rom_whereto
[4];
119 uint8_t debug_abstract
[debug_abstract_size
* 4];
120 uint8_t *program_buffer
;
121 uint8_t dmdata
[datasize
* 4];
124 bool resumeack
[1024];
125 uint8_t debug_rom_flags
[1024];
127 void write32(uint8_t *rom
, unsigned int index
, uint32_t value
);
128 uint32_t read32(uint8_t *rom
, unsigned int index
);
130 void sb_autoincrement();
133 unsigned sb_access_bits();
135 dmcontrol_t dmcontrol
;
137 abstractcs_t abstractcs
;
138 abstractauto_t abstractauto
;
142 uint32_t sbaddress
[4];
146 const uint32_t secret
= 1;
148 processor_t
*current_proc() const;
150 bool perform_abstract_command();