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