uefi/
memory.rs

1#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
2#[repr(transparent)]
3pub struct PhysicalAddress(pub u64);
4
5#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
6#[repr(transparent)]
7pub struct VirtualAddress(pub u64);
8
9#[derive(Clone, Copy, Debug, Default)]
10#[repr(C)]
11pub struct MemoryDescriptor {
12    pub Type: u32,
13    pub PhysicalStart: PhysicalAddress,
14    pub VirtualStart: VirtualAddress,
15    pub NumberOfPages: u64,
16    pub Attribute: u64,
17}
18
19#[derive(Clone, Copy, Debug, Eq, PartialEq)]
20#[repr(C)]
21pub enum MemoryType {
22    ///
23    /// Not used.
24    ///
25    EfiReservedMemoryType,
26    ///
27    /// The code portions of a loaded application.
28    /// (Note that UEFI OS loaders are UEFI applications.)
29    ///
30    EfiLoaderCode,
31    ///
32    /// The data portions of a loaded application and the default data allocation
33    /// type used by an application to allocate pool memory.
34    ///
35    EfiLoaderData,
36    ///
37    /// The code portions of a loaded Boot Services Driver.
38    ///
39    EfiBootServicesCode,
40    ///
41    /// The data portions of a loaded Boot Serves Driver, and the default data
42    /// allocation type used by a Boot Services Driver to allocate pool memory.
43    ///
44    EfiBootServicesData,
45    ///
46    /// The code portions of a loaded Runtime Services Driver.
47    ///
48    EfiRuntimeServicesCode,
49    ///
50    /// The data portions of a loaded Runtime Services Driver and the default
51    /// data allocation type used by a Runtime Services Driver to allocate pool memory.
52    ///
53    EfiRuntimeServicesData,
54    ///
55    /// Free (unallocated) memory.
56    ///
57    EfiConventionalMemory,
58    ///
59    /// Memory in which errors have been detected.
60    ///
61    EfiUnusableMemory,
62    ///
63    /// Memory that holds the ACPI tables.
64    ///
65    EfiACPIReclaimMemory,
66    ///
67    /// Address space reserved for use by the firmware.
68    ///
69    EfiACPIMemoryNVS,
70    ///
71    /// Used by system firmware to request that a memory-mapped IO region
72    /// be mapped by the OS to a virtual address so it can be accessed by EFI runtime services.
73    ///
74    EfiMemoryMappedIO,
75    ///
76    /// System memory-mapped IO region that is used to translate memory
77    /// cycles to IO cycles by the processor.
78    ///
79    EfiMemoryMappedIOPortSpace,
80    ///
81    /// Address space reserved by the firmware for code that is part of the processor.
82    ///
83    EfiPalCode,
84    ///
85    /// A memory region that operates as EfiConventionalMemory,
86    /// however it happens to also support byte-addressable non-volatility.
87    ///
88    EfiPersistentMemory,
89    EfiMaxMemoryType,
90}