OpenOCD
rtt/rtt.h File Reference
Include dependency graph for rtt/rtt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rtt_channel
 RTT channel. More...
 
struct  rtt_channel_info
 RTT channel information. More...
 
struct  rtt_control
 RTT control block. More...
 
struct  rtt_sink_list
 
struct  rtt_source
 RTT source. More...
 

Macros

#define RTT_CB_MAX_ID_LENGTH   16
 Control block ID length in bytes, including the trailing null-terminator. More...
 
#define RTT_CB_SIZE   (RTT_CB_MAX_ID_LENGTH + 2 * sizeof(uint32_t))
 
#define RTT_CHANNEL_BUFFER_MIN_SIZE   2
 
#define RTT_CHANNEL_SIZE   24
 

Typedefs

typedef int(* rtt_sink_read) (unsigned int channel, const uint8_t *buffer, size_t length, void *user_data)
 
typedef int(* rtt_source_find_ctrl_block) (struct target *target, target_addr_t *address, size_t size, const char *id, bool *found, void *user_data)
 
typedef int(* rtt_source_read) (struct target *target, const struct rtt_control *ctrl, struct rtt_sink_list **sinks, size_t num_channels, void *user_data)
 
typedef int(* rtt_source_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)
 
typedef int(* rtt_source_read_ctrl_block) (struct target *target, target_addr_t address, struct rtt_control *ctrl_block, void *user_data)
 
typedef int(* rtt_source_start) (struct target *target, const struct rtt_control *ctrl, void *user_data)
 
typedef int(* rtt_source_stop) (struct target *target, void *user_data)
 
typedef int(* rtt_source_write) (struct target *target, struct rtt_control *ctrl, unsigned int channel, const uint8_t *buffer, size_t *length, void *user_data)
 

Enumerations

enum  rtt_channel_type { RTT_CHANNEL_TYPE_UP , RTT_CHANNEL_TYPE_DOWN }
 Channel type. More...
 

Functions

bool rtt_configured (void)
 Get whether RTT is configured. More...
 
int rtt_exit (void)
 Shutdown Real-Time Transfer (RTT). More...
 
bool rtt_found_cb (void)
 Get whether RTT control block was found. More...
 
const struct rtt_controlrtt_get_control (void)
 Get the RTT control block. More...
 
int rtt_get_polling_interval (unsigned int *interval)
 Get the polling interval. More...
 
int rtt_init (void)
 Initialize Real-Time Transfer (RTT). More...
 
int rtt_read_channel_info (unsigned int channel_index, enum rtt_channel_type type, struct rtt_channel_info *info)
 Read channel information. More...
 
int rtt_register_sink (unsigned int channel_index, rtt_sink_read read, void *user_data)
 Register an RTT sink. More...
 
int rtt_register_source (const struct rtt_source source, struct target *target)
 Register an RTT source for a target. More...
 
int rtt_set_polling_interval (unsigned int interval)
 Set the polling interval. More...
 
int rtt_setup (target_addr_t address, size_t size, const char *id)
 Setup RTT. More...
 
int rtt_start (void)
 Start Real-Time Transfer (RTT). More...
 
bool rtt_started (void)
 Get whether RTT is started. More...
 
int rtt_stop (void)
 Stop Real-Time Transfer (RTT). More...
 
int rtt_unregister_sink (unsigned int channel_index, rtt_sink_read read, void *user_data)
 Unregister an RTT sink. More...
 
int rtt_write_channel (unsigned int channel_index, const uint8_t *buffer, size_t *length)
 Write to an RTT channel. More...
 

Variables

const struct command_registration rtt_target_command_handlers []
 

Macro Definition Documentation

◆ RTT_CB_MAX_ID_LENGTH

#define RTT_CB_MAX_ID_LENGTH   16

Control block ID length in bytes, including the trailing null-terminator.

Definition at line 19 of file rtt/rtt.h.

◆ RTT_CB_SIZE

#define RTT_CB_SIZE   (RTT_CB_MAX_ID_LENGTH + 2 * sizeof(uint32_t))

Definition at line 22 of file rtt/rtt.h.

◆ RTT_CHANNEL_BUFFER_MIN_SIZE

#define RTT_CHANNEL_BUFFER_MIN_SIZE   2

Definition at line 28 of file rtt/rtt.h.

◆ RTT_CHANNEL_SIZE

#define RTT_CHANNEL_SIZE   24

Definition at line 25 of file rtt/rtt.h.

Typedef Documentation

◆ rtt_sink_read

typedef int(* rtt_sink_read) (unsigned int channel, const uint8_t *buffer, size_t length, void *user_data)

Definition at line 80 of file rtt/rtt.h.

◆ rtt_source_find_ctrl_block

typedef int(* rtt_source_find_ctrl_block) (struct target *target, target_addr_t *address, size_t size, const char *id, bool *found, void *user_data)

Definition at line 98 of file rtt/rtt.h.

◆ rtt_source_read

typedef int(* rtt_source_read) (struct target *target, const struct rtt_control *ctrl, struct rtt_sink_list **sinks, size_t num_channels, void *user_data)

Definition at line 111 of file rtt/rtt.h.

◆ rtt_source_read_channel_info

typedef int(* rtt_source_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 at line 104 of file rtt/rtt.h.

◆ rtt_source_read_ctrl_block

typedef int(* rtt_source_read_ctrl_block) (struct target *target, target_addr_t address, struct rtt_control *ctrl_block, void *user_data)

Definition at line 101 of file rtt/rtt.h.

◆ rtt_source_start

typedef int(* rtt_source_start) (struct target *target, const struct rtt_control *ctrl, void *user_data)

Definition at line 108 of file rtt/rtt.h.

◆ rtt_source_stop

typedef int(* rtt_source_stop) (struct target *target, void *user_data)

Definition at line 110 of file rtt/rtt.h.

◆ rtt_source_write

typedef int(* rtt_source_write) (struct target *target, struct rtt_control *ctrl, unsigned int channel, const uint8_t *buffer, size_t *length, void *user_data)

Definition at line 114 of file rtt/rtt.h.

Enumeration Type Documentation

◆ rtt_channel_type

Channel type.

Enumerator
RTT_CHANNEL_TYPE_UP 

Up channel (target to host).

RTT_CHANNEL_TYPE_DOWN 

Down channel (host to target).

Definition at line 91 of file rtt/rtt.h.

Function Documentation

◆ rtt_configured()

bool rtt_configured ( void  )

Get whether RTT is configured.

Returns
Whether RTT is configured.

Definition at line 305 of file rtt/rtt.c.

References rtt.

Referenced by COMMAND_HANDLER().

◆ rtt_exit()

int rtt_exit ( void  )

Shutdown Real-Time Transfer (RTT).

Returns
ERROR_OK on success, an error code on failure.

Definition at line 65 of file rtt/rtt.c.

References ERROR_OK, and rtt.

Referenced by openocd_main().

◆ rtt_found_cb()

bool rtt_found_cb ( void  )

Get whether RTT control block was found.

Returns
Whether RTT was found.

Definition at line 310 of file rtt/rtt.c.

References rtt.

Referenced by COMMAND_HANDLER().

◆ rtt_get_control()

const struct rtt_control* rtt_get_control ( void  )

Get the RTT control block.

Returns
The RTT control block.

Definition at line 315 of file rtt/rtt.c.

References rtt.

Referenced by COMMAND_HANDLER().

◆ rtt_get_polling_interval()

int rtt_get_polling_interval ( unsigned int *  interval)

Get the polling interval.

Parameters
[out]intervalPolling interval in milliseconds.
Returns
ERROR_OK on success, an error code on failure.

Definition at line 262 of file rtt/rtt.c.

References ERROR_FAIL, ERROR_OK, and rtt.

Referenced by COMMAND_HANDLER().

◆ rtt_init()

int rtt_init ( void  )

Initialize Real-Time Transfer (RTT).

Returns
ERROR_OK on success, an error code on failure.

Definition at line 48 of file rtt/rtt.c.

References ERROR_FAIL, ERROR_OK, NULL, and rtt.

Referenced by openocd_main().

◆ rtt_read_channel_info()

int rtt_read_channel_info ( unsigned int  channel_index,
enum rtt_channel_type  type,
struct rtt_channel_info info 
)

Read channel information.

Parameters
[in]channel_indexChannel index.
[in]typeChannel type.
[out]infoChannel information.
Returns
ERROR_OK on success, an error code on failure.

Definition at line 320 of file rtt/rtt.c.

Referenced by COMMAND_HANDLER().

◆ rtt_register_sink()

int rtt_register_sink ( unsigned int  channel_index,
rtt_sink_read  read,
void *  user_data 
)

Register an RTT sink.

Parameters
[in]channel_indexChannel index.
[in]readRead callback function.
[in,out]user_dataUser data to be passed to the callback function.
Returns
ERROR_OK on success, an error code on failure.

Definition at line 206 of file rtt/rtt.c.

References adjust_sink_list(), ERROR_FAIL, ERROR_OK, LOG_DEBUG, rtt_sink_list::next, rtt_sink_list::read, rtt, and rtt_sink_list::user_data.

Referenced by rtt_new_connection().

◆ rtt_register_source()

int rtt_register_source ( const struct rtt_source  source,
struct target target 
)

Register an RTT source for a target.

Parameters
[in]sourceRTT source.
[in,out]targetTarget.
Returns
ERROR_OK on success, an error code on failure.

Definition at line 106 of file rtt/rtt.c.

References ERROR_FAIL, ERROR_OK, rtt_source::find_cb, rtt_source::read, rtt_source::read_cb, rtt_source::read_channel_info, rtt, source, rtt_source::start, rtt_source::stop, target, and rtt_source::write.

Referenced by COMMAND_HANDLER().

◆ rtt_set_polling_interval()

int rtt_set_polling_interval ( unsigned int  interval)

Set the polling interval.

Parameters
[in]intervalPolling interval in milliseconds.
Returns
ERROR_OK on success, an error code on failure.

Definition at line 272 of file rtt/rtt.c.

References ERROR_FAIL, ERROR_OK, NULL, read_channel_callback(), rtt, target_register_timer_callback(), and target_unregister_timer_callback().

Referenced by COMMAND_HANDLER().

◆ rtt_setup()

int rtt_setup ( target_addr_t  address,
size_t  size,
const char *  id 
)

Setup RTT.

Parameters
[in]addressStart address to search for the control block.
[in]sizeSize of the control block search area.
[in]idIdentifier of the control block. Must be null-terminated.
Returns
ERROR_OK on success, an error code on failure.

Definition at line 88 of file rtt/rtt.c.

References ERROR_COMMAND_ARGUMENT_INVALID, ERROR_OK, LOG_ERROR, rtt, RTT_CB_MAX_ID_LENGTH, and size.

Referenced by COMMAND_HANDLER().

◆ rtt_start()

int rtt_start ( void  )

Start Real-Time Transfer (RTT).

Returns
ERROR_OK on success, an error code on failure.

Definition at line 124 of file rtt/rtt.c.

References addr, ERROR_OK, LOG_INFO, NULL, read_channel_callback(), rtt, TARGET_PRIxADDR, and target_register_timer_callback().

Referenced by COMMAND_HANDLER().

◆ rtt_started()

bool rtt_started ( void  )

Get whether RTT is started.

Returns
Whether RTT is started.

Definition at line 300 of file rtt/rtt.c.

References rtt.

◆ rtt_stop()

int rtt_stop ( void  )

Stop Real-Time Transfer (RTT).

Returns
ERROR_OK on success, an error code on failure.

Definition at line 165 of file rtt/rtt.c.

References ERROR_FAIL, ERROR_OK, LOG_ERROR, NULL, read_channel_callback(), rtt, and target_unregister_timer_callback().

Referenced by COMMAND_HANDLER().

◆ rtt_unregister_sink()

int rtt_unregister_sink ( unsigned int  channel_index,
rtt_sink_read  read,
void *  user_data 
)

Unregister an RTT sink.

Parameters
[in]channel_indexChannel index.
[in]readRead callback function.
[in,out]user_dataUser data to be passed to the callback function.
Returns
ERROR_OK on success, an error code on failure.

Definition at line 232 of file rtt/rtt.c.

References ERROR_FAIL, ERROR_OK, LOG_DEBUG, rtt_sink_list::next, rtt_sink_list::read, rtt, and rtt_sink_list::user_data.

Referenced by rtt_connection_closed().

◆ rtt_write_channel()

int rtt_write_channel ( unsigned int  channel_index,
const uint8_t *  buffer,
size_t *  length 
)

Write to an RTT channel.

Parameters
[in]channel_indexChannel index.
[in]bufferBuffer with data that should be written to the channel.
[in,out]lengthNumber of bytes to write. On success, the argument gets updated with the actual number of written bytes.
Returns
ERROR_OK on success, an error code on failure.

Definition at line 288 of file rtt/rtt.c.

References buffer, ERROR_OK, length, LOG_WARNING, NULL, and rtt.

Referenced by rtt_input().

Variable Documentation

◆ rtt_target_command_handlers

const struct command_registration rtt_target_command_handlers[]
extern

Definition at line 159 of file rtt/tcl.c.