338 lines
11 KiB
Diff
338 lines
11 KiB
Diff
|
diff -pruN -X linux/Documentation/dontdiff linux-2.6.29.3/arch/x86/kernel/early_printk.c linux-2.6.29.3-cprintk/arch/x86/kernel/early_printk.c
|
||
|
--- a/arch/x86/kernel/early_printk.c 2009-03-24 00:12:14.000000000 +0100
|
||
|
+++ b/arch/x86/kernel/early_printk.c 2009-05-09 16:10:36.000000000 +0200
|
||
|
@@ -23,7 +23,8 @@
|
||
|
static int max_ypos = 25, max_xpos = 80;
|
||
|
static int current_ypos = 25, current_xpos;
|
||
|
|
||
|
-static void early_vga_write(struct console *con, const char *str, unsigned n)
|
||
|
+static void early_vga_write(struct console *con, const char *str, unsigned n,
|
||
|
+ unsigned int loglevel)
|
||
|
{
|
||
|
char c;
|
||
|
int i, k, j;
|
||
|
@@ -93,7 +94,8 @@ static int early_serial_putc(unsigned ch
|
||
|
return timeout ? 0 : -1;
|
||
|
}
|
||
|
|
||
|
-static void early_serial_write(struct console *con, const char *s, unsigned n)
|
||
|
+static void early_serial_write(struct console *con, const char *s, unsigned n,
|
||
|
+ unsigned int loglevel)
|
||
|
{
|
||
|
while (*s && n-- > 0) {
|
||
|
if (*s == '\n')
|
||
|
@@ -887,7 +889,7 @@ asmlinkage void early_printk(const char
|
||
|
|
||
|
va_start(ap, fmt);
|
||
|
n = vscnprintf(buf, sizeof(buf), fmt, ap);
|
||
|
- early_console->write(early_console, buf, n);
|
||
|
+ early_console->write(early_console, buf, n, 0);
|
||
|
va_end(ap);
|
||
|
}
|
||
|
|
||
|
diff -pruN -X linux/Documentation/dontdiff linux-2.6.29.3/drivers/char/Kconfig linux-2.6.29.3-cprintk/drivers/tty/Kconfig
|
||
|
--- a/drivers/char/Kconfig 2009-03-24 00:12:14.000000000 +0100
|
||
|
+++ b/drivers/tty/Kconfig 2009-05-09 14:43:48.000000000 +0200
|
||
|
@@ -66,6 +66,111 @@ config VT_CONSOLE
|
||
|
|
||
|
If unsure, say Y.
|
||
|
|
||
|
+menuconfig VT_CKO
|
||
|
+ bool "Colored kernel message output"
|
||
|
+ depends on VT_CONSOLE
|
||
|
+ ---help---
|
||
|
+ This option enables kernel messages to be emitted in
|
||
|
+ colors other than the default.
|
||
|
+
|
||
|
+ The color value you need to enter is composed (OR-ed)
|
||
|
+ of a foreground and a background color.
|
||
|
+
|
||
|
+ Foreground:
|
||
|
+ 0x00 = black, 0x08 = dark gray,
|
||
|
+ 0x01 = red, 0x09 = light red,
|
||
|
+ 0x02 = green, 0x0A = light green,
|
||
|
+ 0x03 = brown, 0x0B = yellow,
|
||
|
+ 0x04 = blue, 0x0C = light blue,
|
||
|
+ 0x05 = magenta, 0x0D = light magenta,
|
||
|
+ 0x06 = cyan, 0x0E = light cyan,
|
||
|
+ 0x07 = gray, 0x0F = white,
|
||
|
+
|
||
|
+ (Foreground colors 0x08 to 0x0F do not work when a VGA
|
||
|
+ console font with 512 glyphs is used.)
|
||
|
+
|
||
|
+ Background:
|
||
|
+ 0x00 = black, 0x40 = blue,
|
||
|
+ 0x10 = red, 0x50 = magenta,
|
||
|
+ 0x20 = green, 0x60 = cyan,
|
||
|
+ 0x30 = brown, 0x70 = gray,
|
||
|
+
|
||
|
+ For example, 0x1F would yield white on red.
|
||
|
+
|
||
|
+ If unsure, say N.
|
||
|
+
|
||
|
+config VT_PRINTK_EMERG_COLOR
|
||
|
+ hex "Emergency messages color"
|
||
|
+ range 0x00 0xFF
|
||
|
+ depends on VT_CKO
|
||
|
+ default 0x07
|
||
|
+ ---help---
|
||
|
+ This option defines with which color kernel emergency messages will
|
||
|
+ be printed to the console.
|
||
|
+
|
||
|
+config VT_PRINTK_ALERT_COLOR
|
||
|
+ hex "Alert messages color"
|
||
|
+ range 0x00 0xFF
|
||
|
+ depends on VT_CKO
|
||
|
+ default 0x07
|
||
|
+ ---help---
|
||
|
+ This option defines with which color kernel alert messages will
|
||
|
+ be printed to the console.
|
||
|
+
|
||
|
+config VT_PRINTK_CRIT_COLOR
|
||
|
+ hex "Critical messages color"
|
||
|
+ range 0x00 0xFF
|
||
|
+ depends on VT_CKO
|
||
|
+ default 0x07
|
||
|
+ ---help---
|
||
|
+ This option defines with which color kernel critical messages will
|
||
|
+ be printed to the console.
|
||
|
+
|
||
|
+config VT_PRINTK_ERR_COLOR
|
||
|
+ hex "Error messages color"
|
||
|
+ range 0x00 0xFF
|
||
|
+ depends on VT_CKO
|
||
|
+ default 0x07
|
||
|
+ ---help---
|
||
|
+ This option defines with which color kernel error messages will
|
||
|
+ be printed to the console.
|
||
|
+
|
||
|
+config VT_PRINTK_WARNING_COLOR
|
||
|
+ hex "Warning messages color"
|
||
|
+ range 0x00 0xFF
|
||
|
+ depends on VT_CKO
|
||
|
+ default 0x07
|
||
|
+ ---help---
|
||
|
+ This option defines with which color kernel warning messages will
|
||
|
+ be printed to the console.
|
||
|
+
|
||
|
+config VT_PRINTK_NOTICE_COLOR
|
||
|
+ hex "Notice messages color"
|
||
|
+ range 0x00 0xFF
|
||
|
+ depends on VT_CKO
|
||
|
+ default 0x07
|
||
|
+ ---help---
|
||
|
+ This option defines with which color kernel notice messages will
|
||
|
+ be printed to the console.
|
||
|
+
|
||
|
+config VT_PRINTK_INFO_COLOR
|
||
|
+ hex "Information messages color"
|
||
|
+ range 0x00 0xFF
|
||
|
+ depends on VT_CKO
|
||
|
+ default 0x07
|
||
|
+ ---help---
|
||
|
+ This option defines with which color kernel information messages will
|
||
|
+ be printed to the console.
|
||
|
+
|
||
|
+config VT_PRINTK_DEBUG_COLOR
|
||
|
+ hex "Debug messages color"
|
||
|
+ range 0x00 0xFF
|
||
|
+ depends on VT_CKO
|
||
|
+ default 0x07
|
||
|
+ ---help---
|
||
|
+ This option defines with which color kernel debug messages will
|
||
|
+ be printed to the console.
|
||
|
+
|
||
|
config HW_CONSOLE
|
||
|
bool
|
||
|
depends on VT && !S390 && !UML
|
||
|
diff -pruN -X linux/Documentation/dontdiff linux-2.6.29.3/drivers/char/vt.c linux-2.6.29.3-cprintk/drivers/tty/vt/vt.c
|
||
|
--- a/drivers/char/vt.c 2009-05-09 10:46:57.000000000 +0200
|
||
|
+++ b/drivers/tty/vt/vt.c 2009-05-09 14:43:48.000000000 +0200
|
||
|
@@ -73,6 +73,7 @@
|
||
|
*/
|
||
|
|
||
|
#include <linux/module.h>
|
||
|
+#include <linux/moduleparam.h>
|
||
|
#include <linux/types.h>
|
||
|
#include <linux/sched.h>
|
||
|
#include <linux/tty.h>
|
||
|
@@ -2431,17 +2432,45 @@ struct tty_driver *console_driver;
|
||
|
|
||
|
#ifdef CONFIG_VT_CONSOLE
|
||
|
|
||
|
+#ifdef CONFIG_VT_CKO
|
||
|
+static unsigned int printk_color[8] __read_mostly = {
|
||
|
+ CONFIG_VT_PRINTK_EMERG_COLOR, /* KERN_EMERG */
|
||
|
+ CONFIG_VT_PRINTK_ALERT_COLOR, /* KERN_ALERT */
|
||
|
+ CONFIG_VT_PRINTK_CRIT_COLOR, /* KERN_CRIT */
|
||
|
+ CONFIG_VT_PRINTK_ERR_COLOR, /* KERN_ERR */
|
||
|
+ CONFIG_VT_PRINTK_WARNING_COLOR, /* KERN_WARNING */
|
||
|
+ CONFIG_VT_PRINTK_NOTICE_COLOR, /* KERN_NOTICE */
|
||
|
+ CONFIG_VT_PRINTK_INFO_COLOR, /* KERN_INFO */
|
||
|
+ CONFIG_VT_PRINTK_DEBUG_COLOR, /* KERN_DEBUG */
|
||
|
+};
|
||
|
+module_param_array(printk_color, uint, NULL, S_IRUGO | S_IWUSR);
|
||
|
+
|
||
|
+static inline void vc_set_color(struct vc_data *vc, unsigned char color)
|
||
|
+{
|
||
|
+ vc->vc_color = color_table[color & 0xF] |
|
||
|
+ (color_table[(color >> 4) & 0x7] << 4) |
|
||
|
+ (color & 0x80);
|
||
|
+ update_attr(vc);
|
||
|
+}
|
||
|
+#else
|
||
|
+static unsigned int printk_color[8];
|
||
|
+static inline void vc_set_color(const struct vc_data *vc, unsigned char c)
|
||
|
+{
|
||
|
+}
|
||
|
+#endif
|
||
|
+
|
||
|
/*
|
||
|
* Console on virtual terminal
|
||
|
*
|
||
|
* The console must be locked when we get here.
|
||
|
*/
|
||
|
|
||
|
-static void vt_console_print(struct console *co, const char *b, unsigned count)
|
||
|
+static void vt_console_print(struct console *co, const char *b, unsigned count,
|
||
|
+ unsigned int loglevel)
|
||
|
{
|
||
|
struct vc_data *vc = vc_cons[fg_console].d;
|
||
|
- unsigned char c;
|
||
|
static DEFINE_SPINLOCK(printing_lock);
|
||
|
+ unsigned char current_color, c;
|
||
|
const ushort *start;
|
||
|
ushort cnt = 0;
|
||
|
ushort myx;
|
||
|
@@ -2474,11 +2503,19 @@ static void vt_console_print(struct cons
|
||
|
|
||
|
start = (ushort *)vc->vc_pos;
|
||
|
|
||
|
+ /*
|
||
|
+ * We always get a valid loglevel - <8> and "no level" is transformed
|
||
|
+ * to <4> in the typical kernel.
|
||
|
+ */
|
||
|
+ current_color = printk_color[loglevel];
|
||
|
+ vc_set_color(vc, current_color);
|
||
|
+
|
||
|
/* Contrived structure to try to emulate original need_wrap behaviour
|
||
|
* Problems caused when we have need_wrap set on '\n' character */
|
||
|
while (count--) {
|
||
|
c = *b++;
|
||
|
if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) {
|
||
|
+ vc_set_color(vc, vc->vc_def_color);
|
||
|
if (cnt > 0) {
|
||
|
if (CON_IS_VISIBLE(vc))
|
||
|
vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x);
|
||
|
@@ -2491,6 +2528,7 @@ static void vt_console_print(struct cons
|
||
|
bs(vc);
|
||
|
start = (ushort *)vc->vc_pos;
|
||
|
myx = vc->vc_x;
|
||
|
+ vc_set_color(vc, current_color);
|
||
|
continue;
|
||
|
}
|
||
|
if (c != 13)
|
||
|
@@ -2498,6 +2536,7 @@ static void vt_console_print(struct cons
|
||
|
cr(vc);
|
||
|
start = (ushort *)vc->vc_pos;
|
||
|
myx = vc->vc_x;
|
||
|
+ vc_set_color(vc, current_color);
|
||
|
if (c == 10 || c == 13)
|
||
|
continue;
|
||
|
}
|
||
|
@@ -2520,6 +2559,7 @@ static void vt_console_print(struct cons
|
||
|
vc->vc_need_wrap = 1;
|
||
|
}
|
||
|
}
|
||
|
+ vc_set_color(vc, vc->vc_def_color);
|
||
|
set_cursor(vc);
|
||
|
notify_update(vc);
|
||
|
|
||
|
diff -pruN -X linux/Documentation/dontdiff linux-2.6.29.3/drivers/net/netconsole.c linux-2.6.29.3-cprintk/drivers/net/netconsole.c
|
||
|
--- a/drivers/net/netconsole.c 2009-03-24 00:12:14.000000000 +0100
|
||
|
+++ b/drivers/net/netconsole.c 2009-05-09 14:43:48.000000000 +0200
|
||
|
@@ -691,7 +691,8 @@ static struct notifier_block netconsole_
|
||
|
.notifier_call = netconsole_netdev_event,
|
||
|
};
|
||
|
|
||
|
-static void write_msg(struct console *con, const char *msg, unsigned int len)
|
||
|
+static void write_msg(struct console *con, const char *msg, unsigned int len,
|
||
|
+ unsigned int loglevel)
|
||
|
{
|
||
|
int frag, left;
|
||
|
unsigned long flags;
|
||
|
diff -pruN -X linux/Documentation/dontdiff linux-2.6.29.3/drivers/serial/8250.c linux-2.6.29.3-cprintk/drivers/tty/serial/8250.c
|
||
|
--- a/drivers/serial/8250.c 2009-03-24 00:12:14.000000000 +0100
|
||
|
+++ b/drivers/tty/serial/8250.c 2009-05-09 14:43:48.000000000 +0200
|
||
|
@@ -2698,7 +2698,8 @@ static void serial8250_console_putchar(s
|
||
|
* The console_lock must be held when we get here.
|
||
|
*/
|
||
|
static void
|
||
|
-serial8250_console_write(struct console *co, const char *s, unsigned int count)
|
||
|
+serial8250_console_write(struct console *co, const char *s, unsigned int count,
|
||
|
+ unsigned int loglevel)
|
||
|
{
|
||
|
struct uart_8250_port *up = &serial8250_ports[co->index];
|
||
|
unsigned long flags;
|
||
|
diff -pruN -X linux/Documentation/dontdiff linux-2.6.29.3/drivers/serial/8250_early.c linux-2.6.29.3-cprintk/drivers/tty/serial/8250_early.c
|
||
|
--- a/drivers/serial/8250_early.c 2009-03-24 00:12:14.000000000 +0100
|
||
|
+++ b/drivers/tty/serial/8250_early.c 2009-05-09 14:43:48.000000000 +0200
|
||
|
@@ -83,7 +83,7 @@ static void __init serial_putc(struct ua
|
||
|
}
|
||
|
|
||
|
static void __init early_serial8250_write(struct console *console,
|
||
|
- const char *s, unsigned int count)
|
||
|
+ const char *s, unsigned int count, unsigned int loglevel)
|
||
|
{
|
||
|
struct uart_port *port = &early_device.port;
|
||
|
unsigned int ier;
|
||
|
diff -pruN -X linux/Documentation/dontdiff linux-2.6.29.3/include/linux/console.h linux-2.6.29.3-cprintk/include/linux/console.h
|
||
|
--- a/include/linux/console.h 2009-03-24 00:12:14.000000000 +0100
|
||
|
+++ b/include/linux/console.h 2009-05-09 14:43:48.000000000 +0200
|
||
|
@@ -95,7 +95,7 @@ void give_up_console(const struct consw
|
||
|
|
||
|
struct console {
|
||
|
char name[16];
|
||
|
- void (*write)(struct console *, const char *, unsigned);
|
||
|
+ void (*write)(struct console *, const char *, unsigned, unsigned int);
|
||
|
int (*read)(struct console *, char *, unsigned);
|
||
|
struct tty_driver *(*device)(struct console *, int *);
|
||
|
void (*unblank)(void);
|
||
|
diff -pruN -X linux/Documentation/dontdiff linux-2.6.29.3/kernel/printk.c linux-2.6.29.3-cprintk/kernel/printk.c
|
||
|
--- a/kernel/printk.c 2009-03-24 00:12:14.000000000 +0100
|
||
|
+++ b/kernel/printk.c 2009-05-09 14:43:48.000000000 +0200
|
||
|
@@ -389,7 +389,8 @@ SYSCALL_DEFINE3(syslog, int, type, char
|
||
|
/*
|
||
|
* Call the console drivers on a range of log_buf
|
||
|
*/
|
||
|
-static void __call_console_drivers(unsigned start, unsigned end)
|
||
|
+static void __call_console_drivers(unsigned start, unsigned end,
|
||
|
+ unsigned int loglevel)
|
||
|
{
|
||
|
struct console *con;
|
||
|
|
||
|
@@ -397,7 +398,7 @@ static void __call_console_drivers(unsig
|
||
|
if ((con->flags & CON_ENABLED) && con->write &&
|
||
|
(cpu_online(smp_processor_id()) ||
|
||
|
(con->flags & CON_ANYTIME)))
|
||
|
- con->write(con, &LOG_BUF(start), end - start);
|
||
|
+ con->write(con, &LOG_BUF(start), end - start, loglevel);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@@ -424,10 +425,11 @@ static void _call_console_drivers(unsign
|
||
|
if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) {
|
||
|
/* wrapped write */
|
||
|
__call_console_drivers(start & LOG_BUF_MASK,
|
||
|
- log_buf_len);
|
||
|
- __call_console_drivers(0, end & LOG_BUF_MASK);
|
||
|
+ log_buf_len, msg_log_level);
|
||
|
+ __call_console_drivers(0, end & LOG_BUF_MASK,
|
||
|
+ msg_log_level);
|
||
|
} else {
|
||
|
- __call_console_drivers(start, end);
|
||
|
+ __call_console_drivers(start, end, msg_log_level);
|
||
|
}
|
||
|
}
|
||
|
}
|