From 85fcd69dc2c03025648a1b1b511c1f10abf87c1e Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Fri, 5 Jan 2024 09:22:06 +0200 Subject: fastboot: multiresponse support Currently u-boot fastboot can only send one message back to host, so if there is a need to print more than one line messages must be kept sending until all the required data is obtained. This behavior can be adjusted using multiresponce ability (getting multiple lines of response) proposed in this patch. Signed-off-by: Ion Agorria Signed-off-by: Svyatoslav Ryhel Reviewed-by: Mattijs Korpershoek Link: https://lore.kernel.org/r/20240105072212.6615-2-clamor95@gmail.com Signed-off-by: Mattijs Korpershoek --- drivers/fastboot/fb_command.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/fastboot/fb_command.c') diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index 5fcadcdf503..ab72d8c7810 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -152,6 +153,15 @@ int fastboot_handle_command(char *cmd_string, char *response) return -1; } +void fastboot_multiresponse(int cmd, char *response) +{ + switch (cmd) { + default: + fastboot_fail("Unknown multiresponse command", response); + break; + } +} + /** * okay() - Send bare OKAY response * -- cgit v1.2.3 From 475aa9aabee7ab472341d755cc339f1345d5f49e Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Fri, 5 Jan 2024 09:22:07 +0200 Subject: fastboot: implement "getvar all" This commit implements "fastboot getvar all" listing by iterating the existing dispatchers that don't require parameters (as we pass NULL), uses fastboot multiresponse. Signed-off-by: Ion Agorria Signed-off-by: Svyatoslav Ryhel Reviewed-by: Mattijs Korpershoek Link: https://lore.kernel.org/r/20240105072212.6615-3-clamor95@gmail.com Signed-off-by: Mattijs Korpershoek --- drivers/fastboot/fb_command.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/fastboot/fb_command.c') diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index ab72d8c7810..6f621df074a 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -156,6 +156,9 @@ int fastboot_handle_command(char *cmd_string, char *response) void fastboot_multiresponse(int cmd, char *response) { switch (cmd) { + case FASTBOOT_COMMAND_GETVAR: + fastboot_getvar_all(response); + break; default: fastboot_fail("Unknown multiresponse command", response); break; -- cgit v1.2.3 From 16f79dd4cd624de0ee336dfeeac6db954f99ae68 Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Fri, 5 Jan 2024 09:22:11 +0200 Subject: fastboot: add oem console command support "oem console" serves to read console record buffer. Signed-off-by: Ion Agorria Signed-off-by: Svyatoslav Ryhel Reviewed-by: Mattijs Korpershoek Link: https://lore.kernel.org/r/20240105072212.6615-7-clamor95@gmail.com Signed-off-by: Mattijs Korpershoek --- drivers/fastboot/fb_command.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'drivers/fastboot/fb_command.c') diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index 6f621df074a..f95f4e4ae15 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -41,6 +41,7 @@ static void reboot_recovery(char *, char *); static void oem_format(char *, char *); static void oem_partconf(char *, char *); static void oem_bootbus(char *, char *); +static void oem_console(char *, char *); static void run_ucmd(char *, char *); static void run_acmd(char *, char *); @@ -108,6 +109,10 @@ static const struct { .command = "oem run", .dispatch = CONFIG_IS_ENABLED(FASTBOOT_OEM_RUN, (run_ucmd), (NULL)) }, + [FASTBOOT_COMMAND_OEM_CONSOLE] = { + .command = "oem console", + .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_CONSOLE, (oem_console), (NULL)) + }, [FASTBOOT_COMMAND_UCMD] = { .command = "UCmd", .dispatch = CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT, (run_ucmd), (NULL)) @@ -159,6 +164,23 @@ void fastboot_multiresponse(int cmd, char *response) case FASTBOOT_COMMAND_GETVAR: fastboot_getvar_all(response); break; + case FASTBOOT_COMMAND_OEM_CONSOLE: + if (CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_CONSOLE)) { + char buf[FASTBOOT_RESPONSE_LEN] = { 0 }; + + if (console_record_isempty()) { + console_record_reset(); + fastboot_okay(NULL, response); + } else { + int ret = console_record_readline(buf, sizeof(buf) - 5); + + if (ret < 0) + fastboot_fail("Error reading console", response); + else + fastboot_response("INFO", response, "%s", buf); + } + break; + } default: fastboot_fail("Unknown multiresponse command", response); break; @@ -503,3 +525,20 @@ static void __maybe_unused oem_bootbus(char *cmd_parameter, char *response) else fastboot_okay(NULL, response); } + +/** + * oem_console() - Execute the OEM console command + * + * @cmd_parameter: Pointer to command parameter + * @response: Pointer to fastboot response buffer + */ +static void __maybe_unused oem_console(char *cmd_parameter, char *response) +{ + if (cmd_parameter) + console_in_puts(cmd_parameter); + + if (console_record_isempty()) + fastboot_fail("Empty console", response); + else + fastboot_response(FASTBOOT_MULTIRESPONSE_START, response, NULL); +} -- cgit v1.2.3