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_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 int | jim_adapter_name (Jim_Interp *interp, int argc, Jim_Obj *const *argv) |
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 249 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 258 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 95 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, 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 299 of file adapter.c.
References adapter_config.
Referenced by cmsis_dap_open(), COMMAND_HANDLER(), 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 268 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 208 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(), 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 284 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 1223 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 1217 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 123 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, and adapter_driver::speed.
Referenced by COMMAND_HANDLER(), jtag_init(), jtag_init_reset(), and swd_init_reset().
|
static |
Definition at line 213 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 186 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 232 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 1212 of file adapter.c.
References interface_command_handlers, NULL, and register_commands().
Referenced by setup_command_handler().
|
static |
Definition at line 242 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 325 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 330 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 396 of file adapter.c.
References allow_transports(), CALL_COMMAND_HANDLER, CMD_CTX, and ERROR_OK.
COMMAND_HANDLER | ( | handle_adapter_driver_command | ) |
Definition at line 429 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 415 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_reset_de_assert | ) |
Definition at line 752 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 742 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 714 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 686 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 700 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 467 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 915 of file adapter.c.
References ADAPTER_GPIO_IDX_NUM, CALL_COMMAND_HANDLER, and ERROR_OK.
|
static |
Definition at line 847 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_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 838 of file adapter.c.
References ADAPTER_GPIO_IDX_NUM, and name.
bool is_adapter_initialized | ( | void | ) |
Definition at line 73 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 379 of file adapter.c.
References jim_getopt_info::argc, jim_getopt_info::argv, jim_getopt_info::interp, jim_getopt_setup(), adapter_driver::name, name, and NULL.
|
static |
Definition at line 82 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 30 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 922 of file adapter.c.
Referenced by adapter_register_commands().
char* serial |
Definition at line 47 of file adapter.c.
Referenced by cmsis_dap_hid_open(), cmsis_dap_usb_open(), jlink_init(), jtag_libusb_match_serial(), jtag_libusb_open(), mpsse_open(), and open_matching_device().