debug_module_t::debug_module_t() :
dmcontrol(1 << DMI_DMCONTROL_VERSION_OFFSET |
- 1 << DMI_DMCONTROL_AUTHENTICATED_OFFSET)
+ 1 << DMI_DMCONTROL_AUTHENTICATED_OFFSET),
+ abstractcs(datacount << DMI_ABSTRACTCS_DATACOUNT_OFFSET)
{
}
bool debug_module_t::dmi_read(unsigned address, uint32_t *value)
{
D(fprintf(stderr, "dmi_read(0x%x) -> ", address));
- switch (address) {
- case DMI_DMCONTROL:
- *value = dmcontrol;
- break;
- default:
- D(fprintf(stderr, "error\n"));
- return false;
+ if (address >= DMI_DATA0 && address < DMI_DATA0 + datacount) {
+ *value = data[address - DMI_DATA0];
+ } else if (address >= DMI_IBUF0 && address < DMI_IBUF0 + progsize) {
+ *value = ibuf[address - DMI_IBUF0];
+ } else {
+ switch (address) {
+ case DMI_DMCONTROL:
+ *value = dmcontrol;
+ break;
+ case DMI_ABSTRACTCS:
+ *value = abstractcs;
+ break;
+ case DMI_ACCESSCS:
+ *value = progsize << DMI_ACCESSCS_PROGSIZE_OFFSET;
+ break;
+ default:
+ D(fprintf(stderr, "error\n"));
+ return false;
+ }
}
D(fprintf(stderr, "0x%x\n", *value));
return true;
bool debug_module_t::dmi_write(unsigned address, uint32_t value)
{
D(fprintf(stderr, "dmi_write(0x%x, 0x%x)\n", address, value));
+ if (address >= DMI_DATA0 && address < DMI_DATA0 + datacount) {
+ data[address - DMI_DATA0] = value;
+ return true;
+ } else if (address >= DMI_IBUF0 && address < DMI_IBUF0 + progsize) {
+ ibuf[address - DMI_IBUF0] = value;
+ return true;
+ }
return false;
}
std::set<uint32_t> halt_notification;
char debug_ram[DEBUG_RAM_SIZE];
+ static const unsigned datacount = 8;
+ static const unsigned progsize = 8;
+
uint32_t dmcontrol;
+ uint32_t abstractcs;
+ uint32_t data[datacount];
+ uint32_t ibuf[progsize];
};
#endif