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