Skip to content

Commit aea4371

Browse files
committed
uefi-raw: Add bindings for most HII protocols
Add bindings for the following protocols: - HiiFont (EFI_HII_FONT_PROTOCOL) - HiiFontEx (EFI_HII_FONT_EX_PROTOCOL) - HiiString (EFI_HII_STRING_PROTOCOL) - HiiImage (EFI_HII_IMAGE_PROTOCOL) - HiiImageEx (EFI_HII_IMAGE_EX_PROTOCOL) - HiiPopup (EFI_HII_POPUP_PROTOCOL) - FormBrowser2 (EFI_FORM_BROWSER2_PROTOCOL) Ref: UEFI 2.11: 34 HII Protocols Ref: UEFI 2.11: 35 HII Configuration Processing and Browser Protocol Signed-off-by: Tim Crawford <[email protected]>
1 parent bbe1c5a commit aea4371

File tree

8 files changed

+585
-32
lines changed

8 files changed

+585
-32
lines changed

uefi-raw/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## Added
44
- Added `Tcpv4Protocol`.
5+
- Added `HiiFontProtocol`, `HiiFontExProtocol`.
6+
- Added `HiiImageProtocol`, `HiiImageExProtocol`.
7+
- Added `HiiStringProtocol`.
8+
- Added `HiiPopupProtocol`.
9+
- Added `FormBrowser2Protocol`.
510

611
## Changed
712

uefi-raw/src/protocol/hii/config.rs

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
55
use core::fmt::Debug;
66

7+
use super::form_browser::BrowserActionRequest;
8+
use super::{FormId, QuestionId, StringId};
79
use crate::protocol::device_path::DevicePathProtocol;
810
use crate::{Boolean, Char16, Guid, Status, guid, newtype_enum};
911

@@ -69,34 +71,6 @@ newtype_enum! {
6971
}
7072
}
7173

72-
newtype_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-
10074
#[repr(C)]
10175
#[derive(Debug, Copy, Clone)]
10276
pub struct HiiTime {
@@ -141,10 +115,6 @@ impl core::fmt::Debug for IfrTypeValue {
141115
}
142116
}
143117

144-
pub type QuestionId = u16;
145-
pub type FormId = u16;
146-
pub type StringId = u16;
147-
148118
/// EFI_HII_CONFIG_ACCESS_PROTOCOL
149119
#[derive(Debug)]
150120
#[repr(C)]

uefi-raw/src/protocol/hii/font.rs

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
3+
//! Bindings for HII Font protocols and data types
4+
5+
use super::image::ImageOutput;
6+
use super::{HiiHandle, StringId};
7+
use crate::protocol::console::GraphicsOutputBltPixel;
8+
use crate::{Char8, Char16, Guid, Status, guid};
9+
10+
pub type FontHandle = *mut core::ffi::c_void;
11+
12+
#[derive(Debug)]
13+
#[repr(C)]
14+
pub struct HiiGlyphInfo {
15+
pub width: u16,
16+
pub height: u16,
17+
pub offset_x: i16,
18+
pub offset_y: i16,
19+
pub advance_x: i16,
20+
}
21+
22+
bitflags::bitflags! {
23+
/// EFI_FONT_INFO_MASK
24+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
25+
#[repr(transparent)]
26+
pub struct FontInfoMask: u32 {
27+
const SYS_FONT = 1 << 0;
28+
const SYS_SIZE = 1 << 1;
29+
const SYS_STYLE = 1 << 2;
30+
const SYS_FORE_COLOR = 1 << 4;
31+
const SYS_BACK_COLOR = 1 << 5;
32+
const RESIZE = 1 << 12;
33+
const RESTYLE = 1 << 13;
34+
const ANY_FONT = 1 << 16;
35+
const ANY_SIZE = 1 << 17;
36+
const ANY_STYLE = 1 << 18;
37+
}
38+
}
39+
40+
bitflags::bitflags! {
41+
/// EFI_HII_FONT_STYLE
42+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
43+
#[repr(transparent)]
44+
pub struct HiiFontStyle: u32 {
45+
const BOLD = 1 << 0;
46+
const ITALIC = 1 << 1;
47+
const EMBOSS = 1 << 16;
48+
const OUTLINE = 1 << 17;
49+
const SHADOW = 1 << 18;
50+
const UNDERLINE = 1 << 19;
51+
const DBL_UNDER = 1 << 20;
52+
}
53+
}
54+
55+
impl HiiFontStyle {
56+
pub const NORMAL: Self = Self::empty();
57+
}
58+
59+
/// EFI_FONT_INFO
60+
#[derive(Debug)]
61+
#[repr(C)]
62+
pub struct FontInfo {
63+
pub font_style: HiiFontStyle,
64+
pub font_size: u16,
65+
pub font_name: [Char16; 0],
66+
}
67+
68+
/// EFI_FONT_DISPLAY_INFO
69+
#[derive(Debug)]
70+
#[repr(C)]
71+
pub struct FontDisplayInfo {
72+
pub foreground_color: GraphicsOutputBltPixel,
73+
pub background_color: GraphicsOutputBltPixel,
74+
pub font_mask_info: FontInfoMask,
75+
pub font_info: FontInfo,
76+
}
77+
78+
bitflags::bitflags! {
79+
/// EFI_HII_OUT_FLAGS
80+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
81+
#[repr(transparent)]
82+
pub struct HiiOutFlags: u32 {
83+
const CLIP = 1 << 0;
84+
const WRAP = 1 << 1;
85+
const CLIP_CLEAN_Y = 1 << 2;
86+
const CLIP_CLEAN_X = 1 << 3;
87+
const TRANSPARENT = 1 << 4;
88+
const IGNORE_IF_NO_GLYPH = 1 << 5;
89+
const IGNORE_LINE_BREAK = 1 << 6;
90+
const DIRECT_TO_SCREEN = 1 << 7;
91+
}
92+
}
93+
94+
/// EFI_HII_ROW_INFO
95+
#[derive(Debug)]
96+
#[repr(C)]
97+
pub struct HiiRowInfo {
98+
pub start_index: usize,
99+
pub end_index: usize,
100+
pub line_height: usize,
101+
pub line_width: usize,
102+
pub baseline_offset: usize,
103+
}
104+
105+
/// EFI_HII_FONT_PROTOCOL
106+
#[derive(Debug)]
107+
#[repr(C)]
108+
pub struct HiiFontProtocol {
109+
pub string_to_image: unsafe extern "efiapi" fn(
110+
this: *const Self,
111+
flags: HiiOutFlags,
112+
string: *const Char16,
113+
string_info: *const FontDisplayInfo,
114+
blt: *mut *mut ImageOutput,
115+
blt_x: usize,
116+
blt_y: usize,
117+
row_info_array: *mut *mut HiiRowInfo,
118+
row_info_array_size: *mut usize,
119+
column_info_array: *mut usize,
120+
) -> Status,
121+
pub string_id_to_image: unsafe extern "efiapi" fn(
122+
this: *const Self,
123+
flags: HiiOutFlags,
124+
package_list: HiiHandle,
125+
string_id: StringId,
126+
language: *const Char8,
127+
string_info: *const FontDisplayInfo,
128+
blt: *mut *mut ImageOutput,
129+
blt_x: usize,
130+
blt_y: usize,
131+
row_info_array: *mut *mut HiiRowInfo,
132+
row_info_array_size: *mut usize,
133+
column_info_array: *mut usize,
134+
) -> Status,
135+
pub get_glyph: unsafe extern "efiapi" fn(
136+
this: *const Self,
137+
char: Char16,
138+
string_info: *const FontDisplayInfo,
139+
blt: *mut *mut ImageOutput,
140+
baseline: *mut usize,
141+
) -> Status,
142+
pub get_font_info: unsafe extern "efiapi" fn(
143+
this: *const Self,
144+
font_handle: *mut FontHandle,
145+
string_info_in: *const FontDisplayInfo,
146+
string_info_out: *mut *mut FontDisplayInfo,
147+
string: *const Char16,
148+
) -> Status,
149+
}
150+
151+
impl HiiFontProtocol {
152+
pub const GUID: Guid = guid!("e9ca4775-8657-47fc-97e7-7ed65a084324");
153+
}
154+
155+
// NOTE: This protocol is declared in the UEFI spec, but not defined in edk2.
156+
/// EFI_HII_FONT_EX_PROTOCOL
157+
#[derive(Debug)]
158+
#[repr(C)]
159+
pub struct HiiFontExProtocol {
160+
pub string_to_image_ex: unsafe extern "efiapi" fn(
161+
this: *const Self,
162+
flags: HiiOutFlags,
163+
string: *const Char16,
164+
string_info: *const FontDisplayInfo,
165+
blt: *mut *mut ImageOutput,
166+
blt_x: usize,
167+
blt_y: usize,
168+
row_info_array: *mut *mut HiiRowInfo,
169+
row_info_array_size: *mut usize,
170+
column_info_array: *mut usize,
171+
) -> Status,
172+
pub string_id_to_image_ex: unsafe extern "efiapi" fn(
173+
this: *const Self,
174+
flags: HiiOutFlags,
175+
package_list: HiiHandle,
176+
string_id: StringId,
177+
language: *const Char8,
178+
string_info: *const FontDisplayInfo,
179+
blt: *mut *mut ImageOutput,
180+
blt_x: usize,
181+
blt_y: usize,
182+
row_info_array: *mut *mut HiiRowInfo,
183+
row_info_array_size: *mut usize,
184+
column_info_array: *mut usize,
185+
) -> Status,
186+
pub get_glyph_ex: unsafe extern "efiapi" fn(
187+
this: *const Self,
188+
char: Char16,
189+
string_info: *const FontDisplayInfo,
190+
blt: *mut *mut ImageOutput,
191+
baseline: *mut usize,
192+
) -> Status,
193+
pub get_font_info_ex: unsafe extern "efiapi" fn(
194+
this: *const Self,
195+
font_handle: *mut FontHandle,
196+
string_info_in: *const FontDisplayInfo,
197+
string_info_out: *mut *mut FontDisplayInfo,
198+
string: *const Char16,
199+
) -> Status,
200+
pub get_glyph_info: unsafe extern "efiapi" fn(
201+
this: *const Self,
202+
char: Char16,
203+
font_display_info: *const FontDisplayInfo,
204+
glyph_info: *mut HiiGlyphInfo,
205+
) -> Status,
206+
}
207+
208+
impl HiiFontExProtocol {
209+
pub const GUID: Guid = guid!("849e6875-db35-4df8-b41e-c8f33718073f");
210+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
3+
//! Form Browser protocol
4+
5+
use super::{FormId, HiiHandle};
6+
use crate::{Boolean, Char16, Guid, Status, guid, newtype_enum};
7+
8+
/// EFI_SCREEN_DESCRIPTOR
9+
#[derive(Debug)]
10+
#[repr(C)]
11+
pub struct ScreenDescriptor {
12+
pub left_column: usize,
13+
pub right_column: usize,
14+
pub top_row: usize,
15+
pub bottom_row: usize,
16+
}
17+
18+
newtype_enum! {
19+
/// Represents actions requested by the Forms Browser in response to user interactions.
20+
#[derive(Default)]
21+
pub enum BrowserActionRequest: usize => {
22+
/// No special behavior is taken by the Forms Browser.
23+
NONE = 0,
24+
/// The Forms Browser will exit and request the platform to reset.
25+
RESET = 1,
26+
/// The Forms Browser will save all modified question values to storage and exit.
27+
SUBMIT = 2,
28+
/// The Forms Browser will discard all modified question values and exit.
29+
EXIT = 3,
30+
/// The Forms Browser will write all modified question values on the selected form to storage and exit the form.
31+
FORM_SUBMIT_EXIT = 4,
32+
/// The Forms Browser will discard the modified question values on the selected form and exit the form.
33+
FORM_DISCARD_EXIT = 5,
34+
/// The Forms Browser will write all modified current question values on the selected form to storage.
35+
FORM_APPLY = 6,
36+
/// The Forms Browser will discard the current question values on the selected form and replace them with the original values.
37+
FORM_DISCARD = 7,
38+
/// The user performed a hardware or software configuration change, requiring controller reconnection.
39+
/// The Forms Browser calls `DisconnectController()` followed by `ConnectController()`.
40+
RECONNECT = 8,
41+
/// The Forms Browser will write the current modified question value on the selected form to storage.
42+
QUESTION_APPLY = 9,
43+
}
44+
}
45+
46+
// EFI_FORM_BROWSER2_PROTOCOL
47+
#[derive(Debug)]
48+
#[repr(C)]
49+
pub struct FormBrowser2Protocol {
50+
pub send_form: unsafe extern "efiapi" fn(
51+
this: *const Self,
52+
handles: *const HiiHandle,
53+
handle_count: usize,
54+
formset_guid: *const Guid,
55+
form_id: FormId,
56+
screen_dimensions: *const ScreenDescriptor,
57+
action_request: *mut BrowserActionRequest,
58+
) -> Status,
59+
pub browser_callback: unsafe extern "efiapi" fn(
60+
this: *const Self,
61+
results_data_size: *mut usize,
62+
results_data: *mut Char16,
63+
retrieve_data: Boolean,
64+
variable_guid: *const Guid,
65+
variable_name: *const Char16,
66+
) -> Status,
67+
}
68+
69+
impl FormBrowser2Protocol {
70+
pub const GUID: Guid = guid!("b9d4c360-bcfb-4f9b-9298-53c136982258");
71+
}

0 commit comments

Comments
 (0)