From c8ee99d76e6c3809a1be4ba5b4a84f9aca494a4b Mon Sep 17 00:00:00 2001 From: robertmh Date: Sat, 5 Jan 2008 12:14:05 +0000 Subject: [PATCH] 2008-01-05 Robert Millan * kern/i386/loader.S (grub_linux_is_bzimage): New variable. (grub_linux_boot_zimage): Rename to ... (grub_linux_boot): ... this. (grub_linux_boot_bzimage): Merge with `grub_linux_boot_zimage'. (grub_linux_boot_zimage): Conditionalize zImage copy. * include/grub/i386/loader.h (grub_linux_is_bzimage): Add prototype. (grub_linux_boot_bzimage): Remove prototype. (grub_linux_boot_zimage): Rename to ... (grub_linux_boot): ... this. * loader/i386/pc/linux.c (big_linux): Replace with `grub_linux_is_bzimage'. (grub_linux_boot): Remove function. --- ChangeLog | 16 ++++++++++++++++ include/grub/i386/loader.h | 6 +++--- kern/i386/loader.S | 17 ++++++++++++----- loader/i386/pc/linux.c | 23 +++++------------------ 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d27decfc..554ac03b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2008-01-05 Robert Millan + + * kern/i386/loader.S (grub_linux_is_bzimage): New variable. + (grub_linux_boot_zimage): Rename to ... + (grub_linux_boot): ... this. + (grub_linux_boot_bzimage): Merge with `grub_linux_boot_zimage'. + (grub_linux_boot_zimage): Conditionalize zImage copy. + + * include/grub/i386/loader.h (grub_linux_is_bzimage): Add prototype. + (grub_linux_boot_bzimage): Remove prototype. + (grub_linux_boot_zimage): Rename to ... + (grub_linux_boot): ... this. + + * loader/i386/pc/linux.c (big_linux): Replace with `grub_linux_is_bzimage'. + (grub_linux_boot): Remove function. + 2008-01-05 Robert Millan * include/grub/normal.h (grub_env_write_color_normal): New prototype. diff --git a/include/grub/i386/loader.h b/include/grub/i386/loader.h index 6d9ecb9f0..45a1652e2 100644 --- a/include/grub/i386/loader.h +++ b/include/grub/i386/loader.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2004,2007 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2004,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,11 +26,11 @@ extern grub_uint32_t EXPORT_VAR(grub_linux_prot_size); extern char *EXPORT_VAR(grub_linux_tmp_addr); extern char *EXPORT_VAR(grub_linux_real_addr); +extern grub_int32_t EXPORT_VAR(grub_linux_is_bzimage); extern grub_addr_t EXPORT_VAR(grub_os_area_addr); extern grub_size_t EXPORT_VAR(grub_os_area_size); -void EXPORT_FUNC(grub_linux_boot_zimage) (void) __attribute__ ((noreturn)); -void EXPORT_FUNC(grub_linux_boot_bzimage) (void) __attribute__ ((noreturn)); +void EXPORT_FUNC(grub_linux_boot) (void) __attribute__ ((noreturn)); /* The asm part of the multiboot loader. */ void EXPORT_FUNC(grub_multiboot_real_boot) (grub_addr_t entry, diff --git a/kern/i386/loader.S b/kern/i386/loader.S index 9254c4330..266f4efea 100644 --- a/kern/i386/loader.S +++ b/kern/i386/loader.S @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,8 +56,17 @@ VARIABLE(grub_linux_tmp_addr) .long 0 VARIABLE(grub_linux_real_addr) .long 0 +VARIABLE(grub_linux_is_bzimage) + .long 0 -FUNCTION(grub_linux_boot_zimage) +FUNCTION(grub_linux_boot) + /* Must be done before zImage copy. */ + call EXT_C(grub_dl_unload_all) + + movl EXT_C(grub_linux_is_bzimage), %ebx + test %ebx, %ebx + jne bzimage + /* copy the kernel */ movl EXT_C(grub_linux_prot_size), %ecx addl $3, %ecx @@ -68,9 +77,7 @@ FUNCTION(grub_linux_boot_zimage) rep movsl -FUNCTION(grub_linux_boot_bzimage) - call EXT_C(grub_dl_unload_all) - +bzimage: movl EXT_C(grub_linux_real_addr), %ebx /* copy the real mode code */ diff --git a/loader/i386/pc/linux.c b/loader/i386/pc/linux.c index 818f762e3..d66fd2051 100644 --- a/loader/i386/pc/linux.c +++ b/loader/i386/pc/linux.c @@ -1,7 +1,7 @@ /* linux.c - boot Linux zImage or bzImage */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,22 +33,9 @@ static grub_dl_t my_mod; -static int big_linux; static grub_size_t linux_mem_size; static int loaded; -static grub_err_t -grub_linux_boot (void) -{ - if (big_linux) - grub_linux_boot_bzimage (); - else - grub_linux_boot_zimage (); - - /* Never reach here. */ - return GRUB_ERR_NONE; -} - static grub_err_t grub_linux_unload (void) { @@ -106,14 +93,14 @@ grub_rescue_cmd_linux (int argc, char *argv[]) goto fail; } - big_linux = 0; + grub_linux_is_bzimage = 0; setup_sects = lh.setup_sects; linux_mem_size = 0; if (lh.header == grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE) && grub_le_to_cpu16 (lh.version) >= 0x0200) { - big_linux = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL); + grub_linux_is_bzimage = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL); lh.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE; /* Put the real mode part at as a high location as possible. */ @@ -158,7 +145,7 @@ grub_rescue_cmd_linux (int argc, char *argv[]) grub_linux_tmp_addr = (char *) GRUB_LINUX_BZIMAGE_ADDR + prot_size; - if (! big_linux + if (! grub_linux_is_bzimage && prot_size > (grub_size_t) (grub_linux_real_addr - (char *) GRUB_LINUX_ZIMAGE_ADDR)) { @@ -177,7 +164,7 @@ grub_rescue_cmd_linux (int argc, char *argv[]) } grub_printf (" [Linux-%s, setup=0x%x, size=0x%x]\n", - big_linux ? "bzImage" : "zImage", real_size, prot_size); + grub_linux_is_bzimage ? "bzImage" : "zImage", real_size, prot_size); for (i = 1; i < argc; i++) if (grub_memcmp (argv[i], "vga=", 4) == 0)