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
;
59 class debug_module_t
: public abstract_device_t
62 debug_module_t(sim_t
*sim
, unsigned progbufsize
);
65 void add_device(bus_t
*bus
);
67 bool load(reg_t addr
, size_t len
, uint8_t* bytes
);
68 bool store(reg_t addr
, size_t len
, const uint8_t* bytes
);
70 // Debug Module Interface that the debugger (in our case through JTAG DTM)
71 // uses to access the DM.
72 // Return true for success, false for failure.
73 bool dmi_read(unsigned address
, uint32_t *value
);
74 bool dmi_write(unsigned address
, uint32_t value
);
77 static const unsigned datasize
= 2;
78 // Size of program_buffer in 32-bit words, as exposed to the rest of the
81 // Actual size of the program buffer, which is 1 word bigger than we let on
82 // to implement the implicit ebreak at the end.
83 unsigned program_buffer_bytes
;
84 static const unsigned debug_data_start
= 0x380;
85 unsigned debug_progbuf_start
;
87 static const unsigned debug_abstract_size
= 2;
88 unsigned debug_abstract_start
;
92 uint8_t debug_rom_whereto
[4];
93 uint8_t debug_abstract
[debug_abstract_size
* 4];
94 uint8_t *program_buffer
;
95 uint8_t dmdata
[datasize
* 4];
99 uint8_t debug_rom_flags
[1024];
101 void write32(uint8_t *rom
, unsigned int index
, uint32_t value
);
102 uint32_t read32(uint8_t *rom
, unsigned int index
);
104 dmcontrol_t dmcontrol
;
106 abstractcs_t abstractcs
;
107 abstractauto_t abstractauto
;
110 processor_t
*current_proc() const;
112 bool perform_abstract_command();