1use bitflags::bitflags;
4use plain::Plain;
5use uefi::guid::Guid;
6
7bitflags! {
8 pub struct Attributes: u32 {
9 const READ_DISABLED_CAP = 0x00000001;
10 const READ_ENABLED_CAP = 0x00000002;
11 const READ_STATUS = 0x00000004;
12 const WRITE_DISABLED_CAP = 0x00000008;
13 const WRITE_ENABLED_CAP = 0x00000010;
14 const WRITE_STATUS = 0x00000020;
15 const LOCK_CAP = 0x00000040;
16 const LOCK_STATUS = 0x00000080;
17 const STICKY_WRITE = 0x00000200;
18 const MEMORY_MAPPED = 0x00000400;
19 const ERASE_POLARITY = 0x00000800;
20 const ALIGNMENT_CAP = 0x00008000;
21 const ALIGNMENT_2 = 0x00010000;
22 const ALIGNMENT_4 = 0x00020000;
23 const ALIGNMENT_8 = 0x00040000;
24 const ALIGNMENT_16 = 0x00080000;
25 const ALIGNMENT_32 = 0x00100000;
26 const ALIGNMENT_64 = 0x00200000;
27 const ALIGNMENT_128 = 0x00400000;
28 const ALIGNMENT_256 = 0x00800000;
29 const ALIGNMENT_512 = 0x01000000;
30 const ALIGNMENT_1K = 0x02000000;
31 const ALIGNMENT_2K = 0x04000000;
32 const ALIGNMENT_4K = 0x08000000;
33 const ALIGNMENT_8K = 0x10000000;
34 const ALIGNMENT_16K = 0x20000000;
35 const ALIGNMENT_32K = 0x40000000;
36 const ALIGNMENT_64K = 0x80000000;
37 }
38}
39
40#[repr(packed)]
41pub struct Header {
42 pub zero_vector: [u8; 16],
43 pub guid: Guid,
44 pub length: u64,
45 pub signature: [u8; 4],
46 pub attributes: u32,
47 pub header_length: u16,
48 pub checksum: u16,
49 pub reserved: [u8; 3],
50 pub revision: u8,
51}
52
53impl Header {
54 pub fn valid(&self) -> bool {
55 self.signature == *b"_FVH"
56 }
57
58 pub fn attributes(&self) -> Attributes {
59 Attributes::from_bits_truncate(self.attributes)
60 }
61}
62
63unsafe impl Plain for Header {}
64
65#[repr(packed)]
66pub struct BlockEntry {
67 pub num_blocks: u32,
68 pub block_length: u32,
69}
70
71unsafe impl Plain for BlockEntry {}