From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.134]) by mx.groups.io with SMTP id smtpd.web10.4138.1607505891560451554 for ; Wed, 09 Dec 2020 01:24:51 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=iOw/JrSw; spf=pass (domain: os.amperecomputing.com, ip: 40.107.220.134, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FTHIi6BNAQcCl9/1hfr4uWtSm/XADC7R8Hq46veX2d3UBMAeDH/EMOKBJjTS8VKDhqiIlDe2rOyNUlI5Ex54m2Pl/FZTOPFtb+BJn3spSr4Bx37X/V4SgRCfUL4R2J/6hrjCFupvgtt9gOiR4f+4UWR/96K7YUNT51QScQhQ+IvqToyzhl/gAvnlWWj8GLt1eIlQ10sfcLdcDnuqB6bLIL1IG7+eiau93LATsCYaqr7XTOV2lVwRx9uPZkkVGMvF648c+nyGb4EbN/E6BIfDEDJAYWjTQpe4ScDBPpuKClyc/6L5Wks5HdbgB26IIt0I3YEiWrsJHS7FirT0tmzCsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LH0Fr5X1ijdyYKN0Zk2qL63s4TVm1rtqnltNG2O4t1E=; b=FX3sboQ6xUGHatkJ4yi9dnfkqsXgFBAX1RJVfmY0gG84VveBEXFUg9U3SDsrV73ntw24M/V+bNEQL7SSetpFZuOAnM7YOA15nNDEnYmxoqvML8zvisQXY/sYK65tF0ET8Wdnw7QsEI0Ryb7xHQUKjD5yJj4stDqQ7gTyJ6Y0fMLg3mWYIxrlaQSdP76B9tqASv3lXbBrMj52vhL1Nq6ir4CdW77liRR2BA2HtZvVXk7JfFplhQaaJ/oB82rhJddxv0FPvCmgGOoTxzYwDqnRwIjiZn2Utfz5ATvudCZE+36+qRL2oFOQcGNA/8xoiqvNj4nv9wvc0XowFq5D4LwOUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LH0Fr5X1ijdyYKN0Zk2qL63s4TVm1rtqnltNG2O4t1E=; b=iOw/JrSwhNuCBsA2vjHpVSuLugvy8UVo7UI4ZpwKdyi88IXSnHf7r2poQphSlWr5xX8uZ+t1WyTL05li4xJQsew9NAsCFVZ1dOtjNOBdE2PEyznoW4HH4WSPN9X9PlhlHhvTjl8+q9rypa5tkuBXfsQYLxeOJzHhDBbEKYxsLpc= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) by DM6PR01MB5609.prod.exchangelabs.com (2603:10b6:5:157::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Wed, 9 Dec 2020 09:24:50 +0000 Received: from DM6PR01MB5849.prod.exchangelabs.com ([fe80::c814:9a08:5c2e:4076]) by DM6PR01MB5849.prod.exchangelabs.com ([fe80::c814:9a08:5c2e:4076%5]) with mapi id 15.20.3632.023; Wed, 9 Dec 2020 09:24:50 +0000 From: "Nhi Pham" To: devel@edk2.groups.io Cc: Nhi Pham Subject: [edk2-platforms][PATCH 26/34] JadePkg: Add implementation for UEFI Capsule Update Date: Wed, 9 Dec 2020 16:25:23 +0700 Message-Id: <20201209092531.30867-27-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201209092531.30867-1-nhi@os.amperecomputing.com> References: <20201209092531.30867-1-nhi@os.amperecomputing.com> X-Originating-IP: [118.69.219.201] X-ClientProxiedBy: HK0PR01CA0054.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::18) To DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sw004.amperecomputing.com (118.69.219.201) by HK0PR01CA0054.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Wed, 9 Dec 2020 09:24:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f4d17796-b18e-4e2d-0e66-08d89c244766 X-MS-TrafficTypeDiagnostic: DM6PR01MB5609: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QPNPJVZBIUQC9MRdMVj1FoA8X/WneSvhojDLeS3qCyq1DbhxCZd45w8p3934BfvCWrYab+vONHPoz69ofvonQfnWurZcYd6QFqPXVBVWkqyHqHpvvsolhcq0c47xSgKY58Tw2zho8CWeC5mcfiEwphdjjCaOdZDzLo0RtoZzn1GfDCLjffBpEYz7EeLf3A3pEQFewc1/++wK6ZN3+Z4js6DXbtKw2C7e7wUrR6qpifBVmu6vESYAwexeBdfXAjATwahl55q2W4XvDMgDeT2qol+qaq+I4x0jmoKrJ+EOAPQKBYKpfS+1wcb/KSxhZ7pV2qHajw/NItdEslCK2BsVrGDzrYsRKgw/pjSgxY2WkLDqjJTfyu6WP3fEjmM4DCJF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR01MB5849.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(136003)(346002)(366004)(5660300002)(956004)(508600001)(52116002)(66946007)(6916009)(2616005)(1076003)(86362001)(6512007)(66476007)(26005)(8936002)(16526019)(107886003)(6666004)(186003)(6486002)(8676002)(6506007)(83380400001)(2906002)(15650500001)(34490700003)(66556008)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?kCCD2u1TXhFSpQfAiahdL0nmuHc34SFBNXfM0EBrgalw8zKIm+f6il3l561T?= =?us-ascii?Q?Z4tbXC8jaXFL5HXkLORcLsAEiPUYZZLurAzC/DXWhpTUwTsAiURAHxIQ1Fyz?= =?us-ascii?Q?fSFHF5po5mi4FO1QBs99VhZBYgGsklkV3tpv05ZqyM0IgzJsG/w8u58yZ5sc?= =?us-ascii?Q?WgTv7lySIcqpC7p1aomRxAj2bgB+I4n5x1u48ZOM63cUDxd42eoqWcLJsNCN?= =?us-ascii?Q?zjDCJuXGXocddlmNeGdF1QtOBEaymDGHLXigZvr82TeeueHfUABOCQsIjk+x?= =?us-ascii?Q?BeLwjF+K7FiVFrcdH2rQUWAVWo3kaFirDWu9d+vgz/L15AyGMmE61rJqKkfB?= =?us-ascii?Q?KGEFSvDaZbh+UU8LAFf9SNEbugTDDVT5Qun+wtkwHeBUazd4uSQrA0obTqA6?= =?us-ascii?Q?SI8FxGbzAsIDMBqqGyDEsKPShxUjE16WhKuf7wJGG+lv9iPFK7P2GHcgD/hN?= =?us-ascii?Q?3osYbX3TVMIsWMZH8yNKRENVyxMCBmMk5TXGbh7H/GardjF7ox0WU9UixAmD?= =?us-ascii?Q?up04Qf3INKuTO4MxiKBfO6Ha/4aLtVMza8gbFgbgx+8KJC8Exanwy+4Lf7p+?= =?us-ascii?Q?20Ygp0V4ZjiFWLZE1ayprhduiqtFALCMKoBBSpdPIuRra1KuETanwiyrGUBP?= =?us-ascii?Q?Z6TXqc8u4UMHVEBc9GVV8DVyOUlLGv8QVhrJ18uYQ42Mwa++b1tM7H+S6CSp?= =?us-ascii?Q?YUSNrfPP8IfJOSKlQq7XgHQMFJytlrKD75rEEDJvyy1FDzjlpVIwvoIy4TsT?= =?us-ascii?Q?/ODqJHdqxgHcnQ6SK8DB0EhqwPSLokZhl+XF2WURFBZur4sGXVgfvJnwZ6/0?= =?us-ascii?Q?3EFpHFPOxxtKhNpzAJeJv8pkvvjVp6BbIHzGQEZNaK56CGDbYbHml+q0wjAG?= =?us-ascii?Q?8ZjCa/dSmP/576ROYe8UlOEICcu6AcRa4QsRoAbZdDZc9g0hzveUC1bxaMPv?= =?us-ascii?Q?C81ugekkL8BU64v723pNvMFzxk4Mxo0P9NH7HHJxQziKDtfBJQbTGoLU5P9v?= =?us-ascii?Q?JgCK?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5849.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2020 09:24:50.2682 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-Network-Message-Id: f4d17796-b18e-4e2d-0e66-08d89c244766 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: I0NVPfhcpfKeVsnL2DUDPf3dJIgfomvA/YCj/SXGujZZ3he8KMylSXFlMPXQnjkqUKHHFoGuohc06lx1nGrsoh0L+R5MkpeRVGd0oECtfwE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB5609 Content-Type: text/plain This provides the implementation of required platform components for UEFI Capsule Update: * SystemFirmwareDescriptor: to determine the current firmware version information. * SystemFirmwareUpdateConfig: provides the inventory of components in the capsule. Signed-off-by: Nhi Pham --- Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf | 41 +++++++++++ Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c | 64 +++++++++++++++++ Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc | 75 ++++++++++++++++++++ Platform/Ampere/JadePkg/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini | 21 ++++++ 4 files changed, 201 insertions(+) diff --git a/Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf b/Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf new file mode 100644 index 000000000000..3de2f5346a23 --- /dev/null +++ b/Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf @@ -0,0 +1,41 @@ +## @file +# System Firmware descriptor. +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x0001001A + BASE_NAME = SystemFirmwareDescriptor + FILE_GUID = 90B2B846-CA6D-4D6E-A8D3-C140A8E110AC + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + ENTRY_POINT = SystemFirmwareDescriptorPeimEntry + +[Sources] + SystemFirmwareDescriptorPei.c + SystemFirmwareDescriptor.aslc + +[Packages] + ArmPkg/ArmPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + SignedCapsulePkg/SignedCapsulePkg.dec + +[LibraryClasses] + DebugLib + PcdLib + PeimEntryPoint + PeiServicesLib + +[FixedPcd] + +[Pcd] + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor + +[Depex] + TRUE diff --git a/Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c b/Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c new file mode 100644 index 000000000000..f841b8252b5e --- /dev/null +++ b/Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c @@ -0,0 +1,64 @@ +/** @file + System Firmware descriptor producer. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +/** + Entrypoint for SystemFirmwareDescriptor PEIM. + + @param[in] FileHandle Handle of the file being invoked. + @param[in] PeiServices Describes the list of possible PEI Services. + + @retval EFI_SUCCESS PPI successfully installed. +**/ +EFI_STATUS +EFIAPI +SystemFirmwareDescriptorPeimEntry ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *Descriptor; + UINTN Size; + UINTN Index; + UINT32 AuthenticationStatus; + + // + // Search RAW section. + // + Index = 0; + while (TRUE) { + Status = PeiServicesFfsFindSectionData3(EFI_SECTION_RAW, Index, FileHandle, + (VOID **)&Descriptor, &AuthenticationStatus); + if (EFI_ERROR(Status)) { + // Should not happen, must something wrong in FDF. + ASSERT(FALSE); + return EFI_NOT_FOUND; + } + if (Descriptor->Signature == EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE) { + break; + } + Index++; + } + + DEBUG((DEBUG_INFO, "EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR size - 0x%x\n", + Descriptor->Length)); + + Size = Descriptor->Length; + PcdSetPtrS (PcdEdkiiSystemFirmwareImageDescriptor, &Size, Descriptor); + + return EFI_SUCCESS; +} diff --git a/Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc b/Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc new file mode 100644 index 000000000000..3059e980a72d --- /dev/null +++ b/Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc @@ -0,0 +1,75 @@ +/** @file + System Firmware descriptor. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, Linaro, Ltd. All rights reserved.
+ Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +#define PACKAGE_VERSION 0xFFFFFFFF +#define PACKAGE_VERSION_STRING L"Unknown" + +#define CURRENT_FIRMWARE_VERSION 0x00000001 +#define CURRENT_FIRMWARE_VERSION_STRING L"0x00000001" +#define LOWEST_SUPPORTED_FIRMWARE_VERSION 0x00000001 + +#define IMAGE_ID SIGNATURE_64('J', 'A', 'D', 'E', '_', 'F', 'W', ' ') +#define IMAGE_ID_STRING L"Jade System Firmware" + +// PcdSystemFmpCapsuleImageTypeIdGuid +#define IMAGE_TYPE_ID_GUID { 0xf08bca31, 0x542e, 0x4cea, { 0x8b, 0x48, 0x8e, 0x54, 0xf9, 0x42, 0x25, 0x94 } } + +typedef struct { + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR Descriptor; + // real string data + CHAR16 ImageIdNameStr[sizeof(IMAGE_ID_STRING)/sizeof(CHAR16)]; + CHAR16 VersionNameStr[sizeof(CURRENT_FIRMWARE_VERSION_STRING)/sizeof(CHAR16)]; + CHAR16 PackageVersionNameStr[sizeof(PACKAGE_VERSION_STRING)/sizeof(CHAR16)]; +} IMAGE_DESCRIPTOR; + +STATIC IMAGE_DESCRIPTOR mImageDescriptor = +{ + { + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE, + sizeof(EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR), + sizeof(IMAGE_DESCRIPTOR), + PACKAGE_VERSION, // PackageVersion + OFFSET_OF (IMAGE_DESCRIPTOR, PackageVersionNameStr), // PackageVersionName + 1, // ImageIndex; + {0x0}, // Reserved + IMAGE_TYPE_ID_GUID, // ImageTypeId; + IMAGE_ID, // ImageId; + OFFSET_OF (IMAGE_DESCRIPTOR, ImageIdNameStr), // ImageIdName; + CURRENT_FIRMWARE_VERSION, // Version; + OFFSET_OF (IMAGE_DESCRIPTOR, VersionNameStr), // VersionName; + {0x0}, // Reserved2 + 0, // Size; + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | + IMAGE_ATTRIBUTE_RESET_REQUIRED | + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | + IMAGE_ATTRIBUTE_IN_USE, // AttributesSupported; + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | + IMAGE_ATTRIBUTE_RESET_REQUIRED | + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | + IMAGE_ATTRIBUTE_IN_USE, // AttributesSetting; + 0x0, // Compatibilities; + LOWEST_SUPPORTED_FIRMWARE_VERSION, // LowestSupportedImageVersion; + 0x00000000, // LastAttemptVersion; + 0, // LastAttemptStatus; + {0x0}, // Reserved3 + 0, // HardwareInstance; + }, + // real string data + IMAGE_ID_STRING, + CURRENT_FIRMWARE_VERSION_STRING, + PACKAGE_VERSION_STRING, +}; + +VOID* CONST ReferenceAcpiTable = &mImageDescriptor; diff --git a/Platform/Ampere/JadePkg/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Platform/Ampere/JadePkg/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini new file mode 100644 index 000000000000..2a5891f4ddb4 --- /dev/null +++ b/Platform/Ampere/JadePkg/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini @@ -0,0 +1,21 @@ +## @file +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Head] +NumOfUpdate = 1 +NumOfRecovery = 0 +Update0 = JadeUEFIATF + +[JadeUEFIATF] +FirmwareType = 2147483650 # SystemFirmware: 0x80000002 - OEM UEFI and ARM Trusted Firmware +AddressType = 1 # 0 - relative address, 1 - absolute address. +BaseAddress = 0x00000000 # Base address offset on flash +Length = 0x00D10000 # Length +ImageOffset = 0x00000000 # Image offset of this SystemFirmware image +FileGuid = 431c06ed-4fe2-438f-98a3-a9b1fd923019 # PcdEdkiiSystemFirmwareFileGuid -- 2.17.1