From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.33) id 1CHweY-0007tE-6c for mharc-grub-devel@gnu.org; Wed, 13 Oct 2004 23:51:46 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CHweV-0007t8-VN for grub-devel@gnu.org; Wed, 13 Oct 2004 23:51:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CHweV-0007sw-GT for grub-devel@gnu.org; Wed, 13 Oct 2004 23:51:43 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CHweV-0007st-Dc for grub-devel@gnu.org; Wed, 13 Oct 2004 23:51:43 -0400 Received: from [207.217.120.49] (helo=scaup.mail.pas.earthlink.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CHwX1-0003u7-At for grub-devel@gnu.org; Wed, 13 Oct 2004 23:43:59 -0400 Received: from user-0vvde2s.cable.mindspring.com ([63.246.184.92] helo=miracle) by scaup.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 1CHwX0-0006XY-00 for grub-devel@gnu.org; Wed, 13 Oct 2004 20:43:58 -0700 Received: from hollis by miracle with local (Exim 3.36 #1 (Debian)) id 1CHwRA-0001bU-00 for ; Wed, 13 Oct 2004 22:37:56 -0500 Date: Wed, 13 Oct 2004 22:37:56 -0500 To: grub-devel@gnu.org Message-ID: <20041014033756.GA6157@miracle> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040722i From: Hollis Blanchard Subject: [ppc patch] heap memory allocation X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Oct 2004 03:51:44 -0000 Ok, this is much simpler than the last patch; it just changes which hardcoded region of memory we use. These are the areas I think we need to watch out for (from memory, so not authoritative): 0-16 KB exception handlers 4-5 MB Old World Mac firmware 8-? MB some older RS/6000 12-20 MB newer RS/6000 / pSeries 20+-32 MB other bits on pSeries, like NVRAM Our link base was chosen at 2MB, which is working fine. This patch uses all the memory from the exception handlers (which may or may not be claimed by firmware) to the link base. That should give us plenty of room for the GRUB heap, while also leaving as much as possible open for the OSs to be loaded at. I've tested this by getting to the GRUB command line on Old World Mac, New World Mac, and CodeGen firmware (briQ). Ok? -Hollis 2004-10-13 Hollis Blanchard * include/grub/powerpc/ieee1275/ieee1275.h (abort): Add function prototype. * kern/powerpc/ieee1275/init.c (grub_machine_init): Call grub_console_init first. Change the memory range used for grub_ieee1275_claim and grub_mm_init_region. Print an error message if the claim fails. Index: include/grub/powerpc/ieee1275/ieee1275.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/ieee1275.h,v retrieving revision 1.6 diff -u -r1.6 ieee1275.h --- include/grub/powerpc/ieee1275/ieee1275.h 12 Oct 2004 03:56:10 -0000 1.6 +++ include/grub/powerpc/ieee1275/ieee1275.h 14 Oct 2004 02:53:37 -0000 @@ -102,5 +102,7 @@ grub_err_t EXPORT_FUNC(grub_devalias_iterate) (int (*hook) (struct grub_ieee1275_devalias *alias)); +void EXPORT_FUNC(abort) (void); + #endif /* ! GRUB_IEEE1275_MACHINE_HEADER */ Index: kern/powerpc/ieee1275/init.c =================================================================== RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/init.c,v retrieving revision 1.6 diff -u -r1.6 init.c --- kern/powerpc/ieee1275/init.c 3 Oct 2004 09:19:10 -0000 1.6 +++ kern/powerpc/ieee1275/init.c 14 Oct 2004 02:53:37 -0000 @@ -28,6 +28,7 @@ #include #include #include +#include void grub_ofdisk_init (void); void grub_console_init (void); @@ -49,11 +50,25 @@ void grub_machine_init (void) { - if (grub_ieee1275_claim (0x300000, 0x150000, 0, 0) == -1) - abort (); /* Damn, we are in trouble! */ - - /* The memory allocations were copied from yaboot. */ - grub_mm_init_region ((void *) 0x300000, 0x150000); + extern char _start; + grub_addr_t heap_start; + grub_addr_t heap_len; + + grub_console_init (); + + /* Apple OF 1.0.5 reserves 0x4000 bytes for the exception handlers. */ + heap_start = 0x4000; + /* Apple OF 3.1.1 reserves an extra 0x1000 bytes below the load address + * of an ELF file. */ + heap_len = (grub_addr_t) &_start - 0x1000 - heap_start; + + if (grub_ieee1275_claim (heap_start, heap_len, 0, 0)) + { + grub_printf ("Failed to claim heap at 0x%x, len 0x%x\n", heap_start, + heap_len); + abort (); + } + grub_mm_init_region ((void *) heap_start, heap_len); /* XXX: Loadable modules are not supported. */ grub_env_set ("prefix", ""); @@ -64,7 +79,6 @@ grub_linux_init (); grub_linux_normal_init (); grub_ofdisk_init (); - grub_console_init (); } int