]> Git Repo - J-u-boot.git/blobdiff - cmd/bcb.c
cmd: mmc: Consider GP partitions in mmc hwpartition user enh start -
[J-u-boot.git] / cmd / bcb.c
index b9cd20ea3d56be1b4d5898d7cf47ab53931f7653..92f4d27990df981e66d766dd4c4b4dd7c2f56a03 100644 (file)
--- a/cmd/bcb.c
+++ b/cmd/bcb.c
@@ -6,10 +6,13 @@
  */
 
 #include <android_bootloader_message.h>
+#include <bcb.h>
 #include <command.h>
 #include <common.h>
 #include <log.h>
 #include <part.h>
+#include <malloc.h>
+#include <memalign.h>
 
 enum bcb_cmd {
        BCB_CMD_LOAD,
@@ -22,7 +25,7 @@ enum bcb_cmd {
 
 static int bcb_dev = -1;
 static int bcb_part = -1;
-static struct bootloader_message bcb = { { 0 } };
+static struct bootloader_message bcb __aligned(ARCH_DMA_MINALIGN) = { { 0 } };
 
 static int bcb_cmd_get(char *cmd)
 {
@@ -178,10 +181,10 @@ static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc,
        return __bcb_load(devnum, argv[2]);
 }
 
-static int __bcb_set(char *fieldp, char *valp)
+static int __bcb_set(char *fieldp, const char *valp)
 {
        int size, len;
-       char *field, *str, *found;
+       char *field, *str, *found, *tmp;
 
        if (bcb_field_get(fieldp, &field, &size))
                return CMD_RET_FAILURE;
@@ -192,14 +195,20 @@ static int __bcb_set(char *fieldp, char *valp)
                       valp, len, size, fieldp);
                return CMD_RET_FAILURE;
        }
-       str = valp;
+       str = strdup(valp);
+       if (!str) {
+               printf("Error: Out of memory while strdup\n");
+               return CMD_RET_FAILURE;
+       }
 
+       tmp = str;
        field[0] = '\0';
-       while ((found = strsep(&str, ":"))) {
+       while ((found = strsep(&tmp, ":"))) {
                if (field[0] != '\0')
                        strcat(field, "\n");
                strcat(field, found);
        }
+       free(str);
 
        return CMD_RET_SUCCESS;
 }
@@ -307,6 +316,25 @@ static int do_bcb_store(struct cmd_tbl *cmdtp, int flag, int argc,
        return __bcb_store();
 }
 
+int bcb_write_reboot_reason(int devnum, char *partp, const char *reasonp)
+{
+       int ret;
+
+       ret = __bcb_load(devnum, partp);
+       if (ret != CMD_RET_SUCCESS)
+               return ret;
+
+       ret = __bcb_set("command", reasonp);
+       if (ret != CMD_RET_SUCCESS)
+               return ret;
+
+       ret = __bcb_store();
+       if (ret != CMD_RET_SUCCESS)
+               return ret;
+
+       return 0;
+}
+
 static struct cmd_tbl cmd_bcb_sub[] = {
        U_BOOT_CMD_MKENT(load, CONFIG_SYS_MAXARGS, 1, do_bcb_load, "", ""),
        U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 1, do_bcb_set, "", ""),
This page took 0.027874 seconds and 4 git commands to generate.