From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=104.47.37.129; helo=nam02-cy1-obe.outbound.protection.outlook.com; envelope-from=sean.brogan@microsoft.com; receiver=edk2-devel@lists.01.org Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0129.outbound.protection.outlook.com [104.47.37.129]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D41012263DD93 for ; Tue, 17 Apr 2018 15:26:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=YfMDlnJfPVTmrT1IJ7Kp6pZdw/82kr8XdbJ4oPGne6M=; b=NajyjU3uZlR0IaGLKRyv/vzL8taj8P9HMFjkPUUGJVU4UAKQVD99bzF5J/j6qiT3cKg7H4HvYysADGROUqFVNMwUuEXDzedHX5o3GuDw/d1BBi/4KZM5l0osdcGxl8H0at0vLMk3KVWDHSTXJTtymdS4UVHwIyH9fWYOD8zAs9c= Received: from CY4PR21MB0789.namprd21.prod.outlook.com (10.175.121.143) by CY4PR21MB0181.namprd21.prod.outlook.com (10.173.193.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.715.4; Tue, 17 Apr 2018 22:26:47 +0000 Received: from CY4PR21MB0789.namprd21.prod.outlook.com ([fe80::1468:84b3:8592:87aa]) by CY4PR21MB0789.namprd21.prod.outlook.com ([fe80::1468:84b3:8592:87aa%7]) with mapi id 15.20.0715.004; Tue, 17 Apr 2018 22:26:47 +0000 From: Sean Brogan To: "Kinney, Michael D" , "edk2-devel@lists.01.org" CC: Jiewen Yao Thread-Topic: [RFC v2 2/4] FmpDevicePkg: Add library instances Thread-Index: AQHT1o/RYf/34JhKbkuiKX0uSbeFsqQFiSNw Date: Tue, 17 Apr 2018 22:26:47 +0000 Message-ID: References: <20180417210522.29644-1-michael.d.kinney@intel.com> <20180417210522.29644-3-michael.d.kinney@intel.com> In-Reply-To: <20180417210522.29644-3-michael.d.kinney@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=sebrogan@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2018-04-17T22:26:45.9412612Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General x-originating-ip: [131.107.32.41] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CY4PR21MB0181; 7:k4l6fRaDQvHI4cPqCNliaS37LrlT0h8Mfg5Mp3t0pEHPqAQEsB/XOraGGkxc1sNoILqmkJPEK7ry2dxHsXvDkt42MS9xCzaah6+jOyltp6gSUO2WeX+3HEKigQuMk27keCn8GCDtdnumtV3TC7K/xbkDzIFkoaOE4Q8I/M5db/k7Yq6Af8DHETt7+9wFj8Yy3HCaVLVOta9+GFwN/KEZDDEKow/R7MoVCQ5hZTdBImKBck+lfpMw9OKz1FRnKt+p; 20:sFCSilZphFh+av0RvgtYRUOiORQshl8/bpF6oH4fexuhObgKf/TIlSIwbTgKxN5hnX65Mgwu7zFM3Vrd8/GSzAvjPSgh1w/hCxZLvrevk9wwDwBqBHIln1hGZpG2nHect/uinDhIPWLFCVhgIiQauHl3WfACYZeS9eGJxKe4Tjs= x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:CY4PR21MB0181; x-ms-traffictypediagnostic: CY4PR21MB0181: authentication-results: outbound.protection.outlook.com; spf=skipped (originating message); dkim=none (message not signed) header.d=none; dmarc=none action=none header.from=microsoft.com; x-o365ent-eop-header: Message processed by - O365_ENT: Allow from ranges (Engineering ONLY) x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(189930954265078)(162533806227266)(219752817060721)(211171220733660)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231232)(944501361)(52105095)(3002001)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY4PR21MB0181; BCL:0; PCL:0; RULEID:; SRVR:CY4PR21MB0181; x-forefront-prvs: 0645BEB7AA x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(39380400002)(376002)(39860400002)(13464003)(110136005)(33656002)(74316002)(3660700001)(305945005)(6306002)(3280700002)(9686003)(7736002)(55016002)(86612001)(25786009)(22452003)(3846002)(316002)(5660300001)(8936002)(53936002)(81166006)(6246003)(6436002)(8676002)(53946003)(16799955002)(4326008)(66066001)(966005)(53546011)(102836004)(6506007)(5250100002)(186003)(26005)(99286004)(86362001)(575784001)(44832011)(76176011)(7696005)(10290500003)(476003)(11346002)(2501003)(446003)(10090500001)(2906002)(478600001)(229853002)(59450400001)(579004)(559001)(19627235001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR21MB0181; H:CY4PR21MB0789.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; MLV:sfv; x-microsoft-antispam-message-info: 6KNa069txuo0eN8y4kTopzvYMtTUqsfTZFJRjbuZ03ZEDRTYKt5Up/DUqvqfeeXdRW5ceZV+Ac6Lvf3REQzmoFSCrfELmKosd3w3SUgyVYvSgs5KV44aEtwFlnvKeuhE9DZD6msLAcm/K35KMpSI8eMecdH1oUMUSklitniCRqzDBMoUVQlCxFzo6N8H0LgZ spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 6e97029d-8596-4ce4-23a9-08d5a4b24eee X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e97029d-8596-4ce4-23a9-08d5a4b24eee X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Apr 2018 22:26:47.7165 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0181 Subject: Re: [RFC v2 2/4] FmpDevicePkg: Add library instances X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Apr 2018 22:26:50 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Signed-off-by: Sean Brogan -----Original Message----- From: Kinney, Michael D =20 Sent: Tuesday, April 17, 2018 2:05 PM To: edk2-devel@lists.01.org Cc: Sean Brogan ; Jiewen Yao ; Michael D Kinney Subject: [RFC v2 2/4] FmpDevicePkg: Add library instances https://na01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fbugzilla= .tianocore.org%2Fshow_bug.cgi%3Fid%3D922&data=3D02%7C01%7Csean.brogan%40mic= rosoft.com%7Ce9788e2e77ea4e1d928208d5a4a6f285%7C72f988bf86f141af91ab2d7cd01= 1db47%7C1%7C0%7C636595959307464376&sdata=3D5xeGnjEngnIbzVFfF70RSsyjj3nCizvN= ilN3nansWjo%3D&reserved=3D0 Based on content from the following branch: https://na01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fgithub.c= om%2FMicrosoft%2FMS_UEFI%2Ftree%2Fshare%2FMsCapsuleSupport%2FMsCapsuleUpdat= ePkg&data=3D02%7C01%7Csean.brogan%40microsoft.com%7Ce9788e2e77ea4e1d928208d= 5a4a6f285%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636595959307464376&s= data=3DuadGKsQDA0CdKCD1rRdqulqAysgTOjYGCorgCHFhPcc%3D&reserved=3D0 Add library instances for FmpDeviceLib, CapsuleUpdatePolicyLib, and FmpPayl= oadHeaderLib. Library Classes =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * FmpDeviceLibNull - Non-functional template of the FmpDeviceLib that can be used as a starting point for an FmpDeviceLib for a specific firmware storage device. * CapsuleUpdatePolicyLibNull - Functional template of the CapsuleUpdatePolicyLib that can be used as a starting point of a platform specific implementation. * FmpPayloadHeaderLibV1 - Version 1 of the FmpPayloadHeaderLib. This library is indented to be used "as is" with no need for any device specific or platform specific changes. Cc: Sean Brogan Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney --- .../CapsuleUpdatePolicyLibNull.c | 136 +++++++ .../CapsuleUpdatePolicyLibNull.inf | 45 +++ .../CapsuleUpdatePolicyLibNull.uni | 17 + .../Library/FmpDeviceLibNull/FmpDeviceLib.c | 427 +++++++++++++++++= ++++ .../Library/FmpDeviceLibNull/FmpDeviceLibNull.inf | 48 +++ .../Library/= FmpDeviceLibNull/FmpDeviceLibNull.uni | 18 + .../FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c | 188 +++++++++ .../FmpPayloadHeaderLibV1.inf | 48 +++ .../FmpPayloadHeaderLibV1.uni | 21 + 9 files changed, 948 insertions(+) create mode 100644 FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/Capsule= UpdatePolicyLibNull.c create mode 100644 FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/Capsule= UpdatePolicyLibNull.inf create mode 100644 FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/Capsule= UpdatePolicyLibNull.uni create mode 100644 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c create mode 100644 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.= inf create mode 100644 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.= uni create mode 100644 FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHe= aderLib.c create mode 100644 FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHe= aderLibV1.inf create mode 100644 FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHe= aderLibV1.uni diff --git a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdateP= olicyLibNull.c b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpd= atePolicyLibNull.c new file mode 100644 index 0000000000..943fe372cb --- /dev/null +++ b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolic +++ yLibNull.c @@ -0,0 +1,136 @@ +/** @file + Provides platform policy services used during a capsule update. + + Copyright (c) 2016, Microsoft Corporation. All rights reserved.
=20 + Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + Redistribution and use in source and binary forms, with or without =20 + modification, are permitted provided that the following conditions are me= t: + 1. Redistributions of source code must retain the above copyright=20 + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright=20 + notice, this list of conditions and the following disclaimer in the=20 + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A = PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR=20 + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR=20 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF=20 + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR=20 + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,=20 + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE =20 + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF= ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +**/ + +#include +#include + +/** + Determine if the system power state supports a capsule update. + + @param[out] Good Returns TRUE if system power state supports a capsule + update. Returns FALSE if system power state does not + support a capsule update. Return value is only valid = if + return status is EFI_SUCCESS. + + @retval EFI_SUCCESS Good parameter has been updated with resu= lt. + @retval EFI_INVALID_PARAMETER Good is NULL. + @retval EFI_DEVICE_ERROR System power state can not be determined. + +**/ +EFI_STATUS +EFIAPI +CheckSystemPower ( + OUT BOOLEAN *Good + ) +{ + *Good =3D TRUE; + return EFI_SUCCESS; +} + +/** + Determines if the system thermal state supports a capsule update. + + @param[out] Good Returns TRUE if system thermal state supports a capsul= e + update. Returns FALSE if system thermal state does no= t + support a capsule update. Return value is only valid = if + return status is EFI_SUCCESS. + + @retval EFI_SUCCESS Good parameter has been updated with resu= lt. + @retval EFI_INVALID_PARAMETER Good is NULL. + @retval EFI_DEVICE_ERROR System thermal state can not be determine= d. + +**/ +EFI_STATUS +EFIAPI +CheckSystemThermal ( + IN OUT BOOLEAN *Good + ) +{ + *Good =3D TRUE; + return EFI_SUCCESS; +} + +/** + Determines if the system environment state supports a capsule update. + + @param[out] Good Returns TRUE if system environment state supports a ca= psule + update. Returns FALSE if system environment state doe= s not + support a capsule update. Return value is only valid = if + return status is EFI_SUCCESS. + + @retval EFI_SUCCESS Good parameter has been updated with resu= lt. + @retval EFI_INVALID_PARAMETER Good is NULL. + @retval EFI_DEVICE_ERROR System environment state can not be deter= mined. + +**/ +EFI_STATUS +EFIAPI +CheckSystemEnvironment ( + IN OUT BOOLEAN *Good + ) +{ + *Good =3D TRUE; + return EFI_SUCCESS; +} + +/** + Determines if the Lowest Supported Version checks should be=20 +performed. The + expected result from this function is TRUE. A platform can choose to=20 +return + FALSE (e.g. during manufacturing or servicing) to allow a capsule=20 +update to a + version below the current Lowest Supported Version. + + @retval TRUE Perform Lowest Support Version check. + @retval FALSE Do not perform Lowest Support Version check. + +**/ +BOOLEAN +EFIAPI +CheckLowestSupportedVersion ( + VOID + ) +{ + return TRUE; +} + +/** + Determines if the FMP device should be locked when the event=20 +specified by + PcdFmpDeviceLockEventGuid is signaled. The expected result from this=20 +function + is TRUE so the FMP device is always locked. A platform can choose to=20 +return + FALSE (e.g. during manufacturing) to allow FMP devices to remain unlocke= d. + + @retval TRUE Perform Lowest Support Version check. + @retval FALSE Do not perform Lowest Support Version check. + +**/ +BOOLEAN +EFIAPI +LockFmpDeviceAtLockEventGuid ( + VOID + ) +{ + return TRUE; +} diff --git a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdateP= olicyLibNull.inf b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleU= pdatePolicyLibNull.inf new file mode 100644 index 0000000000..c7c669e3e0 --- /dev/null +++ b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolic +++ yLibNull.inf @@ -0,0 +1,45 @@ +## @file +# Provides platform policy services used during a capsule update. +# +# Copyright (c) 2016, Microsoft Corporation. All rights reserved.
=20 +# Copyright (c) 2018, Intel Corporation. All rights reserved.
# # =20 +Redistribution and use in source and binary forms, with or without # =20 +modification, are permitted provided that the following conditions are met= : +# 1. Redistributions of source code must retain the above copyright=20 +notice, # this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright=20 +notice, # this list of conditions and the following disclaimer in the=20 +documentation # and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 +"AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 +LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A= PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR=20 +ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR=20 +CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF=20 +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR=20 +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # =20 +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING=20 +NEGLIGENCE # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFT= WARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D CapsuleUpdatePolicyLibNull + MODULE_UNI_FILE =3D CapsuleUpdatePolicyLibNull.uni + FILE_GUID =3D 8E36EC87-440D-44F9-AB2F-AA806C61A1A6 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D CapsuleUpdatePolicyLib + +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF ARM AARCH64 +# + +[Sources] + CapsuleUpdatePolicyLibNull.c + +[Packages] + MdePkg/MdePkg.dec + FmpDevicePkg/FmpDevicePkg.dec diff --git a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdateP= olicyLibNull.uni b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleU= pdatePolicyLibNull.uni new file mode 100644 index 0000000000..0f16fea391 --- /dev/null +++ b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolic +++ yLibNull.uni @@ -0,0 +1,17 @@ +// /** @file +// Provides platform policy services used during a capsule update. +// +// Copyright (c) 2018, Intel Corporation. All rights reserved.
//=20 +// This program and the accompanying materials // are licensed and made=20 +available under the terms and conditions of the BSD License // which=20 +accompanies this distribution. The full text of the license may be=20 +found at //=20 +https://na01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fopensou +rce.org%2Flicenses%2Fbsd-license.php&data=3D02%7C01%7Csean.brogan%40micro +soft.com%7Ce9788e2e77ea4e1d928208d5a4a6f285%7C72f988bf86f141af91ab2d7cd +011db47%7C1%7C0%7C636595959307464376&sdata=3DadWebx%2BBv33X%2FOA0RLbPKdAv +Q6b%2FqhTPowHiWHcDOrU%3D&reserved=3D0 +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"=20 +BASIS, // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRES= S OR IMPLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "Provides platform policy= services used during a capsule update." + +#string STR_MODULE_DESCRIPTION #language en-US "Provides platform policy= services used during a capsule update." diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c b/FmpDevi= cePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c new file mode 100644 index 0000000000..03e8750661 --- /dev/null +++ b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c @@ -0,0 +1,427 @@ +/** @file + Provides firmware device specific services to support updates of a=20 +firmware + image stored in a firmware device. + + Copyright (c) 2016, Microsoft Corporation. All rights reserved.
=20 + Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + Redistribution and use in source and binary forms, with or without =20 + modification, are permitted provided that the following conditions are me= t: + 1. Redistributions of source code must retain the above copyright=20 + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright=20 + notice, this list of conditions and the following disclaimer in the=20 + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A = PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR=20 + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR=20 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF=20 + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR=20 + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,=20 + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE =20 + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF= ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +**/ + +#include +#include + +/** + Provide a function to install the Firmware Management Protocol=20 +instance onto a + device handle when the device is managed by a driver that follows the=20 +UEFI + Driver Model. If the device is not managed by a driver that follows=20 +the UEFI + Driver Model, then EFI_UNSUPPORTED is returned. + + @param[in] FmpInstaller Function that installs the Firmware Management + Protocol. + + @retval EFI_SUCCESS The device is managed by a driver that follows = the + UEFI Driver Model. FmpInstaller must be called= on + each Driver Binding Start(). + @retval EFI_UNSUPPORTED The device is not managed by a driver that foll= ows + the UEFI Driver Model. + @retval other The Firmware Management Protocol for this firmw= are + device is not installed. The firmware device i= s + still locked using FmpDeviceLock(). + +**/ +EFI_STATUS +EFIAPI +RegisterFmpInstaller ( + IN FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER Function + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Returns the size, in bytes, of the firmware image currently stored in=20 +the + firmware device. This function is used to by the GetImage() and + GetImageInfo() services of the Firmware Management Protocol. If the=20 +image + size can not be determined from the firmware device, then 0 must be retu= rned. + + @param[out] Size Pointer to the size, in bytes, of the firmware image + currently stored in the firmware device. + + @retval EFI_SUCCESS The size of the firmware image currently + stored in the firmware device was returne= d. + @retval EFI_INVALID_PARAMETER Size is NULL. + @retval EFI_UNSUPPORTED The firmware device does not support repo= rting + the size of the currently stored firmware= image. + @retval EFI_DEVICE_ERROR An error occurred attempting to determine= the + size of the firmware image currently stor= ed in + in the firmware device. + +**/ +EFI_STATUS +EFIAPI +FmpDeviceGetSize ( + IN UINTN *Size + ) +{ + if (Size =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + *Size =3D 0; + return EFI_SUCCESS; +} + +/** + Returns the GUID value used to fill in the ImageTypeId field of the + EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the=20 +GetImageInfo() + service of the Firmware Management Protocol. If EFI_UNSUPPORTED is=20 +returned, + then the ImageTypeId field is set to gEfiCallerIdGuid. If=20 +EFI_SUCCESS is + returned, then ImageTypeId is set to the Guid returned from this functio= n. + + @param[out] Guid Double pointer to a GUID value that is updated to poin= t to + to a GUID value. The GUID value is not allocated and = must + not be modified or freed by the caller. + + @retval EFI_SUCCESS EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID = is set + to the returned Guid value. + @retval EFI_UNSUPPORTED EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID = is set + to gEfiCallerIdGuid. + +**/ +EFI_STATUS +EFIAPI +FmpDeviceGetImageTypeIdGuidPtr ( + OUT EFI_GUID **Guid + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Returns values used to fill in the AttributesSupported and=20 +AttributesSettings + fields of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is=20 +returned by the + GetImageInfo() service of the Firmware Management Protocol. The=20 +following + bit values from the Firmware Management Protocol may be combined: + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE + IMAGE_ATTRIBUTE_RESET_REQUIRED + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED + IMAGE_ATTRIBUTE_IN_USE + IMAGE_ATTRIBUTE_UEFI_IMAGE + + @param[out] Supported Attributes supported by this firmware device. + @param[out] Setting Attributes settings for this firmware device. + + @retval EFI_SUCCESS The attributes supported by the firmware + device were returned. + @retval EFI_INVALID_PARAMETER Supported is NULL. + @retval EFI_INVALID_PARAMETER Setting is NULL. + +**/ +EFI_STATUS +EFIAPI +FmpDeviceGetAttributes ( + IN OUT UINT64 *Supported, + IN OUT UINT64 *Setting + ) +{ + if (Supported =3D=3D NULL || Setting =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + *Supported =3D 0; + *Setting =3D 0; + return EFI_SUCCESS; +} + +/** + Returns the value used to fill in the LowestSupportedVersion field of=20 +the + EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the=20 +GetImageInfo() + service of the Firmware Management Protocol. If EFI_SUCCESS is=20 +returned, then + the firmware device supports a method to report the=20 +LowestSupportedVersion + value from the currently stored firmware image. If the value can not=20 +be + reported for the firmware image currently stored in the firmware=20 +device, then + EFI_UNSUPPORTED must be returned. EFI_DEVICE_ERROR is returned if an=20 +error + occurs attempting to retrieve the LowestSupportedVersion value for=20 +the + currently stored firmware image. + + @note It is recommended that all firmware devices support a method to re= port + the LowestSupportedVersion value from the currently stored firmwar= e + image. + + @param[out] LowestSupportedVersion LowestSupportedVersion value retriev= ed + from the currently stored firmware i= mage. + + @retval EFI_SUCCESS The lowest supported version of currently stor= ed + firmware image was returned in LowestSupported= Version. + @retval EFI_UNSUPPORTED The firmware device does not support a method = to + report the lowest supported version of the cur= rently + stored firmware image. + @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the l= owest + supported version of the currently stored firm= ware + image. + +**/ +EFI_STATUS +EFIAPI +FmpDeviceGetLowestSupportedVersion ( + OUT UINT32 *LowestSupportedVersion + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Returns the Null-terminated Unicode string that is used to fill in=20 +the + VersionName field of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that=20 +is + returned by the GetImageInfo() service of the Firmware Management Protoc= ol. + The returned string must be allocated using EFI_BOOT_SERVICES.AllocatePo= ol(). + + @note It is recommended that all firmware devices support a method to re= port + the VersionName string from the currently stored firmware image. + + @param[out] VersionString The version string retrieved from the current= ly + stored firmware image. + + @retval EFI_SUCCESS The version string of currently stored + firmware image was returned in Version. + @retval EFI_INVALID_PARAMETER VersionString is NULL. + @retval EFI_UNSUPPORTED The firmware device does not support a me= thod + to report the version string of the curre= ntly + stored firmware image. + @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve = the + version string of the currently stored + firmware image. + @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocat= e the + buffer for the version string of the curr= ently + stored firmware image. + +**/ +EFI_STATUS +EFIAPI +FmpDeviceGetVersionString ( + OUT CHAR16 **VersionString + ) +{ + if (VersionString =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + *VersionString =3D NULL; + return EFI_UNSUPPORTED; +} + +/** + Returns the value used to fill in the Version field of the + EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the=20 +GetImageInfo() + service of the Firmware Management Protocol. If EFI_SUCCESS is=20 +returned, then + the firmware device supports a method to report the Version value=20 +from the + currently stored firmware image. If the value can not be reported=20 +for the + firmware image currently stored in the firmware device, then=20 +EFI_UNSUPPORTED + must be returned. EFI_DEVICE_ERROR is returned if an error occurs=20 +attempting + to retrieve the LowestSupportedVersion value for the currently stored=20 +firmware + image. + + @note It is recommended that all firmware devices support a method to re= port + the Version value from the currently stored firmware image. + + @param[out] Version The version value retrieved from the currently stor= ed + firmware image. + + @retval EFI_SUCCESS The version of currently stored firmware image= was + returned in Version. + @retval EFI_UNSUPPORTED The firmware device does not support a method = to + report the version of the currently stored fir= mware + image. + @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the v= ersion + of the currently stored firmware image. + +**/ +EFI_STATUS +EFIAPI +FmpDeviceGetVersion ( + OUT UINT32 *Version + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Returns a copy of the firmware image currently stored in the firmware de= vice. + + @note It is recommended that all firmware devices support a method to re= trieve + a copy currently stored firmware image. This can be used to suppo= rt + features such as recovery and rollback. + + @param[out] Image Pointer to a caller allocated buffer where the + currently stored firmware image is copied to. + @param[in out] ImageSize Pointer the size, in bytes, of the Image buffe= r. + On return, points to the size, in bytes, of fi= rmware + image currently stored in the firmware device. + + @retval EFI_SUCCESS Image contains a copy of the firmware ima= ge + currently stored in the firmware device, = and + ImageSize contains the size, in bytes, of= the + firmware image currently stored in the + firmware device. + @retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too = small + to hold the firmware image currently stor= ed in + the firmware device. The buffer size requ= ired + is returned in ImageSize. + @retval EFI_INVALID_PARAMETER The Image is NULL. + @retval EFI_INVALID_PARAMETER The ImageSize is NULL. + @retval EFI_UNSUPPORTED The operation is not supported. + @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve = the + firmware image currently stored in the fi= rmware + device. + +**/ +EFI_STATUS +EFIAPI +FmpDeviceGetImage ( + IN OUT VOID *Image, + IN IN OUT UINTN *ImageSize + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Checks if a new firmware image is valid for the firmware device. =20 +This + function allows firmware update operation to validate the firmware=20 +image + before FmpDeviceSetImage() is called. + + @param[in] Image Points to a new firmware image. + @param[in] ImageSize Size, in bytes, of a new firmware image. + @param[out] ImageUpdatable Indicates if a new firmware image is valid f= or + a firmware update to the firmware device. T= he + following values from the Firmware Managemen= t + Protocol are supported: + IMAGE_UPDATABLE_VALID + IMAGE_UPDATABLE_INVALID + IMAGE_UPDATABLE_INVALID_TYPE + IMAGE_UPDATABLE_INVALID_OLD + IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE + + @retval EFI_SUCCESS The image was successfully checked. Addi= tional + status information is returned in + ImageUpdateable. + @retval EFI_INVALID_PARAMETER Image is NULL. + @retval EFI_INVALID_PARAMETER ImageUpdateable is NULL. + +**/ +EFI_STATUS +EFIAPI +FmpDeviceCheckImage ( + IN CONST VOID *Image, + IN UINTN ImageSize, + OUT UINT32 *ImageUpdateable + ) +{ + return EFI_SUCCESS; +} + +/** + Updates a firmware device with a new firmware image. This function=20 +returns + EFI_UNSUPPORTED if the firmware image is not updatable. If the=20 +firmware image + is updatable, the function should perform the following minimal=20 +validations + before proceeding to do the firmware image update. + - Validate that the image is a supported image for this firmware devic= e. + Return EFI_ABORTED if the image is not supported. Additional detail= s + on why the image is not a supported image may be returned in AbortRe= ason. + - Validate the data from VendorCode if is not NULL. Firmware image + validation must be performed before VendorCode data validation. + VendorCode data is ignored or considered invalid if image validation + fails. Return EFI_ABORTED if the VendorCode data is invalid. + + VendorCode enables vendor to implement vendor-specific firmware image=20 + update policy. Null if the caller did not specify the policy or use=20 + the default policy. As an example, vendor can implement a policy to=20 + allow an option to force a firmware image update when the abort=20 + reason is due to the new firmware image version is older than the=20 + current firmware image version or bad image checksum. Sensitive=20 + operations such as those wiping the entire firmware image and render=20 + the device to be non-functional should be encoded in the image itself=20 + rather than passed with the VendorCode. AbortReason enables vendor to =20 + have the option to provide a more detailed description of the abort reaso= n to the caller. + + @param[in] Image Points to the new firmware image. + @param[in] ImageSize Size, in bytes, of the new firmware image. + @param[in] VendorCode This enables vendor to implement vendor-sp= ecific + firmware image update policy. NULL indica= tes + the caller did not specify the policy or u= se the + default policy. + @param[in] Progress A function used to report the progress of + updating the firmware device with the new + firmware image. + @param[in] CapsuleFwVersion The version of the new firmware image from= the + update capsule that provided the new firmw= are + image. + @param[out] AbortReason A pointer to a pointer to a Null-terminate= d + Unicode string providing more details on a= n + aborted operation. The buffer is allocated= by + this function with + EFI_BOOT_SERVICES.AllocatePool(). It is t= he + caller's responsibility to free this buffe= r with + EFI_BOOT_SERVICES.FreePool(). + + @retval EFI_SUCCESS The firmware device was successfully upda= ted + with the new firmware image. + @retval EFI_ABORTED The operation is aborted. Additional det= ails + are provided in AbortReason. + @retval EFI_INVALID_PARAMETER The Image was NULL. + @retval EFI_UNSUPPORTED The operation is not supported. + +**/ +EFI_STATUS +EFIAPI +FmpDeviceSetImage ( + IN CONST VOID *Image, + IN UINTN ImageSize, + IN CONST VOID *VendorCode, OP= TIONAL + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OP= TIONAL + IN UINT32 CapsuleFwVersion, + OUT CHAR16 **AbortReason + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Lock the firmware device that contains a firmware image. Once a=20 +firmware + device is locked, any attempts to modify the firmware image contents=20 +in the + firmware device must fail. + + @note It is recommended that all firmware devices support a lock method = to + prevent modifications to a stored firmware image. + + @note A firmware device lock mechanism is typically only cleared by a fu= ll + system reset (not just sleep state/low power mode). + + @retval EFI_SUCCESS The firmware device was locked. + @retval EFI_UNSUPPORTED The firmware device does not support=20 + locking + +**/ +EFI_STATUS +EFIAPI +FmpDeviceLock ( + VOID + ) +{ + return EFI_UNSUPPORTED; +} diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf b/F= mpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf new file mode 100644 index 0000000000..d51f69d0b9 --- /dev/null +++ b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf @@ -0,0 +1,48 @@ +## @file +# Provides firmware device specific services to support updates of a=20 +firmware # image stored in a firmware device. +# +# Copyright (c) 2016, Microsoft Corporation. All rights reserved.
=20 +# Copyright (c) 2018, Intel Corporation. All rights reserved.
# # =20 +Redistribution and use in source and binary forms, with or without # =20 +modification, are permitted provided that the following conditions are met= : +# 1. Redistributions of source code must retain the above copyright=20 +notice, # this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright=20 +notice, # this list of conditions and the following disclaimer in the=20 +documentation # and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 +"AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 +LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A= PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR=20 +ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR=20 +CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF=20 +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR=20 +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # =20 +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING=20 +NEGLIGENCE # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFT= WARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D FmpDeviceLibNull + MODULE_UNI_FILE =3D FmpDeviceLibNull.uni + FILE_GUID =3D 8507642B-AE92-4664-B713-807F7774A96D + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D FmpDeviceLib|DXE_DRIVER + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF ARM AARCH64 +# + +[Sources] + FmpDeviceLib.c + +[Packages] + MdePkg/MdePkg.dec + FmpDevicePkg/FmpDevicePkg.dec diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.uni b/F= mpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.uni new file mode 100644 index 0000000000..bedb38e9cf --- /dev/null +++ b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.uni @@ -0,0 +1,18 @@ +// /** @file +// Provides firmware device specific services to support updates of a=20 +firmware // image stored in a firmware device. +// +// Copyright (c) 2018, Intel Corporation. All rights reserved.
//=20 +// This program and the accompanying materials // are licensed and made=20 +available under the terms and conditions of the BSD License // which=20 +accompanies this distribution. The full text of the license may be=20 +found at //=20 +https://na01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fopensou +rce.org%2Flicenses%2Fbsd-license.php&data=3D02%7C01%7Csean.brogan%40micro +soft.com%7Ce9788e2e77ea4e1d928208d5a4a6f285%7C72f988bf86f141af91ab2d7cd +011db47%7C1%7C0%7C636595959307464376&sdata=3DadWebx%2BBv33X%2FOA0RLbPKdAv +Q6b%2FqhTPowHiWHcDOrU%3D&reserved=3D0 +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"=20 +BASIS, // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRES= S OR IMPLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "Provides firmware device= specific services to support updates of a firmware image stored in a firmw= are device." + +#string STR_MODULE_DESCRIPTION #language en-US "Provides firmware device= specific services to support updates of a firmware image stored in a firmw= are device." diff --git a/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib= .c b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c new file mode 100644 index 0000000000..5f08e8b0fd --- /dev/null +++ b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c @@ -0,0 +1,188 @@ +/** @file + Provides services to retrieve values from Version 1 of a capsule's=20 +FMP Payload + Header. The FMP Payload Header structure is not defined in the library c= lass. + Instead, services are provided to retrieve information from the FMP=20 +Payload + Header. If information is added to the FMP Payload Header, then new=20 +services + may be added to this library class to retrieve the new information. + + Copyright (c) 2016, Microsoft Corporation. All rights reserved.
=20 + Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + Redistribution and use in source and binary forms, with or without =20 + modification, are permitted provided that the following conditions are me= t: + 1. Redistributions of source code must retain the above copyright=20 + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright=20 + notice, this list of conditions and the following disclaimer in the=20 + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A = PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR=20 + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR=20 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF=20 + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR=20 + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,=20 + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE =20 + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF= ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +**/ + +#include +#include + +/// +/// Define FMP Payload Header structure here so it is not public /// + +#pragma pack(1) + +typedef struct { + UINT32 Signature; + UINT32 HeaderSize; + UINT32 FwVersion; + UINT32 LowestSupportedVersion; +} FMP_PAYLOAD_HEADER; + +#pragma pack() + +/// +/// Identifier is used to make sure the data in the header is for this=20 +structure /// and version. If the structure changes update the last digit= . +/// +#define FMP_PAYLOAD_HEADER_SIGNATURE SIGNATURE_32 ('M', 'S', 'S', '1') + +/** + Returns the FMP Payload Header size in bytes. + + @param[in] Header FMP Payload Header to evaluate + @param[in] FmpPayloadSize Size of FMP payload + @param[out] Size The size, in bytes, of the FMP Payload Heade= r. + + @retval EFI_SUCCESS The firmware version was returned. + @retval EFI_INVALID_PARAMETER Header is NULL. + @retval EFI_INVALID_PARAMETER Size is NULL. + @retval EFI_INVALID_PARAMETER Header is not a valid FMP Payload Header. + +**/ +EFI_STATUS +EFIAPI +GetFmpPayloadHeaderSize ( + IN CONST VOID *Header, + IN CONST UINTN FmpPayloadSize, + OUT UINT32 *Size + ) +{ + FMP_PAYLOAD_HEADER *FmpPayloadHeader; + + FmpPayloadHeader =3D NULL; + + if (Header =3D=3D NULL || Size =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + FmpPayloadHeader =3D (FMP_PAYLOAD_HEADER *)Header; if=20 + ((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloa= dHeader || + (UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) >=3D (UINTN)Fm= pPayloadHeader + FmpPayloadSize || + FmpPayloadHeader->HeaderSize < sizeof (FMP_PAYLOAD_HEADER)) { + return EFI_INVALID_PARAMETER; + } + + if (FmpPayloadHeader->Signature !=3D FMP_PAYLOAD_HEADER_SIGNATURE) { + return EFI_INVALID_PARAMETER; + } + + *Size =3D FmpPayloadHeader->HeaderSize; + return EFI_SUCCESS; +} + +/** + Returns the version described in the FMP Payload Header. + + @param[in] Header FMP Payload Header to evaluate + @param[in] FmpPayloadSize Size of FMP payload + @param[out] Version The firmware version described in the FMP Pa= yload + Header. + + @retval EFI_SUCCESS The firmware version was returned. + @retval EFI_INVALID_PARAMETER Header is NULL. + @retval EFI_INVALID_PARAMETER Version is NULL. + @retval EFI_INVALID_PARAMETER Header is not a valid FMP Payload Header. + +**/ +EFI_STATUS +EFIAPI +GetFmpPayloadHeaderVersion ( + IN CONST VOID *Header, + IN CONST UINTN FmpPayloadSize, + OUT UINT32 *Version + ) +{ + FMP_PAYLOAD_HEADER *FmpPayloadHeader; + + FmpPayloadHeader =3D NULL; + + if (Header =3D=3D NULL || Version =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + FmpPayloadHeader =3D (FMP_PAYLOAD_HEADER *)Header; if=20 + ((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloa= dHeader || + (UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) >=3D (UINTN)Fm= pPayloadHeader + FmpPayloadSize || + FmpPayloadHeader->HeaderSize < sizeof (FMP_PAYLOAD_HEADER)) { + return EFI_INVALID_PARAMETER; + } + + if (FmpPayloadHeader->Signature !=3D FMP_PAYLOAD_HEADER_SIGNATURE) { + return EFI_INVALID_PARAMETER; + } + + *Version =3D FmpPayloadHeader->FwVersion; + return EFI_SUCCESS; +} + +/** + Returns the lowest supported version described in the FMP Payload Header= . + + @param[in] Header FMP Payload Header to evaluate + @param[in] FmpPayloadSize Size of FMP payload + @param[out] LowestSupportedVersion The lowest supported version describ= ed in + the FMP Payload Header. + + @retval EFI_SUCCESS The lowest support version was returned. + @retval EFI_INVALID_PARAMETER Header is NULL. + @retval EFI_INVALID_PARAMETER LowestSupportedVersion is NULL. + @retval EFI_INVALID_PARAMETER Header is not a valid FMP Payload Header. + +**/ +EFI_STATUS +EFIAPI +GetFmpPayloadHeaderLowestSupportedVersion ( + IN CONST VOID *Header, + IN CONST UINTN FmpPayloadSize, + IN OUT UINT32 *LowestSupportedVersion + ) +{ + FMP_PAYLOAD_HEADER *FmpPayloadHeader; + + FmpPayloadHeader =3D NULL; + + if (Header =3D=3D NULL || LowestSupportedVersion =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + FmpPayloadHeader =3D (FMP_PAYLOAD_HEADER *)Header; if=20 + ((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloa= dHeader || + (UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) >=3D (UINTN)Fm= pPayloadHeader + FmpPayloadSize || + FmpPayloadHeader->HeaderSize < sizeof (FMP_PAYLOAD_HEADER)) { + return EFI_INVALID_PARAMETER; + } + + if (FmpPayloadHeader->Signature !=3D FMP_PAYLOAD_HEADER_SIGNATURE) { + return EFI_INVALID_PARAMETER; + } + + *LowestSupportedVersion =3D FmpPayloadHeader->LowestSupportedVersion; + return EFI_SUCCESS; +} diff --git a/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib= V1.inf b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.i= nf new file mode 100644 index 0000000000..41ed6e2aca --- /dev/null +++ b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.i +++ nf @@ -0,0 +1,48 @@ +## @file +# Provides services to retrieve values from Version 1 of a capsule's=20 +FMP Payload # Header. The FMP Payload Header structure is not defined in = the library class. +# Instead, services are provided to retrieve information from the FMP=20 +Payload # Header. If information is added to the FMP Payload Header,=20 +then new services # may be added to this library class to retrieve the ne= w information. +# +# Copyright (c) 2016, Microsoft Corporation. All rights reserved.
=20 +# Copyright (c) 2018, Intel Corporation. All rights reserved.
# # =20 +Redistribution and use in source and binary forms, with or without # =20 +modification, are permitted provided that the following conditions are met= : +# 1. Redistributions of source code must retain the above copyright=20 +notice, # this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright=20 +notice, # this list of conditions and the following disclaimer in the=20 +documentation # and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 +"AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 +LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A= PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR=20 +ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR=20 +CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF=20 +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR=20 +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # =20 +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING=20 +NEGLIGENCE # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFT= WARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D FmpPayloadHeaderLibV1 + FILE_GUID =3D 98A79A6C-513C-4E72-8375-39C0A7244C4B + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D FmpPayloadHeaderLib|DXE_DRIVER UEFI_A= PPLICATION + +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF ARM AARCH64 +# + +[Sources] + FmpPayloadHeaderLib.c + +[Packages] + MdePkg/MdePkg.dec + FmpDevicePkg/FmpDevicePkg.dec diff --git a/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib= V1.uni b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.u= ni new file mode 100644 index 0000000000..4eef31753d --- /dev/null +++ b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.u +++ ni @@ -0,0 +1,21 @@ +// /** @file +// Provides services to retrieve values from Version 1 of a capsule's=20 +FMP Payload // Header. The FMP Payload Header structure is not defined in = the library class. +// Instead, services are provided to retrieve information from the FMP=20 +Payload // Header. If information is added to the FMP Payload Header,=20 +then new services // may be added to this library class to retrieve the ne= w information. +// +// Copyright (c) 2018, Intel Corporation. All rights reserved.
//=20 +// This program and the accompanying materials // are licensed and made=20 +available under the terms and conditions of the BSD License // which=20 +accompanies this distribution. The full text of the license may be=20 +found at //=20 +https://na01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fopensou +rce.org%2Flicenses%2Fbsd-license.php&data=3D02%7C01%7Csean.brogan%40micro +soft.com%7Ce9788e2e77ea4e1d928208d5a4a6f285%7C72f988bf86f141af91ab2d7cd +011db47%7C1%7C0%7C636595959307464376&sdata=3DadWebx%2BBv33X%2FOA0RLbPKdAv +Q6b%2FqhTPowHiWHcDOrU%3D&reserved=3D0 +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"=20 +BASIS, // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRES= S OR IMPLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "Provides services to ret= rieve values from Version 1 of a capsule's FMP Payload Header." + +#string STR_MODULE_DESCRIPTION #language en-US "Provides services to ret= rieve values from Version 1 of a capsule's FMP Payload Header." -- 2.14.2.windows.3