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