sys-kernel/geos_one-sources: add colored printk

git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/linamh@715 6952d904-891a-0410-993b-d76249ca496b
This commit is contained in:
geos_one 2009-01-27 14:53:31 +00:00
parent 3af6aa9354
commit 60c3771203
4 changed files with 364 additions and 2 deletions

View File

@ -2,6 +2,10 @@
# Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2
# $Header: $
27 Jan 2009; Mario Fetka <mario.fetka@gmail.com>
+files/colored-printk-2.6.26.patch, geos_one-sources-2.6.28-r1.ebuild:
add colored printk
21 Jan 2009; Mario Fetka <mario.fetka@gmail.com>
+geos_one-sources-2.6.28-r1.ebuild:
Bump

View File

@ -1,3 +1,4 @@
AUX colored-printk-2.6.26.patch 11265 RMD160 1e520168b8813754906513317f5c683dbec2b31b SHA1 d321509ccc286b29b8c0fac9ae18205705fea332 SHA256 e8afce0c43cd534a6f707dc9f8769d0ba03322efccd55e3dc3edc3375e44c4ba
AUX intel-hda-a3530 13174 RMD160 e9fd8a6ffa3689e68edce74733e76378c467ba72 SHA1 5656993837d657271b0001d8bd4d5047d854713e SHA256 b4543cae20203bbd8d144d92f4ef48348c29bf28b44a9de9eece15e05959979f
AUX squashfs-2.6.28 219 RMD160 c1a3ae8e02643051f171500928005ca85d9d83cf SHA1 cf541d09ec2a8fe77525ebb91dd8e73060a4741a SHA256 a3b608a493ad09c983a5a697e05156697d6875a146690b8cda142854c298a9b1
DIST 2.6.27-AA2.3.tgz 96714 RMD160 ad5ed3f35f15fc10ee45020dd7a80926ef9201c8 SHA1 faf2a096b58a704d33a9a633e8e7ced0859cce26 SHA256 c94064437e6655beb9fd399fdbc443fd8a8db4acd3328ae04f23faf834d82e2e
@ -32,7 +33,7 @@ EBUILD geos_one-sources-2.6.27-r4.ebuild 3191 RMD160 310291b7ef6d9015128e5cc04e2
EBUILD geos_one-sources-2.6.27-r5.ebuild 3268 RMD160 fe08f99491a001054194a78df6aa3f89d23e41f0 SHA1 4c14a4f4765a82eebaa29433bcdf189ee342b1dd SHA256 48dbf7e70fd3caa2b99272173afc94119298278f14a7c3bac7bb93c29437e233
EBUILD geos_one-sources-2.6.27-r7.ebuild 2924 RMD160 425863b77e2fc04cca9051061dcdc9c34588ce4f SHA1 f62de54668415fd45d880a1fccd9702c4d0db9f2 SHA256 03a34dd1bae6de85243ca1c3e2bbb494a59ee11042f6d443c87513c42d8eb58b
EBUILD geos_one-sources-2.6.27.ebuild 2821 RMD160 8cddc77851562dcdd261fdda1a98b416a8539cdb SHA1 87f501974802d83ef142114c01c1b7c9dea27a59 SHA256 20cb29a2fcc71d86f85232d092a1339f02f13ac042c570af632d026bad024d54
EBUILD geos_one-sources-2.6.28-r1.ebuild 2724 RMD160 69ebb4d0733e4c9d6f1c2ffc7e462571ba9c99d4 SHA1 59eaacd1f726d8f9b5b05c7f70a6177f223fd40b SHA256 a3372376da68837319638bfcc07b886e5975c5e8c95dfa8030a5739967d9f6e0
EBUILD geos_one-sources-2.6.28-r1.ebuild 2805 RMD160 24ca2fb041e72dedba0406d861f604c85c0a9978 SHA1 8e41e076e69c217b44dcf3e2c2688551b75ddafa SHA256 bf9d6fbdccb20a79657ba675a6ee1497a015e4a9e4fe9436d516fcf1fc06782d
EBUILD geos_one-sources-2.6.28.ebuild 2724 RMD160 59ef67d038f90f54f7ad0224263fe3b8309db45d SHA1 f1e32cf7640706c4843679339d1774bbf89bed45 SHA256 dcb53c7bdbe81d51d74cc5f82e6efbade931fd33e962fd37cf71e7800d5d257c
MISC ChangeLog 3523 RMD160 797b8e257d7727a4a77e1dfc12be03b037dd62c3 SHA1 4dfadf32f143f2c7e79a5e30aa2b107cfc150b43 SHA256 1e06606e4dc16ac5986c6342435f8d53d70f39ef9a0ab0f9b6adb8636bb30176
MISC ChangeLog 3669 RMD160 450a5b6b4c5a2231be227e6e9056b5365a817d3d SHA1 9699532b3f4b456064244edfa21a20fd23fd223b SHA256 ef4f9033ac25d6430983a6da6b522043fbf059992f4a1038f9fb6e6b69403a92
MISC metadata.xml 413 RMD160 7e4e48d47e48804072f4ce93e1948fda82433a90 SHA1 cd61cf36ba79f6635ab7b7957f31609ecf52cc90 SHA256 74fe6520890eaf800a1759f3e4f772fd0e433e5de9cf775a50c7af95b199518b

View File

@ -0,0 +1,355 @@
diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index 643fd86..837f3c2 100644
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -15,7 +15,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;
@@ -84,7 +85,8 @@ static int early_serial_putc(unsigned char 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')
@@ -180,7 +182,8 @@ static void __init simnow_init(char *str)
simnow_fd = simnow(XOPEN, (unsigned long)fn, O_WRONLY|O_APPEND|O_CREAT, 0644);
}
-static void simnow_write(struct console *con, const char *s, unsigned n)
+static void simnow_write(struct console *con, const char *s, unsigned n,
+ unsigned int loglevel)
{
simnow(XWRITE, simnow_fd, (unsigned long)s, n);
}
@@ -204,7 +207,7 @@ void early_printk(const char *fmt, ...)
va_start(ap, fmt);
n = vscnprintf(buf, 512, fmt, ap);
- early_console->write(early_console, buf, n);
+ early_console->write(early_console, buf, n, 0);
va_end(ap);
}
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 57ba5c2..10556dd 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -71,6 +71,111 @@ config NR_TTY_DEVICES
If unsure, say 63.
+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 --git a/drivers/char/vt.c b/drivers/char/vt.c
index 935f1c2..1fee2dc 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -73,6 +73,7 @@
*/
#include <linux/module.h>
+#include <linux/moduleparam.h>
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/tty.h>
@@ -2409,17 +2410,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;
@@ -2452,11 +2481,19 @@ static void vt_console_print(struct console *co, const char *b, unsigned count)
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);
@@ -2469,6 +2506,7 @@ static void vt_console_print(struct console *co, const char *b, unsigned count)
bs(vc);
start = (ushort *)vc->vc_pos;
myx = vc->vc_x;
+ vc_set_color(vc, current_color);
continue;
}
if (c != 13)
@@ -2476,6 +2514,7 @@ static void vt_console_print(struct console *co, const char *b, unsigned count)
cr(vc);
start = (ushort *)vc->vc_pos;
myx = vc->vc_x;
+ vc_set_color(vc, current_color);
if (c == 10 || c == 13)
continue;
}
@@ -2498,6 +2537,7 @@ static void vt_console_print(struct console *co, const char *b, unsigned count)
vc->vc_need_wrap = 1;
}
}
+ vc_set_color(vc, vc->vc_def_color);
set_cursor(vc);
notify_update(vc);
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 665341e..4c27de8 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -694,7 +694,8 @@ static struct notifier_block netconsole_netdev_notifier = {
.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 --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 1bc00b7..b4f1b6f 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2527,7 +2527,8 @@ static void serial8250_console_putchar(struct uart_port *port, int ch)
* 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 --git a/drivers/serial/8250_early.c b/drivers/serial/8250_early.c
index f279745..2a928bd 100644
--- a/drivers/serial/8250_early.c
+++ b/drivers/serial/8250_early.c
@@ -83,7 +83,7 @@ static void __init serial_putc(struct uart_port *port, int c)
}
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 --git a/include/linux/console.h b/include/linux/console.h
index a4f27fb..46fcfd3 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -95,7 +95,7 @@ void give_up_console(const struct consw *sw);
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 --git a/kernel/printk.c b/kernel/printk.c
index 6e920ce..a1aaa3f 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -444,7 +444,8 @@ asmlinkage long sys_syslog(int type, char __user *buf, int len)
/*
* 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;
@@ -452,7 +453,7 @@ static void __call_console_drivers(unsigned start, unsigned end)
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);
}
}
@@ -479,10 +480,11 @@ static void _call_console_drivers(unsigned start,
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);
}
}
}

View File

@ -14,6 +14,7 @@ DSDT_VER="0.9c"
DSDT_KV="2.6.28"
UNION_VER="2.5"
UNION_KV="2.6.27-rc6"
COL_PRINTK_KV="2.6.26"
inherit kernel-2
detect_version
@ -56,6 +57,7 @@ src_unpack() {
epatch ${DISTDIR}/acpi-dsdt-initrd-v${DSDT_VER}-${DSDT_KV}.patch
epatch ${DISTDIR}/unionfs-${UNION_VER}_for_${UNION_KV}.diff.gz
epatch ${DISTDIR}/UnionFS_${UNION_VER}-AppArmor_${AA_VER}.patch
epatch ${FILESDIR}/colored-printk-${COL_PRINTK_KV}.patch
find ${WORKDIR} -iname "*.orig" -exec rm {} \; 2> /dev/null