]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2004-01-11 Yoshinori K. Okuji <okuji@enbug.org>
authorokuji <okuji@localhost>
Sun, 11 Jan 2004 09:38:04 +0000 (09:38 +0000)
committerokuji <okuji@localhost>
Sun, 11 Jan 2004 09:38:04 +0000 (09:38 +0000)
* stage2/terminfo.c (ti_set_term): Use a pointer to struct
terminfo instead to avoid GCC's bug, which inserts a reference
to memcpy implicitly.
(ti_get_term): Likewise.
All callers are fixed.

* stage2/terminfo.h (ti_set_term): Updated.
(ti_get_term): Likewise.

* stage2/shared.h (struct linux_kernel_header): New member,
initrd_max_address. Defined in the boot protocol 2.03 or higher.

* stage2/boot.c (load_initrd): If the boot protocol is greater
than or equal to 2.03, use the field ``initrd_max_address''
instead of LINUX_INITRD_MAX_ADDRESS.

ChangeLog
stage2/boot.c
stage2/builtins.c
stage2/shared.h
stage2/terminfo.c
stage2/terminfo.h

index 76fbf4ae8b5a9b1adcd3f10b0f9ffc7c8246bb61..326859ab4072887e8b842c426bdf557d45e5cf9a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2004-01-11  Yoshinori K. Okuji  <okuji@enbug.org>
+
+       * stage2/terminfo.c (ti_set_term): Use a pointer to struct
+       terminfo instead to avoid GCC's bug, which inserts a reference
+       to memcpy implicitly.
+       (ti_get_term): Likewise.
+       All callers are fixed.
+
+       * stage2/terminfo.h (ti_set_term): Updated.
+       (ti_get_term): Likewise.
+
+       * stage2/shared.h (struct linux_kernel_header): New member,
+       initrd_max_address. Defined in the boot protocol 2.03 or higher.
+
+       * stage2/boot.c (load_initrd): If the boot protocol is greater
+       than or equal to 2.03, use the field ``initrd_max_address''
+       instead of LINUX_INITRD_MAX_ADDRESS.
+
 2003-12-30  Yoshinori K. Okuji  <okuji@enbug.org>
 
        * stage2/fsys_ext2fs.c (ext2_is_fast_symlink): New function.
index 905cf0ec43e66f4e554cc0a684e69f9e328477fc..b49f9fe97ff5bf89523e52b0509c62e83ea64fe3 100644 (file)
@@ -1,7 +1,7 @@
 /* boot.c - load and bootstrap a kernel */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003  Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2003,2004  Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -786,6 +786,7 @@ load_initrd (char *initrd)
 {
   int len;
   unsigned long moveto;
+  unsigned long max_addr;
   struct linux_kernel_header *lh
     = (struct linux_kernel_header *) (cur_addr - LINUX_SETUP_MOVE_SIZE);
   
@@ -809,8 +810,10 @@ load_initrd (char *initrd)
     moveto = (mbi.mem_upper + 0x400) << 10;
   
   moveto = (moveto - len) & 0xfffff000;
-  if (moveto + len >= LINUX_INITRD_MAX_ADDRESS)
-    moveto = (LINUX_INITRD_MAX_ADDRESS - len) & 0xfffff000;
+  max_addr = (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0203
+             ? lh->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS);
+  if (moveto + len >= max_addr)
+    moveto = (max_addr - len) & 0xfffff000;
   
   /* XXX: Linux 2.3.xx has a bug in the memory range check, so avoid
      the last page.
index 1b5d1f21ec2cc565abfccecc8cabd5df24fd1d31..ca8e4e4a73c48568d456dd7ef03302dd834b6728 100644 (file)
@@ -1,7 +1,7 @@
 /* builtins.c - the GRUB builtin commands */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003  Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2003,2004  Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -4208,12 +4208,12 @@ terminfo_func (char *arg, int flags)
          return errnum;
        }
 
-      ti_set_term (term);
+      ti_set_term (&term);
     }
   else
     {
       /* No option specifies printing out current settings.  */
-      term = ti_get_term ();
+      ti_get_term (&term);
 
       grub_printf ("name=%s\n",
                   ti_escape_string (term.name));
index a69658038bf86ca3cb5b5027bb46658927402a4f..3965c740badfd9d2dbf4f917a00377adc25aabfd 100644 (file)
@@ -1,7 +1,7 @@
 /* shared.h - definitions used in all GRUB-specific code */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003  Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2003,2004  Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -403,6 +403,7 @@ struct linux_kernel_header
   unsigned short heap_end_ptr;         /* Free memory after setup end */
   unsigned short pad1;                 /* Unused */
   char *cmd_line_ptr;                  /* Points to the kernel command line */
+  unsigned long initrd_addr_max;       /* The highest address of initrd */
 } __attribute__ ((packed));
 
 /* Memory map address range descriptor used by GET_MMAP_ENTRY. */
index 438d53eff816a98874a2555a30e84f2ba841fa0c..c1c1575fcb5cc87c6f5703cf836e95ab014072b8 100644 (file)
@@ -1,7 +1,7 @@
 /* terminfo.c - read a terminfo entry from the command line */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2002  Free Software Foundation, Inc.
+ *  Copyright (C) 2002,2004  Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -245,15 +245,14 @@ ti_exit_standout_mode (void)
 
 /* set the current terminal emulation to use */
 void 
-ti_set_term (struct terminfo new)
+ti_set_term (const struct terminfo *new)
 {
-  term = new;
+  grub_memmove (&term, new, sizeof (struct terminfo));
 }
 
-/* return the current terminal emulation */
-struct terminfo
-ti_get_term(void)
+/* get the current terminal emulation */
+void
+ti_get_term(struct terminfo *copy)
 {
-  return term;
+  grub_memmove (copy, &term, sizeof (struct terminfo));
 }
-
index aad054a54212915341979801ca14a423a24e74f7..2e59761ea782e27601371313d99f434402d19a83 100644 (file)
@@ -1,7 +1,7 @@
 /* terminfo.h - read a terminfo entry from the command line */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2002,2003  Free Software Foundation, Inc.
+ *  Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -40,8 +40,8 @@ char *ti_escape_string (const char *in);
 char *ti_unescape_memory (const char *in, const char *end);
 char *ti_unescape_string (const char *in);
 
-void ti_set_term (struct terminfo term);
-struct terminfo ti_get_term (void);
+void ti_set_term (const struct terminfo *new);
+void ti_get_term (struct terminfo *copy);
 
 void ti_cursor_address (int x, int y);
 void ti_clear_screen (void);