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