]>
Commit | Line | Data |
---|---|---|
2b59fcd5 | 1 | /**@file\r |
d18d8a1d | 2 | Linux Packet Filter implementation of the EMU_SNP_PROTOCOL that allows the\r |
2b59fcd5 | 3 | emulator to get on real networks.\r |
4 | \r | |
5 | Currently only the Berkeley Packet Filter is fully implemented and this file\r | |
d18d8a1d | 6 | is just a template that needs to get filled in.\r |
2b59fcd5 | 7 | \r |
8 | Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r | |
26cfe2c6 | 9 | Portions copyright (c) 2011, Apple Inc. All rights reserved.\r |
2b59fcd5 | 10 | \r |
e3ba31da | 11 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
2b59fcd5 | 12 | \r |
13 | **/\r | |
14 | \r | |
15 | \r | |
59ad461d | 16 | #include "Host.h"\r |
2b59fcd5 | 17 | \r |
18 | #ifndef __APPLE__\r | |
19 | \r | |
20 | #define EMU_SNP_PRIVATE_SIGNATURE SIGNATURE_32('E', 'M', 's', 'n')\r | |
21 | typedef struct {\r | |
22 | UINTN Signature;\r | |
23 | \r | |
24 | EMU_IO_THUNK_PROTOCOL *Thunk;\r | |
25 | \r | |
26 | \r | |
27 | EMU_SNP_PROTOCOL EmuSnp;\r | |
28 | EFI_SIMPLE_NETWORK_MODE *Mode;\r | |
29 | \r | |
30 | } EMU_SNP_PRIVATE;\r | |
31 | \r | |
32 | #define EMU_SNP_PRIVATE_DATA_FROM_THIS(a) \\r | |
33 | CR(a, EMU_SNP_PRIVATE, EmuSnp, EMU_SNP_PRIVATE_SIGNATURE)\r | |
34 | \r | |
35 | /**\r | |
36 | Register storage for SNP Mode.\r | |
37 | \r | |
38 | @param This Protocol instance pointer.\r | |
39 | @param Mode SimpleNetworkProtocol Mode structure passed into driver.\r | |
40 | \r | |
41 | @retval EFI_SUCCESS The network interface was started.\r | |
42 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
43 | \r | |
44 | **/\r | |
45 | EFI_STATUS\r | |
46 | EmuSnpCreateMapping (\r | |
47 | IN EMU_SNP_PROTOCOL *This,\r | |
48 | IN EFI_SIMPLE_NETWORK_MODE *Mode\r | |
49 | )\r | |
50 | {\r | |
51 | EMU_SNP_PRIVATE *Private;\r | |
52 | \r | |
53 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
54 | \r | |
55 | Private->Mode = Mode;\r | |
d18d8a1d | 56 | \r |
2b59fcd5 | 57 | return EFI_SUCCESS;\r |
58 | }\r | |
59 | \r | |
60 | /**\r | |
61 | Changes the state of a network interface from "stopped" to "started".\r | |
62 | \r | |
63 | @param This Protocol instance pointer.\r | |
64 | \r | |
65 | @retval EFI_SUCCESS The network interface was started.\r | |
66 | @retval EFI_ALREADY_STARTED The network interface is already in the started state.\r | |
67 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
68 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
69 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
70 | \r | |
71 | **/\r | |
72 | EFI_STATUS\r | |
73 | EmuSnpStart (\r | |
74 | IN EMU_SNP_PROTOCOL *This\r | |
75 | )\r | |
76 | {\r | |
77 | EMU_SNP_PRIVATE *Private;\r | |
78 | \r | |
79 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
80 | \r | |
81 | return EFI_UNSUPPORTED;\r | |
82 | }\r | |
83 | \r | |
84 | /**\r | |
85 | Changes the state of a network interface from "started" to "stopped".\r | |
86 | \r | |
87 | @param This Protocol instance pointer.\r | |
88 | \r | |
89 | @retval EFI_SUCCESS The network interface was stopped.\r | |
90 | @retval EFI_ALREADY_STARTED The network interface is already in the stopped state.\r | |
91 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
92 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
93 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
94 | \r | |
95 | **/\r | |
96 | EFI_STATUS\r | |
97 | EmuSnpStop (\r | |
98 | IN EMU_SNP_PROTOCOL *This\r | |
99 | )\r | |
100 | {\r | |
101 | EMU_SNP_PRIVATE *Private;\r | |
102 | \r | |
103 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
104 | \r | |
105 | return EFI_UNSUPPORTED;\r | |
106 | }\r | |
107 | \r | |
108 | /**\r | |
d18d8a1d | 109 | Resets a network adapter and allocates the transmit and receive buffers\r |
110 | required by the network interface; optionally, also requests allocation\r | |
2b59fcd5 | 111 | of additional transmit and receive buffers.\r |
112 | \r | |
113 | @param This The protocol instance pointer.\r | |
114 | @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r | |
115 | that the driver should allocate for the network interface.\r | |
116 | Some network interfaces will not be able to use the extra\r | |
117 | buffer, and the caller will not know if it is actually\r | |
118 | being used.\r | |
119 | @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r | |
120 | that the driver should allocate for the network interface.\r | |
121 | Some network interfaces will not be able to use the extra\r | |
122 | buffer, and the caller will not know if it is actually\r | |
123 | being used.\r | |
124 | \r | |
125 | @retval EFI_SUCCESS The network interface was initialized.\r | |
126 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
127 | @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit and\r | |
128 | receive buffers.\r | |
129 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
130 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
131 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
132 | \r | |
133 | **/\r | |
134 | EFI_STATUS\r | |
135 | EmuSnpInitialize (\r | |
136 | IN EMU_SNP_PROTOCOL *This,\r | |
137 | IN UINTN ExtraRxBufferSize OPTIONAL,\r | |
138 | IN UINTN ExtraTxBufferSize OPTIONAL\r | |
139 | )\r | |
140 | {\r | |
141 | EMU_SNP_PRIVATE *Private;\r | |
142 | \r | |
143 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
144 | \r | |
145 | return EFI_UNSUPPORTED;\r | |
146 | }\r | |
147 | \r | |
148 | /**\r | |
d18d8a1d | 149 | Resets a network adapter and re-initializes it with the parameters that were\r |
150 | provided in the previous call to Initialize().\r | |
2b59fcd5 | 151 | \r |
152 | @param This The protocol instance pointer.\r | |
153 | @param ExtendedVerification Indicates that the driver may perform a more\r | |
154 | exhaustive verification operation of the device\r | |
155 | during reset.\r | |
156 | \r | |
157 | @retval EFI_SUCCESS The network interface was reset.\r | |
158 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
159 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
160 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
161 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
162 | \r | |
163 | **/\r | |
164 | EFI_STATUS\r | |
165 | EmuSnpReset (\r | |
166 | IN EMU_SNP_PROTOCOL *This,\r | |
167 | IN BOOLEAN ExtendedVerification\r | |
168 | )\r | |
169 | {\r | |
170 | EMU_SNP_PRIVATE *Private;\r | |
171 | \r | |
172 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
173 | \r | |
174 | return EFI_UNSUPPORTED;\r | |
175 | }\r | |
176 | \r | |
177 | /**\r | |
d18d8a1d | 178 | Resets a network adapter and leaves it in a state that is safe for\r |
2b59fcd5 | 179 | another driver to initialize.\r |
180 | \r | |
181 | @param This Protocol instance pointer.\r | |
182 | \r | |
183 | @retval EFI_SUCCESS The network interface was shutdown.\r | |
184 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
185 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
186 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
187 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
188 | \r | |
189 | **/\r | |
190 | EFI_STATUS\r | |
191 | EmuSnpShutdown (\r | |
192 | IN EMU_SNP_PROTOCOL *This\r | |
193 | )\r | |
194 | {\r | |
195 | EMU_SNP_PRIVATE *Private;\r | |
196 | \r | |
197 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
198 | \r | |
199 | return EFI_UNSUPPORTED;\r | |
200 | }\r | |
201 | \r | |
202 | /**\r | |
203 | Manages the multicast receive filters of a network interface.\r | |
204 | \r | |
205 | @param This The protocol instance pointer.\r | |
206 | @param Enable A bit mask of receive filters to enable on the network interface.\r | |
207 | @param Disable A bit mask of receive filters to disable on the network interface.\r | |
208 | @param ResetMCastFilter Set to TRUE to reset the contents of the multicast receive\r | |
209 | filters on the network interface to their default values.\r | |
210 | @param McastFilterCnt Number of multicast HW MAC addresses in the new\r | |
211 | MCastFilter list. This value must be less than or equal to\r | |
212 | the MCastFilterCnt field of EMU_SNP_MODE. This\r | |
213 | field is optional if ResetMCastFilter is TRUE.\r | |
214 | @param MCastFilter A pointer to a list of new multicast receive filter HW MAC\r | |
215 | addresses. This list will replace any existing multicast\r | |
216 | HW MAC address list. This field is optional if\r | |
217 | ResetMCastFilter is TRUE.\r | |
218 | \r | |
219 | @retval EFI_SUCCESS The multicast receive filter list was updated.\r | |
220 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
221 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
222 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
223 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
224 | \r | |
225 | **/\r | |
226 | EFI_STATUS\r | |
227 | EmuSnpReceiveFilters (\r | |
228 | IN EMU_SNP_PROTOCOL *This,\r | |
229 | IN UINT32 Enable,\r | |
230 | IN UINT32 Disable,\r | |
231 | IN BOOLEAN ResetMCastFilter,\r | |
232 | IN UINTN MCastFilterCnt OPTIONAL,\r | |
233 | IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL\r | |
234 | )\r | |
235 | {\r | |
236 | EMU_SNP_PRIVATE *Private;\r | |
237 | \r | |
238 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
239 | \r | |
240 | return EFI_UNSUPPORTED;\r | |
241 | }\r | |
242 | \r | |
243 | /**\r | |
244 | Modifies or resets the current station address, if supported.\r | |
245 | \r | |
246 | @param This The protocol instance pointer.\r | |
247 | @param Reset Flag used to reset the station address to the network interfaces\r | |
248 | permanent address.\r | |
249 | @param New The new station address to be used for the network interface.\r | |
250 | \r | |
251 | @retval EFI_SUCCESS The network interfaces station address was updated.\r | |
252 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
253 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
254 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
255 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
256 | \r | |
257 | **/\r | |
258 | EFI_STATUS\r | |
259 | EmuSnpStationAddress (\r | |
260 | IN EMU_SNP_PROTOCOL *This,\r | |
261 | IN BOOLEAN Reset,\r | |
262 | IN EFI_MAC_ADDRESS *New OPTIONAL\r | |
263 | )\r | |
264 | {\r | |
265 | EMU_SNP_PRIVATE *Private;\r | |
266 | \r | |
267 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
268 | \r | |
269 | return EFI_UNSUPPORTED;\r | |
270 | }\r | |
271 | \r | |
272 | /**\r | |
273 | Resets or collects the statistics on a network interface.\r | |
274 | \r | |
275 | @param This Protocol instance pointer.\r | |
276 | @param Reset Set to TRUE to reset the statistics for the network interface.\r | |
277 | @param StatisticsSize On input the size, in bytes, of StatisticsTable. On\r | |
278 | output the size, in bytes, of the resulting table of\r | |
279 | statistics.\r | |
280 | @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r | |
281 | contains the statistics.\r | |
282 | \r | |
283 | @retval EFI_SUCCESS The statistics were collected from the network interface.\r | |
284 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
285 | @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r | |
286 | size needed to hold the statistics is returned in\r | |
287 | StatisticsSize.\r | |
288 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
289 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
290 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
291 | \r | |
292 | **/\r | |
293 | EFI_STATUS\r | |
294 | EmuSnpStatistics (\r | |
295 | IN EMU_SNP_PROTOCOL *This,\r | |
296 | IN BOOLEAN Reset,\r | |
297 | IN OUT UINTN *StatisticsSize OPTIONAL,\r | |
298 | OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL\r | |
299 | )\r | |
300 | {\r | |
301 | EMU_SNP_PRIVATE *Private;\r | |
302 | \r | |
303 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
304 | \r | |
305 | return EFI_UNSUPPORTED;\r | |
306 | }\r | |
307 | \r | |
308 | /**\r | |
309 | Converts a multicast IP address to a multicast HW MAC address.\r | |
310 | \r | |
311 | @param This The protocol instance pointer.\r | |
312 | @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r | |
313 | to FALSE if the multicast IP address is IPv4 [RFC 791].\r | |
314 | @param IP The multicast IP address that is to be converted to a multicast\r | |
315 | HW MAC address.\r | |
316 | @param MAC The multicast HW MAC address that is to be generated from IP.\r | |
317 | \r | |
318 | @retval EFI_SUCCESS The multicast IP address was mapped to the multicast\r | |
319 | HW MAC address.\r | |
320 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
321 | @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r | |
322 | size needed to hold the statistics is returned in\r | |
323 | StatisticsSize.\r | |
324 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
325 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
326 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
327 | \r | |
328 | **/\r | |
329 | EFI_STATUS\r | |
330 | EmuSnpMCastIpToMac (\r | |
331 | IN EMU_SNP_PROTOCOL *This,\r | |
332 | IN BOOLEAN IPv6,\r | |
333 | IN EFI_IP_ADDRESS *IP,\r | |
334 | OUT EFI_MAC_ADDRESS *MAC\r | |
335 | )\r | |
336 | {\r | |
337 | EMU_SNP_PRIVATE *Private;\r | |
338 | \r | |
339 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
340 | \r | |
341 | return EFI_UNSUPPORTED;\r | |
342 | }\r | |
343 | \r | |
344 | /**\r | |
d18d8a1d | 345 | Performs read and write operations on the NVRAM device attached to a\r |
2b59fcd5 | 346 | network interface.\r |
347 | \r | |
348 | @param This The protocol instance pointer.\r | |
349 | @param ReadWrite TRUE for read operations, FALSE for write operations.\r | |
350 | @param Offset Byte offset in the NVRAM device at which to start the read or\r | |
351 | write operation. This must be a multiple of NvRamAccessSize and\r | |
352 | less than NvRamSize.\r | |
353 | @param BufferSize The number of bytes to read or write from the NVRAM device.\r | |
354 | This must also be a multiple of NvramAccessSize.\r | |
355 | @param Buffer A pointer to the data buffer.\r | |
356 | \r | |
357 | @retval EFI_SUCCESS The NVRAM access was performed.\r | |
358 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
359 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
360 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
361 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
362 | \r | |
363 | **/\r | |
364 | EFI_STATUS\r | |
365 | EmuSnpNvData (\r | |
366 | IN EMU_SNP_PROTOCOL *This,\r | |
367 | IN BOOLEAN ReadWrite,\r | |
368 | IN UINTN Offset,\r | |
369 | IN UINTN BufferSize,\r | |
370 | IN OUT VOID *Buffer\r | |
371 | )\r | |
372 | {\r | |
373 | EMU_SNP_PRIVATE *Private;\r | |
374 | \r | |
375 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
376 | \r | |
377 | return EFI_UNSUPPORTED;\r | |
378 | }\r | |
379 | \r | |
380 | /**\r | |
d18d8a1d | 381 | Reads the current interrupt status and recycled transmit buffer status from\r |
2b59fcd5 | 382 | a network interface.\r |
383 | \r | |
384 | @param This The protocol instance pointer.\r | |
385 | @param InterruptStatus A pointer to the bit mask of the currently active interrupts\r | |
386 | If this is NULL, the interrupt status will not be read from\r | |
387 | the device. If this is not NULL, the interrupt status will\r | |
388 | be read from the device. When the interrupt status is read,\r | |
389 | it will also be cleared. Clearing the transmit interrupt\r | |
390 | does not empty the recycled transmit buffer array.\r | |
391 | @param TxBuf Recycled transmit buffer address. The network interface will\r | |
392 | not transmit if its internal recycled transmit buffer array\r | |
393 | is full. Reading the transmit buffer does not clear the\r | |
394 | transmit interrupt. If this is NULL, then the transmit buffer\r | |
395 | status will not be read. If there are no transmit buffers to\r | |
396 | recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r | |
397 | \r | |
398 | @retval EFI_SUCCESS The status of the network interface was retrieved.\r | |
399 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
400 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
401 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
402 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
403 | \r | |
404 | **/\r | |
405 | EFI_STATUS\r | |
406 | EmuSnpGetStatus (\r | |
407 | IN EMU_SNP_PROTOCOL *This,\r | |
408 | OUT UINT32 *InterruptStatus OPTIONAL,\r | |
409 | OUT VOID **TxBuf OPTIONAL\r | |
410 | )\r | |
411 | {\r | |
412 | EMU_SNP_PRIVATE *Private;\r | |
413 | \r | |
414 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
415 | \r | |
416 | return EFI_UNSUPPORTED;\r | |
417 | }\r | |
418 | \r | |
419 | /**\r | |
420 | Places a packet in the transmit queue of a network interface.\r | |
421 | \r | |
422 | @param This The protocol instance pointer.\r | |
423 | @param HeaderSize The size, in bytes, of the media header to be filled in by\r | |
424 | the Transmit() function. If HeaderSize is non-zero, then it\r | |
425 | must be equal to This->Mode->MediaHeaderSize and the DestAddr\r | |
426 | and Protocol parameters must not be NULL.\r | |
427 | @param BufferSize The size, in bytes, of the entire packet (media header and\r | |
428 | data) to be transmitted through the network interface.\r | |
429 | @param Buffer A pointer to the packet (media header followed by data) to be\r | |
430 | transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r | |
431 | then the media header in Buffer must already be filled in by the\r | |
432 | caller. If HeaderSize is non-zero, then the media header will be\r | |
433 | filled in by the Transmit() function.\r | |
434 | @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter\r | |
435 | is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r | |
436 | This->Mode->CurrentAddress is used for the source HW MAC address.\r | |
437 | @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this\r | |
438 | parameter is ignored.\r | |
439 | @param Protocol The type of header to build. If HeaderSize is zero, then this\r | |
440 | parameter is ignored. See RFC 1700, section "Ether Types", for\r | |
441 | examples.\r | |
442 | \r | |
443 | @retval EFI_SUCCESS The packet was placed on the transmit queue.\r | |
444 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
d18d8a1d | 445 | @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.\r |
2b59fcd5 | 446 | @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r |
447 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
448 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
449 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
450 | \r | |
451 | **/\r | |
452 | EFI_STATUS\r | |
453 | EmuSnpTransmit (\r | |
454 | IN EMU_SNP_PROTOCOL *This,\r | |
455 | IN UINTN HeaderSize,\r | |
456 | IN UINTN BufferSize,\r | |
457 | IN VOID *Buffer,\r | |
458 | IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,\r | |
459 | IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,\r | |
460 | IN UINT16 *Protocol OPTIONAL\r | |
461 | )\r | |
462 | {\r | |
463 | EMU_SNP_PRIVATE *Private;\r | |
464 | \r | |
465 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
466 | \r | |
467 | return EFI_UNSUPPORTED;\r | |
468 | }\r | |
469 | \r | |
470 | /**\r | |
471 | Receives a packet from a network interface.\r | |
472 | \r | |
473 | @param This The protocol instance pointer.\r | |
474 | @param HeaderSize The size, in bytes, of the media header received on the network\r | |
475 | interface. If this parameter is NULL, then the media header size\r | |
476 | will not be returned.\r | |
477 | @param BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r | |
478 | bytes, of the packet that was received on the network interface.\r | |
479 | @param Buffer A pointer to the data buffer to receive both the media header and\r | |
480 | the data.\r | |
481 | @param SrcAddr The source HW MAC address. If this parameter is NULL, the\r | |
482 | HW MAC source address will not be extracted from the media\r | |
483 | header.\r | |
484 | @param DestAddr The destination HW MAC address. If this parameter is NULL,\r | |
485 | the HW MAC destination address will not be extracted from the\r | |
486 | media header.\r | |
487 | @param Protocol The media header type. If this parameter is NULL, then the\r | |
488 | protocol will not be extracted from the media header. See\r | |
489 | RFC 1700 section "Ether Types" for examples.\r | |
490 | \r | |
491 | @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has\r | |
492 | been updated to the number of bytes received.\r | |
493 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
494 | @retval EFI_NOT_READY The network interface is too busy to accept this transmit\r | |
495 | request.\r | |
496 | @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r | |
497 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r | |
498 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
499 | @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r | |
500 | \r | |
501 | **/\r | |
502 | EFI_STATUS\r | |
503 | EmuSnpReceive (\r | |
504 | IN EMU_SNP_PROTOCOL *This,\r | |
505 | OUT UINTN *HeaderSize OPTIONAL,\r | |
506 | IN OUT UINTN *BufferSize,\r | |
507 | OUT VOID *Buffer,\r | |
508 | OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,\r | |
509 | OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,\r | |
510 | OUT UINT16 *Protocol OPTIONAL\r | |
511 | )\r | |
512 | {\r | |
513 | EMU_SNP_PRIVATE *Private;\r | |
514 | \r | |
515 | Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r | |
516 | \r | |
517 | return EFI_UNSUPPORTED;\r | |
518 | }\r | |
519 | \r | |
520 | \r | |
521 | EMU_SNP_PROTOCOL gEmuSnpProtocol = {\r | |
522 | GasketSnpCreateMapping,\r | |
523 | GasketSnpStart,\r | |
524 | GasketSnpStop,\r | |
525 | GasketSnpInitialize,\r | |
526 | GasketSnpReset,\r | |
527 | GasketSnpShutdown,\r | |
528 | GasketSnpReceiveFilters,\r | |
529 | GasketSnpStationAddress,\r | |
530 | GasketSnpStatistics,\r | |
531 | GasketSnpMCastIpToMac,\r | |
532 | GasketSnpNvData,\r | |
533 | GasketSnpGetStatus,\r | |
534 | GasketSnpTransmit,\r | |
535 | GasketSnpReceive\r | |
536 | };\r | |
537 | \r | |
538 | EFI_STATUS\r | |
539 | EmuSnpThunkOpen (\r | |
540 | IN EMU_IO_THUNK_PROTOCOL *This\r | |
541 | )\r | |
542 | {\r | |
543 | EMU_SNP_PRIVATE *Private;\r | |
d18d8a1d | 544 | \r |
2b59fcd5 | 545 | if (This->Private != NULL) {\r |
546 | return EFI_ALREADY_STARTED;\r | |
547 | }\r | |
d18d8a1d | 548 | \r |
2b59fcd5 | 549 | if (!CompareGuid (This->Protocol, &gEmuSnpProtocolGuid)) {\r |
550 | return EFI_UNSUPPORTED;\r | |
551 | }\r | |
d18d8a1d | 552 | \r |
2b59fcd5 | 553 | Private = malloc (sizeof (EMU_SNP_PRIVATE));\r |
554 | if (Private == NULL) {\r | |
555 | return EFI_OUT_OF_RESOURCES;\r | |
556 | }\r | |
557 | \r | |
d18d8a1d | 558 | \r |
2b59fcd5 | 559 | Private->Signature = EMU_SNP_PRIVATE_SIGNATURE;\r |
560 | Private->Thunk = This;\r | |
561 | CopyMem (&Private->EmuSnp, &gEmuSnpProtocol, sizeof (gEmuSnpProtocol));\r | |
d18d8a1d | 562 | \r |
2b59fcd5 | 563 | This->Interface = &Private->EmuSnp;\r |
564 | This->Private = Private;\r | |
565 | return EFI_SUCCESS;\r | |
566 | }\r | |
567 | \r | |
568 | \r | |
569 | EFI_STATUS\r | |
570 | EmuSnpThunkClose (\r | |
571 | IN EMU_IO_THUNK_PROTOCOL *This\r | |
572 | )\r | |
573 | {\r | |
574 | EMU_SNP_PRIVATE *Private;\r | |
575 | \r | |
576 | if (!CompareGuid (This->Protocol, &gEmuSnpProtocolGuid)) {\r | |
577 | return EFI_UNSUPPORTED;\r | |
578 | }\r | |
d18d8a1d | 579 | \r |
2b59fcd5 | 580 | Private = This->Private;\r |
581 | free (Private);\r | |
d18d8a1d | 582 | \r |
2b59fcd5 | 583 | return EFI_SUCCESS;\r |
584 | }\r | |
585 | \r | |
586 | \r | |
587 | \r | |
588 | EMU_IO_THUNK_PROTOCOL gSnpThunkIo = {\r | |
589 | &gEmuSnpProtocolGuid,\r | |
590 | NULL,\r | |
591 | NULL,\r | |
592 | 0,\r | |
593 | GasketSnpThunkOpen,\r | |
594 | GasketSnpThunkClose,\r | |
595 | NULL\r | |
596 | };\r | |
597 | \r | |
598 | #endif\r |