diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c b/NetworkPkg/HttpBootDxe/HttpBootClient.c index aae452729c..0c472938a0 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootClient.c +++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c @@ -447,6 +447,7 @@ HttpBootCreateHttpIo ( { HTTP_IO_CONFIG_DATA ConfigData; EFI_STATUS Status; + EFI_HANDLE ImageHandle; ASSERT (Private != NULL); @@ -456,14 +457,16 @@ HttpBootCreateHttpIo ( ConfigData.Config4.RequestTimeOut = HTTP_BOOT_REQUEST_TIMEOUT; IP4_COPY_ADDRESS (&ConfigData.Config4.LocalIp, &Private->StationIp.v4); IP4_COPY_ADDRESS (&ConfigData.Config4.SubnetMask, &Private->SubnetMask.v4); + ImageHandle = Private->Ip4Nic->ImageHandle; } else { ConfigData.Config6.HttpVersion = HttpVersion11; ConfigData.Config6.RequestTimeOut = HTTP_BOOT_REQUEST_TIMEOUT; IP6_COPY_ADDRESS (&ConfigData.Config6.LocalIp, &Private->StationIp.v6); + ImageHandle = Private->Ip6Nic->ImageHandle; } Status = HttpIoCreateIo ( - Private->Image, + ImageHandle, Private->Controller, Private->UsingIpv6 ? IP_VERSION_6 : IP_VERSION_4, &ConfigData, diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.c b/NetworkPkg/HttpBootDxe/HttpBootConfig.c index 597192349d..0c1ff43d5c 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootConfig.c +++ b/NetworkPkg/HttpBootDxe/HttpBootConfig.c @@ -553,7 +553,6 @@ HttpBootConfigFormInit ( EFI_STATUS Status; HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo; VENDOR_DEVICE_PATH VendorDeviceNode; - EFI_SERVICE_BINDING_PROTOCOL *HttpSb; CHAR16 *MacString; CHAR16 *OldMenuString; CHAR16 MenuString[128]; @@ -600,20 +599,6 @@ HttpBootConfigFormInit ( &CallbackInfo->ConfigAccess, NULL ); - if (!EFI_ERROR (Status)) { - // - // Open the Parent Handle for the child - // - Status = gBS->OpenProtocol ( - Private->Controller, - &gEfiHttpServiceBindingProtocolGuid, - (VOID **) &HttpSb, - Private->Image, - CallbackInfo->ChildHandle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER - ); - } - if (EFI_ERROR (Status)) { goto Error; } @@ -636,7 +621,7 @@ HttpBootConfigFormInit ( // // Append MAC string in the menu help string // - Status = NetLibGetMacString (Private->Controller, Private->Image, &MacString); + Status = NetLibGetMacString (Private->Controller, NULL, &MacString); if (!EFI_ERROR (Status)) { OldMenuString = HiiGetString ( CallbackInfo->RegisteredHandle, @@ -654,6 +639,7 @@ HttpBootConfigFormInit ( FreePool (MacString); FreePool (OldMenuString); + CallbackInfo->Initilized = TRUE; return EFI_SUCCESS; } @@ -666,6 +652,7 @@ Error: /** Unload the configuration form, this includes: delete all the configuration entries, uninstall the form callback protocol, and free the resources used. + The form will only be unload completely when both IP4 and IP6 stack are stopped. @param[in] Private Pointer to the driver private data. @@ -680,18 +667,15 @@ HttpBootConfigFormUnload ( { HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo; + if (Private->Ip4Nic != NULL || Private->Ip6Nic != NULL) { + // + // Only unload the configuration form when both IP4 and IP6 stack are stopped. + // + return EFI_SUCCESS; + } + CallbackInfo = &Private->CallbackInfo; if (CallbackInfo->ChildHandle != NULL) { - // - // Close the child handle - // - gBS->CloseProtocol ( - Private->Controller, - &gEfiHttpServiceBindingProtocolGuid, - Private->Image, - CallbackInfo->ChildHandle - ); - // // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL // diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.h b/NetworkPkg/HttpBootDxe/HttpBootConfig.h index a2afd18a88..e610fe8cd9 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootConfig.h +++ b/NetworkPkg/HttpBootDxe/HttpBootConfig.h @@ -63,6 +63,7 @@ HttpBootConfigFormInit ( /** Unload the configuration form, this includes: delete all the configuration entries, uninstall the form callback protocol, and free the resources used. + The form will only be unload completely when both IP4 and IP6 stack are stopped. @param[in] Private Pointer to the driver private data. diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.c b/NetworkPkg/HttpBootDxe/HttpBootDxe.c index 6a3033db11..642e0fe31e 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootDxe.c +++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.c @@ -321,7 +321,7 @@ HttpBootIp4DxeDriverBindingStart ( ); if (!EFI_ERROR (Status)) { - Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id); + Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id); } else { // // Initialize the private data structure. @@ -332,7 +332,6 @@ HttpBootIp4DxeDriverBindingStart ( } Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE; Private->Controller = ControllerHandle; - Private->Image = This->ImageHandle; InitializeListHead (&Private->CacheList); // // Get the NII interface if it exists, it's not required. @@ -399,8 +398,9 @@ HttpBootIp4DxeDriverBindingStart ( if (Private->Ip4Nic == NULL) { return EFI_OUT_OF_RESOURCES; } - Private->Ip4Nic->Private = Private; - Private->Ip4Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE; + Private->Ip4Nic->Private = Private; + Private->Ip4Nic->ImageHandle = This->DriverBindingHandle; + Private->Ip4Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE; // // Create DHCP4 child instance. @@ -793,7 +793,7 @@ HttpBootIp6DxeDriverBindingStart ( ); if (!EFI_ERROR (Status)) { - Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id); + Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id); } else { // // Initialize the private data structure. @@ -804,7 +804,6 @@ HttpBootIp6DxeDriverBindingStart ( } Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE; Private->Controller = ControllerHandle; - Private->Image = This->ImageHandle; InitializeListHead (&Private->CacheList); // // Get the NII interface if it exists, it's not required. @@ -871,9 +870,10 @@ HttpBootIp6DxeDriverBindingStart ( if (Private->Ip6Nic == NULL) { return EFI_OUT_OF_RESOURCES; } - Private->Ip6Nic->Private = Private; - Private->Ip6Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE; - + Private->Ip6Nic->Private = Private; + Private->Ip6Nic->ImageHandle = This->DriverBindingHandle; + Private->Ip6Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE; + // // Create Dhcp6 child and open Dhcp6 protocol Status = NetLibCreateServiceChild ( diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.h b/NetworkPkg/HttpBootDxe/HttpBootDxe.h index 7cb4b2c55a..b3e2576e1e 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootDxe.h +++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.h @@ -102,6 +102,7 @@ typedef union { struct _HTTP_BOOT_VIRTUAL_NIC { UINT32 Signature; EFI_HANDLE Controller; + EFI_HANDLE ImageHandle; EFI_LOAD_FILE_PROTOCOL LoadFile; EFI_DEVICE_PATH_PROTOCOL *DevicePath; HTTP_BOOT_PRIVATE_DATA *Private; @@ -118,7 +119,6 @@ struct _HTTP_BOOT_VIRTUAL_NIC { struct _HTTP_BOOT_PRIVATE_DATA { UINT32 Signature; EFI_HANDLE Controller; - EFI_HANDLE Image; HTTP_BOOT_VIRTUAL_NIC *Ip4Nic; HTTP_BOOT_VIRTUAL_NIC *Ip6Nic; diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c b/NetworkPkg/HttpBootDxe/HttpBootSupport.c index 758c49b712..bd99a913c6 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c +++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c @@ -372,7 +372,7 @@ HttpBootDns ( // Status = NetLibCreateServiceChild ( Private->Controller, - Private->Image, + Private->Ip6Nic->ImageHandle, &gEfiDns6ServiceBindingProtocolGuid, &Dns6Handle ); @@ -384,7 +384,7 @@ HttpBootDns ( Dns6Handle, &gEfiDns6ProtocolGuid, (VOID **) &Dns6, - Private->Image, + Private->Ip6Nic->ImageHandle, Private->Controller, EFI_OPEN_PROTOCOL_BY_DRIVER ); @@ -474,7 +474,7 @@ Exit: gBS->CloseProtocol ( Dns6Handle, &gEfiDns6ProtocolGuid, - Private->Image, + Private->Ip6Nic->ImageHandle, Private->Controller ); } @@ -482,7 +482,7 @@ Exit: if (Dns6Handle != NULL) { NetLibDestroyServiceChild ( Private->Controller, - Private->Image, + Private->Ip6Nic->ImageHandle, &gEfiDns6ServiceBindingProtocolGuid, Dns6Handle );