Fix store to clear debug interrupt.
[riscv-isa-sim.git] / riscv / debug_module.h
1 // See LICENSE for license details.
2 #ifndef _RISCV_DEBUG_MODULE_H
3 #define _RISCV_DEBUG_MODULE_H
4
5 #include <set>
6
7 #include "devices.h"
8
9 class debug_module_t : public abstract_device_t
10 {
11 public:
12 debug_module_t();
13
14 bool load(reg_t addr, size_t len, uint8_t* bytes);
15 bool store(reg_t addr, size_t len, const uint8_t* bytes);
16 char* page(reg_t paddr);
17
18 void ram_write32(unsigned int index, uint32_t value);
19 uint32_t ram_read32(unsigned int index);
20
21 void set_interrupt(uint32_t hartid) {
22 interrupt.insert(hartid);
23 }
24 void clear_interrupt(uint32_t hartid) {
25 interrupt.erase(hartid);
26 }
27 bool get_interrupt(uint32_t hartid) const {
28 return interrupt.find(hartid) != interrupt.end();
29 }
30
31 private:
32 // Track which interrupts from module to debugger are set.
33 std::set<uint32_t> interrupt;
34 // TODO: use PGSIZE, which requires solving some circular include dependencies.
35 char raw_page[4096];
36 };
37
38 #endif