--- /dev/null
+/** @file\r
+\r
+ Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
+\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+ EmuSnp.h\r
+\r
+Abstract:\r
+\r
+-**/\r
+\r
+#ifndef _EMU_SNP_H_\r
+#define _EMU_SNP_H_\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/SimpleNetwork.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/EmuIoThunk.h>\r
+#include <Protocol/EmuSnp.h>\r
+\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/NetLib.h>\r
+\r
+#define NET_ETHER_HEADER_SIZE 14\r
+\r
+//\r
+// Private data for driver.\r
+//\r
+#define EMU_SNP_PRIVATE_DATA_SIGNATURE SIGNATURE_32( 'U', 'S', 'N', 'P' )\r
+\r
+typedef struct {\r
+ UINTN Signature;\r
+ EMU_IO_THUNK_PROTOCOL *IoThunk;\r
+ EMU_SNP_PROTOCOL *Io;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ EFI_HANDLE EfiHandle;\r
+ EFI_HANDLE DeviceHandle;\r
+\r
+ EFI_SIMPLE_NETWORK_PROTOCOL Snp;\r
+ EFI_SIMPLE_NETWORK_MODE Mode;\r
+ \r
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
+\r
+} EMU_SNP_PRIVATE_DATA;\r
+\r
+#define EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS(a) \\r
+ CR( a, EMU_SNP_PRIVATE_DATA, Snp, EMU_SNP_PRIVATE_DATA_SIGNATURE )\r
+\r
+extern EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gEmuSnpDriverComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2;\r
+\r
+/**\r
+ Test to see if this driver supports ControllerHandle. This service\r
+ is called by the EFI boot service ConnectController(). In\r
+ order to make drivers as small as possible, there are a few calling\r
+ restrictions for this service. ConnectController() must\r
+ follow these calling restrictions. If any other agent wishes to call\r
+ Supported() it must also follow these calling restrictions.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ControllerHandle Handle of device to test\r
+ @param RemainingDevicePath Optional parameter use to pick a specific child\r
+ device to start.\r
+\r
+ @retval EFI_SUCCESS This driver supports this device\r
+ @retval EFI_UNSUPPORTED This driver does not support this device\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL * This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL\r
+ );\r
+\r
+/**\r
+ Start this driver on ControllerHandle. This service is called by the\r
+ EFI boot service ConnectController(). In order to make\r
+ drivers as small as possible, there are a few calling restrictions for\r
+ this service. ConnectController() must follow these\r
+ calling restrictions. If any other agent wishes to call Start() it\r
+ must also follow these calling restrictions.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ControllerHandle Handle of device to bind driver to\r
+ @param RemainingDevicePath Optional parameter use to pick a specific child\r
+ device to start.\r
+\r
+ @retval EFI_SUCCESS Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL * This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL\r
+ );\r
+\r
+/**\r
+ Stop this driver on ControllerHandle. This service is called by the\r
+ EFI boot service DisconnectController(). In order to\r
+ make drivers as small as possible, there are a few calling\r
+ restrictions for this service. DisconnectController()\r
+ must follow these calling restrictions. If any other agent wishes\r
+ to call Stop() it must also follow these calling restrictions.\r
+ \r
+ @param This Protocol instance pointer.\r
+ @param ControllerHandle Handle of device to stop driver on\r
+ @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
+ children is zero stop the entire bus driver.\r
+ @param ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+ @retval EFI_SUCCESS Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ );\r
+\r
+/**\r
+ Changes the state of a network interface from "stopped" to "started".\r
+\r
+ @param This Protocol instance pointer.\r
+\r
+ @retval EFI_SUCCESS Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStart(\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL* This\r
+ );\r
+ \r
+/**\r
+ Changes the state of a network interface from "started" to "stopped".\r
+\r
+ @param This Protocol instance pointer.\r
+\r
+ @retval EFI_SUCCESS Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStop(\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL* This\r
+ );\r
+ \r
+/**\r
+ Resets a network adapter and allocates the transmit and receive buffers \r
+ required by the network interface; optionally, also requests allocation \r
+ of additional transmit and receive buffers.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
+ that the driver should allocate for the network interface.\r
+ Some network interfaces will not be able to use the extra\r
+ buffer, and the caller will not know if it is actually\r
+ being used.\r
+ @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
+ that the driver should allocate for the network interface.\r
+ Some network interfaces will not be able to use the extra\r
+ buffer, and the caller will not know if it is actually\r
+ being used.\r
+\r
+ @retval EFI_SUCCESS Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpInitialize(\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
+ IN UINTN ExtraRxBufferSize OPTIONAL,\r
+ IN UINTN ExtraTxBufferSize OPTIONAL\r
+ );\r
+ \r
+/**\r
+ Resets a network adapter and re-initializes it with the parameters that were \r
+ provided in the previous call to Initialize(). \r
+\r
+ @param This Protocol instance pointer.\r
+ @param ExtendedVerification Indicates that the driver may perform a more\r
+ exhaustive verification operation of the device\r
+ during reset.\r
+\r
+ @retval EFI_SUCCESS Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReset(\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
+ IN BOOLEAN ExtendedVerification\r
+ );\r
+\r
+/**\r
+ Resets a network adapter and leaves it in a state that is safe for \r
+ another driver to initialize.\r
+\r
+ @param This Protocol instance pointer.\r
+\r
+ @retval EFI_SUCCESS Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpShutdown(\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL* This\r
+ );\r
+\r
+/**\r
+ Manages the multicast receive filters of a network interface.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param EnableBits A bit mask of receive filters to enable on the network interface.\r
+ @param DisableBits A bit mask of receive filters to disable on the network interface.\r
+ @param ResetMcastFilter Set to TRUE to reset the contents of the multicast receive\r
+ filters on the network interface to their default values.\r
+ @param McastFilterCount Number of multicast HW MAC addresses in the new\r
+ MCastFilter list. This value must be less than or equal to\r
+ the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This\r
+ field is optional if ResetMCastFilter is TRUE.\r
+ @param McastFilter A pointer to a list of new multicast receive filter HW MAC\r
+ addresses. This list will replace any existing multicast\r
+ HW MAC address list. This field is optional if\r
+ ResetMCastFilter is TRUE.\r
+\r
+ @retval EFI_SUCCESS The multicast receive filter list was updated.\r
+ @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReceiveFilters(\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
+ IN UINT32 EnableBits,\r
+ IN UINT32 DisableBits,\r
+ IN BOOLEAN ResetMcastFilter,\r
+ IN UINTN McastFilterCount OPTIONAL,\r
+ IN EFI_MAC_ADDRESS* McastFilter OPTIONAL\r
+ );\r
+\r
+/**\r
+ Modifies or resets the current station address, if supported.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param Reset Flag used to reset the station address to the network interfaces\r
+ permanent address.\r
+ @param NewMacAddr New station address to be used for the network interface.\r
+\r
+ @retval EFI_UNSUPPORTED Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStationAddress(\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
+ IN BOOLEAN Reset,\r
+ IN EFI_MAC_ADDRESS* NewMacAddr OPTIONAL\r
+ );\r
+\r
+/**\r
+ Resets or collects the statistics on a network interface.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param Reset Set to TRUE to reset the statistics for the network interface.\r
+ @param StatisticsSize On input the size, in bytes, of StatisticsTable. On\r
+ output the size, in bytes, of the resulting table of\r
+ statistics.\r
+ @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
+ contains the statistics.\r
+\r
+ @retval EFI_SUCCESS The statistics were collected from the network interface.\r
+ @retval EFI_NOT_STARTED The network interface has not been started.\r
+ @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r
+ size needed to hold the statistics is returned in\r
+ StatisticsSize.\r
+ @retval EFI_UNSUPPORTED Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStatistics(\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
+ IN BOOLEAN Reset,\r
+ IN OUT UINTN* StatisticsSize OPTIONAL,\r
+ OUT EFI_NETWORK_STATISTICS* StatisticsTable OPTIONAL\r
+ );\r
+ \r
+/**\r
+ Converts a multicast IP address to a multicast HW MAC address.\r
+ \r
+ @param This Protocol instance pointer.\r
+ @param Ipv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
+ to FALSE if the multicast IP address is IPv4 [RFC 791].\r
+ @param Ip The multicast IP address that is to be converted to a multicast\r
+ HW MAC address.\r
+ @param Mac The multicast HW MAC address that is to be generated from IP.\r
+\r
+ @retval EFI_SUCCESS The multicast IP address was mapped to the multicast\r
+ HW MAC address.\r
+ @retval EFI_NOT_STARTED The network interface has not been started.\r
+ @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r
+ size needed to hold the statistics is returned in\r
+ StatisticsSize.\r
+ @retval EFI_UNSUPPORTED Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpMcastIptoMac(\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
+ IN BOOLEAN Ipv6,\r
+ IN EFI_IP_ADDRESS* Ip,\r
+ OUT EFI_MAC_ADDRESS* Mac\r
+ );\r
+\r
+/**\r
+ Performs read and write operations on the NVRAM device attached to a \r
+ network interface.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ReadOrWrite TRUE for read operations, FALSE for write operations.\r
+ @param Offset Byte offset in the NVRAM device at which to start the read or\r
+ write operation. This must be a multiple of NvRamAccessSize and\r
+ less than NvRamSize.\r
+ @param BufferSize The number of bytes to read or write from the NVRAM device.\r
+ This must also be a multiple of NvramAccessSize.\r
+ @param Buffer A pointer to the data buffer.\r
+\r
+ @retval EFI_UNSUPPORTED Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpNvdata(\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
+ IN BOOLEAN ReadOrWrite,\r
+ IN UINTN Offset,\r
+ IN UINTN BufferSize,\r
+ IN OUT VOID* Buffer\r
+ );\r
+\r
+/**\r
+ Reads the current interrupt status and recycled transmit buffer status from \r
+ a network interface.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param InterruptStatus A pointer to the bit mask of the currently active interrupts\r
+ If this is NULL, the interrupt status will not be read from\r
+ the device. If this is not NULL, the interrupt status will\r
+ be read from the device. When the interrupt status is read,\r
+ it will also be cleared. Clearing the transmit interrupt\r
+ does not empty the recycled transmit buffer array.\r
+ @param TxBuffer Recycled transmit buffer address. The network interface will\r
+ not transmit if its internal recycled transmit buffer array\r
+ is full. Reading the transmit buffer does not clear the\r
+ transmit interrupt. If this is NULL, then the transmit buffer\r
+ status will not be read. If there are no transmit buffers to\r
+ recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
+\r
+ @retval EFI_SUCCESS Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpGetStatus(\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
+ OUT UINT32* InterruptStatus,\r
+ OUT VOID** TxBuffer\r
+ );\r
+\r
+/**\r
+ Places a packet in the transmit queue of a network interface.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param HeaderSize The size, in bytes, of the media header to be filled in by\r
+ the Transmit() function. If HeaderSize is non-zero, then it\r
+ must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
+ and Protocol parameters must not be NULL.\r
+ @param BufferSize The size, in bytes, of the entire packet (media header and\r
+ data) to be transmitted through the network interface.\r
+ @param Buffer A pointer to the packet (media header followed by data) to be\r
+ transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
+ then the media header in Buffer must already be filled in by the\r
+ caller. If HeaderSize is non-zero, then the media header will be\r
+ filled in by the Transmit() function.\r
+ @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter\r
+ is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
+ This->Mode->CurrentAddress is used for the source HW MAC address.\r
+ @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this\r
+ parameter is ignored.\r
+ @param Protocol The type of header to build. If HeaderSize is zero, then this\r
+ parameter is ignored. See RFC 1700, section "Ether Types", for\r
+ examples.\r
+\r
+ @retval EFI_SUCCESS The packet was placed on the transmit queue.\r
+ @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
+ @retval EFI_ACCESS_DENIED Error acquire global lock for operation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpTransmit(\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
+ IN UINTN HeaderSize,\r
+ IN UINTN BufferSize,\r
+ IN VOID* Buffer,\r
+ IN EFI_MAC_ADDRESS* SrcAddr OPTIONAL,\r
+ IN EFI_MAC_ADDRESS* DestAddr OPTIONAL,\r
+ IN UINT16* Protocol OPTIONAL\r
+ );\r
+\r
+/**\r
+ Receives a packet from a network interface.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param HeaderSize The size, in bytes, of the media header received on the network\r
+ interface. If this parameter is NULL, then the media header size\r
+ will not be returned.\r
+ @param BuffSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
+ bytes, of the packet that was received on the network interface.\r
+ @param Buffer A pointer to the data buffer to receive both the media header and\r
+ the data.\r
+ @param SourceAddr The source HW MAC address. If this parameter is NULL, the\r
+ HW MAC source address will not be extracted from the media\r
+ header.\r
+ @param DestinationAddr The destination HW MAC address. If this parameter is NULL,\r
+ the HW MAC destination address will not be extracted from the\r
+ media header.\r
+ @param Protocol The media header type. If this parameter is NULL, then the\r
+ protocol will not be extracted from the media header. See\r
+ RFC 1700 section "Ether Types" for examples.\r
+\r
+ @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has\r
+ been updated to the number of bytes received.\r
+ @retval EFI_NOT_READY The network interface is too busy to accept this transmit\r
+ request.\r
+ @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r
+ @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
+ @retval EFI_ACCESS_DENIED Error acquire global lock for operation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReceive(\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
+ OUT UINTN* HeaderSize OPTIONAL,\r
+ IN OUT UINTN* BuffSize,\r
+ OUT VOID* Buffer,\r
+ OUT EFI_MAC_ADDRESS* SourceAddr OPTIONAL,\r
+ OUT EFI_MAC_ADDRESS* DestinationAddr OPTIONAL,\r
+ OUT UINT16* Protocol OPTIONAL\r
+ );\r
+\r
+VOID\r
+EFIAPI\r
+EmuSnpWaitForPacketNotify(\r
+ IN EFI_EVENT Event,\r
+ IN VOID* Private\r
+ );\r
+\r
+#endif // _EMU_SNP_H_\r