From 028501a0e06877f14e2445f73a8969bced63c10f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 12 Feb 2011 10:22:55 +0300 Subject: [PATCH] Workaround yet another IEEE1275 bug. * include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): New enum value GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS. * grub-core/kern/ieee1275/mmap.c (grub_machine_mmap_iterate): Ignore adress_cells and size:cells if GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS is set. * grub-core/kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS on powermacs. --- ChangeLog | 12 ++++++++++++ grub-core/kern/ieee1275/cmain.c | 3 +++ grub-core/kern/ieee1275/mmap.c | 6 ++++++ include/grub/ieee1275/ieee1275.h | 6 ++++++ 4 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3a695b25a..72d718b08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2011-02-12 Vladimir Serbinenko + + Workaround yet another IEEE1275 bug. + + * include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): New enum value + GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS. + * grub-core/kern/ieee1275/mmap.c (grub_machine_mmap_iterate): Ignore + adress_cells and size:cells if GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS + is set. + * grub-core/kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set + GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS on powermacs. + 2011-02-12 Vladimir Serbinenko * grub-core/partmap/msdos.c (pc_partition_map_embed): Fix off by one diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c index 30eacbbdd..2fbe809b2 100644 --- a/grub-core/kern/ieee1275/cmain.c +++ b/grub-core/kern/ieee1275/cmain.c @@ -84,6 +84,9 @@ grub_ieee1275_find_options (void) if (rc >= 0 && !grub_strcmp (tmp, "Emulated PC")) is_qemu = 1; + if (grub_strncmp (tmp, "PowerMac", sizeof ("PowerMac") - 1) == 0) + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS); + if (is_smartfirmware) { /* Broken in all versions */ diff --git a/grub-core/kern/ieee1275/mmap.c b/grub-core/kern/ieee1275/mmap.c index 942e5a354..2e4e085bb 100644 --- a/grub-core/kern/ieee1275/mmap.c +++ b/grub-core/kern/ieee1275/mmap.c @@ -50,6 +50,12 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't examine /memory/available property"); + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS)) + { + address_cells = 1; + size_cells = 1; + } + /* Decode each entry and call `hook'. */ i = 0; available_size /= sizeof (grub_uint32_t); diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index 2592dd348..4c56cc20f 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -106,6 +106,12 @@ enum grub_ieee1275_flag /* OLPC / XO firmware has the cursor ON/OFF routines. */ GRUB_IEEE1275_FLAG_HAS_CURSORONOFF, + + /* Some PowerMacs claim to use 2 address cells but in fact use only 1. + Other PowerMacs claim to use only 1 and really do so. Always assume + 1 address cell is used on PowerMacs. + */ + GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS, }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);