|
| 1 | +// SPDX-License-Identifier: MIT OR Apache-2.0 |
| 2 | + |
| 3 | +//! Bindings for HII protocols relating to system configuration. |
| 4 | +
|
| 5 | +use core::fmt::Debug; |
| 6 | + |
| 7 | +use crate::{Char16, Guid, Status, guid}; |
| 8 | + |
| 9 | +/// EFI_KEYWORD_HANDLER_PROTOCOL |
| 10 | +#[derive(Debug)] |
| 11 | +#[repr(C)] |
| 12 | +pub struct HiiKeywordHandlerProtocol { |
| 13 | + pub set_data: unsafe extern "efiapi" fn( |
| 14 | + this: *mut Self, |
| 15 | + keyword_string: *const Char16, |
| 16 | + progress: *mut *const Char16, |
| 17 | + progress_err: *mut u32, |
| 18 | + ) -> Status, |
| 19 | + pub get_data: unsafe extern "efiapi" fn( |
| 20 | + this: *const Self, |
| 21 | + namespace_id: *const Char16, |
| 22 | + keyword_string: *const Char16, |
| 23 | + progress: *mut *const Char16, |
| 24 | + progress_err: *mut u32, |
| 25 | + results: *mut *const Char16, |
| 26 | + ) -> Status, |
| 27 | +} |
| 28 | + |
| 29 | +impl HiiKeywordHandlerProtocol { |
| 30 | + pub const GUID: Guid = guid!("0a8badd5-03b8-4d19-b128-7b8f0edaa596"); |
| 31 | +} |
| 32 | + |
| 33 | +newtype_enum! { |
| 34 | + /// Type of action taken by the form browser |
| 35 | + #[derive(Default)] |
| 36 | + pub enum EfiBrowserAction: u32 => { |
| 37 | + /// Called before the browser changes the value in the display (for questions which have a value) |
| 38 | + /// or takes an action (in the case of an action button or cross-reference). |
| 39 | + /// If EFI_SUCCESS is returned, the browser uses the value returned by Callback(). |
| 40 | + CHANGING = 0, |
| 41 | + /// Called after the browser has changed its internal copy of the question value and displayed it (if appropriate). |
| 42 | + /// For action buttons, this is called after processing. Errors are ignored. |
| 43 | + CHANGED = 1, |
| 44 | + /// Called after the browser has read the current question value but before displaying it. |
| 45 | + /// If EFI_SUCCESS is returned, the updated value is used. |
| 46 | + RETRIEVE = 2, |
| 47 | + /// Called for each question on a form prior to its value being retrieved or displayed. |
| 48 | + /// If a question appears on more than one form, this may be called more than once. |
| 49 | + FORM_OPEN = 3, |
| 50 | + /// Called for each question on a form after processing any submit actions for that form. |
| 51 | + /// If a question appears on multiple forms, this will be called more than once. |
| 52 | + FORM_CLOSE = 4, |
| 53 | + /// Called after the browser submits the modified question value. |
| 54 | + /// ActionRequest is ignored. |
| 55 | + SUBMITTED = 5, |
| 56 | + /// Represents the standard default action, selecting a default value based on lower-priority methods. |
| 57 | + DEFAULT_STANDARD = 0x1000, |
| 58 | + /// Represents the manufacturing default action, selecting a default value relevant to manufacturing. |
| 59 | + DEFAULT_MANUFACTURING = 0x1001, |
| 60 | + /// Represents the safe default action, selecting the safest possible default value. |
| 61 | + DEFAULT_SAFE = 0x1002, |
| 62 | + /// Represents platform-defined default values within a range of possible store identifiers. |
| 63 | + DEFAULT_PLATFORM = 0x2000, |
| 64 | + /// Represents hardware-defined default values within a range of possible store identifiers. |
| 65 | + DEFAULT_HARDWARE = 0x3000, |
| 66 | + /// Represents firmware-defined default values within a range of possible store identifiers. |
| 67 | + DEFAULT_FIRMWARE = 0x4000, |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +newtype_enum! { |
| 72 | + /// Represents actions requested by the Forms Browser in response to user interactions. |
| 73 | + #[derive(Default)] |
| 74 | + pub enum EfiBrowserActionRequest: usize => { |
| 75 | + /// No special behavior is taken by the Forms Browser. |
| 76 | + NONE = 0, |
| 77 | + /// The Forms Browser will exit and request the platform to reset. |
| 78 | + RESET = 1, |
| 79 | + /// The Forms Browser will save all modified question values to storage and exit. |
| 80 | + SUBMIT = 2, |
| 81 | + /// The Forms Browser will discard all modified question values and exit. |
| 82 | + EXIT = 3, |
| 83 | + /// The Forms Browser will write all modified question values on the selected form to storage and exit the form. |
| 84 | + FORM_SUBMIT_EXIT = 4, |
| 85 | + /// The Forms Browser will discard the modified question values on the selected form and exit the form. |
| 86 | + FORM_DISCARD_EXIT = 5, |
| 87 | + /// The Forms Browser will write all modified current question values on the selected form to storage. |
| 88 | + FORM_APPLY = 6, |
| 89 | + /// The Forms Browser will discard the current question values on the selected form and replace them with the original values. |
| 90 | + FORM_DISCARD = 7, |
| 91 | + /// The user performed a hardware or software configuration change, requiring controller reconnection. |
| 92 | + /// The Forms Browser calls `DisconnectController()` followed by `ConnectController()`. |
| 93 | + RECONNECT = 8, |
| 94 | + /// The Forms Browser will write the current modified question value on the selected form to storage. |
| 95 | + QUESTION_APPLY = 9, |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +#[repr(C)] |
| 100 | +#[derive(Debug, Copy, Clone)] |
| 101 | +pub struct EfiHiiTime { |
| 102 | + pub hour: u8, |
| 103 | + pub minute: u8, |
| 104 | + pub second: u8, |
| 105 | +} |
| 106 | + |
| 107 | +#[repr(C)] |
| 108 | +#[derive(Debug, Copy, Clone)] |
| 109 | +pub struct EfiHiiDate { |
| 110 | + pub year: u16, |
| 111 | + pub month: u8, |
| 112 | + pub day: u8, |
| 113 | +} |
| 114 | + |
| 115 | +#[repr(C)] |
| 116 | +#[derive(Debug, Copy, Clone)] |
| 117 | +pub struct EfiHiiRef { |
| 118 | + pub question_id: EfiQuestionId, |
| 119 | + pub form_id: EfiFormId, |
| 120 | + pub guid: Guid, |
| 121 | + pub string_id: EfiStringId, |
| 122 | +} |
| 123 | + |
| 124 | +#[repr(C)] |
| 125 | +#[derive(Copy, Clone)] |
| 126 | +pub union EfiIfrTypeValue { |
| 127 | + pub u8: u8, // EFI_IFR_TYPE_NUM_SIZE_8 |
| 128 | + pub u16: u16, // EFI_IFR_TYPE_NUM_SIZE_16 |
| 129 | + pub u32: u32, // EFI_IFR_TYPE_NUM_SIZE_32 |
| 130 | + pub u64: u64, // EFI_IFR_TYPE_NUM_SIZE_64 |
| 131 | + pub b: bool, // EFI_IFR_TYPE_BOOLEAN |
| 132 | + pub time: EfiHiiTime, // EFI_IFR_TYPE_TIME |
| 133 | + pub date: EfiHiiDate, // EFI_IFR_TYPE_DATE |
| 134 | + pub string: EfiStringId, // EFI_IFR_TYPE_STRING, EFI_IFR_TYPE_ACTION |
| 135 | + pub hii_ref: EfiHiiRef, // EFI_IFR_TYPE_REF |
| 136 | +} |
| 137 | +impl core::fmt::Debug for EfiIfrTypeValue { |
| 138 | + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { |
| 139 | + f.debug_struct("EfiIfrTypeValue").finish() |
| 140 | + } |
| 141 | +} |
| 142 | + |
| 143 | +pub type EfiQuestionId = u16; |
| 144 | +pub type EfiFormId = u16; |
| 145 | +pub type EfiStringId = u16; |
| 146 | + |
| 147 | +/// EFI_HII_CONFIG_ACCESS_PROTOCOL |
| 148 | +#[derive(Debug)] |
| 149 | +#[repr(C)] |
| 150 | +pub struct HiiConfigAccessProtocol { |
| 151 | + pub extract_config: unsafe extern "efiapi" fn( |
| 152 | + this: *const Self, |
| 153 | + request: *const Char16, |
| 154 | + progress: *mut *const Char16, |
| 155 | + results: *mut *const Char16, |
| 156 | + ) -> Status, |
| 157 | + pub route_config: unsafe extern "efiapi" fn( |
| 158 | + this: *const Self, |
| 159 | + configuration: *const Char16, |
| 160 | + progress: *mut *const Char16, |
| 161 | + ) -> Status, |
| 162 | + pub callback: unsafe extern "efiapi" fn( |
| 163 | + this: *const Self, |
| 164 | + action: EfiBrowserAction, |
| 165 | + question_id: u16, |
| 166 | + value_type: u8, |
| 167 | + value: *mut EfiIfrTypeValue, |
| 168 | + action_request: *mut EfiBrowserActionRequest, |
| 169 | + ) -> Status, |
| 170 | +} |
| 171 | + |
| 172 | +impl HiiConfigAccessProtocol { |
| 173 | + pub const GUID: Guid = guid!("330d4706-f2a0-4e4f-a369-b66fa8d54385"); |
| 174 | +} |
0 commit comments