OpenOCD
|
Holds support for configuring debug adapters from TCl scripts. More...
Go to the source code of this file.
Data Structures | |
struct | gpio_map |
Macros | |
#define | DEFAULT_CLOCK_SPEED_KHZ 100U |
#define | USB_MAX_LOCATION_LENGTH 16 |
Enumerations | |
enum | adapter_clk_mode { CLOCK_MODE_UNSELECTED = 0 , CLOCK_MODE_KHZ , CLOCK_MODE_RCLK } |
Functions | |
int | adapter_config_khz (unsigned int khz) |
Attempt to configure the adapter for the specified kHz. More... | |
int | adapter_config_rclk (unsigned int fallback_speed_khz) |
Attempt to enable RTCK/RCLK. More... | |
static void | adapter_driver_gpios_init (void) |
const char * | adapter_get_required_serial (void) |
Retrieves the serial number set with command 'adapter serial'. More... | |
int | adapter_get_speed (int *speed) |
unsigned int | adapter_get_speed_khz (void) |
Retrieves the clock speed of the adapter in kHz. More... | |
int | adapter_get_speed_readable (int *khz) |
Given a speed setting, use the interface speed_div callback to adjust the setting. More... | |
const struct adapter_gpio_config * | adapter_gpio_get_config (void) |
Retrieves gpio configuration set with command "adapter gpio <signal_name>". More... | |
const char * | adapter_gpio_get_name (enum adapter_gpio_config_index idx) |
Retrieves gpio name. More... | |
int | adapter_init (struct command_context *cmd_ctx) |
Do low-level setup like initializing registers, output signals, and clocking. More... | |
static int | adapter_khz_to_speed (unsigned int khz, int *speed) |
int | adapter_quit (void) |
Shutdown the debug adapter upon program exit. More... | |
static int | adapter_rclk_to_speed (unsigned int fallback_speed_khz, int *speed) |
int | adapter_register_commands (struct command_context *ctx) |
Register the commands which deal with arbitrary debug adapter drivers. More... | |
static int | adapter_set_speed (int speed) |
const char * | adapter_usb_get_location (void) |
bool | adapter_usb_location_equal (uint8_t dev_bus, uint8_t *port_path, size_t path_len) |
COMMAND_HANDLER (adapter_gpio_config_handler) | |
COMMAND_HANDLER (adapter_transports_command) | |
COMMAND_HANDLER (handle_adapter_driver_command) | |
COMMAND_HANDLER (handle_adapter_list_command) | |
COMMAND_HANDLER (handle_adapter_name) | |
COMMAND_HANDLER (handle_adapter_reset_de_assert) | |
COMMAND_HANDLER (handle_adapter_serial_command) | |
COMMAND_HANDLER (handle_adapter_speed_command) | |
COMMAND_HANDLER (handle_adapter_srst_delay_command) | |
COMMAND_HANDLER (handle_adapter_srst_pulse_width_command) | |
COMMAND_HANDLER (handle_reset_config_command) | |
COMMAND_HANDLER (helper_adapter_gpio_print_all_configs) | |
static | COMMAND_HELPER (helper_adapter_gpio_print_config, enum adapter_gpio_config_index gpio_idx) |
static int | get_gpio_index (const char *signal_name) |
bool | is_adapter_initialized (void) |
static void | sync_adapter_reset_with_gpios (void) |
Variables | |
static const struct command_registration | adapter_command_handlers [] |
struct { | |
bool adapter_initialized | |
enum adapter_clk_mode clock_mode | |
struct adapter_gpio_config gpios [ADAPTER_GPIO_IDX_NUM] | |
bool gpios_initialized | |
int rclk_fallback_speed_khz | |
char * serial | |
int speed_khz | |
char * usb_location | |
} | adapter_config |
Adapter configuration. More... | |
struct adapter_driver * | adapter_driver |
static const struct command_registration | adapter_srst_command_handlers [] |
static const struct command_registration | adapter_usb_command_handlers [] |
static const struct gpio_map | gpio_map [ADAPTER_GPIO_IDX_NUM] |
static const struct command_registration | interface_command_handlers [] |
const char *const | jtag_only [] = { "jtag", NULL } |
Holds support for configuring debug adapters from TCl scripts.
Definition in file adapter.c.
enum adapter_clk_mode |
int adapter_config_khz | ( | unsigned int | khz | ) |
Attempt to configure the adapter for the specified kHz.
Definition at line 248 of file adapter.c.
References adapter_config, adapter_khz_to_speed(), adapter_set_speed(), CLOCK_MODE_KHZ, ERROR_OK, and LOG_DEBUG.
Referenced by adapter_init(), and COMMAND_HANDLER().
int adapter_config_rclk | ( | unsigned int | fallback_speed_khz | ) |
Attempt to enable RTCK/RCLK.
If that fails, fallback to the specified frequency.
Definition at line 257 of file adapter.c.
References adapter_config, adapter_rclk_to_speed(), adapter_set_speed(), CLOCK_MODE_RCLK, ERROR_OK, and LOG_DEBUG.
Referenced by COMMAND_HANDLER().
|
static |
Definition at line 91 of file adapter.c.
References adapter_config, ADAPTER_GPIO_DIRECTION_INPUT, ADAPTER_GPIO_IDX_NUM, ADAPTER_GPIO_IDX_SRST, ADAPTER_GPIO_IDX_TMS, ADAPTER_GPIO_IDX_TRST, ADAPTER_GPIO_INIT_STATE_ACTIVE, ADAPTER_GPIO_INIT_STATE_INPUT, ADAPTER_GPIO_NOT_SET, direction, and sync_adapter_reset_with_gpios().
Referenced by adapter_init().
const char* adapter_get_required_serial | ( | void | ) |
Retrieves the serial number set with command 'adapter serial'.
Definition at line 298 of file adapter.c.
References adapter_config.
Referenced by cmsis_dap_open(), ft232r_init(), ftdi_initialize(), jlink_init(), jtag_libusb_open(), presto_jtag_init(), stlink_open(), usb_connect(), vsllink_check_usb_strings(), and xds110_show_info().
int adapter_get_speed | ( | int * | speed | ) |
Definition at line 267 of file adapter.c.
References adapter_config, adapter_get_speed_khz(), adapter_khz_to_speed(), adapter_rclk_to_speed(), CLOCK_MODE_KHZ, CLOCK_MODE_RCLK, ERROR_FAIL, ERROR_OK, and LOG_ERROR.
Referenced by adapter_get_speed_readable(), adapter_init(), amt_jtagaccel_scan(), amt_jtagaccel_state_move(), and COMMAND_HANDLER().
unsigned int adapter_get_speed_khz | ( | void | ) |
Retrieves the clock speed of the adapter in kHz.
Definition at line 207 of file adapter.c.
References adapter_config.
Referenced by adapter_get_speed(), adapter_init(), adapter_khz_to_speed(), cmsis_dap_init(), cmsis_dap_swd_switch_seq(), COMMAND_HANDLER(), ftdi_initialize(), gowin_runtest_idle(), intel_load(), jlink_init(), mips32_pracc_fastdata_xfer(), mips32_pracc_queue_exec(), mips64_pracc_fastdata_xfer(), and vsllink_init().
int adapter_get_speed_readable | ( | int * | speed | ) |
Given a speed setting, use the interface speed_div
callback to adjust the setting.
speed | The speed setting to convert back to readable kHz. |
speed_div
callback. Definition at line 283 of file adapter.c.
References adapter_get_speed(), ERROR_FAIL, ERROR_OK, is_adapter_initialized(), LOG_ERROR, and adapter_driver::speed_div.
Referenced by adapter_init(), and COMMAND_HANDLER().
const struct adapter_gpio_config* adapter_gpio_get_config | ( | void | ) |
Retrieves gpio configuration set with command "adapter gpio <signal_name>".
Definition at line 1221 of file adapter.c.
References adapter_config.
Referenced by am335xgpio_init(), bcm2835gpio_init(), and linuxgpiod_init().
const char* adapter_gpio_get_name | ( | enum adapter_gpio_config_index | idx | ) |
Retrieves gpio name.
Definition at line 1215 of file adapter.c.
References gpio_map::name.
Referenced by helper_get_line(), and initialize_gpio().
int adapter_init | ( | struct command_context * | cmd_ctx | ) |
Do low-level setup like initializing registers, output signals, and clocking.
Initialize debug adapter upon startup.
Definition at line 120 of file adapter.c.
References adapter_config, adapter_config_khz(), adapter_driver_gpios_init(), adapter_get_speed(), adapter_get_speed_khz(), adapter_get_speed_readable(), CLOCK_MODE_KHZ, CLOCK_MODE_RCLK, CLOCK_MODE_UNSELECTED, DEFAULT_CLOCK_SPEED_KHZ, ERROR_JTAG_INIT_FAILED, ERROR_JTAG_INVALID_INTERFACE, ERROR_OK, adapter_driver::init, is_adapter_initialized(), LOG_ERROR, LOG_INFO, LOG_WARNING, adapter_driver::name, and adapter_driver::speed.
Referenced by COMMAND_HANDLER(), jtag_init(), jtag_init_reset(), and swd_init_reset().
|
static |
Definition at line 212 of file adapter.c.
References adapter_config, adapter_get_speed_khz(), ERROR_FAIL, ERROR_OK, is_adapter_initialized(), adapter_driver::khz, LOG_DEBUG, and LOG_ERROR.
Referenced by adapter_config_khz(), adapter_get_speed(), and adapter_rclk_to_speed().
int adapter_quit | ( | void | ) |
Shutdown the debug adapter upon program exit.
Definition at line 185 of file adapter.c.
References adapter_config, ERROR_OK, is_adapter_initialized(), jtag_all_taps(), jtag_tap_free(), LOG_ERROR, jtag_tap::next_tap, and adapter_driver::quit.
Referenced by openocd_main().
|
static |
Definition at line 231 of file adapter.c.
References adapter_khz_to_speed(), ERROR_OK, and LOG_DEBUG.
Referenced by adapter_config_rclk(), and adapter_get_speed().
int adapter_register_commands | ( | struct command_context * | ctx | ) |
Register the commands which deal with arbitrary debug adapter drivers.
Register the adapter's commands.
Definition at line 1210 of file adapter.c.
References interface_command_handlers, NULL, and register_commands().
Referenced by setup_command_handler().
|
static |
Definition at line 241 of file adapter.c.
References ERROR_OK, is_adapter_initialized(), and adapter_driver::speed.
Referenced by adapter_config_khz(), and adapter_config_rclk().
const char* adapter_usb_get_location | ( | void | ) |
Definition at line 324 of file adapter.c.
References adapter_config.
Referenced by adapter_usb_location_equal(), ftdi_initialize(), jlink_open_device(), and jtag_libusb_open().
bool adapter_usb_location_equal | ( | uint8_t | dev_bus, |
uint8_t * | port_path, | ||
size_t | path_len | ||
) |
Definition at line 329 of file adapter.c.
References adapter_usb_get_location(), LOG_WARNING, NULL, strndup(), strnlen(), and USB_MAX_LOCATION_LENGTH.
Referenced by jlink_usb_location_equal().
COMMAND_HANDLER | ( | adapter_transports_command | ) |
Definition at line 392 of file adapter.c.
References allow_transports(), CALL_COMMAND_HANDLER, CMD_CTX, and ERROR_OK.
COMMAND_HANDLER | ( | handle_adapter_driver_command | ) |
Definition at line 425 of file adapter.c.
References adapter_drivers, allow_transports(), CALL_COMMAND_HANDLER, CMD_ARGC, CMD_ARGV, CMD_CTX, ERROR_COMMAND_SYNTAX_ERROR, ERROR_JTAG_INVALID_INTERFACE, ERROR_OK, LOG_ERROR, LOG_WARNING, name, NULL, register_commands(), and adapter_driver::transports.
COMMAND_HANDLER | ( | handle_adapter_list_command | ) |
Definition at line 411 of file adapter.c.
References adapter_drivers, CMD, CMD_ARGC, CMD_NAME, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, adapter_driver::name, and name.
COMMAND_HANDLER | ( | handle_adapter_name | ) |
Definition at line 378 of file adapter.c.
References CMD, CMD_ARGC, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, and adapter_driver::name.
COMMAND_HANDLER | ( | handle_adapter_reset_de_assert | ) |
Definition at line 748 of file adapter.c.
References adapter_resets(), CMD, CMD_ARGC, CMD_ARGV, CMD_NAME, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_FAIL, ERROR_OK, jtag_get_reset_config(), jtag_get_srst(), jtag_get_trst(), jtag_reset_config, LOG_ERROR, RESET_HAS_SRST, RESET_HAS_TRST, SRST_ASSERT, SRST_DEASSERT, transport_is_jtag(), TRST_ASSERT, and TRST_DEASSERT.
COMMAND_HANDLER | ( | handle_adapter_serial_command | ) |
Definition at line 738 of file adapter.c.
References adapter_config, CMD_ARGC, CMD_ARGV, ERROR_COMMAND_SYNTAX_ERROR, and ERROR_OK.
COMMAND_HANDLER | ( | handle_adapter_speed_command | ) |
Definition at line 710 of file adapter.c.
References adapter_config_khz(), adapter_get_speed_khz(), adapter_get_speed_readable(), CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_COMMAND_SYNTAX_ERROR, and ERROR_OK.
COMMAND_HANDLER | ( | handle_adapter_srst_delay_command | ) |
Definition at line 682 of file adapter.c.
References CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, jtag_get_nsrst_delay(), and jtag_set_nsrst_delay().
COMMAND_HANDLER | ( | handle_adapter_srst_pulse_width_command | ) |
Definition at line 696 of file adapter.c.
References CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, jtag_get_nsrst_assert_width(), jtag_set_nsrst_assert_width(), and width.
COMMAND_HANDLER | ( | handle_reset_config_command | ) |
Definition at line 463 of file adapter.c.
References CMD, CMD_ARGC, CMD_ARGV, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, jtag_get_reset_config(), jtag_set_reset_config(), LOG_ERROR, mask, RESET_CNCT_UNDER_SRST, RESET_HAS_SRST, RESET_HAS_TRST, RESET_NONE, RESET_SRST_NO_GATING, RESET_SRST_PULLS_TRST, RESET_SRST_PUSH_PULL, RESET_TRST_AND_SRST, RESET_TRST_OPEN_DRAIN, RESET_TRST_PULLS_SRST, and sync_adapter_reset_with_gpios().
COMMAND_HANDLER | ( | helper_adapter_gpio_print_all_configs | ) |
Definition at line 916 of file adapter.c.
References ADAPTER_GPIO_IDX_NUM, CALL_COMMAND_HANDLER, and ERROR_OK.
|
static |
Definition at line 843 of file adapter.c.
References adapter_gpio_config::active_low, adapter_config, ADAPTER_GPIO_DIRECTION_BIDIRECTIONAL, ADAPTER_GPIO_DIRECTION_INPUT, ADAPTER_GPIO_DIRECTION_OUTPUT, ADAPTER_GPIO_DRIVE_MODE_OPEN_DRAIN, ADAPTER_GPIO_DRIVE_MODE_OPEN_SOURCE, ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL, ADAPTER_GPIO_INIT_STATE_ACTIVE, ADAPTER_GPIO_INIT_STATE_INACTIVE, ADAPTER_GPIO_INIT_STATE_INPUT, ADAPTER_GPIO_NOT_SET, ADAPTER_GPIO_PULL_DOWN, ADAPTER_GPIO_PULL_NONE, ADAPTER_GPIO_PULL_UP, adapter_gpio_config::chip_num, CMD, command_print(), direction, adapter_gpio_config::drive, ERROR_OK, adapter_gpio_config::gpio_num, adapter_gpio_config::init_state, name, and adapter_gpio_config::pull.
|
static |
Definition at line 834 of file adapter.c.
References ADAPTER_GPIO_IDX_NUM, and name.
bool is_adapter_initialized | ( | void | ) |
Definition at line 69 of file adapter.c.
References adapter_config.
Referenced by adapter_get_speed_readable(), adapter_init(), adapter_khz_to_speed(), adapter_quit(), adapter_set_speed(), default_interface_jtag_execute_queue(), and jtag_power_dropout().
|
static |
Definition at line 78 of file adapter.c.
References adapter_config, ADAPTER_GPIO_DRIVE_MODE_OPEN_DRAIN, ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL, ADAPTER_GPIO_IDX_SRST, ADAPTER_GPIO_IDX_TRST, jtag_get_reset_config(), RESET_SRST_PUSH_PULL, and RESET_TRST_OPEN_DRAIN.
Referenced by adapter_driver_gpios_init(), and COMMAND_HANDLER().
|
static |
struct { ... } adapter_config |
Adapter configuration.
Referenced by adapter_config_khz(), adapter_config_rclk(), adapter_driver_gpios_init(), adapter_get_required_serial(), adapter_get_speed(), adapter_get_speed_khz(), adapter_gpio_get_config(), adapter_init(), adapter_khz_to_speed(), adapter_quit(), adapter_usb_get_location(), COMMAND_HANDLER(), COMMAND_HELPER(), is_adapter_initialized(), and sync_adapter_reset_with_gpios().
struct adapter_driver* adapter_driver |
Definition at line 26 of file adapter.c.
Referenced by swd_select().
|
static |
|
static |
enum adapter_clk_mode clock_mode |
|
static |
struct adapter_gpio_config gpios[ADAPTER_GPIO_IDX_NUM] |
|
static |
Definition at line 923 of file adapter.c.
Referenced by adapter_register_commands().
char* serial |
Definition at line 43 of file adapter.c.
Referenced by cmsis_dap_hid_open(), cmsis_dap_usb_open(), jlink_init(), jlink_open_device(), jtag_libusb_match_serial(), jtag_libusb_open(), mpsse_open(), and open_matching_device().