* [ppc patch] heap memory allocation
@ 2004-10-14 3:37 Hollis Blanchard
2004-10-14 10:10 ` Johan Rydberg
2004-10-14 11:23 ` Marco Gerards
0 siblings, 2 replies; 3+ messages in thread
From: Hollis Blanchard @ 2004-10-14 3:37 UTC (permalink / raw)
To: grub-devel
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 <hollis@penguinppc.org>
* 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ppc patch] heap memory allocation
2004-10-14 3:37 [ppc patch] heap memory allocation Hollis Blanchard
@ 2004-10-14 10:10 ` Johan Rydberg
2004-10-14 11:23 ` Marco Gerards
1 sibling, 0 replies; 3+ messages in thread
From: Johan Rydberg @ 2004-10-14 10:10 UTC (permalink / raw)
To: The development of GRUB 2
Hollis Blanchard <hollis@penguinppc.org> writes:
> [...]
> I've tested this by getting to the GRUB command line on Old World Mac, New
> World Mac, and CodeGen firmware (briQ).
>
> Ok?
I won't address the technical issues in this mail.
> -Hollis
>
> 2004-10-13 Hollis Blanchard <hollis@penguinppc.org>
>
> * 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.
Looking good Hollis in respect to GCS. There's just one thing:
> + /* 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;
Comments are written without extra prefix stars on new lines.
Like this:
/* Apple OF 3.1.1 reserves an extra 0x1000 bytes below the load address
of an ELF file. */
Other than that, it looks fine to me. But it's up to the others
to accept the patch.
I'm pretty sure Marco could make this little change himself if he
chooses to accept the patch.
Best Regards.
~j
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ppc patch] heap memory allocation
2004-10-14 3:37 [ppc patch] heap memory allocation Hollis Blanchard
2004-10-14 10:10 ` Johan Rydberg
@ 2004-10-14 11:23 ` Marco Gerards
1 sibling, 0 replies; 3+ messages in thread
From: Marco Gerards @ 2004-10-14 11:23 UTC (permalink / raw)
To: The development of GRUB 2
Hollis Blanchard <hollis@penguinppc.org> writes:
> 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.
This is better then what is done now.
> * 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.
You forgot to mention that grub/misc.h is included. Can you add
"Include <grub/misc.h>." here?
If you make the change that Johan mentioned, it can go in as far as I
am concerned.
Thanks,
Marco
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-10-14 11:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-14 3:37 [ppc patch] heap memory allocation Hollis Blanchard
2004-10-14 10:10 ` Johan Rydberg
2004-10-14 11:23 ` Marco Gerards
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.