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