Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aUJTp-0001z2-N1 for mharc-grub-devel@gnu.org; Fri, 12 Feb 2016 14:34:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUJTm-0001yE-SW for grub-devel@gnu.org; Fri, 12 Feb 2016 14:34:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUJTh-0000bV-S3 for grub-devel@gnu.org; Fri, 12 Feb 2016 14:34:10 -0500 Received: from sub5.mail.dreamhost.com ([208.113.200.129]:42189 helo=homiemail-a47.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUJTh-0000bC-Hq for grub-devel@gnu.org; Fri, 12 Feb 2016 14:34:05 -0500 Received: from homiemail-a47.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a47.g.dreamhost.com (Postfix) with ESMTP id D033D284058 for ; Fri, 12 Feb 2016 11:34:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=shealevy.com; h= mime-version:content-type:date:from:to:subject:in-reply-to :references:message-id:content-transfer-encoding; s=shealevy.com ; bh=xm8OT/Kqh+Zf3nV/F3HCeqysXdY=; b=UjJlsrnCwvwe21KZxMtOMgtpuKU AULYMrIT7e3A1+qCepFhEfqk4mwwX0Y3PfVYgbC8uAiLyV4gb0DNNd4xE2AhBskE COeBWNhaomkxQTVgBOpSniC42JWZTmgDylKHtax+En4LD0ZNgRfPqJVuHMPXEx0B p32ZEtMbNRRMuG3k= Received: from webmail.shealevy.com (caiajhbihbdd.dreamhost.com [208.97.187.133]) (Authenticated sender: shea@shealevy.com) by homiemail-a47.g.dreamhost.com (Postfix) with ESMTPA id BD0D9284056 for ; Fri, 12 Feb 2016 11:34:03 -0800 (PST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Date: Fri, 12 Feb 2016 14:34:03 -0500 From: Shea Levy To: Subject: Re: [PATCH v3 2/3] i386: Add support for loading from android bootimg In-Reply-To: References: <1454964459-28213-1-git-send-email-shea@shealevy.com> <1454964459-28213-3-git-send-email-shea@shealevy.com> <56BE1B60.5060900@gmail.com> <7384a36941a77cced1fde7e3d084280a@shealevy.com> Message-ID: <2b7ecf3a0dda2687029878e0e745bd73@shealevy.com> X-Sender: shea@shealevy.com User-Agent: Roundcube Webmail/0.8.2 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 208.113.200.129 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Feb 2016 19:34:12 -0000 OK. Do you have any thoughts on how best to extract the "load the=20 kernel and set the command line to a specific string" functionality out=20 of the linux command, then? On 2016-02-12 14:22, Vladimir 'phcoder' Serbinenko wrote: > Separate command is better as it keeps interface tidy and unpoluted, > decreasing maintenance cost. Correct me if I'm wrong but it should be > clear from context of file is Android image or usual linux one? > > Le=C2=A0ven. 12 f=C3=A9vr. 2016 20:19,=C2=A0Shea Levy a =C3=A9crit=C2=A0: > >> On 2016-02-12 12:50, Vladimir '=CF=86-coder/phcoder' Serbinenko wrote: >> > On 08.02.2016 21:47, Shea Levy wrote: >> >> --- >> >>=C2=A0 grub-core/loader/i386/linux.c | 27 +++++++++++++++++++++-----= - >> >>=C2=A0 1 file changed, 21 insertions(+), 6 deletions(-) >> >> >> >> diff --git a/grub-core/loader/i386/linux.c >> >> b/grub-core/loader/i386/linux.c >> >> index fddcc46..6ab8d3c 100644 >> >> --- a/grub-core/loader/i386/linux.c >> >> +++ b/grub-core/loader/i386/linux.c >> >> @@ -35,6 +35,7 @@ >> >>=C2=A0 #include >> >>=C2=A0 #include >> >>=C2=A0 #include >> >> +#include >> >> >> >>=C2=A0 GRUB_MOD_LICENSE ("GPLv3+"); >> >> >> >> @@ -695,7 +696,13 @@ grub_cmd_linux (grub_command_t cmd >> >> __attribute__ ((unused)), >> >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 goto fail; >> >>=C2=A0 =C2=A0 =C2=A0 } >> >> >> >> -=C2=A0 file =3D grub_file_open (argv[0]); >> >> +=C2=A0 char android_cmdline[BOOT_ARGS_SIZE]; >> >> +=C2=A0 android_cmdline[0] =3D ''; >> >> +=C2=A0 if (grub_memcmp (argv[0], "android_bootimg:", sizeof >> >> "android_bootimg:" - 1) =3D=3D 0) >> >> +=C2=A0 =C2=A0 grub_android_bootimg_load_kernel (argv[0] + sizeof >> >> "android_bootimg:" - 1, >> >> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &file,= android_cmdline); >> >> +=C2=A0 else >> >> +=C2=A0 =C2=A0 =C2=A0 file =3D grub_file_open (argv[0]); >> > I hoped more for autodetection. This gets a bit hairy and proper >> > separation is better. Sorry for confusion. I think it's simpler=20 >> with >> > commands like >> > android_bootimg [--no-cmdline] [--no-initrd] IMAGE=20 >> [EXTRA_ARGUMENTS] >> > by default it will load both IMAGE, with cmdline and initrd. With >> > --no-initrd you can use initrd for custom initrd. >> >> Autodetection would be possible actually, I didn't think of that. If >> grub_file_open fails, we can try grub_android_bootimg_load_kernel on=20 >> the >> same file. Would that be preferable or do we still want a separate >> command? >> >> > >> >>=C2=A0 =C2=A0 if (! file) >> >>=C2=A0 =C2=A0 =C2=A0 goto fail; >> >> >> >> @@ -1008,12 +1015,20 @@ grub_cmd_linux (grub_command_t cmd >> >> __attribute__ ((unused)), >> >>=C2=A0 =C2=A0 linux_cmdline =3D grub_zalloc (maximal_cmdline_size + = 1); >> >>=C2=A0 =C2=A0 if (!linux_cmdline) >> >>=C2=A0 =C2=A0 =C2=A0 goto fail; >> >> -=C2=A0 grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof=20 >> (LINUX_IMAGE)); >> >> +=C2=A0 grub_size_t cmdline_offset =3D 0; >> >> +=C2=A0 if (android_cmdline[0]) >> >> +=C2=A0 =C2=A0 { >> >> +=C2=A0 =C2=A0 =C2=A0 cmdline_offset =3D grub_strlen (android_cmdli= ne) + 1; >> >> +=C2=A0 =C2=A0 =C2=A0 grub_memcpy (linux_cmdline, android_cmdline,=20 >> cmdline_offset - >> >> 1); >> >> +=C2=A0 =C2=A0 =C2=A0 linux_cmdline[cmdline_offset - 1] =3D ' '; >> >> +=C2=A0 =C2=A0 } >> >> +=C2=A0 grub_memcpy (linux_cmdline + cmdline_offset, LINUX_IMAGE,=20 >> sizeof >> >> (LINUX_IMAGE)); >> >> +=C2=A0 cmdline_offset +=3D sizeof LINUX_IMAGE - 1; >> > LINUX_IMAGE must be at the beginning. don't forget brackets around >> > sizeof. >> >>=C2=A0 =C2=A0 grub_create_loader_cmdline (argc, argv, >> >> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 linux_cmdline >> >> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 + sizeof (LINUX_IMAGE) - 1, >> >> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 maximal_cmdline_size >> >> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 - (sizeof (LINUX_IMAGE) - 1)); >> >> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 linux_cmdline >> >> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 + cmdline_offset, >> >> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 maximal_cmdline_size >> >> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - cmdline_offset); >> >> >> >>=C2=A0 =C2=A0 len =3D prot_file_size; >> >>=C2=A0 =C2=A0 if (grub_file_read (file, prot_mode_mem, len) !=3D len= && >> >> !grub_errno) >> >> >> > >> > >> > >> > _______________________________________________ >> > Grub-devel mailing list >> > Grub-devel@gnu.org >> > https://lists.gnu.org/mailman/listinfo/grub-devel [1] >> >> _______________________________________________ >> Grub-devel mailing list >> Grub-devel@gnu.org >> https://lists.gnu.org/mailman/listinfo/grub-devel [1] > > > Links: > ------ > [1] https://lists.gnu.org/mailman/listinfo/grub-devel > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel