# define D(x)
#endif
-debug_module_t::debug_module_t() :
+debug_module_t::debug_module_t(sim_t *sim) :
+ sim(sim),
dmcontrol(1 << DMI_DMCONTROL_VERSION_OFFSET |
1 << DMI_DMCONTROL_AUTHENTICATED_OFFSET),
abstractcs(datacount << DMI_ABSTRACTCS_DATACOUNT_OFFSET)
} else {
switch (address) {
case DMI_DMCONTROL:
- *value = dmcontrol;
+ {
+ processor_t *proc = sim->get_core(get_field(dmcontrol,
+ DMI_DMCONTROL_HARTSEL));
+ if (proc) {
+ D(fprintf(stderr, "(halted=%d) ", proc->halted()));
+ if (proc->halted()) {
+ dmcontrol = set_field(dmcontrol, DMI_DMCONTROL_HARTSTATUS, 0);
+ } else {
+ dmcontrol = set_field(dmcontrol, DMI_DMCONTROL_HARTSTATUS, 1);
+ }
+ } else {
+ dmcontrol = set_field(dmcontrol, DMI_DMCONTROL_HARTSTATUS, 3);
+ }
+ *value = dmcontrol;
+ }
break;
case DMI_ABSTRACTCS:
*value = abstractcs;
#include "devices.h"
+class sim_t;
+
class debug_module_t : public abstract_device_t
{
public:
- debug_module_t();
+ debug_module_t(sim_t *sim);
bool load(reg_t addr, size_t len, uint8_t* bytes);
bool store(reg_t addr, size_t len, const uint8_t* bytes);
bool dmi_write(unsigned address, uint32_t value);
private:
+ sim_t *sim;
// Track which interrupts from module to debugger are set.
std::set<uint32_t> interrupt;
// Track which halt notifications from debugger to module are set.
bool debug;
// When true, take the slow simulation path.
bool slow_path();
+ bool halted() { return state.dcsr.cause ? true : false; }
// Return the index of a trigger that matched, or -1.
inline int trigger_match(trigger_operation_t operation, reg_t address, reg_t data)
sim_t::sim_t(const char* isa, size_t nprocs, size_t mem_mb, bool halted,
const std::vector<std::string>& args)
- : htif_t(args), procs(std::max(nprocs, size_t(1))),
+ : htif_t(args), debug_module(this), procs(std::max(nprocs, size_t(1))),
current_step(0), current_proc(0), debug(false), remote_bitbang(NULL)
{
signal(SIGINT, &handle_signal);