Updates & fixes by Jeremy Kerr <jk@ozlabs.org>.
Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* kexec_load - kexec load helper.
* @l_image: The local image file for kexec to execute.
* @l_initrd: Optional local initrd file for kexec --initrd, can be NULL.
+ * @l_dtb: Optional local dtb file for kexec --dtb, can be NULL.
* @args: Optional command line args for kexec --append, can be NULL.
*/
static int kexec_load(const char *l_image, const char *l_initrd,
- const char *args, int dry_run)
+ const char *l_dtb, const char *args, int dry_run)
{
int result;
- const char *argv[6];
+ const char *argv[7];
const char **p;
char *s_initrd = NULL;
+ char *s_dtb = NULL;
char *s_args = NULL;
p = argv;
*p++ = s_initrd; /* 3 */
}
+ if (l_dtb) {
+ s_dtb = talloc_asprintf(NULL, "--dtb=%s", l_dtb);
+ assert(s_dtb);
+ *p++ = s_dtb; /* 4 */
+ }
+
if (args) {
s_args = talloc_asprintf(NULL, "--append=%s", args);
assert(s_args);
- *p++ = s_args; /* 4 */
+ *p++ = s_args; /* 5 */
}
- *p++ = l_image; /* 5 */
- *p++ = NULL; /* 6 */
+ *p++ = l_image; /* 6*/
+ *p++ = NULL; /* 7 */
result = pb_run_cmd(argv, 1, dry_run);
pb_log("%s: failed: (%d)\n", __func__, result);
talloc_free(s_initrd);
+ talloc_free(s_dtb);
talloc_free(s_args);
return result;
int boot(void *ctx, struct discover_boot_option *opt, struct boot_command *cmd,
int dry_run, boot_status_fn status_fn, void *status_arg)
{
- char *local_image, *local_initrd;
+ char *local_image, *local_initrd, *local_dtb;
+ struct pb_url *image, *initrd, *dtb;
unsigned int clean_image = 0;
unsigned int clean_initrd = 0;
- struct pb_url *image, *initrd;
+ unsigned int clean_dtb = 0;
char *args;
int result;
local_initrd = NULL;
image = NULL;
initrd = NULL;
+ dtb = NULL;
args = NULL;
if (cmd && cmd->boot_image_file) {
initrd = opt->initrd->url;
}
+ if (cmd && cmd->dtb_file) {
+ dtb = pb_url_parse(opt, cmd->dtb_file);
+ } else if (opt && opt->dtb) {
+ dtb = opt->dtb->url;
+ }
+
if (cmd && cmd->boot_args) {
args = talloc_strdup(ctx, cmd->boot_args);
} else if (opt && opt->option->boot_args) {
}
}
+ local_dtb = NULL;
+ if (dtb) {
+ update_status(status_fn, status_arg, BOOT_STATUS_INFO,
+ "loading device tree");
+ local_dtb = load_url(NULL, dtb, &clean_dtb);
+ if (!local_dtb) {
+ update_status(status_fn, status_arg, BOOT_STATUS_ERROR,
+ "Couldn't load device tree");
+ goto no_load;
+ }
+ }
+
update_status(status_fn, status_arg, BOOT_STATUS_INFO,
"performing kexec_load");
- result = kexec_load(local_image, local_initrd, args, dry_run);
+ result = kexec_load(local_image, local_initrd, local_dtb,
+ args, dry_run);
if (result) {
update_status(status_fn, status_arg, BOOT_STATUS_ERROR,
unlink(local_image);
if (clean_initrd)
unlink(local_initrd);
+ if (clean_dtb)
+ unlink(local_dtb);
talloc_free(local_image);
talloc_free(local_initrd);
+ talloc_free(local_dtb);
if (!result) {
update_status(status_fn, status_arg, BOOT_STATUS_INFO,
{
return resource_is_resolved(opt->boot_image) &&
resource_is_resolved(opt->initrd) &&
+ resource_is_resolved(opt->dtb) &&
resource_is_resolved(opt->icon);
}
{
return resource_resolve(opt->boot_image, "boot_image", opt, handler) &&
resource_resolve(opt->initrd, "initrd", opt, handler) &&
+ resource_resolve(opt->dtb, "dtb", opt, handler) &&
resource_resolve(opt->icon, "icon", opt, handler);
}
/* check that the parsers haven't set any of the final data */
assert(!opt->option->boot_image_file);
assert(!opt->option->initrd_file);
+ assert(!opt->option->dtb_file);
assert(!opt->option->icon_file);
assert(!opt->option->device_id);
opt->option->boot_image_file = opt->boot_image->url->full;
if (opt->initrd)
opt->option->initrd_file = opt->initrd->url->full;
+ if (opt->dtb)
+ opt->option->dtb_file = opt->dtb->url->full;
if (opt->icon)
opt->option->icon_file = opt->icon->url->full;
struct resource *boot_image;
struct resource *initrd;
+ struct resource *dtb;
struct resource *icon;
};
char *args;
const char *initrd;
const char *root;
+ const char *dtb;
/* ignore bare values */
args = talloc_strdup(opt, "");
initrd = conf_get_global_option(conf, "initrd");
root = conf_get_global_option(conf, "root");
+ dtb = conf_get_global_option(conf, "dtb");
pos = strchr(value, ' ');
continue;
}
+ if (streq(cl_name, "dtb")) {
+ dtb = cl_value;
+ continue;
+ }
+
args = talloc_asprintf_append(args, "%s=%s ", cl_name,
cl_value);
}
} else
opt->boot_args = args;
+ opt->description = talloc_asprintf(opt, "%s %s", value,
+ opt->boot_args);
+
if (initrd) {
d_opt->initrd = create_devpath_resource(d_opt,
conf->dc->device, initrd);
+ opt->description = talloc_asprintf_append(opt->description,
+ " initrd=%s", initrd);
+ }
- opt->description = talloc_asprintf(opt, "%s initrd=%s %s",
- value, initrd, opt->boot_args);
- } else
- opt->description = talloc_asprintf(opt, "%s %s", value,
- opt->boot_args);
+ if (dtb) {
+ d_opt->dtb = create_devpath_resource(d_opt,
+ conf->dc->device, dtb);
+ opt->description = talloc_asprintf_append(opt->description,
+ " dtb=%s", dtb);
+ }
conf_strip_str(opt->boot_args);
conf_strip_str(opt->description);
}
static struct conf_global_option kboot_global_options[] = {
+ { .name = "dtb" },
{ .name = "initrd" },
{ .name = "root" },
{ .name = "video" },
* 4-byte len, icon_file
* 4-byte len, boot_image_file
* 4-byte len, initrd_file
+ * 4-byte len, dtb_file
* 4-byte len, boot_args
*
* action = 0x2: device remove message
* 4-byte len, boot option id
* 4-byte len, boot_image_file
* 4-byte len, initrd_file
+ * 4-byte len, dtb_file
* 4-byte len, boot_args
*
*/
fprintf(stream, "%s\t\ticon: %s\n", text, opt->icon_file);
fprintf(stream, "%s\t\tboot: %s\n", text, opt->boot_image_file);
fprintf(stream, "%s\t\tinit: %s\n", text, opt->initrd_file);
+ fprintf(stream, "%s\t\tdtb: %s\n", text, opt->dtb_file);
fprintf(stream, "%s\t\targs: %s\n", text, opt->boot_args);
}
}
4 + optional_strlen(opt->icon_file) +
4 + optional_strlen(opt->boot_image_file) +
4 + optional_strlen(opt->initrd_file) +
+ 4 + optional_strlen(opt->dtb_file) +
4 + optional_strlen(opt->boot_args) +
sizeof(opt->is_default);
}
return 4 + optional_strlen(boot->option_id) +
4 + optional_strlen(boot->boot_image_file) +
4 + optional_strlen(boot->initrd_file) +
+ 4 + optional_strlen(boot->dtb_file) +
4 + optional_strlen(boot->boot_args);
}
pos += pb_protocol_serialise_string(pos, opt->icon_file);
pos += pb_protocol_serialise_string(pos, opt->boot_image_file);
pos += pb_protocol_serialise_string(pos, opt->initrd_file);
+ pos += pb_protocol_serialise_string(pos, opt->dtb_file);
pos += pb_protocol_serialise_string(pos, opt->boot_args);
*(bool *)pos = opt->is_default;
pos += pb_protocol_serialise_string(pos, boot->option_id);
pos += pb_protocol_serialise_string(pos, boot->boot_image_file);
pos += pb_protocol_serialise_string(pos, boot->initrd_file);
+ pos += pb_protocol_serialise_string(pos, boot->dtb_file);
pos += pb_protocol_serialise_string(pos, boot->boot_args);
assert(pos <= buf + buf_len);
if (read_string(opt, &pos, &len, &opt->initrd_file))
goto out;
+ if (read_string(opt, &pos, &len, &opt->dtb_file))
+ goto out;
+
if (read_string(opt, &pos, &len, &opt->boot_args))
goto out;
if (read_string(cmd, &pos, &len, &cmd->initrd_file))
goto out;
+ if (read_string(cmd, &pos, &len, &cmd->dtb_file))
+ goto out;
+
if (read_string(cmd, &pos, &len, &cmd->boot_args))
goto out;
char *icon_file;
char *boot_image_file;
char *initrd_file;
+ char *dtb_file;
char *boot_args;
bool is_default;
char *option_id;
char *boot_image_file;
char *initrd_file;
+ char *dtb_file;
char *boot_args;
};
command->option_id = boot_option->id;
command->boot_image_file = data->image;
command->initrd_file = data->initrd;
+ command->dtb_file = data->dtb;
command->boot_args = data->args;
}
struct pb_boot_data {
char *image;
char *initrd;
+ char *dtb;
char *args;
};
bd->initrd = *s ? talloc_strdup(bd, s) : NULL;
s = boot_editor_chomp(field_buffer(boot_editor->fields[2], 0));
+ bd->dtb = *s ? talloc_strdup(bd, s) : NULL;
+
+ s = boot_editor_chomp(field_buffer(boot_editor->fields[3], 0));
bd->args = *s ? talloc_strdup(bd, s) : NULL;
return bd;
pb_log("%s: image: '%s'\n", __func__, bd->image);
pb_log("%s: initrd: '%s'\n", __func__, bd->initrd);
+ pb_log("%s: dtb: '%s'\n", __func__, bd->dtb);
pb_log("%s: args: '%s'\n", __func__, bd->args);
assert(on_exit);
boot_editor->on_exit = on_exit;
- boot_editor->fields = talloc_array(boot_editor, FIELD *, 7);
+ boot_editor->fields = talloc_array(boot_editor, FIELD *, 9);
boot_editor->fields[0] = boot_editor_setup_field(0, 9, bd->image);
boot_editor->fields[1] = boot_editor_setup_field(1, 9, bd->initrd);
- boot_editor->fields[2] = boot_editor_setup_field(2, 9, bd->args);
- boot_editor->fields[3] = boot_editor_setup_label(0, 1, "image:");
- boot_editor->fields[4] = boot_editor_setup_label(1, 1, "initrd:");
- boot_editor->fields[5] = boot_editor_setup_label(2, 1, "args:");
- boot_editor->fields[6] = NULL;
+ boot_editor->fields[2] = boot_editor_setup_field(2, 9, bd->dtb);
+ boot_editor->fields[3] = boot_editor_setup_field(3, 9, bd->args);
+ boot_editor->fields[4] = boot_editor_setup_label(0, 1, "image:");
+ boot_editor->fields[5] = boot_editor_setup_label(1, 1, "initrd:");
+ boot_editor->fields[6] = boot_editor_setup_label(2, 1, "dtb:");
+ boot_editor->fields[7] = boot_editor_setup_label(3, 1, "args:");
+ boot_editor->fields[8] = NULL;
boot_editor->ncf = new_form(boot_editor->fields);
pb_log("%s: updating opt '%s'\n", __func__, cod->name);
pb_log(" image '%s'\n", cod->bd->image);
pb_log(" initrd '%s'\n", cod->bd->initrd);
+ pb_log(" dtb '%s'\n", cod->bd->dtb);
pb_log(" args '%s'\n", cod->bd->args);
}
cod->bd->image = talloc_strdup(cod->bd, opt->boot_image_file);
cod->bd->initrd = talloc_strdup(cod->bd, opt->initrd_file);
+ cod->bd->dtb = talloc_strdup(cod->bd, opt->dtb_file);
cod->bd->args = talloc_strdup(cod->bd, opt->boot_args);
pmenu_item_setup(cui->main, i, insert_pt, cod->name);
printf("\t\ticon: %s\n", opt->icon_file);
printf("\t\tboot: %s\n", opt->boot_image_file);
printf("\t\tinit: %s\n", opt->initrd_file);
+ printf("\t\tdtb: %s\n", opt->dtb_file);
printf("\t\targs: %s\n", opt->boot_args);
}
opt->boot_image_file);
opt_data->bd->initrd = talloc_strdup(opt_data->bd,
opt->initrd_file);
+ opt_data->bd->dtb = talloc_strdup(opt_data->bd,
+ opt->dtb_file);
opt_data->bd->args = talloc_strdup(opt_data->bd,
opt->boot_args);
opt_data->opt = opt;