Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GSvZP-0007LN-Cp for mharc-grub-devel@gnu.org; Thu, 28 Sep 2006 09:04:55 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GSvZN-0007Js-Ey for grub-devel@gnu.org; Thu, 28 Sep 2006 09:04:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GSvZK-0007Gt-Gm for grub-devel@gnu.org; Thu, 28 Sep 2006 09:04:52 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GSvZK-0007Gq-6q for grub-devel@gnu.org; Thu, 28 Sep 2006 09:04:50 -0400 Received: from [212.27.42.28] (helo=smtp2-g19.free.fr) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GSveP-000234-7S for grub-devel@gnu.org; Thu, 28 Sep 2006 09:10:05 -0400 Received: from imp1-g19.free.fr (imp1-g19.free.fr [212.27.42.1]) by smtp2-g19.free.fr (Postfix) with ESMTP id 16BA275BD4 for ; Thu, 28 Sep 2006 15:04:49 +0200 (CEST) Received: by imp1-g19.free.fr (Postfix, from userid 33) id 07B364600; Thu, 28 Sep 2006 15:04:48 +0200 (CEST) Received: from 129.184.84.11 ([129.184.84.11]) by imp1-g19.free.fr (IMP) with HTTP for ; Thu, 28 Sep 2006 15:04:48 +0200 Message-ID: <1159448688.451bc870e9851@imp1-g19.free.fr> Date: Thu, 28 Sep 2006 15:04:48 +0200 From: tgingold@free.fr To: The development of GRUB 2 References: <1159444090.451bb67a38fba@imp6-g19.free.fr> <877izo2ljd.fsf@xs4all.nl> In-Reply-To: <877izo2ljd.fsf@xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 User-Agent: Internet Messaging Program (IMP) 3.2.5 X-Originating-IP: 129.184.84.11 Content-Transfer-Encoding: quoted-printable Subject: Re: patch for kern/efi/mm.c (big memmap) X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Sep 2006 13:04:53 -0000 Quoting Marco Gerards : > tgingold@free.fr writes: > > Hi, > > First of all, thanks a lot for this patch. > > > some systems have a really big memmap. > > What kind of system are you testing GRUB 2 (EFI) on? It would be nice > to know which systems are already supported. This is on an ia64 system (Tiger). > > This patch remove the memmap size limit. > > Cool. Can you please send in this patch in unified diff format (diff > -up) and provide a changelog entry? And while you on it, most people > here prefer patches being sent inline so it is easier to read and to > give feedback on. Sorry, this is my first patch! Tristan. 2006-09-28 Tristan Gingold * kern/efi/mm.c (grub_efi_mm_init): MEMORY_MAP_SIZE removed, dynamically get the size of the memory map. --- grub2.cvs/kern/efi/mm.c 2006-05-29 01:01:43.000000000 +0200 +++ grub2/kern/efi/mm.c 2006-09-28 11:25:47.000000000 +0200 @@ -30,10 +30,6 @@ #define BYTES_TO_PAGES(bytes) ((bytes) >> 12) #define PAGES_TO_BYTES(pages) ((pages) << 12) -/* The size of a memory map obtained from the firmware. This must be - a multiplier of 4KB. */ -#define MEMORY_MAP_SIZE 0x1000 - /* Maintain the list of allocated pages. */ struct allocated_page { @@ -346,6 +342,8 @@ grub_efi_uintn_t desc_size; grub_efi_uint64_t total_pages; grub_efi_uint64_t required_pages; + grub_efi_uintn_t memory_map_size; + int res; /* First of all, allocate pages to maintain allocations. */ allocated_pages @@ -356,15 +354,20 @@ grub_memset (allocated_pages, 0, ALLOCATED_PAGES_SIZE); /* Prepare a memory region to store two memory maps. */ - memory_map =3D grub_efi_allocate_pages (0, - 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); + memory_map_size =3D 0; + res =3D grub_efi_get_memory_map (&memory_map_size, NULL, 0, &desc_size= , 0); + if (res !=3D 0) + grub_fatal ("cannot get memory map size"); + + memory_map =3D grub_efi_allocate_pages + (0, 2 * BYTES_TO_PAGES (memory_map_size + 0x1000)); if (! memory_map) grub_fatal ("cannot allocate memory"); - filtered_memory_map =3D NEXT_MEMORY_DESCRIPTOR (memory_map, MEMORY_MAP= _SIZE); + filtered_memory_map =3D NEXT_MEMORY_DESCRIPTOR (memory_map, memory_map= _size); /* Obtain descriptors for available memory. */ - map_size =3D MEMORY_MAP_SIZE; + map_size =3D memory_map_size; if (grub_efi_get_memory_map (&map_size, memory_map, 0, &desc_size, 0) = < 0) grub_fatal ("cannot get memory map"); @@ -373,7 +376,7 @@ filtered_memory_map_end =3D filter_memory_map (memory_map, filtered_me= mory_map, desc_size, memory_map_end); - + /* By default, request a quarter of the available memory. */ total_pages =3D get_total_pages (filtered_memory_map, desc_size, filtered_memory_map_end); @@ -393,7 +396,7 @@ #if 0 /* For debug. */ - map_size =3D MEMORY_MAP_SIZE; + map_size =3D memory_map_size; if (grub_efi_get_memory_map (&map_size, memory_map, 0, &desc_size, 0) = < 0) grub_fatal ("cannot get memory map"); @@ -406,7 +409,7 @@ /* Release the memory maps. */ grub_efi_free_pages ((grub_addr_t) memory_map, - 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); + 2 * BYTES_TO_PAGES (memory_map_size + 0x1000)); } void