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