grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ppc patch] heap memory allocation


From: Hollis Blanchard
Subject: [ppc patch] heap memory allocation
Date: Wed, 13 Oct 2004 22:37:56 -0500
User-agent: Mutt/1.5.6+20040722i

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  <address@hidden>

    * 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 <grub/fs.h>
 #include <grub/setjmp.h>
 #include <grub/env.h>
+#include <grub/misc.h>
 
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]