OpenOCD
rtt/rtt.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /*
4  * Copyright (C) 2016-2020 by Marc Schink <dev@zapb.de>
5  */
6 
7 #ifndef OPENOCD_RTT_RTT_H
8 #define OPENOCD_RTT_RTT_H
9 
10 #include <stdint.h>
11 #include <stdbool.h>
12 
13 #include <helper/command.h>
14 #include <target/target.h>
15 
19 #define RTT_CB_MAX_ID_LENGTH 16
20 
21 /* Control block size in bytes. */
22 #define RTT_CB_SIZE (RTT_CB_MAX_ID_LENGTH + 2 * sizeof(uint32_t))
23 
24 /* Channel structure size in bytes (32-bit architecture). */
25 #define RTT_CHANNEL_SIZE_32 24
26 
27 /* Channel structure size in bytes (64-bit architecture). */
28 #define RTT_CHANNEL_SIZE_64 32
29 
30 /* Minimal channel buffer size in bytes. */
31 #define RTT_CHANNEL_BUFFER_MIN_SIZE 2
32 
34 struct rtt_control {
40  uint32_t num_up_channels;
43 };
44 
46 struct rtt_channel {
54  uint32_t size;
56  uint32_t write_pos;
58  uint32_t read_pos;
64  uint32_t flags;
65 };
66 
70  char *name;
72  size_t name_length;
74  uint32_t size;
80  uint32_t flags;
81 };
82 
83 typedef int (*rtt_sink_read)(unsigned int channel, const uint8_t *buffer,
84  size_t length, void *user_data);
85 
86 struct rtt_sink_list {
88  void *user_data;
89 
91 };
92 
99 };
100 
102 struct rtt_source {
103  int (*find_cb)(struct target *target,
104  target_addr_t *address, size_t size, const char *id, bool *found,
105  void *user_data);
106  int (*read_cb)(struct target *target,
107  target_addr_t address, struct rtt_control *ctrl_block,
108  void *user_data);
110  const struct rtt_control *ctrl, unsigned int channel,
112  void *user_data);
113  int (*start)(struct target *target,
114  const struct rtt_control *ctrl, void *user_data);
115  int (*stop)(struct target *target, void *user_data);
116  int (*read)(struct target *target,
117  const struct rtt_control *ctrl, struct rtt_sink_list **sinks,
118  size_t num_channels, void *user_data);
119  int (*write)(struct target *target,
120  struct rtt_control *ctrl, unsigned int channel,
121  const uint8_t *buffer, size_t *length, void *user_data);
122 };
123 
129 int rtt_init(void);
130 
136 int rtt_exit(void);
137 
146 int rtt_register_source(const struct rtt_source source,
147  struct target *target);
148 
158 int rtt_setup(target_addr_t address, size_t size, const char *id);
159 
165 int rtt_start(void);
166 
172 int rtt_stop(void);
173 
181 int rtt_get_polling_interval(unsigned int *interval);
182 
190 int rtt_set_polling_interval(unsigned int interval);
191 
197 bool rtt_configured(void);
198 
204 bool rtt_found_cb(void);
205 
211 const struct rtt_control *rtt_get_control(void);
212 
222 int rtt_read_channel_info(unsigned int channel_index,
224 
234 int rtt_register_sink(unsigned int channel_index, rtt_sink_read read,
235  void *user_data);
236 
246 int rtt_unregister_sink(unsigned int channel_index, rtt_sink_read read,
247  void *user_data);
248 
259 int rtt_write_channel(unsigned int channel_index, const uint8_t *buffer,
260  size_t *length);
261 
263 
264 #endif /* OPENOCD_RTT_RTT_H */
uint64_t buffer
Pointer to data buffer to send over SPI.
Definition: dw-spi-helper.h:0
uint32_t size
Size of dw_spi_transaction::buffer.
Definition: dw-spi-helper.h:4
uint32_t address
Starting address. Sector aligned.
Definition: dw-spi-helper.h:0
uint8_t type
Definition: esp_usb_jtag.c:0
uint8_t length
Definition: esp_usb_jtag.c:1
struct target * target
Definition: rtt/rtt.c:26
struct rtt_control ctrl
Control block.
Definition: rtt/rtt.c:25
struct rtt_source source
Definition: rtt/rtt.c:23
char id[RTT_CB_MAX_ID_LENGTH]
Control block identifier.
Definition: rtt/rtt.c:32
int rtt_stop(void)
Stop Real-Time Transfer (RTT).
Definition: rtt/rtt.c:165
#define RTT_CB_MAX_ID_LENGTH
Control block ID length in bytes, including the trailing null-terminator.
Definition: rtt/rtt.h:19
int rtt_start(void)
Start Real-Time Transfer (RTT).
Definition: rtt/rtt.c:124
int rtt_register_sink(unsigned int channel_index, rtt_sink_read read, void *user_data)
Register an RTT sink.
Definition: rtt/rtt.c:206
bool rtt_configured(void)
Get whether RTT is configured.
Definition: rtt/rtt.c:300
bool rtt_found_cb(void)
Get whether RTT control block was found.
Definition: rtt/rtt.c:305
int rtt_set_polling_interval(unsigned int interval)
Set the polling interval.
Definition: rtt/rtt.c:272
int rtt_unregister_sink(unsigned int channel_index, rtt_sink_read read, void *user_data)
Unregister an RTT sink.
Definition: rtt/rtt.c:232
int(* rtt_sink_read)(unsigned int channel, const uint8_t *buffer, size_t length, void *user_data)
Definition: rtt/rtt.h:83
int rtt_init(void)
Initialize Real-Time Transfer (RTT).
Definition: rtt/rtt.c:48
int rtt_register_source(const struct rtt_source source, struct target *target)
Register an RTT source for a target.
Definition: rtt/rtt.c:106
int rtt_exit(void)
Shutdown Real-Time Transfer (RTT).
Definition: rtt/rtt.c:65
const struct rtt_control * rtt_get_control(void)
Get the RTT control block.
Definition: rtt/rtt.c:310
int rtt_get_polling_interval(unsigned int *interval)
Get the polling interval.
Definition: rtt/rtt.c:262
int rtt_setup(target_addr_t address, size_t size, const char *id)
Setup RTT.
Definition: rtt/rtt.c:88
const struct command_registration rtt_target_command_handlers[]
Definition: rtt/tcl.c:267
int rtt_read_channel_info(unsigned int channel_index, enum rtt_channel_type type, struct rtt_channel_info *info)
Read channel information.
Definition: rtt/rtt.c:315
rtt_channel_type
Channel type.
Definition: rtt/rtt.h:94
@ RTT_CHANNEL_TYPE_UP
Up channel (target to host).
Definition: rtt/rtt.h:96
@ RTT_CHANNEL_TYPE_DOWN
Down channel (host to target).
Definition: rtt/rtt.h:98
int rtt_write_channel(unsigned int channel_index, const uint8_t *buffer, size_t *length)
Write to an RTT channel.
Definition: rtt/rtt.c:288
RTT channel information.
Definition: rtt/rtt.h:68
char * name
Channel name.
Definition: rtt/rtt.h:70
uint32_t size
Buffer size in bytes.
Definition: rtt/rtt.h:74
size_t name_length
Length of the name in bytes, including the trailing null-terminator.
Definition: rtt/rtt.h:72
uint32_t flags
Buffer flags.
Definition: rtt/rtt.h:80
RTT channel.
Definition: rtt/rtt.h:46
uint32_t read_pos
Read position within the buffer in bytes.
Definition: rtt/rtt.h:58
target_addr_t buffer_addr
Buffer address on the target.
Definition: rtt/rtt.h:52
target_addr_t address
Channel structure address on the target.
Definition: rtt/rtt.h:48
uint32_t write_pos
Write position within the buffer in bytes.
Definition: rtt/rtt.h:56
uint32_t size
Channel buffer size in bytes.
Definition: rtt/rtt.h:54
target_addr_t name_addr
Channel name address on the target.
Definition: rtt/rtt.h:50
uint32_t flags
Buffer flags.
Definition: rtt/rtt.h:64
RTT control block.
Definition: rtt/rtt.h:34
target_addr_t address
Control block address on the target.
Definition: rtt/rtt.h:36
uint32_t num_up_channels
Maximum number of up-channels.
Definition: rtt/rtt.h:40
uint32_t num_down_channels
Maximum number of down-channels.
Definition: rtt/rtt.h:42
struct rtt_sink_list * next
Definition: rtt/rtt.h:90
rtt_sink_read read
Definition: rtt/rtt.h:87
void * user_data
Definition: rtt/rtt.h:88
RTT source.
Definition: rtt/rtt.h:102
int(* write)(struct target *target, struct rtt_control *ctrl, unsigned int channel, const uint8_t *buffer, size_t *length, void *user_data)
Definition: rtt/rtt.h:119
int(* start)(struct target *target, const struct rtt_control *ctrl, void *user_data)
Definition: rtt/rtt.h:113
int(* stop)(struct target *target, void *user_data)
Definition: rtt/rtt.h:115
int(* read_channel_info)(struct target *target, const struct rtt_control *ctrl, unsigned int channel, enum rtt_channel_type type, struct rtt_channel_info *info, void *user_data)
Definition: rtt/rtt.h:109
int(* find_cb)(struct target *target, target_addr_t *address, size_t size, const char *id, bool *found, void *user_data)
Definition: rtt/rtt.h:103
int(* read)(struct target *target, const struct rtt_control *ctrl, struct rtt_sink_list **sinks, size_t num_channels, void *user_data)
Definition: rtt/rtt.h:116
int(* read_cb)(struct target *target, target_addr_t address, struct rtt_control *ctrl_block, void *user_data)
Definition: rtt/rtt.h:106
Definition: target.h:119
uint64_t target_addr_t
Definition: types.h:279
static struct ublast_lowlevel_priv info