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