mirror of
https://github.com/ziglang/zig.git
synced 2024-12-01 01:22:50 +00:00
std/os/uefi: add some hii support
This commit is contained in:
parent
a4f324e9ea
commit
4527110e02
@ -29,4 +29,11 @@ pub const EdidActiveProtocol = @import("protocols/edid_active_protocol.zig").Edi
|
||||
pub const EdidOverrideProtocol = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocol;
|
||||
pub const EdidOverrideProtocolAttributes = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocolAttributes;
|
||||
|
||||
pub const hii = @import("protocols/hii.zig");
|
||||
pub const HIIDatabaseProtocol = @import("protocols/hii_database_protocol.zig").HIIDatabaseProtocol;
|
||||
pub const HIIPopupProtocol = @import("protocols/hii_popup_protocol.zig").HIIPopupProtocol;
|
||||
pub const HIIPopupStyle = @import("protocols/hii_popup_protocol.zig").HIIPopupStyle;
|
||||
pub const HIIPopupType = @import("protocols/hii_popup_protocol.zig").HIIPopupType;
|
||||
pub const HIIPopupSelection = @import("protocols/hii_popup_protocol.zig").HIIPopupSelection;
|
||||
|
||||
pub const RNGProtocol = @import("protocols/rng_protocol.zig").RNGProtocol;
|
||||
|
71
lib/std/os/uefi/protocols/hii.zig
Normal file
71
lib/std/os/uefi/protocols/hii.zig
Normal file
@ -0,0 +1,71 @@
|
||||
const uefi = @import("std").os.uefi;
|
||||
const Guid = uefi.Guid;
|
||||
|
||||
pub const HIIHandle = *@OpaqueType();
|
||||
|
||||
pub const HIIPackageHeader = packed struct {
|
||||
length: u24,
|
||||
type: u8,
|
||||
|
||||
pub const type_all: u8 = 0x0;
|
||||
pub const type_guid: u8 = 0x1;
|
||||
pub const forms: u8 = 0x2;
|
||||
pub const strings: u8 = 0x4;
|
||||
pub const fonts: u8 = 0x5;
|
||||
pub const images: u8 = 0x6;
|
||||
pub const simple_fonsts: u8 = 0x7;
|
||||
pub const device_path: u8 = 0x8;
|
||||
pub const keyboard_layout: u8 = 0x9;
|
||||
pub const animations: u8 = 0xa;
|
||||
pub const end: u8 = 0xdf;
|
||||
pub const type_system_begin: u8 = 0xe0;
|
||||
pub const type_system_end: u8 = 0xff;
|
||||
};
|
||||
|
||||
pub const HIIPackageList = extern struct {
|
||||
package_list_guid: Guid,
|
||||
package_list_length: u32,
|
||||
|
||||
// TODO implement iterator
|
||||
};
|
||||
|
||||
pub const HIISimplifiedFontPackage = extern struct {
|
||||
header: HIIPackageHeader,
|
||||
number_of_narrow_glyphs: u16,
|
||||
number_of_wide_glyphs: u16,
|
||||
|
||||
pub fn getNarrowGlyphs(self: *HIISimplifiedFontPackage) []NarrowGlyph {
|
||||
return @ptrCast([*]NarrowGlyph, @ptrCast([*]u8, self) + @sizeOf(HIISimplifiedFontPackage))[0..self.number_of_narrow_glyphs];
|
||||
}
|
||||
};
|
||||
|
||||
pub const NarrowGlyph = extern struct {
|
||||
unicode_weight: u16,
|
||||
attributes: packed struct {
|
||||
non_spacing: bool,
|
||||
wide: bool,
|
||||
_pad: u6,
|
||||
},
|
||||
glyph_col_1: [19]u8,
|
||||
};
|
||||
|
||||
pub const WideGlyph = extern struct {
|
||||
unicode_weight: u16,
|
||||
attributes: packed struct {
|
||||
non_spacing: bool,
|
||||
wide: bool,
|
||||
_pad: u6,
|
||||
},
|
||||
glyph_col_1: [19]u8,
|
||||
glyph_col_2: [19]u8,
|
||||
_pad: [3]u8,
|
||||
};
|
||||
|
||||
pub const HIIStringPackage = extern struct {
|
||||
header: HIIPackageHeader,
|
||||
hdr_size: u32,
|
||||
string_info_offset: u32,
|
||||
language_window: [16]u16,
|
||||
language_name: u16,
|
||||
language: [3]u8,
|
||||
};
|
42
lib/std/os/uefi/protocols/hii_database_protocol.zig
Normal file
42
lib/std/os/uefi/protocols/hii_database_protocol.zig
Normal file
@ -0,0 +1,42 @@
|
||||
const uefi = @import("std").os.uefi;
|
||||
const Guid = uefi.Guid;
|
||||
const hii = uefi.protocols.hii;
|
||||
|
||||
pub const HIIDatabaseProtocol = extern struct {
|
||||
_new_package_list: usize, // TODO
|
||||
_remove_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle) usize,
|
||||
_update_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle, *const hii.HIIPackageList) usize,
|
||||
_list_package_lists: extern fn (*const HIIDatabaseProtocol, u8, ?*const Guid, *usize, [*]hii.HIIHandle) usize,
|
||||
_export_package_lists: extern fn (*const HIIDatabaseProtocol, ?hii.HIIHandle, *usize, *hii.HIIPackageList) usize,
|
||||
_register_package_notify: usize, // TODO
|
||||
_unregister_package_notify: usize, // TODO
|
||||
_find_keyboard_layouts: usize, // TODO
|
||||
_get_keyboard_layout: usize, // TODO
|
||||
_set_keyboard_layout: usize, // TODO
|
||||
_get_package_list_handle: usize, // TODO
|
||||
|
||||
pub fn removePackageList(self: *const HIIDatabaseProtocol, handle: hii.HIIHandle) usize {
|
||||
return self._remove_package_list(self, handle);
|
||||
}
|
||||
|
||||
pub fn updatePackageList(self: *const HIIDatabaseProtocol, handle: hii.HIIHandle, buffer: *const hii.HIIPackageList) usize {
|
||||
return self._update_package_list(self, handle, buffer);
|
||||
}
|
||||
|
||||
pub fn listPackageLists(self: *const HIIDatabaseProtocol, package_type: u8, package_guid: ?*const Guid, buffer_length: *usize, handles: [*]hii.HIIHandle) usize {
|
||||
return self._list_package_lists(self, package_type, package_guid, buffer_length, handles);
|
||||
}
|
||||
|
||||
pub fn exportPackageLists(self: *const HIIDatabaseProtocol, handle: ?hii.HIIHandle, buffer_size: *usize, buffer: *hii.HIIPackageList) usize {
|
||||
return self._export_package_lists(self, handle, buffer_size, buffer);
|
||||
}
|
||||
|
||||
pub const guid align(8) = Guid{
|
||||
.time_low = 0xef9fc172,
|
||||
.time_mid = 0xa1b2,
|
||||
.time_high_and_version = 0x4693,
|
||||
.clock_seq_high_and_reserved = 0xb3,
|
||||
.clock_seq_low = 0x27,
|
||||
.node = [_]u8{ 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42 },
|
||||
};
|
||||
};
|
41
lib/std/os/uefi/protocols/hii_popup_protocol.zig
Normal file
41
lib/std/os/uefi/protocols/hii_popup_protocol.zig
Normal file
@ -0,0 +1,41 @@
|
||||
const uefi = @import("std").os.uefi;
|
||||
const Guid = uefi.Guid;
|
||||
const hii = uefi.protocols.hii;
|
||||
|
||||
pub const HIIPopupProtocol = extern struct {
|
||||
revision: u64,
|
||||
_create_popup: extern fn (*const HIIPopupProtocol, HIIPopupStyle, HIIPopupType, hii.HIIHandle, u16, ?*HIIPopupSelection) usize,
|
||||
|
||||
pub fn createPopup(self: *const HIIPopupProtocol, style: HIIPopupStyle, popup_type: HIIPopupType, handle: hii.HIIHandle, msg: u16, user_selection: ?*HIIPopupSelection) usize {
|
||||
return self._create_popup(self, style, popup_type, handle, msg, user_selection);
|
||||
}
|
||||
|
||||
pub const guid align(8) = Guid{
|
||||
.time_low = 0x4311edc0,
|
||||
.time_mid = 0x6054,
|
||||
.time_high_and_version = 0x46d4,
|
||||
.clock_seq_high_and_reserved = 0x9e,
|
||||
.clock_seq_low = 0x40,
|
||||
.node = [_]u8{ 0x89, 0x3e, 0xa9, 0x52, 0xfc, 0xcc },
|
||||
};
|
||||
};
|
||||
|
||||
pub const HIIPopupStyle = extern enum(u32) {
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
};
|
||||
|
||||
pub const HIIPopupType = extern enum(u32) {
|
||||
Ok,
|
||||
Cancel,
|
||||
YesNo,
|
||||
YesNoCancel,
|
||||
};
|
||||
|
||||
pub const HIIPopupSelection = extern enum(u32) {
|
||||
Ok,
|
||||
Cancel,
|
||||
Yes,
|
||||
No,
|
||||
};
|
Loading…
Reference in New Issue
Block a user