Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/uefi-raw/src/table/runtime.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / uefi-raw / src / table / runtime.rs` 177 lines ยท 6220 bytes Raw Blame History 1 // SPDX-License-Identifier: MIT OR Apache-2.0 2 3 //! UEFI services available at runtime, even after the OS boots. 4 5 use crate::capsule::CapsuleHeader; 6 use crate::table::Header; 7 use crate::table::boot::MemoryDescriptor; 8 use crate::time::Time; 9 use crate::{Boolean, Char16, Guid, PhysicalAddress, Status, guid, newtype_enum}; 10 use bitflags::bitflags; 11 use core::ffi::c_void; 12 13 /// Table of pointers to all the runtime services. 14 /// 15 /// This table, and the function pointers it contains are valid even after the 16 /// UEFI OS loader and OS have taken control of the platform. 17 #[derive(Debug)] 18 #[repr(C)] 19 #[expect(missing_docs)] 20 pub struct RuntimeServices { 21 pub header: Header, 22 pub get_time: 23 unsafe extern "efiapi" fn(time: *mut Time, capabilities: *mut TimeCapabilities) -> Status, 24 pub set_time: unsafe extern "efiapi" fn(time: *const Time) -> Status, 25 pub get_wakeup_time: unsafe extern "efiapi" fn( 26 enabled: *mut Boolean, 27 pending: *mut Boolean, 28 time: *mut Time, 29 ) -> Status, 30 pub set_wakeup_time: unsafe extern "efiapi" fn(enable: Boolean, time: *const Time) -> Status, 31 pub set_virtual_address_map: unsafe extern "efiapi" fn( 32 map_size: usize, 33 desc_size: usize, 34 desc_version: u32, 35 virtual_map: *const MemoryDescriptor, 36 ) -> Status, 37 pub convert_pointer: 38 unsafe extern "efiapi" fn(debug_disposition: usize, address: *mut *mut c_void) -> Status, 39 pub get_variable: unsafe extern "efiapi" fn( 40 variable_name: *const Char16, 41 vendor_guid: *const Guid, 42 attributes: *mut VariableAttributes, 43 data_size: *mut usize, 44 data: *mut u8, 45 ) -> Status, 46 pub get_next_variable_name: unsafe extern "efiapi" fn( 47 variable_name_size: *mut usize, 48 variable_name: *mut u16, 49 vendor_guid: *mut Guid, 50 ) -> Status, 51 pub set_variable: unsafe extern "efiapi" fn( 52 variable_name: *const Char16, 53 vendor_guid: *const Guid, 54 attributes: VariableAttributes, 55 data_size: usize, 56 data: *const u8, 57 ) -> Status, 58 pub get_next_high_monotonic_count: unsafe extern "efiapi" fn(high_count: *mut u32) -> Status, 59 pub reset_system: unsafe extern "efiapi" fn( 60 rt: ResetType, 61 status: Status, 62 data_size: usize, 63 data: *const u8, 64 ) -> !, 65 66 // UEFI 2.0 Capsule Services. 67 pub update_capsule: unsafe extern "efiapi" fn( 68 capsule_header_array: *const *const CapsuleHeader, 69 capsule_count: usize, 70 scatter_gather_list: PhysicalAddress, 71 ) -> Status, 72 pub query_capsule_capabilities: unsafe extern "efiapi" fn( 73 capsule_header_array: *const *const CapsuleHeader, 74 capsule_count: usize, 75 maximum_capsule_size: *mut u64, 76 reset_type: *mut ResetType, 77 ) -> Status, 78 79 // Miscellaneous UEFI 2.0 Service. 80 pub query_variable_info: unsafe extern "efiapi" fn( 81 attributes: VariableAttributes, 82 maximum_variable_storage_size: *mut u64, 83 remaining_variable_storage_size: *mut u64, 84 maximum_variable_size: *mut u64, 85 ) -> Status, 86 } 87 88 newtype_enum! { 89 #[derive(Default)] 90 /// The type of system reset. 91 pub enum ResetType: u32 => { 92 /// System-wide reset. 93 /// 94 /// This is analogous to power cycling the device. 95 COLD = 0, 96 97 /// System-wide re-initialization. 98 /// 99 /// If the system doesn't support a warm reset, this will trigger a cold 100 /// reset. 101 WARM = 1, 102 103 /// The system is powered off. 104 SHUTDOWN = 2, 105 106 /// A platform-specific reset type. 107 PLATFORM_SPECIFIC = 3, 108 } 109 } 110 111 /// Real time clock capabilities. 112 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] 113 #[repr(C)] 114 pub struct TimeCapabilities { 115 /// Reporting resolution of the clock in counts per second. 1 for a normal 116 /// PC-AT CMOS RTC device, which reports the time with 1-second resolution. 117 pub resolution: u32, 118 119 /// Timekeeping accuracy in units of 1e-6 parts per million. 120 pub accuracy: u32, 121 122 /// Whether a time set operation clears the device's time below the 123 /// "resolution" reporting level. False for normal PC-AT CMOS RTC devices. 124 pub sets_to_zero: Boolean, 125 } 126 127 bitflags! { 128 /// Flags describing the attributes of a variable. 129 #[repr(transparent)] 130 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] 131 pub struct VariableAttributes: u32 { 132 /// Variable is maintained across a power cycle. 133 const NON_VOLATILE = 0x01; 134 135 /// Variable is accessible during the time that boot services are 136 /// accessible. 137 const BOOTSERVICE_ACCESS = 0x02; 138 139 /// Variable is accessible during the time that runtime services are 140 /// accessible. 141 const RUNTIME_ACCESS = 0x04; 142 143 /// Variable is stored in the portion of NVR allocated for error 144 /// records. 145 const HARDWARE_ERROR_RECORD = 0x08; 146 147 /// Deprecated. 148 const AUTHENTICATED_WRITE_ACCESS = 0x10; 149 150 /// Variable payload begins with an EFI_VARIABLE_AUTHENTICATION_2 151 /// structure. 152 const TIME_BASED_AUTHENTICATED_WRITE_ACCESS = 0x20; 153 154 /// This is never set in the attributes returned by 155 /// `get_variable`. When passed to `set_variable`, the variable payload 156 /// will be appended to the current value of the variable if supported 157 /// by the firmware. 158 const APPEND_WRITE = 0x40; 159 160 /// Variable payload begins with an EFI_VARIABLE_AUTHENTICATION_3 161 /// structure. 162 const ENHANCED_AUTHENTICATED_ACCESS = 0x80; 163 } 164 } 165 166 newtype_enum! { 167 /// Variable vendor GUID. This serves as a namespace for variables to 168 /// avoid naming conflicts between vendors. The UEFI specification 169 /// defines some special values, and vendors will define their own. 170 pub enum VariableVendor: Guid => { 171 /// Used to access global variables. 172 GLOBAL_VARIABLE = guid!("`8be4df61`-93ca-11d2-aa0d-`00e098032b8c`"), 173 174 /// Used to access EFI signature database variables. 175 IMAGE_SECURITY_DATABASE = guid!("`d719b2cb`-3d3a-4596-a3bc-`dad00e67656f`"), 176 } 177 }