From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 F0BF2818CA for ; Sun, 25 Dec 2016 19:12:11 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP; 25 Dec 2016 19:12:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,404,1477983600"; d="scan'208";a="1104205297" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga002.fm.intel.com with ESMTP; 25 Dec 2016 19:12:11 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 25 Dec 2016 19:12:11 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0248.002; Mon, 26 Dec 2016 11:12:09 +0800 From: "Zhang, Chao B" To: "Yao, Jiewen" , "edk2-devel@lists.01.org" CC: "Tian, Feng" , "Zeng, Star" Thread-Topic: [PATCH V2] MdeModulePkg/CapsuleLib: Add CapsuleTarget support. Thread-Index: AQHSXTYEnPFDMw2Y0UuPxmxV2XhE/KEZkSjg Date: Mon, 26 Dec 2016 03:12:09 +0000 Message-ID: References: <1482508959-16144-1-git-send-email-jiewen.yao@intel.com> In-Reply-To: <1482508959-16144-1-git-send-email-jiewen.yao@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZmQ5MmY5NjItOGIwMi00MWViLTk2YTgtNmY3NmRmOGUzZmU1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InZEMWRIcG1UNmNrdnQ2cHo5NGRMSEwzdUM4SWJ6YUtLR2ZyMVUwUVJYMjA9In0= x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH V2] 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: Mon, 26 Dec 2016 03:12:12 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by : Chao Zhang Thanks & Best regards Chao Zhang -----Original Message----- From: Yao, Jiewen=20 Sent: Saturday, December 24, 2016 12:03 AM To: edk2-devel@lists.01.org Cc: Tian, Feng; Zeng, Star; Zhang, Chao B Subject: [PATCH V2] MdeModulePkg/CapsuleLib: Add CapsuleTarget support. 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 | 28 +++++= +++++++++++---- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLibNull.c | 4 ++- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeMod= ulePkg/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 =20 @retval EFI_SUCCESS The capsule status variable is recorded. @retval EFI_OUT_OF_RESOURCES No resource to record the capsule status va= riable. @@ -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 ); =20 /** @@ -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; } =20 + FmpDevicePath =3D NULL; + gBS->HandleProtocol( + HandleBuffer[Index1], + &gEfiDevicePathProtocolGuid, + (VOID **)&FmpDevicePath + ); + ImageInfoSize =3D 0; Status =3D Fmp->GetImageInfo ( Fmp, @@ -1060,7 +1070,8 @@ ProcessFmpCapsuleImage ( CapsuleHeader, // CapsuleGui= d Status, // CapsuleSta= tus Index - FmpCapsuleHeader->EmbeddedDriverCount, // PayloadInd= ex - ImageHeader // ImageHeade= r + ImageHeader, // ImageHeade= r + FmpDevicePath // FmpDeviceP= ath ); if (StatusRet !=3D EFI_SUCCESS) { StatusRet =3D Status; diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c b/= MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c index d34eb25..bba30b5 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c @@ -30,6 +30,7 @@ #include #include #include +#include #include =20 #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 =20 @retval EFI_SUCCESS The capsule status variable is recorded. @retval EFI_OUT_OF_RESOURCES No resource to record the capsule status va= riable. @@ -289,26 +291,37 @@ 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; EFI_CAPSULE_RESULT_VARIABLE_FMP *CapsuleResultVariableFmp; EFI_STATUS Status; UINT8 *CapsuleResultVariable; - UINT32 CapsuleResultVariableSize; + UINTN CapsuleResultVariableSize; + CHAR16 *DevicePathStr; + UINTN DevicePathStrSize; =20 - CapsuleResultVariable =3D NULL; + DevicePathStr =3D NULL; + if (FmpDevicePath !=3D NULL) { + DevicePathStr =3D ConvertDevicePathToText (FmpDevicePath, FALSE, FALSE= ); + } + if (DevicePathStr !=3D NULL) { + DevicePathStrSize =3D StrSize(DevicePathStr); + } else { + DevicePathStrSize =3D sizeof(CHAR16); + } // // Allocate zero CHAR16 for CapsuleFileName and CapsuleTarget. // - CapsuleResultVariableSize =3D sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER)= + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + sizeof(CHAR16) * 2; + CapsuleResultVariableSize =3D sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER)= + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + sizeof(CHAR16) + DevicePathStr= Size; CapsuleResultVariable =3D AllocateZeroPool (CapsuleResultVariableSiz= e); if (CapsuleResultVariable =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } CapsuleResultVariableHeader =3D (VOID *)CapsuleResultVariable; - CapsuleResultVariableHeader->VariableTotalSize =3D CapsuleResultVariable= Size; + CapsuleResultVariableHeader->VariableTotalSize =3D (UINT32)CapsuleResult= VariableSize; CapsuleResultVariableHeader->Reserved =3D 0; CopyGuid(&CapsuleResultVariableHeader->CapsuleGuid, &CapsuleHeader->Caps= uleGuid); ZeroMem(&CapsuleResultVariableHeader->CapsuleProcessed, sizeof(CapsuleRe= sultVariableHeader->CapsuleProcessed)); @@ -320,6 +333,11 @@ RecordFmpCapsuleStatusVariable ( CapsuleResultVariableFmp->PayloadIndex =3D (UINT8)PayloadIndex; CapsuleResultVariableFmp->UpdateImageIndex =3D ImageHeader->UpdateImageI= ndex; CopyGuid (&CapsuleResultVariableFmp->UpdateImageTypeId, &ImageHeader->Up= dateImageTypeId); + if (DevicePathStr !=3D NULL) { + CopyMem ((UINT8 *)CapsuleResultVariableFmp + sizeof(EFI_CAPSULE_RESULT= _VARIABLE_FMP) + sizeof(CHAR16), DevicePathStr, DevicePathStrSize); + FreePool (DevicePathStr); + DevicePathStr =3D NULL; + } =20 // // 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 =20 @retval EFI_SUCCESS The capsule status variable is recorded. @retval EFI_OUT_OF_RESOURCES No resource to record the capsule status va= riable. @@ -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; --=20 2.7.4.windows.1