Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aV3l2-0000rx-ED for mharc-grub-devel@gnu.org; Sun, 14 Feb 2016 15:59:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aV3ky-0000kr-LM for grub-devel@gnu.org; Sun, 14 Feb 2016 15:59:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aV3kv-0002vl-Bh for grub-devel@gnu.org; Sun, 14 Feb 2016 15:59:00 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:27156) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aV3ku-0002uf-VE for grub-devel@gnu.org; Sun, 14 Feb 2016 15:58:57 -0500 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u1EKwnlO004662 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 14 Feb 2016 20:58:49 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u1EKwm8P011306 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 14 Feb 2016 20:58:48 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u1EKwmY6027290 for ; Sun, 14 Feb 2016 20:58:48 GMT Received: from [192.168.2.109] (/73.189.216.229) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 14 Feb 2016 12:58:48 -0800 From: Seth Goldberg Content-Type: multipart/alternative; boundary=Apple-Mail-B954027D-D1D0-4325-9C5D-A223C634774F Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v3 2/3] i386: Add support for loading from android bootimg Message-Id: <68B03F79-6B46-4AEA-A573-9782E56BADE3@oracle.com> Date: Sun, 14 Feb 2016 12:58:47 -0800 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> <2b7ecf3a0dda2687029878e0e745bd73@shealevy.com> <56BE4BB7.6040203@gmail.com> In-Reply-To: To: The development of GNU GRUB X-Mailer: iPhone Mail (13D15) X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 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: Sun, 14 Feb 2016 20:59:03 -0000 --Apple-Mail-B954027D-D1D0-4325-9C5D-A223C634774F Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > On Feb 14, 2016, at 5:26 AM, Vladimir 'phcoder' Serbinenko wrote: >=20 >=20 >=20 > Le dim. 14 f=C3=A9vr. 2016 14:21, Shea Levy a =C3=A9cr= it : >> This patch uses grub_file_open, but the android bootimg is a disk, not >> a file. You mentioned something about file_offset_open, but that also >> expects an input file, not a disk. Should I modify your patch with my >> code I wrote to create a grub_file_t from an android_bootimg disk >> device, or is there another approach? >=20 > We already have syntax (hd0,1)+ that we use for i.a. ch= ainloader perhaps we should extend it to have (hd0,1)+ meaning whole disk as= file? Or even allow the disk to be opened with GRUB_file_open? I'd like a s= econd opinion on this. Andrei, what do you think? I think syntax that allows a whole disk to be specified (e.g. To the multi= boot module command so a disk image can be passed that way) is a great idea.= --S >>=20 >> On 2016-02-12 16:16, Vladimir '=CF=86-coder/phcoder' Serbinenko wrote: >> > On 12.02.2016 20:34, Shea Levy wrote: >> >> OK. Do you have any thoughts on how best to extract the "load the >> >> kernel >> >> and set the command line to a specific string" functionality out of >> >> the >> >> linux command, then? >> >> >> > At first I wanted to write a short skeleton patch to show what I >> > meant >> > but once skeleton is done, there is little actual code involved. >> > Please >> > try attached patch >> >> 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 ven. 12 f=C3=A9vr. 2016 20:19, Shea Levy a =C3= =A9crit >> >>> : >> >>> >> >>>> On 2016-02-12 12:50, Vladimir '=CF=86-coder/phcoder' Serbinenko wrot= e: >> >>>> > On 08.02.2016 21:47, Shea Levy wrote: >> >>>> >> --- >> >>>> >> grub-core/loader/i386/linux.c | 27 +++++++++++++++++++++------ >> >>>> >> 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 @@ >> >>>> >> #include >> >>>> >> #include >> >>>> >> #include >> >>>> >> +#include >> >>>> >> >> >>>> >> GRUB_MOD_LICENSE ("GPLv3+"); >> >>>> >> >> >>>> >> @@ -695,7 +696,13 @@ grub_cmd_linux (grub_command_t cmd >> >>>> >> __attribute__ ((unused)), >> >>>> >> goto fail; >> >>>> >> } >> >>>> >> >> >>>> >> - file =3D grub_file_open (argv[0]); >> >>>> >> + char android_cmdline[BOOT_ARGS_SIZE]; >> >>>> >> + android_cmdline[0] =3D ''; >> >>>> >> + if (grub_memcmp (argv[0], "android_bootimg:", sizeof >> >>>> >> "android_bootimg:" - 1) =3D=3D 0) >> >>>> >> + grub_android_bootimg_load_kernel (argv[0] + sizeof >> >>>> >> "android_bootimg:" - 1, >> >>>> >> + &file, android_cmdline); >> >>>> >> + else >> >>>> >> + 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 >> >>>> with >> >>>> > commands like >> >>>> > android_bootimg [--no-cmdline] [--no-initrd] IMAGE >> >>>> [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 the >> >>>> same file. Would that be preferable or do we still want a separate >> >>>> command? >> >>>> >> >>>> > >> >>>> >> if (! file) >> >>>> >> goto fail; >> >>>> >> >> >>>> >> @@ -1008,12 +1015,20 @@ grub_cmd_linux (grub_command_t cmd >> >>>> >> __attribute__ ((unused)), >> >>>> >> linux_cmdline =3D grub_zalloc (maximal_cmdline_size + 1); >> >>>> >> if (!linux_cmdline) >> >>>> >> goto fail; >> >>>> >> - grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof >> >>>> (LINUX_IMAGE)); >> >>>> >> + grub_size_t cmdline_offset =3D 0; >> >>>> >> + if (android_cmdline[0]) >> >>>> >> + { >> >>>> >> + cmdline_offset =3D grub_strlen (android_cmdline) + 1; >> >>>> >> + grub_memcpy (linux_cmdline, android_cmdline, >> >>>> cmdline_offset - >> >>>> >> 1); >> >>>> >> + linux_cmdline[cmdline_offset - 1] =3D ' '; >> >>>> >> + } >> >>>> >> + grub_memcpy (linux_cmdline + cmdline_offset, LINUX_IMAGE, >> >>>> sizeof >> >>>> >> (LINUX_IMAGE)); >> >>>> >> + cmdline_offset +=3D sizeof LINUX_IMAGE - 1; >> >>>> > LINUX_IMAGE must be at the beginning. don't forget brackets >> >>>> around >> >>>> > sizeof. >> >>>> >> grub_create_loader_cmdline (argc, argv, >> >>>> >> - linux_cmdline >> >>>> >> - + sizeof (LINUX_IMAGE) - 1, >> >>>> >> - maximal_cmdline_size >> >>>> >> - - (sizeof (LINUX_IMAGE) - 1)); >> >>>> >> + linux_cmdline >> >>>> >> + + cmdline_offset, >> >>>> >> + maximal_cmdline_size >> >>>> >> + - cmdline_offset); >> >>>> >> >> >>>> >> len =3D prot_file_size; >> >>>> >> 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 >> >> >> >> >> >> _______________________________________________ >> >> Grub-devel mailing list >> >> Grub-devel@gnu.org >> >> https://lists.gnu.org/mailman/listinfo/grub-devel >> > >> > >> > _______________________________________________ >> > Grub-devel mailing list >> > Grub-devel@gnu.org >> > https://lists.gnu.org/mailman/listinfo/grub-devel >>=20 >>=20 >> _______________________________________________ >> Grub-devel mailing list >> Grub-devel@gnu.org >> https://lists.gnu.org/mailman/listinfo/grub-devel > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel --Apple-Mail-B954027D-D1D0-4325-9C5D-A223C634774F Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Feb 1= 4, 2016, at 5:26 AM, Vladimir 'phcoder' Serbinenko <phcoder@gmail.com> wrote:



Le = ;dim. 14 f=C3=A9vr. 2016 14:21, Shea Levy <shea@shealevy.com> a =C3=A9crit :
This patch uses grub_file_open, but the android bootimg= is a disk, not
a file. You mentioned something about file_offset_open, but that also
expects an input file, not a disk. Should I modify your patch with my
code I wrote to create a grub_file_t from an android_bootimg disk
device, or is there another approach?
We already h= ave syntax (hd0,1)+<number of sectors> that we use for i.a. chainloade= r perhaps we should extend it to have (hd0,1)+ meaning whole disk as file? O= r even allow the disk to be opened with GRUB_file_open? I'd like a second op= inion on this. Andrei, what do you think?

<= /div>
  I think syntax that allows a whole disk to be specified (e.= g. To the multiboot module command so a disk image can be passed that way) i= s a great idea.

  --S


=

On 2016-02-12 16:16, Vladimir '=CF=86-coder/phcoder' Serbinenko wrote:
> On 12.02.2016 20:34, Shea Levy wrote:
>> OK. Do you have any thoughts on how best to extract the "load the >> kernel
>> and set the command line to a specific string" functionality out of=
>> the
>> linux command, then?
>>
> At first I wanted to write a short skeleton patch to show what I
> meant
> but once skeleton is done, there is little actual code involved.
> Please
> try attached patch
>> 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 sho= uld
>>> be
>>> clear from context of file is Android image or usual linux one?=
>>>
>>> Le ven. 12 f=C3=A9vr. 2016 20:19, Shea Levy <shea@shealevy.com> a =C3=A9cr= it
>>> :
>>>
>>>> On 2016-02-12 12:50, Vladimir '=CF=86-coder/phcoder' Serbin= enko wrote:
>>>> > On 08.02.2016 21:47, Shea Levy wrote:
>>>> >> ---
>>>> >>  grub-core/loader/i386/linux.c | 27 +++++++++= ++++++++++++------
>>>> >>  1 file changed, 21 insertions(+), 6 deletion= s(-)
>>>> >>
>>>> >> 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 @@
>>>> >>  #include <grub/i18n.h>
>>>> >>  #include <grub/lib/cmdline.h>
>>>> >>  #include <grub/linux.h>
>>>> >> +#include <grub/android_bootimg.h>
>>>> >>
>>>> >>  GRUB_MOD_LICENSE ("GPLv3+");
>>>> >>
>>>> >> @@ -695,7 +696,13 @@ grub_cmd_linux (grub_command_= t cmd
>>>> >> __attribute__ ((unused)),
>>>> >>        goto fail;
>>>> >>      }
>>>> >>
>>>> >> -  file =3D grub_file_open (argv[0]);
>>>> >> +  char android_cmdline[BOOT_ARGS_SIZE];
>>>> >> +  android_cmdline[0] =3D '';
>>>> >> +  if (grub_memcmp (argv[0], "android_bootimg= :", sizeof
>>>> >> "android_bootimg:" - 1) =3D=3D 0)
>>>> >> +    grub_android_bootimg_load_kernel (a= rgv[0] + sizeof
>>>> >> "android_bootimg:" - 1,
>>>> >> +              &= nbsp;                     &= nbsp; &file, android_cmdline);
>>>> >> +  else
>>>> >> +      file =3D grub_file_open (arg= v[0]);
>>>> > I hoped more for autodetection. This gets a bit hairy a= nd proper
>>>> > separation is better. Sorry for confusion. I think it'= s simpler
>>>> with
>>>> > commands like
>>>> > android_bootimg [--no-cmdline] [--no-initrd] IMAGE
= >>>> [EXTRA_ARGUMENTS]
>>>> > by default it will load both IMAGE, with cmdline and i= nitrd.
>>>> 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 the
>>>> same file. Would that be preferable or do we still want a s= eparate
>>>> command?
>>>>
>>>> >
>>>> >>    if (! file)
>>>> >>      goto fail;
>>>> >>
>>>> >> @@ -1008,12 +1015,20 @@ grub_cmd_linux (grub_comma= nd_t cmd
>>>> >> __attribute__ ((unused)),
>>>> >>    linux_cmdline =3D grub_zalloc (maxima= l_cmdline_size + 1);
>>>> >>    if (!linux_cmdline)
>>>> >>      goto fail;
>>>> >> -  grub_memcpy (linux_cmdline, LINUX_IMAGE, s= izeof
>>>> (LINUX_IMAGE));
>>>> >> +  grub_size_t cmdline_offset =3D 0;
>>>> >> +  if (android_cmdline[0])
>>>> >> +    {
>>>> >> +      cmdline_offset =3D grub_strl= en (android_cmdline) + 1;
>>>> >> +      grub_memcpy (linux_cmdline, a= ndroid_cmdline,
>>>> cmdline_offset -
>>>> >> 1);
>>>> >> +      linux_cmdline[cmdline_offset= - 1] =3D ' ';
>>>> >> +    }
>>>> >> +  grub_memcpy (linux_cmdline + cmdline_offse= t, LINUX_IMAGE,
>>>> sizeof
>>>> >> (LINUX_IMAGE));
>>>> >> +  cmdline_offset +=3D sizeof LINUX_IMAGE - 1= ;
>>>> > LINUX_IMAGE must be at the beginning. don't forget bra= ckets
>>>> around
>>>> > sizeof.
>>>> >>    grub_create_loader_cmdline (argc, arg= v,
>>>> >> -              &= nbsp;           linux_cmdline
>>>> >> -              &= nbsp;           + sizeof (LINUX_IMAGE) - 1,
>>>> >> -              &= nbsp;           maximal_cmdline_size
>>>> >> -              &= nbsp;           - (sizeof (LINUX_IMAGE) - 1));
>>>> >> +              &= nbsp;               linux_cmdline
>>>> >> +              &= nbsp;               + cmdline_offset,
= >>>> >> +              &= nbsp;               maximal_cmdline_size<= br> >>>> >> +              &= nbsp;               - cmdline_offset); >>>> >>
>>>> >>    len =3D prot_file_size;
>>>> >>    if (grub_file_read (file, prot_mode_m= em, len) !=3D len &&
>>>> >> !grub_errno)
>>>> >>
>>>> >
>>>> >
>>>> >
>>>> > _______________________________________________
>>>> > Grub-devel mailing list
>>>> > Grub-devel@gnu.org
>>>> > https://lists.gnu.org/mailman/l= istinfo/grub-devel [1]
>>>>
>>>> _______________________________________________
>>>> Grub-devel mailing list
>>>> Gru= b-devel@gnu.org
>>>> https://lists.gnu.org/mailman/listin= fo/grub-devel [1]
>>>
>>>
>>> Links:
>>> ------
>>> [1] https://lists.gnu.org/mailman/listin= fo/grub-devel
>>>
>>> _______________________________________________
>>> Grub-devel mailing list
>>> Grub-de= vel@gnu.org
>>> https://lists.gnu.org/mailman/listinfo/g= rub-devel
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@= gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-d= evel
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.= org
> https://lists.gnu.org/mailman/listinfo/grub-deve= l


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel=
____________________= ___________________________
Grub-devel mailing listGrub-devel@gnu.org<= br>https= ://lists.gnu.org/mailman/listinfo/grub-devel
= --Apple-Mail-B954027D-D1D0-4325-9C5D-A223C634774F--