]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772/Ax88772.c
edk2: Remove packages moved to edk2-platforms
[mirror_edk2.git] / OptionRomPkg / Bus / Usb / UsbNetworking / Ax88772 / Ax88772.c
diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772/Ax88772.c b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772/Ax88772.c
deleted file mode 100644 (file)
index c9329f5..0000000
+++ /dev/null
@@ -1,1318 +0,0 @@
-/** @file\r
-  Implement the interface to the AX88772 Ethernet controller.\r
-\r
-  This module implements the interface to the ASIX AX88772\r
-  USB to Ethernet MAC with integrated 10/100 PHY.  Note that this implementation\r
-  only supports the integrated PHY since no other test cases were available.\r
-\r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Ax88772.h"\r
-\r
-\r
-/**\r
-  Compute the CRC\r
-\r
-  @param [in] pMacAddress      Address of a six byte buffer to containing the MAC address.\r
-\r
-  @returns The CRC-32 value associated with this MAC address\r
-\r
-**/\r
-UINT32\r
-Ax88772Crc (\r
-  IN UINT8 * pMacAddress\r
-  )\r
-{\r
-  UINT32 BitNumber;\r
-  INT32 Carry;\r
-  INT32 Crc;\r
-  UINT32 Data;\r
-  UINT8 * pEnd;\r
-\r
-  DBG_ENTER ( );\r
-\r
-  //\r
-  //  Walk the MAC address\r
-  //\r
-  Crc = -1;\r
-  pEnd = &pMacAddress[ PXE_HWADDR_LEN_ETHER ];\r
-  while ( pEnd > pMacAddress ) {\r
-    Data = *pMacAddress++;\r
-    \r
-    \r
-    //\r
-    //  CRC32: x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1\r
-    //\r
-    //          1 0000 0100 1100 0001 0001 1101 1011 0111\r
-    //\r
-    for ( BitNumber = 0; 8 > BitNumber; BitNumber++ ) {\r
-      Carry = (( Crc >> 31 ) & 1 ) ^ ( Data & 1 );\r
-      Crc <<= 1;\r
-      if ( 0 != Carry ) {\r
-        Crc ^= 0x04c11db7;\r
-      }\r
-      Data >>= 1;\r
-    }\r
-  }\r
-\r
-  //\r
-  //  Return the CRC value\r
-  //\r
-  DBG_EXIT_HEX ( Crc );\r
-  return (UINT32) Crc;\r
-}\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
-  USB_DEVICE_REQUEST SetupMsg;\r
-  EFI_STATUS Status;\r
-  \r
-  DBG_ENTER ( );\r
-  \r
-  //\r
-  //  Set the register address.\r
-  //\r
-  SetupMsg.RequestType = USB_ENDPOINT_DIR_IN\r
-                       | USB_REQ_TYPE_VENDOR\r
-                       | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_MAC_ADDRESS_READ;\r
-  SetupMsg.Value = 0;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = PXE_HWADDR_LEN_ETHER;\r
-\r
-  //\r
-  //  Read the PHY register\r
-  //\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                               &SetupMsg,\r
-                               pMacAddress );\r
-\r
-  //\r
-  // Return the operation status\r
-  //\r
-  DBG_EXIT_STATUS ( Status );\r
-  return Status;\r
-}\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
-  USB_DEVICE_REQUEST SetupMsg;\r
-  EFI_STATUS Status;\r
-  \r
-  DBG_ENTER ( );\r
-  \r
-  //\r
-  //  Set the register address.\r
-  //\r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                       | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_MAC_ADDRESS_WRITE;\r
-  SetupMsg.Value = 0;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = PXE_HWADDR_LEN_ETHER;\r
-  \r
-  //\r
-  //  Read the PHY register\r
-  //\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                               &SetupMsg,\r
-                               pMacAddress );\r
-  \r
-  //\r
-  // Return the operation status\r
-  //\r
-  DBG_EXIT_STATUS ( Status );\r
-  return Status;\r
-}\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
-  DBG_ENTER ( );\r
-\r
-  //\r
-  // Clear the multicast hash table\r
-  //\r
-  pNicDevice->MulticastHash[0] = 0;\r
-  pNicDevice->MulticastHash[1] = 0;\r
-\r
-  DBG_EXIT ( );\r
-}\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
-  UINT32 BitNumber;\r
-  UINT32 Crc;\r
-  UINT32 Mask;\r
-\r
-  DBG_ENTER ( );\r
-\r
-  //\r
-  //  Compute the CRC on the destination address\r
-  //\r
-  Crc = Ax88772Crc ( pMacAddress );\r
-\r
-  //\r
-  //  Set the bit corresponding to the destination address\r
-  //\r
-  BitNumber = Crc >> 26;\r
-  if ( 32 > BitNumber ) {\r
-    Mask = 1 << BitNumber;\r
-    pNicDevice->MulticastHash[0] |= Mask;\r
-  }\r
-  else {\r
-    Mask = 1 << ( BitNumber - 32 );\r
-    pNicDevice->MulticastHash[1] |= Mask;\r
-  }\r
-\r
-  //\r
-  //  Display the multicast address\r
-  //\r
-  DEBUG (( DEBUG_RX_MULTICAST | DEBUG_INFO,\r
-            "Enable multicast: 0x%02x-%02x-%02x-%02x-%02x-%02x, CRC: 0x%08x, Bit number: 0x%02x\r\n",\r
-            pMacAddress[0],\r
-            pMacAddress[1],\r
-            pMacAddress[2],\r
-            pMacAddress[3],\r
-            pMacAddress[4],\r
-            pMacAddress[5],\r
-            Crc,\r
-            BitNumber ));\r
-\r
-  DBG_EXIT ( );\r
-}\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
-  UINT16 Control;\r
-  EFI_STATUS Status;\r
-\r
-  DBG_ENTER ( );\r
-\r
-  //\r
-  // Set the supported capabilities.\r
-  //\r
-  Status = Ax88772PhyWrite ( pNicDevice,\r
-                             PHY_ANAR,\r
-                             AN_CSMA_CD\r
-                             | AN_TX_FDX | AN_TX_HDX\r
-                             | AN_10_FDX | AN_10_HDX );\r
-  if ( !EFI_ERROR ( Status )) {\r
-    //\r
-    // Set the link speed and duplex\r
-    //\r
-    Control = BMCR_AUTONEGOTIATION_ENABLE\r
-            | BMCR_RESTART_AUTONEGOTIATION;\r
-    if ( pNicDevice->b100Mbps ) {\r
-      Control |= BMCR_100MBPS;\r
-    }\r
-    if ( pNicDevice->bFullDuplex ) {\r
-      Control |= BMCR_FULL_DUPLEX;\r
-    }\r
-    Status = Ax88772PhyWrite ( pNicDevice, PHY_BMCR, Control );\r
-  }\r
-\r
-  //\r
-  // Return the operation status\r
-  //\r
-  DBG_EXIT_STATUS ( Status );\r
-  return Status;\r
-}\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
-  UINT16 Mask;\r
-  UINT16 PhyData;\r
-  EFI_STATUS  Status;\r
-\r
-  DBG_ENTER ( );\r
-  \r
-  //\r
-  //  Determine if the link is up.\r
-  //\r
-  *pbComplete = FALSE;\r
-\r
-  //\r
-  //  Get the link status\r
-  //\r
-  Status = Ax88772PhyRead ( pNicDevice,\r
-                            PHY_BMSR,\r
-                            &PhyData );\r
-  if ( !EFI_ERROR ( Status )) {\r
-    //\r
-    //  Determine if the autonegotiation is complete.\r
-    //\r
-    *pbLinkUp = (BOOLEAN)( 0 != ( PhyData & BMSR_LINKST ));\r
-    *pbComplete = *pbLinkUp;\r
-    if ( 0 != *pbComplete ) {\r
-      //\r
-      //  Get the partners capabilities.\r
-      //\r
-      Status = Ax88772PhyRead ( pNicDevice,\r
-                                PHY_ANLPAR,\r
-                                &PhyData );\r
-      if ( !EFI_ERROR ( Status )) {\r
-        //\r
-        //  Autonegotiation is complete\r
-        //  Determine the link speed.\r
-        //\r
-        *pbHiSpeed = (BOOLEAN)( 0 != ( PhyData & ( AN_TX_FDX | AN_TX_HDX )));\r
-\r
-        //\r
-        //  Determine the link duplex.\r
-        //\r
-        Mask = ( *pbHiSpeed ) ? AN_TX_FDX : AN_10_FDX;\r
-        *pbFullDuplex = (BOOLEAN)( 0 != ( PhyData & Mask ));\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Return the operation status\r
-  //\r
-  DBG_EXIT_STATUS ( Status );\r
-  return Status;\r
-}\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
-  USB_DEVICE_REQUEST SetupMsg;\r
-  EFI_STATUS Status;\r
-\r
-  DBG_ENTER ( );\r
-\r
-  //\r
-  //  Request access to the PHY\r
-  //\r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                       | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_PHY_ACCESS_SOFTWARE;\r
-  SetupMsg.Value = 0;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = 0;\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                               &SetupMsg,\r
-                               NULL );\r
-  if ( !EFI_ERROR ( Status )) {\r
-    //\r
-    //  Read the PHY register address.\r
-    //\r
-    SetupMsg.RequestType = USB_ENDPOINT_DIR_IN\r
-                         | USB_REQ_TYPE_VENDOR\r
-                         | USB_TARGET_DEVICE;\r
-    SetupMsg.Request = CMD_PHY_REG_READ;\r
-    SetupMsg.Value = pNicDevice->PhyId;\r
-    SetupMsg.Index = RegisterAddress;\r
-    SetupMsg.Length = sizeof ( *pPhyData );\r
-    Status = Ax88772UsbCommand ( pNicDevice,\r
-                                 &SetupMsg,\r
-                                 pPhyData );\r
-    if ( !EFI_ERROR ( Status )) {\r
-      DEBUG (( DEBUG_PHY | DEBUG_INFO,\r
-                "PHY %d: 0x%02x --> 0x%04x\r\n",\r
-                pNicDevice->PhyId,\r
-                RegisterAddress,\r
-                *pPhyData ));\r
-\r
-      //\r
-      //  Release the PHY to the hardware\r
-      //\r
-      SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                           | USB_TARGET_DEVICE;\r
-      SetupMsg.Request = CMD_PHY_ACCESS_HARDWARE;\r
-      SetupMsg.Value = 0;\r
-      SetupMsg.Index = 0;\r
-      SetupMsg.Length = 0;\r
-      Status = Ax88772UsbCommand ( pNicDevice,\r
-                                   &SetupMsg,\r
-                                   NULL );\r
-    }\r
-  }\r
-\r
-  //\r
-  //  Return the operation status.\r
-  //\r
-  DBG_EXIT_STATUS ( Status );\r
-  return Status;\r
-}\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
-  USB_DEVICE_REQUEST SetupMsg;\r
-  EFI_STATUS Status;\r
-  \r
-  DBG_ENTER ( );\r
-  \r
-  //\r
-  //  Request access to the PHY\r
-  //\r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                       | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_PHY_ACCESS_SOFTWARE;\r
-  SetupMsg.Value = 0;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = 0;\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                               &SetupMsg,\r
-                               NULL );\r
-  if ( !EFI_ERROR ( Status )) {\r
-    //\r
-    //  Write the PHY register\r
-    //\r
-    SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                         | USB_TARGET_DEVICE;\r
-    SetupMsg.Request = CMD_PHY_REG_WRITE;\r
-    SetupMsg.Value = pNicDevice->PhyId;\r
-    SetupMsg.Index = RegisterAddress;\r
-    SetupMsg.Length = sizeof ( PhyData );\r
-    Status = Ax88772UsbCommand ( pNicDevice,\r
-                                 &SetupMsg,\r
-                                 &PhyData );\r
-    if ( !EFI_ERROR ( Status )) {\r
-      DEBUG (( DEBUG_PHY | DEBUG_INFO,\r
-                "PHY %d: 0x%02x <-- 0x%04x\r\n",\r
-                pNicDevice->PhyId,\r
-                RegisterAddress,\r
-                PhyData ));\r
-\r
-      //\r
-      //  Release the PHY to the hardware\r
-      //\r
-      SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                           | USB_TARGET_DEVICE;\r
-      SetupMsg.Request = CMD_PHY_ACCESS_HARDWARE;\r
-      SetupMsg.Value = 0;\r
-      SetupMsg.Index = 0;\r
-      SetupMsg.Length = 0;\r
-      Status = Ax88772UsbCommand ( pNicDevice,\r
-                                   &SetupMsg,\r
-                                   NULL );\r
-    }\r
-  }\r
-\r
-  //\r
-  //  Return the operation status.\r
-  //\r
-  DBG_EXIT_STATUS ( Status );\r
-  return Status;\r
-}\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
-  USB_DEVICE_REQUEST SetupMsg;\r
-  EFI_STATUS Status;\r
-  \r
-  DBG_ENTER ( );\r
-\r
-  //\r
-  //  Turn off the MAC\r
-  //\r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                       | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_RX_CONTROL_WRITE;\r
-  SetupMsg.Value = 0;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = 0;\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                               &SetupMsg,\r
-                               NULL );\r
-  if ( !EFI_ERROR ( Status )) {\r
-    DEBUG (( DEBUG_PHY | DEBUG_RX_BROADCAST | DEBUG_RX_MULTICAST\r
-              | DEBUG_RX_UNICAST | DEBUG_TX | DEBUG_INFO,\r
-              "MAC reset\r\n" ));\r
-\r
-    //\r
-    //  The link is now idle\r
-    //\r
-    pNicDevice->bLinkIdle = TRUE;\r
-\r
-    //\r
-    //  Delay for a bit\r
-    //\r
-    gBS->Stall ( RESET_MSEC );\r
-\r
-    //\r
-    //  Select the internal PHY\r
-    //\r
-    SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                         | USB_TARGET_DEVICE;\r
-    SetupMsg.Request = CMD_PHY_SELECT;\r
-    SetupMsg.Value = SPHY_PSEL;\r
-    SetupMsg.Index = 0;\r
-    SetupMsg.Length = 0;\r
-    Status = Ax88772UsbCommand ( pNicDevice,\r
-                                 &SetupMsg,\r
-                                 NULL );\r
-    if ( !EFI_ERROR ( Status )) {\r
-      //\r
-      //  Delay for a bit\r
-      //\r
-      gBS->Stall ( PHY_RESET_MSEC );\r
-\r
-      //\r
-      //  Clear the internal PHY reset\r
-      //\r
-      SetupMsg.Request = CMD_RESET;\r
-      SetupMsg.Value = SRR_IPRL | SRR_PRL;\r
-      Status = Ax88772UsbCommand ( pNicDevice,\r
-                                   &SetupMsg,\r
-                                   NULL );\r
-      if ( !EFI_ERROR ( Status )) {\r
-        //\r
-        //  Reset the PHY\r
-        //\r
-        Status = Ax88772PhyWrite ( pNicDevice,\r
-                                   PHY_BMCR,\r
-                                   BMCR_RESET );\r
-        if ( !EFI_ERROR ( Status )) {\r
-          //\r
-          //  Set the gaps\r
-          //\r
-          SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                               | USB_TARGET_DEVICE;\r
-          SetupMsg.Request = CMD_GAPS_WRITE;\r
-          SetupMsg.Value = 0x0c15;\r
-          SetupMsg.Index = 0x0e;\r
-          SetupMsg.Length = 0;\r
-          Status = Ax88772UsbCommand ( pNicDevice,\r
-                                       &SetupMsg,\r
-                                       NULL );\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  //  Return the operation status.\r
-  //\r
-  DBG_EXIT_STATUS ( Status );\r
-  return Status;\r
-}\r
-\r
-\r
-VOID \r
-FillPkt2Queue (\r
-  IN NIC_DEVICE * pNicDevice,\r
-  IN UINTN BufLength)\r
-{\r
-\r
-  UINT16 * pLength;\r
-  UINT16 * pLengthBar;\r
-  UINT8* pData;\r
-  UINT32 offset;\r
-  RX_TX_PACKET * pRxPacket;\r
-  EFI_STATUS Status;\r
-  \r
-  for ( offset = 0; offset < BufLength; ){\r
-    pLength = (UINT16*) (pNicDevice->pBulkInBuff + offset);\r
-    pLengthBar = (UINT16*) (pNicDevice->pBulkInBuff + offset +2);\r
-    \r
-    *pLength &= 0x7ff;\r
-    *pLengthBar &= 0x7ff;\r
-    *pLengthBar |= 0xf800;\r
-      \r
-    if ((*pLength ^ *pLengthBar ) != 0xFFFF) {\r
-      DEBUG (( EFI_D_ERROR , "Pkt length error. BufLength = %d\n", BufLength));\r
-      return;\r
-    }\r
-      \r
-    pRxPacket = pNicDevice->pRxFree;\r
-    if ( NULL == pRxPacket ) {\r
-      Status = gBS->AllocatePool ( EfiRuntimeServicesData,\r
-                                   sizeof( RX_TX_PACKET ),\r
-                                   (VOID **) &pRxPacket );\r
-      if ( !EFI_ERROR ( Status )) {\r
-        //\r
-        //  Add this packet to the free packet list\r
-        //\r
-        pNicDevice->pRxFree = pRxPacket;\r
-        pRxPacket->pNext = NULL;\r
-      }\r
-      else {\r
-        //\r
-        //  Use the discard packet buffer\r
-        //\r
-        //pRxPacket = &Packet;\r
-      }\r
-    }\r
-      \r
-\r
-    pData = pNicDevice->pBulkInBuff + offset + 4;\r
-    pRxPacket->Length = *pLength;\r
-    pRxPacket->LengthBar = *(UINT16*) (pNicDevice->pBulkInBuff + offset +2);\r
-    CopyMem (&pRxPacket->Data[0], pData, *pLength);\r
-    //DEBUG((DEBUG_INFO, "Packet [%d]\n", *pLength));\r
-    \r
-    pNicDevice->pRxFree = pRxPacket->pNext;\r
-    pRxPacket->pNext = NULL;\r
-    \r
-    if ( NULL == pNicDevice->pRxTail ) {\r
-      pNicDevice->pRxHead = pRxPacket;\r
-    }\r
-    else {\r
-      pNicDevice->pRxTail->pNext = pRxPacket;\r
-    }\r
-    pNicDevice->pRxTail = pRxPacket;\r
-    offset += (*pLength + 4);\r
-              \r
-  }\r
-}\r
-\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
-  BOOLEAN bFullDuplex;\r
-  BOOLEAN bLinkUp;\r
-  BOOLEAN bRxPacket;\r
-  BOOLEAN bSpeed100;\r
-  UINTN LengthInBytes;\r
-  RX_TX_PACKET Packet;\r
-  RX_TX_PACKET * pRxPacket;\r
-  EFI_USB_IO_PROTOCOL *pUsbIo;\r
-  EFI_STATUS Status;\r
-  EFI_TPL TplPrevious;\r
-  UINT32 TransferStatus;\r
-\r
-  //\r
-  //  Synchronize with Ax88772Timer\r
-  //\r
-  VERIFY_TPL ( TPL_AX88772 );\r
-  TplPrevious = gBS->RaiseTPL ( TPL_AX88772 );\r
-  DEBUG (( DEBUG_TPL | DEBUG_INFO,\r
-            "%d: TPL\r\n",\r
-            TPL_AX88772 ));\r
-\r
-  //\r
-  //  Get the link status\r
-  //\r
-  if ( bUpdateLink ) {\r
-    bLinkUp = pNicDevice->bLinkUp;\r
-    bSpeed100 = pNicDevice->b100Mbps;\r
-    bFullDuplex = pNicDevice->bFullDuplex;\r
-    Status = Ax88772NegotiateLinkComplete ( pNicDevice,\r
-                                            &pNicDevice->PollCount,\r
-                                            &pNicDevice->bComplete,\r
-                                            &pNicDevice->bLinkUp,\r
-                                            &pNicDevice->b100Mbps,\r
-                                            &pNicDevice->bFullDuplex );\r
-\r
-    //\r
-    // Determine if the autonegotiation is complete\r
-    //\r
-    if ( pNicDevice->bComplete ) {\r
-      if ( pNicDevice->bLinkUp ) {\r
-        if (( bSpeed100 && ( !pNicDevice->b100Mbps ))\r
-          || (( !bSpeed100 ) && pNicDevice->b100Mbps )\r
-          || ( bFullDuplex && ( !pNicDevice->bFullDuplex ))\r
-          || (( !bFullDuplex ) && pNicDevice->bFullDuplex )) {\r
-          pNicDevice->PollCount = 0;\r
-          DEBUG (( DEBUG_LINK | DEBUG_INFO,\r
-                    "Reset to establish proper link setup: %d Mbps, %s duplex\r\n",\r
-                    pNicDevice->b100Mbps ? 100 : 10,\r
-                    pNicDevice->bFullDuplex ? L"Full" : L"Half" ));\r
-          Status = SN_Reset ( &pNicDevice->SimpleNetwork, FALSE );\r
-        }\r
-        if (( !bLinkUp ) && pNicDevice->bLinkUp ) {\r
-          //\r
-          // Display the autonegotiation status\r
-          //\r
-          DEBUG (( DEBUG_LINK | DEBUG_INFO,\r
-                    "Link: Up, %d Mbps, %s duplex\r\n",\r
-                    pNicDevice->b100Mbps ? 100 : 10,\r
-                    pNicDevice->bFullDuplex ? L"Full" : L"Half" ));\r
-        }\r
-      }\r
-    }\r
-\r
-    //\r
-    //  Update the link status\r
-    //\r
-    if ( bLinkUp && ( !pNicDevice->bLinkUp )) {\r
-      DEBUG (( DEBUG_LINK | DEBUG_INFO, "Link: Down\r\n" ));\r
-    }\r
-  }\r
-\r
-  //\r
-  //  Loop until all the packets are emptied from the receiver\r
-  //\r
-  do {\r
-    bRxPacket = FALSE;\r
-\r
-    //\r
-    //  Locate a packet for use\r
-    //\r
-    pRxPacket = pNicDevice->pRxFree;\r
-    LengthInBytes = MAX_BULKIN_SIZE;\r
-    if ( NULL == pRxPacket ) {\r
-      Status = gBS->AllocatePool ( EfiRuntimeServicesData,\r
-                                   sizeof ( *pRxPacket ),\r
-                                   (VOID **) &pRxPacket );\r
-      if ( !EFI_ERROR ( Status )) {\r
-        //\r
-        //  Add this packet to the free packet list\r
-        //\r
-        pNicDevice->pRxFree = pRxPacket;\r
-        pRxPacket->pNext = NULL;\r
-      }\r
-      else {\r
-        //\r
-        //  Use the discard packet buffer\r
-        //\r
-        pRxPacket = &Packet;\r
-      }\r
-    }\r
-\r
-    //\r
-    //  Attempt to receive a packet\r
-    //\r
-    SetMem (&pNicDevice->pBulkInBuff[0], MAX_BULKIN_SIZE, 0);\r
-    pUsbIo = pNicDevice->pUsbIo;\r
-    Status = pUsbIo->UsbBulkTransfer ( pUsbIo,\r
-                                       USB_ENDPOINT_DIR_IN | BULK_IN_ENDPOINT,\r
-                                       &pNicDevice->pBulkInBuff[0],\r
-                                       &LengthInBytes,\r
-                                       2,\r
-                                       &TransferStatus );\r
-    if ( LengthInBytes > 0 ) {\r
-      FillPkt2Queue(pNicDevice, LengthInBytes);\r
-    }\r
-    pRxPacket = pNicDevice->pRxHead;\r
-    if (( !EFI_ERROR ( Status ))\r
-      && ( 0 < pRxPacket->Length )\r
-      && ( pRxPacket->Length <= sizeof ( pRxPacket->Data ))\r
-      && ( LengthInBytes > 0)) {\r
-\r
-      //\r
-      //  Determine if the packet should be received\r
-      //\r
-      bRxPacket = TRUE;\r
-      LengthInBytes = pRxPacket->Length;\r
-      pNicDevice->bLinkIdle = FALSE;\r
-      if ( pNicDevice->pRxFree == pRxPacket ) {\r
-        //\r
-        //  Display the received packet\r
-        //\r
-        if ( 0 != ( pRxPacket->Data[0] & 1 )) {\r
-          if (( 0xff == pRxPacket->Data[0])\r
-            && ( 0xff == pRxPacket->Data[1])\r
-            && ( 0xff == pRxPacket->Data[2])\r
-            && ( 0xff == pRxPacket->Data[3])\r
-            && ( 0xff == pRxPacket->Data[4])\r
-            && ( 0xff == pRxPacket->Data[5])) {\r
-            DEBUG (( DEBUG_RX_BROADCAST | DEBUG_INFO,\r
-                      "RX: %02x-%02x-%02x-%02x-%02x-%02x  %02x-%02x-%02x-%02x-%02x-%02x  %02x-%02x  %d bytes\r\n",\r
-                      pRxPacket->Data[0],\r
-                      pRxPacket->Data[1],\r
-                      pRxPacket->Data[2],\r
-                      pRxPacket->Data[3],\r
-                      pRxPacket->Data[4],\r
-                      pRxPacket->Data[5],\r
-                      pRxPacket->Data[6],\r
-                      pRxPacket->Data[7],\r
-                      pRxPacket->Data[8],\r
-                      pRxPacket->Data[9],\r
-                      pRxPacket->Data[10],\r
-                      pRxPacket->Data[11],\r
-                      pRxPacket->Data[12],\r
-                      pRxPacket->Data[13],\r
-                      LengthInBytes ));\r
-          }\r
-          else {\r
-            DEBUG (( DEBUG_RX_MULTICAST | DEBUG_INFO,\r
-                      "RX: %02x-%02x-%02x-%02x-%02x-%02x  %02x-%02x-%02x-%02x-%02x-%02x  %02x-%02x  %d bytes\r\n",\r
-                      pRxPacket->Data[0],\r
-                      pRxPacket->Data[1],\r
-                      pRxPacket->Data[2],\r
-                      pRxPacket->Data[3],\r
-                      pRxPacket->Data[4],\r
-                      pRxPacket->Data[5],\r
-                      pRxPacket->Data[6],\r
-                      pRxPacket->Data[7],\r
-                      pRxPacket->Data[8],\r
-                      pRxPacket->Data[9],\r
-                      pRxPacket->Data[10],\r
-                      pRxPacket->Data[11],\r
-                      pRxPacket->Data[12],\r
-                      pRxPacket->Data[13],\r
-                      LengthInBytes ));\r
-          }\r
-        }\r
-        else {\r
-          DEBUG (( DEBUG_RX_UNICAST | DEBUG_INFO,\r
-                    "RX: %02x-%02x-%02x-%02x-%02x-%02x  %02x-%02x-%02x-%02x-%02x-%02x  %02x-%02x  %d bytes\r\n",\r
-                    pRxPacket->Data[0],\r
-                    pRxPacket->Data[1],\r
-                    pRxPacket->Data[2],\r
-                    pRxPacket->Data[3],\r
-                    pRxPacket->Data[4],\r
-                    pRxPacket->Data[5],\r
-                    pRxPacket->Data[6],\r
-                    pRxPacket->Data[7],\r
-                    pRxPacket->Data[8],\r
-                    pRxPacket->Data[9],\r
-                    pRxPacket->Data[10],\r
-                    pRxPacket->Data[11],\r
-                    pRxPacket->Data[12],\r
-                    pRxPacket->Data[13],\r
-                    LengthInBytes ));\r
-        }\r
-        \r
-      }\r
-      else {\r
-        //\r
-        //  Error, not enough buffers for this packet, discard packet\r
-        //\r
-        DEBUG (( DEBUG_WARN | DEBUG_INFO,\r
-                  "WARNING - No buffer, discarding RX packet: %02x-%02x-%02x-%02x-%02x-%02x  %02x-%02x-%02x-%02x-%02x-%02x  %02x-%02x  %d bytes\r\n",\r
-                  pRxPacket->Data[0],\r
-                  pRxPacket->Data[1],\r
-                  pRxPacket->Data[2],\r
-                  pRxPacket->Data[3],\r
-                  pRxPacket->Data[4],\r
-                  pRxPacket->Data[5],\r
-                  pRxPacket->Data[6],\r
-                  pRxPacket->Data[7],\r
-                  pRxPacket->Data[8],\r
-                  pRxPacket->Data[9],\r
-                  pRxPacket->Data[10],\r
-                  pRxPacket->Data[11],\r
-                  pRxPacket->Data[12],\r
-                  pRxPacket->Data[13],\r
-                  LengthInBytes ));\r
-      }\r
-    }\r
-  }while ( bRxPacket );\r
-\r
-  //\r
-  //  Release the synchronization withhe Ax88772Timer\r
-  //\r
-  gBS->RestoreTPL ( TplPrevious );\r
-  DEBUG (( DEBUG_TPL | DEBUG_INFO,\r
-            "%d: TPL\r\n",\r
-            TplPrevious ));\r
-}\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
-  UINT16 MediumStatus;\r
-  INT32 MulticastHash[2];\r
-  UINT16 RxControl;\r
-  USB_DEVICE_REQUEST SetupMsg;\r
-  EFI_STATUS Status;\r
-\r
-  DBG_ENTER ( );\r
-\r
-  //\r
-  //  Disable all multicast\r
-  //\r
-  MulticastHash[0] = 0;\r
-  MulticastHash[1] = 0;\r
-\r
-  //\r
-  // Enable the receiver if something is to be received\r
-  //\r
-  Status = EFI_SUCCESS;\r
-  RxControl = RXC_SO | RXC_MFB_16384;\r
-  if ( 0 != RxFilter ) {\r
-    //\r
-    //  Enable the receiver\r
-    //\r
-    SetupMsg.RequestType = USB_ENDPOINT_DIR_IN\r
-                         | USB_REQ_TYPE_VENDOR\r
-                         | USB_TARGET_DEVICE;\r
-    SetupMsg.Request = CMD_MEDIUM_STATUS_READ;\r
-    SetupMsg.Value = 0;\r
-    SetupMsg.Index = 0;\r
-    SetupMsg.Length = sizeof ( MediumStatus );\r
-    Status = Ax88772UsbCommand ( pNicDevice,\r
-                                 &SetupMsg,\r
-                                 &MediumStatus );\r
-    if ( !EFI_ERROR ( Status )) {\r
-      if ( 0 == ( MediumStatus & MS_RE )) {\r
-        MediumStatus |= MS_RE | MS_ONE;\r
-        if ( pNicDevice->bFullDuplex ) {\r
-          MediumStatus |= MS_TFC | MS_RFC;\r
-        }\r
-        SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                             | USB_TARGET_DEVICE;\r
-        SetupMsg.Request = CMD_MEDIUM_STATUS_WRITE;\r
-        SetupMsg.Value = MediumStatus;\r
-        SetupMsg.Index = 0;\r
-        SetupMsg.Length = 0;\r
-        Status = Ax88772UsbCommand ( pNicDevice,\r
-                                     &SetupMsg,\r
-                                     NULL );\r
-        if ( EFI_ERROR ( Status )) {\r
-          DEBUG (( DEBUG_ERROR | DEBUG_INFO,\r
-                    "ERROR - Failed to enable receiver, Status: %r\r\n",\r
-                    Status ));\r
-        }\r
-      }\r
-    }\r
-    else {\r
-      DEBUG (( DEBUG_ERROR | DEBUG_INFO,\r
-                "ERROR - Failed to read receiver status, Status: %r\r\n",\r
-                Status ));\r
-    }\r
-\r
-    //\r
-    //  Enable multicast if requested\r
-    //\r
-    if ( 0 != ( RxFilter & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST )) {\r
-      RxControl |= RXC_AM;\r
-      MulticastHash[0] = pNicDevice->MulticastHash[0];\r
-      MulticastHash[1] = pNicDevice->MulticastHash[1];\r
-    }\r
-\r
-    //\r
-    //  Enable all multicast if requested\r
-    //\r
-    if ( 0 != ( RxFilter & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST )) {\r
-      RxControl |= RXC_AMALL;\r
-      MulticastHash[0] = -1;\r
-      MulticastHash[1] = -1;\r
-    }\r
-\r
-    //\r
-    //  Enable broadcast if requested\r
-    //\r
-    if ( 0 != ( RxFilter & EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST )) {\r
-      RxControl |= RXC_AB;\r
-    }\r
-\r
-    //\r
-    //  Enable promiscuous mode if requested\r
-    //\r
-    if ( 0 != ( RxFilter & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS )) {\r
-      RxControl |= RXC_PRO;\r
-      MulticastHash[0] = -1;\r
-      MulticastHash[1] = -1;\r
-    }\r
-  }\r
-\r
-  //\r
-  //  Update the MAC address\r
-  //\r
-  if ( !EFI_ERROR ( Status )) {\r
-    Status = Ax88772MacAddressSet ( pNicDevice, &pNicDevice->SimpleNetworkData.CurrentAddress.Addr[0]);\r
-  }\r
-\r
-  //\r
-  //  Update the receiver control\r
-  //\r
-  if ( !EFI_ERROR ( Status )) {\r
-    SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                         | USB_TARGET_DEVICE;\r
-    SetupMsg.Request = CMD_RX_CONTROL_WRITE;\r
-    SetupMsg.Value = RxControl;\r
-    SetupMsg.Index = 0;\r
-    SetupMsg.Length = 0;\r
-    Status = Ax88772UsbCommand ( pNicDevice,\r
-                                 &SetupMsg,\r
-                                 NULL );\r
-    if ( !EFI_ERROR ( Status )) {\r
-      DEBUG (( DEBUG_RX_BROADCAST | DEBUG_RX_MULTICAST | DEBUG_RX_UNICAST | DEBUG_INFO,\r
-                "RxControl: 0x%04x\r\n",\r
-                RxControl ));\r
-\r
-      //\r
-      //  Update the multicast hash table\r
-      //\r
-      SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                           | USB_TARGET_DEVICE;\r
-      SetupMsg.Request = CMD_MULTICAST_HASH_WRITE;\r
-      SetupMsg.Value = 0;\r
-      SetupMsg.Index = 0;\r
-      SetupMsg.Length = sizeof ( pNicDevice ->MulticastHash );\r
-      Status = Ax88772UsbCommand ( pNicDevice,\r
-                                   &SetupMsg,\r
-                                   &pNicDevice->MulticastHash );\r
-      if ( !EFI_ERROR ( Status )) {\r
-        DEBUG (( DEBUG_RX_MULTICAST | DEBUG_INFO,\r
-                  "Multicast Hash: 0x%02x %02x %02x %02x %02x %02x %02x %02x\r\n",\r
-                  (UINT8) MulticastHash[0],\r
-                  (UINT8)( MulticastHash[0] >> 8 ),\r
-                  (UINT8)( MulticastHash[0] >> 16 ),\r
-                  (UINT8)( MulticastHash[0] >> 24 ),\r
-                  (UINT8) MulticastHash[1],\r
-                  (UINT8)( MulticastHash[1] >> 8 ),\r
-                  (UINT8)( MulticastHash[1] >> 16 ),\r
-                  (UINT8)( MulticastHash[1] >> 24 )));\r
-      }\r
-      else {\r
-        DEBUG (( DEBUG_ERROR | DEBUG_INFO,\r
-                  "ERROR - Failed to update multicast hash table, Status: %r\r\n",\r
-                  Status ));\r
-      }\r
-    }\r
-    else {\r
-      DEBUG (( DEBUG_ERROR | DEBUG_INFO,\r
-                "ERROR - Failed to set receiver control, Status: %r\r\n",\r
-                Status ));\r
-    }\r
-  }\r
-\r
-  //\r
-  // Return the operation status\r
-  //\r
-  DBG_EXIT_STATUS ( Status );\r
-  return Status;\r
-}\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
-  USB_DEVICE_REQUEST SetupMsg;\r
-  EFI_STATUS Status;\r
-\r
-  DBG_ENTER ( );\r
-\r
-  //\r
-  //  Read a value from the SROM\r
-  //\r
-  SetupMsg.RequestType = USB_ENDPOINT_DIR_IN\r
-                       | USB_REQ_TYPE_VENDOR\r
-                       | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_SROM_READ;\r
-  SetupMsg.Value = (UINT16) Address;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = sizeof ( *pData );\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                               &SetupMsg,\r
-                               pData );\r
-\r
-  //\r
-  // Return the operation status\r
-  //\r
-  DBG_EXIT_STATUS ( Status );\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  This routine is called at a regular interval to poll for\r
-  receive packets.\r
-\r
-  This routine polls the link state and gets any receive packets\r
-  by calling ::Ax88772Rx.\r
-\r
-  @param [in] Event            Timer event\r
-  @param [in] pNicDevice       Pointer to the NIC_DEVICE structure\r
-\r
-**/\r
-VOID\r
-Ax88772Timer (\r
-  IN EFI_EVENT Event,\r
-  IN NIC_DEVICE * pNicDevice\r
-  )\r
-{\r
-  //\r
-  //  Use explicit DEBUG messages since the output frequency is too\r
-  //  high for DEBUG_INFO to keep up and have spare cycles for the\r
-  //  shell\r
-  //\r
-  DEBUG (( DEBUG_TIMER, "Entering Ax88772Timer\r\n" ));\r
-\r
-  //\r
-  //  Poll the link state and get any receive packets\r
-  //\r
-  Ax88772Rx ( pNicDevice, FALSE );\r
-\r
-  DEBUG (( DEBUG_TIMER, "Exiting Ax88772Timer\r\n" ));\r
-}\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
-  UINT32 CmdStatus;\r
-  EFI_USB_DATA_DIRECTION Direction;\r
-  EFI_USB_IO_PROTOCOL * pUsbIo;\r
-  EFI_STATUS Status;\r
-\r
-  DBG_ENTER ( );\r
-\r
-  //\r
-  // Determine the transfer direction\r
-  //\r
-  Direction = EfiUsbNoData;\r
-  if ( 0 != pRequest->Length ) {\r
-    Direction = ( 0 != ( pRequest->RequestType & USB_ENDPOINT_DIR_IN ))\r
-              ? EfiUsbDataIn : EfiUsbDataOut;\r
-  }\r
-\r
-  //\r
-  // Issue the command\r
-  //\r
-  pUsbIo = pNicDevice->pUsbIo;\r
-  Status = pUsbIo->UsbControlTransfer ( pUsbIo,\r
-                                        pRequest,\r
-                                        Direction,\r
-                                        USB_BUS_TIMEOUT,\r
-                                        pBuffer,\r
-                                        pRequest->Length,\r
-                                        &CmdStatus );\r
-\r
-  //\r
-  // Determine the operation status\r
-  //\r
-  if ( !EFI_ERROR ( Status )) {\r
-    Status = CmdStatus;\r
-  }\r
-  else {\r
-    //\r
-    // Display any errors\r
-    //\r
-    DEBUG (( DEBUG_INFO,\r
-              "Ax88772UsbCommand - Status: %r\n",\r
-              Status ));\r
-\r
-    //\r
-    // Only use status values associated with the Simple Network protocol\r
-    //\r
-    if ( EFI_TIMEOUT == Status ) {\r
-      Status = EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Return the operation status\r
-  //\r
-  DBG_EXIT_STATUS ( Status );\r
-  return Status;\r
-}\r