authorgravatar for n@nirf.deNick Erdmann <n@nirf.de> 2019-11-07 02:49:45+01:00
committergravatar for n@nirf.deNick Erdmann <n@nirf.de> 2019-11-07 03:06:06+01:00
log78b54d9c96c84e286b20a2a144eca0b9ddc3fba5
tree0b9f0402cfe9fa35c58efe6b29f646de4720bfab
parentcef51eaffb8fdb7257bc08a61f4fdc7eb7bac457
signaturelock-open Commit is signed but in an unrecognized format.

std/os/uefi: protocol handling improvements


3 files changed, 46 insertions(+), 7 deletions(-)

lib/std/os/uefi/tables.zig+3
......@@ -1,8 +1,11 @@
11pub const BootServices = @import("tables/boot_services.zig").BootServices;
22pub const ConfigurationTable = @import("tables/configuration_table.zig").ConfigurationTable;
33pub const global_variable align(8) = @import("tables/runtime_services.zig").global_variable;
4pub const LocateSearchType = @import("tables/boot_services.zig").LocateSearchType;
45pub const MemoryDescriptor = @import("tables/boot_services.zig").MemoryDescriptor;
56pub const MemoryType = @import("tables/boot_services.zig").MemoryType;
7pub const OpenProtocolAttributes = @import("tables/boot_services.zig").OpenProtocolAttributes;
8pub const ProtocolInformationEntry = @import("tables/boot_services.zig").ProtocolInformationEntry;
69pub const ResetType = @import("tables/runtime_services.zig").ResetType;
710pub const RuntimeServices = @import("tables/runtime_services.zig").RuntimeServices;
811pub const SystemTable = @import("tables/system_table.zig").SystemTable;
lib/std/os/uefi/tables/boot_services.zig+42-7
......@@ -30,10 +30,11 @@ pub const BootServices = extern struct {
3030 /// Allocates pool memory.
3131 allocatePool: extern fn (MemoryType, usize, *align(8) [*]u8) usize,
3232
33 freePool: usize, // TODO
33 /// Returns pool memory to the system.
34 freePool: extern fn ([*]align(8) u8) usize,
3435
3536 /// Creates an event.
36 createEvent: extern fn (u32, usize, ?extern fn (Event, ?*const c_void) void, ?*const c_void, *Event) usize,
37 createEvent: extern fn (u32, usize, ?extern fn (Event, ?*c_void) void, ?*const c_void, *Event) usize,
3738
3839 /// Sets the type of timer and the trigger time for a timer event.
3940 setTimer: extern fn (Event, TimerDelay, u64) usize,
......@@ -47,7 +48,9 @@ pub const BootServices = extern struct {
4748 /// Closes an event.
4849 closeEvent: extern fn (Event) usize,
4950
50 checkEvent: usize, // TODO
51 /// Checks whether an event is in the signaled state.
52 checkEvent: extern fn (Event) usize,
53
5154 installProtocolInterface: usize, // TODO
5255 reinstallProtocolInterface: usize, // TODO
5356 uninstallProtocolInterface: usize, // TODO
......@@ -87,11 +90,20 @@ pub const BootServices = extern struct {
8790
8891 connectController: usize, // TODO
8992 disconnectController: usize, // TODO
90 openProtocol: usize, // TODO
91 closeProtocol: usize, // TODO
92 openProtocolInformation: usize, // TODO
93
94 /// Queries a handle to determine if it supports a specified protocol.
95 openProtocol: extern fn (Handle, *align(8) const Guid, *?*c_void, ?Handle, ?Handle, OpenProtocolAttributes) usize,
96
97 /// Closes a protocol on a handle that was opened using openProtocol().
98 closeProtocol: extern fn (Handle, *align(8) const Guid, Handle, ?Handle) usize,
99
100 /// Retrieves the list of agents that currently have a protocol interface opened.
101 openProtocolInformation: extern fn (Handle, *align(8) const Guid, *[*]ProtocolInformationEntry, *usize) usize,
102
93103 protocolsPerHandle: usize, // TODO
94 locateHandleBuffer: usize, // TODO
104
105 /// Returns an array of handles that support the requested protocol in a buffer allocated from pool.
106 locateHandleBuffer: extern fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, *[*]Handle) usize,
95107
96108 /// Returns the first protocol instance that matches the given protocol.
97109 locateProtocol: extern fn (*align(8) const Guid, ?*const c_void, *?*c_void) usize,
......@@ -167,3 +179,26 @@ pub const MemoryDescriptor = extern struct {
167179 memory_runtime: bool,
168180 },
169181};
182
183pub const LocateSearchType = extern enum(u32) {
184 AllHandles,
185 ByRegisterNotify,
186 ByProtocol,
187};
188
189pub const OpenProtocolAttributes = packed struct {
190 by_handle_protocol: bool,
191 get_protocol: bool,
192 test_protocol: bool,
193 by_child_controller: bool,
194 by_driver: bool,
195 exclusive: bool,
196 _pad: u26,
197};
198
199pub const ProtocolInformationEntry = extern struct {
200 agent_handle: ?Handle,
201 controller_handle: ?Handle,
202 attributes: OpenProtocolAttributes,
203 open_count: u32,
204};
lib/std/os/uefi/tables/system_table.zig+1
......@@ -17,6 +17,7 @@ const TableHeader = uefi.tables.TableHeader;
1717/// hdr.crc32 must be recomputed.
1818pub const SystemTable = extern struct {
1919 hdr: TableHeader,
20
2021 /// A null-terminated string that identifies the vendor that produces the system firmware of the platform.
2122 firmware_vendor: [*]u16,
2223 firmware_revision: u32,