authorgravatar for n@nirf.deNick Erdmann <n@nirf.de> 2019-08-10 00:32:43+02:00
committergravatar for n@nirf.deNick Erdmann <n@nirf.de> 2019-08-10 19:14:47+02:00
log47ce736abec2d97c70eed619b5a6a58edeb4816a
tree4cc918bfe2412ca8cea57bc32b026a2ba5ce5bed
parent9445b3f057bdeb57cdb02c86b94145ae9a345531
signaturelock-open Commit is signed but in an unrecognized format.

std/os/uefi: add basic Event support


6 files changed, 27 insertions(+), 7 deletions(-)

std/os/uefi.zig+1-1
...@@ -8,7 +8,7 @@ pub const is_the_target = builtin.os == .uefi;...@@ -8,7 +8,7 @@ pub const is_the_target = builtin.os == .uefi;
8pub var handle: Handle = undefined;8pub var handle: Handle = undefined;
9pub var system_table: *tables.SystemTable = undefined;9pub var system_table: *tables.SystemTable = undefined;
1010
11pub const Event = @OpaqueType();11pub const Event = *@OpaqueType();
12// GUIDs must be align(8)12// GUIDs must be align(8)
13pub const Guid = extern struct {13pub const Guid = extern struct {
14 time_low: u32,14 time_low: u32,
std/os/uefi/protocols/absolute_pointer_protocol.zig+1-1
...@@ -6,7 +6,7 @@ const Guid = uefi.Guid;...@@ -6,7 +6,7 @@ const Guid = uefi.Guid;
6pub const AbsolutePointerProtocol = extern struct {6pub const AbsolutePointerProtocol = extern struct {
7 _reset: extern fn (*const AbsolutePointerProtocol, bool) usize,7 _reset: extern fn (*const AbsolutePointerProtocol, bool) usize,
8 _get_state: extern fn (*const AbsolutePointerProtocol, *AbsolutePointerState) usize,8 _get_state: extern fn (*const AbsolutePointerProtocol, *AbsolutePointerState) usize,
9 wait_for_input: *Event,9 wait_for_input: Event,
10 mode: *AbsolutePointerMode,10 mode: *AbsolutePointerMode,
1111
12 pub fn reset(self: *const AbsolutePointerProtocol, verify: bool) usize {12 pub fn reset(self: *const AbsolutePointerProtocol, verify: bool) usize {
std/os/uefi/protocols/simple_pointer_protocol.zig+1-1
...@@ -6,7 +6,7 @@ const Guid = uefi.Guid;...@@ -6,7 +6,7 @@ const Guid = uefi.Guid;
6pub const SimplePointerProtocol = struct {6pub const SimplePointerProtocol = struct {
7 _reset: extern fn (*const SimplePointerProtocol, bool) usize,7 _reset: extern fn (*const SimplePointerProtocol, bool) usize,
8 _get_state: extern fn (*const SimplePointerProtocol, *SimplePointerState) usize,8 _get_state: extern fn (*const SimplePointerProtocol, *SimplePointerState) usize,
9 wait_for_input: *Event,9 wait_for_input: Event,
10 mode: *SimplePointerMode,10 mode: *SimplePointerMode,
1111
12 pub fn reset(self: *const SimplePointerProtocol, verify: bool) usize {12 pub fn reset(self: *const SimplePointerProtocol, verify: bool) usize {
std/os/uefi/protocols/simple_text_input_ex_protocol.zig+1-1
...@@ -6,7 +6,7 @@ const Guid = uefi.Guid;...@@ -6,7 +6,7 @@ const Guid = uefi.Guid;
6pub const SimpleTextInputExProtocol = extern struct {6pub const SimpleTextInputExProtocol = extern struct {
7 _reset: extern fn (*const SimpleTextInputExProtocol, bool) usize,7 _reset: extern fn (*const SimpleTextInputExProtocol, bool) usize,
8 _read_key_stroke_ex: extern fn (*const SimpleTextInputExProtocol, *KeyData) usize,8 _read_key_stroke_ex: extern fn (*const SimpleTextInputExProtocol, *KeyData) usize,
9 wait_for_key_ex: *Event,9 wait_for_key_ex: Event,
10 _set_state: extern fn (*const SimpleTextInputExProtocol, *const u8) usize,10 _set_state: extern fn (*const SimpleTextInputExProtocol, *const u8) usize,
11 _register_key_notify: extern fn (*const SimpleTextInputExProtocol, *const KeyData, extern fn (*const KeyData) usize, **c_void) usize,11 _register_key_notify: extern fn (*const SimpleTextInputExProtocol, *const KeyData, extern fn (*const KeyData) usize, **c_void) usize,
12 _unregister_key_notify: extern fn (*const SimpleTextInputExProtocol, *const c_void) usize,12 _unregister_key_notify: extern fn (*const SimpleTextInputExProtocol, *const c_void) usize,
std/os/uefi/tables.zig+1
...@@ -4,3 +4,4 @@ pub const ResetType = @import("tables/runtime_services.zig").ResetType;...@@ -4,3 +4,4 @@ pub const ResetType = @import("tables/runtime_services.zig").ResetType;
4pub const RuntimeServices = @import("tables/runtime_services.zig").RuntimeServices;4pub const RuntimeServices = @import("tables/runtime_services.zig").RuntimeServices;
5pub const SystemTable = @import("tables/system_table.zig").SystemTable;5pub const SystemTable = @import("tables/system_table.zig").SystemTable;
6pub const TableHeader = @import("tables/table_header.zig").TableHeader;6pub const TableHeader = @import("tables/table_header.zig").TableHeader;
7pub const TimerDelay = @import("tables/boot_services.zig").TimerDelay;
std/os/uefi/tables/boot_services.zig+22-3
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1const uefi = @import("std").os.uefi;1const uefi = @import("std").os.uefi;
2const Event = uefi.Event;
2const Guid = uefi.Guid;3const Guid = uefi.Guid;
3const Handle = uefi.Handle;4const Handle = uefi.Handle;
4const TableHeader = uefi.tables.TableHeader;5const TableHeader = uefi.tables.TableHeader;
...@@ -22,10 +23,10 @@ pub const BootServices = extern struct {...@@ -22,10 +23,10 @@ pub const BootServices = extern struct {
22 getMemoryMap: usize, // TODO23 getMemoryMap: usize, // TODO
23 allocatePool: usize, // TODO24 allocatePool: usize, // TODO
24 freePool: usize, // TODO25 freePool: usize, // TODO
25 createEvent: usize, // TODO26 createEvent: extern fn (u32, usize, ?extern fn (Event, ?*const c_void) void, ?*const c_void, *Event) usize,
26 setTimer: usize, // TODO27 setTimer: extern fn (Event, TimerDelay, u64) usize,
27 waitForEvent: usize, // TODO28 waitForEvent: usize, // TODO
28 signalEvent: usize, // TODO29 signalEvent: extern fn (Event) usize,
29 closeEvent: usize, // TODO30 closeEvent: usize, // TODO
30 checkEvent: usize, // TODO31 checkEvent: usize, // TODO
31 installProtocolInterface: usize, // TODO32 installProtocolInterface: usize, // TODO
...@@ -61,4 +62,22 @@ pub const BootServices = extern struct {...@@ -61,4 +62,22 @@ pub const BootServices = extern struct {
61 createEventEx: usize, // TODO62 createEventEx: usize, // TODO
6263
63 pub const signature: u64 = 0x56524553544f4f42;64 pub const signature: u64 = 0x56524553544f4f42;
65
66 pub const event_timer: u32 = 0x80000000;
67 pub const event_runtime: u32 = 0x40000000;
68 pub const event_notify_wait: u32 = 0x00000100;
69 pub const event_notify_signal: u32 = 0x00000200;
70 pub const event_signal_exit_boot_services: u32 = 0x00000201;
71 pub const event_signal_virtual_address_change: u32 = 0x00000202;
72
73 pub const tpl_application: usize = 4;
74 pub const tpl_callback: usize = 8;
75 pub const tpl_notify: usize = 16;
76 pub const tpl_high_level: usize = 31;
77};
78
79pub const TimerDelay = extern enum(u32) {
80 TimerCancel,
81 TimerPeriodic,
82 TimerRelative,
64};83};