Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Rikitav/Unified.Firmware/llms.txt
Use this file to discover all available pages before exploring further.
FirmwareInterface is the top-level static entry point for the Unified.Firmware library. It selects the correct platform backend for the current operating system, exposes a simple boolean check for UEFI availability, provides a DirectoryInfo handle to the EFI System Partition, and offers a one-call method to schedule a reboot into the firmware user interface. All UEFI work in the library flows through this class first.
Namespace: Unified.Firmware
Properties
CurrentBackend
Returns the platform-specific IFirmwareBackend implementation for the running OS. On Windows (PlatformID.Win32NT) the backend is Win32PlatformBackend; on Linux (PlatformID.Unix) it is LinuxPlatfromBackend. Any other platform throws PlatformNotSupportedException. The result is lazily cached — the backend is instantiated once and reused for all subsequent calls.
| |
|---|
| Type | IFirmwareBackend |
| Access | static read-only |
| Throws | PlatformNotSupportedException on unsupported OS |
// Inspect which backend is active at runtime
IFirmwareBackend backend = FirmwareInterface.CurrentBackend;
Console.WriteLine(backend.GetType().Name);
// Windows → "Win32PlatformBackend"
// Linux → "LinuxPlatfromBackend"
Available
Returns true if the system booted in UEFI mode, false if it booted in Legacy BIOS mode or UEFI cannot be accessed. Internally delegates to CurrentBackend.CheckFirmwareAvailablity(). Always check this property before performing any UEFI operation.
| |
|---|
| Type | bool |
| Access | static read-only |
if (!FirmwareInterface.Available)
{
Console.WriteLine("System is running in Legacy BIOS mode. UEFI features unavailable.");
return;
}
Console.WriteLine("UEFI is available.");
SystemPartition
Returns a DirectoryInfo pointing to the root of the EFI System Partition (ESP). The property reads EfiPartition.VolumePath — a lazily-initialised VolumePath struct that is itself resolved by calling CurrentBackend.FindEfiSystemPartition() — and returns it via an implicit VolumePath → DirectoryInfo conversion.
| |
|---|
| Type | System.IO.DirectoryInfo |
| Access | static read-only |
| Throws | PlatformNotSupportedException when Available is false |
if (!FirmwareInterface.Available)
throw new PlatformNotSupportedException("UEFI is not available.");
DirectoryInfo esp = FirmwareInterface.SystemPartition;
Console.WriteLine($"ESP path: {esp.FullName}");
// List top-level directories on the ESP
foreach (DirectoryInfo dir in esp.EnumerateDirectories())
Console.WriteLine(dir.Name);
Methods
BootToUserInterface()
Schedules the system to boot into the UEFI firmware user interface on the next reboot. The method does not trigger a reboot itself — it only sets the OsIndications.BOOT_TO_FW_UI flag in the OsIndications global UEFI variable. The firmware reads this flag during the next startup sequence and enters the setup UI instead of booting the operating system.
| |
|---|
| Returns | void |
| Throws | PlatformNotSupportedException if Available is false, or if the firmware reports it does not support BOOT_TO_FW_UI via OsIndicationsSupported |
public static void BootToUserInterface()
{
if (!Available)
throw new PlatformNotSupportedException(
"This system does not support UEFI, or is loaded in LEGACY mode");
if (!FirmwareEnvironment.Global.OsIndicationsSupported
.HasFlag(OsIndications.BOOT_TO_FW_UI))
throw new PlatformNotSupportedException(
"Current UEFI platform does not support force reboot in Firmware UI");
FirmwareEnvironment.Global.OsIndications |= OsIndications.BOOT_TO_FW_UI;
}
Full Usage Example
The example below demonstrates the typical usage pattern: guard with Available, inspect the ESP, then schedule a firmware-UI reboot.
using System;
using System.IO;
using Unified.Firmware;
// 1. Guard: only proceed on UEFI systems
if (!FirmwareInterface.Available)
{
Console.WriteLine("Legacy BIOS detected — UEFI features are not available.");
return;
}
// 2. Identify the active backend
Console.WriteLine($"Backend: {FirmwareInterface.CurrentBackend.GetType().Name}");
// 3. Access the EFI System Partition
DirectoryInfo esp = FirmwareInterface.SystemPartition;
Console.WriteLine($"ESP located at: {esp.FullName}");
foreach (DirectoryInfo subDir in esp.EnumerateDirectories())
Console.WriteLine($" {subDir.Name}/");
// 4. Schedule a reboot into the firmware UI
try
{
FirmwareInterface.BootToUserInterface();
Console.WriteLine("Firmware UI boot scheduled. Reboot to enter UEFI setup.");
}
catch (PlatformNotSupportedException ex)
{
Console.WriteLine($"Firmware UI boot not supported: {ex.Message}");
}
Most UEFI operations — including reading or writing NVRAM variables, enumerating the EFI System Partition, and calling BootToUserInterface() — require elevated privileges. Run as Administrator on Windows or as root (or with CAP_SYS_ADMIN) on Linux. Without the necessary privileges, the underlying platform APIs will throw access-denied exceptions.