1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Copyright (C) 2011 by Mathias Kuester *
5 * Mathias Kuester <kesmtp@freenet.de> *
7 * Copyright (C) 2012 by Spencer Oliver *
8 * spen@spen-soft.co.uk *
9 ***************************************************************************/
11 #ifndef OPENOCD_JTAG_HLA_HLA_LAYOUT_H
12 #define OPENOCD_JTAG_HLA_HLA_LAYOUT_H
14 #include <target/armv7m_trace.h>
15 #include <target/arm_tpiu_swo.h>
18 struct hl_interface_s
;
19 struct hl_interface_param_s
;
22 extern struct hl_layout_api_s stlink_usb_layout_api
;
23 extern struct hl_layout_api_s icdi_usb_layout_api
;
24 extern struct hl_layout_api_s nulink_usb_layout_api
;
27 struct hl_layout_api_s
{
29 int (*open
)(struct hl_interface_param_s
*param
, void **handle
);
31 int (*close
)(void *handle
);
33 int (*reset
)(void *handle
);
35 int (*assert_srst
)(void *handle
, int srst
);
37 int (*run
)(void *handle
);
39 int (*halt
)(void *handle
);
41 int (*step
)(void *handle
);
43 int (*read_regs
)(void *handle
);
45 * Read one register from the target
47 * @param handle A pointer to the device-specific handle
48 * @param regsel Register selection index compatible with all the
49 * values allowed by armv7m DCRSR.REGSEL
50 * @param val A pointer to retrieve the register value
51 * @returns ERROR_OK on success, or an error code on failure.
53 int (*read_reg
)(void *handle
, unsigned int regsel
, uint32_t *val
);
55 * Write one register to the target
56 * @param handle A pointer to the device-specific handle
57 * @param regsel Register selection index compatible with all the
58 * values allowed by armv7m DCRSR.REGSEL
59 * @param val The value to be written in the register
60 * @returns ERROR_OK on success, or an error code on failure.
62 int (*write_reg
)(void *handle
, unsigned int regsel
, uint32_t val
);
64 int (*read_mem
)(void *handle
, uint32_t addr
, uint32_t size
,
65 uint32_t count
, uint8_t *buffer
);
67 int (*write_mem
)(void *handle
, uint32_t addr
, uint32_t size
,
68 uint32_t count
, const uint8_t *buffer
);
70 int (*write_debug_reg
)(void *handle
, uint32_t addr
, uint32_t val
);
72 * Read the idcode of the target connected to the adapter
74 * If the adapter doesn't support idcode retrieval, this callback should
75 * store 0 to indicate a wildcard match.
77 * @param handle A pointer to the device-specific handle
78 * @param idcode Storage for the detected idcode
79 * @returns ERROR_OK on success, or an error code on failure.
81 int (*idcode
)(void *handle
, uint32_t *idcode
);
83 int (*override_target
)(const char *targetname
);
85 int (*custom_command
)(void *handle
, const char *command
);
87 int (*speed
)(void *handle
, int khz
, bool query
);
89 * Configure trace parameters for the adapter
91 * @param handle A handle to adapter
92 * @param enabled Whether to enable trace
93 * @param pin_protocol Configured pin protocol
94 * @param port_size Trace port width for sync mode
95 * @param trace_freq A pointer to the configured trace
96 * frequency; if it points to 0, the adapter driver must write
97 * its maximum supported rate there
98 * @returns ERROR_OK on success, an error code on failure.
100 int (*config_trace
)(void *handle
, bool enabled
,
101 enum tpiu_pin_protocol pin_protocol
, uint32_t port_size
,
102 unsigned int *trace_freq
, unsigned int traceclkin_freq
,
103 uint16_t *prescaler
);
105 * Poll for new trace data
107 * @param handle A handle to adapter
108 * @param buf A pointer to buffer to store received data
109 * @param size A pointer to buffer size; must be filled with
110 * the actual amount of bytes written
112 * @returns ERROR_OK on success, an error code on failure.
114 int (*poll_trace
)(void *handle
, uint8_t *buf
, size_t *size
);
116 enum target_state (*state
)(void *fd
);
124 int (*open
)(struct hl_interface_s
*adapter
);
126 int (*close
)(struct hl_interface_s
*adapter
);
128 struct hl_layout_api_s
*api
;
132 const struct hl_layout
*hl_layout_get_list(void);
134 int hl_layout_init(struct hl_interface_s
*adapter
);
136 #endif /* OPENOCD_JTAG_HLA_HLA_LAYOUT_H */