2 * Copyright (C) 2003 by SONE Takeshi <ts1@tsn.or.jp> and others.
3 * This program is licensed under the terms of GNU General Public License.
5 * Modified for LinuxBIOS by Greg Watson <gwatson@lanl.gov>
8 #include <console/console.h>
11 #include <boot/tables.h>
17 #ifndef AUTOBOOT_CMDLINE
21 #ifndef AUTOBOOT_DELAY
22 #define autoboot_delay() 0 /* success */
25 #define havechar() console_tst_byte()
26 #define putchar(c) console_tx_byte(c)
27 #define getchar(c) console_rx_byte(c)
29 extern char *boot_file;
31 int getline(char *buf, int max)
33 int cur, ch, nonspace_seen;
59 case 'W' & 0x1f: /* ^W */
62 if (buf[cur-1] != ' ')
68 if (nonspace_seen && cur < max-1 && cur > 0 && buf[cur-1]==' ')
73 case 'U' & 0x1f: /* ^U */
84 break; /* ignore control char */
88 putchar(ch); /* echo back */
101 static void boot(struct lb_memory *mem, const char *line)
105 /* Split filename and parameter */
106 boot_file = strdup(line);
107 param = strchr(boot_file, ' ');
114 printk_info("Unsupported image format\n");
118 #ifdef AUTOBOOT_CMDLINE
120 static inline int autoboot_delay(void)
122 unsigned int timeout;
128 printk_info("Press <Enter> for default boot, or <Esc> for boot prompt... ");
129 for (sec = AUTOBOOT_DELAY; sec>0 && key==0; sec--) {
130 printk_info("%d", sec);
132 while (timeout-- > 0) {
135 if (key==ENTER || key==ESCAPE)
140 for (tmp = sec; tmp; tmp /= 10)
141 printk_info("\b \b");
144 printk_info("timed out\n");
145 return 0; /* success */
149 return -1; /* canceled */
151 return 0; /* default accepted */
154 #endif /* AUTOBOOT_DELAY */
156 static void autoboot(struct lb_memory *mem)
158 /* If Escape key is pressed already, skip autoboot */
159 if (havechar() && getchar()==ESCAPE)
162 if (autoboot_delay()==0) {
163 printk_info("boot: %s\n", AUTOBOOT_CMDLINE);
164 boot(mem, AUTOBOOT_CMDLINE);
167 #endif /* AUTOBOOT_CMDLINE */
169 /* The main routine */
170 int filo(struct lb_memory *mem)
174 printk_info("FILO version 0.4.1\n");
176 /* Try default image */
179 /* The above didn't work, ask user */
182 #ifdef AUTOBOOT_CMDLINE
183 strncpy(line, AUTOBOOT_CMDLINE, sizeof(line)-1);
184 line[sizeof(line)-1] = '\0';
189 printk_info("boot: ");
190 getline(line, sizeof line);