stduefiHandleEventGuidccmathassertBootServicesRuntimeServicesConfigurationTableSystemTableTableHeaderEventNotifyTimerDelayMemoryTypeMemoryDescriptorAttributeMemoryMapKeyMemoryDescriptorMemoryMapInfoMemoryMapSliceMemoryDescriptorIteratorLocateSearchTypeLocateSearchOpenProtocolAttributesOpenProtocolArgsProtocolInformationEntryInterfaceTypeAllocateLocationAllocateTypePhysicalAddressCapsuleHeaderUefiCapsuleBlockDescriptorResetTypeglobal_variable
std.os.uefi.tables.AllocateLocation
容器
字段
std.os.uefi.tables.AllocateType
容器
字段
any
max_address
address
std.os.uefi.tables.assert
别名
别名目标 std.debug.assert
std.os.uefi.tables.BootServices
别名
std.os.uefi.tables.CapsuleHeader
容器
字段
std.os.uefi.tables.cc
别名
别名目标 std.os.uefi.cc
std.os.uefi.tables.ConfigurationTable
别名
别名目标 std.os.uefi.tables.configuration_table.ConfigurationTable
std.os.uefi.tables.Event
别名
别名目标 std.os.uefi.Event
std.os.uefi.tables.EventNotify
类型
std.os.uefi.tables.global_variable
常量
std.os.uefi.tables.Guid
别名
别名目标 std.os.uefi.Guid
std.os.uefi.tables.Handle
别名
别名目标 std.os.uefi.Handle
std.os.uefi.tables.InterfaceType
容器
字段
native
std.os.uefi.tables.LocateSearch
容器
字段
std.os.uefi.tables.LocateSearchType
容器
字段
all_handles
by_register_notify
by_protocol
std.os.uefi.tables.math
别名
别名目标 std.math
std.os.uefi.tables.MemoryDescriptor
容器
字段
type: MemoryType
physical_start: u64
virtual_start: u64
number_of_pages: u64
attribute: MemoryDescriptorAttribute
std.os.uefi.tables.MemoryDescriptorAttribute
容器
字段
uc: bool
wc: bool
wt: bool
wb: bool
uce: bool
_pad1: u7 = 0
wp: bool
rp: bool
xp: bool
nv: bool
more_reliable: bool
ro: bool
sp: bool
cpu_crypto: bool
_pad2: u43 = 0
memory_runtime: bool
std.os.uefi.tables.MemoryDescriptorIterator
容器
字段
ctx: MemoryMapSlice
index: usize = 0
std.os.uefi.tables.MemoryDescriptorIterator.next
函数
pub fn next(self: *MemoryDescriptorIterator) ?*MemoryDescriptor
参数
self: *MemoryDescriptorIterator
std.os.uefi.tables.MemoryMapInfo
容器
字段
std.os.uefi.tables.MemoryMapKey
容器
字段
_
std.os.uefi.tables.MemoryMapSlice
容器
字段
info: MemoryMapInfo
ptr: [*]align(@alignOf(MemoryDescriptor)) u8
std.os.uefi.tables.MemoryMapSlice.get
函数
pub fn get(self: MemoryMapSlice, index: usize) ?*MemoryDescriptor
参数
self: MemoryMapSlice
index: usize
std.os.uefi.tables.MemoryMapSlice.getUnchecked
函数
pub fn getUnchecked(self: MemoryMapSlice, index: usize) *MemoryDescriptor
参数
self: MemoryMapSlice
index: usize
std.os.uefi.tables.MemoryMapSlice.iterator
函数
pub fn iterator(self: MemoryMapSlice) MemoryDescriptorIterator
参数
self: MemoryMapSlice
std.os.uefi.tables.MemoryType
容器
字段
reserved_memory_type除非明确针对另有规定的接口,否则仅能使用 .allocate_any_pages 模式分配。
loader_code
loader_data
boot_services_code
boot_services_data
runtime_services_code除非明确针对另有规定的接口,否则仅能使用 .allocate_any_pages 模式分配。
runtime_services_data除非明确针对另有规定的接口,否则仅能使用 .allocate_any_pages 模式分配。
conventional_memory
unusable_memory
acpi_reclaim_memory除非明确针对另有规定的接口,否则仅能使用 .allocate_any_pages 模式分配。
acpi_memory_nvs除非明确针对另有规定的接口,否则仅能使用 .allocate_any_pages 模式分配。
memory_mapped_io
memory_mapped_io_port_space
pal_code
persistent_memory
unaccepted_memory
max_memory_type
invalid_start
invalid_end = 0x6FFFFFFF
oem_start = 0x700000000x70000000..0x7FFFFFFF 范围的 MemoryType 值保留给 OEM 使用。
oem_end = 0x7FFFFFFF
vendor_start = 0x80000000范围 0x80000000..0xFFFFFFFF 内的 MemoryType 值保留给 操作系统供应商提供的 UEFI 操作系统加载器使用。
vendor_end = 0xFFFFFFFF
_
std.os.uefi.tables.MemoryType.format
函数
pub fn format(self: MemoryType, w: *std.Io.Writer) std.Io.Writer.Error!void
参数
self: MemoryType
w: *std.Io.Writer
错误
- WriteFailed
详细诊断信息见
Writer实现。
std.os.uefi.tables.MemoryType.fromOem
函数
pub fn fromOem(value: Oem) MemoryType
参数
value: Oem
std.os.uefi.tables.MemoryType.fromVendor
函数
pub fn fromVendor(value: Vendor) MemoryType
参数
value: Vendor
std.os.uefi.tables.MemoryType.Oem
类型
std.os.uefi.tables.MemoryType.toOem
函数
pub fn toOem(memtype: MemoryType) ?Oem
参数
memtype: MemoryType
std.os.uefi.tables.MemoryType.toVendor
函数
pub fn toVendor(memtype: MemoryType) ?Vendor
参数
memtype: MemoryType
std.os.uefi.tables.MemoryType.Vendor
类型
std.os.uefi.tables.OpenProtocolArgs
容器
字段
by_handle_protocol: struct { agent: ?Handle = null, controller: ?Handle = null }用于 handleProtocol 的实现。
get_protocol: struct { agent: ?Handle = null, controller: ?Handle = null }驱动用它从句柄取得协议接口。使用此打开模式时必须谨慎,因为以这种方式打开协议接口的驱动,在接口被卸载或重新安装时不会收到通知。
调用者也无需通过 closeProtocol 关闭协议接口。
test_protocol: struct { agent: ?Handle = null, controller: ?Handle = null }供驱动程序测试句柄上是否存在协议接口。
调用方仅使用返回的状态码。
调用方也无需使用 closeProtocol 关闭协议接口。
by_child_controller: struct { agent: Handle, controller: Handle }总线驱动使用此模式,表示某个协议接口正被该总线的一个子控制器使用。
BootServices.connectController 使用此信息递归连接所有子控制器,BootServices.disconnectController 则据此获取总线驱动创建的子控制器列表。
by_driver: struct { agent: Handle, controller: Handle }由驱动程序用于访问协议接口。使用此模式
时,如果协议接口被重新安装或卸载,
BootServices.disconnectController 将调用驱动程序的 Stop()
函数。一旦某驱动程序以此属性打开协议接口,
就不允许其他驱动程序以 .by_driver
属性打开同一协议接口。
by_driver_exclusive: struct { agent: Handle, controller: Handle }驱动程序用它获取协议接口的独占访问权。若有其他
驱动程序已使用 .by_driver 属性打开该协议接口,
则尝试通过
BootServices.disconnectController 移除它们。
exclusive: struct { agent: Handle, controller: ?Handle = null }应用程序用于独占访问协议接口。如果
任何驱动程序已通过 .by_driver 属性打开该协议接口,
则尝试调用其 Stop() 函数,
移除这些驱动程序。
std.os.uefi.tables.OpenProtocolAttributes
容器
字段
by_handle_protocol = @bitCast(Bits{ .by_handle_protocol = true })
get_protocol = @bitCast(Bits{ .get_protocol = true })
test_protocol = @bitCast(Bits{ .test_protocol = true })
by_child_controller = @bitCast(Bits{ .by_child_controller = true })
by_driver = @bitCast(Bits{ .by_driver = true })
by_driver_exclusive = @bitCast(Bits{ .by_driver = true, .exclusive = true })
exclusive = @bitCast(Bits{ .exclusive = true })
_
std.os.uefi.tables.OpenProtocolAttributes.Bits
容器
字段
by_handle_protocol: bool = false
get_protocol: bool = false
test_protocol: bool = false
by_child_controller: bool = false
by_driver: bool = false
exclusive: bool = false
reserved: u26 = 0
std.os.uefi.tables.OpenProtocolAttributes.fromBits
函数
pub fn fromBits(bits: Bits) OpenProtocolAttributes
参数
bits: Bits
std.os.uefi.tables.OpenProtocolAttributes.toBits
函数
pub fn toBits(self: OpenProtocolAttributes) Bits
参数
self: OpenProtocolAttributes
std.os.uefi.tables.PhysicalAddress
类型
std.os.uefi.tables.ProtocolInformationEntry
容器
字段
std.os.uefi.tables.ResetType
容器
字段
cold
warm
shutdown
platform_specific
std.os.uefi.tables.RuntimeServices
别名
std.os.uefi.tables.std
别名
别名目标 std
std.os.uefi.tables.SystemTable
别名
std.os.uefi.tables.TableHeader
别名
std.os.uefi.tables.TimerDelay
容器
字段
cancel
periodic
relative
std.os.uefi.tables.uefi
别名
别名目标 std.os.uefi
std.os.uefi.tables.UefiCapsuleBlockDescriptor
容器
字段
length: u64
address: extern union {
data_block: PhysicalAddress,
continuation_pointer: PhysicalAddress,
}
源码
std/os/uefi/tables.zig
const std = @import("std");
const uefi = std.os.uefi;
const Handle = uefi.Handle;
const Event = uefi.Event;
const Guid = uefi.Guid;
const cc = uefi.cc;
const math = std.math;
const assert = std.debug.assert;
pub const BootServices = @import("tables/boot_services.zig").BootServices;
pub const RuntimeServices = @import("tables/runtime_services.zig").RuntimeServices;
pub const ConfigurationTable = @import("tables/configuration_table.zig").ConfigurationTable;
pub const SystemTable = @import("tables/system_table.zig").SystemTable;
pub const TableHeader = @import("tables/table_header.zig").TableHeader;
pub const EventNotify = *const fn (event: Event, ctx: *anyopaque) callconv(cc) void;
pub const TimerDelay = enum(u32) {
cancel,
periodic,
relative,
};
pub const MemoryType = enum(u32) {
pub const Oem = math.IntFittingRange(
0,
@backingInt(MemoryType.oem_end) - @backingInt(MemoryType.oem_start),
);
pub const Vendor = math.IntFittingRange(
0,
@backingInt(MemoryType.vendor_end) - @backingInt(MemoryType.vendor_start),
);
/// 除非明确针对另有规定的接口,否则仅能使用 .allocate_any_pages 模式分配。
reserved_memory_type,
loader_code,
loader_data,
boot_services_code,
boot_services_data,
/// 除非明确针对另有规定的接口,否则仅能使用 .allocate_any_pages 模式分配。
runtime_services_code,
/// 除非明确针对另有规定的接口,否则仅能使用 .allocate_any_pages 模式分配。
runtime_services_data,
conventional_memory,
unusable_memory,
/// 除非明确针对另有规定的接口,否则仅能使用 .allocate_any_pages 模式分配。
acpi_reclaim_memory,
/// 除非明确针对另有规定的接口,否则仅能使用 .allocate_any_pages 模式分配。
acpi_memory_nvs,
memory_mapped_io,
memory_mapped_io_port_space,
pal_code,
persistent_memory,
unaccepted_memory,
max_memory_type,
invalid_start,
invalid_end = 0x6FFFFFFF,
/// 0x70000000..0x7FFFFFFF 范围的 MemoryType 值保留给 OEM 使用。
oem_start = 0x70000000,
oem_end = 0x7FFFFFFF,
/// 范围 0x80000000..0xFFFFFFFF 内的 MemoryType 值保留给
/// 操作系统供应商提供的 UEFI 操作系统加载器使用。
vendor_start = 0x80000000,
vendor_end = 0xFFFFFFFF,
_,
pub fn fromOem(value: Oem) MemoryType {
const oem_start = @backingInt(MemoryType.oem_start);
return @fromBackingInt(@intCast(oem_start + value));
}
pub fn toOem(memtype: MemoryType) ?Oem {
const as_int = @backingInt(memtype);
const oem_start = @backingInt(MemoryType.oem_start);
if (as_int < oem_start) return null;
if (as_int > @backingInt(MemoryType.oem_end)) return null;
return @truncate(as_int - oem_start);
}
pub fn fromVendor(value: Vendor) MemoryType {
const vendor_start = @backingInt(MemoryType.vendor_start);
return @fromBackingInt(@intCast(vendor_start + value));
}
pub fn toVendor(memtype: MemoryType) ?Vendor {
const as_int = @backingInt(memtype);
const vendor_start = @backingInt(MemoryType.vendor_start);
if (as_int < @backingInt(MemoryType.vendor_end)) return null;
if (as_int > @backingInt(MemoryType.vendor_end)) return null;
return @truncate(as_int - vendor_start);
}
pub fn format(self: MemoryType, w: *std.Io.Writer) std.Io.Writer.Error!void {
if (self.toOem()) |oemval|
try w.print("OEM({X})", .{oemval})
else if (self.toVendor()) |vendorval|
try w.print("Vendor({X})", .{vendorval})
else if (std.enums.tagName(MemoryType, self)) |name|
try w.print("{s}", .{name})
else
try w.print("INVALID({X})", .{@backingInt(self)});
}
};
pub const MemoryDescriptorAttribute = packed struct(u64) {
uc: bool,
wc: bool,
wt: bool,
wb: bool,
uce: bool,
_pad1: u7 = 0,
wp: bool,
rp: bool,
xp: bool,
nv: bool,
more_reliable: bool,
ro: bool,
sp: bool,
cpu_crypto: bool,
_pad2: u43 = 0,
memory_runtime: bool,
};
pub const MemoryMapKey = enum(usize) { _ };
pub const MemoryDescriptor = extern struct {
type: MemoryType,
physical_start: u64,
virtual_start: u64,
number_of_pages: u64,
attribute: MemoryDescriptorAttribute,
};
pub const MemoryMapInfo = struct {
key: MemoryMapKey,
descriptor_size: usize,
descriptor_version: u32,
/// 映射中的描述符数量。
len: usize,
};
pub const MemoryMapSlice = struct {
info: MemoryMapInfo,
ptr: [*]align(@alignOf(MemoryDescriptor)) u8,
pub fn iterator(self: MemoryMapSlice) MemoryDescriptorIterator {
return .{ .ctx = self };
}
pub fn get(self: MemoryMapSlice, index: usize) ?*MemoryDescriptor {
if (index >= self.info.len) return null;
return self.getUnchecked(index);
}
pub fn getUnchecked(self: MemoryMapSlice, index: usize) *MemoryDescriptor {
const offset: usize = index * self.info.descriptor_size;
return @ptrCast(@alignCast(self.ptr[offset..]));
}
};
pub const MemoryDescriptorIterator = struct {
ctx: MemoryMapSlice,
index: usize = 0,
pub fn next(self: *MemoryDescriptorIterator) ?*MemoryDescriptor {
const md = self.ctx.get(self.index) orelse return null;
self.index += 1;
return md;
}
};
pub const LocateSearchType = enum(u32) {
all_handles,
by_register_notify,
by_protocol,
};
pub const LocateSearch = union(LocateSearchType) {
all_handles,
by_register_notify: uefi.EventRegistration,
by_protocol: *const Guid,
};
pub const OpenProtocolAttributes = enum(u32) {
pub const Bits = packed struct(u32) {
by_handle_protocol: bool = false,
get_protocol: bool = false,
test_protocol: bool = false,
by_child_controller: bool = false,
by_driver: bool = false,
exclusive: bool = false,
reserved: u26 = 0,
};
by_handle_protocol = @bitCast(Bits{ .by_handle_protocol = true }),
get_protocol = @bitCast(Bits{ .get_protocol = true }),
test_protocol = @bitCast(Bits{ .test_protocol = true }),
by_child_controller = @bitCast(Bits{ .by_child_controller = true }),
by_driver = @bitCast(Bits{ .by_driver = true }),
by_driver_exclusive = @bitCast(Bits{ .by_driver = true, .exclusive = true }),
exclusive = @bitCast(Bits{ .exclusive = true }),
_,
pub fn fromBits(bits: Bits) OpenProtocolAttributes {
return @bitCast(bits);
}
pub fn toBits(self: OpenProtocolAttributes) Bits {
return @bitCast(self);
}
};
pub const OpenProtocolArgs = union(OpenProtocolAttributes) {
/// 用于 `handleProtocol` 的实现。
by_handle_protocol: struct { agent: ?Handle = null, controller: ?Handle = null },
/// 驱动用它从句柄取得协议接口。使用此打开模式时必须谨慎,因为以这种方式打开协议接口的驱动,在接口被卸载或重新安装时不会收到通知。
/// 调用者也无需通过 `closeProtocol` 关闭协议接口。
///
///
///
get_protocol: struct { agent: ?Handle = null, controller: ?Handle = null },
/// 供驱动程序测试句柄上是否存在协议接口。
/// 调用方仅使用返回的状态码。
/// 调用方也无需使用 `closeProtocol` 关闭协议接口。
test_protocol: struct { agent: ?Handle = null, controller: ?Handle = null },
/// 总线驱动使用此模式,表示某个协议接口正被该总线的一个子控制器使用。
/// `BootServices.connectController` 使用此信息递归连接所有子控制器,`BootServices.disconnectController` 则据此获取总线驱动创建的子控制器列表。
///
///
///
by_child_controller: struct { agent: Handle, controller: Handle },
/// 由驱动程序用于访问协议接口。使用此模式
/// 时,如果协议接口被重新安装或卸载,
/// `BootServices.disconnectController` 将调用驱动程序的 Stop()
/// 函数。一旦某驱动程序以此属性打开协议接口,
/// 就不允许其他驱动程序以 `.by_driver`
/// 属性打开同一协议接口。
by_driver: struct { agent: Handle, controller: Handle },
/// 驱动程序用它获取协议接口的独占访问权。若有其他
/// 驱动程序已使用 `.by_driver` 属性打开该协议接口,
/// 则尝试通过
/// `BootServices.disconnectController` 移除它们。
by_driver_exclusive: struct { agent: Handle, controller: Handle },
/// 应用程序用于独占访问协议接口。如果
/// 任何驱动程序已通过 `.by_driver` 属性打开该协议接口,
/// 则尝试调用其 Stop() 函数,
/// 移除这些驱动程序。
exclusive: struct { agent: Handle, controller: ?Handle = null },
};
pub const ProtocolInformationEntry = extern struct {
agent_handle: ?Handle,
controller_handle: ?Handle,
attributes: OpenProtocolAttributes,
open_count: u32,
};
pub const InterfaceType = enum(u32) {
native,
};
pub const AllocateLocation = union(AllocateType) {
any,
max_address: [*]align(4096) uefi.Page,
address: [*]align(4096) uefi.Page,
};
pub const AllocateType = enum(u32) {
any,
max_address,
address,
};
pub const PhysicalAddress = u64;
pub const CapsuleHeader = extern struct {
capsule_guid: Guid,
header_size: u32,
flags: u32,
capsule_image_size: u32,
};
pub const UefiCapsuleBlockDescriptor = extern struct {
length: u64,
address: extern union {
data_block: PhysicalAddress,
continuation_pointer: PhysicalAddress,
},
};
pub const ResetType = enum(u32) {
cold,
warm,
shutdown,
platform_specific,
};
pub const global_variable = Guid{
.time_low = 0x8be4df61,
.time_mid = 0x93ca,
.time_high_and_version = 0x11d2,
.clock_seq_high_and_reserved = 0xaa,
.clock_seq_low = 0x0d,
.node = [_]u8{ 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c },
};
test {
std.testing.refAllDecls(@This());
}