X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIp4Dxe%2FIp4Driver.c;h=0f2558141459a59b1ad1fc7e617076fee95c0467;hb=4a76d9b9a33783c9a8bd4a77df5427522292586c;hp=642e453e020eace3db9b8cfb5ec5e633382dff5d;hpb=2048c585b46d240d76e3097917cbbfe43a7be88e;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c index 642e453e02..0f25581414 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c @@ -1,7 +1,7 @@ /** @file The driver binding and service binding protocol for IP4 driver. -Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
This program and the accompanying materials @@ -41,12 +41,20 @@ IpSec2InstalledCallback ( IN VOID *Context ) { + EFI_STATUS Status; // - // Close the event so it does not get called again. + // Test if protocol was even found. + // Notification function will be called at least once. // - gBS->CloseEvent (Event); + Status = gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **)&mIpSec); + if (Status == EFI_SUCCESS && mIpSec != NULL) { + // + // Close the event so it does not get called again. + // + gBS->CloseEvent (Event); - mIpSec2Installed = TRUE; + mIpSec2Installed = TRUE; + } } /** @@ -245,11 +253,12 @@ Ip4CreateService ( ZeroMem (&IpSb->SnpMode, sizeof (EFI_SIMPLE_NETWORK_MODE)); IpSb->Timer = NULL; + IpSb->ReconfigCheckTimer = NULL; IpSb->ReconfigEvent = NULL; IpSb->Reconfig = FALSE; - + IpSb->MediaPresent = TRUE; // @@ -276,6 +285,18 @@ Ip4CreateService ( goto ON_ERROR; } + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + Ip4TimerReconfigChecking, + IpSb, + &IpSb->ReconfigCheckTimer + ); + + if (EFI_ERROR (Status)) { + goto ON_ERROR; + } + Status = gBS->CreateEvent ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, @@ -331,7 +352,7 @@ Ip4CreateService ( IpSb->MacString = NULL; Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString); - + if (EFI_ERROR (Status)) { goto ON_ERROR; } @@ -346,7 +367,7 @@ Ip4CreateService ( InsertHeadList (&IpSb->Interfaces, &IpSb->DefaultInterface->Link); ZeroMem (&IpSb->Ip4Config2Instance, sizeof (IP4_CONFIG2_INSTANCE)); - + Status = Ip4Config2InitInstance (&IpSb->Ip4Config2Instance); if (EFI_ERROR (Status)) { @@ -402,6 +423,13 @@ Ip4CleanService ( IpSb->Timer = NULL; } + if (IpSb->ReconfigCheckTimer != NULL) { + gBS->SetTimer (IpSb->ReconfigCheckTimer, TimerCancel, 0); + gBS->CloseEvent (IpSb->ReconfigCheckTimer); + + IpSb->ReconfigCheckTimer = NULL; + } + if (IpSb->DefaultInterface != NULL) { Status = Ip4FreeInterface (IpSb->DefaultInterface, NULL); @@ -460,7 +488,7 @@ Ip4CleanService ( /** Callback function which provided by user to remove one node in NetDestroyLinkList process. - + @param[in] Entry The entry to be removed. @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. @@ -521,7 +549,7 @@ Ip4DriverBindingStart ( IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ) -{ +{ EFI_STATUS Status; IP4_SERVICE *IpSb; EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2; @@ -547,13 +575,13 @@ Ip4DriverBindingStart ( if (Status == EFI_SUCCESS) { return EFI_ALREADY_STARTED; } - + Status = Ip4CreateService (ControllerHandle, This->DriverBindingHandle, &IpSb); - + if (EFI_ERROR (Status)) { return Status; } - + ASSERT (IpSb != NULL); Ip4Cfg2 = &IpSb->Ip4Config2Instance.Ip4Config2; @@ -575,16 +603,16 @@ Ip4DriverBindingStart ( } // - // Read the config data from NV variable again. + // 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. + // Consume the installed EFI_IP4_CONFIG2_PROTOCOL to set the default data items. // for (Index = Ip4Config2DataTypePolicy; Index < Ip4Config2DataTypeMaximum; Index++) { DataItem = &IpSb->Ip4Config2Instance.DataItem[Index]; @@ -598,13 +626,13 @@ Ip4DriverBindingStart ( if (EFI_ERROR(Status)) { goto UNINSTALL_PROTOCOL; } - + if (Index == Ip4Config2DataTypePolicy && (*(DataItem->Data.Policy) == Ip4Config2PolicyDhcp)) { break; - } + } } } - + // // Ready to go: start the receiving and timer. // Ip4Config2SetPolicy maybe call Ip4ReceiveFrame() to set the default interface's RecvRequest first after @@ -622,6 +650,12 @@ Ip4DriverBindingStart ( goto UNINSTALL_PROTOCOL; } + Status = gBS->SetTimer (IpSb->ReconfigCheckTimer, TimerPeriodic, 500 * TICKS_PER_MS); + + if (EFI_ERROR (Status)) { + goto UNINSTALL_PROTOCOL; + } + // // Initialize the IP4 ID // @@ -671,9 +705,9 @@ Ip4DriverBindingStop ( ) { EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; - IP4_SERVICE *IpSb; + IP4_SERVICE *IpSb; EFI_HANDLE NicHandle; - EFI_STATUS Status; + EFI_STATUS Status; INTN State; LIST_ENTRY *List; IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; @@ -683,20 +717,20 @@ Ip4DriverBindingStop ( BOOLEAN IsDhcp4; IsDhcp4 = FALSE; - + NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp4ProtocolGuid); if (NicHandle != NULL) { - IsDhcp4 = TRUE; + IsDhcp4 = TRUE; } else { return EFI_SUCCESS; } } } - + Status = gBS->OpenProtocol ( NicHandle, &gEfiIp4ServiceBindingProtocolGuid, @@ -708,7 +742,7 @@ Ip4DriverBindingStop ( if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } - + IpSb = IP4_SERVICE_FROM_PROTOCOL (ServiceBinding); if (IsDhcp4) { @@ -727,7 +761,7 @@ Ip4DriverBindingStop ( NULL ); } else if (IpSb->DefaultInterface->ArpHandle == ControllerHandle) { - + // // The ARP protocol for the default interface is being uninstalled and all // its IP child handles should have been destroyed before. So, release the @@ -736,7 +770,7 @@ Ip4DriverBindingStop ( Ip4CancelReceive (IpSb->DefaultInterface); Ip4FreeInterface (IpSb->DefaultInterface, NULL); Ip4FreeRouteTable (IpSb->DefaultRouteTable); - + IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image); if (IpIf == NULL) { goto ON_ERROR; @@ -746,7 +780,7 @@ Ip4DriverBindingStop ( Ip4FreeInterface (IpIf, NULL); goto ON_ERROR;; } - + IpSb->DefaultInterface = IpIf; InsertHeadList (&IpSb->Interfaces, &IpIf->Link); IpSb->DefaultRouteTable = RouteTable; @@ -773,7 +807,7 @@ Ip4DriverBindingStop ( &IpSb->Ip4Config2Instance.Ip4Config2, NULL ); - + if (gIp4ControllerNameTable != NULL) { FreeUnicodeStringTable (gIp4ControllerNameTable); gIp4ControllerNameTable = NULL; @@ -922,7 +956,6 @@ Ip4ServiceBindingDestroyChild ( IP4_PROTOCOL *IpInstance; EFI_IP4_PROTOCOL *Ip4; EFI_TPL OldTpl; - INTN State; if ((This == NULL) || (ChildHandle == NULL)) { return EFI_INVALID_PARAMETER; @@ -960,13 +993,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. @@ -1009,6 +1041,7 @@ Ip4ServiceBindingDestroyChild ( ); OldTpl = gBS->RaiseTPL (TPL_CALLBACK); if (EFI_ERROR (Status)) { + IpInstance->InDestroy = FALSE; goto ON_ERROR; } @@ -1033,7 +1066,6 @@ Ip4ServiceBindingDestroyChild ( return EFI_SUCCESS; ON_ERROR: - IpInstance->State = State; gBS->RestoreTPL (OldTpl); return Status;