From d08bbb491e08cb455da3d1953c632bb15c8d4d33 Mon Sep 17 00:00:00 2001 From: proski Date: Thu, 24 Jan 2008 08:21:43 +0000 Subject: [PATCH] * include/grub/ieee1275/ieee1275.h: Introduce flag for firmwares that hang if GRUB tries to setup colors. * term/ieee1275/ofconsole.c (grub_ofconsole_init): Don't set colors for firmwares that don't support it. * kern/powerpc/ieee1275/cmain.c (grub_ieee1275_set_flag): Recognize Open Hack'Ware, set flags to work around its limitations. --- ChangeLog | 10 ++++++++++ include/grub/ieee1275/ieee1275.h | 3 +++ kern/powerpc/ieee1275/cmain.c | 18 +++++++++++++++++- term/ieee1275/ofconsole.c | 13 ++++++++----- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6450ebe8f..75e91fd53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-01-24 Pavel Roskin + + * include/grub/ieee1275/ieee1275.h: Introduce flag for firmwares + that hang if GRUB tries to setup colors. + * term/ieee1275/ofconsole.c (grub_ofconsole_init): Don't set + colors for firmwares that don't support it. + * kern/powerpc/ieee1275/cmain.c (grub_ieee1275_set_flag): + Recognize Open Hack'Ware, set flags to work around its + limitations. + 2008-01-24 Robert Millan * kern/file.c (grub_file_open): Do not account previous failures of diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index 008a114f6..463180dca 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -86,6 +86,9 @@ enum grub_ieee1275_flag /* OLPC / XO firmware hangs when accessing USB devices. */ GRUB_IEEE1275_FLAG_OFDISK_SDCARD_ONLY, + + /* Open Hack'Ware stops when trying to set colors */ + GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS, }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); diff --git a/kern/powerpc/ieee1275/cmain.c b/kern/powerpc/ieee1275/cmain.c index 2b7cce56c..0a3a2a5c7 100644 --- a/kern/powerpc/ieee1275/cmain.c +++ b/kern/powerpc/ieee1275/cmain.c @@ -46,12 +46,16 @@ grub_ieee1275_set_flag (enum grub_ieee1275_flag flag) grub_ieee1275_flags |= (1 << flag); } +#define SF "SmartFirmware(tm)" +#define OHW "PPC Open Hack'Ware" + static void grub_ieee1275_find_options (void) { grub_ieee1275_phandle_t root; grub_ieee1275_phandle_t options; grub_ieee1275_phandle_t openprom; + grub_ieee1275_phandle_t bootrom; int rc; int realmode = 0; char tmp[32]; @@ -69,7 +73,6 @@ grub_ieee1275_find_options (void) rc = grub_ieee1275_get_property (openprom, "CodeGen-copyright", tmp, sizeof (tmp), 0); -#define SF "SmartFirmware(tm)" if (rc >= 0 && !grub_strncmp (tmp, SF, sizeof (SF) - 1)) is_smartfirmware = 1; @@ -133,8 +136,21 @@ grub_ieee1275_find_options (void) grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_OFDISK_SDCARD_ONLY); } + + if (! grub_ieee1275_finddevice ("/rom/boot-rom", &bootrom)) + { + rc = grub_ieee1275_get_property (bootrom, "model", tmp, sizeof (tmp), 0); + if (rc >= 0 && !grub_strncmp (tmp, OHW, sizeof (OHW) - 1)) + { + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT); + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS); + } + } } +#undef SF +#undef OHW + void cmain (void); void cmain (void) diff --git a/term/ieee1275/ofconsole.c b/term/ieee1275/ofconsole.c index dbd0b6e97..b44950749 100644 --- a/term/ieee1275/ofconsole.c +++ b/term/ieee1275/ofconsole.c @@ -333,12 +333,15 @@ grub_ofconsole_init (void) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Cannot find stdin"); /* Initialize colors. */ - for (col = 0; col < 7; col++) - grub_ieee1275_set_color (stdout_ihandle, col, colors[col].red, - colors[col].green, colors[col].blue); + if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS)) + { + for (col = 0; col < 7; col++) + grub_ieee1275_set_color (stdout_ihandle, col, colors[col].red, + colors[col].green, colors[col].blue); - /* Set the right fg and bg colors. */ - grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL); + /* Set the right fg and bg colors. */ + grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL); + } return 0; }