* [PATCH] GRUB2 does not provide Multiboot Legacy memory map @ 2008-04-19 21:11 Julian Salazar 2008-04-19 21:32 ` Thomas Schwinge 0 siblings, 1 reply; 4+ messages in thread From: Julian Salazar @ 2008-04-19 21:11 UTC (permalink / raw) To: grub-devel [-- Attachment #1: Type: text/plain, Size: 632 bytes --] Hi, I'm developing a small kernel and I've been using GRUB2 with the Legacy Multiboot Specification for some time now. I've noticed that it does not provide some of the things in the Multiboot Information structure that GRUB Legacy does, like the memory map. So I've created a small patch which works in QEMU and real hardware so that GRUB2 will pass the memory map to my kernel or any multiboot-compliant kernel for the i386-pc. Since I've never actually contributed code to a GNU project before, are there certain rules and regulations of some sort that I have to comply with before I can send my patch here? Thanks. [-- Attachment #2: Type: text/html, Size: 2528 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] GRUB2 does not provide Multiboot Legacy memory map 2008-04-19 21:11 [PATCH] GRUB2 does not provide Multiboot Legacy memory map Julian Salazar @ 2008-04-19 21:32 ` Thomas Schwinge 2008-04-19 22:09 ` Julian Salazar 0 siblings, 1 reply; 4+ messages in thread From: Thomas Schwinge @ 2008-04-19 21:32 UTC (permalink / raw) To: Julian Salazar; +Cc: grub-devel [-- Attachment #1: Type: text/plain, Size: 1261 bytes --] Hello! On Sat, Apr 19, 2008 at 03:11:43PM -0600, Julian Salazar wrote: > I'm developing a small kernel and I've been using GRUB2 with the Legacy > Multiboot Specification for some time now. I've noticed that it does not > provide some of the things in the Multiboot Information structure that GRUB > Legacy does, like the memory map. So I've created a small patch which works > in QEMU and real hardware so that GRUB2 will pass the memory map to my > kernel or any multiboot-compliant kernel for the i386-pc. Now this is interesting as I've just today seen an incompatibility between booting a multiboot kernel with GRUB legacy and GRUB2. It might actually be the same issue, but I didn't fully investigate yet. Therefore I'm quite interested in seeing your patch. > Since I've never actually contributed code to a GNU project before, are Welcome! > there certain rules and regulations of some sort that I have to comply with Your guessed right: sure there are :-). See, for example, (parts of) the GNU Coding Standards, <http://www.gnu.org/prep/standards/html_node/>. Not everything is relevant in your case, though. > before I can send my patch here? Feel free to simply send it here and we'll tell you what needs to be changed. Regards, Thomas [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 191 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] GRUB2 does not provide Multiboot Legacy memory map 2008-04-19 21:32 ` Thomas Schwinge @ 2008-04-19 22:09 ` Julian Salazar 2008-04-20 10:12 ` Robert Millan 0 siblings, 1 reply; 4+ messages in thread From: Julian Salazar @ 2008-04-19 22:09 UTC (permalink / raw) To: 'The development of GRUB 2' [-- Attachment #1: Type: text/plain, Size: 1828 bytes --] Attached is the patch. Since I'm not completely familiar with GRUB2's internals, there might be a more efficient way of implementing this. Thoughts/improvements? > -----Original Message----- > From: grub-devel-bounces+julian.salazar=shaw.ca@gnu.org [mailto:grub- > devel-bounces+julian.salazar=shaw.ca@gnu.org] On Behalf Of Thomas Schwinge > Sent: April-19-08 3:32 PM > To: Julian Salazar > Cc: grub-devel@gnu.org > Subject: Re: [PATCH] GRUB2 does not provide Multiboot Legacy memory map > > Hello! > > On Sat, Apr 19, 2008 at 03:11:43PM -0600, Julian Salazar wrote: > > I'm developing a small kernel and I've been using GRUB2 with the Legacy > > Multiboot Specification for some time now. I've noticed that it does not > > provide some of the things in the Multiboot Information structure that > GRUB > > Legacy does, like the memory map. So I've created a small patch which > works > > in QEMU and real hardware so that GRUB2 will pass the memory map to my > > kernel or any multiboot-compliant kernel for the i386-pc. > > Now this is interesting as I've just today seen an incompatibility > between booting a multiboot kernel with GRUB legacy and GRUB2. It might > actually be the same issue, but I didn't fully investigate yet. > Therefore I'm quite interested in seeing your patch. > > > > Since I've never actually contributed code to a GNU project before, are > > Welcome! > > > there certain rules and regulations of some sort that I have to comply > with > > Your guessed right: sure there are :-). See, for example, (parts of) the > GNU Coding Standards, <http://www.gnu.org/prep/standards/html_node/>. > Not everything is relevant in your case, though. > > > before I can send my patch here? > > Feel free to simply send it here and we'll tell you what needs to be > changed. > > > Regards, > Thomas [-- Attachment #2: multiboot_memmap.patch --] [-- Type: application/octet-stream, Size: 2342 bytes --] Index: loader/i386/pc/multiboot.c =================================================================== RCS file: /sources/grub/grub2/loader/i386/pc/multiboot.c,v retrieving revision 1.19 diff -u -p -r1.19 multiboot.c --- loader/i386/pc/multiboot.c 5 Mar 2008 05:09:35 -0000 1.19 +++ loader/i386/pc/multiboot.c 19 Apr 2008 20:36:54 -0000 @@ -24,7 +24,6 @@ * - a.out support * - boot device * - symbol table - * - memory map * - drives table * - ROM configuration table * - APM table @@ -74,6 +73,7 @@ grub_multiboot_unload (void) } grub_free ((void *) mbi->mods_addr); grub_free ((void *) mbi->cmdline); + grub_free ((void *) mbi->mmap_addr); grub_free (mbi); } @@ -314,6 +314,10 @@ grub_multiboot (int argc, char *argv[]) char buffer[MULTIBOOT_SEARCH], *cmdline = 0, *p; struct grub_multiboot_header *header; grub_ssize_t len; + struct grub_machine_mmap_entry *mmap_entry + = (struct grub_machine_mmap_entry *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR; + struct grub_machine_mmap_entry *mmap; + grub_uint32_t cont; int i; grub_loader_unset (); @@ -411,6 +415,26 @@ grub_multiboot (int argc, char *argv[]) mbi->flags |= MULTIBOOT_INFO_CMDLINE; mbi->cmdline = (grub_uint32_t) cmdline; + /* Create memory map */ + cont = grub_get_mmap_entry (mmap_entry, 0); + + if (mmap_entry->size) + { + /* Allocate space for 32 memory map entries */ + mmap = grub_malloc (sizeof (struct grub_machine_mmap_entry) * 32); + if (! mmap) + goto fail; + mmap[0] = *mmap_entry; + for (i = 1; cont; i++) + { + cont = grub_get_mmap_entry (mmap_entry, cont); + mmap[i] = *mmap_entry; + } + mbi->flags |= MULTIBOOT_INFO_MEM_MAP; + mbi->mmap_length = sizeof (struct grub_machine_mmap_entry) * i; + mbi->mmap_addr = (grub_uint32_t) mmap; + } + mbi->flags |= MULTIBOOT_INFO_BOOT_LOADER_NAME; mbi->boot_loader_name = (grub_uint32_t) grub_strdup (PACKAGE_STRING); @@ -426,6 +450,8 @@ grub_multiboot (int argc, char *argv[]) if (grub_errno != GRUB_ERR_NONE) { grub_free (cmdline); + if (mbi->flags & MULTIBOOT_INFO_MEM_MAP) + grub_free (mmap); grub_free (mbi); grub_dl_unref (my_mod); } ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] GRUB2 does not provide Multiboot Legacy memory map 2008-04-19 22:09 ` Julian Salazar @ 2008-04-20 10:12 ` Robert Millan 0 siblings, 0 replies; 4+ messages in thread From: Robert Millan @ 2008-04-20 10:12 UTC (permalink / raw) To: The development of GRUB 2 On Sat, Apr 19, 2008 at 04:09:15PM -0600, Julian Salazar wrote: > Attached is the patch. Since I'm not completely familiar with GRUB2's > internals, there might be a more efficient way of implementing this. > > Thoughts/improvements? Thanks for the patch. It'd be interesting if it was done portably. The coreboot (aka LinuxBIOS) target also uses this code, and the memory map is obtained differently there (see kern/i386/linuxbios/init.c). At least, it could be #ifdef'ed, although it'd be nice to have something more ellegant (e.g. an isolated, generic function to probe for memory map arch-dependantly that arch-independant code can use). -- Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call… if you are unable to speak? (as seen on /.) ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-04-20 10:13 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-04-19 21:11 [PATCH] GRUB2 does not provide Multiboot Legacy memory map Julian Salazar 2008-04-19 21:32 ` Thomas Schwinge 2008-04-19 22:09 ` Julian Salazar 2008-04-20 10:12 ` Robert Millan
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.