Role of UEFI Runtime Services After OS Boot
UEFI Runtime Services are a specialized set of firmware interfaces that remain active in system memory even after the operating system has fully initialized. Unlike Boot Services, which are discarded during the handoff to the OS to free up memory, Runtime Services bridge the gap between running software and underlying hardware. They provide the operating system with low-level capabilities to manage persistent configuration data, adjust hardware clocks, control system power states, and deploy firmware updates directly from the operating environment.
Transition from Boot to Runtime
During the startup process, the UEFI firmware initializes system
hardware and loads the OS bootloader. Once the operating system kernel
is ready to assume control of the computer's resources, it calls the
ExitBootServices() function. This terminates all UEFI Boot
Services, reclaiming that memory for the OS.
However, the operating system preserves the memory regions containing
UEFI Runtime Services and remaps their physical addresses to virtual
memory addresses using the SetVirtualAddressMap() call.
This ensures the kernel can invoke firmware routines safely during
standard operation.
Core Functions of Runtime Services
Runtime Services expose standardized functions defined by the UEFI specification. These functions are divided into several key operational areas:
1. Non-Volatile Variable Management
The operating system constantly needs to read, write, and query platform settings stored in non-volatile storage (NVRAM). Runtime Services provide three primary APIs for this purpose:
GetVariable: Reads the value of a specific firmware environment variable, such as the active boot order, Secure Boot status, or platform language settings.SetVariable: Modifies existing variables or creates new ones. Operating systems utilize this to alter the boot priority for the next reboot or install Secure Boot keys.QueryVariableInfo: Determines the remaining storage capacity and maximum variable size in the NVRAM to prevent storage exhaustion.
2. Hardware Time and Wakeup Management
Operating systems maintain software-based clocks, but they synchronize with and schedule platform hardware using Runtime Time Services:
GetTimeandSetTime: Reads and writes the Real-Time Clock (RTC) on the motherboard, ensuring proper system time across power cycles.GetWakeupTimeandSetWakeupTime: Enables the OS to configure hardware alarms that can wake a system from sleep or low-power states at a designated time.
3. Power Management and System Resets
While Advanced Configuration and Power Interface (ACPI) handles most everyday power transitions, UEFI Runtime Services provide standard fallback mechanisms for system termination:
ResetSystem: Executes direct hardware resets. The OS passes parameters indicating the reset type: cold reset (full power cycle), warm reset (reboot without cutting main power), shutdown (power off), or platform-specific resets.
4. Capsule-Based Firmware Updates
UEFI provides a standardized method for operating systems to deliver firmware updates via Capsule Services:
UpdateCapsule: Passes an update payload (capsule) from the OS to the firmware. The payload is stored in memory across a warm reboot, enabling the firmware to flash itself before the OS boots again.QueryCapsuleCapabilities: Checks whether the system firmware supports a specific update format and confirms that the payload fits within available memory.
Importance to Modern Operating Systems
By providing these functions, UEFI Runtime Services abstract away motherboard-specific hardware implementations. Operating system kernels do not require specialized drivers for every vendor's unique NVRAM chip or RTC controller. Instead, the OS relies on a uniform API to control essential platform configurations securely throughout its runtime.