authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-16 18:14:32-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-10-16 18:14:32-04:00
log45e5841281e0adf7924f0931dff219bf38f74622
treea832edd59787dd3548681dcc0975775ef5275384
parent09abd09ab85189b15c3296407a5a8a803e93ebd0
parente6eae25053581032f7b26cb86fa6c8c84465e1c8
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #3464 from nrdmn/uefi

UEFI improvements

19 files changed, 164 insertions(+), 30 deletions(-)

lib/std/os/uefi.zig+46-1
......@@ -1,15 +1,23 @@
1/// A protocol is an interface identified by a GUID.
12pub const protocols = @import("uefi/protocols.zig");
3/// Status codes returned by EFI interfaces
24pub const status = @import("uefi/status.zig");
35pub const tables = @import("uefi/tables.zig");
46
7const fmt = @import("std").fmt;
8
59const builtin = @import("builtin");
610pub const is_the_target = builtin.os == .uefi;
711
12/// The EFI image's handle that is passed to its entry point.
813pub var handle: Handle = undefined;
14/// A pointer to the EFI System Table that is passed to the EFI image's entry point.
915pub var system_table: *tables.SystemTable = undefined;
1016
17/// A handle to an event structure.
1118pub const Event = *@OpaqueType();
12// GUIDs must be align(8)
19
20/// GUIDs must be align(8)
1321pub const Guid = extern struct {
1422 time_low: u32,
1523 time_mid: u16,
......@@ -17,29 +25,66 @@ pub const Guid = extern struct {
1725 clock_seq_high_and_reserved: u8,
1826 clock_seq_low: u8,
1927 node: [6]u8,
28
29 /// Format GUID into hexadecimal lowercase xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format
30 pub fn format(
31 self: @This(),
32 comptime f: []const u8,
33 options: fmt.FormatOptions,
34 context: var,
35 comptime Errors: type,
36 output: fn (@typeOf(context), []const u8) Errors!void,
37 ) Errors!void {
38 if (f.len == 0) {
39 return fmt.format(context, Errors, output, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", self.time_low, self.time_mid, self.time_high_and_version, self.clock_seq_high_and_reserved, self.clock_seq_low, self.node);
40 } else {
41 @compileError("Unknown format character: '" ++ f ++ "'");
42 }
43 }
2044};
45
46/// An EFI Handle represents a collection of related interfaces.
2147pub const Handle = *@OpaqueType();
48
49/// This structure represents time information.
2250pub const Time = extern struct {
51 /// 1900 - 9999
2352 year: u16,
53 /// 1 - 12
2454 month: u8,
55 /// 1 - 31
2556 day: u8,
57 /// 0 - 23
2658 hour: u8,
59 /// 0 - 59
2760 minute: u8,
61 /// 0 - 59
2862 second: u8,
2963 _pad1: u8,
64 /// 0 - 999999999
3065 nanosecond: u32,
66 /// The time's offset in minutes from UTC.
67 /// Allowed values are -1440 to 1440 or unspecified_timezone
3168 timezone: i16,
3269 daylight: packed struct {
3370 _pad1: u6,
71 /// If true, the time has been adjusted for daylight savings time.
3472 in_daylight: bool,
73 /// If true, the time is affected by daylight savings time.
3574 adjust_daylight: bool,
3675 },
3776 _pad2: u8,
3877
78 /// Time is to be interpreted as local time
3979 pub const unspecified_timezone: i16 = 0x7ff;
4080};
81
82/// Capabilities of the clock device
4183pub const TimeCapabilities = extern struct {
84 /// Resolution in Hz
4285 resolution: u32,
86 /// Accuracy in an error rate of 1e-6 parts per million.
4387 accuracy: u32,
88 /// If true, a time set operation clears the device's time below the resolution level.
4489 sets_to_zero: bool,
4590};
lib/std/os/uefi/protocols/absolute_pointer_protocol.zig+7-5
......@@ -2,17 +2,19 @@ const uefi = @import("std").os.uefi;
22const Event = uefi.Event;
33const Guid = uefi.Guid;
44
5/// UEFI Specification, Version 2.8, 12.7
5/// Protocol for touchscreens
66pub const AbsolutePointerProtocol = extern struct {
77 _reset: extern fn (*const AbsolutePointerProtocol, bool) usize,
88 _get_state: extern fn (*const AbsolutePointerProtocol, *AbsolutePointerState) usize,
99 wait_for_input: Event,
1010 mode: *AbsolutePointerMode,
1111
12 /// Resets the pointer device hardware.
1213 pub fn reset(self: *const AbsolutePointerProtocol, verify: bool) usize {
1314 return self._reset(self, verify);
1415 }
1516
17 /// Retrieves the current state of a pointer device.
1618 pub fn getState(self: *const AbsolutePointerProtocol, state: *AbsolutePointerState) usize {
1719 return self._get_state(self, state);
1820 }
......@@ -42,12 +44,12 @@ pub const AbsolutePointerMode = extern struct {
4244};
4345
4446pub const AbsolutePointerState = extern struct {
45 current_x: u64 = undefined,
46 current_y: u64 = undefined,
47 current_z: u64 = undefined,
47 current_x: u64,
48 current_y: u64,
49 current_z: u64,
4850 active_buttons: packed struct {
4951 touch_active: bool,
5052 alt_active: bool,
5153 _pad1: u30,
52 } = undefined,
54 },
5355};
lib/std/os/uefi/protocols/edid_active_protocol.zig+1-1
......@@ -1,7 +1,7 @@
11const uefi = @import("std").os.uefi;
22const Guid = uefi.Guid;
33
4/// UEFI Specification, Version 2.8, 12.9
4/// EDID information for an active video output device
55pub const EdidActiveProtocol = extern struct {
66 size_of_edid: u32,
77 edid: ?[*]u8,
lib/std/os/uefi/protocols/edid_discovered_protocol.zig+1-1
......@@ -1,7 +1,7 @@
11const uefi = @import("std").os.uefi;
22const Guid = uefi.Guid;
33
4/// UEFI Specification, Version 2.8, 12.9
4/// EDID information for a video output device
55pub const EdidDiscoveredProtocol = extern struct {
66 size_of_edid: u32,
77 edid: ?[*]u8,
lib/std/os/uefi/protocols/edid_override_protocol.zig+2-1
......@@ -2,10 +2,11 @@ const uefi = @import("std").os.uefi;
22const Guid = uefi.Guid;
33const Handle = uefi.Handle;
44
5/// UEFI Specification, Version 2.8, 12.9
5/// Override EDID information
66pub const EdidOverrideProtocol = extern struct {
77 _get_edid: extern fn (*const EdidOverrideProtocol, Handle, *u32, *usize, *?[*]u8) usize,
88
9 /// Returns policy information and potentially a replacement EDID for the specified video output device.
910 /// attributes must be align(4)
1011 pub fn getEdid(self: *const EdidOverrideProtocol, handle: Handle, attributes: *EdidOverrideProtocolAttributes, edid_size: *usize, edid: *?[*]u8) usize {
1112 return self._get_edid(self, handle, attributes, edid_size, edid);
lib/std/os/uefi/protocols/graphics_output_protocol.zig+4-1
......@@ -1,21 +1,24 @@
11const uefi = @import("std").os.uefi;
22const Guid = uefi.Guid;
33
4/// UEFI Specification, Version 2.8, 12.9
4/// Graphics output
55pub const GraphicsOutputProtocol = extern struct {
66 _query_mode: extern fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) usize,
77 _set_mode: extern fn (*const GraphicsOutputProtocol, u32) usize,
88 _blt: extern fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) usize,
99 mode: *GraphicsOutputProtocolMode,
1010
11 /// Returns information for an available graphics mode that the graphics device and the set of active video output devices supports.
1112 pub fn queryMode(self: *const GraphicsOutputProtocol, mode: u32, size_of_info: *usize, info: **GraphicsOutputModeInformation) usize {
1213 return self._query_mode(self, mode, size_of_info, info);
1314 }
1415
16 /// Set the video device into the specified mode and clears the visible portions of the output display to black.
1517 pub fn setMode(self: *const GraphicsOutputProtocol, mode: u32) usize {
1618 return self._set_mode(self, mode);
1719 }
1820
21 /// Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
1922 pub fn blt(self: *const GraphicsOutputProtocol, blt_buffer: ?[*]GraphicsOutputBltPixel, blt_operation: GraphicsOutputBltOperation, source_x: usize, source_y: usize, destination_x: usize, destination_y: usize, width: usize, height: usize, delta: usize) usize {
2023 return self._blt(self, blt_buffer, blt_operation, source_x, source_y, destination_x, destination_y, width, height, delta);
2124 }
lib/std/os/uefi/protocols/hii.zig+3
......@@ -3,6 +3,7 @@ const Guid = uefi.Guid;
33
44pub const HIIHandle = *@OpaqueType();
55
6/// The header found at the start of each package.
67pub const HIIPackageHeader = packed struct {
78 length: u24,
89 type: u8,
......@@ -22,8 +23,10 @@ pub const HIIPackageHeader = packed struct {
2223 pub const type_system_end: u8 = 0xff;
2324};
2425
26/// The header found at the start of each package list.
2527pub const HIIPackageList = extern struct {
2628 package_list_guid: Guid,
29 /// The size of the package list (in bytes), including the header.
2730 package_list_length: u32,
2831
2932 // TODO implement iterator
lib/std/os/uefi/protocols/hii_database_protocol.zig+5
......@@ -2,6 +2,7 @@ const uefi = @import("std").os.uefi;
22const Guid = uefi.Guid;
33const hii = uefi.protocols.hii;
44
5/// Database manager for HII-related data structures.
56pub const HIIDatabaseProtocol = extern struct {
67 _new_package_list: usize, // TODO
78 _remove_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle) usize,
......@@ -15,18 +16,22 @@ pub const HIIDatabaseProtocol = extern struct {
1516 _set_keyboard_layout: usize, // TODO
1617 _get_package_list_handle: usize, // TODO
1718
19 /// Removes a package list from the HII database.
1820 pub fn removePackageList(self: *const HIIDatabaseProtocol, handle: hii.HIIHandle) usize {
1921 return self._remove_package_list(self, handle);
2022 }
2123
24 /// Update a package list in the HII database.
2225 pub fn updatePackageList(self: *const HIIDatabaseProtocol, handle: hii.HIIHandle, buffer: *const hii.HIIPackageList) usize {
2326 return self._update_package_list(self, handle, buffer);
2427 }
2528
29 /// Determines the handles that are currently active in the database.
2630 pub fn listPackageLists(self: *const HIIDatabaseProtocol, package_type: u8, package_guid: ?*const Guid, buffer_length: *usize, handles: [*]hii.HIIHandle) usize {
2731 return self._list_package_lists(self, package_type, package_guid, buffer_length, handles);
2832 }
2933
34 /// Exports the contents of one or all package lists in the HII database into a buffer.
3035 pub fn exportPackageLists(self: *const HIIDatabaseProtocol, handle: ?hii.HIIHandle, buffer_size: *usize, buffer: *hii.HIIPackageList) usize {
3136 return self._export_package_lists(self, handle, buffer_size, buffer);
3237 }
lib/std/os/uefi/protocols/hii_popup_protocol.zig+2
......@@ -2,10 +2,12 @@ const uefi = @import("std").os.uefi;
22const Guid = uefi.Guid;
33const hii = uefi.protocols.hii;
44
5/// Display a popup window
56pub const HIIPopupProtocol = extern struct {
67 revision: u64,
78 _create_popup: extern fn (*const HIIPopupProtocol, HIIPopupStyle, HIIPopupType, hii.HIIHandle, u16, ?*HIIPopupSelection) usize,
89
10 /// Displays a popup window.
911 pub fn createPopup(self: *const HIIPopupProtocol, style: HIIPopupStyle, popup_type: HIIPopupType, handle: hii.HIIHandle, msg: u16, user_selection: ?*HIIPopupSelection) usize {
1012 return self._create_popup(self, style, popup_type, handle, msg, user_selection);
1113 }
lib/std/os/uefi/protocols/rng_protocol.zig+3-1
......@@ -1,15 +1,17 @@
11const uefi = @import("std").os.uefi;
22const Guid = uefi.Guid;
33
4/// UEFI Specification, Version 2.8, 37.5
4/// Random Number Generator protocol
55pub const RNGProtocol = extern struct {
66 _get_info: extern fn (*const RNGProtocol, *usize, [*]align(8) Guid) usize,
77 _get_rng: extern fn (*const RNGProtocol, ?*align(8) const Guid, usize, [*]u8) usize,
88
9 /// Returns information about the random number generation implementation.
910 pub fn getInfo(self: *const RNGProtocol, list_size: *usize, list: [*]align(8) Guid) usize {
1011 return self._get_info(self, list_size, list);
1112 }
1213
14 /// Produces and returns an RNG value using either the default or specified RNG algorithm.
1315 pub fn getRNG(self: *const RNGProtocol, algo: ?*align(8) const Guid, value_length: usize, value: [*]u8) usize {
1416 return self._get_rng(self, algo, value_length, value);
1517 }
lib/std/os/uefi/protocols/simple_pointer_protocol.zig+3-1
......@@ -2,17 +2,19 @@ const uefi = @import("std").os.uefi;
22const Event = uefi.Event;
33const Guid = uefi.Guid;
44
5/// UEFI Specification, Version 2.8, 12.5
5/// Protocol for mice
66pub const SimplePointerProtocol = struct {
77 _reset: extern fn (*const SimplePointerProtocol, bool) usize,
88 _get_state: extern fn (*const SimplePointerProtocol, *SimplePointerState) usize,
99 wait_for_input: Event,
1010 mode: *SimplePointerMode,
1111
12 /// Resets the pointer device hardware.
1213 pub fn reset(self: *const SimplePointerProtocol, verify: bool) usize {
1314 return self._reset(self, verify);
1415 }
1516
17 /// Retrieves the current state of a pointer device.
1618 pub fn getState(self: *const SimplePointerProtocol, state: *SimplePointerState) usize {
1719 return self._get_state(self, state);
1820 }
lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig+6-1
......@@ -2,7 +2,7 @@ const uefi = @import("std").os.uefi;
22const Event = uefi.Event;
33const Guid = uefi.Guid;
44
5/// UEFI Specification, Version 2.8, 12.3
5/// Character input devices, e.g. Keyboard
66pub const SimpleTextInputExProtocol = extern struct {
77 _reset: extern fn (*const SimpleTextInputExProtocol, bool) usize,
88 _read_key_stroke_ex: extern fn (*const SimpleTextInputExProtocol, *KeyData) usize,
......@@ -11,22 +11,27 @@ pub const SimpleTextInputExProtocol = extern struct {
1111 _register_key_notify: extern fn (*const SimpleTextInputExProtocol, *const KeyData, extern fn (*const KeyData) usize, **c_void) usize,
1212 _unregister_key_notify: extern fn (*const SimpleTextInputExProtocol, *const c_void) usize,
1313
14 /// Resets the input device hardware.
1415 pub fn reset(self: *const SimpleTextInputExProtocol, verify: bool) usize {
1516 return self._reset(self, verify);
1617 }
1718
19 /// Reads the next keystroke from the input device.
1820 pub fn readKeyStrokeEx(self: *const SimpleTextInputExProtocol, key_data: *KeyData) usize {
1921 return self._read_key_stroke_ex(self, key_data);
2022 }
2123
24 /// Set certain state for the input device.
2225 pub fn setState(self: *const SimpleTextInputExProtocol, state: *const u8) usize {
2326 return self._set_state(self, state);
2427 }
2528
29 /// Register a notification function for a particular keystroke for the input device.
2630 pub fn registerKeyNotify(self: *const SimpleTextInputExProtocol, key_data: *const KeyData, notify: extern fn (*const KeyData) usize, handle: **c_void) usize {
2731 return self._register_key_notify(self, key_data, notify, handle);
2832 }
2933
34 /// Remove the notification that was previously registered.
3035 pub fn unregisterKeyNotify(self: *const SimpleTextInputExProtocol, handle: *const c_void) usize {
3136 return self._unregister_key_notify(self, handle);
3237 }
lib/std/os/uefi/protocols/simple_text_output_protocol.zig+10-1
......@@ -1,7 +1,7 @@
11const uefi = @import("std").os.uefi;
22const Guid = uefi.Guid;
33
4/// UEFI Specification, Version 2.8, 12.4
4/// Character output devices
55pub const SimpleTextOutputProtocol = extern struct {
66 _reset: extern fn (*const SimpleTextOutputProtocol, bool) usize,
77 _output_string: extern fn (*const SimpleTextOutputProtocol, [*]const u16) usize,
......@@ -14,38 +14,47 @@ pub const SimpleTextOutputProtocol = extern struct {
1414 _enable_cursor: extern fn (*const SimpleTextOutputProtocol, bool) usize,
1515 mode: *SimpleTextOutputMode,
1616
17 /// Resets the text output device hardware.
1718 pub fn reset(self: *const SimpleTextOutputProtocol, verify: bool) usize {
1819 return self._reset(self, verify);
1920 }
2021
22 /// Writes a string to the output device.
2123 pub fn outputString(self: *const SimpleTextOutputProtocol, msg: [*]const u16) usize {
2224 return self._output_string(self, msg);
2325 }
2426
27 /// Verifies that all characters in a string can be output to the target device.
2528 pub fn testString(self: *const SimpleTextOutputProtocol, msg: [*]const u16) usize {
2629 return self._test_string(self, msg);
2730 }
2831
32 /// Returns information for an available text mode that the output device(s) supports.
2933 pub fn queryMode(self: *const SimpleTextOutputProtocol, mode_number: usize, columns: *usize, rows: *usize) usize {
3034 return self._query_mode(self, mode_number, columns, rows);
3135 }
3236
37 /// Sets the output device(s) to a specified mode.
3338 pub fn setMode(self: *const SimpleTextOutputProtocol, mode_number: usize) usize {
3439 return self._set_mode(self, mode_number);
3540 }
3641
42 /// Sets the background and foreground colors for the outputString() and clearScreen() functions.
3743 pub fn setAttribute(self: *const SimpleTextOutputProtocol, attribute: usize) usize {
3844 return self._set_attribute(self, attribute);
3945 }
4046
47 /// Clears the output device(s) display to the currently selected background color.
4148 pub fn clearScreen(self: *const SimpleTextOutputProtocol) usize {
4249 return self._clear_screen(self);
4350 }
4451
52 /// Sets the current coordinates of the cursor position.
4553 pub fn setCursorPosition(self: *const SimpleTextOutputProtocol, column: usize, row: usize) usize {
4654 return self._set_cursor_position(self, column, row);
4755 }
4856
57 /// Makes the cursor visible or invisible.
4958 pub fn enableCursor(self: *const SimpleTextOutputProtocol, visible: bool) usize {
5059 return self._enable_cursor(self, visible);
5160 }
lib/std/os/uefi/status.zig+41-1
......@@ -1,46 +1,86 @@
11const high_bit = 1 << @typeInfo(usize).Int.bits - 1;
22
3/// UEFI Specification, Version 2.8, Appendix D
3/// The operation completed successfully.
44pub const success: usize = 0;
55
6/// The image failed to load.
67pub const load_error: usize = high_bit | 1;
8/// A parameter was incorrect.
79pub const invalid_parameter: usize = high_bit | 2;
10/// The operation is not supported.
811pub const unsupported: usize = high_bit | 3;
12/// The buffer was not the proper size for the request.
913pub const bad_buffer_size: usize = high_bit | 4;
14/// The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs.
1015pub const buffer_too_small: usize = high_bit | 5;
16/// There is no data pending upon return.
1117pub const not_ready: usize = high_bit | 6;
18/// The physical device reported an error while attempting the operation.
1219pub const device_error: usize = high_bit | 7;
20/// The device cannot be written to.
1321pub const write_protected: usize = high_bit | 8;
22/// A resource has run out.
1423pub const out_of_resources: usize = high_bit | 9;
24/// An inconstancy was detected on the file system causing the operating to fail.
1525pub const volume_corrupted: usize = high_bit | 10;
26/// There is no more space on the file system.
1627pub const volume_full: usize = high_bit | 11;
28/// The device does not contain any medium to perform the operation.
1729pub const no_media: usize = high_bit | 12;
30/// The medium in the device has changed since the last access.
1831pub const media_changed: usize = high_bit | 13;
32/// The item was not found.
1933pub const not_found: usize = high_bit | 14;
34/// Access was denied.
2035pub const access_denied: usize = high_bit | 15;
36/// The server was not found or did not respond to the request.
2137pub const no_response: usize = high_bit | 16;
38/// A mapping to a device does not exist.
2239pub const no_mapping: usize = high_bit | 17;
40/// The timeout time expired.
2341pub const timeout: usize = high_bit | 18;
42/// The protocol has not been started.
2443pub const not_started: usize = high_bit | 19;
44/// The protocol has already been started.
2545pub const already_started: usize = high_bit | 20;
46/// The operation was aborted.
2647pub const aborted: usize = high_bit | 21;
48/// An ICMP error occurred during the network operation.
2749pub const icmp_error: usize = high_bit | 22;
50/// A TFTP error occurred during the network operation.
2851pub const tftp_error: usize = high_bit | 23;
52/// A protocol error occurred during the network operation.
2953pub const protocol_error: usize = high_bit | 24;
54/// The function encountered an internal version that was incompatible with a version requested by the caller.
3055pub const incompatible_version: usize = high_bit | 25;
56/// The function was not performed due to a security violation.
3157pub const security_violation: usize = high_bit | 26;
58/// A CRC error was detected.
3259pub const crc_error: usize = high_bit | 27;
60/// Beginning or end of media was reached
3361pub const end_of_media: usize = high_bit | 28;
62/// The end of the file was reached.
3463pub const end_of_file: usize = high_bit | 31;
64/// The language specified was invalid.
3565pub const invalid_language: usize = high_bit | 32;
66/// The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status.
3667pub const compromised_data: usize = high_bit | 33;
68/// There is an address conflict address allocation
3769pub const ip_address_conflict: usize = high_bit | 34;
70/// A HTTP error occurred during the network operation.
3871pub const http_error: usize = high_bit | 35;
3972
73/// The string contained one or more characters that the device could not render and were skipped.
4074pub const warn_unknown_glyph: usize = 1;
75/// The handle was closed, but the file was not deleted.
4176pub const warn_delete_failure: usize = 2;
77/// The handle was closed, but the data to the file was not flushed properly.
4278pub const warn_write_failure: usize = 3;
79/// The resulting buffer was too small, and the data was truncated to the buffer size.
4380pub const warn_buffer_too_small: usize = 4;
81/// The data has not been updated within the timeframe set by localpolicy for this type of data.
4482pub const warn_stale_data: usize = 5;
83/// The resulting buffer contains UEFI-compliant file system.
4584pub const warn_file_system: usize = 6;
85/// The operation will be processed across a system reset.
4686pub const warn_reset_required: usize = 7;
lib/std/os/uefi/tables/boot_services.zig+17-4
......@@ -4,29 +4,37 @@ const Guid = uefi.Guid;
44const Handle = uefi.Handle;
55const TableHeader = uefi.tables.TableHeader;
66
7/// UEFI Specification, Version 2.8, 4.4
8///
9/// As the boot_services table may grow with new UEFI versions, it is important to check hdr.header_size.
7/// Boot services are services provided by the system's firmware until the operating system takes
8/// over control over the hardware by calling exitBootServices.
109///
1110/// Boot Services must not be used after exitBootServices has been called. The only exception is
1211/// getMemoryMap, which may be used after the first unsuccessful call to exitBootServices.
1312/// After successfully calling exitBootServices, system_table.console_in_handle, system_table.con_in,
1413/// system_table.console_out_handle, system_table.con_out, system_table.standard_error_handle,
1514/// system_table.std_err, and system_table.boot_services should be set to null. After setting these
16/// attributes to null, system_table.hdr.crc32 must be recomputed. See UEFI Specification, Version 2.8, 7.4.
15/// attributes to null, system_table.hdr.crc32 must be recomputed.
16///
17/// As the boot_services table may grow with new UEFI versions, it is important to check hdr.header_size.
1718pub const BootServices = extern struct {
1819 hdr: TableHeader,
1920 raiseTpl: usize, // TODO
2021 restoreTpl: usize, // TODO
2122 allocatePages: usize, // TODO
2223 freePages: usize, // TODO
24 /// Returns the current memory map.
2325 getMemoryMap: extern fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) usize,
26 /// Allocates pool memory.
2427 allocatePool: extern fn (MemoryType, usize, *align(8) [*]u8) usize,
2528 freePool: usize, // TODO
29 /// Creates an event.
2630 createEvent: extern fn (u32, usize, ?extern fn (Event, ?*const c_void) void, ?*const c_void, *Event) usize,
31 /// Sets the type of timer and the trigger time for a timer event.
2732 setTimer: extern fn (Event, TimerDelay, u64) usize,
33 /// Stops execution until an event is signaled.
2834 waitForEvent: extern fn (usize, [*]const Event, *usize) usize,
35 /// Signals an event.
2936 signalEvent: extern fn (Event) usize,
37 /// Closes an event.
3038 closeEvent: extern fn (Event) usize,
3139 checkEvent: usize, // TODO
3240 installProtocolInterface: usize, // TODO
......@@ -40,11 +48,15 @@ pub const BootServices = extern struct {
4048 installConfigurationTable: usize, // TODO
4149 imageLoad: usize, // TODO
4250 imageStart: usize, // TODO
51 /// Terminates a loaded EFI image and returns control to boot services.
4352 exit: extern fn (Handle, usize, usize, ?*const c_void) usize,
4453 imageUnload: usize, // TODO
54 /// Terminates all boot services.
4555 exitBootServices: extern fn (Handle, usize) usize,
4656 getNextMonotonicCount: usize, // TODO
57 /// Induces a fine-grained stall.
4758 stall: extern fn (usize) usize,
59 /// Sets the system's watchdog timer.
4860 setWatchdogTimer: extern fn (usize, u64, usize, ?[*]const u16) usize,
4961 connectController: usize, // TODO
5062 disconnectController: usize, // TODO
......@@ -53,6 +65,7 @@ pub const BootServices = extern struct {
5365 openProtocolInformation: usize, // TODO
5466 protocolsPerHandle: usize, // TODO
5567 locateHandleBuffer: usize, // TODO
68 /// Returns the first protocol instance that matches the given protocol.
5669 locateProtocol: extern fn (*align(8) const Guid, ?*const c_void, *?*c_void) usize,
5770 installMultipleProtocolInterfaces: usize, // TODO
5871 uninstallMultipleProtocolInterfaces: usize, // TODO
lib/std/os/uefi/tables/configuration_table.zig-2
......@@ -1,8 +1,6 @@
11const uefi = @import("std").os.uefi;
22const Guid = uefi.Guid;
33
4/// UEFI Specification, Version 2.8, 4.6
5/// Because GUIDs must be align(8), structs of this type also must be align(8)
64pub const ConfigurationTable = extern struct {
75 vendor_guid: Guid,
86 vendor_table: *c_void,
lib/std/os/uefi/tables/runtime_services.zig+8-5
......@@ -4,26 +4,31 @@ const TableHeader = uefi.tables.TableHeader;
44const Time = uefi.Time;
55const TimeCapabilities = uefi.TimeCapabilities;
66
7/// UEFI Specification, Version 2.8, 4.5
7/// Runtime services are provided by the firmware before and after exitBootServices has been called.
88///
99/// As the runtime_services table may grow with new UEFI versions, it is important to check hdr.header_size.
1010///
1111/// Some functions may not be supported. Check the RuntimeServicesSupported variable using getVariable.
12/// getVariable is one of the functions that may not be supported. See UEFI Specification, Version 2.8, 8.1.
12/// getVariable is one of the functions that may not be supported.
1313///
14/// Some functions may not be called while other functions are running. See UEFI Specification, Version 2.8, 8.1.
14/// Some functions may not be called while other functions are running.
1515pub const RuntimeServices = extern struct {
1616 hdr: TableHeader,
17 /// Returns the current time and date information, and the time-keeping capabilities of the hardware platform.
1718 getTime: extern fn (*uefi.Time, ?*TimeCapabilities) usize,
1819 setTime: usize, // TODO
1920 getWakeupTime: usize, // TODO
2021 setWakeupTime: usize, // TODO
2122 setVirtualAddressMap: usize, // TODO
2223 convertPointer: usize, // TODO
24 /// Returns the value of a variable.
2325 getVariable: extern fn ([*]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) usize,
26 /// Enumerates the current variable names.
2427 getNextVariableName: extern fn (*usize, [*]u16, *align(8) Guid) usize,
28 /// Sets the value of a variable.
2529 setVariable: extern fn ([*]const u16, *align(8) const Guid, u32, usize, *c_void) usize,
2630 getNextHighMonotonicCount: usize, // TODO
31 /// Resets the entire platform.
2732 resetSystem: extern fn (ResetType, usize, usize, ?*const c_void) noreturn,
2833 updateCapsule: usize, // TODO
2934 queryCapsuleCapabilities: usize, // TODO
......@@ -32,7 +37,6 @@ pub const RuntimeServices = extern struct {
3237 pub const signature: u64 = 0x56524553544e5552;
3338};
3439
35/// UEFI Specification, Version 2.8, 8.5.1
3640pub const ResetType = extern enum(u32) {
3741 ResetCold,
3842 ResetWarm,
......@@ -40,7 +44,6 @@ pub const ResetType = extern enum(u32) {
4044 ResetPlatformSpecific,
4145};
4246
43/// UEFI Specification, Version 2.8, 3.3
4447pub const global_variable align(8) = Guid{
4548 .time_low = 0x8be4df61,
4649 .time_mid = 0x93ca,
lib/std/os/uefi/tables/system_table.zig+4-3
......@@ -7,17 +7,18 @@ const SimpleTextInputExProtocol = uefi.protocols.SimpleTextInputExProtocol;
77const SimpleTextOutputProtocol = uefi.protocols.SimpleTextOutputProtocol;
88const TableHeader = uefi.tables.TableHeader;
99
10/// UEFI Specification, Version 2.8, 4.3
10/// The EFI System Table contains pointers to the runtime and boot services tables.
1111///
1212/// As the system_table may grow with new UEFI versions, it is important to check hdr.header_size.
1313///
1414/// After successfully calling boot_services.exitBootServices, console_in_handle,
1515/// con_in, console_out_handle, con_out, standard_error_handle, std_err, and
1616/// boot_services should be set to null. After setting these attributes to null,
17/// hdr.crc32 must be recomputed. See UEFI Specification, Version 2.8, 7.4.
17/// hdr.crc32 must be recomputed.
1818pub const SystemTable = extern struct {
1919 hdr: TableHeader,
20 firmware_vendor: *u16,
20 /// A null-terminated string that identifies the vendor that produces the system firmware of the platform.
21 firmware_vendor: [*]u16,
2122 firmware_revision: u32,
2223 console_in_handle: ?Handle,
2324 con_in: ?*SimpleTextInputExProtocol,
lib/std/os/uefi/tables/table_header.zig+1-1
......@@ -1,7 +1,7 @@
1/// UEFI Specification, Version 2.8, 4.2
21pub const TableHeader = extern struct {
32 signature: u64,
43 revision: u32,
4 /// The size, in bytes, of the entire table including the TableHeader
55 header_size: u32,
66 crc32: u32,
77 reserved: u32,