diff -NurbP --minimal grub-0.93/stage2/boot.c grub-0.93-console/stage2/boot.c --- grub-0.93/stage2/boot.c Sat Nov 30 18:29:16 2002 +++ grub-0.93-console/stage2/boot.c Sun Mar 9 18:00:39 2003 @@ -20,6 +20,10 @@ #include "shared.h" +#ifdef SUPPORT_SERIAL +#include +#include +#endif #include "freebsd.h" #include "imgact_aout.h" @@ -406,6 +410,30 @@ while (dest < linux_data_tmp_addr + LINUX_CL_END_OFFSET && *src) *(dest++) = *(src++); + +#ifdef SUPPORT_SERIAL + /* Add a console option automatically only if the user doesn't + specify it explicitly. */ + if (! grub_strstr (arg, "console=") + && (load_flags & KERNEL_LOAD_CONSOLE_OPTION) + && (grub_strstr (current_term->name, "serial")) + && dest + 23 < linux_data_tmp_addr + LINUX_CL_END_OFFSET) + { + int count = 0, port = 0; + unsigned int unit, speed, word_len; + unsigned char parity; + +# ifndef GRUB_UTIL + port = serial_hw_get_param(&unit, &speed, &word_len, &parity); +# endif + if (port) + { + count = grub_sprintf(dest, " console=ttyS%d,%d%c%d", + unit, speed, parity, word_len); + dest += count; + } + } +#endif /* Add a mem option automatically only if the user doesn't specify it explicitly. */ diff -NurbP --minimal grub-0.93/stage2/builtins.c grub-0.93-console/stage2/builtins.c --- grub-0.93/stage2/builtins.c Wed Dec 4 05:41:57 2002 +++ grub-0.93-console/stage2/builtins.c Sun Mar 9 18:00:39 2003 @@ -2327,6 +2327,8 @@ has no effect. */ else if (grub_memcmp (arg, "--no-mem-option", 15) == 0) load_flags |= KERNEL_LOAD_NO_MEM_OPTION; + else if (grub_memcmp (arg, "--console-option", 16) == 0) + load_flags |= KERNEL_LOAD_CONSOLE_OPTION; else break; diff -NurbP --minimal grub-0.93/stage2/serial.c grub-0.93-console/stage2/serial.c --- grub-0.93/stage2/serial.c Fri Nov 29 20:05:59 2002 +++ grub-0.93-console/stage2/serial.c Sun Mar 9 18:00:39 2003 @@ -48,6 +48,11 @@ /* Store the port number of a serial unit. */ static unsigned short serial_hw_port = 0; +/* Store serial unit parameters. */ +static unsigned int serial_hw_speed = 0; +static unsigned char serial_hw_word_len = 0; +static unsigned char serial_hw_parity = 0; + /* The table which lists common configurations. */ static struct divisor divisor_tab[] = { @@ -123,6 +128,38 @@ return addr[unit]; } +/* Return the unit number for the serial device at PORT. */ +unsigned short +serial_hw_get_unit (unsigned short port) +{ + /* The BIOS data area. */ + const unsigned short *addr = (const unsigned short *) 0x0400; + unsigned int i; + + for (i=0; i<4; i++) + if (addr[i] == port) break; + + return (i%4); +} + +/* Return the serial port parameters */ +int +serial_hw_get_param (unsigned int *unit, unsigned int *speed, + unsigned int *word_len, unsigned char *parity) +{ + if (unit) + *unit = serial_hw_get_unit(serial_hw_port); + if (speed) + *speed = serial_hw_speed; + if (word_len) + *word_len = serial_hw_word_len + 0x05; + if (parity) + *parity = (serial_hw_parity == UART_NO_PARITY)?'n': + ((serial_hw_parity == UART_EVEN_PARITY)?'e': + ((serial_hw_parity == UART_ODD_PARITY)?'o':'x')); + return serial_hw_port; +} + /* Initialize a serial device. PORT is the port number for a serial device. SPEED is a DTE-DTE speed which must be one of these: 2400, 4800, 9600, 19200, 38400, 57600 and 115200. WORD_LEN is the word length to be used @@ -170,6 +207,11 @@ /* Store the port number. */ serial_hw_port = port; + + /* Store unit parameters */ + serial_hw_speed = speed; + serial_hw_word_len = word_len; + serial_hw_parity = parity; /* Drain the input buffer. */ while (serial_checkkey () != -1) diff -NurbP --minimal grub-0.93/stage2/serial.h grub-0.93-console/stage2/serial.h --- grub-0.93/stage2/serial.h Tue Jun 11 14:48:10 2002 +++ grub-0.93-console/stage2/serial.h Sun Mar 9 18:00:39 2003 @@ -79,7 +79,13 @@ /* Return the port number for the UNITth serial device. */ unsigned short serial_hw_get_port (int unit); +/* Return the unit number for the serial device at PORT. */ +unsigned short serial_hw_get_unit (unsigned short port); +/* Return the serial port parameters */ +int +serial_hw_get_param (unsigned int *unit, unsigned int *speed, + unsigned int *word_len, unsigned char *parity); /* Initialize a serial device. */ int serial_hw_init (unsigned short port, unsigned int speed, int word_len, int parity, int stop_bit_len); diff -NurbP --minimal grub-0.93/stage2/shared.h grub-0.93-console/stage2/shared.h --- grub-0.93/stage2/shared.h Tue Dec 3 00:15:12 2002 +++ grub-0.93-console/stage2/shared.h Sun Mar 9 18:00:39 2003 @@ -963,6 +963,9 @@ /* Don't pass a Linux's mem option automatically. */ #define KERNEL_LOAD_NO_MEM_OPTION (1 << 0) +/* Pass a Linux's console option automatically. */ +#define KERNEL_LOAD_CONSOLE_OPTION (1 << 1) + kernel_t load_image (char *kernel, char *arg, kernel_t suggested_type, unsigned long load_flags);