Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1IqsZM-0008Dn-V5 for mharc-grub-devel@gnu.org; Sat, 10 Nov 2007 10:48:24 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IqsZL-0008Ca-1E for grub-devel@gnu.org; Sat, 10 Nov 2007 10:48:23 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IqsZG-0008AZ-B9 for grub-devel@gnu.org; Sat, 10 Nov 2007 10:48:22 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IqsZF-0008AG-Uu for grub-devel@gnu.org; Sat, 10 Nov 2007 10:48:18 -0500 Received: from smtp-vbr14.xs4all.nl ([194.109.24.34]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IqsZF-0003Xv-D1 for grub-devel@gnu.org; Sat, 10 Nov 2007 10:48:17 -0500 Received: from localhost.localdomain (249-174.surfsnel.dsl.internl.net [145.99.174.249]) by smtp-vbr14.xs4all.nl (8.13.8/8.13.8) with ESMTP id lAAFmGOM035933 for ; Sat, 10 Nov 2007 16:48:16 +0100 (CET) (envelope-from mgerards@xs4all.nl) From: Marco Gerards To: The development of GRUB 2 References: <20071103230631.GA2875@boeglin.org> <7e294475cc68725187c34c141b65a48c@boeglin.org> Mail-Copies-To: mgerards@xs4all.nl Date: Sat, 10 Nov 2007 16:48:50 +0100 In-Reply-To: <7e294475cc68725187c34c141b65a48c@boeglin.org> (Alexandre Boeglin's message of "Sun, 4 Nov 2007 01:04:24 +0100") Message-ID: <87d4uihzj1.fsf@xs4all.nl> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by XS4ALL Virus Scanner X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.6-4.9 Subject: Re: grub2 efi patches 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: Sat, 10 Nov 2007 15:48:23 -0000 Alexandre Boeglin writes: > On Sun, 4 Nov 2007 00:06:31 +0100, Alexandre Boeglin > wrote: >> grub2_efi_chainloader_options.patch adds support for efi chainload >> options, >> it is not really beautiful (for instance, the ascii to utf16 conversion), >> but it works for the MacOSX loader, > > Sorry, there was a mistake in the previous one ... Ok :-) > By the way, it's using boot_services->allocate_pool instead of grub_malloc. > I don't know if it's okay, but when I tried using grub_malloc, I was > getting "free magic is broken 0x0" errors. Please use grub_malloc. If you get this error, something is most likely writing to unallocated memory or something like that... > Index: include/grub/efi/chainloader.h > =================================================================== > RCS file: /sources/grub/grub2/include/grub/efi/chainloader.h,v > retrieving revision 1.2 > diff -u -r1.2 chainloader.h > --- include/grub/efi/chainloader.h 21 Jul 2007 23:32:22 -0000 1.2 > +++ include/grub/efi/chainloader.h 4 Nov 2007 00:00:40 -0000 > @@ -19,6 +19,6 @@ > #ifndef GRUB_EFI_CHAINLOADER_HEADER > #define GRUB_EFI_CHAINLOADER_HEADER 1 > > -void grub_chainloader_cmd (const char *filename); > +void grub_chainloader_cmd (int argc, char *argv[]); > > #endif /* ! GRUB_EFI_CHAINLOADER_HEADER */ > Index: loader/efi/chainloader.c > =================================================================== > RCS file: /sources/grub/grub2/loader/efi/chainloader.c,v > retrieving revision 1.2 > diff -u -r1.2 chainloader.c > --- loader/efi/chainloader.c 21 Jul 2007 23:32:28 -0000 1.2 > +++ loader/efi/chainloader.c 4 Nov 2007 00:01:05 -0000 > @@ -17,8 +17,6 @@ > * along with GRUB. If not, see . > */ > > -/* TODO: support load options. */ > - > #include > #include > #include > @@ -175,7 +173,7 @@ > } > > void > -grub_chainloader_cmd (const char *filename) > +grub_chainloader_cmd (int argc, char *argv[]) > { > grub_file_t file = 0; > grub_ssize_t size; > @@ -185,6 +183,11 @@ > grub_device_t dev = 0; > grub_efi_device_path_t *dp = 0; > grub_efi_loaded_image_t *loaded_image; > + char *filename = argv[0]; > + grub_efi_char16_t *options = NULL, *p; > + int i, j, options_len = 0; > + > + b = grub_efi_system_table->boot_services; > > grub_dl_ref (my_mod); > > @@ -192,6 +195,30 @@ > address = 0; > image_handle = 0; > file_path = 0; > + > + if (argc == 0) > + { > + grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified"); > + goto fail; > + } > + > + /* copy options */ /* Copy options. */ > + if (argc > 1) > + { > + for (i = 1; i < argc; i++) > + options_len += (grub_strlen (argv[i]) + 1) * sizeof (*options); > + > + status = b->allocate_pool (GRUB_EFI_LOADER_DATA, options_len + sizeof (*options), &options); > + if (status != GRUB_EFI_SUCCESS) > + goto fail; Please use grub_malloc. There are several ways to debug mm.c... > + p = options; > + > + for (i = 1; i < argc; i++){ > + *p++ = ' '; > + for (j = 0; j < grub_strlen (argv[i]) + 1; j++) > + p[j] = argv[i][j]; > + } > + } > > b = grub_efi_system_table->boot_services; > > @@ -267,6 +294,10 @@ > goto fail; > } > loaded_image->device_handle = dev_handle; > + > + if (options) > + loaded_image->load_options = options; > + loaded_image->load_options_size = options_len + 1; > > grub_file_close (file); > grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); > @@ -292,10 +323,7 @@ > static void > grub_rescue_cmd_chainloader (int argc, char *argv[]) > { > - if (argc == 0) > - grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified"); > - else > - grub_chainloader_cmd (argv[0]); > + grub_chainloader_cmd (argc, argv); > } > > static const char loader_name[] = "chainloader"; > Index: loader/efi/chainloader_normal.c > =================================================================== > RCS file: /sources/grub/grub2/loader/efi/chainloader_normal.c,v > retrieving revision 1.2 > diff -u -r1.2 chainloader_normal.c > --- loader/efi/chainloader_normal.c 21 Jul 2007 23:32:28 -0000 1.2 > +++ loader/efi/chainloader_normal.c 4 Nov 2007 00:01:05 -0000 > @@ -26,10 +26,7 @@ > chainloader_command (struct grub_arg_list *state __attribute__ ((unused)), > int argc, char **args) > { > - if (argc == 0) > - grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified"); > - else > - grub_chainloader_cmd (args[0]); > + grub_chainloader_cmd (argc, args); > return grub_errno; > } > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel