Skip to content

Commit 8fd7aa9

Browse files
committed
[DAP] Support dbg_write_memory
1 parent 82f488a commit 8fd7aa9

File tree

3 files changed

+254
-46
lines changed

3 files changed

+254
-46
lines changed

src/common/webapi.h

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
#include <stddef.h>
44
#include "chips/chips_common.h"
55

6-
#define WEBAPI_STOPREASON_UNKNOWN (0)
7-
#define WEBAPI_STOPREASON_BREAK (1)
8-
#define WEBAPI_STOPREASON_BREAKPOINT (2)
9-
#define WEBAPI_STOPREASON_STEP (3)
10-
#define WEBAPI_STOPREASON_ENTRY (4)
11-
#define WEBAPI_STOPREASON_EXIT (5)
6+
#define WEBAPI_STOPREASON_UNKNOWN (0)
7+
#define WEBAPI_STOPREASON_BREAK (1)
8+
#define WEBAPI_STOPREASON_BREAKPOINT (2)
9+
#define WEBAPI_STOPREASON_STEP (3)
10+
#define WEBAPI_STOPREASON_ENTRY (4)
11+
#define WEBAPI_STOPREASON_EXIT (5)
1212

1313
#define WEBAPI_CPUTYPE_INVALID (0)
1414
#define WEBAPI_CPUTYPE_Z80 (1)
@@ -17,21 +17,21 @@
1717

1818
#define WEBAPI_CPUSTATE_TYPE (0)
1919

20-
#define WEBAPI_CPUSTATE_Z80_AF (1)
21-
#define WEBAPI_CPUSTATE_Z80_BC (2)
22-
#define WEBAPI_CPUSTATE_Z80_DE (3)
23-
#define WEBAPI_CPUSTATE_Z80_HL (4)
24-
#define WEBAPI_CPUSTATE_Z80_IX (5)
25-
#define WEBAPI_CPUSTATE_Z80_IY (6)
26-
#define WEBAPI_CPUSTATE_Z80_SP (7)
27-
#define WEBAPI_CPUSTATE_Z80_PC (8)
28-
#define WEBAPI_CPUSTATE_Z80_AF2 (9)
29-
#define WEBAPI_CPUSTATE_Z80_BC2 (10)
30-
#define WEBAPI_CPUSTATE_Z80_DE2 (11)
31-
#define WEBAPI_CPUSTATE_Z80_HL2 (12)
32-
#define WEBAPI_CPUSTATE_Z80_IM (13)
33-
#define WEBAPI_CPUSTATE_Z80_IR (14)
34-
#define WEBAPI_CPUSTATE_Z80_IFF (15) // bit0: iff1, bit2: iff2
20+
#define WEBAPI_CPUSTATE_Z80_AF (1)
21+
#define WEBAPI_CPUSTATE_Z80_BC (2)
22+
#define WEBAPI_CPUSTATE_Z80_DE (3)
23+
#define WEBAPI_CPUSTATE_Z80_HL (4)
24+
#define WEBAPI_CPUSTATE_Z80_IX (5)
25+
#define WEBAPI_CPUSTATE_Z80_IY (6)
26+
#define WEBAPI_CPUSTATE_Z80_SP (7)
27+
#define WEBAPI_CPUSTATE_Z80_PC (8)
28+
#define WEBAPI_CPUSTATE_Z80_AF2 (9)
29+
#define WEBAPI_CPUSTATE_Z80_BC2 (10)
30+
#define WEBAPI_CPUSTATE_Z80_DE2 (11)
31+
#define WEBAPI_CPUSTATE_Z80_HL2 (12)
32+
#define WEBAPI_CPUSTATE_Z80_IM (13)
33+
#define WEBAPI_CPUSTATE_Z80_IR (14)
34+
#define WEBAPI_CPUSTATE_Z80_IFF (15) // bit0: iff1, bit2: iff2
3535

3636
#define WEBAPI_CPUSTATE_6502_A (1)
3737
#define WEBAPI_CPUSTATE_6502_X (2)
@@ -51,7 +51,7 @@
5151
#define WEBAPI_CPUSTATE_65816_PBR (9)
5252
#define WEBAPI_CPUSTATE_65816_E (10)
5353

54-
#define WEBAPI_CPUSTATE_MAX (16)
54+
#define WEBAPI_CPUSTATE_MAX (16)
5555

5656
typedef struct webapi_cpu_state_t {
5757
uint16_t items[WEBAPI_CPUSTATE_MAX];
@@ -81,8 +81,8 @@ typedef struct {
8181
uint8_t payload[];
8282
} webapi_fileheader_t;
8383

84-
#define WEBAPI_FILEHEADER_FLAG_START (1<<0) // if set, start automatically
85-
#define WEBAPI_FILEHEADER_FLAG_STOPONENTRY (1<<1) // if set, stop execution on entry
84+
#define WEBAPI_FILEHEADER_FLAG_START (1 << 0) // if set, start automatically
85+
#define WEBAPI_FILEHEADER_FLAG_STOPONENTRY (1 << 1) // if set, stop execution on entry
8686

8787
typedef struct {
8888
void (*boot)(void);
@@ -104,6 +104,7 @@ typedef struct {
104104
webapi_cpu_state_t (*dbg_cpu_state)(void);
105105
void (*dbg_request_disassembly)(uint32_t addr, int offset_lines, int num_lines, webapi_dasm_line_t* dst_lines);
106106
void (*dbg_read_memory)(uint32_t addr, int num_bytes, uint8_t* dst_ptr);
107+
void (*dbg_write_memory)(uint32_t addr, int num_bytes, const uint8_t* src_ptr);
107108
void (*input)(const char* text);
108109
} webapi_interface_t;
109110

@@ -116,4 +117,4 @@ void webapi_init(const webapi_desc_t* desc);
116117
void webapi_event_stopped(int stop_reason, uint32_t addr);
117118
void webapi_event_continued(void);
118119
void webapi_event_reboot(void);
119-
void webapi_event_reset(void);
120+
void webapi_event_reset(void);

0 commit comments

Comments
 (0)