Merge branch '2022-08-04-Kconfig-migrations'
[platform/kernel/u-boot.git] / drivers / fastboot / fb_command.c
index 41fc8d7..bdfdf26 100644 (file)
@@ -10,7 +10,6 @@
 #include <fastboot-internal.h>
 #include <fb_mmc.h>
 #include <fb_nand.h>
-#include <flash.h>
 #include <part.h>
 #include <stdlib.h>
 
@@ -49,6 +48,11 @@ static void oem_partconf(char *, char *);
 static void oem_bootbus(char *, char *);
 #endif
 
+#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
+static void run_ucmd(char *, char *);
+static void run_acmd(char *, char *);
+#endif
+
 static const struct {
        const char *command;
        void (*dispatch)(char *cmd_parameter, char *response);
@@ -117,6 +121,16 @@ static const struct {
                .dispatch = oem_bootbus,
        },
 #endif
+#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
+       [FASTBOOT_COMMAND_UCMD] = {
+               .command = "UCmd",
+               .dispatch = run_ucmd,
+       },
+       [FASTBOOT_COMMAND_ACMD] = {
+               .command = "ACmd",
+               .dispatch = run_acmd,
+       },
+#endif
 };
 
 /**
@@ -193,7 +207,7 @@ static void download(char *cmd_parameter, char *response)
                return;
        }
        fastboot_bytes_received = 0;
-       fastboot_bytes_expected = simple_strtoul(cmd_parameter, &tmp, 16);
+       fastboot_bytes_expected = hextoul(cmd_parameter, &tmp);
        if (fastboot_bytes_expected == 0) {
                fastboot_fail("Expected nonzero image size", response);
                return;
@@ -327,6 +341,59 @@ static void erase(char *cmd_parameter, char *response)
 }
 #endif
 
+#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
+/**
+ * run_ucmd() - Execute the UCmd command
+ *
+ * @cmd_parameter: Pointer to command parameter
+ * @response: Pointer to fastboot response buffer
+ */
+static void run_ucmd(char *cmd_parameter, char *response)
+{
+       if (!cmd_parameter) {
+               pr_err("missing slot suffix\n");
+               fastboot_fail("missing command", response);
+               return;
+       }
+
+       if (run_command(cmd_parameter, 0))
+               fastboot_fail("", response);
+       else
+               fastboot_okay(NULL, response);
+}
+
+static char g_a_cmd_buff[64];
+
+void fastboot_acmd_complete(void)
+{
+       run_command(g_a_cmd_buff, 0);
+}
+
+/**
+ * run_acmd() - Execute the ACmd command
+ *
+ * @cmd_parameter: Pointer to command parameter
+ * @response: Pointer to fastboot response buffer
+ */
+static void run_acmd(char *cmd_parameter, char *response)
+{
+       if (!cmd_parameter) {
+               pr_err("missing slot suffix\n");
+               fastboot_fail("missing command", response);
+               return;
+       }
+
+       if (strlen(cmd_parameter) > sizeof(g_a_cmd_buff)) {
+               pr_err("too long command\n");
+               fastboot_fail("too long command", response);
+               return;
+       }
+
+       strcpy(g_a_cmd_buff, cmd_parameter);
+       fastboot_okay(NULL, response);
+}
+#endif
+
 /**
  * reboot_bootloader() - Sets reboot bootloader flag.
  *