Ax88772.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. /** @file
  2. Definitions for ASIX AX88772 Ethernet adapter.
  3. Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _AX88772_H_
  7. #define _AX88772_H_
  8. #include <Uefi.h>
  9. #include <Guid/EventGroup.h>
  10. #include <IndustryStandard/Pci.h>
  11. #include <Library/BaseMemoryLib.h>
  12. #include <Library/DebugLib.h>
  13. #include <Library/DevicePathLib.h>
  14. #include <Library/UefiBootServicesTableLib.h>
  15. #include <Library/UefiDriverEntryPoint.h>
  16. #include <Library/UefiLib.h>
  17. #include <Library/UefiRuntimeLib.h>
  18. #include <Protocol/DevicePath.h>
  19. #include <Protocol/LoadedImage.h>
  20. #include <Protocol/NetworkInterfaceIdentifier.h>
  21. #include <Protocol/SimpleNetwork.h>
  22. #include <Protocol/UsbIo.h>
  23. //------------------------------------------------------------------------------
  24. // Macros
  25. //------------------------------------------------------------------------------
  26. //
  27. //Too many output debug info hangs system in Debug tip
  28. //
  29. //#if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */
  30. //#define DBG_ENTER() DEBUG (( DEBUG_INFO, "Entering " __FUNCTION__ "\n" )) ///< Display routine entry
  31. //#define DBG_EXIT() DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ "\n" )) ///< Display routine exit
  32. //#define DBG_EXIT_DEC(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %d\n", Status )) ///< Display routine exit with decimal value
  33. //#define DBG_EXIT_HEX(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: 0x%08x\n", Status )) ///< Display routine exit with hex value
  34. //#define DBG_EXIT_STATUS(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %r\n", Status )) ///< Display routine exit with status value
  35. //#define DBG_EXIT_TF(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", returning %s\n", (FALSE == Status) ? L"FALSE" : L"TRUE" )) ///< Display routine with TRUE/FALSE value
  36. //#else // _MSC_VER
  37. #define DBG_ENTER() ///< Display routine entry
  38. #define DBG_EXIT() ///< Display routine exit
  39. #define DBG_EXIT_DEC(Status) ///< Display routine exit with decimal value
  40. #define DBG_EXIT_HEX(Status) ///< Display routine exit with hex value
  41. #define DBG_EXIT_STATUS(Status) ///< Display routine exit with status value
  42. #define DBG_EXIT_TF(Status) ///< Display routine with TRUE/FALSE value
  43. //#endif // _MSC_VER
  44. #define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) != 0) ///< Return TRUE/FALSE for IN direction
  45. #define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == 0) ///< Return TRUE/FALSE for OUT direction
  46. #define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_BULK) ///< Return TRUE/FALSE for BULK type
  47. #define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) ///< Return TRUE/FALSE for INTERRUPT type
  48. //------------------------------------------------------------------------------
  49. // Constants
  50. //------------------------------------------------------------------------------
  51. #define DEBUG_RX_BROADCAST 0x40000000 ///< Display RX broadcast messages
  52. #define DEBUG_RX_MULTICAST 0x20000000 ///< Display RX multicast messages
  53. #define DEBUG_RX_UNICAST 0x10000000 ///< Display RX unicast messages
  54. #define DEBUG_MAC_ADDRESS 0x08000000 ///< Display the MAC address
  55. #define DEBUG_LINK 0x04000000 ///< Display the link status
  56. #define DEBUG_TX 0x02000000 ///< Display the TX messages
  57. #define DEBUG_PHY 0x01000000 ///< Display the PHY register values
  58. #define DEBUG_SROM 0x00800000 ///< Display the SROM contents
  59. #define DEBUG_TIMER 0x00400000 ///< Display the timer routine entry/exit
  60. #define DEBUG_TPL 0x00200000 ///< Display the timer routine entry/exit
  61. #define AX88772_MAX_PKT_SIZE ( 2048 - 4 ) ///< Maximum packet size
  62. #define ETHERNET_HEADER_SIZE sizeof ( ETHERNET_HEADER ) ///< Size in bytes of the Ethernet header
  63. #define MIN_ETHERNET_PKT_SIZE 60 ///< Minimum packet size including Ethernet header
  64. #define MAX_ETHERNET_PKT_SIZE 1500 ///< Ethernet spec 3.1.1: Minimum packet size
  65. #define MAX_BULKIN_SIZE 2048 ///< Maximum size of one UsbBulk
  66. #define USB_NETWORK_CLASS 0x09 ///< USB Network class code
  67. #define USB_BUS_TIMEOUT 1000 ///< USB timeout in milliseconds
  68. #define TIMER_MSEC 20 ///< Polling interval for the NIC
  69. #define TPL_AX88772 TPL_CALLBACK ///< TPL for routine synchronization
  70. /**
  71. Verify new TPL value
  72. This macro which is enabled when debug is enabled verifies that
  73. the new TPL value is >= the current TPL value.
  74. **/
  75. #ifdef VERIFY_TPL
  76. #undef VERIFY_TPL
  77. #endif // VERIFY_TPL
  78. #if !defined(MDEPKG_NDEBUG)
  79. #define VERIFY_TPL(tpl) \
  80. { \
  81. EFI_TPL PreviousTpl; \
  82. \
  83. PreviousTpl = gBS->RaiseTPL ( TPL_HIGH_LEVEL ); \
  84. gBS->RestoreTPL ( PreviousTpl ); \
  85. if ( PreviousTpl > tpl ) { \
  86. DEBUG (( DEBUG_ERROR, "Current TPL: %d, New TPL: %d\r\n", PreviousTpl, tpl )); \
  87. ASSERT ( PreviousTpl <= tpl ); \
  88. } \
  89. }
  90. #else // MDEPKG_NDEBUG
  91. #define VERIFY_TPL(tpl)
  92. #endif // MDEPKG_NDEBUG
  93. //------------------------------------------------------------------------------
  94. // Hardware Definition
  95. //------------------------------------------------------------------------------
  96. #define DEV_SIGNATURE SIGNATURE_32 ('A','X','8','8') ///< Signature of data structures in memory
  97. #define VENDOR_ID 0x0b95 ///< Vendor ID for Asix
  98. #define PRODUCT_ID 0x7720 ///< Product ID for the AX88772 USB 10/100 Ethernet controller
  99. #define RESET_MSEC 1000 ///< Reset duration
  100. #define PHY_RESET_MSEC 500 ///< PHY reset duration
  101. //
  102. // RX Control register
  103. //
  104. #define RXC_PRO 0x0001 ///< Receive all packets
  105. #define RXC_AMALL 0x0002 ///< Receive all multicast packets
  106. #define RXC_SEP 0x0004 ///< Save error packets
  107. #define RXC_AB 0x0008 ///< Receive broadcast packets
  108. #define RXC_AM 0x0010 ///< Use multicast destination address hash table
  109. #define RXC_AP 0x0020 ///< Accept physical address from Multicast Filter
  110. #define RXC_SO 0x0080 ///< Start operation
  111. #define RXC_MFB 0x0300 ///< Maximum frame burst
  112. #define RXC_MFB_2048 0 ///< Maximum frame size: 2048 bytes
  113. #define RXC_MFB_4096 0x0100 ///< Maximum frame size: 4096 bytes
  114. #define RXC_MFB_8192 0x0200 ///< Maximum frame size: 8192 bytes
  115. #define RXC_MFB_16384 0x0300 ///< Maximum frame size: 16384 bytes
  116. //
  117. // Medium Status register
  118. //
  119. #define MS_FD 0x0002 ///< Full duplex
  120. #define MS_ONE 0x0004 ///< Must be one
  121. #define MS_RFC 0x0010 ///< RX flow control enable
  122. #define MS_TFC 0x0020 ///< TX flow control enable
  123. #define MS_PF 0x0080 ///< Pause frame enable
  124. #define MS_RE 0x0100 ///< Receive enable
  125. #define MS_PS 0x0200 ///< Port speed 1=100, 0=10 Mbps
  126. #define MS_SBP 0x0800 ///< Stop back pressure
  127. #define MS_SM 0x1000 ///< Super MAC support
  128. //
  129. // Software PHY Select register
  130. //
  131. #define SPHY_PSEL 0x01 ///< Select internal PHY
  132. #define SPHY_ASEL 0x02 ///< 1=Auto select, 0=Manual select
  133. //
  134. // Software Reset register
  135. //
  136. #define SRR_RR 0x01 ///< Clear receive frame length error
  137. #define SRR_RT 0x02 ///< Clear transmit frame length error
  138. #define SRR_PRTE 0x04 ///< External PHY reset pin tri-state enable
  139. #define SRR_PRL 0x08 ///< External PHY reset pin level
  140. #define SRR_BZ 0x10 ///< Force Bulk to return zero length packet
  141. #define SRR_IPRL 0x20 ///< Internal PHY reset control
  142. #define SRR_IPPD 0x40 ///< Internal PHY power down
  143. //
  144. // PHY ID values
  145. //
  146. #define PHY_ID_INTERNAL 0x0010 ///< Internal PHY
  147. //
  148. // USB Commands
  149. //
  150. #define CMD_PHY_ACCESS_SOFTWARE 0x06 ///< Software in control of PHY
  151. #define CMD_PHY_REG_READ 0x07 ///< Read PHY register, Value: PHY, Index: Register, Data: Register value
  152. #define CMD_PHY_REG_WRITE 0x08 ///< Write PHY register, Value: PHY, Index: Register, Data: New 16-bit value
  153. #define CMD_PHY_ACCESS_HARDWARE 0x0a ///< Hardware in control of PHY
  154. #define CMD_SROM_READ 0x0b ///< Read SROM register: Value: Address, Data: Value
  155. #define CMD_RX_CONTROL_WRITE 0x10 ///< Set the RX control register, Value: New value
  156. #define CMD_GAPS_WRITE 0x12 ///< Write the gaps register, Value: New value
  157. #define CMD_MAC_ADDRESS_READ 0x13 ///< Read the MAC address, Data: 6 byte MAC address
  158. #define CMD_MAC_ADDRESS_WRITE 0x14 ///< Set the MAC address, Data: New 6 byte MAC address
  159. #define CMD_MULTICAST_HASH_WRITE 0x16 ///< Write the multicast hash table, Data: New 8 byte value
  160. #define CMD_MEDIUM_STATUS_READ 0x1a ///< Read medium status register, Data: Register value
  161. #define CMD_MEDIUM_STATUS_WRITE 0x1b ///< Write medium status register, Value: New value
  162. #define CMD_RESET 0x20 ///< Reset register, Value: New value
  163. #define CMD_PHY_SELECT 0x22 ///< PHY select register, Value: New value
  164. //------------------------------
  165. // USB Endpoints
  166. //------------------------------
  167. #define CONTROL_ENDPOINT 0 ///< Control endpoint
  168. #define INTERRUPT_ENDPOINT 1 ///< Interrupt endpoint
  169. #define BULK_IN_ENDPOINT 2 ///< Receive endpoint
  170. #define BULK_OUT_ENDPOINT 3 ///< Transmit endpoint
  171. //------------------------------
  172. // PHY Registers
  173. //------------------------------
  174. #define PHY_BMCR 0 ///< Control register
  175. #define PHY_BMSR 1 ///< Status register
  176. #define PHY_ANAR 4 ///< Autonegotiation advertisement register
  177. #define PHY_ANLPAR 5 ///< Autonegotiation link parter ability register
  178. #define PHY_ANER 6 ///< Autonegotiation expansion register
  179. // BMCR - Register 0
  180. #define BMCR_RESET 0x8000 ///< 1 = Reset the PHY, bit clears after reset
  181. #define BMCR_LOOPBACK 0x4000 ///< 1 = Loopback enabled
  182. #define BMCR_100MBPS 0x2000 ///< 100 Mbits/Sec
  183. #define BMCR_10MBPS 0 ///< 10 Mbits/Sec
  184. #define BMCR_AUTONEGOTIATION_ENABLE 0x1000 ///< 1 = Enable autonegotiation
  185. #define BMCR_POWER_DOWN 0x0800 ///< 1 = Power down
  186. #define BMCR_ISOLATE 0x0400 ///< 0 = Isolate PHY
  187. #define BMCR_RESTART_AUTONEGOTIATION 0x0200 ///< 1 = Restart autonegotiation
  188. #define BMCR_FULL_DUPLEX 0x0100 ///< Full duplex operation
  189. #define BMCR_HALF_DUPLEX 0 ///< Half duplex operation
  190. #define BMCR_COLLISION_TEST 0x0080 ///< 1 = Collision test enabled
  191. // BSMR - Register 1
  192. #define BMSR_100BASET4 0x8000 ///< 1 = 100BASE-T4 mode
  193. #define BMSR_100BASETX_FDX 0x4000 ///< 1 = 100BASE-TX full duplex
  194. #define BMSR_100BASETX_HDX 0x2000 ///< 1 = 100BASE-TX half duplex
  195. #define BMSR_10BASET_FDX 0x1000 ///< 1 = 10BASE-T full duplex
  196. #define BMSR_10BASET_HDX 0x0800 ///< 1 = 10BASE-T half duplex
  197. #define BMSR_MF 0x0040 ///< 1 = PHY accepts frames with preamble suppressed
  198. #define BMSR_AUTONEG_CMPLT 0x0020 ///< 1 = Autonegotiation complete
  199. #define BMSR_RF 0x0010 ///< 1 = Remote fault
  200. #define BMSR_AUTONEG 0x0008 ///< 1 = Able to perform autonegotiation
  201. #define BMSR_LINKST 0x0004 ///< 1 = Link up
  202. #define BMSR_JABBER_DETECT 0x0002 ///< 1 = jabber condition detected
  203. #define BMSR_EXTENDED_CAPABILITY 0x0001 ///< 1 = Extended register capable
  204. // ANAR and ANLPAR Registers 4, 5
  205. #define AN_NP 0x8000 ///< 1 = Next page available
  206. #define AN_ACK 0x4000 ///< 1 = Link partner acknowledged
  207. #define AN_RF 0x2000 ///< 1 = Remote fault indicated by link partner
  208. #define AN_FCS 0x0400 ///< 1 = Flow control ability
  209. #define AN_T4 0x0200 ///< 1 = 100BASE-T4 support
  210. #define AN_TX_FDX 0x0100 ///< 1 = 100BASE-TX Full duplex
  211. #define AN_TX_HDX 0x0080 ///< 1 = 100BASE-TX support
  212. #define AN_10_FDX 0x0040 ///< 1 = 10BASE-T Full duplex
  213. #define AN_10_HDX 0x0020 ///< 1 = 10BASE-T support
  214. #define AN_CSMA_CD 0x0001 ///< 1 = IEEE 802.3 CSMA/CD support
  215. //------------------------------------------------------------------------------
  216. // Data Types
  217. //------------------------------------------------------------------------------
  218. /**
  219. Ethernet header layout
  220. IEEE 802.3-2002 Part 3 specification, section 3.1.1.
  221. **/
  222. #pragma pack(1)
  223. typedef struct {
  224. UINT8 dest_addr[PXE_HWADDR_LEN_ETHER]; ///< Destination LAN address
  225. UINT8 src_addr[PXE_HWADDR_LEN_ETHER]; ///< Source LAN address
  226. UINT16 type; ///< Protocol or length
  227. } ETHERNET_HEADER;
  228. #pragma pack()
  229. /**
  230. Receive and Transmit packet structure
  231. **/
  232. #pragma pack(1)
  233. typedef struct _RX_TX_PACKET {
  234. struct _RX_TX_PACKET * pNext; ///< Next receive packet
  235. UINT16 Length; ///< Packet length
  236. UINT16 LengthBar; ///< Complement of the length
  237. UINT8 Data[ AX88772_MAX_PKT_SIZE ]; ///< Received packet data
  238. } RX_TX_PACKET;
  239. #pragma pack()
  240. /**
  241. AX88772 control structure
  242. The driver uses this structure to manage the Asix AX88772 10/100
  243. Ethernet controller.
  244. **/
  245. typedef struct {
  246. UINTN Signature; ///< Structure identification
  247. //
  248. // USB data
  249. //
  250. EFI_HANDLE Controller; ///< Controller handle
  251. EFI_USB_IO_PROTOCOL * pUsbIo; ///< USB driver interface
  252. //
  253. // Simple network protocol data
  254. //
  255. EFI_SIMPLE_NETWORK_PROTOCOL SimpleNetwork; ///< Driver's network stack interface
  256. EFI_SIMPLE_NETWORK_MODE SimpleNetworkData; ///< Data for simple network
  257. //
  258. // Ethernet controller data
  259. //
  260. BOOLEAN bInitialized; ///< Controller initialized
  261. VOID * pTxBuffer; ///< Last transmit buffer
  262. UINT16 PhyId; ///< PHY ID
  263. //
  264. // Link state
  265. //
  266. BOOLEAN b100Mbps; ///< Current link speed, FALSE = 10 Mbps
  267. BOOLEAN bComplete; ///< Current state of auto-negotiation
  268. BOOLEAN bFullDuplex; ///< Current duplex
  269. BOOLEAN bLinkUp; ///< Current link state
  270. BOOLEAN bLinkIdle; ///< TRUE = No received traffic
  271. EFI_EVENT Timer; ///< Timer to monitor link state and receive packets
  272. UINTN PollCount; ///< Number of times the autonegotiation status was polled
  273. //
  274. // Receive buffer list
  275. //
  276. RX_TX_PACKET * pRxHead; ///< Head of receive packet list
  277. RX_TX_PACKET * pRxTail; ///< Tail of receive packet list
  278. RX_TX_PACKET * pRxFree; ///< Free packet list
  279. INT32 MulticastHash[2]; ///< Hash table for multicast destination addresses
  280. UINT8 * pBulkInBuff; ///< Buffer for Usb Bulk
  281. } NIC_DEVICE;
  282. #define DEV_FROM_SIMPLE_NETWORK(a) CR (a, NIC_DEVICE, SimpleNetwork, DEV_SIGNATURE) ///< Locate NIC_DEVICE from Simple Network Protocol
  283. //------------------------------------------------------------------------------
  284. // Simple Network Protocol
  285. //------------------------------------------------------------------------------
  286. /**
  287. Reset the network adapter.
  288. Resets a network adapter and reinitializes it with the parameters that
  289. were provided in the previous call to Initialize (). The transmit and
  290. receive queues are cleared. Receive filters, the station address, the
  291. statistics, and the multicast-IP-to-HW MAC addresses are not reset by
  292. this call.
  293. This routine calls ::Ax88772Reset to perform the adapter specific
  294. reset operation. This routine also starts the link negotiation
  295. by calling ::Ax88772NegotiateLinkStart.
  296. @param [in] pSimpleNetwork Protocol instance pointer
  297. @param [in] bExtendedVerification Indicates that the driver may perform a more
  298. exhaustive verification operation of the device
  299. during reset.
  300. @retval EFI_SUCCESS This operation was successful.
  301. @retval EFI_NOT_STARTED The network interface was not started.
  302. @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
  303. EFI_SIMPLE_NETWORK_PROTOCOL structure.
  304. @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
  305. @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
  306. **/
  307. EFI_STATUS
  308. EFIAPI
  309. SN_Reset (
  310. IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
  311. IN BOOLEAN bExtendedVerification
  312. );
  313. /**
  314. Initialize the simple network protocol.
  315. This routine calls ::Ax88772MacAddressGet to obtain the
  316. MAC address.
  317. @param [in] pNicDevice NIC_DEVICE_INSTANCE pointer
  318. @retval EFI_SUCCESS Setup was successful
  319. **/
  320. EFI_STATUS
  321. SN_Setup (
  322. IN NIC_DEVICE * pNicDevice
  323. );
  324. /**
  325. This routine starts the network interface.
  326. @param [in] pSimpleNetwork Protocol instance pointer
  327. @retval EFI_SUCCESS This operation was successful.
  328. @retval EFI_ALREADY_STARTED The network interface was already started.
  329. @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
  330. EFI_SIMPLE_NETWORK_PROTOCOL structure.
  331. @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
  332. @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
  333. **/
  334. EFI_STATUS
  335. EFIAPI
  336. SN_Start (
  337. IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork
  338. );
  339. /**
  340. Set the MAC address.
  341. This function modifies or resets the current station address of a
  342. network interface. If Reset is TRUE, then the current station address
  343. is set ot the network interface's permanent address. If Reset if FALSE
  344. then the current station address is changed to the address specified by
  345. pNew.
  346. This routine calls ::Ax88772MacAddressSet to update the MAC address
  347. in the network adapter.
  348. @param [in] pSimpleNetwork Protocol instance pointer
  349. @param [in] bReset Flag used to reset the station address to the
  350. network interface's permanent address.
  351. @param [in] pNew New station address to be used for the network
  352. interface.
  353. @retval EFI_SUCCESS This operation was successful.
  354. @retval EFI_NOT_STARTED The network interface was not started.
  355. @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
  356. EFI_SIMPLE_NETWORK_PROTOCOL structure.
  357. @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
  358. @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
  359. **/
  360. EFI_STATUS
  361. EFIAPI
  362. SN_StationAddress (
  363. IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
  364. IN BOOLEAN bReset,
  365. IN EFI_MAC_ADDRESS * pNew
  366. );
  367. /**
  368. This function resets or collects the statistics on a network interface.
  369. If the size of the statistics table specified by StatisticsSize is not
  370. big enough for all of the statistics that are collected by the network
  371. interface, then a partial buffer of statistics is returned in
  372. StatisticsTable.
  373. @param [in] pSimpleNetwork Protocol instance pointer
  374. @param [in] bReset Set to TRUE to reset the statistics for the network interface.
  375. @param [in, out] pStatisticsSize On input the size, in bytes, of StatisticsTable. On output
  376. the size, in bytes, of the resulting table of statistics.
  377. @param [out] pStatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
  378. conains the statistics.
  379. @retval EFI_SUCCESS This operation was successful.
  380. @retval EFI_NOT_STARTED The network interface was not started.
  381. @retval EFI_BUFFER_TOO_SMALL The pStatisticsTable is NULL or the buffer is too small.
  382. @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
  383. EFI_SIMPLE_NETWORK_PROTOCOL structure.
  384. @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
  385. @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
  386. **/
  387. EFI_STATUS
  388. EFIAPI
  389. SN_Statistics (
  390. IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
  391. IN BOOLEAN bReset,
  392. IN OUT UINTN * pStatisticsSize,
  393. OUT EFI_NETWORK_STATISTICS * pStatisticsTable
  394. );
  395. /**
  396. This function stops a network interface. This call is only valid
  397. if the network interface is in the started state.
  398. @param [in] pSimpleNetwork Protocol instance pointer
  399. @retval EFI_SUCCESS This operation was successful.
  400. @retval EFI_NOT_STARTED The network interface was not started.
  401. @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
  402. EFI_SIMPLE_NETWORK_PROTOCOL structure.
  403. @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
  404. @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
  405. **/
  406. EFI_STATUS
  407. EFIAPI
  408. SN_Stop (
  409. IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork
  410. );
  411. /**
  412. This function releases the memory buffers assigned in the Initialize() call.
  413. Pending transmits and receives are lost, and interrupts are cleared and disabled.
  414. After this call, only Initialize() and Stop() calls may be used.
  415. @param [in] pSimpleNetwork Protocol instance pointer
  416. @retval EFI_SUCCESS This operation was successful.
  417. @retval EFI_NOT_STARTED The network interface was not started.
  418. @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
  419. EFI_SIMPLE_NETWORK_PROTOCOL structure.
  420. @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
  421. @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
  422. **/
  423. EFI_STATUS
  424. EFIAPI
  425. SN_Shutdown (
  426. IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork
  427. );
  428. /**
  429. Send a packet over the network.
  430. This function places the packet specified by Header and Buffer on
  431. the transmit queue. This function performs a non-blocking transmit
  432. operation. When the transmit is complete, the buffer is returned
  433. via the GetStatus() call.
  434. This routine calls ::Ax88772Rx to empty the network adapter of
  435. receive packets. The routine then passes the transmit packet
  436. to the network adapter.
  437. @param [in] pSimpleNetwork Protocol instance pointer
  438. @param [in] HeaderSize The size, in bytes, of the media header to be filled in by
  439. the Transmit() function. If HeaderSize is non-zero, then
  440. it must be equal to SimpleNetwork->Mode->MediaHeaderSize
  441. and DestAddr and Protocol parameters must not be NULL.
  442. @param [in] BufferSize The size, in bytes, of the entire packet (media header and
  443. data) to be transmitted through the network interface.
  444. @param [in] pBuffer A pointer to the packet (media header followed by data) to
  445. to be transmitted. This parameter can not be NULL. If
  446. HeaderSize is zero, then the media header is Buffer must
  447. already be filled in by the caller. If HeaderSize is nonzero,
  448. then the media header will be filled in by the Transmit()
  449. function.
  450. @param [in] pSrcAddr The source HW MAC address. If HeaderSize is zero, then
  451. this parameter is ignored. If HeaderSize is nonzero and
  452. SrcAddr is NULL, then SimpleNetwork->Mode->CurrentAddress
  453. is used for the source HW MAC address.
  454. @param [in] pDestAddr The destination HW MAC address. If HeaderSize is zero, then
  455. this parameter is ignored.
  456. @param [in] pProtocol The type of header to build. If HeaderSize is zero, then
  457. this parameter is ignored.
  458. @retval EFI_SUCCESS This operation was successful.
  459. @retval EFI_NOT_STARTED The network interface was not started.
  460. @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.
  461. @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
  462. @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
  463. EFI_SIMPLE_NETWORK_PROTOCOL structure.
  464. @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
  465. **/
  466. EFI_STATUS
  467. EFIAPI
  468. SN_Transmit (
  469. IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
  470. IN UINTN HeaderSize,
  471. IN UINTN BufferSize,
  472. IN VOID * pBuffer,
  473. IN EFI_MAC_ADDRESS * pSrcAddr,
  474. IN EFI_MAC_ADDRESS * pDestAddr,
  475. IN UINT16 * pProtocol
  476. );
  477. //------------------------------------------------------------------------------
  478. // Support Routines
  479. //------------------------------------------------------------------------------
  480. /**
  481. Get the MAC address
  482. This routine calls ::Ax88772UsbCommand to request the MAC
  483. address from the network adapter.
  484. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  485. @param [out] pMacAddress Address of a six byte buffer to receive the MAC address.
  486. @retval EFI_SUCCESS The MAC address is available.
  487. @retval other The MAC address is not valid.
  488. **/
  489. EFI_STATUS
  490. Ax88772MacAddressGet (
  491. IN NIC_DEVICE * pNicDevice,
  492. OUT UINT8 * pMacAddress
  493. );
  494. /**
  495. Set the MAC address
  496. This routine calls ::Ax88772UsbCommand to set the MAC address
  497. in the network adapter.
  498. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  499. @param [in] pMacAddress Address of a six byte buffer to containing the new MAC address.
  500. @retval EFI_SUCCESS The MAC address was set.
  501. @retval other The MAC address was not set.
  502. **/
  503. EFI_STATUS
  504. Ax88772MacAddressSet (
  505. IN NIC_DEVICE * pNicDevice,
  506. IN UINT8 * pMacAddress
  507. );
  508. /**
  509. Clear the multicast hash table
  510. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  511. **/
  512. VOID
  513. Ax88772MulticastClear (
  514. IN NIC_DEVICE * pNicDevice
  515. );
  516. /**
  517. Enable a multicast address in the multicast hash table
  518. This routine calls ::Ax88772Crc to compute the hash bit for
  519. this MAC address.
  520. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  521. @param [in] pMacAddress Address of a six byte buffer to containing the MAC address.
  522. **/
  523. VOID
  524. Ax88772MulticastSet (
  525. IN NIC_DEVICE * pNicDevice,
  526. IN UINT8 * pMacAddress
  527. );
  528. /**
  529. Start the link negotiation
  530. This routine calls ::Ax88772PhyWrite to start the PHY's link
  531. negotiation.
  532. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  533. @retval EFI_SUCCESS The link negotiation was started.
  534. @retval other Failed to start the link negotiation.
  535. **/
  536. EFI_STATUS
  537. Ax88772NegotiateLinkStart (
  538. IN NIC_DEVICE * pNicDevice
  539. );
  540. /**
  541. Complete the negotiation of the PHY link
  542. This routine calls ::Ax88772PhyRead to determine if the
  543. link negotiation is complete.
  544. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  545. @param [in, out] pPollCount Address of number of times this routine was polled
  546. @param [out] pbComplete Address of boolean to receive complate status.
  547. @param [out] pbLinkUp Address of boolean to receive link status, TRUE=up.
  548. @param [out] pbHiSpeed Address of boolean to receive link speed, TRUE=100Mbps.
  549. @param [out] pbFullDuplex Address of boolean to receive link duplex, TRUE=full.
  550. @retval EFI_SUCCESS The MAC address is available.
  551. @retval other The MAC address is not valid.
  552. **/
  553. EFI_STATUS
  554. Ax88772NegotiateLinkComplete (
  555. IN NIC_DEVICE * pNicDevice,
  556. IN OUT UINTN * pPollCount,
  557. OUT BOOLEAN * pbComplete,
  558. OUT BOOLEAN * pbLinkUp,
  559. OUT BOOLEAN * pbHiSpeed,
  560. OUT BOOLEAN * pbFullDuplex
  561. );
  562. /**
  563. Read a register from the PHY
  564. This routine calls ::Ax88772UsbCommand to read a PHY register.
  565. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  566. @param [in] RegisterAddress Number of the register to read.
  567. @param [in, out] pPhyData Address of a buffer to receive the PHY register value
  568. @retval EFI_SUCCESS The PHY data is available.
  569. @retval other The PHY data is not valid.
  570. **/
  571. EFI_STATUS
  572. Ax88772PhyRead (
  573. IN NIC_DEVICE * pNicDevice,
  574. IN UINT8 RegisterAddress,
  575. IN OUT UINT16 * pPhyData
  576. );
  577. /**
  578. Write to a PHY register
  579. This routine calls ::Ax88772UsbCommand to write a PHY register.
  580. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  581. @param [in] RegisterAddress Number of the register to read.
  582. @param [in] PhyData Address of a buffer to receive the PHY register value
  583. @retval EFI_SUCCESS The PHY data was written.
  584. @retval other Failed to wwrite the PHY register.
  585. **/
  586. EFI_STATUS
  587. Ax88772PhyWrite (
  588. IN NIC_DEVICE * pNicDevice,
  589. IN UINT8 RegisterAddress,
  590. IN UINT16 PhyData
  591. );
  592. /**
  593. Reset the AX88772
  594. This routine uses ::Ax88772UsbCommand to reset the network
  595. adapter. This routine also uses ::Ax88772PhyWrite to reset
  596. the PHY.
  597. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  598. @retval EFI_SUCCESS The MAC address is available.
  599. @retval other The MAC address is not valid.
  600. **/
  601. EFI_STATUS
  602. Ax88772Reset (
  603. IN NIC_DEVICE * pNicDevice
  604. );
  605. /**
  606. Receive a frame from the network.
  607. This routine polls the USB receive interface for a packet. If a packet
  608. is available, this routine adds the receive packet to the list of
  609. pending receive packets.
  610. This routine calls ::Ax88772NegotiateLinkComplete to verify
  611. that the link is up. This routine also calls ::SN_Reset to
  612. reset the network adapter when necessary. Finally this
  613. routine attempts to receive one or more packets from the
  614. network adapter.
  615. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  616. @param [in] bUpdateLink TRUE = Update link status
  617. **/
  618. VOID
  619. Ax88772Rx (
  620. IN NIC_DEVICE * pNicDevice,
  621. IN BOOLEAN bUpdateLink
  622. );
  623. /**
  624. Enable or disable the receiver
  625. This routine calls ::Ax88772UsbCommand to update the
  626. receiver state. This routine also calls ::Ax88772MacAddressSet
  627. to establish the MAC address for the network adapter.
  628. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  629. @param [in] RxFilter Simple network RX filter mask value
  630. @retval EFI_SUCCESS The MAC address was set.
  631. @retval other The MAC address was not set.
  632. **/
  633. EFI_STATUS
  634. Ax88772RxControl (
  635. IN NIC_DEVICE * pNicDevice,
  636. IN UINT32 RxFilter
  637. );
  638. /**
  639. Read an SROM location
  640. This routine calls ::Ax88772UsbCommand to read data from the
  641. SROM.
  642. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  643. @param [in] Address SROM address
  644. @param [out] pData Buffer to receive the data
  645. @retval EFI_SUCCESS The read was successful
  646. @retval other The read failed
  647. **/
  648. EFI_STATUS
  649. Ax88772SromRead (
  650. IN NIC_DEVICE * pNicDevice,
  651. IN UINT32 Address,
  652. OUT UINT16 * pData
  653. );
  654. /**
  655. This routine is called at a regular interval to poll for
  656. receive packets.
  657. This routine polls the link state and gets any receive packets
  658. by calling ::Ax88772Rx.
  659. @param [in] Event Timer event
  660. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  661. **/
  662. VOID
  663. Ax88772Timer (
  664. IN EFI_EVENT Event,
  665. IN NIC_DEVICE * pNicDevice
  666. );
  667. /**
  668. Send a command to the USB device.
  669. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  670. @param [in] pRequest Pointer to the request structure
  671. @param [in, out] pBuffer Data buffer address
  672. @retval EFI_SUCCESS The USB transfer was successful
  673. @retval other The USB transfer failed
  674. **/
  675. EFI_STATUS
  676. Ax88772UsbCommand (
  677. IN NIC_DEVICE * pNicDevice,
  678. IN USB_DEVICE_REQUEST * pRequest,
  679. IN OUT VOID * pBuffer
  680. );
  681. //------------------------------------------------------------------------------
  682. // EFI Component Name Protocol Support
  683. //------------------------------------------------------------------------------
  684. extern EFI_COMPONENT_NAME_PROTOCOL gComponentName; ///< Component name protocol declaration
  685. extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2; ///< Component name 2 protocol declaration
  686. /**
  687. Retrieves a Unicode string that is the user readable name of the driver.
  688. This function retrieves the user readable name of a driver in the form of a
  689. Unicode string. If the driver specified by This has a user readable name in
  690. the language specified by Language, then a pointer to the driver name is
  691. returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
  692. by This does not support the language specified by Language,
  693. then EFI_UNSUPPORTED is returned.
  694. @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  695. EFI_COMPONENT_NAME_PROTOCOL instance.
  696. @param [in] pLanguage A pointer to a Null-terminated ASCII string
  697. array indicating the language. This is the
  698. language of the driver name that the caller is
  699. requesting, and it must match one of the
  700. languages specified in SupportedLanguages. The
  701. number of languages supported by a driver is up
  702. to the driver writer. Language is specified
  703. in RFC 3066 or ISO 639-2 language code format.
  704. @param [out] ppDriverName A pointer to the Unicode string to return.
  705. This Unicode string is the name of the
  706. driver specified by This in the language
  707. specified by Language.
  708. @retval EFI_SUCCESS The Unicode string for the Driver specified by
  709. This and the language specified by Language was
  710. returned in DriverName.
  711. @retval EFI_INVALID_PARAMETER Language is NULL.
  712. @retval EFI_INVALID_PARAMETER DriverName is NULL.
  713. @retval EFI_UNSUPPORTED The driver specified by This does not support
  714. the language specified by Language.
  715. **/
  716. EFI_STATUS
  717. EFIAPI
  718. GetDriverName (
  719. IN EFI_COMPONENT_NAME_PROTOCOL * pThis,
  720. IN CHAR8 * pLanguage,
  721. OUT CHAR16 ** ppDriverName
  722. );
  723. /**
  724. Retrieves a Unicode string that is the user readable name of the controller
  725. that is being managed by a driver.
  726. This function retrieves the user readable name of the controller specified by
  727. ControllerHandle and ChildHandle in the form of a Unicode string. If the
  728. driver specified by This has a user readable name in the language specified by
  729. Language, then a pointer to the controller name is returned in ControllerName,
  730. and EFI_SUCCESS is returned. If the driver specified by This is not currently
  731. managing the controller specified by ControllerHandle and ChildHandle,
  732. then EFI_UNSUPPORTED is returned. If the driver specified by This does not
  733. support the language specified by Language, then EFI_UNSUPPORTED is returned.
  734. @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  735. EFI_COMPONENT_NAME_PROTOCOL instance.
  736. @param [in] ControllerHandle The handle of a controller that the driver
  737. specified by This is managing. This handle
  738. specifies the controller whose name is to be
  739. returned.
  740. @param [in] ChildHandle The handle of the child controller to retrieve
  741. the name of. This is an optional parameter that
  742. may be NULL. It will be NULL for device
  743. drivers. It will also be NULL for a bus drivers
  744. that wish to retrieve the name of the bus
  745. controller. It will not be NULL for a bus
  746. driver that wishes to retrieve the name of a
  747. child controller.
  748. @param [in] pLanguage A pointer to a Null-terminated ASCII string
  749. array indicating the language. This is the
  750. language of the driver name that the caller is
  751. requesting, and it must match one of the
  752. languages specified in SupportedLanguages. The
  753. number of languages supported by a driver is up
  754. to the driver writer. Language is specified in
  755. RFC 3066 or ISO 639-2 language code format.
  756. @param [out] ppControllerName A pointer to the Unicode string to return.
  757. This Unicode string is the name of the
  758. controller specified by ControllerHandle and
  759. ChildHandle in the language specified by
  760. Language from the point of view of the driver
  761. specified by This.
  762. @retval EFI_SUCCESS The Unicode string for the user readable name in
  763. the language specified by Language for the
  764. driver specified by This was returned in
  765. DriverName.
  766. @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
  767. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
  768. EFI_HANDLE.
  769. @retval EFI_INVALID_PARAMETER Language is NULL.
  770. @retval EFI_INVALID_PARAMETER ControllerName is NULL.
  771. @retval EFI_UNSUPPORTED The driver specified by This is not currently
  772. managing the controller specified by
  773. ControllerHandle and ChildHandle.
  774. @retval EFI_UNSUPPORTED The driver specified by This does not support
  775. the language specified by Language.
  776. **/
  777. EFI_STATUS
  778. EFIAPI
  779. GetControllerName (
  780. IN EFI_COMPONENT_NAME_PROTOCOL * pThis,
  781. IN EFI_HANDLE ControllerHandle,
  782. IN OPTIONAL EFI_HANDLE ChildHandle,
  783. IN CHAR8 * pLanguage,
  784. OUT CHAR16 ** ppControllerName
  785. );
  786. //------------------------------------------------------------------------------
  787. #endif // _AX88772_H_