1const std = @import("../std.zig");
2
3/// A protocol is an interface identified by a GUID.
4pub const protocols = @import("uefi/protocols.zig");
5
6/// Status codes returned by EFI interfaces
7pub const Status = @import("uefi/status.zig").Status;
8pub const tables = @import("uefi/tables.zig");
9
10/// The EFI image's handle that is passed to its entry point.
11pub var handle: Handle = undefined;
12
13/// A pointer to the EFI System Table that is passed to the EFI image's entry point.
14pub var system_table: *tables.SystemTable = undefined;
15
16/// A handle to an event structure.
17pub const Event = *opaque {};
18
19/// GUIDs must be align(8)
20pub const Guid = extern struct {
21    time_low: u32,
22    time_mid: u16,
23    time_high_and_version: u16,
24    clock_seq_high_and_reserved: u8,
25    clock_seq_low: u8,
26    node: [6]u8,
27
28    /// Format GUID into hexadecimal lowercase xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format
29    pub fn format(
30        self: @This(),
31        comptime f: []const u8,
32        options: std.fmt.FormatOptions,
33        writer: anytype,
34    ) !void {
35        _ = options;
36        if (f.len == 0) {
37            return std.fmt.format(writer, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{
38                self.time_low,
39                self.time_mid,
40                self.time_high_and_version,
41                self.clock_seq_high_and_reserved,
42                self.clock_seq_low,
43                self.node,
44            });
45        } else {
46            @compileError("Unknown format character: '" ++ f ++ "'");
47        }
48    }
49
50    pub fn eql(a: std.os.uefi.Guid, b: std.os.uefi.Guid) bool {
51        return a.time_low == b.time_low and
52            a.time_mid == b.time_mid and
53            a.time_high_and_version == b.time_high_and_version and
54            a.clock_seq_high_and_reserved == b.clock_seq_high_and_reserved and
55            a.clock_seq_low == b.clock_seq_low and
56            std.mem.eql(u8, &a.node, &b.node);
57    }
58};
59
60/// An EFI Handle represents a collection of related interfaces.
61pub const Handle = *opaque {};
62
63/// This structure represents time information.
64pub const Time = extern struct {
65    /// 1900 - 9999
66    year: u16,
67
68    /// 1 - 12
69    month: u8,
70
71    /// 1 - 31
72    day: u8,
73
74    /// 0 - 23
75    hour: u8,
76
77    /// 0 - 59
78    minute: u8,
79
80    /// 0 - 59
81    second: u8,
82    _pad1: u8,
83
84    /// 0 - 999999999
85    nanosecond: u32,
86
87    /// The time's offset in minutes from UTC.
88    /// Allowed values are -1440 to 1440 or unspecified_timezone
89    timezone: i16,
90    daylight: packed struct {
91        _pad1: u6,
92
93        /// If true, the time has been adjusted for daylight savings time.
94        in_daylight: bool,
95
96        /// If true, the time is affected by daylight savings time.
97        adjust_daylight: bool,
98    },
99    _pad2: u8,
100
101    /// Time is to be interpreted as local time
102    pub const unspecified_timezone: i16 = 0x7ff;
103};
104
105/// Capabilities of the clock device
106pub const TimeCapabilities = extern struct {
107    /// Resolution in Hz
108    resolution: u32,
109
110    /// Accuracy in an error rate of 1e-6 parts per million.
111    accuracy: u32,
112
113    /// If true, a time set operation clears the device's time below the resolution level.
114    sets_to_zero: bool,
115};
116
117/// File Handle as specified in the EFI Shell Spec
118pub const FileHandle = *opaque {};
119