zig/lib/std/os/uefi.zig

101 lines
2.7 KiB
Zig
Raw Normal View History

2019-10-17 01:42:44 +08:00
/// A protocol is an interface identified by a GUID.
pub const protocols = @import("uefi/protocols.zig");
2019-10-17 01:42:44 +08:00
/// Status codes returned by EFI interfaces
pub const status = @import("uefi/status.zig");
pub const tables = @import("uefi/tables.zig");
2019-05-29 15:43:39 +08:00
2019-10-07 20:53:14 +08:00
const fmt = @import("std").fmt;
2019-10-17 01:42:44 +08:00
/// The EFI image's handle that is passed to its entry point.
pub var handle: Handle = undefined;
2019-10-17 01:42:44 +08:00
/// A pointer to the EFI System Table that is passed to the EFI image's entry point.
pub var system_table: *tables.SystemTable = undefined;
2019-10-17 01:42:44 +08:00
/// A handle to an event structure.
2019-08-10 06:32:43 +08:00
pub const Event = *@OpaqueType();
2019-10-17 01:42:44 +08:00
/// GUIDs must be align(8)
pub const Guid = extern struct {
time_low: u32,
time_mid: u16,
time_high_and_version: u16,
clock_seq_high_and_reserved: u8,
clock_seq_low: u8,
node: [6]u8,
2019-10-07 20:53:14 +08:00
2019-10-17 01:42:44 +08:00
/// Format GUID into hexadecimal lowercase xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format
2019-10-07 20:53:14 +08:00
pub fn format(
self: @This(),
comptime f: []const u8,
options: fmt.FormatOptions,
context: var,
comptime Errors: type,
output: fn (@typeOf(context), []const u8) Errors!void,
) Errors!void {
if (f.len == 0) {
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);
} else {
@compileError("Unknown format character: '" ++ f ++ "'");
}
}
};
2019-10-17 01:42:44 +08:00
/// An EFI Handle represents a collection of related interfaces.
pub const Handle = *@OpaqueType();
2019-10-17 01:42:44 +08:00
/// This structure represents time information.
pub const Time = extern struct {
2019-10-17 01:42:44 +08:00
/// 1900 - 9999
year: u16,
2019-10-17 01:42:44 +08:00
/// 1 - 12
month: u8,
2019-10-17 01:42:44 +08:00
/// 1 - 31
day: u8,
2019-10-17 01:42:44 +08:00
/// 0 - 23
hour: u8,
2019-10-17 01:42:44 +08:00
/// 0 - 59
minute: u8,
2019-10-17 01:42:44 +08:00
/// 0 - 59
second: u8,
_pad1: u8,
2019-10-17 01:42:44 +08:00
/// 0 - 999999999
nanosecond: u32,
2019-10-17 01:42:44 +08:00
/// The time's offset in minutes from UTC.
/// Allowed values are -1440 to 1440 or unspecified_timezone
timezone: i16,
daylight: packed struct {
_pad1: u6,
2019-10-17 01:42:44 +08:00
/// If true, the time has been adjusted for daylight savings time.
in_daylight: bool,
2019-10-17 01:42:44 +08:00
/// If true, the time is affected by daylight savings time.
adjust_daylight: bool,
},
_pad2: u8,
2019-10-17 01:42:44 +08:00
/// Time is to be interpreted as local time
pub const unspecified_timezone: i16 = 0x7ff;
};
2019-10-17 01:42:44 +08:00
/// Capabilities of the clock device
pub const TimeCapabilities = extern struct {
2019-10-17 01:42:44 +08:00
/// Resolution in Hz
resolution: u32,
2019-10-17 01:42:44 +08:00
/// Accuracy in an error rate of 1e-6 parts per million.
accuracy: u32,
2019-10-17 01:42:44 +08:00
/// If true, a time set operation clears the device's time below the resolution level.
sets_to_zero: bool,
};