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