Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does UEFI boot mode boot flows?

The expression of this question is same as What is UEFI's boot sequence?, but it doesn't seem what I want. I'd like to know UEFI sequence in instruction perspective.

For example, in case of BIOS boot mode, in simplified fashion,

  • Computer power is on.
  • Content of BIOS chip attached to motherboard performs the POST(Power On Self Test) process.
  • BIOS searches for MBR(Master Boot Record)s, which has boot signature in preset boot device order.
  • If MBR with boot signature is found, load the first sector (512 bytes) of the device to DRAM, address 0x7C00. This loaded sector (512 bytes) becomes the "first stage bootloader".
  • BIOS transfers control to this first stage bootloader. In other words, opcode located at physical memory address 0x7C00 in DRAM is executed.

Image

Related article: https://neosmart.net/wiki/mbr-boot-process/

But,

in case of UEFI, I'm having trouble grasping this sequence.

I've already glanced UEFI spec documentation and OS Dev UEFI part.

UEFI: https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf

OS Dev: https://wiki.osdev.org/UEFI

It seems this efi_main() function works as the point equivalent to 0x7C00 in BIOS mode. But how?

Is UEFI firmware doing something like

jmp efi_main

after performing a series of jobs?

Q1. How is UEFI boot mode flows?

Q2. Is there a good UEFI example or tutorial like brokenthorn that of BIOS based?

P.S.

I've seen the news (which years have passed already) that Intel removes BIOS support by 2020.

https://www.anandtech.com/show/12068/intel-to-remove-bios-support-from-uefi-by-2020

It says

Once CSM is removed, the new platforms will be unable to run 32-bit operating systems, unable to use related software (at least natively), and unable to use older hardware, such as RAID HBAs (and therefore older hard drives that are connected to those HBAs), network cards, and even graphics cards that lack UEFI-compatible vBIOS (launched before 2012 – 2013)

Q3. Doesn't it mean that everything related to BIOS booting (first stage bootloader at 0x7C00 and BIOS interrupts and etc) becomes deprecated?

like image 524
YoonSeok OH Avatar asked Sep 19 '19 01:09

YoonSeok OH


People also ask

What is UEFI boot method?

UEFI boot mode refers to the boot process used by UEFI firmware. UEFI stores all the information about initialization and startup in an . efi file that is saved on a special partition called EFI System Partition (ESP).

What happens if I boot from UEFI?

If you're a normal PC user, switching to a computer with UEFI won't be a noticeable change. Your new computer will boot up and shut down faster than it would have with a BIOS, and you can use drives of 2.2 TB or more in size.

How do bootable devices work in UEFI mode?

This article provides information on how bootable devices work in UEFI mode. In order for BIOS to show a UEFI boot option for a fixed disk, there are only two possibilities: The fixed disk has this file: EFI\boot\bootX64.efi stored in the root folder The OS installer has created a boot option on the disk.

What is the UEFI environment in Windows?

The UEFI environment launches the Windows Boot Manager, which determines whether to boot to Full Flash Update (FFU) image flashing or device reset mode, to the update OS, or to the main OS. The following diagram illustrates this process at a high level. Following are additional details about some of the components in this diagram:

Can UEFI boot legacy BIOS?

That's easier in UEFI: There is the EFI System Partition, that is just a FAT32 partition (usually the first one, but that's implementation defined) with PE executables that the UEFI must load and parse (just like Windows does) . Once the CSM is dropped, the legacy BIOS boot won't be supported anymore.

How does the BIOS determine if a device is bootable?

Last but not least it identifies a boot device, one of potentially several partitions flagged as bootable, looks at the boot sector (MBR) and loads it into memory. Now the BIOS proceeds to check each device in it’s specified order for a bootable device.


1 Answers

Q1:

The UEFI boot sequence is devided in multiple "phases", you can find some basic information about each phase here.

To load the SEC phase, the SecCore is located at memory address 0xFFFFFFF0 (this address is mapped to the UEFI Flash Memory) and therefore is the target of the reset vector.

After the dxe phase multiple UEFI Applications can be called before the operating system is loaded.

Q2:

If you want to get a basic understanding of how UEFI works i would recommend the book "Beyond BIOS".

If you want to learn how to write UEFI Drivers/Applications i would recommend to have a look at some of the sample applications in the EDK2 repository (and how to build Applications with it), more details can be found in the specification.

like image 127
MiSimon Avatar answered Oct 01 '22 11:10

MiSimon