1 // See LICENSE for license details.
2 #ifndef _RISCV_DEBUG_MODULE_H
3 #define _RISCV_DEBUG_MODULE_H
18 HARTSTATUS_UNAVAILABLE
,
32 class debug_module_t
: public abstract_device_t
35 debug_module_t(sim_t
*sim
);
37 bool load(reg_t addr
, size_t len
, uint8_t* bytes
);
38 bool store(reg_t addr
, size_t len
, const uint8_t* bytes
);
40 void set_interrupt(uint32_t hartid
) {
41 interrupt
.insert(hartid
);
43 void clear_interrupt(uint32_t hartid
) {
44 interrupt
.erase(hartid
);
46 bool get_interrupt(uint32_t hartid
) const {
47 return interrupt
.find(hartid
) != interrupt
.end();
50 void set_halt_notification(uint32_t hartid
) {
51 halt_notification
.insert(hartid
);
53 void clear_halt_notification(uint32_t hartid
) {
54 halt_notification
.erase(hartid
);
56 bool get_halt_notification(uint32_t hartid
) const {
57 return halt_notification
.find(hartid
) != halt_notification
.end();
60 // Debug Module Interface that the debugger (in our case through JTAG DTM)
61 // uses to access the DM.
62 // Return true for success, false for failure.
63 bool dmi_read(unsigned address
, uint32_t *value
);
64 bool dmi_write(unsigned address
, uint32_t value
);
68 // Track which interrupts from module to debugger are set.
69 std::set
<uint32_t> interrupt
;
70 // Track which halt notifications from debugger to module are set.
71 std::set
<uint32_t> halt_notification
;
72 uint8_t debug_rom_entry
[1024 * 4];
74 void write32(uint8_t *rom
, unsigned int index
, uint32_t value
);
75 uint32_t read32(uint8_t *rom
, unsigned int index
);
77 static const unsigned datacount
= 8;
78 static const unsigned progsize
= 8;
80 dmcontrol_t dmcontrol
;
82 uint32_t data
[datacount
];
83 uint32_t ibuf
[progsize
];
85 processor_t
*current_proc() const;
87 bool perform_abstract_command(uint32_t command
);