From 8a40612b2ceba33194d26dd7d51a12f68f716832 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 15 Dec 2009 19:57:23 +0100 Subject: [PATCH 1/3] fix ofconsole palette --- term/ieee1275/ofconsole.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/term/ieee1275/ofconsole.c b/term/ieee1275/ofconsole.c index c61e16eb7..4464ed13f 100644 --- a/term/ieee1275/ofconsole.c +++ b/term/ieee1275/ofconsole.c @@ -43,17 +43,26 @@ struct color int blue; }; -#define MAX 0xff -static struct color colors[8] = +static struct color colors[16] = { - { 0, 0, 0}, - { MAX, 0, 0}, - { 0, MAX, 0}, - { MAX, MAX, 0}, - { 0, 0, MAX}, - { MAX, 0, MAX}, - { 0, MAX, MAX}, - { MAX, MAX, MAX} + // {R, G, B} + {0x00, 0x00, 0x00}, + {0x00, 0x00, 0xA8}, // 1 = blue + {0x00, 0xA8, 0x00}, // 2 = green + {0x00, 0xA8, 0xA8}, // 3 = cyan + {0xA8, 0x00, 0x00}, // 4 = red + {0xA8, 0x00, 0xA8}, // 5 = magenta + {0xA8, 0x54, 0x00}, // 6 = brown + {0xA8, 0xA8, 0xA8}, // 7 = light gray + + {0x54, 0x54, 0x54}, // 8 = dark gray + {0x54, 0x54, 0xFE}, // 9 = bright blue + {0x54, 0xFE, 0x54}, // 10 = bright green + {0x54, 0xFE, 0xFE}, // 11 = bright cyan + {0xFE, 0x54, 0x54}, // 12 = bright red + {0xFE, 0x54, 0xFE}, // 13 = bright magenta + {0xFE, 0xFE, 0x54}, // 14 = yellow + {0xFE, 0xFE, 0xFE} // 15 = white }; static grub_uint8_t grub_ofconsole_normal_color = 0x7; From 2ecf0c7ea49998b7e5cfb4bd1c0c72c9093709ad Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 18 Dec 2009 17:19:12 +0100 Subject: [PATCH 2/3] Discard brightness bit --- term/ieee1275/ofconsole.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/term/ieee1275/ofconsole.c b/term/ieee1275/ofconsole.c index 4464ed13f..ab11e9fb2 100644 --- a/term/ieee1275/ofconsole.c +++ b/term/ieee1275/ofconsole.c @@ -1,7 +1,7 @@ /* ofconsole.c -- Open Firmware console for GRUB. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ struct color int blue; }; -static struct color colors[16] = +static struct color colors[] = { // {R, G, B} {0x00, 0x00, 0x00}, @@ -52,17 +52,8 @@ static struct color colors[16] = {0x00, 0xA8, 0xA8}, // 3 = cyan {0xA8, 0x00, 0x00}, // 4 = red {0xA8, 0x00, 0xA8}, // 5 = magenta - {0xA8, 0x54, 0x00}, // 6 = brown - {0xA8, 0xA8, 0xA8}, // 7 = light gray - - {0x54, 0x54, 0x54}, // 8 = dark gray - {0x54, 0x54, 0xFE}, // 9 = bright blue - {0x54, 0xFE, 0x54}, // 10 = bright green - {0x54, 0xFE, 0xFE}, // 11 = bright cyan - {0xFE, 0x54, 0x54}, // 12 = bright red - {0xFE, 0x54, 0xFE}, // 13 = bright magenta - {0xFE, 0xFE, 0x54}, // 14 = yellow - {0xFE, 0xFE, 0xFE} // 15 = white + {0xFE, 0xFE, 0x54}, // 6 = yellow + {0xFE, 0xFE, 0xFE} // 7 = white }; static grub_uint8_t grub_ofconsole_normal_color = 0x7; @@ -140,8 +131,9 @@ static void grub_ofconsole_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color) { - grub_ofconsole_normal_color = normal_color; - grub_ofconsole_highlight_color = highlight_color; + /* Discard bright bit. */ + grub_ofconsole_normal_color = normal_color & 0x77; + grub_ofconsole_highlight_color = highlight_color & 0x77; } static void @@ -363,7 +355,6 @@ static grub_err_t grub_ofconsole_init_output (void) { grub_ssize_t actual; - int col; /* The latest PowerMacs don't actually initialize the screen for us, so we * use this trick to re-open the output device (but we avoid doing this on @@ -379,7 +370,8 @@ grub_ofconsole_init_output (void) /* Initialize colors. */ if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS)) { - for (col = 0; col < 7; col++) + unsigned col; + for (col = 0; col < ARRAY_SIZE (colors); col++) grub_ieee1275_set_color (stdout_ihandle, col, colors[col].red, colors[col].green, colors[col].blue); From d3d389719c664cceed114c2e26400d0fd95010e3 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 18 Dec 2009 17:24:12 +0100 Subject: [PATCH 3/3] ChangeLog --- ChangeLog.ofconsole | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 ChangeLog.ofconsole diff --git a/ChangeLog.ofconsole b/ChangeLog.ofconsole new file mode 100644 index 000000000..fa059f387 --- /dev/null +++ b/ChangeLog.ofconsole @@ -0,0 +1,9 @@ +2009-12-18 Vladimir Serbinenko + + Fix console palette on OpenFirmware. + + * term/ieee1275/ofconsole.c (MAX): Removed. + (colors): Redone based on VGA palette. + (grub_ofconsole_setcolor): Discard brightness bit since only 8 + colors are supported. + (grub_ofconsole_init_output): Use ARRAY_SIZE instead of hardcoded size.