console= options: reverse order [PATCH]

Miquel van Smoorenburg (miquels@cistron.nl)
21 Mar 1998 21:44:11 +0100


This patch reverses the order in which the console command line options
are honoured. Now the last console= command line option becomes the
r/w console device. This way it is possible to override the console from
the boot command line, which would otherwise be impossible.

diff -ruN linux-2.1.90.orig/Documentation/serial-console.txt linux-2.1.90/Documentation/serial-console.txt
--- linux-2.1.90.orig/Documentation/serial-console.txt Thu Dec 4 00:21:57 1997
+++ linux-2.1.90/Documentation/serial-console.txt Sat Mar 21 21:21:45 1998
@@ -19,10 +19,10 @@
9600n8. The maximum baudrate is 115200.

You can specify multiple console= options on the kernel command line.
-Output will appear on all of them. The first device will be used when
+Output will appear on all of them. The last device will be used when
you open /dev/console. So, for example:

- console=tty0 console=ttyS1,9600
+ console=ttyS1,9600 console=tty0

defines that opening /dev/console will get you the current foreground
virtual console, and kernel messages will appear on both the VGA
@@ -91,4 +91,4 @@
for porting the patches from 2.1.4x to 2.1.6x for taking care of
the integration of these patches into m68k, ppc and alpha.

-Miquel van Smoorenburg <miquels@cistron.nl>, 03-Dec-1997
+Miquel van Smoorenburg <miquels@cistron.nl>, 21-Mar-1998
diff -ruN linux-2.1.90.orig/drivers/char/serial.c linux-2.1.90/drivers/char/serial.c
--- linux-2.1.90.orig/drivers/char/serial.c Sat Mar 21 18:23:24 1998
+++ linux-2.1.90/drivers/char/serial.c Sat Mar 21 19:42:32 1998
@@ -3212,7 +3212,7 @@
* The interrupt of the serial console port
* can't be shared.
*/
- if (sercons.flags & CON_FIRST) {
+ if (sercons.flags & CON_CONSDEV) {
for(i = 0; i < NR_PORTS; i++)
if (i != sercons.index &&
rs_table[i].irq == rs_table[sercons.index].irq)
diff -ruN linux-2.1.90.orig/include/linux/console.h linux-2.1.90/include/linux/console.h
--- linux-2.1.90.orig/include/linux/console.h Wed Jan 21 01:44:58 1998
+++ linux-2.1.90/include/linux/console.h Sat Mar 21 19:43:51 1998
@@ -80,7 +80,7 @@
*/

#define CON_PRINTBUFFER (1)
-#define CON_FIRST (2)
+#define CON_CONSDEV (2) /* Last on the command line */
#define CON_ENABLED (4)

struct console
diff -ruN linux-2.1.90.orig/kernel/printk.c linux-2.1.90/kernel/printk.c
--- linux-2.1.90.orig/kernel/printk.c Sat Feb 21 13:07:24 1998
+++ linux-2.1.90/kernel/printk.c Sat Mar 21 20:05:10 1998
@@ -54,7 +54,7 @@
static unsigned long log_start = 0;
static unsigned long logged_chars = 0;
struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
-static int selected_console = 0;
+static int preferred_console = -1;

/*
* Setup a list of consoles. Called from init/main.c
@@ -95,11 +95,13 @@
*/
for(i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
if (strcmp(console_cmdline[i].name, name) == 0 &&
- console_cmdline[i].index == idx)
+ console_cmdline[i].index == idx) {
+ preferred_console = i;
return;
+ }
if (i == MAX_CMDLINECONSOLES)
return;
- selected_console = 1;
+ preferred_console = i;
c = &console_cmdline[i];
memcpy(c->name, name, sizeof(c->name));
c->options = options;
@@ -336,13 +338,13 @@
* didn't select a console we take the first one
* that registers here.
*/
- if (selected_console == 0) {
+ if (preferred_console < 0) {
if (console->index < 0)
console->index = 0;
if (console->setup == NULL ||
console->setup(console, NULL) == 0) {
- console->flags |= CON_ENABLED | CON_FIRST;
- selected_console = 1;
+ console->flags |= CON_ENABLED | CON_CONSDEV;
+ preferred_console = 0;
}
}

@@ -362,8 +364,8 @@
break;
console->flags |= CON_ENABLED;
console->index = console_cmdline[i].index;
- if (i == 0)
- console->flags |= CON_FIRST;
+ if (i == preferred_console)
+ console->flags |= CON_CONSDEV;
break;
}

@@ -374,7 +376,7 @@
* Put this console in the list - keep the
* preferred driver at the head of the list.
*/
- if ((console->flags & CON_FIRST) || console_drivers == NULL) {
+ if ((console->flags & CON_CONSDEV) || console_drivers == NULL) {
console->next = console_drivers;
console_drivers = console;
} else {

-- 
 Miquel van Smoorenburg | Our vision is to speed up time,
    miquels@cistron.nl  |   eventually eliminating it.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu