diff options
author | Daniel Anselmi <danselmi@gmx.ch> | 2024-01-01 16:05:07 +0100 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2024-03-16 14:44:31 +0000 |
commit | a88db9b1211ea71b5795b91d11d94fb0f37cc905 (patch) | |
tree | c802465d7f236682b8c9cad199186eee6663698a | |
parent | 7a77355a3ea574dc5b7fc0a6ea8be413589ef847 (diff) | |
download | riscv-openocd-a88db9b1211ea71b5795b91d11d94fb0f37cc905.zip riscv-openocd-a88db9b1211ea71b5795b91d11d94fb0f37cc905.tar.gz riscv-openocd-a88db9b1211ea71b5795b91d11d94fb0f37cc905.tar.bz2 |
ipdbg: configurable queue size used between JTAG-Host and JTAG-Hub
Change-Id: I7941de02a968ccab730bfebd3483b8c3b84d7e53
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7980
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
-rw-r--r-- | doc/openocd.texi | 14 | ||||
-rw-r--r-- | src/server/ipdbg.c | 68 |
2 files changed, 68 insertions, 14 deletions
diff --git a/doc/openocd.texi b/doc/openocd.texi index 651cc53..6b71fe8 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -12198,6 +12198,20 @@ xc7.ipdbghub ipdbg start -port 5555 -tool 0 Starts a server listening on tcp-port 5555 which connects to tool 0 (data_up_0/data_down_0). The TAP and ir value used to reach the JTAG Hub is given by the pld driver. +@deffn {Command} {$hub_name queuing} @option{-size @var{size}} +Configure the queuing between IPDBG JTAG-Host and Hub. +The maximum possible queue size is 1024 which is also the default. + +@itemize @bullet +@item @option{-size @var{size}} max number of transfers in the queue. +@end itemize +@end deffn + +@example +bitbang.ibdbghub queuing -size 32 +@end example +Send a maximum of 32 transfers to the queue before executing them. + @node Utility Commands @chapter Utility Commands diff --git a/src/server/ipdbg.c b/src/server/ipdbg.c index e218b82..e7eb96e 100644 --- a/src/server/ipdbg.c +++ b/src/server/ipdbg.c @@ -19,20 +19,11 @@ #define IPDBG_MAX_NUM_OF_CREATE_OPTIONS 10 #define IPDBG_NUM_OF_START_OPTIONS 4 #define IPDBG_NUM_OF_STOP_OPTIONS 2 +#define IPDBG_NUM_OF_QUEUE_OPTIONS 2 #define IPDBG_MIN_DR_LENGTH 11 #define IPDBG_MAX_DR_LENGTH 13 #define IPDBG_TCP_PORT_STR_MAX_LENGTH 6 #define IPDBG_SCRATCH_MEMORY_SIZE 1024 -#define IPDBG_EMPTY_DOWN_TRANSFERS 1024 -#define IPDBG_CONSECUTIVE_UP_TRANSFERS 1024 - -#if IPDBG_SCRATCH_MEMORY_SIZE < IPDBG_EMPTY_DOWN_TRANSFERS -#error "scratch Memory must be at least IPDBG_EMPTY_DOWN_TRANSFERS" -#endif - -#if IPDBG_SCRATCH_MEMORY_SIZE < IPDBG_CONSECUTIVE_UP_TRANSFERS -#error "scratch Memory must be at least IPDBG_CONSECUTIVE_UP_TRANSFERS" -#endif /* private connection data for IPDBG */ struct ipdbg_fifo { @@ -78,6 +69,7 @@ struct ipdbg_hub { uint32_t tool_mask; uint32_t last_dn_tool; char *name; + size_t using_queue_size; struct ipdbg_hub *next; struct jtag_tap *tap; struct connection **connections; @@ -461,7 +453,7 @@ static int ipdbg_shift_empty_data(struct ipdbg_hub *hub) const size_t dreg_buffer_size = DIV_ROUND_UP(hub->data_register_length, 8); memset(hub->scratch_memory.dr_out_vals, 0, dreg_buffer_size); - for (size_t i = 0; i < IPDBG_EMPTY_DOWN_TRANSFERS; ++i) { + for (size_t i = 0; i < hub->using_queue_size; ++i) { ipdbg_init_scan_field(hub->scratch_memory.fields + i, hub->scratch_memory.dr_in_vals + i * dreg_buffer_size, hub->data_register_length, @@ -473,7 +465,7 @@ static int ipdbg_shift_empty_data(struct ipdbg_hub *hub) if (retval == ERROR_OK) { uint32_t up_data; - for (size_t i = 0; i < IPDBG_EMPTY_DOWN_TRANSFERS; ++i) { + for (size_t i = 0; i < hub->using_queue_size; ++i) { up_data = buf_get_u32(hub->scratch_memory.dr_in_vals + i * dreg_buffer_size, 0, hub->data_register_length); @@ -522,8 +514,8 @@ static int ipdbg_jtag_transfer_bytes(struct ipdbg_hub *hub, return ERROR_FAIL; const size_t dreg_buffer_size = DIV_ROUND_UP(hub->data_register_length, 8); - size_t num_tx = (connection->dn_fifo.count < IPDBG_CONSECUTIVE_UP_TRANSFERS) ? - connection->dn_fifo.count : IPDBG_CONSECUTIVE_UP_TRANSFERS; + size_t num_tx = (connection->dn_fifo.count < hub->using_queue_size) ? + connection->dn_fifo.count : hub->using_queue_size; for (size_t i = 0; i < num_tx; ++i) { uint32_t dn_data = hub->valid_mask | ((tool & hub->tool_mask) << 8) | @@ -906,6 +898,46 @@ static const struct command_registration ipdbg_hostserver_subcommand_handlers[] COMMAND_REGISTRATION_DONE }; +static COMMAND_HELPER(ipdbg_config_queuing, struct ipdbg_hub *hub, unsigned int size) +{ + if (!hub) + return ERROR_FAIL; + + if (hub->active_connections) { + command_print(CMD, "Configuration change not allowed when hub has active connections"); + return ERROR_FAIL; + } + + if (size == 0 || size > IPDBG_SCRATCH_MEMORY_SIZE) { + command_print(CMD, "queuing size out of range! Must be 0 < size <= %d", IPDBG_SCRATCH_MEMORY_SIZE); + return ERROR_COMMAND_ARGUMENT_INVALID; + } + + hub->using_queue_size = size; + return ERROR_OK; +} + +COMMAND_HANDLER(handle_ipdbg_cfg_queuing_command) +{ + struct ipdbg_hub *hub = CMD_DATA; + + unsigned int size; + + if (CMD_ARGC != IPDBG_NUM_OF_QUEUE_OPTIONS) + return ERROR_COMMAND_SYNTAX_ERROR; + + for (unsigned int i = 0; i < CMD_ARGC; ++i) { + if (strcmp(CMD_ARGV[i], "-size") == 0) { + COMMAND_PARSE_ADDITIONAL_NUMBER(uint, i, size, "size"); + } else { + command_print(CMD, "Unknown argument: %s", CMD_ARGV[i]); + return ERROR_FAIL; + } + } + + return CALL_COMMAND_HANDLER(ipdbg_config_queuing, hub, size); +} + static const struct command_registration ipdbg_hub_subcommand_handlers[] = { { .name = "ipdbg", @@ -914,6 +946,13 @@ static const struct command_registration ipdbg_hub_subcommand_handlers[] = { .usage = "", .chain = ipdbg_hostserver_subcommand_handlers }, + { + .name = "queuing", + .handler = handle_ipdbg_cfg_queuing_command, + .mode = COMMAND_ANY, + .help = "configures queuing between IPDBG Host and Hub.", + .usage = "-size size", + }, COMMAND_REGISTRATION_DONE }; @@ -960,6 +999,7 @@ static int ipdbg_create_hub(struct jtag_tap *tap, uint32_t user_instruction, uin new_hub->last_dn_tool = new_hub->tool_mask; new_hub->virtual_ir = virtual_ir; new_hub->max_tools = ipdbg_max_tools_from_data_register_length(data_register_length); + new_hub->using_queue_size = IPDBG_SCRATCH_MEMORY_SIZE; int retval = ipdbg_register_hub_command(new_hub, cmd); if (retval != ERROR_OK) { |