On Sun, 28 Mar 2004, Yoshinori K. Okuji wrote:

> On Sunday 28 March 2004 09:18, Pavel Roskin wrote:
> > The attached patch makes --no-mem-option implied for Linux kernels
> > with boot protocol 2.03, i.e. kernel versions 2.4.18 and newer.
>
> Honestly speaking, I don't like to use the protocol version this way,
> but I must admit that it would solve 99.9% problems related to this
> feature and I have no better idea.
>
> So, please add a rich comment into boot.c which explains why you use the
> protocol version for this purpose. Then, I will accept your patch.

Attached.  I hope it's rich enough :-)

-- 
Regards,
Pavel Roskin
--- ChangeLog
+++ ChangeLog
@@ -1 +1,6 @@
+2004-03-28  Pavel Roskin  <[EMAIL PROTECTED]>
+
+       * stage2/boot.c: Imply --no-mem-option for Linux kernels with
+       protocol version 0x0203 and above (Linux 2.4.18 and newer).
+
 2004-03-27  Yoshinori K. Okuji  <[EMAIL PROTECTED]>
--- NEWS
+++ NEWS
@@ -6,6 +6,7 @@
 * Support ATARAID for Linux in the grub shell and grub-install.
 * Add CDROM support for El Torito with no emulation mode. You can use
   (cd) as a CDROM drive in the config file.
+* Option --no-mem-option is implied for Linux 2.4.18 and newer.
 
 New in 0.94 - 2004-01-25:
 * Support building on x86-64 with gcc -m32.
--- docs/grub.texi
+++ docs/grub.texi
@@ -2735,7 +2735,7 @@
 
 The option @option{--no-mem-option} is effective only for Linux. If the
 option is specified, GRUB doesn't pass the option @option{mem=} to the
-kernel.
+kernel.  This option is implied for Linux kernels 2.4.18 and newer.
 @end deffn
 
 
--- stage2/boot.c
+++ stage2/boot.c
@@ -407,10 +407,24 @@ load_image (char *kernel, char *arg, ker
            while (dest < linux_data_tmp_addr + LINUX_CL_END_OFFSET && *src)
              *(dest++) = *(src++);
        
-           /* Add a mem option automatically only if the user doesn't
-              specify it explicitly.  */
+           /* Old Linux kernels have problems determining the amount of
+              the available memory.  To work around this problem, we add
+              the "mem" option to the kernel command line.  This has its
+              own drawbacks because newer kernels can determine the
+              memory map more accurately.  Boot protocol 2.03, which
+              appeared in Linux 2.4.18, provides a pointer to the kernel
+              version string, so we could check it.  But since kernel
+              2.4.18 and newer are known to detect memory reliably, boot
+              protocol 2.03 already implies that the kernel is new
+              enough.  The "mem" option is added if neither of the
+              following conditions is met:
+              1) The "mem" option is already present.
+              2) The "kernel" command is used with "--no-mem-option".
+              3) GNU GRUB is configured not to pass the "mem" option.
+              4) The kernel supports boot protocol 2.03 or newer.  */
            if (! grub_strstr (arg, "mem=")
                && ! (load_flags & KERNEL_LOAD_NO_MEM_OPTION)
+               && lh->version < 0x0203         /* kernel version < 2.4.18 */
                && dest + 15 < linux_data_tmp_addr + LINUX_CL_END_OFFSET)
              {
                *dest++ = ' ';
_______________________________________________
Bug-grub mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-grub

Reply via email to