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 @@...@@ -1,8 +1,11 @@
1pub const BootServices = @import("tables/boot_services.zig").BootServices;1pub 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 LocateSearchType = @import("tables/boot_services.zig").LocateSearchType;
4pub const MemoryDescriptor = @import("tables/boot_services.zig").MemoryDescriptor;5pub const MemoryDescriptor = @import("tables/boot_services.zig").MemoryDescriptor;
5pub const MemoryType = @import("tables/boot_services.zig").MemoryType;6pub 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;
6pub const ResetType = @import("tables/runtime_services.zig").ResetType;9pub const ResetType = @import("tables/runtime_services.zig").ResetType;
7pub const RuntimeServices = @import("tables/runtime_services.zig").RuntimeServices;10pub const RuntimeServices = @import("tables/runtime_services.zig").RuntimeServices;
8pub const SystemTable = @import("tables/system_table.zig").SystemTable;11pub 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 {...@@ -30,10 +30,11 @@ pub const BootServices = extern struct {
30 /// Allocates pool memory.30 /// Allocates pool memory.
31 allocatePool: extern fn (MemoryType, usize, *align(8) [*]u8) usize,31 allocatePool: extern fn (MemoryType, usize, *align(8) [*]u8) usize,
3232
33 freePool: usize, // TODO33 /// Returns pool memory to the system.
34 freePool: extern fn ([*]align(8) u8) usize,
3435
35 /// Creates an event.36 /// 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
38 /// Sets the type of timer and the trigger time for a timer event.39 /// Sets the type of timer and the trigger time for a timer event.
39 setTimer: extern fn (Event, TimerDelay, u64) usize,40 setTimer: extern fn (Event, TimerDelay, u64) usize,
...@@ -47,7 +48,9 @@ pub const BootServices = extern struct {...@@ -47,7 +48,9 @@ pub const BootServices = extern struct {
47 /// Closes an event.48 /// Closes an event.
48 closeEvent: extern fn (Event) usize,49 closeEvent: extern fn (Event) usize,
4950
50 checkEvent: usize, // TODO51 /// Checks whether an event is in the signaled state.
52 checkEvent: extern fn (Event) usize,
53
51 installProtocolInterface: usize, // TODO54 installProtocolInterface: usize, // TODO
52 reinstallProtocolInterface: usize, // TODO55 reinstallProtocolInterface: usize, // TODO
53 uninstallProtocolInterface: usize, // TODO56 uninstallProtocolInterface: usize, // TODO
...@@ -87,11 +90,20 @@ pub const BootServices = extern struct {...@@ -87,11 +90,20 @@ pub const BootServices = extern struct {
8790
88 connectController: usize, // TODO91 connectController: usize, // TODO
89 disconnectController: usize, // TODO92 disconnectController: usize, // TODO
90 openProtocol: usize, // TODO93
91 closeProtocol: usize, // TODO94 /// Queries a handle to determine if it supports a specified protocol.
92 openProtocolInformation: usize, // TODO95 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
93 protocolsPerHandle: usize, // TODO103 protocolsPerHandle: usize, // TODO
94 locateHandleBuffer: usize, // TODO104
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
96 /// Returns the first protocol instance that matches the given protocol.108 /// Returns the first protocol instance that matches the given protocol.
97 locateProtocol: extern fn (*align(8) const Guid, ?*const c_void, *?*c_void) usize,109 locateProtocol: extern fn (*align(8) const Guid, ?*const c_void, *?*c_void) usize,
...@@ -167,3 +179,26 @@ pub const MemoryDescriptor = extern struct {...@@ -167,3 +179,26 @@ pub const MemoryDescriptor = extern struct {
167 memory_runtime: bool,179 memory_runtime: bool,
168 },180 },
169};181};
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;...@@ -17,6 +17,7 @@ const TableHeader = uefi.tables.TableHeader;
17/// hdr.crc32 must be recomputed.17/// hdr.crc32 must be recomputed.
18pub const SystemTable = extern struct {18pub const SystemTable = extern struct {
19 hdr: TableHeader,19 hdr: TableHeader,
20
20 /// A null-terminated string that identifies the vendor that produces the system firmware of the platform.21 /// A null-terminated string that identifies the vendor that produces the system firmware of the platform.
21 firmware_vendor: [*]u16,22 firmware_vendor: [*]u16,
22 firmware_revision: u32,23 firmware_revision: u32,