From: Tim Riker <[EMAIL PROTECTED]>
Subject: Re: please test the CVS version!
Date: Thu, 08 Jun 2000 16:55:48 -0600

> The 2.4.x kernels now have support for > 4gig of memory. I'm running
> grub 0.5.94 on a IBM Netfinity 7000 m10 with 5 gig of ram and grub
> passed the kernel a mem= with only 4 gig on it. Has this been addressed?

  I didn't think PC would have more than 4GB so soon... How about this
patch? If it works fine, I'll check it in, though it is ad hoc.
Perhaps the real fix will be one of the goals in 1.0.

Okuji
? objs
Index: ChangeLog
===================================================================
RCS file: /home/cvs/grub/ChangeLog,v
retrieving revision 1.250
diff -u -r1.250 ChangeLog
--- ChangeLog   2000/06/07 22:43:37     1.250
+++ ChangeLog   2000/06/09 16:35:32
@@ -1,3 +1,23 @@
+2000-06-09  OKUJI Yoshinori  <[EMAIL PROTECTED]>
+
+       * stage2/mb_info.h (AddrRangeDesc): Use one 64bits field instead
+       of two 32bits fields for BaseAddr and Length, respectively.
+       BaseAddrLow + BaseAddrHigh -> BaseAddr, LengthLow + LengthHigh
+       -> Length.
+       * stage2/builtins.c (displaymem_func): Print BaseAddr >> 32,
+       BaseAddr & 0xFFFFFFFF, Length >> 32 and Length & 0xFFFFFFFF,
+       instead of BaseAddrLow, BaseAddrHigh, LengthLow and LengthHigh,
+       for MAP.
+       * stage2/common.c (fakemap): Adjusted to the new definition of
+       AddrRangeDesc.
+       (mmap_avail_at): Change the type of TOP to unsigned long long.
+       If TOP is greater than 0xFFFFFFFF, set it to 0xFFFFFFFF, since
+       GRUB itself cannot deal with 64bits addresses at the moment.
+       (init_bios_info): When getting a maximum available address from
+       the memory map, use a new unsigned long long variable MAX_ADDR
+       as the temporary variable instead of MEMTMP. This should allow
+       GRUB to detect at most 4TB.
+       
 2000-06-08  OKUJI Yoshinori  <[EMAIL PROTECTED]>
 
        * docs/tutorial.texi (Network): The body is moved to ...
Index: stage2/builtins.c
===================================================================
RCS file: /home/cvs/grub/stage2/builtins.c,v
retrieving revision 1.61
diff -u -r1.61 builtins.c
--- stage2/builtins.c   2000/06/01 06:26:52     1.61
+++ stage2/builtins.c   2000/06/09 16:35:40
@@ -810,8 +810,11 @@
            str = "Reserved";
          grub_printf ("   %s:  Base Address:  0x%x X 4GB + 0x%x,\n"
                       "      Length:   %u X 4GB + %u bytes\n",
-                      str, map->BaseAddrHigh, map->BaseAddrLow,
-                      map->LengthHigh, map->LengthLow);
+                      str,
+                      (unsigned long) (map->BaseAddr >> 32),
+                      (unsigned long) (map->BaseAddr & 0xFFFFFFFF),
+                      (unsigned long) (map->Length >> 32),
+                      (unsigned long) (map->Length & 0xFFFFFFFF));
 
          map = ((struct AddrRangeDesc *) (((int) map) + 4 + map->size));
        }
Index: stage2/common.c
===================================================================
RCS file: /home/cvs/grub/stage2/common.c,v
retrieving revision 1.12
diff -u -r1.12 common.c
--- stage2/common.c     2000/05/29 16:11:08     1.12
+++ stage2/common.c     2000/06/09 16:35:40
@@ -90,9 +90,9 @@
 /* static for BIOS memory map fakery */
 static struct AddrRangeDesc fakemap[3] =
 {
-  {20, 0, 0, 0, 0, MB_ARD_MEMORY},
-  {20, 0x100000, 0, 0, 0, MB_ARD_MEMORY},
-  {20, 0x1000000, 0, 0, 0, MB_ARD_MEMORY}
+  {20, 0, 0, MB_ARD_MEMORY},
+  {20, 0x100000, 0, MB_ARD_MEMORY},
+  {20, 0x1000000, 0, MB_ARD_MEMORY}
 };
 
 /* A big problem is that the memory areas aren't guaranteed to be:
@@ -101,7 +101,8 @@
 static unsigned long
 mmap_avail_at (unsigned long bottom)
 {
-  unsigned long top, addr;
+  unsigned long long top;
+  unsigned long addr;
   int cont;
   
   top = bottom;
@@ -113,19 +114,22 @@
        {
          struct AddrRangeDesc *desc = (struct AddrRangeDesc *) addr;
          
-         if (desc->BaseAddrHigh == 0
-             && desc->Type == MB_ARD_MEMORY
-             && desc->BaseAddrLow <= top
-             && desc->BaseAddrLow + desc->LengthLow > top)
+         if (desc->Type == MB_ARD_MEMORY
+             && desc->BaseAddr <= top
+             && desc->BaseAddr + desc->Length > top)
            {
-             top = desc->BaseAddrLow + desc->LengthLow;
+             top = desc->BaseAddr + desc->Length;
              cont++;
            }
        }
     }
   while (cont);
+
+  /* For now, GRUB assumes 32bits addresses, so...  */
+  if (top > 0xFFFFFFFF)
+    top = 0xFFFFFFFF;
   
-  return top - bottom;
+  return (unsigned long) top - bottom;
 }
 #endif /* ! STAGE1_5 */
 
@@ -203,6 +207,8 @@
 
   if (mbi.mmap_length)
     {
+      unsigned long long max_addr;
+      
       /*
        *  This is to get the lower memory, and upper memory (up to the
        *  first memory hole), into the "mbi.mem_{lower,upper}"
@@ -213,19 +219,18 @@
       mbi.mem_upper = mmap_avail_at (0x100000) >> 10;
 
       /* Find the maximum available address. Ignore any memory holes.  */
-      for (memtmp = 0, addr = mbi.mmap_addr;
+      for (max_addr = 0, addr = mbi.mmap_addr;
           addr < mbi.mmap_addr + mbi.mmap_length;
           addr += *((unsigned long *) addr) + 4)
        {
          struct AddrRangeDesc *desc = (struct AddrRangeDesc *) addr;
          
-         if (desc->BaseAddrHigh == 0
-             && desc->Type == MB_ARD_MEMORY
-             && desc->BaseAddrLow + desc->LengthLow > memtmp)
-           memtmp = desc->BaseAddrLow + desc->LengthLow;
+         if (desc->Type == MB_ARD_MEMORY
+             && desc->BaseAddr + desc->Length > max_addr)
+           max_addr = desc->BaseAddr + desc->Length;
        }
 
-      extended_memory = (memtmp - 0x100000) >> 10;
+      extended_memory = (max_addr - 0x100000) >> 10;
     }
   else if ((memtmp = get_eisamemsize ()) != -1)
     {
@@ -245,9 +250,9 @@
 
          mbi.mmap_addr = (unsigned long) fakemap;
          mbi.mmap_length = sizeof (fakemap);
-         fakemap[0].LengthLow = (mbi.mem_lower << 10);
-         fakemap[1].LengthLow = (memtmp << 10);
-         fakemap[2].LengthLow = cont;
+         fakemap[0].Length = (mbi.mem_lower << 10);
+         fakemap[1].Length = (memtmp << 10);
+         fakemap[2].Length = cont;
        }
 
       mbi.mem_upper = memtmp;
Index: stage2/mb_info.h
===================================================================
RCS file: /home/cvs/grub/stage2/mb_info.h,v
retrieving revision 1.1
diff -u -r1.1 mb_info.h
--- stage2/mb_info.h    1999/06/24 00:03:23     1.1
+++ stage2/mb_info.h    2000/06/09 16:35:41
@@ -1,7 +1,7 @@
-
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1996   Erich Boleyn  <[EMAIL PROTECTED]>
+ *  Copyright (C) 1996  Erich Boleyn  <[EMAIL PROTECTED]>
+ *  Copyright (C) 2000  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
@@ -46,10 +46,8 @@
 struct AddrRangeDesc
   {
     unsigned long size;
-    unsigned long BaseAddrLow;
-    unsigned long BaseAddrHigh;
-    unsigned long LengthLow;
-    unsigned long LengthHigh;
+    unsigned long long BaseAddr;
+    unsigned long long Length;
     unsigned long Type;
 
     /* unspecified optional padding... */

Reply via email to