Skip to content

Commit 3f187e7

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 <tcrawford@system76.com>
1 parent bbe1c5a commit 3f187e7

File tree

6 files changed

+454
-4
lines changed

6 files changed

+454
-4
lines changed

uefi-raw/CHANGELOG.md

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

33
## Added
44
- Added `Tcpv4Protocol`.
5+
- Added `HiiFontProtocol`, `HiiFontExProtocol`.
6+
- Added `HiiImageProtocol`, `HiiImageExProtocol`.
7+
- Added `HiiStringProtocol`.
58

69
## Changed
710

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: 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::{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 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+
}

0 commit comments

Comments
 (0)