aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / uefi-raw / src / firmware_storage.rs
| 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 |
| 2 | |
| 3 | //! Types related to firmware storage. |
| 4 | |
| 5 | #![expect(missing_docs)] |
| 6 | |
| 7 | use crate::Guid; |
| 8 | use bitflags::bitflags; |
| 9 | |
| 10 | /// Corresponds to the C type `EFI_FIRMWARE_VOLUME_HEADER`. |
| 11 | #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] |
| 12 | #[repr(C)] |
| 13 | pub struct FirmwareVolumeHeader { |
| 14 | pub zero_vector: [u8; 16], |
| 15 | pub file_system_guid: Guid, |
| 16 | pub fv_length: u64, |
| 17 | pub signature: [u8; 4], |
| 18 | pub attributes: FirmwareVolumeAttributes, |
| 19 | pub header_length: u16, |
| 20 | pub checksum: u16, |
| 21 | pub ext_header_offset: u16, |
| 22 | pub reserved: u8, |
| 23 | pub revision: u8, |
| 24 | |
| 25 | /// Variable-length array of block maps, terminated with a zero-filled |
| 26 | /// entry. |
| 27 | pub block_map: [FirmwareVolumeBlockMap; 0], |
| 28 | } |
| 29 | |
| 30 | impl FirmwareVolumeHeader { |
| 31 | pub const SIGNATURE: [u8; 4] = *b"_FVH"; |
| 32 | } |
| 33 | |
| 34 | /// Corresponds to the C type `EFI_FV_BLOCK_MAP`. |
| 35 | #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] |
| 36 | #[repr(C)] |
| 37 | pub struct FirmwareVolumeBlockMap { |
| 38 | pub num_blocks: u32, |
| 39 | pub length: u32, |
| 40 | } |
| 41 | |
| 42 | bitflags! { |
| 43 | /// Corresponds to the C type `EFI_FVB_ATTRIBUTES_2`. |
| 44 | #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] |
| 45 | #[repr(transparent)] |
| 46 | pub struct FirmwareVolumeAttributes: u32 { |
| 47 | const READ_DISABLED_CAP = 0x0000_0001; |
| 48 | const READ_ENABLED_CAP = 0x0000_0002; |
| 49 | const READ_STATUS = 0x0000_0004; |
| 50 | |
| 51 | const WRITE_DISABLED_CAP = 0x0000_0008; |
| 52 | const WRITE_ENABLED_CAP = 0x0000_0010; |
| 53 | const WRITE_STATUS = 0x0000_0020; |
| 54 | |
| 55 | const LOCK_CAP = 0x0000_0040; |
| 56 | const LOCK_STATUS = 0x0000_0080; |
| 57 | |
| 58 | const STICKY_WRITE = 0x0000_0200; |
| 59 | const MEMORY_MAPPED = 0x0000_0400; |
| 60 | const ERASE_POLARITY = 0x0000_0800; |
| 61 | |
| 62 | const READ_LOCK_CAP = 0x0000_1000; |
| 63 | const READ_LOCK_STATUS = 0x0000_2000; |
| 64 | |
| 65 | const WRITE_LOCK_CAP = 0x0000_4000; |
| 66 | const WRITE_LOCK_STATUS = 0x0000_8000; |
| 67 | |
| 68 | const ALIGNMENT = 0x001f_0000; |
| 69 | const WEAK_ALIGNMENT = 0x8000_0000; |
| 70 | const ALIGNMENT_1 = 0x0000_0000; |
| 71 | const ALIGNMENT_2 = 0x0001_0000; |
| 72 | const ALIGNMENT_4 = 0x0002_0000; |
| 73 | const ALIGNMENT_8 = 0x0003_0000; |
| 74 | const ALIGNMENT_16 = 0x0004_0000; |
| 75 | const ALIGNMENT_32 = 0x0005_0000; |
| 76 | const ALIGNMENT_64 = 0x0006_0000; |
| 77 | const ALIGNMENT_128 = 0x0007_0000; |
| 78 | const ALIGNMENT_256 = 0x0008_0000; |
| 79 | const ALIGNMENT_512 = 0x0009_0000; |
| 80 | const ALIGNMENT_1K = 0x000a_0000; |
| 81 | const ALIGNMENT_2K = 0x000b_0000; |
| 82 | const ALIGNMENT_4K = 0x000c_0000; |
| 83 | const ALIGNMENT_8K = 0x000d_0000; |
| 84 | const ALIGNMENT_16K = 0x000e_0000; |
| 85 | const ALIGNMENT_32K = 0x000f_0000; |
| 86 | const ALIGNMENT_64K = 0x0010_0000; |
| 87 | const ALIGNMENT_128K = 0x0011_0000; |
| 88 | const ALIGNMENT_256K = 0x0012_0000; |
| 89 | const ALIGNMENT_512K = 0x0013_0000; |
| 90 | const ALIGNMENT_1M = 0x0014_0000; |
| 91 | const ALIGNMENT_2M = 0x0015_0000; |
| 92 | const ALIGNMENT_4M = 0x0016_0000; |
| 93 | const ALIGNMENT_8M = 0x0017_0000; |
| 94 | const ALIGNMENT_16M = 0x0018_0000; |
| 95 | const ALIGNMENT_32M = 0x0019_0000; |
| 96 | const ALIGNMENT_64M = 0x001a_0000; |
| 97 | const ALIGNMENT_128M = 0x001b_0000; |
| 98 | const ALIGNMENT_256M = 0x001c_0000; |
| 99 | const ALIGNMENT_512M = 0x001d_0000; |
| 100 | const ALIGNMENT_1G = 0x001e_0000; |
| 101 | const ALIGNMENT_2G = 0x001f_0000; |
| 102 | } |
| 103 | } |