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