All of lore.kernel.org
 help / color / mirror / Atom feed
* Standalone Application in GRUB
@ 2012-05-31  6:44 Parul Aggarwal
  2012-05-31  9:46 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 6+ messages in thread
From: Parul Aggarwal @ 2012-05-31  6:44 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 676 bytes --]

Hello,

I have a standalone application which I want to run in GRUB environment
i.e. for e.g at GRUB prompt. So the flow would be I enter grub prompt and
from there run my standalone application binary. By adding multiboot header
to the binary I am able to do that.

Now in my application I want to access GRUB functions for e.g.
grub_printf(), so when I add this to my application and run the application
hangs. Can anyone suggest how to access GRUB functions from my application?
Is it possible?

What is the method defined in GRUB to run a custom application which uses
grub functions? Is grub modules the way or we can go with standalone binary?

Please suggest.

Thanks,

[-- Attachment #2: Type: text/html, Size: 721 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Standalone Application in GRUB
  2012-05-31  6:44 Standalone Application in GRUB Parul Aggarwal
@ 2012-05-31  9:46 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2012-05-31 10:03   ` Parul Aggarwal
  0 siblings, 1 reply; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2012-05-31  9:46 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 1457 bytes --]

On 31.05.2012 08:44, Parul Aggarwal wrote:

> Hello,
> 
> I have a standalone application which I want to run in GRUB environment
> i.e. for e.g at GRUB prompt. So the flow would be I enter grub prompt
> and from there run my standalone application binary. By adding multiboot
> header to the binary I am able to do that.
> 
> Now in my application I want to access GRUB functions for e.g.
> grub_printf(), so when I add this to my application and run the
> application hangs. Can anyone suggest how to access GRUB functions from
> my application? Is it possible?
> 

No. GRUB does a harakiri after launching its payload. No functions is
available after boot.

> What is the method defined in GRUB to run a custom application which
> uses grub functions? Is grub modules the way or we can go with
> standalone binary?
> 

Only GRUB modules can use GRUB functions. But be sure that:
1) You compile it together with the rest of GRUB for dependency tracking
(see also how grub-extras does it)
2) Make sure that your module is under GPLv3+. You can distribute it
dual-licensed under GPLv3+ and something else if you wish but GPLv3+ has
to be one of available licenses.

> Please suggest.
> 
> Thanks,
> 
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel



-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Standalone Application in GRUB
  2012-05-31  9:46 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2012-05-31 10:03   ` Parul Aggarwal
  2012-05-31 10:26     ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 6+ messages in thread
From: Parul Aggarwal @ 2012-05-31 10:03 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 2368 bytes --]

Thanks Vladimir.

1. In uboot we can have standalone application (which uses uboot functions)
compiled and run independently on uboot prompt. As I understand from your
comments that in GRUB this is not possible. We wanted to run the
application in a way similar to memtest in GRUB. But our application wants
to use GRUB functions.

2. If I use dynamically loaded GRUB module for my application, does that
mean that also I cannot compile module independently. Do i need to compile
the whole GRUB for that?

3. Licensing yes i will check.

Regards,
Parul

On Thu, May 31, 2012 at 3:16 PM, Vladimir 'φ-coder/phcoder' Serbinenko <
phcoder@gmail.com> wrote:

> On 31.05.2012 08:44, Parul Aggarwal wrote:
>
> > Hello,
> >
> > I have a standalone application which I want to run in GRUB environment
> > i.e. for e.g at GRUB prompt. So the flow would be I enter grub prompt
> > and from there run my standalone application binary. By adding multiboot
> > header to the binary I am able to do that.
> >
> > Now in my application I want to access GRUB functions for e.g.
> > grub_printf(), so when I add this to my application and run the
> > application hangs. Can anyone suggest how to access GRUB functions from
> > my application? Is it possible?
> >
>
> No. GRUB does a harakiri after launching its payload. No functions is
> available after boot.
>
> > What is the method defined in GRUB to run a custom application which
> > uses grub functions? Is grub modules the way or we can go with
> > standalone binary?
> >
>
> Only GRUB modules can use GRUB functions. But be sure that:
> 1) You compile it together with the rest of GRUB for dependency tracking
> (see also how grub-extras does it)
> 2) Make sure that your module is under GPLv3+. You can distribute it
> dual-licensed under GPLv3+ and something else if you wish but GPLv3+ has
> to be one of available licenses.
>
> > Please suggest.
> >
> > Thanks,
> >
> >
> >
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
>
>
>
> --
> Regards
> Vladimir 'φ-coder/phcoder' Serbinenko
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
>

[-- Attachment #2: Type: text/html, Size: 3188 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Standalone Application in GRUB
  2012-05-31 10:03   ` Parul Aggarwal
@ 2012-05-31 10:26     ` Vladimir 'φ-coder/phcoder' Serbinenko
  2012-06-03 19:00       ` Parul Aggarwal
  0 siblings, 1 reply; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2012-05-31 10:26 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]

On 31.05.2012 12:03, Parul Aggarwal wrote:

> Thanks Vladimir.
> 
> 1. In uboot we can have standalone application (which uses uboot
> functions) compiled and run independently on uboot prompt. As I
> understand from your comments that in GRUB this is not possible. We
> wanted to run the application in a way similar to memtest in GRUB. But
> our application wants to use GRUB functions.

It's not possible because of 3 factors:
- On all platforms except EFI (and EMU) GRUB is prelinked at
predetermined address.
- All protocols except appleloader, EFI chainloader, newer linux, ia64
linux, ppc linux and sparc64 linux also load at predetermined address.
- We don't have a complete control over memory map.
Under such circumstances there is no way to ensure that there is no
overlap between GRUB and payload.
So you can't use GRUB functions.

> 
> 2. If I use dynamically loaded GRUB module for my application, does that
> mean that also I cannot compile module independently. Do i need to
> compile the whole GRUB for that?

Currently dependency tracking is done at compile time and there is no
way to dependency-track 2 sets of modules at the same time. Patches are
welcome.--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Standalone Application in GRUB
  2012-05-31 10:26     ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2012-06-03 19:00       ` Parul Aggarwal
  2012-06-03 19:14         ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 6+ messages in thread
From: Parul Aggarwal @ 2012-06-03 19:00 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 2489 bytes --]

Hi Vladimir,

I understand what you are saying and grub modules seems the right way to
go.

Other two apparoaches I can think of is:

1. Make our standalone appliaction totally independent of GRUB like memtest
application. This way we can go with independent application .bin running.

2. If we statically link the grub libraries to our standalone
application. We tried hello world program using grub_printf, and linked few
grup static libraries. When we run the program the application got hanged.
Seems its because of few undefined symbols used in grub_printf(). Now we
are trying to link glibc (as grub_printf uses this library interally)
static library which should resolve the hang issue.

What do you think on above approaches. Especially point 2 to link static
grub libraries is that way right approach and should be followed?

Appreciate your response.

Regards,
Parul




On Thu, May 31, 2012 at 3:56 PM, Vladimir 'φ-coder/phcoder' Serbinenko <
phcoder@gmail.com> wrote:

> On 31.05.2012 12:03, Parul Aggarwal wrote:
>
> > Thanks Vladimir.
> >
> > 1. In uboot we can have standalone application (which uses uboot
> > functions) compiled and run independently on uboot prompt. As I
> > understand from your comments that in GRUB this is not possible. We
> > wanted to run the application in a way similar to memtest in GRUB. But
> > our application wants to use GRUB functions.
>
> It's not possible because of 3 factors:
> - On all platforms except EFI (and EMU) GRUB is prelinked at
> predetermined address.
> - All protocols except appleloader, EFI chainloader, newer linux, ia64
> linux, ppc linux and sparc64 linux also load at predetermined address.
> - We don't have a complete control over memory map.
> Under such circumstances there is no way to ensure that there is no
> overlap between GRUB and payload.
> So you can't use GRUB functions.
>
> >
> > 2. If I use dynamically loaded GRUB module for my application, does that
> > mean that also I cannot compile module independently. Do i need to
> > compile the whole GRUB for that?
>
> Currently dependency tracking is done at compile time and there is no
> way to dependency-track 2 sets of modules at the same time. Patches are
> welcome.--
> Regards
> Vladimir 'φ-coder/phcoder' Serbinenko
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
>

[-- Attachment #2: Type: text/html, Size: 3234 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Standalone Application in GRUB
  2012-06-03 19:00       ` Parul Aggarwal
@ 2012-06-03 19:14         ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 0 replies; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2012-06-03 19:14 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1052 bytes --]

On 03.06.2012 21:00, Parul Aggarwal wrote:

> Hi Vladimir,
>  
> I understand what you are saying and grub modules seems the right way to
> go.
>  
> Other two apparoaches I can think of is:
>  
> 1. Make our standalone appliaction totally independent of GRUB like
> memtest application. This way we can go with independent application
> .bin running.

You can always do this but you can't use GRUB functions this way.

>  
> 2. If we statically link the grub libraries to our standalone
> application. We tried hello world program using grub_printf, and linked
> few grup static libraries. When we run the program the application got
> hanged.  Seems its because of few undefined symbols used in
> grub_printf(). Now we are trying to link glibc (as grub_printf uses this
> library interally) static library which should resolve the hang issue.
>  

Not going to work. GRUB is not intended to be statically linked in this
sense. GRUB doesn't use any glibc on runtime.

-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-06-03 19:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-31  6:44 Standalone Application in GRUB Parul Aggarwal
2012-05-31  9:46 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-05-31 10:03   ` Parul Aggarwal
2012-05-31 10:26     ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-06-03 19:00       ` Parul Aggarwal
2012-06-03 19:14         ` Vladimir 'φ-coder/phcoder' Serbinenko

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.