Skip to main content

uefi_specs/uefi/
firmware_volume.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! PI firmware volume, file, and section definitions.
5
6use guid::Guid;
7use zerocopy::FromBytes;
8use zerocopy::Immutable;
9use zerocopy::KnownLayout;
10
11/// PI firmware volume header signature.
12pub const FV_SIGNATURE: u32 = u32::from_le_bytes(*b"_FVH");
13
14/// PI firmware section type for raw data.
15pub const SECTION_RAW: u8 = 0x19;
16/// PI firmware section type for a PE32 image.
17pub const SECTION_PE32: u8 = 0x10;
18/// PI firmware file type for the security core.
19pub const FILETYPE_SECURITY_CORE: u8 = 0x03;
20
21#[repr(C)]
22#[derive(FromBytes, Immutable, KnownLayout)]
23pub struct FirmwareVolumeHeader {
24    pub zero_vector: [u8; 16],
25    pub file_system_guid: Guid,
26    pub fv_length: u64,
27    pub signature: u32,
28    pub attributes: u32,
29    pub header_length: u16,
30    pub checksum: u16,
31    pub ext_header_offset: u16,
32    pub reserved: u8,
33    pub revision: u8,
34}
35
36#[repr(C)]
37#[derive(FromBytes, Immutable, KnownLayout)]
38pub struct FfsFileHeader {
39    pub name: Guid,
40    pub integrity_check: u16,
41    pub file_type: u8,
42    pub attributes: u8,
43    pub size: [u8; 3],
44    pub state: u8,
45}
46
47#[repr(C)]
48#[derive(FromBytes, Immutable, KnownLayout)]
49pub struct CommonSectionHeader {
50    pub size: [u8; 3],
51    pub section_type: u8,
52}