]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2008-07-02 Bean <bean123ch@gmail.com>
authorbean <bean@localhost>
Wed, 2 Jul 2008 07:38:46 +0000 (07:38 +0000)
committerbean <bean@localhost>
Wed, 2 Jul 2008 07:38:46 +0000 (07:38 +0000)
* include/grub/ieee1275.h (grub_ieee1275_flag): New constant
GRUB_IEEE1275_FLAG_CANNOT_INTERPRET, GRUB_IEEE1275_FLAG_FORCE_CLAIM
and GRUB_IEEE1275_FLAG_NO_ANSI.

* kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set flag
GRUB_IEEE1275_FLAG_CANNOT_INTERPRET, GRUB_IEEE1275_FLAG_FORCE_CLAIM
and GRUB_IEEE1275_FLAG_NO_ANSI for Open Hackware.

* kern/ieee1275/ieee1275.c (grub_ieee1275_interpret): Return
immediately if GRUB_IEEE1275_FLAG_CANNOT_INTERPRET is set.

* kern/ieee1275/init.c (grub_claim_heap): Claim memory directly if
GRUB_IEEE1275_FLAG_FORCE_CLAIM is set.

* term/ieee1275/ofconsole.c (grub_ofconsole_writeesc): Don't output
esc sequence on non ANSI terminal.
(grub_ofconsole_gotoxy): Emulate backspace key on non ANSI terminal.

* util/elf/grub-mkimage.c (add_segments): Move ELF header to the
beginning of file.

ChangeLog
include/grub/ieee1275/ieee1275.h
kern/ieee1275/cmain.c
kern/ieee1275/ieee1275.c
kern/ieee1275/init.c
term/ieee1275/ofconsole.c
util/elf/grub-mkimage.c

index f27f59b6fe1d77c05f077cff9c08ce239ed8e464..24d486e350d7b247bf838d8aace0a1e6d95b4725 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2008-07-02  Bean  <bean123ch@gmail.com>
+
+       * include/grub/ieee1275.h (grub_ieee1275_flag): New constant
+       GRUB_IEEE1275_FLAG_CANNOT_INTERPRET, GRUB_IEEE1275_FLAG_FORCE_CLAIM
+       and GRUB_IEEE1275_FLAG_NO_ANSI.
+
+       * kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set flag
+       GRUB_IEEE1275_FLAG_CANNOT_INTERPRET, GRUB_IEEE1275_FLAG_FORCE_CLAIM
+       and GRUB_IEEE1275_FLAG_NO_ANSI for Open Hackware.
+
+       * kern/ieee1275/ieee1275.c (grub_ieee1275_interpret): Return
+       immediately if GRUB_IEEE1275_FLAG_CANNOT_INTERPRET is set.
+
+       * kern/ieee1275/init.c (grub_claim_heap): Claim memory directly if
+       GRUB_IEEE1275_FLAG_FORCE_CLAIM is set.
+
+       * term/ieee1275/ofconsole.c (grub_ofconsole_writeesc): Don't output
+       esc sequence on non ANSI terminal.
+       (grub_ofconsole_gotoxy): Emulate backspace key on non ANSI terminal.
+
+       * util/elf/grub-mkimage.c (add_segments): Move ELF header to the
+       beginning of file.
+
 2008-07-02  Bean  <bean123ch@gmail.com>
 
        * conf/common.rmk (bin_UTILITIES): Add grub-editenv.
index 5c06025ca356e30a4b49ac43dc2a982a871dc80a..6f8f1ccb83c843efed3ca733313c5b5e443c5d1e 100644 (file)
@@ -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);
index 54a52b69411c4bf7e0dfe57d38fbd4bebcd9bf0f..b5e2ba66b40416533ddaa36b36cb69ac95ece0f9 100644 (file)
@@ -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);
        }
     }
 }
index 135b30e7f81034d3e40b9d65dce0d7fa2302a24e..2e88976698b13251dfe8959c5f22333b626d2b50 100644 (file)
@@ -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;
 
index b8f414b1d0ae3fe997ea3c0b6166b7d394876f09..26aca778eb12e579c988a894df0be0636581932c 100644 (file)
@@ -171,7 +171,10 @@ static void grub_claim_heap (void)
     return 0;
   }
 
-  grub_available_iterate (heap_init);
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_INTERPRET))
+    heap_init (HEAP_MAX_ADDR - HEAP_MIN_SIZE, HEAP_MIN_SIZE);
+  else
+    grub_available_iterate (heap_init);
 }
 
 #ifdef __i386__
index dd60de6f2f6dbb2ce086ea2edfb767476e9065a8..5d701ca64de3c772f8fc0b0dd82740d42035a146 100644 (file)
@@ -63,6 +63,9 @@ static grub_uint8_t grub_ofconsole_highlight_color = 0x70;
 static void
 grub_ofconsole_writeesc (const char *str)
 {
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_ANSI))
+    return;
+
   while (*str)
     {
       char chr = *(str++);
@@ -284,11 +287,28 @@ static void
 grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y)
 {
   char s[11]; /* 5 + 3 + 3.  */
-  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_curr_x = x;
+      grub_curr_y = y;
+
+      grub_sprintf (s, "\e[%d;%dH", y + 1, x + 1);
+      grub_ofconsole_writeesc (s);
+    }
+  else
+    {
+      if ((y == grub_curr_y) && (x == grub_curr_x - 1))
+        {
+          char chr;
+
+          chr = '\b';
+          grub_ieee1275_write (stdout_ihandle, &chr, 1, 0);
+        }
+
+      grub_curr_x = x;
+      grub_curr_y = y;
+    }
 }
 
 static void
index ca138dd5d77d932dad98f6ce22db10ab233f9068..43c873e5f7bbbc91338ab611aaad5c99a3e16982 100644 (file)
@@ -166,8 +166,8 @@ add_segments (char *dir, FILE *out, int chrp, char *mods[])
   FILE *in;
   char *kernel_path;
   grub_addr_t grub_end = 0;
-  off_t phdroff;
-  int i;
+  off_t offset;
+  int i, phdr_size;
 
   /* Read ELF header.  */
   kernel_path = grub_util_get_path (dir, "kernel.elf");
@@ -177,8 +177,21 @@ add_segments (char *dir, FILE *out, int chrp, char *mods[])
 
   grub_util_read_at (&ehdr, sizeof (ehdr), 0, in);
   
-  phdrs = xmalloc (grub_target_to_host16 (ehdr.e_phentsize)
-                  * (grub_target_to_host16 (ehdr.e_phnum) + 2));
+  offset = ALIGN_UP (sizeof (ehdr), sizeof (long));
+  ehdr.e_phoff = grub_host_to_target32 (offset);
+
+  phdr_size = (grub_target_to_host16 (ehdr.e_phentsize) *
+               grub_target_to_host16 (ehdr.e_phnum));
+
+  if (mods[0] != NULL)
+    phdr_size += grub_target_to_host16 (ehdr.e_phentsize);
+
+  if (chrp)
+    phdr_size += grub_target_to_host16 (ehdr.e_phentsize);
+
+  phdrs = xmalloc (phdr_size);
+  offset += ALIGN_UP (phdr_size, sizeof (long));
+
   /* Copy all existing segments.  */
   for (i = 0; i < grub_target_to_host16 (ehdr.e_phnum); i++)
     {
@@ -207,8 +220,11 @@ add_segments (char *dir, FILE *out, int chrp, char *mods[])
   
       grub_util_read_at (segment_img, grub_target_to_host32 (phdr->p_filesz),
                         grub_target_to_host32 (phdr->p_offset), in);
+
+      phdr->p_offset = grub_host_to_target32 (offset);
       grub_util_write_image_at (segment_img, grub_target_to_host32 (phdr->p_filesz),
-                               grub_target_to_host32 (phdr->p_offset), out);
+                               offset, out);
+      offset += ALIGN_UP (grub_target_to_host32 (phdr->p_filesz), sizeof (long));
 
       free (segment_img);
     }
@@ -249,14 +265,10 @@ add_segments (char *dir, FILE *out, int chrp, char *mods[])
   ehdr.e_shnum = 0;
   ehdr.e_shstrndx = 0;
 
-  /* Append entire segment table to the file.  */
-  phdroff = ALIGN_UP (grub_util_get_fp_size (out), sizeof (long));
-  grub_util_write_image_at (phdrs, grub_target_to_host16 (ehdr.e_phentsize)
-                           * grub_target_to_host16 (ehdr.e_phnum), phdroff,
-                           out);
+  /* Write entire segment table to the file.  */
+  grub_util_write_image_at (phdrs, phdr_size, grub_target_to_host32 (ehdr.e_phoff), out);
 
   /* Write ELF header.  */
-  ehdr.e_phoff = grub_host_to_target32 (phdroff);
   grub_util_write_image_at (&ehdr, sizeof (ehdr), 0, out);
 
   free (phdrs);