diff options
Diffstat (limited to 'drivers/fastboot/fb_command.c')
-rw-r--r-- | drivers/fastboot/fb_command.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index 5fcadcdf50..f95f4e4ae1 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -5,6 +5,7 @@ #include <common.h> #include <command.h> +#include <console.h> #include <env.h> #include <fastboot.h> #include <fastboot-internal.h> @@ -40,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 *); @@ -107,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)) @@ -152,6 +158,35 @@ int fastboot_handle_command(char *cmd_string, char *response) return -1; } +void fastboot_multiresponse(int cmd, char *response) +{ + switch (cmd) { + 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; + } +} + /** * okay() - Send bare OKAY response * @@ -490,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); +} |