Hi,

This patch fix a few problem regarding the open hackware
implementation of qemu-ppc:

1, halts when calling grub_ieee1275_interpret
Add new flag GRUB_IEEE1275_FLAG_CANNOT_INTERPRET

2, no memory map, which cause out of memory error
Add new flag GRUB_IEEE1275_FLAG_FORCE_CLAIM, just claim what we need.

3. Can't understand ansi sequence.
Add new flag GRUB_IEEE1275_FLAG_NO_ANSI

-- 
Bean
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
index 5c06025..e73c516 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -89,6 +89,15 @@ enum grub_ieee1275_flag
 
   /* Open Hack'Ware stops when trying to set colors */
   GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS,
+
+  /* Open Hack'Ware stops when grub_ieee1275_interpret is used.  */
+  GRUB_IEEE1275_FLAG_CANNOT_INTERPRET,
+
+  /* Open Hack'Ware has no memory map, just claim what we need.  */
+  GRUB_IEEE1275_FLAG_FORCE_CLAIM,
+
+  /* Open Hack'Ware don't support the ANSI sequence.  */
+  GRUB_IEEE1275_FLAG_NO_ANSI,
 };
 
 extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);
diff --git a/kern/ieee1275/cmain.c b/kern/ieee1275/cmain.c
index 54a52b6..b5e2ba6 100644
--- a/kern/ieee1275/cmain.c
+++ b/kern/ieee1275/cmain.c
@@ -144,6 +144,9 @@ grub_ieee1275_find_options (void)
 	{
 	  grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT);
 	  grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS);
+	  grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_CANNOT_INTERPRET);
+	  grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_FORCE_CLAIM);
+	  grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_ANSI);
 	}
     }
 }
diff --git a/kern/ieee1275/ieee1275.c b/kern/ieee1275/ieee1275.c
index 135b30e..2605901 100644
--- a/kern/ieee1275/ieee1275.c
+++ b/kern/ieee1275/ieee1275.c
@@ -390,6 +390,9 @@ grub_ieee1275_interpret (const char *command, grub_ieee1275_cell_t *catch)
   }
   args;
 
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_INTERPRET))
+    return -1;
+
   INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1);
   args.command = (grub_ieee1275_cell_t) command;
 
diff --git a/kern/ieee1275/init.c b/kern/ieee1275/init.c
index b8f414b..93c0e68 100644
--- a/kern/ieee1275/init.c
+++ b/kern/ieee1275/init.c
@@ -171,7 +171,23 @@ static void grub_claim_heap (void)
     return 0;
   }
 
-  grub_available_iterate (heap_init);
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_INTERPRET))
+    {
+      grub_addr_t addr;
+      grub_uint32_t len;
+
+      addr = HEAP_MAX_ADDR - HEAP_MIN_SIZE;
+      len = HEAP_MIN_SIZE;
+
+      if (grub_claimmap (addr, len) < 0)
+        return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+                           "Failed to claim heap at 0x%llx, len 0x%llx\n",
+                           addr, len);
+
+      grub_mm_init_region ((void *) addr, len);
+    }
+  else
+    grub_available_iterate (heap_init);
 }
 
 #ifdef __i386__
diff --git a/term/ieee1275/ofconsole.c b/term/ieee1275/ofconsole.c
index 3b269ce..b9206a8 100644
--- a/term/ieee1275/ofconsole.c
+++ b/term/ieee1275/ofconsole.c
@@ -287,8 +287,11 @@ grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y)
   grub_curr_x = x;
   grub_curr_y = y;
 
-  grub_sprintf (s, "\e[%d;%dH", y + 1, x + 1);
-  grub_ofconsole_writeesc (s);
+  if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_ANSI))
+    {
+      grub_sprintf (s, "\e[%d;%dH", y + 1, x + 1);
+      grub_ofconsole_writeesc (s);
+    }
 }
 
 static void
@@ -297,8 +300,11 @@ grub_ofconsole_cls (void)
   /* Clear the screen.  Using serial console, screen(1) only recognizes the
    * ANSI escape sequence.  Using video console, Apple Open Firmware (version
    * 3.1.1) only recognizes the literal ^L.  So use both.  */
-  grub_ofconsole_writeesc ("\e[2J");
-  grub_gotoxy (0, 0);
+  if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_ANSI))
+    {
+      grub_ofconsole_writeesc ("\e[2J");
+      grub_gotoxy (0, 0);
+    }
 }
 
 static void
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to