2 * Copyright (C) 2016-2020 by Marc Schink <dev@zapb.de>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef OPENOCD_RTT_RTT_H
19 #define OPENOCD_RTT_RTT_H
24 #include <helper/command.h>
25 #include <target/target.h>
28 * Control block ID length in bytes, including the trailing null-terminator.
30 #define RTT_CB_MAX_ID_LENGTH 16
32 /* Control block size in bytes. */
33 #define RTT_CB_SIZE (RTT_CB_MAX_ID_LENGTH + 2 * sizeof(uint32_t))
35 /* Channel structure size in bytes. */
36 #define RTT_CHANNEL_SIZE 24
38 /* Minimal channel buffer size in bytes. */
39 #define RTT_CHANNEL_BUFFER_MIN_SIZE 2
41 /** RTT control block. */
43 /** Control block address on the target. */
44 target_addr_t address
;
45 /** Control block identifier, including trailing null-terminator. */
46 char id
[RTT_CB_MAX_ID_LENGTH
];
47 /** Maximum number of up-channels. */
48 uint32_t num_up_channels
;
49 /** Maximum number of down-channels. */
50 uint32_t num_down_channels
;
55 /** Channel structure address on the target. */
56 target_addr_t address
;
57 /** Channel name address on the target. */
59 /** Buffer address on the target. */
61 /** Channel buffer size in bytes. */
63 /** Write position within the buffer in bytes. */
65 /** Read position within the buffer in bytes. */
70 * @note: Not used at the moment.
75 /** RTT channel information. */
76 struct rtt_channel_info
{
79 /** Length of the name in bytes, including the trailing null-terminator. */
81 /** Buffer size in bytes. */
86 * @note: Not used at the moment.
91 typedef int (*rtt_sink_read
)(unsigned int channel
, const uint8_t *buffer
,
92 size_t length
, void *user_data
);
94 struct rtt_sink_list
{
98 struct rtt_sink_list
*next
;
102 enum rtt_channel_type
{
103 /** Up channel (target to host). */
105 /** Down channel (host to target). */
106 RTT_CHANNEL_TYPE_DOWN
109 typedef int (*rtt_source_find_ctrl_block
)(struct target
*target
,
110 target_addr_t
*address
, size_t size
, const char *id
, bool *found
,
112 typedef int (*rtt_source_read_ctrl_block
)(struct target
*target
,
113 target_addr_t address
, struct rtt_control
*ctrl_block
,
115 typedef int (*rtt_source_read_channel_info
)(struct target
*target
,
116 const struct rtt_control
*ctrl
, unsigned int channel
,
117 enum rtt_channel_type type
, struct rtt_channel_info
*info
,
119 typedef int (*rtt_source_start
)(struct target
*target
,
120 const struct rtt_control
*ctrl
, void *user_data
);
121 typedef int (*rtt_source_stop
)(struct target
*target
, void *user_data
);
122 typedef int (*rtt_source_read
)(struct target
*target
,
123 const struct rtt_control
*ctrl
, struct rtt_sink_list
**sinks
,
124 size_t num_channels
, void *user_data
);
125 typedef int (*rtt_source_write
)(struct target
*target
,
126 struct rtt_control
*ctrl
, unsigned int channel
,
127 const uint8_t *buffer
, size_t *length
, void *user_data
);
131 rtt_source_find_ctrl_block find_cb
;
132 rtt_source_read_ctrl_block read_cb
;
133 rtt_source_read_channel_info read_channel_info
;
134 rtt_source_start start
;
135 rtt_source_stop stop
;
136 rtt_source_read read
;
137 rtt_source_write write
;
141 * Initialize Real-Time Transfer (RTT).
143 * @returns ERROR_OK on success, an error code on failure.
148 * Shutdown Real-Time Transfer (RTT).
150 * @returns ERROR_OK on success, an error code on failure.
155 * Register an RTT source for a target.
157 * @param[in] source RTT source.
158 * @param[in,out] target Target.
160 * @returns ERROR_OK on success, an error code on failure.
162 int rtt_register_source(const struct rtt_source source
,
163 struct target
*target
);
168 * @param[in] address Start address to search for the control block.
169 * @param[in] size Size of the control block search area.
170 * @param[in] id Identifier of the control block. Must be null-terminated.
172 * @returns ERROR_OK on success, an error code on failure.
174 int rtt_setup(target_addr_t address
, size_t size
, const char *id
);
177 * Start Real-Time Transfer (RTT).
179 * @returns ERROR_OK on success, an error code on failure.
184 * Stop Real-Time Transfer (RTT).
186 * @returns ERROR_OK on success, an error code on failure.
191 * Get the polling interval.
193 * @param[out] interval Polling interval in milliseconds.
195 * @returns ERROR_OK on success, an error code on failure.
197 int rtt_get_polling_interval(unsigned int *interval
);
200 * Set the polling interval.
202 * @param[in] interval Polling interval in milliseconds.
204 * @returns ERROR_OK on success, an error code on failure.
206 int rtt_set_polling_interval(unsigned int interval
);
209 * Get whether RTT is started.
211 * @returns Whether RTT is started.
213 bool rtt_started(void);
216 * Get whether RTT is configured.
218 * @returns Whether RTT is configured.
220 bool rtt_configured(void);
223 * Get whether RTT control block was found.
225 * @returns Whether RTT was found.
227 bool rtt_found_cb(void);
230 * Get the RTT control block.
232 * @returns The RTT control block.
234 const struct rtt_control
*rtt_get_control(void);
237 * Read channel information.
239 * @param[in] channel_index Channel index.
240 * @param[in] type Channel type.
241 * @param[out] info Channel information.
243 * @returns ERROR_OK on success, an error code on failure.
245 int rtt_read_channel_info(unsigned int channel_index
,
246 enum rtt_channel_type type
, struct rtt_channel_info
*info
);
249 * Register an RTT sink.
251 * @param[in] channel_index Channel index.
252 * @param[in] read Read callback function.
253 * @param[in,out] user_data User data to be passed to the callback function.
255 * @returns ERROR_OK on success, an error code on failure.
257 int rtt_register_sink(unsigned int channel_index
, rtt_sink_read read
,
261 * Unregister an RTT sink.
263 * @param[in] channel_index Channel index.
264 * @param[in] read Read callback function.
265 * @param[in,out] user_data User data to be passed to the callback function.
267 * @returns ERROR_OK on success, an error code on failure.
269 int rtt_unregister_sink(unsigned int channel_index
, rtt_sink_read read
,
273 * Write to an RTT channel.
275 * @param[in] channel_index Channel index.
276 * @param[in] buffer Buffer with data that should be written to the channel.
277 * @param[in,out] length Number of bytes to write. On success, the argument gets
278 * updated with the actual number of written bytes.
280 * @returns ERROR_OK on success, an error code on failure.
282 int rtt_write_channel(unsigned int channel_index
, const uint8_t *buffer
,
285 extern const struct command_registration rtt_target_command_handlers
[];
287 #endif /* OPENOCD_RTT_RTT_H */
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)