From c67be0dccd65d33087edecac8b01d0741c8b8920 Mon Sep 17 00:00:00 2001 From: okuji Date: Sun, 18 Jun 2000 13:58:48 +0000 Subject: [PATCH] recoginize >4gb memory. --- ChangeLog | 21 +++++++++++++++++++++ stage2/builtins.c | 7 +++++-- stage2/common.c | 43 ++++++++++++++++++++++++------------------- stage2/mb_info.h | 10 ++++------ 4 files changed, 54 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3a652777..7d8b8e734 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2000-06-09 OKUJI Yoshinori + + * 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-18 OKUJI Yoshinori * docs/appendices.texi (FAQ): Added an question about Linux's @@ -62,6 +82,7 @@ quite inconsistent with hard disks? Why not /dev/fd[a-z]?) Report by Pavel Roskin. +>>>>>>> 1.258 2000-06-08 OKUJI Yoshinori * docs/tutorial.texi (Network): The body is moved to ... diff --git a/stage2/builtins.c b/stage2/builtins.c index a3f3d4ae1..b0c4c717e 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -810,8 +810,11 @@ displaymem_func (char *arg, int flags) 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)); } diff --git a/stage2/common.c b/stage2/common.c index c84571afc..618d34bef 100644 --- a/stage2/common.c +++ b/stage2/common.c @@ -90,9 +90,9 @@ char *err_list[] = /* 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 struct AddrRangeDesc fakemap[3] = 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 @@ mmap_avail_at (unsigned long bottom) { 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 @@ init_bios_info (void) 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 @@ init_bios_info (void) 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 @@ init_bios_info (void) 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; diff --git a/stage2/mb_info.h b/stage2/mb_info.h index 91b3876db..f01690a75 100644 --- a/stage2/mb_info.h +++ b/stage2/mb_info.h @@ -1,7 +1,7 @@ - /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1996 Erich Boleyn + * Copyright (C) 1996 Erich Boleyn + * 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 mod_list 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... */