]> git.proxmox.com Git - mirror_edk2.git/blob - OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h
ArmPkg/CompilerIntrinsicsLib: Add uread, uwrite GCC assembly sources
[mirror_edk2.git] / OptionRomPkg / Bus / Usb / UsbNetworking / Ax88772b / Ax88772.h
1 /** @file
2 Definitions for ASIX AX88772 Ethernet adapter.
3
4 Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
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 #define MAX_QUEUE_SIZE 50
33 #define MAX_BULKIN_SIZE 16384
34 #define HW_HDR_LENGTH 8
35
36
37 #define MAX_LINKIDLE_THRESHOLD 20000
38
39
40
41 //------------------------------------------------------------------------------
42 // Macros
43 //------------------------------------------------------------------------------
44
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
52 #else // _MSC_VER
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
59 #endif // _MSC_VER
60
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
65
66
67 #define PRINT(_L_STR) (gST->ConOut->OutputString(gST->ConOut,(_L_STR)))
68 //------------------------------------------------------------------------------
69 // Constants
70 //------------------------------------------------------------------------------
71
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
82
83 #define AX88772_MAX_PKT_SIZE 2048 ///< Maximum packet size
84
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
88
89 #define USB_NETWORK_CLASS 0x09 ///< USB Network class code
90 #define USB_BUS_TIMEOUT 1000 ///< USB timeout in milliseconds
91
92 #define TIMER_MSEC 20 ///< Polling interval for the NIC
93 //#define TPL_AX88772 TPL_CALLBACK ///< TPL for routine synchronization
94
95 #define HC_DEBUG 0
96 #define BULKIN_TIMEOUT 20
97 #define AUTONEG_DELAY 500000
98 #define AUTONEG_POLLCNT 20
99
100 /**
101 Verify new TPL value
102
103 This macro which is enabled when debug is enabled verifies that
104 the new TPL value is >= the current TPL value.
105 **/
106 #ifdef VERIFY_TPL
107 #undef VERIFY_TPL
108 #endif // VERIFY_TPL
109
110 #if !defined(MDEPKG_NDEBUG)
111
112 #define VERIFY_TPL(tpl) \
113 { \
114 EFI_TPL PreviousTpl; \
115 \
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 ); \
121 } \
122 }
123
124 #else // MDEPKG_NDEBUG
125
126 #define VERIFY_TPL(tpl)
127
128 #endif // MDEPKG_NDEBUG
129
130 //------------------------------------------------------------------------------
131 // Hardware Definition
132 //------------------------------------------------------------------------------
133
134 #define FreeQueueSize 10
135
136 #define DEV_SIGNATURE SIGNATURE_32 ('A','X','8','8') ///< Signature of data structures in memory
137
138 #define RESET_MSEC 1000 ///< Reset duration
139 #define PHY_RESET_MSEC 500 ///< PHY reset duration
140
141 //
142 // RX Control register
143 //
144
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
157
158 /*Freddy*/
159 #define RXC_RH1M 0x0100 ///< Rx header 1
160 #define RXC_RH2M 0x0200 ///< Rx header 2
161 #define RXC_RH3M 0x0400 ///< Rx header 3
162 /*Freddy*/
163
164 //
165 // Medium Status register
166 //
167
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
177
178 //
179 // Software PHY Select register
180 //
181
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
186
187 //
188 // Software Reset register
189 //
190
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
198
199 //
200 // PHY ID values
201 //
202
203 #define PHY_ID_INTERNAL 0x0010 ///< Internal PHY
204
205 //
206 // USB Commands
207 //
208
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
225
226 /*Freddy*/
227 #define CMD_RXQTC 0x2a ///< RX Queue Cascade Threshold Control Register
228 /*Freddy*/
229
230 //------------------------------
231 // USB Endpoints
232 //------------------------------
233
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
238
239 //------------------------------
240 // PHY Registers
241 //------------------------------
242
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
248
249 // BMCR - Register 0
250
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
262
263 // BSMR - Register 1
264
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
277
278 // ANAR and ANLPAR Registers 4, 5
279
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
290
291 // asix_flags defines
292 #define FLAG_NONE 0
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
297
298 //------------------------------------------------------------------------------
299 // Data Types
300 //------------------------------------------------------------------------------
301
302 typedef struct {
303 UINT16 VendorId;
304 UINT16 ProductId;
305 INT32 Flags;
306 }ASIX_DONGLE;
307
308 /**
309 Ethernet header layout
310
311 IEEE 802.3-2002 Part 3 specification, section 3.1.1.
312 **/
313 #pragma pack(1)
314 typedef struct {
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
318 } ETHERNET_HEADER;
319 #pragma pack()
320
321 /**
322 Receive and Transmit packet structure
323 **/
324 #pragma pack(1)
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
330 } RX_TX_PACKET;
331 #pragma pack()
332
333
334 #pragma pack(1)
335 typedef struct _RX_PKT {
336 struct _RX_PKT *pNext;
337 BOOLEAN f_Used;
338 UINT16 Length;
339 UINT8 Data [AX88772_MAX_PKT_SIZE] ;
340 } RX_PKT;
341 #pragma pack()
342
343 /**
344 AX88772 control structure
345
346 The driver uses this structure to manage the Asix AX88772 10/100
347 Ethernet controller.
348 **/
349 typedef struct {
350 UINTN Signature; ///< Structure identification
351
352 //
353 // USB data
354 //
355 EFI_HANDLE Controller; ///< Controller handle
356 EFI_USB_IO_PROTOCOL * pUsbIo; ///< USB driver interface
357
358 //
359 // Simple network protocol data
360 //
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
364
365 //
366 // Ethernet controller data
367 //
368 BOOLEAN bInitialized; ///< Controller initialized
369 VOID * pTxBuffer; ///< Last transmit buffer
370 UINT16 PhyId; ///< PHY ID
371
372 //
373 // Link state
374 //
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
379 UINTN LinkIdleCnt;
380 UINTN PollCount; ///< Number of times the autonegotiation status was polled
381 UINT16 CurRxControl;
382 //
383 // Receive buffer list
384 //
385 RX_TX_PACKET * pRxTest;
386 RX_TX_PACKET * pTxTest;
387
388 INT8 MulticastHash[8];
389 EFI_MAC_ADDRESS MAC;
390 BOOLEAN bHavePkt;
391
392 EFI_DEVICE_PATH_PROTOCOL *MyDevPath;
393
394 EFI_DRIVER_BINDING_PROTOCOL * DrvBind;
395
396 RX_PKT * QueueHead;
397 RX_PKT * pNextFill;
398 RX_PKT * pFirstFill;
399 UINTN PktCntInQueue;
400 UINT8 * pBulkInBuff;
401
402 INT32 Flags;
403
404 } NIC_DEVICE;
405
406 #define DEV_FROM_SIMPLE_NETWORK(a) CR (a, NIC_DEVICE, SimpleNetwork, DEV_SIGNATURE) ///< Locate NIC_DEVICE from Simple Network Protocol
407
408 //------------------------------------------------------------------------------
409 // Simple Network Protocol
410 //------------------------------------------------------------------------------
411
412 /**
413 Reset the network adapter.
414
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
419 this call.
420
421 This routine calls ::Ax88772Reset to perform the adapter specific
422 reset operation. This routine also starts the link negotiation
423 by calling ::Ax88772NegotiateLinkStart.
424
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
428 during reset.
429
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.
436
437 **/
438 EFI_STATUS
439 EFIAPI
440 SN_Reset (
441 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
442 IN BOOLEAN bExtendedVerification
443 );
444
445 /**
446 Initialize the simple network protocol.
447
448 This routine calls ::Ax88772MacAddressGet to obtain the
449 MAC address.
450
451 @param [in] pNicDevice NIC_DEVICE_INSTANCE pointer
452
453 @retval EFI_SUCCESS Setup was successful
454
455 **/
456 EFI_STATUS
457 SN_Setup (
458 IN NIC_DEVICE * pNicDevice
459 );
460
461 /**
462 This routine starts the network interface.
463
464 @param [in] pSimpleNetwork Protocol instance pointer
465
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.
472
473 **/
474 EFI_STATUS
475 EFIAPI
476 SN_Start (
477 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork
478 );
479
480 /**
481 Set the MAC address.
482
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
487 pNew.
488
489 This routine calls ::Ax88772MacAddressSet to update the MAC address
490 in the network adapter.
491
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
496 interface.
497
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.
504
505 **/
506 EFI_STATUS
507 EFIAPI
508 SN_StationAddress (
509 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
510 IN BOOLEAN bReset,
511 IN EFI_MAC_ADDRESS * pNew
512 );
513
514 /**
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
519 StatisticsTable.
520
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.
527
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.
535
536 **/
537 EFI_STATUS
538 EFIAPI
539 SN_Statistics (
540 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
541 IN BOOLEAN bReset,
542 IN OUT UINTN * pStatisticsSize,
543 OUT EFI_NETWORK_STATISTICS * pStatisticsTable
544 );
545
546 /**
547 This function stops a network interface. This call is only valid
548 if the network interface is in the started state.
549
550 @param [in] pSimpleNetwork Protocol instance pointer
551
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.
558
559 **/
560 EFI_STATUS
561 EFIAPI
562 SN_Stop (
563 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork
564 );
565
566 /**
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.
570
571 @param [in] pSimpleNetwork Protocol instance pointer
572
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.
579
580 **/
581 EFI_STATUS
582 EFIAPI
583 SN_Shutdown (
584 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork
585 );
586
587 /**
588 Send a packet over the network.
589
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.
594
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.
598
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()
611 function.
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.
620
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.
628
629 **/
630 EFI_STATUS
631 EFIAPI
632 SN_Transmit (
633 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
634 IN UINTN HeaderSize,
635 IN UINTN BufferSize,
636 IN VOID * pBuffer,
637 IN EFI_MAC_ADDRESS * pSrcAddr,
638 IN EFI_MAC_ADDRESS * pDestAddr,
639 IN UINT16 * pProtocol
640 );
641
642 //------------------------------------------------------------------------------
643 // Support Routines
644 //------------------------------------------------------------------------------
645
646 /**
647 Get the MAC address
648
649 This routine calls ::Ax88772UsbCommand to request the MAC
650 address from the network adapter.
651
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.
654
655 @retval EFI_SUCCESS The MAC address is available.
656 @retval other The MAC address is not valid.
657
658 **/
659 EFI_STATUS
660 Ax88772MacAddressGet (
661 IN NIC_DEVICE * pNicDevice,
662 OUT UINT8 * pMacAddress
663 );
664
665 /**
666 Set the MAC address
667
668 This routine calls ::Ax88772UsbCommand to set the MAC address
669 in the network adapter.
670
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.
673
674 @retval EFI_SUCCESS The MAC address was set.
675 @retval other The MAC address was not set.
676
677 **/
678 EFI_STATUS
679 Ax88772MacAddressSet (
680 IN NIC_DEVICE * pNicDevice,
681 IN UINT8 * pMacAddress
682 );
683
684 /**
685 Clear the multicast hash table
686
687 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
688
689 **/
690 VOID
691 Ax88772MulticastClear (
692 IN NIC_DEVICE * pNicDevice
693 );
694
695 /**
696 Enable a multicast address in the multicast hash table
697
698 This routine calls ::Ax88772Crc to compute the hash bit for
699 this MAC address.
700
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.
703
704 **/
705 VOID
706 Ax88772MulticastSet (
707 IN NIC_DEVICE * pNicDevice,
708 IN UINT8 * pMacAddress
709 );
710
711 /**
712 Start the link negotiation
713
714 This routine calls ::Ax88772PhyWrite to start the PHY's link
715 negotiation.
716
717 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
718
719 @retval EFI_SUCCESS The link negotiation was started.
720 @retval other Failed to start the link negotiation.
721
722 **/
723 EFI_STATUS
724 Ax88772NegotiateLinkStart (
725 IN NIC_DEVICE * pNicDevice
726 );
727
728 /**
729 Complete the negotiation of the PHY link
730
731 This routine calls ::Ax88772PhyRead to determine if the
732 link negotiation is complete.
733
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.
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 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
753 );
754
755 /**
756 Read a register from the PHY
757
758 This routine calls ::Ax88772UsbCommand to read a PHY register.
759
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
763
764 @retval EFI_SUCCESS The PHY data is available.
765 @retval other The PHY data is not valid.
766
767 **/
768 EFI_STATUS
769 Ax88772PhyRead (
770 IN NIC_DEVICE * pNicDevice,
771 IN UINT8 RegisterAddress,
772 IN OUT UINT16 * pPhyData
773 );
774
775 /**
776 Write to a PHY register
777
778 This routine calls ::Ax88772UsbCommand to write a PHY register.
779
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
783
784 @retval EFI_SUCCESS The PHY data was written.
785 @retval other Failed to wwrite the PHY register.
786
787 **/
788 EFI_STATUS
789 Ax88772PhyWrite (
790 IN NIC_DEVICE * pNicDevice,
791 IN UINT8 RegisterAddress,
792 IN UINT16 PhyData
793 );
794
795 /**
796 Reset the AX88772
797
798 This routine uses ::Ax88772UsbCommand to reset the network
799 adapter. This routine also uses ::Ax88772PhyWrite to reset
800 the PHY.
801
802 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
803
804 @retval EFI_SUCCESS The MAC address is available.
805 @retval other The MAC address is not valid.
806
807 **/
808 EFI_STATUS
809 Ax88772Reset (
810 IN NIC_DEVICE * pNicDevice
811 );
812
813 VOID
814 Ax88772ChkLink (
815 IN NIC_DEVICE * pNicDevice,
816 IN BOOLEAN bUpdateLink
817 );
818
819 /**
820 Receive a frame from the network.
821
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.
825
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
830 network adapter.
831
832 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
833 @param [in] bUpdateLink TRUE = Update link status
834
835 **/
836 VOID
837 Ax88772Rx (
838 IN NIC_DEVICE * pNicDevice,
839 IN BOOLEAN bUpdateLink
840 );
841
842 /**
843 Enable or disable the receiver
844
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.
848
849 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
850 @param [in] RxFilter Simple network RX filter mask value
851
852 @retval EFI_SUCCESS The MAC address was set.
853 @retval other The MAC address was not set.
854
855 **/
856 EFI_STATUS
857 Ax88772RxControl (
858 IN NIC_DEVICE * pNicDevice,
859 IN UINT32 RxFilter
860 );
861
862 /**
863 Read an SROM location
864
865 This routine calls ::Ax88772UsbCommand to read data from the
866 SROM.
867
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
871
872 @retval EFI_SUCCESS The read was successful
873 @retval other The read failed
874
875 **/
876 EFI_STATUS
877 Ax88772SromRead (
878 IN NIC_DEVICE * pNicDevice,
879 IN UINT32 Address,
880 OUT UINT16 * pData
881 );
882
883 /**
884 Send a command to the USB device.
885
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
889
890 @retval EFI_SUCCESS The USB transfer was successful
891 @retval other The USB transfer failed
892
893 **/
894 EFI_STATUS
895 Ax88772UsbCommand (
896 IN NIC_DEVICE * pNicDevice,
897 IN USB_DEVICE_REQUEST * pRequest,
898 IN OUT VOID * pBuffer
899 );
900
901 //------------------------------------------------------------------------------
902 // EFI Component Name Protocol Support
903 //------------------------------------------------------------------------------
904
905 extern EFI_COMPONENT_NAME_PROTOCOL gComponentName; ///< Component name protocol declaration
906 extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2; ///< Component name 2 protocol declaration
907
908 /**
909 Retrieves a Unicode string that is the user readable name of the driver.
910
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.
917
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.
932
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.
940
941 **/
942 EFI_STATUS
943 EFIAPI
944 GetDriverName (
945 IN EFI_COMPONENT_NAME_PROTOCOL * pThis,
946 IN CHAR8 * pLanguage,
947 OUT CHAR16 ** ppDriverName
948 );
949
950
951 /**
952 Retrieves a Unicode string that is the user readable name of the controller
953 that is being managed by a driver.
954
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.
963
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
969 returned.
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
977 child controller.
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
991 specified by This.
992
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
996 DriverName.
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
999 EFI_HANDLE.
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.
1007
1008 **/
1009 EFI_STATUS
1010 EFIAPI
1011 GetControllerName (
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
1017 );
1018
1019 VOID
1020 FillPkt2Queue (
1021 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
1022 IN UINTN BufLength);
1023
1024 //------------------------------------------------------------------------------
1025
1026 #endif // _AX88772_H_