1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
/** @file
*
* Copyright (c) 2012-2014, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
* which accompanies this distribution. The full text of the license may be found at
* http://opensource.org/licenses/bsd-license.php
*
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*
**/
#ifndef __LAN9118_DXE_H__
#define __LAN9118_DXE_H__
#include <Uefi.h>
#include <Uefi/UefiSpec.h>
#include <Base.h>
// Protocols used by this driver
#include <Protocol/SimpleNetwork.h>
#include <Protocol/ComponentName2.h>
#include <Protocol/PxeBaseCode.h>
#include <Protocol/DevicePath.h>
// Libraries used by this driver
#include <Library/UefiLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
#include <Library/NetLib.h>
#include <Library/DevicePathLib.h>
#include "Lan9118DxeUtil.h"
#include "Lan9118DxeHw.h"
#define LAN9118_STALL 2
#define LAN9118_DEFAULT_MAC_ADDRL 0x00F70200
#define LAN9118_DEFAULT_MAC_ADDRH 0x00009040
#define LAN9118_TX_DATA_SIZE 4608
#define LAN9118_TX_STATUS_SIZE 512
#define LAN9118_RX_DATA_SIZE 10560
#define LAN9118_RX_STATUS_SIZE 704
#define LAN9118_TX_RING_NUM_ENTRIES 32
/*------------------------------------------------------------------------------
LAN9118 Information Structure
------------------------------------------------------------------------------*/
typedef struct {
// Driver signature
UINT32 Signature;
EFI_HANDLE ControllerHandle;
// EFI SNP protocol instances
EFI_SIMPLE_NETWORK_PROTOCOL Snp;
EFI_SIMPLE_NETWORK_MODE SnpMode;
// EFI Snp statistics instance
EFI_NETWORK_STATISTICS Stats;
// Saved transmitted buffers so we can notify consumers when packets have been sent.
UINT16 NextPacketTag;
VOID *TxRing[LAN9118_TX_RING_NUM_ENTRIES];
} LAN9118_DRIVER;
#define LAN9118_SIGNATURE SIGNATURE_32('l', 'a', 'n', '9')
#define INSTANCE_FROM_SNP_THIS(a) CR(a, LAN9118_DRIVER, Snp, LAN9118_SIGNATURE)
/*---------------------------------------------------------------------------------------------------------------------
UEFI-Compliant functions for EFI_SIMPLE_NETWORK_PROTOCOL
Refer to the Simple Network Protocol section (21.1) in the UEFI 2.3.1 Specification for related definitions
---------------------------------------------------------------------------------------------------------------------*/
/*
* UEFI Start() function
*
* Parameters:
*
* @param pobj: A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
*
* Description:
*
* This function starts a network interface. If the network interface successfully starts, then
* EFI_SUCCESS will be returned.
*/
EFI_STATUS
EFIAPI
SnpStart (
IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp
);
/*
* UEFI Stop() function
*
*/
EFI_STATUS
EFIAPI
SnpStop (
IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp
);
/*
* UEFI Initialize() function
*
*/
EFI_STATUS
EFIAPI
SnpInitialize (
IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
IN UINTN rx_buff_size,
IN UINTN tx_buff_size
);
/*
* UEFI Reset() function
*
*/
EFI_STATUS
EFIAPI
SnpReset (
IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
IN BOOLEAN ext_ver
);
/*
* UEFI Shutdown() function
*
*/
EFI_STATUS
EFIAPI
SnpShutdown (
IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp
);
/*
* UEFI ReceiveFilters() function
*
*/
EFI_STATUS
EFIAPI
SnpReceiveFilters (
IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
IN UINT32 enable,
IN UINT32 disable,
IN BOOLEAN reset_mfilter,
IN UINTN num_mfilter,
IN EFI_MAC_ADDRESS *mfilter
);
/*
* UEFI StationAddress() function
*
*/
EFI_STATUS
EFIAPI
SnpStationAddress (
IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
IN BOOLEAN reset,
IN EFI_MAC_ADDRESS *new_maddr
);
/*
* UEFI Statistics() function
*
*/
EFI_STATUS
EFIAPI
SnpStatistics (
IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
IN BOOLEAN reset,
IN OUT UINTN *stat_size,
OUT EFI_NETWORK_STATISTICS *stat_table
);
/*
* UEFI MCastIPtoMAC() function
*
*/
EFI_STATUS
EFIAPI
SnpMcastIptoMac (
IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
IN BOOLEAN use_ipv6,
IN EFI_IP_ADDRESS *ip_addr,
OUT EFI_MAC_ADDRESS *mac_addr
);
/*
* UEFI NvData() function
*
*/
EFI_STATUS
EFIAPI
SnpNvData (
IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
IN BOOLEAN read_write,
IN UINTN offset,
IN UINTN buff_size,
IN OUT VOID *data
);
/*
* UEFI GetStatus() function
*
*/
EFI_STATUS
EFIAPI
SnpGetStatus (
IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
OUT UINT32 *irq_stat OPTIONAL,
OUT VOID **tx_buff OPTIONAL
);
/*
* UEFI Transmit() function
*
*/
EFI_STATUS
EFIAPI
SnpTransmit (
IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
IN UINTN hdr_size,
IN UINTN buff_size,
IN VOID *data,
IN EFI_MAC_ADDRESS *src_addr OPTIONAL,
IN EFI_MAC_ADDRESS *dest_addr OPTIONAL,
IN UINT16 *protocol OPTIONAL
);
/*
* UEFI Receive() function
*
*/
EFI_STATUS
EFIAPI
SnpReceive (
IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
OUT UINTN *hdr_size OPTIONAL,
IN OUT UINTN *buff_size,
OUT VOID *data,
OUT EFI_MAC_ADDRESS *src_addr OPTIONAL,
OUT EFI_MAC_ADDRESS *dest_addr OPTIONAL,
OUT UINT16 *protocol OPTIONAL
);
/*---------------------------------------------------------------------------------------------------------------------
UEFI-Compliant functions for EFI_COMPONENT_NAME2_PROTOCOL
Refer to the Component Name Protocol section (10.5) in the UEFI 2.3.1 Specification for related definitions
---------------------------------------------------------------------------------------------------------------------*/
/*
* UEFI GetDriverName() function
*
*/
EFI_STATUS
EFIAPI
SnpGetDriverName (
IN EFI_COMPONENT_NAME2_PROTOCOL *Snp,
IN CHAR8 *Lang,
OUT CHAR16 **DriverName
);
/*
* UEFI GetControllerName() function
*
*/
EFI_STATUS
EFIAPI
SnpGetControllerName (
IN EFI_COMPONENT_NAME2_PROTOCOL *Cnp,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Lang,
OUT CHAR16 **ControllerName
);
/*------------------------------------------------------------------------------
Utility functions
------------------------------------------------------------------------------*/
EFI_MAC_ADDRESS
GetCurrentMacAddress (
VOID
);
#endif // __LAN9118_DXE_H__
|