aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/os')
-rw-r--r--lib/std/os/bits/darwin.zig3
-rw-r--r--lib/std/os/bits/dragonfly.zig4
-rw-r--r--lib/std/os/bits/freebsd.zig3
-rw-r--r--lib/std/os/bits/linux.zig18
-rw-r--r--lib/std/os/bits/linux/netlink.zig498
-rw-r--r--lib/std/os/bits/linux/x86_64.zig3
-rw-r--r--lib/std/os/bits/netbsd.zig3
-rw-r--r--lib/std/os/bits/wasi.zig1
-rw-r--r--lib/std/os/bits/windows.zig1
-rw-r--r--lib/std/os/linux.zig66
-rw-r--r--lib/std/os/test.zig43
-rw-r--r--lib/std/os/uefi.zig15
-rw-r--r--lib/std/os/uefi/protocols.zig15
-rw-r--r--lib/std/os/uefi/protocols/absolute_pointer_protocol.zig9
-rw-r--r--lib/std/os/uefi/protocols/device_path_protocol.zig340
-rw-r--r--lib/std/os/uefi/protocols/edid_override_protocol.zig5
-rw-r--r--lib/std/os/uefi/protocols/file_protocol.zig91
-rw-r--r--lib/std/os/uefi/protocols/graphics_output_protocol.zig13
-rw-r--r--lib/std/os/uefi/protocols/hii_database_protocol.zig31
-rw-r--r--lib/std/os/uefi/protocols/hii_popup_protocol.zig5
-rw-r--r--lib/std/os/uefi/protocols/ip6_config_protocol.zig17
-rw-r--r--lib/std/os/uefi/protocols/ip6_protocol.zig39
-rw-r--r--lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig9
-rw-r--r--lib/std/os/uefi/protocols/loaded_image_protocol.zig16
-rw-r--r--lib/std/os/uefi/protocols/managed_network_protocol.zig33
-rw-r--r--lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig9
-rw-r--r--lib/std/os/uefi/protocols/rng_protocol.zig9
-rw-r--r--lib/std/os/uefi/protocols/shell_parameters_protocol.zig20
-rw-r--r--lib/std/os/uefi/protocols/simple_file_system_protocol.zig22
-rw-r--r--lib/std/os/uefi/protocols/simple_network_protocol.zig53
-rw-r--r--lib/std/os/uefi/protocols/simple_pointer_protocol.zig9
-rw-r--r--lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig21
-rw-r--r--lib/std/os/uefi/protocols/simple_text_input_protocol.zig8
-rw-r--r--lib/std/os/uefi/protocols/simple_text_output_protocol.zig37
-rw-r--r--lib/std/os/uefi/protocols/udp6_protocol.zig33
-rw-r--r--lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig9
-rw-r--r--lib/std/os/uefi/status.zig182
-rw-r--r--lib/std/os/uefi/tables.zig1
-rw-r--r--lib/std/os/uefi/tables/boot_services.zig126
-rw-r--r--lib/std/os/uefi/tables/runtime_services.zig29
-rw-r--r--lib/std/os/windows.zig3
-rw-r--r--lib/std/os/windows/bits.zig4
-rw-r--r--lib/std/os/windows/kernel32.zig1
-rw-r--r--lib/std/os/windows/ntdll.zig7
44 files changed, 1518 insertions, 346 deletions
diff --git a/lib/std/os/bits/darwin.zig b/lib/std/os/bits/darwin.zig
index fb933c6698..6808af0315 100644
--- a/lib/std/os/bits/darwin.zig
+++ b/lib/std/os/bits/darwin.zig
@@ -53,6 +53,7 @@ pub const mach_timebase_info_data = extern struct {
};
pub const off_t = i64;
+pub const ino_t = u64;
/// Renamed to Stat to not conflict with the stat function.
/// atime, mtime, and ctime have functions to return `timespec`,
@@ -64,7 +65,7 @@ pub const Stat = extern struct {
dev: i32,
mode: u16,
nlink: u16,
- ino: u64,
+ ino: ino_t,
uid: u32,
gid: u32,
rdev: i32,
diff --git a/lib/std/os/bits/dragonfly.zig b/lib/std/os/bits/dragonfly.zig
index c6c23affa7..27b2733b76 100644
--- a/lib/std/os/bits/dragonfly.zig
+++ b/lib/std/os/bits/dragonfly.zig
@@ -138,8 +138,10 @@ pub const MAP_SIZEALIGN = 262144;
pub const PATH_MAX = 1024;
+pub const ino_t = c_ulong;
+
pub const Stat = extern struct {
- ino: c_ulong,
+ ino: ino_t,
nlink: c_uint,
dev: c_uint,
mode: c_ushort,
diff --git a/lib/std/os/bits/freebsd.zig b/lib/std/os/bits/freebsd.zig
index b7d14934f5..02fe7e75b3 100644
--- a/lib/std/os/bits/freebsd.zig
+++ b/lib/std/os/bits/freebsd.zig
@@ -98,6 +98,7 @@ pub const msghdr_const = extern struct {
};
pub const off_t = i64;
+pub const ino_t = u64;
/// Renamed to Stat to not conflict with the stat function.
/// atime, mtime, and ctime have functions to return `timespec`,
@@ -107,7 +108,7 @@ pub const off_t = i64;
/// methods to accomplish this.
pub const Stat = extern struct {
dev: u64,
- ino: u64,
+ ino: ino_t,
nlink: usize,
mode: u16,
diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig
index c5a9a7d774..2a58c14490 100644
--- a/lib/std/os/bits/linux.zig
+++ b/lib/std/os/bits/linux.zig
@@ -18,6 +18,8 @@ pub usingnamespace switch (builtin.arch) {
else => struct {},
};
+pub usingnamespace @import("linux/netlink.zig");
+
const is_mips = builtin.arch.isMIPS();
pub const pid_t = i32;
@@ -30,6 +32,10 @@ pub const NAME_MAX = 255;
pub const PATH_MAX = 4096;
pub const IOV_MAX = 1024;
+/// Largest hardware address length
+/// e.g. a mac address is a type of hardware address
+pub const MAX_ADDR_LEN = 32;
+
pub const STDIN_FILENO = 0;
pub const STDOUT_FILENO = 1;
pub const STDERR_FILENO = 2;
@@ -1290,12 +1296,12 @@ pub const io_uring_files_update = struct {
};
pub const utsname = extern struct {
- sysname: [65]u8,
- nodename: [65]u8,
- release: [65]u8,
- version: [65]u8,
- machine: [65]u8,
- domainname: [65]u8,
+ sysname: [64:0]u8,
+ nodename: [64:0]u8,
+ release: [64:0]u8,
+ version: [64:0]u8,
+ machine: [64:0]u8,
+ domainname: [64:0]u8,
};
pub const HOST_NAME_MAX = 64;
diff --git a/lib/std/os/bits/linux/netlink.zig b/lib/std/os/bits/linux/netlink.zig
new file mode 100644
index 0000000000..b40308d6fc
--- /dev/null
+++ b/lib/std/os/bits/linux/netlink.zig
@@ -0,0 +1,498 @@
+usingnamespace @import("../linux.zig");
+
+/// Routing/device hook
+pub const NETLINK_ROUTE = 0;
+
+/// Unused number
+pub const NETLINK_UNUSED = 1;
+
+/// Reserved for user mode socket protocols
+pub const NETLINK_USERSOCK = 2;
+
+/// Unused number, formerly ip_queue
+pub const NETLINK_FIREWALL = 3;
+
+/// socket monitoring
+pub const NETLINK_SOCK_DIAG = 4;
+
+/// netfilter/iptables ULOG
+pub const NETLINK_NFLOG = 5;
+
+/// ipsec
+pub const NETLINK_XFRM = 6;
+
+/// SELinux event notifications
+pub const NETLINK_SELINUX = 7;
+
+/// Open-iSCSI
+pub const NETLINK_ISCSI = 8;
+
+/// auditing
+pub const NETLINK_AUDIT = 9;
+
+pub const NETLINK_FIB_LOOKUP = 10;
+
+pub const NETLINK_CONNECTOR = 11;
+
+/// netfilter subsystem
+pub const NETLINK_NETFILTER = 12;
+
+pub const NETLINK_IP6_FW = 13;
+
+/// DECnet routing messages
+pub const NETLINK_DNRTMSG = 14;
+
+/// Kernel messages to userspace
+pub const NETLINK_KOBJECT_UEVENT = 15;
+
+pub const NETLINK_GENERIC = 16;
+
+// leave room for NETLINK_DM (DM Events)
+
+/// SCSI Transports
+pub const NETLINK_SCSITRANSPORT = 18;
+
+pub const NETLINK_ECRYPTFS = 19;
+
+pub const NETLINK_RDMA = 20;
+
+/// Crypto layer
+pub const NETLINK_CRYPTO = 21;
+
+/// SMC monitoring
+pub const NETLINK_SMC = 22;
+
+// Flags values
+
+/// It is request message.
+pub const NLM_F_REQUEST = 0x01;
+
+/// Multipart message, terminated by NLMSG_DONE
+pub const NLM_F_MULTI = 0x02;
+
+/// Reply with ack, with zero or error code
+pub const NLM_F_ACK = 0x04;
+
+/// Echo this request
+pub const NLM_F_ECHO = 0x08;
+
+/// Dump was inconsistent due to sequence change
+pub const NLM_F_DUMP_INTR = 0x10;
+
+/// Dump was filtered as requested
+pub const NLM_F_DUMP_FILTERED = 0x20;
+
+// Modifiers to GET request
+
+/// specify tree root
+pub const NLM_F_ROOT = 0x100;
+
+/// return all matching
+pub const NLM_F_MATCH = 0x200;
+
+/// atomic GET
+pub const NLM_F_ATOMIC = 0x400;
+pub const NLM_F_DUMP = NLM_F_ROOT | NLM_F_MATCH;
+
+// Modifiers to NEW request
+
+/// Override existing
+pub const NLM_F_REPLACE = 0x100;
+
+/// Do not touch, if it exists
+pub const NLM_F_EXCL = 0x200;
+
+/// Create, if it does not exist
+pub const NLM_F_CREATE = 0x400;
+
+/// Add to end of list
+pub const NLM_F_APPEND = 0x800;
+
+// Modifiers to DELETE request
+
+/// Do not delete recursively
+pub const NLM_F_NONREC = 0x100;
+
+// Flags for ACK message
+
+/// request was capped
+pub const NLM_F_CAPPED = 0x100;
+
+/// extended ACK TVLs were included
+pub const NLM_F_ACK_TLVS = 0x200;
+
+pub const NetlinkMessageType = extern enum(u16) {
+ /// Nothing.
+ NOOP = 0x1,
+
+ /// Error
+ ERROR = 0x2,
+
+ /// End of a dump
+ DONE = 0x3,
+
+ /// Data lost
+ OVERRUN = 0x4,
+
+ /// < 0x10: reserved control messages
+ pub const MIN_TYPE = 0x10;
+
+ // rtlink types
+
+ RTM_NEWLINK = 16,
+ RTM_DELLINK,
+ RTM_GETLINK,
+ RTM_SETLINK,
+
+ RTM_NEWADDR = 20,
+ RTM_DELADDR,
+ RTM_GETADDR,
+
+ RTM_NEWROUTE = 24,
+ RTM_DELROUTE,
+ RTM_GETROUTE,
+
+ RTM_NEWNEIGH = 28,
+ RTM_DELNEIGH,
+ RTM_GETNEIGH,
+
+ RTM_NEWRULE = 32,
+ RTM_DELRULE,
+ RTM_GETRULE,
+
+ RTM_NEWQDISC = 36,
+ RTM_DELQDISC,
+ RTM_GETQDISC,
+
+ RTM_NEWTCLASS = 40,
+ RTM_DELTCLASS,
+ RTM_GETTCLASS,
+
+ RTM_NEWTFILTER = 44,
+ RTM_DELTFILTER,
+ RTM_GETTFILTER,
+
+ RTM_NEWACTION = 48,
+ RTM_DELACTION,
+ RTM_GETACTION,
+
+ RTM_NEWPREFIX = 52,
+
+ RTM_GETMULTICAST = 58,
+
+ RTM_GETANYCAST = 62,
+
+ RTM_NEWNEIGHTBL = 64,
+ RTM_GETNEIGHTBL = 66,
+ RTM_SETNEIGHTBL,
+
+ RTM_NEWNDUSEROPT = 68,
+
+ RTM_NEWADDRLABEL = 72,
+ RTM_DELADDRLABEL,
+ RTM_GETADDRLABEL,
+
+ RTM_GETDCB = 78,
+ RTM_SETDCB,
+
+ RTM_NEWNETCONF = 80,
+ RTM_DELNETCONF,
+ RTM_GETNETCONF = 82,
+
+ RTM_NEWMDB = 84,
+ RTM_DELMDB = 85,
+ RTM_GETMDB = 86,
+
+ RTM_NEWNSID = 88,
+ RTM_DELNSID = 89,
+ RTM_GETNSID = 90,
+
+ RTM_NEWSTATS = 92,
+ RTM_GETSTATS = 94,
+
+ RTM_NEWCACHEREPORT = 96,
+
+ RTM_NEWCHAIN = 100,
+ RTM_DELCHAIN,
+ RTM_GETCHAIN,
+
+ RTM_NEWNEXTHOP = 104,
+ RTM_DELNEXTHOP,
+ RTM_GETNEXTHOP,
+
+ _,
+};
+
+/// Netlink socket address
+pub const sockaddr_nl = extern struct {
+ family: sa_family_t = AF_NETLINK,
+ __pad1: c_ushort = 0,
+
+ /// port ID
+ pid: u32,
+
+ /// multicast groups mask
+ groups: u32,
+};
+
+/// Netlink message header
+/// Specified in RFC 3549 Section 2.3.2
+pub const nlmsghdr = extern struct {
+ /// Length of message including header
+ len: u32,
+
+ /// Message content
+ @"type": NetlinkMessageType,
+
+ /// Additional flags
+ flags: u16,
+
+ /// Sequence number
+ seq: u32,
+
+ /// Sending process port ID
+ pid: u32,
+};
+
+pub const ifinfomsg = extern struct {
+ family: u8,
+ __pad1: u8 = 0,
+
+ /// ARPHRD_*
+ @"type": c_ushort,
+
+ /// Link index
+ index: c_int,
+
+ /// IFF_* flags
+ flags: c_uint,
+
+ /// IFF_* change mask
+ /// is reserved for future use and should be always set to 0xFFFFFFFF.
+ change: c_uint = 0xFFFFFFFF,
+};
+
+pub const rtattr = extern struct {
+ /// Length of option
+ len: c_ushort,
+
+ /// Type of option
+ @"type": IFLA,
+
+ pub const ALIGNTO = 4;
+};
+
+pub const IFLA = extern enum(c_ushort) {
+ UNSPEC,
+ ADDRESS,
+ BROADCAST,
+ IFNAME,
+ MTU,
+ LINK,
+ QDISC,
+ STATS,
+ COST,
+ PRIORITY,
+ MASTER,
+
+ /// Wireless Extension event
+ WIRELESS,
+
+ /// Protocol specific information for a link
+ PROTINFO,
+
+ TXQLEN,
+ MAP,
+ WEIGHT,
+ OPERSTATE,
+ LINKMODE,
+ LINKINFO,
+ NET_NS_PID,
+ IFALIAS,
+
+ /// Number of VFs if device is SR-IOV PF
+ NUM_VF,
+
+ VFINFO_LIST,
+ STATS64,
+ VF_PORTS,
+ PORT_SELF,
+ AF_SPEC,
+
+ /// Group the device belongs to
+ GROUP,
+
+ NET_NS_FD,
+
+ /// Extended info mask, VFs, etc
+ EXT_MASK,
+
+ /// Promiscuity count: > 0 means acts PROMISC
+ PROMISCUITY,
+
+ NUM_TX_QUEUES,
+ NUM_RX_QUEUES,
+ CARRIER,
+ PHYS_PORT_ID,
+ CARRIER_CHANGES,
+ PHYS_SWITCH_ID,
+ LINK_NETNSID,
+ PHYS_PORT_NAME,
+ PROTO_DOWN,
+ GSO_MAX_SEGS,
+ GSO_MAX_SIZE,
+ PAD,
+ XDP,
+ EVENT,
+
+ NEW_NETNSID,
+ IF_NETNSID = 46,
+ TARGET_NETNSID = 46, // new alias
+
+ CARRIER_UP_COUNT,
+ CARRIER_DOWN_COUNT,
+ NEW_IFINDEX,
+ MIN_MTU,
+ MAX_MTU,
+
+ _,
+};
+
+pub const rtnl_link_ifmap = extern struct {
+ mem_start: u64,
+ mem_end: u64,
+ base_addr: u64,
+ irq: u16,
+ dma: u8,
+ port: u8,
+};
+
+pub const rtnl_link_stats = extern struct {
+ /// total packets received
+ rx_packets: u32,
+
+ /// total packets transmitted
+ tx_packets: u32,
+
+ /// total bytes received
+ rx_bytes: u32,
+
+ /// total bytes transmitted
+ tx_bytes: u32,
+
+ /// bad packets received
+ rx_errors: u32,
+
+ /// packet transmit problems
+ tx_errors: u32,
+
+ /// no space in linux buffers
+ rx_dropped: u32,
+
+ /// no space available in linux
+ tx_dropped: u32,
+
+ /// multicast packets received
+ multicast: u32,
+
+ collisions: u32,
+
+ // detailed rx_errors
+
+ rx_length_errors: u32,
+
+ /// receiver ring buff overflow
+ rx_over_errors: u32,
+
+ /// recved pkt with crc error
+ rx_crc_errors: u32,
+
+ /// recv'd frame alignment error
+ rx_frame_errors: u32,
+
+ /// recv'r fifo overrun
+ rx_fifo_errors: u32,
+
+ /// receiver missed packet
+ rx_missed_errors: u32,
+
+ // detailed tx_errors
+ tx_aborted_errors: u32,
+ tx_carrier_errors: u32,
+ tx_fifo_errors: u32,
+ tx_heartbeat_errors: u32,
+ tx_window_errors: u32,
+
+ // for cslip etc
+
+ rx_compressed: u32,
+ tx_compressed: u32,
+
+ /// dropped, no handler found
+ rx_nohandler: u32,
+};
+
+pub const rtnl_link_stats64 = extern struct {
+ /// total packets received
+ rx_packets: u64,
+
+ /// total packets transmitted
+ tx_packets: u64,
+
+ /// total bytes received
+ rx_bytes: u64,
+
+ /// total bytes transmitted
+ tx_bytes: u64,
+
+ /// bad packets received
+ rx_errors: u64,
+
+ /// packet transmit problems
+ tx_errors: u64,
+
+ /// no space in linux buffers
+ rx_dropped: u64,
+
+ /// no space available in linux
+ tx_dropped: u64,
+
+ /// multicast packets received
+ multicast: u64,
+
+ collisions: u64,
+
+ // detailed rx_errors
+
+ rx_length_errors: u64,
+
+ /// receiver ring buff overflow
+ rx_over_errors: u64,
+
+ /// recved pkt with crc error
+ rx_crc_errors: u64,
+
+ /// recv'd frame alignment error
+ rx_frame_errors: u64,
+
+ /// recv'r fifo overrun
+ rx_fifo_errors: u64,
+
+ /// receiver missed packet
+ rx_missed_errors: u64,
+
+ // detailed tx_errors
+ tx_aborted_errors: u64,
+ tx_carrier_errors: u64,
+ tx_fifo_errors: u64,
+ tx_heartbeat_errors: u64,
+ tx_window_errors: u64,
+
+ // for cslip etc
+
+ rx_compressed: u64,
+ tx_compressed: u64,
+
+ /// dropped, no handler found
+ rx_nohandler: u64,
+};
diff --git a/lib/std/os/bits/linux/x86_64.zig b/lib/std/os/bits/linux/x86_64.zig
index 608f74e2d3..e92591d94e 100644
--- a/lib/std/os/bits/linux/x86_64.zig
+++ b/lib/std/os/bits/linux/x86_64.zig
@@ -481,6 +481,7 @@ pub const msghdr_const = extern struct {
};
pub const off_t = i64;
+pub const ino_t = u64;
/// Renamed to Stat to not conflict with the stat function.
/// atime, mtime, and ctime have functions to return `timespec`,
@@ -490,7 +491,7 @@ pub const off_t = i64;
/// methods to accomplish this.
pub const Stat = extern struct {
dev: u64,
- ino: u64,
+ ino: ino_t,
nlink: usize,
mode: u32,
diff --git a/lib/std/os/bits/netbsd.zig b/lib/std/os/bits/netbsd.zig
index 89e0998d6d..735485695a 100644
--- a/lib/std/os/bits/netbsd.zig
+++ b/lib/std/os/bits/netbsd.zig
@@ -69,6 +69,7 @@ pub const msghdr_const = extern struct {
};
pub const off_t = i64;
+pub const ino_t = u64;
/// Renamed to Stat to not conflict with the stat function.
/// atime, mtime, and ctime have functions to return `timespec`,
@@ -79,7 +80,7 @@ pub const off_t = i64;
pub const Stat = extern struct {
dev: u64,
mode: u32,
- ino: u64,
+ ino: ino_t,
nlink: usize,
uid: u32,
diff --git a/lib/std/os/bits/wasi.zig b/lib/std/os/bits/wasi.zig
index f56e53504e..8fb85e1fcd 100644
--- a/lib/std/os/bits/wasi.zig
+++ b/lib/std/os/bits/wasi.zig
@@ -178,6 +178,7 @@ pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004;
pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008;
pub const inode_t = u64;
+pub const ino_t = inode_t;
pub const linkcount_t = u32;
diff --git a/lib/std/os/bits/windows.zig b/lib/std/os/bits/windows.zig
index ba2725e0a9..05486c8f7b 100644
--- a/lib/std/os/bits/windows.zig
+++ b/lib/std/os/bits/windows.zig
@@ -4,6 +4,7 @@ usingnamespace @import("../windows/bits.zig");
const ws2_32 = @import("../windows/ws2_32.zig");
pub const fd_t = HANDLE;
+pub const ino_t = LARGE_INTEGER;
pub const pid_t = HANDLE;
pub const mode_t = u0;
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig
index 719e541846..ba7356d62c 100644
--- a/lib/std/os/linux.zig
+++ b/lib/std/os/linux.zig
@@ -350,7 +350,13 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize {
);
}
} else {
- return syscall4(SYS_pread, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), count, offset);
+ return syscall4(
+ SYS_pread,
+ @bitCast(usize, @as(isize, fd)),
+ @ptrToInt(buf),
+ count,
+ offset,
+ );
}
}
@@ -384,8 +390,64 @@ pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {
return syscall3(SYS_write, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), count);
}
+pub fn ftruncate(fd: i32, length: u64) usize {
+ if (@hasDecl(@This(), "SYS_ftruncate64")) {
+ if (require_aligned_register_pair) {
+ return syscall4(
+ SYS_ftruncate64,
+ @bitCast(usize, @as(isize, fd)),
+ 0,
+ @truncate(usize, length),
+ @truncate(usize, length >> 32),
+ );
+ } else {
+ return syscall3(
+ SYS_ftruncate64,
+ @bitCast(usize, @as(isize, fd)),
+ @truncate(usize, length),
+ @truncate(usize, length >> 32),
+ );
+ }
+ } else {
+ return syscall2(
+ SYS_ftruncate,
+ @bitCast(usize, @as(isize, fd)),
+ @truncate(usize, length),
+ );
+ }
+}
+
pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: usize) usize {
- return syscall4(SYS_pwrite, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), count, offset);
+ if (@hasDecl(@This(), "SYS_pwrite64")) {
+ if (require_aligned_register_pair) {
+ return syscall6(
+ SYS_pwrite64,
+ @bitCast(usize, @as(isize, fd)),
+ @ptrToInt(buf),
+ count,
+ 0,
+ @truncate(usize, offset),
+ @truncate(usize, offset >> 32),
+ );
+ } else {
+ return syscall5(
+ SYS_pwrite64,
+ @bitCast(usize, @as(isize, fd)),
+ @ptrToInt(buf),
+ count,
+ @truncate(usize, offset),
+ @truncate(usize, offset >> 32),
+ );
+ }
+ } else {
+ return syscall4(
+ SYS_pwrite,
+ @bitCast(usize, @as(isize, fd)),
+ @ptrToInt(buf),
+ count,
+ offset,
+ );
+ }
}
pub fn rename(old: [*:0]const u8, new: [*:0]const u8) usize {
diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig
index 5f97597537..1ef6798b50 100644
--- a/lib/std/os/test.zig
+++ b/lib/std/os/test.zig
@@ -95,15 +95,41 @@ test "sendfile" {
},
};
- var written_buf: [header1.len + header2.len + 10 + trailer1.len + trailer2.len]u8 = undefined;
+ var written_buf: [100]u8 = undefined;
try dest_file.writeFileAll(src_file, .{
.in_offset = 1,
.in_len = 10,
.headers_and_trailers = &hdtr,
.header_count = 2,
});
- try dest_file.preadAll(&written_buf, 0);
- expect(mem.eql(u8, &written_buf, "header1\nsecond header\nine1\nsecontrailer1\nsecond trailer\n"));
+ const amt = try dest_file.preadAll(&written_buf, 0);
+ expect(mem.eql(u8, written_buf[0..amt], "header1\nsecond header\nine1\nsecontrailer1\nsecond trailer\n"));
+}
+
+test "fs.copyFile" {
+ const data = "u6wj+JmdF3qHsFPE BUlH2g4gJCmEz0PP";
+ const src_file = "tmp_test_copy_file.txt";
+ const dest_file = "tmp_test_copy_file2.txt";
+ const dest_file2 = "tmp_test_copy_file3.txt";
+
+ try fs.cwd().writeFile(src_file, data);
+ defer fs.cwd().deleteFile(src_file) catch {};
+
+ try fs.copyFile(src_file, dest_file);
+ defer fs.cwd().deleteFile(dest_file) catch {};
+
+ try fs.copyFileMode(src_file, dest_file2, File.default_mode);
+ defer fs.cwd().deleteFile(dest_file2) catch {};
+
+ try expectFileContents(dest_file, data);
+ try expectFileContents(dest_file2, data);
+}
+
+fn expectFileContents(file_path: []const u8, data: []const u8) !void {
+ const contents = try fs.cwd().readFileAlloc(testing.allocator, file_path, 1000);
+ defer testing.allocator.free(contents);
+
+ testing.expectEqualSlices(u8, data, contents);
}
test "std.Thread.getCurrentId" {
@@ -354,8 +380,7 @@ test "mmap" {
const file = try fs.cwd().createFile(test_out_file, .{});
defer file.close();
- var out_stream = file.outStream();
- const stream = &out_stream.stream;
+ const stream = file.outStream();
var i: u32 = 0;
while (i < alloc_size / @sizeOf(u32)) : (i += 1) {
@@ -378,8 +403,8 @@ test "mmap" {
);
defer os.munmap(data);
- var mem_stream = io.SliceInStream.init(data);
- const stream = &mem_stream.stream;
+ var mem_stream = io.fixedBufferStream(data);
+ const stream = mem_stream.inStream();
var i: u32 = 0;
while (i < alloc_size / @sizeOf(u32)) : (i += 1) {
@@ -402,8 +427,8 @@ test "mmap" {
);
defer os.munmap(data);
- var mem_stream = io.SliceInStream.init(data);
- const stream = &mem_stream.stream;
+ var mem_stream = io.fixedBufferStream(data);
+ const stream = mem_stream.inStream();
var i: u32 = alloc_size / 2 / @sizeOf(u32);
while (i < alloc_size / @sizeOf(u32)) : (i += 1) {
diff --git a/lib/std/os/uefi.zig b/lib/std/os/uefi.zig
index 81d13ac1c3..64ee81150e 100644
--- a/lib/std/os/uefi.zig
+++ b/lib/std/os/uefi.zig
@@ -2,11 +2,9 @@
pub const protocols = @import("uefi/protocols.zig");
/// Status codes returned by EFI interfaces
-pub const status = @import("uefi/status.zig");
+pub const Status = @import("uefi/status.zig").Status;
pub const tables = @import("uefi/tables.zig");
-const fmt = @import("std").fmt;
-
/// The EFI image's handle that is passed to its entry point.
pub var handle: Handle = undefined;
@@ -29,13 +27,11 @@ pub const Guid = extern struct {
pub fn format(
self: @This(),
comptime f: []const u8,
- options: fmt.FormatOptions,
- context: var,
- comptime Errors: type,
- output: fn (@TypeOf(context), []const u8) Errors!void,
+ options: std.fmt.FormatOptions,
+ out_stream: var,
) Errors!void {
if (f.len == 0) {
- return fmt.format(context, Errors, output, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{
+ return std.fmt.format(out_stream, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{
self.time_low,
self.time_mid,
self.time_high_and_version,
@@ -105,3 +101,6 @@ pub const TimeCapabilities = extern struct {
/// If true, a time set operation clears the device's time below the resolution level.
sets_to_zero: bool,
};
+
+/// File Handle as specified in the EFI Shell Spec
+pub const FileHandle = *@OpaqueType();
diff --git a/lib/std/os/uefi/protocols.zig b/lib/std/os/uefi/protocols.zig
index 58f342ac22..353c628a05 100644
--- a/lib/std/os/uefi/protocols.zig
+++ b/lib/std/os/uefi/protocols.zig
@@ -1,6 +1,19 @@
pub const LoadedImageProtocol = @import("protocols/loaded_image_protocol.zig").LoadedImageProtocol;
+pub const loaded_image_device_path_protocol_guid = @import("protocols/loaded_image_protocol.zig").loaded_image_device_path_protocol_guid;
+pub const AcpiDevicePath = @import("protocols/device_path_protocol.zig").AcpiDevicePath;
+pub const BiosBootSpecificationDevicePath = @import("protocols/device_path_protocol.zig").BiosBootSpecificationDevicePath;
+pub const DevicePath = @import("protocols/device_path_protocol.zig").DevicePath;
pub const DevicePathProtocol = @import("protocols/device_path_protocol.zig").DevicePathProtocol;
+pub const DevicePathType = @import("protocols/device_path_protocol.zig").DevicePathType;
+pub const EndDevicePath = @import("protocols/device_path_protocol.zig").EndDevicePath;
+pub const HardwareDevicePath = @import("protocols/device_path_protocol.zig").HardwareDevicePath;
+pub const MediaDevicePath = @import("protocols/device_path_protocol.zig").MediaDevicePath;
+pub const MessagingDevicePath = @import("protocols/device_path_protocol.zig").MessagingDevicePath;
+
+pub const SimpleFileSystemProtocol = @import("protocols/simple_file_system_protocol.zig").SimpleFileSystemProtocol;
+pub const FileProtocol = @import("protocols/file_protocol.zig").FileProtocol;
+pub const FileInfo = @import("protocols/file_protocol.zig").FileInfo;
pub const InputKey = @import("protocols/simple_text_input_ex_protocol.zig").InputKey;
pub const KeyData = @import("protocols/simple_text_input_ex_protocol.zig").KeyData;
@@ -82,3 +95,5 @@ pub const HIIPopupType = @import("protocols/hii_popup_protocol.zig").HIIPopupTyp
pub const HIIPopupSelection = @import("protocols/hii_popup_protocol.zig").HIIPopupSelection;
pub const RNGProtocol = @import("protocols/rng_protocol.zig").RNGProtocol;
+
+pub const ShellParametersProtocol = @import("protocols/shell_parameters_protocol.zig").ShellParametersProtocol;
diff --git a/lib/std/os/uefi/protocols/absolute_pointer_protocol.zig b/lib/std/os/uefi/protocols/absolute_pointer_protocol.zig
index 722972a202..1a46b9cf2c 100644
--- a/lib/std/os/uefi/protocols/absolute_pointer_protocol.zig
+++ b/lib/std/os/uefi/protocols/absolute_pointer_protocol.zig
@@ -1,21 +1,22 @@
const uefi = @import("std").os.uefi;
const Event = uefi.Event;
const Guid = uefi.Guid;
+const Status = uefi.Status;
/// Protocol for touchscreens
pub const AbsolutePointerProtocol = extern struct {
- _reset: extern fn (*const AbsolutePointerProtocol, bool) usize,
- _get_state: extern fn (*const AbsolutePointerProtocol, *AbsolutePointerState) usize,
+ _reset: extern fn (*const AbsolutePointerProtocol, bool) Status,
+ _get_state: extern fn (*const AbsolutePointerProtocol, *AbsolutePointerState) Status,
wait_for_input: Event,
mode: *AbsolutePointerMode,
/// Resets the pointer device hardware.
- pub fn reset(self: *const AbsolutePointerProtocol, verify: bool) usize {
+ pub fn reset(self: *const AbsolutePointerProtocol, verify: bool) Status {
return self._reset(self, verify);
}
/// Retrieves the current state of a pointer device.
- pub fn getState(self: *const AbsolutePointerProtocol, state: *AbsolutePointerState) usize {
+ pub fn getState(self: *const AbsolutePointerProtocol, state: *AbsolutePointerState) Status {
return self._get_state(self, state);
}
diff --git a/lib/std/os/uefi/protocols/device_path_protocol.zig b/lib/std/os/uefi/protocols/device_path_protocol.zig
index a945608f88..f359484eb9 100644
--- a/lib/std/os/uefi/protocols/device_path_protocol.zig
+++ b/lib/std/os/uefi/protocols/device_path_protocol.zig
@@ -1,8 +1,8 @@
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
-pub const DevicePathProtocol = extern struct {
- type: u8,
+pub const DevicePathProtocol = packed struct {
+ type: DevicePathType,
subtype: u8,
length: u16,
@@ -14,4 +14,340 @@ pub const DevicePathProtocol = extern struct {
.clock_seq_low = 0x39,
.node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
};
+
+ pub fn getDevicePath(self: *const DevicePathProtocol) ?DevicePath {
+ return switch (self.type) {
+ .Hardware => blk: {
+ const hardware: ?HardwareDevicePath = switch (@intToEnum(HardwareDevicePath.Subtype, self.subtype)) {
+ .Pci => .{ .Pci = @ptrCast(*const HardwareDevicePath.PciDevicePath, self) },
+ .PcCard => .{ .PcCard = @ptrCast(*const HardwareDevicePath.PcCardDevicePath, self) },
+ .MemoryMapped => .{ .MemoryMapped = @ptrCast(*const HardwareDevicePath.MemoryMappedDevicePath, self) },
+ .Vendor => .{ .Vendor = @ptrCast(*const HardwareDevicePath.VendorDevicePath, self) },
+ .Controller => .{ .Controller = @ptrCast(*const HardwareDevicePath.ControllerDevicePath, self) },
+ .Bmc => .{ .Bmc = @ptrCast(*const HardwareDevicePath.BmcDevicePath, self) },
+ _ => null,
+ };
+ break :blk if (hardware) |h| .{ .Hardware = h } else null;
+ },
+ .Acpi => blk: {
+ const acpi: ?AcpiDevicePath = switch (@intToEnum(AcpiDevicePath.Subtype, self.subtype)) {
+ else => null, // TODO
+ };
+ break :blk if (acpi) |a| .{ .Acpi = a } else null;
+ },
+ .Messaging => blk: {
+ const messaging: ?MessagingDevicePath = switch (@intToEnum(MessagingDevicePath.Subtype, self.subtype)) {
+ else => null, // TODO
+ };
+ break :blk if (messaging) |m| .{ .Messaging = m } else null;
+ },
+ .Media => blk: {
+ const media: ?MediaDevicePath = switch (@intToEnum(MediaDevicePath.Subtype, self.subtype)) {
+ .HardDrive => .{ .HardDrive = @ptrCast(*const MediaDevicePath.HardDriveDevicePath, self) },
+ .Cdrom => .{ .Cdrom = @ptrCast(*const MediaDevicePath.CdromDevicePath, self) },
+ .Vendor => .{ .Vendor = @ptrCast(*const MediaDevicePath.VendorDevicePath, self) },
+ .FilePath => .{ .FilePath = @ptrCast(*const MediaDevicePath.FilePathDevicePath, self) },
+ .MediaProtocol => .{ .MediaProtocol = @ptrCast(*const MediaDevicePath.MediaProtocolDevicePath, self) },
+ .PiwgFirmwareFile => .{ .PiwgFirmwareFile = @ptrCast(*const MediaDevicePath.PiwgFirmwareFileDevicePath, self) },
+ .PiwgFirmwareVolume => .{ .PiwgFirmwareVolume = @ptrCast(*const MediaDevicePath.PiwgFirmwareVolumeDevicePath, self) },
+ .RelativeOffsetRange => .{ .RelativeOffsetRange = @ptrCast(*const MediaDevicePath.RelativeOffsetRangeDevicePath, self) },
+ .RamDisk => .{ .RamDisk = @ptrCast(*const MediaDevicePath.RamDiskDevicePath, self) },
+ _ => null,
+ };
+ break :blk if (media) |m| .{ .Media = m } else null;
+ },
+ .BiosBootSpecification => blk: {
+ const bbs: ?BiosBootSpecificationDevicePath = switch (@intToEnum(BiosBootSpecificationDevicePath.Subtype, self.subtype)) {
+ .BBS101 => .{ .BBS101 = @ptrCast(*const BiosBootSpecificationDevicePath.BBS101DevicePath, self) },
+ _ => null,
+ };
+ break :blk if (bbs) |b| .{ .BiosBootSpecification = b } else null;
+ },
+ .End => blk: {
+ const end: ?EndDevicePath = switch (@intToEnum(EndDevicePath.Subtype, self.subtype)) {
+ .EndEntire => .{ .EndEntire = @ptrCast(*const EndDevicePath.EndEntireDevicePath, self) },
+ .EndThisInstance => .{ .EndThisInstance = @ptrCast(*const EndDevicePath.EndThisInstanceDevicePath, self) },
+ _ => null,
+ };
+ break :blk if (end) |e| .{ .End = e } else null;
+ },
+ _ => null,
+ };
+ }
+};
+
+pub const DevicePath = union(DevicePathType) {
+ Hardware: HardwareDevicePath,
+ Acpi: AcpiDevicePath,
+ Messaging: MessagingDevicePath,
+ Media: MediaDevicePath,
+ BiosBootSpecification: BiosBootSpecificationDevicePath,
+ End: EndDevicePath,
+};
+
+pub const DevicePathType = extern enum(u8) {
+ Hardware = 0x01,
+ Acpi = 0x02,
+ Messaging = 0x03,
+ Media = 0x04,
+ BiosBootSpecification = 0x05,
+ End = 0x7f,
+ _,
+};
+
+pub const HardwareDevicePath = union(Subtype) {
+ Pci: *const PciDevicePath,
+ PcCard: *const PcCardDevicePath,
+ MemoryMapped: *const MemoryMappedDevicePath,
+ Vendor: *const VendorDevicePath,
+ Controller: *const ControllerDevicePath,
+ Bmc: *const BmcDevicePath,
+
+ pub const Subtype = extern enum(u8) {
+ Pci = 1,
+ PcCard = 2,
+ MemoryMapped = 3,
+ Vendor = 4,
+ Controller = 5,
+ Bmc = 6,
+ _,
+ };
+
+ pub const PciDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ // TODO
+ };
+
+ pub const PcCardDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ // TODO
+ };
+
+ pub const MemoryMappedDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ // TODO
+ };
+
+ pub const VendorDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ // TODO
+ };
+
+ pub const ControllerDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ // TODO
+ };
+
+ pub const BmcDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ // TODO
+ };
+};
+
+pub const AcpiDevicePath = union(Subtype) {
+ Acpi: void, // TODO
+ ExpandedAcpi: void, // TODO
+ Adr: void, // TODO
+ Nvdimm: void, // TODO
+
+ pub const Subtype = extern enum(u8) {
+ Acpi = 1,
+ ExpandedAcpi = 2,
+ Adr = 3,
+ Nvdimm = 4,
+ _,
+ };
+};
+
+pub const MessagingDevicePath = union(Subtype) {
+ Atapi: void, // TODO
+ Scsi: void, // TODO
+ FibreChannel: void, // TODO
+ FibreChannelEx: void, // TODO
+ @"1394": void, // TODO
+ Usb: void, // TODO
+ Sata: void, // TODO
+ UsbWwid: void, // TODO
+ Lun: void, // TODO
+ UsbClass: void, // TODO
+ I2o: void, // TODO
+ MacAddress: void, // TODO
+ Ipv4: void, // TODO
+ Ipv6: void, // TODO
+ Vlan: void, // TODO
+ InfiniBand: void, // TODO
+ Uart: void, // TODO
+ Vendor: void, // TODO
+
+ pub const Subtype = extern enum(u8) {
+ Atapi = 1,
+ Scsi = 2,
+ FibreChannel = 3,
+ FibreChannelEx = 21,
+ @"1394" = 4,
+ Usb = 5,
+ Sata = 18,
+ UsbWwid = 16,
+ Lun = 17,
+ UsbClass = 15,
+ I2o = 6,
+ MacAddress = 11,
+ Ipv4 = 12,
+ Ipv6 = 13,
+ Vlan = 20,
+ InfiniBand = 9,
+ Uart = 14,
+ Vendor = 10,
+ _,
+ };
+};
+
+pub const MediaDevicePath = union(Subtype) {
+ HardDrive: *const HardDriveDevicePath,
+ Cdrom: *const CdromDevicePath,
+ Vendor: *const VendorDevicePath,
+ FilePath: *const FilePathDevicePath,
+ MediaProtocol: *const MediaProtocolDevicePath,
+ PiwgFirmwareFile: *const PiwgFirmwareFileDevicePath,
+ PiwgFirmwareVolume: *const PiwgFirmwareVolumeDevicePath,
+ RelativeOffsetRange: *const RelativeOffsetRangeDevicePath,
+ RamDisk: *const RamDiskDevicePath,
+
+ pub const Subtype = extern enum(u8) {
+ HardDrive = 1,
+ Cdrom = 2,
+ Vendor = 3,
+ FilePath = 4,
+ MediaProtocol = 5,
+ PiwgFirmwareFile = 6,
+ PiwgFirmwareVolume = 7,
+ RelativeOffsetRange = 8,
+ RamDisk = 9,
+ _,
+ };
+
+ pub const HardDriveDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ // TODO
+ };
+
+ pub const CdromDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ // TODO
+ };
+
+ pub const VendorDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ // TODO
+ };
+
+ pub const FilePathDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+
+ pub fn getPath(self: *const FilePathDevicePath) [*:0]const u16 {
+ return @ptrCast([*:0]const u16, @alignCast(2, @ptrCast([*]const u8, self)) + @sizeOf(FilePathDevicePath));
+ }
+ };
+
+ pub const MediaProtocolDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ // TODO
+ };
+
+ pub const PiwgFirmwareFileDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ };
+
+ pub const PiwgFirmwareVolumeDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ };
+
+ pub const RelativeOffsetRangeDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ reserved: u32,
+ start: u64,
+ end: u64,
+ };
+
+ pub const RamDiskDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ start: u64,
+ end: u64,
+ disk_type: uefi.Guid,
+ instance: u16,
+ };
+};
+
+pub const BiosBootSpecificationDevicePath = union(Subtype) {
+ BBS101: *const BBS101DevicePath,
+
+ pub const Subtype = extern enum(u8) {
+ BBS101 = 1,
+ _,
+ };
+
+ pub const BBS101DevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ device_type: u16,
+ status_flag: u16,
+
+ pub fn getDescription(self: *const BBS101DevicePath) [*:0]const u8 {
+ return @ptrCast([*:0]const u8, self) + @sizeOf(BBS101DevicePath);
+ }
+ };
+};
+
+pub const EndDevicePath = union(Subtype) {
+ EndEntire: *const EndEntireDevicePath,
+ EndThisInstance: *const EndThisInstanceDevicePath,
+
+ pub const Subtype = extern enum(u8) {
+ EndEntire = 0xff,
+ EndThisInstance = 0x01,
+ _,
+ };
+
+ pub const EndEntireDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ };
+
+ pub const EndThisInstanceDevicePath = packed struct {
+ type: DevicePathType,
+ subtype: Subtype,
+ length: u16,
+ };
};
diff --git a/lib/std/os/uefi/protocols/edid_override_protocol.zig b/lib/std/os/uefi/protocols/edid_override_protocol.zig
index c11af8f0a1..2c37baa7a4 100644
--- a/lib/std/os/uefi/protocols/edid_override_protocol.zig
+++ b/lib/std/os/uefi/protocols/edid_override_protocol.zig
@@ -1,14 +1,15 @@
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
const Handle = uefi.Handle;
+const Status = uefi.Status;
/// Override EDID information
pub const EdidOverrideProtocol = extern struct {
- _get_edid: extern fn (*const EdidOverrideProtocol, Handle, *u32, *usize, *?[*]u8) usize,
+ _get_edid: extern fn (*const EdidOverrideProtocol, Handle, *u32, *usize, *?[*]u8) Status,
/// Returns policy information and potentially a replacement EDID for the specified video output device.
/// attributes must be align(4)
- pub fn getEdid(self: *const EdidOverrideProtocol, handle: Handle, attributes: *EdidOverrideProtocolAttributes, edid_size: *usize, edid: *?[*]u8) usize {
+ pub fn getEdid(self: *const EdidOverrideProtocol, handle: Handle, attributes: *EdidOverrideProtocolAttributes, edid_size: *usize, edid: *?[*]u8) Status {
return self._get_edid(self, handle, attributes, edid_size, edid);
}
diff --git a/lib/std/os/uefi/protocols/file_protocol.zig b/lib/std/os/uefi/protocols/file_protocol.zig
new file mode 100644
index 0000000000..fb5810d4f4
--- /dev/null
+++ b/lib/std/os/uefi/protocols/file_protocol.zig
@@ -0,0 +1,91 @@
+const uefi = @import("std").os.uefi;
+const Guid = uefi.Guid;
+const Time = uefi.Time;
+const Status = uefi.Status;
+
+pub const FileProtocol = extern struct {
+ revision: u64,
+ _open: extern fn (*const FileProtocol, **const FileProtocol, [*:0]const u16, u64, u64) Status,
+ _close: extern fn (*const FileProtocol) Status,
+ _delete: extern fn (*const FileProtocol) Status,
+ _read: extern fn (*const FileProtocol, *usize, [*]u8) Status,
+ _write: extern fn (*const FileProtocol, *usize, [*]const u8) Status,
+ _get_info: extern fn (*const FileProtocol, *Guid, *usize, *c_void) Status,
+ _set_info: extern fn (*const FileProtocol, *Guid, usize, *const c_void) Status,
+ _flush: extern fn (*const FileProtocol) Status,
+
+ pub fn open(self: *const FileProtocol, new_handle: **const FileProtocol, file_name: [*:0]const u16, open_mode: u64, attributes: u64) Status {
+ return self._open(self, new_handle, file_name, open_mode, attributes);
+ }
+
+ pub fn close(self: *const FileProtocol) Status {
+ return self._close(self);
+ }
+
+ pub fn delete(self: *const FileProtocol) Status {
+ return self._delete(self);
+ }
+
+ pub fn read(self: *const FileProtocol, buffer_size: *usize, buffer: [*]u8) Status {
+ return self._read(self, buffer_size, buffer);
+ }
+
+ pub fn write(self: *const FileProtocol, buffer_size: *usize, buffer: [*]const u8) Status {
+ return self._write(self, buffer_size, buffer);
+ }
+
+ pub fn get_info(self: *const FileProtocol, information_type: *Guid, buffer_size: *usize, buffer: *c_void) Status {
+ return self._get_info(self, information_type, buffer_size, buffer);
+ }
+
+ pub fn set_info(self: *const FileProtocol, information_type: *Guid, buffer_size: usize, buffer: *const c_void) Status {
+ return self._set_info(self, information_type, buffer_size, buffer);
+ }
+
+ pub fn flush(self: *const FileProtocol) Status {
+ return self._flush(self);
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x09576e92,
+ .time_mid = 0x6d3f,
+ .time_high_and_version = 0x11d2,
+ .clock_seq_high_and_reserved = 0x8e,
+ .clock_seq_low = 0x39,
+ .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
+ };
+
+ pub const efi_file_mode_read: u64 = 0x0000000000000001;
+ pub const efi_file_mode_write: u64 = 0x0000000000000002;
+ pub const efi_file_mode_create: u64 = 0x8000000000000000;
+
+ pub const efi_file_read_only: u64 = 0x0000000000000001;
+ pub const efi_file_hidden: u64 = 0x0000000000000002;
+ pub const efi_file_system: u64 = 0x0000000000000004;
+ pub const efi_file_reserved: u64 = 0x0000000000000008;
+ pub const efi_file_directory: u64 = 0x0000000000000010;
+ pub const efi_file_archive: u64 = 0x0000000000000020;
+ pub const efi_file_valid_attr: u64 = 0x0000000000000037;
+};
+
+pub const FileInfo = extern struct {
+ size: u64,
+ file_size: u64,
+ physical_size: u64,
+ create_time: Time,
+ last_access_time: Time,
+ modification_time: Time,
+ attribute: u64,
+
+ pub fn getFileName(self: *const FileInfo) [*:0]const u16 {
+ return @ptrCast([*:0]const u16, @ptrCast([*]const u8, self) + @sizeOf(FileInfo));
+ }
+
+ pub const efi_file_read_only: u64 = 0x0000000000000001;
+ pub const efi_file_hidden: u64 = 0x0000000000000002;
+ pub const efi_file_system: u64 = 0x0000000000000004;
+ pub const efi_file_reserved: u64 = 0x0000000000000008;
+ pub const efi_file_directory: u64 = 0x0000000000000010;
+ pub const efi_file_archive: u64 = 0x0000000000000020;
+ pub const efi_file_valid_attr: u64 = 0x0000000000000037;
+};
diff --git a/lib/std/os/uefi/protocols/graphics_output_protocol.zig b/lib/std/os/uefi/protocols/graphics_output_protocol.zig
index f63f9d12dc..7370f537bf 100644
--- a/lib/std/os/uefi/protocols/graphics_output_protocol.zig
+++ b/lib/std/os/uefi/protocols/graphics_output_protocol.zig
@@ -1,25 +1,26 @@
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
+const Status = uefi.Status;
/// Graphics output
pub const GraphicsOutputProtocol = extern struct {
- _query_mode: extern fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) usize,
- _set_mode: extern fn (*const GraphicsOutputProtocol, u32) usize,
- _blt: extern fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) usize,
+ _query_mode: extern fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) Status,
+ _set_mode: extern fn (*const GraphicsOutputProtocol, u32) Status,
+ _blt: extern fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) Status,
mode: *GraphicsOutputProtocolMode,
/// Returns information for an available graphics mode that the graphics device and the set of active video output devices supports.
- pub fn queryMode(self: *const GraphicsOutputProtocol, mode: u32, size_of_info: *usize, info: **GraphicsOutputModeInformation) usize {
+ pub fn queryMode(self: *const GraphicsOutputProtocol, mode: u32, size_of_info: *usize, info: **GraphicsOutputModeInformation) Status {
return self._query_mode(self, mode, size_of_info, info);
}
/// Set the video device into the specified mode and clears the visible portions of the output display to black.
- pub fn setMode(self: *const GraphicsOutputProtocol, mode: u32) usize {
+ pub fn setMode(self: *const GraphicsOutputProtocol, mode: u32) Status {
return self._set_mode(self, mode);
}
/// Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
- pub fn blt(self: *const GraphicsOutputProtocol, blt_buffer: ?[*]GraphicsOutputBltPixel, blt_operation: GraphicsOutputBltOperation, source_x: usize, source_y: usize, destination_x: usize, destination_y: usize, width: usize, height: usize, delta: usize) usize {
+ pub fn blt(self: *const GraphicsOutputProtocol, blt_buffer: ?[*]GraphicsOutputBltPixel, blt_operation: GraphicsOutputBltOperation, source_x: usize, source_y: usize, destination_x: usize, destination_y: usize, width: usize, height: usize, delta: usize) Status {
return self._blt(self, blt_buffer, blt_operation, source_x, source_y, destination_x, destination_y, width, height, delta);
}
diff --git a/lib/std/os/uefi/protocols/hii_database_protocol.zig b/lib/std/os/uefi/protocols/hii_database_protocol.zig
index aaacce8462..c79f693f6f 100644
--- a/lib/std/os/uefi/protocols/hii_database_protocol.zig
+++ b/lib/std/os/uefi/protocols/hii_database_protocol.zig
@@ -1,38 +1,39 @@
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
+const Status = uefi.Status;
const hii = uefi.protocols.hii;
/// Database manager for HII-related data structures.
pub const HIIDatabaseProtocol = extern struct {
- _new_package_list: usize, // TODO
- _remove_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle) usize,
- _update_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle, *const hii.HIIPackageList) usize,
- _list_package_lists: extern fn (*const HIIDatabaseProtocol, u8, ?*const Guid, *usize, [*]hii.HIIHandle) usize,
- _export_package_lists: extern fn (*const HIIDatabaseProtocol, ?hii.HIIHandle, *usize, *hii.HIIPackageList) usize,
- _register_package_notify: usize, // TODO
- _unregister_package_notify: usize, // TODO
- _find_keyboard_layouts: usize, // TODO
- _get_keyboard_layout: usize, // TODO
- _set_keyboard_layout: usize, // TODO
- _get_package_list_handle: usize, // TODO
+ _new_package_list: Status, // TODO
+ _remove_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle) Status,
+ _update_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle, *const hii.HIIPackageList) Status,
+ _list_package_lists: extern fn (*const HIIDatabaseProtocol, u8, ?*const Guid, *usize, [*]hii.HIIHandle) Status,
+ _export_package_lists: extern fn (*const HIIDatabaseProtocol, ?hii.HIIHandle, *usize, *hii.HIIPackageList) Status,
+ _register_package_notify: Status, // TODO
+ _unregister_package_notify: Status, // TODO
+ _find_keyboard_layouts: Status, // TODO
+ _get_keyboard_layout: Status, // TODO
+ _set_keyboard_layout: Status, // TODO
+ _get_package_list_handle: Status, // TODO
/// Removes a package list from the HII database.
- pub fn removePackageList(self: *const HIIDatabaseProtocol, handle: hii.HIIHandle) usize {
+ pub fn removePackageList(self: *const HIIDatabaseProtocol, handle: hii.HIIHandle) Status {
return self._remove_package_list(self, handle);
}
/// Update a package list in the HII database.
- pub fn updatePackageList(self: *const HIIDatabaseProtocol, handle: hii.HIIHandle, buffer: *const hii.HIIPackageList) usize {
+ pub fn updatePackageList(self: *const HIIDatabaseProtocol, handle: hii.HIIHandle, buffer: *const hii.HIIPackageList) Status {
return self._update_package_list(self, handle, buffer);
}
/// Determines the handles that are currently active in the database.
- pub fn listPackageLists(self: *const HIIDatabaseProtocol, package_type: u8, package_guid: ?*const Guid, buffer_length: *usize, handles: [*]hii.HIIHandle) usize {
+ pub fn listPackageLists(self: *const HIIDatabaseProtocol, package_type: u8, package_guid: ?*const Guid, buffer_length: *usize, handles: [*]hii.HIIHandle) Status {
return self._list_package_lists(self, package_type, package_guid, buffer_length, handles);
}
/// Exports the contents of one or all package lists in the HII database into a buffer.
- pub fn exportPackageLists(self: *const HIIDatabaseProtocol, handle: ?hii.HIIHandle, buffer_size: *usize, buffer: *hii.HIIPackageList) usize {
+ pub fn exportPackageLists(self: *const HIIDatabaseProtocol, handle: ?hii.HIIHandle, buffer_size: *usize, buffer: *hii.HIIPackageList) Status {
return self._export_package_lists(self, handle, buffer_size, buffer);
}
diff --git a/lib/std/os/uefi/protocols/hii_popup_protocol.zig b/lib/std/os/uefi/protocols/hii_popup_protocol.zig
index 3152a8b7a8..96afe21fbc 100644
--- a/lib/std/os/uefi/protocols/hii_popup_protocol.zig
+++ b/lib/std/os/uefi/protocols/hii_popup_protocol.zig
@@ -1,14 +1,15 @@
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
+const Status = uefi.Status;
const hii = uefi.protocols.hii;
/// Display a popup window
pub const HIIPopupProtocol = extern struct {
revision: u64,
- _create_popup: extern fn (*const HIIPopupProtocol, HIIPopupStyle, HIIPopupType, hii.HIIHandle, u16, ?*HIIPopupSelection) usize,
+ _create_popup: extern fn (*const HIIPopupProtocol, HIIPopupStyle, HIIPopupType, hii.HIIHandle, u16, ?*HIIPopupSelection) Status,
/// Displays a popup window.
- pub fn createPopup(self: *const HIIPopupProtocol, style: HIIPopupStyle, popup_type: HIIPopupType, handle: hii.HIIHandle, msg: u16, user_selection: ?*HIIPopupSelection) usize {
+ pub fn createPopup(self: *const HIIPopupProtocol, style: HIIPopupStyle, popup_type: HIIPopupType, handle: hii.HIIHandle, msg: u16, user_selection: ?*HIIPopupSelection) Status {
return self._create_popup(self, style, popup_type, handle, msg, user_selection);
}
diff --git a/lib/std/os/uefi/protocols/ip6_config_protocol.zig b/lib/std/os/uefi/protocols/ip6_config_protocol.zig
index a86e2cbba2..89ff39e8d1 100644
--- a/lib/std/os/uefi/protocols/ip6_config_protocol.zig
+++ b/lib/std/os/uefi/protocols/ip6_config_protocol.zig
@@ -1,26 +1,27 @@
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
const Event = uefi.Event;
+const Status = uefi.Status;
pub const Ip6ConfigProtocol = extern struct {
- _set_data: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, usize, *const c_void) usize,
- _get_data: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, *usize, ?*const c_void) usize,
- _register_data_notify: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) usize,
- _unregister_data_notify: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) usize,
+ _set_data: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, usize, *const c_void) Status,
+ _get_data: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, *usize, ?*const c_void) Status,
+ _register_data_notify: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) Status,
+ _unregister_data_notify: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) Status,
- pub fn setData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: usize, data: *const c_void) usize {
+ pub fn setData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: usize, data: *const c_void) Status {
return self._set_data(self, data_type, data_size, data);
}
- pub fn getData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: *usize, data: ?*const c_void) usize {
+ pub fn getData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: *usize, data: ?*const c_void) Status {
return self._get_data(self, data_type, data_size, data);
}
- pub fn registerDataNotify(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, event: Event) usize {
+ pub fn registerDataNotify(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, event: Event) Status {
return self._register_data_notify(self, data_type, event);
}
- pub fn unregisterDataNotify(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, event: Event) usize {
+ pub fn unregisterDataNotify(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, event: Event) Status {
return self._unregister_data_notify(self, data_type, event);
}
diff --git a/lib/std/os/uefi/protocols/ip6_protocol.zig b/lib/std/os/uefi/protocols/ip6_protocol.zig
index a412dc3c7b..f9a5c23d3c 100644
--- a/lib/std/os/uefi/protocols/ip6_protocol.zig
+++ b/lib/std/os/uefi/protocols/ip6_protocol.zig
@@ -1,63 +1,64 @@
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
const Event = uefi.Event;
+const Status = uefi.Status;
const MacAddress = uefi.protocols.MacAddress;
const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData;
const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
pub const Ip6Protocol = extern struct {
- _get_mode_data: extern fn (*const Ip6Protocol, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) usize,
- _configure: extern fn (*const Ip6Protocol, ?*const Ip6ConfigData) usize,
- _groups: extern fn (*const Ip6Protocol, bool, ?*const Ip6Address) usize,
- _routes: extern fn (*const Ip6Protocol, bool, ?*const Ip6Address, u8, ?*const Ip6Address) usize,
- _neighbors: extern fn (*const Ip6Protocol, bool, *const Ip6Address, ?*const MacAddress, u32, bool) usize,
- _transmit: extern fn (*const Ip6Protocol, *Ip6CompletionToken) usize,
- _receive: extern fn (*const Ip6Protocol, *Ip6CompletionToken) usize,
- _cancel: extern fn (*const Ip6Protocol, ?*Ip6CompletionToken) usize,
- _poll: extern fn (*const Ip6Protocol) usize,
+ _get_mode_data: extern fn (*const Ip6Protocol, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) Status,
+ _configure: extern fn (*const Ip6Protocol, ?*const Ip6ConfigData) Status,
+ _groups: extern fn (*const Ip6Protocol, bool, ?*const Ip6Address) Status,
+ _routes: extern fn (*const Ip6Protocol, bool, ?*const Ip6Address, u8, ?*const Ip6Address) Status,
+ _neighbors: extern fn (*const Ip6Protocol, bool, *const Ip6Address, ?*const MacAddress, u32, bool) Status,
+ _transmit: extern fn (*const Ip6Protocol, *Ip6CompletionToken) Status,
+ _receive: extern fn (*const Ip6Protocol, *Ip6CompletionToken) Status,
+ _cancel: extern fn (*const Ip6Protocol, ?*Ip6CompletionToken) Status,
+ _poll: extern fn (*const Ip6Protocol) 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) usize {
+ pub fn getModeData(self: *const Ip6Protocol, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {
return self._get_mode_data(self, ip6_mode_data, mnp_config_data, snp_mode_data);
}
/// Assign IPv6 address and other configuration parameter to this EFI IPv6 Protocol driver instance.
- pub fn configure(self: *const Ip6Protocol, ip6_config_data: ?*const Ip6ConfigData) usize {
+ pub fn configure(self: *const Ip6Protocol, ip6_config_data: ?*const Ip6ConfigData) Status {
return self._configure(self, ip6_config_data);
}
/// Joins and leaves multicast groups.
- pub fn groups(self: *const Ip6Protocol, join_flag: bool, group_address: ?*const Ip6Address) usize {
+ pub fn groups(self: *const Ip6Protocol, join_flag: bool, group_address: ?*const Ip6Address) Status {
return self._groups(self, join_flag, group_address);
}
/// Adds and deletes routing table entries.
- pub fn routes(self: *const Ip6Protocol, delete_route: bool, destination: ?*const Ip6Address, prefix_length: u8, gateway_address: ?*const Ip6Address) usize {
+ pub fn routes(self: *const Ip6Protocol, delete_route: bool, destination: ?*const Ip6Address, prefix_length: u8, gateway_address: ?*const Ip6Address) Status {
return self._routes(self, delete_route, destination, prefix_length, gateway_address);
}
/// Add or delete Neighbor cache entries.
- pub fn neighbors(self: *const Ip6Protocol, delete_flag: bool, target_ip6_address: *const Ip6Address, target_link_address: ?*const MacAddress, timeout: u32, override: bool) usize {
+ pub fn neighbors(self: *const Ip6Protocol, delete_flag: bool, target_ip6_address: *const Ip6Address, target_link_address: ?*const MacAddress, timeout: u32, override: bool) Status {
return self._neighbors(self, delete_flag, target_ip6_address, target_link_address, timeout, override);
}
/// Places outgoing data packets into the transmit queue.
- pub fn transmit(self: *const Ip6Protocol, token: *Ip6CompletionToken) usize {
+ pub fn transmit(self: *const Ip6Protocol, token: *Ip6CompletionToken) Status {
return self._transmit(self, token);
}
/// Places a receiving request into the receiving queue.
- pub fn receive(self: *const Ip6Protocol, token: *Ip6CompletionToken) usize {
+ pub fn receive(self: *const Ip6Protocol, token: *Ip6CompletionToken) Status {
return self._receive(self, token);
}
/// Abort an asynchronous transmits or receive request.
- pub fn cancel(self: *const Ip6Protocol, token: ?*Ip6CompletionToken) usize {
+ pub fn cancel(self: *const Ip6Protocol, token: ?*Ip6CompletionToken) Status {
return self._cancel(self, token);
}
/// Polls for incoming data packets and processes outgoing data packets.
- pub fn poll(self: *const Ip6Protocol) usize {
+ pub fn poll(self: *const Ip6Protocol) Status {
return self._poll(self);
}
@@ -138,6 +139,6 @@ pub const Ip6IcmpType = extern struct {
pub const Ip6CompletionToken = extern struct {
event: Event,
- status: usize,
+ status: Status,
packet: *c_void, // union TODO
};
diff --git a/lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig b/lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig
index 9ecbb29607..030ae5cae2 100644
--- a/lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig
+++ b/lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig
@@ -1,16 +1,17 @@
const uefi = @import("std").os.uefi;
const Handle = uefi.Handle;
const Guid = uefi.Guid;
+const Status = uefi.Status;
pub const Ip6ServiceBindingProtocol = extern struct {
- _create_child: extern fn (*const Ip6ServiceBindingProtocol, *?Handle) usize,
- _destroy_child: extern fn (*const Ip6ServiceBindingProtocol, Handle) usize,
+ _create_child: extern fn (*const Ip6ServiceBindingProtocol, *?Handle) Status,
+ _destroy_child: extern fn (*const Ip6ServiceBindingProtocol, Handle) Status,
- pub fn createChild(self: *const Ip6ServiceBindingProtocol, handle: *?Handle) usize {
+ pub fn createChild(self: *const Ip6ServiceBindingProtocol, handle: *?Handle) Status {
return self._create_child(self, handle);
}
- pub fn destroyChild(self: *const Ip6ServiceBindingProtocol, handle: Handle) usize {
+ pub fn destroyChild(self: *const Ip6ServiceBindingProtocol, handle: Handle) Status {
return self._destroy_child(self, handle);
}
diff --git a/lib/std/os/uefi/protocols/loaded_image_protocol.zig b/lib/std/os/uefi/protocols/loaded_image_protocol.zig
index b7b281e249..cff2bdccc0 100644
--- a/lib/std/os/uefi/protocols/loaded_image_protocol.zig
+++ b/lib/std/os/uefi/protocols/loaded_image_protocol.zig
@@ -1,6 +1,7 @@
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
const Handle = uefi.Handle;
+const Status = uefi.Status;
const SystemTable = uefi.tables.SystemTable;
const MemoryType = uefi.tables.MemoryType;
const DevicePathProtocol = uefi.protocols.DevicePathProtocol;
@@ -13,15 +14,15 @@ pub const LoadedImageProtocol = extern struct {
file_path: *DevicePathProtocol,
reserved: *c_void,
load_options_size: u32,
- load_options: *c_void,
+ load_options: ?*c_void,
image_base: [*]u8,
image_size: u64,
image_code_type: MemoryType,
image_data_type: MemoryType,
- _unload: extern fn (*const LoadedImageProtocol, Handle) usize,
+ _unload: extern fn (*const LoadedImageProtocol, Handle) Status,
/// Unloads an image from memory.
- pub fn unload(self: *const LoadedImageProtocol, handle: Handle) usize {
+ pub fn unload(self: *const LoadedImageProtocol, handle: Handle) Status {
return self._unload(self, handle);
}
@@ -34,3 +35,12 @@ pub const LoadedImageProtocol = extern struct {
.node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
};
};
+
+pub const loaded_image_device_path_protocol_guid align(8) = Guid{
+ .time_low = 0xbc62157e,
+ .time_mid = 0x3e33,
+ .time_high_and_version = 0x4fec,
+ .clock_seq_high_and_reserved = 0x99,
+ .clock_seq_low = 0x20,
+ .node = [_]u8{ 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf },
+};
diff --git a/lib/std/os/uefi/protocols/managed_network_protocol.zig b/lib/std/os/uefi/protocols/managed_network_protocol.zig
index a2cf6e2eca..60dc6996ad 100644
--- a/lib/std/os/uefi/protocols/managed_network_protocol.zig
+++ b/lib/std/os/uefi/protocols/managed_network_protocol.zig
@@ -1,60 +1,61 @@
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
const Event = uefi.Event;
+const Status = uefi.Status;
const Time = uefi.Time;
const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
const MacAddress = uefi.protocols.MacAddress;
pub const ManagedNetworkProtocol = extern struct {
- _get_mode_data: extern fn (*const ManagedNetworkProtocol, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) usize,
- _configure: extern fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkConfigData) usize,
- _mcast_ip_to_mac: extern fn (*const ManagedNetworkProtocol, bool, *const c_void, *MacAddress) usize,
- _groups: extern fn (*const ManagedNetworkProtocol, bool, ?*const MacAddress) usize,
- _transmit: extern fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) usize,
- _receive: extern fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) usize,
- _cancel: extern fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkCompletionToken) usize,
+ _get_mode_data: extern fn (*const ManagedNetworkProtocol, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) Status,
+ _configure: extern fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkConfigData) Status,
+ _mcast_ip_to_mac: extern fn (*const ManagedNetworkProtocol, bool, *const c_void, *MacAddress) Status,
+ _groups: extern fn (*const ManagedNetworkProtocol, bool, ?*const MacAddress) Status,
+ _transmit: extern fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) Status,
+ _receive: extern fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) Status,
+ _cancel: extern fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkCompletionToken) Status,
_poll: extern fn (*const ManagedNetworkProtocol) usize,
/// Returns the operational parameters for the current MNP child driver.
/// May also support returning the underlying SNP driver mode data.
- pub fn getModeData(self: *const ManagedNetworkProtocol, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) usize {
+ pub fn getModeData(self: *const ManagedNetworkProtocol, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {
return self._get_mode_data(self, mnp_config_data, snp_mode_data);
}
/// Sets or clears the operational parameters for the MNP child driver.
- pub fn configure(self: *const ManagedNetworkProtocol, mnp_config_data: ?*const ManagedNetworkConfigData) usize {
+ pub fn configure(self: *const ManagedNetworkProtocol, mnp_config_data: ?*const ManagedNetworkConfigData) Status {
return self._configure(self, mnp_config_data);
}
/// Translates an IP multicast address to a hardware (MAC) multicast address.
/// This function may be unsupported in some MNP implementations.
- pub fn mcastIpToMac(self: *const ManagedNetworkProtocol, ipv6flag: bool, ipaddress: *const c_void, mac_address: *MacAddress) usize {
+ pub fn mcastIpToMac(self: *const ManagedNetworkProtocol, ipv6flag: bool, ipaddress: *const c_void, mac_address: *MacAddress) Status {
return self._mcast_ip_to_mac(self, ipv6flag, ipaddress);
}
/// Enables and disables receive filters for multicast address.
/// This function may be unsupported in some MNP implementations.
- pub fn groups(self: *const ManagedNetworkProtocol, join_flag: bool, mac_address: ?*const MacAddress) usiz {
+ pub fn groups(self: *const ManagedNetworkProtocol, join_flag: bool, mac_address: ?*const MacAddress) Status {
return self._groups(self, join_flag, mac_address);
}
/// Places asynchronous outgoing data packets into the transmit queue.
- pub fn transmit(self: *const ManagedNetworkProtocol, token: *const ManagedNetworkCompletionToken) usize {
+ pub fn transmit(self: *const ManagedNetworkProtocol, token: *const ManagedNetworkCompletionToken) Status {
return self._transmit(self, token);
}
/// Places an asynchronous receiving request into the receiving queue.
- pub fn receive(self: *const ManagedNetworkProtocol, token: *const ManagedNetworkCompletionToken) usize {
+ pub fn receive(self: *const ManagedNetworkProtocol, token: *const ManagedNetworkCompletionToken) Status {
return self._receive(self, token);
}
/// Aborts an asynchronous transmit or receive request.
- pub fn cancel(self: *const ManagedNetworkProtocol, token: ?*const ManagedNetworkCompletionToken) usize {
+ pub fn cancel(self: *const ManagedNetworkProtocol, token: ?*const ManagedNetworkCompletionToken) Status {
return self._cancel(self, token);
}
/// Polls for incoming data packets and processes outgoing data packets.
- pub fn poll(self: *const ManagedNetworkProtocol) usize {
+ pub fn poll(self: *const ManagedNetworkProtocol) Status {
return self._poll(self);
}
@@ -83,7 +84,7 @@ pub const ManagedNetworkConfigData = extern struct {
pub const ManagedNetworkCompletionToken = extern struct {
event: Event,
- status: usize,
+ status: Status,
packet: extern union {
RxData: *ManagedNetworkReceiveData,
TxData: *ManagedNetworkTransmitData,
diff --git a/lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig b/lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig
index 492fe450ba..ea8bd470c3 100644
--- a/lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig
+++ b/lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig
@@ -1,16 +1,17 @@
const uefi = @import("std").os.uefi;
const Handle = uefi.Handle;
const Guid = uefi.Guid;
+const Status = uefi.Status;
pub const ManagedNetworkServiceBindingProtocol = extern struct {
- _create_child: extern fn (*const ManagedNetworkServiceBindingProtocol, *?Handle) usize,
- _destroy_child: extern fn (*const ManagedNetworkServiceBindingProtocol, Handle) usize,
+ _create_child: extern fn (*const ManagedNetworkServiceBindingProtocol, *?Handle) Status,
+ _destroy_child: extern fn (*const ManagedNetworkServiceBindingProtocol, Handle) Status,
- pub fn createChild(self: *const ManagedNetworkServiceBindingProtocol, handle: *?Handle) usize {
+ pub fn createChild(self: *const ManagedNetworkServiceBindingProtocol, handle: *?Handle) Status {
return self._create_child(self, handle);
}
- pub fn destroyChild(self: *const ManagedNetworkServiceBindingProtocol, handle: Handle) usize {
+ pub fn destroyChild(self: *const ManagedNetworkServiceBindingProtocol, handle: Handle) Status {
return self._destroy_child(self, handle);
}
diff --git a/lib/std/os/uefi/protocols/rng_protocol.zig b/lib/std/os/uefi/protocols/rng_protocol.zig
index 65eb882afb..4d5dd496af 100644
--- a/lib/std/os/uefi/protocols/rng_protocol.zig
+++ b/lib/std/os/uefi/protocols/rng_protocol.zig
@@ -1,18 +1,19 @@
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
+const Status = uefi.Status;
/// Random Number Generator protocol
pub const RNGProtocol = extern struct {
- _get_info: extern fn (*const RNGProtocol, *usize, [*]align(8) Guid) usize,
- _get_rng: extern fn (*const RNGProtocol, ?*align(8) const Guid, usize, [*]u8) usize,
+ _get_info: extern fn (*const RNGProtocol, *usize, [*]align(8) Guid) Status,
+ _get_rng: extern fn (*const RNGProtocol, ?*align(8) const Guid, usize, [*]u8) Status,
/// Returns information about the random number generation implementation.
- pub fn getInfo(self: *const RNGProtocol, list_size: *usize, list: [*]align(8) Guid) usize {
+ pub fn getInfo(self: *const RNGProtocol, list_size: *usize, list: [*]align(8) Guid) Status {
return self._get_info(self, list_size, list);
}
/// Produces and returns an RNG value using either the default or specified RNG algorithm.
- pub fn getRNG(self: *const RNGProtocol, algo: ?*align(8) const Guid, value_length: usize, value: [*]u8) usize {
+ pub fn getRNG(self: *const RNGProtocol, algo: ?*align(8) const Guid, value_length: usize, value: [*]u8) Status {
return self._get_rng(self, algo, value_length, value);
}
diff --git a/lib/std/os/uefi/protocols/shell_parameters_protocol.zig b/lib/std/os/uefi/protocols/shell_parameters_protocol.zig
new file mode 100644
index 0000000000..afbd26e939
--- /dev/null
+++ b/lib/std/os/uefi/protocols/shell_parameters_protocol.zig
@@ -0,0 +1,20 @@
+const uefi = @import("std").os.uefi;
+const Guid = uefi.Guid;
+const FileHandle = uefi.FileHandle;
+
+pub const ShellParametersProtocol = extern struct {
+ argv: [*][*:0]const u16,
+ argc: usize,
+ stdin: FileHandle,
+ stdout: FileHandle,
+ stderr: FileHandle,
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x752f3136,
+ .time_mid = 0x4e16,
+ .time_high_and_version = 0x4fdc,
+ .clock_seq_high_and_reserved = 0xa2,
+ .clock_seq_low = 0x2a,
+ .node = [_]u8{ 0xe5, 0xf4, 0x68, 0x12, 0xf4, 0xca },
+ };
+};
diff --git a/lib/std/os/uefi/protocols/simple_file_system_protocol.zig b/lib/std/os/uefi/protocols/simple_file_system_protocol.zig
new file mode 100644
index 0000000000..31da02595a
--- /dev/null
+++ b/lib/std/os/uefi/protocols/simple_file_system_protocol.zig
@@ -0,0 +1,22 @@
+const uefi = @import("std").os.uefi;
+const Guid = uefi.Guid;
+const FileProtocol = uefi.protocols.FileProtocol;
+const Status = uefi.Status;
+
+pub const SimpleFileSystemProtocol = extern struct {
+ revision: u64,
+ _open_volume: extern fn (*const SimpleFileSystemProtocol, **const FileProtocol) Status,
+
+ pub fn openVolume(self: *const SimpleFileSystemProtocol, root: **const FileProtocol) Status {
+ return self._open_volume(self, root);
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x0964e5b22,
+ .time_mid = 0x6459,
+ .time_high_and_version = 0x11d2,
+ .clock_seq_high_and_reserved = 0x8e,
+ .clock_seq_low = 0x39,
+ .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
+ };
+};
diff --git a/lib/std/os/uefi/protocols/simple_network_protocol.zig b/lib/std/os/uefi/protocols/simple_network_protocol.zig
index f5e62734b6..a0d85b06d1 100644
--- a/lib/std/os/uefi/protocols/simple_network_protocol.zig
+++ b/lib/std/os/uefi/protocols/simple_network_protocol.zig
@@ -1,87 +1,88 @@
const uefi = @import("std").os.uefi;
const Event = uefi.Event;
const Guid = uefi.Guid;
+const Status = uefi.Status;
pub const SimpleNetworkProtocol = extern struct {
revision: u64,
- _start: extern fn (*const SimpleNetworkProtocol) usize,
- _stop: extern fn (*const SimpleNetworkProtocol) usize,
- _initialize: extern fn (*const SimpleNetworkProtocol, usize, usize) usize,
- _reset: extern fn (*const SimpleNetworkProtocol, bool) usize,
- _shutdown: extern fn (*const SimpleNetworkProtocol) usize,
- _receive_filters: extern fn (*const SimpleNetworkProtocol, SimpleNetworkReceiveFilter, SimpleNetworkReceiveFilter, bool, usize, ?[*]const MacAddress) usize,
- _station_address: extern fn (*const SimpleNetworkProtocol, bool, ?*const MacAddress) usize,
- _statistics: extern fn (*const SimpleNetworkProtocol, bool, ?*usize, ?*NetworkStatistics) usize,
- _mcast_ip_to_mac: extern fn (*const SimpleNetworkProtocol, bool, *const c_void, *MacAddress) usize,
- _nvdata: extern fn (*const SimpleNetworkProtocol, bool, usize, usize, [*]u8) usize,
- _get_status: extern fn (*const SimpleNetworkProtocol, *SimpleNetworkInterruptStatus, ?*?[*]u8) usize,
- _transmit: extern fn (*const SimpleNetworkProtocol, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) usize,
- _receive: extern fn (*const SimpleNetworkProtocol, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) usize,
+ _start: extern fn (*const SimpleNetworkProtocol) Status,
+ _stop: extern fn (*const SimpleNetworkProtocol) Status,
+ _initialize: extern fn (*const SimpleNetworkProtocol, usize, usize) Status,
+ _reset: extern fn (*const SimpleNetworkProtocol, bool) Status,
+ _shutdown: extern fn (*const SimpleNetworkProtocol) Status,
+ _receive_filters: extern fn (*const SimpleNetworkProtocol, SimpleNetworkReceiveFilter, SimpleNetworkReceiveFilter, bool, usize, ?[*]const MacAddress) Status,
+ _station_address: extern fn (*const SimpleNetworkProtocol, bool, ?*const MacAddress) Status,
+ _statistics: extern fn (*const SimpleNetworkProtocol, bool, ?*usize, ?*NetworkStatistics) Status,
+ _mcast_ip_to_mac: extern fn (*const SimpleNetworkProtocol, bool, *const c_void, *MacAddress) Status,
+ _nvdata: extern fn (*const SimpleNetworkProtocol, bool, usize, usize, [*]u8) Status,
+ _get_status: extern fn (*const SimpleNetworkProtocol, *SimpleNetworkInterruptStatus, ?*?[*]u8) Status,
+ _transmit: extern fn (*const SimpleNetworkProtocol, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) Status,
+ _receive: extern fn (*const SimpleNetworkProtocol, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) Status,
wait_for_packet: Event,
mode: *SimpleNetworkMode,
/// Changes the state of a network interface from "stopped" to "started".
- pub fn start(self: *const SimpleNetworkProtocol) usize {
+ pub fn start(self: *const SimpleNetworkProtocol) Status {
return self._start(self);
}
/// Changes the state of a network interface from "started" to "stopped".
- pub fn stop(self: *const SimpleNetworkProtocol) usize {
+ pub fn stop(self: *const SimpleNetworkProtocol) Status {
return self._stop(self);
}
/// Resets a network adapter and allocates the transmit and receive buffers required by the network interface.
- pub fn initialize(self: *const SimpleNetworkProtocol, extra_rx_buffer_size: usize, extra_tx_buffer_size: usize) usize {
+ pub fn initialize(self: *const SimpleNetworkProtocol, extra_rx_buffer_size: usize, extra_tx_buffer_size: usize) Status {
return self._initialize(self, extra_rx_buffer_size, extra_tx_buffer_size);
}
/// Resets a network adapter and reinitializes it with the parameters that were provided in the previous call to initialize().
- pub fn reset(self: *const SimpleNetworkProtocol, extended_verification: bool) usize {
+ pub fn reset(self: *const SimpleNetworkProtocol, extended_verification: bool) Status {
return self._reset(self, extended_verification);
}
/// Resets a network adapter and leaves it in a state that is safe for another driver to initialize.
- pub fn shutdown(self: *const SimpleNetworkProtocol) usize {
+ pub fn shutdown(self: *const SimpleNetworkProtocol) Status {
return self._shutdown(self);
}
/// Manages the multicast receive filters of a network interface.
- pub fn receiveFilters(self: *const SimpleNetworkProtocol, enable: SimpleNetworkReceiveFilter, disable: SimpleNetworkReceiveFilter, reset_mcast_filter: bool, mcast_filter_cnt: usize, mcast_filter: ?[*]const MacAddress) usize {
+ pub fn receiveFilters(self: *const SimpleNetworkProtocol, enable: SimpleNetworkReceiveFilter, disable: SimpleNetworkReceiveFilter, reset_mcast_filter: bool, mcast_filter_cnt: usize, mcast_filter: ?[*]const MacAddress) Status {
return self._receive_filters(self, enable, disable, reset_mcast_filter, mcast_filter_cnt, mcast_filter);
}
/// Modifies or resets the current station address, if supported.
- pub fn stationAddress(self: *const SimpleNetworkProtocol, reset: bool, new: ?*const MacAddress) usize {
+ pub fn stationAddress(self: *const SimpleNetworkProtocol, reset: bool, new: ?*const MacAddress) Status {
return self._station_address(self, reset, new);
}
/// Resets or collects the statistics on a network interface.
- pub fn statistics(self: *const SimpleNetworkProtocol, reset_: bool, statistics_size: ?*usize, statistics_table: ?*NetworkStatistics) usize {
+ pub fn statistics(self: *const SimpleNetworkProtocol, reset_: bool, statistics_size: ?*usize, statistics_table: ?*NetworkStatistics) Status {
return self._statistics(self, reset_, statistics_size, statistics_table);
}
/// Converts a multicast IP address to a multicast HW MAC address.
- pub fn mcastIpToMac(self: *const SimpleNetworkProtocol, ipv6: bool, ip: *const c_void, mac: *MacAddress) usize {
+ pub fn mcastIpToMac(self: *const SimpleNetworkProtocol, ipv6: bool, ip: *const c_void, mac: *MacAddress) Status {
return self._mcast_ip_to_mac(self, ipv6, ip, mac);
}
/// Performs read and write operations on the NVRAM device attached to a network interface.
- pub fn nvdata(self: *const SimpleNetworkProtocol, read_write: bool, offset: usize, buffer_size: usize, buffer: [*]u8) usize {
+ pub fn nvdata(self: *const SimpleNetworkProtocol, read_write: bool, offset: usize, buffer_size: usize, buffer: [*]u8) Status {
return self._nvdata(self, read_write, offset, buffer_size, buffer);
}
/// Reads the current interrupt status and recycled transmit buffer status from a network interface.
- pub fn getStatus(self: *const SimpleNetworkProtocol, interrupt_status: *SimpleNetworkInterruptStatus, tx_buf: ?*?[*]u8) usize {
+ pub fn getStatus(self: *const SimpleNetworkProtocol, interrupt_status: *SimpleNetworkInterruptStatus, tx_buf: ?*?[*]u8) Status {
return self._get_status(self, interrupt_status, tx_buf);
}
/// Places a packet in the transmit queue of a network interface.
- pub fn transmit(self: *const SimpleNetworkProtocol, header_size: usize, buffer_size: usize, buffer: [*]const u8, src_addr: ?*const MacAddress, dest_addr: ?*const MacAddress, protocol: ?*const u16) usize {
+ pub fn transmit(self: *const SimpleNetworkProtocol, header_size: usize, buffer_size: usize, buffer: [*]const u8, src_addr: ?*const MacAddress, dest_addr: ?*const MacAddress, protocol: ?*const u16) Status {
return self._transmit(self, header_size, buffer_size, buffer, src_addr, dest_addr, protocol);
}
/// Receives a packet from a network interface.
- pub fn receive(self: *const SimpleNetworkProtocol, header_size: ?*usize, buffer_size: *usize, buffer: [*]u8, src_addr: ?*MacAddress, dest_addr: ?*MacAddress, protocol: ?*u16) usize {
+ pub fn receive(self: *const SimpleNetworkProtocol, header_size: ?*usize, buffer_size: *usize, buffer: [*]u8, src_addr: ?*MacAddress, dest_addr: ?*MacAddress, protocol: ?*u16) Status {
return self._receive(self, header_size, buffer_size, buffer, src_addr, dest_addr, protocol);
}
diff --git a/lib/std/os/uefi/protocols/simple_pointer_protocol.zig b/lib/std/os/uefi/protocols/simple_pointer_protocol.zig
index e0cb4ba354..2d1c7d4504 100644
--- a/lib/std/os/uefi/protocols/simple_pointer_protocol.zig
+++ b/lib/std/os/uefi/protocols/simple_pointer_protocol.zig
@@ -1,21 +1,22 @@
const uefi = @import("std").os.uefi;
const Event = uefi.Event;
const Guid = uefi.Guid;
+const Status = uefi.Status;
/// Protocol for mice
pub const SimplePointerProtocol = struct {
- _reset: extern fn (*const SimplePointerProtocol, bool) usize,
- _get_state: extern fn (*const SimplePointerProtocol, *SimplePointerState) usize,
+ _reset: extern fn (*const SimplePointerProtocol, bool) Status,
+ _get_state: extern fn (*const SimplePointerProtocol, *SimplePointerState) Status,
wait_for_input: Event,
mode: *SimplePointerMode,
/// Resets the pointer device hardware.
- pub fn reset(self: *const SimplePointerProtocol, verify: bool) usize {
+ pub fn reset(self: *const SimplePointerProtocol, verify: bool) Status {
return self._reset(self, verify);
}
/// Retrieves the current state of a pointer device.
- pub fn getState(self: *const SimplePointerProtocol, state: *SimplePointerState) usize {
+ pub fn getState(self: *const SimplePointerProtocol, state: *SimplePointerState) Status {
return self._get_state(self, state);
}
diff --git a/lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig b/lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig
index e2c4be7847..c361ffa9a1 100644
--- a/lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig
+++ b/lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig
@@ -1,38 +1,39 @@
const uefi = @import("std").os.uefi;
const Event = uefi.Event;
const Guid = uefi.Guid;
+const Status = uefi.Status;
/// Character input devices, e.g. Keyboard
pub const SimpleTextInputExProtocol = extern struct {
- _reset: extern fn (*const SimpleTextInputExProtocol, bool) usize,
- _read_key_stroke_ex: extern fn (*const SimpleTextInputExProtocol, *KeyData) usize,
+ _reset: extern fn (*const SimpleTextInputExProtocol, bool) Status,
+ _read_key_stroke_ex: extern fn (*const SimpleTextInputExProtocol, *KeyData) Status,
wait_for_key_ex: Event,
- _set_state: extern fn (*const SimpleTextInputExProtocol, *const u8) usize,
- _register_key_notify: extern fn (*const SimpleTextInputExProtocol, *const KeyData, extern fn (*const KeyData) usize, **c_void) usize,
- _unregister_key_notify: extern fn (*const SimpleTextInputExProtocol, *const c_void) usize,
+ _set_state: extern fn (*const SimpleTextInputExProtocol, *const u8) Status,
+ _register_key_notify: extern fn (*const SimpleTextInputExProtocol, *const KeyData, extern fn (*const KeyData) usize, **c_void) Status,
+ _unregister_key_notify: extern fn (*const SimpleTextInputExProtocol, *const c_void) Status,
/// Resets the input device hardware.
- pub fn reset(self: *const SimpleTextInputExProtocol, verify: bool) usize {
+ pub fn reset(self: *const SimpleTextInputExProtocol, verify: bool) Status {
return self._reset(self, verify);
}
/// Reads the next keystroke from the input device.
- pub fn readKeyStrokeEx(self: *const SimpleTextInputExProtocol, key_data: *KeyData) usize {
+ pub fn readKeyStrokeEx(self: *const SimpleTextInputExProtocol, key_data: *KeyData) Status {
return self._read_key_stroke_ex(self, key_data);
}
/// Set certain state for the input device.
- pub fn setState(self: *const SimpleTextInputExProtocol, state: *const u8) usize {
+ pub fn setState(self: *const SimpleTextInputExProtocol, state: *const u8) Status {
return self._set_state(self, state);
}
/// Register a notification function for a particular keystroke for the input device.
- pub fn registerKeyNotify(self: *const SimpleTextInputExProtocol, key_data: *const KeyData, notify: extern fn (*const KeyData) usize, handle: **c_void) usize {
+ pub fn registerKeyNotify(self: *const SimpleTextInputExProtocol, key_data: *const KeyData, notify: extern fn (*const KeyData) usize, handle: **c_void) Status {
return self._register_key_notify(self, key_data, notify, handle);
}
/// Remove the notification that was previously registered.
- pub fn unregisterKeyNotify(self: *const SimpleTextInputExProtocol, handle: *const c_void) usize {
+ pub fn unregisterKeyNotify(self: *const SimpleTextInputExProtocol, handle: *const c_void) Status {
return self._unregister_key_notify(self, handle);
}
diff --git a/lib/std/os/uefi/protocols/simple_text_input_protocol.zig b/lib/std/os/uefi/protocols/simple_text_input_protocol.zig
index b56ff728ef..fdae001145 100644
--- a/lib/std/os/uefi/protocols/simple_text_input_protocol.zig
+++ b/lib/std/os/uefi/protocols/simple_text_input_protocol.zig
@@ -1,20 +1,22 @@
const uefi = @import("std").os.uefi;
const Event = uefi.Event;
const Guid = uefi.Guid;
+const InputKey = uefi.protocols.InputKey;
+const Status = uefi.Status;
/// Character input devices, e.g. Keyboard
pub const SimpleTextInputProtocol = extern struct {
_reset: extern fn (*const SimpleTextInputProtocol, bool) usize,
- _read_key_stroke: extern fn (*const SimpleTextInputProtocol, *uefi.protocols.InputKey) usize,
+ _read_key_stroke: extern fn (*const SimpleTextInputProtocol, *InputKey) Status,
wait_for_key: Event,
/// Resets the input device hardware.
- pub fn reset(self: *const SimpleTextInputProtocol, verify: bool) usize {
+ pub fn reset(self: *const SimpleTextInputProtocol, verify: bool) Status {
return self._reset(self, verify);
}
/// Reads the next keystroke from the input device.
- pub fn readKeyStroke(self: *const SimpleTextInputProtocol, input_key: *uefi.protocols.InputKey) usize {
+ pub fn readKeyStroke(self: *const SimpleTextInputProtocol, input_key: *InputKey) Status {
return self._read_key_stroke(self, input_key);
}
diff --git a/lib/std/os/uefi/protocols/simple_text_output_protocol.zig b/lib/std/os/uefi/protocols/simple_text_output_protocol.zig
index 2a643ec834..09f3cb1cd2 100644
--- a/lib/std/os/uefi/protocols/simple_text_output_protocol.zig
+++ b/lib/std/os/uefi/protocols/simple_text_output_protocol.zig
@@ -1,61 +1,62 @@
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
+const Status = uefi.Status;
/// Character output devices
pub const SimpleTextOutputProtocol = extern struct {
- _reset: extern fn (*const SimpleTextOutputProtocol, bool) usize,
- _output_string: extern fn (*const SimpleTextOutputProtocol, [*:0]const u16) usize,
- _test_string: extern fn (*const SimpleTextOutputProtocol, [*:0]const u16) usize,
- _query_mode: extern fn (*const SimpleTextOutputProtocol, usize, *usize, *usize) usize,
- _set_mode: extern fn (*const SimpleTextOutputProtocol, usize) usize,
- _set_attribute: extern fn (*const SimpleTextOutputProtocol, usize) usize,
- _clear_screen: extern fn (*const SimpleTextOutputProtocol) usize,
- _set_cursor_position: extern fn (*const SimpleTextOutputProtocol, usize, usize) usize,
- _enable_cursor: extern fn (*const SimpleTextOutputProtocol, bool) usize,
+ _reset: extern fn (*const SimpleTextOutputProtocol, bool) Status,
+ _output_string: extern fn (*const SimpleTextOutputProtocol, [*:0]const u16) Status,
+ _test_string: extern fn (*const SimpleTextOutputProtocol, [*:0]const u16) Status,
+ _query_mode: extern fn (*const SimpleTextOutputProtocol, usize, *usize, *usize) Status,
+ _set_mode: extern fn (*const SimpleTextOutputProtocol, usize) Status,
+ _set_attribute: extern fn (*const SimpleTextOutputProtocol, usize) Status,
+ _clear_screen: extern fn (*const SimpleTextOutputProtocol) Status,
+ _set_cursor_position: extern fn (*const SimpleTextOutputProtocol, usize, usize) Status,
+ _enable_cursor: extern fn (*const SimpleTextOutputProtocol, bool) Status,
mode: *SimpleTextOutputMode,
/// Resets the text output device hardware.
- pub fn reset(self: *const SimpleTextOutputProtocol, verify: bool) usize {
+ pub fn reset(self: *const SimpleTextOutputProtocol, verify: bool) Status {
return self._reset(self, verify);
}
/// Writes a string to the output device.
- pub fn outputString(self: *const SimpleTextOutputProtocol, msg: [*:0]const u16) usize {
+ pub fn outputString(self: *const SimpleTextOutputProtocol, msg: [*:0]const u16) Status {
return self._output_string(self, msg);
}
/// Verifies that all characters in a string can be output to the target device.
- pub fn testString(self: *const SimpleTextOutputProtocol, msg: [*:0]const u16) usize {
+ pub fn testString(self: *const SimpleTextOutputProtocol, msg: [*:0]const u16) Status {
return self._test_string(self, msg);
}
/// Returns information for an available text mode that the output device(s) supports.
- pub fn queryMode(self: *const SimpleTextOutputProtocol, mode_number: usize, columns: *usize, rows: *usize) usize {
+ pub fn queryMode(self: *const SimpleTextOutputProtocol, mode_number: usize, columns: *usize, rows: *usize) Status {
return self._query_mode(self, mode_number, columns, rows);
}
/// Sets the output device(s) to a specified mode.
- pub fn setMode(self: *const SimpleTextOutputProtocol, mode_number: usize) usize {
+ pub fn setMode(self: *const SimpleTextOutputProtocol, mode_number: usize) Status {
return self._set_mode(self, mode_number);
}
/// Sets the background and foreground colors for the outputString() and clearScreen() functions.
- pub fn setAttribute(self: *const SimpleTextOutputProtocol, attribute: usize) usize {
+ pub fn setAttribute(self: *const SimpleTextOutputProtocol, attribute: usize) Status {
return self._set_attribute(self, attribute);
}
/// Clears the output device(s) display to the currently selected background color.
- pub fn clearScreen(self: *const SimpleTextOutputProtocol) usize {
+ pub fn clearScreen(self: *const SimpleTextOutputProtocol) Status {
return self._clear_screen(self);
}
/// Sets the current coordinates of the cursor position.
- pub fn setCursorPosition(self: *const SimpleTextOutputProtocol, column: usize, row: usize) usize {
+ pub fn setCursorPosition(self: *const SimpleTextOutputProtocol, column: usize, row: usize) Status {
return self._set_cursor_position(self, column, row);
}
/// Makes the cursor visible or invisible.
- pub fn enableCursor(self: *const SimpleTextOutputProtocol, visible: bool) usize {
+ pub fn enableCursor(self: *const SimpleTextOutputProtocol, visible: bool) Status {
return self._enable_cursor(self, visible);
}
diff --git a/lib/std/os/uefi/protocols/udp6_protocol.zig b/lib/std/os/uefi/protocols/udp6_protocol.zig
index 266f2964f9..f0ab2789f3 100644
--- a/lib/std/os/uefi/protocols/udp6_protocol.zig
+++ b/lib/std/os/uefi/protocols/udp6_protocol.zig
@@ -1,6 +1,7 @@
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
const Event = uefi.Event;
+const Status = uefi.Status;
const Time = uefi.Time;
const Ip6ModeData = uefi.protocols.Ip6ModeData;
const Ip6Address = uefi.protocols.Ip6Address;
@@ -8,39 +9,39 @@ const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData;
const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
pub const Udp6Protocol = extern struct {
- _get_mode_data: extern fn (*const Udp6Protocol, ?*Udp6ConfigData, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) usize,
- _configure: extern fn (*const Udp6Protocol, ?*const Udp6ConfigData) usize,
- _groups: extern fn (*const Udp6Protocol, bool, ?*const Ip6Address) usize,
- _transmit: extern fn (*const Udp6Protocol, *Udp6CompletionToken) usize,
- _receive: extern fn (*const Udp6Protocol, *Udp6CompletionToken) usize,
- _cancel: extern fn (*const Udp6Protocol, ?*Udp6CompletionToken) usize,
- _poll: extern fn (*const Udp6Protocol) usize,
-
- pub fn getModeData(self: *const Udp6Protocol, udp6_config_data: ?*Udp6ConfigData, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) usize {
+ _get_mode_data: extern fn (*const Udp6Protocol, ?*Udp6ConfigData, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) Status,
+ _configure: extern fn (*const Udp6Protocol, ?*const Udp6ConfigData) Status,
+ _groups: extern fn (*const Udp6Protocol, bool, ?*const Ip6Address) Status,
+ _transmit: extern fn (*const Udp6Protocol, *Udp6CompletionToken) Status,
+ _receive: extern fn (*const Udp6Protocol, *Udp6CompletionToken) Status,
+ _cancel: extern fn (*const Udp6Protocol, ?*Udp6CompletionToken) Status,
+ _poll: extern fn (*const Udp6Protocol) Status,
+
+ pub fn getModeData(self: *const Udp6Protocol, udp6_config_data: ?*Udp6ConfigData, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {
return self._get_mode_data(self, udp6_config_data, ip6_mode_data, mnp_config_data, snp_mode_data);
}
- pub fn configure(self: *const Udp6Protocol, udp6_config_data: ?*const Udp6ConfigData) usize {
+ pub fn configure(self: *const Udp6Protocol, udp6_config_data: ?*const Udp6ConfigData) Status {
return self._configure(self, udp6_config_data);
}
- pub fn groups(self: *const Udp6Protocol, join_flag: bool, multicast_address: ?*const Ip6Address) usize {
+ pub fn groups(self: *const Udp6Protocol, join_flag: bool, multicast_address: ?*const Ip6Address) Status {
return self._groups(self, join_flag, multicast_address);
}
- pub fn transmit(self: *const Udp6Protocol, token: *Udp6CompletionToken) usize {
+ pub fn transmit(self: *const Udp6Protocol, token: *Udp6CompletionToken) Status {
return self._transmit(self, token);
}
- pub fn receive(self: *const Udp6Protocol, token: *Udp6CompletionToken) usize {
+ pub fn receive(self: *const Udp6Protocol, token: *Udp6CompletionToken) Status {
return self._receive(self, token);
}
- pub fn cancel(self: *const Udp6Protocol, token: ?*Udp6CompletionToken) usize {
+ pub fn cancel(self: *const Udp6Protocol, token: ?*Udp6CompletionToken) Status {
return self._cancel(self, token);
}
- pub fn poll(self: *const Udp6Protocol) usize {
+ pub fn poll(self: *const Udp6Protocol) Status {
return self._poll(self);
}
@@ -70,7 +71,7 @@ pub const Udp6ConfigData = extern struct {
pub const Udp6CompletionToken = extern struct {
event: Event,
- status: usize,
+ Status: usize,
packet: extern union {
RxData: *Udp6ReceiveData,
TxData: *Udp6TransmitData,
diff --git a/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig b/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig
index 2f499b50c6..9a7a67807c 100644
--- a/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig
+++ b/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig
@@ -1,16 +1,17 @@
const uefi = @import("std").os.uefi;
const Handle = uefi.Handle;
const Guid = uefi.Guid;
+const Status = uefi.Status;
pub const Udp6ServiceBindingProtocol = extern struct {
- _create_child: extern fn (*const Udp6ServiceBindingProtocol, *?Handle) usize,
- _destroy_child: extern fn (*const Udp6ServiceBindingProtocol, Handle) usize,
+ _create_child: extern fn (*const Udp6ServiceBindingProtocol, *?Handle) Status,
+ _destroy_child: extern fn (*const Udp6ServiceBindingProtocol, Handle) Status,
- pub fn createChild(self: *const Udp6ServiceBindingProtocol, handle: *?Handle) usize {
+ pub fn createChild(self: *const Udp6ServiceBindingProtocol, handle: *?Handle) Status {
return self._create_child(self, handle);
}
- pub fn destroyChild(self: *const Udp6ServiceBindingProtocol, handle: Handle) usize {
+ pub fn destroyChild(self: *const Udp6ServiceBindingProtocol, handle: Handle) Status {
return self._destroy_child(self, handle);
}
diff --git a/lib/std/os/uefi/status.zig b/lib/std/os/uefi/status.zig
index 171f3cb05c..0da4508e8f 100644
--- a/lib/std/os/uefi/status.zig
+++ b/lib/std/os/uefi/status.zig
@@ -1,124 +1,142 @@
const high_bit = 1 << @typeInfo(usize).Int.bits - 1;
-/// The operation completed successfully.
-pub const success: usize = 0;
+pub const Status = extern enum(usize) {
+ /// The operation completed successfully.
+ Success = 0,
-/// The image failed to load.
-pub const load_error: usize = high_bit | 1;
+ /// The image failed to load.
+ LoadError = high_bit | 1,
-/// A parameter was incorrect.
-pub const invalid_parameter: usize = high_bit | 2;
+ /// A parameter was incorrect.
+ InvalidParameter = high_bit | 2,
-/// The operation is not supported.
-pub const unsupported: usize = high_bit | 3;
+ /// The operation is not supported.
+ Unsupported = high_bit | 3,
-/// The buffer was not the proper size for the request.
-pub const bad_buffer_size: usize = high_bit | 4;
+ /// The buffer was not the proper size for the request.
+ BadBufferSize = high_bit | 4,
-/// The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs.
-pub const buffer_too_small: usize = high_bit | 5;
+ /// The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs.
+ BufferTooSmall = high_bit | 5,
-/// There is no data pending upon return.
-pub const not_ready: usize = high_bit | 6;
+ /// There is no data pending upon return.
+ NotReady = high_bit | 6,
-/// The physical device reported an error while attempting the operation.
-pub const device_error: usize = high_bit | 7;
+ /// The physical device reported an error while attempting the operation.
+ DeviceError = high_bit | 7,
-/// The device cannot be written to.
-pub const write_protected: usize = high_bit | 8;
+ /// The device cannot be written to.
+ WriteProtected = high_bit | 8,
-/// A resource has run out.
-pub const out_of_resources: usize = high_bit | 9;
+ /// A resource has run out.
+ OutOfResources = high_bit | 9,
-/// An inconstancy was detected on the file system causing the operating to fail.
-pub const volume_corrupted: usize = high_bit | 10;
+ /// An inconstancy was detected on the file system causing the operating to fail.
+ VolumeCorrupted = high_bit | 10,
-/// There is no more space on the file system.
-pub const volume_full: usize = high_bit | 11;
+ /// There is no more space on the file system.
+ VolumeFull = high_bit | 11,
-/// The device does not contain any medium to perform the operation.
-pub const no_media: usize = high_bit | 12;
+ /// The device does not contain any medium to perform the operation.
+ NoMedia = high_bit | 12,
-/// The medium in the device has changed since the last access.
-pub const media_changed: usize = high_bit | 13;
+ /// The medium in the device has changed since the last access.
+ MediaChanged = high_bit | 13,
-/// The item was not found.
-pub const not_found: usize = high_bit | 14;
+ /// The item was not found.
+ NotFound = high_bit | 14,
-/// Access was denied.
-pub const access_denied: usize = high_bit | 15;
+ /// Access was denied.
+ AccessDenied = high_bit | 15,
-/// The server was not found or did not respond to the request.
-pub const no_response: usize = high_bit | 16;
+ /// The server was not found or did not respond to the request.
+ NoResponse = high_bit | 16,
-/// A mapping to a device does not exist.
-pub const no_mapping: usize = high_bit | 17;
+ /// A mapping to a device does not exist.
+ NoMapping = high_bit | 17,
-/// The timeout time expired.
-pub const timeout: usize = high_bit | 18;
+ /// The timeout time expired.
+ Timeout = high_bit | 18,
-/// The protocol has not been started.
-pub const not_started: usize = high_bit | 19;
+ /// The protocol has not been started.
+ NotStarted = high_bit | 19,
-/// The protocol has already been started.
-pub const already_started: usize = high_bit | 20;
+ /// The protocol has already been started.
+ AlreadyStarted = high_bit | 20,
-/// The operation was aborted.
-pub const aborted: usize = high_bit | 21;
+ /// The operation was aborted.
+ Aborted = high_bit | 21,
-/// An ICMP error occurred during the network operation.
-pub const icmp_error: usize = high_bit | 22;
+ /// An ICMP error occurred during the network operation.
+ IcmpError = high_bit | 22,
-/// A TFTP error occurred during the network operation.
-pub const tftp_error: usize = high_bit | 23;
+ /// A TFTP error occurred during the network operation.
+ TftpError = high_bit | 23,
-/// A protocol error occurred during the network operation.
-pub const protocol_error: usize = high_bit | 24;
+ /// A protocol error occurred during the network operation.
+ ProtocolError = high_bit | 24,
-/// The function encountered an internal version that was incompatible with a version requested by the caller.
-pub const incompatible_version: usize = high_bit | 25;
+ /// The function encountered an internal version that was incompatible with a version requested by the caller.
+ IncompatibleVersion = high_bit | 25,
-/// The function was not performed due to a security violation.
-pub const security_violation: usize = high_bit | 26;
+ /// The function was not performed due to a security violation.
+ SecurityViolation = high_bit | 26,
-/// A CRC error was detected.
-pub const crc_error: usize = high_bit | 27;
+ /// A CRC error was detected.
+ CrcError = high_bit | 27,
-/// Beginning or end of media was reached
-pub const end_of_media: usize = high_bit | 28;
+ /// Beginning or end of media was reached
+ EndOfMedia = high_bit | 28,
-/// The end of the file was reached.
-pub const end_of_file: usize = high_bit | 31;
+ /// The end of the file was reached.
+ EndOfFile = high_bit | 31,
-/// The language specified was invalid.
-pub const invalid_language: usize = high_bit | 32;
+ /// The language specified was invalid.
+ InvalidLanguage = high_bit | 32,
-/// The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status.
-pub const compromised_data: usize = high_bit | 33;
+ /// The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status.
+ CompromisedData = high_bit | 33,
-/// There is an address conflict address allocation
-pub const ip_address_conflict: usize = high_bit | 34;
+ /// There is an address conflict address allocation
+ IpAddressConflict = high_bit | 34,
-/// A HTTP error occurred during the network operation.
-pub const http_error: usize = high_bit | 35;
+ /// A HTTP error occurred during the network operation.
+ HttpError = high_bit | 35,
-/// The string contained one or more characters that the device could not render and were skipped.
-pub const warn_unknown_glyph: usize = 1;
+ NetworkUnreachable = high_bit | 100,
-/// The handle was closed, but the file was not deleted.
-pub const warn_delete_failure: usize = 2;
+ HostUnreachable = high_bit | 101,
-/// The handle was closed, but the data to the file was not flushed properly.
-pub const warn_write_failure: usize = 3;
+ ProtocolUnreachable = high_bit | 102,
-/// The resulting buffer was too small, and the data was truncated to the buffer size.
-pub const warn_buffer_too_small: usize = 4;
+ PortUnreachable = high_bit | 103,
-/// The data has not been updated within the timeframe set by localpolicy for this type of data.
-pub const warn_stale_data: usize = 5;
+ ConnectionFin = high_bit | 104,
-/// The resulting buffer contains UEFI-compliant file system.
-pub const warn_file_system: usize = 6;
+ ConnectionReset = high_bit | 105,
-/// The operation will be processed across a system reset.
-pub const warn_reset_required: usize = 7;
+ ConnectionRefused = high_bit | 106,
+
+ /// The string contained one or more characters that the device could not render and were skipped.
+ WarnUnknownGlyph = 1,
+
+ /// The handle was closed, but the file was not deleted.
+ WarnDeleteFailure = 2,
+
+ /// The handle was closed, but the data to the file was not flushed properly.
+ WarnWriteFailure = 3,
+
+ /// The resulting buffer was too small, and the data was truncated to the buffer size.
+ WarnBufferTooSmall = 4,
+
+ /// The data has not been updated within the timeframe set by localpolicy for this type of data.
+ WarnStaleData = 5,
+
+ /// The resulting buffer contains UEFI-compliant file system.
+ WarnFileSystem = 6,
+
+ /// The operation will be processed across a system reset.
+ WarnResetRequired = 7,
+
+ _,
+};
diff --git a/lib/std/os/uefi/tables.zig b/lib/std/os/uefi/tables.zig
index d34408dfba..0011c80a9c 100644
--- a/lib/std/os/uefi/tables.zig
+++ b/lib/std/os/uefi/tables.zig
@@ -1,3 +1,4 @@
+pub const AllocateType = @import("tables/boot_services.zig").AllocateType;
pub const BootServices = @import("tables/boot_services.zig").BootServices;
pub const ConfigurationTable = @import("tables/configuration_table.zig").ConfigurationTable;
pub const global_variable align(8) = @import("tables/runtime_services.zig").global_variable;
diff --git a/lib/std/os/uefi/tables/boot_services.zig b/lib/std/os/uefi/tables/boot_services.zig
index 2358b4f842..1969b46403 100644
--- a/lib/std/os/uefi/tables/boot_services.zig
+++ b/lib/std/os/uefi/tables/boot_services.zig
@@ -2,6 +2,7 @@ const uefi = @import("std").os.uefi;
const Event = uefi.Event;
const Guid = uefi.Guid;
const Handle = uefi.Handle;
+const Status = uefi.Status;
const TableHeader = uefi.tables.TableHeader;
const DevicePathProtocol = uefi.protocols.DevicePathProtocol;
@@ -19,101 +20,120 @@ const DevicePathProtocol = uefi.protocols.DevicePathProtocol;
pub const BootServices = extern struct {
hdr: TableHeader,
- raiseTpl: usize, // TODO
- restoreTpl: usize, // TODO
- allocatePages: usize, // TODO
- freePages: usize, // TODO
+ /// Raises a task's priority level and returns its previous level.
+ raiseTpl: extern fn (usize) usize,
+
+ /// Restores a task's priority level to its previous value.
+ restoreTpl: extern fn (usize) void,
+
+ /// Allocates memory pages from the system.
+ allocatePages: extern fn (AllocateType, MemoryType, usize, *[*]align(4096) u8) Status,
+
+ /// Frees memory pages.
+ freePages: extern fn ([*]align(4096) u8, usize) Status,
/// Returns the current memory map.
- getMemoryMap: extern fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) usize,
+ getMemoryMap: extern fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) Status,
/// Allocates pool memory.
- allocatePool: extern fn (MemoryType, usize, *align(8) [*]u8) usize,
+ allocatePool: extern fn (MemoryType, usize, *[*]align(8) u8) Status,
/// Returns pool memory to the system.
- freePool: extern fn ([*]align(8) u8) usize,
+ freePool: extern fn ([*]align(8) u8) Status,
/// Creates an event.
- createEvent: extern fn (u32, usize, ?extern fn (Event, ?*c_void) void, ?*const c_void, *Event) usize,
+ createEvent: extern fn (u32, usize, ?extern fn (Event, ?*c_void) void, ?*const c_void, *Event) Status,
/// Sets the type of timer and the trigger time for a timer event.
- setTimer: extern fn (Event, TimerDelay, u64) usize,
+ setTimer: extern fn (Event, TimerDelay, u64) Status,
/// Stops execution until an event is signaled.
- waitForEvent: extern fn (usize, [*]const Event, *usize) usize,
+ waitForEvent: extern fn (usize, [*]const Event, *usize) Status,
/// Signals an event.
- signalEvent: extern fn (Event) usize,
+ signalEvent: extern fn (Event) Status,
/// Closes an event.
- closeEvent: extern fn (Event) usize,
+ closeEvent: extern fn (Event) Status,
/// Checks whether an event is in the signaled state.
- checkEvent: extern fn (Event) usize,
+ checkEvent: extern fn (Event) Status,
- installProtocolInterface: usize, // TODO
- reinstallProtocolInterface: usize, // TODO
- uninstallProtocolInterface: usize, // TODO
+ installProtocolInterface: Status, // TODO
+ reinstallProtocolInterface: Status, // TODO
+ uninstallProtocolInterface: Status, // TODO
/// Queries a handle to determine if it supports a specified protocol.
- handleProtocol: extern fn (Handle, *align(8) const Guid, *?*c_void) usize,
+ handleProtocol: extern fn (Handle, *align(8) const Guid, *?*c_void) Status,
reserved: *c_void,
- registerProtocolNotify: usize, // TODO
- locateHandle: usize, // TODO
- locateDevicePath: usize, // TODO
- installConfigurationTable: usize, // TODO
+ registerProtocolNotify: Status, // TODO
+
+ /// Returns an array of handles that support a specified protocol.
+ locateHandle: extern fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, [*]Handle) Status,
+
+ locateDevicePath: Status, // TODO
+ installConfigurationTable: Status, // TODO
/// Loads an EFI image into memory.
- loadImage: extern fn (bool, Handle, ?*const DevicePathProtocol, ?[*]const u8, usize, *?Handle) usize,
+ loadImage: extern fn (bool, Handle, ?*const DevicePathProtocol, ?[*]const u8, usize, *?Handle) Status,
/// Transfers control to a loaded image's entry point.
- startImage: extern fn (Handle, ?*usize, ?*[*]u16) usize,
+ startImage: extern fn (Handle, ?*usize, ?*[*]u16) Status,
/// Terminates a loaded EFI image and returns control to boot services.
- exit: extern fn (Handle, usize, usize, ?*const c_void) usize,
+ exit: extern fn (Handle, Status, usize, ?*const c_void) Status,
/// Unloads an image.
- unloadImage: extern fn (Handle) usize,
+ unloadImage: extern fn (Handle) Status,
/// Terminates all boot services.
- exitBootServices: extern fn (Handle, usize) usize,
+ exitBootServices: extern fn (Handle, usize) Status,
- getNextMonotonicCount: usize, // TODO
+ /// Returns a monotonically increasing count for the platform.
+ getNextMonotonicCount: extern fn (*u64) Status,
/// Induces a fine-grained stall.
- stall: extern fn (usize) usize,
+ stall: extern fn (usize) Status,
/// Sets the system's watchdog timer.
- setWatchdogTimer: extern fn (usize, u64, usize, ?[*]const u16) usize,
+ setWatchdogTimer: extern fn (usize, u64, usize, ?[*]const u16) Status,
- connectController: usize, // TODO
- disconnectController: usize, // TODO
+ connectController: Status, // TODO
+ disconnectController: Status, // TODO
/// Queries a handle to determine if it supports a specified protocol.
- openProtocol: extern fn (Handle, *align(8) const Guid, *?*c_void, ?Handle, ?Handle, OpenProtocolAttributes) usize,
+ openProtocol: extern fn (Handle, *align(8) const Guid, *?*c_void, ?Handle, ?Handle, OpenProtocolAttributes) Status,
/// Closes a protocol on a handle that was opened using openProtocol().
- closeProtocol: extern fn (Handle, *align(8) const Guid, Handle, ?Handle) usize,
+ closeProtocol: extern fn (Handle, *align(8) const Guid, Handle, ?Handle) Status,
/// Retrieves the list of agents that currently have a protocol interface opened.
- openProtocolInformation: extern fn (Handle, *align(8) const Guid, *[*]ProtocolInformationEntry, *usize) usize,
+ openProtocolInformation: extern fn (Handle, *align(8) const Guid, *[*]ProtocolInformationEntry, *usize) Status,
- protocolsPerHandle: usize, // TODO
+ /// Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated from pool.
+ protocolsPerHandle: extern fn (Handle, *[*]*align(8) const Guid, *usize) Status,
/// Returns an array of handles that support the requested protocol in a buffer allocated from pool.
- locateHandleBuffer: extern fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, *[*]Handle) usize,
+ locateHandleBuffer: extern fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, *[*]Handle) Status,
/// Returns the first protocol instance that matches the given protocol.
- locateProtocol: extern fn (*align(8) const Guid, ?*const c_void, *?*c_void) usize,
+ locateProtocol: extern fn (*align(8) const Guid, ?*const c_void, *?*c_void) Status,
+
+ installMultipleProtocolInterfaces: Status, // TODO
+ uninstallMultipleProtocolInterfaces: Status, // TODO
- installMultipleProtocolInterfaces: usize, // TODO
- uninstallMultipleProtocolInterfaces: usize, // TODO
- calculateCrc32: usize, // TODO
- copyMem: usize, // TODO
- setMem: usize, // TODO
- createEventEx: usize, // TODO
+ /// Computes and returns a 32-bit CRC for a data buffer.
+ calculateCrc32: extern fn ([*]const u8, usize, *u32) Status,
+
+ /// Copies the contents of one buffer to another buffer
+ copyMem: extern fn ([*]u8, [*]const u8, usize) void,
+
+ /// Fills a buffer with a specified value
+ setMem: extern fn ([*]u8, usize, u8) void,
+
+ createEventEx: Status, // TODO
pub const signature: u64 = 0x56524553544f4f42;
@@ -187,13 +207,13 @@ pub const LocateSearchType = extern enum(u32) {
};
pub const OpenProtocolAttributes = packed struct {
- by_handle_protocol: bool,
- get_protocol: bool,
- test_protocol: bool,
- by_child_controller: bool,
- by_driver: bool,
- exclusive: bool,
- _pad: u26,
+ 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,
+ _pad: u26 = undefined,
};
pub const ProtocolInformationEntry = extern struct {
@@ -202,3 +222,9 @@ pub const ProtocolInformationEntry = extern struct {
attributes: OpenProtocolAttributes,
open_count: u32,
};
+
+pub const AllocateType = extern enum(u32) {
+ AllocateAnyPages,
+ AllocateMaxAddress,
+ AllocateAddress,
+};
diff --git a/lib/std/os/uefi/tables/runtime_services.zig b/lib/std/os/uefi/tables/runtime_services.zig
index 9e6861377b..1f0c7efad4 100644
--- a/lib/std/os/uefi/tables/runtime_services.zig
+++ b/lib/std/os/uefi/tables/runtime_services.zig
@@ -3,6 +3,7 @@ const Guid = uefi.Guid;
const TableHeader = uefi.tables.TableHeader;
const Time = uefi.Time;
const TimeCapabilities = uefi.TimeCapabilities;
+const Status = uefi.Status;
/// Runtime services are provided by the firmware before and after exitBootServices has been called.
///
@@ -16,31 +17,31 @@ pub const RuntimeServices = extern struct {
hdr: TableHeader,
/// Returns the current time and date information, and the time-keeping capabilities of the hardware platform.
- getTime: extern fn (*uefi.Time, ?*TimeCapabilities) usize,
+ getTime: extern fn (*uefi.Time, ?*TimeCapabilities) Status,
- setTime: usize, // TODO
- getWakeupTime: usize, // TODO
- setWakeupTime: usize, // TODO
- setVirtualAddressMap: usize, // TODO
- convertPointer: usize, // TODO
+ setTime: Status, // TODO
+ getWakeupTime: Status, // TODO
+ setWakeupTime: Status, // TODO
+ setVirtualAddressMap: Status, // TODO
+ convertPointer: Status, // TODO
/// Returns the value of a variable.
- getVariable: extern fn ([*:0]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) usize,
+ getVariable: extern fn ([*:0]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) Status,
/// Enumerates the current variable names.
- getNextVariableName: extern fn (*usize, [*]u16, *align(8) Guid) usize,
+ getNextVariableName: extern fn (*usize, [*:0]u16, *align(8) Guid) Status,
/// Sets the value of a variable.
- setVariable: extern fn ([*:0]const u16, *align(8) const Guid, u32, usize, *c_void) usize,
+ setVariable: extern fn ([*:0]const u16, *align(8) const Guid, u32, usize, *c_void) Status,
- getNextHighMonotonicCount: usize, // TODO
+ getNextHighMonotonicCount: Status, // TODO
/// Resets the entire platform.
- resetSystem: extern fn (ResetType, usize, usize, ?*const c_void) noreturn,
+ resetSystem: extern fn (ResetType, Status, usize, ?*const c_void) noreturn,
- updateCapsule: usize, // TODO
- queryCapsuleCapabilities: usize, // TODO
- queryVariableInfo: usize, // TODO
+ updateCapsule: Status, // TODO
+ queryCapsuleCapabilities: Status, // TODO
+ queryVariableInfo: Status, // TODO
pub const signature: u64 = 0x56524553544e5552;
};
diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig
index ba55845a4f..6c9a1f24b7 100644
--- a/lib/std/os/windows.zig
+++ b/lib/std/os/windows.zig
@@ -407,6 +407,7 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64) ReadFileError!usiz
switch (kernel32.GetLastError()) {
.OPERATION_ABORTED => continue,
.BROKEN_PIPE => return index,
+ .HANDLE_EOF => return index,
else => |err| return unexpectedError(err),
}
}
@@ -591,6 +592,8 @@ pub const CreateDirectoryError = error{
FileNotFound,
NoDevice,
AccessDenied,
+ InvalidUtf8,
+ BadPathName,
Unexpected,
};
diff --git a/lib/std/os/windows/bits.zig b/lib/std/os/windows/bits.zig
index 41466234ed..1e49b903cb 100644
--- a/lib/std/os/windows/bits.zig
+++ b/lib/std/os/windows/bits.zig
@@ -225,6 +225,10 @@ pub const FILE_POSITION_INFORMATION = extern struct {
CurrentByteOffset: LARGE_INTEGER,
};
+pub const FILE_END_OF_FILE_INFORMATION = extern struct {
+ EndOfFile: LARGE_INTEGER,
+};
+
pub const FILE_MODE_INFORMATION = extern struct {
Mode: ULONG,
};
diff --git a/lib/std/os/windows/kernel32.zig b/lib/std/os/windows/kernel32.zig
index 05a7a8f6a3..2e5214eb20 100644
--- a/lib/std/os/windows/kernel32.zig
+++ b/lib/std/os/windows/kernel32.zig
@@ -8,6 +8,7 @@ pub extern "kernel32" fn CancelIoEx(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) c
pub extern "kernel32" fn CloseHandle(hObject: HANDLE) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn CreateDirectoryW(lpPathName: [*:0]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES) callconv(.Stdcall) BOOL;
+pub extern "kernel32" fn SetEndOfFile(hFile: HANDLE) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn CreateEventExW(
lpEventAttributes: ?*SECURITY_ATTRIBUTES,
diff --git a/lib/std/os/windows/ntdll.zig b/lib/std/os/windows/ntdll.zig
index 49e60803bc..7ba58b2392 100644
--- a/lib/std/os/windows/ntdll.zig
+++ b/lib/std/os/windows/ntdll.zig
@@ -16,6 +16,13 @@ pub extern "NtDll" fn NtQueryInformationFile(
Length: ULONG,
FileInformationClass: FILE_INFORMATION_CLASS,
) callconv(.Stdcall) NTSTATUS;
+pub extern "NtDll" fn NtSetInformationFile(
+ FileHandle: HANDLE,
+ IoStatusBlock: *IO_STATUS_BLOCK,
+ FileInformation: PVOID,
+ Length: ULONG,
+ FileInformationClass: FILE_INFORMATION_CLASS,
+) callconv(.Stdcall) NTSTATUS;
pub extern "NtDll" fn NtQueryAttributesFile(
ObjectAttributes: *OBJECT_ATTRIBUTES,