From 47ce736abec2d97c70eed619b5a6a58edeb4816a Mon Sep 17 00:00:00 2001 From: Nick Erdmann Date: Sat, 10 Aug 2019 00:32:43 +0200 Subject: [PATCH] std/os/uefi: add basic Event support --- std/os/uefi.zig | 2 +- .../protocols/absolute_pointer_protocol.zig | 2 +- .../protocols/simple_pointer_protocol.zig | 2 +- .../simple_text_input_ex_protocol.zig | 2 +- std/os/uefi/tables.zig | 1 + std/os/uefi/tables/boot_services.zig | 25 ++++++++++++++++--- 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/std/os/uefi.zig b/std/os/uefi.zig index 9ddaad5aa6cb7491f71cf934ccb2e1b79c700008..db46d50c1ffa909fa19932546e4bae9c0eb85dcd 100644 --- a/std/os/uefi.zig +++ b/std/os/uefi.zig @@ -8,7 +8,7 @@ pub const is_the_target = builtin.os == .uefi; pub var handle: Handle = undefined; pub var system_table: *tables.SystemTable = undefined; -pub const Event = @OpaqueType(); +pub const Event = *@OpaqueType(); // GUIDs must be align(8) pub const Guid = extern struct { time_low: u32, diff --git a/std/os/uefi/protocols/absolute_pointer_protocol.zig b/std/os/uefi/protocols/absolute_pointer_protocol.zig index b1fcc4902e0c21fb63b26578d198d35a0e53e3fb..8be52ad7e473ffcd0c96aa80cb1ce50d87e2d960 100644 --- a/std/os/uefi/protocols/absolute_pointer_protocol.zig +++ b/std/os/uefi/protocols/absolute_pointer_protocol.zig @@ -6,7 +6,7 @@ const Guid = uefi.Guid; pub const AbsolutePointerProtocol = extern struct { _reset: extern fn (*const AbsolutePointerProtocol, bool) usize, _get_state: extern fn (*const AbsolutePointerProtocol, *AbsolutePointerState) usize, - wait_for_input: *Event, + wait_for_input: Event, mode: *AbsolutePointerMode, pub fn reset(self: *const AbsolutePointerProtocol, verify: bool) usize { diff --git a/std/os/uefi/protocols/simple_pointer_protocol.zig b/std/os/uefi/protocols/simple_pointer_protocol.zig index 26d11ca7f54d06401e5dbe3a8b056630bac95ad2..369bc76aaa0e7a4687a6df53eece51e27b412d26 100644 --- a/std/os/uefi/protocols/simple_pointer_protocol.zig +++ b/std/os/uefi/protocols/simple_pointer_protocol.zig @@ -6,7 +6,7 @@ const Guid = uefi.Guid; pub const SimplePointerProtocol = struct { _reset: extern fn (*const SimplePointerProtocol, bool) usize, _get_state: extern fn (*const SimplePointerProtocol, *SimplePointerState) usize, - wait_for_input: *Event, + wait_for_input: Event, mode: *SimplePointerMode, pub fn reset(self: *const SimplePointerProtocol, verify: bool) usize { diff --git a/std/os/uefi/protocols/simple_text_input_ex_protocol.zig b/std/os/uefi/protocols/simple_text_input_ex_protocol.zig index 16f676fd2d0f7c2b83b916d26bf4edf4f6715701..e23a68bacfbb3ab0fa44b6c4d5cfebbb45b4492c 100644 --- a/std/os/uefi/protocols/simple_text_input_ex_protocol.zig +++ b/std/os/uefi/protocols/simple_text_input_ex_protocol.zig @@ -6,7 +6,7 @@ const Guid = uefi.Guid; pub const SimpleTextInputExProtocol = extern struct { _reset: extern fn (*const SimpleTextInputExProtocol, bool) usize, _read_key_stroke_ex: extern fn (*const SimpleTextInputExProtocol, *KeyData) usize, - wait_for_key_ex: *Event, + wait_for_key_ex: Event, _set_state: extern fn (*const SimpleTextInputExProtocol, *const u8) usize, _register_key_notify: extern fn (*const SimpleTextInputExProtocol, *const KeyData, extern fn (*const KeyData) usize, **c_void) usize, _unregister_key_notify: extern fn (*const SimpleTextInputExProtocol, *const c_void) usize, diff --git a/std/os/uefi/tables.zig b/std/os/uefi/tables.zig index e5867ae657fd4f012ff810aa448e1417579366c2..51caed19d175c832962c095c9d1b78a6c91522a0 100644 --- a/std/os/uefi/tables.zig +++ b/std/os/uefi/tables.zig @@ -4,3 +4,4 @@ pub const ResetType = @import("tables/runtime_services.zig").ResetType; pub const RuntimeServices = @import("tables/runtime_services.zig").RuntimeServices; pub const SystemTable = @import("tables/system_table.zig").SystemTable; pub const TableHeader = @import("tables/table_header.zig").TableHeader; +pub const TimerDelay = @import("tables/boot_services.zig").TimerDelay; diff --git a/std/os/uefi/tables/boot_services.zig b/std/os/uefi/tables/boot_services.zig index 813677910be704754cceb0947556bb4b1181d02d..6007552bdda098bdf5abce034e70b36b4ab47263 100644 --- a/std/os/uefi/tables/boot_services.zig +++ b/std/os/uefi/tables/boot_services.zig @@ -1,4 +1,5 @@ const uefi = @import("std").os.uefi; +const Event = uefi.Event; const Guid = uefi.Guid; const Handle = uefi.Handle; const TableHeader = uefi.tables.TableHeader; @@ -22,10 +23,10 @@ pub const BootServices = extern struct { getMemoryMap: usize, // TODO allocatePool: usize, // TODO freePool: usize, // TODO - createEvent: usize, // TODO - setTimer: usize, // TODO + createEvent: extern fn (u32, usize, ?extern fn (Event, ?*const c_void) void, ?*const c_void, *Event) usize, + setTimer: extern fn (Event, TimerDelay, u64) usize, waitForEvent: usize, // TODO - signalEvent: usize, // TODO + signalEvent: extern fn (Event) usize, closeEvent: usize, // TODO checkEvent: usize, // TODO installProtocolInterface: usize, // TODO @@ -61,4 +62,22 @@ pub const BootServices = extern struct { createEventEx: usize, // TODO pub const signature: u64 = 0x56524553544f4f42; + + pub const event_timer: u32 = 0x80000000; + pub const event_runtime: u32 = 0x40000000; + pub const event_notify_wait: u32 = 0x00000100; + pub const event_notify_signal: u32 = 0x00000200; + pub const event_signal_exit_boot_services: u32 = 0x00000201; + pub const event_signal_virtual_address_change: u32 = 0x00000202; + + pub const tpl_application: usize = 4; + pub const tpl_callback: usize = 8; + pub const tpl_notify: usize = 16; + pub const tpl_high_level: usize = 31; +}; + +pub const TimerDelay = extern enum(u32) { + TimerCancel, + TimerPeriodic, + TimerRelative, }; -- 2.54.0