Patina SMBIOS Component
The Patina SMBIOS component provides type-safe SMBIOS table management for Patina-based firmware. It offers both a modern Rust service API and legacy C/EDKII protocol compatibility for managing SMBIOS records throughout the boot process.
Capabilities
- Produces the
Smbiosservice for adding, updating, and publishing SMBIOS records with type-safe structured record types. - Installs the EDKII-compatible
EFI_SMBIOS_PROTOCOLfor C drivers that need to interact with SMBIOS tables. - Manages SMBIOS record handles with automatic allocation, reuse, and PI specification compliance.
- Validates and serializes structured SMBIOS records with proper string pool handling.
- Publishes SMBIOS tables to the UEFI Configuration Table with proper entry point structures and checksums.
- Emits focused log output to aid in debugging record addition, string updates, and table publication.
Components and Services
- SmbiosProvider component: Creates the SMBIOS manager, registers the
Service<dyn Smbios>, and installs the C/EDKII protocol. Both interfaces share the same underlying manager for consistency. - Smbios trait: Defines core operations (
version,publish_table,update_string,remove,add_from_bytes) accessible through trait object dynamic dispatch. - SmbiosExt trait: Provides the type-safe
add_record<T>()generic method for adding structured records without manual serialization.
Configuration
The SMBIOS component requires version configuration during instantiation:
commands.add_component; // SMBIOS 3.9
Only SMBIOS 3.x versions are supported. The component will panic at initialization if
SmbiosProvider::new()is called with an unsupported major version (i.e., major version != 3). This is intentional to catch configuration errors early during platform development. If the manager creation fails duringentry_point(), the component returnsEfiError::Unsupportedinstead of panicking.
Platform Integration
To integrate the patina_smbios component into your platform, remove the
SmbiosDxe driver and add the SmbiosProvider component. This replaces
SmbiosDxe as the producer of the EFI_SMBIOS_PROTOCOL.
Step 1: Remove the SmbiosDxe Driver
Remove SmbiosDxe.inf from your platform's DSC file (e.g.,
YourPlatform.dsc or YourPlatformCommon.dsc.inc):
- #
- # SMBIOS Support
- #
- MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf {
- <LibraryClasses>
- NULL|YourPlatform/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf
- }
Remove the corresponding entry from your platform's FDF file (e.g.,
YourPlatform.fdf):
-INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
Existing C drivers can locate and use the EFI_SMBIOS_PROTOCOL produced by the
Patina SMBIOS component to add their records.
Step 2: Add the Patina SMBIOS Component
In your Patina DXE core configuration (e.g., your_platform_dxe_core.rs), add
the SmbiosProvider component:
use SmbiosProvider;
// In your DXE core builder
new
.with_component // SMBIOS version 3.9
// ... other components
The version parameters represent the SMBIOS specification version (major, minor). Only SMBIOS 3.x versions are supported.
Step 3 (Optional): Create a Platform SMBIOS Component
If you want to develop your own Patina-based platform SMBIOS component, remove
your platform's existing SMBIOS driver (e.g., SmbiosPlatformDxe,
SbsaQemuSmbiosDxe, ProcessorSubClassDxe) from your DSC and FDF files, then
create a platform-specific component that populates your SMBIOS tables. This
component uses the #[component] macro and receives the Smbios service as a
parameter:
use ;
use ;
;
Then add the platform component to your DXE core:
new
.with_component
.with_component
// ... other components
Integration Guidance
Adding SMBIOS Records
Platform components should use the type-safe add_record<T>() method from SmbiosExt:
use Service;
use ;
Available Record Types
The crate provides structured types for common SMBIOS records:
- Type0PlatformFirmwareInformation: BIOS/firmware information
- Type1SystemInformation: System manufacturer, product name, UUID, SKU
- Type2BaseboardInformation: Baseboard/motherboard information
- Type3SystemEnclosure: Chassis/enclosure information
- Type127EndOfTable: End-of-table marker (required)
Each record type implements SmbiosRecordStructure and handles
serialization automatically, including proper string pool conversion and
length calculations.
String Pool Handling
SMBIOS strings are stored in a Vec<String> field marked with
#[string_pool]. String indices in record fields are 1-based. The
serialization process automatically converts the string pool to
null-terminated SMBIOS format:
string_pool: vec!,
Updating Existing Records
Records can be updated after creation using update_string:
// Update string 1 in the record
smbios.update_string?;
C/EDKII Protocol Compatibility
The component automatically installs the EFI_SMBIOS_PROTOCOL with functions:
Add: Add SMBIOS records from raw bytesUpdateString: Update strings in existing recordsRemove: Remove records by handleGetNext: Iterate through SMBIOS records
C drivers can locate and use this protocol as they would in traditional EDKII firmware.
Testing
The crate includes comprehensive unit tests demonstrating:
- Record creation and serialization
- Handle allocation and reuse
- String pool validation
- Mock service patterns using
Service::mock() - Integration with the service system
Run tests with:
Documentation
For detailed implementation and architectural information, see the inline documentation and: