2007-07-30 Robert Millan * include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): Add GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION flag. * kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options): Set GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION flag when running on an Efika (SmartFirmware). * kern/powerpc/ieee1275/init.c (grub_claim_heap): Fail gracefuly when addr > heaplimit. Use grub_printf instead of grub_error for error reporting, since grub_error doesn't work at this point of execution. When GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION was set, release hardcoded 0x4000:0xffc000 region. Index: include/grub/ieee1275/ieee1275.h =================================================================== RCS file: /sources/grub/grub2/include/grub/ieee1275/ieee1275.h,v retrieving revision 1.7 diff -u -r1.7 ieee1275.h --- include/grub/ieee1275/ieee1275.h 22 Jul 2007 09:05:10 -0000 1.7 +++ include/grub/ieee1275/ieee1275.h 30 Jul 2007 19:52:32 -0000 @@ -82,6 +82,10 @@ /* CodeGen firmware does not correctly implement "output-device output" */ GRUB_IEEE1275_FLAG_BROKEN_OUTPUT, + + /* Efika version of CodeGen firmware has an available memory region that + is not represented in /memory/available. */ + GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION, }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); Index: kern/powerpc/ieee1275/cmain.c =================================================================== RCS file: /sources/grub/grub2/kern/powerpc/ieee1275/cmain.c,v retrieving revision 1.9 diff -u -r1.9 cmain.c --- kern/powerpc/ieee1275/cmain.c 22 Jul 2007 09:16:51 -0000 1.9 +++ kern/powerpc/ieee1275/cmain.c 30 Jul 2007 19:52:32 -0000 @@ -63,9 +63,14 @@ rc = grub_ieee1275_get_property (openprom, "SmartFirmware-version", 0, 0, 0); if (rc >= 0) { + char model[32]; grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0); grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS); grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT); + + rc = grub_ieee1275_get_property (openprom, "model", &model, sizeof model, 0); + if ((rc >= 0) && !grub_strncmp (model, "EFIKA", 5)) + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION); } } Index: kern/powerpc/ieee1275/init.c =================================================================== RCS file: /sources/grub/grub2/kern/powerpc/ieee1275/init.c,v retrieving revision 1.31 diff -u -r1.31 init.c --- kern/powerpc/ieee1275/init.c 21 Jul 2007 23:32:27 -0000 1.31 +++ kern/powerpc/ieee1275/init.c 30 Jul 2007 19:52:32 -0000 @@ -121,6 +121,12 @@ len -= 1; /* Required for some firmware. */ /* Don't claim anything above `heaplimit'. */ + if (addr > heaplimit) + { + grub_printf ("Cannot claim heap above limit (0x%llx > 0x%lx)\n", addr, heaplimit); + return GRUB_ERR_OUT_OF_MEMORY; + } + if (addr + len > heaplimit) len = heaplimit - addr; @@ -128,15 +134,19 @@ { /* Claim and use it. */ if (grub_claimmap (addr, len) < 0) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Failed to claim heap at 0x%llx, len 0x%llx\n", - addr, len); + { + grub_printf ("Failed to claim heap at 0x%llx, len 0x%llx\n", addr, len); + return GRUB_ERR_OUT_OF_MEMORY; + } grub_mm_init_region ((void *) (grub_addr_t) addr, len); } return 0; } + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION)); + grub_ieee1275_release (0x4000, 0xffc000); + grub_available_iterate (heap_init); }