~ilya-yanok/ubuntu/precise/grub2/fix-for-948716

« back to all changes in this revision

Viewing changes to loader/i386/pc/linux.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Millan
  • Date: 2008-01-28 00:01:11 UTC
  • mto: (17.3.1 squeeze) (1.9.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080128000111-0764agvqzg601o1d
Tags: upstream-1.95+20080128
ImportĀ upstreamĀ versionĀ 1.95+20080128

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* linux.c - boot Linux zImage or bzImage */
2
2
/*
3
3
 *  GRUB  --  GRand Unified Bootloader
4
 
 *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007  Free Software Foundation, Inc.
 
4
 *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008  Free Software Foundation, Inc.
5
5
 *
6
6
 *  GRUB is free software: you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
33
33
 
34
34
static grub_dl_t my_mod;
35
35
 
36
 
static int big_linux;
37
36
static grub_size_t linux_mem_size;
38
37
static int loaded;
39
38
 
40
39
static grub_err_t
41
 
grub_linux_boot (void)
42
 
{
43
 
  if (big_linux)
44
 
    grub_linux_boot_bzimage ();
45
 
  else
46
 
    grub_linux_boot_zimage ();
47
 
 
48
 
  /* Never reach here.  */
49
 
  return GRUB_ERR_NONE;
50
 
}
51
 
 
52
 
static grub_err_t
53
40
grub_linux_unload (void)
54
41
{
55
42
  grub_dl_unref (my_mod);
106
93
      goto fail;
107
94
    }
108
95
 
109
 
  big_linux = 0;
 
96
  grub_linux_is_bzimage = 0;
110
97
  setup_sects = lh.setup_sects;
111
98
  linux_mem_size = 0;
112
99
  
113
100
  if (lh.header == grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE)
114
101
      && grub_le_to_cpu16 (lh.version) >= 0x0200)
115
102
    {
116
 
      big_linux = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL);
 
103
      grub_linux_is_bzimage = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL);
117
104
      lh.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE;
118
105
      
119
106
      /* Put the real mode part at as a high location as possible.  */
158
145
  
159
146
  grub_linux_tmp_addr = (char *) GRUB_LINUX_BZIMAGE_ADDR + prot_size;
160
147
 
161
 
  if (! big_linux
162
 
      && prot_size > (grub_size_t) (grub_linux_real_addr
163
 
                                    - (char *) GRUB_LINUX_ZIMAGE_ADDR))
 
148
  if (! grub_linux_is_bzimage
 
149
      && ((char *) GRUB_LINUX_ZIMAGE_ADDR + prot_size
 
150
          > (grub_size_t) grub_linux_real_addr))
164
151
    {
165
 
      grub_error (GRUB_ERR_BAD_OS, "too big zImage, use bzImage instead");
 
152
      grub_error (GRUB_ERR_BAD_OS, "too big zImage (0x%x > 0x%x), use bzImage instead",
 
153
                  (char *) GRUB_LINUX_ZIMAGE_ADDR + prot_size,
 
154
                  (grub_size_t) grub_linux_real_addr);
166
155
      goto fail;
167
156
    }
168
157
  
177
166
    }
178
167
 
179
168
  grub_printf ("   [Linux-%s, setup=0x%x, size=0x%x]\n",
180
 
               big_linux ? "bzImage" : "zImage", real_size, prot_size);
 
169
               grub_linux_is_bzimage ? "bzImage" : "zImage", real_size, prot_size);
181
170
 
182
171
  for (i = 1; i < argc; i++)
183
172
    if (grub_memcmp (argv[i], "vga=", 4) == 0)