We shouldn't try to use the serial terminal if the user hasn't properly
configured it yet. This patch (against current CVS) makes it so ensures
that we have set up a serial port prior to switching to a serial
terminal.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/grub/grub/ChangeLog,v
retrieving revision 1.428
diff -u -r1.428 ChangeLog
--- ChangeLog 2001/08/08 05:17:20 1.428
+++ ChangeLog 2001/08/08 05:46:58
@@ -1,3 +1,13 @@
+2001-08-08 Jeremy Katz <[EMAIL PROTECTED]>
+
+ * grub/asmstub.c, stage2/serial.c, stage2/serial.h:
+ add serial_exists() function to ensure that serial port is set up
+ prior to use
+
+ * stage2/builtins.c:
+ use serial_exists when serial terminal is selected or fallback to
+ previous terminal definition
+
2001-08-08 OKUJI Yoshinori <[EMAIL PROTECTED]>
* util/grub-md5-crypt.in: Prefix backquotes with backslashes in
Index: grub/asmstub.c
===================================================================
RCS file: /cvsroot/grub/grub/grub/asmstub.c,v
retrieving revision 1.70
diff -u -r1.70 asmstub.c
--- grub/asmstub.c 2001/05/03 08:34:56 1.70
+++ grub/asmstub.c 2001/08/08 05:46:59
@@ -1026,6 +1026,21 @@
return 0;
}
+/* Do we have a serial port set up? In the grub shell, we should check
+ if the fd is open */
+int serial_exists(void)
+{
+ grub_printf("serial_fd is %d\n", serial_fd);
+ if (serial_fd >= 0)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
/* Initialize a serial device. In the grub shell, PORT is unused. */
int
serial_init (unsigned short port, unsigned int speed,
Index: stage2/builtins.c
===================================================================
RCS file: /cvsroot/grub/grub/stage2/builtins.c,v
retrieving revision 1.112
diff -u -r1.112 builtins.c
--- stage2/builtins.c 2001/06/21 23:15:02 1.112
+++ stage2/builtins.c 2001/08/08 05:47:02
@@ -3914,9 +3914,18 @@
#ifdef SUPPORT_SERIAL
else if (grub_memcmp (arg, "serial", sizeof ("serial") - 1) == 0)
{
- terminal |= TERMINAL_SERIAL;
- if (! default_terminal)
- default_terminal = TERMINAL_SERIAL;
+ if (serial_exists())
+ {
+ terminal |= TERMINAL_SERIAL;
+ if (! default_terminal)
+ default_terminal = TERMINAL_SERIAL;
+ }
+ else
+ {
+ terminal = saved_terminal;
+ grub_printf("No serial device configured.\n");
+ grub_printf("Resetting to previous terminal configuration.\n");
+ }
}
#endif /* SUPPORT_SERIAL */
else
Index: stage2/serial.c
===================================================================
RCS file: /cvsroot/grub/grub/stage2/serial.c,v
retrieving revision 1.3
diff -u -r1.3 serial.c
--- stage2/serial.c 2000/08/26 17:36:07 1.3
+++ stage2/serial.c 2001/08/08 05:47:02
@@ -31,7 +31,7 @@
};
/* Store the port number of a serial unit. */
-static unsigned short serial_port;
+static unsigned short serial_port = -1;
/* The table which lists common configurations. */
static struct divisor divisor_tab[] =
@@ -100,6 +100,15 @@
return;
outb (serial_port + UART_TX, c);
+}
+
+/* do we have a serial port set up? */
+int
+serial_exists (void)
+{
+ if (serial_port == -1)
+ return 0;
+ return 1;
}
/* Return the port number for the UNITth serial device. */
Index: stage2/serial.h
===================================================================
RCS file: /cvsroot/grub/grub/stage2/serial.h,v
retrieving revision 1.5
diff -u -r1.5 serial.h
--- stage2/serial.h 2000/08/26 17:36:07 1.5
+++ stage2/serial.h 2001/08/08 05:47:02
@@ -93,6 +93,9 @@
int serial_init (unsigned short port, unsigned int speed,
int word_len, int parity, int stop_bit_len);
+/* Do we have a serial port set up? */
+int serial_exists (void);
+
#ifdef GRUB_UTIL
/* Set the file name of a serial device (or a pty device). This is a
function specific to the grub shell. */
_______________________________________________
Bug-grub mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-grub