diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/os/uefi/protocols.zig | 40 | ||||
| -rw-r--r-- | lib/std/os/uefi/protocols/ip6_config_protocol.zig | 45 | ||||
| -rw-r--r-- | lib/std/os/uefi/protocols/ip6_protocol.zig | 143 | ||||
| -rw-r--r-- | lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig | 25 | ||||
| -rw-r--r-- | lib/std/os/uefi/protocols/managed_network_protocol.zig | 126 | ||||
| -rw-r--r-- | lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig | 25 | ||||
| -rw-r--r-- | lib/std/os/uefi/protocols/simple_network_protocol.zig | 172 | ||||
| -rw-r--r-- | lib/std/os/uefi/protocols/udp6_protocol.zig | 112 | ||||
| -rw-r--r-- | lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig | 25 |
9 files changed, 713 insertions, 0 deletions
diff --git a/lib/std/os/uefi/protocols.zig b/lib/std/os/uefi/protocols.zig index b8a39d1815..f3c3747e1e 100644 --- a/lib/std/os/uefi/protocols.zig +++ b/lib/std/os/uefi/protocols.zig @@ -33,6 +33,46 @@ pub const EdidActiveProtocol = @import("protocols/edid_active_protocol.zig").Edi pub const EdidOverrideProtocol = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocol; pub const EdidOverrideProtocolAttributes = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocolAttributes; +pub const SimpleNetworkProtocol = @import("protocols/simple_network_protocol.zig").SimpleNetworkProtocol; +pub const MacAddress = @import("protocols/simple_network_protocol.zig").MacAddress; +pub const SimpleNetworkMode = @import("protocols/simple_network_protocol.zig").SimpleNetworkMode; +pub const SimpleNetworkReceiveFilter = @import("protocols/simple_network_protocol.zig").SimpleNetworkReceiveFilter; +pub const SimpleNetworkState = @import("protocols/simple_network_protocol.zig").SimpleNetworkState; +pub const NetworkStatistics = @import("protocols/simple_network_protocol.zig").NetworkStatistics; +pub const SimpleNetworkInterruptStatus = @import("protocols/simple_network_protocol.zig").SimpleNetworkInterruptStatus; + +pub const ManagedNetworkServiceBindingProtocol = @import("protocols/managed_network_service_binding_protocol.zig").ManagedNetworkServiceBindingProtocol; +pub const ManagedNetworkProtocol = @import("protocols/managed_network_protocol.zig").ManagedNetworkProtocol; +pub const ManagedNetworkConfigData = @import("protocols/managed_network_protocol.zig").ManagedNetworkConfigData; +pub const ManagedNetworkCompletionToken = @import("protocols/managed_network_protocol.zig").ManagedNetworkCompletionToken; +pub const ManagedNetworkReceiveData = @import("protocols/managed_network_protocol.zig").ManagedNetworkReceiveData; +pub const ManagedNetworkTransmitData = @import("protocols/managed_network_protocol.zig").ManagedNetworkTransmitData; +pub const ManagedNetworkFragmentData = @import("protocols/managed_network_protocol.zig").ManagedNetworkFragmentData; + +pub const Ip6ServiceBindingProtocol = @import("protocols/ip6_service_binding_protocol.zig").Ip6ServiceBindingProtocol; +pub const Ip6Protocol = @import("protocols/ip6_protocol.zig").Ip6Protocol; +pub const Ip6ModeData = @import("protocols/ip6_protocol.zig").Ip6ModeData; +pub const Ip6ConfigData = @import("protocols/ip6_protocol.zig").Ip6ConfigData; +pub const Ip6Address = @import("protocols/ip6_protocol.zig").Ip6Address; +pub const Ip6AddressInfo = @import("protocols/ip6_protocol.zig").Ip6AddressInfo; +pub const Ip6RouteTable = @import("protocols/ip6_protocol.zig").Ip6RouteTable; +pub const Ip6NeighborState = @import("protocols/ip6_protocol.zig").Ip6NeighborState; +pub const Ip6NeighborCache = @import("protocols/ip6_protocol.zig").Ip6NeighborCache; +pub const Ip6IcmpType = @import("protocols/ip6_protocol.zig").Ip6IcmpType; +pub const Ip6CompletionToken = @import("protocols/ip6_protocol.zig").Ip6CompletionToken; + +pub const Ip6ConfigProtocol = @import("protocols/ip6_config_protocol.zig").Ip6ConfigProtocol; +pub const Ip6ConfigDataType = @import("protocols/ip6_config_protocol.zig").Ip6ConfigDataType; + +pub const Udp6ServiceBindingProtocol = @import("protocols/udp6_service_binding_protocol.zig").Udp6ServiceBindingProtocol; +pub const Udp6Protocol = @import("protocols/udp6_protocol.zig").Udp6Protocol; +pub const Udp6ConfigData = @import("protocols/udp6_protocol.zig").Udp6ConfigData; +pub const Udp6CompletionToken = @import("protocols/udp6_protocol.zig").Udp6CompletionToken; +pub const Udp6ReceiveData = @import("protocols/udp6_protocol.zig").Udp6ReceiveData; +pub const Udp6TransmitData = @import("protocols/udp6_protocol.zig").Udp6TransmitData; +pub const Udp6SessionData = @import("protocols/udp6_protocol.zig").Udp6SessionData; +pub const Udp6FragmentData = @import("protocols/udp6_protocol.zig").Udp6FragmentData; + pub const hii = @import("protocols/hii.zig"); pub const HIIDatabaseProtocol = @import("protocols/hii_database_protocol.zig").HIIDatabaseProtocol; pub const HIIPopupProtocol = @import("protocols/hii_popup_protocol.zig").HIIPopupProtocol; diff --git a/lib/std/os/uefi/protocols/ip6_config_protocol.zig b/lib/std/os/uefi/protocols/ip6_config_protocol.zig new file mode 100644 index 0000000000..a86e2cbba2 --- /dev/null +++ b/lib/std/os/uefi/protocols/ip6_config_protocol.zig @@ -0,0 +1,45 @@ +const uefi = @import("std").os.uefi; +const Guid = uefi.Guid; +const Event = uefi.Event; + +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, + + pub fn setData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: usize, data: *const c_void) usize { + 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 { + return self._get_data(self, data_type, data_size, data); + } + + pub fn registerDataNotify(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, event: Event) usize { + return self._register_data_notify(self, data_type, event); + } + + pub fn unregisterDataNotify(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, event: Event) usize { + return self._unregister_data_notify(self, data_type, event); + } + + pub const guid align(8) = Guid{ + .time_low = 0x937fe521, + .time_mid = 0x95ae, + .time_high_and_version = 0x4d1a, + .clock_seq_high_and_reserved = 0x89, + .clock_seq_low = 0x29, + .node = [_]u8{ 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a }, + }; +}; + +pub const Ip6ConfigDataType = extern enum(u32) { + InterfaceInfo, + AltInterfaceId, + Policy, + DupAddrDetectTransmits, + ManualAddress, + Gateway, + DnsServer, +}; diff --git a/lib/std/os/uefi/protocols/ip6_protocol.zig b/lib/std/os/uefi/protocols/ip6_protocol.zig new file mode 100644 index 0000000000..a412dc3c7b --- /dev/null +++ b/lib/std/os/uefi/protocols/ip6_protocol.zig @@ -0,0 +1,143 @@ +const uefi = @import("std").os.uefi; +const Guid = uefi.Guid; +const Event = uefi.Event; +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, + + /// 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 { + 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 { + 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 { + 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 { + 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 { + 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 { + return self._transmit(self, token); + } + + /// Places a receiving request into the receiving queue. + pub fn receive(self: *const Ip6Protocol, token: *Ip6CompletionToken) usize { + return self._receive(self, token); + } + + /// Abort an asynchronous transmits or receive request. + pub fn cancel(self: *const Ip6Protocol, token: ?*Ip6CompletionToken) usize { + return self._cancel(self, token); + } + + /// Polls for incoming data packets and processes outgoing data packets. + pub fn poll(self: *const Ip6Protocol) usize { + return self._poll(self); + } + + pub const guid align(8) = Guid{ + .time_low = 0x2c8759d5, + .time_mid = 0x5c2d, + .time_high_and_version = 0x66ef, + .clock_seq_high_and_reserved = 0x92, + .clock_seq_low = 0x5f, + .node = [_]u8{ 0xb6, 0x6c, 0x10, 0x19, 0x57, 0xe2 }, + }; +}; + +pub const Ip6ModeData = extern struct { + is_started: bool, + max_packet_size: u32, + config_data: Ip6ConfigData, + is_configured: bool, + address_count: u32, + address_list: [*]Ip6AddressInfo, + group_count: u32, + group_table: [*]Ip6Address, + route_count: u32, + route_table: [*]Ip6RouteTable, + neighbor_count: u32, + neighbor_cache: [*]Ip6NeighborCache, + prefix_count: u32, + prefix_table: [*]Ip6AddressInfo, + icmp_type_count: u32, + icmp_type_list: [*]Ip6IcmpType, +}; + +pub const Ip6ConfigData = extern struct { + default_protocol: u8, + accept_any_protocol: bool, + accept_icmp_errors: bool, + accept_promiscuous: bool, + destination_address: Ip6Address, + station_address: Ip6Address, + traffic_class: u8, + hop_limit: u8, + flow_label: u32, + receive_timeout: u32, + transmit_timeout: u32, +}; + +pub const Ip6Address = [16]u8; + +pub const Ip6AddressInfo = extern struct { + address: Ip6Address, + prefix_length: u8, +}; + +pub const Ip6RouteTable = extern struct { + gateway: Ip6Address, + destination: Ip6Address, + prefix_length: u8, +}; + +pub const Ip6NeighborState = extern enum(u32) { + Incomplete, + Reachable, + Stale, + Delay, + Probe, +}; + +pub const Ip6NeighborCache = extern struct { + neighbor: Ip6Address, + link_address: MacAddress, + state: Ip6NeighborState, +}; + +pub const Ip6IcmpType = extern struct { + type: u8, + code: u8, +}; + +pub const Ip6CompletionToken = extern struct { + event: Event, + status: usize, + 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 new file mode 100644 index 0000000000..9ecbb29607 --- /dev/null +++ b/lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig @@ -0,0 +1,25 @@ +const uefi = @import("std").os.uefi; +const Handle = uefi.Handle; +const Guid = uefi.Guid; + +pub const Ip6ServiceBindingProtocol = extern struct { + _create_child: extern fn (*const Ip6ServiceBindingProtocol, *?Handle) usize, + _destroy_child: extern fn (*const Ip6ServiceBindingProtocol, Handle) usize, + + pub fn createChild(self: *const Ip6ServiceBindingProtocol, handle: *?Handle) usize { + return self._create_child(self, handle); + } + + pub fn destroyChild(self: *const Ip6ServiceBindingProtocol, handle: Handle) usize { + return self._destroy_child(self, handle); + } + + pub const guid align(8) = Guid{ + .time_low = 0xec835dd3, + .time_mid = 0xfe0f, + .time_high_and_version = 0x617b, + .clock_seq_high_and_reserved = 0xa6, + .clock_seq_low = 0x21, + .node = [_]u8{ 0xb3, 0x50, 0xc3, 0xe1, 0x33, 0x88 }, + }; +}; diff --git a/lib/std/os/uefi/protocols/managed_network_protocol.zig b/lib/std/os/uefi/protocols/managed_network_protocol.zig new file mode 100644 index 0000000000..a2cf6e2eca --- /dev/null +++ b/lib/std/os/uefi/protocols/managed_network_protocol.zig @@ -0,0 +1,126 @@ +const uefi = @import("std").os.uefi; +const Guid = uefi.Guid; +const Event = uefi.Event; +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, + _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 { + 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 { + 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 { + 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 { + 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 { + return self._transmit(self, token); + } + + /// Places an asynchronous receiving request into the receiving queue. + pub fn receive(self: *const ManagedNetworkProtocol, token: *const ManagedNetworkCompletionToken) usize { + return self._receive(self, token); + } + + /// Aborts an asynchronous transmit or receive request. + pub fn cancel(self: *const ManagedNetworkProtocol, token: ?*const ManagedNetworkCompletionToken) usize { + return self._cancel(self, token); + } + + /// Polls for incoming data packets and processes outgoing data packets. + pub fn poll(self: *const ManagedNetworkProtocol) usize { + return self._poll(self); + } + + pub const guid align(8) = Guid{ + .time_low = 0x7ab33a91, + .time_mid = 0xace5, + .time_high_and_version = 0x4326, + .clock_seq_high_and_reserved = 0xb5, + .clock_seq_low = 0x72, + .node = [_]u8{ 0xe7, 0xee, 0x33, 0xd3, 0x9f, 0x16 }, + }; +}; + +pub const ManagedNetworkConfigData = extern struct { + received_queue_timeout_value: u32, + transmit_queue_timeout_value: u32, + protocol_type_filter: u16, + enable_unicast_receive: bool, + enable_multicast_receive: bool, + enable_broadcast_receive: bool, + enable_promiscuous_receive: bool, + flush_queues_on_reset: bool, + enable_receive_timestamps: bool, + disable_background_polling: bool, +}; + +pub const ManagedNetworkCompletionToken = extern struct { + event: Event, + status: usize, + packet: extern union { + RxData: *ManagedNetworkReceiveData, + TxData: *ManagedNetworkTransmitData, + }, +}; + +pub const ManagedNetworkReceiveData = extern struct { + timestamp: Time, + recycle_event: Event, + packet_length: u32, + header_length: u32, + address_length: u32, + data_length: u32, + broadcast_flag: bool, + multicast_flag: bool, + promiscuous_flag: bool, + protocol_type: u16, + destination_address: [*]u8, + source_address: [*]u8, + media_header: [*]u8, + packet_data: [*]u8, +}; + +pub const ManagedNetworkTransmitData = extern struct { + destination_address: ?*MacAddress, + source_address: ?*MacAddress, + protocol_type: u16, + data_length: u32, + header_length: u16, + fragment_count: u16, + + pub fn getFragments(self: *ManagedNetworkTransmitData) []ManagedNetworkFragmentData { + return @ptrCast([*]ManagedNetworkFragmentData, @ptrCast([*]u8, self) + @sizeOf(ManagedNetworkTransmitData))[0..self.fragment_count]; + } +}; + +pub const ManagedNetworkFragmentData = extern struct { + fragment_length: u32, + fragment_buffer: [*]u8, +}; 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 new file mode 100644 index 0000000000..492fe450ba --- /dev/null +++ b/lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig @@ -0,0 +1,25 @@ +const uefi = @import("std").os.uefi; +const Handle = uefi.Handle; +const Guid = uefi.Guid; + +pub const ManagedNetworkServiceBindingProtocol = extern struct { + _create_child: extern fn (*const ManagedNetworkServiceBindingProtocol, *?Handle) usize, + _destroy_child: extern fn (*const ManagedNetworkServiceBindingProtocol, Handle) usize, + + pub fn createChild(self: *const ManagedNetworkServiceBindingProtocol, handle: *?Handle) usize { + return self._create_child(self, handle); + } + + pub fn destroyChild(self: *const ManagedNetworkServiceBindingProtocol, handle: Handle) usize { + return self._destroy_child(self, handle); + } + + pub const guid align(8) = Guid{ + .time_low = 0xf36ff770, + .time_mid = 0xa7e1, + .time_high_and_version = 0x42cf, + .clock_seq_high_and_reserved = 0x9e, + .clock_seq_low = 0xd2, + .node = [_]u8{ 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c }, + }; +}; diff --git a/lib/std/os/uefi/protocols/simple_network_protocol.zig b/lib/std/os/uefi/protocols/simple_network_protocol.zig new file mode 100644 index 0000000000..f5e62734b6 --- /dev/null +++ b/lib/std/os/uefi/protocols/simple_network_protocol.zig @@ -0,0 +1,172 @@ +const uefi = @import("std").os.uefi; +const Event = uefi.Event; +const Guid = uefi.Guid; + +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, + wait_for_packet: Event, + mode: *SimpleNetworkMode, + + /// Changes the state of a network interface from "stopped" to "started". + pub fn start(self: *const SimpleNetworkProtocol) usize { + return self._start(self); + } + + /// Changes the state of a network interface from "started" to "stopped". + pub fn stop(self: *const SimpleNetworkProtocol) usize { + 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 { + 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 { + 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 { + 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 { + 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 { + 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 { + 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 { + 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 { + 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 { + 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 { + 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 { + return self._receive(self, header_size, buffer_size, buffer, src_addr, dest_addr, protocol); + } + + pub const guid align(8) = Guid{ + .time_low = 0xa19832b9, + .time_mid = 0xac25, + .time_high_and_version = 0x11d3, + .clock_seq_high_and_reserved = 0x9a, + .clock_seq_low = 0x2d, + .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }, + }; +}; + +pub const MacAddress = [32]u8; + +pub const SimpleNetworkMode = extern struct { + state: SimpleNetworkState, + hw_address_size: u32, + media_header_size: u32, + max_packet_size: u32, + nvram_size: u32, + nvram_access_size: u32, + receive_filter_mask: SimpleNetworkReceiveFilter, + receive_filter_setting: SimpleNetworkReceiveFilter, + max_mcast_filter_count: u32, + mcast_filter_count: u32, + mcast_filter: [16]MacAddress, + current_address: MacAddress, + broadcast_address: MacAddress, + permanent_address: MacAddress, + if_type: u8, + mac_address_changeable: bool, + multiple_tx_supported: bool, + media_present_supported: bool, + media_present: bool, +}; + +pub const SimpleNetworkReceiveFilter = packed struct { + receive_unicast: bool, + receive_multicast: bool, + receive_broadcast: bool, + receive_promiscuous: bool, + receive_promiscuous_multicast: bool, + _pad: u27 = undefined, +}; + +pub const SimpleNetworkState = extern enum(u32) { + Stopped, + Started, + Initialized, +}; + +pub const NetworkStatistics = extern struct { + rx_total_frames: u64, + rx_good_frames: u64, + rx_undersize_frames: u64, + rx_oversize_frames: u64, + rx_dropped_frames: u64, + rx_unicast_frames: u64, + rx_broadcast_frames: u64, + rx_multicast_frames: u64, + rx_crc_error_frames: u64, + rx_total_bytes: u64, + tx_total_frames: u64, + tx_good_frames: u64, + tx_undersize_frames: u64, + tx_oversize_frames: u64, + tx_dropped_frames: u64, + tx_unicast_frames: u64, + tx_broadcast_frames: u64, + tx_multicast_frames: u64, + tx_crc_error_frames: u64, + tx_total_bytes: u64, + collisions: u64, + unsupported_protocol: u64, + rx_duplicated_frames: u64, + rx_decryptError_frames: u64, + tx_error_frames: u64, + tx_retry_frames: u64, +}; + +pub const SimpleNetworkInterruptStatus = packed struct { + receive_interrupt: bool, + transmit_interrupt: bool, + command_interrupt: bool, + software_interrupt: bool, + _pad: u28, +}; diff --git a/lib/std/os/uefi/protocols/udp6_protocol.zig b/lib/std/os/uefi/protocols/udp6_protocol.zig new file mode 100644 index 0000000000..266f2964f9 --- /dev/null +++ b/lib/std/os/uefi/protocols/udp6_protocol.zig @@ -0,0 +1,112 @@ +const uefi = @import("std").os.uefi; +const Guid = uefi.Guid; +const Event = uefi.Event; +const Time = uefi.Time; +const Ip6ModeData = uefi.protocols.Ip6ModeData; +const Ip6Address = uefi.protocols.Ip6Address; +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 { + 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 { + return self._configure(self, udp6_config_data); + } + + pub fn groups(self: *const Udp6Protocol, join_flag: bool, multicast_address: ?*const Ip6Address) usize { + return self._groups(self, join_flag, multicast_address); + } + + pub fn transmit(self: *const Udp6Protocol, token: *Udp6CompletionToken) usize { + return self._transmit(self, token); + } + + pub fn receive(self: *const Udp6Protocol, token: *Udp6CompletionToken) usize { + return self._receive(self, token); + } + + pub fn cancel(self: *const Udp6Protocol, token: ?*Udp6CompletionToken) usize { + return self._cancel(self, token); + } + + pub fn poll(self: *const Udp6Protocol) usize { + return self._poll(self); + } + + pub const guid align(8) = uefi.Guid{ + .time_low = 0x4f948815, + .time_mid = 0xb4b9, + .time_high_and_version = 0x43cb, + .clock_seq_high_and_reserved = 0x8a, + .clock_seq_low = 0x33, + .node = [_]u8{ 0x90, 0xe0, 0x60, 0xb3, 0x49, 0x55 }, + }; +}; + +pub const Udp6ConfigData = extern struct { + accept_promiscuous: bool, + accept_any_port: bool, + allow_duplicate_port: bool, + traffic_class: u8, + hop_limit: u8, + receive_timeout: u32, + transmit_timeout: u32, + station_address: Ip6Address, + station_port: u16, + remote_address: Ip6Address, + remote_port: u16, +}; + +pub const Udp6CompletionToken = extern struct { + event: Event, + status: usize, + packet: extern union { + RxData: *Udp6ReceiveData, + TxData: *Udp6TransmitData, + }, +}; + +pub const Udp6ReceiveData = extern struct { + timestamp: Time, + recycle_signal: Event, + udp6_session: Udp6SessionData, + data_length: u32, + fragment_count: u32, + + pub fn getFragments(self: *Udp6ReceiveData) []Udp6FragmentData { + return @ptrCast([*]Udp6FragmentData, @ptrCast([*]u8, self) + @sizeOf(Udp6ReceiveData))[0..self.fragment_count]; + } +}; + +pub const Udp6TransmitData = extern struct { + udp6_session_data: ?*Udp6SessionData, + data_length: u32, + fragment_count: u32, + + pub fn getFragments(self: *Udp6TransmitData) []Udp6FragmentData { + return @ptrCast([*]Udp6FragmentData, @ptrCast([*]u8, self) + @sizeOf(Udp6TransmitData))[0..self.fragment_count]; + } +}; + +pub const Udp6SessionData = extern struct { + source_address: Ip6Address, + source_port: u16, + destination_address: Ip6Address, + destination_port: u16, +}; + +pub const Udp6FragmentData = extern struct { + fragment_length: u32, + fragment_buffer: [*]u8, +}; diff --git a/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig b/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig new file mode 100644 index 0000000000..2f499b50c6 --- /dev/null +++ b/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig @@ -0,0 +1,25 @@ +const uefi = @import("std").os.uefi; +const Handle = uefi.Handle; +const Guid = uefi.Guid; + +pub const Udp6ServiceBindingProtocol = extern struct { + _create_child: extern fn (*const Udp6ServiceBindingProtocol, *?Handle) usize, + _destroy_child: extern fn (*const Udp6ServiceBindingProtocol, Handle) usize, + + pub fn createChild(self: *const Udp6ServiceBindingProtocol, handle: *?Handle) usize { + return self._create_child(self, handle); + } + + pub fn destroyChild(self: *const Udp6ServiceBindingProtocol, handle: Handle) usize { + return self._destroy_child(self, handle); + } + + pub const guid align(8) = Guid{ + .time_low = 0x66ed4721, + .time_mid = 0x3c98, + .time_high_and_version = 0x4d3e, + .clock_seq_high_and_reserved = 0x81, + .clock_seq_low = 0xe3, + .node = [_]u8{ 0xd0, 0x3d, 0xd3, 0x9a, 0x72, 0x54 }, + }; +}; |
