101 uint32_t first_length;
114 len - first_length,
buffer + first_length);
132 uint32_t first_length;
154 len - first_length,
buffer);
183 unsigned int channel_index,
const uint8_t *
buffer,
size_t *
length,
193 LOG_ERROR(
"rtt: Failed to read down-channel %u description",
199 LOG_WARNING(
"rtt: Down-channel %u is not active", channel_index);
204 LOG_WARNING(
"rtt: Down-channel %u is not large enough",
250 size_t id_matched_length = 0;
251 const size_t id_length = strlen(
id);
253 LOG_INFO(
"rtt: Searching for control block '%s'",
id);
258 const size_t buf_size =
MIN(
sizeof(buf), address_end -
addr);
264 for (
size_t buf_off = 0; buf_off < buf_size; buf_off++) {
265 if (id_matched_length > 0 &&
266 buf[buf_off] !=
id[id_matched_length]) {
268 id_matched_length = 0;
271 if (buf[buf_off] ==
id[id_matched_length])
274 if (id_matched_length == id_length) {
296 LOG_ERROR(
"rtt: Failed to read channel %u description",
334 uint32_t first_length;
347 len - first_length,
buffer + first_length);
368 size_t num_channels,
void *user_data)
372 for (
size_t i = 0; i < num_channels; i++) {
385 LOG_ERROR(
"rtt: Failed to read up-channel %zu description", i);
390 LOG_WARNING(
"rtt: Up-channel %zu is not active", i);
395 LOG_WARNING(
"rtt: Up-channel %zu is not large enough", i);
403 LOG_ERROR(
"rtt: Failed to read from up-channel %zu", i);
Support functions to access arbitrary bits in a byte array.
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned int first, unsigned int num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word.
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
target_addr_t addr
Start address to search for the control block.
struct rtt_control ctrl
Control block.
size_t size
Size of the control block search area.
#define RTT_CB_MAX_ID_LENGTH
Control block ID length in bytes, including the trailing null-terminator.
#define RTT_CHANNEL_BUFFER_MIN_SIZE
rtt_channel_type
Channel type.
@ RTT_CHANNEL_TYPE_UP
Up channel (target to host).
@ RTT_CHANNEL_TYPE_DOWN
Down channel (host to target).
uint32_t read_pos
Read position within the buffer in bytes.
uint32_t name_addr
Channel name address on the target.
target_addr_t address
Channel structure address on the target.
uint32_t write_pos
Write position within the buffer in bytes.
uint32_t size
Channel buffer size in bytes.
uint32_t flags
Buffer flags.
uint32_t buffer_addr
Buffer address on the target.
char id[RTT_CB_MAX_ID_LENGTH]
Control block identifier, including trailing null-terminator.
target_addr_t address
Control block address on the target.
uint32_t num_up_channels
Maximum number of up-channels.
uint32_t num_down_channels
Maximum number of down-channels.
struct rtt_sink_list * next
int target_rtt_read_control_block(struct target *target, target_addr_t address, struct rtt_control *ctrl, void *user_data)
static int read_from_channel(struct target *target, const struct rtt_channel *channel, uint8_t *buffer, size_t *length)
static int read_channel_name(struct target *target, target_addr_t address, char *name, size_t length)
static int read_rtt_channel(struct target *target, const struct rtt_control *ctrl, unsigned int channel_index, enum rtt_channel_type type, struct rtt_channel *channel)
static bool channel_is_active(const struct rtt_channel *channel)
int target_rtt_read_callback(struct target *target, const struct rtt_control *ctrl, struct rtt_sink_list **sinks, size_t num_channels, void *user_data)
static int write_to_channel(struct target *target, const struct rtt_channel *channel, const uint8_t *buffer, size_t *length)
int target_rtt_find_control_block(struct target *target, target_addr_t *address, size_t size, const char *id, bool *found, void *user_data)
int target_rtt_stop(struct target *target, void *user_data)
int target_rtt_start(struct target *target, const struct rtt_control *ctrl, void *user_data)
int target_rtt_write_callback(struct target *target, struct rtt_control *ctrl, unsigned int channel_index, const uint8_t *buffer, size_t *length, void *user_data)
int target_rtt_read_channel_info(struct target *target, const struct rtt_control *ctrl, unsigned int channel_index, enum rtt_channel_type type, struct rtt_channel_info *info, void *user_data)
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
int target_read_buffer(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
static struct ublast_lowlevel_priv info