3 * Copyright (c) 2012-2014, ARM Limited. All rights reserved.
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
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.
15 #ifndef __LAN9118_DXE_H__
16 #define __LAN9118_DXE_H__
19 #include <Uefi/UefiSpec.h>
22 // Protocols used by this driver
23 #include <Protocol/SimpleNetwork.h>
24 #include <Protocol/ComponentName2.h>
25 #include <Protocol/PxeBaseCode.h>
26 #include <Protocol/DevicePath.h>
28 // Libraries used by this driver
29 #include <Library/UefiLib.h>
30 #include <Library/DebugLib.h>
31 #include <Library/UefiBootServicesTableLib.h>
32 #include <Library/MemoryAllocationLib.h>
33 #include <Library/IoLib.h>
34 #include <Library/PcdLib.h>
35 #include <Library/NetLib.h>
36 #include <Library/DevicePathLib.h>
38 #include "Lan9118DxeUtil.h"
39 #include "Lan9118DxeHw.h"
41 #define LAN9118_STALL 2
43 #define LAN9118_DEFAULT_MAC_ADDRL 0x00F70200
44 #define LAN9118_DEFAULT_MAC_ADDRH 0x00009040
46 #define LAN9118_TX_DATA_SIZE 4608
47 #define LAN9118_TX_STATUS_SIZE 512
48 #define LAN9118_RX_DATA_SIZE 10560
49 #define LAN9118_RX_STATUS_SIZE 704
51 #define LAN9118_TX_RING_NUM_ENTRIES 32
53 /*------------------------------------------------------------------------------
54 LAN9118 Information Structure
55 ------------------------------------------------------------------------------*/
60 EFI_HANDLE ControllerHandle
;
62 // EFI SNP protocol instances
63 EFI_SIMPLE_NETWORK_PROTOCOL Snp
;
64 EFI_SIMPLE_NETWORK_MODE SnpMode
;
66 // EFI Snp statistics instance
67 EFI_NETWORK_STATISTICS Stats
;
69 // Saved transmitted buffers so we can notify consumers when packets have been sent.
71 VOID
*TxRing
[LAN9118_TX_RING_NUM_ENTRIES
];
74 #define LAN9118_SIGNATURE SIGNATURE_32('l', 'a', 'n', '9')
75 #define INSTANCE_FROM_SNP_THIS(a) CR(a, LAN9118_DRIVER, Snp, LAN9118_SIGNATURE)
78 /*---------------------------------------------------------------------------------------------------------------------
80 UEFI-Compliant functions for EFI_SIMPLE_NETWORK_PROTOCOL
82 Refer to the Simple Network Protocol section (21.1) in the UEFI 2.3.1 Specification for related definitions
84 ---------------------------------------------------------------------------------------------------------------------*/
88 * UEFI Start() function
92 * @param pobj: A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
96 * This function starts a network interface. If the network interface successfully starts, then
97 * EFI_SUCCESS will be returned.
102 IN EFI_SIMPLE_NETWORK_PROTOCOL
* Snp
106 * UEFI Stop() function
112 IN EFI_SIMPLE_NETWORK_PROTOCOL
* Snp
116 * UEFI Initialize() function
122 IN EFI_SIMPLE_NETWORK_PROTOCOL
* Snp
,
123 IN UINTN rx_buff_size
,
124 IN UINTN tx_buff_size
128 * UEFI Reset() function
134 IN EFI_SIMPLE_NETWORK_PROTOCOL
* Snp
,
139 * UEFI Shutdown() function
145 IN EFI_SIMPLE_NETWORK_PROTOCOL
* Snp
149 * UEFI ReceiveFilters() function
155 IN EFI_SIMPLE_NETWORK_PROTOCOL
* Snp
,
158 IN BOOLEAN reset_mfilter
,
159 IN UINTN num_mfilter
,
160 IN EFI_MAC_ADDRESS
*mfilter
164 * UEFI StationAddress() function
170 IN EFI_SIMPLE_NETWORK_PROTOCOL
* Snp
,
172 IN EFI_MAC_ADDRESS
*new_maddr
176 * UEFI Statistics() function
182 IN EFI_SIMPLE_NETWORK_PROTOCOL
* Snp
,
184 IN OUT UINTN
*stat_size
,
185 OUT EFI_NETWORK_STATISTICS
*stat_table
189 * UEFI MCastIPtoMAC() function
195 IN EFI_SIMPLE_NETWORK_PROTOCOL
* Snp
,
197 IN EFI_IP_ADDRESS
*ip_addr
,
198 OUT EFI_MAC_ADDRESS
*mac_addr
202 * UEFI NvData() function
208 IN EFI_SIMPLE_NETWORK_PROTOCOL
* Snp
,
209 IN BOOLEAN read_write
,
216 * UEFI GetStatus() function
222 IN EFI_SIMPLE_NETWORK_PROTOCOL
* Snp
,
223 OUT UINT32
*irq_stat OPTIONAL
,
224 OUT VOID
**tx_buff OPTIONAL
228 * UEFI Transmit() function
234 IN EFI_SIMPLE_NETWORK_PROTOCOL
* Snp
,
238 IN EFI_MAC_ADDRESS
*src_addr OPTIONAL
,
239 IN EFI_MAC_ADDRESS
*dest_addr OPTIONAL
,
240 IN UINT16
*protocol OPTIONAL
244 * UEFI Receive() function
250 IN EFI_SIMPLE_NETWORK_PROTOCOL
* Snp
,
251 OUT UINTN
*hdr_size OPTIONAL
,
252 IN OUT UINTN
*buff_size
,
254 OUT EFI_MAC_ADDRESS
*src_addr OPTIONAL
,
255 OUT EFI_MAC_ADDRESS
*dest_addr OPTIONAL
,
256 OUT UINT16
*protocol OPTIONAL
260 /*---------------------------------------------------------------------------------------------------------------------
262 UEFI-Compliant functions for EFI_COMPONENT_NAME2_PROTOCOL
264 Refer to the Component Name Protocol section (10.5) in the UEFI 2.3.1 Specification for related definitions
266 ---------------------------------------------------------------------------------------------------------------------*/
269 * UEFI GetDriverName() function
275 IN EFI_COMPONENT_NAME2_PROTOCOL
*Snp
,
277 OUT CHAR16
**DriverName
281 * UEFI GetControllerName() function
286 SnpGetControllerName (
287 IN EFI_COMPONENT_NAME2_PROTOCOL
*Cnp
,
288 IN EFI_HANDLE ControllerHandle
,
289 IN EFI_HANDLE ChildHandle OPTIONAL
,
291 OUT CHAR16
**ControllerName
294 /*------------------------------------------------------------------------------
296 ------------------------------------------------------------------------------*/
299 GetCurrentMacAddress (
303 #endif // __LAN9118_DXE_H__