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. */
25 #define RTT_CHANNEL_SIZE 24
26 
27 /* Minimal channel buffer size in bytes. */
28 #define RTT_CHANNEL_BUFFER_MIN_SIZE 2
29 
31 struct rtt_control {
37  uint32_t num_up_channels;
40 };
41 
43 struct rtt_channel {
47  uint32_t name_addr;
49  uint32_t buffer_addr;
51  uint32_t size;
53  uint32_t write_pos;
55  uint32_t read_pos;
61  uint32_t flags;
62 };
63 
67  char *name;
69  size_t name_length;
71  uint32_t size;
77  uint32_t flags;
78 };
79 
80 typedef int (*rtt_sink_read)(unsigned int channel, const uint8_t *buffer,
81  size_t length, void *user_data);
82 
83 struct rtt_sink_list {
85  void *user_data;
86 
88 };
89 
96 };
97 
99 struct rtt_source {
100  int (*find_cb)(struct target *target,
101  target_addr_t *address, size_t size, const char *id, bool *found,
102  void *user_data);
103  int (*read_cb)(struct target *target,
104  target_addr_t address, struct rtt_control *ctrl_block,
105  void *user_data);
107  const struct rtt_control *ctrl, unsigned int channel,
109  void *user_data);
110  int (*start)(struct target *target,
111  const struct rtt_control *ctrl, void *user_data);
112  int (*stop)(struct target *target, void *user_data);
113  int (*read)(struct target *target,
114  const struct rtt_control *ctrl, struct rtt_sink_list **sinks,
115  size_t num_channels, void *user_data);
116  int (*write)(struct target *target,
117  struct rtt_control *ctrl, unsigned int channel,
118  const uint8_t *buffer, size_t *length, void *user_data);
119 };
120 
126 int rtt_init(void);
127 
133 int rtt_exit(void);
134 
143 int rtt_register_source(const struct rtt_source source,
144  struct target *target);
145 
155 int rtt_setup(target_addr_t address, size_t size, const char *id);
156 
162 int rtt_start(void);
163 
169 int rtt_stop(void);
170 
178 int rtt_get_polling_interval(unsigned int *interval);
179 
187 int rtt_set_polling_interval(unsigned int interval);
188 
194 bool rtt_configured(void);
195 
201 bool rtt_found_cb(void);
202 
208 const struct rtt_control *rtt_get_control(void);
209 
219 int rtt_read_channel_info(unsigned int channel_index,
221 
231 int rtt_register_sink(unsigned int channel_index, rtt_sink_read read,
232  void *user_data);
233 
243 int rtt_unregister_sink(unsigned int channel_index, rtt_sink_read read,
244  void *user_data);
245 
256 int rtt_write_channel(unsigned int channel_index, const uint8_t *buffer,
257  size_t *length);
258 
260 
261 #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:80
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:91
@ RTT_CHANNEL_TYPE_UP
Up channel (target to host).
Definition: rtt/rtt.h:93
@ RTT_CHANNEL_TYPE_DOWN
Down channel (host to target).
Definition: rtt/rtt.h:95
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:65
char * name
Channel name.
Definition: rtt/rtt.h:67
uint32_t size
Buffer size in bytes.
Definition: rtt/rtt.h:71
size_t name_length
Length of the name in bytes, including the trailing null-terminator.
Definition: rtt/rtt.h:69
uint32_t flags
Buffer flags.
Definition: rtt/rtt.h:77
RTT channel.
Definition: rtt/rtt.h:43
uint32_t read_pos
Read position within the buffer in bytes.
Definition: rtt/rtt.h:55
uint32_t name_addr
Channel name address on the target.
Definition: rtt/rtt.h:47
target_addr_t address
Channel structure address on the target.
Definition: rtt/rtt.h:45
uint32_t write_pos
Write position within the buffer in bytes.
Definition: rtt/rtt.h:53
uint32_t size
Channel buffer size in bytes.
Definition: rtt/rtt.h:51
uint32_t flags
Buffer flags.
Definition: rtt/rtt.h:61
uint32_t buffer_addr
Buffer address on the target.
Definition: rtt/rtt.h:49
RTT control block.
Definition: rtt/rtt.h:31
target_addr_t address
Control block address on the target.
Definition: rtt/rtt.h:33
uint32_t num_up_channels
Maximum number of up-channels.
Definition: rtt/rtt.h:37
uint32_t num_down_channels
Maximum number of down-channels.
Definition: rtt/rtt.h:39
struct rtt_sink_list * next
Definition: rtt/rtt.h:87
rtt_sink_read read
Definition: rtt/rtt.h:84
void * user_data
Definition: rtt/rtt.h:85
RTT source.
Definition: rtt/rtt.h:99
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:116
int(* start)(struct target *target, const struct rtt_control *ctrl, void *user_data)
Definition: rtt/rtt.h:110
int(* stop)(struct target *target, void *user_data)
Definition: rtt/rtt.h:112
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:106
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:100
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:113
int(* read_cb)(struct target *target, target_addr_t address, struct rtt_control *ctrl_block, void *user_data)
Definition: rtt/rtt.h:103
Definition: target.h:116
uint64_t target_addr_t
Definition: types.h:335
static struct ublast_lowlevel_priv info