3.7 UEFI images
There are different types of UEFI images, but all UEFI images contain a PE/COFF header that defines the format of the executable code. The PE/COFF image header follows the format defined by the Microsoft Portable Executable and Common Object File Format Specification. The code can be for IA32, X64, IPF, or EBC. The header defines the processor type and the image type. Refer to the UEFI Image section of the Overview chapter in the UEFI Specification for definitions of the processor types and the following three image types:
- UEFI applications
- UEFI boot services drivers
- UEFI runtime drivers
UEFI images are loaded and relocated into memory with the boot service
There are several supported storage locations for UEFI images, including:
- Expansion ROMs on a PCI card
- System ROM or system flash
- A media device such as a hard disk, floppy, CD-ROM, DVD, FLASH drive
- LAN server
In general, UEFI images are not compiled and linked at a specific address. Instead, they are compiled and linked such that relocation fix-ups are included in the UEFI image. This allows the UEFI image to be placed anywhere in system memory. The Boot Service
LoadImage()does the following:
- Allocates memory for the image being loaded
- Automatically applies the relocation fix-ups to the image
- Creates a new image handle in the handle database, which installs an instance of the
This instance of the
EFI_LOADED_IMAGE_PROTOCOLcontains information about the UEFI image that was loaded. Because this information is published in the handle database, it is available to all UEFI components.
After a UEFI image is loaded with
LoadImage(), the image can be started with a call to
StartImage(). The header for a UEFI image contains the address of the entry point called by
StartImage(). The entry point always receives the following two parameters:
- The image handle of the UEFI image being started
- A pointer to the UEFI system table
The image handle and pointer allow the UEFI image to:
- Access all of the UEFI services that are available in the platform.
- Retrieve information about where the UEFI image was loaded from and where in memory the image was placed.
The operations performed by the UEFI image in its entry point vary depending on the type of UEFI image. The figure below shows the various UEFI image types and the relationships between the different levels of images.
The table below describes the types of images shown in the preceding figure.