X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIp4Dxe%2FIp4Driver.c;h=792db5c173f2ad47a5578e31407ce8279074d73e;hb=ad18ec95437e6947ba4190f2b281659999db880b;hp=4d3ccec61047c9b1ddde686a43e21ac2b38401c9;hpb=2c3200072f94313600c6fa9af57715220b51a5fb;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c index 4d3ccec610..792db5c173 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c @@ -1,7 +1,9 @@ /** @file The driver binding and service binding protocol for IP4 driver. -Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
+(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -23,6 +25,30 @@ EFI_DRIVER_BINDING_PROTOCOL gIp4DriverBinding = { NULL }; +BOOLEAN mIpSec2Installed = FALSE; + +/** + Callback function for IpSec2 Protocol install. + + @param[in] Event Event whose notification function is being invoked + @param[in] Context Pointer to the notification function's context + +**/ +VOID +EFIAPI +IpSec2InstalledCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // Close the event so it does not get called again. + // + gBS->CloseEvent (Event); + + mIpSec2Installed = TRUE; +} + /** This is the declaration of an EFI image entry point. This entry point is the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including @@ -45,6 +71,16 @@ Ip4DriverEntryPoint ( IN EFI_SYSTEM_TABLE *SystemTable ) { + VOID *Registration; + + EfiCreateProtocolNotifyEvent ( + &gEfiIpSec2ProtocolGuid, + TPL_CALLBACK, + IpSec2InstalledCallback, + NULL, + &Registration + ); + return EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, @@ -211,12 +247,14 @@ Ip4CreateService ( IpSb->Timer = NULL; IpSb->ReconfigEvent = NULL; + + IpSb->Reconfig = FALSE; IpSb->MediaPresent = TRUE; // // Create various resources. First create the route table, timer - // event and MNP child. IGMP, interface's initialization depend + // event, ReconfigEvent and MNP child. IGMP, interface's initialization depend // on the MNP child. // IpSb->DefaultRouteTable = Ip4CreateRouteTable (); @@ -238,6 +276,17 @@ Ip4CreateService ( goto ON_ERROR; } + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + Ip4AutoReconfigCallBack, + IpSb, + &IpSb->ReconfigEvent + ); + if (EFI_ERROR (Status)) { + goto ON_ERROR; + } + Status = NetLibCreateServiceChild ( Controller, ImageHandle, @@ -344,6 +393,15 @@ Ip4CleanService ( { EFI_STATUS Status; + IpSb->State = IP4_SERVICE_DESTROY; + + if (IpSb->Timer != NULL) { + gBS->SetTimer (IpSb->Timer, TimerCancel, 0); + gBS->CloseEvent (IpSb->Timer); + + IpSb->Timer = NULL; + } + if (IpSb->DefaultInterface != NULL) { Status = Ip4FreeInterface (IpSb->DefaultInterface, NULL); @@ -383,19 +441,14 @@ Ip4CleanService ( IpSb->MnpChildHandle = NULL; } - if (IpSb->Timer != NULL) { - gBS->SetTimer (IpSb->Timer, TimerCancel, 0); - gBS->CloseEvent (IpSb->Timer); - - IpSb->Timer = NULL; - } - if (IpSb->ReconfigEvent != NULL) { gBS->CloseEvent (IpSb->ReconfigEvent); IpSb->ReconfigEvent = NULL; } + IpSb->Reconfig = FALSE; + if (IpSb->MacString != NULL) { FreePool (IpSb->MacString); } @@ -471,6 +524,13 @@ Ip4DriverBindingStart ( { EFI_STATUS Status; IP4_SERVICE *IpSb; + EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2; + UINTN Index; + IP4_CONFIG2_DATA_ITEM *DataItem; + + IpSb = NULL; + Ip4Cfg2 = NULL; + DataItem = NULL; // // Test for the Ip4 service binding protocol @@ -496,6 +556,8 @@ Ip4DriverBindingStart ( ASSERT (IpSb != NULL); + Ip4Cfg2 = &IpSb->Ip4Config2Instance.Ip4Config2; + // // Install the Ip4ServiceBinding Protocol onto ControlerHandle // @@ -504,13 +566,44 @@ Ip4DriverBindingStart ( &gEfiIp4ServiceBindingProtocolGuid, &IpSb->ServiceBinding, &gEfiIp4Config2ProtocolGuid, - &IpSb->Ip4Config2Instance.Ip4Config2, + Ip4Cfg2, NULL ); if (EFI_ERROR (Status)) { goto FREE_SERVICE; } + + // + // Read the config data from NV variable again. + // The default data can be changed by other drivers. + // + Status = Ip4Config2ReadConfigData (IpSb->MacString, &IpSb->Ip4Config2Instance); + if (EFI_ERROR (Status)) { + goto UNINSTALL_PROTOCOL; + } + + // + // Consume the installed EFI_IP4_CONFIG2_PROTOCOL to set the default data items. + // + for (Index = Ip4Config2DataTypePolicy; Index < Ip4Config2DataTypeMaximum; Index++) { + DataItem = &IpSb->Ip4Config2Instance.DataItem[Index]; + if (DataItem->Data.Ptr != NULL) { + Status = Ip4Cfg2->SetData ( + Ip4Cfg2, + Index, + DataItem->DataSize, + DataItem->Data.Ptr + ); + if (EFI_ERROR(Status)) { + goto UNINSTALL_PROTOCOL; + } + + if (Index == Ip4Config2DataTypePolicy && (*(DataItem->Data.Policy) == Ip4Config2PolicyDhcp)) { + break; + } + } + } // // Ready to go: start the receiving and timer. @@ -663,8 +756,6 @@ Ip4DriverBindingStop ( } else if (IsListEmpty (&IpSb->Children)) { State = IpSb->State; - IpSb->State = IP4_SERVICE_DESTROY; - // // OK, clean other resources then uninstall the service binding protocol. // @@ -709,7 +800,7 @@ ON_ERROR: @retval EFI_SUCCES The protocol was added to ChildHandle. @retval EFI_INVALID_PARAMETER ChildHandle is NULL. - @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create + @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create the child @retval other The child handle was not created @@ -831,7 +922,6 @@ Ip4ServiceBindingDestroyChild ( IP4_PROTOCOL *IpInstance; EFI_IP4_PROTOCOL *Ip4; EFI_TPL OldTpl; - INTN State; if ((This == NULL) || (ChildHandle == NULL)) { return EFI_INVALID_PARAMETER; @@ -869,13 +959,12 @@ Ip4ServiceBindingDestroyChild ( // when UDP driver is being stopped, it will destroy all // the IP child it opens. // - if (IpInstance->State == IP4_STATE_DESTROY) { + if (IpInstance->InDestroy) { gBS->RestoreTPL (OldTpl); return EFI_SUCCESS; } - State = IpInstance->State; - IpInstance->State = IP4_STATE_DESTROY; + IpInstance->InDestroy = TRUE; // // Close the Managed Network protocol. @@ -918,6 +1007,7 @@ Ip4ServiceBindingDestroyChild ( ); OldTpl = gBS->RaiseTPL (TPL_CALLBACK); if (EFI_ERROR (Status)) { + IpInstance->InDestroy = FALSE; goto ON_ERROR; } @@ -942,7 +1032,6 @@ Ip4ServiceBindingDestroyChild ( return EFI_SUCCESS; ON_ERROR: - IpInstance->State = State; gBS->RestoreTPL (OldTpl); return Status;