]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/Include/Protocol/EmuSnp.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / EmulatorPkg / Include / Protocol / EmuSnp.h
CommitLineData
572287f8 1/** @file\r
d18d8a1d 2 The EMU_SNP_PROTOCOL provides services to initialize a network interface,\r
572287f8 3 transmit packets, receive packets, and close a network interface.\r
4\r
5\r
6Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
d18d8a1d 7Portitions copyright (c) 2011, Apple Inc. All rights reserved.\r
e3ba31da 8SPDX-License-Identifier: BSD-2-Clause-Patent\r
572287f8 9\r
10**/\r
11\r
12#ifndef __EMU_SNP_H__\r
13#define __EMU_SNP_H__\r
14\r
2b59fcd5 15#include <Protocol/SimpleNetwork.h>\r
16\r
572287f8 17#define EMU_SNP_PROTOCOL_GUID \\r
18 { 0xFD5FBE54, 0x8C35, 0xB345, { 0x8A, 0x0F, 0x7A, 0xC8, 0xA5, 0xFD, 0x05, 0x21 } }\r
19\r
a550d468 20typedef struct _EMU_SNP_PROTOCOL EMU_SNP_PROTOCOL;\r
572287f8 21\r
22/**\r
2b59fcd5 23 Register storage for SNP Mode.\r
572287f8 24\r
25 @param This Protocol instance pointer.\r
26 @param Mode SimpleNetworkProtocol Mode structure passed into driver.\r
27\r
28 @retval EFI_SUCCESS The network interface was started.\r
572287f8 29 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
30\r
31**/\r
32typedef\r
33EFI_STATUS\r
34(EFIAPI *EMU_SNP_CREATE_MAPPING)(\r
35 IN EMU_SNP_PROTOCOL *This,\r
36 IN EFI_SIMPLE_NETWORK_MODE *Mode\r
37 );\r
38\r
572287f8 39/**\r
40 Changes the state of a network interface from "stopped" to "started".\r
41\r
42 @param This Protocol instance pointer.\r
43\r
44 @retval EFI_SUCCESS The network interface was started.\r
45 @retval EFI_ALREADY_STARTED The network interface is already in the started state.\r
46 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
47 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
48 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
49\r
50**/\r
51typedef\r
52EFI_STATUS\r
53(EFIAPI *EMU_SNP_START)(\r
54 IN EMU_SNP_PROTOCOL *This\r
55 );\r
56\r
57/**\r
58 Changes the state of a network interface from "started" to "stopped".\r
59\r
60 @param This Protocol instance pointer.\r
61\r
62 @retval EFI_SUCCESS The network interface was stopped.\r
63 @retval EFI_ALREADY_STARTED The network interface is already in the stopped 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
69typedef\r
70EFI_STATUS\r
71(EFIAPI *EMU_SNP_STOP)(\r
72 IN EMU_SNP_PROTOCOL *This\r
73 );\r
74\r
75/**\r
d18d8a1d 76 Resets a network adapter and allocates the transmit and receive buffers\r
77 required by the network interface; optionally, also requests allocation\r
572287f8 78 of additional transmit and receive buffers.\r
79\r
80 @param This The protocol instance pointer.\r
81 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
82 that the driver should allocate for the network interface.\r
83 Some network interfaces will not be able to use the extra\r
84 buffer, and the caller will not know if it is actually\r
85 being used.\r
86 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
87 that the driver should allocate for the network interface.\r
88 Some network interfaces will not be able to use the extra\r
89 buffer, and the caller will not know if it is actually\r
90 being used.\r
91\r
92 @retval EFI_SUCCESS The network interface was initialized.\r
93 @retval EFI_NOT_STARTED The network interface has not been started.\r
94 @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit and\r
95 receive buffers.\r
96 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
97 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
98 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
99\r
100**/\r
101typedef\r
102EFI_STATUS\r
103(EFIAPI *EMU_SNP_INITIALIZE)(\r
104 IN EMU_SNP_PROTOCOL *This,\r
2b59fcd5 105 IN UINTN ExtraRxBufferSize OPTIONAL,\r
106 IN UINTN ExtraTxBufferSize OPTIONAL\r
572287f8 107 );\r
108\r
109/**\r
d18d8a1d 110 Resets a network adapter and re-initializes it with the parameters that were\r
111 provided in the previous call to Initialize().\r
572287f8 112\r
113 @param This The protocol instance pointer.\r
114 @param ExtendedVerification Indicates that the driver may perform a more\r
115 exhaustive verification operation of the device\r
116 during reset.\r
117\r
118 @retval EFI_SUCCESS The network interface was reset.\r
119 @retval EFI_NOT_STARTED The network interface has not been started.\r
120 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
121 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
122 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
123\r
124**/\r
125typedef\r
126EFI_STATUS\r
127(EFIAPI *EMU_SNP_RESET)(\r
128 IN EMU_SNP_PROTOCOL *This,\r
2b59fcd5 129 IN BOOLEAN ExtendedVerification\r
572287f8 130 );\r
131\r
132/**\r
d18d8a1d 133 Resets a network adapter and leaves it in a state that is safe for\r
572287f8 134 another driver to initialize.\r
135\r
136 @param This Protocol instance pointer.\r
137\r
138 @retval EFI_SUCCESS The network interface was shutdown.\r
139 @retval EFI_NOT_STARTED The network interface has not been started.\r
140 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
141 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
142 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
143\r
144**/\r
145typedef\r
146EFI_STATUS\r
147(EFIAPI *EMU_SNP_SHUTDOWN)(\r
148 IN EMU_SNP_PROTOCOL *This\r
149 );\r
150\r
151/**\r
152 Manages the multicast receive filters of a network interface.\r
153\r
154 @param This The protocol instance pointer.\r
155 @param Enable A bit mask of receive filters to enable on the network interface.\r
156 @param Disable A bit mask of receive filters to disable on the network interface.\r
157 @param ResetMCastFilter Set to TRUE to reset the contents of the multicast receive\r
158 filters on the network interface to their default values.\r
159 @param McastFilterCnt Number of multicast HW MAC addresses in the new\r
160 MCastFilter list. This value must be less than or equal to\r
161 the MCastFilterCnt field of EMU_SNP_MODE. This\r
162 field is optional if ResetMCastFilter is TRUE.\r
163 @param MCastFilter A pointer to a list of new multicast receive filter HW MAC\r
164 addresses. This list will replace any existing multicast\r
165 HW MAC address list. This field is optional if\r
166 ResetMCastFilter is TRUE.\r
167\r
168 @retval EFI_SUCCESS The multicast receive filter list was updated.\r
169 @retval EFI_NOT_STARTED The network interface has not been started.\r
170 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
171 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
172 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
173\r
174**/\r
175typedef\r
176EFI_STATUS\r
177(EFIAPI *EMU_SNP_RECEIVE_FILTERS)(\r
178 IN EMU_SNP_PROTOCOL *This,\r
2b59fcd5 179 IN UINT32 Enable,\r
180 IN UINT32 Disable,\r
181 IN BOOLEAN ResetMCastFilter,\r
182 IN UINTN MCastFilterCnt OPTIONAL,\r
183 IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL\r
572287f8 184 );\r
185\r
186/**\r
187 Modifies or resets the current station address, if supported.\r
188\r
189 @param This The protocol instance pointer.\r
190 @param Reset Flag used to reset the station address to the network interfaces\r
191 permanent address.\r
192 @param New The new station address to be used for the network interface.\r
193\r
194 @retval EFI_SUCCESS The network interfaces station address was updated.\r
195 @retval EFI_NOT_STARTED The network interface has not been started.\r
196 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
197 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
198 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
199\r
200**/\r
201typedef\r
202EFI_STATUS\r
203(EFIAPI *EMU_SNP_STATION_ADDRESS)(\r
204 IN EMU_SNP_PROTOCOL *This,\r
2b59fcd5 205 IN BOOLEAN Reset,\r
206 IN EFI_MAC_ADDRESS *New OPTIONAL\r
572287f8 207 );\r
208\r
209/**\r
210 Resets or collects the statistics on a network interface.\r
211\r
212 @param This Protocol instance pointer.\r
213 @param Reset Set to TRUE to reset the statistics for the network interface.\r
214 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On\r
215 output the size, in bytes, of the resulting table of\r
216 statistics.\r
217 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
218 contains the statistics.\r
219\r
220 @retval EFI_SUCCESS The statistics were collected from the network interface.\r
221 @retval EFI_NOT_STARTED The network interface has not been started.\r
222 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r
223 size needed to hold the statistics is returned in\r
224 StatisticsSize.\r
225 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
226 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
227 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
228\r
229**/\r
230typedef\r
231EFI_STATUS\r
232(EFIAPI *EMU_SNP_STATISTICS)(\r
233 IN EMU_SNP_PROTOCOL *This,\r
234 IN BOOLEAN Reset,\r
235 IN OUT UINTN *StatisticsSize OPTIONAL,\r
236 OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL\r
237 );\r
238\r
239/**\r
240 Converts a multicast IP address to a multicast HW MAC address.\r
241\r
242 @param This The protocol instance pointer.\r
243 @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
244 to FALSE if the multicast IP address is IPv4 [RFC 791].\r
245 @param IP The multicast IP address that is to be converted to a multicast\r
246 HW MAC address.\r
247 @param MAC The multicast HW MAC address that is to be generated from IP.\r
248\r
249 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast\r
250 HW MAC address.\r
251 @retval EFI_NOT_STARTED The network interface has not been started.\r
252 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r
253 size needed to hold the statistics is returned in\r
254 StatisticsSize.\r
255 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
256 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
257 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
258\r
259**/\r
260typedef\r
261EFI_STATUS\r
262(EFIAPI *EMU_SNP_MCAST_IP_TO_MAC)(\r
263 IN EMU_SNP_PROTOCOL *This,\r
264 IN BOOLEAN IPv6,\r
265 IN EFI_IP_ADDRESS *IP,\r
266 OUT EFI_MAC_ADDRESS *MAC\r
267 );\r
268\r
269/**\r
d18d8a1d 270 Performs read and write operations on the NVRAM device attached to a\r
572287f8 271 network interface.\r
272\r
273 @param This The protocol instance pointer.\r
274 @param ReadWrite TRUE for read operations, FALSE for write operations.\r
275 @param Offset Byte offset in the NVRAM device at which to start the read or\r
276 write operation. This must be a multiple of NvRamAccessSize and\r
277 less than NvRamSize.\r
278 @param BufferSize The number of bytes to read or write from the NVRAM device.\r
279 This must also be a multiple of NvramAccessSize.\r
280 @param Buffer A pointer to the data buffer.\r
281\r
282 @retval EFI_SUCCESS The NVRAM access was performed.\r
283 @retval EFI_NOT_STARTED The network interface has not been started.\r
284 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
285 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
286 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
287\r
288**/\r
289typedef\r
290EFI_STATUS\r
291(EFIAPI *EMU_SNP_NVDATA)(\r
292 IN EMU_SNP_PROTOCOL *This,\r
293 IN BOOLEAN ReadWrite,\r
294 IN UINTN Offset,\r
295 IN UINTN BufferSize,\r
296 IN OUT VOID *Buffer\r
297 );\r
298\r
299/**\r
d18d8a1d 300 Reads the current interrupt status and recycled transmit buffer status from\r
572287f8 301 a network interface.\r
302\r
303 @param This The protocol instance pointer.\r
304 @param InterruptStatus A pointer to the bit mask of the currently active interrupts\r
305 If this is NULL, the interrupt status will not be read from\r
306 the device. If this is not NULL, the interrupt status will\r
307 be read from the device. When the interrupt status is read,\r
308 it will also be cleared. Clearing the transmit interrupt\r
309 does not empty the recycled transmit buffer array.\r
310 @param TxBuf Recycled transmit buffer address. The network interface will\r
311 not transmit if its internal recycled transmit buffer array\r
312 is full. Reading the transmit buffer does not clear the\r
313 transmit interrupt. If this is NULL, then the transmit buffer\r
314 status will not be read. If there are no transmit buffers to\r
315 recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
316\r
317 @retval EFI_SUCCESS The status of the network interface was retrieved.\r
318 @retval EFI_NOT_STARTED The network interface has not been started.\r
319 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
320 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
321 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
322\r
323**/\r
324typedef\r
325EFI_STATUS\r
326(EFIAPI *EMU_SNP_GET_STATUS)(\r
327 IN EMU_SNP_PROTOCOL *This,\r
328 OUT UINT32 *InterruptStatus OPTIONAL,\r
329 OUT VOID **TxBuf OPTIONAL\r
330 );\r
331\r
332/**\r
333 Places a packet in the transmit queue of a network interface.\r
334\r
335 @param This The protocol instance pointer.\r
336 @param HeaderSize The size, in bytes, of the media header to be filled in by\r
337 the Transmit() function. If HeaderSize is non-zero, then it\r
338 must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
339 and Protocol parameters must not be NULL.\r
340 @param BufferSize The size, in bytes, of the entire packet (media header and\r
341 data) to be transmitted through the network interface.\r
342 @param Buffer A pointer to the packet (media header followed by data) to be\r
343 transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
344 then the media header in Buffer must already be filled in by the\r
345 caller. If HeaderSize is non-zero, then the media header will be\r
346 filled in by the Transmit() function.\r
347 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter\r
348 is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
349 This->Mode->CurrentAddress is used for the source HW MAC address.\r
350 @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this\r
351 parameter is ignored.\r
352 @param Protocol The type of header to build. If HeaderSize is zero, then this\r
353 parameter is ignored. See RFC 1700, section "Ether Types", for\r
354 examples.\r
355\r
356 @retval EFI_SUCCESS The packet was placed on the transmit queue.\r
357 @retval EFI_NOT_STARTED The network interface has not been started.\r
d18d8a1d 358 @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.\r
572287f8 359 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r
360 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
361 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
362 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
363\r
364**/\r
365typedef\r
366EFI_STATUS\r
367(EFIAPI *EMU_SNP_TRANSMIT)(\r
368 IN EMU_SNP_PROTOCOL *This,\r
369 IN UINTN HeaderSize,\r
370 IN UINTN BufferSize,\r
371 IN VOID *Buffer,\r
372 IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,\r
373 IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,\r
374 IN UINT16 *Protocol OPTIONAL\r
375 );\r
376\r
377/**\r
378 Receives a packet from a network interface.\r
379\r
380 @param This The protocol instance pointer.\r
381 @param HeaderSize The size, in bytes, of the media header received on the network\r
382 interface. If this parameter is NULL, then the media header size\r
383 will not be returned.\r
384 @param BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
385 bytes, of the packet that was received on the network interface.\r
386 @param Buffer A pointer to the data buffer to receive both the media header and\r
387 the data.\r
388 @param SrcAddr The source HW MAC address. If this parameter is NULL, the\r
389 HW MAC source address will not be extracted from the media\r
390 header.\r
391 @param DestAddr The destination HW MAC address. If this parameter is NULL,\r
392 the HW MAC destination address will not be extracted from the\r
393 media header.\r
394 @param Protocol The media header type. If this parameter is NULL, then the\r
395 protocol will not be extracted from the media header. See\r
396 RFC 1700 section "Ether Types" for examples.\r
397\r
398 @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has\r
399 been updated to the number of bytes received.\r
400 @retval EFI_NOT_STARTED The network interface has not been started.\r
401 @retval EFI_NOT_READY The network interface is too busy to accept this transmit\r
402 request.\r
403 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r
404 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
405 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
406 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
407\r
408**/\r
409typedef\r
410EFI_STATUS\r
411(EFIAPI *EMU_SNP_RECEIVE)(\r
412 IN EMU_SNP_PROTOCOL *This,\r
413 OUT UINTN *HeaderSize OPTIONAL,\r
414 IN OUT UINTN *BufferSize,\r
415 OUT VOID *Buffer,\r
416 OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,\r
417 OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,\r
418 OUT UINT16 *Protocol OPTIONAL\r
419 );\r
420\r
421#define EMU_SNP_PROTOCOL_REVISION 0x00010000\r
422\r
423//\r
424// Revision defined in EFI1.1\r
d18d8a1d 425//\r
a550d468 426#define EMU_SNP_INTERFACE_REVISION EMU_SNP_PROTOCOL_REVISION\r
572287f8 427\r
428///\r
d18d8a1d 429/// The EMU_SNP_PROTOCOL protocol abstracts OS network sercices\r
572287f8 430/// from the EFI driver that produces EFI Simple Network Protocol.\r
431///\r
432struct _EMU_SNP_PROTOCOL {\r
a550d468
MK
433 EMU_SNP_CREATE_MAPPING CreateMapping;\r
434 EMU_SNP_START Start;\r
435 EMU_SNP_STOP Stop;\r
436 EMU_SNP_INITIALIZE Initialize;\r
437 EMU_SNP_RESET Reset;\r
438 EMU_SNP_SHUTDOWN Shutdown;\r
439 EMU_SNP_RECEIVE_FILTERS ReceiveFilters;\r
440 EMU_SNP_STATION_ADDRESS StationAddress;\r
441 EMU_SNP_STATISTICS Statistics;\r
442 EMU_SNP_MCAST_IP_TO_MAC MCastIpToMac;\r
443 EMU_SNP_NVDATA NvData;\r
444 EMU_SNP_GET_STATUS GetStatus;\r
445 EMU_SNP_TRANSMIT Transmit;\r
446 EMU_SNP_RECEIVE Receive;\r
572287f8 447};\r
448\r
a550d468 449extern EFI_GUID gEmuSnpProtocolGuid;\r
572287f8 450\r
451#endif\r