3 #include "debug_module.h"
6 #include "debug_rom/debug_rom.h"
8 debug_module_t::debug_module_t()
10 /* Copy Debug ROM into the page. */
11 memcpy(raw_page
+ DEBUG_ROM_START
- DEBUG_START
,
12 debug_rom_raw
, debug_rom_raw_len
);
15 bool debug_module_t::load(reg_t addr
, size_t len
, uint8_t* bytes
)
17 addr
= DEBUG_START
+ addr
;
19 fprintf(stderr
, "ERROR: invalid load from debug module: %ld bytes at 0x%lx\n",
24 bool debug_module_t::store(reg_t addr
, size_t len
, const uint8_t* bytes
)
26 addr
= DEBUG_START
+ addr
;
29 fprintf(stderr
, "ERROR: unaligned store to debug module: %ld bytes at 0x%lx\n",
34 if (addr
>= DEBUG_RAM_START
&& addr
+ len
<= DEBUG_RAM_END
) {
35 memcpy(raw_page
+ addr
- DEBUG_START
, bytes
, len
);
37 } else if (len
== 4 && addr
== DEBUG_CLEARDEBINT
) {
38 clear_interrupt(bytes
[0] | (bytes
[1] << 8) |
39 (bytes
[2] << 16) | (bytes
[3] << 24));
43 fprintf(stderr
, "ERROR: invalid store to debug module: %ld bytes at 0x%lx\n",
48 void debug_module_t::ram_write32(unsigned int index
, uint32_t value
)
50 char* base
= raw_page
+ DEBUG_RAM_START
- DEBUG_START
+ index
* 4;
51 base
[0] = value
& 0xff;
52 base
[1] = (value
>> 8) & 0xff;
53 base
[2] = (value
>> 16) & 0xff;
54 base
[3] = (value
>> 24) & 0xff;
57 uint32_t debug_module_t::ram_read32(unsigned int index
)
59 char* base
= raw_page
+ DEBUG_RAM_START
- DEBUG_START
+ index
* 4;
66 char* debug_module_t::page(reg_t paddr
)
68 fprintf(stderr
, "dm::page(0x%lx)\n", paddr
);
70 assert(PGSHIFT
== 12);
72 if (paddr
== (DEBUG_START
& PGMASK
)) {
76 fprintf(stderr
, "ERROR: invalid page to debug module at 0x%lx\n", paddr
);