authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-27 10:41:26-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-09-27 10:41:26-04:00
loga1a3e46e0aa9add9997fe8d56f167830e007ab7f
tree0ee5cb6550f6f27e5453c35fcc312688bbf7d4de
parent23a82b5ffdc0973e6d62b0171268781f8cbcb70d
parent4527110e02d599c31a8aa51e1d24f34aff879de7
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #3323 from nrdmn/uefi

some minor UEFI improvements

6 files changed, 184 insertions(+), 20 deletions(-)

lib/std/os/uefi/protocols.zig+7
...@@ -29,4 +29,11 @@ pub const EdidActiveProtocol = @import("protocols/edid_active_protocol.zig").Edi...@@ -29,4 +29,11 @@ pub const EdidActiveProtocol = @import("protocols/edid_active_protocol.zig").Edi
29pub const EdidOverrideProtocol = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocol;29pub const EdidOverrideProtocol = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocol;
30pub const EdidOverrideProtocolAttributes = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocolAttributes;30pub 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
32pub const RNGProtocol = @import("protocols/rng_protocol.zig").RNGProtocol;39pub 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};
lib/std/os/uefi/tables.zig+1
...@@ -2,6 +2,7 @@ pub const BootServices = @import("tables/boot_services.zig").BootServices;...@@ -2,6 +2,7 @@ pub const BootServices = @import("tables/boot_services.zig").BootServices;
2pub const ConfigurationTable = @import("tables/configuration_table.zig").ConfigurationTable;2pub const ConfigurationTable = @import("tables/configuration_table.zig").ConfigurationTable;
3pub const global_variable align(8) = @import("tables/runtime_services.zig").global_variable;3pub const global_variable align(8) = @import("tables/runtime_services.zig").global_variable;
4pub const MemoryDescriptor = @import("tables/boot_services.zig").MemoryDescriptor;4pub const MemoryDescriptor = @import("tables/boot_services.zig").MemoryDescriptor;
5pub const MemoryType = @import("tables/boot_services.zig").MemoryType;
5pub const ResetType = @import("tables/runtime_services.zig").ResetType;6pub const ResetType = @import("tables/runtime_services.zig").ResetType;
6pub const RuntimeServices = @import("tables/runtime_services.zig").RuntimeServices;7pub const RuntimeServices = @import("tables/runtime_services.zig").RuntimeServices;
7pub const SystemTable = @import("tables/system_table.zig").SystemTable;8pub const SystemTable = @import("tables/system_table.zig").SystemTable;
lib/std/os/uefi/tables/boot_services.zig+22-20
...@@ -21,7 +21,7 @@ pub const BootServices = extern struct {...@@ -21,7 +21,7 @@ pub const BootServices = extern struct {
21 allocatePages: usize, // TODO21 allocatePages: usize, // TODO
22 freePages: usize, // TODO22 freePages: usize, // TODO
23 getMemoryMap: extern fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) usize,23 getMemoryMap: extern fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) usize,
24 allocatePool: usize, // TODO24 allocatePool: extern fn (MemoryType, usize, *align(8) [*]u8) usize,
25 freePool: usize, // TODO25 freePool: usize, // TODO
26 createEvent: extern fn (u32, usize, ?extern fn (Event, ?*const c_void) void, ?*const c_void, *Event) usize,26 createEvent: extern fn (u32, usize, ?extern fn (Event, ?*const c_void) void, ?*const c_void, *Event) usize,
27 setTimer: extern fn (Event, TimerDelay, u64) usize,27 setTimer: extern fn (Event, TimerDelay, u64) usize,
...@@ -42,7 +42,7 @@ pub const BootServices = extern struct {...@@ -42,7 +42,7 @@ pub const BootServices = extern struct {
42 imageStart: usize, // TODO42 imageStart: usize, // TODO
43 exit: extern fn (Handle, usize, usize, ?*const c_void) usize,43 exit: extern fn (Handle, usize, usize, ?*const c_void) usize,
44 imageUnload: usize, // TODO44 imageUnload: usize, // TODO
45 exitBootServices: usize, // TODO45 exitBootServices: extern fn (Handle, usize) usize,
46 getNextMonotonicCount: usize, // TODO46 getNextMonotonicCount: usize, // TODO
47 stall: extern fn (usize) usize,47 stall: extern fn (usize) usize,
48 setWatchdogTimer: extern fn (usize, u64, usize, ?[*]const u16) usize,48 setWatchdogTimer: extern fn (usize, u64, usize, ?[*]const u16) usize,
...@@ -82,25 +82,27 @@ pub const TimerDelay = extern enum(u32) {...@@ -82,25 +82,27 @@ pub const TimerDelay = extern enum(u32) {
82 TimerRelative,82 TimerRelative,
83};83};
8484
85pub const MemoryType = extern enum(u32) {
86 ReservedMemoryType,
87 LoaderCode,
88 LoaderData,
89 BootServicesCode,
90 BootServicesData,
91 RuntimeServicesCode,
92 RuntimeServicesData,
93 ConventionalMemory,
94 UnusableMemory,
95 ACPIReclaimMemory,
96 ACPIMemoryNVS,
97 MemoryMappedIO,
98 MemoryMappedIOPortSpace,
99 PalCode,
100 PersistentMemory,
101 MaxMemoryType,
102};
103
85pub const MemoryDescriptor = extern struct {104pub const MemoryDescriptor = extern struct {
86 type: extern enum(u32) {105 type: MemoryType,
87 ReservedMemoryType,
88 LoaderCode,
89 LoaderData,
90 BootServicesCode,
91 BootServicesData,
92 RuntimeServicesCode,
93 RuntimeServicesData,
94 ConventionalMemory,
95 UnusableMemory,
96 ACPIReclaimMemory,
97 ACPIMemoryNVS,
98 MemoryMappedIO,
99 MemoryMappedIOPortSpace,
100 PalCode,
101 PersistentMemory,
102 MaxMemoryType,
103 },
104 physical_start: u64,106 physical_start: u64,
105 virtual_start: u64,107 virtual_start: u64,
106 number_of_pages: usize,108 number_of_pages: usize,