| author | |
| committer | |
| log | f4767186dd34118a27c205fe481b42c33e7ba0d3 |
| tree | 190cb224846f06894b05da1620487b43172145e2 |
| parent | 6fdeaac338f3a4a1f3455653ce29bf6ce4bbe335 |
| signature |
5 files changed, 98 insertions(+), 4 deletions(-)
lib/std/os/uefi/protocols.zig+4| ... | ... | @@ -1,3 +1,7 @@ |
| 1 | pub const LoadedImageProtocol = @import("protocols/loaded_image_protocol.zig").LoadedImageProtocol; | |
| 2 | ||
| 3 | pub const DevicePathProtocol = @import("protocols/device_path_protocol.zig").DevicePathProtocol; | |
| 4 | ||
| 1 | 5 | pub const InputKey = @import("protocols/simple_text_input_ex_protocol.zig").InputKey; |
| 2 | 6 | pub const KeyData = @import("protocols/simple_text_input_ex_protocol.zig").KeyData; |
| 3 | 7 | pub const KeyState = @import("protocols/simple_text_input_ex_protocol.zig").KeyState; |
lib/std/os/uefi/protocols/device_path_protocol.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | const uefi = @import("std").os.uefi; | |
| 2 | const Guid = uefi.Guid; | |
| 3 | ||
| 4 | pub const DevicePathProtocol = extern struct { | |
| 5 | type: u8, | |
| 6 | subtype: u8, | |
| 7 | length: u16, | |
| 8 | ||
| 9 | pub const guid align(8) = Guid{ | |
| 10 | .time_low = 0x09576e91, | |
| 11 | .time_mid = 0x6d3f, | |
| 12 | .time_high_and_version = 0x11d2, | |
| 13 | .clock_seq_high_and_reserved = 0x8e, | |
| 14 | .clock_seq_low = 0x39, | |
| 15 | .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b }, | |
| 16 | }; | |
| 17 | }; |
lib/std/os/uefi/protocols/loaded_image_protocol.zig created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | const uefi = @import("std").os.uefi; | |
| 2 | const Guid = uefi.Guid; | |
| 3 | const Handle = uefi.Handle; | |
| 4 | const SystemTable = uefi.tables.SystemTable; | |
| 5 | const MemoryType = uefi.tables.MemoryType; | |
| 6 | const DevicePathProtocol = uefi.protocols.DevicePathProtocol; | |
| 7 | ||
| 8 | pub const LoadedImageProtocol = extern struct { | |
| 9 | revision: u32, | |
| 10 | parent_handle: Handle, | |
| 11 | system_table: *SystemTable, | |
| 12 | device_handle: ?Handle, | |
| 13 | file_path: *DevicePathProtocol, | |
| 14 | reserved: *c_void, | |
| 15 | load_options_size: u32, | |
| 16 | load_options: *c_void, | |
| 17 | image_base: [*]u8, | |
| 18 | image_size: u64, | |
| 19 | image_code_type: MemoryType, | |
| 20 | image_data_type: MemoryType, | |
| 21 | _unload: extern fn (*const LoadedImageProtocol, Handle) usize, | |
| 22 | ||
| 23 | /// Unloads an image from memory. | |
| 24 | pub fn unload(self: *const LoadedImageProtocol, handle: Handle) usize { | |
| 25 | return self._unload(self, handle); | |
| 26 | } | |
| 27 | ||
| 28 | pub const guid align(8) = Guid{ | |
| 29 | .time_low = 0x5b1b31a1, | |
| 30 | .time_mid = 0x9562, | |
| 31 | .time_high_and_version = 0x11d2, | |
| 32 | .clock_seq_high_and_reserved = 0x8e, | |
| 33 | .clock_seq_low = 0x3f, | |
| 34 | .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b }, | |
| 35 | }; | |
| 36 | }; |
lib/std/os/uefi/tables/boot_services.zig+33-4| ... | ... | @@ -3,6 +3,7 @@ const Event = uefi.Event; |
| 3 | 3 | const Guid = uefi.Guid; |
| 4 | 4 | const Handle = uefi.Handle; |
| 5 | 5 | const TableHeader = uefi.tables.TableHeader; |
| 6 | const DevicePathProtocol = uefi.protocols.DevicePathProtocol; | |
| 6 | 7 | |
| 7 | 8 | /// Boot services are services provided by the system's firmware until the operating system takes |
| 8 | 9 | /// over control over the hardware by calling exitBootServices. |
| ... | ... | @@ -17,47 +18,73 @@ const TableHeader = uefi.tables.TableHeader; |
| 17 | 18 | /// As the boot_services table may grow with new UEFI versions, it is important to check hdr.header_size. |
| 18 | 19 | pub const BootServices = extern struct { |
| 19 | 20 | hdr: TableHeader, |
| 21 | ||
| 20 | 22 | raiseTpl: usize, // TODO |
| 21 | 23 | restoreTpl: usize, // TODO |
| 22 | 24 | allocatePages: usize, // TODO |
| 23 | 25 | freePages: usize, // TODO |
| 26 | ||
| 24 | 27 | /// Returns the current memory map. |
| 25 | 28 | getMemoryMap: extern fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) usize, |
| 29 | ||
| 26 | 30 | /// Allocates pool memory. |
| 27 | 31 | allocatePool: extern fn (MemoryType, usize, *align(8) [*]u8) usize, |
| 32 | ||
| 28 | 33 | freePool: usize, // TODO |
| 34 | ||
| 29 | 35 | /// Creates an event. |
| 30 | 36 | createEvent: extern fn (u32, usize, ?extern fn (Event, ?*const c_void) void, ?*const c_void, *Event) usize, |
| 37 | ||
| 31 | 38 | /// Sets the type of timer and the trigger time for a timer event. |
| 32 | 39 | setTimer: extern fn (Event, TimerDelay, u64) usize, |
| 40 | ||
| 33 | 41 | /// Stops execution until an event is signaled. |
| 34 | 42 | waitForEvent: extern fn (usize, [*]const Event, *usize) usize, |
| 43 | ||
| 35 | 44 | /// Signals an event. |
| 36 | 45 | signalEvent: extern fn (Event) usize, |
| 46 | ||
| 37 | 47 | /// Closes an event. |
| 38 | 48 | closeEvent: extern fn (Event) usize, |
| 49 | ||
| 39 | 50 | checkEvent: usize, // TODO |
| 40 | 51 | installProtocolInterface: usize, // TODO |
| 41 | 52 | reinstallProtocolInterface: usize, // TODO |
| 42 | 53 | uninstallProtocolInterface: usize, // TODO |
| 43 | handleProtocol: usize, // TODO | |
| 54 | ||
| 55 | /// Queries a handle to determine if it supports a specified protocol. | |
| 56 | handleProtocol: extern fn (Handle, *align(8) const Guid, *?*c_void) usize, | |
| 57 | ||
| 44 | 58 | reserved: *c_void, |
| 59 | ||
| 45 | 60 | registerProtocolNotify: usize, // TODO |
| 46 | 61 | locateHandle: usize, // TODO |
| 47 | 62 | locateDevicePath: usize, // TODO |
| 48 | 63 | installConfigurationTable: usize, // TODO |
| 49 | imageLoad: usize, // TODO | |
| 50 | imageStart: usize, // TODO | |
| 64 | ||
| 65 | /// Loads an EFI image into memory. | |
| 66 | loadImage: extern fn (bool, Handle, ?*const DevicePathProtocol, ?[*]const u8, usize, *?Handle) usize, | |
| 67 | ||
| 68 | /// Transfers control to a loaded image's entry point. | |
| 69 | startImage: extern fn (Handle, ?*usize, ?*[*]u16) usize, | |
| 70 | ||
| 51 | 71 | /// Terminates a loaded EFI image and returns control to boot services. |
| 52 | 72 | exit: extern fn (Handle, usize, usize, ?*const c_void) usize, |
| 53 | imageUnload: usize, // TODO | |
| 73 | ||
| 74 | /// Unloads an image. | |
| 75 | unloadImage: extern fn (Handle) usize, | |
| 76 | ||
| 54 | 77 | /// Terminates all boot services. |
| 55 | 78 | exitBootServices: extern fn (Handle, usize) usize, |
| 79 | ||
| 56 | 80 | getNextMonotonicCount: usize, // TODO |
| 81 | ||
| 57 | 82 | /// Induces a fine-grained stall. |
| 58 | 83 | stall: extern fn (usize) usize, |
| 84 | ||
| 59 | 85 | /// Sets the system's watchdog timer. |
| 60 | 86 | setWatchdogTimer: extern fn (usize, u64, usize, ?[*]const u16) usize, |
| 87 | ||
| 61 | 88 | connectController: usize, // TODO |
| 62 | 89 | disconnectController: usize, // TODO |
| 63 | 90 | openProtocol: usize, // TODO |
| ... | ... | @@ -65,8 +92,10 @@ pub const BootServices = extern struct { |
| 65 | 92 | openProtocolInformation: usize, // TODO |
| 66 | 93 | protocolsPerHandle: usize, // TODO |
| 67 | 94 | locateHandleBuffer: usize, // TODO |
| 95 | ||
| 68 | 96 | /// Returns the first protocol instance that matches the given protocol. |
| 69 | 97 | locateProtocol: extern fn (*align(8) const Guid, ?*const c_void, *?*c_void) usize, |
| 98 | ||
| 70 | 99 | installMultipleProtocolInterfaces: usize, // TODO |
| 71 | 100 | uninstallMultipleProtocolInterfaces: usize, // TODO |
| 72 | 101 | calculateCrc32: usize, // TODO |
lib/std/os/uefi/tables/runtime_services.zig+8| ... | ... | @@ -14,22 +14,30 @@ const TimeCapabilities = uefi.TimeCapabilities; |
| 14 | 14 | /// Some functions may not be called while other functions are running. |
| 15 | 15 | pub const RuntimeServices = extern struct { |
| 16 | 16 | hdr: TableHeader, |
| 17 | ||
| 17 | 18 | /// Returns the current time and date information, and the time-keeping capabilities of the hardware platform. |
| 18 | 19 | getTime: extern fn (*uefi.Time, ?*TimeCapabilities) usize, |
| 20 | ||
| 19 | 21 | setTime: usize, // TODO |
| 20 | 22 | getWakeupTime: usize, // TODO |
| 21 | 23 | setWakeupTime: usize, // TODO |
| 22 | 24 | setVirtualAddressMap: usize, // TODO |
| 23 | 25 | convertPointer: usize, // TODO |
| 26 | ||
| 24 | 27 | /// Returns the value of a variable. |
| 25 | 28 | getVariable: extern fn ([*]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) usize, |
| 29 | ||
| 26 | 30 | /// Enumerates the current variable names. |
| 27 | 31 | getNextVariableName: extern fn (*usize, [*]u16, *align(8) Guid) usize, |
| 32 | ||
| 28 | 33 | /// Sets the value of a variable. |
| 29 | 34 | setVariable: extern fn ([*]const u16, *align(8) const Guid, u32, usize, *c_void) usize, |
| 35 | ||
| 30 | 36 | getNextHighMonotonicCount: usize, // TODO |
| 37 | ||
| 31 | 38 | /// Resets the entire platform. |
| 32 | 39 | resetSystem: extern fn (ResetType, usize, usize, ?*const c_void) noreturn, |
| 40 | ||
| 33 | 41 | updateCapsule: usize, // TODO |
| 34 | 42 | queryCapsuleCapabilities: usize, // TODO |
| 35 | 43 | queryVariableInfo: usize, // TODO |