authorgravatar for n@nirf.deNick Erdmann <n@nirf.de> 2020-03-07 22:43:20+01:00
committergravatar for n@nirf.deNick Erdmann <n@nirf.de> 2020-03-12 23:22:08+01:00
log7c12f93734b17408e8a334b8a6df284966809804
tree85751bfcfec4007189d2e495dc39c694e65d95c0
parentaa49f972d655eb61ca899f76ba37933254f780a2

std/os/uefi: boot services and runtime services improvements

- Several function signatures added - Add getNextVariableName sentinel termination annotation

3 files changed, 45 insertions(+), 19 deletions(-)

lib/std/os/uefi/tables.zig+1
......@@ -1,3 +1,4 @@
1pub const AllocateType = @import("tables/boot_services.zig").AllocateType;
12pub const BootServices = @import("tables/boot_services.zig").BootServices;
23pub const ConfigurationTable = @import("tables/configuration_table.zig").ConfigurationTable;
34pub const global_variable align(8) = @import("tables/runtime_services.zig").global_variable;
lib/std/os/uefi/tables/boot_services.zig+43-18
......@@ -19,16 +19,23 @@ const DevicePathProtocol = uefi.protocols.DevicePathProtocol;
1919pub const BootServices = extern struct {
2020 hdr: TableHeader,
2121
22 raiseTpl: usize, // TODO
23 restoreTpl: usize, // TODO
24 allocatePages: usize, // TODO
25 freePages: usize, // TODO
22 /// Raises a task's priority level and returns its previous level.
23 raiseTpl: extern fn (usize) usize,
24
25 /// Restores a task's priority level to its previous value.
26 restoreTpl: extern fn (usize) void,
27
28 /// Allocates memory pages from the system.
29 allocatePages: extern fn (AllocateType, MemoryType, usize, *[*]align(4096) u8) usize,
30
31 /// Frees memory pages.
32 freePages: extern fn ([*]align(4096) u8, usize) usize,
2633
2734 /// Returns the current memory map.
2835 getMemoryMap: extern fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) usize,
2936
3037 /// Allocates pool memory.
31 allocatePool: extern fn (MemoryType, usize, *align(8) [*]u8) usize,
38 allocatePool: extern fn (MemoryType, usize, *[*]align(8) u8) usize,
3239
3340 /// Returns pool memory to the system.
3441 freePool: extern fn ([*]align(8) u8) usize,
......@@ -61,7 +68,10 @@ pub const BootServices = extern struct {
6168 reserved: *c_void,
6269
6370 registerProtocolNotify: usize, // TODO
64 locateHandle: usize, // TODO
71
72 /// Returns an array of handles that support a specified protocol.
73 locateHandle: extern fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, [*]Handle) usize,
74
6575 locateDevicePath: usize, // TODO
6676 installConfigurationTable: usize, // TODO
6777
......@@ -80,7 +90,8 @@ pub const BootServices = extern struct {
8090 /// Terminates all boot services.
8191 exitBootServices: extern fn (Handle, usize) usize,
8292
83 getNextMonotonicCount: usize, // TODO
93 /// Returns a monotonically increasing count for the platform.
94 getNextMonotonicCount: extern fn (*u64) usize,
8495
8596 /// Induces a fine-grained stall.
8697 stall: extern fn (usize) usize,
......@@ -100,7 +111,8 @@ pub const BootServices = extern struct {
100111 /// Retrieves the list of agents that currently have a protocol interface opened.
101112 openProtocolInformation: extern fn (Handle, *align(8) const Guid, *[*]ProtocolInformationEntry, *usize) usize,
102113
103 protocolsPerHandle: usize, // TODO
114 /// Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated from pool.
115 protocolsPerHandle: extern fn (Handle, *[*]*align(8) const Guid, *usize) usize,
104116
105117 /// Returns an array of handles that support the requested protocol in a buffer allocated from pool.
106118 locateHandleBuffer: extern fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, *[*]Handle) usize,
......@@ -110,9 +122,16 @@ pub const BootServices = extern struct {
110122
111123 installMultipleProtocolInterfaces: usize, // TODO
112124 uninstallMultipleProtocolInterfaces: usize, // TODO
113 calculateCrc32: usize, // TODO
114 copyMem: usize, // TODO
115 setMem: usize, // TODO
125
126 /// Computes and returns a 32-bit CRC for a data buffer.
127 calculateCrc32: extern fn ([*]const u8, usize, *u32) usize,
128
129 /// Copies the contents of one buffer to another buffer
130 copyMem: extern fn ([*]u8, [*]const u8, usize) void,
131
132 /// Fills a buffer with a specified value
133 setMem: extern fn ([*]u8, usize, u8) void,
134
116135 createEventEx: usize, // TODO
117136
118137 pub const signature: u64 = 0x56524553544f4f42;
......@@ -187,13 +206,13 @@ pub const LocateSearchType = extern enum(u32) {
187206};
188207
189208pub 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,
209 by_handle_protocol: bool = false,
210 get_protocol: bool = false,
211 test_protocol: bool = false,
212 by_child_controller: bool = false,
213 by_driver: bool = false,
214 exclusive: bool = false,
215 _pad: u26 = undefined,
197216};
198217
199218pub const ProtocolInformationEntry = extern struct {
......@@ -202,3 +221,9 @@ pub const ProtocolInformationEntry = extern struct {
202221 attributes: OpenProtocolAttributes,
203222 open_count: u32,
204223};
224
225pub const AllocateType = extern enum(u32) {
226 AllocateAnyPages,
227 AllocateMaxAddress,
228 AllocateAddress,
229};
lib/std/os/uefi/tables/runtime_services.zig+1-1
......@@ -28,7 +28,7 @@ pub const RuntimeServices = extern struct {
2828 getVariable: extern fn ([*:0]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) usize,
2929
3030 /// Enumerates the current variable names.
31 getNextVariableName: extern fn (*usize, [*]u16, *align(8) Guid) usize,
31 getNextVariableName: extern fn (*usize, [*:0]u16, *align(8) Guid) usize,
3232
3333 /// Sets the value of a variable.
3434 setVariable: extern fn ([*:0]const u16, *align(8) const Guid, u32, usize, *c_void) usize,