1
2
3
4
5
6
7
8
9
10
11
16
17
19
20
21
26
27
28
29
30
31
32
33
34
35
36
37
39
40
41
42
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef OPENOCD_JTAG_DRIVERS_CMSIS_DAP_H
#define OPENOCD_JTAG_DRIVERS_CMSIS_DAP_H
#include <stdint.h>
struct cmsis_dap_backend;
struct cmsis_dap_backend_data;
struct pending_transfer_result {
uint8_t cmd;
uint32_t data;
void *buffer;
...};
/* ... */
#define MAX_PENDING_REQUESTS 4
struct pending_request_block {
struct pending_transfer_result *transfers;
unsigned int transfer_count;
uint8_t command;
...};
struct cmsis_dap {
struct cmsis_dap_backend_data *bdata;
const struct cmsis_dap_backend *backend;
unsigned int packet_size;
unsigned int packet_usable_size;
unsigned int packet_buffer_size;
uint8_t *packet_buffer;
uint8_t *command;
uint8_t *response;
/* ... */
unsigned int write_count;
unsigned int read_count;
/* ... */
uint8_t common_swd_cmd;
bool swd_cmds_differ;
struct pending_request_block pending_fifo[MAX_PENDING_REQUESTS];
unsigned int packet_count;
unsigned int pending_fifo_put_idx, pending_fifo_get_idx;
unsigned int pending_fifo_block_count;
uint16_t caps;
bool quirk_mode;
uint32_t swo_buf_sz;
bool trace_enabled;
...};
struct cmsis_dap_backend {
const char *name;
int (*open)(struct cmsis_dap *dap, uint16_t vids[], uint16_t pids[], const char *serial);
void (*close)(struct cmsis_dap *dap);
int (*read)(struct cmsis_dap *dap, int transfer_timeout_ms,
struct timeval *wait_timeout);
int (*write)(struct cmsis_dap *dap, int len, int timeout_ms);
int (*packet_buffer_alloc)(struct cmsis_dap *dap, unsigned int pkt_sz);
void (*packet_buffer_free)(struct cmsis_dap *dap);
void (*cancel_all)(struct cmsis_dap *dap);
...};
extern const struct cmsis_dap_backend cmsis_dap_hid_backend;
extern const struct cmsis_dap_backend cmsis_dap_usb_backend;
extern const struct command_registration cmsis_dap_usb_subcommand_handlers[];
#define REPORT_ID_SIZE 1
/* ... */
#endif