Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.os.uefi: use std.os.uefi.cc instead of .C as calling convention #16339

Merged
merged 2 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/std/os/uefi.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ pub var system_table: *tables.SystemTable = undefined;
/// A handle to an event structure.
pub const Event = *opaque {};

/// The calling convention used for all external functions part of the UEFI API.
pub const cc = switch (@import("builtin").target.cpu.arch) {
.x86_64 => .Win64,
else => .C,
};

pub const MacAddress = extern struct {
address: [32]u8,
};
Expand Down
5 changes: 3 additions & 2 deletions lib/std/os/uefi/protocols/absolute_pointer_protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ const uefi = std.os.uefi;
const Event = uefi.Event;
const Guid = uefi.Guid;
const Status = uefi.Status;
const cc = uefi.cc;

/// Protocol for touchscreens
pub const AbsolutePointerProtocol = extern struct {
_reset: *const fn (*const AbsolutePointerProtocol, bool) callconv(.C) Status,
_get_state: *const fn (*const AbsolutePointerProtocol, *AbsolutePointerState) callconv(.C) Status,
_reset: *const fn (*const AbsolutePointerProtocol, bool) callconv(cc) Status,
_get_state: *const fn (*const AbsolutePointerProtocol, *AbsolutePointerState) callconv(cc) Status,
wait_for_input: Event,
mode: *AbsolutePointerMode,

Expand Down
9 changes: 5 additions & 4 deletions lib/std/os/uefi/protocols/block_io_protocol.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const std = @import("std");
const uefi = std.os.uefi;
const Status = uefi.Status;
const cc = uefi.cc;

pub const EfiBlockMedia = extern struct {
/// The current media ID. If the media changes, this value is changed.
Expand Down Expand Up @@ -44,10 +45,10 @@ pub const BlockIoProtocol = extern struct {
revision: u64,
media: *EfiBlockMedia,

_reset: *const fn (*BlockIoProtocol, extended_verification: bool) callconv(.C) Status,
_read_blocks: *const fn (*BlockIoProtocol, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) callconv(.C) Status,
_write_blocks: *const fn (*BlockIoProtocol, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) callconv(.C) Status,
_flush_blocks: *const fn (*BlockIoProtocol) callconv(.C) Status,
_reset: *const fn (*BlockIoProtocol, extended_verification: bool) callconv(cc) Status,
_read_blocks: *const fn (*BlockIoProtocol, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) callconv(cc) Status,
_write_blocks: *const fn (*BlockIoProtocol, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) callconv(cc) Status,
_flush_blocks: *const fn (*BlockIoProtocol) callconv(cc) Status,

/// Resets the block device hardware.
pub fn reset(self: *Self, extended_verification: bool) Status {
Expand Down
3 changes: 2 additions & 1 deletion lib/std/os/uefi/protocols/edid_override_protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ const uefi = std.os.uefi;
const Guid = uefi.Guid;
const Handle = uefi.Handle;
const Status = uefi.Status;
const cc = uefi.cc;

/// Override EDID information
pub const EdidOverrideProtocol = extern struct {
_get_edid: *const fn (*const EdidOverrideProtocol, Handle, *EdidOverrideProtocolAttributes, *usize, *?[*]u8) callconv(.C) Status,
_get_edid: *const fn (*const EdidOverrideProtocol, Handle, *EdidOverrideProtocolAttributes, *usize, *?[*]u8) callconv(cc) Status,

/// Returns policy information and potentially a replacement EDID for the specified video output device.
pub fn getEdid(
Expand Down
21 changes: 11 additions & 10 deletions lib/std/os/uefi/protocols/file_protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ const io = std.io;
const Guid = uefi.Guid;
const Time = uefi.Time;
const Status = uefi.Status;
const cc = uefi.cc;

pub const FileProtocol = extern struct {
revision: u64,
_open: *const fn (*const FileProtocol, **const FileProtocol, [*:0]const u16, u64, u64) callconv(.C) Status,
_close: *const fn (*const FileProtocol) callconv(.C) Status,
_delete: *const fn (*const FileProtocol) callconv(.C) Status,
_read: *const fn (*const FileProtocol, *usize, [*]u8) callconv(.C) Status,
_write: *const fn (*const FileProtocol, *usize, [*]const u8) callconv(.C) Status,
_get_position: *const fn (*const FileProtocol, *u64) callconv(.C) Status,
_set_position: *const fn (*const FileProtocol, u64) callconv(.C) Status,
_get_info: *const fn (*const FileProtocol, *align(8) const Guid, *const usize, [*]u8) callconv(.C) Status,
_set_info: *const fn (*const FileProtocol, *align(8) const Guid, usize, [*]const u8) callconv(.C) Status,
_flush: *const fn (*const FileProtocol) callconv(.C) Status,
_open: *const fn (*const FileProtocol, **const FileProtocol, [*:0]const u16, u64, u64) callconv(cc) Status,
_close: *const fn (*const FileProtocol) callconv(cc) Status,
_delete: *const fn (*const FileProtocol) callconv(cc) Status,
_read: *const fn (*const FileProtocol, *usize, [*]u8) callconv(cc) Status,
_write: *const fn (*const FileProtocol, *usize, [*]const u8) callconv(cc) Status,
_get_position: *const fn (*const FileProtocol, *u64) callconv(cc) Status,
_set_position: *const fn (*const FileProtocol, u64) callconv(cc) Status,
_get_info: *const fn (*const FileProtocol, *align(8) const Guid, *const usize, [*]u8) callconv(cc) Status,
_set_info: *const fn (*const FileProtocol, *align(8) const Guid, usize, [*]const u8) callconv(cc) Status,
_flush: *const fn (*const FileProtocol) callconv(cc) Status,

pub const SeekError = error{SeekError};
pub const GetSeekPosError = error{GetSeekPosError};
Expand Down
7 changes: 4 additions & 3 deletions lib/std/os/uefi/protocols/graphics_output_protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ const std = @import("std");
const uefi = std.os.uefi;
const Guid = uefi.Guid;
const Status = uefi.Status;
const cc = uefi.cc;

/// Graphics output
pub const GraphicsOutputProtocol = extern struct {
_query_mode: *const fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) callconv(.C) Status,
_set_mode: *const fn (*const GraphicsOutputProtocol, u32) callconv(.C) Status,
_blt: *const fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) callconv(.C) Status,
_query_mode: *const fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) callconv(cc) Status,
_set_mode: *const fn (*const GraphicsOutputProtocol, u32) callconv(cc) Status,
_blt: *const fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) callconv(cc) Status,
mode: *GraphicsOutputProtocolMode,

/// Returns information for an available graphics mode that the graphics device and the set of active video output devices supports.
Expand Down
9 changes: 5 additions & 4 deletions lib/std/os/uefi/protocols/hii_database_protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ const uefi = std.os.uefi;
const Guid = uefi.Guid;
const Status = uefi.Status;
const hii = uefi.protocols.hii;
const cc = uefi.cc;

/// Database manager for HII-related data structures.
pub const HIIDatabaseProtocol = extern struct {
_new_package_list: Status, // TODO
_remove_package_list: *const fn (*const HIIDatabaseProtocol, hii.HIIHandle) callconv(.C) Status,
_update_package_list: *const fn (*const HIIDatabaseProtocol, hii.HIIHandle, *const hii.HIIPackageList) callconv(.C) Status,
_list_package_lists: *const fn (*const HIIDatabaseProtocol, u8, ?*const Guid, *usize, [*]hii.HIIHandle) callconv(.C) Status,
_export_package_lists: *const fn (*const HIIDatabaseProtocol, ?hii.HIIHandle, *usize, *hii.HIIPackageList) callconv(.C) Status,
_remove_package_list: *const fn (*const HIIDatabaseProtocol, hii.HIIHandle) callconv(cc) Status,
_update_package_list: *const fn (*const HIIDatabaseProtocol, hii.HIIHandle, *const hii.HIIPackageList) callconv(cc) Status,
_list_package_lists: *const fn (*const HIIDatabaseProtocol, u8, ?*const Guid, *usize, [*]hii.HIIHandle) callconv(cc) Status,
_export_package_lists: *const fn (*const HIIDatabaseProtocol, ?hii.HIIHandle, *usize, *hii.HIIPackageList) callconv(cc) Status,
_register_package_notify: Status, // TODO
_unregister_package_notify: Status, // TODO
_find_keyboard_layouts: Status, // TODO
Expand Down
3 changes: 2 additions & 1 deletion lib/std/os/uefi/protocols/hii_popup_protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ const uefi = std.os.uefi;
const Guid = uefi.Guid;
const Status = uefi.Status;
const hii = uefi.protocols.hii;
const cc = uefi.cc;

/// Display a popup window
pub const HIIPopupProtocol = extern struct {
revision: u64,
_create_popup: *const fn (*const HIIPopupProtocol, HIIPopupStyle, HIIPopupType, hii.HIIHandle, u16, ?*HIIPopupSelection) callconv(.C) Status,
_create_popup: *const fn (*const HIIPopupProtocol, HIIPopupStyle, HIIPopupType, hii.HIIHandle, u16, ?*HIIPopupSelection) callconv(cc) Status,

/// Displays a popup window.
pub fn createPopup(self: *const HIIPopupProtocol, style: HIIPopupStyle, popup_type: HIIPopupType, handle: hii.HIIHandle, msg: u16, user_selection: ?*HIIPopupSelection) Status {
Expand Down
9 changes: 5 additions & 4 deletions lib/std/os/uefi/protocols/ip6_config_protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ const uefi = std.os.uefi;
const Guid = uefi.Guid;
const Event = uefi.Event;
const Status = uefi.Status;
const cc = uefi.cc;

pub const Ip6ConfigProtocol = extern struct {
_set_data: *const fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, usize, *const anyopaque) callconv(.C) Status,
_get_data: *const fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, *usize, ?*const anyopaque) callconv(.C) Status,
_register_data_notify: *const fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) callconv(.C) Status,
_unregister_data_notify: *const fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) callconv(.C) Status,
_set_data: *const fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, usize, *const anyopaque) callconv(cc) Status,
_get_data: *const fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, *usize, ?*const anyopaque) callconv(cc) Status,
_register_data_notify: *const fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) callconv(cc) Status,
_unregister_data_notify: *const fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) callconv(cc) Status,

pub fn setData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: usize, data: *const anyopaque) Status {
return self._set_data(self, data_type, data_size, data);
Expand Down
19 changes: 10 additions & 9 deletions lib/std/os/uefi/protocols/ip6_protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ const Status = uefi.Status;
const MacAddress = uefi.protocols.MacAddress;
const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData;
const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
const cc = uefi.cc;

pub const Ip6Protocol = extern struct {
_get_mode_data: *const fn (*const Ip6Protocol, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(.C) Status,
_configure: *const fn (*const Ip6Protocol, ?*const Ip6ConfigData) callconv(.C) Status,
_groups: *const fn (*const Ip6Protocol, bool, ?*const Ip6Address) callconv(.C) Status,
_routes: *const fn (*const Ip6Protocol, bool, ?*const Ip6Address, u8, ?*const Ip6Address) callconv(.C) Status,
_neighbors: *const fn (*const Ip6Protocol, bool, *const Ip6Address, ?*const MacAddress, u32, bool) callconv(.C) Status,
_transmit: *const fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(.C) Status,
_receive: *const fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(.C) Status,
_cancel: *const fn (*const Ip6Protocol, ?*Ip6CompletionToken) callconv(.C) Status,
_poll: *const fn (*const Ip6Protocol) callconv(.C) Status,
_get_mode_data: *const fn (*const Ip6Protocol, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(cc) Status,
_configure: *const fn (*const Ip6Protocol, ?*const Ip6ConfigData) callconv(cc) Status,
_groups: *const fn (*const Ip6Protocol, bool, ?*const Ip6Address) callconv(cc) Status,
_routes: *const fn (*const Ip6Protocol, bool, ?*const Ip6Address, u8, ?*const Ip6Address) callconv(cc) Status,
_neighbors: *const fn (*const Ip6Protocol, bool, *const Ip6Address, ?*const MacAddress, u32, bool) callconv(cc) Status,
_transmit: *const fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(cc) Status,
_receive: *const fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(cc) Status,
_cancel: *const fn (*const Ip6Protocol, ?*Ip6CompletionToken) callconv(cc) Status,
_poll: *const fn (*const Ip6Protocol) callconv(cc) Status,

/// Gets the current operational settings for this instance of the EFI IPv6 Protocol driver.
pub fn getModeData(self: *const Ip6Protocol, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {
Expand Down
5 changes: 3 additions & 2 deletions lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ const uefi = std.os.uefi;
const Handle = uefi.Handle;
const Guid = uefi.Guid;
const Status = uefi.Status;
const cc = uefi.cc;

pub const Ip6ServiceBindingProtocol = extern struct {
_create_child: *const fn (*const Ip6ServiceBindingProtocol, *?Handle) callconv(.C) Status,
_destroy_child: *const fn (*const Ip6ServiceBindingProtocol, Handle) callconv(.C) Status,
_create_child: *const fn (*const Ip6ServiceBindingProtocol, *?Handle) callconv(cc) Status,
_destroy_child: *const fn (*const Ip6ServiceBindingProtocol, Handle) callconv(cc) Status,

pub fn createChild(self: *const Ip6ServiceBindingProtocol, handle: *?Handle) Status {
return self._create_child(self, handle);
Expand Down
3 changes: 2 additions & 1 deletion lib/std/os/uefi/protocols/loaded_image_protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const Status = uefi.Status;
const SystemTable = uefi.tables.SystemTable;
const MemoryType = uefi.tables.MemoryType;
const DevicePathProtocol = uefi.protocols.DevicePathProtocol;
const cc = uefi.cc;

pub const LoadedImageProtocol = extern struct {
revision: u32,
Expand All @@ -20,7 +21,7 @@ pub const LoadedImageProtocol = extern struct {
image_size: u64,
image_code_type: MemoryType,
image_data_type: MemoryType,
_unload: *const fn (*const LoadedImageProtocol, Handle) callconv(.C) Status,
_unload: *const fn (*const LoadedImageProtocol, Handle) callconv(cc) Status,

/// Unloads an image from memory.
pub fn unload(self: *const LoadedImageProtocol, handle: Handle) Status {
Expand Down
17 changes: 9 additions & 8 deletions lib/std/os/uefi/protocols/managed_network_protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ const Status = uefi.Status;
const Time = uefi.Time;
const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
const MacAddress = uefi.protocols.MacAddress;
const cc = uefi.cc;

pub const ManagedNetworkProtocol = extern struct {
_get_mode_data: *const fn (*const ManagedNetworkProtocol, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(.C) Status,
_configure: *const fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkConfigData) callconv(.C) Status,
_mcast_ip_to_mac: *const fn (*const ManagedNetworkProtocol, bool, *const anyopaque, *MacAddress) callconv(.C) Status,
_groups: *const fn (*const ManagedNetworkProtocol, bool, ?*const MacAddress) callconv(.C) Status,
_transmit: *const fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) callconv(.C) Status,
_receive: *const fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) callconv(.C) Status,
_cancel: *const fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkCompletionToken) callconv(.C) Status,
_poll: *const fn (*const ManagedNetworkProtocol) callconv(.C) Status,
_get_mode_data: *const fn (*const ManagedNetworkProtocol, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(cc) Status,
_configure: *const fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkConfigData) callconv(cc) Status,
_mcast_ip_to_mac: *const fn (*const ManagedNetworkProtocol, bool, *const anyopaque, *MacAddress) callconv(cc) Status,
_groups: *const fn (*const ManagedNetworkProtocol, bool, ?*const MacAddress) callconv(cc) Status,
_transmit: *const fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) callconv(cc) Status,
_receive: *const fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) callconv(cc) Status,
_cancel: *const fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkCompletionToken) callconv(cc) Status,
_poll: *const fn (*const ManagedNetworkProtocol) callconv(cc) Status,

/// Returns the operational parameters for the current MNP child driver.
/// May also support returning the underlying SNP driver mode data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ const uefi = std.os.uefi;
const Handle = uefi.Handle;
const Guid = uefi.Guid;
const Status = uefi.Status;
const cc = uefi.cc;

pub const ManagedNetworkServiceBindingProtocol = extern struct {
_create_child: *const fn (*const ManagedNetworkServiceBindingProtocol, *?Handle) callconv(.C) Status,
_destroy_child: *const fn (*const ManagedNetworkServiceBindingProtocol, Handle) callconv(.C) Status,
_create_child: *const fn (*const ManagedNetworkServiceBindingProtocol, *?Handle) callconv(cc) Status,
_destroy_child: *const fn (*const ManagedNetworkServiceBindingProtocol, Handle) callconv(cc) Status,

pub fn createChild(self: *const ManagedNetworkServiceBindingProtocol, handle: *?Handle) Status {
return self._create_child(self, handle);
Expand Down
5 changes: 3 additions & 2 deletions lib/std/os/uefi/protocols/rng_protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ const std = @import("std");
const uefi = std.os.uefi;
const Guid = uefi.Guid;
const Status = uefi.Status;
const cc = uefi.cc;

/// Random Number Generator protocol
pub const RNGProtocol = extern struct {
_get_info: *const fn (*const RNGProtocol, *usize, [*]align(8) Guid) callconv(.C) Status,
_get_rng: *const fn (*const RNGProtocol, ?*align(8) const Guid, usize, [*]u8) callconv(.C) Status,
_get_info: *const fn (*const RNGProtocol, *usize, [*]align(8) Guid) callconv(cc) Status,
_get_rng: *const fn (*const RNGProtocol, ?*align(8) const Guid, usize, [*]u8) callconv(cc) Status,

/// Returns information about the random number generation implementation.
pub fn getInfo(self: *const RNGProtocol, list_size: *usize, list: [*]align(8) Guid) Status {
Expand Down
3 changes: 2 additions & 1 deletion lib/std/os/uefi/protocols/simple_file_system_protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ const uefi = std.os.uefi;
const Guid = uefi.Guid;
const FileProtocol = uefi.protocols.FileProtocol;
const Status = uefi.Status;
const cc = uefi.cc;

pub const SimpleFileSystemProtocol = extern struct {
revision: u64,
_open_volume: *const fn (*const SimpleFileSystemProtocol, **const FileProtocol) callconv(.C) Status,
_open_volume: *const fn (*const SimpleFileSystemProtocol, **const FileProtocol) callconv(cc) Status,

pub fn openVolume(self: *const SimpleFileSystemProtocol, root: **const FileProtocol) Status {
return self._open_volume(self, root);
Expand Down
Loading