summaryrefslogtreecommitdiffstats
path: root/common/bootm.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-09-23 11:15:46 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-09-24 09:03:18 +0200
commitb15c5eeecfbe4e4d1167b67a897d6c61dbae4251 (patch)
tree4fe11d458b5732eb716f5231c65c6bd9415486fd /common/bootm.c
parent172fc40f617799023e56cb005f088a522ab6fe6f (diff)
downloadbarebox-b15c5eeecfbe4e4d1167b67a897d6c61dbae4251.tar.gz
barebox-b15c5eeecfbe4e4d1167b67a897d6c61dbae4251.tar.xz
bootm: separate bootm input data and internal data
We used to use struct image_data as the central data structure for bootm and also as the input data structure. This makes it unclear which of the fields are actually input data. This patch creates a struct bootm_data which is exclusively used for input data to make usage clearer. Also it moves the dispatching of multifile uImage pathnames to the core bootm code so that the core code gets more flexible and the command code simpler. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/bootm.c')
-rw-r--r--common/bootm.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/common/bootm.c b/common/bootm.c
index 259feaca33..3c5689bed7 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -219,17 +219,54 @@ static void bootm_print_info(struct image_data *data)
}
}
-int bootm_boot(struct image_data *data)
+static char *bootm_image_name_and_no(const char *name, int *no)
{
+ char *at, *ret;
+
+ if (!name || !*name)
+ return NULL;
+
+ *no = 0;
+
+ ret = xstrdup(name);
+ at = strchr(ret, '@');
+ if (!at)
+ return ret;
+
+ *at++ = 0;
+
+ *no = simple_strtoul(at, NULL, 10);
+
+ return ret;
+}
+
+/*
+ * bootm_boot - Boot an application image described by bootm_data
+ */
+int bootm_boot(struct bootm_data *bootm_data)
+{
+ struct image_data *data;
struct image_handler *handler;
int ret;
enum filetype os_type, initrd_type = filetype_unknown;
- if (!data->os_file) {
+ if (!bootm_data->os_file) {
printf("no image given\n");
return -ENOENT;
}
+ data = xzalloc(sizeof(*data));
+
+ data->os_file = bootm_image_name_and_no(bootm_data->os_file, &data->os_num);
+ data->oftree_file = bootm_image_name_and_no(bootm_data->oftree_file, &data->oftree_num);
+ data->initrd_file = bootm_image_name_and_no(bootm_data->initrd_file, &data->initrd_num);
+ data->verbose = bootm_data->verbose;
+ data->verify = bootm_data->verify;
+ data->force = bootm_data->force;
+ data->initrd_address = bootm_data->initrd_address;
+ data->os_address = bootm_data->os_address;
+ data->os_entry = bootm_data->os_entry;
+
os_type = file_name_detect_type(data->os_file);
if ((int)os_type < 0) {
printf("could not open %s: %s\n", data->os_file,
@@ -322,6 +359,11 @@ err_out:
if (data->of_root_node && data->of_root_node != of_get_root_node())
of_delete_node(data->of_root_node);
+ free(data->os_file);
+ free(data->oftree_file);
+ free(data->initrd_file);
+ free(data);
+
return ret;
}