* [PATCH] Running GRUB under qemu on PowerPC
@ 2008-01-16 8:19 Pavel Roskin
2008-01-16 10:40 ` Robert Millan
2008-01-23 11:07 ` Marco Gerards
0 siblings, 2 replies; 10+ messages in thread
From: Pavel Roskin @ 2008-01-16 8:19 UTC (permalink / raw)
To: grub-devel
Hello!
I'm very close to being able to run GRUB2 on an emulated PowerPC
machine. I haven't tried cross compiling. I compile GRUB on a
PowerPC system and run it there under qemu. This saves time, as it
allows to avoid lengthy reboots.
Only the latest qemu 0.9.1 appears to be working with bootable CD-ROMs
for PowerPC. The new qemu is not even in Fedora 8, so I had to
compile and install it locally.
A patch needs to be applied to the GRUB sources. First of all, the
firmware used in qemu (Open Hack'Ware) doesn't have an interpreter.
It knows how to interpret some commands, but not "output-device
output", which means that GRUB_IEEE1275_FLAG_BROKEN_OUTPUT has to be
set.
Also, setting colors doesn't work (i.e. the boot stops). I introduced
a separate flag to suppress color settings.
Here's how to make a bootable image. Start in an empty directory.
Make a subdirectory called "cdtree" with the "boot" subdirectory in
it. Copy kernel.elf from the GRUB directory to cdtree/boot.
Optionally, copy other files there. Create a file hfs.map in the
current directory. Here's its contents:
# EXTN XLate CREATOR TYPE Comment
kernel.elf Raw 'UNIX' 'tbxi' "bootstrap"
.cfg Raw 'UNIX' 'conf' "bootstrap"
To create the HFS/ISO image, run
genisoimage -hfs -part -map hfs.map -no-desktop -r -J \
-o bootcd.iso -hfs-bless cdtree/boot cdtree
The compressed image is available at
http://red-bean.com/proski/grub/bootcd.iso.bz2
To run it under qemu (PowerPC is not required!), run:
qemu-system-ppc -cdrom bootcd.iso -boot d
Please note that the "-hfs-bless" switch is extremely finicky and
tends to fail silently if there is any extra slash or something like
that. I could not find a way to bless the root directory with
genisoimage. That's why "boot" is used.
The unresolved problem is that the "/memory/available" property is not
available. I get the "grub rescue" prompt, but all commands fail with
"out of memory".
ChangeLog:
* include/grub/ieee1275/ieee1275.h: Introduce a flag for
broken color support, needed for Open Hack'Ware.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Recognize Open Hack'Ware.
* term/ieee1275/ofconsole.c (grub_ofconsole_init): Skip color
initialization for Open Hack'Ware.
diff --git a/include/grub/ieee1275/ieee1275.h
b/include/grub/ieee1275/ieee1275.h
index 57285d8..ddfe1b1 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -82,6 +82,9 @@ enum grub_ieee1275_flag
/* CodeGen firmware does not correctly implement "output-device output" */
GRUB_IEEE1275_FLAG_BROKEN_OUTPUT,
+
+ /* Open Hack'Ware stops while trying to set colors */
+ GRUB_IEEE1275_FLAG_BROKEN_COLORS,
};
extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum
grub_ieee1275_flag flag);
diff --git a/kern/powerpc/ieee1275/cmain.c b/kern/powerpc/ieee1275/cmain.c
index f560a03..c34c934 100644
--- a/kern/powerpc/ieee1275/cmain.c
+++ b/kern/powerpc/ieee1275/cmain.c
@@ -50,6 +50,7 @@ grub_ieee1275_find_options (void)
{
grub_ieee1275_phandle_t options;
grub_ieee1275_phandle_t openprom;
+ grub_ieee1275_phandle_t bootrom;
int rc;
int realmode = 0;
char tmp[32];
@@ -100,6 +101,16 @@ grub_ieee1275_find_options (void)
}
}
}
+
+ if (! grub_ieee1275_finddevice ("/rom/boot-rom", &bootrom)) {
+ rc = grub_ieee1275_get_property (bootrom, "model",
+ tmp, sizeof (tmp), 0);
+#define OHW "PPC Open Hack'Ware"
+ if (rc >= 0 && !grub_strncmp (tmp, OHW, sizeof (OHW) - 1)) {
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT);
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_COLORS);
+ }
+ }
}
void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
diff --git a/term/ieee1275/ofconsole.c b/term/ieee1275/ofconsole.c
index 845f198..9246319 100644
--- a/term/ieee1275/ofconsole.c
+++ b/term/ieee1275/ofconsole.c
@@ -338,12 +338,14 @@ grub_ofconsole_init (void)
stdin_ihandle = grub_ieee1275_decode_int_4 (data);
/* Initialize colors. */
- for (col = 0; col < 7; col++)
- grub_ieee1275_set_color (stdout_ihandle, col, colors[col].red,
- colors[col].green, colors[col].blue);
-
- /* Set the right fg and bg colors. */
- grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL);
+ if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_COLORS)) {
+ for (col = 0; col < 7; col++)
+ grub_ieee1275_set_color (stdout_ihandle, col, colors[col].red,
+ colors[col].green, colors[col].blue);
+
+ /* Set the right fg and bg colors. */
+ grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL);
+ }
return 0;
}
--
Regards,
Pavel Roskin
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] Running GRUB under qemu on PowerPC
2008-01-16 8:19 [PATCH] Running GRUB under qemu on PowerPC Pavel Roskin
@ 2008-01-16 10:40 ` Robert Millan
2008-01-16 18:22 ` Pavel Roskin
2008-01-23 11:07 ` Marco Gerards
1 sibling, 1 reply; 10+ messages in thread
From: Robert Millan @ 2008-01-16 10:40 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, Jan 16, 2008 at 03:19:49AM -0500, Pavel Roskin wrote:
>
> The unresolved problem is that the "/memory/available" property is not
> available. I get the "grub rescue" prompt, but all commands fail with
> "out of memory".
Does this mean all memory is ours to deal with as pleased? :-)
I suggest you try poking it by trying to read all existing memory in your
address space.
> + if (! grub_ieee1275_finddevice ("/rom/boot-rom", &bootrom)) {
> + rc = grub_ieee1275_get_property (bootrom, "model",
> + tmp, sizeof (tmp), 0);
> +#define OHW "PPC Open Hack'Ware"
> + if (rc >= 0 && !grub_strncmp (tmp, OHW, sizeof (OHW) - 1)) {
> + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT);
> + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_COLORS);
> + }
> + }
> }
Please add a newline (and double-space indent) before '{'.
> - /* Set the right fg and bg colors. */
> - grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL);
> + if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_COLORS)) {
Same here.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] Running GRUB under qemu on PowerPC
2008-01-16 10:40 ` Robert Millan
@ 2008-01-16 18:22 ` Pavel Roskin
2008-01-16 19:33 ` Robert Millan
0 siblings, 1 reply; 10+ messages in thread
From: Pavel Roskin @ 2008-01-16 18:22 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, 2008-01-16 at 11:40 +0100, Robert Millan wrote:
> On Wed, Jan 16, 2008 at 03:19:49AM -0500, Pavel Roskin wrote:
> >
> > The unresolved problem is that the "/memory/available" property is not
> > available. I get the "grub rescue" prompt, but all commands fail with
> > "out of memory".
>
> Does this mean all memory is ours to deal with as pleased? :-)
>
> I suggest you try poking it by trying to read all existing memory in your
> address space.
I guess the simplest approach would be to assume that we have a certain
amount of memory that would be enough for GRUB. The issue with
"/memory/available" is known to Open Hack'Ware developers:
http://perso.magic.fr/l_indien/OpenHackWare/0.4-pre2/README
I guess they didn't implement a decent memory probe.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Running GRUB under qemu on PowerPC
2008-01-16 18:22 ` Pavel Roskin
@ 2008-01-16 19:33 ` Robert Millan
2008-01-16 21:52 ` Pavel Roskin
0 siblings, 1 reply; 10+ messages in thread
From: Robert Millan @ 2008-01-16 19:33 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, Jan 16, 2008 at 01:22:48PM -0500, Pavel Roskin wrote:
>
> On Wed, 2008-01-16 at 11:40 +0100, Robert Millan wrote:
> > On Wed, Jan 16, 2008 at 03:19:49AM -0500, Pavel Roskin wrote:
> > >
> > > The unresolved problem is that the "/memory/available" property is not
> > > available. I get the "grub rescue" prompt, but all commands fail with
> > > "out of memory".
> >
> > Does this mean all memory is ours to deal with as pleased? :-)
> >
> > I suggest you try poking it by trying to read all existing memory in your
> > address space.
>
> I guess the simplest approach would be to assume that we have a certain
> amount of memory that would be enough for GRUB.
What a mess. What does Linux do? They have to support callbacks to get the
memory map, so it can't just claim everything.
In any case, if you have to make this assumption, considering reusing the
HEAP_MIN_SIZE macro, which has the same meaning.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Running GRUB under qemu on PowerPC
2008-01-16 19:33 ` Robert Millan
@ 2008-01-16 21:52 ` Pavel Roskin
2008-01-16 22:51 ` Robert Millan
0 siblings, 1 reply; 10+ messages in thread
From: Pavel Roskin @ 2008-01-16 21:52 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, 2008-01-16 at 20:33 +0100, Robert Millan wrote:
> On Wed, Jan 16, 2008 at 01:22:48PM -0500, Pavel Roskin wrote:
> >
> > I guess the simplest approach would be to assume that we have a certain
> > amount of memory that would be enough for GRUB.
>
> What a mess. What does Linux do? They have to support callbacks to get the
> memory map, so it can't just claim everything.
I don't see any references to "available" in the Linux code, except for
some exotic machines. Neither does yaboot use anything like that.
yaboot loads under qemu, but hangs trying to load the Linux kernel (both
extracted from the Fedora 8 rescue disk), so I don't know if Linux would
boot.
It seems to me that Linux uses "#size-cells" and "#address-cells" (see
drivers/of/base.c and arch/powerpc/kernel/prom_parse.c)
As for yaboot, I have no idea. It gets a handle for "/memory" but never
uses it. I don't see any references to "cells".
> In any case, if you have to make this assumption, considering reusing the
> HEAP_MIN_SIZE macro, which has the same meaning.
OK, I'll try.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Running GRUB under qemu on PowerPC
2008-01-16 21:52 ` Pavel Roskin
@ 2008-01-16 22:51 ` Robert Millan
2008-01-18 5:07 ` Pavel Roskin
0 siblings, 1 reply; 10+ messages in thread
From: Robert Millan @ 2008-01-16 22:51 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, Jan 16, 2008 at 04:52:46PM -0500, Pavel Roskin wrote:
>
> It seems to me that Linux uses "#size-cells" and "#address-cells" (see
> drivers/of/base.c and arch/powerpc/kernel/prom_parse.c)
We use "#size-cells" and "#address-cells" too, but they aren't useful by
themselves. They describe the layout of /memory/available.
See kern/powerpc/ieee1275/openfw.c:grub_available_iterate()
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Running GRUB under qemu on PowerPC
2008-01-16 22:51 ` Robert Millan
@ 2008-01-18 5:07 ` Pavel Roskin
2008-01-18 15:05 ` Robert Millan
0 siblings, 1 reply; 10+ messages in thread
From: Pavel Roskin @ 2008-01-18 5:07 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, 2008-01-16 at 23:51 +0100, Robert Millan wrote:
> On Wed, Jan 16, 2008 at 04:52:46PM -0500, Pavel Roskin wrote:
> >
> > It seems to me that Linux uses "#size-cells" and "#address-cells" (see
> > drivers/of/base.c and arch/powerpc/kernel/prom_parse.c)
>
> We use "#size-cells" and "#address-cells" too, but they aren't useful by
> themselves. They describe the layout of /memory/available.
>
> See kern/powerpc/ieee1275/openfw.c:grub_available_iterate()
As I understand, Linux uses "ranges", although it's hard to be sure.
There are many references to "ranges" in Linux sources under
arch/powerpc, although many of them are pertinent to buses rather than
to the system memory. Open Hack'Ware provides "ranges" for the memory.
As for yaboot, it uses "claim" both for its needs and for loading the
kernel. And that's probably what GRUB could do.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Running GRUB under qemu on PowerPC
2008-01-18 5:07 ` Pavel Roskin
@ 2008-01-18 15:05 ` Robert Millan
0 siblings, 0 replies; 10+ messages in thread
From: Robert Millan @ 2008-01-18 15:05 UTC (permalink / raw)
To: The development of GRUB 2
On Fri, Jan 18, 2008 at 12:07:31AM -0500, Pavel Roskin wrote:
>
> On Wed, 2008-01-16 at 23:51 +0100, Robert Millan wrote:
> > On Wed, Jan 16, 2008 at 04:52:46PM -0500, Pavel Roskin wrote:
> > >
> > > It seems to me that Linux uses "#size-cells" and "#address-cells" (see
> > > drivers/of/base.c and arch/powerpc/kernel/prom_parse.c)
> >
> > We use "#size-cells" and "#address-cells" too, but they aren't useful by
> > themselves. They describe the layout of /memory/available.
> >
> > See kern/powerpc/ieee1275/openfw.c:grub_available_iterate()
>
> As I understand, Linux uses "ranges", although it's hard to be sure.
> There are many references to "ranges" in Linux sources under
> arch/powerpc, although many of them are pertinent to buses rather than
> to the system memory. Open Hack'Ware provides "ranges" for the memory.
/memory/available is organized in ranges (address, whose length is described
by #address-cells, and size, whose length is described by #size-cells). Is
that what you mean?
> As for yaboot, it uses "claim" both for its needs and for loading the
> kernel. And that's probably what GRUB could do.
It is:
loader/powerpc/ieee1275/linux.c: found_addr = grub_claimmap (linux_addr, linux_size);
loader/powerpc/ieee1275/multiboot2.c: rc = grub_claimmap (phdr->p_paddr, phdr->p_memsz);
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Running GRUB under qemu on PowerPC
2008-01-16 8:19 [PATCH] Running GRUB under qemu on PowerPC Pavel Roskin
2008-01-16 10:40 ` Robert Millan
@ 2008-01-23 11:07 ` Marco Gerards
2008-01-23 11:22 ` Robert Millan
1 sibling, 1 reply; 10+ messages in thread
From: Marco Gerards @ 2008-01-23 11:07 UTC (permalink / raw)
To: The development of GRUB 2
Pavel Roskin <proski@gnu.org> writes:
Hi,
[...]
> ChangeLog:
>
> * include/grub/ieee1275/ieee1275.h: Introduce a flag for
> broken color support, needed for Open Hack'Ware.
> * kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
> Recognize Open Hack'Ware.
> * term/ieee1275/ofconsole.c (grub_ofconsole_init): Skip color
> initialization for Open Hack'Ware.
This looks fine to me. Robert, what do you think about this patch
specifically? I see no reason why this can't be committed, but I am
not working on the PPC port lately.
--
Marco
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Running GRUB under qemu on PowerPC
2008-01-23 11:07 ` Marco Gerards
@ 2008-01-23 11:22 ` Robert Millan
0 siblings, 0 replies; 10+ messages in thread
From: Robert Millan @ 2008-01-23 11:22 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, Jan 23, 2008 at 12:07:57PM +0100, Marco Gerards wrote:
> Pavel Roskin <proski@gnu.org> writes:
>
> Hi,
>
> [...]
>
> > ChangeLog:
> >
> > * include/grub/ieee1275/ieee1275.h: Introduce a flag for
> > broken color support, needed for Open Hack'Ware.
> > * kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
> > Recognize Open Hack'Ware.
> > * term/ieee1275/ofconsole.c (grub_ofconsole_init): Skip color
> > initialization for Open Hack'Ware.
>
> This looks fine to me. Robert, what do you think about this patch
> specifically? I see no reason why this can't be committed, but I am
> not working on the PPC port lately.
It looks mostly fine to me. I have 3 suggestions:
> + if (! grub_ieee1275_finddevice ("/rom/boot-rom", &bootrom)) {
> + rc = grub_ieee1275_get_property (bootrom, "model",
> + tmp, sizeof (tmp), 0);
> +#define OHW "PPC Open Hack'Ware"
> + if (rc >= 0 && !grub_strncmp (tmp, OHW, sizeof (OHW) - 1)) {
I think it's better to #undef OHW after using it, just in case.
> - /* Set the right fg and bg colors. */
> - grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL);
> + if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_COLORS)) {
Perhaps GRUB_IEEE1275_FLAG_BROKEN_COLORS could be made more descriptive
(in the future we might find other, new, amusing ways in which colors can
break! :-)). How about GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS ?
Also, GRUB code style puts a newline before opening brackets.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-01-23 11:24 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-16 8:19 [PATCH] Running GRUB under qemu on PowerPC Pavel Roskin
2008-01-16 10:40 ` Robert Millan
2008-01-16 18:22 ` Pavel Roskin
2008-01-16 19:33 ` Robert Millan
2008-01-16 21:52 ` Pavel Roskin
2008-01-16 22:51 ` Robert Millan
2008-01-18 5:07 ` Pavel Roskin
2008-01-18 15:05 ` Robert Millan
2008-01-23 11:07 ` Marco Gerards
2008-01-23 11:22 ` Robert Millan
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.