Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1765129AbXJFTNt (ORCPT ); Sat, 6 Oct 2007 15:13:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1764245AbXJFTNn (ORCPT ); Sat, 6 Oct 2007 15:13:43 -0400 Received: from sovereign.computergmbh.de ([85.214.69.204]:54668 "EHLO sovereign.computergmbh.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1764238AbXJFTNm (ORCPT ); Sat, 6 Oct 2007 15:13:42 -0400 Date: Sat, 6 Oct 2007 21:13:40 +0200 (CEST) From: Jan Engelhardt To: Linux Kernel Mailing List cc: Dave Jones , Oleg Verych , Ingo Molnar , Krzysztof Halasa , Medve Emilian-EMMEDVE1 , Helge Deller Subject: [PATCH 1/2] Colored kernel output (run2) In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4149 Lines: 140 Colored kernel message output (1/2) This patch makes it possible to give kernel messages a selectable color. It can be chosen at compile time, overridden at boot time, and changed at run time. There is no way to disable this option. It would only add ugly ifdefs, and the default color is the one that vt.c used for all the past years anyway, so apart from the config option, nothing changes for the conservative user. References: http://lkml.org/lkml/2007/4/1/162 http://lkml.org/lkml/2007/10/5/199 Signed-off-by: Jan Engelhardt --- drivers/char/Kconfig | 33 +++++++++++++++++++++++++++++++++ drivers/char/vt.c | 17 +++++++++++++++++ 2 files changed, 50 insertions(+) Index: linux-2.6.23/drivers/char/Kconfig =================================================================== --- linux-2.6.23.orig/drivers/char/Kconfig +++ linux-2.6.23/drivers/char/Kconfig @@ -58,6 +58,39 @@ config VT_CONSOLE If unsure, say Y. +config VT_PRINTK_COLOR + hex "Colored kernel message output" + range 0x00 0xFF + depends on VT_CONSOLE + default 0x07 + ---help--- + This option defines with which color kernel messages will be + printed to the console. + + The value you need to enter here is the value 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. + config HW_CONSOLE bool depends on VT && !S390 && !UML Index: linux-2.6.23/drivers/char/vt.c =================================================================== --- linux-2.6.23.orig/drivers/char/vt.c +++ linux-2.6.23/drivers/char/vt.c @@ -73,6 +73,7 @@ */ #include +#include #include #include #include @@ -2344,6 +2345,17 @@ struct tty_driver *console_driver; #ifdef CONFIG_VT_CONSOLE +static unsigned int printk_color __read_mostly = CONFIG_VT_PRINTK_COLOR; +module_param(printk_color, uint, 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); +} + /* * Console on virtual terminal * @@ -2384,12 +2396,14 @@ static void vt_console_print(struct cons hide_cursor(vc); start = (ushort *)vc->vc_pos; + vc_set_color(vc, printk_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); @@ -2402,6 +2416,7 @@ static void vt_console_print(struct cons bs(vc); start = (ushort *)vc->vc_pos; myx = vc->vc_x; + vc_set_color(vc, printk_color); continue; } if (c != 13) @@ -2409,6 +2424,7 @@ static void vt_console_print(struct cons cr(vc); start = (ushort *)vc->vc_pos; myx = vc->vc_x; + vc_set_color(vc, printk_color); if (c == 10 || c == 13) continue; } @@ -2430,6 +2446,7 @@ static void vt_console_print(struct cons vc->vc_need_wrap = 1; } } + vc_set_color(vc, vc->vc_def_color); set_cursor(vc); quit: - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/