1 /***************************************************************************
2 * Copyright (C) 2011 by Mathias Kuester *
3 * Mathias Kuester <kesmtp@freenet.de> *
5 * Copyright (C) 2012 by Spencer Oliver *
6 * spen@spen-soft.co.uk *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
22 ***************************************************************************/
27 #include <target/armv7m_trace.h>
30 struct hl_interface_s;
31 struct hl_interface_param_s;
34 extern struct hl_layout_api_s stlink_usb_layout_api;
35 extern struct hl_layout_api_s icdi_usb_layout_api;
38 struct hl_layout_api_s {
40 int (*open) (struct hl_interface_param_s *param, void **handle);
42 int (*close) (void *handle);
44 int (*reset) (void *handle);
46 int (*assert_srst) (void *handle, int srst);
48 int (*run) (void *handle);
50 int (*halt) (void *handle);
52 int (*step) (void *handle);
54 int (*read_regs) (void *handle);
56 int (*read_reg) (void *handle, int num, uint32_t *val);
58 int (*write_reg) (void *handle, int num, uint32_t val);
60 int (*read_mem) (void *handle, uint32_t addr, uint32_t size,
61 uint32_t count, uint8_t *buffer);
63 int (*write_mem) (void *handle, uint32_t addr, uint32_t size,
64 uint32_t count, const uint8_t *buffer);
66 int (*write_debug_reg) (void *handle, uint32_t addr, uint32_t val);
68 * Read the idcode of the target connected to the adapter
70 * If the adapter doesn't support idcode retrieval, this callback should
71 * store 0 to indicate a wildcard match.
73 * @param handle A pointer to the device-specific handle
74 * @param idcode Storage for the detected idcode
75 * @returns ERROR_OK on success, or an error code on failure.
77 int (*idcode) (void *handle, uint32_t *idcode);
79 int (*override_target) (const char *targetname);
81 int (*custom_command) (void *handle, const char *command);
83 int (*speed)(void *handle, int khz, bool query);
85 * Configure trace parameters for the adapter
87 * @param handle A handle to adapter
88 * @param enabled Whether to enable trace
89 * @param pin_protocol Configured pin protocol
90 * @param port_size Trace port width for sync mode
91 * @param trace_freq A pointer to the configured trace
92 * frequency; if it points to 0, the adapter driver must write
93 * its maximum supported rate there
94 * @returns ERROR_OK on success, an error code on failure.
96 int (*config_trace)(void *handle, bool enabled, enum tpio_pin_protocol pin_protocol,
97 uint32_t port_size, unsigned int *trace_freq);
99 * Poll for new trace data
101 * @param handle A handle to adapter
102 * @param buf A pointer to buffer to store received data
103 * @param size A pointer to buffer size; must be filled with
104 * the actual amount of bytes written
106 * @returns ERROR_OK on success, an error code on failure.
108 int (*poll_trace)(void *handle, uint8_t *buf, size_t *size);
110 enum target_state (*state) (void *fd);
118 int (*open) (struct hl_interface_s *adapter);
120 int (*close) (struct hl_interface_s *adapter);
122 struct hl_layout_api_s *api;
126 const struct hl_layout *hl_layout_get_list(void);
128 int hl_layout_init(struct hl_interface_s *adapter);
130 #endif /* _HL_LAYOUT_H */