[coreboot] r66 - in trunk/filo: . drivers fs i386 include main main/grub

svn at coreboot.org svn at coreboot.org
Fri Sep 26 21:20:46 CEST 2008


Author: stepan
Date: 2008-09-26 21:20:46 +0200 (Fri, 26 Sep 2008)
New Revision: 66

Added:
   trunk/filo/drivers/intel.c
Modified:
   trunk/filo/Makefile
   trunk/filo/build.sh
   trunk/filo/drivers/Makefile.inc
   trunk/filo/drivers/ide.c
   trunk/filo/fs/blockdev.c
   trunk/filo/fs/vfs.c
   trunk/filo/i386/linux_load.c
   trunk/filo/include/debug.h
   trunk/filo/main/filo.c
   trunk/filo/main/grub/builtins.c
   trunk/filo/main/grub/char_io.c
   trunk/filo/main/grub/grub.c
   trunk/filo/main/sound.c
Log:
Ok, here's the next bunch of fixes for FILO. It should be safe to use this one
for buildrom, too.

* fix driver output in the menu interface
* menu interface: try to read a list of boot devices from the cmos variable
  "boot_devices". Use with nvramtool -w boot_devices="(hd2,0);(hd1,1);(hd3)"
  filo tries to read /filo.lst, /boot/filo.lst, /menu.lst, /boot/menu.lst.
  If none of the path contains one of these files, or if the variable does not
  exist in CMOS, or if it does not contain valid root devices, FILO will
  continue with the old behavior.
  nvramtool requires another patch to work with strings.
* fix colors in menu interface
* validate root command (#2)
* replace value of root if root command is specified multiple times (#3)
* replace initrd string instead of appending it multiple times
* Fix "configfile" command
* fix behavior of kernel and initrd and configfile commands (check whether file exists
  _before_ the actual boot command
* drop nvram-default and nvram-root commands, they never worked before and the
  boot_devices mechanism is much more flexible and useful
* re-enable serial and terminal commands and fix them to work with the
  tinycurses console.
* add keymap command. Try keymap us or keymap de for now.
* install a reset handler (make CTRL-ALT-DEL work)
* add implementations of poweroff and reboot (poweroff doesn't work :-()
* change build.sh to work with equally named config files in libpayload and
  filo. This makes switching between configurations very convenient.
* fix minor typos

--> push version to 0.6.0 rc1 <--



Modified: trunk/filo/Makefile
===================================================================
--- trunk/filo/Makefile	2008-09-26 18:57:43 UTC (rev 65)
+++ trunk/filo/Makefile	2008-09-26 19:20:46 UTC (rev 66)
@@ -17,7 +17,7 @@
 #
 
 export PROGRAM_NAME := FILO
-export PROGRAM_VERSION := 0.6.0b1
+export PROGRAM_VERSION := 0.6.0rc1
 
 export src := $(shell pwd)
 export srctree := $(src)

Modified: trunk/filo/build.sh
===================================================================
--- trunk/filo/build.sh	2008-09-26 18:57:43 UTC (rev 65)
+++ trunk/filo/build.sh	2008-09-26 19:20:46 UTC (rev 66)
@@ -1,7 +1,9 @@
 #!/bin/sh
 
-#ALLCLEAN=1
+CONFIG=defconfig
 
+ALLCLEAN=1
+
 OS=`uname -s`
 if [ "$OS" == "Darwin" -o "${OS:0:6}" == "CYGWIN" ]; then
     MAKEFLAGS="			\
@@ -21,6 +23,7 @@
 
 if [ "$ALLCLEAN" != "" -o ! -r libpayload/build/lib/libpayload.a ]; then
   cd libpayload
+  cp configs/$CONFIG .config
   make clean
   make oldconfig
   eval make $MAKEFLAGS
@@ -28,6 +31,7 @@
 fi
 
 make distclean
-make defconfig
+cp configs/$CONFIG ./.config
+make oldconfig
 eval make $MAKEFLAGS
 

Modified: trunk/filo/drivers/Makefile.inc
===================================================================
--- trunk/filo/drivers/Makefile.inc	2008-09-26 18:57:43 UTC (rev 65)
+++ trunk/filo/drivers/Makefile.inc	2008-09-26 19:20:46 UTC (rev 66)
@@ -18,4 +18,5 @@
 
 TARGETS-$(CONFIG_IDE_DISK) += drivers/ide.o
 TARGETS-$(CONFIG_VIA_SOUND) += drivers/via-sound.o
+TARGETS-y += drivers/intel.o
 

Modified: trunk/filo/drivers/ide.c
===================================================================
--- trunk/filo/drivers/ide.c	2008-09-26 18:57:43 UTC (rev 65)
+++ trunk/filo/drivers/ide.c	2008-09-26 19:20:46 UTC (rev 66)
@@ -347,9 +347,9 @@
 		if (master_exist) {
 			debug("master found.");
 		}
-		if (slave_exist)
+		if (slave_exist) {
 			printf ("reset failed, but slave may exist\n");
-		else {
+		} else {
 			// return -1;
 			printf("reset failed, but we may be on SATA\n");
 		}
@@ -822,12 +822,13 @@
 		(info->address_mode==ADDRESS_MODE_LBA48) ? "LBA48" :
 		(info->address_mode==ADDRESS_MODE_PACKET) ? "ATAPI" : "???");
 
-	if (info->sectors > (10LL*1000*1000*1000/512))
+	if (info->sectors > (10LL*1000*1000*1000/512)) {
 		printf(" %uGB", (unsigned) (info->sectors / (1000*1000*1000/512)));
-	else if (info->sectors > (10*1000*1000/512))
+	} else if (info->sectors > (10*1000*1000/512)) {
 		printf(" %uMB", (unsigned) (info->sectors / (1000*1000/512)));
-	else if (info->sectors > 0)
+	} else if (info->sectors > 0) {
 		printf(" %uKB", (unsigned) (info->sectors / 2));
+	}
 	printf(": %s\n", info->model_number);
 
 	return 0;

Added: trunk/filo/drivers/intel.c
===================================================================
--- trunk/filo/drivers/intel.c	                        (rev 0)
+++ trunk/filo/drivers/intel.c	2008-09-26 19:20:46 UTC (rev 66)
@@ -0,0 +1,80 @@
+/*
+ * This file is part of FILO.
+ *
+ * Copyright (C) 2008 coresystems GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include <libpayload.h>
+#include <config.h>
+#include <pci.h>
+
+#define DEBUG_THIS CONFIG_DEBUG_INTEL
+#include <debug.h>
+
+/**
+ * Mostly for testing purposes without booting an OS
+ */
+
+void platform_poweroff(void)
+{
+	int pmbase = 0x800;
+
+	/* XXX The sequence is correct; It works fine under Linux. 
+	 * Yet, it does not power off the system in FILO. 
+	 * Some initialization is missing
+	 */
+
+        /* PMBASE + 4, Bit 10-12, Sleeping Type,
+	 * set to 110 -> S5, soft_off */
+
+	outl((6 << 10), pmbase + 0x04);
+	outl((1 << 13) | (6 << 10), pmbase + 0x04);
+
+	for (;;) ;
+}
+
+static inline void kbc_wait(void)
+{
+	int i;
+	for (i = 0; i < 0x10000; i++) {
+		if ((inb(0x64) & 0x02) == 0)
+			break;
+		udelay(2);
+	}
+}
+
+void platform_reboot(void)
+{
+	int i;
+
+	for (i = 0; i < 10; i++) {
+		kbc_wait();
+
+		outb(0x60, 0x64);       /* write Controller Command Byte */
+		udelay(50);
+		kbc_wait();
+
+		outb(0x14, 0x60);       /* set "System flag" */
+		udelay(50);
+		kbc_wait();
+
+		outb(0xfe, 0x64);       /* pulse reset low */
+		udelay(50);
+	}
+	
+	for (;;) ;
+}
+

Modified: trunk/filo/fs/blockdev.c
===================================================================
--- trunk/filo/fs/blockdev.c	2008-09-26 18:57:43 UTC (rev 65)
+++ trunk/filo/fs/blockdev.c	2008-09-26 19:20:46 UTC (rev 66)
@@ -204,7 +204,7 @@
 	}
 
 	if (*name != '\0') {
-		printf("Can't parse device name\n");
+		printf("Can't parse device name.\n");
 		return 0;
 	}
 

Modified: trunk/filo/fs/vfs.c
===================================================================
--- trunk/filo/fs/vfs.c	2008-09-26 18:57:43 UTC (rev 65)
+++ trunk/filo/fs/vfs.c	2008-09-26 19:20:46 UTC (rev 66)
@@ -124,7 +124,7 @@
 			continue;
 
 		fsys = &fsys_table[i];
-		printf("Mounted %s\n", fsys->name);
+		debug("Mounted %s\n", fsys->name);
 		return 1;
 	}
 	fsys = 0;

Modified: trunk/filo/i386/linux_load.c
===================================================================
--- trunk/filo/i386/linux_load.c	2008-09-26 18:57:43 UTC (rev 65)
+++ trunk/filo/i386/linux_load.c	2008-09-26 19:20:46 UTC (rev 66)
@@ -350,9 +350,9 @@
 	 * which I believe is a paramter to the realmode part of Linux,
 	 * which we don't execute. */
 	if (strcmp(name, "initrd") == 0) {
-	    if (!val)
+	    if (!val) {
 		printf("Missing filename to initrd parameter\n");
-	    else {
+	    } else {
 		initrd = malloc(len + 1);
 		memcpy(initrd, val, len);
 		initrd[len] = 0;
@@ -361,9 +361,9 @@
 	    /* Don't pass this to kernel */
 	    to_kern = 0;
 	} else if (strcmp(name, "mem") == 0) {
-	    if (!val)
+	    if (!val) {
 		printf("Missing value for mem parameter\n");
-	    else {
+	    } else {
 		forced_memsize = strtoull_with_suffix(val, (char**)&val, 0);
 		if (forced_memsize == 0)
 		    printf("Invalid mem option, ignored\n");

Modified: trunk/filo/include/debug.h
===================================================================
--- trunk/filo/include/debug.h	2008-09-26 18:57:43 UTC (rev 65)
+++ trunk/filo/include/debug.h	2008-09-26 19:20:46 UTC (rev 66)
@@ -39,4 +39,10 @@
 # define debug_hexdump(...) /* nothing */
 #endif
 
+#ifdef CONFIG_USE_GRUB
+extern int using_grub_interface;
+void grub_printf (const char *format,...);
+#define printf(x...) { if (using_grub_interface) { grub_printf(x); } else { printf(x); } }
+#endif
+
 #endif /* DEBUG_H */

Modified: trunk/filo/main/filo.c
===================================================================
--- trunk/filo/main/filo.c	2008-09-26 18:57:43 UTC (rev 65)
+++ trunk/filo/main/filo.c	2008-09-26 19:20:46 UTC (rev 66)
@@ -23,6 +23,7 @@
 #include <sys_info.h>
 #include <sound.h>
 #include <arch/timer.h>
+#include <debug.h>
 
 PAYLOAD_INFO(name, PROGRAM_NAME " " PROGRAM_VERSION);
 PAYLOAD_INFO(listname, PROGRAM_NAME);
@@ -90,6 +91,19 @@
     free(file);
 }
 
+
+void __attribute__((weak)) platform_reboot(void)
+{
+	grub_printf("Rebooting not supported.\n");
+}
+
+void reset_handler(void)
+{
+	void platform_reboot(void);
+
+	platform_reboot();
+}
+
 #if CONFIG_USE_GRUB
 /* The main routine */
 int main(void)
@@ -99,6 +113,7 @@
     
     /* Initialize */
     init();
+    keyboard_add_reset_handler(reset_handler);
     grub_menulst();
     grub_main();
     return 0;   

Modified: trunk/filo/main/grub/builtins.c
===================================================================
--- trunk/filo/main/grub/builtins.c	2008-09-26 18:57:43 UTC (rev 65)
+++ trunk/filo/main/grub/builtins.c	2008-09-26 19:20:46 UTC (rev 66)
@@ -67,6 +67,10 @@
 char root_device[16] = { 0 };
 /* ---------------------------- */
 
+/* temporary space for run time checks */
+static char temp_space[BOOT_LINE_LENGTH];
+char initrd_space[BOOT_LINE_LENGTH]="\0";
+
 int show_menu = 1;
 
 /* Initialize the data for builtins.  */
@@ -104,7 +108,19 @@
 static int boot_func(char *arg, int flags)
 {
 	void boot(const char *line);
+
+	if(!boot_line[0]) {
+		grub_printf("No kernel.\n");
+		return 1;
+	}
+
 	cls();
+
+	if (initrd_space[0]) {
+		strncat(boot_line, " initrd=", BOOT_LINE_LENGTH);
+		strncat(boot_line, initrd_space, BOOT_LINE_LENGTH);
+	}
+
 	grub_printf("\nBooting '%s'\n", boot_line);
 	boot(boot_line);
 	return 1;
@@ -131,20 +147,20 @@
 	int new_highlight_color;
 	static char *color_list[16] = {
 		"black",
-		"blue",
-		"green",
-		"cyan",
 		"red",
-		"magenta",
+		"green",
 		"brown",
+		"blue",
+		"magenta",
+		"cyan",
 		"light-gray",
 		"dark-gray",
-		"light-blue",
-		"light-green",
-		"light-cyan",
 		"light-red",
-		"light-magenta",
+		"light-green",
 		"yellow",
+		"light-blue",
+		"light-magenta",
+		"light-cyan",
 		"white"
 	};
 
@@ -175,7 +191,7 @@
 		/* Search for the color name.  */
 		for (i = 0; i < 16; i++)
 			if (strcmp(color_list[i], str) == 0) {
-				color |= i;
+				color |= (i << 4);
 				break;
 			}
 
@@ -188,7 +204,7 @@
 		/* Search for the color name.  */
 		for (i = 0; i < 8; i++)
 			if (strcmp(color_list[i], str) == 0) {
-				color |= i << 4;
+				color |= i;
 				break;
 			}
 
@@ -237,17 +253,16 @@
 	    " \"blink-\" to FG if you want a blinking foreground color."
 };
 
-static char temp_config_file[128];
 /* configfile */
 static int configfile_func(char *arg, int flags)
 {
 	extern int is_opened, keep_cmdline_running;
 
 	/* Check if the file ARG is present.  */
-	memset(temp_config_file, 0, 128);
-	copy_path_to_filo_bootline(arg, temp_config_file, 1);
-	if (!file_open(temp_config_file)) {
-		grub_printf("Could not open '%s'.\n", temp_config_file);
+	temp_space[0]=0;
+	copy_path_to_filo_bootline(arg, temp_space, 1);
+	if (!file_open(temp_space)) {
+		errnum = ERR_FILE_NOT_FOUND;
 		return 1;
 	}
 
@@ -295,51 +310,6 @@
 #endif
 };
 
-/* nvram-default */
-static int nvram_default_func(char *arg, int flags)
-{
-	u8 boot_default;
-
-	if (get_option(&boot_default, "boot_default"))
-		return 1;
-
-	default_entry = boot_default;
-
-	return 0;
-}
-
-static struct builtin builtin_nvram_default = {
-	"nvram-default",
-	nvram_default_func,
-	BUILTIN_MENU,
-#if 0
-	"nvram-default",
-	"Set the default entry to entry number NUM read from nvram."
-#endif
-};
-
-/* nvram-root */
-static int nvram_root_func(char *arg, int flags)
-{
-	char new_root[16]; /* Assume 128 bits in cmos.layout */
-
-	if (get_option(new_root, "boot_device"))
-		return 1;
-
-	memset(root_device, 0, 16);
-	copy_path_to_filo_bootline(new_root, root_device, 0);
-
-	return 0;
-}
-
-static struct builtin builtin_nvram_root = {
-	"nvram-root",
-	nvram_root_func,
-	BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
-	"nvram-root",
-	"Set the root device according to the NVRAM entry boot_device"
-};
-
 #if CONFIG_EXPERIMENTAL
 #warning "FIND not implemented yet."
 /* find */
@@ -614,9 +584,16 @@
 /* initrd */
 static int initrd_func(char *arg, int flags)
 {
-	strncat(boot_line, " initrd=", BOOT_LINE_LENGTH);
-	copy_path_to_filo_bootline(arg, boot_line, 1);
+	initrd_space[0]=0; // Erase string
+	copy_path_to_filo_bootline(arg, initrd_space, 1);
+	if (!file_open(initrd_space)) {
+		initrd_space[0]=0; // Erase string
+		errnum = ERR_FILE_NOT_FOUND;
+		file_close();
+		return 1;
+	}
 
+	file_close();
 	return 0;
 }
 
@@ -635,12 +612,30 @@
 /* kernel */
 static int kernel_func(char *arg, int flags)
 {
-	/* Needed to pass grub checks */
-	kernel_type = KERNEL_TYPE_LINUX;
+	int i;
 
+	kernel_type = KERNEL_TYPE_NONE;
+
 	/* clear out boot_line. Kernel is the first thing */
-	memset(boot_line, 0, BOOT_LINE_LENGTH);
+	boot_line[0] = 0;  // Erase string
 
+	/* Get the real boot line and extract the kernel name */
+	temp_space[0] = 0; // Erase string
+	copy_path_to_filo_bootline(arg, temp_space, 1);
+	i=0; while ((temp_space[i] != 0) && (temp_space[i]!=' ')) i++;
+	temp_space[i] = 0;
+
+	if (!file_open(temp_space)) {
+		errnum = ERR_FILE_NOT_FOUND;
+		file_close();
+		return 1;
+	}
+
+	file_close();
+
+	/* Needed to pass grub checks */
+	kernel_type = KERNEL_TYPE_LINUX;
+
 	copy_path_to_filo_bootline(arg, boot_line, 1);
 
 	return 0;
@@ -814,17 +809,16 @@
 	"Print MESSAGE, then wait until a key is pressed."
 };
 
-static int poweroff_func(char *arg, int flags)
+void __attribute__((weak)) platform_poweroff(void)
 {
-	void platform_poweroff(void);
+	grub_printf("Poweroff not supported.\n");
+}
 
-#ifdef PLATFORM_SUPPORT
+static int poweroff_func(char *arg, int flags)
+{
 	platform_poweroff();
-#else
-	grub_printf("Poweroff not supported.\n");
-#endif
 
-	// Will never return;
+	// Will (hopefully) never return;
 	return 0;
 }
 
@@ -840,13 +834,9 @@
 {
 	void platform_reboot(void);
 
-#ifdef PLATFORM_SUPPORT
 	platform_reboot();
-#else
-	grub_printf("Rebooting not supported.\n");
-#endif
 
-	// Will never return;
+	// Will (hopefully) never return;
 	return 0;
 }
 
@@ -860,9 +850,21 @@
 
 static int root_func(char *arg, int flags)
 {
-	memset(root_device, 0, 16);
+	int len;
+
+	root_device[0] = 0; /* Clear root device */
 	copy_path_to_filo_bootline(arg, root_device, 0);
 
+	/* The following code handles an extra case
+	 * where the user specifies "root hde1" without
+	 * a trailing colon.
+	 */
+	len=strlen(root_device);
+	if(root_device[len - 1] != ':') {
+		root_device[len] = ':';
+		root_device[len + 1] = 0;
+	}
+
 	return 0;
 }
 
@@ -874,15 +876,20 @@
 	"Set the current \"root device\" to the device DEVICE."
 };
 
+void __attribute__((weak))  serial_hardware_init(int port, int speed, int word_bits, int parity, int stop_bits)
+{
+	grub_printf("This version of FILO does not have serial console support.\n");
+}
+
 /* serial */
 static int serial_func(char *arg, int flags)
 {
-#if 0
-	unsigned short port = serial_hw_get_port(0);
+	unsigned short serial_port[] = {0x3f8, 0x2f8, 0x3e8, 0x2e8 };
+	unsigned short port = 0x3f8;
 	unsigned int speed = 9600;
-	int word_len = UART_8BITS_WORD;
-	int parity = UART_NO_PARITY;
-	int stop_bit_len = UART_1_STOP_BIT;
+	int word_len = 8;
+	int parity = 0;
+	int stop_bit_len = 1;
 
 	/* Process GNU-style long options.
 	   FIXME: We should implement a getopt-like function, to avoid
@@ -900,7 +907,7 @@
 				return 1;
 			}
 
-			port = serial_hw_get_port(unit);
+			port = serial_port[unit];
 		} else if (memcmp(arg, "--speed=", sizeof("--speed=") - 1) == 0) {
 			char *p = arg + sizeof("--speed=") - 1;
 			int num;
@@ -927,18 +934,9 @@
 				return 1;
 
 			switch (len) {
-			case 5:
-				word_len = UART_5BITS_WORD;
+			case 5 ... 8:
+				word_len = len;
 				break;
-			case 6:
-				word_len = UART_6BITS_WORD;
-				break;
-			case 7:
-				word_len = UART_7BITS_WORD;
-				break;
-			case 8:
-				word_len = UART_8BITS_WORD;
-				break;
 			default:
 				errnum = ERR_BAD_ARGUMENT;
 				return 1;
@@ -952,12 +950,9 @@
 				return 1;
 
 			switch (len) {
-			case 1:
-				stop_bit_len = UART_1_STOP_BIT;
+			case 1 ... 2:
+				stop_bit_len = len;
 				break;
-			case 2:
-				stop_bit_len = UART_2_STOP_BITS;
-				break;
 			default:
 				errnum = ERR_BAD_ARGUMENT;
 				return 1;
@@ -966,13 +961,13 @@
 			char *p = arg + sizeof("--parity=") - 1;
 
 			if (memcmp(p, "no", sizeof("no") - 1) == 0)
-				parity = UART_NO_PARITY;
+				parity = 0;
 			else if (memcmp(p, "odd", sizeof("odd") - 1)
 				 == 0)
-				parity = UART_ODD_PARITY;
+				parity = 1;
 			else if (memcmp(p, "even", sizeof("even") - 1)
 				 == 0)
-				parity = UART_EVEN_PARITY;
+				parity = 2;
 			else {
 				errnum = ERR_BAD_ARGUMENT;
 				return 1;
@@ -984,11 +979,8 @@
 	}
 
 	/* Initialize the serial unit.  */
-	if (!serial_hw_init(port, speed, word_len, parity, stop_bit_len)) {
-		errnum = ERR_BAD_ARGUMENT;
-		return 1;
-	}
-#endif
+	serial_hardware_init(port, speed, word_len, parity, stop_bit_len);
+
 	return 0;
 }
 
@@ -1011,29 +1003,19 @@
 /* terminal */
 static int terminal_func(char *arg, int flags)
 {
-#if 0
+	int use_serial = 0, use_vga = 0;
+	int terminal_changed = 0;
 	/* The index of the default terminal in TERM_TABLE.  */
-	int default_term = -1;
-	struct term_entry *prev_term = current_term;
-	int to = -1;
 	int lines = 0;
-	int no_message = 0;
 	unsigned long term_flags = 0;
-	/* XXX: Assume less than 32 terminals.  */
-	unsigned long term_bitmap = 0;
 
 	/* Get GNU-style long options.  */
 	while (1) {
-		if (memcmp(arg, "--no-echo", sizeof("--no-echo") - 1) == 0)
+		if (memcmp(arg, "--no-echo", sizeof("--no-echo") - 1) == 0) {
 			/* ``--no-echo'' implies ``--no-edit''.  */
 			term_flags |= (TERM_NO_ECHO | TERM_NO_EDIT);
-		else if (memcmp(arg, "--no-edit", sizeof("--no-edit") - 1) == 0)
+		} else if (memcmp(arg, "--no-edit", sizeof("--no-edit") - 1) == 0) {
 			term_flags |= TERM_NO_EDIT;
-		else if (memcmp(arg, "--timeout=", sizeof("--timeout=") - 1) == 0) {
-			char *val = arg + sizeof("--timeout=") - 1;
-
-			if (!safe_parse_maxint(&val, &to))
-				return 1;
 		} else if (memcmp(arg, "--lines=", sizeof("--lines=") - 1) == 0) {
 			char *val = arg + sizeof("--lines=") - 1;
 
@@ -1045,26 +1027,25 @@
 				errnum = ERR_BAD_ARGUMENT;
 				return 1;
 			}
-		} else if (memcmp(arg, "--silent", sizeof("--silent") - 1) == 0)
-			no_message = 1;
-		else {
+		} else {
 			while (*arg) {
-				int i;
 				char *next = skip_to(0, arg);
 
 				nul_terminate(arg);
 
-				for (i = 0; term_table[i].name; i++) {
-					if (strcmp(arg, term_table[i].name) == 0) {
-						if (default_term < 0)
-							default_term = i;
-
-						term_bitmap |= (1 << i);
-						break;
-					}
-				}
-
-				if (!term_table[i].name) {
+				/* We also accept "terminal console" as GRUB
+				 * heritage.
+				 */
+				if (strcmp(arg, "serial") == 0) {
+					use_serial = 1;
+					terminal_changed = 1;
+				} else if (strcmp(arg, "console") == 0) {
+					use_vga = 1;
+					terminal_changed = 1;
+				} else if (strcmp(arg, "vga") == 0) {
+					use_vga = 1;
+					terminal_changed = 1;
+				} else {
 					errnum = ERR_BAD_ARGUMENT;
 					return 1;
 				}
@@ -1080,78 +1061,29 @@
 		arg = skip_to(0, arg);
 	}
 
-	/* If no argument is specified, show current setting.  */
-	// if (! *arg)
-	if (!term_bitmap) {
-		grub_printf("%s%s%s\n",
-			    current_term->name,
-			    current_term->
-			    current_term->
-			    flags & TERM_NO_EDIT ? " (no edit)" : "",
-			    terminal_flags & TERM_NO_ECHO ? " (no echo)" : "");
-		return 0;
+	if (terminal_changed) {
+		curses_enable_serial(use_serial);
+		curses_enable_vga(use_vga);
+		terminal_flags = term_flags;
 	}
 
-	/* If multiple terminals are specified, wait until the user pushes any key on one of the terminals.  */
-	if (term_bitmap & ~(1 << default_term)) {
-		int time1, time2 = -1;
-
-		/* XXX: Disable the pager.  */
-		count_lines = -1;
-
-		/* Get current time.  */
-		while ((time1 = getrtsecs()) == 0xFF);
-
-		/* Wait for a key input.  */
-		while (to) {
-			int i;
-
-			for (i = 0; term_table[i].name; i++) {
-				if (term_bitmap & (1 << i)) {
-					if (term_table[i].checkkey() >= 0) {
-						(void) term_table[i].getkey();
-						default_term = i;
-
-						goto end;
-					}
-				}
-			}
-
-			/* Prompt the user, once per sec.  */
-			if ((time1 = getrtsecs()) != time2 && time1 != 0xFF) {
-				if (!no_message) {
-					/* Need to set CURRENT_TERM to each of selected terminals.  */
-					for (i = 0; term_table[i].name; i++)
-						if (term_bitmap & (1 << i)) {
-							current_term = term_table + i;
-							grub_printf("\rPress any key to continue.\n");
-						}
-
-					/* Restore CURRENT_TERM.  */
-					current_term = prev_term;
-				}
-
-				time2 = time1;
-				if (to > 0)
-					to--;
-			}
-		}
-	}
-
-      end:
-	current_term = term_table + default_term;
-	terminal_flags = term_flags;
-
 	if (lines)
 		max_lines = lines;
 	else
-		/* 24 would be a good default value.  */
-		max_lines = 24;
+		/* 25 would be a good default value.  */
+		max_lines = 25;
 
-	/* If the interface is currently the command-line, restart it to repaint the screen. */
-	//if (current_term != prev_term && (flags & BUILTIN_CMDLINE))
-	//  grub_longjmp (restart_cmdline_env, 0);
-#endif
+	/* If no argument is specified, show current setting.  */
+	if (! *arg) {
+		grub_printf("Serial console terminal %s.\n",
+				curses_serial_enabled()?"enabled":"disabled");
+		grub_printf("VGA console terminal %s.\n",
+				curses_vga_enabled()?"enabled":"disabled");
+		grub_printf("Flags:%s%s\n",
+			    terminal_flags & TERM_NO_EDIT ? " (no edit)" : "",
+			    terminal_flags & TERM_NO_ECHO ? " (no echo)" : "");
+	}
+
 	return 0;
 }
 
@@ -1159,17 +1091,15 @@
 	"terminal",
 	terminal_func,
 	BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST | BUILTIN_NO_ECHO,
-	"terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial]",
+	"terminal [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial]",
 	"Select a terminal. When multiple terminals are specified, wait until"
 	    " you push any key to continue. If both console and serial are specified,"
 	    " the terminal to which you input a key first will be selected. If no"
-	    " argument is specified, print current setting. The option --dumb"
-	    " specifies that your terminal is dumb, otherwise, vt100-compatibility"
-	    " is assumed. If you specify --no-echo, input characters won't be echoed."
+	    " argument is specified, print current setting. If you specify --no-echo,"
+	    " input characters won't be echoed."
 	    " If you specify --no-edit, the BASH-like editing feature will be disabled."
 	    " If --timeout is present, this command will wait at most for SECS"
 	    " seconds. The option --lines specifies the maximum number of lines."
-	    " The option --silent is used to suppress messages."
 };
 
 /* timeout */
@@ -1193,7 +1123,23 @@
 };
 
 
+static int keymap_func(char *arg, int flags)
+{
+	if (keyboard_set_layout(arg)) {
+		errnum = ERR_BAD_ARGUMENT;
+		return 1;
+	}
+	return 0;
+}
 
+static struct builtin builtin_keymap = {
+	"keymap",
+	keymap_func,
+	BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST | BUILTIN_NO_ECHO,
+	"keymap LANGCODE",
+	"Select a keymap to use. Currently only 'en' and 'de' are supported."
+};
+
 static int title_func(char *arg, int flags)
 {
 	/* This function is not actually used at least currently.  */
@@ -1226,12 +1172,11 @@
 	&builtin_hiddenmenu,
 	&builtin_initrd,
 	&builtin_kernel,
+	&builtin_keymap,
 	&builtin_lock,
 #ifdef CONFIG_USE_MD5_PASSWORDS
 	&builtin_md5crypt,
 #endif
-	&builtin_nvram_default,
-	&builtin_nvram_root,
 	&builtin_password,
 	&builtin_pause,
 	&builtin_poweroff,

Modified: trunk/filo/main/grub/char_io.c
===================================================================
--- trunk/filo/main/grub/char_io.c	2008-09-26 18:57:43 UTC (rev 65)
+++ trunk/filo/main/grub/char_io.c	2008-09-26 19:20:46 UTC (rev 66)
@@ -737,38 +737,21 @@
 
 int terminal_flags;
 
-static int console_current_color = A_NORMAL;
-static int console_standard_color = A_NORMAL;
-static int console_normal_color = A_NORMAL;
-static int console_highlight_color = A_REVERSE;
 static color_state console_color_state = COLOR_STATE_STANDARD;
 
 void console_setcolorstate(color_state state)
 {
-	switch (state) {
-	case COLOR_STATE_STANDARD:
-		console_current_color = console_standard_color;
-		break;
-	case COLOR_STATE_NORMAL:
-		console_current_color = console_normal_color;
-		break;
-	case COLOR_STATE_HIGHLIGHT:
-		console_current_color = console_highlight_color;
-		break;
-	default:
-		console_current_color = console_standard_color;
-		break;
-	}
-
 	console_color_state = state;
 }
 
 void console_setcolor(int normal_color, int highlight_color)
 {
-	console_normal_color = normal_color;
-	console_highlight_color = highlight_color;
+	init_pair(1,(normal_color >> 4) &0xf, normal_color & 0xf);
+	init_pair(2,(highlight_color >> 4) &0xf, highlight_color & 0xf);
 
-	console_setcolorstate(console_color_state);
+	/* Make curses update the whole screen */
+	redrawwin(stdscr);
+	refresh();
 }
 
 /* The store for ungetch simulation. This is necessary, because
@@ -954,7 +937,11 @@
 		if (x + 1 == COLS) {
 			console_putchar('\n');
 		}
-		addch(c | console_current_color);
+		if (console_color_state == COLOR_STATE_HIGHLIGHT)
+			color_set(2, NULL);
+		else
+			color_set(1, NULL);
+		addch(c);
 	} else {
 		addch(c);
 	}

Modified: trunk/filo/main/grub/grub.c
===================================================================
--- trunk/filo/main/grub/grub.c	2008-09-26 18:57:43 UTC (rev 65)
+++ trunk/filo/main/grub/grub.c	2008-09-26 19:20:46 UTC (rev 66)
@@ -39,6 +39,8 @@
 char MENU_BUF[MENU_BUFLEN]; /* The buffer for the menu entries.  */
 static char configs[16384];
 
+int using_grub_interface = 0;
+
 #define ENTER '\r'
 #define ESCAPE '\x1b'
 
@@ -89,7 +91,7 @@
 }
 #endif				/* CONFIG_MENULST_TIMEOUT */
 
-void grub_menulst(void)
+void manual_grub_menulst(void)
 {
 	char line[256];
 
@@ -130,6 +132,53 @@
 
 }
 
+int probe_menulst(char *bootdevice, char *filename)
+{
+	char menulst[256];
+
+	strcpy(menulst, bootdevice);
+	strncat(menulst, filename, 256);
+	copy_path_to_filo_bootline(menulst, config_file, 0);
+	if (file_open(config_file)) {
+		/* We found a config file. Bail out */
+		/* The valid config file name stays in config_file[] */
+		file_close();
+		return 1;
+	}
+
+	return 0;
+}
+
+void grub_menulst(void)
+{
+	char bootdevices[256];
+	char *running = bootdevices;
+	char *bootdevice;
+
+	if (get_option(bootdevices, "boot_devices"))
+		goto old;
+
+	printf("boot_devices = '%s'\n", bootdevices);
+
+	do {
+		bootdevice = strsep(&running, ";");
+		if (bootdevice && *bootdevice) {
+			if (probe_menulst(bootdevice, "/filo.lst"))
+				return;
+			if (probe_menulst(bootdevice, "/boot/filo.lst"))
+				return;
+			if (probe_menulst(bootdevice, "/menu.lst"))
+				return;
+			if (probe_menulst(bootdevice, "/boot/menu.lst"))
+				return;
+		}
+	} while (bootdevice);
+
+old:
+	manual_grub_menulst();
+
+}
+
 /* Define if there is user specified preset menu string */
 /* #undef PRESET_MENU_STRING */
 
@@ -850,7 +899,11 @@
 	keypad(stdscr, TRUE);
 	wtimeout(stdscr, 100);
 	endwin();
+	using_grub_interface = 1;
 
+	console_setcolor((COLOR_WHITE << 4) | COLOR_BLACK, 
+			 (COLOR_BLACK << 4) | COLOR_WHITE);
+
 	/* Initialize the kill buffer.  */
 	*kill_buf = 0;
 

Modified: trunk/filo/main/sound.c
===================================================================
--- trunk/filo/main/sound.c	2008-09-26 18:57:43 UTC (rev 65)
+++ trunk/filo/main/sound.c	2008-09-26 19:20:46 UTC (rev 66)
@@ -18,6 +18,7 @@
 #include <drivers.h>
 #include <sound.h>
 #include <pci.h>
+#include <debug.h>
 
 static const struct sound_ops *ops;
 





More information about the coreboot mailing list