2 Implementation of driver entry point and driver binding protocol.
4 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed
6 and made available under the terms and conditions of the BSD License which
7 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.
18 One notified function to stop UNDI device when gBS->ExitBootServices() called.
20 @param Event Pointer to this event
21 @param Context Event handler private data
26 SnpNotifyExitBootServices (
33 Snp
= (SNP_DRIVER
*)Context
;
36 // Shutdown and stop UNDI driver
43 Send command to UNDI. It does nothing currently.
45 @param Cdb command to be sent to UNDI.
47 @retval EFI_INVALID_PARAMETER The command is 0.
48 @retval EFI_UNSUPPORTED Default return status because it's not
58 DEBUG ((EFI_D_ERROR
, "\nIssueHwUndiCommand() - This should not be called!"));
61 return EFI_INVALID_PARAMETER
;
65 // %%TBD - For now, nothing is done.
67 return EFI_UNSUPPORTED
;
72 Compute 8-bit checksum of a buffer.
74 @param Buffer Pointer to buffer.
75 @param Length Length of buffer in bytes.
77 @return 8-bit checksum of all bytes in buffer, or zero if ptr is NULL or len
93 if (Ptr
== NULL
|| Length
== 0) {
97 while (Length
-- != 0) {
98 Cksum
= (UINT8
) (Cksum
+ *Ptr
++);
105 Test to see if this driver supports ControllerHandle. This service
106 is called by the EFI boot service ConnectController(). In
107 order to make drivers as small as possible, there are a few calling
108 restrictions for this service. ConnectController() must
109 follow these calling restrictions. If any other agent wishes to call
110 Supported() it must also follow these calling restrictions.
112 @param This Protocol instance pointer.
113 @param ControllerHandle Handle of device to test.
114 @param RemainingDevicePath Optional parameter use to pick a specific child
117 @retval EFI_SUCCESS This driver supports this device.
118 @retval EFI_ALREADY_STARTED This driver is already running on this device.
119 @retval other This driver does not support this device.
124 SimpleNetworkDriverSupported (
125 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
126 IN EFI_HANDLE Controller
,
127 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
131 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL
*NiiProtocol
;
134 Status
= gBS
->OpenProtocol (
136 &gEfiDevicePathProtocolGuid
,
138 This
->DriverBindingHandle
,
140 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
142 if (EFI_ERROR (Status
)) {
146 Status
= gBS
->OpenProtocol (
148 &gEfiNetworkInterfaceIdentifierProtocolGuid_31
,
149 (VOID
**) &NiiProtocol
,
150 This
->DriverBindingHandle
,
152 EFI_OPEN_PROTOCOL_BY_DRIVER
155 if (EFI_ERROR (Status
)) {
156 if (Status
== EFI_ALREADY_STARTED
) {
157 DEBUG ((EFI_D_INFO
, "Support(): Already Started. on handle %p\n", Controller
));
162 DEBUG ((EFI_D_INFO
, "Support(): UNDI3.1 found on handle %p\n", Controller
));
165 // check the version, we don't want to connect to the undi16
167 if (NiiProtocol
->Type
!= EfiNetworkInterfaceUndi
) {
168 Status
= EFI_UNSUPPORTED
;
172 // Check to see if !PXE structure is valid. Paragraph alignment of !PXE structure is required.
174 if ((NiiProtocol
->Id
& 0x0F) != 0) {
175 DEBUG ((EFI_D_NET
, "\n!PXE structure is not paragraph aligned.\n"));
176 Status
= EFI_UNSUPPORTED
;
180 Pxe
= (PXE_UNDI
*) (UINTN
) (NiiProtocol
->Id
);
183 // Verify !PXE revisions.
185 if (Pxe
->hw
.Signature
!= PXE_ROMID_SIGNATURE
) {
186 DEBUG ((EFI_D_NET
, "\n!PXE signature is not valid.\n"));
187 Status
= EFI_UNSUPPORTED
;
191 if (Pxe
->hw
.Rev
< PXE_ROMID_REV
) {
192 DEBUG ((EFI_D_NET
, "\n!PXE.Rev is not supported.\n"));
193 Status
= EFI_UNSUPPORTED
;
197 if (Pxe
->hw
.MajorVer
< PXE_ROMID_MAJORVER
) {
199 DEBUG ((EFI_D_NET
, "\n!PXE.MajorVer is not supported.\n"));
200 Status
= EFI_UNSUPPORTED
;
203 } else if (Pxe
->hw
.MajorVer
== PXE_ROMID_MAJORVER
&& Pxe
->hw
.MinorVer
< PXE_ROMID_MINORVER
) {
204 DEBUG ((EFI_D_NET
, "\n!PXE.MinorVer is not supported."));
205 Status
= EFI_UNSUPPORTED
;
209 // Do S/W UNDI specific checks.
211 if ((Pxe
->hw
.Implementation
& PXE_ROMID_IMP_HW_UNDI
) == 0) {
212 if (Pxe
->sw
.EntryPoint
< Pxe
->sw
.Len
) {
213 DEBUG ((EFI_D_NET
, "\n!PXE S/W entry point is not valid."));
214 Status
= EFI_UNSUPPORTED
;
218 if (Pxe
->sw
.BusCnt
== 0) {
219 DEBUG ((EFI_D_NET
, "\n!PXE.BusCnt is zero."));
220 Status
= EFI_UNSUPPORTED
;
225 Status
= EFI_SUCCESS
;
226 DEBUG ((EFI_D_INFO
, "Support(): supported on %p\n", Controller
));
231 &gEfiNetworkInterfaceIdentifierProtocolGuid_31
,
232 This
->DriverBindingHandle
,
240 Start this driver on ControllerHandle. This service is called by the
241 EFI boot service ConnectController(). In order to make
242 drivers as small as possible, there are a few calling restrictions for
243 this service. ConnectController() must follow these
244 calling restrictions. If any other agent wishes to call Start() it
245 must also follow these calling restrictions.
247 @param This Protocol instance pointer.
248 @param ControllerHandle Handle of device to bind driver to.
249 @param RemainingDevicePath Optional parameter use to pick a specific child
252 @retval EFI_SUCCESS This driver is added to ControllerHandle
253 @retval EFI_DEVICE_ERROR This driver could not be started due to a device error
254 @retval other This driver does not support this device
259 SimpleNetworkDriverStart (
260 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
261 IN EFI_HANDLE Controller
,
262 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
265 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL
*Nii
;
266 EFI_DEVICE_PATH_PROTOCOL
*NiiDevicePath
;
273 PXE_STATFLAGS InitStatFlags
;
274 EFI_PCI_IO_PROTOCOL
*PciIo
;
275 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*BarDesc
;
277 BOOLEAN FoundMemoryBar
;
279 DEBUG ((EFI_D_NET
, "\nSnpNotifyNetworkInterfaceIdentifier() "));
281 Status
= gBS
->OpenProtocol (
283 &gEfiDevicePathProtocolGuid
,
284 (VOID
**) &NiiDevicePath
,
285 This
->DriverBindingHandle
,
287 EFI_OPEN_PROTOCOL_BY_DRIVER
290 if (EFI_ERROR (Status
)) {
294 Status
= gBS
->LocateDevicePath (
295 &gEfiPciIoProtocolGuid
,
300 if (EFI_ERROR (Status
)) {
304 Status
= gBS
->OpenProtocol (
306 &gEfiPciIoProtocolGuid
,
308 This
->DriverBindingHandle
,
310 EFI_OPEN_PROTOCOL_GET_PROTOCOL
312 if (EFI_ERROR (Status
)) {
316 // Get the NII interface.
318 Status
= gBS
->OpenProtocol (
320 &gEfiNetworkInterfaceIdentifierProtocolGuid_31
,
322 This
->DriverBindingHandle
,
324 EFI_OPEN_PROTOCOL_BY_DRIVER
326 if (EFI_ERROR (Status
)) {
329 &gEfiDevicePathProtocolGuid
,
330 This
->DriverBindingHandle
,
336 DEBUG ((EFI_D_INFO
, "Start(): UNDI3.1 found\n"));
338 Pxe
= (PXE_UNDI
*) (UINTN
) (Nii
->Id
);
340 if (Calc8BitCksum (Pxe
, Pxe
->hw
.Len
) != 0) {
341 DEBUG ((EFI_D_NET
, "\n!PXE checksum is not correct.\n"));
345 if ((Pxe
->hw
.Implementation
& PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED
) != 0) {
347 // We can get any packets.
349 } else if ((Pxe
->hw
.Implementation
& PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED
) != 0) {
351 // We need to be able to get broadcast packets for DHCP.
352 // If we do not have promiscuous support, we must at least have
353 // broadcast support or we cannot do DHCP!
356 DEBUG ((EFI_D_NET
, "\nUNDI does not have promiscuous or broadcast support."));
360 // OK, we like this UNDI, and we know snp is not already there on this handle
361 // Allocate and initialize a new simple network protocol structure.
363 Status
= PciIo
->AllocateBuffer (
367 SNP_MEM_PAGES (sizeof (SNP_DRIVER
)),
372 if (Status
!= EFI_SUCCESS
) {
373 DEBUG ((EFI_D_NET
, "\nCould not allocate SNP_DRIVER structure.\n"));
377 Snp
= (SNP_DRIVER
*) (UINTN
) Address
;
379 ZeroMem (Snp
, sizeof (SNP_DRIVER
));
382 Snp
->Signature
= SNP_DRIVER_SIGNATURE
;
384 EfiInitializeLock (&Snp
->Lock
, TPL_NOTIFY
);
386 Snp
->Snp
.Revision
= EFI_SIMPLE_NETWORK_PROTOCOL_REVISION
;
387 Snp
->Snp
.Start
= SnpUndi32Start
;
388 Snp
->Snp
.Stop
= SnpUndi32Stop
;
389 Snp
->Snp
.Initialize
= SnpUndi32Initialize
;
390 Snp
->Snp
.Reset
= SnpUndi32Reset
;
391 Snp
->Snp
.Shutdown
= SnpUndi32Shutdown
;
392 Snp
->Snp
.ReceiveFilters
= SnpUndi32ReceiveFilters
;
393 Snp
->Snp
.StationAddress
= SnpUndi32StationAddress
;
394 Snp
->Snp
.Statistics
= SnpUndi32Statistics
;
395 Snp
->Snp
.MCastIpToMac
= SnpUndi32McastIpToMac
;
396 Snp
->Snp
.NvData
= SnpUndi32NvData
;
397 Snp
->Snp
.GetStatus
= SnpUndi32GetStatus
;
398 Snp
->Snp
.Transmit
= SnpUndi32Transmit
;
399 Snp
->Snp
.Receive
= SnpUndi32Receive
;
400 Snp
->Snp
.WaitForPacket
= NULL
;
402 Snp
->Snp
.Mode
= &Snp
->Mode
;
404 Snp
->TxRxBufferSize
= 0;
405 Snp
->TxRxBuffer
= NULL
;
407 if (Nii
->Revision
>= EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION
) {
408 Snp
->IfNum
= Nii
->IfNum
;
411 Snp
->IfNum
= (UINT8
) (Nii
->IfNum
& 0xFF);
414 if ((Pxe
->hw
.Implementation
& PXE_ROMID_IMP_HW_UNDI
) != 0) {
415 Snp
->IsSwUndi
= FALSE
;
416 Snp
->IssueUndi32Command
= &IssueHwUndiCommand
;
418 Snp
->IsSwUndi
= TRUE
;
420 if ((Pxe
->sw
.Implementation
& PXE_ROMID_IMP_SW_VIRT_ADDR
) != 0) {
421 Snp
->IssueUndi32Command
= (ISSUE_UNDI32_COMMAND
) (UINTN
) Pxe
->sw
.EntryPoint
;
423 Snp
->IssueUndi32Command
= (ISSUE_UNDI32_COMMAND
) (UINTN
) ((UINT8
) (UINTN
) Pxe
+ Pxe
->sw
.EntryPoint
);
427 // Allocate a global CPB and DB buffer for this UNDI interface.
428 // we do this because:
430 // -UNDI 3.0 wants all the addresses passed to it (even the cpb and db) to be
431 // within 2GB limit, create them here and map them so that when undi calls
432 // v2p callback to check if the physical address is < 2gb, we will pass.
434 // -This is not a requirement for 3.1 or later UNDIs but the code looks
435 // simpler if we use the same cpb, db variables for both old and new undi
436 // interfaces from all the SNP interface calls (we don't map the buffers
437 // for the newer undi interfaces though)
439 // -it is OK to allocate one global set of CPB, DB pair for each UNDI
440 // interface as EFI does not multi-task and so SNP will not be re-entered!
442 Status
= PciIo
->AllocateBuffer (
446 SNP_MEM_PAGES (4096),
451 if (Status
!= EFI_SUCCESS
) {
452 DEBUG ((EFI_D_NET
, "\nCould not allocate CPB and DB structures.\n"));
453 goto Error_DeleteSNP
;
456 Snp
->Cpb
= (VOID
*) (UINTN
) Address
;
457 Snp
->Db
= (VOID
*) ((UINTN
) Address
+ 2048);
460 // Find the correct BAR to do IO.
462 // Enumerate through the PCI BARs for the device to determine which one is
463 // the IO BAR. Save the index of the BAR into the adapter info structure.
464 // for regular 32bit BARs, 0 is memory mapped, 1 is io mapped
466 Snp
->MemoryBarIndex
= 0;
468 FoundMemoryBar
= FALSE
;
470 for (BarIndex
= 0; BarIndex
< PCI_MAX_BAR
; BarIndex
++) {
471 Status
= PciIo
->GetBarAttributes (
477 if (Status
== EFI_UNSUPPORTED
) {
479 } else if (EFI_ERROR (Status
)) {
480 goto Error_DeleteSNP
;
483 if ((!FoundMemoryBar
) && (BarDesc
->ResType
== ACPI_ADDRESS_SPACE_TYPE_MEM
)) {
484 Snp
->MemoryBarIndex
= BarIndex
;
485 FoundMemoryBar
= TRUE
;
486 } else if ((!FoundIoBar
) && (BarDesc
->ResType
== ACPI_ADDRESS_SPACE_TYPE_IO
)) {
487 Snp
->IoBarIndex
= BarIndex
;
493 if (FoundMemoryBar
&& FoundIoBar
) {
498 Status
= PxeStart (Snp
);
500 if (Status
!= EFI_SUCCESS
) {
501 goto Error_DeleteSNP
;
504 Snp
->Cdb
.OpCode
= PXE_OPCODE_GET_INIT_INFO
;
505 Snp
->Cdb
.OpFlags
= PXE_OPFLAGS_NOT_USED
;
507 Snp
->Cdb
.CPBsize
= PXE_CPBSIZE_NOT_USED
;
508 Snp
->Cdb
.CPBaddr
= PXE_DBADDR_NOT_USED
;
510 Snp
->Cdb
.DBsize
= (UINT16
) sizeof (Snp
->InitInfo
);
511 Snp
->Cdb
.DBaddr
= (UINT64
)(UINTN
) (&Snp
->InitInfo
);
513 Snp
->Cdb
.StatCode
= PXE_STATCODE_INITIALIZE
;
514 Snp
->Cdb
.StatFlags
= PXE_STATFLAGS_INITIALIZE
;
516 Snp
->Cdb
.IFnum
= Snp
->IfNum
;
517 Snp
->Cdb
.Control
= PXE_CONTROL_LAST_CDB_IN_LIST
;
519 DEBUG ((EFI_D_NET
, "\nSnp->undi.get_init_info() "));
521 (*Snp
->IssueUndi32Command
) ((UINT64
)(UINTN
) &Snp
->Cdb
);
524 // Save the INIT Stat Code...
526 InitStatFlags
= Snp
->Cdb
.StatFlags
;
528 if (Snp
->Cdb
.StatCode
!= PXE_STATCODE_SUCCESS
) {
529 DEBUG ((EFI_D_NET
, "\nSnp->undi.init_info() %xh:%xh\n", Snp
->Cdb
.StatFlags
, Snp
->Cdb
.StatCode
));
531 goto Error_DeleteSNP
;
535 // Initialize simple network protocol mode structure
537 Snp
->Mode
.State
= EfiSimpleNetworkStopped
;
538 Snp
->Mode
.HwAddressSize
= Snp
->InitInfo
.HWaddrLen
;
539 Snp
->Mode
.MediaHeaderSize
= Snp
->InitInfo
.MediaHeaderLen
;
540 Snp
->Mode
.MaxPacketSize
= Snp
->InitInfo
.FrameDataLen
;
541 Snp
->Mode
.NvRamAccessSize
= Snp
->InitInfo
.NvWidth
;
542 Snp
->Mode
.NvRamSize
= Snp
->InitInfo
.NvCount
* Snp
->Mode
.NvRamAccessSize
;
543 Snp
->Mode
.IfType
= Snp
->InitInfo
.IFtype
;
544 Snp
->Mode
.MaxMCastFilterCount
= Snp
->InitInfo
.MCastFilterCnt
;
545 Snp
->Mode
.MCastFilterCount
= 0;
547 switch (InitStatFlags
& PXE_STATFLAGS_CABLE_DETECT_MASK
) {
548 case PXE_STATFLAGS_CABLE_DETECT_SUPPORTED
:
549 Snp
->Mode
.MediaPresentSupported
= TRUE
;
552 case PXE_STATFLAGS_CABLE_DETECT_NOT_SUPPORTED
:
554 Snp
->Mode
.MediaPresentSupported
= FALSE
;
557 switch (InitStatFlags
& PXE_STATFLAGS_GET_STATUS_NO_MEDIA_MASK
) {
558 case PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED
:
559 Snp
->MediaStatusSupported
= TRUE
;
562 case PXE_STATFLAGS_GET_STATUS_NO_MEDIA_NOT_SUPPORTED
:
564 Snp
->MediaStatusSupported
= FALSE
;
567 if ((Pxe
->hw
.Implementation
& PXE_ROMID_IMP_STATION_ADDR_SETTABLE
) != 0) {
568 Snp
->Mode
.MacAddressChangeable
= TRUE
;
570 Snp
->Mode
.MacAddressChangeable
= FALSE
;
573 if ((Pxe
->hw
.Implementation
& PXE_ROMID_IMP_MULTI_FRAME_SUPPORTED
) != 0) {
574 Snp
->Mode
.MultipleTxSupported
= TRUE
;
576 Snp
->Mode
.MultipleTxSupported
= FALSE
;
579 Snp
->Mode
.ReceiveFilterMask
= EFI_SIMPLE_NETWORK_RECEIVE_UNICAST
;
581 if ((Pxe
->hw
.Implementation
& PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED
) != 0) {
582 Snp
->Mode
.ReceiveFilterMask
|= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST
;
586 if ((Pxe
->hw
.Implementation
& PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED
) != 0) {
587 Snp
->Mode
.ReceiveFilterMask
|= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS
;
591 if ((Pxe
->hw
.Implementation
& PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED
) != 0) {
592 Snp
->Mode
.ReceiveFilterMask
|= EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST
;
596 if ((Pxe
->hw
.Implementation
& PXE_ROMID_IMP_FILTERED_MULTICAST_RX_SUPPORTED
) != 0) {
597 Snp
->Mode
.ReceiveFilterMask
|= EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST
;
601 if ((Pxe
->hw
.Implementation
& PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED
) != 0) {
602 Snp
->Mode
.ReceiveFilterMask
|= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST
;
606 Snp
->Mode
.ReceiveFilterSetting
= 0;
609 // need to get the station address to save in the mode structure. we need to
610 // initialize the UNDI first for this.
612 Snp
->TxRxBufferSize
= Snp
->InitInfo
.MemoryRequired
;
613 Status
= PxeInit (Snp
, PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE
);
615 if (EFI_ERROR (Status
)) {
617 goto Error_DeleteSNP
;
620 Status
= PxeGetStnAddr (Snp
);
622 if (Status
!= EFI_SUCCESS
) {
623 DEBUG ((EFI_D_ERROR
, "\nSnp->undi.get_station_addr() failed.\n"));
626 goto Error_DeleteSNP
;
629 Snp
->Mode
.MediaPresent
= FALSE
;
632 // We should not leave UNDI started and initialized here. this DriverStart()
633 // routine must only find and attach the SNP interface to UNDI layer that it
634 // finds on the given handle!
635 // The UNDI layer will be started when upper layers call Snp->start.
636 // How ever, this DriverStart() must fill up the snp mode structure which
637 // contains the MAC address of the NIC. For this reason we started and
638 // initialized UNDI here, now we are done, do a shutdown and stop of the
645 // Create EXIT_BOOT_SERIVES Event
647 Status
= gBS
->CreateEventEx (
650 SnpNotifyExitBootServices
,
652 &gEfiEventExitBootServicesGuid
,
653 &Snp
->ExitBootServicesEvent
655 if (EFI_ERROR (Status
)) {
656 goto Error_DeleteSNP
;
660 // add SNP to the undi handle
662 Status
= gBS
->InstallProtocolInterface (
664 &gEfiSimpleNetworkProtocolGuid
,
665 EFI_NATIVE_INTERFACE
,
669 if (!EFI_ERROR (Status
)) {
675 SNP_MEM_PAGES (4096),
683 SNP_MEM_PAGES (sizeof (SNP_DRIVER
)),
689 &gEfiNetworkInterfaceIdentifierProtocolGuid_31
,
690 This
->DriverBindingHandle
,
696 &gEfiDevicePathProtocolGuid
,
697 This
->DriverBindingHandle
,
702 // If we got here that means we are in error state.
704 if (!EFI_ERROR (Status
)) {
705 Status
= EFI_DEVICE_ERROR
;
712 Stop this driver on ControllerHandle. This service is called by the
713 EFI boot service DisconnectController(). In order to
714 make drivers as small as possible, there are a few calling
715 restrictions for this service. DisconnectController()
716 must follow these calling restrictions. If any other agent wishes
717 to call Stop() it must also follow these calling restrictions.
719 @param This Protocol instance pointer.
720 @param ControllerHandle Handle of device to stop driver on
721 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
722 children is zero stop the entire bus driver.
723 @param ChildHandleBuffer List of Child Handles to Stop.
725 @retval EFI_SUCCESS This driver is removed ControllerHandle
726 @retval other This driver was not removed from this device
731 SimpleNetworkDriverStop (
732 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
733 IN EFI_HANDLE Controller
,
734 IN UINTN NumberOfChildren
,
735 IN EFI_HANDLE
*ChildHandleBuffer
739 EFI_SIMPLE_NETWORK_PROTOCOL
*SnpProtocol
;
741 EFI_PCI_IO_PROTOCOL
*PciIo
;
744 // Get our context back.
746 Status
= gBS
->OpenProtocol (
748 &gEfiSimpleNetworkProtocolGuid
,
749 (VOID
**) &SnpProtocol
,
750 This
->DriverBindingHandle
,
752 EFI_OPEN_PROTOCOL_GET_PROTOCOL
755 if (EFI_ERROR (Status
)) {
756 return EFI_UNSUPPORTED
;
759 Snp
= EFI_SIMPLE_NETWORK_DEV_FROM_THIS (SnpProtocol
);
761 Status
= gBS
->UninstallProtocolInterface (
763 &gEfiSimpleNetworkProtocolGuid
,
767 if (EFI_ERROR (Status
)) {
772 // Close EXIT_BOOT_SERIVES Event
774 gBS
->CloseEvent (Snp
->ExitBootServicesEvent
);
776 Status
= gBS
->CloseProtocol (
778 &gEfiNetworkInterfaceIdentifierProtocolGuid_31
,
779 This
->DriverBindingHandle
,
783 Status
= gBS
->CloseProtocol (
785 &gEfiDevicePathProtocolGuid
,
786 This
->DriverBindingHandle
,
796 SNP_MEM_PAGES (4096),
802 SNP_MEM_PAGES (sizeof (SNP_DRIVER
)),
810 // Simple Network Protocol Driver Global Variables
812 EFI_DRIVER_BINDING_PROTOCOL gSimpleNetworkDriverBinding
= {
813 SimpleNetworkDriverSupported
,
814 SimpleNetworkDriverStart
,
815 SimpleNetworkDriverStop
,
822 The SNP driver entry point.
824 @param ImageHandle The driver image handle.
825 @param SystemTable The system table.
827 @retval EFI_SUCEESS Initialization routine has found UNDI hardware,
828 loaded it's ROM, and installed a notify event for
829 the Network Indentifier Interface Protocol
831 @retval Other Return value from HandleProtocol for
832 DeviceIoProtocol or LoadedImageProtocol
837 InitializeSnpNiiDriver (
838 IN EFI_HANDLE ImageHandle
,
839 IN EFI_SYSTEM_TABLE
*SystemTable
842 return EfiLibInstallDriverBindingComponentName2 (
845 &gSimpleNetworkDriverBinding
,
847 &gSimpleNetworkComponentName
,
848 &gSimpleNetworkComponentName2