From: Johan Rydberg <jrydberg@night.trouble.net>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: patch for kern/efi/mm.c (big memmap)
Date: Thu, 28 Sep 2006 16:24:24 +0200 [thread overview]
Message-ID: <874pus9ihz.fsf@night.trouble.net> (raw)
In-Reply-To: <87irj814kp.fsf@xs4all.nl> (Marco Gerards's message of "Thu, 28 Sep 2006 15:52:22 +0200")
[-- Attachment #1.1: Type: text/plain, Size: 646 bytes --]
Marco Gerards <mgerards@xs4all.nl> writes:
>> + memory_map = grub_efi_allocate_pages
>> + (0, 2 * BYTES_TO_PAGES (memory_map_size + 0x1000));
>>
>> I suppose you add 0x1000 to round it up. Maybe we should change
>> the BYTES_TO_PAGES macro to do roundup.
>
> Agreed. Can you make this change as well?
Done. See attached patch.
>> Even through this patch is quite trivial and small, I believe we
>> need you to sign over the copyright for it to FSF. Okuji, Marco,
>> what are your opinions?
>
> This patch is trivial enough to apply without the paperwork, I
> think.
OK.
I'll commit it after I get a few minutes over to test it.
~j
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: grub.efi-mm.2.patch --]
[-- Type: text/x-patch, Size: 2753 bytes --]
Index: kern/efi/mm.c
===================================================================
RCS file: /sources/grub/grub2/kern/efi/mm.c,v
retrieving revision 1.3
diff -u -p -r1.3 mm.c
--- kern/efi/mm.c 28 May 2006 23:01:43 -0000 1.3
+++ kern/efi/mm.c 28 Sep 2006 13:57:30 -0000
@@ -27,13 +27,9 @@
#define NEXT_MEMORY_DESCRIPTOR(desc, size) \
((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
-#define BYTES_TO_PAGES(bytes) ((bytes) >> 12)
+#define BYTES_TO_PAGES(bytes) (((bytes) + 4095) >> 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_mm_init (void)
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
@@ -355,16 +353,23 @@ grub_efi_mm_init (void)
grub_memset (allocated_pages, 0, ALLOCATED_PAGES_SIZE);
- /* Prepare a memory region to store two memory maps. */
- memory_map = grub_efi_allocate_pages (0,
- 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
+ /* Prepare a memory region to store two memory maps. Obtain size of
+ memory map by passing a NULL buffer and a buffer size of
+ zero. */
+ memory_map_size = 0;
+ res = grub_efi_get_memory_map (&memory_map_size, NULL, 0, &desc_size, 0);
+ if (res != 0)
+ grub_fatal ("cannot get memory map size");
+
+ memory_map = grub_efi_allocate_pages
+ (0, 2 * BYTES_TO_PAGES (memory_map_size));
if (! memory_map)
grub_fatal ("cannot allocate memory");
- filtered_memory_map = NEXT_MEMORY_DESCRIPTOR (memory_map, MEMORY_MAP_SIZE);
+ filtered_memory_map = NEXT_MEMORY_DESCRIPTOR (memory_map, memory_map_size);
/* Obtain descriptors for available memory. */
- map_size = MEMORY_MAP_SIZE;
+ map_size = memory_map_size;
if (grub_efi_get_memory_map (&map_size, memory_map, 0, &desc_size, 0) < 0)
grub_fatal ("cannot get memory map");
@@ -393,7 +398,7 @@ grub_efi_mm_init (void)
#if 0
/* For debug. */
- map_size = MEMORY_MAP_SIZE;
+ map_size = 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 +411,7 @@ grub_efi_mm_init (void)
/* 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));
}
void
[-- Attachment #2: Type: application/pgp-signature, Size: 190 bytes --]
next prev parent reply other threads:[~2006-09-28 14:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-28 11:48 patch for kern/efi/mm.c (big memmap) tgingold
2006-09-28 13:00 ` Marco Gerards
2006-09-28 13:04 ` tgingold
2006-09-28 13:41 ` Marco Gerards
2006-09-28 14:01 ` Johan Rydberg
2006-09-28 13:52 ` Marco Gerards
2006-09-28 14:24 ` Johan Rydberg [this message]
2006-09-28 14:16 ` Marco Gerards
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874pus9ihz.fsf@night.trouble.net \
--to=jrydberg@night.trouble.net \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.