UEFI Graphics Output Protocol Blt Function Explained
The UEFI Graphics Output Protocol (GOP) provides a runtime and
boot-time interface for displaying graphical content prior to the
operating system loading its native graphics drivers. Within this
protocol, the Blt (Block Transfer) function serves as the
primary mechanism for manipulating blocks of pixels on the screen. This
article explains the architectural purpose of the Blt
function, its key operations, and why UEFI firmware and bootloaders rely
on it for display management.
Purpose of the Blt Function
The primary purpose of the Blt function is to provide an
abstracted, hardware-independent method for reading, writing, and
copying rectangular areas of pixels on a display device. Before full
operating system device drivers are initialized, firmware and
bootloaders need a reliable way to render graphical user interfaces,
boot logos, text consoles, and status bars.
While GOP also provides access to a raw linear framebuffer,
interacting directly with memory addresses can introduce compatibility
issues due to variations in pixel formats, color depth, and
memory-mapping architectures. The Blt function abstracts
these complexities, allowing developers to manipulate standard 32-bit
color data (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) without directly
managing hardware-specific video memory layouts.
Blt Operations
The Blt function executes different graphical tasks
based on the specified EFI_GRAPHICS_OUTPUT_BLT_OPERATION
parameter:
- Video Fill (
EfiBltVideoFill): Fills a specified rectangular area on the display with a single, uniform color. This is typically used for clearing the screen, drawing solid backgrounds, or rendering simple rectangular UI elements. - Buffer to Video (
EfiBltBufferToVideo): Copies an image stored in system memory (the Blt buffer) directly to a target coordinate on the display. This operation is essential for rendering pre-rendered assets such as operating system logos, complex icons, and software-rendered fonts. - Video to Blt Buffer
(
EfiBltVideoToBltBuffer): Reads a rectangular region of pixels from the display and copies it into a system memory buffer. This is commonly used for capturing screenshots or saving background areas before drawing temporary overlays like pop-up dialogs. - Video to Video (
EfiBltVideoToVideo): Copies a block of pixels directly from one location on the screen to another. This is heavily utilized for hardware-accelerated scrolling in graphical terminal emulators or moving interface elements efficiently without transferring data back through system memory.
Advantages Over Direct Framebuffer Writes
By using the Blt function, UEFI applications benefit
from automatic format translation. The standard Blt pixel structure uses
an 8-bit per channel Red-Green-Blue-Reserved layout. If the underlying
hardware display is configured for a different color representation
(such as Blue-Green-Red-Reserved or a non-standard bitmask), the GOP
implementation handles the color channel translation transparently.
Additionally, implementations may utilize underlying hardware
acceleration features if available in the firmware, resulting in faster
visual updates than unoptimized direct memory access.