Commit 88687645b2

fifty-six <ybham6@gmail.com>
2022-01-13 17:19:22
std/os/uefi: Fill out remaining runtime services and add parameter names
1 parent fe28cb8
Changed files (1)
lib
std
os
lib/std/os/uefi/tables/runtime_services.zig
@@ -18,39 +18,71 @@ pub const RuntimeServices = extern struct {
     hdr: TableHeader,
 
     /// Returns the current time and date information, and the time-keeping capabilities of the hardware platform.
-    getTime: fn (*uefi.Time, ?*TimeCapabilities) callconv(.C) Status,
+    getTime: fn (time: *uefi.Time, capabilities: ?*TimeCapabilities) callconv(.C) Status,
 
-    setTime: Status, // TODO
-    getWakeupTime: Status, // TODO
-    setWakeupTime: Status, // TODO
+    /// Sets the current local time and date information
+    setTime: fn (time: *uefi.Time) callconv(.C) Status,
+
+    /// Returns the current wakeup alarm clock setting
+    getWakeupTime: fn (enabled: *bool, pending: *bool, time: *uefi.Time) callconv(.C) Status,
+
+    /// Sets the system wakeup alarm clock time
+    setWakeupTime: fn (enable: *bool, time: ?*uefi.Time) callconv(.C) Status,
 
     /// Changes the runtime addressing mode of EFI firmware from physical to virtual.
-    setVirtualAddressMap: fn (usize, usize, u32, [*]MemoryDescriptor) callconv(.C) Status,
+    setVirtualAddressMap: fn (mmap_size: usize, descriptor_size: usize, descriptor_version: u32, virtual_map: [*]MemoryDescriptor) callconv(.C) Status,
 
     /// Determines the new virtual address that is to be used on subsequent memory accesses.
-    convertPointer: fn (usize, **anyopaque) callconv(.C) Status,
+    convertPointer: fn (debug_disposition: usize, address: **anyopaque) callconv(.C) Status,
 
     /// Returns the value of a variable.
-    getVariable: fn ([*:0]const u16, *align(8) const Guid, ?*u32, *usize, ?*anyopaque) callconv(.C) Status,
+    getVariable: fn (var_name: [*:0]const u16, vendor_guid: *align(8) const Guid, attributes: ?*u32, data_size: *usize, data: ?*anyopaque) callconv(.C) Status,
 
     /// Enumerates the current variable names.
-    getNextVariableName: fn (*usize, [*:0]u16, *align(8) Guid) callconv(.C) Status,
+    getNextVariableName: fn (var_name_size: *usize, var_name: [*:0]u16, vendor_guid: *align(8) Guid) callconv(.C) Status,
 
     /// Sets the value of a variable.
-    setVariable: fn ([*:0]const u16, *align(8) const Guid, u32, usize, *anyopaque) callconv(.C) Status,
+    setVariable: fn (var_name: [*:0]const u16, vendor_guid: *align(8) const Guid, attributes: u32, data_size: usize, data: *anyopaque) callconv(.C) Status,
 
-    getNextHighMonotonicCount: Status, // TODO
+    /// Return the next high 32 bits of the platform's monotonic counter
+    getNextHighMonotonicCount: fn (high_count: *u32) callconv(.C) Status,
 
     /// Resets the entire platform.
-    resetSystem: fn (ResetType, Status, usize, ?*const anyopaque) callconv(.C) noreturn,
+    resetSystem: fn (reset_type: ResetType, reset_status: Status, data_size: usize, reset_data: ?*const anyopaque) callconv(.C) noreturn,
+
+    /// Passes capsules to the firmware with both virtual and physical mapping.
+    /// Depending on the intended consumption, the firmware may process the capsule immediately.
+    /// If the payload should persist across a system reset, the reset value returned from
+    /// `queryCapsuleCapabilities` must be passed into resetSystem and will cause the capsule
+    /// to be processed by the firmware as part of the reset process.
+    updateCapsule: fn (capsule_header_array: **CapsuleHeader, capsule_count: usize, scatter_gather_list: EfiPhysicalAddress) callconv(.C) Status,
 
-    updateCapsule: Status, // TODO
-    queryCapsuleCapabilities: Status, // TODO
-    queryVariableInfo: Status, // TODO
+    /// Returns if the capsule can be supported via `updateCapsule`
+    queryCapsuleCapabilities: fn (capsule_header_array: **CapsuleHeader, capsule_count: usize, maximum_capsule_size: *usize, resetType: ResetType) callconv(.C) Status,
+
+    /// Returns information about the EFI variables
+    queryVariableInfo: fn (attributes: *u32, maximum_variable_storage_size: *u64, remaining_variable_storage_size: *u64, maximum_variable_size: *u64) callconv(.C) Status,
 
     pub const signature: u64 = 0x56524553544e5552;
 };
 
+const EfiPhysicalAddress = u64;
+
+pub const CapsuleHeader = extern struct {
+    capsuleGuid: Guid align(8),
+    headerSize: u32,
+    flags: u32,
+    capsuleImageSize: u32,
+};
+
+pub const UefiCapsuleBlockDescriptor = extern struct {
+    length: u64,
+    address: union {
+        dataBlock: EfiPhysicalAddress,
+        continuationPointer: EfiPhysicalAddress,
+    },
+};
+
 pub const ResetType = enum(u32) {
     ResetCold,
     ResetWarm,