Patina FIrmware File System (FFS) Crate
Rust support for the UEFI Platform Initialization (PI) Specification defined Firmware File System (FFS). Offers zero-copy inspection helpers for firmware volumes, files, and sections together with serialization to spec-compliant byte streams. It targets firmware environments that run without the Rust standard library.
Key Capabilities
- Parse firmware volumes, firmware files, and sections directly from immutable byte slices using
VolumeRef,FileRef, andSection. - Compose new firmware content with builders (
Volume,File,Section) that enforce header layout, checksum calculation, erase polarity, and inter-section padding. - Provide trait-based extension points (
SectionExtractor,SectionComposer) so platforms can plug in custom decompression or guided-section handling. - Return consistent errors through
FirmwareFileSystemError, which maps to Patina’sEfiErrorandefi::Status.
Core Data Types
VolumeRef<'a>– A view over a firmware volume that validates headers, block maps, and extended headers, and exposes iterators over contained files. It also supports creation from a physical address (unsafe fn new_from_address).Volume– A firmware volume builder that accepts a block map and a collection of files and emits byte streams.FileRef<'a>andFile– Read and compose firmware files, including large-file headers, checksum enforcement, and section traversal.SectionandSectionHeader– Represent leaf and encapsulation sections, track dirty state, and serialize with the correct header variant (standard or extended).SectionIteratorwalks a serialized section list with 4-byte alignment handling.SectionExtractor– Trait that defines interfaces to expand encapsulated sections (for example Brotli or UEFI Compress), with implementations available in thepatina_ffs_extractorscompanion crate.SectionComposer– Trait for turning higher-level inputs into serialized section payloads before they are inserted into aFile.
Example: Scanning FIrmware Volumes (FVs)
use c_void;
use Core;
use VolumeRef;
use BrotliSectionExtractor;
#
pub extern "efiapi" !
Example: Compsosing a Driver File
use Vec;
use ffs;
use File;
use ;
use efi;