--- /dev/null
+/** @file\r
+ Definitions for ASIX AX88772 Ethernet adapter.\r
+\r
+ Copyright (c) 2011, Intel Corporation\r
+ All rights reserved. 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
+**/\r
+\r
+#ifndef _AX88772_H_\r
+#define _AX88772_H_\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Guid/EventGroup.h>\r
+#include <Guid/NicIp4ConfigNvData.h>\r
+\r
+#include <IndustryStandard/Pci.h>\r
+\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiRuntimeLib.h>\r
+\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/LoadedImage.h>\r
+#include <Protocol/NetworkInterfaceIdentifier.h>\r
+#include <Protocol/SimpleNetwork.h>\r
+#include <Protocol/UsbIo.h>\r
+\r
+#define MAX_QUEUE_SIZE 50\r
+#define MAX_BULKIN_SIZE 16384\r
+#define HW_HDR_LENGTH 8\r
+\r
+\r
+#define MAX_LINKIDLE_THRESHOLD 20000\r
+\r
+\r
+\r
+//------------------------------------------------------------------------------\r
+// Macros\r
+//------------------------------------------------------------------------------\r
+\r
+#if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */\r
+#define DBG_ENTER() DEBUG (( 0xffffffff, "Entering " __FUNCTION__ "\n" )) ///< Display routine entry\r
+#define DBG_EXIT() DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ "\n" )) ///< Display routine exit\r
+#define DBG_EXIT_DEC(Status) DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ ", Status: %d\n", Status )) ///< Display routine exit with decimal value\r
+#define DBG_EXIT_HEX(Status) DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ ", Status: 0x%08x\n", Status )) ///< Display routine exit with hex value\r
+#define DBG_EXIT_STATUS(Status) DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ ", Status: %r\n", Status )) ///< Display routine exit with status value\r
+#define DBG_EXIT_TF(Status) DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ ", returning %s\n", (FALSE == Status) ? L"FALSE" : L"TRUE" )) ///< Display routine with TRUE/FALSE value\r
+#else // _MSC_VER\r
+#define DBG_ENTER() ///< Display routine entry\r
+#define DBG_EXIT() ///< Display routine exit\r
+#define DBG_EXIT_DEC(Status) ///< Display routine exit with decimal value\r
+#define DBG_EXIT_HEX(Status) ///< Display routine exit with hex value\r
+#define DBG_EXIT_STATUS(Status) ///< Display routine exit with status value\r
+#define DBG_EXIT_TF(Status) ///< Display routine with TRUE/FALSE value\r
+#endif // _MSC_VER\r
+\r
+#define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) != 0) ///< Return TRUE/FALSE for IN direction\r
+#define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == 0) ///< Return TRUE/FALSE for OUT direction\r
+#define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_BULK) ///< Return TRUE/FALSE for BULK type\r
+#define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) ///< Return TRUE/FALSE for INTERRUPT type\r
+\r
+\r
+#define PRINT(_L_STR) (gST->ConOut->OutputString(gST->ConOut,(_L_STR)))\r
+//------------------------------------------------------------------------------\r
+// Constants\r
+//------------------------------------------------------------------------------\r
+\r
+#define DEBUG_RX_BROADCAST 0x40000000 ///< Display RX broadcast messages\r
+#define DEBUG_RX_MULTICAST 0x20000000 ///< Display RX multicast messages\r
+#define DEBUG_RX_UNICAST 0x10000000 ///< Display RX unicast messages\r
+#define DEBUG_MAC_ADDRESS 0x08000000 ///< Display the MAC address\r
+#define DEBUG_LINK 0x04000000 ///< Display the link status\r
+#define DEBUG_TX 0x02000000 ///< Display the TX messages\r
+#define DEBUG_PHY 0x01000000 ///< Display the PHY register values\r
+#define DEBUG_SROM 0x00800000 ///< Display the SROM contents\r
+#define DEBUG_TIMER 0x00400000 ///< Display the timer routine entry/exit\r
+#define DEBUG_TPL 0x00200000 ///< Display the timer routine entry/exit\r
+\r
+#define AX88772_MAX_PKT_SIZE 2048 ///< Maximum packet size\r
+\r
+#define ETHERNET_HEADER_SIZE sizeof ( ETHERNET_HEADER ) ///< Size in bytes of the Ethernet header\r
+#define MIN_ETHERNET_PKT_SIZE 60 ///< Minimum packet size including Ethernet header\r
+#define MAX_ETHERNET_PKT_SIZE 1500 ///< Ethernet spec 3.1.1: Minimum packet size\r
+\r
+#define USB_NETWORK_CLASS 0x09 ///< USB Network class code\r
+#define USB_BUS_TIMEOUT 1000 ///< USB timeout in milliseconds\r
+\r
+#define TIMER_MSEC 20 ///< Polling interval for the NIC\r
+//#define TPL_AX88772 TPL_CALLBACK ///< TPL for routine synchronization\r
+\r
+#define HC_DEBUG 0\r
+#define BULKIN_TIMEOUT 20\r
+#define AUTONEG_DELAY 500000\r
+#define AUTONEG_POLLCNT 20\r
+\r
+/**\r
+ Verify new TPL value\r
+\r
+ This macro which is enabled when debug is enabled verifies that\r
+ the new TPL value is >= the current TPL value.\r
+**/\r
+#ifdef VERIFY_TPL\r
+#undef VERIFY_TPL\r
+#endif // VERIFY_TPL\r
+\r
+#if !defined(MDEPKG_NDEBUG)\r
+\r
+#define VERIFY_TPL(tpl) \\r
+{ \\r
+ EFI_TPL PreviousTpl; \\r
+ \\r
+ PreviousTpl = gBS->RaiseTPL ( TPL_HIGH_LEVEL ); \\r
+ gBS->RestoreTPL ( PreviousTpl ); \\r
+ if ( PreviousTpl > tpl ) { \\r
+ DEBUG (( DEBUG_ERROR, "Current TPL: %d, New TPL: %d\r\n", PreviousTpl, tpl )); \\r
+ ASSERT ( PreviousTpl <= tpl ); \\r
+ } \\r
+}\r
+\r
+#else // MDEPKG_NDEBUG\r
+\r
+#define VERIFY_TPL(tpl)\r
+\r
+#endif // MDEPKG_NDEBUG\r
+\r
+//------------------------------------------------------------------------------\r
+// Hardware Definition\r
+//------------------------------------------------------------------------------\r
+\r
+#define FreeQueueSize 10\r
+\r
+#define DEV_SIGNATURE SIGNATURE_32 ('A','X','8','8') ///< Signature of data structures in memory\r
+\r
+#define VENDOR_ID 0x0B95 ///< Vendor ID for Asix\r
+#define PRODUCT_ID 0x772B ///< Product ID for the AX88772 USB 10/100 Ethernet controller\r
+\r
+#define RESET_MSEC 1000 ///< Reset duration\r
+#define PHY_RESET_MSEC 500 ///< PHY reset duration\r
+\r
+//\r
+// RX Control register\r
+//\r
+\r
+#define RXC_PRO 0x0001 ///< Receive all packets\r
+#define RXC_AMALL 0x0002 ///< Receive all multicast packets\r
+#define RXC_SEP 0x0004 ///< Save error packets\r
+#define RXC_AB 0x0008 ///< Receive broadcast packets\r
+#define RXC_AM 0x0010 ///< Use multicast destination address hash table\r
+#define RXC_AP 0x0020 ///< Accept physical address from Multicast Filter\r
+#define RXC_SO 0x0080 ///< Start operation\r
+#define RXC_MFB 0x0300 ///< Maximum frame burst\r
+#define RXC_MFB_2048 0 ///< Maximum frame size: 2048 bytes\r
+#define RXC_MFB_4096 0x0100 ///< Maximum frame size: 4096 bytes\r
+#define RXC_MFB_8192 0x0200 ///< Maximum frame size: 8192 bytes\r
+#define RXC_MFB_16384 0x0300 ///< Maximum frame size: 16384 bytes\r
+\r
+/*Freddy*/\r
+#define RXC_RH1M 0x0100 ///< Rx header 1\r
+#define RXC_RH2M 0x0200 ///< Rx header 2\r
+#define RXC_RH3M 0x0400 ///< Rx header 3\r
+/*Freddy*/\r
+\r
+//\r
+// Medium Status register\r
+//\r
+\r
+#define MS_FD 0x0002 ///< Full duplex\r
+#define MS_ONE 0x0004 ///< Must be one\r
+#define MS_RFC 0x0010 ///< RX flow control enable\r
+#define MS_TFC 0x0020 ///< TX flow control enable\r
+#define MS_PF 0x0080 ///< Pause frame enable\r
+#define MS_RE 0x0100 ///< Receive enable\r
+#define MS_PS 0x0200 ///< Port speed 1=100, 0=10 Mbps\r
+#define MS_SBP 0x0800 ///< Stop back pressure\r
+#define MS_SM 0x1000 ///< Super MAC support\r
+\r
+//\r
+// Software PHY Select register\r
+//\r
+\r
+#define SPHY_PSEL (1 << 0) ///< Select internal PHY\r
+#define SPHY_SSMII (1 << 2)\r
+#define SPHY_SSEN (1 << 4)\r
+#define SPHY_ASEL 0x02 ///< 1=Auto select, 0=Manual select\r
+\r
+//\r
+// Software Reset register\r
+//\r
+\r
+#define SRR_RR 0x01 ///< Clear receive frame length error\r
+#define SRR_RT 0x02 ///< Clear transmit frame length error\r
+#define SRR_BZTYPE 0x04 ///< External PHY reset pin tri-state enable\r
+#define SRR_PRL 0x08 ///< External PHY reset pin level\r
+#define SRR_BZ 0x10 ///< Force Bulk to return zero length packet\r
+#define SRR_IPRL 0x20 ///< Internal PHY reset control\r
+#define SRR_IPPD 0x40 ///< Internal PHY power down\r
+\r
+//\r
+// PHY ID values\r
+//\r
+\r
+#define PHY_ID_INTERNAL 0x0010 ///< Internal PHY\r
+\r
+//\r
+// USB Commands\r
+//\r
+\r
+#define CMD_PHY_ACCESS_SOFTWARE 0x06 ///< Software in control of PHY\r
+#define CMD_PHY_REG_READ 0x07 ///< Read PHY register, Value: PHY, Index: Register, Data: Register value\r
+#define CMD_PHY_REG_WRITE 0x08 ///< Write PHY register, Value: PHY, Index: Register, Data: New 16-bit value\r
+#define CMD_PHY_ACCESS_HARDWARE 0x0a ///< Hardware in control of PHY\r
+#define CMD_SROM_READ 0x0b ///< Read SROM register: Value: Address, Data: Value\r
+#define CMD_RX_CONTROL_WRITE 0x10 ///< Set the RX control register, Value: New value\r
+#define CMD_GAPS_WRITE 0x12 ///< Write the gaps register, Value: New value\r
+#define CMD_MAC_ADDRESS_READ 0x13 ///< Read the MAC address, Data: 6 byte MAC address\r
+#define CMD_MAC_ADDRESS_WRITE 0x14 ///< Set the MAC address, Data: New 6 byte MAC address\r
+#define CMD_MULTICAST_HASH_WRITE 0x16 ///< Write the multicast hash table, Data: New 8 byte value\r
+#define CMD_MULTICAST_HASH_READ 0x16 ///< Read the multicast hash table\r
+#define CMD_MEDIUM_STATUS_READ 0x1a ///< Read medium status register, Data: Register value\r
+#define CMD_MEDIUM_STATUS_WRITE 0x1b ///< Write medium status register, Value: New value\r
+#define CMD_WRITE_GPIOS 0x1f\r
+#define CMD_RESET 0x20 ///< Reset register, Value: New value\r
+#define CMD_PHY_SELECT 0x22 ///< PHY select register, Value: New value\r
+\r
+/*Freddy*/\r
+#define CMD_RXQTC 0x2a ///< RX Queue Cascade Threshold Control Register\r
+/*Freddy*/\r
+\r
+//------------------------------\r
+// USB Endpoints\r
+//------------------------------\r
+\r
+#define CONTROL_ENDPOINT 0 ///< Control endpoint\r
+#define INTERRUPT_ENDPOINT 1 ///< Interrupt endpoint\r
+#define BULK_IN_ENDPOINT 2 ///< Receive endpoint\r
+#define BULK_OUT_ENDPOINT 3 ///< Transmit endpoint\r
+\r
+//------------------------------\r
+// PHY Registers\r
+//------------------------------\r
+\r
+#define PHY_BMCR 0 ///< Control register\r
+#define PHY_BMSR 1 ///< Status register\r
+#define PHY_ANAR 4 ///< Autonegotiation advertisement register\r
+#define PHY_ANLPAR 5 ///< Autonegotiation link parter ability register\r
+#define PHY_ANER 6 ///< Autonegotiation expansion register\r
+\r
+// BMCR - Register 0\r
+\r
+#define BMCR_RESET 0x8000 ///< 1 = Reset the PHY, bit clears after reset\r
+#define BMCR_LOOPBACK 0x4000 ///< 1 = Loopback enabled\r
+#define BMCR_100MBPS 0x2000 ///< 100 Mbits/Sec\r
+#define BMCR_10MBPS 0 ///< 10 Mbits/Sec\r
+#define BMCR_AUTONEGOTIATION_ENABLE 0x1000 ///< 1 = Enable autonegotiation\r
+#define BMCR_POWER_DOWN 0x0800 ///< 1 = Power down\r
+#define BMCR_ISOLATE 0x0400 ///< 0 = Isolate PHY\r
+#define BMCR_RESTART_AUTONEGOTIATION 0x0200 ///< 1 = Restart autonegotiation\r
+#define BMCR_FULL_DUPLEX 0x0100 ///< Full duplex operation\r
+#define BMCR_HALF_DUPLEX 0 ///< Half duplex operation\r
+#define BMCR_COLLISION_TEST 0x0080 ///< 1 = Collision test enabled\r
+\r
+// BSMR - Register 1\r
+\r
+#define BMSR_100BASET4 0x8000 ///< 1 = 100BASE-T4 mode\r
+#define BMSR_100BASETX_FDX 0x4000 ///< 1 = 100BASE-TX full duplex\r
+#define BMSR_100BASETX_HDX 0x2000 ///< 1 = 100BASE-TX half duplex\r
+#define BMSR_10BASET_FDX 0x1000 ///< 1 = 10BASE-T full duplex\r
+#define BMSR_10BASET_HDX 0x0800 ///< 1 = 10BASE-T half duplex\r
+#define BMSR_MF 0x0040 ///< 1 = PHY accepts frames with preamble suppressed\r
+#define BMSR_AUTONEG_CMPLT 0x0020 ///< 1 = Autonegotiation complete\r
+#define BMSR_RF 0x0010 ///< 1 = Remote fault\r
+#define BMSR_AUTONEG 0x0008 ///< 1 = Able to perform autonegotiation\r
+#define BMSR_LINKST 0x0004 ///< 1 = Link up\r
+#define BMSR_JABBER_DETECT 0x0002 ///< 1 = jabber condition detected\r
+#define BMSR_EXTENDED_CAPABILITY 0x0001 ///< 1 = Extended register capable\r
+\r
+// ANAR and ANLPAR Registers 4, 5\r
+\r
+#define AN_NP 0x8000 ///< 1 = Next page available\r
+#define AN_ACK 0x4000 ///< 1 = Link partner acknowledged\r
+#define AN_RF 0x2000 ///< 1 = Remote fault indicated by link partner\r
+#define AN_FCS 0x0400 ///< 1 = Flow control ability\r
+#define AN_T4 0x0200 ///< 1 = 100BASE-T4 support\r
+#define AN_TX_FDX 0x0100 ///< 1 = 100BASE-TX Full duplex\r
+#define AN_TX_HDX 0x0080 ///< 1 = 100BASE-TX support\r
+#define AN_10_FDX 0x0040 ///< 1 = 10BASE-T Full duplex\r
+#define AN_10_HDX 0x0020 ///< 1 = 10BASE-T support\r
+#define AN_CSMA_CD 0x0001 ///< 1 = IEEE 802.3 CSMA/CD support\r
+\r
+\r
+\r
+//------------------------------------------------------------------------------\r
+// Data Types\r
+//------------------------------------------------------------------------------\r
+\r
+/**\r
+ Ethernet header layout\r
+\r
+ IEEE 802.3-2002 Part 3 specification, section 3.1.1.\r
+**/\r
+#pragma pack(1)\r
+typedef struct {\r
+ UINT8 dest_addr[PXE_HWADDR_LEN_ETHER]; ///< Destination LAN address\r
+ UINT8 src_addr[PXE_HWADDR_LEN_ETHER]; ///< Source LAN address\r
+ UINT16 type; ///< Protocol or length\r
+} ETHERNET_HEADER;\r
+#pragma pack()\r
+\r
+/**\r
+ Receive and Transmit packet structure\r
+**/\r
+#pragma pack(1)\r
+typedef struct _RX_TX_PACKET {\r
+ struct _RX_TX_PACKET * pNext; ///< Next receive packet\r
+ UINT16 Length; ///< Packet length\r
+ UINT16 LengthBar; ///< Complement of the length\r
+ UINT8 Data[ AX88772_MAX_PKT_SIZE ]; ///< Received packet data\r
+} RX_TX_PACKET;\r
+#pragma pack()\r
+\r
+\r
+#pragma pack(1)\r
+typedef struct _RX_PKT {\r
+ struct _RX_PKT *pNext;\r
+ BOOLEAN f_Used;\r
+ UINT16 Length;\r
+ UINT8 Data [AX88772_MAX_PKT_SIZE] ;\r
+} RX_PKT;\r
+#pragma pack()\r
+\r
+/**\r
+ AX88772 control structure\r
+\r
+ The driver uses this structure to manage the Asix AX88772 10/100\r
+ Ethernet controller.\r
+**/\r
+typedef struct {\r
+ UINTN Signature; ///< Structure identification\r
+\r
+ //\r
+ // USB data\r
+ //\r
+ EFI_HANDLE Controller; ///< Controller handle\r
+ EFI_USB_IO_PROTOCOL * pUsbIo; ///< USB driver interface\r
+\r
+ //\r
+ // Simple network protocol data\r
+ //\r
+ EFI_SIMPLE_NETWORK_PROTOCOL SimpleNetwork; ///< Driver's network stack interface\r
+ EFI_SIMPLE_NETWORK_PROTOCOL SimpleNetwork_Backup;\r
+ EFI_SIMPLE_NETWORK_MODE SimpleNetworkData; ///< Data for simple network\r
+\r
+ //\r
+ // Ethernet controller data\r
+ //\r
+ BOOLEAN bInitialized; ///< Controller initialized\r
+ VOID * pTxBuffer; ///< Last transmit buffer\r
+ UINT16 PhyId; ///< PHY ID\r
+\r
+ //\r
+ // Link state\r
+ //\r
+ BOOLEAN b100Mbps; ///< Current link speed, FALSE = 10 Mbps\r
+ BOOLEAN bComplete; ///< Current state of auto-negotiation\r
+ BOOLEAN bFullDuplex; ///< Current duplex\r
+ BOOLEAN bLinkUp; ///< Current link state\r
+ UINTN LinkIdleCnt;\r
+ UINTN PollCount; ///< Number of times the autonegotiation status was polled\r
+ UINT16 CurRxControl;\r
+ //\r
+ // Receive buffer list\r
+ //\r
+ RX_TX_PACKET * pRxTest;\r
+ RX_TX_PACKET * pTxTest;\r
+\r
+ INT8 MulticastHash[8];\r
+ EFI_MAC_ADDRESS MAC;\r
+ BOOLEAN bHavePkt;\r
+ \r
+ EFI_DEVICE_PATH_PROTOCOL *MyDevPath;\r
+ \r
+ EFI_DRIVER_BINDING_PROTOCOL * DrvBind;\r
+ \r
+ RX_PKT * QueueHead;\r
+ RX_PKT * pNextFill;\r
+ RX_PKT * pFirstFill;\r
+ UINTN PktCntInQueue;\r
+ UINT8 * pBulkInBuff;\r
+ \r
+} NIC_DEVICE;\r
+\r
+#define DEV_FROM_SIMPLE_NETWORK(a) CR (a, NIC_DEVICE, SimpleNetwork, DEV_SIGNATURE) ///< Locate NIC_DEVICE from Simple Network Protocol\r
+\r
+//------------------------------------------------------------------------------\r
+// Simple Network Protocol\r
+//------------------------------------------------------------------------------\r
+\r
+/**\r
+ Reset the network adapter.\r
+\r
+ Resets a network adapter and reinitializes it with the parameters that\r
+ were provided in the previous call to Initialize (). The transmit and\r
+ receive queues are cleared. Receive filters, the station address, the\r
+ statistics, and the multicast-IP-to-HW MAC addresses are not reset by\r
+ this call.\r
+\r
+ This routine calls ::Ax88772Reset to perform the adapter specific\r
+ reset operation. This routine also starts the link negotiation\r
+ by calling ::Ax88772NegotiateLinkStart.\r
+\r
+ @param [in] pSimpleNetwork Protocol instance pointer\r
+ @param [in] bExtendedVerification Indicates that the driver may perform a more\r
+ exhaustive verification operation of the device\r
+ during reset.\r
+\r
+ @retval EFI_SUCCESS This operation was successful.\r
+ @retval EFI_NOT_STARTED The network interface was not started.\r
+ @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid\r
+ EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
+ @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
+ @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SN_Reset (\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,\r
+ IN BOOLEAN bExtendedVerification\r
+ );\r
+\r
+/**\r
+ Initialize the simple network protocol.\r
+\r
+ This routine calls ::Ax88772MacAddressGet to obtain the\r
+ MAC address.\r
+\r
+ @param [in] pNicDevice NIC_DEVICE_INSTANCE pointer\r
+\r
+ @retval EFI_SUCCESS Setup was successful\r
+\r
+**/\r
+EFI_STATUS\r
+SN_Setup (\r
+ IN NIC_DEVICE * pNicDevice\r
+ );\r
+\r
+/**\r
+ This routine starts the network interface.\r
+\r
+ @param [in] pSimpleNetwork Protocol instance pointer\r
+\r
+ @retval EFI_SUCCESS This operation was successful.\r
+ @retval EFI_ALREADY_STARTED The network interface was already started.\r
+ @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid\r
+ EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
+ @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
+ @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SN_Start (\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork\r
+ );\r
+\r
+/**\r
+ Set the MAC address.\r
+ \r
+ This function modifies or resets the current station address of a\r
+ network interface. If Reset is TRUE, then the current station address\r
+ is set ot the network interface's permanent address. If Reset if FALSE\r
+ then the current station address is changed to the address specified by\r
+ pNew.\r
+\r
+ This routine calls ::Ax88772MacAddressSet to update the MAC address\r
+ in the network adapter.\r
+\r
+ @param [in] pSimpleNetwork Protocol instance pointer\r
+ @param [in] bReset Flag used to reset the station address to the\r
+ network interface's permanent address.\r
+ @param [in] pNew New station address to be used for the network\r
+ interface.\r
+\r
+ @retval EFI_SUCCESS This operation was successful.\r
+ @retval EFI_NOT_STARTED The network interface was not started.\r
+ @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid\r
+ EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
+ @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
+ @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SN_StationAddress (\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,\r
+ IN BOOLEAN bReset,\r
+ IN EFI_MAC_ADDRESS * pNew\r
+ );\r
+\r
+/**\r
+ This function resets or collects the statistics on a network interface.\r
+ If the size of the statistics table specified by StatisticsSize is not\r
+ big enough for all of the statistics that are collected by the network\r
+ interface, then a partial buffer of statistics is returned in\r
+ StatisticsTable.\r
+\r
+ @param [in] pSimpleNetwork Protocol instance pointer\r
+ @param [in] bReset Set to TRUE to reset the statistics for the network interface.\r
+ @param [in, out] pStatisticsSize On input the size, in bytes, of StatisticsTable. On output\r
+ the size, in bytes, of the resulting table of statistics.\r
+ @param [out] pStatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
+ conains the statistics.\r
+\r
+ @retval EFI_SUCCESS This operation was successful.\r
+ @retval EFI_NOT_STARTED The network interface was not started.\r
+ @retval EFI_BUFFER_TOO_SMALL The pStatisticsTable is NULL or the buffer is too small.\r
+ @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid\r
+ EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
+ @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
+ @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SN_Statistics (\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,\r
+ IN BOOLEAN bReset,\r
+ IN OUT UINTN * pStatisticsSize,\r
+ OUT EFI_NETWORK_STATISTICS * pStatisticsTable\r
+ );\r
+\r
+/**\r
+ This function stops a network interface. This call is only valid\r
+ if the network interface is in the started state.\r
+\r
+ @param [in] pSimpleNetwork Protocol instance pointer\r
+\r
+ @retval EFI_SUCCESS This operation was successful.\r
+ @retval EFI_NOT_STARTED The network interface was not started.\r
+ @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid\r
+ EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
+ @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
+ @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SN_Stop (\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork\r
+ );\r
+\r
+/**\r
+ This function releases the memory buffers assigned in the Initialize() call.\r
+ Pending transmits and receives are lost, and interrupts are cleared and disabled.\r
+ After this call, only Initialize() and Stop() calls may be used.\r
+\r
+ @param [in] pSimpleNetwork Protocol instance pointer\r
+\r
+ @retval EFI_SUCCESS This operation was successful.\r
+ @retval EFI_NOT_STARTED The network interface was not started.\r
+ @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid\r
+ EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
+ @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
+ @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SN_Shutdown (\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork\r
+ );\r
+\r
+/**\r
+ Send a packet over the network.\r
+\r
+ This function places the packet specified by Header and Buffer on\r
+ the transmit queue. This function performs a non-blocking transmit\r
+ operation. When the transmit is complete, the buffer is returned\r
+ via the GetStatus() call.\r
+\r
+ This routine calls ::Ax88772Rx to empty the network adapter of\r
+ receive packets. The routine then passes the transmit packet\r
+ to the network adapter.\r
+\r
+ @param [in] pSimpleNetwork Protocol instance pointer\r
+ @param [in] HeaderSize The size, in bytes, of the media header to be filled in by\r
+ the Transmit() function. If HeaderSize is non-zero, then\r
+ it must be equal to SimpleNetwork->Mode->MediaHeaderSize\r
+ and DestAddr and Protocol parameters must not be NULL.\r
+ @param [in] BufferSize The size, in bytes, of the entire packet (media header and\r
+ data) to be transmitted through the network interface.\r
+ @param [in] pBuffer A pointer to the packet (media header followed by data) to\r
+ to be transmitted. This parameter can not be NULL. If\r
+ HeaderSize is zero, then the media header is Buffer must\r
+ already be filled in by the caller. If HeaderSize is nonzero,\r
+ then the media header will be filled in by the Transmit()\r
+ function.\r
+ @param [in] pSrcAddr The source HW MAC address. If HeaderSize is zero, then\r
+ this parameter is ignored. If HeaderSize is nonzero and\r
+ SrcAddr is NULL, then SimpleNetwork->Mode->CurrentAddress\r
+ is used for the source HW MAC address.\r
+ @param [in] pDestAddr The destination HW MAC address. If HeaderSize is zero, then\r
+ this parameter is ignored.\r
+ @param [in] pProtocol The type of header to build. If HeaderSize is zero, then\r
+ this parameter is ignored.\r
+\r
+ @retval EFI_SUCCESS This operation was successful.\r
+ @retval EFI_NOT_STARTED The network interface was not started.\r
+ @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.\r
+ @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r
+ @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid\r
+ EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
+ @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SN_Transmit (\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,\r
+ IN UINTN HeaderSize,\r
+ IN UINTN BufferSize,\r
+ IN VOID * pBuffer,\r
+ IN EFI_MAC_ADDRESS * pSrcAddr,\r
+ IN EFI_MAC_ADDRESS * pDestAddr,\r
+ IN UINT16 * pProtocol\r
+ );\r
+\r
+//------------------------------------------------------------------------------\r
+// Support Routines\r
+//------------------------------------------------------------------------------\r
+\r
+/**\r
+ Get the MAC address\r
+\r
+ This routine calls ::Ax88772UsbCommand to request the MAC\r
+ address from the network adapter.\r
+\r
+ @param [in] pNicDevice Pointer to the NIC_DEVICE structure\r
+ @param [out] pMacAddress Address of a six byte buffer to receive the MAC address.\r
+\r
+ @retval EFI_SUCCESS The MAC address is available.\r
+ @retval other The MAC address is not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+Ax88772MacAddressGet (\r
+ IN NIC_DEVICE * pNicDevice,\r
+ OUT UINT8 * pMacAddress\r
+ );\r
+\r
+/**\r
+ Set the MAC address\r
+\r
+ This routine calls ::Ax88772UsbCommand to set the MAC address\r
+ in the network adapter.\r
+\r
+ @param [in] pNicDevice Pointer to the NIC_DEVICE structure\r
+ @param [in] pMacAddress Address of a six byte buffer to containing the new MAC address.\r
+\r
+ @retval EFI_SUCCESS The MAC address was set.\r
+ @retval other The MAC address was not set.\r
+\r
+**/\r
+EFI_STATUS\r
+Ax88772MacAddressSet (\r
+ IN NIC_DEVICE * pNicDevice,\r
+ IN UINT8 * pMacAddress\r
+ );\r
+\r
+/**\r
+ Clear the multicast hash table\r
+\r
+ @param [in] pNicDevice Pointer to the NIC_DEVICE structure\r
+\r
+**/\r
+VOID\r
+Ax88772MulticastClear (\r
+ IN NIC_DEVICE * pNicDevice\r
+ );\r
+\r
+/**\r
+ Enable a multicast address in the multicast hash table\r
+\r
+ This routine calls ::Ax88772Crc to compute the hash bit for\r
+ this MAC address.\r
+\r
+ @param [in] pNicDevice Pointer to the NIC_DEVICE structure\r
+ @param [in] pMacAddress Address of a six byte buffer to containing the MAC address.\r
+\r
+**/\r
+VOID\r
+Ax88772MulticastSet (\r
+ IN NIC_DEVICE * pNicDevice,\r
+ IN UINT8 * pMacAddress\r
+ );\r
+\r
+/**\r
+ Start the link negotiation\r
+\r
+ This routine calls ::Ax88772PhyWrite to start the PHY's link\r
+ negotiation.\r
+\r
+ @param [in] pNicDevice Pointer to the NIC_DEVICE structure\r
+\r
+ @retval EFI_SUCCESS The link negotiation was started.\r
+ @retval other Failed to start the link negotiation.\r
+\r
+**/\r
+EFI_STATUS\r
+Ax88772NegotiateLinkStart (\r
+ IN NIC_DEVICE * pNicDevice\r
+ );\r
+\r
+/**\r
+ Complete the negotiation of the PHY link\r
+\r
+ This routine calls ::Ax88772PhyRead to determine if the\r
+ link negotiation is complete.\r
+\r
+ @param [in] pNicDevice Pointer to the NIC_DEVICE structure\r
+ @param [in, out] pPollCount Address of number of times this routine was polled\r
+ @param [out] pbComplete Address of boolean to receive complate status.\r
+ @param [out] pbLinkUp Address of boolean to receive link status, TRUE=up.\r
+ @param [out] pbHiSpeed Address of boolean to receive link speed, TRUE=100Mbps.\r
+ @param [out] pbFullDuplex Address of boolean to receive link duplex, TRUE=full.\r
+\r
+ @retval EFI_SUCCESS The MAC address is available.\r
+ @retval other The MAC address is not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+Ax88772NegotiateLinkComplete (\r
+ IN NIC_DEVICE * pNicDevice,\r
+ IN OUT UINTN * pPollCount,\r
+ OUT BOOLEAN * pbComplete,\r
+ OUT BOOLEAN * pbLinkUp,\r
+ OUT BOOLEAN * pbHiSpeed,\r
+ OUT BOOLEAN * pbFullDuplex\r
+ );\r
+\r
+/**\r
+ Read a register from the PHY\r
+\r
+ This routine calls ::Ax88772UsbCommand to read a PHY register.\r
+\r
+ @param [in] pNicDevice Pointer to the NIC_DEVICE structure\r
+ @param [in] RegisterAddress Number of the register to read.\r
+ @param [in, out] pPhyData Address of a buffer to receive the PHY register value\r
+\r
+ @retval EFI_SUCCESS The PHY data is available.\r
+ @retval other The PHY data is not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+Ax88772PhyRead (\r
+ IN NIC_DEVICE * pNicDevice,\r
+ IN UINT8 RegisterAddress,\r
+ IN OUT UINT16 * pPhyData\r
+ );\r
+\r
+/**\r
+ Write to a PHY register\r
+\r
+ This routine calls ::Ax88772UsbCommand to write a PHY register.\r
+\r
+ @param [in] pNicDevice Pointer to the NIC_DEVICE structure\r
+ @param [in] RegisterAddress Number of the register to read.\r
+ @param [in] PhyData Address of a buffer to receive the PHY register value\r
+\r
+ @retval EFI_SUCCESS The PHY data was written.\r
+ @retval other Failed to wwrite the PHY register.\r
+\r
+**/\r
+EFI_STATUS\r
+Ax88772PhyWrite (\r
+ IN NIC_DEVICE * pNicDevice,\r
+ IN UINT8 RegisterAddress,\r
+ IN UINT16 PhyData\r
+ );\r
+\r
+/**\r
+ Reset the AX88772\r
+\r
+ This routine uses ::Ax88772UsbCommand to reset the network\r
+ adapter. This routine also uses ::Ax88772PhyWrite to reset\r
+ the PHY.\r
+\r
+ @param [in] pNicDevice Pointer to the NIC_DEVICE structure\r
+\r
+ @retval EFI_SUCCESS The MAC address is available.\r
+ @retval other The MAC address is not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+Ax88772Reset (\r
+ IN NIC_DEVICE * pNicDevice\r
+ );\r
+\r
+VOID\r
+Ax88772ChkLink (\r
+ IN NIC_DEVICE * pNicDevice,\r
+ IN BOOLEAN bUpdateLink\r
+ );\r
+\r
+/**\r
+ Receive a frame from the network.\r
+\r
+ This routine polls the USB receive interface for a packet. If a packet\r
+ is available, this routine adds the receive packet to the list of\r
+ pending receive packets.\r
+\r
+ This routine calls ::Ax88772NegotiateLinkComplete to verify\r
+ that the link is up. This routine also calls ::SN_Reset to\r
+ reset the network adapter when necessary. Finally this\r
+ routine attempts to receive one or more packets from the\r
+ network adapter.\r
+\r
+ @param [in] pNicDevice Pointer to the NIC_DEVICE structure\r
+ @param [in] bUpdateLink TRUE = Update link status\r
+\r
+**/\r
+VOID\r
+Ax88772Rx (\r
+ IN NIC_DEVICE * pNicDevice,\r
+ IN BOOLEAN bUpdateLink\r
+ );\r
+\r
+/**\r
+ Enable or disable the receiver\r
+\r
+ This routine calls ::Ax88772UsbCommand to update the\r
+ receiver state. This routine also calls ::Ax88772MacAddressSet\r
+ to establish the MAC address for the network adapter.\r
+\r
+ @param [in] pNicDevice Pointer to the NIC_DEVICE structure\r
+ @param [in] RxFilter Simple network RX filter mask value\r
+\r
+ @retval EFI_SUCCESS The MAC address was set.\r
+ @retval other The MAC address was not set.\r
+\r
+**/\r
+EFI_STATUS\r
+Ax88772RxControl (\r
+ IN NIC_DEVICE * pNicDevice,\r
+ IN UINT32 RxFilter\r
+ );\r
+\r
+/**\r
+ Read an SROM location\r
+\r
+ This routine calls ::Ax88772UsbCommand to read data from the\r
+ SROM.\r
+\r
+ @param [in] pNicDevice Pointer to the NIC_DEVICE structure\r
+ @param [in] Address SROM address\r
+ @param [out] pData Buffer to receive the data\r
+\r
+ @retval EFI_SUCCESS The read was successful\r
+ @retval other The read failed\r
+\r
+**/\r
+EFI_STATUS\r
+Ax88772SromRead (\r
+ IN NIC_DEVICE * pNicDevice,\r
+ IN UINT32 Address,\r
+ OUT UINT16 * pData\r
+ );\r
+\r
+/**\r
+ Send a command to the USB device.\r
+\r
+ @param [in] pNicDevice Pointer to the NIC_DEVICE structure\r
+ @param [in] pRequest Pointer to the request structure\r
+ @param [in, out] pBuffer Data buffer address\r
+\r
+ @retval EFI_SUCCESS The USB transfer was successful\r
+ @retval other The USB transfer failed\r
+\r
+**/\r
+EFI_STATUS\r
+Ax88772UsbCommand (\r
+ IN NIC_DEVICE * pNicDevice,\r
+ IN USB_DEVICE_REQUEST * pRequest,\r
+ IN OUT VOID * pBuffer\r
+ );\r
+\r
+//------------------------------------------------------------------------------\r
+// EFI Component Name Protocol Support\r
+//------------------------------------------------------------------------------\r
+\r
+extern EFI_COMPONENT_NAME_PROTOCOL gComponentName; ///< Component name protocol declaration\r
+extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2; ///< Component name 2 protocol declaration\r
+\r
+/**\r
+ Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+ This function retrieves the user readable name of a driver in the form of a\r
+ Unicode string. If the driver specified by This has a user readable name in\r
+ the language specified by Language, then a pointer to the driver name is\r
+ returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+ by This does not support the language specified by Language,\r
+ then EFI_UNSUPPORTED is returned.\r
+\r
+ @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+ EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ @param [in] pLanguage A pointer to a Null-terminated ASCII string\r
+ array indicating the language. This is the\r
+ language of the driver name that the caller is\r
+ requesting, and it must match one of the\r
+ languages specified in SupportedLanguages. The\r
+ number of languages supported by a driver is up\r
+ to the driver writer. Language is specified\r
+ in RFC 3066 or ISO 639-2 language code format.\r
+ @param [out] ppDriverName A pointer to the Unicode string to return.\r
+ This Unicode string is the name of the\r
+ driver specified by This in the language\r
+ specified by Language.\r
+\r
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
+ This and the language specified by Language was\r
+ returned in DriverName.\r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+ @retval EFI_UNSUPPORTED The driver specified by This does not support\r
+ the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL * pThis,\r
+ IN CHAR8 * pLanguage,\r
+ OUT CHAR16 ** ppDriverName\r
+ );\r
+\r
+\r
+/**\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by a driver.\r
+\r
+ This function retrieves the user readable name of the controller specified by\r
+ ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+ driver specified by This has a user readable name in the language specified by\r
+ Language, then a pointer to the controller name is returned in ControllerName,\r
+ and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
+ managing the controller specified by ControllerHandle and ChildHandle,\r
+ then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
+ support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+ @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+ EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ @param [in] ControllerHandle The handle of a controller that the driver\r
+ specified by This is managing. This handle\r
+ specifies the controller whose name is to be\r
+ returned.\r
+ @param [in] ChildHandle The handle of the child controller to retrieve\r
+ the name of. This is an optional parameter that\r
+ may be NULL. It will be NULL for device\r
+ drivers. It will also be NULL for a bus drivers\r
+ that wish to retrieve the name of the bus\r
+ controller. It will not be NULL for a bus\r
+ driver that wishes to retrieve the name of a\r
+ child controller.\r
+ @param [in] pLanguage A pointer to a Null-terminated ASCII string\r
+ array indicating the language. This is the\r
+ language of the driver name that the caller is\r
+ requesting, and it must match one of the\r
+ languages specified in SupportedLanguages. The\r
+ number of languages supported by a driver is up\r
+ to the driver writer. Language is specified in\r
+ RFC 3066 or ISO 639-2 language code format.\r
+ @param [out] ppControllerName A pointer to the Unicode string to return.\r
+ This Unicode string is the name of the\r
+ controller specified by ControllerHandle and\r
+ ChildHandle in the language specified by\r
+ Language from the point of view of the driver\r
+ specified by This.\r
+\r
+ @retval EFI_SUCCESS The Unicode string for the user readable name in\r
+ the language specified by Language for the\r
+ driver specified by This was returned in\r
+ DriverName.\r
+ @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+ EFI_HANDLE.\r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+ @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
+ managing the controller specified by\r
+ ControllerHandle and ChildHandle.\r
+ @retval EFI_UNSUPPORTED The driver specified by This does not support\r
+ the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL * pThis,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN OPTIONAL EFI_HANDLE ChildHandle,\r
+ IN CHAR8 * pLanguage,\r
+ OUT CHAR16 ** ppControllerName\r
+ );\r
+ \r
+VOID \r
+FillPkt2Queue (\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,\r
+ IN UINTN BufLength);\r
+\r
+//------------------------------------------------------------------------------\r
+\r
+#endif // _AX88772_H_\r