diff --git a/ChangeLog b/ChangeLog index 76fbf4ae8..326859ab4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2004-01-11 Yoshinori K. Okuji + + * 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 * stage2/fsys_ext2fs.c (ext2_is_fast_symlink): New function. diff --git a/stage2/boot.c b/stage2/boot.c index 905cf0ec4..b49f9fe97 100644 --- a/stage2/boot.c +++ b/stage2/boot.c @@ -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. diff --git a/stage2/builtins.c b/stage2/builtins.c index 1b5d1f21e..ca8e4e4a7 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -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)); diff --git a/stage2/shared.h b/stage2/shared.h index a69658038..3965c740b 100644 --- a/stage2/shared.h +++ b/stage2/shared.h @@ -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. */ diff --git a/stage2/terminfo.c b/stage2/terminfo.c index 438d53eff..c1c1575fc 100644 --- a/stage2/terminfo.c +++ b/stage2/terminfo.c @@ -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)); } - diff --git a/stage2/terminfo.h b/stage2/terminfo.h index aad054a54..2e59761ea 100644 --- a/stage2/terminfo.h +++ b/stage2/terminfo.h @@ -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);