1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! All MBI tags related to (U)EFI.

use crate::TagType;

/// EFI system table in 32 bit mode
#[derive(Clone, Copy, Debug)]
#[repr(C, packed)] // only repr(C) would add unwanted padding before first_section
pub struct EFISdt32 {
    typ: TagType,
    size: u32,
    pointer: u32,
}

impl EFISdt32 {
    /// The physical address of a i386 EFI system table.
    pub fn sdt_address(&self) -> usize {
        self.pointer as usize
    }
}

/// EFI system table in 64 bit mode
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct EFISdt64 {
    typ: TagType,
    size: u32,
    pointer: u64,
}

impl EFISdt64 {
    /// The physical address of a x86_64 EFI system table.
    pub fn sdt_address(&self) -> usize {
        self.pointer as usize
    }
}

/// Contains pointer to boot loader image handle.
#[derive(Debug)]
#[repr(C)]
pub struct EFIImageHandle32 {
    typ: TagType,
    size: u32,
    pointer: u32,
}

impl EFIImageHandle32 {
    /// Returns the physical address of the EFI image handle.
    pub fn image_handle(&self) -> usize {
        self.pointer as usize
    }
}

/// Contains pointer to boot loader image handle.
#[derive(Debug)]
#[repr(C)]
pub struct EFIImageHandle64 {
    typ: TagType,
    size: u32,
    pointer: u64,
}

impl EFIImageHandle64 {
    /// Returns the physical address of the EFI image handle.
    pub fn image_handle(&self) -> usize {
        self.pointer as usize
    }
}