public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* What Bios data is sent to the Bootloader/OS ?
@ 2017-08-11 13:00 Rafael Machado
  2017-08-11 22:21 ` Andrew Fish
  2017-08-14 20:49 ` Igor Skochinsky
  0 siblings, 2 replies; 8+ messages in thread
From: Rafael Machado @ 2017-08-11 13:00 UTC (permalink / raw)
  To: edk2-devel@lists.01.org

Hi everyone

I have a question that probably some guys here can help.
The scenario I have, is that I need to create a OS image that must be able
to boot at a UEFI system (with no csm module), and at a legacy bios system.
My fist thought is that this is not possible.

The first thing I see that is different is the what the memory map is
presented to the Bootloader/OS. At legacy bios the int15/0xE820 is used,
and at a UEFI bios the GetMemoryMap() from the boot service is used. Is my
understanding correct?

Besides that. Is there any other change that could not make it possible to
create a single BootloaderLoader/OS image able to boot on a UEFI BIOS(with
no CSM) and on a Legacy Bios ?

I would like to create a list or arguments to talk with my client that
requested this, in case this is really not possible.

The OS in this case is Linux, and the bootloader is Grub or Syslinux.

Thanks and Regards
Rafael R. Machado


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

* Re: What Bios data is sent to the Bootloader/OS ?
  2017-08-11 13:00 What Bios data is sent to the Bootloader/OS ? Rafael Machado
@ 2017-08-11 22:21 ` Andrew Fish
  2017-08-12  3:22   ` Rod Smith
  2017-08-14 20:49 ` Igor Skochinsky
  1 sibling, 1 reply; 8+ messages in thread
From: Andrew Fish @ 2017-08-11 22:21 UTC (permalink / raw)
  To: Rafael Machado; +Cc: edk2-devel@lists.01.org


> On Aug 11, 2017, at 6:00 AM, Rafael Machado <rafaelrodrigues.machado@gmail.com> wrote:
> 
> Hi everyone
> 
> I have a question that probably some guys here can help.
> The scenario I have, is that I need to create a OS image that must be able
> to boot at a UEFI system (with no csm module), and at a legacy bios system.
> My fist thought is that this is not possible.
> 


Rafael,

We designed EFI to co-exist with legacy BIOS  so you could make media that boots both ways. I think it is useful to step back and think about how booting works. 
1) EFI loads a relocatable PE/COFF image that is a file (pointed to by an NVRAM variable, or in a known path for removable media) on a FAT32 file system (Usually the EFI System Partition). 
2) For a legacy hard disk boot the the BIOS loads the 1st 0x200 (512) bytes of the disk (MBR) into 0x7C00 and jumps to it in real mode. The MBR code usually plays a similar trick and loads 1st 0x200 bytes of the boot partition into memory and jump to it, this is usually the start of the file system on the disk partition. 

The 0x200 byte limit in MBR in combination with the 4 partition limit ended up with a lot of creative "grabbing of space" which worked great util different code broke each other. This grabbing "unused space" and the size limits is why we ended up adding GPT to the EFI spec as a next generation partitioning scheme. 

I think your problem is more about can you put a BIOS boot loader and a EFI Boot loader on the same disk and have them boot the same kernel. Seems like most of what the OS loader needs to do is a solved problem, it is just making everything coexist you have to figure out.

Thanks,

Andrew Fish



> The first thing I see that is different is the what the memory map is
> presented to the Bootloader/OS. At legacy bios the int15/0xE820 is used,
> and at a UEFI bios the GetMemoryMap() from the boot service is used. Is my
> understanding correct?
> 
> Besides that. Is there any other change that could not make it possible to
> create a single BootloaderLoader/OS image able to boot on a UEFI BIOS(with
> no CSM) and on a Legacy Bios ?
> 
> I would like to create a list or arguments to talk with my client that
> requested this, in case this is really not possible.
> 
> The OS in this case is Linux, and the bootloader is Grub or Syslinux.
> 
> Thanks and Regards
> Rafael R. Machado
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel



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

* Re: What Bios data is sent to the Bootloader/OS ?
  2017-08-11 22:21 ` Andrew Fish
@ 2017-08-12  3:22   ` Rod Smith
  2017-08-13 13:07     ` Rafael Machado
  0 siblings, 1 reply; 8+ messages in thread
From: Rod Smith @ 2017-08-12  3:22 UTC (permalink / raw)
  To: edk2-devel

On Aug 11, 2017, at 6:00 AM, Rafael Machado
<rafaelrodrigues.machado@gmail.com> wrote:
>>
>> Hi everyone
>>
>> I have a question that probably some guys here can help.
>> The scenario I have, is that I need to create a OS image that must be able
>> to boot at a UEFI system (with no csm module), and at a legacy bios system.
>> My fist thought is that this is not possible.

If I understand you correctly, it most definitely IS possible. Most
major Linux distributions provide installation media that can boot in
either BIOS/CSM/legacy mode or in EFI/UEFI mode. Replicating what those
media do might not be the best way to go, though, since they are also
typically designed to boot when written to optical media or when written
to USB flash drives. To do this, they use a sort of "Frankenstein's
Monster" disk format, so unless you need this cross-media compatibility,
too, using the tools and procedures used to create these installation
media would be overkill and would create something that's overly
complex. These media do illustrate the practicality of what you're
suggesting -- or at least, what I *BELIEVE* you're suggesting. If I've
misinterpreted, please clarify your needs.

>> The OS in this case is Linux, and the bootloader is Grub or Syslinux.

A single GRUB (or SYSLINUX) binary will not do the job; however, there
are both BIOS and EFI builds of both GRUB and SYSLINUX. The details of
what you'd do would depend on the boot medium (hard disk, USB flash
drive, optical disc, etc.); however, broadly speaking you need to write
both BIOS-mode and EFI-mode versions of your chosen boot loader to the
boot medium, with suitable configuration files in appropriate locations.

Both GRUB and SYSLINUX are boot loaders that can load a Linux kernel
into memory. The Linux kernel, in turn, does not need to be built for
either BIOS or EFI environments; the same kernel binary will work in
either environment. (One partial exception is that there's a feature
known as the EFI stub loader that turns the Linux kernel into its own
EFI boot loader. If you wanted to use this feature, it would obviously
need to be compiled into the kernel. GRUB does not require this feature,
though, and its presence will not interfere with the kernel being booted
on a BIOS-based computer. Thus, you probably don't need to worry about
it for your purposes. I mention it simply so you don't think it's an
issue if you read something about it elsewhere.)

-- 
Rod Smith
rodsmith@rodsbooks.com
http://www.rodsbooks.com


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

* Re: What Bios data is sent to the Bootloader/OS ?
  2017-08-12  3:22   ` Rod Smith
@ 2017-08-13 13:07     ` Rafael Machado
  2017-08-13 18:08       ` Andrew Fish
  0 siblings, 1 reply; 8+ messages in thread
From: Rafael Machado @ 2017-08-13 13:07 UTC (permalink / raw)
  To: Rod Smith, edk2-devel

Thanks a lot Andrew and Rod. Your comments clarified a lot.

Just onde last question.
In case of int15/e820 and uefi getMemoryMap. Do you know If this
information os used by the bootloaders?
And do you know the format on these calls outputs? (For the  getMemoryMap
the uefi Spec os clear, but didn't find anything about e820).

Thanks and Regards
Rafael Machado

Em sáb, 12 de ago de 2017 00:23, Rod Smith <rodsmith@rodsbooks.com>
escreveu:

> On Aug 11, 2017, at 6:00 AM, Rafael Machado
> <rafaelrodrigues.machado@gmail.com> wrote:
> >>
> >> Hi everyone
> >>
> >> I have a question that probably some guys here can help.
> >> The scenario I have, is that I need to create a OS image that must be
> able
> >> to boot at a UEFI system (with no csm module), and at a legacy bios
> system.
> >> My fist thought is that this is not possible.
>
> If I understand you correctly, it most definitely IS possible. Most
> major Linux distributions provide installation media that can boot in
> either BIOS/CSM/legacy mode or in EFI/UEFI mode. Replicating what those
> media do might not be the best way to go, though, since they are also
> typically designed to boot when written to optical media or when written
> to USB flash drives. To do this, they use a sort of "Frankenstein's
> Monster" disk format, so unless you need this cross-media compatibility,
> too, using the tools and procedures used to create these installation
> media would be overkill and would create something that's overly
> complex. These media do illustrate the practicality of what you're
> suggesting -- or at least, what I *BELIEVE* you're suggesting. If I've
> misinterpreted, please clarify your needs.
>
> >> The OS in this case is Linux, and the bootloader is Grub or Syslinux.
>
> A single GRUB (or SYSLINUX) binary will not do the job; however, there
> are both BIOS and EFI builds of both GRUB and SYSLINUX. The details of
> what you'd do would depend on the boot medium (hard disk, USB flash
> drive, optical disc, etc.); however, broadly speaking you need to write
> both BIOS-mode and EFI-mode versions of your chosen boot loader to the
> boot medium, with suitable configuration files in appropriate locations.
>
> Both GRUB and SYSLINUX are boot loaders that can load a Linux kernel
> into memory. The Linux kernel, in turn, does not need to be built for
> either BIOS or EFI environments; the same kernel binary will work in
> either environment. (One partial exception is that there's a feature
> known as the EFI stub loader that turns the Linux kernel into its own
> EFI boot loader. If you wanted to use this feature, it would obviously
> need to be compiled into the kernel. GRUB does not require this feature,
> though, and its presence will not interfere with the kernel being booted
> on a BIOS-based computer. Thus, you probably don't need to worry about
> it for your purposes. I mention it simply so you don't think it's an
> issue if you read something about it elsewhere.)
>
> --
> Rod Smith
> rodsmith@rodsbooks.com
> http://www.rodsbooks.com
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>


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

* Re: What Bios data is sent to the Bootloader/OS ?
  2017-08-13 13:07     ` Rafael Machado
@ 2017-08-13 18:08       ` Andrew Fish
  2017-08-14 17:43         ` Rafael Machado
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Fish @ 2017-08-13 18:08 UTC (permalink / raw)
  To: Rafael Machado; +Cc: Rod Smith, edk2-devel


> On Aug 13, 2017, at 6:07 AM, Rafael Machado <rafaelrodrigues.machado@gmail.com> wrote:
> 
> Thanks a lot Andrew and Rod. Your comments clarified a lot.
> 
> Just onde last question.
> In case of int15/e820 and uefi getMemoryMap. Do you know If this
> information os used by the bootloaders?

Yes it is, this is how the OS discovers the memory map. 

> And do you know the format on these calls outputs? (For the  getMemoryMap
> the uefi Spec os clear, but didn't find anything about e820).
> 

The modern version of 0xE820 is documented in the ACPI Spec owned by your friendly UEFI Forum. ACPI Spec is here:  http://www.uefi.org/specifications <http://www.uefi.org/specifications>. 

There are some other specs from the 1990's that may be useful for legacy BIOS. Plug and Play BIOS Specification from 1994, and BIOS Boot Specification from 1996. For older stuff most people use Ralf Brown's interrupt list. You kind find all this old BIOS stuff searching the internwebs. 

Thanks,

Andrew Fish

> Thanks and Regards
> Rafael Machado
> 
> Em sáb, 12 de ago de 2017 00:23, Rod Smith <rodsmith@rodsbooks.com>
> escreveu:
> 
>> On Aug 11, 2017, at 6:00 AM, Rafael Machado
>> <rafaelrodrigues.machado@gmail.com> wrote:
>>>> 
>>>> Hi everyone
>>>> 
>>>> I have a question that probably some guys here can help.
>>>> The scenario I have, is that I need to create a OS image that must be
>> able
>>>> to boot at a UEFI system (with no csm module), and at a legacy bios
>> system.
>>>> My fist thought is that this is not possible.
>> 
>> If I understand you correctly, it most definitely IS possible. Most
>> major Linux distributions provide installation media that can boot in
>> either BIOS/CSM/legacy mode or in EFI/UEFI mode. Replicating what those
>> media do might not be the best way to go, though, since they are also
>> typically designed to boot when written to optical media or when written
>> to USB flash drives. To do this, they use a sort of "Frankenstein's
>> Monster" disk format, so unless you need this cross-media compatibility,
>> too, using the tools and procedures used to create these installation
>> media would be overkill and would create something that's overly
>> complex. These media do illustrate the practicality of what you're
>> suggesting -- or at least, what I *BELIEVE* you're suggesting. If I've
>> misinterpreted, please clarify your needs.
>> 
>>>> The OS in this case is Linux, and the bootloader is Grub or Syslinux.
>> 
>> A single GRUB (or SYSLINUX) binary will not do the job; however, there
>> are both BIOS and EFI builds of both GRUB and SYSLINUX. The details of
>> what you'd do would depend on the boot medium (hard disk, USB flash
>> drive, optical disc, etc.); however, broadly speaking you need to write
>> both BIOS-mode and EFI-mode versions of your chosen boot loader to the
>> boot medium, with suitable configuration files in appropriate locations.
>> 
>> Both GRUB and SYSLINUX are boot loaders that can load a Linux kernel
>> into memory. The Linux kernel, in turn, does not need to be built for
>> either BIOS or EFI environments; the same kernel binary will work in
>> either environment. (One partial exception is that there's a feature
>> known as the EFI stub loader that turns the Linux kernel into its own
>> EFI boot loader. If you wanted to use this feature, it would obviously
>> need to be compiled into the kernel. GRUB does not require this feature,
>> though, and its presence will not interfere with the kernel being booted
>> on a BIOS-based computer. Thus, you probably don't need to worry about
>> it for your purposes. I mention it simply so you don't think it's an
>> issue if you read something about it elsewhere.)
>> 
>> --
>> Rod Smith
>> rodsmith@rodsbooks.com
>> http://www.rodsbooks.com
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
>> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel



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

* Re: What Bios data is sent to the Bootloader/OS ?
  2017-08-13 18:08       ` Andrew Fish
@ 2017-08-14 17:43         ` Rafael Machado
  0 siblings, 0 replies; 8+ messages in thread
From: Rafael Machado @ 2017-08-14 17:43 UTC (permalink / raw)
  To: Andrew Fish; +Cc: Rod Smith, edk2-devel

Hi Andrew.
Thanks a lot for the guidance!!

Rafael R. Machado

Em dom, 13 de ago de 2017 às 15:08, Andrew Fish <afish@apple.com> escreveu:

> On Aug 13, 2017, at 6:07 AM, Rafael Machado <
> rafaelrodrigues.machado@gmail.com> wrote:
>
> Thanks a lot Andrew and Rod. Your comments clarified a lot.
>
> Just onde last question.
> In case of int15/e820 and uefi getMemoryMap. Do you know If this
> information os used by the bootloaders?
>
>
> Yes it is, this is how the OS discovers the memory map.
>
> And do you know the format on these calls outputs? (For the  getMemoryMap
> the uefi Spec os clear, but didn't find anything about e820).
>
>
> The modern version of 0xE820 is documented in the ACPI Spec owned by your
> friendly UEFI Forum. ACPI Spec is here:
> http://www.uefi.org/specifications.
>
> There are some other specs from the 1990's that may be useful for legacy
> BIOS. Plug and Play BIOS Specification from 1994, and BIOS Boot
> Specification from 1996. For older stuff most people use Ralf Brown's
> interrupt list. You kind find all this old BIOS stuff searching the
> internwebs.
>
> Thanks,
>
> Andrew Fish
>
> Thanks and Regards
> Rafael Machado
>
> Em sáb, 12 de ago de 2017 00:23, Rod Smith <rodsmith@rodsbooks.com>
> escreveu:
>
> On Aug 11, 2017, at 6:00 AM, Rafael Machado
> <rafaelrodrigues.machado@gmail.com> wrote:
>
>
> Hi everyone
>
> I have a question that probably some guys here can help.
> The scenario I have, is that I need to create a OS image that must be
>
> able
>
> to boot at a UEFI system (with no csm module), and at a legacy bios
>
> system.
>
> My fist thought is that this is not possible.
>
>
> If I understand you correctly, it most definitely IS possible. Most
> major Linux distributions provide installation media that can boot in
> either BIOS/CSM/legacy mode or in EFI/UEFI mode. Replicating what those
> media do might not be the best way to go, though, since they are also
> typically designed to boot when written to optical media or when written
> to USB flash drives. To do this, they use a sort of "Frankenstein's
> Monster" disk format, so unless you need this cross-media compatibility,
> too, using the tools and procedures used to create these installation
> media would be overkill and would create something that's overly
> complex. These media do illustrate the practicality of what you're
> suggesting -- or at least, what I *BELIEVE* you're suggesting. If I've
> misinterpreted, please clarify your needs.
>
> The OS in this case is Linux, and the bootloader is Grub or Syslinux.
>
>
> A single GRUB (or SYSLINUX) binary will not do the job; however, there
> are both BIOS and EFI builds of both GRUB and SYSLINUX. The details of
> what you'd do would depend on the boot medium (hard disk, USB flash
> drive, optical disc, etc.); however, broadly speaking you need to write
> both BIOS-mode and EFI-mode versions of your chosen boot loader to the
> boot medium, with suitable configuration files in appropriate locations.
>
> Both GRUB and SYSLINUX are boot loaders that can load a Linux kernel
> into memory. The Linux kernel, in turn, does not need to be built for
> either BIOS or EFI environments; the same kernel binary will work in
> either environment. (One partial exception is that there's a feature
> known as the EFI stub loader that turns the Linux kernel into its own
> EFI boot loader. If you wanted to use this feature, it would obviously
> need to be compiled into the kernel. GRUB does not require this feature,
> though, and its presence will not interfere with the kernel being booted
> on a BIOS-based computer. Thus, you probably don't need to worry about
> it for your purposes. I mention it simply so you don't think it's an
> issue if you read something about it elsewhere.)
>
> --
> Rod Smith
> rodsmith@rodsbooks.com
> http://www.rodsbooks.com
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>
>


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

* Re: What Bios data is sent to the Bootloader/OS ?
  2017-08-11 13:00 What Bios data is sent to the Bootloader/OS ? Rafael Machado
  2017-08-11 22:21 ` Andrew Fish
@ 2017-08-14 20:49 ` Igor Skochinsky
  2017-08-16  9:56   ` Rafael Machado
  1 sibling, 1 reply; 8+ messages in thread
From: Igor Skochinsky @ 2017-08-14 20:49 UTC (permalink / raw)
  To: Rafael Machado; +Cc: edk2-devel@lists.01.org

Hi Rafael,

It's certainly possible although not trivial.
One possible approach is DUET which can emulate UEFI environment on top of
the legacy BIOS. So you could have your legacy bootloader load DUET, which
would in turn load and boot the UEFI-compatible OS. This page may be of
use: http://www.rodsbooks.com/bios2uefi/index.html

AFAIK GRUB already supports both BIOS and UEFI booting, so you may not have
to do anything except set it up correctly.

On Fri, Aug 11, 2017 at 3:00 PM, Rafael Machado <
rafaelrodrigues.machado@gmail.com> wrote:

> Hi everyone
>
> I have a question that probably some guys here can help.
> The scenario I have, is that I need to create a OS image that must be able
> to boot at a UEFI system (with no csm module), and at a legacy bios system.
> My fist thought is that this is not possible.
>
> The first thing I see that is different is the what the memory map is
> presented to the Bootloader/OS. At legacy bios the int15/0xE820 is used,
> and at a UEFI bios the GetMemoryMap() from the boot service is used. Is my
> understanding correct?
>
> Besides that. Is there any other change that could not make it possible to
> create a single BootloaderLoader/OS image able to boot on a UEFI BIOS(with
> no CSM) and on a Legacy Bios ?
>
> I would like to create a list or arguments to talk with my client that
> requested this, in case this is really not possible.
>
> The OS in this case is Linux, and the bootloader is Grub or Syslinux.
>
> Thanks and Regards
> Rafael R. Machado
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>



-- 
WBR, Igor


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

* Re: What Bios data is sent to the Bootloader/OS ?
  2017-08-14 20:49 ` Igor Skochinsky
@ 2017-08-16  9:56   ` Rafael Machado
  0 siblings, 0 replies; 8+ messages in thread
From: Rafael Machado @ 2017-08-16  9:56 UTC (permalink / raw)
  To: Igor Skochinsky; +Cc: edk2-devel@lists.01.org

Hi Igor

Nice catch.
Thanks for this idea!

Rafael Machado

On seg, 14 de ago de 2017 17:49 Igor Skochinsky <skochinsky@gmail.com>
wrote:

>
> Hi Rafael,
>
> It's certainly possible although not trivial.
> One possible approach is DUET which can emulate UEFI environment on top of
> the legacy BIOS. So you could have your legacy bootloader load DUET, which
> would in turn load and boot the UEFI-compatible OS. This page may be of
> use: http://www.rodsbooks.com/bios2uefi/index.html
>
> AFAIK GRUB already supports both BIOS and UEFI booting, so you may not
> have to do anything except set it up correctly.
>
> On Fri, Aug 11, 2017 at 3:00 PM, Rafael Machado <
> rafaelrodrigues.machado@gmail.com> wrote:
>
>> Hi everyone
>>
>> I have a question that probably some guys here can help.
>> The scenario I have, is that I need to create a OS image that must be able
>> to boot at a UEFI system (with no csm module), and at a legacy bios
>> system.
>> My fist thought is that this is not possible.
>>
>> The first thing I see that is different is the what the memory map is
>> presented to the Bootloader/OS. At legacy bios the int15/0xE820 is used,
>> and at a UEFI bios the GetMemoryMap() from the boot service is used. Is my
>> understanding correct?
>>
>> Besides that. Is there any other change that could not make it possible to
>> create a single BootloaderLoader/OS image able to boot on a UEFI BIOS(with
>> no CSM) and on a Legacy Bios ?
>>
>> I would like to create a list or arguments to talk with my client that
>> requested this, in case this is really not possible.
>>
>> The OS in this case is Linux, and the bootloader is Grub or Syslinux.
>>
>> Thanks and Regards
>> Rafael R. Machado
>>
> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
>>
>
>
>
> --
> WBR, Igor
>


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

end of thread, other threads:[~2017-08-16  9:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-11 13:00 What Bios data is sent to the Bootloader/OS ? Rafael Machado
2017-08-11 22:21 ` Andrew Fish
2017-08-12  3:22   ` Rod Smith
2017-08-13 13:07     ` Rafael Machado
2017-08-13 18:08       ` Andrew Fish
2017-08-14 17:43         ` Rafael Machado
2017-08-14 20:49 ` Igor Skochinsky
2017-08-16  9:56   ` Rafael Machado

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox