Open-Source Internship opportunity by OpenGenus for programmers. Apply now.
UEFI (Unified Extensible Firmware Interface) is the interface between the operating system and the low-level initialization firmware. It initializes hardware components and is responsible for executing the OS stored in a boot device.
Table of contents.
- Introduction.
- Features of UEFI.
- UEFI boot sequence.
- Summary.
- References.
Introduction.
EFI/UEFI defines an interface between the operating system and low-level initialization firmware.
It is comprised of data tables containing platform-related information, boot and run-time service calls available to the operating system and its loader.
It is an improvement over BIOS in that;
- The UEFI firmware is responsible for selecting an OS and not a boot loader therefore we don't need a boot loader.
- Allows vendors to create drivers that can't be reverse-engineered.
- Can be programmed in a high-level language such as C.
- Its interface is object-oriented.
The EFI specification was made a general standard now known as UEFI.
To understand UEFI, let's remember what we learned about BIOS, during startup BIOS reads the first sector of the bootable such as an HDD or USB to find the next jump instruction which has the location of the code(boot loader) to be executed.
On the other hand, UEFI works with an .efi file that is used to store all initialization and startup information that was previously etched into the firmware.
This file is stored in the EFI System Partition(ESP) that will also store boot loaders for the OS.
Features of UEFI.
UEFI is a replacement for BIOS because of its great features that cannot be implemented with BIOS. Some include;
1. Speed and performance.
UEFI is platform-independent therefore we can improve the boot time and speed of a computer, this is useful when we have large drives.
Programmers can also use the UEFI shell to execute commands from other UEFI apps thereby optimizing the system performance.
Speed and performance all depend on the configuration of UEFI.
2. Security.
UEFI prioritizes security compared to BIOS. It comes with secure boot whereby it only allows authentic drivers and services to load at boot time. This is a good way to prevent malware from being loaded to the OS.
Secure boot in Windows is the reason why it is difficult to install another operating system on a windows machine.
3. Size limitations.
While BIOS uses the MBR, UEFI uses GPT(GUID Partitioning Table). The former, MBR, uses 32-bit entries in its table meaning that we can only have 4 physical partitions(not logical).
With GPT, it uses 64-bit entries in its table and this extends the support for larger sizes.
UEFI also supports larger HDDs and SDDs i.e > 9 zettabytes while BIOS can only boot from <= 2.2 TB.
Additional UEFI features are;
- UEFI is written in high-level C programming language which is human-readable, therefore can be easily changed or updated compared to BIOS which is written in low-level assembly code that is architecture-specific.
- UEFI runs in 32-bit or 64-bit mode while BIOS only runs in 16-bit mode while utilizing only 1MB of executable memory.
- UEFI comes with an intuitive GUI which we can navigate with a keyboard or mouse.
- UEFI is maintained by an industry-wide interface forum and thus more manufactures-agnostic than BIOS.
UEFI booting sequence.
The UEFI booting sequence comprises of three phases;
1. SEC - Security phase.
This stage has all the processor initialization code written in assembly code and is responsible for the following;
- Creating a temporary memory store.
- It is the root of trust in the system
- It handles all restart events.
2. PIE - Pre-EFI Initialization phase.
At this stage, the configuration of the entire platform, loading, and booting of the DXE(Driver Execution Environment) happens.
Other responsibilities are;
- Initialization of a permanent memory complement.
- Passing on control to DXE phase - next phase.
- Describing firmware locations(HOBs).
- Describing memory hand-off blocks(HOBs).
3. DXE - Driver eXecution Environment.
UEFI now loads drivers for configured devices. When control is transferred to the OS, DXE runtime stays resident so that it can handle any calls to the UEFI from/to the operating system.
4. BDS - Boot Device Selection.
This stage is implemented as part of the BDS architectural protocol, It is responsible for; initializing console devices, loading drivers, loading boot selections, and executing them.
5. TSL - Transient System Load and RT - Runtime.
TSL is the primary boot loader provided by the OS vendor. Both of these stages TSL and RT allow access to persistent content via the UEFI drivers and applications.
6. AL - After Life.
This phase consists of persistent UEFI drivers that store the state of the system during an orderly sleep, hibernate, restart, or shutdown.
Summary.
UEFI is platform-independent. Therefore, manufacturers don't concern themselves with a specific OS that might run on the computers.
The UEFI configuration is stored in a specified ESP partition mounted at /EFI and not etched directly in the hardware.
With UEFI, there is no need for a boot loader such as GRUB.
All these features make UEFI the superior interface compared with legacy however, there are cases when BIOS is preferred for example, when we need to dual boot or when we have less than 2TB of storage space.