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
49 Changes the state of a network interface from "stopped" to "started".
51 @param This Protocol instance pointer.
53 @retval EFI_SUCCESS Always succeeds.
59 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
63 EMU_SNP_PRIVATE_DATA
*Private
;
65 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
67 Status
= Private
->Io
->Start (Private
->Io
);
73 Changes the state of a network interface from "started" to "stopped".
75 @param This Protocol instance pointer.
77 @retval EFI_SUCCESS Always succeeds.
83 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
87 EMU_SNP_PRIVATE_DATA
*Private
;
89 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
91 Status
= Private
->Io
->Stop (Private
->Io
);
97 Resets a network adapter and allocates the transmit and receive buffers
98 required by the network interface; optionally, also requests allocation
99 of additional transmit and receive buffers.
101 @param This Protocol instance pointer.
102 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space
103 that the driver should allocate for the network interface.
104 Some network interfaces will not be able to use the extra
105 buffer, and the caller will not know if it is actually
107 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space
108 that the driver should allocate for the network interface.
109 Some network interfaces will not be able to use the extra
110 buffer, and the caller will not know if it is actually
113 @retval EFI_SUCCESS Always succeeds.
119 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
120 IN UINTN ExtraRxBufferSize OPTIONAL
,
121 IN UINTN ExtraTxBufferSize OPTIONAL
125 EMU_SNP_PRIVATE_DATA
*Private
;
127 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
129 Status
= Private
->Io
->Initialize (Private
->Io
, ExtraRxBufferSize
, ExtraTxBufferSize
);
134 Resets a network adapter and re-initializes it with the parameters that were
135 provided in the previous call to Initialize().
137 @param This Protocol instance pointer.
138 @param ExtendedVerification Indicates that the driver may perform a more
139 exhaustive verification operation of the device
142 @retval EFI_SUCCESS Always succeeds.
148 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
149 IN BOOLEAN ExtendedVerification
153 EMU_SNP_PRIVATE_DATA
*Private
;
155 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
157 Status
= Private
->Io
->Reset (Private
->Io
, ExtendedVerification
);
162 Resets a network adapter and leaves it in a state that is safe for
163 another driver to initialize.
165 @param This Protocol instance pointer.
167 @retval EFI_SUCCESS Always succeeds.
173 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
177 EMU_SNP_PRIVATE_DATA
*Private
;
179 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
181 Status
= Private
->Io
->Shutdown (Private
->Io
);
186 Manages the multicast receive filters of a network interface.
188 @param This Protocol instance pointer.
189 @param EnableBits A bit mask of receive filters to enable on the network interface.
190 @param DisableBits A bit mask of receive filters to disable on the network interface.
191 @param ResetMcastFilter Set to TRUE to reset the contents of the multicast receive
192 filters on the network interface to their default values.
193 @param McastFilterCount Number of multicast HW MAC addresses in the new
194 MCastFilter list. This value must be less than or equal to
195 the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This
196 field is optional if ResetMCastFilter is TRUE.
197 @param McastFilter A pointer to a list of new multicast receive filter HW MAC
198 addresses. This list will replace any existing multicast
199 HW MAC address list. This field is optional if
200 ResetMCastFilter is TRUE.
202 @retval EFI_SUCCESS The multicast receive filter list was updated.
203 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
208 EmuSnpReceiveFilters (
209 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
210 IN UINT32 EnableBits
,
211 IN UINT32 DisableBits
,
212 IN BOOLEAN ResetMcastFilter
,
213 IN UINTN McastFilterCount OPTIONAL
,
214 IN EFI_MAC_ADDRESS
*McastFilter OPTIONAL
218 EMU_SNP_PRIVATE_DATA
*Private
;
220 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
222 Status
= Private
->Io
->ReceiveFilters (
234 Modifies or resets the current station address, if supported.
236 @param This Protocol instance pointer.
237 @param Reset Flag used to reset the station address to the network interfaces
239 @param NewMacAddr New station address to be used for the network interface.
241 @retval EFI_UNSUPPORTED Not supported yet.
246 EmuSnpStationAddress (
247 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
249 IN EFI_MAC_ADDRESS
*NewMacAddr OPTIONAL
253 EMU_SNP_PRIVATE_DATA
*Private
;
255 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
257 Status
= Private
->Io
->StationAddress (Private
->Io
, Reset
, NewMacAddr
);
262 Resets or collects the statistics on a network interface.
264 @param This Protocol instance pointer.
265 @param Reset Set to TRUE to reset the statistics for the network interface.
266 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On
267 output the size, in bytes, of the resulting table of
269 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
270 contains the statistics.
272 @retval EFI_SUCCESS The statistics were collected from the network interface.
273 @retval EFI_NOT_STARTED The network interface has not been started.
274 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
275 size needed to hold the statistics is returned in
277 @retval EFI_UNSUPPORTED Not supported yet.
283 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
285 IN OUT UINTN
*StatisticsSize OPTIONAL
,
286 OUT EFI_NETWORK_STATISTICS
*StatisticsTable OPTIONAL
290 EMU_SNP_PRIVATE_DATA
*Private
;
292 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
294 Status
= Private
->Io
->Statistics (Private
->Io
, Reset
, StatisticsSize
, StatisticsTable
);
299 Converts a multicast IP address to a multicast HW MAC address.
301 @param This Protocol instance pointer.
302 @param Ipv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set
303 to FALSE if the multicast IP address is IPv4 [RFC 791].
304 @param Ip The multicast IP address that is to be converted to a multicast
306 @param Mac The multicast HW MAC address that is to be generated from IP.
308 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast
310 @retval EFI_NOT_STARTED The network interface has not been started.
311 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
312 size needed to hold the statistics is returned in
314 @retval EFI_UNSUPPORTED Not supported yet.
320 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
322 IN EFI_IP_ADDRESS
*Ip
,
323 OUT EFI_MAC_ADDRESS
*Mac
327 EMU_SNP_PRIVATE_DATA
*Private
;
329 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
331 Status
= Private
->Io
->MCastIpToMac (Private
->Io
, Ipv6
, Ip
, Mac
);
337 Performs read and write operations on the NVRAM device attached to a
340 @param This Protocol instance pointer.
341 @param ReadOrWrite TRUE for read operations, FALSE for write operations.
342 @param Offset Byte offset in the NVRAM device at which to start the read or
343 write operation. This must be a multiple of NvRamAccessSize and
345 @param BufferSize The number of bytes to read or write from the NVRAM device.
346 This must also be a multiple of NvramAccessSize.
347 @param Buffer A pointer to the data buffer.
349 @retval EFI_UNSUPPORTED Not supported yet.
355 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
356 IN BOOLEAN ReadOrWrite
,
363 EMU_SNP_PRIVATE_DATA
*Private
;
365 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
367 Status
= Private
->Io
->NvData (Private
->Io
, ReadOrWrite
, Offset
, BufferSize
, Buffer
);
373 Reads the current interrupt status and recycled transmit buffer status from
376 @param This Protocol instance pointer.
377 @param InterruptStatus A pointer to the bit mask of the currently active interrupts
378 If this is NULL, the interrupt status will not be read from
379 the device. If this is not NULL, the interrupt status will
380 be read from the device. When the interrupt status is read,
381 it will also be cleared. Clearing the transmit interrupt
382 does not empty the recycled transmit buffer array.
383 @param TxBuffer Recycled transmit buffer address. The network interface will
384 not transmit if its internal recycled transmit buffer array
385 is full. Reading the transmit buffer does not clear the
386 transmit interrupt. If this is NULL, then the transmit buffer
387 status will not be read. If there are no transmit buffers to
388 recycle and TxBuf is not NULL, * TxBuf will be set to NULL.
390 @retval EFI_SUCCESS Always succeeds.
396 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
397 OUT UINT32
*InterruptStatus
,
402 EMU_SNP_PRIVATE_DATA
*Private
;
404 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
406 Status
= Private
->Io
->GetStatus (Private
->Io
, InterruptStatus
, TxBuffer
);
412 Places a packet in the transmit queue of a network interface.
414 @param This Protocol instance pointer.
415 @param HeaderSize The size, in bytes, of the media header to be filled in by
416 the Transmit() function. If HeaderSize is non-zero, then it
417 must be equal to This->Mode->MediaHeaderSize and the DestAddr
418 and Protocol parameters must not be NULL.
419 @param BufferSize The size, in bytes, of the entire packet (media header and
420 data) to be transmitted through the network interface.
421 @param Buffer A pointer to the packet (media header followed by data) to be
422 transmitted. This parameter cannot be NULL. If HeaderSize is zero,
423 then the media header in Buffer must already be filled in by the
424 caller. If HeaderSize is non-zero, then the media header will be
425 filled in by the Transmit() function.
426 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter
427 is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then
428 This->Mode->CurrentAddress is used for the source HW MAC address.
429 @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this
430 parameter is ignored.
431 @param Protocol The type of header to build. If HeaderSize is zero, then this
432 parameter is ignored. See RFC 1700, section "Ether Types", for
435 @retval EFI_SUCCESS The packet was placed on the transmit queue.
436 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
437 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
438 @retval EFI_NOT_STARTED The network interface has not been started.
444 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
448 IN EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
449 IN EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
450 IN UINT16
*Protocol OPTIONAL
454 EMU_SNP_PRIVATE_DATA
*Private
;
456 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
458 Status
= Private
->Io
->Transmit (
471 Receives a packet from a network interface.
473 @param This Protocol instance pointer.
474 @param HeaderSize The size, in bytes, of the media header received on the network
475 interface. If this parameter is NULL, then the media header size
476 will not be returned.
477 @param BuffSize On entry, the size, in bytes, of Buffer. On exit, the size, in
478 bytes, of the packet that was received on the network interface.
479 @param Buffer A pointer to the data buffer to receive both the media header and
481 @param SourceAddr The source HW MAC address. If this parameter is NULL, the
482 HW MAC source address will not be extracted from the media
484 @param DestinationAddr The destination HW MAC address. If this parameter is NULL,
485 the HW MAC destination address will not be extracted from the
487 @param Protocol The media header type. If this parameter is NULL, then the
488 protocol will not be extracted from the media header. See
489 RFC 1700 section "Ether Types" for examples.
491 @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has
492 been updated to the number of bytes received.
493 @retval EFI_NOT_READY The network interface is too busy to accept this transmit
495 @retval EFI_NOT_STARTED The network interface has not been started.
496 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
497 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
503 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
504 OUT UINTN
*HeaderSize OPTIONAL
,
505 IN OUT UINTN
*BuffSize
,
507 OUT EFI_MAC_ADDRESS
*SourceAddr OPTIONAL
,
508 OUT EFI_MAC_ADDRESS
*DestinationAddr OPTIONAL
,
509 OUT UINT16
*Protocol OPTIONAL
513 EMU_SNP_PRIVATE_DATA
*Private
;
515 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This
);
517 Status
= Private
->Io
->Receive (
532 Test to see if this driver supports ControllerHandle. This service
533 is called by the EFI boot service ConnectController(). In
534 order to make drivers as small as possible, there are a few calling
535 restrictions for this service. ConnectController() must
536 follow these calling restrictions. If any other agent wishes to call
537 Supported() it must also follow these calling restrictions.
539 @param This Protocol instance pointer.
540 @param ControllerHandle Handle of device to test
541 @param RemainingDevicePath Optional parameter use to pick a specific child
544 @retval EFI_SUCCESS This driver supports this device
545 @retval EFI_UNSUPPORTED This driver does not support this device
550 EmuSnpDriverBindingSupported (
551 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
552 IN EFI_HANDLE ControllerHandle
,
553 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
557 EMU_IO_THUNK_PROTOCOL
*EmuIoThunk
;
558 MAC_ADDR_DEVICE_PATH
*Node
;
559 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
561 if (RemainingDevicePath
!= NULL
) {
562 if (!IsDevicePathEnd (RemainingDevicePath
)) {
563 Node
= (MAC_ADDR_DEVICE_PATH
*)RemainingDevicePath
;
564 if (Node
->Header
.Type
!= MESSAGING_DEVICE_PATH
||
565 Node
->Header
.SubType
!= MSG_MAC_ADDR_DP
) {
566 // If the remaining device path does not match we don't support the request
567 return EFI_UNSUPPORTED
;
574 // Open the IO Abstraction(s) needed to perform the supported test
576 Status
= gBS
->OpenProtocol (
578 &gEmuIoThunkProtocolGuid
,
579 (VOID
**)&EmuIoThunk
,
580 This
->DriverBindingHandle
,
582 EFI_OPEN_PROTOCOL_BY_DRIVER
584 if (EFI_ERROR (Status
)) {
589 // Make sure GUID is for a File System handle.
591 Status
= EFI_UNSUPPORTED
;
592 if (CompareGuid (EmuIoThunk
->Protocol
, &gEmuSnpProtocolGuid
)) {
593 Status
= EFI_SUCCESS
;
597 // Close the I/O Abstraction(s) used to perform the supported test
601 &gEmuIoThunkProtocolGuid
,
602 This
->DriverBindingHandle
,
608 // Open the EFI Device Path protocol needed to perform the supported test
610 Status
= gBS
->OpenProtocol (
612 &gEfiDevicePathProtocolGuid
,
613 (VOID
**) &ParentDevicePath
,
614 This
->DriverBindingHandle
,
616 EFI_OPEN_PROTOCOL_BY_DRIVER
618 if (Status
== EFI_ALREADY_STARTED
) {
622 if (EFI_ERROR (Status
)) {
627 // Close protocol, don't use device path protocol in the Support() function
631 &gEfiDevicePathProtocolGuid
,
632 This
->DriverBindingHandle
,
641 Start this driver on ControllerHandle. This service is called by the
642 EFI boot service ConnectController(). In order to make
643 drivers as small as possible, there are a few calling restrictions for
644 this service. ConnectController() must follow these
645 calling restrictions. If any other agent wishes to call Start() it
646 must also follow these calling restrictions.
648 @param This Protocol instance pointer.
649 @param ControllerHandle Handle of device to bind driver to
650 @param RemainingDevicePath Optional parameter use to pick a specific child
653 @retval EFI_SUCCESS Always succeeds.
658 EmuSnpDriverBindingStart (
659 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
660 IN EFI_HANDLE ControllerHandle
,
661 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
665 EMU_IO_THUNK_PROTOCOL
*EmuIoThunk
;
666 EMU_SNP_PRIVATE_DATA
*Private
;
667 MAC_ADDR_DEVICE_PATH Node
;
668 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
673 // Grab the protocols we need
675 Status
= gBS
->OpenProtocol(
677 &gEfiDevicePathProtocolGuid
,
678 ( VOID
** ) &ParentDevicePath
,
679 This
->DriverBindingHandle
,
681 EFI_OPEN_PROTOCOL_BY_DRIVER
683 if (EFI_ERROR (Status
) && Status
) {
687 Status
= gBS
->OpenProtocol (
689 &gEmuIoThunkProtocolGuid
,
690 (VOID
**)&EmuIoThunk
,
691 This
->DriverBindingHandle
,
693 EFI_OPEN_PROTOCOL_BY_DRIVER
695 if (EFI_ERROR (Status
)) {
699 if (!CompareGuid (EmuIoThunk
->Protocol
, &gEmuSnpProtocolGuid
)) {
700 return EFI_UNSUPPORTED
;
703 Status
= EmuIoThunk
->Open (EmuIoThunk
);
704 if (EFI_ERROR (Status
)) {
709 // Allocate the private data.
711 Private
= AllocateZeroPool (sizeof (EMU_SNP_PRIVATE_DATA
));
712 if (Private
== NULL
) {
713 Status
= EFI_OUT_OF_RESOURCES
;
717 CopyMem (&Private
->Snp
, &gEmuSnpTemplate
, sizeof (EFI_SIMPLE_NETWORK_PROTOCOL
));
719 Private
->Signature
= EMU_SNP_PRIVATE_DATA_SIGNATURE
;
720 Private
->IoThunk
= EmuIoThunk
;
721 Private
->Io
= EmuIoThunk
->Interface
;
722 Private
->EfiHandle
= ControllerHandle
;
723 Private
->DeviceHandle
= NULL
;
724 Private
->Snp
.Mode
= &Private
->Mode
;
725 Private
->ControllerNameTable
= NULL
;
728 Status
= Private
->Io
->CreateMapping (Private
->Io
, &Private
->Mode
);
729 if (EFI_ERROR (Status
)) {
734 // Build the device path by appending the MAC node to the ParentDevicePath
735 // from the EmuIo handle.
737 ZeroMem (&Node
, sizeof (MAC_ADDR_DEVICE_PATH
));
739 Node
.Header
.Type
= MESSAGING_DEVICE_PATH
;
740 Node
.Header
.SubType
= MSG_MAC_ADDR_DP
;
741 Node
.IfType
= Private
->Mode
.IfType
;
743 SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
* )&Node
, sizeof (MAC_ADDR_DEVICE_PATH
));
745 CopyMem (&Node
.MacAddress
, &Private
->Mode
.CurrentAddress
, sizeof (EFI_MAC_ADDRESS
));
748 // Build the device path by appending the MAC node to the ParentDevicePath from the EmuIo handle.
750 Private
->DevicePath
= AppendDevicePathNode (ParentDevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&Node
);
751 if ( Private
->DevicePath
== NULL
) {
752 Status
= EFI_OUT_OF_RESOURCES
;
758 gEmuSnpDriverComponentName
.SupportedLanguages
,
759 &Private
->ControllerNameTable
,
760 EmuIoThunk
->ConfigString
,
766 gEmuSnpDriverComponentName2
.SupportedLanguages
,
767 &Private
->ControllerNameTable
,
768 EmuIoThunk
->ConfigString
,
773 // Create Child Handle
775 Status
= gBS
->InstallMultipleProtocolInterfaces(
776 &Private
->DeviceHandle
,
777 &gEfiSimpleNetworkProtocolGuid
, &Private
->Snp
,
778 &gEfiDevicePathProtocolGuid
, Private
->DevicePath
,
781 if (EFI_ERROR (Status
)) {
786 // Open For Child Device
788 Status
= gBS
->OpenProtocol (
790 &gEmuIoThunkProtocolGuid
,
791 (VOID
**)&EmuIoThunk
,
792 This
->DriverBindingHandle
,
793 Private
->DeviceHandle
,
794 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
798 if (EFI_ERROR (Status
)) {
799 if (Private
!= NULL
) {
802 if (ParentDevicePath
!= NULL
) {
805 &gEfiDevicePathProtocolGuid
,
806 This
->DriverBindingHandle
,
816 Stop this driver on ControllerHandle. This service is called by the
817 EFI boot service DisconnectController(). In order to
818 make drivers as small as possible, there are a few calling
819 restrictions for this service. DisconnectController()
820 must follow these calling restrictions. If any other agent wishes
821 to call Stop() it must also follow these calling restrictions.
823 @param This Protocol instance pointer.
824 @param ControllerHandle Handle of device to stop driver on
825 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
826 children is zero stop the entire bus driver.
827 @param ChildHandleBuffer List of Child Handles to Stop.
829 @retval EFI_SUCCESS Always succeeds.
834 EmuSnpDriverBindingStop (
835 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
836 IN EFI_HANDLE ControllerHandle
,
837 IN UINTN NumberOfChildren
,
838 IN EFI_HANDLE
*ChildHandleBuffer
842 EMU_SNP_PRIVATE_DATA
*Private
= NULL
;
843 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
846 // Complete all outstanding transactions to Controller.
847 // Don't allow any new transaction to Controller to be started.
849 if (NumberOfChildren
== 0) {
851 // Close the bus driver
853 Status
= gBS
->CloseProtocol (
855 &gEmuIoThunkProtocolGuid
,
856 This
->DriverBindingHandle
,
860 Status
= gBS
->CloseProtocol (
862 &gEfiDevicePathProtocolGuid
,
863 This
->DriverBindingHandle
,
869 ASSERT (NumberOfChildren
== 1);
873 // Get our context back.
875 Status
= gBS
->OpenProtocol(
876 ChildHandleBuffer
[0],
877 &gEfiSimpleNetworkProtocolGuid
,
879 This
->DriverBindingHandle
,
881 EFI_OPEN_PROTOCOL_GET_PROTOCOL
883 if (EFI_ERROR (Status
)) {
884 return EFI_DEVICE_ERROR
;
887 Private
= EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (Snp
);
888 Status
= Private
->IoThunk
->Close (Private
->IoThunk
);
890 Status
= gBS
->CloseProtocol(
891 ChildHandleBuffer
[0],
892 &gEmuIoThunkProtocolGuid
,
893 This
->DriverBindingHandle
,
894 Private
->DeviceHandle
897 Status
= gBS
->UninstallMultipleProtocolInterfaces(
898 ChildHandleBuffer
[0],
899 &gEfiSimpleNetworkProtocolGuid
, &Private
->Snp
,
900 &gEfiDevicePathProtocolGuid
, Private
->DevicePath
,
904 FreePool (Private
->DevicePath
);
905 FreeUnicodeStringTable (Private
->ControllerNameTable
);
912 EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding
= {
913 EmuSnpDriverBindingSupported
,
914 EmuSnpDriverBindingStart
,
915 EmuSnpDriverBindingStop
,
924 This is the declaration of an EFI image entry point. This entry point is
925 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
926 both device drivers and bus drivers.
928 @param ImageHandle The firmware allocated handle for the UEFI image.
929 @param SystemTable A pointer to the EFI System Table.
931 @retval EFI_SUCCESS The operation completed successfully.
932 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
937 InitializeEmuSnpDriver (
938 IN EFI_HANDLE ImageHandle
,
939 IN EFI_SYSTEM_TABLE
*SystemTable
945 // Install the Driver Protocols
948 Status
= EfiLibInstallDriverBindingComponentName2(
951 &gEmuSnpDriverBinding
,
953 &gEmuSnpDriverComponentName
,
954 &gEmuSnpDriverComponentName2