authorgravatar for n@nirf.deNick Erdmann <n@nirf.de> 2019-09-25 21:18:05+02:00
committergravatar for n@nirf.deNick Erdmann <n@nirf.de> 2019-09-27 07:56:14+02:00
log4527110e02d599c31a8aa51e1d24f34aff879de7
tree0ee5cb6550f6f27e5453c35fcc312688bbf7d4de
parenta4f324e9ea37b086d5bf2aa962d74e18adeeb4d0
signaturelock-open Commit is signed but in an unrecognized format.

std/os/uefi: add some hii support


4 files changed, 161 insertions(+), 0 deletions(-)

lib/std/os/uefi/protocols.zig+7
......@@ -29,4 +29,11 @@ pub const EdidActiveProtocol = @import("protocols/edid_active_protocol.zig").Edi
2929pub const EdidOverrideProtocol = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocol;
3030pub const EdidOverrideProtocolAttributes = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocolAttributes;
3131
32pub const hii = @import("protocols/hii.zig");
33pub const HIIDatabaseProtocol = @import("protocols/hii_database_protocol.zig").HIIDatabaseProtocol;
34pub const HIIPopupProtocol = @import("protocols/hii_popup_protocol.zig").HIIPopupProtocol;
35pub const HIIPopupStyle = @import("protocols/hii_popup_protocol.zig").HIIPopupStyle;
36pub const HIIPopupType = @import("protocols/hii_popup_protocol.zig").HIIPopupType;
37pub const HIIPopupSelection = @import("protocols/hii_popup_protocol.zig").HIIPopupSelection;
38
3239pub const RNGProtocol = @import("protocols/rng_protocol.zig").RNGProtocol;
lib/std/os/uefi/protocols/hii.zig created+71
......@@ -0,0 +1,71 @@
1const uefi = @import("std").os.uefi;
2const Guid = uefi.Guid;
3
4pub const HIIHandle = *@OpaqueType();
5
6pub const HIIPackageHeader = packed struct {
7 length: u24,
8 type: u8,
9
10 pub const type_all: u8 = 0x0;
11 pub const type_guid: u8 = 0x1;
12 pub const forms: u8 = 0x2;
13 pub const strings: u8 = 0x4;
14 pub const fonts: u8 = 0x5;
15 pub const images: u8 = 0x6;
16 pub const simple_fonsts: u8 = 0x7;
17 pub const device_path: u8 = 0x8;
18 pub const keyboard_layout: u8 = 0x9;
19 pub const animations: u8 = 0xa;
20 pub const end: u8 = 0xdf;
21 pub const type_system_begin: u8 = 0xe0;
22 pub const type_system_end: u8 = 0xff;
23};
24
25pub const HIIPackageList = extern struct {
26 package_list_guid: Guid,
27 package_list_length: u32,
28
29 // TODO implement iterator
30};
31
32pub const HIISimplifiedFontPackage = extern struct {
33 header: HIIPackageHeader,
34 number_of_narrow_glyphs: u16,
35 number_of_wide_glyphs: u16,
36
37 pub fn getNarrowGlyphs(self: *HIISimplifiedFontPackage) []NarrowGlyph {
38 return @ptrCast([*]NarrowGlyph, @ptrCast([*]u8, self) + @sizeOf(HIISimplifiedFontPackage))[0..self.number_of_narrow_glyphs];
39 }
40};
41
42pub const NarrowGlyph = extern struct {
43 unicode_weight: u16,
44 attributes: packed struct {
45 non_spacing: bool,
46 wide: bool,
47 _pad: u6,
48 },
49 glyph_col_1: [19]u8,
50};
51
52pub const WideGlyph = extern struct {
53 unicode_weight: u16,
54 attributes: packed struct {
55 non_spacing: bool,
56 wide: bool,
57 _pad: u6,
58 },
59 glyph_col_1: [19]u8,
60 glyph_col_2: [19]u8,
61 _pad: [3]u8,
62};
63
64pub const HIIStringPackage = extern struct {
65 header: HIIPackageHeader,
66 hdr_size: u32,
67 string_info_offset: u32,
68 language_window: [16]u16,
69 language_name: u16,
70 language: [3]u8,
71};
lib/std/os/uefi/protocols/hii_database_protocol.zig created+42
......@@ -0,0 +1,42 @@
1const uefi = @import("std").os.uefi;
2const Guid = uefi.Guid;
3const hii = uefi.protocols.hii;
4
5pub const HIIDatabaseProtocol = extern struct {
6 _new_package_list: usize, // TODO
7 _remove_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle) usize,
8 _update_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle, *const hii.HIIPackageList) usize,
9 _list_package_lists: extern fn (*const HIIDatabaseProtocol, u8, ?*const Guid, *usize, [*]hii.HIIHandle) usize,
10 _export_package_lists: extern fn (*const HIIDatabaseProtocol, ?hii.HIIHandle, *usize, *hii.HIIPackageList) usize,
11 _register_package_notify: usize, // TODO
12 _unregister_package_notify: usize, // TODO
13 _find_keyboard_layouts: usize, // TODO
14 _get_keyboard_layout: usize, // TODO
15 _set_keyboard_layout: usize, // TODO
16 _get_package_list_handle: usize, // TODO
17
18 pub fn removePackageList(self: *const HIIDatabaseProtocol, handle: hii.HIIHandle) usize {
19 return self._remove_package_list(self, handle);
20 }
21
22 pub fn updatePackageList(self: *const HIIDatabaseProtocol, handle: hii.HIIHandle, buffer: *const hii.HIIPackageList) usize {
23 return self._update_package_list(self, handle, buffer);
24 }
25
26 pub fn listPackageLists(self: *const HIIDatabaseProtocol, package_type: u8, package_guid: ?*const Guid, buffer_length: *usize, handles: [*]hii.HIIHandle) usize {
27 return self._list_package_lists(self, package_type, package_guid, buffer_length, handles);
28 }
29
30 pub fn exportPackageLists(self: *const HIIDatabaseProtocol, handle: ?hii.HIIHandle, buffer_size: *usize, buffer: *hii.HIIPackageList) usize {
31 return self._export_package_lists(self, handle, buffer_size, buffer);
32 }
33
34 pub const guid align(8) = Guid{
35 .time_low = 0xef9fc172,
36 .time_mid = 0xa1b2,
37 .time_high_and_version = 0x4693,
38 .clock_seq_high_and_reserved = 0xb3,
39 .clock_seq_low = 0x27,
40 .node = [_]u8{ 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42 },
41 };
42};
lib/std/os/uefi/protocols/hii_popup_protocol.zig created+41
......@@ -0,0 +1,41 @@
1const uefi = @import("std").os.uefi;
2const Guid = uefi.Guid;
3const hii = uefi.protocols.hii;
4
5pub const HIIPopupProtocol = extern struct {
6 revision: u64,
7 _create_popup: extern fn (*const HIIPopupProtocol, HIIPopupStyle, HIIPopupType, hii.HIIHandle, u16, ?*HIIPopupSelection) usize,
8
9 pub fn createPopup(self: *const HIIPopupProtocol, style: HIIPopupStyle, popup_type: HIIPopupType, handle: hii.HIIHandle, msg: u16, user_selection: ?*HIIPopupSelection) usize {
10 return self._create_popup(self, style, popup_type, handle, msg, user_selection);
11 }
12
13 pub const guid align(8) = Guid{
14 .time_low = 0x4311edc0,
15 .time_mid = 0x6054,
16 .time_high_and_version = 0x46d4,
17 .clock_seq_high_and_reserved = 0x9e,
18 .clock_seq_low = 0x40,
19 .node = [_]u8{ 0x89, 0x3e, 0xa9, 0x52, 0xfc, 0xcc },
20 };
21};
22
23pub const HIIPopupStyle = extern enum(u32) {
24 Info,
25 Warning,
26 Error,
27};
28
29pub const HIIPopupType = extern enum(u32) {
30 Ok,
31 Cancel,
32 YesNo,
33 YesNoCancel,
34};
35
36pub const HIIPopupSelection = extern enum(u32) {
37 Ok,
38 Cancel,
39 Yes,
40 No,
41};