From 868e76b2d001b89853d6a22295a10ed3d653b474 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Mon, 29 Aug 2022 18:18:54 +0100 Subject: [PATCH] hosted: Addition of selectable fast polling for hosted use cases --- src/gdb_main.c | 1 + src/include/platform_support.h | 2 ++ src/platforms/hosted/cli.c | 8 +++++++- src/platforms/hosted/cli.h | 5 +++-- src/platforms/hosted/platform.c | 6 ++++++ 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/gdb_main.c b/src/gdb_main.c index d0fc871..3fee2b7 100644 --- a/src/gdb_main.c +++ b/src/gdb_main.c @@ -222,6 +222,7 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall) char c = (char)gdb_if_getchar_to(0); if(c == '\x03' || c == '\x04') target_halt_request(cur_target); + platform_pace_poll(); #ifdef ENABLE_RTT if (rtt_enabled) poll_rtt(cur_target); diff --git a/src/include/platform_support.h b/src/include/platform_support.h index ed0b027..51ddf03 100644 --- a/src/include/platform_support.h +++ b/src/include/platform_support.h @@ -28,8 +28,10 @@ #if PC_HOSTED == 1 void platform_init(int argc, char **argv); +void platform_pace_poll(void); #else void platform_init(void); +inline void platform_pace_poll(void) { } #endif typedef struct platform_timeout platform_timeout; diff --git a/src/platforms/hosted/cli.c b/src/platforms/hosted/cli.c index 3893364..8471b3e 100644 --- a/src/platforms/hosted/cli.c +++ b/src/platforms/hosted/cli.c @@ -159,6 +159,8 @@ static void cl_help(char **argv) "\t-j, --jtag Use JTAG instead of SWD\n" "\t-A, --auto-scan Automatic scanning - try JTAG first, then SWD\n" "\t-C, --hw-reset Connect to target under hardware reset\n" + "\t-F, --fast-poll Poll the target for execution status at maximum speed at\n" + "\t the expense of increased CPU and USB resource utilisation.\n" "\t-t, --list-chain Perform a chain scan and display information about the\n" "\t conected devices\n" "\t-T, --timing Perform continues read- or write-back of a value to allow\n" @@ -205,6 +207,7 @@ static const struct option long_options[] = { {"probe", required_argument, NULL, 'P'}, {"serial", required_argument, NULL, 's'}, {"ftdi-type", required_argument, NULL, 'c'}, + {"fast-poll", no_argument, NULL, 'F'}, {"number", required_argument, NULL, 'n'}, {"jtag", no_argument, NULL, 'j'}, {"auto-scan", no_argument, NULL, 'A'}, @@ -236,7 +239,7 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv) opt->opt_max_swj_frequency = 4000000; opt->opt_scanmode = BMP_SCAN_SWD; opt->opt_mode = BMP_MODE_DEBUG; - while((c = getopt_long(argc, argv, "eEhHv:d:f:s:I:c:Cln:m:M:wVtTa:S:jApP:rR::", long_options, NULL)) != -1) { + while((c = getopt_long(argc, argv, "eEFhHv:d:f:s:I:c:Cln:m:M:wVtTa:S:jApP:rR::", long_options, NULL)) != -1) { switch(c) { case 'c': if (optarg) @@ -273,6 +276,9 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv) if (optarg) opt->opt_device = optarg; break; + case 'F': + opt->fast_poll = true; + break; case 'f': if (optarg) { char *p; diff --git a/src/platforms/hosted/cli.h b/src/platforms/hosted/cli.h index b3015b4..8bf501a 100644 --- a/src/platforms/hosted/cli.h +++ b/src/platforms/hosted/cli.h @@ -53,13 +53,14 @@ typedef struct BMP_CL_OPTIONS_s { bool opt_list_only; bool opt_connect_under_reset; bool external_resistor_swd; + bool fast_poll; bool opt_no_hl; char *opt_flash_file; char *opt_device; char *opt_serial; uint32_t opt_targetid; char *opt_ident_string; - int opt_position; + int opt_position; char *opt_cable; char *opt_monitor; int opt_debuglevel; @@ -67,7 +68,7 @@ typedef struct BMP_CL_OPTIONS_s { uint32_t opt_flash_start; uint32_t opt_max_swj_frequency; size_t opt_flash_size; -}BMP_CL_OPTIONS_t; +} BMP_CL_OPTIONS_t; void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv); int cl_execute(BMP_CL_OPTIONS_t *opt); diff --git a/src/platforms/hosted/platform.c b/src/platforms/hosted/platform.c index 9a26812..290335b 100644 --- a/src/platforms/hosted/platform.c +++ b/src/platforms/hosted/platform.c @@ -483,6 +483,12 @@ void platform_buffer_flush(void) } } +void platform_pace_poll(void) +{ + if (!cl_opts.fast_poll) + platform_delay(8); +} + void platform_target_clk_output_enable(const bool enable) { switch (info.bmp_type) {