This patch creates a config option which allows you to see libpayload output
without escape sequences.  It's useful for getting readable output from an
emulator whose serial port is redirected to a file.

Signed-off-by: Myles Watson <[EMAIL PROTECTED]>

A related note: coreinfo's make menuconfig doesn't work for me.  It can't
find its include files:
 make menuconfig
  CC      build/util/kconfig/lxdialog/checklist.o
In file included from
/home/myles/buildrom/buildrom-devel/work/libpayload/svn/util/kconfig/lxdialog/checklist.c:24:
/home/myles/buildrom/buildrom-devel/work/libpayload/svn/util/kconfig/lxdialog/dialog.h:21:23:
error: sys/types.h: No such file or directory
/home/myles/buildrom/buildrom-devel/work/libpayload/svn/util/kconfig/lxdialog/dialog.h:22:19:
error: fcntl.h: No such file or directory
/home/myles/buildrom/buildrom-devel/work/libpayload/svn/util/kconfig/lxdialog/dialog.h:23:20:
error: unistd.h: No such file or directory
/home/myles/buildrom/buildrom-devel/work/libpayload/svn/util/kconfig/lxdialog/dialog.h:24:19:
error: ctype.h: No such file or directory

Thanks,
Myles
Index: curses/tinycurses.c
===================================================================
--- curses/tinycurses.c	(revision 3646)
+++ curses/tinycurses.c	(working copy)
@@ -201,9 +201,11 @@
 int curs_set(int on)
 {
 #ifdef CONFIG_SERIAL_CONSOLE
+#ifndef CONFIG_SERIAL_LOG_FILE
 	if (curses_flags & F_ENABLE_SERIAL) {
 		serial_cursor_enable(on);
 	}
+#endif //SERIAL_LOG_FILE
 #endif
 #ifdef CONFIG_VIDEO_CONSOLE
 	if (curses_flags & F_ENABLE_CONSOLE) {
@@ -308,9 +310,11 @@
 	for (i = 0; i < 128; i++)
 	  acs_map[i] = (chtype) i | A_ALTCHARSET;
 #ifdef CONFIG_SERIAL_CONSOLE
+#ifndef CONFIG_SERIAL_LOG_FILE
 	if (curses_flags & F_ENABLE_SERIAL) {
 		serial_clear();
 	}
+#endif //SERIAL_LOG_FILE
 #endif
 #ifdef CONFIG_VIDEO_CONSOLE
 	if (curses_flags & F_ENABLE_CONSOLE) {
@@ -703,6 +707,7 @@
 int wnoutrefresh(WINDOW *win)
 {
 #ifdef CONFIG_SERIAL_CONSOLE
+#ifndef CONFIG_SERIAL_LOG_FILE
 	// FIXME.
 	int serial_is_bold = 0;
 	int serial_is_reverse = 0;
@@ -711,13 +716,16 @@
 
 	int need_altcharset;
 	short fg, bg;
+#endif //SERIAL_LOG_FILE
 #endif
 	int x, y;
 	chtype ch;
 
 #ifdef CONFIG_SERIAL_CONSOLE
+#ifndef CONFIG_SERIAL_LOG_FILE
 	serial_end_bold();
 	serial_end_altcharset();
+#endif //SERIAL_LOG_FILE
 #endif
 
 	for (y = 0; y <= win->_maxy; y++) {
@@ -729,8 +737,21 @@
 
 #ifdef CONFIG_SERIAL_CONSOLE
 		if (curses_flags & F_ENABLE_SERIAL)
+#ifndef CONFIG_SERIAL_LOG_FILE
 			serial_set_cursor(win->_begy + y, win->_begx +
 					win->_line[y].firstchar);
+#else
+		{
+			serial_putchar('\r');
+			serial_putchar('\n');
+			serial_putchar('0'+(win->_begx + win->_line[y].firstchar)/10);
+			serial_putchar('0'+(win->_begx + win->_line[y].firstchar)%10);
+			serial_putchar(',');
+			serial_putchar('0'+(win->_begy + y)/10);
+			serial_putchar('0'+(win->_begy + y)%10);
+			serial_putchar(':');
+		}
+#endif //SERIAL_LOG_FILE
 #endif
 
 		for (x = win->_line[y].firstchar; x <= win->_line[y].lastchar; x++) {
@@ -739,6 +760,7 @@
 #ifdef CONFIG_SERIAL_CONSOLE
 			if (curses_flags & F_ENABLE_SERIAL) {
 				ch = win->_line[y].text[x].chars[0];
+#ifndef CONFIG_SERIAL_LOG_FILE
 
 				if (attr & A_BOLD) {
 					if (!serial_is_bold) {
@@ -798,6 +820,7 @@
 					serial_cur_pair = PAIR_NUMBER(attr);
 				}
 
+#endif //SERIAL_LOG_FILE
 				serial_putchar(ch);
 
 			}
Index: Config.in
===================================================================
--- Config.in	(revision 3646)
+++ Config.in	(working copy)
@@ -82,6 +82,14 @@
 	  approximate the appearance of ACS characters on the serial port 
 	  console.
 
+config SERIAL_LOG_FILE
+	bool "Skip cursors and fanciness and add coordinates."
+	default n
+	depends on SERIAL_CONSOLE
+	help
+	  If you're using an emulator and sending the serial output to a
+	  file, this is for you.
+
 config VIDEO_CONSOLE
 	bool "See output on a video console"
 	default y
--
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to