const std = @import("../std.zig");
pub const protocols = @import("uefi/protocols.zig");
pub const Status = @import("uefi/status.zig").Status;
pub const tables = @import("uefi/tables.zig");
pub var efi_pool_memory_type: tables.MemoryType = .LoaderData;
pub const pool_allocator = @import("uefi/pool_allocator.zig").pool_allocator;
pub const raw_pool_allocator = @import("uefi/pool_allocator.zig").raw_pool_allocator;
pub var handle: Handle = undefined;
pub var system_table: *tables.SystemTable = undefined;
pub const Event = *opaque {};
pub const MacAddress = extern struct {
    address: [32]u8,
};
pub const Ipv4Address = extern struct {
    address: [4]u8,
};
pub const Ipv6Address = extern struct {
    address: [16]u8,
};
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,
    
    pub fn format(
        self: @This(),
        comptime f: []const u8,
        options: std.fmt.FormatOptions,
        writer: anytype,
    ) !void {
        _ = options;
        if (f.len == 0) {
            const fmt = std.fmt.fmtSliceHexLower;
            const time_low = @byteSwap(self.time_low);
            const time_mid = @byteSwap(self.time_mid);
            const time_high_and_version = @byteSwap(self.time_high_and_version);
            return std.fmt.format(writer, "{:0>8}-{:0>4}-{:0>4}-{:0>2}{:0>2}-{:0>12}", .{
                fmt(std.mem.asBytes(&time_low)),
                fmt(std.mem.asBytes(&time_mid)),
                fmt(std.mem.asBytes(&time_high_and_version)),
                fmt(std.mem.asBytes(&self.clock_seq_high_and_reserved)),
                fmt(std.mem.asBytes(&self.clock_seq_low)),
                fmt(std.mem.asBytes(&self.node)),
            });
        } else {
            @compileError("Unknown format character: '" ++ f ++ "'");
        }
    }
    pub fn eql(a: std.os.uefi.Guid, b: std.os.uefi.Guid) bool {
        return a.time_low == b.time_low and
            a.time_mid == b.time_mid and
            a.time_high_and_version == b.time_high_and_version and
            a.clock_seq_high_and_reserved == b.clock_seq_high_and_reserved and
            a.clock_seq_low == b.clock_seq_low and
            std.mem.eql(u8, &a.node, &b.node);
    }
};
pub const Handle = *opaque {};
pub const Time = extern struct {
    
    year: u16,
    
    month: u8,
    
    day: u8,
    
    hour: u8,
    
    minute: u8,
    
    second: u8,
    
    nanosecond: u32,
    
    
    timezone: i16,
    daylight: packed struct {
        _pad1: u6,
        
        in_daylight: bool,
        
        adjust_daylight: bool,
    },
    
    pub const unspecified_timezone: i16 = 0x7ff;
};
pub const TimeCapabilities = extern struct {
    
    resolution: u32,
    
    accuracy: u32,
    
    sets_to_zero: bool,
};
pub const FileHandle = *opaque {};
test "GUID formatting" {
    var bytes = [_]u8{ 137, 60, 203, 50, 128, 128, 124, 66, 186, 19, 80, 73, 135, 59, 194, 135 };
    var guid = @bitCast(Guid, bytes);
    var str = try std.fmt.allocPrint(std.testing.allocator, "{}", .{guid});
    defer std.testing.allocator.free(str);
    try std.testing.expect(std.mem.eql(u8, str, "32cb3c89-8080-427c-ba13-5049873bc287"));
}
test {
    _ = tables;
    _ = protocols;
}