CONFIG_SERIAL_CONSOLE in v2.1.31

Paul Gortmaker (paul@rasty.anu.edu.au)
Sat, 5 Apr 1997 16:58:58 +1000 (EST)


First off, thanks to whoever did the console work in v2.1.31 -- it saves
between 50 and 60k on a headless box by dumping selection, console,
keyboard and friends from the kernel. Good stuff.

My only minor gripe is that you still can't select the serial port without
having to locate and edit some #define buried in some file. This can either
be addressed via a boot time argument or as a CONFIG option. The latter
is probably an adequate solution, and what the following patch implements
via the "choice" configure function (same as how you select your CPU on
i386 builds).

Paul.

-------------------------------------------------------------------------

diff -ur /tmp/linux/drivers/char/Config.in linux/drivers/char/Config.in
--- /tmp/linux/drivers/char/Config.in Fri Apr 4 21:04:04 1997
+++ linux/drivers/char/Config.in Sat Apr 5 15:08:46 1997
@@ -16,6 +16,13 @@
bool ' Support special multiport boards' CONFIG_SERIAL_MULTIPORT
bool ' Support the Bell Technologies HUB6 card' CONFIG_HUB6
bool ' Console on serial port' CONFIG_SERIAL_CONSOLE
+ if [ "$CONFIG_SERIAL_CONSOLE" = "y" ]; then
+ choice ' Serial console port' \
+ "ttyS0 CONFIG_SERIAL_CONSOLE_TTYS0 \
+ ttyS1 CONFIG_SERIAL_CONSOLE_TTYS1 \
+ ttyS2 CONFIG_SERIAL_CONSOLE_TTYS2 \
+ ttyS3 CONFIG_SERIAL_CONSOLE_TTYS3" ttyS1
+ fi
fi
bool 'Non-standard serial port support' CONFIG_SERIAL_NONSTANDARD
if [ "$CONFIG_SERIAL_NONSTANDARD" = "y" ]; then
diff -ur /tmp/linux/drivers/char/serial.c linux/drivers/char/serial.c
--- /tmp/linux/drivers/char/serial.c Fri Apr 4 21:04:08 1997
+++ linux/drivers/char/serial.c Sat Apr 5 15:14:22 1997
@@ -3442,8 +3442,14 @@
/*
* this defines the index into rs_table for the port to use
*/
-#ifndef CONFIG_SERIAL_CONSOLE_PORT
-#define CONFIG_SERIAL_CONSOLE_PORT 0
+#if defined (CONFIG_SERIAL_CONSOLE_TTYS0)
+#define SERIAL_CONSOLE_PORT 0
+#elif defined (CONFIG_SERIAL_CONSOLE_TTYS1)
+#define SERIAL_CONSOLE_PORT 1
+#elif defined (CONFIG_SERIAL_CONSOLE_TTYS2)
+#define SERIAL_CONSOLE_PORT 2
+#elif defined (CONFIG_SERIAL_CONSOLE_TTYS3)
+#define SERIAL_CONSOLE_PORT 3
#endif

#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
@@ -3467,7 +3473,7 @@
int ier;
unsigned i;

- ser = rs_table + CONFIG_SERIAL_CONSOLE_PORT;
+ ser = rs_table + SERIAL_CONSOLE_PORT;
/*
* First save the IER then disable the interrupts
*/
@@ -3510,7 +3516,7 @@
int lsr;
int c;

- ser = rs_table + CONFIG_SERIAL_CONSOLE_PORT;
+ ser = rs_table + SERIAL_CONSOLE_PORT;

/*
* First save the IER then disable the interrupts so
@@ -3533,7 +3539,7 @@

static int serial_console_device(void)
{
- return MKDEV(TTYAUX_MAJOR, 64 + CONFIG_SERIAL_CONSOLE_PORT);
+ return MKDEV(TTYAUX_MAJOR, 64 + SERIAL_CONSOLE_PORT);
}

long serial_console_init(long kmem_start, long kmem_end)
@@ -3544,7 +3550,7 @@
};
struct serial_state *ser;

- ser = rs_table + CONFIG_SERIAL_CONSOLE_PORT;
+ ser = rs_table + SERIAL_CONSOLE_PORT;

/* Disable all interrupts, it works in polled mode */
outb(0x00, ser->port + UART_IER);