From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2AC99823F1 for ; Thu, 22 Dec 2016 23:47:57 -0800 (PST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP; 22 Dec 2016 23:47:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,392,1477983600"; d="scan'208";a="46078268" Received: from jyao1-mobl.ccr.corp.intel.com ([10.239.193.82]) by fmsmga005.fm.intel.com with ESMTP; 22 Dec 2016 23:47:55 -0800 From: Jiewen Yao To: edk2-devel@lists.01.org Cc: Feng Tian , Star Zeng , Chao Zhang Date: Fri, 23 Dec 2016 15:47:49 +0800 Message-Id: <1482479269-8800-1-git-send-email-jiewen.yao@intel.com> X-Mailer: git-send-email 2.7.4.windows.1 Subject: [PATCH] MdeModulePkg/CapsuleLib: Add CapsuleTarget support. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Dec 2016 07:47:57 -0000 UEFI spec requires CapsuleTarget to be a device path associated with FMP producer. Cc: Feng Tian Cc: Star Zeng Cc: Chao Zhang Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao --- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 15 +++++++++++-- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 22 +++++++++++++++++--- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLibNull.c | 4 +++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index af08886..2bb6ac8 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -100,6 +100,7 @@ RecordCapsuleStatusVariable ( @param[in] CapsuleStatus The capsule process stauts @param[in] PayloadIndex FMP payload index @param[in] ImageHeader FMP image header + @param[in] FmpDevicePath DevicePath associated with the FMP producer @retval EFI_SUCCESS The capsule status variable is recorded. @retval EFI_OUT_OF_RESOURCES No resource to record the capsule status variable. @@ -109,7 +110,8 @@ RecordFmpCapsuleStatusVariable ( IN EFI_CAPSULE_HEADER *CapsuleHeader, IN EFI_STATUS CapsuleStatus, IN UINTN PayloadIndex, - IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader + IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader, + IN EFI_DEVICE_PATH_PROTOCOL *FmpDevicePath OPTIONAL ); /** @@ -818,6 +820,7 @@ ProcessFmpCapsuleImage ( UINTN Index2; MEMMAP_DEVICE_PATH MemMapNode; EFI_DEVICE_PATH_PROTOCOL *DriverDevicePath; + EFI_DEVICE_PATH_PROTOCOL *FmpDevicePath; ESRT_MANAGEMENT_PROTOCOL *EsrtProtocol; EFI_SYSTEM_RESOURCE_ENTRY EsrtEntry; VOID *VendorCode; @@ -941,6 +944,13 @@ ProcessFmpCapsuleImage ( continue; } + FmpDevicePath = NULL; + gBS->HandleProtocol( + HandleBuffer[Index1], + &gEfiDevicePathProtocolGuid, + (VOID **)&FmpDevicePath + ); + ImageInfoSize = 0; Status = Fmp->GetImageInfo ( Fmp, @@ -1060,7 +1070,8 @@ ProcessFmpCapsuleImage ( CapsuleHeader, // CapsuleGuid Status, // CapsuleStatus Index - FmpCapsuleHeader->EmbeddedDriverCount, // PayloadIndex - ImageHeader // ImageHeader + ImageHeader, // ImageHeader + FmpDevicePath // FmpDevicePath ); if (StatusRet != EFI_SUCCESS) { StatusRet = Status; diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c index d34eb25..788793b 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -280,6 +281,7 @@ RecordCapsuleStatusVariable ( @param[in] CapsuleStatus The capsule process stauts @param[in] PayloadIndex FMP payload index @param[in] ImageHeader FMP image header + @param[in] FmpDevicePath DevicePath associated with the FMP producer @retval EFI_SUCCESS The capsule status variable is recorded. @retval EFI_OUT_OF_RESOURCES No resource to record the capsule status variable. @@ -289,7 +291,8 @@ RecordFmpCapsuleStatusVariable ( IN EFI_CAPSULE_HEADER *CapsuleHeader, IN EFI_STATUS CapsuleStatus, IN UINTN PayloadIndex, - IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader + IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader, + IN EFI_DEVICE_PATH_PROTOCOL *FmpDevicePath OPTIONAL ) { EFI_CAPSULE_RESULT_VARIABLE_HEADER *CapsuleResultVariableHeader; @@ -297,12 +300,22 @@ RecordFmpCapsuleStatusVariable ( EFI_STATUS Status; UINT8 *CapsuleResultVariable; UINT32 CapsuleResultVariableSize; + CHAR16 *DevicePathStr; + UINTN DevicePathStrSize; - CapsuleResultVariable = NULL; + DevicePathStr = NULL; + if (FmpDevicePath != NULL) { + DevicePathStr = ConvertDevicePathToText (FmpDevicePath, FALSE, FALSE); + } + if (DevicePathStr != NULL) { + DevicePathStrSize = StrSize(DevicePathStr); + } else { + DevicePathStrSize = sizeof(CHAR16); + } // // Allocate zero CHAR16 for CapsuleFileName and CapsuleTarget. // - CapsuleResultVariableSize = sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + sizeof(CHAR16) * 2; + CapsuleResultVariableSize = sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + sizeof(CHAR16) + DevicePathStrSize; CapsuleResultVariable = AllocateZeroPool (CapsuleResultVariableSize); if (CapsuleResultVariable == NULL) { return EFI_OUT_OF_RESOURCES; @@ -320,6 +333,9 @@ RecordFmpCapsuleStatusVariable ( CapsuleResultVariableFmp->PayloadIndex = (UINT8)PayloadIndex; CapsuleResultVariableFmp->UpdateImageIndex = ImageHeader->UpdateImageIndex; CopyGuid (&CapsuleResultVariableFmp->UpdateImageTypeId, &ImageHeader->UpdateImageTypeId); + if (DevicePathStr != NULL) { + CopyMem ((UINT8 *)CapsuleResultVariableFmp + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + sizeof(CHAR16), DevicePathStr, DevicePathStrSize); + } // // Save Local Cache diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLibNull.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLibNull.c index bf550e5..6ab198d 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLibNull.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLibNull.c @@ -64,6 +64,7 @@ RecordCapsuleStatusVariable ( @param[in] CapsuleStatus The capsule process stauts @param[in] PayloadIndex FMP payload index @param[in] ImageHeader FMP image header + @param[in] FmpDevicePath DevicePath associated with the FMP producer @retval EFI_SUCCESS The capsule status variable is recorded. @retval EFI_OUT_OF_RESOURCES No resource to record the capsule status variable. @@ -73,7 +74,8 @@ RecordFmpCapsuleStatusVariable ( IN EFI_CAPSULE_HEADER *CapsuleHeader, IN EFI_STATUS CapsuleStatus, IN UINTN PayloadIndex, - IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader + IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader, + IN EFI_DEVICE_PATH_PROTOCOL *FmpDevicePath OPTIONAL ) { return EFI_UNSUPPORTED; -- 2.7.4.windows.1