]> xenbits.xensource.com Git - seabios.git/commitdiff
Automatically reboot after 60 second delay on failed boot.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 13 May 2012 02:12:22 +0000 (22:12 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 14 May 2012 03:13:45 +0000 (23:13 -0400)
If no valid boot devices are found, display the error for 60 seconds
(by default) and then reboot.  This enables a periodic retry in case
one of the boot devices is still coming online.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/boot.c

index 8cc94b0e005955c855397908e869a5f64b102633..4447b9a39d0cf32b728357e6bfd981c1d0170d50 100644 (file)
@@ -617,6 +617,29 @@ boot_rom(u32 vector)
     call_boot_entry(so, 0);
 }
 
+// Unable to find bootable device - warn user and eventually retry.
+static void
+boot_fail(void)
+{
+    u32 retrytime = romfile_loadint("etc/boot-fail-wait", 60*1000);
+    if (retrytime == (u32)-1)
+        printf("No bootable device.\n");
+    else
+        printf("No bootable device.  Retrying in %d seconds.\n", retrytime/1000);
+    // Wait for 'retrytime' milliseconds and then reboot.
+    u32 end = calc_future_timer(retrytime);
+    for (;;) {
+        if (retrytime != (u32)-1 && check_timer(end))
+            break;
+        wait_irq();
+    }
+    printf("Rebooting.\n");
+    struct bregs br;
+    memset(&br, 0, sizeof(br));
+    br.code = SEGOFF(SEG_BIOS, (u32)reset_vector);
+    call16big(&br);
+}
+
 // Determine next boot method and attempt a boot using it.
 static void
 do_boot(u16 seq_nr)
@@ -624,12 +647,8 @@ do_boot(u16 seq_nr)
     if (! CONFIG_BOOT)
         panic("Boot support not compiled in.\n");
 
-    if (seq_nr >= BEVCount) {
-        printf("No bootable device.\n");
-        // Loop with irqs enabled - this allows ctrl+alt+delete to work.
-        for (;;)
-            wait_irq();
-    }
+    if (seq_nr >= BEVCount)
+        boot_fail();
 
     // Boot the given BEV type.
     struct bev_s *ie = &BEV[seq_nr];