]>
Commit | Line | Data |
---|---|---|
593a8308 | 1 | /** @file\r |
2 | \r | |
d547b32d | 3 | Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r |
8f2a5f80 | 4 | This program and the accompanying materials\r |
593a8308 | 5 | are licensed and made available under the terms and conditions of the BSD License\r |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | SnpNt32.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | -**/\r | |
19 | \r | |
20 | #include "SnpNt32.h"\r | |
21 | \r | |
22 | EFI_DRIVER_BINDING_PROTOCOL gSnpNt32DriverBinding = {\r | |
23 | SnpNt32DriverBindingSupported,\r | |
24 | SnpNt32DriverBindingStart,\r | |
25 | SnpNt32DriverBindingStop,\r | |
26 | 0xa,\r | |
27 | NULL,\r | |
28 | NULL\r | |
29 | };\r | |
30 | \r | |
31 | SNPNT32_GLOBAL_DATA gSnpNt32GlobalData = {\r | |
32 | SNP_NT32_DRIVER_SIGNATURE, // Signature\r | |
33 | {\r | |
34 | NULL,\r | |
35 | NULL\r | |
36 | }, // InstanceList\r | |
37 | NULL, // WinNtThunk\r | |
38 | NULL, // NetworkLibraryHandle\r | |
39 | {\r | |
40 | 0\r | |
41 | }, // NtNetUtilityTable\r | |
42 | {\r | |
43 | 0,\r | |
44 | 0,\r | |
a00ec39b | 45 | EfiLockUninitialized\r |
593a8308 | 46 | }, // Lock\r |
47 | //\r | |
48 | // Private functions\r | |
49 | //\r | |
50 | SnpNt32InitializeGlobalData, // InitializeGlobalData\r | |
51 | SnpNt32InitializeInstanceData, // InitializeInstanceData\r | |
52 | SnpNt32CloseInstance // CloseInstance\r | |
53 | };\r | |
54 | \r | |
531237a5 | 55 | /**\r |
56 | Changes the state of a network interface from "stopped" to "started".\r | |
57 | \r | |
58 | @param This Protocol instance pointer.\r | |
59 | \r | |
60 | @retval EFI_SUCCESS Always succeeds.\r | |
61 | \r | |
62 | **/\r | |
63 | EFI_STATUS\r | |
64 | EFIAPI\r | |
65 | SnpNt32Start (\r | |
66 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r | |
67 | );\r | |
68 | \r | |
69 | /**\r | |
70 | Changes the state of a network interface from "started" to "stopped".\r | |
71 | \r | |
72 | @param This Protocol instance pointer.\r | |
73 | \r | |
74 | @retval EFI_SUCCESS Always succeeds.\r | |
75 | \r | |
76 | **/\r | |
77 | EFI_STATUS\r | |
78 | EFIAPI\r | |
79 | SnpNt32Stop (\r | |
80 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r | |
81 | );\r | |
82 | \r | |
83 | /**\r | |
84 | Resets a network adapter and allocates the transmit and receive buffers \r | |
85 | required by the network interface; optionally, also requests allocation \r | |
86 | of additional transmit and receive buffers.\r | |
87 | \r | |
88 | @param This Protocol instance pointer.\r | |
89 | @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r | |
90 | that the driver should allocate for the network interface.\r | |
91 | Some network interfaces will not be able to use the extra\r | |
92 | buffer, and the caller will not know if it is actually\r | |
93 | being used.\r | |
94 | @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r | |
95 | that the driver should allocate for the network interface.\r | |
96 | Some network interfaces will not be able to use the extra\r | |
97 | buffer, and the caller will not know if it is actually\r | |
98 | being used.\r | |
99 | \r | |
100 | @retval EFI_SUCCESS Always succeeds.\r | |
101 | \r | |
102 | **/\r | |
103 | EFI_STATUS\r | |
104 | EFIAPI\r | |
105 | SnpNt32Initialize (\r | |
106 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
107 | IN UINTN ExtraRxBufferSize OPTIONAL,\r | |
108 | IN UINTN ExtraTxBufferSize OPTIONAL\r | |
109 | );\r | |
110 | \r | |
111 | /**\r | |
112 | Resets a network adapter and re-initializes it with the parameters that were \r | |
113 | provided in the previous call to Initialize(). \r | |
114 | \r | |
115 | @param This Protocol instance pointer.\r | |
116 | @param ExtendedVerification Indicates that the driver may perform a more\r | |
117 | exhaustive verification operation of the device\r | |
118 | during reset.\r | |
119 | \r | |
120 | @retval EFI_SUCCESS Always succeeds.\r | |
121 | \r | |
122 | **/\r | |
123 | EFI_STATUS\r | |
124 | EFIAPI\r | |
125 | SnpNt32Reset (\r | |
126 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
127 | IN BOOLEAN ExtendedVerification\r | |
128 | );\r | |
129 | \r | |
130 | /**\r | |
131 | Resets a network adapter and leaves it in a state that is safe for \r | |
132 | another driver to initialize.\r | |
133 | \r | |
134 | @param This Protocol instance pointer.\r | |
135 | \r | |
136 | @retval EFI_SUCCESS Always succeeds.\r | |
137 | \r | |
138 | **/\r | |
139 | EFI_STATUS\r | |
140 | EFIAPI\r | |
141 | SnpNt32Shutdown (\r | |
142 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r | |
143 | );\r | |
144 | \r | |
145 | /**\r | |
146 | Manages the multicast receive filters of a network interface.\r | |
147 | \r | |
148 | @param This Protocol instance pointer.\r | |
149 | @param EnableBits A bit mask of receive filters to enable on the network interface.\r | |
150 | @param DisableBits A bit mask of receive filters to disable on the network interface.\r | |
151 | @param ResetMcastFilter Set to TRUE to reset the contents of the multicast receive\r | |
152 | filters on the network interface to their default values.\r | |
153 | @param McastFilterCount Number of multicast HW MAC addresses in the new\r | |
154 | MCastFilter list. This value must be less than or equal to\r | |
155 | the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This\r | |
156 | field is optional if ResetMCastFilter is TRUE.\r | |
157 | @param McastFilter A pointer to a list of new multicast receive filter HW MAC\r | |
158 | addresses. This list will replace any existing multicast\r | |
159 | HW MAC address list. This field is optional if\r | |
160 | ResetMCastFilter is TRUE.\r | |
161 | \r | |
162 | @retval EFI_SUCCESS The multicast receive filter list was updated.\r | |
163 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
164 | \r | |
165 | **/\r | |
166 | EFI_STATUS\r | |
167 | EFIAPI\r | |
168 | SnpNt32ReceiveFilters (\r | |
169 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
170 | IN UINT32 EnableBits,\r | |
171 | IN UINT32 DisableBits,\r | |
172 | IN BOOLEAN ResetMcastFilter,\r | |
173 | IN UINTN McastFilterCount OPTIONAL,\r | |
174 | IN EFI_MAC_ADDRESS *McastFilter OPTIONAL\r | |
175 | );\r | |
176 | \r | |
177 | /**\r | |
178 | Modifies or resets the current station address, if supported.\r | |
179 | \r | |
180 | @param This Protocol instance pointer.\r | |
181 | @param Reset Flag used to reset the station address to the network interfaces\r | |
182 | permanent address.\r | |
183 | @param NewMacAddr New station address to be used for the network interface.\r | |
184 | \r | |
185 | @retval EFI_UNSUPPORTED Not supported yet.\r | |
186 | \r | |
187 | **/\r | |
188 | EFI_STATUS\r | |
189 | EFIAPI\r | |
190 | SnpNt32StationAddress (\r | |
191 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
192 | IN BOOLEAN Reset,\r | |
193 | IN EFI_MAC_ADDRESS *NewMacAddr OPTIONAL\r | |
194 | );\r | |
195 | \r | |
196 | /**\r | |
197 | Resets or collects the statistics on a network interface.\r | |
198 | \r | |
199 | @param This Protocol instance pointer.\r | |
200 | @param Reset Set to TRUE to reset the statistics for the network interface.\r | |
201 | @param StatisticsSize On input the size, in bytes, of StatisticsTable. On\r | |
202 | output the size, in bytes, of the resulting table of\r | |
203 | statistics.\r | |
204 | @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r | |
205 | contains the statistics.\r | |
206 | \r | |
207 | @retval EFI_SUCCESS The statistics were collected from the network interface.\r | |
208 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
209 | @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r | |
210 | size needed to hold the statistics is returned in\r | |
211 | StatisticsSize.\r | |
212 | @retval EFI_UNSUPPORTED Not supported yet.\r | |
213 | \r | |
214 | **/\r | |
215 | EFI_STATUS\r | |
216 | EFIAPI\r | |
217 | SnpNt32Statistics (\r | |
218 | IN EFI_SIMPLE_NETWORK_PROTOCOL * This,\r | |
219 | IN BOOLEAN Reset,\r | |
220 | IN OUT UINTN *StatisticsSize OPTIONAL,\r | |
221 | OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL\r | |
222 | );\r | |
223 | \r | |
224 | /**\r | |
225 | Converts a multicast IP address to a multicast HW MAC address.\r | |
226 | \r | |
227 | @param This Protocol instance pointer.\r | |
228 | @param Ipv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r | |
229 | to FALSE if the multicast IP address is IPv4 [RFC 791].\r | |
230 | @param Ip The multicast IP address that is to be converted to a multicast\r | |
231 | HW MAC address.\r | |
232 | @param Mac The multicast HW MAC address that is to be generated from IP.\r | |
233 | \r | |
234 | @retval EFI_SUCCESS The multicast IP address was mapped to the multicast\r | |
235 | HW MAC address.\r | |
236 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
237 | @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r | |
238 | size needed to hold the statistics is returned in\r | |
239 | StatisticsSize.\r | |
240 | @retval EFI_UNSUPPORTED Not supported yet.\r | |
241 | \r | |
242 | **/\r | |
243 | EFI_STATUS\r | |
244 | EFIAPI\r | |
245 | SnpNt32McastIptoMac (\r | |
246 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
247 | IN BOOLEAN Ipv6,\r | |
248 | IN EFI_IP_ADDRESS *Ip,\r | |
249 | OUT EFI_MAC_ADDRESS *Mac\r | |
250 | );\r | |
251 | \r | |
252 | /**\r | |
253 | Performs read and write operations on the NVRAM device attached to a \r | |
254 | network interface.\r | |
255 | \r | |
256 | @param This Protocol instance pointer.\r | |
257 | @param ReadOrWrite TRUE for read operations, FALSE for write operations.\r | |
258 | @param Offset Byte offset in the NVRAM device at which to start the read or\r | |
259 | write operation. This must be a multiple of NvRamAccessSize and\r | |
260 | less than NvRamSize.\r | |
261 | @param BufferSize The number of bytes to read or write from the NVRAM device.\r | |
262 | This must also be a multiple of NvramAccessSize.\r | |
263 | @param Buffer A pointer to the data buffer.\r | |
264 | \r | |
265 | @retval EFI_UNSUPPORTED Not supported yet.\r | |
266 | \r | |
267 | **/\r | |
268 | EFI_STATUS\r | |
269 | EFIAPI\r | |
270 | SnpNt32Nvdata (\r | |
271 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
272 | IN BOOLEAN ReadOrWrite,\r | |
273 | IN UINTN Offset,\r | |
274 | IN UINTN BufferSize,\r | |
275 | IN OUT VOID *Buffer\r | |
276 | );\r | |
277 | \r | |
278 | /**\r | |
279 | Reads the current interrupt status and recycled transmit buffer status from \r | |
280 | a network interface.\r | |
281 | \r | |
282 | @param This Protocol instance pointer.\r | |
283 | @param InterruptStatus A pointer to the bit mask of the currently active interrupts\r | |
284 | If this is NULL, the interrupt status will not be read from\r | |
285 | the device. If this is not NULL, the interrupt status will\r | |
286 | be read from the device. When the interrupt status is read,\r | |
287 | it will also be cleared. Clearing the transmit interrupt\r | |
288 | does not empty the recycled transmit buffer array.\r | |
289 | @param TxBuffer Recycled transmit buffer address. The network interface will\r | |
290 | not transmit if its internal recycled transmit buffer array\r | |
291 | is full. Reading the transmit buffer does not clear the\r | |
292 | transmit interrupt. If this is NULL, then the transmit buffer\r | |
293 | status will not be read. If there are no transmit buffers to\r | |
294 | recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r | |
295 | \r | |
296 | @retval EFI_SUCCESS Always succeeds.\r | |
297 | \r | |
298 | **/\r | |
299 | EFI_STATUS\r | |
300 | EFIAPI\r | |
301 | SnpNt32GetStatus (\r | |
302 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
303 | OUT UINT32 *InterruptStatus,\r | |
304 | OUT VOID **TxBuffer\r | |
305 | );\r | |
306 | \r | |
307 | /**\r | |
308 | Places a packet in the transmit queue of a network interface.\r | |
309 | \r | |
310 | @param This Protocol instance pointer.\r | |
311 | @param HeaderSize The size, in bytes, of the media header to be filled in by\r | |
312 | the Transmit() function. If HeaderSize is non-zero, then it\r | |
313 | must be equal to This->Mode->MediaHeaderSize and the DestAddr\r | |
314 | and Protocol parameters must not be NULL.\r | |
315 | @param BufferSize The size, in bytes, of the entire packet (media header and\r | |
316 | data) to be transmitted through the network interface.\r | |
317 | @param Buffer A pointer to the packet (media header followed by data) to be\r | |
318 | transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r | |
319 | then the media header in Buffer must already be filled in by the\r | |
320 | caller. If HeaderSize is non-zero, then the media header will be\r | |
321 | filled in by the Transmit() function.\r | |
322 | @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter\r | |
323 | is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r | |
324 | This->Mode->CurrentAddress is used for the source HW MAC address.\r | |
325 | @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this\r | |
326 | parameter is ignored.\r | |
327 | @param Protocol The type of header to build. If HeaderSize is zero, then this\r | |
328 | parameter is ignored. See RFC 1700, section "Ether Types", for\r | |
329 | examples.\r | |
330 | \r | |
331 | @retval EFI_SUCCESS The packet was placed on the transmit queue.\r | |
332 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
333 | @retval EFI_ACCESS_DENIED Error acquire global lock for operation.\r | |
334 | \r | |
335 | **/\r | |
336 | EFI_STATUS\r | |
337 | EFIAPI\r | |
338 | SnpNt32Transmit (\r | |
339 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
340 | IN UINTN HeaderSize,\r | |
341 | IN UINTN BufferSize,\r | |
342 | IN VOID *Buffer,\r | |
343 | IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,\r | |
344 | IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,\r | |
345 | IN UINT16 *Protocol OPTIONAL\r | |
346 | );\r | |
347 | \r | |
348 | /**\r | |
349 | Receives a packet from a network interface.\r | |
350 | \r | |
351 | @param This Protocol instance pointer.\r | |
352 | @param HeaderSize The size, in bytes, of the media header received on the network\r | |
353 | interface. If this parameter is NULL, then the media header size\r | |
354 | will not be returned.\r | |
355 | @param BuffSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r | |
356 | bytes, of the packet that was received on the network interface.\r | |
357 | @param Buffer A pointer to the data buffer to receive both the media header and\r | |
358 | the data.\r | |
359 | @param SourceAddr The source HW MAC address. If this parameter is NULL, the\r | |
360 | HW MAC source address will not be extracted from the media\r | |
361 | header.\r | |
362 | @param DestinationAddr The destination HW MAC address. If this parameter is NULL,\r | |
363 | the HW MAC destination address will not be extracted from the\r | |
364 | media header.\r | |
365 | @param Protocol The media header type. If this parameter is NULL, then the\r | |
366 | protocol will not be extracted from the media header. See\r | |
367 | RFC 1700 section "Ether Types" for examples.\r | |
368 | \r | |
369 | @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has\r | |
370 | been updated to the number of bytes received.\r | |
371 | @retval EFI_NOT_READY The network interface is too busy to accept this transmit\r | |
372 | request.\r | |
373 | @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r | |
374 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
375 | @retval EFI_ACCESS_DENIED Error acquire global lock for operation.\r | |
376 | \r | |
377 | **/\r | |
378 | EFI_STATUS\r | |
379 | EFIAPI\r | |
380 | SnpNt32Receive (\r | |
381 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
382 | OUT UINTN *HeaderSize,\r | |
383 | IN OUT UINTN *BuffSize,\r | |
384 | OUT VOID *Buffer,\r | |
385 | OUT EFI_MAC_ADDRESS *SourceAddr,\r | |
386 | OUT EFI_MAC_ADDRESS *DestinationAddr,\r | |
387 | OUT UINT16 *Protocol\r | |
388 | );\r | |
389 | \r | |
390 | SNPNT32_INSTANCE_DATA gSnpNt32InstanceTemplate = {\r | |
391 | SNP_NT32_INSTANCE_SIGNATURE, // Signature\r | |
392 | {\r | |
393 | NULL,\r | |
394 | NULL\r | |
395 | }, // Entry\r | |
d547b32d JW |
396 | NULL, // RecycledTxBuf\r |
397 | 0, // RecycledTxBufCount\r | |
398 | 32, // MaxRecycledTxBuf\r | |
531237a5 | 399 | NULL, // GlobalData\r |
400 | NULL, // DeviceHandle\r | |
401 | NULL, // DevicePath\r | |
402 | { // Snp\r | |
403 | EFI_SIMPLE_NETWORK_PROTOCOL_REVISION, // Revision\r | |
404 | SnpNt32Start, // Start\r | |
405 | SnpNt32Stop, // Stop\r | |
406 | SnpNt32Initialize, // Initialize\r | |
407 | SnpNt32Reset, // Reset\r | |
408 | SnpNt32Shutdown, // Shutdown\r | |
409 | SnpNt32ReceiveFilters, // ReceiveFilters\r | |
410 | SnpNt32StationAddress, // StationAddress\r | |
411 | SnpNt32Statistics, // Statistics\r | |
412 | SnpNt32McastIptoMac, // MCastIpToMac\r | |
413 | SnpNt32Nvdata, // NvData\r | |
414 | SnpNt32GetStatus, // GetStatus\r | |
415 | SnpNt32Transmit, // Transmit\r | |
416 | SnpNt32Receive, // Receive\r | |
417 | NULL, // WaitForPacket\r | |
418 | NULL // Mode\r | |
419 | },\r | |
420 | { // Mode\r | |
421 | EfiSimpleNetworkInitialized, // State\r | |
422 | NET_ETHER_ADDR_LEN, // HwAddressSize\r | |
423 | NET_ETHER_HEADER_SIZE, // MediaHeaderSize\r | |
424 | 1500, // MaxPacketSize\r | |
425 | 0, // NvRamSize\r | |
426 | 0, // NvRamAccessSize\r | |
427 | 0, // ReceiveFilterMask\r | |
428 | 0, // ReceiveFilterSetting\r | |
429 | MAX_MCAST_FILTER_CNT, // MaxMCastFilterCount\r | |
430 | 0, // MCastFilterCount\r | |
431 | {\r | |
432 | 0\r | |
433 | }, // MCastFilter\r | |
434 | {\r | |
435 | 0\r | |
436 | }, // CurrentAddress\r | |
437 | {\r | |
438 | 0\r | |
439 | }, // BroadcastAddress\r | |
440 | {\r | |
441 | 0\r | |
442 | }, // PermanentAddress\r | |
443 | NET_IFTYPE_ETHERNET, // IfType\r | |
444 | FALSE, // MacAddressChangeable\r | |
445 | FALSE, // MultipleTxSupported\r | |
7ee525b2 | 446 | TRUE, // MediaPresentSupported\r |
531237a5 | 447 | TRUE // MediaPresent\r |
448 | },\r | |
449 | {\r | |
450 | 0\r | |
451 | } // InterfaceInfo\r | |
452 | };\r | |
593a8308 | 453 | \r |
454 | /**\r | |
531237a5 | 455 | Test to see if this driver supports ControllerHandle. This service\r |
456 | is called by the EFI boot service ConnectController(). In\r | |
457 | order to make drivers as small as possible, there are a few calling\r | |
458 | restrictions for this service. ConnectController() must\r | |
459 | follow these calling restrictions. If any other agent wishes to call\r | |
460 | Supported() it must also follow these calling restrictions.\r | |
593a8308 | 461 | \r |
531237a5 | 462 | @param This Protocol instance pointer.\r |
463 | @param ControllerHandle Handle of device to test\r | |
464 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
465 | device to start.\r | |
593a8308 | 466 | \r |
531237a5 | 467 | @retval EFI_SUCCESS This driver supports this device\r |
468 | @retval EFI_UNSUPPORTED This driver does not support this device\r | |
593a8308 | 469 | \r |
470 | **/\r | |
471 | EFI_STATUS\r | |
472 | EFIAPI\r | |
473 | SnpNt32DriverBindingSupported (\r | |
474 | IN EFI_DRIVER_BINDING_PROTOCOL * This,\r | |
475 | IN EFI_HANDLE ControllerHandle,\r | |
476 | IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL\r | |
477 | )\r | |
478 | {\r | |
479 | \r | |
480 | SNPNT32_GLOBAL_DATA *GlobalData;\r | |
e90e8777 | 481 | LIST_ENTRY *Entry;\r |
593a8308 | 482 | SNPNT32_INSTANCE_DATA *Instance;\r |
483 | \r | |
484 | GlobalData = &gSnpNt32GlobalData;\r | |
485 | \r | |
486 | NET_LIST_FOR_EACH (Entry, &GlobalData->InstanceList) {\r | |
487 | \r | |
488 | Instance = NET_LIST_USER_STRUCT_S (Entry, SNPNT32_INSTANCE_DATA, Entry, SNP_NT32_INSTANCE_SIGNATURE);\r | |
489 | \r | |
490 | if (Instance->DeviceHandle == ControllerHandle) {\r | |
491 | return EFI_SUCCESS;\r | |
492 | }\r | |
493 | \r | |
494 | }\r | |
495 | \r | |
496 | return EFI_UNSUPPORTED;\r | |
497 | }\r | |
498 | \r | |
499 | \r | |
500 | /**\r | |
531237a5 | 501 | Start this driver on ControllerHandle. This service is called by the\r |
502 | EFI boot service ConnectController(). In order to make\r | |
503 | drivers as small as possible, there are a few calling restrictions for\r | |
504 | this service. ConnectController() must follow these\r | |
505 | calling restrictions. If any other agent wishes to call Start() it\r | |
506 | must also follow these calling restrictions.\r | |
593a8308 | 507 | \r |
531237a5 | 508 | @param This Protocol instance pointer.\r |
509 | @param ControllerHandle Handle of device to bind driver to\r | |
510 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
511 | device to start.\r | |
593a8308 | 512 | \r |
531237a5 | 513 | @retval EFI_SUCCESS Always succeeds.\r |
593a8308 | 514 | \r |
515 | **/\r | |
516 | EFI_STATUS\r | |
517 | EFIAPI\r | |
518 | SnpNt32DriverBindingStart (\r | |
519 | IN EFI_DRIVER_BINDING_PROTOCOL * This,\r | |
520 | IN EFI_HANDLE ControllerHandle,\r | |
521 | IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL\r | |
522 | )\r | |
523 | {\r | |
524 | return EFI_SUCCESS;\r | |
525 | }\r | |
526 | \r | |
593a8308 | 527 | /**\r |
531237a5 | 528 | Stop this driver on ControllerHandle. This service is called by the\r |
529 | EFI boot service DisconnectController(). In order to\r | |
530 | make drivers as small as possible, there are a few calling\r | |
531 | restrictions for this service. DisconnectController()\r | |
532 | must follow these calling restrictions. If any other agent wishes\r | |
533 | to call Stop() it must also follow these calling restrictions.\r | |
534 | \r | |
535 | @param This Protocol instance pointer.\r | |
536 | @param ControllerHandle Handle of device to stop driver on\r | |
537 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
538 | children is zero stop the entire bus driver.\r | |
539 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
540 | \r | |
541 | @retval EFI_SUCCESS Always succeeds.\r | |
593a8308 | 542 | \r |
543 | **/\r | |
544 | EFI_STATUS\r | |
545 | EFIAPI\r | |
546 | SnpNt32DriverBindingStop (\r | |
547 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
548 | IN EFI_HANDLE ControllerHandle,\r | |
549 | IN UINTN NumberOfChildren,\r | |
550 | IN EFI_HANDLE *ChildHandleBuffer\r | |
551 | )\r | |
552 | {\r | |
593a8308 | 553 | return EFI_SUCCESS;\r |
554 | }\r | |
555 | \r | |
556 | \r | |
557 | /**\r | |
531237a5 | 558 | Changes the state of a network interface from "stopped" to "started".\r |
593a8308 | 559 | \r |
531237a5 | 560 | @param This Protocol instance pointer.\r |
593a8308 | 561 | \r |
531237a5 | 562 | @retval EFI_SUCCESS Always succeeds.\r |
593a8308 | 563 | \r |
564 | **/\r | |
565 | EFI_STATUS\r | |
531237a5 | 566 | EFIAPI\r |
593a8308 | 567 | SnpNt32Start (\r |
568 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r | |
569 | )\r | |
570 | {\r | |
571 | return EFI_SUCCESS;\r | |
572 | }\r | |
573 | \r | |
574 | \r | |
575 | /**\r | |
531237a5 | 576 | Changes the state of a network interface from "started" to "stopped".\r |
593a8308 | 577 | \r |
531237a5 | 578 | @param This Protocol instance pointer.\r |
593a8308 | 579 | \r |
531237a5 | 580 | @retval EFI_SUCCESS Always succeeds.\r |
593a8308 | 581 | \r |
582 | **/\r | |
583 | EFI_STATUS\r | |
531237a5 | 584 | EFIAPI\r |
593a8308 | 585 | SnpNt32Stop (\r |
586 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r | |
587 | )\r | |
588 | {\r | |
589 | return EFI_SUCCESS;\r | |
590 | }\r | |
591 | \r | |
593a8308 | 592 | /**\r |
531237a5 | 593 | Resets a network adapter and allocates the transmit and receive buffers \r |
594 | required by the network interface; optionally, also requests allocation \r | |
595 | of additional transmit and receive buffers.\r | |
596 | \r | |
597 | @param This Protocol instance pointer.\r | |
598 | @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r | |
599 | that the driver should allocate for the network interface.\r | |
600 | Some network interfaces will not be able to use the extra\r | |
601 | buffer, and the caller will not know if it is actually\r | |
602 | being used.\r | |
603 | @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r | |
604 | that the driver should allocate for the network interface.\r | |
605 | Some network interfaces will not be able to use the extra\r | |
606 | buffer, and the caller will not know if it is actually\r | |
607 | being used.\r | |
608 | \r | |
609 | @retval EFI_SUCCESS Always succeeds.\r | |
593a8308 | 610 | \r |
611 | **/\r | |
612 | EFI_STATUS\r | |
531237a5 | 613 | EFIAPI\r |
593a8308 | 614 | SnpNt32Initialize (\r |
615 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
616 | IN UINTN ExtraRxBufferSize OPTIONAL,\r | |
617 | IN UINTN ExtraTxBufferSize OPTIONAL\r | |
618 | )\r | |
619 | {\r | |
620 | return EFI_SUCCESS;\r | |
621 | }\r | |
622 | \r | |
593a8308 | 623 | /**\r |
531237a5 | 624 | Resets a network adapter and re-initializes it with the parameters that were \r |
625 | provided in the previous call to Initialize(). \r | |
593a8308 | 626 | \r |
531237a5 | 627 | @param This Protocol instance pointer.\r |
628 | @param ExtendedVerification Indicates that the driver may perform a more\r | |
629 | exhaustive verification operation of the device\r | |
630 | during reset.\r | |
593a8308 | 631 | \r |
531237a5 | 632 | @retval EFI_SUCCESS Always succeeds.\r |
593a8308 | 633 | \r |
634 | **/\r | |
635 | EFI_STATUS\r | |
531237a5 | 636 | EFIAPI\r |
593a8308 | 637 | SnpNt32Reset (\r |
638 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
639 | IN BOOLEAN ExtendedVerification\r | |
640 | )\r | |
641 | {\r | |
642 | return EFI_SUCCESS;\r | |
643 | }\r | |
644 | \r | |
593a8308 | 645 | /**\r |
531237a5 | 646 | Resets a network adapter and leaves it in a state that is safe for \r |
647 | another driver to initialize.\r | |
593a8308 | 648 | \r |
531237a5 | 649 | @param This Protocol instance pointer.\r |
593a8308 | 650 | \r |
531237a5 | 651 | @retval EFI_SUCCESS Always succeeds.\r |
593a8308 | 652 | \r |
653 | **/\r | |
654 | EFI_STATUS\r | |
531237a5 | 655 | EFIAPI\r |
593a8308 | 656 | SnpNt32Shutdown (\r |
657 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r | |
658 | )\r | |
659 | {\r | |
660 | return EFI_SUCCESS;\r | |
661 | }\r | |
662 | \r | |
593a8308 | 663 | /**\r |
531237a5 | 664 | Manages the multicast receive filters of a network interface.\r |
665 | \r | |
666 | @param This Protocol instance pointer.\r | |
667 | @param EnableBits A bit mask of receive filters to enable on the network interface.\r | |
668 | @param DisableBits A bit mask of receive filters to disable on the network interface.\r | |
669 | @param ResetMcastFilter Set to TRUE to reset the contents of the multicast receive\r | |
670 | filters on the network interface to their default values.\r | |
671 | @param McastFilterCount Number of multicast HW MAC addresses in the new\r | |
672 | MCastFilter list. This value must be less than or equal to\r | |
673 | the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This\r | |
674 | field is optional if ResetMCastFilter is TRUE.\r | |
675 | @param McastFilter A pointer to a list of new multicast receive filter HW MAC\r | |
676 | addresses. This list will replace any existing multicast\r | |
677 | HW MAC address list. This field is optional if\r | |
678 | ResetMCastFilter is TRUE.\r | |
679 | \r | |
680 | @retval EFI_SUCCESS The multicast receive filter list was updated.\r | |
681 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
593a8308 | 682 | \r |
683 | **/\r | |
684 | EFI_STATUS\r | |
531237a5 | 685 | EFIAPI\r |
593a8308 | 686 | SnpNt32ReceiveFilters (\r |
687 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
688 | IN UINT32 EnableBits,\r | |
689 | IN UINT32 DisableBits,\r | |
690 | IN BOOLEAN ResetMcastFilter,\r | |
691 | IN UINTN McastFilterCount OPTIONAL,\r | |
531237a5 | 692 | IN EFI_MAC_ADDRESS *McastFilter OPTIONAL\r |
593a8308 | 693 | )\r |
694 | {\r | |
695 | SNPNT32_INSTANCE_DATA *Instance;\r | |
696 | SNPNT32_GLOBAL_DATA *GlobalData;\r | |
697 | INT32 ReturnValue;\r | |
698 | \r | |
699 | Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);\r | |
700 | \r | |
701 | GlobalData = Instance->GlobalData;\r | |
702 | \r | |
e90e8777 | 703 | if (EFI_ERROR (EfiAcquireLockOrFail (&GlobalData->Lock))) {\r |
593a8308 | 704 | return EFI_ACCESS_DENIED;\r |
705 | }\r | |
706 | \r | |
707 | ReturnValue = GlobalData->NtNetUtilityTable.SetReceiveFilter (\r | |
708 | Instance->InterfaceInfo.InterfaceIndex,\r | |
709 | EnableBits,\r | |
f66a43b2 | 710 | (UINT32)McastFilterCount,\r |
593a8308 | 711 | McastFilter\r |
712 | );\r | |
713 | \r | |
e90e8777 | 714 | EfiReleaseLock (&GlobalData->Lock);\r |
593a8308 | 715 | \r |
716 | if (ReturnValue <= 0) {\r | |
717 | return EFI_DEVICE_ERROR;\r | |
718 | }\r | |
719 | \r | |
720 | return EFI_SUCCESS;\r | |
721 | }\r | |
722 | \r | |
593a8308 | 723 | /**\r |
531237a5 | 724 | Modifies or resets the current station address, if supported.\r |
593a8308 | 725 | \r |
531237a5 | 726 | @param This Protocol instance pointer.\r |
727 | @param Reset Flag used to reset the station address to the network interfaces\r | |
728 | permanent address.\r | |
729 | @param NewMacAddr New station address to be used for the network interface.\r | |
593a8308 | 730 | \r |
731 | @retval EFI_UNSUPPORTED Not supported yet.\r | |
732 | \r | |
733 | **/\r | |
734 | EFI_STATUS\r | |
531237a5 | 735 | EFIAPI\r |
593a8308 | 736 | SnpNt32StationAddress (\r |
737 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
738 | IN BOOLEAN Reset,\r | |
739 | IN EFI_MAC_ADDRESS *NewMacAddr OPTIONAL\r | |
740 | )\r | |
741 | {\r | |
742 | return EFI_UNSUPPORTED;\r | |
743 | }\r | |
744 | \r | |
593a8308 | 745 | /**\r |
531237a5 | 746 | Resets or collects the statistics on a network interface.\r |
747 | \r | |
748 | @param This Protocol instance pointer.\r | |
749 | @param Reset Set to TRUE to reset the statistics for the network interface.\r | |
750 | @param StatisticsSize On input the size, in bytes, of StatisticsTable. On\r | |
751 | output the size, in bytes, of the resulting table of\r | |
752 | statistics.\r | |
753 | @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r | |
754 | contains the statistics.\r | |
755 | \r | |
756 | @retval EFI_SUCCESS The statistics were collected from the network interface.\r | |
757 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
758 | @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r | |
759 | size needed to hold the statistics is returned in\r | |
760 | StatisticsSize.\r | |
593a8308 | 761 | @retval EFI_UNSUPPORTED Not supported yet.\r |
762 | \r | |
763 | **/\r | |
764 | EFI_STATUS\r | |
531237a5 | 765 | EFIAPI\r |
593a8308 | 766 | SnpNt32Statistics (\r |
767 | IN EFI_SIMPLE_NETWORK_PROTOCOL * This,\r | |
768 | IN BOOLEAN Reset,\r | |
769 | IN OUT UINTN *StatisticsSize OPTIONAL,\r | |
531237a5 | 770 | OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL\r |
593a8308 | 771 | )\r |
772 | {\r | |
773 | return EFI_UNSUPPORTED;\r | |
774 | }\r | |
775 | \r | |
593a8308 | 776 | /**\r |
531237a5 | 777 | Converts a multicast IP address to a multicast HW MAC address.\r |
778 | \r | |
779 | @param This Protocol instance pointer.\r | |
780 | @param Ipv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r | |
781 | to FALSE if the multicast IP address is IPv4 [RFC 791].\r | |
782 | @param Ip The multicast IP address that is to be converted to a multicast\r | |
783 | HW MAC address.\r | |
784 | @param Mac The multicast HW MAC address that is to be generated from IP.\r | |
785 | \r | |
786 | @retval EFI_SUCCESS The multicast IP address was mapped to the multicast\r | |
787 | HW MAC address.\r | |
788 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
789 | @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r | |
790 | size needed to hold the statistics is returned in\r | |
791 | StatisticsSize.\r | |
593a8308 | 792 | @retval EFI_UNSUPPORTED Not supported yet.\r |
793 | \r | |
794 | **/\r | |
795 | EFI_STATUS\r | |
531237a5 | 796 | EFIAPI\r |
593a8308 | 797 | SnpNt32McastIptoMac (\r |
798 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
799 | IN BOOLEAN Ipv6,\r | |
800 | IN EFI_IP_ADDRESS *Ip,\r | |
801 | OUT EFI_MAC_ADDRESS *Mac\r | |
802 | )\r | |
803 | {\r | |
804 | return EFI_UNSUPPORTED;\r | |
805 | }\r | |
806 | \r | |
807 | \r | |
808 | /**\r | |
531237a5 | 809 | Performs read and write operations on the NVRAM device attached to a \r |
810 | network interface.\r | |
811 | \r | |
812 | @param This Protocol instance pointer.\r | |
813 | @param ReadOrWrite TRUE for read operations, FALSE for write operations.\r | |
814 | @param Offset Byte offset in the NVRAM device at which to start the read or\r | |
815 | write operation. This must be a multiple of NvRamAccessSize and\r | |
816 | less than NvRamSize.\r | |
817 | @param BufferSize The number of bytes to read or write from the NVRAM device.\r | |
818 | This must also be a multiple of NvramAccessSize.\r | |
819 | @param Buffer A pointer to the data buffer.\r | |
593a8308 | 820 | \r |
821 | @retval EFI_UNSUPPORTED Not supported yet.\r | |
822 | \r | |
823 | **/\r | |
824 | EFI_STATUS\r | |
531237a5 | 825 | EFIAPI\r |
593a8308 | 826 | SnpNt32Nvdata (\r |
827 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
828 | IN BOOLEAN ReadOrWrite,\r | |
829 | IN UINTN Offset,\r | |
830 | IN UINTN BufferSize,\r | |
831 | IN OUT VOID *Buffer\r | |
832 | )\r | |
833 | {\r | |
834 | return EFI_UNSUPPORTED;\r | |
835 | }\r | |
836 | \r | |
837 | \r | |
838 | /**\r | |
531237a5 | 839 | Reads the current interrupt status and recycled transmit buffer status from \r |
840 | a network interface.\r | |
841 | \r | |
842 | @param This Protocol instance pointer.\r | |
843 | @param InterruptStatus A pointer to the bit mask of the currently active interrupts\r | |
844 | If this is NULL, the interrupt status will not be read from\r | |
845 | the device. If this is not NULL, the interrupt status will\r | |
846 | be read from the device. When the interrupt status is read,\r | |
847 | it will also be cleared. Clearing the transmit interrupt\r | |
848 | does not empty the recycled transmit buffer array.\r | |
849 | @param TxBuffer Recycled transmit buffer address. The network interface will\r | |
850 | not transmit if its internal recycled transmit buffer array\r | |
851 | is full. Reading the transmit buffer does not clear the\r | |
852 | transmit interrupt. If this is NULL, then the transmit buffer\r | |
853 | status will not be read. If there are no transmit buffers to\r | |
854 | recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r | |
855 | \r | |
856 | @retval EFI_SUCCESS Always succeeds.\r | |
593a8308 | 857 | \r |
858 | **/\r | |
859 | EFI_STATUS\r | |
531237a5 | 860 | EFIAPI\r |
593a8308 | 861 | SnpNt32GetStatus (\r |
862 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
863 | OUT UINT32 *InterruptStatus,\r | |
864 | OUT VOID **TxBuffer\r | |
865 | )\r | |
866 | {\r | |
a2cc5fea | 867 | SNPNT32_INSTANCE_DATA *Instance;\r |
a2cc5fea ZL |
868 | \r |
869 | Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);\r | |
870 | \r | |
593a8308 | 871 | if (TxBuffer != NULL) {\r |
d547b32d JW |
872 | if (Instance->RecycledTxBufCount != 0) {\r |
873 | Instance->RecycledTxBufCount --;\r | |
874 | *((UINT8 **) TxBuffer) = (UINT8 *) (UINTN)Instance->RecycledTxBuf[Instance->RecycledTxBufCount];\r | |
a2cc5fea ZL |
875 | } else {\r |
876 | *((UINT8 **) TxBuffer) = NULL;\r | |
877 | }\r | |
593a8308 | 878 | }\r |
879 | \r | |
880 | if (InterruptStatus != NULL) {\r | |
881 | *InterruptStatus = EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;\r | |
882 | }\r | |
883 | \r | |
884 | return EFI_SUCCESS;\r | |
885 | }\r | |
886 | \r | |
887 | \r | |
888 | /**\r | |
531237a5 | 889 | Places a packet in the transmit queue of a network interface.\r |
890 | \r | |
891 | @param This Protocol instance pointer.\r | |
892 | @param HeaderSize The size, in bytes, of the media header to be filled in by\r | |
893 | the Transmit() function. If HeaderSize is non-zero, then it\r | |
894 | must be equal to This->Mode->MediaHeaderSize and the DestAddr\r | |
895 | and Protocol parameters must not be NULL.\r | |
896 | @param BufferSize The size, in bytes, of the entire packet (media header and\r | |
897 | data) to be transmitted through the network interface.\r | |
898 | @param Buffer A pointer to the packet (media header followed by data) to be\r | |
899 | transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r | |
900 | then the media header in Buffer must already be filled in by the\r | |
901 | caller. If HeaderSize is non-zero, then the media header will be\r | |
902 | filled in by the Transmit() function.\r | |
903 | @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter\r | |
904 | is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r | |
905 | This->Mode->CurrentAddress is used for the source HW MAC address.\r | |
906 | @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this\r | |
907 | parameter is ignored.\r | |
908 | @param Protocol The type of header to build. If HeaderSize is zero, then this\r | |
909 | parameter is ignored. See RFC 1700, section "Ether Types", for\r | |
910 | examples.\r | |
911 | \r | |
912 | @retval EFI_SUCCESS The packet was placed on the transmit queue.\r | |
913 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
914 | @retval EFI_ACCESS_DENIED Error acquire global lock for operation.\r | |
593a8308 | 915 | \r |
916 | **/\r | |
917 | EFI_STATUS\r | |
531237a5 | 918 | EFIAPI\r |
593a8308 | 919 | SnpNt32Transmit (\r |
920 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
921 | IN UINTN HeaderSize,\r | |
922 | IN UINTN BufferSize,\r | |
923 | IN VOID *Buffer,\r | |
924 | IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,\r | |
925 | IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,\r | |
926 | IN UINT16 *Protocol OPTIONAL\r | |
927 | )\r | |
928 | {\r | |
929 | SNPNT32_INSTANCE_DATA *Instance;\r | |
930 | SNPNT32_GLOBAL_DATA *GlobalData;\r | |
931 | INT32 ReturnValue;\r | |
a2cc5fea | 932 | UINT64 *Tmp;\r |
593a8308 | 933 | \r |
934 | Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);\r | |
935 | \r | |
936 | GlobalData = Instance->GlobalData;\r | |
937 | \r | |
938 | if ((HeaderSize != 0) && (SrcAddr == NULL)) {\r | |
939 | SrcAddr = &Instance->Mode.CurrentAddress;\r | |
940 | }\r | |
941 | \r | |
e90e8777 | 942 | if (EFI_ERROR (EfiAcquireLockOrFail (&GlobalData->Lock))) {\r |
593a8308 | 943 | return EFI_ACCESS_DENIED;\r |
944 | }\r | |
945 | \r | |
946 | ReturnValue = GlobalData->NtNetUtilityTable.Transmit (\r | |
947 | Instance->InterfaceInfo.InterfaceIndex,\r | |
f66a43b2 JM |
948 | (UINT32)HeaderSize,\r |
949 | (UINT32)BufferSize,\r | |
593a8308 | 950 | Buffer,\r |
951 | SrcAddr,\r | |
952 | DestAddr,\r | |
953 | Protocol\r | |
954 | );\r | |
955 | \r | |
e90e8777 | 956 | EfiReleaseLock (&GlobalData->Lock);\r |
593a8308 | 957 | \r |
958 | if (ReturnValue < 0) {\r | |
959 | return EFI_DEVICE_ERROR;\r | |
a2cc5fea | 960 | } else {\r |
d547b32d | 961 | if ((Instance->MaxRecycledTxBuf + SNP_TX_BUFFER_INCREASEMENT) >= SNP_MAX_TX_BUFFER_NUM) {\r |
a2cc5fea ZL |
962 | return EFI_NOT_READY;\r |
963 | }\r | |
964 | \r | |
d547b32d JW |
965 | if (Instance->RecycledTxBufCount < Instance->MaxRecycledTxBuf) {\r |
966 | Instance->RecycledTxBuf[Instance->RecycledTxBufCount] = (UINT64) Buffer;\r | |
967 | Instance->RecycledTxBufCount ++;\r | |
a2cc5fea | 968 | } else {\r |
d547b32d | 969 | Tmp = AllocatePool (sizeof (UINT64) * (Instance->MaxRecycledTxBuf + SNP_TX_BUFFER_INCREASEMENT));\r |
a2cc5fea ZL |
970 | if (Tmp == NULL) {\r |
971 | return EFI_DEVICE_ERROR;\r | |
972 | }\r | |
d547b32d JW |
973 | CopyMem (Tmp, Instance->RecycledTxBuf, sizeof (UINT64) * Instance->RecycledTxBufCount);\r |
974 | FreePool (Instance->RecycledTxBuf);\r | |
975 | Instance->RecycledTxBuf = Tmp;\r | |
976 | Instance->MaxRecycledTxBuf += SNP_TX_BUFFER_INCREASEMENT;\r | |
a2cc5fea | 977 | }\r |
593a8308 | 978 | }\r |
979 | \r | |
980 | return EFI_SUCCESS;\r | |
981 | }\r | |
982 | \r | |
593a8308 | 983 | /**\r |
531237a5 | 984 | Receives a packet from a network interface.\r |
985 | \r | |
986 | @param This Protocol instance pointer.\r | |
987 | @param HeaderSize The size, in bytes, of the media header received on the network\r | |
988 | interface. If this parameter is NULL, then the media header size\r | |
989 | will not be returned.\r | |
990 | @param BuffSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r | |
991 | bytes, of the packet that was received on the network interface.\r | |
992 | @param Buffer A pointer to the data buffer to receive both the media header and\r | |
993 | the data.\r | |
994 | @param SourceAddr The source HW MAC address. If this parameter is NULL, the\r | |
995 | HW MAC source address will not be extracted from the media\r | |
996 | header.\r | |
997 | @param DestinationAddr The destination HW MAC address. If this parameter is NULL,\r | |
998 | the HW MAC destination address will not be extracted from the\r | |
999 | media header.\r | |
1000 | @param Protocol The media header type. If this parameter is NULL, then the\r | |
1001 | protocol will not be extracted from the media header. See\r | |
1002 | RFC 1700 section "Ether Types" for examples.\r | |
1003 | \r | |
1004 | @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has\r | |
1005 | been updated to the number of bytes received.\r | |
1006 | @retval EFI_NOT_READY The network interface is too busy to accept this transmit\r | |
1007 | request.\r | |
1008 | @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r | |
1009 | @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r | |
1010 | @retval EFI_ACCESS_DENIED Error acquire global lock for operation.\r | |
593a8308 | 1011 | \r |
1012 | **/\r | |
1013 | EFI_STATUS\r | |
531237a5 | 1014 | EFIAPI\r |
593a8308 | 1015 | SnpNt32Receive (\r |
1016 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
1017 | OUT UINTN *HeaderSize,\r | |
1018 | IN OUT UINTN *BuffSize,\r | |
1019 | OUT VOID *Buffer,\r | |
1020 | OUT EFI_MAC_ADDRESS *SourceAddr,\r | |
1021 | OUT EFI_MAC_ADDRESS *DestinationAddr,\r | |
1022 | OUT UINT16 *Protocol\r | |
1023 | )\r | |
1024 | {\r | |
1025 | SNPNT32_INSTANCE_DATA *Instance;\r | |
1026 | SNPNT32_GLOBAL_DATA *GlobalData;\r | |
1027 | INT32 ReturnValue;\r | |
aaf779a7 | 1028 | UINTN BufSize;\r |
1029 | \r | |
1030 | BufSize = *BuffSize;\r | |
593a8308 | 1031 | \r |
1032 | Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);\r | |
1033 | \r | |
1034 | GlobalData = Instance->GlobalData;\r | |
1035 | \r | |
1036 | ASSERT (GlobalData->NtNetUtilityTable.Receive != NULL);\r | |
1037 | \r | |
e90e8777 | 1038 | if (EFI_ERROR (EfiAcquireLockOrFail (&GlobalData->Lock))) {\r |
593a8308 | 1039 | return EFI_ACCESS_DENIED;\r |
1040 | }\r | |
1041 | \r | |
1042 | ReturnValue = GlobalData->NtNetUtilityTable.Receive (\r | |
1043 | Instance->InterfaceInfo.InterfaceIndex,\r | |
1044 | BuffSize,\r | |
1045 | Buffer\r | |
1046 | );\r | |
1047 | \r | |
e90e8777 | 1048 | EfiReleaseLock (&GlobalData->Lock);\r |
593a8308 | 1049 | \r |
1050 | if (ReturnValue < 0) {\r | |
1051 | if (ReturnValue == -100) {\r | |
1052 | return EFI_BUFFER_TOO_SMALL;\r | |
1053 | }\r | |
1054 | \r | |
1055 | return EFI_DEVICE_ERROR;\r | |
1056 | } else if (ReturnValue == 0) {\r | |
1057 | return EFI_NOT_READY;\r | |
1058 | }\r | |
1059 | \r | |
1060 | if (HeaderSize != NULL) {\r | |
1061 | *HeaderSize = 14;\r | |
1062 | }\r | |
1063 | \r | |
1064 | if (SourceAddr != NULL) {\r | |
e90e8777 | 1065 | ZeroMem (SourceAddr, sizeof (EFI_MAC_ADDRESS));\r |
1066 | CopyMem (SourceAddr, ((UINT8 *) Buffer) + 6, 6);\r | |
593a8308 | 1067 | }\r |
1068 | \r | |
1069 | if (DestinationAddr != NULL) {\r | |
e90e8777 | 1070 | ZeroMem (DestinationAddr, sizeof (EFI_MAC_ADDRESS));\r |
1071 | CopyMem (DestinationAddr, ((UINT8 *) Buffer), 6);\r | |
593a8308 | 1072 | }\r |
1073 | \r | |
1074 | if (Protocol != NULL) {\r | |
1075 | *Protocol = NTOHS (*((UINT16 *) (((UINT8 *) Buffer) + 12)));\r | |
1076 | }\r | |
1077 | \r | |
aaf779a7 | 1078 | return (*BuffSize <= BufSize) ? EFI_SUCCESS : EFI_BUFFER_TOO_SMALL; \r |
593a8308 | 1079 | }\r |
1080 | \r | |
593a8308 | 1081 | /**\r |
1082 | Initialize the driver's global data.\r | |
1083 | \r | |
1084 | @param This Pointer to the global context data.\r | |
1085 | \r | |
1086 | @retval EFI_SUCCESS The global data is initialized.\r | |
1087 | @retval EFI_NOT_FOUND The required DLL is not found.\r | |
531237a5 | 1088 | @retval EFI_DEVICE_ERROR Error initialize network utility library.\r |
1089 | @retval EFI_OUT_OF_RESOURCES Out of resource.\r | |
1090 | @retval other Other errors.\r | |
593a8308 | 1091 | \r |
1092 | **/\r | |
1093 | EFI_STATUS\r | |
1094 | SnpNt32InitializeGlobalData (\r | |
531237a5 | 1095 | IN OUT SNPNT32_GLOBAL_DATA *This\r |
593a8308 | 1096 | )\r |
1097 | {\r | |
1098 | EFI_STATUS Status;\r | |
1099 | CHAR16 *DllFileNameU;\r | |
1100 | UINT32 Index;\r | |
1101 | INT32 ReturnValue;\r | |
1102 | BOOLEAN NetUtilityLibInitDone;\r | |
1103 | NT_NET_INTERFACE_INFO NetInterfaceInfoBuffer[MAX_INTERFACE_INFO_NUMBER];\r | |
1104 | SNPNT32_INSTANCE_DATA *Instance;\r | |
e90e8777 | 1105 | LIST_ENTRY *Entry;\r |
593a8308 | 1106 | UINT32 InterfaceCount;\r |
1107 | \r | |
1108 | ASSERT (This != NULL);\r | |
1109 | \r | |
1110 | NetUtilityLibInitDone = FALSE;\r | |
1111 | InterfaceCount = MAX_INTERFACE_INFO_NUMBER;\r | |
1112 | \r | |
e90e8777 | 1113 | InitializeListHead (&This->InstanceList);\r |
1114 | EfiInitializeLock (&This->Lock, TPL_CALLBACK);\r | |
593a8308 | 1115 | \r |
1116 | //\r | |
1117 | // Get the WinNT thunk\r | |
1118 | //\r | |
a00ec39b | 1119 | Status = gBS->LocateProtocol (&gEfiWinNtThunkProtocolGuid, NULL, (VOID **)&This->WinNtThunk);\r |
593a8308 | 1120 | \r |
1121 | if (EFI_ERROR (Status)) {\r | |
1122 | return Status;\r | |
1123 | }\r | |
1124 | \r | |
1125 | ASSERT (This->WinNtThunk != NULL);\r | |
1126 | \r | |
1127 | DllFileNameU = NETWORK_LIBRARY_NAME_U;\r | |
1128 | \r | |
1129 | //\r | |
1130 | // Load network utility library\r | |
1131 | //\r | |
1132 | This->NetworkLibraryHandle = This->WinNtThunk->LoadLibraryEx (DllFileNameU, NULL, 0);\r | |
1133 | \r | |
1134 | if (NULL == This->NetworkLibraryHandle) {\r | |
1135 | return EFI_NOT_FOUND;\r | |
1136 | }\r | |
1137 | \r | |
1138 | This->NtNetUtilityTable.Initialize = (NT_NET_INITIALIZE) This->WinNtThunk->GetProcAddress (\r | |
531237a5 | 1139 | This->NetworkLibraryHandle,\r |
1140 | NETWORK_LIBRARY_INITIALIZE\r | |
1141 | );\r | |
593a8308 | 1142 | \r |
1143 | if (NULL == This->NtNetUtilityTable.Initialize) {\r | |
1144 | Status = EFI_NOT_FOUND;\r | |
1145 | goto ErrorReturn;\r | |
1146 | }\r | |
1147 | \r | |
1148 | This->NtNetUtilityTable.Finalize = (NT_NET_FINALIZE) This->WinNtThunk->GetProcAddress (\r | |
531237a5 | 1149 | This->NetworkLibraryHandle,\r |
1150 | NETWORK_LIBRARY_FINALIZE\r | |
1151 | );\r | |
593a8308 | 1152 | \r |
1153 | if (NULL == This->NtNetUtilityTable.Finalize) {\r | |
1154 | Status = EFI_NOT_FOUND;\r | |
1155 | goto ErrorReturn;\r | |
1156 | }\r | |
1157 | \r | |
1158 | This->NtNetUtilityTable.SetReceiveFilter = (NT_NET_SET_RECEIVE_FILTER) This->WinNtThunk->GetProcAddress (\r | |
531237a5 | 1159 | This->NetworkLibraryHandle,\r |
1160 | NETWORK_LIBRARY_SET_RCV_FILTER\r | |
1161 | );\r | |
593a8308 | 1162 | \r |
1163 | if (NULL == This->NtNetUtilityTable.SetReceiveFilter) {\r | |
1164 | Status = EFI_NOT_FOUND;\r | |
1165 | goto ErrorReturn;\r | |
1166 | }\r | |
1167 | \r | |
1168 | This->NtNetUtilityTable.Receive = (NT_NET_RECEIVE) This->WinNtThunk->GetProcAddress (\r | |
531237a5 | 1169 | This->NetworkLibraryHandle,\r |
1170 | NETWORK_LIBRARY_RECEIVE\r | |
1171 | );\r | |
593a8308 | 1172 | \r |
1173 | if (NULL == This->NtNetUtilityTable.Receive) {\r | |
1174 | Status = EFI_NOT_FOUND;\r | |
1175 | goto ErrorReturn;\r | |
1176 | }\r | |
1177 | \r | |
1178 | This->NtNetUtilityTable.Transmit = (NT_NET_TRANSMIT) This->WinNtThunk->GetProcAddress (\r | |
531237a5 | 1179 | This->NetworkLibraryHandle,\r |
1180 | NETWORK_LIBRARY_TRANSMIT\r | |
1181 | );\r | |
593a8308 | 1182 | \r |
1183 | if (NULL == This->NtNetUtilityTable.Transmit) {\r | |
1184 | Status = EFI_NOT_FOUND;\r | |
1185 | goto ErrorReturn;\r | |
1186 | }\r | |
1187 | //\r | |
1188 | // Initialize the network utility library\r | |
1189 | // And enumerate the interfaces in NT32 host\r | |
1190 | //\r | |
1191 | ReturnValue = This->NtNetUtilityTable.Initialize (&InterfaceCount, &NetInterfaceInfoBuffer[0]);\r | |
1192 | if (ReturnValue <= 0) {\r | |
1193 | Status = EFI_DEVICE_ERROR;\r | |
1194 | goto ErrorReturn;\r | |
1195 | }\r | |
1196 | \r | |
1197 | NetUtilityLibInitDone = TRUE;\r | |
1198 | \r | |
1199 | if (InterfaceCount == 0) {\r | |
1200 | Status = EFI_NOT_FOUND;\r | |
1201 | goto ErrorReturn;\r | |
1202 | }\r | |
1203 | //\r | |
1204 | // Create fake SNP instances\r | |
1205 | //\r | |
1206 | for (Index = 0; Index < InterfaceCount; Index++) {\r | |
1207 | \r | |
d547b32d | 1208 | Instance = AllocateZeroPool (sizeof (SNPNT32_INSTANCE_DATA));\r |
593a8308 | 1209 | \r |
1210 | if (NULL == Instance) {\r | |
1211 | Status = EFI_OUT_OF_RESOURCES;\r | |
1212 | goto ErrorReturn;\r | |
1213 | }\r | |
1214 | //\r | |
1215 | // Copy the content from a template\r | |
1216 | //\r | |
e90e8777 | 1217 | CopyMem (Instance, &gSnpNt32InstanceTemplate, sizeof (SNPNT32_INSTANCE_DATA));\r |
593a8308 | 1218 | \r |
d547b32d JW |
1219 | //\r |
1220 | // Allocate the RecycledTxBuf.\r | |
1221 | //\r | |
1222 | Instance->RecycledTxBuf = AllocatePool (sizeof (UINT64) * Instance->MaxRecycledTxBuf);\r | |
1223 | if (Instance->RecycledTxBuf == NULL) {\r | |
1224 | return EFI_OUT_OF_RESOURCES;\r | |
1225 | }\r | |
1226 | \r | |
593a8308 | 1227 | //\r |
1228 | // Set the interface information.\r | |
1229 | //\r | |
f66a43b2 | 1230 | CopyMem (&Instance->InterfaceInfo, &NetInterfaceInfoBuffer[Index], sizeof(Instance->InterfaceInfo));\r |
593a8308 | 1231 | //\r |
1232 | // Initialize this instance\r | |
1233 | //\r | |
1234 | Status = This->InitializeInstanceData (This, Instance);\r | |
1235 | if (EFI_ERROR (Status)) {\r | |
1236 | \r | |
e90e8777 | 1237 | gBS->FreePool (Instance);\r |
593a8308 | 1238 | goto ErrorReturn;\r |
1239 | }\r | |
1240 | //\r | |
1241 | // Insert this instance into the instance list\r | |
1242 | //\r | |
e90e8777 | 1243 | InsertTailList (&This->InstanceList, &Instance->Entry);\r |
593a8308 | 1244 | }\r |
1245 | \r | |
1246 | return EFI_SUCCESS;\r | |
1247 | \r | |
1248 | ErrorReturn:\r | |
1249 | \r | |
e90e8777 | 1250 | while (!IsListEmpty (&This->InstanceList)) {\r |
593a8308 | 1251 | \r |
1252 | Entry = This->InstanceList.ForwardLink;\r | |
1253 | \r | |
1254 | Instance = NET_LIST_USER_STRUCT_S (Entry, SNPNT32_INSTANCE_DATA, Entry, SNP_NT32_INSTANCE_SIGNATURE);\r | |
1255 | \r | |
e90e8777 | 1256 | RemoveEntryList (Entry);\r |
593a8308 | 1257 | \r |
1258 | This->CloseInstance (This, Instance);\r | |
e90e8777 | 1259 | gBS->FreePool (Instance);\r |
593a8308 | 1260 | }\r |
1261 | \r | |
1262 | if (NetUtilityLibInitDone) {\r | |
1263 | \r | |
1264 | ASSERT (This->WinNtThunk != NULL);\r | |
1265 | \r | |
1266 | if (This->NtNetUtilityTable.Finalize != NULL) {\r | |
1267 | This->NtNetUtilityTable.Finalize ();\r | |
1268 | This->NtNetUtilityTable.Finalize = NULL;\r | |
1269 | }\r | |
1270 | }\r | |
1271 | \r | |
1272 | return Status;\r | |
1273 | }\r | |
1274 | \r | |
1275 | \r | |
1276 | /**\r | |
1277 | Initialize the snpnt32 driver instance.\r | |
1278 | \r | |
1279 | @param This Pointer to the SnpNt32 global data.\r | |
1280 | @param Instance Pointer to the instance context data.\r | |
1281 | \r | |
1282 | @retval EFI_SUCCESS The driver instance is initialized.\r | |
531237a5 | 1283 | @retval other Initialization errors.\r |
593a8308 | 1284 | \r |
1285 | **/\r | |
1286 | EFI_STATUS\r | |
1287 | SnpNt32InitializeInstanceData (\r | |
531237a5 | 1288 | IN SNPNT32_GLOBAL_DATA *This,\r |
1289 | IN OUT SNPNT32_INSTANCE_DATA *Instance\r | |
593a8308 | 1290 | )\r |
1291 | {\r | |
1292 | EFI_STATUS Status;\r | |
1293 | EFI_DEV_PATH EndNode;\r | |
1294 | EFI_DEV_PATH Node;\r | |
1295 | \r | |
1296 | Instance->GlobalData = This;\r | |
1297 | Instance->Snp.Mode = &Instance->Mode;\r | |
1298 | //\r | |
1299 | // Set broadcast address\r | |
1300 | //\r | |
1301 | SetMem (&Instance->Mode.BroadcastAddress, sizeof (EFI_MAC_ADDRESS), 0xFF);\r | |
1302 | \r | |
1303 | //\r | |
1304 | // Copy Current/PermanentAddress MAC address\r | |
1305 | //\r | |
f66a43b2 JM |
1306 | CopyMem (&Instance->Mode.CurrentAddress, &Instance->InterfaceInfo.MacAddr, sizeof(Instance->Mode.CurrentAddress));\r |
1307 | CopyMem (&Instance->Mode.PermanentAddress, &Instance->InterfaceInfo.MacAddr, sizeof(Instance->Mode.PermanentAddress));\r | |
593a8308 | 1308 | \r |
1309 | //\r | |
1310 | // Since the fake SNP is based on a real NIC, to avoid conflict with the host\r | |
1311 | // NIC network stack, we use a different MAC address.\r | |
1312 | // So just change the last byte of the MAC address for the real NIC.\r | |
1313 | //\r | |
1314 | Instance->Mode.CurrentAddress.Addr[NET_ETHER_ADDR_LEN - 1]++;\r | |
1315 | \r | |
1316 | //\r | |
1317 | // Create a fake device path for the instance\r | |
1318 | //\r | |
e90e8777 | 1319 | ZeroMem (&Node, sizeof (Node));\r |
593a8308 | 1320 | \r |
1321 | Node.DevPath.Type = MESSAGING_DEVICE_PATH;\r | |
1322 | Node.DevPath.SubType = MSG_MAC_ADDR_DP;\r | |
1323 | SetDevicePathNodeLength (&Node.DevPath, sizeof (MAC_ADDR_DEVICE_PATH));\r | |
1324 | \r | |
e90e8777 | 1325 | CopyMem (\r |
593a8308 | 1326 | &Node.MacAddr.MacAddress,\r |
1327 | &Instance->Mode.CurrentAddress,\r | |
4324075f | 1328 | NET_ETHER_ADDR_LEN\r |
593a8308 | 1329 | );\r |
1330 | \r | |
1331 | Node.MacAddr.IfType = Instance->Mode.IfType;\r | |
1332 | \r | |
1333 | SetDevicePathEndNode (&EndNode.DevPath);\r | |
1334 | \r | |
1335 | Instance->DevicePath = AppendDevicePathNode (\r | |
531237a5 | 1336 | &EndNode.DevPath,\r |
1337 | &Node.DevPath\r | |
1338 | );\r | |
593a8308 | 1339 | \r |
1340 | //\r | |
1341 | // Create a fake device handle for the fake SNP\r | |
1342 | //\r | |
1343 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
1344 | &Instance->DeviceHandle,\r | |
1345 | &gEfiSimpleNetworkProtocolGuid,\r | |
1346 | &Instance->Snp,\r | |
1347 | &gEfiDevicePathProtocolGuid,\r | |
1348 | Instance->DevicePath,\r | |
1349 | NULL\r | |
1350 | );\r | |
593a8308 | 1351 | return Status;\r |
1352 | }\r | |
1353 | \r | |
1354 | \r | |
1355 | /**\r | |
1356 | Close the SnpNt32 driver instance.\r | |
1357 | \r | |
1358 | @param This Pointer to the SnpNt32 global data.\r | |
1359 | @param Instance Pointer to the instance context data.\r | |
1360 | \r | |
1361 | @retval EFI_SUCCESS The instance is closed.\r | |
1362 | \r | |
1363 | **/\r | |
1364 | EFI_STATUS\r | |
1365 | SnpNt32CloseInstance (\r | |
531237a5 | 1366 | IN SNPNT32_GLOBAL_DATA *This,\r |
1367 | IN OUT SNPNT32_INSTANCE_DATA *Instance\r | |
593a8308 | 1368 | )\r |
1369 | {\r | |
1370 | ASSERT (This != NULL);\r | |
1371 | ASSERT (Instance != NULL);\r | |
1372 | \r | |
1373 | gBS->UninstallMultipleProtocolInterfaces (\r | |
531237a5 | 1374 | Instance->DeviceHandle,\r |
1375 | &gEfiSimpleNetworkProtocolGuid,\r | |
1376 | &Instance->Snp,\r | |
1377 | &gEfiDevicePathProtocolGuid,\r | |
1378 | Instance->DevicePath,\r | |
1379 | NULL\r | |
1380 | );\r | |
593a8308 | 1381 | \r |
1382 | if (Instance->DevicePath != NULL) {\r | |
1383 | gBS->FreePool (Instance->DevicePath);\r | |
1384 | }\r | |
1385 | \r | |
1386 | return EFI_SUCCESS;\r | |
1387 | }\r | |
1388 | \r | |
593a8308 | 1389 | /**\r |
531237a5 | 1390 | Unloads an image.\r |
593a8308 | 1391 | \r |
531237a5 | 1392 | @param ImageHandle Handle that identifies the image to be unloaded.\r |
593a8308 | 1393 | \r |
531237a5 | 1394 | @retval EFI_SUCCESS The image has been unloaded.\r |
1395 | @return Exit code from the image's unload handler\r | |
593a8308 | 1396 | \r |
1397 | **/\r | |
1398 | EFI_STATUS\r | |
1399 | EFIAPI\r | |
1400 | SnpNt32Unload (\r | |
1401 | IN EFI_HANDLE ImageHandle\r | |
1402 | )\r | |
1403 | {\r | |
1404 | EFI_STATUS Status;\r | |
1405 | SNPNT32_GLOBAL_DATA *This;\r | |
e90e8777 | 1406 | LIST_ENTRY *Entry;\r |
593a8308 | 1407 | SNPNT32_INSTANCE_DATA *Instance;\r |
1408 | \r | |
1409 | This = &gSnpNt32GlobalData;\r | |
1410 | \r | |
1411 | Status = NetLibDefaultUnload (ImageHandle);\r | |
1412 | \r | |
1413 | if (EFI_ERROR (Status)) {\r | |
1414 | return Status;\r | |
1415 | }\r | |
1416 | \r | |
e90e8777 | 1417 | while (!IsListEmpty (&This->InstanceList)) {\r |
593a8308 | 1418 | //\r |
1419 | // Walkthrough the interfaces and remove all the SNP instance\r | |
1420 | //\r | |
1421 | Entry = This->InstanceList.ForwardLink;\r | |
1422 | \r | |
1423 | Instance = NET_LIST_USER_STRUCT_S (Entry, SNPNT32_INSTANCE_DATA, Entry, SNP_NT32_INSTANCE_SIGNATURE);\r | |
1424 | \r | |
e90e8777 | 1425 | RemoveEntryList (Entry);\r |
593a8308 | 1426 | \r |
1427 | This->CloseInstance (This, Instance);\r | |
e90e8777 | 1428 | gBS->FreePool (Instance);\r |
593a8308 | 1429 | }\r |
1430 | \r | |
1431 | if (This->NtNetUtilityTable.Finalize != NULL) {\r | |
1432 | This->NtNetUtilityTable.Finalize ();\r | |
1433 | }\r | |
1434 | \r | |
1435 | This->WinNtThunk->FreeLibrary (This->NetworkLibraryHandle);\r | |
1436 | \r | |
1437 | return EFI_SUCCESS;\r | |
1438 | }\r | |
1439 | \r | |
531237a5 | 1440 | /**\r |
1441 | This is the declaration of an EFI image entry point. This entry point is\r | |
1442 | the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including\r | |
1443 | both device drivers and bus drivers.\r | |
1444 | \r | |
1445 | @param ImageHandle The firmware allocated handle for the UEFI image.\r | |
1446 | @param SystemTable A pointer to the EFI System Table.\r | |
1447 | \r | |
1448 | @retval EFI_SUCCESS The operation completed successfully.\r | |
1449 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
593a8308 | 1450 | \r |
531237a5 | 1451 | **/\r |
593a8308 | 1452 | EFI_STATUS\r |
6c76a5da | 1453 | InitializeSnpNt32Driver (\r |
593a8308 | 1454 | IN EFI_HANDLE ImageHandle,\r |
1455 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
1456 | )\r | |
593a8308 | 1457 | {\r |
1458 | \r | |
1459 | EFI_STATUS Status;\r | |
1460 | \r | |
1461 | //\r | |
1462 | // Install the Driver Protocols\r | |
1463 | //\r | |
1464 | \r | |
057d744e | 1465 | Status = EfiLibInstallDriverBindingComponentName2 (\r |
1466 | ImageHandle,\r | |
1467 | SystemTable,\r | |
1468 | &gSnpNt32DriverBinding,\r | |
1469 | ImageHandle,\r | |
1470 | &gSnpNt32DriverComponentName,\r | |
1471 | &gSnpNt32DriverComponentName2\r | |
1472 | );\r | |
593a8308 | 1473 | if (EFI_ERROR (Status)) {\r |
1474 | return Status;\r | |
1475 | }\r | |
1476 | \r | |
1477 | //\r | |
1478 | // Initialize the global data\r | |
1479 | //\r | |
1480 | Status = SnpNt32InitializeGlobalData (&gSnpNt32GlobalData);\r | |
1481 | if (EFI_ERROR (Status)) {\r | |
1482 | SnpNt32Unload (ImageHandle);\r | |
1483 | }\r | |
1484 | \r | |
1485 | return Status;\r | |
1486 | }\r |