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