Skip to main content

uefi_raw/protocol/hii/
config.rs

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