]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/SnpDxe/Snp.h
1. Add EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName() support.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Snp.h
CommitLineData
2883b67e 1/** @file\r
4cda7726 2 Declaration of strctures and functions for SnpDxe driver.\r
2883b67e 3\r
216f7970 4Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 5This program and the accompanying materials are licensed\r
c777c357 6and made available under the terms and conditions of the BSD License which\r
7accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
2883b67e 9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
2883b67e 13**/\r
4cda7726 14#ifndef _SNP_H_\r
15#define _SNP_H_\r
2883b67e 16\r
17\r
f3816027 18#include <Uefi.h>\r
2883b67e 19\r
20#include <Protocol/SimpleNetwork.h>\r
21#include <Protocol/PciIo.h>\r
22#include <Protocol/NetworkInterfaceIdentifier.h>\r
23#include <Protocol/DevicePath.h>\r
24\r
0428a6cb 25#include <Guid/EventGroup.h>\r
26\r
2883b67e 27#include <Library/DebugLib.h>\r
28#include <Library/BaseMemoryLib.h>\r
29#include <Library/UefiDriverEntryPoint.h>\r
30#include <Library/UefiBootServicesTableLib.h>\r
31#include <Library/BaseLib.h>\r
32#include <Library/UefiLib.h>\r
33#include <Library/MemoryAllocationLib.h>\r
216f7970 34#include <Library/PrintLib.h>\r
2883b67e 35\r
2248bd60 36#include <IndustryStandard/Pci.h>\r
2883b67e 37\r
38#define FOUR_GIGABYTES (UINT64) 0x100000000ULL\r
39\r
40\r
f3f2e05d 41#define SNP_DRIVER_SIGNATURE SIGNATURE_32 ('s', 'n', 'd', 's')\r
2883b67e 42#define MAX_MAP_LENGTH 100\r
43\r
44#define PCI_BAR_IO_MASK 0x00000003\r
45#define PCI_BAR_IO_MODE 0x00000001\r
46\r
47#define PCI_BAR_MEM_MASK 0x0000000F\r
48#define PCI_BAR_MEM_MODE 0x00000000\r
49#define PCI_BAR_MEM_64BIT 0x00000004\r
50\r
4cda7726 51typedef\r
52EFI_STATUS\r
9c9f5859 53(EFIAPI *ISSUE_UNDI32_COMMAND) (\r
4cda7726 54 UINT64 Cdb\r
55 );\r
c777c357 56\r
2883b67e 57typedef struct {\r
58 UINT32 Signature;\r
4cda7726 59 EFI_LOCK Lock;\r
2883b67e 60\r
4cda7726 61 EFI_SIMPLE_NETWORK_PROTOCOL Snp;\r
62 EFI_SIMPLE_NETWORK_MODE Mode;\r
2883b67e 63\r
4cda7726 64 EFI_HANDLE DeviceHandle;\r
65 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
2883b67e 66\r
67 //\r
68 // Local instance data needed by SNP driver\r
69 //\r
70 // Pointer to S/W UNDI API entry point\r
71 // This will be NULL for H/W UNDI\r
72 //\r
4cda7726 73 ISSUE_UNDI32_COMMAND IssueUndi32Command;\r
2883b67e 74\r
4cda7726 75 BOOLEAN IsSwUndi;\r
2883b67e 76\r
77 //\r
78 // undi interface number, if one undi manages more nics\r
79 //\r
4cda7726 80 PXE_IFNUM IfNum;\r
2883b67e 81\r
82 //\r
83 // Allocated tx/rx buffer that was passed to UNDI Initialize.\r
84 //\r
4cda7726 85 UINT32 TxRxBufferSize;\r
86 VOID *TxRxBuffer;\r
2883b67e 87 //\r
88 // mappable buffers for receive and fill header for undi3.0\r
89 // these will be used if the user buffers are above 4GB limit (instead of\r
90 // mapping the user buffers)\r
91 //\r
4cda7726 92 UINT8 *ReceiveBufffer;\r
93 VOID *ReceiveBufferUnmap;\r
94 UINT8 *FillHeaderBuffer;\r
95 VOID *FillHeaderBufferUnmap;\r
2883b67e 96\r
4cda7726 97 EFI_PCI_IO_PROTOCOL *PciIo;\r
2883b67e 98 UINT8 IoBarIndex;\r
99 UINT8 MemoryBarIndex;\r
100\r
101 //\r
102 // Buffers for command descriptor block, command parameter block\r
103 // and data block.\r
104 //\r
4cda7726 105 PXE_CDB Cdb;\r
106 VOID *Cpb;\r
2883b67e 107 VOID *CpbUnmap;\r
4cda7726 108 VOID *Db;\r
2883b67e 109\r
110 //\r
111 // UNDI structure, we need to remember the init info for a long time!\r
112 //\r
4cda7726 113 PXE_DB_GET_INIT_INFO InitInfo;\r
2883b67e 114\r
115 VOID *SnpDriverUnmap;\r
116 //\r
117 // when ever we map an address, we must remember it's address and the un-map\r
118 // cookie so that we can unmap later\r
119 //\r
4cda7726 120 struct MAP_LIST {\r
121 EFI_PHYSICAL_ADDRESS VirtualAddress;\r
122 VOID *MapCookie;\r
123 } MapList[MAX_MAP_LENGTH];\r
0428a6cb 124\r
125 EFI_EVENT ExitBootServicesEvent;\r
c777c357 126\r
127 //\r
128 // Whether UNDI support reporting media status from GET_STATUS command,\r
129 // i.e. PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED\r
130 //\r
131 BOOLEAN MediaStatusSupported;\r
4cda7726 132} SNP_DRIVER;\r
2883b67e 133\r
4cda7726 134#define EFI_SIMPLE_NETWORK_DEV_FROM_THIS(a) CR (a, SNP_DRIVER, Snp, SNP_DRIVER_SIGNATURE)\r
2883b67e 135\r
136//\r
137// Global Variables\r
138//\r
216f7970 139extern EFI_DRIVER_BINDING_PROTOCOL gSimpleNetworkDriverBinding;\r
2883b67e 140extern EFI_COMPONENT_NAME_PROTOCOL gSimpleNetworkComponentName;\r
141extern EFI_COMPONENT_NAME2_PROTOCOL gSimpleNetworkComponentName2;\r
142\r
143//\r
144// Virtual to physical mapping for all UNDI 3.0s.\r
145//\r
f6b7393c 146typedef struct _V2P V2P;\r
147\r
148struct _V2P {\r
149 V2P *Next;\r
4cda7726 150 VOID *VirtualAddress;\r
151 UINTN BufferSize;\r
152 EFI_PHYSICAL_ADDRESS PhysicalAddress;\r
153 VOID *Unmap;\r
f6b7393c 154};\r
4cda7726 155\r
156/**\r
157 This routine maps the given CPU address to a Device address. It creates a\r
158 an entry in the map list with the virtual and physical addresses and the\r
159 un map cookie.\r
160\r
161 @param V2p pointer to return a map list node pointer.\r
162 @param Type the direction in which the data flows from the given\r
163 virtual address device->cpu or cpu->device or both\r
164 ways.\r
165 @param VirtualAddress virtual address (or CPU address) to be mapped.\r
166 @param BufferSize size of the buffer to be mapped.\r
167\r
168 @retval EFI_SUCEESS routine has completed the mapping.\r
169 @retval other error as indicated.\r
2883b67e 170\r
4cda7726 171**/\r
2883b67e 172EFI_STATUS\r
4cda7726 173AddV2p (\r
174 V2P **V2p,\r
175 EFI_PCI_IO_PROTOCOL_OPERATION Type,\r
176 VOID *VirtualAddress,\r
177 UINTN BufferSize\r
ed66e1bc 178 );\r
2883b67e 179\r
4cda7726 180/**\r
181 This routine searches the linked list of mapped address nodes (for undi3.0\r
182 interface) to find the node that corresponds to the given virtual address and\r
183 returns a pointer to that node.\r
184\r
185 @param V2p pointer to return a map list node pointer.\r
186 @param VirtualAddress virtual address (or CPU address) to be searched in\r
187 the map list\r
188\r
189 @retval EFI_SUCEESS if a match found!\r
190 @retval Other match not found\r
191\r
192**/\r
2883b67e 193EFI_STATUS\r
4cda7726 194FindV2p (\r
195 V2P **V2p,\r
196 VOID *VirtualAddress\r
ed66e1bc 197 );\r
2883b67e 198\r
4cda7726 199/**\r
200 this routine calls undi to start the interface and changes the snp state.\r
201\r
202 @param Snp pointer to snp driver structure\r
203\r
204 @retval EFI_DEVICE_ERROR UNDI could not be started\r
205 @retval EFI_SUCCESS UNDI is started successfully\r
c777c357 206\r
4cda7726 207**/\r
208EFI_STATUS\r
209PxeStart (\r
210 IN SNP_DRIVER *Snp\r
211 );\r
212\r
213/**\r
214 this routine calls undi to stop the interface and changes the snp state.\r
215\r
216 @param Snp pointer to snp driver structure\r
217\r
218 @retval EFI_INVALID_PARAMETER invalid parameter\r
219 @retval EFI_NOT_STARTED SNP is not started\r
220 @retval EFI_DEVICE_ERROR SNP is not initialized\r
221 @retval EFI_UNSUPPORTED operation unsupported\r
222\r
223**/\r
224EFI_STATUS\r
225PxeStop (\r
226 SNP_DRIVER *Snp\r
227 );\r
228\r
229/**\r
230 this routine calls undi to initialize the interface.\r
231\r
232 @param Snp pointer to snp driver structure\r
233 @param CableDetectFlag Do/don't detect the cable (depending on what undi supports)\r
c777c357 234\r
4cda7726 235 @retval EFI_SUCCESS UNDI is initialized successfully\r
236 @retval EFI_DEVICE_ERROR UNDI could not be initialized\r
c777c357 237 @retval Other other errors\r
4cda7726 238\r
239**/\r
240EFI_STATUS\r
241PxeInit (\r
242 SNP_DRIVER *Snp,\r
243 UINT16 CableDetectFlag\r
244 );\r
c777c357 245\r
4cda7726 246/**\r
247 this routine calls undi to shut down the interface.\r
248\r
249 @param Snp pointer to snp driver structure\r
250\r
251 @retval EFI_SUCCESS UNDI is shut down successfully\r
252 @retval EFI_DEVICE_ERROR UNDI could not be shut down\r
253\r
254**/\r
2883b67e 255EFI_STATUS\r
4cda7726 256PxeShutdown (\r
257 IN SNP_DRIVER *Snp\r
ed66e1bc 258 );\r
2883b67e 259\r
4cda7726 260/**\r
261 this routine calls undi to read the MAC address of the NIC and updates the\r
262 mode structure with the address.\r
263\r
264 @param Snp pointer to snp driver structure.\r
c777c357 265\r
4cda7726 266 @retval EFI_SUCCESS the MAC address of the NIC is read successfully.\r
267 @retval EFI_DEVICE_ERROR failed to read the MAC address of the NIC.\r
268\r
269**/\r
270EFI_STATUS\r
271PxeGetStnAddr (\r
272 SNP_DRIVER *Snp\r
273 );\r
274\r
275/**\r
276 This routine unmaps the given virtual address and frees the memory allocated\r
277 for the map list node corresponding to that address.\r
278\r
279 @param VirtualAddress virtual address (or CPU address) to be unmapped\r
280\r
281 @retval EFI_SUCEESS if successfully unmapped\r
282 @retval Other as indicated by the error\r
283\r
284**/\r
285EFI_STATUS\r
286DelV2p (\r
287 VOID *VirtualAddress\r
288 );\r
289\r
290/**\r
291 This is a callback routine supplied to UNDI at undi_start time.\r
292 UNDI call this routine when it wants to have exclusive access to a critical\r
293 section of the code/data.\r
294\r
295 @param Enable non-zero indicates acquire\r
296 zero indicates release\r
297\r
298**/\r
299VOID\r
9c9f5859 300EFIAPI\r
4cda7726 301SnpUndi32CallbackBlock30 (\r
2883b67e 302 IN UINT32 Enable\r
ed66e1bc 303 );\r
2883b67e 304\r
4cda7726 305/**\r
306 This is a callback routine supplied to UNDI at undi_start time.\r
307 UNDI call this routine with the number of micro seconds when it wants to\r
308 pause.\r
309\r
310 @param MicroSeconds number of micro seconds to pause, ususlly multiple of 10.\r
311\r
312**/\r
313VOID\r
9c9f5859 314EFIAPI\r
4cda7726 315SnpUndi32CallbackDelay30 (\r
2883b67e 316 IN UINT64 MicroSeconds\r
ed66e1bc 317 );\r
2883b67e 318\r
4cda7726 319/**\r
320 This is a callback routine supplied to UNDI at undi_start time.\r
321 This is the IO routine for UNDI. This is not currently being used by UNDI3.0\r
322 because Undi3.0 uses io/mem offsets relative to the beginning of the device\r
323 io/mem address and so it needs to use the PCI_IO_FUNCTION that abstracts the\r
324 start of the device's io/mem addresses. Since SNP cannot retrive the context\r
325 of the undi3.0 interface it cannot use the PCI_IO_FUNCTION that specific for\r
326 that NIC and uses one global IO functions structure, this does not work.\r
327 This however works fine for EFI1.0 Undis because they use absolute addresses\r
328 for io/mem access.\r
329\r
330 @param ReadOrWrite indicates read or write, IO or Memory\r
331 @param NumBytes number of bytes to read or write\r
332 @param Address IO or memory address to read from or write to\r
c777c357 333 @param BufferAddr memory location to read into or that contains the bytes to\r
4cda7726 334 write\r
335\r
336**/\r
337VOID\r
9c9f5859 338EFIAPI\r
4cda7726 339SnpUndi32CallbackMemio30 (\r
2883b67e 340 IN UINT8 ReadOrWrite,\r
341 IN UINT8 NumBytes,\r
4cda7726 342 IN UINT64 Address,\r
343 IN OUT UINT64 BufferAddr\r
ed66e1bc 344 );\r
2883b67e 345\r
4cda7726 346/**\r
347 This is a callback routine supplied to UNDI at undi_start time.\r
c777c357 348 UNDI call this routine with a virtual or CPU address that SNP provided to\r
349 convert it to a physical or device address. Since EFI uses the identical\r
4cda7726 350 mapping, this routine returns the physical address same as the virtual address\r
c777c357 351 for most of the addresses. an address above 4GB cannot generally be used as a\r
352 device address, it needs to be mapped to a lower physical address. This\r
4cda7726 353 routine does not call the map routine itself, but it assumes that the mapping\r
c777c357 354 was done at the time of providing the address to UNDI. This routine just\r
355 looks up the address in a map table (which is the v2p structure chain).\r
356\r
4cda7726 357 @param CpuAddr virtual address of a buffer.\r
358 @param DeviceAddrPtr pointer to the physical address.\r
359 The DeviceAddrPtr will contain 0 in case of any error.\r
360\r
361**/\r
362VOID\r
9c9f5859 363EFIAPI\r
4cda7726 364SnpUndi32CallbackV2p30 (\r
2883b67e 365 IN UINT64 CpuAddr,\r
366 IN OUT UINT64 DeviceAddrPtr\r
ed66e1bc 367 );\r
2883b67e 368\r
4cda7726 369/**\r
370 This is a callback routine supplied to UNDI3.1 at undi_start time.\r
371 UNDI call this routine when it wants to have exclusive access to a critical\r
372 section of the code/data.\r
373 New callbacks for 3.1:\r
374 there won't be a virtual2physical callback for UNDI 3.1 because undi3.1 uses\r
375 the MemMap call to map the required address by itself!\r
376\r
c777c357 377 @param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this to\r
9c9f5859 378 store Undi interface context (Undi does not read or write\r
379 this variable)\r
4cda7726 380 @param Enable non-zero indicates acquire\r
381 zero indicates release\r
382**/\r
383VOID\r
9c9f5859 384EFIAPI\r
4cda7726 385SnpUndi32CallbackBlock (\r
2883b67e 386 IN UINT64 UniqueId,\r
387 IN UINT32 Enable\r
ed66e1bc 388 );\r
2883b67e 389\r
4cda7726 390/**\r
391 This is a callback routine supplied to UNDI at undi_start time.\r
392 UNDI call this routine with the number of micro seconds when it wants to\r
393 pause.\r
394\r
395 @param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this to\r
9c9f5859 396 store Undi interface context (Undi does not read or write\r
397 this variable)\r
4cda7726 398 @param MicroSeconds number of micro seconds to pause, ususlly multiple of 10.\r
399**/\r
400VOID\r
9c9f5859 401EFIAPI\r
4cda7726 402SnpUndi32CallbackDelay (\r
2883b67e 403 IN UINT64 UniqueId,\r
404 IN UINT64 MicroSeconds\r
ed66e1bc 405 );\r
2883b67e 406\r
4cda7726 407/**\r
408 This is a callback routine supplied to UNDI at undi_start time.\r
409 This is the IO routine for UNDI3.1 to start CPB.\r
410\r
c777c357 411 @param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this\r
9c9f5859 412 to store Undi interface context (Undi does not read or\r
413 write this variable)\r
4cda7726 414 @param ReadOrWrite indicates read or write, IO or Memory.\r
415 @param NumBytes number of bytes to read or write.\r
416 @param MemOrPortAddr IO or memory address to read from or write to.\r
417 @param BufferPtr memory location to read into or that contains the bytes\r
418 to write.\r
419**/\r
420VOID\r
9c9f5859 421EFIAPI\r
4cda7726 422SnpUndi32CallbackMemio (\r
2883b67e 423 IN UINT64 UniqueId,\r
424 IN UINT8 ReadOrWrite,\r
425 IN UINT8 NumBytes,\r
426 IN UINT64 MemOrPortAddr,\r
427 IN OUT UINT64 BufferPtr\r
ed66e1bc 428 );\r
2883b67e 429\r
4cda7726 430/**\r
431 This is a callback routine supplied to UNDI at undi_start time.\r
432 UNDI call this routine when it has to map a CPU address to a device\r
433 address.\r
434\r
435 @param UniqueId - This was supplied to UNDI at Undi_Start, SNP uses this to store\r
436 Undi interface context (Undi does not read or write this variable)\r
437 @param CpuAddr - Virtual address to be mapped!\r
438 @param NumBytes - size of memory to be mapped\r
439 @param Direction - direction of data flow for this memory's usage:\r
440 cpu->device, device->cpu or both ways\r
441 @param DeviceAddrPtr - pointer to return the mapped device address\r
442\r
443**/\r
444VOID\r
9c9f5859 445EFIAPI\r
4cda7726 446SnpUndi32CallbackMap (\r
2883b67e 447 IN UINT64 UniqueId,\r
448 IN UINT64 CpuAddr,\r
449 IN UINT32 NumBytes,\r
450 IN UINT32 Direction,\r
451 IN OUT UINT64 DeviceAddrPtr\r
ed66e1bc 452 );\r
2883b67e 453\r
4cda7726 454/**\r
455 This is a callback routine supplied to UNDI at undi_start time.\r
456 UNDI call this routine when it wants to unmap an address that was previously\r
457 mapped using map callback.\r
458\r
459 @param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this to store.\r
460 Undi interface context (Undi does not read or write this variable)\r
461 @param CpuAddr Virtual address that was mapped!\r
462 @param NumBytes size of memory mapped\r
463 @param Direction direction of data flow for this memory's usage:\r
464 cpu->device, device->cpu or both ways\r
465 @param DeviceAddr the mapped device address\r
466\r
467**/\r
468VOID\r
9c9f5859 469EFIAPI\r
4cda7726 470SnpUndi32CallbackUnmap (\r
2883b67e 471 IN UINT64 UniqueId,\r
472 IN UINT64 CpuAddr,\r
473 IN UINT32 NumBytes,\r
474 IN UINT32 Direction,\r
4cda7726 475 IN UINT64 DeviceAddr\r
ed66e1bc 476 );\r
2883b67e 477\r
4cda7726 478/**\r
479 This is a callback routine supplied to UNDI at undi_start time.\r
480 UNDI call this routine when it wants synchronize the virtual buffer contents\r
481 with the mapped buffer contents. The virtual and mapped buffers need not\r
482 correspond to the same physical memory (especially if the virtual address is\r
483 > 4GB). Depending on the direction for which the buffer is mapped, undi will\r
484 need to synchronize their contents whenever it writes to/reads from the buffer\r
485 using either the cpu address or the device address.\r
486\r
487 EFI does not provide a sync call, since virt=physical, we sould just do\r
488 the synchronization ourself here!\r
489\r
490 @param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this to store\r
491 Undi interface context (Undi does not read or write this variable)\r
492 @param CpuAddr Virtual address that was mapped!\r
493 @param NumBytes size of memory mapped.\r
494 @param Direction direction of data flow for this memory's usage:\r
495 cpu->device, device->cpu or both ways.\r
496 @param DeviceAddr the mapped device address.\r
497\r
498**/\r
499VOID\r
9c9f5859 500EFIAPI\r
4cda7726 501SnpUndi32CallbackSync (\r
2883b67e 502 IN UINT64 UniqueId,\r
503 IN UINT64 CpuAddr,\r
504 IN UINT32 NumBytes,\r
505 IN UINT32 Direction,\r
4cda7726 506 IN UINT64 DeviceAddr\r
ed66e1bc 507 );\r
2883b67e 508\r
4cda7726 509/**\r
510 Changes the state of a network interface from "stopped" to "started".\r
c777c357 511\r
4cda7726 512 This function starts a network interface. If the network interface successfully\r
513 starts, then EFI_SUCCESS will be returned.\r
514\r
515 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
516\r
517 @retval EFI_SUCCESS The network interface was started.\r
518 @retval EFI_ALREADY_STARTED The network interface is already in the started state.\r
c777c357 519 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid\r
4cda7726 520 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
521 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
522 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
523\r
524**/\r
525EFI_STATUS\r
2883b67e 526EFIAPI\r
4cda7726 527SnpUndi32Start (\r
528 IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
ed66e1bc 529 );\r
2883b67e 530\r
4cda7726 531/**\r
532 Changes the state of a network interface from "started" to "stopped".\r
c777c357 533\r
4cda7726 534 This function stops a network interface. This call is only valid if the network\r
535 interface is in the started state. If the network interface was successfully\r
536 stopped, then EFI_SUCCESS will be returned.\r
c777c357 537\r
4cda7726 538 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
c777c357 539\r
540\r
4cda7726 541 @retval EFI_SUCCESS The network interface was stopped.\r
542 @retval EFI_NOT_STARTED The network interface has not been started.\r
c777c357 543 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid\r
4cda7726 544 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
545 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
546 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
547\r
548**/\r
549EFI_STATUS\r
2883b67e 550EFIAPI\r
4cda7726 551SnpUndi32Stop (\r
552 IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
ed66e1bc 553 );\r
2883b67e 554\r
4cda7726 555/**\r
c777c357 556 Resets a network adapter and allocates the transmit and receive buffers\r
557 required by the network interface; optionally, also requests allocation of\r
4cda7726 558 additional transmit and receive buffers.\r
559\r
560 This function allocates the transmit and receive buffers required by the network\r
561 interface. If this allocation fails, then EFI_OUT_OF_RESOURCES is returned.\r
562 If the allocation succeeds and the network interface is successfully initialized,\r
563 then EFI_SUCCESS will be returned.\r
564\r
565 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
566\r
567 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
568 that the driver should allocate for the network interface.\r
c777c357 569 Some network interfaces will not be able to use the\r
570 extra buffer, and the caller will not know if it is\r
4cda7726 571 actually being used.\r
572 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
573 that the driver should allocate for the network interface.\r
574 Some network interfaces will not be able to use the\r
575 extra buffer, and the caller will not know if it is\r
576 actually being used.\r
577\r
578 @retval EFI_SUCCESS The network interface was initialized.\r
579 @retval EFI_NOT_STARTED The network interface has not been started.\r
580 @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit and\r
581 receive buffers.\r
582 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid\r
583 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
584 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
585 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.\r
586\r
587**/\r
c777c357 588EFI_STATUS\r
2883b67e 589EFIAPI\r
4cda7726 590SnpUndi32Initialize (\r
591 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
592 IN UINTN ExtraRxBufferSize OPTIONAL,\r
593 IN UINTN ExtraTxBufferSize OPTIONAL\r
ed66e1bc 594 );\r
2883b67e 595\r
4cda7726 596/**\r
597 Resets a network adapter and reinitializes it with the parameters that were\r
598 provided in the previous call to Initialize().\r
599\r
600 This function resets a network adapter and reinitializes it with the parameters\r
c777c357 601 that were provided in the previous call to Initialize(). The transmit and\r
4cda7726 602 receive queues are emptied and all pending interrupts are cleared.\r
c777c357 603 Receive filters, the station address, the statistics, and the multicast-IP-to-HW\r
604 MAC addresses are not reset by this call. If the network interface was\r
605 successfully reset, then EFI_SUCCESS will be returned. If the driver has not\r
4cda7726 606 been initialized, EFI_DEVICE_ERROR will be returned.\r
607\r
608 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
c777c357 609 @param ExtendedVerification Indicates that the driver may perform a more\r
610 exhaustive verification operation of the device\r
4cda7726 611 during reset.\r
612\r
613 @retval EFI_SUCCESS The network interface was reset.\r
614 @retval EFI_NOT_STARTED The network interface has not been started.\r
615 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
616 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
617 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
618\r
619**/\r
620EFI_STATUS\r
2883b67e 621EFIAPI\r
4cda7726 622SnpUndi32Reset (\r
623 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
2883b67e 624 IN BOOLEAN ExtendedVerification\r
ed66e1bc 625 );\r
2883b67e 626\r
4cda7726 627/**\r
c777c357 628 Resets a network adapter and leaves it in a state that is safe for another\r
629 driver to initialize.\r
630\r
4cda7726 631 This function releases the memory buffers assigned in the Initialize() call.\r
632 Pending transmits and receives are lost, and interrupts are cleared and disabled.\r
c777c357 633 After this call, only the Initialize() and Stop() calls may be used. If the\r
4cda7726 634 network interface was successfully shutdown, then EFI_SUCCESS will be returned.\r
635 If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.\r
636\r
637 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
638\r
639 @retval EFI_SUCCESS The network interface was shutdown.\r
640 @retval EFI_NOT_STARTED The network interface has not been started.\r
c777c357 641 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid\r
4cda7726 642 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
643 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
644\r
645**/\r
646EFI_STATUS\r
2883b67e 647EFIAPI\r
4cda7726 648SnpUndi32Shutdown (\r
649 IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
ed66e1bc 650 );\r
2883b67e 651\r
4cda7726 652/**\r
653 Manages the multicast receive filters of a network interface.\r
c777c357 654\r
655 This function is used enable and disable the hardware and software receive\r
4cda7726 656 filters for the underlying network device.\r
c777c357 657 The receive filter change is broken down into three steps:\r
658 * The filter mask bits that are set (ON) in the Enable parameter are added to\r
659 the current receive filter settings.\r
4cda7726 660 * The filter mask bits that are set (ON) in the Disable parameter are subtracted\r
661 from the updated receive filter settings.\r
662 * If the resulting receive filter setting is not supported by the hardware a\r
663 more liberal setting is selected.\r
c777c357 664 If the same bits are set in the Enable and Disable parameters, then the bits\r
4cda7726 665 in the Disable parameter takes precedence.\r
c777c357 666 If the ResetMCastFilter parameter is TRUE, then the multicast address list\r
667 filter is disabled (irregardless of what other multicast bits are set in the\r
668 Enable and Disable parameters). The SNP->Mode->MCastFilterCount field is set\r
4cda7726 669 to zero. The Snp->Mode->MCastFilter contents are undefined.\r
c777c357 670 After enabling or disabling receive filter settings, software should verify\r
671 the new settings by checking the Snp->Mode->ReceiveFilterSettings,\r
4cda7726 672 Snp->Mode->MCastFilterCount and Snp->Mode->MCastFilter fields.\r
c777c357 673 Note: Some network drivers and/or devices will automatically promote receive\r
4cda7726 674 filter settings if the requested setting can not be honored. For example, if\r
c777c357 675 a request for four multicast addresses is made and the underlying hardware\r
676 only supports two multicast addresses the driver might set the promiscuous\r
4cda7726 677 or promiscuous multicast receive filters instead. The receiving software is\r
c777c357 678 responsible for discarding any extra packets that get through the hardware\r
4cda7726 679 receive filters.\r
c777c357 680 Note: Note: To disable all receive filter hardware, the network driver must\r
4cda7726 681 be Shutdown() and Stopped(). Calling ReceiveFilters() with Disable set to\r
c777c357 682 Snp->Mode->ReceiveFilterSettings will make it so no more packets are\r
683 returned by the Receive() function, but the receive hardware may still be\r
4cda7726 684 moving packets into system memory before inspecting and discarding them.\r
c777c357 685 Unexpected system errors, reboots and hangs can occur if an OS is loaded\r
4cda7726 686 and the network devices are not Shutdown() and Stopped().\r
c777c357 687 If ResetMCastFilter is TRUE, then the multicast receive filter list on the\r
4cda7726 688 network interface will be reset to the default multicast receive filter list.\r
c777c357 689 If ResetMCastFilter is FALSE, and this network interface allows the multicast\r
690 receive filter list to be modified, then the MCastFilterCnt and MCastFilter\r
691 are used to update the current multicast receive filter list. The modified\r
692 receive filter list settings can be found in the MCastFilter field of\r
4cda7726 693 EFI_SIMPLE_NETWORK_MODE. If the network interface does not allow the multicast\r
694 receive filter list to be modified, then EFI_INVALID_PARAMETER will be returned.\r
695 If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.\r
c777c357 696 If the receive filter mask and multicast receive filter list have been\r
4cda7726 697 successfully updated on the network interface, EFI_SUCCESS will be returned.\r
698\r
699 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
700 @param Enable A bit mask of receive filters to enable on the network\r
701 interface.\r
702 @param Disable A bit mask of receive filters to disable on the network\r
c777c357 703 interface. For backward compatibility with EFI 1.1\r
4cda7726 704 platforms, the EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST bit\r
705 must be set when the ResetMCastFilter parameter is TRUE.\r
c777c357 706 @param ResetMCastFilter Set to TRUE to reset the contents of the multicast\r
707 receive filters on the network interface to their\r
708 default values.\r
4cda7726 709 @param MCastFilterCnt Number of multicast HW MAC addresses in the new MCastFilter\r
c777c357 710 list. This value must be less than or equal to the\r
711 MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE.\r
4cda7726 712 This field is optional if ResetMCastFilter is TRUE.\r
713 @param MCastFilter A pointer to a list of new multicast receive filter HW\r
c777c357 714 MAC addresses. This list will replace any existing\r
715 multicast HW MAC address list. This field is optional\r
4cda7726 716 if ResetMCastFilter is TRUE.\r
c777c357 717\r
4cda7726 718 @retval EFI_SUCCESS The multicast receive filter list was updated.\r
719 @retval EFI_NOT_STARTED The network interface has not been started.\r
720 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
721 * This is NULL\r
722 * There are bits set in Enable that are not set\r
723 in Snp->Mode->ReceiveFilterMask\r
724 * There are bits set in Disable that are not set\r
725 in Snp->Mode->ReceiveFilterMask\r
c777c357 726 * Multicast is being enabled (the\r
727 EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST bit is\r
728 set in Enable, it is not set in Disable, and\r
4cda7726 729 ResetMCastFilter is FALSE) and MCastFilterCount\r
730 is zero\r
731 * Multicast is being enabled and MCastFilterCount\r
732 is greater than Snp->Mode->MaxMCastFilterCount\r
733 * Multicast is being enabled and MCastFilter is NULL\r
734 * Multicast is being enabled and one or more of\r
735 the addresses in the MCastFilter list are not\r
736 valid multicast MAC addresses\r
737 @retval EFI_DEVICE_ERROR One or more of the following conditions is TRUE:\r
738 * The network interface has been started but has\r
739 not been initialized\r
c777c357 740 * An unexpected error was returned by the\r
4cda7726 741 underlying network driver or device\r
742 @retval EFI_UNSUPPORTED This function is not supported by the network\r
743 interface.\r
744\r
745**/\r
746EFI_STATUS\r
2883b67e 747EFIAPI\r
4cda7726 748SnpUndi32ReceiveFilters (\r
749 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
750 IN UINT32 Enable,\r
751 IN UINT32 Disable,\r
752 IN BOOLEAN ResetMCastFilter,\r
753 IN UINTN MCastFilterCnt, OPTIONAL\r
754 IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL\r
ed66e1bc 755 );\r
2883b67e 756\r
4cda7726 757/**\r
758 Modifies or resets the current station address, if supported.\r
c777c357 759\r
760 This function modifies or resets the current station address of a network\r
4cda7726 761 interface, if supported. If Reset is TRUE, then the current station address is\r
c777c357 762 set to the network interface's permanent address. If Reset is FALSE, and the\r
763 network interface allows its station address to be modified, then the current\r
764 station address is changed to the address specified by New. If the network\r
765 interface does not allow its station address to be modified, then\r
4cda7726 766 EFI_INVALID_PARAMETER will be returned. If the station address is successfully\r
767 updated on the network interface, EFI_SUCCESS will be returned. If the driver\r
768 has not been initialized, EFI_DEVICE_ERROR will be returned.\r
769\r
770 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
c777c357 771 @param Reset Flag used to reset the station address to the network interface's\r
4cda7726 772 permanent address.\r
773 @param New New station address to be used for the network interface.\r
774\r
775\r
776 @retval EFI_SUCCESS The network interface's station address was updated.\r
c777c357 777 @retval EFI_NOT_STARTED The Simple Network Protocol interface has not been\r
4cda7726 778 started by calling Start().\r
779 @retval EFI_INVALID_PARAMETER The New station address was not accepted by the NIC.\r
780 @retval EFI_INVALID_PARAMETER Reset is FALSE and New is NULL.\r
c777c357 781 @retval EFI_DEVICE_ERROR The Simple Network Protocol interface has not\r
4cda7726 782 been initialized by calling Initialize().\r
c777c357 783 @retval EFI_DEVICE_ERROR An error occurred attempting to set the new\r
4cda7726 784 station address.\r
c777c357 785 @retval EFI_UNSUPPORTED The NIC does not support changing the network\r
4cda7726 786 interface's station address.\r
787\r
788**/\r
789EFI_STATUS\r
2883b67e 790EFIAPI\r
4cda7726 791SnpUndi32StationAddress (\r
792 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
793 IN BOOLEAN Reset,\r
794 IN EFI_MAC_ADDRESS *New OPTIONAL\r
ed66e1bc 795 );\r
2883b67e 796\r
4cda7726 797/**\r
798 Resets or collects the statistics on a network interface.\r
c777c357 799\r
4cda7726 800 This function resets or collects the statistics on a network interface. If the\r
801 size of the statistics table specified by StatisticsSize is not big enough for\r
802 all the statistics that are collected by the network interface, then a partial\r
c777c357 803 buffer of statistics is returned in StatisticsTable, StatisticsSize is set to\r
804 the size required to collect all the available statistics, and\r
4cda7726 805 EFI_BUFFER_TOO_SMALL is returned.\r
c777c357 806 If StatisticsSize is big enough for all the statistics, then StatisticsTable\r
807 will be filled, StatisticsSize will be set to the size of the returned\r
4cda7726 808 StatisticsTable structure, and EFI_SUCCESS is returned.\r
809 If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.\r
810 If Reset is FALSE, and both StatisticsSize and StatisticsTable are NULL, then\r
811 no operations will be performed, and EFI_SUCCESS will be returned.\r
812 If Reset is TRUE, then all of the supported statistics counters on this network\r
813 interface will be reset to zero.\r
814\r
815 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
816 @param Reset Set to TRUE to reset the statistics for the network interface.\r
c777c357 817 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On output\r
4cda7726 818 the size, in bytes, of the resulting table of statistics.\r
c777c357 819 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
820 contains the statistics. Type EFI_NETWORK_STATISTICS is\r
821 defined in "Related Definitions" below.\r
822\r
4cda7726 823 @retval EFI_SUCCESS The requested operation succeeded.\r
824 @retval EFI_NOT_STARTED The Simple Network Protocol interface has not been\r
825 started by calling Start().\r
c777c357 826 @retval EFI_BUFFER_TOO_SMALL StatisticsSize is not NULL and StatisticsTable is\r
827 NULL. The current buffer size that is needed to\r
4cda7726 828 hold all the statistics is returned in StatisticsSize.\r
c777c357 829 @retval EFI_BUFFER_TOO_SMALL StatisticsSize is not NULL and StatisticsTable is\r
4cda7726 830 not NULL. The current buffer size that is needed\r
c777c357 831 to hold all the statistics is returned in\r
832 StatisticsSize. A partial set of statistics is\r
4cda7726 833 returned in StatisticsTable.\r
c777c357 834 @retval EFI_INVALID_PARAMETER StatisticsSize is NULL and StatisticsTable is not\r
4cda7726 835 NULL.\r
c777c357 836 @retval EFI_DEVICE_ERROR The Simple Network Protocol interface has not\r
4cda7726 837 been initialized by calling Initialize().\r
c777c357 838 @retval EFI_DEVICE_ERROR An error was encountered collecting statistics\r
4cda7726 839 from the NIC.\r
c777c357 840 @retval EFI_UNSUPPORTED The NIC does not support collecting statistics\r
4cda7726 841 from the network interface.\r
842\r
843**/\r
844EFI_STATUS\r
2883b67e 845EFIAPI\r
4cda7726 846SnpUndi32Statistics (\r
847 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
848 IN BOOLEAN Reset,\r
849 IN OUT UINTN *StatisticsSize, OPTIONAL\r
850 IN OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL\r
ed66e1bc 851 );\r
2883b67e 852\r
4cda7726 853/**\r
854 Converts a multicast IP address to a multicast HW MAC address.\r
c777c357 855\r
856 This function converts a multicast IP address to a multicast HW MAC address\r
4cda7726 857 for all packet transactions. If the mapping is accepted, then EFI_SUCCESS will\r
858 be returned.\r
859\r
860 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
861 @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460].\r
c777c357 862 Set to FALSE if the multicast IP address is IPv4 [RFC 791].\r
863 @param IP The multicast IP address that is to be converted to a multicast\r
4cda7726 864 HW MAC address.\r
865 @param MAC The multicast HW MAC address that is to be generated from IP.\r
c777c357 866\r
4cda7726 867 @retval EFI_SUCCESS The multicast IP address was mapped to the\r
868 multicast HW MAC address.\r
869 @retval EFI_NOT_STARTED The Simple Network Protocol interface has not\r
870 been started by calling Start().\r
871 @retval EFI_INVALID_PARAMETER IP is NULL.\r
872 @retval EFI_INVALID_PARAMETER MAC is NULL.\r
c777c357 873 @retval EFI_INVALID_PARAMETER IP does not point to a valid IPv4 or IPv6\r
4cda7726 874 multicast address.\r
c777c357 875 @retval EFI_DEVICE_ERROR The Simple Network Protocol interface has not\r
4cda7726 876 been initialized by calling Initialize().\r
c777c357 877 @retval EFI_UNSUPPORTED IPv6 is TRUE and the implementation does not\r
4cda7726 878 support IPv6 multicast to MAC address conversion.\r
879\r
880**/\r
881EFI_STATUS\r
2883b67e 882EFIAPI\r
4cda7726 883SnpUndi32McastIpToMac (\r
884 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
2883b67e 885 IN BOOLEAN IPv6,\r
886 IN EFI_IP_ADDRESS *IP,\r
887 OUT EFI_MAC_ADDRESS *MAC\r
ed66e1bc 888 );\r
2883b67e 889\r
4cda7726 890/**\r
c777c357 891 Performs read and write operations on the NVRAM device attached to a network\r
4cda7726 892 interface.\r
c777c357 893\r
894 This function performs read and write operations on the NVRAM device attached\r
4cda7726 895 to a network interface. If ReadWrite is TRUE, a read operation is performed.\r
c777c357 896 If ReadWrite is FALSE, a write operation is performed. Offset specifies the\r
897 byte offset at which to start either operation. Offset must be a multiple of\r
898 NvRamAccessSize , and it must have a value between zero and NvRamSize.\r
4cda7726 899 BufferSize specifies the length of the read or write operation. BufferSize must\r
900 also be a multiple of NvRamAccessSize, and Offset + BufferSize must not exceed\r
c777c357 901 NvRamSize.\r
902 If any of the above conditions is not met, then EFI_INVALID_PARAMETER will be\r
903 returned.\r
904 If all the conditions are met and the operation is "read," the NVRAM device\r
905 attached to the network interface will be read into Buffer and EFI_SUCCESS\r
4cda7726 906 will be returned. If this is a write operation, the contents of Buffer will be\r
c777c357 907 used to update the contents of the NVRAM device attached to the network\r
4cda7726 908 interface and EFI_SUCCESS will be returned.\r
c777c357 909\r
4cda7726 910 It does the basic checking on the input parameters and retrieves snp structure\r
911 and then calls the read_nvdata() call which does the actual reading\r
912\r
913 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
914 @param ReadWrite TRUE for read operations, FALSE for write operations.\r
c777c357 915 @param Offset Byte offset in the NVRAM device at which to start the read or\r
916 write operation. This must be a multiple of NvRamAccessSize\r
917 and less than NvRamSize. (See EFI_SIMPLE_NETWORK_MODE)\r
918 @param BufferSize The number of bytes to read or write from the NVRAM device.\r
4cda7726 919 This must also be a multiple of NvramAccessSize.\r
920 @param Buffer A pointer to the data buffer.\r
921\r
922 @retval EFI_SUCCESS The NVRAM access was performed.\r
923 @retval EFI_NOT_STARTED The network interface has not been started.\r
924 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
c777c357 925 * The This parameter is NULL\r
926 * The This parameter does not point to a valid\r
4cda7726 927 EFI_SIMPLE_NETWORK_PROTOCOL structure\r
c777c357 928 * The Offset parameter is not a multiple of\r
4cda7726 929 EFI_SIMPLE_NETWORK_MODE.NvRamAccessSize\r
c777c357 930 * The Offset parameter is not less than\r
4cda7726 931 EFI_SIMPLE_NETWORK_MODE.NvRamSize\r
c777c357 932 * The BufferSize parameter is not a multiple of\r
4cda7726 933 EFI_SIMPLE_NETWORK_MODE.NvRamAccessSize\r
934 * The Buffer parameter is NULL\r
c777c357 935 @retval EFI_DEVICE_ERROR The command could not be sent to the network\r
4cda7726 936 interface.\r
937 @retval EFI_UNSUPPORTED This function is not supported by the network\r
938 interface.\r
2883b67e 939\r
4cda7726 940**/\r
941EFI_STATUS\r
2883b67e 942EFIAPI\r
4cda7726 943SnpUndi32NvData (\r
944 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
945 IN BOOLEAN ReadWrite,\r
946 IN UINTN Offset,\r
947 IN UINTN BufferSize,\r
948 IN OUT VOID *Buffer\r
ed66e1bc 949 );\r
2883b67e 950\r
4cda7726 951/**\r
952 Reads the current interrupt status and recycled transmit buffer status from a\r
953 network interface.\r
c777c357 954\r
955 This function gets the current interrupt and recycled transmit buffer status\r
4cda7726 956 from the network interface. The interrupt status is returned as a bit mask in\r
957 InterruptStatus. If InterruptStatus is NULL, the interrupt status will not be\r
958 read. If TxBuf is not NULL, a recycled transmit buffer address will be retrieved.\r
959 If a recycled transmit buffer address is returned in TxBuf, then the buffer has\r
960 been successfully transmitted, and the status for that buffer is cleared. If\r
c777c357 961 the status of the network interface is successfully collected, EFI_SUCCESS\r
4cda7726 962 will be returned. If the driver has not been initialized, EFI_DEVICE_ERROR will\r
963 be returned.\r
964\r
965 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
c777c357 966 @param InterruptStatus A pointer to the bit mask of the currently active\r
4cda7726 967 interrupts (see "Related Definitions"). If this is NULL,\r
968 the interrupt status will not be read from the device.\r
969 If this is not NULL, the interrupt status will be read\r
c777c357 970 from the device. When the interrupt status is read, it\r
971 will also be cleared. Clearing the transmit interrupt does\r
4cda7726 972 not empty the recycled transmit buffer array.\r
973 @param TxBuf Recycled transmit buffer address. The network interface\r
c777c357 974 will not transmit if its internal recycled transmit\r
4cda7726 975 buffer array is full. Reading the transmit buffer does\r
976 not clear the transmit interrupt. If this is NULL, then\r
c777c357 977 the transmit buffer status will not be read. If there\r
978 are no transmit buffers to recycle and TxBuf is not NULL,\r
4cda7726 979 TxBuf will be set to NULL.\r
980\r
981 @retval EFI_SUCCESS The status of the network interface was retrieved.\r
982 @retval EFI_NOT_STARTED The network interface has not been started.\r
c777c357 983 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid\r
4cda7726 984 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
c777c357 985 @retval EFI_DEVICE_ERROR The command could not be sent to the network\r
4cda7726 986 interface.\r
987\r
988**/\r
989EFI_STATUS\r
2883b67e 990EFIAPI\r
4cda7726 991SnpUndi32GetStatus (\r
992 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
993 OUT UINT32 *InterruptStatus, OPTIONAL\r
994 OUT VOID **TxBuf OPTIONAL\r
ed66e1bc 995 );\r
2883b67e 996\r
4cda7726 997/**\r
998 Places a packet in the transmit queue of a network interface.\r
c777c357 999\r
4cda7726 1000 This function places the packet specified by Header and Buffer on the transmit\r
c777c357 1001 queue. If HeaderSize is nonzero and HeaderSize is not equal to\r
1002 This->Mode->MediaHeaderSize, then EFI_INVALID_PARAMETER will be returned. If\r
4cda7726 1003 BufferSize is less than This->Mode->MediaHeaderSize, then EFI_BUFFER_TOO_SMALL\r
c777c357 1004 will be returned. If Buffer is NULL, then EFI_INVALID_PARAMETER will be\r
4cda7726 1005 returned. If HeaderSize is nonzero and DestAddr or Protocol is NULL, then\r
1006 EFI_INVALID_PARAMETER will be returned. If the transmit engine of the network\r
c777c357 1007 interface is busy, then EFI_NOT_READY will be returned. If this packet can be\r
1008 accepted by the transmit engine of the network interface, the packet contents\r
1009 specified by Buffer will be placed on the transmit queue of the network\r
1010 interface, and EFI_SUCCESS will be returned. GetStatus() can be used to\r
1011 determine when the packet has actually been transmitted. The contents of the\r
1012 Buffer must not be modified until the packet has actually been transmitted.\r
4cda7726 1013 The Transmit() function performs nonblocking I/O. A caller who wants to perform\r
c777c357 1014 blocking I/O, should call Transmit(), and then GetStatus() until the\r
4cda7726 1015 transmitted buffer shows up in the recycled transmit buffer.\r
1016 If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.\r
1017\r
1018 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
c777c357 1019 @param HeaderSize The size, in bytes, of the media header to be filled in by the\r
4cda7726 1020 Transmit() function. If HeaderSize is nonzero, then it must\r
1021 be equal to This->Mode->MediaHeaderSize and the DestAddr and\r
1022 Protocol parameters must not be NULL.\r
1023 @param BufferSize The size, in bytes, of the entire packet (media header and\r
1024 data) to be transmitted through the network interface.\r
c777c357 1025 @param Buffer A pointer to the packet (media header followed by data) to be\r
1026 transmitted. This parameter cannot be NULL. If HeaderSize is\r
4cda7726 1027 zero, then the media header in Buffer must already be filled\r
c777c357 1028 in by the caller. If HeaderSize is nonzero, then the media\r
4cda7726 1029 header will be filled in by the Transmit() function.\r
c777c357 1030 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this\r
1031 parameter is ignored. If HeaderSize is nonzero and SrcAddr\r
1032 is NULL, then This->Mode->CurrentAddress is used for the\r
4cda7726 1033 source HW MAC address.\r
c777c357 1034 @param DestAddr The destination HW MAC address. If HeaderSize is zero, then\r
4cda7726 1035 this parameter is ignored.\r
c777c357 1036 @param Protocol The type of header to build. If HeaderSize is zero, then this\r
1037 parameter is ignored. See RFC 1700, section "Ether Types,"\r
4cda7726 1038 for examples.\r
1039\r
1040 @retval EFI_SUCCESS The packet was placed on the transmit queue.\r
1041 @retval EFI_NOT_STARTED The network interface has not been started.\r
1042 @retval EFI_NOT_READY The network interface is too busy to accept this\r
1043 transmit request.\r
1044 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r
1045 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported\r
1046 value.\r
1047 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
1048 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
1049\r
1050**/\r
c777c357 1051EFI_STATUS\r
2883b67e 1052EFIAPI\r
4cda7726 1053SnpUndi32Transmit (\r
1054 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
1055 IN UINTN HeaderSize,\r
1056 IN UINTN BufferSize,\r
1057 IN VOID *Buffer,\r
1058 IN EFI_MAC_ADDRESS *SrcAddr, OPTIONAL\r
1059 IN EFI_MAC_ADDRESS *DestAddr, OPTIONAL\r
1060 IN UINT16 *Protocol OPTIONAL\r
ed66e1bc 1061 );\r
2883b67e 1062\r
4cda7726 1063/**\r
1064 Receives a packet from a network interface.\r
1065\r
1066 This function retrieves one packet from the receive queue of a network interface.\r
c777c357 1067 If there are no packets on the receive queue, then EFI_NOT_READY will be\r
4cda7726 1068 returned. If there is a packet on the receive queue, and the size of the packet\r
1069 is smaller than BufferSize, then the contents of the packet will be placed in\r
1070 Buffer, and BufferSize will be updated with the actual size of the packet.\r
1071 In addition, if SrcAddr, DestAddr, and Protocol are not NULL, then these values\r
c777c357 1072 will be extracted from the media header and returned. EFI_SUCCESS will be\r
4cda7726 1073 returned if a packet was successfully received.\r
1074 If BufferSize is smaller than the received packet, then the size of the receive\r
1075 packet will be placed in BufferSize and EFI_BUFFER_TOO_SMALL will be returned.\r
1076 If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.\r
1077\r
1078 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
c777c357 1079 @param HeaderSize The size, in bytes, of the media header received on the network\r
1080 interface. If this parameter is NULL, then the media header size\r
4cda7726 1081 will not be returned.\r
c777c357 1082 @param BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
4cda7726 1083 bytes, of the packet that was received on the network interface.\r
1084 @param Buffer A pointer to the data buffer to receive both the media\r
1085 header and the data.\r
1086 @param SrcAddr The source HW MAC address. If this parameter is NULL, the HW\r
c777c357 1087 MAC source address will not be extracted from the media header.\r
1088 @param DestAddr The destination HW MAC address. If this parameter is NULL,\r
1089 the HW MAC destination address will not be extracted from\r
4cda7726 1090 the media header.\r
c777c357 1091 @param Protocol The media header type. If this parameter is NULL, then the\r
1092 protocol will not be extracted from the media header. See\r
4cda7726 1093 RFC 1700 section "Ether Types" for examples.\r
1094\r
c777c357 1095 @retval EFI_SUCCESS The received data was stored in Buffer, and\r
1096 BufferSize has been updated to the number of\r
4cda7726 1097 bytes received.\r
1098 @retval EFI_NOT_STARTED The network interface has not been started.\r
1099 @retval EFI_NOT_READY No packets have been received on the network interface.\r
c777c357 1100 @retval EFI_BUFFER_TOO_SMALL BufferSize is too small for the received packets.\r
4cda7726 1101 BufferSize has been updated to the required size.\r
1102 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
1103 * The This parameter is NULL\r
c777c357 1104 * The This parameter does not point to a valid\r
4cda7726 1105 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
1106 * The BufferSize parameter is NULL\r
1107 * The Buffer parameter is NULL\r
1108 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
1109\r
1110**/\r
2883b67e 1111EFI_STATUS\r
4cda7726 1112EFIAPI\r
1113SnpUndi32Receive (\r
1114 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
1115 OUT UINTN *HeaderSize OPTIONAL,\r
1116 IN OUT UINTN *BufferSize,\r
1117 OUT VOID *Buffer,\r
1118 OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,\r
1119 OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,\r
1120 OUT UINT16 *Protocol OPTIONAL\r
2883b67e 1121 );\r
1122\r
2883b67e 1123/**\r
4cda7726 1124 Nofication call back function for WaitForPacket event.\r
2883b67e 1125\r
4cda7726 1126 @param Event EFI Event.\r
1127 @param SnpPtr Pointer to SNP_DRIVER structure.\r
2883b67e 1128\r
1129**/\r
4cda7726 1130VOID\r
2883b67e 1131EFIAPI\r
4cda7726 1132SnpWaitForPacketNotify (\r
1133 EFI_EVENT Event,\r
1134 VOID *SnpPtr\r
ed66e1bc 1135 );\r
2883b67e 1136\r
1137#define SNP_MEM_PAGES(x) (((x) - 1) / 4096 + 1)\r
1138\r
1139\r
4cda7726 1140#endif /* _SNP_H_ */\r