OVMF, open virtual machine firmware, is project from EDK-II which to support UEFI for virtual machines. It contains a sample firmware for QEMU and KVM
Its source is under the OvmfPkg directory within EDK-II source code. it could run UEFI shell and boot Linux in UEFI boot.
1. Building OVMF
check edk2 build process, you will find the binaries under Build/*/*/FV directory. and file OVMF.FD, this is aUEFI virtual version. Sample command like below:
OvmfPkg/build.sh -a X64 qemu
For arm architecture, use this
/uefi-tools/uefi-build.sh -b DEBUG -b RELEASE qemu64
and the firmware image is at
2. Running OVMF
It could use option -pflash to flash0.img or -bios or -L to OVMF.FD. Detail check reference 2. Sample command line like below:
$ qemu-system-aarch64 \ -m 1024 \ -cpu cortex-a57 \ -M virt \ -pflash flash0.img \ -pflash flash1.img \ -serial stdio
3. Booting order for OVMF
3.1 SEC - Security
When push the power button, system gets in SEC phase, no ram memory could be used now. So its CAM(cache as memory), CPU becomes protect mode, no necessary for real-mode like bios. It evolves Assembly operation here.
3.2 PEI - Pre-EFI Initialization Enviroment
Initialize memory, cpu and chipset. It works on ROM.
it needs to know boot path, system ram and firmware volume. and enable DXEIPL(DXE Initial Program Loader) which could lead to next phase.
3.3 DXE - Driver Execution Enviroment
Important phase. Most work is done here. Create Boot Services Runtime Services and DXE Services, will disappear getting in RT phase. Initialize UEFI platform and provide all services to load system kernel.
3.4 BDS - Boot Device Select
Trying to load all drivers list in Driver and booting OS. When loading drivers, it need to interactive with DXE, once all drivers is ready, it starts booting os, and close DXE totally.
3.5 TSL - Transient System Load
OS boot loader shell.
3.6 RF - Run Time
Only left EFI Runtime Serivce and EFI System Table could be used.
3.7 AL - After Life
EFI Runtime Service ResetSystem() or ACPI Sleep State.
4. ACPI - Advanced Configuration and Power Interface
UEFI + ACPI is a new boot mode for modern computer architecture. One important part of UEFI is to pass the ACPI table created by firmware to OS kernel, and these tables will be used for OS to do power management for all physical devices. Detail will be introduced in other wiki link soon.
OVMS is still a new techniques in QEMU, there are still some problems, especially in ARM architecture. But with the help of QEMU, it will apply UEFI to real physical environment very soon.