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 int 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_disable)
 
 COMMAND_HANDLER (handle_arm_tpiu_swo_enable)
 
 COMMAND_HANDLER (handle_arm_tpiu_swo_event_list)
 
 COMMAND_HANDLER (handle_arm_tpiu_swo_init)
 
 COMMAND_HANDLER (handle_arm_tpiu_swo_names)
 
 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 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 131 of file arm_tpiu_swo.c.

◆ MSG

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

Definition at line 43 of file arm_tpiu_swo.c.

◆ TCP_SERVICE_NAME

#define TCP_SERVICE_NAME   "tpiu_swo_trace"

Definition at line 46 of file arm_tpiu_swo.c.

◆ TPIU_ACPR_MAX_PRESCALER

#define TPIU_ACPR_MAX_PRESCALER   0x1fff

Definition at line 60 of file arm_tpiu_swo.c.

◆ TPIU_ACPR_OFFSET

#define TPIU_ACPR_OFFSET   0x010

Definition at line 53 of file arm_tpiu_swo.c.

◆ TPIU_CSPSR_OFFSET

#define TPIU_CSPSR_OFFSET   0x004

Definition at line 52 of file arm_tpiu_swo.c.

◆ TPIU_DEVID_NOSUPPORT_SYNC

#define TPIU_DEVID_NOSUPPORT_SYNC   BIT(9)

Definition at line 64 of file arm_tpiu_swo.c.

◆ TPIU_DEVID_OFFSET

#define TPIU_DEVID_OFFSET   0xfc8

Definition at line 58 of file arm_tpiu_swo.c.

◆ TPIU_DEVID_SUPPORT_MANCHESTER

#define TPIU_DEVID_SUPPORT_MANCHESTER   BIT(10)

Definition at line 65 of file arm_tpiu_swo.c.

◆ TPIU_DEVID_SUPPORT_UART

#define TPIU_DEVID_SUPPORT_UART   BIT(11)

Definition at line 66 of file arm_tpiu_swo.c.

◆ TPIU_FFCR_OFFSET

#define TPIU_FFCR_OFFSET   0x304

Definition at line 56 of file arm_tpiu_swo.c.

◆ TPIU_FFSR_OFFSET

#define TPIU_FFSR_OFFSET   0x300

Definition at line 55 of file arm_tpiu_swo.c.

◆ TPIU_FSCR_OFFSET

#define TPIU_FSCR_OFFSET   0x308

Definition at line 57 of file arm_tpiu_swo.c.

◆ TPIU_SPPR_OFFSET

#define TPIU_SPPR_OFFSET   0x0F0

Definition at line 54 of file arm_tpiu_swo.c.

◆ TPIU_SPPR_PROTOCOL_MANCHESTER

#define TPIU_SPPR_PROTOCOL_MANCHESTER   (TPIU_PIN_PROTOCOL_ASYNC_MANCHESTER)

Definition at line 62 of file arm_tpiu_swo.c.

◆ TPIU_SPPR_PROTOCOL_SYNC

#define TPIU_SPPR_PROTOCOL_SYNC   (TPIU_PIN_PROTOCOL_SYNC)

Definition at line 61 of file arm_tpiu_swo.c.

◆ TPIU_SPPR_PROTOCOL_UART

#define TPIU_SPPR_PROTOCOL_UART   (TPIU_PIN_PROTOCOL_ASYNC_UART)

Definition at line 63 of file arm_tpiu_swo.c.

◆ TPIU_SSPSR_OFFSET

#define TPIU_SSPSR_OFFSET   0x000

Definition at line 51 of file arm_tpiu_swo.c.

◆ TPIU_SWO_DEFAULT_BASE

#define TPIU_SWO_DEFAULT_BASE   0xE0040000

Definition at line 49 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 313 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 68 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 1232 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 263 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/6]

COMMAND_HANDLER ( handle_arm_tpiu_swo_disable  )

Definition at line 834 of file arm_tpiu_swo.c.

◆ COMMAND_HANDLER() [2/6]

COMMAND_HANDLER ( handle_arm_tpiu_swo_enable  )

Definition at line 600 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, CMD, CMD_ARGC, CMD_CTX, CMD_DATA, COMMAND_CONFIG, command_print(), CONNECTION_LIMIT_UNLIMITED, 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_COMMAND_SYNTAX_ERROR, ERROR_FAIL, ERROR_OK, arm_tpiu_swo_object::file, get_current_target(), jim_nvp_value2name_simple(), LOG_DEBUG, LOG_ERROR, LOG_INFO, MSG, jim_nvp::name, arm_tpiu_swo_object::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_type_name(), 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(), jim_nvp::value, wrap_read_u32(), and wrap_write_u32().

◆ COMMAND_HANDLER() [3/6]

◆ COMMAND_HANDLER() [4/6]

◆ COMMAND_HANDLER() [5/6]

COMMAND_HANDLER ( handle_arm_tpiu_swo_names  )

◆ COMMAND_HANDLER() [6/6]

COMMAND_HANDLER ( handle_tpiu_deprecated_config_command  )

Definition at line 1037 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()

◆ 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 582 of file arm_tpiu_swo.c.

Referenced by COMMAND_HANDLER().

◆ wrap_write_u32()

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

Definition at line 573 of file arm_tpiu_swo.c.

References mem_ap_write_atomic_u32(), target_write_u32(), and transport_is_hla().

Referenced by COMMAND_HANDLER().

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:253
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:241

Definition at line 1037 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 1037 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 1037 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 834 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:279
static int arm_tpiu_swo_service_input(struct connection *connection)
Definition: arm_tpiu_swo.c:263
static int arm_tpiu_swo_service_new_connection(struct connection *connection)
Definition: arm_tpiu_swo.c:249
#define NULL
Definition: usb.h:16

Definition at line 582 of file arm_tpiu_swo.c.

Referenced by COMMAND_HANDLER().

◆ 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,
.handler = handle_arm_tpiu_swo_names,
.usage = "",
.help = "Lists all registered TPIU and SWO objects by name",
},
{
.name = "init",
.mode = COMMAND_EXEC,
.handler = handle_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:947
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 1037 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 295 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:315
@ CFG_TRACECLKIN
Definition: arm_tpiu_swo.c:317
@ CFG_FORMATTER
Definition: arm_tpiu_swo.c:316
@ CFG_PORT_WIDTH
Definition: arm_tpiu_swo.c:314
@ CFG_OUTFILE
Definition: arm_tpiu_swo.c:319
@ CFG_EVENT
Definition: arm_tpiu_swo.c:320
@ CFG_BITRATE
Definition: arm_tpiu_swo.c:318

Definition at line 295 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:71
@ TPIU_SWO_EVENT_PRE_ENABLE
Definition: arm_tpiu_swo.c:69
@ TPIU_SWO_EVENT_POST_ENABLE
Definition: arm_tpiu_swo.c:70
@ TPIU_SWO_EVENT_POST_DISABLE
Definition: arm_tpiu_swo.c:72

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:62
#define TPIU_SPPR_PROTOCOL_SYNC
Definition: arm_tpiu_swo.c:61
#define TPIU_SPPR_PROTOCOL_UART
Definition: arm_tpiu_swo.c:63

Definition at line 295 of file arm_tpiu_swo.c.

Referenced by arm_tpiu_swo_configure(), and COMMAND_HANDLER().