]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2002-03-26 Yoshinori K. Okuji <okuji@enbug.org>
authorokuji <okuji@localhost>
Mon, 25 Mar 2002 21:43:55 +0000 (21:43 +0000)
committerokuji <okuji@localhost>
Mon, 25 Mar 2002 21:43:55 +0000 (21:43 +0000)
* stage2/boot.c (linux_mem_size): New variable.
(load_image): Check a mem= option and set LINUX_MEM_SIZE to the
specified memory size, if any. Otherwise, to zero. When an
overflow is detected, use LINUX_INITRD_MAX_ADDRESS instead.
(load_initrd): If LINUX_MEM_SIZE is non-zero, use it instead of
the actual memory size.
* stage2/char_io.c (safe_parse_maxint): Use ERR_NUMBER_OVERFLOW
instead of ERR_NUMBER_PARSING, when an overflow occurs.
* stage2/common.c [!STAGE1_5] (err_list): Added
ERR_NUMBER_OVERFLOW.
* stage2/shared.h (ERR_NUMBER_OVERFLOW): New constant.

ChangeLog
NEWS
stage2/boot.c
stage2/char_io.c
stage2/common.c
stage2/shared.h

index 101370144c73b4ee25c5f62e54a9dc37ccca929c..8b97ea49741f12d03f7e8dfd4b75c81b08ed05b7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2002-03-26  Yoshinori K. Okuji  <okuji@enbug.org>
+
+       * stage2/boot.c (linux_mem_size): New variable.
+       (load_image): Check a mem= option and set LINUX_MEM_SIZE to the
+       specified memory size, if any. Otherwise, to zero. When an
+       overflow is detected, use LINUX_INITRD_MAX_ADDRESS instead.
+       (load_initrd): If LINUX_MEM_SIZE is non-zero, use it instead of
+       the actual memory size.
+       * stage2/char_io.c (safe_parse_maxint): Use ERR_NUMBER_OVERFLOW
+       instead of ERR_NUMBER_PARSING, when an overflow occurs.
+       * stage2/common.c [!STAGE1_5] (err_list): Added
+       ERR_NUMBER_OVERFLOW.
+       * stage2/shared.h (ERR_NUMBER_OVERFLOW): New constant.
+       
 2002-03-24  Yoshinori K. Okuji  <okuji@enbug.org>
 
        * stage2/stage2.c (run_menu): Call cls outside the loop to run
diff --git a/NEWS b/NEWS
index 7b10123c383b2661ab550d8c246486e94651baae..68105444fb4984008ac0e6b8e44b29666d69302e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,11 @@ New in 0.92:
 * The command "terminal" accepts a new option, "--lines=LINES". You can
   set the maximum number of lines arbitrarily with this option. If you
   don't specify it, the maximum number will be 24.
+* The mem= option for Linux is recognized and used to limit the maximum
+  address of initrd.
+* A fallback entry is executed immediately after a default entry,
+  without prompting a user's intervention, as the manual has ever been
+  saying.
 
 New in 0.91 - 2002-01-21:
 * Support for Linux DAC960 is added.
index 15701879897b6a0a1cbddf793911c6474e6aa041..cc23a052e9ae1a66d9378e640a28ddd1a53dcfcd 100644 (file)
@@ -1,7 +1,7 @@
 /* boot.c - load and bootstrap a kernel */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999, 2000, 2001  Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002  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
@@ -28,7 +28,7 @@
 static int cur_addr;
 entry_func entry_addr;
 static struct mod_list mll[99];
-
+static int linux_mem_size;
 
 /*
  *  The next two functions, 'load_image' and 'load_module', are the building
@@ -298,6 +298,60 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
                lh->vid_mode = vid_mode;
              }
          }
+
+         /* Check the mem= option to limit memory used for initrd.  */
+         {
+           char *mem;
+           
+           mem = grub_strstr (arg, "mem=");
+           if (mem)
+             {
+               char *value = mem + 4;
+
+               safe_parse_maxint (&value, &linux_mem_size);
+               switch (errnum)
+                 {
+                 case ERR_NUMBER_OVERFLOW:
+                   /* If an overflow occurs, use the maximum address for
+                      initrd instead. This is good, because MAXINT is
+                      greater than LINUX_INITRD_MAX_ADDRESS.  */
+                   linux_mem_size = LINUX_INITRD_MAX_ADDRESS;
+                   errnum = ERR_NONE;
+                   break;
+                   
+                 case ERR_NONE:
+                   {
+                     int shift = 0;
+                     
+                     switch (grub_tolower (*value))
+                       {
+                       case 'g':
+                         shift += 10;
+                       case 'm':
+                         shift += 10;
+                       case 'k':
+                         shift += 10;
+                       default:
+                         break;
+                       }
+
+                     /* Check an overflow.  */
+                     if (linux_mem_size > (MAXINT >> shift))
+                       linux_mem_size = LINUX_INITRD_MAX_ADDRESS;
+                     else
+                       linux_mem_size <<= shift;
+                   }
+                   break;
+                   
+                 default:
+                   linux_mem_size = 0;
+                   errnum = ERR_NONE;
+                   break;
+                 }
+             }
+           else
+             linux_mem_size = 0;
+         }
                
          memmove ((char *) LINUX_SETUP, buffer, data_len + SECTOR_SIZE);
 
@@ -720,7 +774,12 @@ load_initrd (char *initrd)
       goto fail;
     }
 
-  moveto = ((mbi.mem_upper + 0x400) * 0x400 - len) & 0xfffff000;
+  if (linux_mem_size)
+    moveto = linux_mem_size;
+  else
+    moveto = (mbi.mem_upper + 0x400) << 10;
+  
+  moveto = (moveto - len) & 0xfffff000;
   if (moveto + len >= LINUX_INITRD_MAX_ADDRESS)
     moveto = (LINUX_INITRD_MAX_ADDRESS - len) & 0xfffff000;
   
index 8a5a2ceb7ba9489c1f2e6dd8bd4b2b98dd525bb1..d82ed5be72e0161a15664b22dc5bbeda734bf47c 100644 (file)
@@ -948,7 +948,7 @@ safe_parse_maxint (char **str_ptr, int *myint_ptr)
       found = 1;
       if (myint > ((MAXINT - digit) / mult))
        {
-         errnum = ERR_NUMBER_PARSING;
+         errnum = ERR_NUMBER_OVERFLOW;
          return 0;
        }
       myint = (myint * mult) + digit;
index 3e63c171f19cf7e2b31ddbe16894080f3c8bfad4..e9cfeb535a380d023000c5e8bcfe8efbc911c162 100644 (file)
@@ -1,7 +1,7 @@
 /* common.c - miscellaneous shared variables and routines */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999, 2000, 2001  Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002  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
@@ -77,6 +77,7 @@ char *err_list[] =
   [ERR_NO_DISK] = "Selected disk does not exist",
   [ERR_NO_DISK_SPACE] = "No spare sectors on the disk",
   [ERR_NO_PART] = "No such partition",
+  [ERR_NUMBER_OVERFLOW] = "Overflow while parsing number",
   [ERR_NUMBER_PARSING] = "Error while parsing number",
   [ERR_OUTSIDE_PART] = "Attempt to access block outside partition",
   [ERR_PRIVILEGED] = "Must be authenticated",
index 87688e5aa10100951ef2f8279de6bd9f1400fb60..b540852c933c04e4889d37a5c4757aad828c69b2 100644 (file)
@@ -548,6 +548,7 @@ typedef enum
   ERR_PRIVILEGED,
   ERR_NEED_SERIAL,
   ERR_NO_DISK_SPACE,
+  ERR_NUMBER_OVERFLOW,
 
   MAX_ERR_NUM
 } grub_error_t;