uefi_specs/hyperv/
nvram.rs1use self::packed_nums::*;
7use crate::hyperv::common::EfiStatus64NoErrorBit;
8use bitfield_struct::bitfield;
9use guid::Guid;
10use open_enum::open_enum;
11use zerocopy::FromBytes;
12use zerocopy::Immutable;
13use zerocopy::IntoBytes;
14use zerocopy::KnownLayout;
15
16#[allow(non_camel_case_types)]
17mod packed_nums {
18 pub type u64_ne = zerocopy::U64<zerocopy::NativeEndian>;
19}
20
21open_enum! {
22 #[derive(IntoBytes, FromBytes, Immutable, KnownLayout)]
28 pub enum NvramCommand: u32 {
29 GET_VARIABLE = 0,
30 SET_VARIABLE = 1,
31 GET_FIRST_VARIABLE_NAME = 2,
32 GET_NEXT_VARIABLE_NAME = 3,
33 QUERY_INFO = 4,
34 SIGNAL_RUNTIME = 5,
35 DEBUG_STRING = 6,
36 }
37}
38
39#[repr(C)]
41#[derive(Debug, Clone, Copy, IntoBytes, FromBytes, Immutable, KnownLayout)]
42pub struct NvramCommandDescriptor {
43 pub command: NvramCommand,
44 pub status: EfiStatus64NoErrorBit,
45}
46
47#[repr(C)]
49#[derive(Debug, IntoBytes, FromBytes, Immutable, KnownLayout)]
50pub struct NvramDebugStringCommand {
51 pub padding: u32,
52 pub address: u64_ne,
53 pub len: u32,
54}
55
56#[repr(C)]
58#[derive(Debug, IntoBytes, FromBytes, Immutable, KnownLayout)]
59pub struct NvramVariableCommand {
60 pub attributes: u32,
66
67 pub name_address: u64_ne,
73
74 pub name_bytes: u32,
79
80 pub vendor_guid: Guid,
85
86 pub data_address: u64_ne,
91
92 pub data_bytes: u32,
97}
98
99#[repr(C)]
101#[derive(Debug, IntoBytes, FromBytes, Immutable, KnownLayout)]
102pub struct NvramQueryInfo {
103 pub attributes: u32,
108
109 pub maximum_variable_storage: u64_ne,
111 pub remaining_variable_storage: u64_ne,
112 pub maximum_variable_size: u64_ne,
113}
114
115#[bitfield(u64)]
117#[derive(IntoBytes, FromBytes, Immutable, KnownLayout)]
118pub struct SignalRuntimeCommandFlags {
119 pub vsm_aware: bool,
120 #[bits(63)]
121 _reserved: u64,
122}
123
124#[repr(C)]
138#[derive(Debug, IntoBytes, FromBytes, Immutable, KnownLayout)]
139pub struct NvramSignalRuntimeCommand {
140 pub flags: SignalRuntimeCommandFlags,
141}
142
143pub mod vars {
144 use guid::Guid;
145
146 const SECURE_BOOT_ENABLE_GUID: Guid = guid::guid!("f0a30bc7-af08-4556-99c4-001009c93a44");
147
148 pub const MSFT_SECURE_BOOT_PRODUCTION_GUID: Guid =
149 guid::guid!("77fa9abd-0359-4d32-bd60-28f4e78f784b");
150
151 const EFI_HYPERV_PRIVATE_GUID: Guid = guid::guid!("610b9e98-c6f6-47f8-8b47-2d2da0d52a91");
152
153 defn_nvram_var!(SECURE_BOOT_ENABLE = (SECURE_BOOT_ENABLE_GUID, "SecureBootEnable"));
154 defn_nvram_var!(CURRENT_POLICY = (MSFT_SECURE_BOOT_PRODUCTION_GUID, "CurrentPolicy"));
155 defn_nvram_var!(OS_LOADER_INDICATIONS = (EFI_HYPERV_PRIVATE_GUID, "OsLoaderIndications"));
156 defn_nvram_var!(
157 OS_LOADER_INDICATIONS_SUPPORTED = (EFI_HYPERV_PRIVATE_GUID, "OsLoaderIndicationsSupported")
158 );
159}