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