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