3 Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>
4 Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 #include "EmuSnpDxe.h"
26 EFI_SIMPLE_NETWORK_PROTOCOL gEmuSnpTemplate
= {
27 EFI_SIMPLE_NETWORK_PROTOCOL_REVISION
,
41 NULL
, // WaitForPacket
45 EFI_SIMPLE_NETWORK_MODE gEmuSnpModeTemplate
= {
46 EfiSimpleNetworkStopped
, // State
47 NET_ETHER_ADDR_LEN
, // HwAddressSize
48 NET_ETHER_HEADER_SIZE
, // MediaHeaderSize
49 1500, // MaxPacketSize
52 0, // ReceiveFilterMask
53 0, // ReceiveFilterSetting
54 MAX_MCAST_FILTER_CNT
, // MaxMCastFilterCount
55 0, // MCastFilterCount
64 }, // BroadcastAddress
67 }, // PermanentAddress
68 NET_IFTYPE_ETHERNET
, // IfType
69 FALSE
, // MacAddressChangeable
70 FALSE
, // MultipleTxSupported
71 FALSE
, // MediaPresentSupported
77 Changes the state of a network interface from "stopped" to "started".
79 @param This Protocol instance pointer.
81 @retval EFI_SUCCESS Always succeeds.
87 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
91 EMU_SNP_PRIVATE_DATA
*Private
;
93 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
95 Status
= Private
->Io
->Start (Private
->Io
);
101 Changes the state of a network interface from "started" to "stopped".
103 @param This Protocol instance pointer.
105 @retval EFI_SUCCESS Always succeeds.
111 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
115 EMU_SNP_PRIVATE_DATA
*Private
;
117 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
119 Status
= Private
->Io
->Stop (Private
->Io
);
125 Resets a network adapter and allocates the transmit and receive buffers
126 required by the network interface; optionally, also requests allocation
127 of additional transmit and receive buffers.
129 @param This Protocol instance pointer.
130 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space
131 that the driver should allocate for the network interface.
132 Some network interfaces will not be able to use the extra
133 buffer, and the caller will not know if it is actually
135 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space
136 that the driver should allocate for the network interface.
137 Some network interfaces will not be able to use the extra
138 buffer, and the caller will not know if it is actually
141 @retval EFI_SUCCESS Always succeeds.
147 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
148 IN UINTN ExtraRxBufferSize OPTIONAL
,
149 IN UINTN ExtraTxBufferSize OPTIONAL
153 EMU_SNP_PRIVATE_DATA
*Private
;
155 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
157 Status
= Private
->Io
->Initialize (Private
->Io
, ExtraRxBufferSize
, ExtraTxBufferSize
);
162 Resets a network adapter and re-initializes it with the parameters that were
163 provided in the previous call to Initialize().
165 @param This Protocol instance pointer.
166 @param ExtendedVerification Indicates that the driver may perform a more
167 exhaustive verification operation of the device
170 @retval EFI_SUCCESS Always succeeds.
176 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
177 IN BOOLEAN ExtendedVerification
181 EMU_SNP_PRIVATE_DATA
*Private
;
183 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
185 Status
= Private
->Io
->Reset (Private
->Io
, ExtendedVerification
);
190 Resets a network adapter and leaves it in a state that is safe for
191 another driver to initialize.
193 @param This Protocol instance pointer.
195 @retval EFI_SUCCESS Always succeeds.
201 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
205 EMU_SNP_PRIVATE_DATA
*Private
;
207 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
209 Status
= Private
->Io
->Shutdown (Private
->Io
);
214 Manages the multicast receive filters of a network interface.
216 @param This Protocol instance pointer.
217 @param EnableBits A bit mask of receive filters to enable on the network interface.
218 @param DisableBits A bit mask of receive filters to disable on the network interface.
219 @param ResetMcastFilter Set to TRUE to reset the contents of the multicast receive
220 filters on the network interface to their default values.
221 @param McastFilterCount Number of multicast HW MAC addresses in the new
222 MCastFilter list. This value must be less than or equal to
223 the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This
224 field is optional if ResetMCastFilter is TRUE.
225 @param McastFilter A pointer to a list of new multicast receive filter HW MAC
226 addresses. This list will replace any existing multicast
227 HW MAC address list. This field is optional if
228 ResetMCastFilter is TRUE.
230 @retval EFI_SUCCESS The multicast receive filter list was updated.
231 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
236 EmuSnpReceiveFilters (
237 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
238 IN UINT32 EnableBits
,
239 IN UINT32 DisableBits
,
240 IN BOOLEAN ResetMcastFilter
,
241 IN UINTN McastFilterCount OPTIONAL
,
242 IN EFI_MAC_ADDRESS
*McastFilter OPTIONAL
246 EMU_SNP_PRIVATE_DATA
*Private
;
248 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
250 Status
= Private
->Io
->ReceiveFilters (
262 Modifies or resets the current station address, if supported.
264 @param This Protocol instance pointer.
265 @param Reset Flag used to reset the station address to the network interfaces
267 @param NewMacAddr New station address to be used for the network interface.
269 @retval EFI_UNSUPPORTED Not supported yet.
274 EmuSnpStationAddress (
275 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
277 IN EFI_MAC_ADDRESS
*NewMacAddr OPTIONAL
281 EMU_SNP_PRIVATE_DATA
*Private
;
283 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
285 Status
= Private
->Io
->StationAddress (Private
->Io
, Reset
, NewMacAddr
);
290 Resets or collects the statistics on a network interface.
292 @param This Protocol instance pointer.
293 @param Reset Set to TRUE to reset the statistics for the network interface.
294 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On
295 output the size, in bytes, of the resulting table of
297 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
298 contains the statistics.
300 @retval EFI_SUCCESS The statistics were collected from the network interface.
301 @retval EFI_NOT_STARTED The network interface has not been started.
302 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
303 size needed to hold the statistics is returned in
305 @retval EFI_UNSUPPORTED Not supported yet.
311 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
313 IN OUT UINTN
*StatisticsSize OPTIONAL
,
314 OUT EFI_NETWORK_STATISTICS
*StatisticsTable OPTIONAL
318 EMU_SNP_PRIVATE_DATA
*Private
;
320 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
322 Status
= Private
->Io
->Statistics (Private
->Io
, Reset
, StatisticsSize
, StatisticsTable
);
327 Converts a multicast IP address to a multicast HW MAC address.
329 @param This Protocol instance pointer.
330 @param Ipv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set
331 to FALSE if the multicast IP address is IPv4 [RFC 791].
332 @param Ip The multicast IP address that is to be converted to a multicast
334 @param Mac The multicast HW MAC address that is to be generated from IP.
336 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast
338 @retval EFI_NOT_STARTED The network interface has not been started.
339 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
340 size needed to hold the statistics is returned in
342 @retval EFI_UNSUPPORTED Not supported yet.
348 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
350 IN EFI_IP_ADDRESS
*Ip
,
351 OUT EFI_MAC_ADDRESS
*Mac
355 EMU_SNP_PRIVATE_DATA
*Private
;
357 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
359 Status
= Private
->Io
->MCastIpToMac (Private
->Io
, Ipv6
, Ip
, Mac
);
365 Performs read and write operations on the NVRAM device attached to a
368 @param This Protocol instance pointer.
369 @param ReadOrWrite TRUE for read operations, FALSE for write operations.
370 @param Offset Byte offset in the NVRAM device at which to start the read or
371 write operation. This must be a multiple of NvRamAccessSize and
373 @param BufferSize The number of bytes to read or write from the NVRAM device.
374 This must also be a multiple of NvramAccessSize.
375 @param Buffer A pointer to the data buffer.
377 @retval EFI_UNSUPPORTED Not supported yet.
383 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
384 IN BOOLEAN ReadOrWrite
,
391 EMU_SNP_PRIVATE_DATA
*Private
;
393 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
395 Status
= Private
->Io
->NvData (Private
->Io
, ReadOrWrite
, Offset
, BufferSize
, Buffer
);
401 Reads the current interrupt status and recycled transmit buffer status from
404 @param This Protocol instance pointer.
405 @param InterruptStatus A pointer to the bit mask of the currently active interrupts
406 If this is NULL, the interrupt status will not be read from
407 the device. If this is not NULL, the interrupt status will
408 be read from the device. When the interrupt status is read,
409 it will also be cleared. Clearing the transmit interrupt
410 does not empty the recycled transmit buffer array.
411 @param TxBuffer Recycled transmit buffer address. The network interface will
412 not transmit if its internal recycled transmit buffer array
413 is full. Reading the transmit buffer does not clear the
414 transmit interrupt. If this is NULL, then the transmit buffer
415 status will not be read. If there are no transmit buffers to
416 recycle and TxBuf is not NULL, * TxBuf will be set to NULL.
418 @retval EFI_SUCCESS Always succeeds.
424 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
425 OUT UINT32
*InterruptStatus
,
430 EMU_SNP_PRIVATE_DATA
*Private
;
432 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
434 Status
= Private
->Io
->GetStatus (Private
->Io
, InterruptStatus
, TxBuffer
);
440 Places a packet in the transmit queue of a network interface.
442 @param This Protocol instance pointer.
443 @param HeaderSize The size, in bytes, of the media header to be filled in by
444 the Transmit() function. If HeaderSize is non-zero, then it
445 must be equal to This->Mode->MediaHeaderSize and the DestAddr
446 and Protocol parameters must not be NULL.
447 @param BufferSize The size, in bytes, of the entire packet (media header and
448 data) to be transmitted through the network interface.
449 @param Buffer A pointer to the packet (media header followed by data) to be
450 transmitted. This parameter cannot be NULL. If HeaderSize is zero,
451 then the media header in Buffer must already be filled in by the
452 caller. If HeaderSize is non-zero, then the media header will be
453 filled in by the Transmit() function.
454 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter
455 is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then
456 This->Mode->CurrentAddress is used for the source HW MAC address.
457 @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this
458 parameter is ignored.
459 @param Protocol The type of header to build. If HeaderSize is zero, then this
460 parameter is ignored. See RFC 1700, section "Ether Types", for
463 @retval EFI_SUCCESS The packet was placed on the transmit queue.
464 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
465 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
466 @retval EFI_NOT_STARTED The network interface has not been started.
472 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
476 IN EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
477 IN EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
478 IN UINT16
*Protocol OPTIONAL
482 EMU_SNP_PRIVATE_DATA
*Private
;
484 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
486 Status
= Private
->Io
->Transmit (
499 Receives a packet from a network interface.
501 @param This Protocol instance pointer.
502 @param HeaderSize The size, in bytes, of the media header received on the network
503 interface. If this parameter is NULL, then the media header size
504 will not be returned.
505 @param BuffSize On entry, the size, in bytes, of Buffer. On exit, the size, in
506 bytes, of the packet that was received on the network interface.
507 @param Buffer A pointer to the data buffer to receive both the media header and
509 @param SourceAddr The source HW MAC address. If this parameter is NULL, the
510 HW MAC source address will not be extracted from the media
512 @param DestinationAddr The destination HW MAC address. If this parameter is NULL,
513 the HW MAC destination address will not be extracted from the
515 @param Protocol The media header type. If this parameter is NULL, then the
516 protocol will not be extracted from the media header. See
517 RFC 1700 section "Ether Types" for examples.
519 @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has
520 been updated to the number of bytes received.
521 @retval EFI_NOT_READY The network interface is too busy to accept this transmit
523 @retval EFI_NOT_STARTED The network interface has not been started.
524 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
525 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
531 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
532 OUT UINTN
*HeaderSize OPTIONAL
,
533 IN OUT UINTN
*BuffSize
,
535 OUT EFI_MAC_ADDRESS
*SourceAddr OPTIONAL
,
536 OUT EFI_MAC_ADDRESS
*DestinationAddr OPTIONAL
,
537 OUT UINT16
*Protocol OPTIONAL
541 EMU_SNP_PRIVATE_DATA
*Private
;
543 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
545 Status
= Private
->Io
->Receive (
560 Test to see if this driver supports ControllerHandle. This service
561 is called by the EFI boot service ConnectController(). In
562 order to make drivers as small as possible, there are a few calling
563 restrictions for this service. ConnectController() must
564 follow these calling restrictions. If any other agent wishes to call
565 Supported() it must also follow these calling restrictions.
567 @param This Protocol instance pointer.
568 @param ControllerHandle Handle of device to test
569 @param RemainingDevicePath Optional parameter use to pick a specific child
572 @retval EFI_SUCCESS This driver supports this device
573 @retval EFI_UNSUPPORTED This driver does not support this device
578 EmuSnpDriverBindingSupported (
579 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
580 IN EFI_HANDLE ControllerHandle
,
581 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
585 EMU_IO_THUNK_PROTOCOL
*EmuIoThunk
;
586 MAC_ADDR_DEVICE_PATH
*Node
;
587 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
589 if (RemainingDevicePath
!= NULL
) {
590 if (!IsDevicePathEnd (RemainingDevicePath
)) {
591 Node
= (MAC_ADDR_DEVICE_PATH
*)RemainingDevicePath
;
592 if (Node
->Header
.Type
!= MESSAGING_DEVICE_PATH
||
593 Node
->Header
.SubType
!= MSG_MAC_ADDR_DP
) {
594 // If the remaining device path does not match we don't support the request
595 return EFI_UNSUPPORTED
;
602 // Open the IO Abstraction(s) needed to perform the supported test
604 Status
= gBS
->OpenProtocol (
606 &gEmuIoThunkProtocolGuid
,
607 (VOID
**)&EmuIoThunk
,
608 This
->DriverBindingHandle
,
610 EFI_OPEN_PROTOCOL_BY_DRIVER
612 if (EFI_ERROR (Status
)) {
617 // Close the I/O Abstraction(s) used to perform the supported test
621 &gEmuIoThunkProtocolGuid
,
622 This
->DriverBindingHandle
,
628 // Open the EFI Device Path protocol needed to perform the supported test
630 Status
= gBS
->OpenProtocol (
632 &gEfiDevicePathProtocolGuid
,
633 (VOID
**) &ParentDevicePath
,
634 This
->DriverBindingHandle
,
636 EFI_OPEN_PROTOCOL_BY_DRIVER
638 if (Status
== EFI_ALREADY_STARTED
) {
642 if (EFI_ERROR (Status
)) {
647 // Make sure GUID is for a SNP handle.
649 Status
= EFI_UNSUPPORTED
;
650 if (CompareGuid (EmuIoThunk
->Protocol
, &gEmuSnpProtocolGuid
)) {
651 Status
= EFI_SUCCESS
;
655 // Close protocol, don't use device path protocol in the Support() function
659 &gEfiDevicePathProtocolGuid
,
660 This
->DriverBindingHandle
,
669 Start this driver on ControllerHandle. This service is called by the
670 EFI boot service ConnectController(). In order to make
671 drivers as small as possible, there are a few calling restrictions for
672 this service. ConnectController() must follow these
673 calling restrictions. If any other agent wishes to call Start() it
674 must also follow these calling restrictions.
676 @param This Protocol instance pointer.
677 @param ControllerHandle Handle of device to bind driver to
678 @param RemainingDevicePath Optional parameter use to pick a specific child
681 @retval EFI_SUCCESS Always succeeds.
686 EmuSnpDriverBindingStart (
687 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
688 IN EFI_HANDLE ControllerHandle
,
689 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
693 EMU_IO_THUNK_PROTOCOL
*EmuIoThunk
;
694 EMU_SNP_PRIVATE_DATA
*Private
;
695 MAC_ADDR_DEVICE_PATH Node
;
696 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
701 // Grab the protocols we need
703 Status
= gBS
->OpenProtocol(
705 &gEfiDevicePathProtocolGuid
,
706 ( VOID
** ) &ParentDevicePath
,
707 This
->DriverBindingHandle
,
709 EFI_OPEN_PROTOCOL_BY_DRIVER
711 if (EFI_ERROR (Status
) && Status
) {
715 Status
= gBS
->OpenProtocol (
717 &gEmuIoThunkProtocolGuid
,
718 (VOID
**)&EmuIoThunk
,
719 This
->DriverBindingHandle
,
721 EFI_OPEN_PROTOCOL_BY_DRIVER
723 if (EFI_ERROR (Status
)) {
727 if (!CompareGuid (EmuIoThunk
->Protocol
, &gEmuSnpProtocolGuid
)) {
728 return EFI_UNSUPPORTED
;
731 Status
= EmuIoThunk
->Open (EmuIoThunk
);
732 if (EFI_ERROR (Status
)) {
737 // Allocate the private data.
739 Private
= AllocateZeroPool (sizeof (EMU_SNP_PRIVATE_DATA
));
740 if (Private
== NULL
) {
741 Status
= EFI_OUT_OF_RESOURCES
;
745 CopyMem (&Private
->Snp
, &gEmuSnpTemplate
, sizeof (EFI_SIMPLE_NETWORK_PROTOCOL
));
746 CopyMem (&Private
->Mode
, &gEmuSnpModeTemplate
, sizeof (EFI_SIMPLE_NETWORK_MODE
));
748 Private
->Signature
= EMU_SNP_PRIVATE_DATA_SIGNATURE
;
749 Private
->IoThunk
= EmuIoThunk
;
750 Private
->Io
= EmuIoThunk
->Interface
;
751 Private
->EfiHandle
= ControllerHandle
;
752 Private
->DeviceHandle
= NULL
;
753 Private
->Snp
.Mode
= &Private
->Mode
;
754 Private
->ControllerNameTable
= NULL
;
757 Status
= Private
->Io
->CreateMapping (Private
->Io
, &Private
->Mode
);
758 if (EFI_ERROR (Status
)) {
763 // Build the device path by appending the MAC node to the ParentDevicePath
764 // from the EmuIo handle.
766 ZeroMem (&Node
, sizeof (MAC_ADDR_DEVICE_PATH
));
768 Node
.Header
.Type
= MESSAGING_DEVICE_PATH
;
769 Node
.Header
.SubType
= MSG_MAC_ADDR_DP
;
770 Node
.IfType
= Private
->Mode
.IfType
;
772 SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
* )&Node
, sizeof (MAC_ADDR_DEVICE_PATH
));
774 CopyMem (&Node
.MacAddress
, &Private
->Mode
.CurrentAddress
, sizeof (EFI_MAC_ADDRESS
));
777 // Build the device path by appending the MAC node to the ParentDevicePath from the EmuIo handle.
779 Private
->DevicePath
= AppendDevicePathNode (ParentDevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&Node
);
780 if ( Private
->DevicePath
== NULL
) {
781 Status
= EFI_OUT_OF_RESOURCES
;
787 gEmuSnpDriverComponentName
.SupportedLanguages
,
788 &Private
->ControllerNameTable
,
789 EmuIoThunk
->ConfigString
,
795 gEmuSnpDriverComponentName2
.SupportedLanguages
,
796 &Private
->ControllerNameTable
,
797 EmuIoThunk
->ConfigString
,
802 // Create Child Handle
804 Status
= gBS
->InstallMultipleProtocolInterfaces(
805 &Private
->DeviceHandle
,
806 &gEfiSimpleNetworkProtocolGuid
, &Private
->Snp
,
807 &gEfiDevicePathProtocolGuid
, Private
->DevicePath
,
810 if (EFI_ERROR (Status
)) {
815 // Open For Child Device
817 Status
= gBS
->OpenProtocol (
819 &gEmuIoThunkProtocolGuid
,
820 (VOID
**)&EmuIoThunk
,
821 This
->DriverBindingHandle
,
822 Private
->DeviceHandle
,
823 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
827 if (EFI_ERROR (Status
)) {
828 if (Private
!= NULL
) {
831 if (ParentDevicePath
!= NULL
) {
834 &gEfiDevicePathProtocolGuid
,
835 This
->DriverBindingHandle
,
845 Stop this driver on ControllerHandle. This service is called by the
846 EFI boot service DisconnectController(). In order to
847 make drivers as small as possible, there are a few calling
848 restrictions for this service. DisconnectController()
849 must follow these calling restrictions. If any other agent wishes
850 to call Stop() it must also follow these calling restrictions.
852 @param This Protocol instance pointer.
853 @param ControllerHandle Handle of device to stop driver on
854 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
855 children is zero stop the entire bus driver.
856 @param ChildHandleBuffer List of Child Handles to Stop.
858 @retval EFI_SUCCESS Always succeeds.
863 EmuSnpDriverBindingStop (
864 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
865 IN EFI_HANDLE ControllerHandle
,
866 IN UINTN NumberOfChildren
,
867 IN EFI_HANDLE
*ChildHandleBuffer
871 EMU_SNP_PRIVATE_DATA
*Private
= NULL
;
872 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
875 // Complete all outstanding transactions to Controller.
876 // Don't allow any new transaction to Controller to be started.
878 if (NumberOfChildren
== 0) {
880 // Close the bus driver
882 Status
= gBS
->CloseProtocol (
884 &gEmuIoThunkProtocolGuid
,
885 This
->DriverBindingHandle
,
889 Status
= gBS
->CloseProtocol (
891 &gEfiDevicePathProtocolGuid
,
892 This
->DriverBindingHandle
,
898 ASSERT (NumberOfChildren
== 1);
902 // Get our context back.
904 Status
= gBS
->OpenProtocol(
905 ChildHandleBuffer
[0],
906 &gEfiSimpleNetworkProtocolGuid
,
908 This
->DriverBindingHandle
,
910 EFI_OPEN_PROTOCOL_GET_PROTOCOL
912 if (EFI_ERROR (Status
)) {
913 return EFI_DEVICE_ERROR
;
916 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (Snp
);
917 Status
= Private
->IoThunk
->Close (Private
->IoThunk
);
919 Status
= gBS
->CloseProtocol(
920 ChildHandleBuffer
[0],
921 &gEmuIoThunkProtocolGuid
,
922 This
->DriverBindingHandle
,
923 Private
->DeviceHandle
926 Status
= gBS
->UninstallMultipleProtocolInterfaces(
927 ChildHandleBuffer
[0],
928 &gEfiSimpleNetworkProtocolGuid
, &Private
->Snp
,
929 &gEfiDevicePathProtocolGuid
, Private
->DevicePath
,
933 FreePool (Private
->DevicePath
);
934 FreeUnicodeStringTable (Private
->ControllerNameTable
);
941 EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding
= {
942 EmuSnpDriverBindingSupported
,
943 EmuSnpDriverBindingStart
,
944 EmuSnpDriverBindingStop
,
953 This is the declaration of an EFI image entry point. This entry point is
954 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
955 both device drivers and bus drivers.
957 @param ImageHandle The firmware allocated handle for the UEFI image.
958 @param SystemTable A pointer to the EFI System Table.
960 @retval EFI_SUCCESS The operation completed successfully.
961 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
966 InitializeEmuSnpDriver (
967 IN EFI_HANDLE ImageHandle
,
968 IN EFI_SYSTEM_TABLE
*SystemTable
974 // Install the Driver Protocols
976 Status
= EfiLibInstallDriverBindingComponentName2(
979 &gEmuSnpDriverBinding
,
981 &gEmuSnpDriverComponentName
,
982 &gEmuSnpDriverComponentName2