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