All of lore.kernel.org
 help / color / mirror / Atom feed
* [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

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.