*/
#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,
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)
{
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;
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;
}
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, "", ""),