[PATCH] printk patch

Wolfram Kleff (kleff@informatik.uni-bonn.de)
Sat, 31 May 1997 00:28:12 +0200 (MET DST)


This is the separated printk patch, it is completely optional
now - no support for monochrome displays anymore, because nobody voted
for it.

diff -u --recursive --new-file linux-2.1.41/Documentation/Configure.help linux/Documentation/Configure.help
--- linux-2.1.41/Documentation/Configure.help Tue May 27 14:01:16 1997
+++ linux/Documentation/Configure.help Tue May 27 14:01:16 1997
@@ -4021,6 +4021,12 @@
visible on your display. You should say Y here if you have no other
console device.

+Console on color display
+CONFIG_VT_CONSOLE_COLOR
+ If you have a color monitor connected to your Computer
+ and you want colored kernel messages say Y here.
+
Standard/generic serial support
CONFIG_SERIAL
This selects whether you want to include the driver for the standard
diff -u --recursive --new-file linux-2.1.41/drivers/char/Config.in linux/drivers/char/Config.in
--- linux-2.1.41/drivers/char/Config.in Tue May 27 14:01:16 1997
+++ linux/drivers/char/Config.in Tue May 27 14:01:16 1997
@@ -7,6 +7,7 @@
bool 'Virtual terminal' CONFIG_VT
if [ "$CONFIG_VT" = "y" ]; then
bool 'Console on virtual terminal' CONFIG_VT_CONSOLE
+ bool 'Console on color display' CONFIG_VT_CONSOLE_COLOR
fi
tristate 'Standard/generic (dumb) serial support' CONFIG_SERIAL
bool 'Extended dumb serial driver options' CONFIG_SERIAL_EXTENDED
diff -u --recursive --new-file linux-2.1.41/kernel/printk.c linux/kernel/printk.c
--- linux-2.1.41/kernel/printk.c Tue May 20 20:02:08 1997
+++ linux/kernel/printk.c Tue May 27 13:30:26 1997
@@ -10,6 +10,9 @@
* elsewhere, in preparation for a serial line console (someday).
* Ted Ts'o, 2/11/93.
* Modified for sysctl support, 1/8/97, Chris Horn.
+ *
+ * make printk message level visible on console 1997-05-22, Wolfram Kleff
+ *
*/

#include <stdarg.h>
@@ -26,9 +29,14 @@
#include <linux/smp_lock.h>
#include <linux/console.h>
#include <linux/init.h>
+#include <linux/config.h>

#include <asm/uaccess.h>

+#ifdef CONFIG_VT_CONSOLE_COLOR
+#include "../drivers/char/console_struct.h"
+#endif
+
#define LOG_BUF_LEN 8192

static char buf[1024];
@@ -171,7 +179,6 @@
return error;
}

-
asmlinkage int printk(const char *fmt, ...)
{
va_list args;
@@ -181,6 +188,11 @@
static signed char msg_level = -1;
long flags;

+#ifdef CONFIG_VT_CONSOLE
+ unsigned char s_attr;
+ int currcons=0;
+#endif
+
__save_flags(flags);
__cli();
va_start(args, fmt);
@@ -221,11 +233,38 @@
}
if (msg_level < console_loglevel && console_drivers) {
struct console *c = console_drivers;
+
+#ifdef CONFIG_VT_CONSOLE_COLOR
+ s_attr = attr;
+ switch (msg_level) {
+ case 0: /* system is unusable */
+ attr = 0x47 | 0x08 | 0x80; /* white on red, bright, blink */
+ break;
+ case 1: /* action must be taken immediately */
+ attr = 0x74 | 0x08 | 0x80; /* red on white, bright, blink */
+ break;
+ case 2: /* critical conditions */
+ attr = 0x74 | 0x08; /* red on white, bright */
+ break;
+ case 3: /* error conditions */
+ attr = 0x04 | 0x08; /* red on black, bright */
+ break;
+ case 4: /* warning conditions */
+ attr = 0x04; /* red on black */
+ break;
+ case 5: /* normal but significant condition */
+ attr |= 0x08; /* bright */
+ break;
+ }
+#endif
while(c) {
if (c->write)
c->write(msg, p - msg + line_feed);
c = c->next;
}
+#ifdef CONFIG_VT_CONSOLE_COLOR
+ attr = s_attr;
+#endif
}
if (line_feed)
msg_level = -1;