2 Definitions for ASIX AX88772 Ethernet adapter.
4 Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Guid/EventGroup.h>
16 #include <IndustryStandard/Pci.h>
18 #include <Library/BaseMemoryLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/DevicePathLib.h>
21 #include <Library/UefiBootServicesTableLib.h>
22 #include <Library/UefiDriverEntryPoint.h>
23 #include <Library/UefiLib.h>
24 #include <Library/UefiRuntimeLib.h>
26 #include <Protocol/DevicePath.h>
27 #include <Protocol/LoadedImage.h>
28 #include <Protocol/NetworkInterfaceIdentifier.h>
29 #include <Protocol/SimpleNetwork.h>
30 #include <Protocol/UsbIo.h>
32 #define MAX_QUEUE_SIZE 50
33 #define MAX_BULKIN_SIZE 16384
34 #define HW_HDR_LENGTH 8
37 #define MAX_LINKIDLE_THRESHOLD 20000
41 //------------------------------------------------------------------------------
43 //------------------------------------------------------------------------------
45 #if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */
46 #define DBG_ENTER() DEBUG (( 0xffffffff, "Entering " __FUNCTION__ "\n" )) ///< Display routine entry
47 #define DBG_EXIT() DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ "\n" )) ///< Display routine exit
48 #define DBG_EXIT_DEC(Status) DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ ", Status: %d\n", Status )) ///< Display routine exit with decimal value
49 #define DBG_EXIT_HEX(Status) DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ ", Status: 0x%08x\n", Status )) ///< Display routine exit with hex value
50 #define DBG_EXIT_STATUS(Status) DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ ", Status: %r\n", Status )) ///< Display routine exit with status value
51 #define DBG_EXIT_TF(Status) DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ ", returning %s\n", (FALSE == Status) ? L"FALSE" : L"TRUE" )) ///< Display routine with TRUE/FALSE value
53 #define DBG_ENTER() ///< Display routine entry
54 #define DBG_EXIT() ///< Display routine exit
55 #define DBG_EXIT_DEC(Status) ///< Display routine exit with decimal value
56 #define DBG_EXIT_HEX(Status) ///< Display routine exit with hex value
57 #define DBG_EXIT_STATUS(Status) ///< Display routine exit with status value
58 #define DBG_EXIT_TF(Status) ///< Display routine with TRUE/FALSE value
61 #define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) != 0) ///< Return TRUE/FALSE for IN direction
62 #define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == 0) ///< Return TRUE/FALSE for OUT direction
63 #define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_BULK) ///< Return TRUE/FALSE for BULK type
64 #define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) ///< Return TRUE/FALSE for INTERRUPT type
67 #define PRINT(_L_STR) (gST->ConOut->OutputString(gST->ConOut,(_L_STR)))
68 //------------------------------------------------------------------------------
70 //------------------------------------------------------------------------------
72 #define DEBUG_RX_BROADCAST 0x40000000 ///< Display RX broadcast messages
73 #define DEBUG_RX_MULTICAST 0x20000000 ///< Display RX multicast messages
74 #define DEBUG_RX_UNICAST 0x10000000 ///< Display RX unicast messages
75 #define DEBUG_MAC_ADDRESS 0x08000000 ///< Display the MAC address
76 #define DEBUG_LINK 0x04000000 ///< Display the link status
77 #define DEBUG_TX 0x02000000 ///< Display the TX messages
78 #define DEBUG_PHY 0x01000000 ///< Display the PHY register values
79 #define DEBUG_SROM 0x00800000 ///< Display the SROM contents
80 #define DEBUG_TIMER 0x00400000 ///< Display the timer routine entry/exit
81 #define DEBUG_TPL 0x00200000 ///< Display the timer routine entry/exit
83 #define AX88772_MAX_PKT_SIZE 2048 ///< Maximum packet size
85 #define ETHERNET_HEADER_SIZE sizeof ( ETHERNET_HEADER ) ///< Size in bytes of the Ethernet header
86 #define MIN_ETHERNET_PKT_SIZE 60 ///< Minimum packet size including Ethernet header
87 #define MAX_ETHERNET_PKT_SIZE 1500 ///< Ethernet spec 3.1.1: Minimum packet size
89 #define USB_NETWORK_CLASS 0x09 ///< USB Network class code
90 #define USB_BUS_TIMEOUT 1000 ///< USB timeout in milliseconds
92 #define TIMER_MSEC 20 ///< Polling interval for the NIC
93 //#define TPL_AX88772 TPL_CALLBACK ///< TPL for routine synchronization
96 #define BULKIN_TIMEOUT 20
97 #define AUTONEG_DELAY 500000
98 #define AUTONEG_POLLCNT 20
103 This macro which is enabled when debug is enabled verifies that
104 the new TPL value is >= the current TPL value.
110 #if !defined(MDEPKG_NDEBUG)
112 #define VERIFY_TPL(tpl) \
114 EFI_TPL PreviousTpl; \
116 PreviousTpl = gBS->RaiseTPL ( TPL_HIGH_LEVEL ); \
117 gBS->RestoreTPL ( PreviousTpl ); \
118 if ( PreviousTpl > tpl ) { \
119 DEBUG (( DEBUG_ERROR, "Current TPL: %d, New TPL: %d\r\n", PreviousTpl, tpl )); \
120 ASSERT ( PreviousTpl <= tpl ); \
124 #else // MDEPKG_NDEBUG
126 #define VERIFY_TPL(tpl)
128 #endif // MDEPKG_NDEBUG
130 //------------------------------------------------------------------------------
131 // Hardware Definition
132 //------------------------------------------------------------------------------
134 #define FreeQueueSize 10
136 #define DEV_SIGNATURE SIGNATURE_32 ('A','X','8','8') ///< Signature of data structures in memory
138 #define RESET_MSEC 1000 ///< Reset duration
139 #define PHY_RESET_MSEC 500 ///< PHY reset duration
142 // RX Control register
145 #define RXC_PRO 0x0001 ///< Receive all packets
146 #define RXC_AMALL 0x0002 ///< Receive all multicast packets
147 #define RXC_SEP 0x0004 ///< Save error packets
148 #define RXC_AB 0x0008 ///< Receive broadcast packets
149 #define RXC_AM 0x0010 ///< Use multicast destination address hash table
150 #define RXC_AP 0x0020 ///< Accept physical address from Multicast Filter
151 #define RXC_SO 0x0080 ///< Start operation
152 #define RXC_MFB 0x0300 ///< Maximum frame burst
153 #define RXC_MFB_2048 0 ///< Maximum frame size: 2048 bytes
154 #define RXC_MFB_4096 0x0100 ///< Maximum frame size: 4096 bytes
155 #define RXC_MFB_8192 0x0200 ///< Maximum frame size: 8192 bytes
156 #define RXC_MFB_16384 0x0300 ///< Maximum frame size: 16384 bytes
159 #define RXC_RH1M 0x0100 ///< Rx header 1
160 #define RXC_RH2M 0x0200 ///< Rx header 2
161 #define RXC_RH3M 0x0400 ///< Rx header 3
165 // Medium Status register
168 #define MS_FD 0x0002 ///< Full duplex
169 #define MS_ONE 0x0004 ///< Must be one
170 #define MS_RFC 0x0010 ///< RX flow control enable
171 #define MS_TFC 0x0020 ///< TX flow control enable
172 #define MS_PF 0x0080 ///< Pause frame enable
173 #define MS_RE 0x0100 ///< Receive enable
174 #define MS_PS 0x0200 ///< Port speed 1=100, 0=10 Mbps
175 #define MS_SBP 0x0800 ///< Stop back pressure
176 #define MS_SM 0x1000 ///< Super MAC support
179 // Software PHY Select register
182 #define SPHY_PSEL (1 << 0) ///< Select internal PHY
183 #define SPHY_SSMII (1 << 2)
184 #define SPHY_SSEN (1 << 4)
185 #define SPHY_ASEL 0x02 ///< 1=Auto select, 0=Manual select
188 // Software Reset register
191 #define SRR_RR 0x01 ///< Clear receive frame length error
192 #define SRR_RT 0x02 ///< Clear transmit frame length error
193 #define SRR_BZTYPE 0x04 ///< External PHY reset pin tri-state enable
194 #define SRR_PRL 0x08 ///< External PHY reset pin level
195 #define SRR_BZ 0x10 ///< Force Bulk to return zero length packet
196 #define SRR_IPRL 0x20 ///< Internal PHY reset control
197 #define SRR_IPPD 0x40 ///< Internal PHY power down
203 #define PHY_ID_INTERNAL 0x0010 ///< Internal PHY
209 #define CMD_PHY_ACCESS_SOFTWARE 0x06 ///< Software in control of PHY
210 #define CMD_PHY_REG_READ 0x07 ///< Read PHY register, Value: PHY, Index: Register, Data: Register value
211 #define CMD_PHY_REG_WRITE 0x08 ///< Write PHY register, Value: PHY, Index: Register, Data: New 16-bit value
212 #define CMD_PHY_ACCESS_HARDWARE 0x0a ///< Hardware in control of PHY
213 #define CMD_SROM_READ 0x0b ///< Read SROM register: Value: Address, Data: Value
214 #define CMD_RX_CONTROL_WRITE 0x10 ///< Set the RX control register, Value: New value
215 #define CMD_GAPS_WRITE 0x12 ///< Write the gaps register, Value: New value
216 #define CMD_MAC_ADDRESS_READ 0x13 ///< Read the MAC address, Data: 6 byte MAC address
217 #define CMD_MAC_ADDRESS_WRITE 0x14 ///< Set the MAC address, Data: New 6 byte MAC address
218 #define CMD_MULTICAST_HASH_WRITE 0x16 ///< Write the multicast hash table, Data: New 8 byte value
219 #define CMD_MULTICAST_HASH_READ 0x16 ///< Read the multicast hash table
220 #define CMD_MEDIUM_STATUS_READ 0x1a ///< Read medium status register, Data: Register value
221 #define CMD_MEDIUM_STATUS_WRITE 0x1b ///< Write medium status register, Value: New value
222 #define CMD_WRITE_GPIOS 0x1f
223 #define CMD_RESET 0x20 ///< Reset register, Value: New value
224 #define CMD_PHY_SELECT 0x22 ///< PHY select register, Value: New value
227 #define CMD_RXQTC 0x2a ///< RX Queue Cascade Threshold Control Register
230 //------------------------------
232 //------------------------------
234 #define CONTROL_ENDPOINT 0 ///< Control endpoint
235 #define INTERRUPT_ENDPOINT 1 ///< Interrupt endpoint
236 #define BULK_IN_ENDPOINT 2 ///< Receive endpoint
237 #define BULK_OUT_ENDPOINT 3 ///< Transmit endpoint
239 //------------------------------
241 //------------------------------
243 #define PHY_BMCR 0 ///< Control register
244 #define PHY_BMSR 1 ///< Status register
245 #define PHY_ANAR 4 ///< Autonegotiation advertisement register
246 #define PHY_ANLPAR 5 ///< Autonegotiation link parter ability register
247 #define PHY_ANER 6 ///< Autonegotiation expansion register
251 #define BMCR_RESET 0x8000 ///< 1 = Reset the PHY, bit clears after reset
252 #define BMCR_LOOPBACK 0x4000 ///< 1 = Loopback enabled
253 #define BMCR_100MBPS 0x2000 ///< 100 Mbits/Sec
254 #define BMCR_10MBPS 0 ///< 10 Mbits/Sec
255 #define BMCR_AUTONEGOTIATION_ENABLE 0x1000 ///< 1 = Enable autonegotiation
256 #define BMCR_POWER_DOWN 0x0800 ///< 1 = Power down
257 #define BMCR_ISOLATE 0x0400 ///< 0 = Isolate PHY
258 #define BMCR_RESTART_AUTONEGOTIATION 0x0200 ///< 1 = Restart autonegotiation
259 #define BMCR_FULL_DUPLEX 0x0100 ///< Full duplex operation
260 #define BMCR_HALF_DUPLEX 0 ///< Half duplex operation
261 #define BMCR_COLLISION_TEST 0x0080 ///< 1 = Collision test enabled
265 #define BMSR_100BASET4 0x8000 ///< 1 = 100BASE-T4 mode
266 #define BMSR_100BASETX_FDX 0x4000 ///< 1 = 100BASE-TX full duplex
267 #define BMSR_100BASETX_HDX 0x2000 ///< 1 = 100BASE-TX half duplex
268 #define BMSR_10BASET_FDX 0x1000 ///< 1 = 10BASE-T full duplex
269 #define BMSR_10BASET_HDX 0x0800 ///< 1 = 10BASE-T half duplex
270 #define BMSR_MF 0x0040 ///< 1 = PHY accepts frames with preamble suppressed
271 #define BMSR_AUTONEG_CMPLT 0x0020 ///< 1 = Autonegotiation complete
272 #define BMSR_RF 0x0010 ///< 1 = Remote fault
273 #define BMSR_AUTONEG 0x0008 ///< 1 = Able to perform autonegotiation
274 #define BMSR_LINKST 0x0004 ///< 1 = Link up
275 #define BMSR_JABBER_DETECT 0x0002 ///< 1 = jabber condition detected
276 #define BMSR_EXTENDED_CAPABILITY 0x0001 ///< 1 = Extended register capable
278 // ANAR and ANLPAR Registers 4, 5
280 #define AN_NP 0x8000 ///< 1 = Next page available
281 #define AN_ACK 0x4000 ///< 1 = Link partner acknowledged
282 #define AN_RF 0x2000 ///< 1 = Remote fault indicated by link partner
283 #define AN_FCS 0x0400 ///< 1 = Flow control ability
284 #define AN_T4 0x0200 ///< 1 = 100BASE-T4 support
285 #define AN_TX_FDX 0x0100 ///< 1 = 100BASE-TX Full duplex
286 #define AN_TX_HDX 0x0080 ///< 1 = 100BASE-TX support
287 #define AN_10_FDX 0x0040 ///< 1 = 10BASE-T Full duplex
288 #define AN_10_HDX 0x0020 ///< 1 = 10BASE-T support
289 #define AN_CSMA_CD 0x0001 ///< 1 = IEEE 802.3 CSMA/CD support
291 // asix_flags defines
293 #define FLAG_TYPE_AX88172 BIT0
294 #define FLAG_TYPE_AX88772 BIT1
295 #define FLAG_TYPE_AX88772B BIT2
296 #define FLAG_EEPROM_MAC BIT3 // initial mac address in eeprom
298 //------------------------------------------------------------------------------
300 //------------------------------------------------------------------------------
309 Ethernet header layout
311 IEEE 802.3-2002 Part 3 specification, section 3.1.1.
315 UINT8 dest_addr
[PXE_HWADDR_LEN_ETHER
]; ///< Destination LAN address
316 UINT8 src_addr
[PXE_HWADDR_LEN_ETHER
]; ///< Source LAN address
317 UINT16 type
; ///< Protocol or length
322 Receive and Transmit packet structure
325 typedef struct _RX_TX_PACKET
{
326 struct _RX_TX_PACKET
* pNext
; ///< Next receive packet
327 UINT16 Length
; ///< Packet length
328 UINT16 LengthBar
; ///< Complement of the length
329 UINT8 Data
[ AX88772_MAX_PKT_SIZE
]; ///< Received packet data
335 typedef struct _RX_PKT
{
336 struct _RX_PKT
*pNext
;
339 UINT8 Data
[AX88772_MAX_PKT_SIZE
] ;
344 AX88772 control structure
346 The driver uses this structure to manage the Asix AX88772 10/100
350 UINTN Signature
; ///< Structure identification
355 EFI_HANDLE Controller
; ///< Controller handle
356 EFI_USB_IO_PROTOCOL
* pUsbIo
; ///< USB driver interface
359 // Simple network protocol data
361 EFI_SIMPLE_NETWORK_PROTOCOL SimpleNetwork
; ///< Driver's network stack interface
362 EFI_SIMPLE_NETWORK_PROTOCOL SimpleNetwork_Backup
;
363 EFI_SIMPLE_NETWORK_MODE SimpleNetworkData
; ///< Data for simple network
366 // Ethernet controller data
368 BOOLEAN bInitialized
; ///< Controller initialized
369 VOID
* pTxBuffer
; ///< Last transmit buffer
370 UINT16 PhyId
; ///< PHY ID
375 BOOLEAN b100Mbps
; ///< Current link speed, FALSE = 10 Mbps
376 BOOLEAN bComplete
; ///< Current state of auto-negotiation
377 BOOLEAN bFullDuplex
; ///< Current duplex
378 BOOLEAN bLinkUp
; ///< Current link state
380 UINTN PollCount
; ///< Number of times the autonegotiation status was polled
383 // Receive buffer list
385 RX_TX_PACKET
* pRxTest
;
386 RX_TX_PACKET
* pTxTest
;
388 INT8 MulticastHash
[8];
392 EFI_DEVICE_PATH_PROTOCOL
*MyDevPath
;
394 EFI_DRIVER_BINDING_PROTOCOL
* DrvBind
;
406 #define DEV_FROM_SIMPLE_NETWORK(a) CR (a, NIC_DEVICE, SimpleNetwork, DEV_SIGNATURE) ///< Locate NIC_DEVICE from Simple Network Protocol
408 //------------------------------------------------------------------------------
409 // Simple Network Protocol
410 //------------------------------------------------------------------------------
413 Reset the network adapter.
415 Resets a network adapter and reinitializes it with the parameters that
416 were provided in the previous call to Initialize (). The transmit and
417 receive queues are cleared. Receive filters, the station address, the
418 statistics, and the multicast-IP-to-HW MAC addresses are not reset by
421 This routine calls ::Ax88772Reset to perform the adapter specific
422 reset operation. This routine also starts the link negotiation
423 by calling ::Ax88772NegotiateLinkStart.
425 @param [in] pSimpleNetwork Protocol instance pointer
426 @param [in] bExtendedVerification Indicates that the driver may perform a more
427 exhaustive verification operation of the device
430 @retval EFI_SUCCESS This operation was successful.
431 @retval EFI_NOT_STARTED The network interface was not started.
432 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
433 EFI_SIMPLE_NETWORK_PROTOCOL structure.
434 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
435 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
441 IN EFI_SIMPLE_NETWORK_PROTOCOL
* pSimpleNetwork
,
442 IN BOOLEAN bExtendedVerification
446 Initialize the simple network protocol.
448 This routine calls ::Ax88772MacAddressGet to obtain the
451 @param [in] pNicDevice NIC_DEVICE_INSTANCE pointer
453 @retval EFI_SUCCESS Setup was successful
458 IN NIC_DEVICE
* pNicDevice
462 This routine starts the network interface.
464 @param [in] pSimpleNetwork Protocol instance pointer
466 @retval EFI_SUCCESS This operation was successful.
467 @retval EFI_ALREADY_STARTED The network interface was already started.
468 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
469 EFI_SIMPLE_NETWORK_PROTOCOL structure.
470 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
471 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
477 IN EFI_SIMPLE_NETWORK_PROTOCOL
* pSimpleNetwork
483 This function modifies or resets the current station address of a
484 network interface. If Reset is TRUE, then the current station address
485 is set ot the network interface's permanent address. If Reset if FALSE
486 then the current station address is changed to the address specified by
489 This routine calls ::Ax88772MacAddressSet to update the MAC address
490 in the network adapter.
492 @param [in] pSimpleNetwork Protocol instance pointer
493 @param [in] bReset Flag used to reset the station address to the
494 network interface's permanent address.
495 @param [in] pNew New station address to be used for the network
498 @retval EFI_SUCCESS This operation was successful.
499 @retval EFI_NOT_STARTED The network interface was not started.
500 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
501 EFI_SIMPLE_NETWORK_PROTOCOL structure.
502 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
503 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
509 IN EFI_SIMPLE_NETWORK_PROTOCOL
* pSimpleNetwork
,
511 IN EFI_MAC_ADDRESS
* pNew
515 This function resets or collects the statistics on a network interface.
516 If the size of the statistics table specified by StatisticsSize is not
517 big enough for all of the statistics that are collected by the network
518 interface, then a partial buffer of statistics is returned in
521 @param [in] pSimpleNetwork Protocol instance pointer
522 @param [in] bReset Set to TRUE to reset the statistics for the network interface.
523 @param [in, out] pStatisticsSize On input the size, in bytes, of StatisticsTable. On output
524 the size, in bytes, of the resulting table of statistics.
525 @param [out] pStatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
526 conains the statistics.
528 @retval EFI_SUCCESS This operation was successful.
529 @retval EFI_NOT_STARTED The network interface was not started.
530 @retval EFI_BUFFER_TOO_SMALL The pStatisticsTable is NULL or the buffer is too small.
531 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
532 EFI_SIMPLE_NETWORK_PROTOCOL structure.
533 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
534 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
540 IN EFI_SIMPLE_NETWORK_PROTOCOL
* pSimpleNetwork
,
542 IN OUT UINTN
* pStatisticsSize
,
543 OUT EFI_NETWORK_STATISTICS
* pStatisticsTable
547 This function stops a network interface. This call is only valid
548 if the network interface is in the started state.
550 @param [in] pSimpleNetwork Protocol instance pointer
552 @retval EFI_SUCCESS This operation was successful.
553 @retval EFI_NOT_STARTED The network interface was not started.
554 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
555 EFI_SIMPLE_NETWORK_PROTOCOL structure.
556 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
557 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
563 IN EFI_SIMPLE_NETWORK_PROTOCOL
* pSimpleNetwork
567 This function releases the memory buffers assigned in the Initialize() call.
568 Pending transmits and receives are lost, and interrupts are cleared and disabled.
569 After this call, only Initialize() and Stop() calls may be used.
571 @param [in] pSimpleNetwork Protocol instance pointer
573 @retval EFI_SUCCESS This operation was successful.
574 @retval EFI_NOT_STARTED The network interface was not started.
575 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
576 EFI_SIMPLE_NETWORK_PROTOCOL structure.
577 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
578 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
584 IN EFI_SIMPLE_NETWORK_PROTOCOL
* pSimpleNetwork
588 Send a packet over the network.
590 This function places the packet specified by Header and Buffer on
591 the transmit queue. This function performs a non-blocking transmit
592 operation. When the transmit is complete, the buffer is returned
593 via the GetStatus() call.
595 This routine calls ::Ax88772Rx to empty the network adapter of
596 receive packets. The routine then passes the transmit packet
597 to the network adapter.
599 @param [in] pSimpleNetwork Protocol instance pointer
600 @param [in] HeaderSize The size, in bytes, of the media header to be filled in by
601 the Transmit() function. If HeaderSize is non-zero, then
602 it must be equal to SimpleNetwork->Mode->MediaHeaderSize
603 and DestAddr and Protocol parameters must not be NULL.
604 @param [in] BufferSize The size, in bytes, of the entire packet (media header and
605 data) to be transmitted through the network interface.
606 @param [in] pBuffer A pointer to the packet (media header followed by data) to
607 to be transmitted. This parameter can not be NULL. If
608 HeaderSize is zero, then the media header is Buffer must
609 already be filled in by the caller. If HeaderSize is nonzero,
610 then the media header will be filled in by the Transmit()
612 @param [in] pSrcAddr The source HW MAC address. If HeaderSize is zero, then
613 this parameter is ignored. If HeaderSize is nonzero and
614 SrcAddr is NULL, then SimpleNetwork->Mode->CurrentAddress
615 is used for the source HW MAC address.
616 @param [in] pDestAddr The destination HW MAC address. If HeaderSize is zero, then
617 this parameter is ignored.
618 @param [in] pProtocol The type of header to build. If HeaderSize is zero, then
619 this parameter is ignored.
621 @retval EFI_SUCCESS This operation was successful.
622 @retval EFI_NOT_STARTED The network interface was not started.
623 @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.
624 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
625 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
626 EFI_SIMPLE_NETWORK_PROTOCOL structure.
627 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
633 IN EFI_SIMPLE_NETWORK_PROTOCOL
* pSimpleNetwork
,
637 IN EFI_MAC_ADDRESS
* pSrcAddr
,
638 IN EFI_MAC_ADDRESS
* pDestAddr
,
639 IN UINT16
* pProtocol
642 //------------------------------------------------------------------------------
644 //------------------------------------------------------------------------------
649 This routine calls ::Ax88772UsbCommand to request the MAC
650 address from the network adapter.
652 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
653 @param [out] pMacAddress Address of a six byte buffer to receive the MAC address.
655 @retval EFI_SUCCESS The MAC address is available.
656 @retval other The MAC address is not valid.
660 Ax88772MacAddressGet (
661 IN NIC_DEVICE
* pNicDevice
,
662 OUT UINT8
* pMacAddress
668 This routine calls ::Ax88772UsbCommand to set the MAC address
669 in the network adapter.
671 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
672 @param [in] pMacAddress Address of a six byte buffer to containing the new MAC address.
674 @retval EFI_SUCCESS The MAC address was set.
675 @retval other The MAC address was not set.
679 Ax88772MacAddressSet (
680 IN NIC_DEVICE
* pNicDevice
,
681 IN UINT8
* pMacAddress
685 Clear the multicast hash table
687 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
691 Ax88772MulticastClear (
692 IN NIC_DEVICE
* pNicDevice
696 Enable a multicast address in the multicast hash table
698 This routine calls ::Ax88772Crc to compute the hash bit for
701 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
702 @param [in] pMacAddress Address of a six byte buffer to containing the MAC address.
706 Ax88772MulticastSet (
707 IN NIC_DEVICE
* pNicDevice
,
708 IN UINT8
* pMacAddress
712 Start the link negotiation
714 This routine calls ::Ax88772PhyWrite to start the PHY's link
717 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
719 @retval EFI_SUCCESS The link negotiation was started.
720 @retval other Failed to start the link negotiation.
724 Ax88772NegotiateLinkStart (
725 IN NIC_DEVICE
* pNicDevice
729 Complete the negotiation of the PHY link
731 This routine calls ::Ax88772PhyRead to determine if the
732 link negotiation is complete.
734 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
735 @param [in, out] pPollCount Address of number of times this routine was polled
736 @param [out] pbComplete Address of boolean to receive complate status.
737 @param [out] pbLinkUp Address of boolean to receive link status, TRUE=up.
738 @param [out] pbHiSpeed Address of boolean to receive link speed, TRUE=100Mbps.
739 @param [out] pbFullDuplex Address of boolean to receive link duplex, TRUE=full.
741 @retval EFI_SUCCESS The MAC address is available.
742 @retval other The MAC address is not valid.
746 Ax88772NegotiateLinkComplete (
747 IN NIC_DEVICE
* pNicDevice
,
748 IN OUT UINTN
* pPollCount
,
749 OUT BOOLEAN
* pbComplete
,
750 OUT BOOLEAN
* pbLinkUp
,
751 OUT BOOLEAN
* pbHiSpeed
,
752 OUT BOOLEAN
* pbFullDuplex
756 Read a register from the PHY
758 This routine calls ::Ax88772UsbCommand to read a PHY register.
760 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
761 @param [in] RegisterAddress Number of the register to read.
762 @param [in, out] pPhyData Address of a buffer to receive the PHY register value
764 @retval EFI_SUCCESS The PHY data is available.
765 @retval other The PHY data is not valid.
770 IN NIC_DEVICE
* pNicDevice
,
771 IN UINT8 RegisterAddress
,
772 IN OUT UINT16
* pPhyData
776 Write to a PHY register
778 This routine calls ::Ax88772UsbCommand to write a PHY register.
780 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
781 @param [in] RegisterAddress Number of the register to read.
782 @param [in] PhyData Address of a buffer to receive the PHY register value
784 @retval EFI_SUCCESS The PHY data was written.
785 @retval other Failed to wwrite the PHY register.
790 IN NIC_DEVICE
* pNicDevice
,
791 IN UINT8 RegisterAddress
,
798 This routine uses ::Ax88772UsbCommand to reset the network
799 adapter. This routine also uses ::Ax88772PhyWrite to reset
802 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
804 @retval EFI_SUCCESS The MAC address is available.
805 @retval other The MAC address is not valid.
810 IN NIC_DEVICE
* pNicDevice
815 IN NIC_DEVICE
* pNicDevice
,
816 IN BOOLEAN bUpdateLink
820 Receive a frame from the network.
822 This routine polls the USB receive interface for a packet. If a packet
823 is available, this routine adds the receive packet to the list of
824 pending receive packets.
826 This routine calls ::Ax88772NegotiateLinkComplete to verify
827 that the link is up. This routine also calls ::SN_Reset to
828 reset the network adapter when necessary. Finally this
829 routine attempts to receive one or more packets from the
832 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
833 @param [in] bUpdateLink TRUE = Update link status
838 IN NIC_DEVICE
* pNicDevice
,
839 IN BOOLEAN bUpdateLink
843 Enable or disable the receiver
845 This routine calls ::Ax88772UsbCommand to update the
846 receiver state. This routine also calls ::Ax88772MacAddressSet
847 to establish the MAC address for the network adapter.
849 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
850 @param [in] RxFilter Simple network RX filter mask value
852 @retval EFI_SUCCESS The MAC address was set.
853 @retval other The MAC address was not set.
858 IN NIC_DEVICE
* pNicDevice
,
863 Read an SROM location
865 This routine calls ::Ax88772UsbCommand to read data from the
868 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
869 @param [in] Address SROM address
870 @param [out] pData Buffer to receive the data
872 @retval EFI_SUCCESS The read was successful
873 @retval other The read failed
878 IN NIC_DEVICE
* pNicDevice
,
884 Send a command to the USB device.
886 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
887 @param [in] pRequest Pointer to the request structure
888 @param [in, out] pBuffer Data buffer address
890 @retval EFI_SUCCESS The USB transfer was successful
891 @retval other The USB transfer failed
896 IN NIC_DEVICE
* pNicDevice
,
897 IN USB_DEVICE_REQUEST
* pRequest
,
898 IN OUT VOID
* pBuffer
901 //------------------------------------------------------------------------------
902 // EFI Component Name Protocol Support
903 //------------------------------------------------------------------------------
905 extern EFI_COMPONENT_NAME_PROTOCOL gComponentName
; ///< Component name protocol declaration
906 extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2
; ///< Component name 2 protocol declaration
909 Retrieves a Unicode string that is the user readable name of the driver.
911 This function retrieves the user readable name of a driver in the form of a
912 Unicode string. If the driver specified by This has a user readable name in
913 the language specified by Language, then a pointer to the driver name is
914 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
915 by This does not support the language specified by Language,
916 then EFI_UNSUPPORTED is returned.
918 @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
919 EFI_COMPONENT_NAME_PROTOCOL instance.
920 @param [in] pLanguage A pointer to a Null-terminated ASCII string
921 array indicating the language. This is the
922 language of the driver name that the caller is
923 requesting, and it must match one of the
924 languages specified in SupportedLanguages. The
925 number of languages supported by a driver is up
926 to the driver writer. Language is specified
927 in RFC 3066 or ISO 639-2 language code format.
928 @param [out] ppDriverName A pointer to the Unicode string to return.
929 This Unicode string is the name of the
930 driver specified by This in the language
931 specified by Language.
933 @retval EFI_SUCCESS The Unicode string for the Driver specified by
934 This and the language specified by Language was
935 returned in DriverName.
936 @retval EFI_INVALID_PARAMETER Language is NULL.
937 @retval EFI_INVALID_PARAMETER DriverName is NULL.
938 @retval EFI_UNSUPPORTED The driver specified by This does not support
939 the language specified by Language.
945 IN EFI_COMPONENT_NAME_PROTOCOL
* pThis
,
946 IN CHAR8
* pLanguage
,
947 OUT CHAR16
** ppDriverName
952 Retrieves a Unicode string that is the user readable name of the controller
953 that is being managed by a driver.
955 This function retrieves the user readable name of the controller specified by
956 ControllerHandle and ChildHandle in the form of a Unicode string. If the
957 driver specified by This has a user readable name in the language specified by
958 Language, then a pointer to the controller name is returned in ControllerName,
959 and EFI_SUCCESS is returned. If the driver specified by This is not currently
960 managing the controller specified by ControllerHandle and ChildHandle,
961 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
962 support the language specified by Language, then EFI_UNSUPPORTED is returned.
964 @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
965 EFI_COMPONENT_NAME_PROTOCOL instance.
966 @param [in] ControllerHandle The handle of a controller that the driver
967 specified by This is managing. This handle
968 specifies the controller whose name is to be
970 @param [in] ChildHandle The handle of the child controller to retrieve
971 the name of. This is an optional parameter that
972 may be NULL. It will be NULL for device
973 drivers. It will also be NULL for a bus drivers
974 that wish to retrieve the name of the bus
975 controller. It will not be NULL for a bus
976 driver that wishes to retrieve the name of a
978 @param [in] pLanguage A pointer to a Null-terminated ASCII string
979 array indicating the language. This is the
980 language of the driver name that the caller is
981 requesting, and it must match one of the
982 languages specified in SupportedLanguages. The
983 number of languages supported by a driver is up
984 to the driver writer. Language is specified in
985 RFC 3066 or ISO 639-2 language code format.
986 @param [out] ppControllerName A pointer to the Unicode string to return.
987 This Unicode string is the name of the
988 controller specified by ControllerHandle and
989 ChildHandle in the language specified by
990 Language from the point of view of the driver
993 @retval EFI_SUCCESS The Unicode string for the user readable name in
994 the language specified by Language for the
995 driver specified by This was returned in
997 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
998 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
1000 @retval EFI_INVALID_PARAMETER Language is NULL.
1001 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
1002 @retval EFI_UNSUPPORTED The driver specified by This is not currently
1003 managing the controller specified by
1004 ControllerHandle and ChildHandle.
1005 @retval EFI_UNSUPPORTED The driver specified by This does not support
1006 the language specified by Language.
1012 IN EFI_COMPONENT_NAME_PROTOCOL
* pThis
,
1013 IN EFI_HANDLE ControllerHandle
,
1014 IN OPTIONAL EFI_HANDLE ChildHandle
,
1015 IN CHAR8
* pLanguage
,
1016 OUT CHAR16
** ppControllerName
1021 IN EFI_SIMPLE_NETWORK_PROTOCOL
* pSimpleNetwork
,
1022 IN UINTN BufLength
);
1024 //------------------------------------------------------------------------------
1026 #endif // _AX88772_H_