authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-06 23:19:46-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-11-06 23:19:46-05:00
logc7fd414dab3c69819c6528e8dcbb9de8ab17cdf9
tree941a72a599ee3048dd29d5a61b21c855199a2dc7
parent6ee3cabe5cc0b2c9af30b1fa0233381faa18e700
parent78b54d9c96c84e286b20a2a144eca0b9ddc3fba5
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #3618 from nrdmn/uefi

UEFI improvements

15 files changed, 857 insertions(+), 11 deletions(-)

lib/std/os/uefi/protocols.zig+44
......@@ -1,3 +1,7 @@
1pub const LoadedImageProtocol = @import("protocols/loaded_image_protocol.zig").LoadedImageProtocol;
2
3pub const DevicePathProtocol = @import("protocols/device_path_protocol.zig").DevicePathProtocol;
4
15pub const InputKey = @import("protocols/simple_text_input_ex_protocol.zig").InputKey;
26pub const KeyData = @import("protocols/simple_text_input_ex_protocol.zig").KeyData;
37pub const KeyState = @import("protocols/simple_text_input_ex_protocol.zig").KeyState;
......@@ -29,6 +33,46 @@ pub const EdidActiveProtocol = @import("protocols/edid_active_protocol.zig").Edi
2933pub const EdidOverrideProtocol = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocol;
3034pub const EdidOverrideProtocolAttributes = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocolAttributes;
3135
36pub const SimpleNetworkProtocol = @import("protocols/simple_network_protocol.zig").SimpleNetworkProtocol;
37pub const MacAddress = @import("protocols/simple_network_protocol.zig").MacAddress;
38pub const SimpleNetworkMode = @import("protocols/simple_network_protocol.zig").SimpleNetworkMode;
39pub const SimpleNetworkReceiveFilter = @import("protocols/simple_network_protocol.zig").SimpleNetworkReceiveFilter;
40pub const SimpleNetworkState = @import("protocols/simple_network_protocol.zig").SimpleNetworkState;
41pub const NetworkStatistics = @import("protocols/simple_network_protocol.zig").NetworkStatistics;
42pub const SimpleNetworkInterruptStatus = @import("protocols/simple_network_protocol.zig").SimpleNetworkInterruptStatus;
43
44pub const ManagedNetworkServiceBindingProtocol = @import("protocols/managed_network_service_binding_protocol.zig").ManagedNetworkServiceBindingProtocol;
45pub const ManagedNetworkProtocol = @import("protocols/managed_network_protocol.zig").ManagedNetworkProtocol;
46pub const ManagedNetworkConfigData = @import("protocols/managed_network_protocol.zig").ManagedNetworkConfigData;
47pub const ManagedNetworkCompletionToken = @import("protocols/managed_network_protocol.zig").ManagedNetworkCompletionToken;
48pub const ManagedNetworkReceiveData = @import("protocols/managed_network_protocol.zig").ManagedNetworkReceiveData;
49pub const ManagedNetworkTransmitData = @import("protocols/managed_network_protocol.zig").ManagedNetworkTransmitData;
50pub const ManagedNetworkFragmentData = @import("protocols/managed_network_protocol.zig").ManagedNetworkFragmentData;
51
52pub const Ip6ServiceBindingProtocol = @import("protocols/ip6_service_binding_protocol.zig").Ip6ServiceBindingProtocol;
53pub const Ip6Protocol = @import("protocols/ip6_protocol.zig").Ip6Protocol;
54pub const Ip6ModeData = @import("protocols/ip6_protocol.zig").Ip6ModeData;
55pub const Ip6ConfigData = @import("protocols/ip6_protocol.zig").Ip6ConfigData;
56pub const Ip6Address = @import("protocols/ip6_protocol.zig").Ip6Address;
57pub const Ip6AddressInfo = @import("protocols/ip6_protocol.zig").Ip6AddressInfo;
58pub const Ip6RouteTable = @import("protocols/ip6_protocol.zig").Ip6RouteTable;
59pub const Ip6NeighborState = @import("protocols/ip6_protocol.zig").Ip6NeighborState;
60pub const Ip6NeighborCache = @import("protocols/ip6_protocol.zig").Ip6NeighborCache;
61pub const Ip6IcmpType = @import("protocols/ip6_protocol.zig").Ip6IcmpType;
62pub const Ip6CompletionToken = @import("protocols/ip6_protocol.zig").Ip6CompletionToken;
63
64pub const Ip6ConfigProtocol = @import("protocols/ip6_config_protocol.zig").Ip6ConfigProtocol;
65pub const Ip6ConfigDataType = @import("protocols/ip6_config_protocol.zig").Ip6ConfigDataType;
66
67pub const Udp6ServiceBindingProtocol = @import("protocols/udp6_service_binding_protocol.zig").Udp6ServiceBindingProtocol;
68pub const Udp6Protocol = @import("protocols/udp6_protocol.zig").Udp6Protocol;
69pub const Udp6ConfigData = @import("protocols/udp6_protocol.zig").Udp6ConfigData;
70pub const Udp6CompletionToken = @import("protocols/udp6_protocol.zig").Udp6CompletionToken;
71pub const Udp6ReceiveData = @import("protocols/udp6_protocol.zig").Udp6ReceiveData;
72pub const Udp6TransmitData = @import("protocols/udp6_protocol.zig").Udp6TransmitData;
73pub const Udp6SessionData = @import("protocols/udp6_protocol.zig").Udp6SessionData;
74pub const Udp6FragmentData = @import("protocols/udp6_protocol.zig").Udp6FragmentData;
75
3276pub const hii = @import("protocols/hii.zig");
3377pub const HIIDatabaseProtocol = @import("protocols/hii_database_protocol.zig").HIIDatabaseProtocol;
3478pub const HIIPopupProtocol = @import("protocols/hii_popup_protocol.zig").HIIPopupProtocol;
lib/std/os/uefi/protocols/device_path_protocol.zig created+17
......@@ -0,0 +1,17 @@
1const uefi = @import("std").os.uefi;
2const Guid = uefi.Guid;
3
4pub const DevicePathProtocol = extern struct {
5 type: u8,
6 subtype: u8,
7 length: u16,
8
9 pub const guid align(8) = Guid{
10 .time_low = 0x09576e91,
11 .time_mid = 0x6d3f,
12 .time_high_and_version = 0x11d2,
13 .clock_seq_high_and_reserved = 0x8e,
14 .clock_seq_low = 0x39,
15 .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
16 };
17};
lib/std/os/uefi/protocols/ip6_config_protocol.zig created+45
......@@ -0,0 +1,45 @@
1const uefi = @import("std").os.uefi;
2const Guid = uefi.Guid;
3const Event = uefi.Event;
4
5pub const Ip6ConfigProtocol = extern struct {
6 _set_data: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, usize, *const c_void) usize,
7 _get_data: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, *usize, ?*const c_void) usize,
8 _register_data_notify: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) usize,
9 _unregister_data_notify: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) usize,
10
11 pub fn setData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: usize, data: *const c_void) usize {
12 return self._set_data(self, data_type, data_size, data);
13 }
14
15 pub fn getData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: *usize, data: ?*const c_void) usize {
16 return self._get_data(self, data_type, data_size, data);
17 }
18
19 pub fn registerDataNotify(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, event: Event) usize {
20 return self._register_data_notify(self, data_type, event);
21 }
22
23 pub fn unregisterDataNotify(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, event: Event) usize {
24 return self._unregister_data_notify(self, data_type, event);
25 }
26
27 pub const guid align(8) = Guid{
28 .time_low = 0x937fe521,
29 .time_mid = 0x95ae,
30 .time_high_and_version = 0x4d1a,
31 .clock_seq_high_and_reserved = 0x89,
32 .clock_seq_low = 0x29,
33 .node = [_]u8{ 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a },
34 };
35};
36
37pub const Ip6ConfigDataType = extern enum(u32) {
38 InterfaceInfo,
39 AltInterfaceId,
40 Policy,
41 DupAddrDetectTransmits,
42 ManualAddress,
43 Gateway,
44 DnsServer,
45};
lib/std/os/uefi/protocols/ip6_protocol.zig created+143
......@@ -0,0 +1,143 @@
1const uefi = @import("std").os.uefi;
2const Guid = uefi.Guid;
3const Event = uefi.Event;
4const MacAddress = uefi.protocols.MacAddress;
5const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData;
6const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
7
8pub const Ip6Protocol = extern struct {
9 _get_mode_data: extern fn (*const Ip6Protocol, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) usize,
10 _configure: extern fn (*const Ip6Protocol, ?*const Ip6ConfigData) usize,
11 _groups: extern fn (*const Ip6Protocol, bool, ?*const Ip6Address) usize,
12 _routes: extern fn (*const Ip6Protocol, bool, ?*const Ip6Address, u8, ?*const Ip6Address) usize,
13 _neighbors: extern fn (*const Ip6Protocol, bool, *const Ip6Address, ?*const MacAddress, u32, bool) usize,
14 _transmit: extern fn (*const Ip6Protocol, *Ip6CompletionToken) usize,
15 _receive: extern fn (*const Ip6Protocol, *Ip6CompletionToken) usize,
16 _cancel: extern fn (*const Ip6Protocol, ?*Ip6CompletionToken) usize,
17 _poll: extern fn (*const Ip6Protocol) usize,
18
19 /// Gets the current operational settings for this instance of the EFI IPv6 Protocol driver.
20 pub fn getModeData(self: *const Ip6Protocol, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) usize {
21 return self._get_mode_data(self, ip6_mode_data, mnp_config_data, snp_mode_data);
22 }
23
24 /// Assign IPv6 address and other configuration parameter to this EFI IPv6 Protocol driver instance.
25 pub fn configure(self: *const Ip6Protocol, ip6_config_data: ?*const Ip6ConfigData) usize {
26 return self._configure(self, ip6_config_data);
27 }
28
29 /// Joins and leaves multicast groups.
30 pub fn groups(self: *const Ip6Protocol, join_flag: bool, group_address: ?*const Ip6Address) usize {
31 return self._groups(self, join_flag, group_address);
32 }
33
34 /// Adds and deletes routing table entries.
35 pub fn routes(self: *const Ip6Protocol, delete_route: bool, destination: ?*const Ip6Address, prefix_length: u8, gateway_address: ?*const Ip6Address) usize {
36 return self._routes(self, delete_route, destination, prefix_length, gateway_address);
37 }
38
39 /// Add or delete Neighbor cache entries.
40 pub fn neighbors(self: *const Ip6Protocol, delete_flag: bool, target_ip6_address: *const Ip6Address, target_link_address: ?*const MacAddress, timeout: u32, override: bool) usize {
41 return self._neighbors(self, delete_flag, target_ip6_address, target_link_address, timeout, override);
42 }
43
44 /// Places outgoing data packets into the transmit queue.
45 pub fn transmit(self: *const Ip6Protocol, token: *Ip6CompletionToken) usize {
46 return self._transmit(self, token);
47 }
48
49 /// Places a receiving request into the receiving queue.
50 pub fn receive(self: *const Ip6Protocol, token: *Ip6CompletionToken) usize {
51 return self._receive(self, token);
52 }
53
54 /// Abort an asynchronous transmits or receive request.
55 pub fn cancel(self: *const Ip6Protocol, token: ?*Ip6CompletionToken) usize {
56 return self._cancel(self, token);
57 }
58
59 /// Polls for incoming data packets and processes outgoing data packets.
60 pub fn poll(self: *const Ip6Protocol) usize {
61 return self._poll(self);
62 }
63
64 pub const guid align(8) = Guid{
65 .time_low = 0x2c8759d5,
66 .time_mid = 0x5c2d,
67 .time_high_and_version = 0x66ef,
68 .clock_seq_high_and_reserved = 0x92,
69 .clock_seq_low = 0x5f,
70 .node = [_]u8{ 0xb6, 0x6c, 0x10, 0x19, 0x57, 0xe2 },
71 };
72};
73
74pub const Ip6ModeData = extern struct {
75 is_started: bool,
76 max_packet_size: u32,
77 config_data: Ip6ConfigData,
78 is_configured: bool,
79 address_count: u32,
80 address_list: [*]Ip6AddressInfo,
81 group_count: u32,
82 group_table: [*]Ip6Address,
83 route_count: u32,
84 route_table: [*]Ip6RouteTable,
85 neighbor_count: u32,
86 neighbor_cache: [*]Ip6NeighborCache,
87 prefix_count: u32,
88 prefix_table: [*]Ip6AddressInfo,
89 icmp_type_count: u32,
90 icmp_type_list: [*]Ip6IcmpType,
91};
92
93pub const Ip6ConfigData = extern struct {
94 default_protocol: u8,
95 accept_any_protocol: bool,
96 accept_icmp_errors: bool,
97 accept_promiscuous: bool,
98 destination_address: Ip6Address,
99 station_address: Ip6Address,
100 traffic_class: u8,
101 hop_limit: u8,
102 flow_label: u32,
103 receive_timeout: u32,
104 transmit_timeout: u32,
105};
106
107pub const Ip6Address = [16]u8;
108
109pub const Ip6AddressInfo = extern struct {
110 address: Ip6Address,
111 prefix_length: u8,
112};
113
114pub const Ip6RouteTable = extern struct {
115 gateway: Ip6Address,
116 destination: Ip6Address,
117 prefix_length: u8,
118};
119
120pub const Ip6NeighborState = extern enum(u32) {
121 Incomplete,
122 Reachable,
123 Stale,
124 Delay,
125 Probe,
126};
127
128pub const Ip6NeighborCache = extern struct {
129 neighbor: Ip6Address,
130 link_address: MacAddress,
131 state: Ip6NeighborState,
132};
133
134pub const Ip6IcmpType = extern struct {
135 type: u8,
136 code: u8,
137};
138
139pub const Ip6CompletionToken = extern struct {
140 event: Event,
141 status: usize,
142 packet: *c_void, // union TODO
143};
lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig created+25
......@@ -0,0 +1,25 @@
1const uefi = @import("std").os.uefi;
2const Handle = uefi.Handle;
3const Guid = uefi.Guid;
4
5pub const Ip6ServiceBindingProtocol = extern struct {
6 _create_child: extern fn (*const Ip6ServiceBindingProtocol, *?Handle) usize,
7 _destroy_child: extern fn (*const Ip6ServiceBindingProtocol, Handle) usize,
8
9 pub fn createChild(self: *const Ip6ServiceBindingProtocol, handle: *?Handle) usize {
10 return self._create_child(self, handle);
11 }
12
13 pub fn destroyChild(self: *const Ip6ServiceBindingProtocol, handle: Handle) usize {
14 return self._destroy_child(self, handle);
15 }
16
17 pub const guid align(8) = Guid{
18 .time_low = 0xec835dd3,
19 .time_mid = 0xfe0f,
20 .time_high_and_version = 0x617b,
21 .clock_seq_high_and_reserved = 0xa6,
22 .clock_seq_low = 0x21,
23 .node = [_]u8{ 0xb3, 0x50, 0xc3, 0xe1, 0x33, 0x88 },
24 };
25};
lib/std/os/uefi/protocols/loaded_image_protocol.zig created+36
......@@ -0,0 +1,36 @@
1const uefi = @import("std").os.uefi;
2const Guid = uefi.Guid;
3const Handle = uefi.Handle;
4const SystemTable = uefi.tables.SystemTable;
5const MemoryType = uefi.tables.MemoryType;
6const DevicePathProtocol = uefi.protocols.DevicePathProtocol;
7
8pub const LoadedImageProtocol = extern struct {
9 revision: u32,
10 parent_handle: Handle,
11 system_table: *SystemTable,
12 device_handle: ?Handle,
13 file_path: *DevicePathProtocol,
14 reserved: *c_void,
15 load_options_size: u32,
16 load_options: *c_void,
17 image_base: [*]u8,
18 image_size: u64,
19 image_code_type: MemoryType,
20 image_data_type: MemoryType,
21 _unload: extern fn (*const LoadedImageProtocol, Handle) usize,
22
23 /// Unloads an image from memory.
24 pub fn unload(self: *const LoadedImageProtocol, handle: Handle) usize {
25 return self._unload(self, handle);
26 }
27
28 pub const guid align(8) = Guid{
29 .time_low = 0x5b1b31a1,
30 .time_mid = 0x9562,
31 .time_high_and_version = 0x11d2,
32 .clock_seq_high_and_reserved = 0x8e,
33 .clock_seq_low = 0x3f,
34 .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
35 };
36};
lib/std/os/uefi/protocols/managed_network_protocol.zig created+126
......@@ -0,0 +1,126 @@
1const uefi = @import("std").os.uefi;
2const Guid = uefi.Guid;
3const Event = uefi.Event;
4const Time = uefi.Time;
5const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
6const MacAddress = uefi.protocols.MacAddress;
7
8pub const ManagedNetworkProtocol = extern struct {
9 _get_mode_data: extern fn (*const ManagedNetworkProtocol, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) usize,
10 _configure: extern fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkConfigData) usize,
11 _mcast_ip_to_mac: extern fn (*const ManagedNetworkProtocol, bool, *const c_void, *MacAddress) usize,
12 _groups: extern fn (*const ManagedNetworkProtocol, bool, ?*const MacAddress) usize,
13 _transmit: extern fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) usize,
14 _receive: extern fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) usize,
15 _cancel: extern fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkCompletionToken) usize,
16 _poll: extern fn (*const ManagedNetworkProtocol) usize,
17
18 /// Returns the operational parameters for the current MNP child driver.
19 /// May also support returning the underlying SNP driver mode data.
20 pub fn getModeData(self: *const ManagedNetworkProtocol, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) usize {
21 return self._get_mode_data(self, mnp_config_data, snp_mode_data);
22 }
23
24 /// Sets or clears the operational parameters for the MNP child driver.
25 pub fn configure(self: *const ManagedNetworkProtocol, mnp_config_data: ?*const ManagedNetworkConfigData) usize {
26 return self._configure(self, mnp_config_data);
27 }
28
29 /// Translates an IP multicast address to a hardware (MAC) multicast address.
30 /// This function may be unsupported in some MNP implementations.
31 pub fn mcastIpToMac(self: *const ManagedNetworkProtocol, ipv6flag: bool, ipaddress: *const c_void, mac_address: *MacAddress) usize {
32 return self._mcast_ip_to_mac(self, ipv6flag, ipaddress);
33 }
34
35 /// Enables and disables receive filters for multicast address.
36 /// This function may be unsupported in some MNP implementations.
37 pub fn groups(self: *const ManagedNetworkProtocol, join_flag: bool, mac_address: ?*const MacAddress) usiz {
38 return self._groups(self, join_flag, mac_address);
39 }
40
41 /// Places asynchronous outgoing data packets into the transmit queue.
42 pub fn transmit(self: *const ManagedNetworkProtocol, token: *const ManagedNetworkCompletionToken) usize {
43 return self._transmit(self, token);
44 }
45
46 /// Places an asynchronous receiving request into the receiving queue.
47 pub fn receive(self: *const ManagedNetworkProtocol, token: *const ManagedNetworkCompletionToken) usize {
48 return self._receive(self, token);
49 }
50
51 /// Aborts an asynchronous transmit or receive request.
52 pub fn cancel(self: *const ManagedNetworkProtocol, token: ?*const ManagedNetworkCompletionToken) usize {
53 return self._cancel(self, token);
54 }
55
56 /// Polls for incoming data packets and processes outgoing data packets.
57 pub fn poll(self: *const ManagedNetworkProtocol) usize {
58 return self._poll(self);
59 }
60
61 pub const guid align(8) = Guid{
62 .time_low = 0x7ab33a91,
63 .time_mid = 0xace5,
64 .time_high_and_version = 0x4326,
65 .clock_seq_high_and_reserved = 0xb5,
66 .clock_seq_low = 0x72,
67 .node = [_]u8{ 0xe7, 0xee, 0x33, 0xd3, 0x9f, 0x16 },
68 };
69};
70
71pub const ManagedNetworkConfigData = extern struct {
72 received_queue_timeout_value: u32,
73 transmit_queue_timeout_value: u32,
74 protocol_type_filter: u16,
75 enable_unicast_receive: bool,
76 enable_multicast_receive: bool,
77 enable_broadcast_receive: bool,
78 enable_promiscuous_receive: bool,
79 flush_queues_on_reset: bool,
80 enable_receive_timestamps: bool,
81 disable_background_polling: bool,
82};
83
84pub const ManagedNetworkCompletionToken = extern struct {
85 event: Event,
86 status: usize,
87 packet: extern union {
88 RxData: *ManagedNetworkReceiveData,
89 TxData: *ManagedNetworkTransmitData,
90 },
91};
92
93pub const ManagedNetworkReceiveData = extern struct {
94 timestamp: Time,
95 recycle_event: Event,
96 packet_length: u32,
97 header_length: u32,
98 address_length: u32,
99 data_length: u32,
100 broadcast_flag: bool,
101 multicast_flag: bool,
102 promiscuous_flag: bool,
103 protocol_type: u16,
104 destination_address: [*]u8,
105 source_address: [*]u8,
106 media_header: [*]u8,
107 packet_data: [*]u8,
108};
109
110pub const ManagedNetworkTransmitData = extern struct {
111 destination_address: ?*MacAddress,
112 source_address: ?*MacAddress,
113 protocol_type: u16,
114 data_length: u32,
115 header_length: u16,
116 fragment_count: u16,
117
118 pub fn getFragments(self: *ManagedNetworkTransmitData) []ManagedNetworkFragmentData {
119 return @ptrCast([*]ManagedNetworkFragmentData, @ptrCast([*]u8, self) + @sizeOf(ManagedNetworkTransmitData))[0..self.fragment_count];
120 }
121};
122
123pub const ManagedNetworkFragmentData = extern struct {
124 fragment_length: u32,
125 fragment_buffer: [*]u8,
126};
lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig created+25
......@@ -0,0 +1,25 @@
1const uefi = @import("std").os.uefi;
2const Handle = uefi.Handle;
3const Guid = uefi.Guid;
4
5pub const ManagedNetworkServiceBindingProtocol = extern struct {
6 _create_child: extern fn (*const ManagedNetworkServiceBindingProtocol, *?Handle) usize,
7 _destroy_child: extern fn (*const ManagedNetworkServiceBindingProtocol, Handle) usize,
8
9 pub fn createChild(self: *const ManagedNetworkServiceBindingProtocol, handle: *?Handle) usize {
10 return self._create_child(self, handle);
11 }
12
13 pub fn destroyChild(self: *const ManagedNetworkServiceBindingProtocol, handle: Handle) usize {
14 return self._destroy_child(self, handle);
15 }
16
17 pub const guid align(8) = Guid{
18 .time_low = 0xf36ff770,
19 .time_mid = 0xa7e1,
20 .time_high_and_version = 0x42cf,
21 .clock_seq_high_and_reserved = 0x9e,
22 .clock_seq_low = 0xd2,
23 .node = [_]u8{ 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c },
24 };
25};
lib/std/os/uefi/protocols/simple_network_protocol.zig created+172
......@@ -0,0 +1,172 @@
1const uefi = @import("std").os.uefi;
2const Event = uefi.Event;
3const Guid = uefi.Guid;
4
5pub const SimpleNetworkProtocol = extern struct {
6 revision: u64,
7 _start: extern fn (*const SimpleNetworkProtocol) usize,
8 _stop: extern fn (*const SimpleNetworkProtocol) usize,
9 _initialize: extern fn (*const SimpleNetworkProtocol, usize, usize) usize,
10 _reset: extern fn (*const SimpleNetworkProtocol, bool) usize,
11 _shutdown: extern fn (*const SimpleNetworkProtocol) usize,
12 _receive_filters: extern fn (*const SimpleNetworkProtocol, SimpleNetworkReceiveFilter, SimpleNetworkReceiveFilter, bool, usize, ?[*]const MacAddress) usize,
13 _station_address: extern fn (*const SimpleNetworkProtocol, bool, ?*const MacAddress) usize,
14 _statistics: extern fn (*const SimpleNetworkProtocol, bool, ?*usize, ?*NetworkStatistics) usize,
15 _mcast_ip_to_mac: extern fn (*const SimpleNetworkProtocol, bool, *const c_void, *MacAddress) usize,
16 _nvdata: extern fn (*const SimpleNetworkProtocol, bool, usize, usize, [*]u8) usize,
17 _get_status: extern fn (*const SimpleNetworkProtocol, *SimpleNetworkInterruptStatus, ?*?[*]u8) usize,
18 _transmit: extern fn (*const SimpleNetworkProtocol, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) usize,
19 _receive: extern fn (*const SimpleNetworkProtocol, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) usize,
20 wait_for_packet: Event,
21 mode: *SimpleNetworkMode,
22
23 /// Changes the state of a network interface from "stopped" to "started".
24 pub fn start(self: *const SimpleNetworkProtocol) usize {
25 return self._start(self);
26 }
27
28 /// Changes the state of a network interface from "started" to "stopped".
29 pub fn stop(self: *const SimpleNetworkProtocol) usize {
30 return self._stop(self);
31 }
32
33 /// Resets a network adapter and allocates the transmit and receive buffers required by the network interface.
34 pub fn initialize(self: *const SimpleNetworkProtocol, extra_rx_buffer_size: usize, extra_tx_buffer_size: usize) usize {
35 return self._initialize(self, extra_rx_buffer_size, extra_tx_buffer_size);
36 }
37
38 /// Resets a network adapter and reinitializes it with the parameters that were provided in the previous call to initialize().
39 pub fn reset(self: *const SimpleNetworkProtocol, extended_verification: bool) usize {
40 return self._reset(self, extended_verification);
41 }
42
43 /// Resets a network adapter and leaves it in a state that is safe for another driver to initialize.
44 pub fn shutdown(self: *const SimpleNetworkProtocol) usize {
45 return self._shutdown(self);
46 }
47
48 /// Manages the multicast receive filters of a network interface.
49 pub fn receiveFilters(self: *const SimpleNetworkProtocol, enable: SimpleNetworkReceiveFilter, disable: SimpleNetworkReceiveFilter, reset_mcast_filter: bool, mcast_filter_cnt: usize, mcast_filter: ?[*]const MacAddress) usize {
50 return self._receive_filters(self, enable, disable, reset_mcast_filter, mcast_filter_cnt, mcast_filter);
51 }
52
53 /// Modifies or resets the current station address, if supported.
54 pub fn stationAddress(self: *const SimpleNetworkProtocol, reset: bool, new: ?*const MacAddress) usize {
55 return self._station_address(self, reset, new);
56 }
57
58 /// Resets or collects the statistics on a network interface.
59 pub fn statistics(self: *const SimpleNetworkProtocol, reset_: bool, statistics_size: ?*usize, statistics_table: ?*NetworkStatistics) usize {
60 return self._statistics(self, reset_, statistics_size, statistics_table);
61 }
62
63 /// Converts a multicast IP address to a multicast HW MAC address.
64 pub fn mcastIpToMac(self: *const SimpleNetworkProtocol, ipv6: bool, ip: *const c_void, mac: *MacAddress) usize {
65 return self._mcast_ip_to_mac(self, ipv6, ip, mac);
66 }
67
68 /// Performs read and write operations on the NVRAM device attached to a network interface.
69 pub fn nvdata(self: *const SimpleNetworkProtocol, read_write: bool, offset: usize, buffer_size: usize, buffer: [*]u8) usize {
70 return self._nvdata(self, read_write, offset, buffer_size, buffer);
71 }
72
73 /// Reads the current interrupt status and recycled transmit buffer status from a network interface.
74 pub fn getStatus(self: *const SimpleNetworkProtocol, interrupt_status: *SimpleNetworkInterruptStatus, tx_buf: ?*?[*]u8) usize {
75 return self._get_status(self, interrupt_status, tx_buf);
76 }
77
78 /// Places a packet in the transmit queue of a network interface.
79 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 {
80 return self._transmit(self, header_size, buffer_size, buffer, src_addr, dest_addr, protocol);
81 }
82
83 /// Receives a packet from a network interface.
84 pub fn receive(self: *const SimpleNetworkProtocol, header_size: ?*usize, buffer_size: *usize, buffer: [*]u8, src_addr: ?*MacAddress, dest_addr: ?*MacAddress, protocol: ?*u16) usize {
85 return self._receive(self, header_size, buffer_size, buffer, src_addr, dest_addr, protocol);
86 }
87
88 pub const guid align(8) = Guid{
89 .time_low = 0xa19832b9,
90 .time_mid = 0xac25,
91 .time_high_and_version = 0x11d3,
92 .clock_seq_high_and_reserved = 0x9a,
93 .clock_seq_low = 0x2d,
94 .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d },
95 };
96};
97
98pub const MacAddress = [32]u8;
99
100pub const SimpleNetworkMode = extern struct {
101 state: SimpleNetworkState,
102 hw_address_size: u32,
103 media_header_size: u32,
104 max_packet_size: u32,
105 nvram_size: u32,
106 nvram_access_size: u32,
107 receive_filter_mask: SimpleNetworkReceiveFilter,
108 receive_filter_setting: SimpleNetworkReceiveFilter,
109 max_mcast_filter_count: u32,
110 mcast_filter_count: u32,
111 mcast_filter: [16]MacAddress,
112 current_address: MacAddress,
113 broadcast_address: MacAddress,
114 permanent_address: MacAddress,
115 if_type: u8,
116 mac_address_changeable: bool,
117 multiple_tx_supported: bool,
118 media_present_supported: bool,
119 media_present: bool,
120};
121
122pub const SimpleNetworkReceiveFilter = packed struct {
123 receive_unicast: bool,
124 receive_multicast: bool,
125 receive_broadcast: bool,
126 receive_promiscuous: bool,
127 receive_promiscuous_multicast: bool,
128 _pad: u27 = undefined,
129};
130
131pub const SimpleNetworkState = extern enum(u32) {
132 Stopped,
133 Started,
134 Initialized,
135};
136
137pub const NetworkStatistics = extern struct {
138 rx_total_frames: u64,
139 rx_good_frames: u64,
140 rx_undersize_frames: u64,
141 rx_oversize_frames: u64,
142 rx_dropped_frames: u64,
143 rx_unicast_frames: u64,
144 rx_broadcast_frames: u64,
145 rx_multicast_frames: u64,
146 rx_crc_error_frames: u64,
147 rx_total_bytes: u64,
148 tx_total_frames: u64,
149 tx_good_frames: u64,
150 tx_undersize_frames: u64,
151 tx_oversize_frames: u64,
152 tx_dropped_frames: u64,
153 tx_unicast_frames: u64,
154 tx_broadcast_frames: u64,
155 tx_multicast_frames: u64,
156 tx_crc_error_frames: u64,
157 tx_total_bytes: u64,
158 collisions: u64,
159 unsupported_protocol: u64,
160 rx_duplicated_frames: u64,
161 rx_decryptError_frames: u64,
162 tx_error_frames: u64,
163 tx_retry_frames: u64,
164};
165
166pub const SimpleNetworkInterruptStatus = packed struct {
167 receive_interrupt: bool,
168 transmit_interrupt: bool,
169 command_interrupt: bool,
170 software_interrupt: bool,
171 _pad: u28,
172};
lib/std/os/uefi/protocols/udp6_protocol.zig created+112
......@@ -0,0 +1,112 @@
1const uefi = @import("std").os.uefi;
2const Guid = uefi.Guid;
3const Event = uefi.Event;
4const Time = uefi.Time;
5const Ip6ModeData = uefi.protocols.Ip6ModeData;
6const Ip6Address = uefi.protocols.Ip6Address;
7const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData;
8const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
9
10pub const Udp6Protocol = extern struct {
11 _get_mode_data: extern fn (*const Udp6Protocol, ?*Udp6ConfigData, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) usize,
12 _configure: extern fn (*const Udp6Protocol, ?*const Udp6ConfigData) usize,
13 _groups: extern fn (*const Udp6Protocol, bool, ?*const Ip6Address) usize,
14 _transmit: extern fn (*const Udp6Protocol, *Udp6CompletionToken) usize,
15 _receive: extern fn (*const Udp6Protocol, *Udp6CompletionToken) usize,
16 _cancel: extern fn (*const Udp6Protocol, ?*Udp6CompletionToken) usize,
17 _poll: extern fn (*const Udp6Protocol) usize,
18
19 pub fn getModeData(self: *const Udp6Protocol, udp6_config_data: ?*Udp6ConfigData, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) usize {
20 return self._get_mode_data(self, udp6_config_data, ip6_mode_data, mnp_config_data, snp_mode_data);
21 }
22
23 pub fn configure(self: *const Udp6Protocol, udp6_config_data: ?*const Udp6ConfigData) usize {
24 return self._configure(self, udp6_config_data);
25 }
26
27 pub fn groups(self: *const Udp6Protocol, join_flag: bool, multicast_address: ?*const Ip6Address) usize {
28 return self._groups(self, join_flag, multicast_address);
29 }
30
31 pub fn transmit(self: *const Udp6Protocol, token: *Udp6CompletionToken) usize {
32 return self._transmit(self, token);
33 }
34
35 pub fn receive(self: *const Udp6Protocol, token: *Udp6CompletionToken) usize {
36 return self._receive(self, token);
37 }
38
39 pub fn cancel(self: *const Udp6Protocol, token: ?*Udp6CompletionToken) usize {
40 return self._cancel(self, token);
41 }
42
43 pub fn poll(self: *const Udp6Protocol) usize {
44 return self._poll(self);
45 }
46
47 pub const guid align(8) = uefi.Guid{
48 .time_low = 0x4f948815,
49 .time_mid = 0xb4b9,
50 .time_high_and_version = 0x43cb,
51 .clock_seq_high_and_reserved = 0x8a,
52 .clock_seq_low = 0x33,
53 .node = [_]u8{ 0x90, 0xe0, 0x60, 0xb3, 0x49, 0x55 },
54 };
55};
56
57pub const Udp6ConfigData = extern struct {
58 accept_promiscuous: bool,
59 accept_any_port: bool,
60 allow_duplicate_port: bool,
61 traffic_class: u8,
62 hop_limit: u8,
63 receive_timeout: u32,
64 transmit_timeout: u32,
65 station_address: Ip6Address,
66 station_port: u16,
67 remote_address: Ip6Address,
68 remote_port: u16,
69};
70
71pub const Udp6CompletionToken = extern struct {
72 event: Event,
73 status: usize,
74 packet: extern union {
75 RxData: *Udp6ReceiveData,
76 TxData: *Udp6TransmitData,
77 },
78};
79
80pub const Udp6ReceiveData = extern struct {
81 timestamp: Time,
82 recycle_signal: Event,
83 udp6_session: Udp6SessionData,
84 data_length: u32,
85 fragment_count: u32,
86
87 pub fn getFragments(self: *Udp6ReceiveData) []Udp6FragmentData {
88 return @ptrCast([*]Udp6FragmentData, @ptrCast([*]u8, self) + @sizeOf(Udp6ReceiveData))[0..self.fragment_count];
89 }
90};
91
92pub const Udp6TransmitData = extern struct {
93 udp6_session_data: ?*Udp6SessionData,
94 data_length: u32,
95 fragment_count: u32,
96
97 pub fn getFragments(self: *Udp6TransmitData) []Udp6FragmentData {
98 return @ptrCast([*]Udp6FragmentData, @ptrCast([*]u8, self) + @sizeOf(Udp6TransmitData))[0..self.fragment_count];
99 }
100};
101
102pub const Udp6SessionData = extern struct {
103 source_address: Ip6Address,
104 source_port: u16,
105 destination_address: Ip6Address,
106 destination_port: u16,
107};
108
109pub const Udp6FragmentData = extern struct {
110 fragment_length: u32,
111 fragment_buffer: [*]u8,
112};
lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig created+25
......@@ -0,0 +1,25 @@
1const uefi = @import("std").os.uefi;
2const Handle = uefi.Handle;
3const Guid = uefi.Guid;
4
5pub const Udp6ServiceBindingProtocol = extern struct {
6 _create_child: extern fn (*const Udp6ServiceBindingProtocol, *?Handle) usize,
7 _destroy_child: extern fn (*const Udp6ServiceBindingProtocol, Handle) usize,
8
9 pub fn createChild(self: *const Udp6ServiceBindingProtocol, handle: *?Handle) usize {
10 return self._create_child(self, handle);
11 }
12
13 pub fn destroyChild(self: *const Udp6ServiceBindingProtocol, handle: Handle) usize {
14 return self._destroy_child(self, handle);
15 }
16
17 pub const guid align(8) = Guid{
18 .time_low = 0x66ed4721,
19 .time_mid = 0x3c98,
20 .time_high_and_version = 0x4d3e,
21 .clock_seq_high_and_reserved = 0x81,
22 .clock_seq_low = 0xe3,
23 .node = [_]u8{ 0xd0, 0x3d, 0xd3, 0x9a, 0x72, 0x54 },
24 };
25};
lib/std/os/uefi/tables.zig+3
......@@ -1,8 +1,11 @@
11pub const BootServices = @import("tables/boot_services.zig").BootServices;
22pub const ConfigurationTable = @import("tables/configuration_table.zig").ConfigurationTable;
33pub const global_variable align(8) = @import("tables/runtime_services.zig").global_variable;
4pub const LocateSearchType = @import("tables/boot_services.zig").LocateSearchType;
45pub const MemoryDescriptor = @import("tables/boot_services.zig").MemoryDescriptor;
56pub const MemoryType = @import("tables/boot_services.zig").MemoryType;
7pub const OpenProtocolAttributes = @import("tables/boot_services.zig").OpenProtocolAttributes;
8pub const ProtocolInformationEntry = @import("tables/boot_services.zig").ProtocolInformationEntry;
69pub const ResetType = @import("tables/runtime_services.zig").ResetType;
710pub const RuntimeServices = @import("tables/runtime_services.zig").RuntimeServices;
811pub const SystemTable = @import("tables/system_table.zig").SystemTable;
lib/std/os/uefi/tables/boot_services.zig+75-11
......@@ -3,6 +3,7 @@ const Event = uefi.Event;
33const Guid = uefi.Guid;
44const Handle = uefi.Handle;
55const TableHeader = uefi.tables.TableHeader;
6const DevicePathProtocol = uefi.protocols.DevicePathProtocol;
67
78/// Boot services are services provided by the system's firmware until the operating system takes
89/// over control over the hardware by calling exitBootServices.
......@@ -17,56 +18,96 @@ const TableHeader = uefi.tables.TableHeader;
1718/// As the boot_services table may grow with new UEFI versions, it is important to check hdr.header_size.
1819pub const BootServices = extern struct {
1920 hdr: TableHeader,
21
2022 raiseTpl: usize, // TODO
2123 restoreTpl: usize, // TODO
2224 allocatePages: usize, // TODO
2325 freePages: usize, // TODO
26
2427 /// Returns the current memory map.
2528 getMemoryMap: extern fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) usize,
29
2630 /// Allocates pool memory.
2731 allocatePool: extern fn (MemoryType, usize, *align(8) [*]u8) usize,
28 freePool: usize, // TODO
32
33 /// Returns pool memory to the system.
34 freePool: extern fn ([*]align(8) u8) usize,
35
2936 /// Creates an event.
30 createEvent: extern fn (u32, usize, ?extern fn (Event, ?*const c_void) void, ?*const c_void, *Event) usize,
37 createEvent: extern fn (u32, usize, ?extern fn (Event, ?*c_void) void, ?*const c_void, *Event) usize,
38
3139 /// Sets the type of timer and the trigger time for a timer event.
3240 setTimer: extern fn (Event, TimerDelay, u64) usize,
41
3342 /// Stops execution until an event is signaled.
3443 waitForEvent: extern fn (usize, [*]const Event, *usize) usize,
44
3545 /// Signals an event.
3646 signalEvent: extern fn (Event) usize,
47
3748 /// Closes an event.
3849 closeEvent: extern fn (Event) usize,
39 checkEvent: usize, // TODO
50
51 /// Checks whether an event is in the signaled state.
52 checkEvent: extern fn (Event) usize,
53
4054 installProtocolInterface: usize, // TODO
4155 reinstallProtocolInterface: usize, // TODO
4256 uninstallProtocolInterface: usize, // TODO
43 handleProtocol: usize, // TODO
57
58 /// Queries a handle to determine if it supports a specified protocol.
59 handleProtocol: extern fn (Handle, *align(8) const Guid, *?*c_void) usize,
60
4461 reserved: *c_void,
62
4563 registerProtocolNotify: usize, // TODO
4664 locateHandle: usize, // TODO
4765 locateDevicePath: usize, // TODO
4866 installConfigurationTable: usize, // TODO
49 imageLoad: usize, // TODO
50 imageStart: usize, // TODO
67
68 /// Loads an EFI image into memory.
69 loadImage: extern fn (bool, Handle, ?*const DevicePathProtocol, ?[*]const u8, usize, *?Handle) usize,
70
71 /// Transfers control to a loaded image's entry point.
72 startImage: extern fn (Handle, ?*usize, ?*[*]u16) usize,
73
5174 /// Terminates a loaded EFI image and returns control to boot services.
5275 exit: extern fn (Handle, usize, usize, ?*const c_void) usize,
53 imageUnload: usize, // TODO
76
77 /// Unloads an image.
78 unloadImage: extern fn (Handle) usize,
79
5480 /// Terminates all boot services.
5581 exitBootServices: extern fn (Handle, usize) usize,
82
5683 getNextMonotonicCount: usize, // TODO
84
5785 /// Induces a fine-grained stall.
5886 stall: extern fn (usize) usize,
87
5988 /// Sets the system's watchdog timer.
6089 setWatchdogTimer: extern fn (usize, u64, usize, ?[*]const u16) usize,
90
6191 connectController: usize, // TODO
6292 disconnectController: usize, // TODO
63 openProtocol: usize, // TODO
64 closeProtocol: usize, // TODO
65 openProtocolInformation: usize, // TODO
93
94 /// Queries a handle to determine if it supports a specified protocol.
95 openProtocol: extern fn (Handle, *align(8) const Guid, *?*c_void, ?Handle, ?Handle, OpenProtocolAttributes) usize,
96
97 /// Closes a protocol on a handle that was opened using openProtocol().
98 closeProtocol: extern fn (Handle, *align(8) const Guid, Handle, ?Handle) usize,
99
100 /// Retrieves the list of agents that currently have a protocol interface opened.
101 openProtocolInformation: extern fn (Handle, *align(8) const Guid, *[*]ProtocolInformationEntry, *usize) usize,
102
66103 protocolsPerHandle: usize, // TODO
67 locateHandleBuffer: usize, // TODO
104
105 /// Returns an array of handles that support the requested protocol in a buffer allocated from pool.
106 locateHandleBuffer: extern fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, *[*]Handle) usize,
107
68108 /// Returns the first protocol instance that matches the given protocol.
69109 locateProtocol: extern fn (*align(8) const Guid, ?*const c_void, *?*c_void) usize,
110
70111 installMultipleProtocolInterfaces: usize, // TODO
71112 uninstallMultipleProtocolInterfaces: usize, // TODO
72113 calculateCrc32: usize, // TODO
......@@ -138,3 +179,26 @@ pub const MemoryDescriptor = extern struct {
138179 memory_runtime: bool,
139180 },
140181};
182
183pub const LocateSearchType = extern enum(u32) {
184 AllHandles,
185 ByRegisterNotify,
186 ByProtocol,
187};
188
189pub const OpenProtocolAttributes = packed struct {
190 by_handle_protocol: bool,
191 get_protocol: bool,
192 test_protocol: bool,
193 by_child_controller: bool,
194 by_driver: bool,
195 exclusive: bool,
196 _pad: u26,
197};
198
199pub const ProtocolInformationEntry = extern struct {
200 agent_handle: ?Handle,
201 controller_handle: ?Handle,
202 attributes: OpenProtocolAttributes,
203 open_count: u32,
204};
lib/std/os/uefi/tables/runtime_services.zig+8
......@@ -14,22 +14,30 @@ const TimeCapabilities = uefi.TimeCapabilities;
1414/// Some functions may not be called while other functions are running.
1515pub const RuntimeServices = extern struct {
1616 hdr: TableHeader,
17
1718 /// Returns the current time and date information, and the time-keeping capabilities of the hardware platform.
1819 getTime: extern fn (*uefi.Time, ?*TimeCapabilities) usize,
20
1921 setTime: usize, // TODO
2022 getWakeupTime: usize, // TODO
2123 setWakeupTime: usize, // TODO
2224 setVirtualAddressMap: usize, // TODO
2325 convertPointer: usize, // TODO
26
2427 /// Returns the value of a variable.
2528 getVariable: extern fn ([*]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) usize,
29
2630 /// Enumerates the current variable names.
2731 getNextVariableName: extern fn (*usize, [*]u16, *align(8) Guid) usize,
32
2833 /// Sets the value of a variable.
2934 setVariable: extern fn ([*]const u16, *align(8) const Guid, u32, usize, *c_void) usize,
35
3036 getNextHighMonotonicCount: usize, // TODO
37
3138 /// Resets the entire platform.
3239 resetSystem: extern fn (ResetType, usize, usize, ?*const c_void) noreturn,
40
3341 updateCapsule: usize, // TODO
3442 queryCapsuleCapabilities: usize, // TODO
3543 queryVariableInfo: usize, // TODO
lib/std/os/uefi/tables/system_table.zig+1
......@@ -17,6 +17,7 @@ const TableHeader = uefi.tables.TableHeader;
1717/// hdr.crc32 must be recomputed.
1818pub const SystemTable = extern struct {
1919 hdr: TableHeader,
20
2021 /// A null-terminated string that identifies the vendor that produces the system firmware of the platform.
2122 firmware_vendor: [*]u16,
2223 firmware_revision: u32,