Skip to content

Commit 3dfb0d2

Browse files
committed
uefi-raw: Add bindings for more HII protocols
Add bindings for the following UEFI 2.11 protocols: - Font (EFI_HII_FONT_PROTOCOL) - Font Ex (EFI_HII_FONT_EX_PROTOCOL) - String (EFI_HII_STRING_PROTOCOL) - Image (EFI_HII_IMAGE_PROTOCOL) - Image Ex (EFI_HII_IMAGE_EX_PROTOCOL) Ref: UEFI 2.11: 34 HII Protocols Signed-off-by: Tim Crawford <[email protected]>
1 parent 2fc1b45 commit 3dfb0d2

File tree

6 files changed

+449
-4
lines changed

6 files changed

+449
-4
lines changed

uefi-raw/CHANGELOG.md

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

33
## Added
44

5+
- Added `HiiFontProtocol`, `HiiFontExProtocol`.
6+
- Added `HiiImageProtocol`, `HiiImageExProtocol`.
7+
- Added `HiiStringProtocol`.
8+
59
## Changed
610

711

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
use core::fmt::Debug;
66

7+
use super::{FormId, QuestionId, StringId};
78
use crate::protocol::device_path::DevicePathProtocol;
89
use crate::{Boolean, Char16, Guid, Status, guid, newtype_enum};
910

@@ -141,10 +142,6 @@ impl core::fmt::Debug for IfrTypeValue {
141142
}
142143
}
143144

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

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

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
3+
//! Bindings for HII Font protocols and data types
4+
5+
use super::{HiiHandle, StringId};
6+
use crate::protocol::console::GraphicsOutputBltPixel;
7+
use crate::protocol::hii::image::ImageOutput;
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 NORMAL = 0;
46+
const BOLD = 1 << 0;
47+
const ITALIC = 1 << 1;
48+
const EMBOSS = 1 << 16;
49+
const OUTLINE = 1 << 17;
50+
const SHADOW = 1 << 18;
51+
const UNDERLINE = 1 << 19;
52+
const DBL_UNDER = 1 << 20;
53+
}
54+
}
55+
56+
/// EFI_FONT_INFO
57+
#[derive(Debug)]
58+
#[repr(C)]
59+
pub struct FontInfo {
60+
pub font_style: HiiFontStyle,
61+
pub font_size: u16,
62+
pub font_name: [Char16; 0],
63+
}
64+
65+
/// EFI_FONT_DISPLAY_INFO
66+
#[derive(Debug)]
67+
#[repr(C)]
68+
pub struct FontDisplayInfo {
69+
pub foreground_color: GraphicsOutputBltPixel,
70+
pub background_color: GraphicsOutputBltPixel,
71+
pub font_mask_info: FontInfoMask,
72+
pub font_info: FontInfo,
73+
}
74+
75+
bitflags::bitflags! {
76+
/// EFI_HII_OUT_FLAGS
77+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
78+
#[repr(transparent)]
79+
pub struct HiiOutFlags: u32 {
80+
const CLIP = 1 << 0;
81+
const WRAP = 1 << 1;
82+
const CLIP_CLEAN_Y = 1 << 2;
83+
const CLIP_CLEAN_X = 1 << 3;
84+
const TRANSPARENT = 1 << 4;
85+
const IGNORE_IF_NO_GLYPH = 1 << 5;
86+
const IGNORE_LINE_BREAK = 1 << 6;
87+
const DIRECT_TO_SCREEN = 1 << 7;
88+
}
89+
}
90+
91+
/// EFI_HII_ROW_INFO
92+
#[derive(Debug)]
93+
#[repr(C)]
94+
pub struct HiiRowInfo {
95+
pub start_index: usize,
96+
pub end_index: usize,
97+
pub line_height: usize,
98+
pub line_width: usize,
99+
pub baseline_offset: usize,
100+
}
101+
102+
/// EFI_HII_FONT_PROTOCOL
103+
#[derive(Debug)]
104+
#[repr(C)]
105+
pub struct HiiFontProtocol {
106+
pub string_to_image: unsafe extern "efiapi" fn(
107+
this: *const Self,
108+
flags: HiiOutFlags,
109+
string: *const Char16,
110+
string_info: *const FontDisplayInfo,
111+
blt: *mut *mut ImageOutput,
112+
blt_x: usize,
113+
blt_y: usize,
114+
row_info_array: *mut *mut HiiRowInfo,
115+
row_info_array_size: *mut usize,
116+
column_info_array: *mut usize,
117+
) -> Status,
118+
pub string_id_to_image: unsafe extern "efiapi" fn(
119+
this: *const Self,
120+
flags: HiiOutFlags,
121+
package_list: HiiHandle,
122+
string_id: StringId,
123+
language: *const Char8,
124+
string_info: *const FontDisplayInfo,
125+
blt: *mut *mut ImageOutput,
126+
blt_x: usize,
127+
blt_y: usize,
128+
row_info_array: *mut *mut HiiRowInfo,
129+
row_info_array_size: *mut usize,
130+
column_info_array: *mut usize,
131+
) -> Status,
132+
pub get_glyph: unsafe extern "efiapi" fn(
133+
this: *const Self,
134+
char: Char16,
135+
string_info: *const FontDisplayInfo,
136+
blt: *mut *mut ImageOutput,
137+
baseline: *mut usize,
138+
) -> Status,
139+
pub get_font_info: unsafe extern "efiapi" fn(
140+
this: *const Self,
141+
font_handle: *mut FontHandle,
142+
string_info_in: *const FontDisplayInfo,
143+
string_info_out: *mut *mut FontDisplayInfo,
144+
string: *const Char16,
145+
) -> Status,
146+
}
147+
148+
impl HiiFontProtocol {
149+
pub const GUID: Guid = guid!("e9ca4775-8657-47fc-97e7-7ed65a084324");
150+
}
151+
152+
// NOTE: This protocol is declared in the UEFI spec, but not defined in edk2.
153+
/// EFI_HII_FONT_EX_PROTOCOL
154+
#[derive(Debug)]
155+
#[repr(C)]
156+
pub struct HiiFontExProtocol {
157+
pub string_to_image_ex: unsafe extern "efiapi" fn(
158+
this: *const Self,
159+
flags: HiiOutFlags,
160+
string: *const Char16,
161+
string_info: *const FontDisplayInfo,
162+
blt: *mut *mut ImageOutput,
163+
blt_x: usize,
164+
blt_y: usize,
165+
row_info_array: *mut *mut HiiRowInfo,
166+
row_info_array_size: *mut usize,
167+
column_info_array: *mut usize,
168+
) -> Status,
169+
pub string_id_to_image_ex: unsafe extern "efiapi" fn(
170+
this: *const Self,
171+
flags: HiiOutFlags,
172+
package_list: HiiHandle,
173+
string_id: StringId,
174+
language: *const Char8,
175+
string_info: *const FontDisplayInfo,
176+
blt: *mut *mut ImageOutput,
177+
blt_x: usize,
178+
blt_y: usize,
179+
row_info_array: *mut *mut HiiRowInfo,
180+
row_info_array_size: *mut usize,
181+
column_info_array: *mut usize,
182+
) -> Status,
183+
pub get_glyph_ex: unsafe extern "efiapi" fn(
184+
this: *const Self,
185+
char: Char16,
186+
string_info: *const FontDisplayInfo,
187+
blt: *mut *mut ImageOutput,
188+
baseline: *mut usize,
189+
) -> Status,
190+
pub get_font_info_ex: unsafe extern "efiapi" fn(
191+
this: *const Self,
192+
font_handle: *mut FontHandle,
193+
string_info_in: *const FontDisplayInfo,
194+
string_info_out: *mut *mut FontDisplayInfo,
195+
string: *const Char16,
196+
) -> Status,
197+
pub get_glyph_info: unsafe extern "efiapi" fn(
198+
this: *const Self,
199+
char: Char16,
200+
font_display_info: *const FontDisplayInfo,
201+
glyph_info: *mut HiiGlyphInfo,
202+
) -> Status,
203+
}
204+
205+
impl HiiFontExProtocol {
206+
pub const GUID: Guid = guid!("849e6875-db35-4df8-b41e-c8f33718073f");
207+
}

0 commit comments

Comments
 (0)