]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/EmuSnpDxe/EmuSnpDxe.h
EmulatorPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmulatorPkg / EmuSnpDxe / EmuSnpDxe.h
CommitLineData
572287f8 1/** @file\r
2\r
3 Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
4\r
e3ba31da 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
572287f8 6\r
7Module Name:\r
8\r
9 EmuSnp.h\r
10\r
11Abstract:\r
12\r
13-**/\r
14\r
15#ifndef _EMU_SNP_H_\r
16#define _EMU_SNP_H_\r
17\r
18#include <Uefi.h>\r
19\r
20#include <Protocol/SimpleNetwork.h>\r
21#include <Protocol/DevicePath.h>\r
22#include <Protocol/EmuIoThunk.h>\r
23#include <Protocol/EmuSnp.h>\r
24\r
25\r
26#include <Library/BaseLib.h>\r
27#include <Library/DebugLib.h>\r
28#include <Library/BaseMemoryLib.h>\r
29#include <Library/UefiBootServicesTableLib.h>\r
30#include <Library/UefiLib.h>\r
31#include <Library/DevicePathLib.h>\r
32#include <Library/MemoryAllocationLib.h>\r
33#include <Library/NetLib.h>\r
34\r
35#define NET_ETHER_HEADER_SIZE 14\r
36\r
37//\r
38// Private data for driver.\r
39//\r
40#define EMU_SNP_PRIVATE_DATA_SIGNATURE SIGNATURE_32( 'U', 'S', 'N', 'P' )\r
41\r
42typedef struct {\r
43 UINTN Signature;\r
44 EMU_IO_THUNK_PROTOCOL *IoThunk;\r
45 EMU_SNP_PROTOCOL *Io;\r
46 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
47\r
48 EFI_HANDLE EfiHandle;\r
49 EFI_HANDLE DeviceHandle;\r
50\r
51 EFI_SIMPLE_NETWORK_PROTOCOL Snp;\r
52 EFI_SIMPLE_NETWORK_MODE Mode;\r
d18d8a1d 53\r
572287f8 54 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
55\r
56} EMU_SNP_PRIVATE_DATA;\r
57\r
58#define EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS(a) \\r
59 CR( a, EMU_SNP_PRIVATE_DATA, Snp, EMU_SNP_PRIVATE_DATA_SIGNATURE )\r
60\r
61extern EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding;\r
62extern EFI_COMPONENT_NAME_PROTOCOL gEmuSnpDriverComponentName;\r
63extern EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2;\r
64\r
65/**\r
66 Test to see if this driver supports ControllerHandle. This service\r
67 is called by the EFI boot service ConnectController(). In\r
68 order to make drivers as small as possible, there are a few calling\r
69 restrictions for this service. ConnectController() must\r
70 follow these calling restrictions. If any other agent wishes to call\r
71 Supported() it must also follow these calling restrictions.\r
72\r
73 @param This Protocol instance pointer.\r
74 @param ControllerHandle Handle of device to test\r
75 @param RemainingDevicePath Optional parameter use to pick a specific child\r
76 device to start.\r
77\r
78 @retval EFI_SUCCESS This driver supports this device\r
79 @retval EFI_UNSUPPORTED This driver does not support this device\r
80\r
81**/\r
82EFI_STATUS\r
83EFIAPI\r
84EmuSnpDriverBindingSupported (\r
85 IN EFI_DRIVER_BINDING_PROTOCOL * This,\r
86 IN EFI_HANDLE ControllerHandle,\r
87 IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL\r
88 );\r
89\r
90/**\r
91 Start this driver on ControllerHandle. This service is called by the\r
92 EFI boot service ConnectController(). In order to make\r
93 drivers as small as possible, there are a few calling restrictions for\r
94 this service. ConnectController() must follow these\r
95 calling restrictions. If any other agent wishes to call Start() it\r
96 must also follow these calling restrictions.\r
97\r
98 @param This Protocol instance pointer.\r
99 @param ControllerHandle Handle of device to bind driver to\r
100 @param RemainingDevicePath Optional parameter use to pick a specific child\r
101 device to start.\r
102\r
103 @retval EFI_SUCCESS Always succeeds.\r
104\r
105**/\r
106EFI_STATUS\r
107EFIAPI\r
108EmuSnpDriverBindingStart (\r
109 IN EFI_DRIVER_BINDING_PROTOCOL * This,\r
110 IN EFI_HANDLE ControllerHandle,\r
111 IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL\r
112 );\r
113\r
114/**\r
115 Stop this driver on ControllerHandle. This service is called by the\r
116 EFI boot service DisconnectController(). In order to\r
117 make drivers as small as possible, there are a few calling\r
118 restrictions for this service. DisconnectController()\r
119 must follow these calling restrictions. If any other agent wishes\r
120 to call Stop() it must also follow these calling restrictions.\r
d18d8a1d 121\r
572287f8 122 @param This Protocol instance pointer.\r
123 @param ControllerHandle Handle of device to stop driver on\r
124 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
125 children is zero stop the entire bus driver.\r
126 @param ChildHandleBuffer List of Child Handles to Stop.\r
127\r
128 @retval EFI_SUCCESS Always succeeds.\r
129\r
130**/\r
131EFI_STATUS\r
132EFIAPI\r
133EmuSnpDriverBindingStop (\r
134 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
135 IN EFI_HANDLE ControllerHandle,\r
136 IN UINTN NumberOfChildren,\r
137 IN EFI_HANDLE *ChildHandleBuffer\r
138 );\r
139\r
140/**\r
141 Changes the state of a network interface from "stopped" to "started".\r
142\r
143 @param This Protocol instance pointer.\r
144\r
145 @retval EFI_SUCCESS Always succeeds.\r
146\r
147**/\r
148EFI_STATUS\r
149EFIAPI\r
150EmuSnpStart(\r
151 IN EFI_SIMPLE_NETWORK_PROTOCOL* This\r
152 );\r
d18d8a1d 153\r
572287f8 154/**\r
155 Changes the state of a network interface from "started" to "stopped".\r
156\r
157 @param This Protocol instance pointer.\r
158\r
159 @retval EFI_SUCCESS Always succeeds.\r
160\r
161**/\r
162EFI_STATUS\r
163EFIAPI\r
164EmuSnpStop(\r
165 IN EFI_SIMPLE_NETWORK_PROTOCOL* This\r
166 );\r
d18d8a1d 167\r
572287f8 168/**\r
d18d8a1d 169 Resets a network adapter and allocates the transmit and receive buffers\r
170 required by the network interface; optionally, also requests allocation\r
572287f8 171 of additional transmit and receive buffers.\r
172\r
173 @param This Protocol instance pointer.\r
174 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
175 that the driver should allocate for the network interface.\r
176 Some network interfaces will not be able to use the extra\r
177 buffer, and the caller will not know if it is actually\r
178 being used.\r
179 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
180 that the driver should allocate for the network interface.\r
181 Some network interfaces will not be able to use the extra\r
182 buffer, and the caller will not know if it is actually\r
183 being used.\r
184\r
185 @retval EFI_SUCCESS Always succeeds.\r
186\r
187**/\r
188EFI_STATUS\r
189EFIAPI\r
190EmuSnpInitialize(\r
191 IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
192 IN UINTN ExtraRxBufferSize OPTIONAL,\r
193 IN UINTN ExtraTxBufferSize OPTIONAL\r
194 );\r
d18d8a1d 195\r
572287f8 196/**\r
d18d8a1d 197 Resets a network adapter and re-initializes it with the parameters that were\r
198 provided in the previous call to Initialize().\r
572287f8 199\r
200 @param This Protocol instance pointer.\r
201 @param ExtendedVerification Indicates that the driver may perform a more\r
202 exhaustive verification operation of the device\r
203 during reset.\r
204\r
205 @retval EFI_SUCCESS Always succeeds.\r
206\r
207**/\r
208EFI_STATUS\r
209EFIAPI\r
210EmuSnpReset(\r
211 IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
212 IN BOOLEAN ExtendedVerification\r
213 );\r
214\r
215/**\r
d18d8a1d 216 Resets a network adapter and leaves it in a state that is safe for\r
572287f8 217 another driver to initialize.\r
218\r
219 @param This Protocol instance pointer.\r
220\r
221 @retval EFI_SUCCESS Always succeeds.\r
222\r
223**/\r
224EFI_STATUS\r
225EFIAPI\r
226EmuSnpShutdown(\r
227 IN EFI_SIMPLE_NETWORK_PROTOCOL* This\r
228 );\r
229\r
230/**\r
231 Manages the multicast receive filters of a network interface.\r
232\r
233 @param This Protocol instance pointer.\r
234 @param EnableBits A bit mask of receive filters to enable on the network interface.\r
235 @param DisableBits A bit mask of receive filters to disable on the network interface.\r
236 @param ResetMcastFilter Set to TRUE to reset the contents of the multicast receive\r
237 filters on the network interface to their default values.\r
238 @param McastFilterCount Number of multicast HW MAC addresses in the new\r
239 MCastFilter list. This value must be less than or equal to\r
240 the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This\r
241 field is optional if ResetMCastFilter is TRUE.\r
242 @param McastFilter A pointer to a list of new multicast receive filter HW MAC\r
243 addresses. This list will replace any existing multicast\r
244 HW MAC address list. This field is optional if\r
245 ResetMCastFilter is TRUE.\r
246\r
247 @retval EFI_SUCCESS The multicast receive filter list was updated.\r
248 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
249\r
250**/\r
251EFI_STATUS\r
252EFIAPI\r
253EmuSnpReceiveFilters(\r
254 IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
255 IN UINT32 EnableBits,\r
256 IN UINT32 DisableBits,\r
257 IN BOOLEAN ResetMcastFilter,\r
258 IN UINTN McastFilterCount OPTIONAL,\r
259 IN EFI_MAC_ADDRESS* McastFilter OPTIONAL\r
260 );\r
261\r
262/**\r
263 Modifies or resets the current station address, if supported.\r
264\r
265 @param This Protocol instance pointer.\r
266 @param Reset Flag used to reset the station address to the network interfaces\r
267 permanent address.\r
268 @param NewMacAddr New station address to be used for the network interface.\r
269\r
270 @retval EFI_UNSUPPORTED Not supported yet.\r
271\r
272**/\r
273EFI_STATUS\r
274EFIAPI\r
275EmuSnpStationAddress(\r
276 IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
277 IN BOOLEAN Reset,\r
278 IN EFI_MAC_ADDRESS* NewMacAddr OPTIONAL\r
279 );\r
280\r
281/**\r
282 Resets or collects the statistics on a network interface.\r
283\r
284 @param This Protocol instance pointer.\r
285 @param Reset Set to TRUE to reset the statistics for the network interface.\r
286 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On\r
287 output the size, in bytes, of the resulting table of\r
288 statistics.\r
289 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
290 contains the statistics.\r
291\r
292 @retval EFI_SUCCESS The statistics were collected from the network interface.\r
293 @retval EFI_NOT_STARTED The network interface has not been started.\r
294 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r
295 size needed to hold the statistics is returned in\r
296 StatisticsSize.\r
297 @retval EFI_UNSUPPORTED Not supported yet.\r
298\r
299**/\r
300EFI_STATUS\r
301EFIAPI\r
302EmuSnpStatistics(\r
303 IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
304 IN BOOLEAN Reset,\r
305 IN OUT UINTN* StatisticsSize OPTIONAL,\r
306 OUT EFI_NETWORK_STATISTICS* StatisticsTable OPTIONAL\r
307 );\r
d18d8a1d 308\r
572287f8 309/**\r
310 Converts a multicast IP address to a multicast HW MAC address.\r
d18d8a1d 311\r
572287f8 312 @param This Protocol instance pointer.\r
313 @param Ipv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
314 to FALSE if the multicast IP address is IPv4 [RFC 791].\r
315 @param Ip The multicast IP address that is to be converted to a multicast\r
316 HW MAC address.\r
317 @param Mac The multicast HW MAC address that is to be generated from IP.\r
318\r
319 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast\r
320 HW MAC address.\r
321 @retval EFI_NOT_STARTED The network interface has not been started.\r
322 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r
323 size needed to hold the statistics is returned in\r
324 StatisticsSize.\r
325 @retval EFI_UNSUPPORTED Not supported yet.\r
326\r
327**/\r
328EFI_STATUS\r
329EFIAPI\r
330EmuSnpMcastIptoMac(\r
331 IN EFI_SIMPLE_NETWORK_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/**\r
d18d8a1d 338 Performs read and write operations on the NVRAM device attached to a\r
572287f8 339 network interface.\r
340\r
341 @param This Protocol instance pointer.\r
342 @param ReadOrWrite TRUE for read operations, FALSE for write operations.\r
343 @param Offset Byte offset in the NVRAM device at which to start the read or\r
344 write operation. This must be a multiple of NvRamAccessSize and\r
345 less than NvRamSize.\r
346 @param BufferSize The number of bytes to read or write from the NVRAM device.\r
347 This must also be a multiple of NvramAccessSize.\r
348 @param Buffer A pointer to the data buffer.\r
349\r
350 @retval EFI_UNSUPPORTED Not supported yet.\r
351\r
352**/\r
353EFI_STATUS\r
354EFIAPI\r
355EmuSnpNvdata(\r
356 IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
357 IN BOOLEAN ReadOrWrite,\r
358 IN UINTN Offset,\r
359 IN UINTN BufferSize,\r
360 IN OUT VOID* Buffer\r
361 );\r
362\r
363/**\r
d18d8a1d 364 Reads the current interrupt status and recycled transmit buffer status from\r
572287f8 365 a network interface.\r
366\r
367 @param This Protocol instance pointer.\r
368 @param InterruptStatus A pointer to the bit mask of the currently active interrupts\r
369 If this is NULL, the interrupt status will not be read from\r
370 the device. If this is not NULL, the interrupt status will\r
371 be read from the device. When the interrupt status is read,\r
372 it will also be cleared. Clearing the transmit interrupt\r
373 does not empty the recycled transmit buffer array.\r
374 @param TxBuffer Recycled transmit buffer address. The network interface will\r
375 not transmit if its internal recycled transmit buffer array\r
376 is full. Reading the transmit buffer does not clear the\r
377 transmit interrupt. If this is NULL, then the transmit buffer\r
378 status will not be read. If there are no transmit buffers to\r
379 recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
380\r
381 @retval EFI_SUCCESS Always succeeds.\r
382\r
383**/\r
384EFI_STATUS\r
385EFIAPI\r
386EmuSnpGetStatus(\r
387 IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
388 OUT UINT32* InterruptStatus,\r
389 OUT VOID** TxBuffer\r
390 );\r
391\r
392/**\r
393 Places a packet in the transmit queue of a network interface.\r
394\r
395 @param This Protocol instance pointer.\r
396 @param HeaderSize The size, in bytes, of the media header to be filled in by\r
397 the Transmit() function. If HeaderSize is non-zero, then it\r
398 must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
399 and Protocol parameters must not be NULL.\r
400 @param BufferSize The size, in bytes, of the entire packet (media header and\r
401 data) to be transmitted through the network interface.\r
402 @param Buffer A pointer to the packet (media header followed by data) to be\r
403 transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
404 then the media header in Buffer must already be filled in by the\r
405 caller. If HeaderSize is non-zero, then the media header will be\r
406 filled in by the Transmit() function.\r
407 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter\r
408 is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
409 This->Mode->CurrentAddress is used for the source HW MAC address.\r
410 @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this\r
411 parameter is ignored.\r
412 @param Protocol The type of header to build. If HeaderSize is zero, then this\r
413 parameter is ignored. See RFC 1700, section "Ether Types", for\r
414 examples.\r
415\r
416 @retval EFI_SUCCESS The packet was placed on the transmit queue.\r
417 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
418 @retval EFI_ACCESS_DENIED Error acquire global lock for operation.\r
419\r
420**/\r
421EFI_STATUS\r
422EFIAPI\r
423EmuSnpTransmit(\r
424 IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
425 IN UINTN HeaderSize,\r
426 IN UINTN BufferSize,\r
427 IN VOID* Buffer,\r
428 IN EFI_MAC_ADDRESS* SrcAddr OPTIONAL,\r
429 IN EFI_MAC_ADDRESS* DestAddr OPTIONAL,\r
430 IN UINT16* Protocol OPTIONAL\r
431 );\r
432\r
433/**\r
434 Receives a packet from a network interface.\r
435\r
436 @param This Protocol instance pointer.\r
437 @param HeaderSize The size, in bytes, of the media header received on the network\r
438 interface. If this parameter is NULL, then the media header size\r
439 will not be returned.\r
440 @param BuffSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
441 bytes, of the packet that was received on the network interface.\r
442 @param Buffer A pointer to the data buffer to receive both the media header and\r
443 the data.\r
444 @param SourceAddr The source HW MAC address. If this parameter is NULL, the\r
445 HW MAC source address will not be extracted from the media\r
446 header.\r
447 @param DestinationAddr The destination HW MAC address. If this parameter is NULL,\r
448 the HW MAC destination address will not be extracted from the\r
449 media header.\r
450 @param Protocol The media header type. If this parameter is NULL, then the\r
451 protocol will not be extracted from the media header. See\r
452 RFC 1700 section "Ether Types" for examples.\r
453\r
454 @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has\r
455 been updated to the number of bytes received.\r
456 @retval EFI_NOT_READY The network interface is too busy to accept this transmit\r
457 request.\r
458 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r
459 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
460 @retval EFI_ACCESS_DENIED Error acquire global lock for operation.\r
461\r
462**/\r
463EFI_STATUS\r
464EFIAPI\r
465EmuSnpReceive(\r
466 IN EFI_SIMPLE_NETWORK_PROTOCOL* This,\r
467 OUT UINTN* HeaderSize OPTIONAL,\r
468 IN OUT UINTN* BuffSize,\r
469 OUT VOID* Buffer,\r
470 OUT EFI_MAC_ADDRESS* SourceAddr OPTIONAL,\r
471 OUT EFI_MAC_ADDRESS* DestinationAddr OPTIONAL,\r
472 OUT UINT16* Protocol OPTIONAL\r
473 );\r
474\r
475VOID\r
476EFIAPI\r
477EmuSnpWaitForPacketNotify(\r
478 IN EFI_EVENT Event,\r
479 IN VOID* Private\r
480 );\r
481\r
482#endif // _EMU_SNP_H_\r