This patch adds a fallback command line in case the autoboot
command line fails.  This could be used on an AMD Geode board to
try booting a kernel off IDE, before falling back to NAND flash.

Signed-off-by: Nathan Williams <[email protected]>

Index: main/filo.c
===================================================================
--- main/filo.c (revision 143)
+++ main/filo.c (working copy)
@@ -37,11 +37,11 @@
 #define ESCAPE '\x1b'
 
 #if !defined(CONFIG_AUTOBOOT_FILE)
-#define autoboot() ((void) 0) /* nop */
+#define autoboot() ((int) 0) /* nop */
 #endif
 
 #ifndef CONFIG_AUTOBOOT_DELAY
-#define autoboot_delay() 0 /* success */
+#define autoboot_delay(boot_type) 0 /* success */
 #endif
 
 struct sys_info sys_info;
@@ -156,7 +156,7 @@
 
 #ifdef CONFIG_AUTOBOOT_FILE
 #ifdef CONFIG_AUTOBOOT_DELAY
-static inline int autoboot_delay(void)
+static inline int autoboot_delay(const char *boot_type)
 {
     u64 timeout;
     int sec, tmp;
@@ -164,7 +164,7 @@
     
     key = 0;
 
-    printf("Press <Enter> for default boot, or <Esc> for boot prompt... ");
+    printf("Press <Enter> for %s boot, or <Esc> for boot prompt... ", 
boot_type);
     for (sec = CONFIG_AUTOBOOT_DELAY; sec>0 && key==0; sec--) {
        printf("%d", sec);
        timeout = currticks() + TICKS_PER_SEC;
@@ -191,17 +191,33 @@
 }
 #endif /* CONFIG_AUTOBOOT_DELAY */
 
-static void autoboot(void)
+static int autoboot(void)
 {
     /* If Escape key is pressed already, skip autoboot */
     if (havechar() && getchar()==ESCAPE)
-       return;
+       return 0;
 
-    if (autoboot_delay()==0) {
+    if (autoboot_delay("default")==0) {
        printf("boot: %s\n", CONFIG_AUTOBOOT_FILE);
        boot(CONFIG_AUTOBOOT_FILE);
+       return 1;
     }
+       return 0;
 }
+
+#ifdef CONFIG_FALLBACKBOOT_FILE
+static void fallbackboot(void)
+{
+    /* If Escape key is pressed already, skip autoboot */
+    if (havechar() && getchar()==ESCAPE)
+       return;
+
+    if (autoboot_delay("fallback")==0) {
+       printf("boot: %s\n", CONFIG_FALLBACKBOOT_FILE);
+       boot(CONFIG_FALLBACKBOOT_FILE);
+    }
+}
+#endif /* FALLBACKBOOT_FILE */
 #endif /* AUTOBOOT_FILE */
 
 /* The main routine */
@@ -213,17 +229,30 @@
     init();
     
     /* Try default image */
-    autoboot();
+    if (autoboot()) {
+       /* Default boot has failed */
+#ifdef CONFIG_AUTOBOOT_FILE
+#ifdef CONFIG_FALLBACKBOOT_FILE
+       fallbackboot();
+       strncpy(line, CONFIG_FALLBACKBOOT_FILE, sizeof(line)-1);
+#else
+       strncpy(line, CONFIG_AUTOBOOT_FILE, sizeof(line)-1);
+#endif
+#endif
+       line[sizeof(line)-1] = '\0';
+    } else {
+    /* Either CONFIG_AUTOBOOT_FILE not defined, or delay escaped by user */
+#ifdef CONFIG_AUTOBOOT_FILE
+           strncpy(line, CONFIG_AUTOBOOT_FILE, sizeof(line)-1);
+           line[sizeof(line)-1] = '\0';
+#else
+           line[0] = '\0';
+#endif
+    }
 
     /* The above didn't work, ask user */
     while (havechar())
        getchar();
-#ifdef CONFIG_AUTOBOOT_FILE
-    strncpy(line, CONFIG_AUTOBOOT_FILE, sizeof(line)-1);
-    line[sizeof(line)-1] = '\0';
-#else
-    line[0] = '\0';
-#endif
     for (;;) {
        printf("boot: ");
        getline(line, sizeof line);
Index: Config.in
===================================================================
--- Config.in   (revision 143)
+++ Config.in   (working copy)
@@ -75,6 +75,23 @@
        help
          Time in second before booting AUTOBOOT_FILE
 
+config USE_FALLBACKBOOT
+       bool "Use a fallback command line"
+       default n
+       depends on USE_AUTOBOOT
+       help
+         If autoboot fails, try a fallback command line.
+
+config FALLBACKBOOT_FILE
+       string "Fallback kernel filename and parameters"
+       default ""
+       depends on USE_FALLBACKBOOT
+       help
+         #FALLBACKBOOT_FILE = "mem@0xfff80000"
+         #FALLBACKBOOT_FILE = "hde1@0"
+         #FALLBACKBOOT_FILE = "uda1:/vmlinuz.elf"
+         #FALLBACKBOOT_FILE = "flashb@0x00400000,0x154a00 console=tty0 
console=ttyS0,115200"
+
 config ISOLINUX_PARSER
        bool "Support for parsing isolinux.cfg config files"
        default n



-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to