3 Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #include "EmuSnpDxe.h"
25 EFI_SIMPLE_NETWORK_PROTOCOL gEmuSnpTemplate
= {
26 EFI_SIMPLE_NETWORK_PROTOCOL_REVISION
,
40 NULL
, // WaitForPacket
48 Changes the state of a network interface from "stopped" to "started".
50 @param This Protocol instance pointer.
52 @retval EFI_SUCCESS Always succeeds.
58 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
62 EMU_SNP_PRIVATE_DATA
*Private
;
64 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
66 Status
= Private
->Io
->Start (Private
->Io
);
72 Changes the state of a network interface from "started" to "stopped".
74 @param This Protocol instance pointer.
76 @retval EFI_SUCCESS Always succeeds.
82 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
86 EMU_SNP_PRIVATE_DATA
*Private
;
88 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
90 Status
= Private
->Io
->Stop (Private
->Io
);
96 Resets a network adapter and allocates the transmit and receive buffers
97 required by the network interface; optionally, also requests allocation
98 of additional transmit and receive buffers.
100 @param This Protocol instance pointer.
101 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space
102 that the driver should allocate for the network interface.
103 Some network interfaces will not be able to use the extra
104 buffer, and the caller will not know if it is actually
106 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space
107 that the driver should allocate for the network interface.
108 Some network interfaces will not be able to use the extra
109 buffer, and the caller will not know if it is actually
112 @retval EFI_SUCCESS Always succeeds.
118 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
119 IN UINTN ExtraRxBufferSize OPTIONAL
,
120 IN UINTN ExtraTxBufferSize OPTIONAL
124 EMU_SNP_PRIVATE_DATA
*Private
;
126 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
128 Status
= Private
->Io
->Initialize (Private
->Io
, ExtraRxBufferSize
, ExtraTxBufferSize
);
133 Resets a network adapter and re-initializes it with the parameters that were
134 provided in the previous call to Initialize().
136 @param This Protocol instance pointer.
137 @param ExtendedVerification Indicates that the driver may perform a more
138 exhaustive verification operation of the device
141 @retval EFI_SUCCESS Always succeeds.
147 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
148 IN BOOLEAN ExtendedVerification
152 EMU_SNP_PRIVATE_DATA
*Private
;
154 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
156 Status
= Private
->Io
->Reset (Private
->Io
, ExtendedVerification
);
161 Resets a network adapter and leaves it in a state that is safe for
162 another driver to initialize.
164 @param This Protocol instance pointer.
166 @retval EFI_SUCCESS Always succeeds.
172 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
176 EMU_SNP_PRIVATE_DATA
*Private
;
178 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
180 Status
= Private
->Io
->Shutdown (Private
->Io
);
185 Manages the multicast receive filters of a network interface.
187 @param This Protocol instance pointer.
188 @param EnableBits A bit mask of receive filters to enable on the network interface.
189 @param DisableBits A bit mask of receive filters to disable on the network interface.
190 @param ResetMcastFilter Set to TRUE to reset the contents of the multicast receive
191 filters on the network interface to their default values.
192 @param McastFilterCount Number of multicast HW MAC addresses in the new
193 MCastFilter list. This value must be less than or equal to
194 the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This
195 field is optional if ResetMCastFilter is TRUE.
196 @param McastFilter A pointer to a list of new multicast receive filter HW MAC
197 addresses. This list will replace any existing multicast
198 HW MAC address list. This field is optional if
199 ResetMCastFilter is TRUE.
201 @retval EFI_SUCCESS The multicast receive filter list was updated.
202 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
207 EmuSnpReceiveFilters (
208 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
209 IN UINT32 EnableBits
,
210 IN UINT32 DisableBits
,
211 IN BOOLEAN ResetMcastFilter
,
212 IN UINTN McastFilterCount OPTIONAL
,
213 IN EFI_MAC_ADDRESS
*McastFilter OPTIONAL
217 EMU_SNP_PRIVATE_DATA
*Private
;
219 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
221 Status
= Private
->Io
->ReceiveFilters (
233 Modifies or resets the current station address, if supported.
235 @param This Protocol instance pointer.
236 @param Reset Flag used to reset the station address to the network interfaces
238 @param NewMacAddr New station address to be used for the network interface.
240 @retval EFI_UNSUPPORTED Not supported yet.
245 EmuSnpStationAddress (
246 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
248 IN EFI_MAC_ADDRESS
*NewMacAddr OPTIONAL
252 EMU_SNP_PRIVATE_DATA
*Private
;
254 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
256 Status
= Private
->Io
->StationAddress (Private
->Io
, Reset
, NewMacAddr
);
261 Resets or collects the statistics on a network interface.
263 @param This Protocol instance pointer.
264 @param Reset Set to TRUE to reset the statistics for the network interface.
265 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On
266 output the size, in bytes, of the resulting table of
268 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
269 contains the statistics.
271 @retval EFI_SUCCESS The statistics were collected from the network interface.
272 @retval EFI_NOT_STARTED The network interface has not been started.
273 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
274 size needed to hold the statistics is returned in
276 @retval EFI_UNSUPPORTED Not supported yet.
282 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
284 IN OUT UINTN
*StatisticsSize OPTIONAL
,
285 OUT EFI_NETWORK_STATISTICS
*StatisticsTable OPTIONAL
289 EMU_SNP_PRIVATE_DATA
*Private
;
291 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
293 Status
= Private
->Io
->Statistics (Private
->Io
, Reset
, StatisticsSize
, StatisticsTable
);
298 Converts a multicast IP address to a multicast HW MAC address.
300 @param This Protocol instance pointer.
301 @param Ipv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set
302 to FALSE if the multicast IP address is IPv4 [RFC 791].
303 @param Ip The multicast IP address that is to be converted to a multicast
305 @param Mac The multicast HW MAC address that is to be generated from IP.
307 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast
309 @retval EFI_NOT_STARTED The network interface has not been started.
310 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
311 size needed to hold the statistics is returned in
313 @retval EFI_UNSUPPORTED Not supported yet.
319 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
321 IN EFI_IP_ADDRESS
*Ip
,
322 OUT EFI_MAC_ADDRESS
*Mac
326 EMU_SNP_PRIVATE_DATA
*Private
;
328 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
330 Status
= Private
->Io
->MCastIpToMac (Private
->Io
, Ipv6
, Ip
, Mac
);
336 Performs read and write operations on the NVRAM device attached to a
339 @param This Protocol instance pointer.
340 @param ReadOrWrite TRUE for read operations, FALSE for write operations.
341 @param Offset Byte offset in the NVRAM device at which to start the read or
342 write operation. This must be a multiple of NvRamAccessSize and
344 @param BufferSize The number of bytes to read or write from the NVRAM device.
345 This must also be a multiple of NvramAccessSize.
346 @param Buffer A pointer to the data buffer.
348 @retval EFI_UNSUPPORTED Not supported yet.
354 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
355 IN BOOLEAN ReadOrWrite
,
362 EMU_SNP_PRIVATE_DATA
*Private
;
364 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
366 Status
= Private
->Io
->NvData (Private
->Io
, ReadOrWrite
, Offset
, BufferSize
, Buffer
);
372 Reads the current interrupt status and recycled transmit buffer status from
375 @param This Protocol instance pointer.
376 @param InterruptStatus A pointer to the bit mask of the currently active interrupts
377 If this is NULL, the interrupt status will not be read from
378 the device. If this is not NULL, the interrupt status will
379 be read from the device. When the interrupt status is read,
380 it will also be cleared. Clearing the transmit interrupt
381 does not empty the recycled transmit buffer array.
382 @param TxBuffer Recycled transmit buffer address. The network interface will
383 not transmit if its internal recycled transmit buffer array
384 is full. Reading the transmit buffer does not clear the
385 transmit interrupt. If this is NULL, then the transmit buffer
386 status will not be read. If there are no transmit buffers to
387 recycle and TxBuf is not NULL, * TxBuf will be set to NULL.
389 @retval EFI_SUCCESS Always succeeds.
395 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
396 OUT UINT32
*InterruptStatus
,
401 EMU_SNP_PRIVATE_DATA
*Private
;
403 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
405 Status
= Private
->Io
->GetStatus (Private
->Io
, InterruptStatus
, TxBuffer
);
411 Places a packet in the transmit queue of a network interface.
413 @param This Protocol instance pointer.
414 @param HeaderSize The size, in bytes, of the media header to be filled in by
415 the Transmit() function. If HeaderSize is non-zero, then it
416 must be equal to This->Mode->MediaHeaderSize and the DestAddr
417 and Protocol parameters must not be NULL.
418 @param BufferSize The size, in bytes, of the entire packet (media header and
419 data) to be transmitted through the network interface.
420 @param Buffer A pointer to the packet (media header followed by data) to be
421 transmitted. This parameter cannot be NULL. If HeaderSize is zero,
422 then the media header in Buffer must already be filled in by the
423 caller. If HeaderSize is non-zero, then the media header will be
424 filled in by the Transmit() function.
425 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter
426 is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then
427 This->Mode->CurrentAddress is used for the source HW MAC address.
428 @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this
429 parameter is ignored.
430 @param Protocol The type of header to build. If HeaderSize is zero, then this
431 parameter is ignored. See RFC 1700, section "Ether Types", for
434 @retval EFI_SUCCESS The packet was placed on the transmit queue.
435 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
436 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
437 @retval EFI_NOT_STARTED The network interface has not been started.
443 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
447 IN EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
448 IN EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
449 IN UINT16
*Protocol OPTIONAL
453 EMU_SNP_PRIVATE_DATA
*Private
;
455 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
457 Status
= Private
->Io
->Transmit (
470 Receives a packet from a network interface.
472 @param This Protocol instance pointer.
473 @param HeaderSize The size, in bytes, of the media header received on the network
474 interface. If this parameter is NULL, then the media header size
475 will not be returned.
476 @param BuffSize On entry, the size, in bytes, of Buffer. On exit, the size, in
477 bytes, of the packet that was received on the network interface.
478 @param Buffer A pointer to the data buffer to receive both the media header and
480 @param SourceAddr The source HW MAC address. If this parameter is NULL, the
481 HW MAC source address will not be extracted from the media
483 @param DestinationAddr The destination HW MAC address. If this parameter is NULL,
484 the HW MAC destination address will not be extracted from the
486 @param Protocol The media header type. If this parameter is NULL, then the
487 protocol will not be extracted from the media header. See
488 RFC 1700 section "Ether Types" for examples.
490 @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has
491 been updated to the number of bytes received.
492 @retval EFI_NOT_READY The network interface is too busy to accept this transmit
494 @retval EFI_NOT_STARTED The network interface has not been started.
495 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
496 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
502 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
503 OUT UINTN
*HeaderSize OPTIONAL
,
504 IN OUT UINTN
*BuffSize
,
506 OUT EFI_MAC_ADDRESS
*SourceAddr OPTIONAL
,
507 OUT EFI_MAC_ADDRESS
*DestinationAddr OPTIONAL
,
508 OUT UINT16
*Protocol OPTIONAL
512 EMU_SNP_PRIVATE_DATA
*Private
;
514 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
516 Status
= Private
->Io
->Receive (
531 Test to see if this driver supports ControllerHandle. This service
532 is called by the EFI boot service ConnectController(). In
533 order to make drivers as small as possible, there are a few calling
534 restrictions for this service. ConnectController() must
535 follow these calling restrictions. If any other agent wishes to call
536 Supported() it must also follow these calling restrictions.
538 @param This Protocol instance pointer.
539 @param ControllerHandle Handle of device to test
540 @param RemainingDevicePath Optional parameter use to pick a specific child
543 @retval EFI_SUCCESS This driver supports this device
544 @retval EFI_UNSUPPORTED This driver does not support this device
549 EmuSnpDriverBindingSupported (
550 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
551 IN EFI_HANDLE ControllerHandle
,
552 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
556 EMU_IO_THUNK_PROTOCOL
*EmuIoThunk
;
557 MAC_ADDR_DEVICE_PATH
*Node
;
558 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
560 if (RemainingDevicePath
!= NULL
) {
561 if (!IsDevicePathEnd (RemainingDevicePath
)) {
562 Node
= (MAC_ADDR_DEVICE_PATH
*)RemainingDevicePath
;
563 if (Node
->Header
.Type
!= MESSAGING_DEVICE_PATH
||
564 Node
->Header
.SubType
!= MSG_MAC_ADDR_DP
) {
565 // If the remaining device path does not match we don't support the request
566 return EFI_UNSUPPORTED
;
573 // Open the IO Abstraction(s) needed to perform the supported test
575 Status
= gBS
->OpenProtocol (
577 &gEmuIoThunkProtocolGuid
,
578 (VOID
**)&EmuIoThunk
,
579 This
->DriverBindingHandle
,
581 EFI_OPEN_PROTOCOL_BY_DRIVER
583 if (EFI_ERROR (Status
)) {
588 // Make sure GUID is for a File System handle.
590 Status
= EFI_UNSUPPORTED
;
591 if (CompareGuid (EmuIoThunk
->Protocol
, &gEmuSnpProtocolGuid
)) {
592 Status
= EFI_SUCCESS
;
596 // Close the I/O Abstraction(s) used to perform the supported test
600 &gEmuIoThunkProtocolGuid
,
601 This
->DriverBindingHandle
,
607 // Open the EFI Device Path protocol needed to perform the supported test
609 Status
= gBS
->OpenProtocol (
611 &gEfiDevicePathProtocolGuid
,
612 (VOID
**) &ParentDevicePath
,
613 This
->DriverBindingHandle
,
615 EFI_OPEN_PROTOCOL_BY_DRIVER
617 if (Status
== EFI_ALREADY_STARTED
) {
621 if (EFI_ERROR (Status
)) {
626 // Close protocol, don't use device path protocol in the Support() function
630 &gEfiDevicePathProtocolGuid
,
631 This
->DriverBindingHandle
,
640 Start this driver on ControllerHandle. This service is called by the
641 EFI boot service ConnectController(). In order to make
642 drivers as small as possible, there are a few calling restrictions for
643 this service. ConnectController() must follow these
644 calling restrictions. If any other agent wishes to call Start() it
645 must also follow these calling restrictions.
647 @param This Protocol instance pointer.
648 @param ControllerHandle Handle of device to bind driver to
649 @param RemainingDevicePath Optional parameter use to pick a specific child
652 @retval EFI_SUCCESS Always succeeds.
657 EmuSnpDriverBindingStart (
658 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
659 IN EFI_HANDLE ControllerHandle
,
660 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
664 EMU_IO_THUNK_PROTOCOL
*EmuIoThunk
;
665 EMU_SNP_PRIVATE_DATA
*Private
;
666 MAC_ADDR_DEVICE_PATH Node
;
667 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
670 // Grab the protocols we need
673 Status
= gBS
->OpenProtocol(
675 &gEfiDevicePathProtocolGuid
,
676 ( VOID
** ) &ParentDevicePath
,
677 This
->DriverBindingHandle
,
679 EFI_OPEN_PROTOCOL_BY_DRIVER
681 if (EFI_ERROR (Status
) && Status
) {
685 Status
= gBS
->OpenProtocol (
687 &gEmuIoThunkProtocolGuid
,
688 (VOID
**)&EmuIoThunk
,
689 This
->DriverBindingHandle
,
691 EFI_OPEN_PROTOCOL_BY_DRIVER
693 if (EFI_ERROR (Status
)) {
697 if (!CompareGuid (EmuIoThunk
->Protocol
, &gEmuSnpProtocolGuid
)) {
698 return EFI_UNSUPPORTED
;
701 Status
= EmuIoThunk
->Open (EmuIoThunk
);
702 if (EFI_ERROR (Status
)) {
707 // Allocate the private data.
709 Private
= AllocateZeroPool (sizeof (EMU_SNP_PRIVATE_DATA
));
710 if (Private
== NULL
) {
711 Status
= EFI_OUT_OF_RESOURCES
;
715 CopyMem (&Private
->Snp
, &gEmuSnpTemplate
, sizeof (EFI_SIMPLE_NETWORK_PROTOCOL
));
717 Private
->Signature
= EMU_SNP_PRIVATE_DATA_SIGNATURE
;
718 Private
->IoThunk
= EmuIoThunk
;
719 Private
->Io
= EmuIoThunk
->Interface
;
720 Private
->EfiHandle
= ControllerHandle
;
721 Private
->DeviceHandle
= NULL
;
722 Private
->Snp
.Mode
= &Private
->Mode
;
723 Private
->ControllerNameTable
= NULL
;
726 Status
= Private
->Io
->CreateMapping (Private
->Io
, &Private
->Mode
);
727 if (EFI_ERROR (Status
)) {
732 // Build the device path by appending the MAC node to the ParentDevicePath
733 // from the EmuIo handle.
735 ZeroMem (&Node
, sizeof (MAC_ADDR_DEVICE_PATH
));
737 Node
.Header
.Type
= MESSAGING_DEVICE_PATH
;
738 Node
.Header
.SubType
= MSG_MAC_ADDR_DP
;
739 Node
.IfType
= Private
->Mode
.IfType
;
741 SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
* )&Node
, sizeof (MAC_ADDR_DEVICE_PATH
));
743 CopyMem (&Node
.MacAddress
, &Private
->Mode
.CurrentAddress
, sizeof (EFI_MAC_ADDRESS
));
746 // Build the device path by appending the MAC node to the ParentDevicePath from the EmuIo handle.
748 Private
->DevicePath
= AppendDevicePathNode (ParentDevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&Node
);
749 if ( Private
->DevicePath
== NULL
) {
750 Status
= EFI_OUT_OF_RESOURCES
;
756 gEmuSnpDriverComponentName
.SupportedLanguages
,
757 &Private
->ControllerNameTable
,
758 EmuIoThunk
->ConfigString
,
764 gEmuSnpDriverComponentName2
.SupportedLanguages
,
765 &Private
->ControllerNameTable
,
766 EmuIoThunk
->ConfigString
,
771 // Create Child Handle
773 Status
= gBS
->InstallMultipleProtocolInterfaces(
774 &Private
->DeviceHandle
,
775 &gEfiSimpleNetworkProtocolGuid
, &Private
->Snp
,
776 &gEfiDevicePathProtocolGuid
, Private
->DevicePath
,
779 if (EFI_ERROR (Status
)) {
784 // Open For Child Device
786 Status
= gBS
->OpenProtocol (
788 &gEmuIoThunkProtocolGuid
,
789 (VOID
**)&EmuIoThunk
,
790 This
->DriverBindingHandle
,
791 Private
->DeviceHandle
,
792 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
796 if (EFI_ERROR (Status
)) {
797 if (Private
!= NULL
) {
800 if (ParentDevicePath
!= NULL
) {
803 &gEfiDevicePathProtocolGuid
,
804 This
->DriverBindingHandle
,
814 Stop this driver on ControllerHandle. This service is called by the
815 EFI boot service DisconnectController(). In order to
816 make drivers as small as possible, there are a few calling
817 restrictions for this service. DisconnectController()
818 must follow these calling restrictions. If any other agent wishes
819 to call Stop() it must also follow these calling restrictions.
821 @param This Protocol instance pointer.
822 @param ControllerHandle Handle of device to stop driver on
823 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
824 children is zero stop the entire bus driver.
825 @param ChildHandleBuffer List of Child Handles to Stop.
827 @retval EFI_SUCCESS Always succeeds.
832 EmuSnpDriverBindingStop (
833 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
834 IN EFI_HANDLE ControllerHandle
,
835 IN UINTN NumberOfChildren
,
836 IN EFI_HANDLE
*ChildHandleBuffer
840 EMU_SNP_PRIVATE_DATA
*Private
= NULL
;
841 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
842 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
845 // Complete all outstanding transactions to Controller.
846 // Don't allow any new transaction to Controller to be started.
848 if (NumberOfChildren
== 0) {
850 // Close the bus driver
852 Status
= gBS
->CloseProtocol (
854 &gEmuIoThunkProtocolGuid
,
855 This
->DriverBindingHandle
,
859 Status
= gBS
->CloseProtocol (
861 &gEfiDevicePathProtocolGuid
,
862 This
->DriverBindingHandle
,
868 ASSERT (NumberOfChildren
== 1);
872 // Get our context back.
874 Status
= gBS
->OpenProtocol(
875 ChildHandleBuffer
[0],
876 &gEfiSimpleNetworkProtocolGuid
,
878 This
->DriverBindingHandle
,
880 EFI_OPEN_PROTOCOL_GET_PROTOCOL
882 if (EFI_ERROR (Status
)) {
883 return EFI_DEVICE_ERROR
;
886 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (Snp
);
887 Status
= Private
->IoThunk
->Close (Private
->IoThunk
);
889 Status
= gBS
->CloseProtocol(
890 ChildHandleBuffer
[0],
891 &gEmuIoThunkProtocolGuid
,
892 This
->DriverBindingHandle
,
893 Private
->DeviceHandle
896 Status
= gBS
->UninstallMultipleProtocolInterfaces(
897 ChildHandleBuffer
[0],
898 &gEfiSimpleNetworkProtocolGuid
, &Private
->Snp
,
899 &gEfiDevicePathProtocolGuid
, Private
->DevicePath
,
903 FreePool (Private
->DevicePath
);
904 FreeUnicodeStringTable (Private
->ControllerNameTable
);
911 EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding
= {
912 EmuSnpDriverBindingSupported
,
913 EmuSnpDriverBindingStart
,
914 EmuSnpDriverBindingStop
,
923 This is the declaration of an EFI image entry point. This entry point is
924 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
925 both device drivers and bus drivers.
927 @param ImageHandle The firmware allocated handle for the UEFI image.
928 @param SystemTable A pointer to the EFI System Table.
930 @retval EFI_SUCCESS The operation completed successfully.
931 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
936 InitializeEmuSnpDriver (
937 IN EFI_HANDLE ImageHandle
,
938 IN EFI_SYSTEM_TABLE
*SystemTable
944 // Install the Driver Protocols
947 Status
= EfiLibInstallDriverBindingComponentName2(
950 &gEmuSnpDriverBinding
,
952 &gEmuSnpDriverComponentName
,
953 &gEmuSnpDriverComponentName2