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