summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/boot.c37
-rw-r--r--include/blspec.h10
2 files changed, 41 insertions, 6 deletions
diff --git a/commands/boot.c b/commands/boot.c
index a54d0d51ec..4a839790d1 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -243,7 +243,7 @@ static struct blspec *bootentries_collect(char *entries[], int num_entries)
static void bootsources_menu(char *entries[], int num_entries)
{
struct blspec *blspec = NULL;
- struct blspec_entry *entry;
+ struct blspec_entry *entry, *entry_default;
struct menu_entry *back_entry;
if (!IS_ENABLED(CONFIG_MENU)) {
@@ -252,10 +252,16 @@ static void bootsources_menu(char *entries[], int num_entries)
}
blspec = bootentries_collect(entries, num_entries);
+ if (blspec)
+ return;
+
+ entry_default = blspec_entry_default(blspec);
blspec_for_each_entry(blspec, entry) {
entry->me.action = bootsource_action;
menu_add_entry(blspec->menu, &entry->me);
+ if (entry == entry_default)
+ menu_set_selected_entry(blspec->menu, &entry->me);
}
back_entry = xzalloc(sizeof(*back_entry));
@@ -280,14 +286,23 @@ static void bootsources_menu(char *entries[], int num_entries)
static void bootsources_list(char *entries[], int num_entries)
{
struct blspec *blspec;
- struct blspec_entry *entry;
+ struct blspec_entry *entry, *entry_default;
blspec = bootentries_collect(entries, num_entries);
+ if (!blspec)
+ return;
- printf("%-20s %-20s %s\n", "device", "hwdevice", "title");
- printf("%-20s %-20s %s\n", "------", "--------", "-----");
+ entry_default = blspec_entry_default(blspec);
+
+ printf(" %-20s %-20s %s\n", "device", "hwdevice", "title");
+ printf(" %-20s %-20s %s\n", "------", "--------", "-----");
blspec_for_each_entry(blspec, entry) {
+ if (entry == entry_default)
+ printf("* ");
+ else
+ printf(" ");
+
if (entry->scriptpath)
printf("%-40s %s\n", basename(entry->scriptpath), entry->me.display);
else
@@ -312,7 +327,7 @@ static void bootsources_list(char *entries[], int num_entries)
static int boot(const char *name)
{
struct blspec *blspec;
- struct blspec_entry *entry;
+ struct blspec_entry *entry, *entry_default;
int ret;
blspec = blspec_alloc();
@@ -325,7 +340,19 @@ static int boot(const char *name)
return -ENOENT;
}
+ entry_default = blspec_entry_default(blspec);
+ if (entry_default) {
+ ret = boot_entry(entry_default);
+ if (!ret)
+ return ret;
+ printf("booting %s failed: %s\n", entry_default->me.display,
+ strerror(-ret));
+ }
+
blspec_for_each_entry(blspec, entry) {
+ if (entry == entry_default)
+ continue;
+
printf("booting %s\n", entry->me.display);
ret = boot_entry(entry);
if (!ret)
diff --git a/include/blspec.h b/include/blspec.h
index 66d2e8485d..afac5ed7ba 100644
--- a/include/blspec.h
+++ b/include/blspec.h
@@ -35,7 +35,6 @@ int blspec_boot_devicename(const char *devname, int verbose, int dryrun);
int blspec_scan_devices(struct blspec *blspec);
-struct blspec_entry *blspec_entry_default(struct blspec *l);
int blspec_scan_devicename(struct blspec *blspec, const char *devname);
int blspec_scan_directory(struct blspec *blspec, const char *root);
@@ -91,4 +90,13 @@ static inline void blspec_free(struct blspec *blspec)
free(blspec);
}
+#ifdef CONFIG_BLSPEC
+struct blspec_entry *blspec_entry_default(struct blspec *l);
+#else
+static inline struct blspec_entry *blspec_entry_default(struct blspec *l)
+{
+ return NULL;
+}
+#endif
+
#endif /* __LOADER_H__ */