11

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?

YoonSeok OH
  • 647
  • 2
  • 7
  • 15
  • 2
    UEFI has a modular structure, with many components. The boot process is entangled with the hardware initialisation and security considerations. In short, which part are you interested in? The final one, the loading of the OS? 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. However it is relatively easy to make an UEFI shim to bring it back. – Margaret Bloom Sep 19 '19 at 07:02
  • Thank you again Margaret Bloom! The part I am interested in is UEFI boot mode's simplified process from power on to UEFI bootloader control transfer (Q1), there is a diagram in UEFI spec document "2 - Overview" section, but it was difficult to understand for me... Also, I'm interested in practical exercise of writing custom bootloader in UEFI mode to follow to see (Q2). I just found here https://hackerpulp.com/os/os-development-windows-1-building-uefi-applications-nasm/ – YoonSeok OH Sep 19 '19 at 08:08
  • [Google image has a lot of diagrams](https://www.google.it/search?q=uefi+dxe+init&tbm=isch), maybe they leads somewhere. – Margaret Bloom Sep 19 '19 at 08:12
  • Thanks to your help I just found here. https://answers.microsoft.com/en-us/windows/forum/windows8_1-security/uefi-secure-boot-in-windows-81/65d74e19-9572-4a91-85aa-57fa783f0759 – YoonSeok OH Sep 19 '19 at 08:26

1 Answers1

11

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.

MiSimon
  • 1,225
  • 1
  • 8
  • 10
  • Thank you for answer MiSimon! I must have a precise look at the link you've given. Thank you for the book recommendation too! This seems to be the book you've spoken https://www.microbe.cz/docs/Beyond_BIOS_Second_Edition_Digital_Edition_(15-12-10)%20.pdf – YoonSeok OH Sep 19 '19 at 08:15
  • You're welcome! This is the book there is also a 3rd edition available. – MiSimon Sep 19 '19 at 08:20