Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3f819f4

Browse files
authoredJan 7, 2025··
Merge pull request #1510 from crawfxrd/hii-db
uefi-raw: hii: Add Database Protocol
2 parents bf8cfa7 + 37871ad commit 3f819f4

File tree

4 files changed

+306
-0
lines changed

4 files changed

+306
-0
lines changed
 

‎uefi-raw/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Added `DriverBindingProtocol`.
88
- Added `FirmwareVolume2Protocol`.
99
- Added `FirmwareVolumeBlock2Protocol`.
10+
- Added `HiiDatabaseProtocol`.
1011

1112

1213
# uefi-raw - 0.9.0 (2024-10-23)

‎uefi-raw/src/protocol/hii/database.rs

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//! Bindings for HII Database Protocol
2+
3+
use super::{HiiHandle, HiiPackageHeader, HiiPackageListHeader, KeyDescriptor};
4+
use crate::{guid, Guid, Handle, Status};
5+
6+
/// EFI_HII_KEYBOARD_LAYOUT
7+
#[derive(Debug)]
8+
#[repr(C)]
9+
pub struct HiiKeyboardLayout {
10+
pub layout_length: u16,
11+
pub guid: Guid,
12+
pub layout_descriptor_string_offset: u32,
13+
pub descriptor_count: u8,
14+
pub descriptors: [KeyDescriptor; 0],
15+
}
16+
17+
newtype_enum! {
18+
/// EFI_HII_DATABASE_NOTIFY_TYPE
19+
pub enum HiiDatabaseNotifyType: usize => {
20+
NEW_PACK = 1 << 0,
21+
REMOVE_PACK = 1 << 1,
22+
EXPORT_PACK = 1 << 2,
23+
ADD_PACK = 1 << 3,
24+
}
25+
}
26+
27+
/// EFI_HII_DATABASE_NOTIFY
28+
pub type HiiDatabaseNotifyFn = unsafe extern "efiapi" fn(
29+
package_type: u8,
30+
package_guid: *const Guid,
31+
package: *const HiiPackageHeader,
32+
handle: HiiHandle,
33+
notify_type: HiiDatabaseNotifyType,
34+
) -> Status;
35+
36+
/// EFI_HII_DATABASE_PROTOCOL
37+
#[derive(Debug)]
38+
#[repr(C)]
39+
pub struct HiiDatabaseProtocol {
40+
pub new_package_list: unsafe extern "efiapi" fn(
41+
this: *const Self,
42+
package_list: *const HiiPackageListHeader,
43+
driver_handle: Handle,
44+
handle: *mut HiiHandle,
45+
) -> Status,
46+
pub remove_package_list:
47+
unsafe extern "efiapi" fn(this: *const Self, handle: HiiHandle) -> Status,
48+
pub update_package_list: unsafe extern "efiapi" fn(
49+
this: *const Self,
50+
handle: HiiHandle,
51+
package_list: *const HiiPackageListHeader,
52+
) -> Status,
53+
pub list_package_lists: unsafe extern "efiapi" fn(
54+
this: *const Self,
55+
package_type: u8,
56+
package_guid: *const Guid,
57+
handle_buffer_length: *mut usize,
58+
handle: *mut HiiHandle,
59+
) -> Status,
60+
pub export_package_lists: unsafe extern "efiapi" fn(
61+
this: *const Self,
62+
handle: HiiHandle,
63+
buffer_size: *mut usize,
64+
buffer: *mut HiiPackageListHeader,
65+
) -> Status,
66+
pub register_package_notify: unsafe extern "efiapi" fn(
67+
this: *const Self,
68+
package_type: u8,
69+
package_guid: *const Guid,
70+
package_notify_fn: HiiDatabaseNotifyFn,
71+
notify_type: HiiDatabaseNotifyType,
72+
notify_handle: *mut Handle,
73+
) -> Status,
74+
pub unregister_package_notify:
75+
unsafe extern "efiapi" fn(this: *const Self, notification_handle: Handle) -> Status,
76+
pub find_keyboard_layouts: unsafe extern "efiapi" fn(
77+
this: *const Self,
78+
key_guid_buffer_length: *mut u16,
79+
key_guid_buffer: *mut Guid,
80+
) -> Status,
81+
pub get_keyboard_layout: unsafe extern "efiapi" fn(
82+
this: *const Self,
83+
key_guid: *const Guid,
84+
leyboard_layout_length: *mut u16,
85+
keyboard_layout: *mut HiiKeyboardLayout,
86+
) -> Status,
87+
pub set_keyboard_layout:
88+
unsafe extern "efiapi" fn(this: *const Self, key_guid: *const Guid) -> Status,
89+
pub get_package_list_handle: unsafe extern "efiapi" fn(
90+
this: *const Self,
91+
package_list_handle: HiiHandle,
92+
driver_handle: *mut Handle,
93+
) -> Status,
94+
}
95+
96+
impl HiiDatabaseProtocol {
97+
pub const GUID: Guid = guid!("ef9fc172-a1b2-4693-b327-6d32fc416042");
98+
}

‎uefi-raw/src/protocol/hii/mod.rs

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
//! HII Protocols
2+
3+
pub mod database;
4+
5+
use crate::{Char16, Guid};
6+
7+
pub type HiiHandle = *mut core::ffi::c_void;
8+
9+
/// EFI_HII_PACKAGE_HEADER
10+
#[derive(Debug)]
11+
#[repr(C)]
12+
pub struct HiiPackageHeader {
13+
pub length_and_type: u32,
14+
pub data: [u8; 0],
15+
}
16+
17+
/// EFI_HII_PACKAGE_LIST_HEADER
18+
#[derive(Debug)]
19+
#[repr(C)]
20+
pub struct HiiPackageListHeader {
21+
pub package_list_guid: Guid,
22+
pub package_length: u32,
23+
}
24+
25+
newtype_enum! {
26+
/// EFI_KEY: A physical key on a keyboard.
27+
pub enum Key: u32 => {
28+
LCTRL = 0,
29+
A0 = 1,
30+
LALT = 2,
31+
SPACEBAR = 3,
32+
A2 = 4,
33+
A3 = 5,
34+
A4 = 6,
35+
RCTRL = 7,
36+
LEFT_ARROW = 8,
37+
DOWN_ARROW = 9,
38+
RIGHT_ARROW = 10,
39+
ZERO = 11,
40+
PERIOD = 12,
41+
ENTER = 13,
42+
LSHIFT = 14,
43+
B0 = 15,
44+
B1 = 16,
45+
B2 = 17,
46+
B3 = 18,
47+
B4 = 19,
48+
B5 = 20,
49+
B6 = 21,
50+
B7 = 22,
51+
B8 = 23,
52+
B9 = 24,
53+
B10 = 25,
54+
RSHIFT = 26,
55+
UP_ARROW = 27,
56+
ONE = 28,
57+
TWO = 29,
58+
THREE = 30,
59+
CAPS_LOCK = 31,
60+
C1 = 32,
61+
C2 = 33,
62+
C3 = 34,
63+
C4 = 35,
64+
C5 = 36,
65+
C6 = 37,
66+
C7 = 38,
67+
C8 = 39,
68+
C9 = 40,
69+
C10 = 41,
70+
C11 = 42,
71+
C12 = 43,
72+
FOUR = 44,
73+
FIVE = 45,
74+
SIX = 46,
75+
PLUS = 47,
76+
TAB = 48,
77+
D1 = 49,
78+
D2 = 50,
79+
D3 = 51,
80+
D4 = 52,
81+
D5 = 53,
82+
D6 = 54,
83+
D7 = 55,
84+
D8 = 56,
85+
D9 = 57,
86+
D10 = 58,
87+
D11 = 59,
88+
D12 = 60,
89+
D13 = 61,
90+
DEL = 62,
91+
END = 63,
92+
PG_DN = 64,
93+
SEVEN = 65,
94+
EIGHT = 66,
95+
NINE = 67,
96+
E0 = 68,
97+
E1 = 69,
98+
E2 = 70,
99+
E3 = 71,
100+
E4 = 72,
101+
E5 = 73,
102+
E6 = 74,
103+
E7 = 75,
104+
E8 = 76,
105+
E9 = 77,
106+
E10 = 78,
107+
E11 = 79,
108+
E12 = 80,
109+
BACK_SPACE = 81,
110+
INS = 82,
111+
HOME = 83,
112+
PG_UP = 84,
113+
NLCK = 85,
114+
SLASH = 86,
115+
ASTERISK = 87,
116+
MINUS = 88,
117+
ESC = 89,
118+
F1 = 90,
119+
F2 = 91,
120+
F3 = 92,
121+
F4 = 93,
122+
F5 = 94,
123+
F6 = 95,
124+
F7 = 96,
125+
F8 = 97,
126+
F9 = 98,
127+
F10 = 99,
128+
F11 = 100,
129+
F12 = 101,
130+
PRINT = 102,
131+
SLCK = 103,
132+
PAUSE = 104,
133+
INTL0 = 105,
134+
INTL1 = 106,
135+
INTL2 = 107,
136+
INTL3 = 108,
137+
INTL4 = 109,
138+
INTL5 = 110,
139+
INTL6 = 111,
140+
INTL7 = 112,
141+
INTL8 = 113,
142+
INTL9 = 114,
143+
}
144+
}
145+
146+
// NOTE: This has no associated type in UEFI; They are all top-level defines.
147+
newtype_enum! {
148+
/// Key modifier values
149+
pub enum Modifier: u16 => {
150+
NULL = 0x0000,
151+
LEFT_CONTROL = 0x0001,
152+
RIGHT_CONTROL = 0x0002,
153+
LEFT_ALT = 0x0003,
154+
RIGHT_ALT = 0x0004,
155+
ALT_GR = 0x0005,
156+
INSERT = 0x0006,
157+
DELETE = 0x0007,
158+
PAGE_DOWN = 0x0008,
159+
PAGE_UP = 0x0009,
160+
HOME = 0x000A,
161+
END = 0x000B,
162+
LEFT_SHIFT = 0x000C,
163+
RIGHT_SHIFT = 0x000D,
164+
CAPS_LOCK = 0x000E,
165+
NUM_LOCK = 0x000F,
166+
LEFT_ARROW = 0x0010,
167+
RIGHT_ARROW = 0x0011,
168+
DOWN_ARROW = 0x0012,
169+
UP_ARROW = 0x0013,
170+
NS_KEY = 0x0014,
171+
NS_KEY_DEPENDENCY = 0x0015,
172+
FUNCTION_KEY_ONE = 0x0016,
173+
FUNCTION_KEY_TWO = 0x0017,
174+
FUNCTION_KEY_THREE = 0x0018,
175+
FUNCTION_KEY_FOUR = 0x0019,
176+
FUNCTION_KEY_FIVE = 0x001A,
177+
FUNCTION_KEY_SIX = 0x001B,
178+
FUNCTION_KEY_SEVEN = 0x001C,
179+
FUNCTION_KEY_EIGHT = 0x001D,
180+
FUNCTION_KEY_NINE = 0x001E,
181+
FUNCTION_KEY_TEN = 0x001F,
182+
FUNCTION_KEY_ELEVEN = 0x0020,
183+
FUNCTION_KEY_TWELVE = 0x0021,
184+
PRINT = 0x0022,
185+
SYS_REQUEST = 0x0023,
186+
SCROLL_LOCK = 0x0024,
187+
PAUSE = 0x0025,
188+
BREAK = 0x0026,
189+
LEFT_LOGO = 0x0027,
190+
RIGHT_LOGO = 0x0028,
191+
MENU = 0x0029,
192+
}
193+
}
194+
195+
/// EFI_KEY_DESCRIPTOR
196+
#[derive(Debug)]
197+
#[repr(C)]
198+
pub struct KeyDescriptor {
199+
pub key: Key,
200+
pub unicode: Char16,
201+
pub shifted_unicode: Char16,
202+
pub alt_gr_unicode: Char16,
203+
pub shifted_alt_gr_unicode: Char16,
204+
pub modifier: u16,
205+
pub affected_attribute: u16,
206+
}

‎uefi-raw/src/protocol/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub mod disk;
1111
pub mod driver;
1212
pub mod file_system;
1313
pub mod firmware_volume;
14+
pub mod hii;
1415
pub mod loaded_image;
1516
pub mod media;
1617
pub mod memory_protection;

0 commit comments

Comments
 (0)
Please sign in to comment.