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 @@...@@ -1,3 +1,4 @@
1pub const AllocateType = @import("tables/boot_services.zig").AllocateType;
1pub const BootServices = @import("tables/boot_services.zig").BootServices;2pub const BootServices = @import("tables/boot_services.zig").BootServices;
2pub const ConfigurationTable = @import("tables/configuration_table.zig").ConfigurationTable;3pub const ConfigurationTable = @import("tables/configuration_table.zig").ConfigurationTable;
3pub const global_variable align(8) = @import("tables/runtime_services.zig").global_variable;4pub 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;...@@ -19,16 +19,23 @@ const DevicePathProtocol = uefi.protocols.DevicePathProtocol;
19pub const BootServices = extern struct {19pub const BootServices = extern struct {
20 hdr: TableHeader,20 hdr: TableHeader,
2121
22 raiseTpl: usize, // TODO22 /// Raises a task's priority level and returns its previous level.
23 restoreTpl: usize, // TODO23 raiseTpl: extern fn (usize) usize,
24 allocatePages: usize, // TODO24
25 freePages: usize, // TODO25 /// 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
27 /// Returns the current memory map.34 /// Returns the current memory map.
28 getMemoryMap: extern fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) usize,35 getMemoryMap: extern fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) usize,
2936
30 /// Allocates pool memory.37 /// Allocates pool memory.
31 allocatePool: extern fn (MemoryType, usize, *align(8) [*]u8) usize,38 allocatePool: extern fn (MemoryType, usize, *[*]align(8) u8) usize,
3239
33 /// Returns pool memory to the system.40 /// Returns pool memory to the system.
34 freePool: extern fn ([*]align(8) u8) usize,41 freePool: extern fn ([*]align(8) u8) usize,
...@@ -61,7 +68,10 @@ pub const BootServices = extern struct {...@@ -61,7 +68,10 @@ pub const BootServices = extern struct {
61 reserved: *c_void,68 reserved: *c_void,
6269
63 registerProtocolNotify: usize, // TODO70 registerProtocolNotify: usize, // TODO
64 locateHandle: usize, // TODO71
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
65 locateDevicePath: usize, // TODO75 locateDevicePath: usize, // TODO
66 installConfigurationTable: usize, // TODO76 installConfigurationTable: usize, // TODO
6777
...@@ -80,7 +90,8 @@ pub const BootServices = extern struct {...@@ -80,7 +90,8 @@ pub const BootServices = extern struct {
80 /// Terminates all boot services.90 /// Terminates all boot services.
81 exitBootServices: extern fn (Handle, usize) usize,91 exitBootServices: extern fn (Handle, usize) usize,
8292
83 getNextMonotonicCount: usize, // TODO93 /// Returns a monotonically increasing count for the platform.
94 getNextMonotonicCount: extern fn (*u64) usize,
8495
85 /// Induces a fine-grained stall.96 /// Induces a fine-grained stall.
86 stall: extern fn (usize) usize,97 stall: extern fn (usize) usize,
...@@ -100,7 +111,8 @@ pub const BootServices = extern struct {...@@ -100,7 +111,8 @@ pub const BootServices = extern struct {
100 /// Retrieves the list of agents that currently have a protocol interface opened.111 /// Retrieves the list of agents that currently have a protocol interface opened.
101 openProtocolInformation: extern fn (Handle, *align(8) const Guid, *[*]ProtocolInformationEntry, *usize) usize,112 openProtocolInformation: extern fn (Handle, *align(8) const Guid, *[*]ProtocolInformationEntry, *usize) usize,
102113
103 protocolsPerHandle: usize, // TODO114 /// 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
105 /// Returns an array of handles that support the requested protocol in a buffer allocated from pool.117 /// 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,118 locateHandleBuffer: extern fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, *[*]Handle) usize,
...@@ -110,9 +122,16 @@ pub const BootServices = extern struct {...@@ -110,9 +122,16 @@ pub const BootServices = extern struct {
110122
111 installMultipleProtocolInterfaces: usize, // TODO123 installMultipleProtocolInterfaces: usize, // TODO
112 uninstallMultipleProtocolInterfaces: usize, // TODO124 uninstallMultipleProtocolInterfaces: usize, // TODO
113 calculateCrc32: usize, // TODO125
114 copyMem: usize, // TODO126 /// Computes and returns a 32-bit CRC for a data buffer.
115 setMem: usize, // TODO127 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
116 createEventEx: usize, // TODO135 createEventEx: usize, // TODO
117136
118 pub const signature: u64 = 0x56524553544f4f42;137 pub const signature: u64 = 0x56524553544f4f42;
...@@ -187,13 +206,13 @@ pub const LocateSearchType = extern enum(u32) {...@@ -187,13 +206,13 @@ pub const LocateSearchType = extern enum(u32) {
187};206};
188207
189pub const OpenProtocolAttributes = packed struct {208pub const OpenProtocolAttributes = packed struct {
190 by_handle_protocol: bool,209 by_handle_protocol: bool = false,
191 get_protocol: bool,210 get_protocol: bool = false,
192 test_protocol: bool,211 test_protocol: bool = false,
193 by_child_controller: bool,212 by_child_controller: bool = false,
194 by_driver: bool,213 by_driver: bool = false,
195 exclusive: bool,214 exclusive: bool = false,
196 _pad: u26,215 _pad: u26 = undefined,
197};216};
198217
199pub const ProtocolInformationEntry = extern struct {218pub const ProtocolInformationEntry = extern struct {
...@@ -202,3 +221,9 @@ pub const ProtocolInformationEntry = extern struct {...@@ -202,3 +221,9 @@ pub const ProtocolInformationEntry = extern struct {
202 attributes: OpenProtocolAttributes,221 attributes: OpenProtocolAttributes,
203 open_count: u32,222 open_count: u32,
204};223};
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 {...@@ -28,7 +28,7 @@ pub const RuntimeServices = extern struct {
28 getVariable: extern fn ([*:0]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) usize,28 getVariable: extern fn ([*:0]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) usize,
2929
30 /// Enumerates the current variable names.30 /// 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
33 /// Sets the value of a variable.33 /// Sets the value of a variable.
34 setVariable: extern fn ([*:0]const u16, *align(8) const Guid, u32, usize, *c_void) usize,34 setVariable: extern fn ([*:0]const u16, *align(8) const Guid, u32, usize, *c_void) usize,