100 uint32_t first_length;
113 len - first_length,
buffer + first_length);
131 uint32_t first_length;
153 len - first_length,
buffer);
182 unsigned int channel_index,
const uint8_t *
buffer,
size_t *
length,
192 LOG_ERROR(
"rtt: Failed to read down-channel %u description",
198 LOG_WARNING(
"rtt: Down-channel %u is not active", channel_index);
203 LOG_WARNING(
"rtt: Down-channel %u is not large enough",
249 size_t id_matched_length = 0;
250 const size_t id_length = strlen(
id);
252 LOG_INFO(
"rtt: Searching for control block '%s'",
id);
257 const size_t buf_size =
MIN(
sizeof(buf), address_end -
addr);
263 for (
size_t buf_off = 0; buf_off < buf_size; buf_off++) {
264 if (id_matched_length > 0 &&
265 buf[buf_off] !=
id[id_matched_length]) {
267 id_matched_length = 0;
270 if (buf[buf_off] ==
id[id_matched_length])
273 if (id_matched_length == id_length) {
295 LOG_ERROR(
"rtt: Failed to read channel %u description",
333 uint32_t first_length;
346 len - first_length,
buffer + first_length);
367 size_t num_channels,
void *user_data)
371 for (
size_t i = 0; i < num_channels; i++) {
384 LOG_ERROR(
"rtt: Failed to read up-channel %zu description", i);
389 LOG_WARNING(
"rtt: Up-channel %zu is not active", i);
394 LOG_WARNING(
"rtt: Up-channel %zu is not large enough", i);
402 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 first, unsigned 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 ...)
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