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/protocol/firmware_management.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 / protocol / firmware_management.rs` 204 lines ยท 5787 bytes Raw Blame History 1 // SPDX-License-Identifier: MIT OR Apache-2.0 2 3 //! Firmware update and reporting 4 5 use crate::{Char16, Guid, Status, guid, newtype_enum}; 6 use core::ffi::c_void; 7 8 bitflags::bitflags! { 9 #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] 10 #[repr(transparent)] 11 pub struct CapsuleSupport: u64 { 12 const AUTHENTICATION = 1 << 0; 13 const DEPENDENCY = 1 << 1; 14 } 15 } 16 17 /// EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER 18 #[derive(Debug)] 19 #[repr(C, packed)] 20 pub struct FirmwareManagementCapsuleHeader { 21 pub version: u32, 22 pub embedded_driver_count: u16, 23 pub payload_item_count: u16, 24 pub item_offset_list: [u64; 0], 25 } 26 27 impl FirmwareManagementCapsuleHeader { 28 pub const INIT_VERSION: u32 = 1; 29 } 30 31 /// EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER 32 #[derive(Debug)] 33 #[repr(C, packed)] 34 pub struct FirmwareManagementCapsuleImageHeader { 35 pub version: u32, 36 pub update_image_type_id: Guid, 37 pub update_image_index: u8, 38 pub reserved_bytes: [u8; 3], 39 pub update_image_size: u32, 40 pub update_vendor_code_size: u32, 41 pub update_hardware_instance: u64, 42 pub image_capsule_support: CapsuleSupport, 43 } 44 45 impl FirmwareManagementCapsuleImageHeader { 46 pub const INIT_VERSION: u32 = 3; 47 } 48 49 newtype_enum! { 50 /// FMP dependency expression opcodes (`EFI_FMP_DEP_*`) 51 pub enum FmpDep: u8 => { 52 PUSH_GUID = 0x00, 53 PUSH_VERSION = 0x01, 54 VERSION_STR = 0x02, 55 AND = 0x03, 56 OR = 0x04, 57 NOT = 0x05, 58 TRUE = 0x06, 59 FALSE = 0x07, 60 EQ = 0x08, 61 GT = 0x09, 62 GTE = 0x0A, 63 LT = 0x0B, 64 LTE = 0x0C, 65 END = 0x0D, 66 DECLARE_LENGTH = 0x0E, 67 } 68 } 69 70 /// EFI_FIRMWARE_IMAGE_DEP 71 #[derive(Debug)] 72 #[repr(C)] 73 pub struct FirmwareImageDep { 74 pub dependencies: [u8; 0], 75 } 76 77 bitflags::bitflags! { 78 #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] 79 #[repr(transparent)] 80 pub struct ImageAttributes: u64 { 81 const IMAGE_UPDATABLE = 1 << 0; 82 const RESET_REQUIRED = 1 << 1; 83 const AUTHENTICATION_REQUIRED = 1 << 2; 84 const IN_USE = 1 << 3; 85 const UEFI_IMAGE = 1 << 4; 86 const DEPENDENCY = 1 << 5; 87 } 88 } 89 90 bitflags::bitflags! { 91 // Lower 16 bits are reserved for UEFI assignment. 92 // Other bits are for vendor-specific compatibility checks. 93 #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] 94 #[repr(transparent)] 95 pub struct ImageCompatibilities: u64 { 96 const CHECK_SUPPORTED = 1 << 0; 97 const _ = !0; 98 } 99 } 100 101 bitflags::bitflags! { 102 #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] 103 #[repr(transparent)] 104 pub struct ImageUpdatable: u32 { 105 const VALID = 1 << 0; 106 const INVALID = 1 << 1; 107 const INVALID_TYPE = 1 << 2; 108 const INVALID_OLD = 1 << 3; 109 const VALID_WITH_VENDOR_CODE = 1 << 4; 110 } 111 } 112 113 bitflags::bitflags! { 114 #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] 115 #[repr(transparent)] 116 pub struct PackageAttributes: u64 { 117 const UPDATABLE = 1 << 0; 118 const RESET_REQUIRED = 1 << 1; 119 const AUTHENTICATION_REQUIRED = 1 << 2; 120 } 121 } 122 123 /// EFI_FIRMWARE_IMAGE_DESCRIPTOR 124 #[derive(Debug)] 125 #[repr(C)] 126 pub struct FirmwareImageDescriptor { 127 pub image_index: u8, 128 pub image_type_id: Guid, 129 pub image_id: u64, 130 pub image_id_name: *const Char16, 131 pub version: u32, 132 pub version_name: *const Char16, 133 pub size: usize, 134 pub attributes_supported: ImageAttributes, 135 pub attributes_setting: ImageAttributes, 136 pub compatibilities: ImageCompatibilities, 137 pub lowest_supported_image_version: u32, 138 pub last_attempt_version: u32, 139 pub last_attempt_status: u32, 140 pub hardware_instance: u64, 141 pub dependencies: *const FirmwareImageDep, 142 } 143 144 impl FirmwareImageDescriptor { 145 pub const VERSION: u32 = 4; 146 } 147 148 /// EFI_FIRMWARE_MANAGEMENT_PROTOCOL 149 #[derive(Debug)] 150 #[repr(C)] 151 pub struct FirmwareManagementProtocol { 152 pub get_image_info: unsafe extern "efiapi" fn( 153 this: *const Self, 154 image_info_size: *mut usize, 155 image_info: *mut FirmwareImageDescriptor, 156 descriptor_version: *mut u32, 157 descriptor_count: *mut u8, 158 descriptor_size: *mut usize, 159 package_version: *mut u32, 160 package_version_name: *mut *mut Char16, 161 ) -> Status, 162 pub get_image: unsafe extern "efiapi" fn( 163 this: *const Self, 164 image_index: u8, 165 image: *mut c_void, 166 image_size: *mut usize, 167 ) -> Status, 168 pub set_image: unsafe extern "efiapi" fn( 169 this: *const Self, 170 image_index: u8, 171 image: *const c_void, 172 image_size: usize, 173 vendor_code: *const c_void, 174 progress: unsafe extern "efiapi" fn(completion: usize) -> Status, 175 abort_reason: *mut *mut Char16, 176 ) -> Status, 177 pub check_image: unsafe extern "efiapi" fn( 178 this: *const Self, 179 image_index: u8, 180 image: *const c_void, 181 image_size: usize, 182 image_updatable: *mut ImageUpdatable, 183 ) -> Status, 184 pub get_package_info: unsafe extern "efiapi" fn( 185 this: *const Self, 186 package_version: *mut u32, 187 package_version_name: *mut *mut Char16, 188 package_version_name_max_len: *mut u32, 189 attributes_supported: *mut PackageAttributes, 190 attributes_setting: *mut PackageAttributes, 191 ) -> Status, 192 pub set_package_info: unsafe extern "efiapi" fn( 193 this: *const Self, 194 image: *const c_void, 195 image_size: usize, 196 vendor_code: *const c_void, 197 package_version: u32, 198 package_version_name: *const Char16, 199 ) -> Status, 200 } 201 202 impl FirmwareManagementProtocol { 203 pub const GUID: Guid = guid!("`86c77a67`-0b97-4633-a187-`49104d0685c7`"); 204 }