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