OpenOCD
arm_tpiu_swo.c File Reference

This file implements support for the ARM CoreSight components Trace Port Interface Unit (TPIU) and Serial Wire Output (SWO). More...

Include dependency graph for arm_tpiu_swo.c:

Go to the source code of this file.

Data Structures

struct  arm_tpiu_swo_connection
 
struct  arm_tpiu_swo_event_action
 
struct  arm_tpiu_swo_object
 
struct  arm_tpiu_swo_priv_connection
 

Macros

#define ARM_TPIU_SWO_TRACE_BUF_SIZE   4096
 
#define MSG   "DEPRECATED \'tpiu config\' command: "
 
#define TCP_SERVICE_NAME   "tpiu_swo_trace"
 
#define TPIU_ACPR_MAX_PRESCALER   0x1fff
 
#define TPIU_ACPR_OFFSET   0x010
 
#define TPIU_CSPSR_OFFSET   0x004
 
#define TPIU_DEVID_NOSUPPORT_SYNC   BIT(9)
 
#define TPIU_DEVID_OFFSET   0xfc8
 
#define TPIU_DEVID_SUPPORT_MANCHESTER   BIT(10)
 
#define TPIU_DEVID_SUPPORT_UART   BIT(11)
 
#define TPIU_FFCR_OFFSET   0x304
 
#define TPIU_FFSR_OFFSET   0x300
 
#define TPIU_FSCR_OFFSET   0x308
 
#define TPIU_SPPR_OFFSET   0x0F0
 
#define TPIU_SPPR_PROTOCOL_MANCHESTER   (TPIU_PIN_PROTOCOL_ASYNC_MANCHESTER)
 
#define TPIU_SPPR_PROTOCOL_SYNC   (TPIU_PIN_PROTOCOL_SYNC)
 
#define TPIU_SPPR_PROTOCOL_UART   (TPIU_PIN_PROTOCOL_ASYNC_UART)
 
#define TPIU_SSPSR_OFFSET   0x000
 
#define TPIU_SWO_DEFAULT_BASE   0xE0040000
 

Enumerations

enum  arm_tpiu_swo_cfg_param {
  CFG_PORT_WIDTH , CFG_PROTOCOL , CFG_FORMATTER , CFG_TRACECLKIN ,
  CFG_BITRATE , CFG_OUTFILE , CFG_EVENT
}
 
enum  arm_tpiu_swo_event { TPIU_SWO_EVENT_PRE_ENABLE , TPIU_SWO_EVENT_POST_ENABLE , TPIU_SWO_EVENT_PRE_DISABLE , TPIU_SWO_EVENT_POST_DISABLE }
 

Functions

int arm_tpiu_swo_cleanup_all (void)
 
static void arm_tpiu_swo_close_output (struct arm_tpiu_swo_object *obj)
 
static int arm_tpiu_swo_configure (struct jim_getopt_info *goi, struct arm_tpiu_swo_object *obj)
 
static int arm_tpiu_swo_create (Jim_Interp *interp, struct arm_tpiu_swo_object *obj)
 
static void arm_tpiu_swo_handle_event (struct arm_tpiu_swo_object *obj, enum arm_tpiu_swo_event event)
 
static int arm_tpiu_swo_poll_trace (void *priv)
 
int arm_tpiu_swo_register_commands (struct command_context *cmd_ctx)
 
static int arm_tpiu_swo_service_connection_closed (struct connection *connection)
 
static int arm_tpiu_swo_service_input (struct connection *connection)
 
static int arm_tpiu_swo_service_new_connection (struct connection *connection)
 
 COMMAND_HANDLER (handle_arm_tpiu_swo_event_list)
 
 COMMAND_HANDLER (handle_tpiu_deprecated_config_command)
 
static int jim_arm_tpiu_swo_configure (Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
static int jim_arm_tpiu_swo_create (Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
static int jim_arm_tpiu_swo_disable (Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
static int jim_arm_tpiu_swo_enable (Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
static int jim_arm_tpiu_swo_init (Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
static int jim_arm_tpiu_swo_names (Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
static LIST_HEAD (all_tpiu_swo)
 
static int wrap_read_u32 (struct target *target, struct adiv5_ap *tpiu_ap, target_addr_t address, uint32_t *value)
 
static int wrap_write_u32 (struct target *target, struct adiv5_ap *tpiu_ap, target_addr_t address, uint32_t value)
 

Variables

const struct command_registration arm_tpiu_deprecated_command_handlers []
 
static const struct command_registration arm_tpiu_deprecated_subcommand_handlers []
 
static const struct command_registration arm_tpiu_swo_command_handlers []
 
static const struct command_registration arm_tpiu_swo_instance_command_handlers []
 
static const struct service_driver arm_tpiu_swo_service_driver
 
static const struct command_registration arm_tpiu_swo_subcommand_handlers []
 
static const struct jim_nvp nvp_arm_tpiu_swo_bool_opts []
 
static const struct jim_nvp nvp_arm_tpiu_swo_config_opts []
 
static const struct jim_nvp nvp_arm_tpiu_swo_event []
 
static const struct jim_nvp nvp_arm_tpiu_swo_protocol_opts []
 

Detailed Description

This file implements support for the ARM CoreSight components Trace Port Interface Unit (TPIU) and Serial Wire Output (SWO).

It also supports the CoreSight TPIU-Lite and the special TPIU version present with Cortex-M3 and Cortex-M4 (that includes SWO).

Definition in file arm_tpiu_swo.c.

Macro Definition Documentation

◆ ARM_TPIU_SWO_TRACE_BUF_SIZE

#define ARM_TPIU_SWO_TRACE_BUF_SIZE   4096

Definition at line 132 of file arm_tpiu_swo.c.

◆ MSG

#define MSG   "DEPRECATED \'tpiu config\' command: "

Definition at line 44 of file arm_tpiu_swo.c.

◆ TCP_SERVICE_NAME

#define TCP_SERVICE_NAME   "tpiu_swo_trace"

Definition at line 47 of file arm_tpiu_swo.c.

◆ TPIU_ACPR_MAX_PRESCALER

#define TPIU_ACPR_MAX_PRESCALER   0x1fff

Definition at line 61 of file arm_tpiu_swo.c.

◆ TPIU_ACPR_OFFSET

#define TPIU_ACPR_OFFSET   0x010

Definition at line 54 of file arm_tpiu_swo.c.

◆ TPIU_CSPSR_OFFSET

#define TPIU_CSPSR_OFFSET   0x004

Definition at line 53 of file arm_tpiu_swo.c.

◆ TPIU_DEVID_NOSUPPORT_SYNC

#define TPIU_DEVID_NOSUPPORT_SYNC   BIT(9)

Definition at line 65 of file arm_tpiu_swo.c.

◆ TPIU_DEVID_OFFSET

#define TPIU_DEVID_OFFSET   0xfc8

Definition at line 59 of file arm_tpiu_swo.c.

◆ TPIU_DEVID_SUPPORT_MANCHESTER

#define TPIU_DEVID_SUPPORT_MANCHESTER   BIT(10)

Definition at line 66 of file arm_tpiu_swo.c.

◆ TPIU_DEVID_SUPPORT_UART

#define TPIU_DEVID_SUPPORT_UART   BIT(11)

Definition at line 67 of file arm_tpiu_swo.c.

◆ TPIU_FFCR_OFFSET

#define TPIU_FFCR_OFFSET   0x304

Definition at line 57 of file arm_tpiu_swo.c.

◆ TPIU_FFSR_OFFSET

#define TPIU_FFSR_OFFSET   0x300

Definition at line 56 of file arm_tpiu_swo.c.

◆ TPIU_FSCR_OFFSET

#define TPIU_FSCR_OFFSET   0x308

Definition at line 58 of file arm_tpiu_swo.c.

◆ TPIU_SPPR_OFFSET

#define TPIU_SPPR_OFFSET   0x0F0

Definition at line 55 of file arm_tpiu_swo.c.

◆ TPIU_SPPR_PROTOCOL_MANCHESTER

#define TPIU_SPPR_PROTOCOL_MANCHESTER   (TPIU_PIN_PROTOCOL_ASYNC_MANCHESTER)

Definition at line 63 of file arm_tpiu_swo.c.

◆ TPIU_SPPR_PROTOCOL_SYNC

#define TPIU_SPPR_PROTOCOL_SYNC   (TPIU_PIN_PROTOCOL_SYNC)

Definition at line 62 of file arm_tpiu_swo.c.

◆ TPIU_SPPR_PROTOCOL_UART

#define TPIU_SPPR_PROTOCOL_UART   (TPIU_PIN_PROTOCOL_ASYNC_UART)

Definition at line 64 of file arm_tpiu_swo.c.

◆ TPIU_SSPSR_OFFSET

#define TPIU_SSPSR_OFFSET   0x000

Definition at line 52 of file arm_tpiu_swo.c.

◆ TPIU_SWO_DEFAULT_BASE

#define TPIU_SWO_DEFAULT_BASE   0xE0040000

Definition at line 50 of file arm_tpiu_swo.c.

Enumeration Type Documentation

◆ arm_tpiu_swo_cfg_param

Enumerator
CFG_PORT_WIDTH 
CFG_PROTOCOL 
CFG_FORMATTER 
CFG_TRACECLKIN 
CFG_BITRATE 
CFG_OUTFILE 
CFG_EVENT 

Definition at line 312 of file arm_tpiu_swo.c.

◆ arm_tpiu_swo_event

Enumerator
TPIU_SWO_EVENT_PRE_ENABLE 
TPIU_SWO_EVENT_POST_ENABLE 
TPIU_SWO_EVENT_PRE_DISABLE 
TPIU_SWO_EVENT_POST_DISABLE 

Definition at line 69 of file arm_tpiu_swo.c.

Function Documentation

◆ arm_tpiu_swo_cleanup_all()

◆ arm_tpiu_swo_close_output()

static void arm_tpiu_swo_close_output ( struct arm_tpiu_swo_object obj)
static

◆ arm_tpiu_swo_configure()

◆ arm_tpiu_swo_create()

◆ arm_tpiu_swo_handle_event()

◆ arm_tpiu_swo_poll_trace()

◆ arm_tpiu_swo_register_commands()

int arm_tpiu_swo_register_commands ( struct command_context cmd_ctx)

Definition at line 1226 of file arm_tpiu_swo.c.

Referenced by setup_command_handler().

◆ arm_tpiu_swo_service_connection_closed()

static int arm_tpiu_swo_service_connection_closed ( struct connection connection)
static

◆ arm_tpiu_swo_service_input()

static int arm_tpiu_swo_service_input ( struct connection connection)
static

Definition at line 262 of file arm_tpiu_swo.c.

References connection_read(), dummy, ERROR_OK, ERROR_SERVER_REMOTE_CLOSED, and LOG_ERROR.

◆ arm_tpiu_swo_service_new_connection()

static int arm_tpiu_swo_service_new_connection ( struct connection connection)
static

◆ COMMAND_HANDLER() [1/2]

◆ COMMAND_HANDLER() [2/2]

COMMAND_HANDLER ( handle_tpiu_deprecated_config_command  )

Definition at line 1031 of file arm_tpiu_swo.c.

◆ jim_arm_tpiu_swo_configure()

static int jim_arm_tpiu_swo_configure ( Jim_Interp *  interp,
int  argc,
Jim_Obj *const *  argv 
)
static

◆ jim_arm_tpiu_swo_create()

◆ jim_arm_tpiu_swo_disable()

static int jim_arm_tpiu_swo_disable ( Jim_Interp *  interp,
int  argc,
Jim_Obj *const *  argv 
)
static

Definition at line 823 of file arm_tpiu_swo.c.

◆ jim_arm_tpiu_swo_enable()

static int jim_arm_tpiu_swo_enable ( Jim_Interp *  interp,
int  argc,
Jim_Obj *const *  argv 
)
static

Definition at line 598 of file arm_tpiu_swo.c.

References adapter_config_trace(), add_service(), adiv5_dap_name(), arm_tpiu_swo_object::ap, adiv5_ap::ap_num, adiv5_mem_ap_spot::ap_num, arm_tpiu_swo_close_output(), arm_tpiu_swo_handle_event(), arm_tpiu_swo_poll_trace(), arm_tpiu_swo_service_driver, cortex_m_common::armv7m, adiv5_mem_ap_spot::base, BIT, COMMAND_CONFIG, CONNECTION_LIMIT_UNLIMITED, current_command_context(), adiv5_mem_ap_spot::dap, dap_get_ap(), armv7m_common::debug_ap, arm_tpiu_swo_object::deferred_enable, arm_tpiu_swo_object::en_capture, arm_tpiu_swo_object::en_formatter, arm_tpiu_swo_object::enabled, ERROR_OK, arm_tpiu_swo_object::file, get_current_target(), command_context::interp, command::jim_handler_data, jim_nvp_value2name(), jim_to_command(), LOG_DEBUG, LOG_ERROR, LOG_INFO, command_context::mode, MSG, jim_nvp::name, arm_tpiu_swo_object::name, target_type::name, NULL, nvp_arm_tpiu_swo_protocol_opts, arm_tpiu_swo_priv_connection::obj, arm_tpiu_swo_object::out_filename, arm_tpiu_swo_object::pin_protocol, arm_tpiu_swo_object::port_width, priv, arm_tpiu_swo_object::recheck_ap_cur_target, arm_tpiu_swo_object::spot, arm_tpiu_swo_object::swo_pin_freq, TARGET_EVENT_TRACE_CONFIG, target_handle_event(), target_name(), target_register_timer_callback(), TARGET_TIMER_TYPE_PERIODIC, target_to_cm(), target_unregister_timer_callback(), target_was_examined(), TPIU_ACPR_MAX_PRESCALER, TPIU_ACPR_OFFSET, TPIU_CSPSR_OFFSET, TPIU_DEVID_NOSUPPORT_SYNC, TPIU_DEVID_OFFSET, TPIU_DEVID_SUPPORT_MANCHESTER, TPIU_DEVID_SUPPORT_UART, TPIU_FFCR_OFFSET, TPIU_SPPR_OFFSET, TPIU_SPPR_PROTOCOL_MANCHESTER, TPIU_SPPR_PROTOCOL_SYNC, TPIU_SPPR_PROTOCOL_UART, TPIU_SSPSR_OFFSET, TPIU_SWO_EVENT_POST_ENABLE, TPIU_SWO_EVENT_PRE_ENABLE, arm_tpiu_swo_object::traceclkin_freq, transport_is_hla(), target::type, jim_nvp::value, wrap_read_u32(), and wrap_write_u32().

◆ jim_arm_tpiu_swo_init()

static int jim_arm_tpiu_swo_init ( Jim_Interp *  interp,
int  argc,
Jim_Obj *const *  argv 
)
static

◆ jim_arm_tpiu_swo_names()

static int jim_arm_tpiu_swo_names ( Jim_Interp *  interp,
int  argc,
Jim_Obj *const *  argv 
)
static

Definition at line 992 of file arm_tpiu_swo.c.

References lh(), list_for_each_entry, arm_tpiu_swo_object::name, and NULL.

◆ LIST_HEAD()

static LIST_HEAD ( all_tpiu_swo  )
static

◆ wrap_read_u32()

static int wrap_read_u32 ( struct target target,
struct adiv5_ap tpiu_ap,
target_addr_t  address,
uint32_t *  value 
)
static

Definition at line 580 of file arm_tpiu_swo.c.

Referenced by jim_arm_tpiu_swo_enable().

◆ wrap_write_u32()

static int wrap_write_u32 ( struct target target,
struct adiv5_ap tpiu_ap,
target_addr_t  address,
uint32_t  value 
)
static

Variable Documentation

◆ arm_tpiu_deprecated_command_handlers

const struct command_registration arm_tpiu_deprecated_command_handlers[]
Initial value:
= {
{
.name = "tpiu",
.usage = "",
.help = "tpiu command group",
},
}
static const struct command_registration arm_tpiu_deprecated_subcommand_handlers[]
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:247
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:235

Definition at line 1031 of file arm_tpiu_swo.c.

◆ arm_tpiu_deprecated_subcommand_handlers

const struct command_registration arm_tpiu_deprecated_subcommand_handlers[]
static
Initial value:
= {
{
.name = "config",
.handler = handle_tpiu_deprecated_config_command,
.mode = COMMAND_ANY,
.help = "Configure TPIU features, DEPRECATED, use \'tpiu create\'",
.usage = "(disable | "
"((external | internal (<filename> | <:port> | -)) "
"(sync <port width> | ((manchester | uart) <formatter enable>)) "
"<TRACECLKIN freq> [<trace freq>]))",
},
}
@ COMMAND_ANY
Definition: command.h:42

Definition at line 1031 of file arm_tpiu_swo.c.

◆ arm_tpiu_swo_command_handlers

const struct command_registration arm_tpiu_swo_command_handlers[]
static
Initial value:
= {
{
.name = "tpiu",
.usage = "",
.help = "tpiu command group",
},
{
.name = "swo",
.usage = "",
.help = "swo command group",
},
}
static const struct command_registration arm_tpiu_swo_subcommand_handlers[]

Definition at line 1031 of file arm_tpiu_swo.c.

◆ arm_tpiu_swo_instance_command_handlers

const struct command_registration arm_tpiu_swo_instance_command_handlers[]
static

Definition at line 823 of file arm_tpiu_swo.c.

Referenced by arm_tpiu_swo_create().

◆ arm_tpiu_swo_service_driver

const struct service_driver arm_tpiu_swo_service_driver
static
Initial value:
= {
.name = "tpiu_swo_trace",
.new_connection_during_keep_alive_handler = NULL,
.new_connection_handler = arm_tpiu_swo_service_new_connection,
.input_handler = arm_tpiu_swo_service_input,
.connection_closed_handler = arm_tpiu_swo_service_connection_closed,
.keep_client_alive_handler = NULL,
}
static int arm_tpiu_swo_service_connection_closed(struct connection *connection)
Definition: arm_tpiu_swo.c:278
static int arm_tpiu_swo_service_input(struct connection *connection)
Definition: arm_tpiu_swo.c:262
static int arm_tpiu_swo_service_new_connection(struct connection *connection)
Definition: arm_tpiu_swo.c:248
#define NULL
Definition: usb.h:16

Definition at line 580 of file arm_tpiu_swo.c.

Referenced by jim_arm_tpiu_swo_enable().

◆ arm_tpiu_swo_subcommand_handlers

const struct command_registration arm_tpiu_swo_subcommand_handlers[]
static
Initial value:
= {
{
.name = "create",
.mode = COMMAND_ANY,
.jim_handler = jim_arm_tpiu_swo_create,
.usage = "name [-dap dap] [-ap-num num] [-baseaddr baseaddr]",
.help = "Creates a new TPIU or SWO object",
},
{
.name = "names",
.mode = COMMAND_ANY,
.jim_handler = jim_arm_tpiu_swo_names,
.usage = "",
.help = "Lists all registered TPIU and SWO objects by name",
},
{
.name = "init",
.mode = COMMAND_EXEC,
.jim_handler = jim_arm_tpiu_swo_init,
.usage = "",
.help = "Initialize TPIU and SWO",
},
}
static int jim_arm_tpiu_swo_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Definition: arm_tpiu_swo.c:940
static int jim_arm_tpiu_swo_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Definition: arm_tpiu_swo.c:992
static int jim_arm_tpiu_swo_init(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 1031 of file arm_tpiu_swo.c.

◆ nvp_arm_tpiu_swo_bool_opts

const struct jim_nvp nvp_arm_tpiu_swo_bool_opts[]
static
Initial value:
= {
{ .name = "on", .value = 1 },
{ .name = "yes", .value = 1 },
{ .name = "1", .value = 1 },
{ .name = "true", .value = 1 },
{ .name = "off", .value = 0 },
{ .name = "no", .value = 0 },
{ .name = "0", .value = 0 },
{ .name = "false", .value = 0 },
{ .name = NULL, .value = -1 },
}

Definition at line 294 of file arm_tpiu_swo.c.

Referenced by arm_tpiu_swo_configure().

◆ nvp_arm_tpiu_swo_config_opts

const struct jim_nvp nvp_arm_tpiu_swo_config_opts[]
static
Initial value:
= {
{ .name = "-port-width", .value = CFG_PORT_WIDTH },
{ .name = "-protocol", .value = CFG_PROTOCOL },
{ .name = "-formatter", .value = CFG_FORMATTER },
{ .name = "-traceclk", .value = CFG_TRACECLKIN },
{ .name = "-pin-freq", .value = CFG_BITRATE },
{ .name = "-output", .value = CFG_OUTFILE },
{ .name = "-event", .value = CFG_EVENT },
{ .name = "-dap", .value = -1 },
{ .name = "-ap-num", .value = -1 },
{ .name = "-baseaddr", .value = -1 },
{ .name = NULL, .value = -1 },
}
@ CFG_PROTOCOL
Definition: arm_tpiu_swo.c:314
@ CFG_TRACECLKIN
Definition: arm_tpiu_swo.c:316
@ CFG_FORMATTER
Definition: arm_tpiu_swo.c:315
@ CFG_PORT_WIDTH
Definition: arm_tpiu_swo.c:313
@ CFG_OUTFILE
Definition: arm_tpiu_swo.c:318
@ CFG_EVENT
Definition: arm_tpiu_swo.c:319
@ CFG_BITRATE
Definition: arm_tpiu_swo.c:317

Definition at line 294 of file arm_tpiu_swo.c.

Referenced by arm_tpiu_swo_configure().

◆ nvp_arm_tpiu_swo_event

const struct jim_nvp nvp_arm_tpiu_swo_event[]
static
Initial value:
= {
{ .value = TPIU_SWO_EVENT_PRE_ENABLE, .name = "pre-enable" },
{ .value = TPIU_SWO_EVENT_POST_ENABLE, .name = "post-enable" },
{ .value = TPIU_SWO_EVENT_PRE_DISABLE, .name = "pre-disable" },
{ .value = TPIU_SWO_EVENT_POST_DISABLE, .name = "post-disable" },
}
@ TPIU_SWO_EVENT_PRE_DISABLE
Definition: arm_tpiu_swo.c:72
@ TPIU_SWO_EVENT_PRE_ENABLE
Definition: arm_tpiu_swo.c:70
@ TPIU_SWO_EVENT_POST_ENABLE
Definition: arm_tpiu_swo.c:71
@ TPIU_SWO_EVENT_POST_DISABLE
Definition: arm_tpiu_swo.c:73

Definition at line 1 of file arm_tpiu_swo.c.

Referenced by arm_tpiu_swo_configure(), arm_tpiu_swo_handle_event(), and COMMAND_HANDLER().

◆ nvp_arm_tpiu_swo_protocol_opts

const struct jim_nvp nvp_arm_tpiu_swo_protocol_opts[]
static
Initial value:
= {
{ .name = "sync", .value = TPIU_SPPR_PROTOCOL_SYNC },
{ .name = "uart", .value = TPIU_SPPR_PROTOCOL_UART },
{ .name = "manchester", .value = TPIU_SPPR_PROTOCOL_MANCHESTER },
{ .name = NULL, .value = -1 },
}
#define TPIU_SPPR_PROTOCOL_MANCHESTER
Definition: arm_tpiu_swo.c:63
#define TPIU_SPPR_PROTOCOL_SYNC
Definition: arm_tpiu_swo.c:62
#define TPIU_SPPR_PROTOCOL_UART
Definition: arm_tpiu_swo.c:64

Definition at line 294 of file arm_tpiu_swo.c.

Referenced by arm_tpiu_swo_configure(), and jim_arm_tpiu_swo_enable().