3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 EFI_DRIVER_BINDING_PROTOCOL gSnpNt32DriverBinding
= {
23 SnpNt32DriverBindingSupported
,
24 SnpNt32DriverBindingStart
,
25 SnpNt32DriverBindingStop
,
31 SNPNT32_GLOBAL_DATA gSnpNt32GlobalData
= {
32 SNP_NT32_DRIVER_SIGNATURE
, // Signature
38 NULL
, // NetworkLibraryHandle
41 }, // NtNetUtilityTable
50 SnpNt32InitializeGlobalData
, // InitializeGlobalData
51 SnpNt32InitializeInstanceData
, // InitializeInstanceData
52 SnpNt32CloseInstance
// CloseInstance
57 Test to see if this driver supports ControllerHandle.
59 @param This Protocol instance pointer.
60 @param ControllerHandle Handle of device to test.
61 @param RemainingDevicePath Optional parameter use to pick a specific child
64 @retval EFI_SUCCES This driver supports this device.
65 @retval other This driver does not support this device.
70 SnpNt32DriverBindingSupported (
71 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
72 IN EFI_HANDLE ControllerHandle
,
73 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
77 SNPNT32_GLOBAL_DATA
*GlobalData
;
79 SNPNT32_INSTANCE_DATA
*Instance
;
81 GlobalData
= &gSnpNt32GlobalData
;
83 NET_LIST_FOR_EACH (Entry
, &GlobalData
->InstanceList
) {
85 Instance
= NET_LIST_USER_STRUCT_S (Entry
, SNPNT32_INSTANCE_DATA
, Entry
, SNP_NT32_INSTANCE_SIGNATURE
);
87 if (Instance
->DeviceHandle
== ControllerHandle
) {
93 return EFI_UNSUPPORTED
;
98 Start this driver on ControllerHandle.
100 @param This Protocol instance pointer.
101 @param ControllerHandle Handle of device to bind driver to.
102 @param RemainingDevicePath Optional parameter use to pick a specific child
105 @retval EFI_SUCCES This driver is added to ControllerHandle.
110 SnpNt32DriverBindingStart (
111 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
112 IN EFI_HANDLE ControllerHandle
,
113 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
121 Stop this driver on ControllerHandle.
123 @param This Protocol instance pointer.
124 @param ControllerHandle Handle of device to stop driver on.
125 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number
126 of children is zero stop the entire bus driver.
127 @param ChildHandleBuffer List of Child Handles to Stop.
129 @retval EFI_SUCCES This driver is removed ControllerHandle.
134 SnpNt32DriverBindingStop (
135 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
136 IN EFI_HANDLE ControllerHandle
,
137 IN UINTN NumberOfChildren
,
138 IN EFI_HANDLE
*ChildHandleBuffer
147 Start the SnpNt32 interface.
149 @param This Context pointer.
151 @retval EFI_SUCCESS The interface is started.
156 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
164 Stop the SnpNt32 interface.
166 @param This Context pointer.
168 @retval EFI_SUCCESS The interface is stopped.
173 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
181 Initialize the SnpNt32 interface.
183 @param This Context pointer.
184 @param ExtraRxBufferSize Number of extra receive buffer.
185 @param ExtraTxBufferSize Number of extra transmit buffer.
187 @retval EFI_SUCCESS The interface is initialized.
192 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
193 IN UINTN ExtraRxBufferSize OPTIONAL
,
194 IN UINTN ExtraTxBufferSize OPTIONAL
202 Reset the snpnt32 interface.
204 @param This Context pointer.
205 @param ExtendedVerification Not implemented.
207 @retval EFI_SUCCESS The interface is reseted.
212 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
213 IN BOOLEAN ExtendedVerification
221 Shut down the snpnt32 interface.
223 @param This Context pointer.
225 @retval EFI_SUCCESS The interface is shut down.
230 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
238 Change the interface's receive filter setting.
240 @param This Context pointer.
241 @param EnableBits The receive filters to enable.
242 @param DisableBits The receive filters to disable
243 @param ResetMcastFilter Reset the multicast filters or not.
244 @param McastFilterCount The count of multicast filter to set.
245 @param McastFilter Pointer to the arrya of multicast addresses to set.
247 @retval EFI_SUCCESS The receive filter is updated.
248 @retval EFI_ACCESS_DENIED The snpnt32 lock is already owned by another
250 @retval EFI_DEVICE_ERROR Failed to update the receive filter.
254 SnpNt32ReceiveFilters (
255 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
256 IN UINT32 EnableBits
,
257 IN UINT32 DisableBits
,
258 IN BOOLEAN ResetMcastFilter
,
259 IN UINTN McastFilterCount OPTIONAL
,
260 IN EFI_MAC_ADDRESS
*McastFilter OPTIONAL
263 SNPNT32_INSTANCE_DATA
*Instance
;
264 SNPNT32_GLOBAL_DATA
*GlobalData
;
267 Instance
= SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This
);
269 GlobalData
= Instance
->GlobalData
;
271 if (EFI_ERROR (EfiAcquireLockOrFail (&GlobalData
->Lock
))) {
272 return EFI_ACCESS_DENIED
;
275 ReturnValue
= GlobalData
->NtNetUtilityTable
.SetReceiveFilter (
276 Instance
->InterfaceInfo
.InterfaceIndex
,
282 EfiReleaseLock (&GlobalData
->Lock
);
284 if (ReturnValue
<= 0) {
285 return EFI_DEVICE_ERROR
;
293 Change or reset the mac address of the interface.
295 @param This Context pointer.
296 @param reset Reset the mac address to the original one or not.
297 @param NewMacAddr Pointer to the new mac address to set.
299 @retval EFI_UNSUPPORTED Not supported yet.
303 SnpNt32StationAddress (
304 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
306 IN EFI_MAC_ADDRESS
*NewMacAddr OPTIONAL
309 return EFI_UNSUPPORTED
;
314 Get or reset the statistics data.
316 @param This Context pointer.
317 @param Reset Reset the statistics or not.
318 @param StatisticsSize The size of the buffer used to receive the
320 @param StatisticsTable Pointer to the table used to receive the statistics
323 @retval EFI_UNSUPPORTED Not supported yet.
328 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
,
330 IN OUT UINTN
*StatisticsSize OPTIONAL
,
331 IN OUT EFI_NETWORK_STATISTICS
*StatisticsTable OPTIONAL
334 return EFI_UNSUPPORTED
;
339 Convert a multicast ip address to the multicast mac address.
341 @param This Context pointer.
342 @param Ipv6 The Ip is an Ipv6 address or not.
343 @param Ip Pointer to the Ip address to convert.
344 @param Mac Pointer to the buffer used to hold the converted
347 @retval EFI_UNSUPPORTED Not supported yet.
351 SnpNt32McastIptoMac (
352 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
354 IN EFI_IP_ADDRESS
*Ip
,
355 OUT EFI_MAC_ADDRESS
*Mac
358 return EFI_UNSUPPORTED
;
363 Read or write the nv data.
365 @param This Context pinter.
366 @param ReadOrWrite Read or write the nv data.
367 @param Offset The offset to the start of the nv data.
368 @param BufferSize Size of the buffer.
369 @param Buffer Pointer to the buffer containing the data to write
370 or used to receive the data read.
372 @retval EFI_UNSUPPORTED Not supported yet.
377 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
378 IN BOOLEAN ReadOrWrite
,
384 return EFI_UNSUPPORTED
;
389 Get the status information of the interface.
391 @param This Context pointer.
392 @param InterruptStatus The storage to hold the interrupt status.
393 @param TxBuffer Pointer to get the list of pointers of previously
394 transmitted buffers whose transmission was
395 completed asynchrnously.
397 @retval EFI_SUCCESS The status is got.
402 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
403 OUT UINT32
*InterruptStatus
,
408 if (TxBuffer
!= NULL
) {
409 *((UINT8
**) TxBuffer
) = (UINT8
*) 1;
412 if (InterruptStatus
!= NULL
) {
413 *InterruptStatus
= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT
;
423 @param This Context pointer.
424 @param HeaderSize The media header size contained in the packet
426 @param BufferSize The size of the packet buffer.
427 @param Buffer Pointer to the buffer containing the packet data.
428 @param SrcAddr If non null, points to the source address of this
430 @param DestAddr If non null, points to the destination address of
432 @param Protocol The protocol type of this packet.
434 @retval EFI_SUCCESS The packet is transmitted or put into the transmit
436 @retval other Some error occurs.
441 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
445 IN EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
446 IN EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
447 IN UINT16
*Protocol OPTIONAL
450 SNPNT32_INSTANCE_DATA
*Instance
;
451 SNPNT32_GLOBAL_DATA
*GlobalData
;
454 Instance
= SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This
);
456 GlobalData
= Instance
->GlobalData
;
458 if ((HeaderSize
!= 0) && (SrcAddr
== NULL
)) {
459 SrcAddr
= &Instance
->Mode
.CurrentAddress
;
462 if (EFI_ERROR (EfiAcquireLockOrFail (&GlobalData
->Lock
))) {
463 return EFI_ACCESS_DENIED
;
466 ReturnValue
= GlobalData
->NtNetUtilityTable
.Transmit (
467 Instance
->InterfaceInfo
.InterfaceIndex
,
476 EfiReleaseLock (&GlobalData
->Lock
);
478 if (ReturnValue
< 0) {
479 return EFI_DEVICE_ERROR
;
487 Receive network data.
489 @param This Context pointer.
490 @param HeaderSize Optional parameter and is a pointer to the header
491 portion of the data received.
492 @param BuffSize Pointer to the length of the Buffer on entry and
493 contains the length of the received data on return
494 @param Buffer Pointer to the memory for the received data
495 @param SourceAddr Optional parameter, is a pointer to contain the
496 source ethernet address on return
497 @param DestinationAddr Optional parameter, is a pointer to contain the
498 destination ethernet address on return.
499 @param Protocol Optional parameter, is a pointer to contain the
500 Protocol type from the ethernet header on return.
502 @retval EFI_SUCCESS A packet is received and put into the buffer.
503 @retval EFI_BUFFER_TOO_SMALL The provided buffer is too small to receive the
505 @retval EFI_NOT_READY There is no packet received.
510 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
511 OUT UINTN
*HeaderSize
,
512 IN OUT UINTN
*BuffSize
,
514 OUT EFI_MAC_ADDRESS
*SourceAddr
,
515 OUT EFI_MAC_ADDRESS
*DestinationAddr
,
519 SNPNT32_INSTANCE_DATA
*Instance
;
520 SNPNT32_GLOBAL_DATA
*GlobalData
;
523 Instance
= SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This
);
525 GlobalData
= Instance
->GlobalData
;
527 ASSERT (GlobalData
->NtNetUtilityTable
.Receive
!= NULL
);
529 if (EFI_ERROR (EfiAcquireLockOrFail (&GlobalData
->Lock
))) {
530 return EFI_ACCESS_DENIED
;
533 ReturnValue
= GlobalData
->NtNetUtilityTable
.Receive (
534 Instance
->InterfaceInfo
.InterfaceIndex
,
539 EfiReleaseLock (&GlobalData
->Lock
);
541 if (ReturnValue
< 0) {
542 if (ReturnValue
== -100) {
543 return EFI_BUFFER_TOO_SMALL
;
546 return EFI_DEVICE_ERROR
;
547 } else if (ReturnValue
== 0) {
548 return EFI_NOT_READY
;
551 if (HeaderSize
!= NULL
) {
555 if (SourceAddr
!= NULL
) {
556 ZeroMem (SourceAddr
, sizeof (EFI_MAC_ADDRESS
));
557 CopyMem (SourceAddr
, ((UINT8
*) Buffer
) + 6, 6);
560 if (DestinationAddr
!= NULL
) {
561 ZeroMem (DestinationAddr
, sizeof (EFI_MAC_ADDRESS
));
562 CopyMem (DestinationAddr
, ((UINT8
*) Buffer
), 6);
565 if (Protocol
!= NULL
) {
566 *Protocol
= NTOHS (*((UINT16
*) (((UINT8
*) Buffer
) + 12)));
572 SNPNT32_INSTANCE_DATA gSnpNt32InstanceTemplate
= {
573 SNP_NT32_INSTANCE_SIGNATURE
, // Signature
579 NULL
, // DeviceHandle
582 EFI_SIMPLE_NETWORK_PROTOCOL_REVISION
, // Revision
583 SnpNt32Start
, // Start
585 SnpNt32Initialize
, // Initialize
586 SnpNt32Reset
, // Reset
587 SnpNt32Shutdown
, // Shutdown
588 SnpNt32ReceiveFilters
, // ReceiveFilters
589 SnpNt32StationAddress
, // StationAddress
590 SnpNt32Statistics
, // Statistics
591 SnpNt32McastIptoMac
, // MCastIpToMac
592 SnpNt32Nvdata
, // NvData
593 SnpNt32GetStatus
, // GetStatus
594 SnpNt32Transmit
, // Transmit
595 SnpNt32Receive
, // Receive
596 NULL
, // WaitForPacket
600 EfiSimpleNetworkInitialized
, // State
601 NET_ETHER_ADDR_LEN
, // HwAddressSize
602 NET_ETHER_HEADER_SIZE
, // MediaHeaderSize
603 1500, // MaxPacketSize
605 0, // NvRamAccessSize
606 0, // ReceiveFilterMask
607 0, // ReceiveFilterSetting
608 MAX_MCAST_FILTER_CNT
, // MaxMCastFilterCount
609 0, // MCastFilterCount
618 }, // BroadcastAddress
621 }, // PermanentAddress
622 NET_IFTYPE_ETHERNET
, // IfType
623 FALSE
, // MacAddressChangeable
624 FALSE
, // MultipleTxSupported
625 FALSE
, // MediaPresentSupported
635 Initialize the driver's global data.
637 @param This Pointer to the global context data.
639 @retval EFI_SUCCESS The global data is initialized.
640 @retval EFI_NOT_FOUND The required DLL is not found.
644 SnpNt32InitializeGlobalData (
645 IN SNPNT32_GLOBAL_DATA
*This
649 CHAR16
*DllFileNameU
;
652 BOOLEAN NetUtilityLibInitDone
;
653 NT_NET_INTERFACE_INFO NetInterfaceInfoBuffer
[MAX_INTERFACE_INFO_NUMBER
];
654 SNPNT32_INSTANCE_DATA
*Instance
;
656 UINT32 InterfaceCount
;
658 ASSERT (This
!= NULL
);
660 NetUtilityLibInitDone
= FALSE
;
661 InterfaceCount
= MAX_INTERFACE_INFO_NUMBER
;
663 InitializeListHead (&This
->InstanceList
);
664 EfiInitializeLock (&This
->Lock
, TPL_CALLBACK
);
667 // Get the WinNT thunk
669 Status
= gBS
->LocateProtocol (&gEfiWinNtThunkProtocolGuid
, NULL
, &This
->WinNtThunk
);
671 if (EFI_ERROR (Status
)) {
675 ASSERT (This
->WinNtThunk
!= NULL
);
677 DllFileNameU
= NETWORK_LIBRARY_NAME_U
;
680 // Load network utility library
682 This
->NetworkLibraryHandle
= This
->WinNtThunk
->LoadLibraryEx (DllFileNameU
, NULL
, 0);
684 if (NULL
== This
->NetworkLibraryHandle
) {
685 return EFI_NOT_FOUND
;
688 This
->NtNetUtilityTable
.Initialize
= (NT_NET_INITIALIZE
) This
->WinNtThunk
->GetProcAddress (
689 This
->NetworkLibraryHandle
,
690 NETWORK_LIBRARY_INITIALIZE
693 if (NULL
== This
->NtNetUtilityTable
.Initialize
) {
694 Status
= EFI_NOT_FOUND
;
698 This
->NtNetUtilityTable
.Finalize
= (NT_NET_FINALIZE
) This
->WinNtThunk
->GetProcAddress (
699 This
->NetworkLibraryHandle
,
700 NETWORK_LIBRARY_FINALIZE
703 if (NULL
== This
->NtNetUtilityTable
.Finalize
) {
704 Status
= EFI_NOT_FOUND
;
708 This
->NtNetUtilityTable
.SetReceiveFilter
= (NT_NET_SET_RECEIVE_FILTER
) This
->WinNtThunk
->GetProcAddress (
709 This
->NetworkLibraryHandle
,
710 NETWORK_LIBRARY_SET_RCV_FILTER
713 if (NULL
== This
->NtNetUtilityTable
.SetReceiveFilter
) {
714 Status
= EFI_NOT_FOUND
;
718 This
->NtNetUtilityTable
.Receive
= (NT_NET_RECEIVE
) This
->WinNtThunk
->GetProcAddress (
719 This
->NetworkLibraryHandle
,
720 NETWORK_LIBRARY_RECEIVE
723 if (NULL
== This
->NtNetUtilityTable
.Receive
) {
724 Status
= EFI_NOT_FOUND
;
728 This
->NtNetUtilityTable
.Transmit
= (NT_NET_TRANSMIT
) This
->WinNtThunk
->GetProcAddress (
729 This
->NetworkLibraryHandle
,
730 NETWORK_LIBRARY_TRANSMIT
733 if (NULL
== This
->NtNetUtilityTable
.Transmit
) {
734 Status
= EFI_NOT_FOUND
;
738 // Initialize the network utility library
739 // And enumerate the interfaces in NT32 host
741 ReturnValue
= This
->NtNetUtilityTable
.Initialize (&InterfaceCount
, &NetInterfaceInfoBuffer
[0]);
742 if (ReturnValue
<= 0) {
743 Status
= EFI_DEVICE_ERROR
;
747 NetUtilityLibInitDone
= TRUE
;
749 if (InterfaceCount
== 0) {
750 Status
= EFI_NOT_FOUND
;
754 // Create fake SNP instances
756 for (Index
= 0; Index
< InterfaceCount
; Index
++) {
758 Instance
= AllocatePool (sizeof (SNPNT32_INSTANCE_DATA
));
760 if (NULL
== Instance
) {
761 Status
= EFI_OUT_OF_RESOURCES
;
765 // Copy the content from a template
767 CopyMem (Instance
, &gSnpNt32InstanceTemplate
, sizeof (SNPNT32_INSTANCE_DATA
));
770 // Set the interface information.
772 Instance
->InterfaceInfo
= NetInterfaceInfoBuffer
[Index
];
774 // Initialize this instance
776 Status
= This
->InitializeInstanceData (This
, Instance
);
777 if (EFI_ERROR (Status
)) {
779 gBS
->FreePool (Instance
);
783 // Insert this instance into the instance list
785 InsertTailList (&This
->InstanceList
, &Instance
->Entry
);
792 while (!IsListEmpty (&This
->InstanceList
)) {
794 Entry
= This
->InstanceList
.ForwardLink
;
796 Instance
= NET_LIST_USER_STRUCT_S (Entry
, SNPNT32_INSTANCE_DATA
, Entry
, SNP_NT32_INSTANCE_SIGNATURE
);
798 RemoveEntryList (Entry
);
800 This
->CloseInstance (This
, Instance
);
801 gBS
->FreePool (Instance
);
804 if (NetUtilityLibInitDone
) {
806 ASSERT (This
->WinNtThunk
!= NULL
);
808 if (This
->NtNetUtilityTable
.Finalize
!= NULL
) {
809 This
->NtNetUtilityTable
.Finalize ();
810 This
->NtNetUtilityTable
.Finalize
= NULL
;
819 Initialize the snpnt32 driver instance.
821 @param This Pointer to the SnpNt32 global data.
822 @param Instance Pointer to the instance context data.
824 @retval EFI_SUCCESS The driver instance is initialized.
828 SnpNt32InitializeInstanceData (
829 IN SNPNT32_GLOBAL_DATA
*This
,
830 IN SNPNT32_INSTANCE_DATA
*Instance
834 EFI_DEV_PATH EndNode
;
837 Instance
->GlobalData
= This
;
838 Instance
->Snp
.Mode
= &Instance
->Mode
;
840 // Set broadcast address
842 SetMem (&Instance
->Mode
.BroadcastAddress
, sizeof (EFI_MAC_ADDRESS
), 0xFF);
845 // Copy Current/PermanentAddress MAC address
847 Instance
->Mode
.CurrentAddress
= Instance
->InterfaceInfo
.MacAddr
;
848 Instance
->Mode
.PermanentAddress
= Instance
->InterfaceInfo
.MacAddr
;
851 // Since the fake SNP is based on a real NIC, to avoid conflict with the host
852 // NIC network stack, we use a different MAC address.
853 // So just change the last byte of the MAC address for the real NIC.
855 Instance
->Mode
.CurrentAddress
.Addr
[NET_ETHER_ADDR_LEN
- 1]++;
858 // Create a fake device path for the instance
860 ZeroMem (&Node
, sizeof (Node
));
862 Node
.DevPath
.Type
= MESSAGING_DEVICE_PATH
;
863 Node
.DevPath
.SubType
= MSG_MAC_ADDR_DP
;
864 SetDevicePathNodeLength (&Node
.DevPath
, sizeof (MAC_ADDR_DEVICE_PATH
));
867 &Node
.MacAddr
.MacAddress
,
868 &Instance
->Mode
.CurrentAddress
,
869 sizeof (EFI_MAC_ADDRESS
)
872 Node
.MacAddr
.IfType
= Instance
->Mode
.IfType
;
874 SetDevicePathEndNode (&EndNode
.DevPath
);
876 Instance
->DevicePath
= AppendDevicePathNode (
882 // Create a fake device handle for the fake SNP
884 Status
= gBS
->InstallMultipleProtocolInterfaces (
885 &Instance
->DeviceHandle
,
886 &gEfiSimpleNetworkProtocolGuid
,
888 &gEfiDevicePathProtocolGuid
,
889 Instance
->DevicePath
,
892 if (EFI_ERROR (Status
)) {
904 Close the SnpNt32 driver instance.
906 @param This Pointer to the SnpNt32 global data.
907 @param Instance Pointer to the instance context data.
909 @retval EFI_SUCCESS The instance is closed.
913 SnpNt32CloseInstance (
914 IN SNPNT32_GLOBAL_DATA
*This
,
915 IN SNPNT32_INSTANCE_DATA
*Instance
918 ASSERT (This
!= NULL
);
919 ASSERT (Instance
!= NULL
);
921 gBS
->UninstallMultipleProtocolInterfaces (
922 Instance
->DeviceHandle
,
923 &gEfiSimpleNetworkProtocolGuid
,
925 &gEfiDevicePathProtocolGuid
,
926 Instance
->DevicePath
,
930 if (Instance
->DevicePath
!= NULL
) {
931 gBS
->FreePool (Instance
->DevicePath
);
939 Unload the SnpNt32 driver.
941 @param ImageHandle The handle of the driver image.
943 @retval EFI_SUCCESS The driver is unloaded.
944 @retval other Some error occurs.
950 IN EFI_HANDLE ImageHandle
954 SNPNT32_GLOBAL_DATA
*This
;
956 SNPNT32_INSTANCE_DATA
*Instance
;
958 This
= &gSnpNt32GlobalData
;
960 Status
= NetLibDefaultUnload (ImageHandle
);
962 if (EFI_ERROR (Status
)) {
966 while (!IsListEmpty (&This
->InstanceList
)) {
968 // Walkthrough the interfaces and remove all the SNP instance
970 Entry
= This
->InstanceList
.ForwardLink
;
972 Instance
= NET_LIST_USER_STRUCT_S (Entry
, SNPNT32_INSTANCE_DATA
, Entry
, SNP_NT32_INSTANCE_SIGNATURE
);
974 RemoveEntryList (Entry
);
976 This
->CloseInstance (This
, Instance
);
977 gBS
->FreePool (Instance
);
980 if (This
->NtNetUtilityTable
.Finalize
!= NULL
) {
981 This
->NtNetUtilityTable
.Finalize ();
984 This
->WinNtThunk
->FreeLibrary (This
->NetworkLibraryHandle
);
991 InitializeSnpNt32river (
992 IN EFI_HANDLE ImageHandle
,
993 IN EFI_SYSTEM_TABLE
*SystemTable
999 Install DriverBinding Protocol for the Win NT Bus driver on the drivers
1004 ImageHandle - The handle of this image.
1005 SystemTable - Pointer to the EFI system table.
1009 EFI_SUCEESS - The protocols are installed and the SnpNt32 is initialized.
1010 other - Some error occurs.
1018 // Install the Driver Protocols
1021 Status
= EfiLibInstallDriverBindingComponentName2 (
1024 &gSnpNt32DriverBinding
,
1026 &gSnpNt32DriverComponentName
,
1027 &gSnpNt32DriverComponentName2
1029 if (EFI_ERROR (Status
)) {
1034 // Initialize the global data
1036 Status
= SnpNt32InitializeGlobalData (&gSnpNt32GlobalData
);
1037 if (EFI_ERROR (Status
)) {
1038 SnpNt32Unload (ImageHandle
);