From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.23956.1688156518873609997 for ; Fri, 30 Jun 2023 13:21:59 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=NA20yytK; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: isaac.w.oram@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688156518; x=1719692518; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=bO0xaR3zFBuxISEN9rzLSFZsapyiPw3TuzUC4vOsQs4=; b=NA20yytKBU8ltRDB2EpgNpc5r5jziACU4xTiysJS9aNnypEB7u4Wh/oF LxPUYdueoa1OY8q8xxZdDYktPU6hJbQqnZmEJYwSq5YICyP5i6f8cwt6+ s7u9Vl+shEMhIxptSoen6w0reapd/XZVwq82DCuKtubMuZUzuoaZ/t7oB QjYZztNZHwKAime1y8OmYS6GqUk33dyxTvA2cs87RWcWvfrTnIBoiLtdn sqCoOAjOI1t9kh6KQs57Fy8x+PGL0V50ggr9uA1daxe/2WmlGLmuw/i5V I+3qfrb2Lzge2DGl4jpkShpgAeh3KhE69VJqhMRp0cD6oaPcsR+ERpQnd w==; X-IronPort-AV: E=McAfee;i="6600,9927,10757"; a="342070537" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="342070537" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2023 13:21:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10757"; a="1048357350" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="1048357350" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga005.fm.intel.com with ESMTP; 30 Jun 2023 13:21:53 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 30 Jun 2023 13:21:53 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 30 Jun 2023 13:21:52 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Fri, 30 Jun 2023 13:21:52 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.105) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Fri, 30 Jun 2023 13:21:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U5p17jLWqygp3T/I6Db78VfF2DjmeBgB2DVzWNYrcpkSuf7foCHT5Lk1H9aTrLNJ4mfSkpO11oAyQKtscd92EmXAgJJnYFJTejpWMlo8AUhICAGBEm2lt8OJi7H8xEoEov+j2XAfs/rnIKIOR4s5OGghbEFPNqXbUASsYN4i6XAEwizoYnz+PNyp0/1UMyL1qdReQjDFNni97F/B4/SPH8gtQDux7ayF+IE1SHOS6kFkgAVaOTaLTeCT61Px9UhWk1DKXGkqZriuqUxSR17PHrml4tJfal1TV3/LaFo31GLssHK1brr8qeDM6jHXnRWVzi/UxWf7V9CRzoONskXuXw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Mw5Ese654TJo57vBTkS5S9GPnGAuzpbZq793SQJRuUU=; b=A6YleyAR2jRzEbgMPruORgpOJ1GLcphSa2cFOQuaTM0cnh+OXMbXiLeNsCntrTBuEwOIh15CIziO1Kk3u3YdfC6kbtmYo+NHbqaTeDDajwsxuloxkwCQvd6UfHyMF5cO6WW4DSC9vtSZM7Qa7HL2VNLT66vYNkTfq2JVmPAna9VVUs3EGeqkTAUNltcDPa6Po+EZIEgkDaTBAIPJpFsfov0QLMTObpLbaGLQiEwRgEpEke/yKkJMxvCPNVmC8RatW4ZC7SfS1MZBywr40UAvIeb9AjvtunXFzRBt2EMwxGz3p7dgEN20O1NqcxnN6pECq1jyrB4DDqUy/yeQFrVc5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SA1PR11MB5801.namprd11.prod.outlook.com (2603:10b6:806:23d::13) by MW5PR11MB5810.namprd11.prod.outlook.com (2603:10b6:303:192::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Fri, 30 Jun 2023 20:21:49 +0000 Received: from SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::ba9b:b98b:c9f2:b32]) by SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::ba9b:b98b:c9f2:b32%6]) with mapi id 15.20.6544.019; Fri, 30 Jun 2023 20:21:48 +0000 From: "Isaac Oram" To: "S, Ashraf Ali" , "devel@edk2.groups.io" , "mikuback@linux.microsoft.com" CC: "Ni, Ray" , "Chaganty, Rangasai V" Subject: Re: [edk2-devel] [edk2-platforms][PATCH v1 1/1] IntelSiliconPkg/SpiFvbService: Non-functional cleanup Thread-Topic: [edk2-devel] [edk2-platforms][PATCH v1 1/1] IntelSiliconPkg/SpiFvbService: Non-functional cleanup Thread-Index: AQHZqvs6XP8kbQgFT06EXt+XAn/a7a+js1mAgAATiVA= Date: Fri, 30 Jun 2023 20:21:48 +0000 Message-ID: References: <20230630023236.746-1-mikuback@linux.microsoft.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA1PR11MB5801:EE_|MW5PR11MB5810:EE_ x-ms-office365-filtering-correlation-id: 70083407-d50c-4461-5126-08db79a7a210 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 3RQ3BC4ir+kv3bwJCIFJZIPoWmJCcVLGwVj4bqNzhoX2EP2xaWBIgJjxK1BPF4yoY+ad4ln2i/Ml1JrsXRhC5iIB6r34L1Nqs6EdxDnn33AJXZyC0GyNlPtnfTZPLWCREnWPLxDOSA/e6NW3ahEHu06DmVnMYLWghrEcoh8RcPuM/zhv37FO3y4eZgiHxc3HDcHHszdm4LbNYh4BVA26D+euwPwygbKKRjp+Qr9uj4e5XKHW8AxHAkkVKl32T8WOKxFDwEeQk8fo3D3Bm5XD+fFpS6a3vl7VsJxS31EBYx0vmoVRKXnOCAekJaPrg3X7c4J7ehvNzEb59nz7FYQhm3Mawt4L+KSfAFvDo5dnRj8aZ3R8k53NCCCsthQ9yv9bBQ/m7RMshsWsINpejo/X4ZDXPmphvXFzRD0Emirf2qvCS5jMgbocm6XUJFc+wAnWUqpNzvNyEFWUsAwmsZ6T6974nLMX+H56TrFrZFA67sbzqUXeoUYb050sgQu3hlqXbou8YGKABA7Rc0L02IXMUX/w+Z+B8kjwMhU0OB6urAeajKehOvOweAKIGp7scIMbVxa0fR/qinI/9sgRsxL1+4BHlWfV8skTnhMMY2ZA7b4pYN8Ts0EnQAQH+LJ8OSB4J8UuTJFBoj4DWZdM2dypEg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR11MB5801.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(136003)(346002)(39860400002)(366004)(396003)(451199021)(53546011)(186003)(41300700001)(107886003)(9686003)(966005)(54906003)(83380400001)(478600001)(110136005)(71200400001)(6506007)(7696005)(45080400002)(2906002)(26005)(30864003)(66556008)(52536014)(66476007)(55016003)(76116006)(82960400001)(38100700002)(122000001)(316002)(5660300002)(8936002)(64756008)(66946007)(33656002)(38070700005)(4326008)(66446008)(86362001)(8676002)(66899021)(579004)(559001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?pcsJh270h17SLwQ8gYKOaa1XbTb07ZEqOIDxNsVYGNxa+CQlyVglm60oUOCh?= =?us-ascii?Q?lhi6dqO5Y0T/onyU5wHKUkLJtL27FMQ+c5e+CWoX/eTkgGyNpCAIetCV70Ic?= =?us-ascii?Q?S9OgEFiUMqBS1Bfzq7ZUdqWKKsddVBlVgs1ERzJysvbEZ8s2jnbmLR+h1FFR?= =?us-ascii?Q?HxMm4wlOuEoqmrqxjCjQRO0JBqQ8O4dKGThmfIxGyi0BdxRWGerlVoVUB/qy?= =?us-ascii?Q?Z2um6k6tq9W6mhNOQ9waq5EyDu9K1Udxrw2Nqnycr7ev1du0iHbj88+HDl1z?= =?us-ascii?Q?JpeuTo4rtwdIvbgM67cZryyV3n7ehKO3gpUdaJavTy6PSQoKX4R2Zmy4/IwW?= =?us-ascii?Q?p+Q+PiRoHHiqscvZ0qZ0eVpxilQ7W53iHJjtwyKo2dPKwGs7Il7LbqE1Its6?= =?us-ascii?Q?dv0Rijjd0wKv4RvhX+yy52RFNmnDPLyOE28OKsvD9b5hseO6Ztz0GbepT13F?= =?us-ascii?Q?FvP3Xh/xu/cnbhWyWiLGHeQs9p7fqJK+cfyDWaQgCmchaCBG+ie/weZWxtYp?= =?us-ascii?Q?vREs000LkFEPuGp7dTR095loUtBaGM0xRDsyUx9f8uOV747CTkEMGossebTl?= =?us-ascii?Q?jvsrYZ23hEC0i4hPVaVtV0bU/k6yQr5kJj65fZ9+RNF71vjucG1W8AwwFUaq?= =?us-ascii?Q?4dsCtkY96AhmbOZHS4egjOtyigcFrbUYYLc1wIP6p8i25KlQBV3QbtobSD/U?= =?us-ascii?Q?GC0Vvc5ORFrvbhhcTJ2628LI0LU8VpXZbTTWdJzN0MjIZq3IGPKPTm7MpBem?= =?us-ascii?Q?CA/qzxjdSk4Fde9XQHevjUALs8yxQ+mNExS7Iw6Dw5vnGEvKR78PR8UnBo+c?= =?us-ascii?Q?AwrMX1O4aIfaKRXwozzlk2gToP+oNPB/suZJ7kNCkkFw4OIAFe2sgbNxmMqt?= =?us-ascii?Q?zb/+L6fowTPqWkbwioBK88ecNh5w8tbVQVY3t7YqgvThOndoZ+QOOuf/qI95?= =?us-ascii?Q?gDswfPrWjHsou0/Fi8PIeTle0T4XIeNmhLC58HkXPkNSz18cSAFaXnY418m7?= =?us-ascii?Q?Xs+mK5Hn85EEQpfWWJ/BoRDOEOGfxVGD1SvhQu16gi8mE3DjOyePcebbvVKj?= =?us-ascii?Q?/pI/W05ajI4gwSvmFB7biEkjUoBb1MUmHPvxoybJJGSQ8TjavOZ4VqLCC00T?= =?us-ascii?Q?a+63RflyqFSTasEU9G1Qo2s9LO1NemOgwAOK+slZd3EfinDWsvbLOyQ0GvlH?= =?us-ascii?Q?6GQPROvCYTPWtwWT1dy4gneSqkevS0C0VTuu0zoEYTrTNvFCMr+qzCyTmfKd?= =?us-ascii?Q?IEMSRbwd3XTQXKJieV2aXpecRuMss+ACWud3OXGMGFZAPnHf61uEDVf+bgpM?= =?us-ascii?Q?u8E56xN3IRyG34WF617lzUfi91stslNlTRY7iAcIuF2bsX/HkV/dBtoWrpXe?= =?us-ascii?Q?+2ee7HDemX/Wamh4VpIiDNZp7oYRIuiUrsUdNgghE1j8FMk4qucKZmif+JZS?= =?us-ascii?Q?g7ltfYU5Bu9sZdq/z2nnJzE9/fe8T/FddLHoNBE0IZT2ttz77gBBMW86ic1U?= =?us-ascii?Q?Wu2rYj4r8rvq/X9SXW47jDBH5A1p8e2EuwoQBQbvn3Sw1tdu5Hh6YqyB07Vq?= =?us-ascii?Q?luLG3+PQwb8im6WGY9YK+fBxWt4BbF3T/Ge/vSCU?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA1PR11MB5801.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70083407-d50c-4461-5126-08db79a7a210 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jun 2023 20:21:48.8419 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: YAPsZmBW1RggW/dBBKNo2F4mIfY0ZuIMW8khLb3BaWvrn+PQqJ3jJLU3wbX/wQI+O0BYsupgeWXk45Zq9igqSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR11MB5810 Return-Path: isaac.w.oram@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Isaac Oram Mixing DEBUG_WARN | DEBUG_ERROR confuses me a bit. I would prefer simpler = definitions were errors are "something is wrong" and warnings are "somethin= g might be wrong". But it is a pretty minor nit and cleanup is good, so don't worry about chan= ging it. Regards, Isaac -----Original Message----- From: S, Ashraf Ali =20 Sent: Friday, June 30, 2023 11:57 AM To: devel@edk2.groups.io; mikuback@linux.microsoft.com Cc: Ni, Ray ; Chaganty, Rangasai V ; Oram, Isaac W Subject: RE: [edk2-devel] [edk2-platforms][PATCH v1 1/1] IntelSiliconPkg/Sp= iFvbService: Non-functional cleanup Reviewed-by: Ashraf Ali S -----Original Message----- From: devel@edk2.groups.io On Behalf Of Michael Kuba= cki Sent: Friday, June 30, 2023 8:03 AM To: devel@edk2.groups.io Cc: Ni, Ray ; Chaganty, Rangasai V ; Oram, Isaac W ; S, Ashraf Ali Subject: [edk2-devel] [edk2-platforms][PATCH v1 1/1] IntelSiliconPkg/SpiFvb= Service: Non-functional cleanup From: Michael Kubacki During a review of this driver a number of improvements were noted such as = strengthening function input validation, checking return values, making deb= ug print error levels consistent in certain code blocks, etc. These type of changes are made with no explicit change to driver functional= ity. Cc: Ray Ni Cc: Rangasai V Chaganty Cc: Isaac Oram Cc: Ashraf Ali S Signed-off-by: Michael Kubacki --- Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/FvbInfo.c = | 35 ++- Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServiceCom= mon.c | 248 ++++++++++++-------- Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServiceMm.= c | 54 +++-- Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServiceCom= mon.h | 31 ++- Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServiceMm.= h | 6 +- 5 files changed, 239 insertions(+), 135 deletions(-) diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/FvbI= nfo.c b/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/FvbInfo.c index ab1cb2ef1622..ebbd9edaada3 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/FvbInfo.c +++ b/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/FvbInfo. +++ c @@ -2,16 +2,17 @@ Defines data structure that is the volume header found. These data is intent to decouple FVB driver with FV header. =20 -Copyright (c) 2017, Intel Corporation. All rights reserved.
-Copyright= (c) Microsoft Corporation.
-SPDX-License-Identifier: BSD-2-Clause-Patent + Copyright (c) 2017, Intel Corporation. All rights reserved.
=20 + Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 #include "SpiFvbServiceCommon.h" =20 -#define FIRMWARE_BLOCK_SIZE 0x10000 +#define FIRMWARE_BLOCK_SIZE SIZE_64KB #define FVB_MEDIA_BLOCK_SIZE FIRMWARE_BLOCK_SIZE + typedef struct { EFI_PHYSICAL_ADDRESS BaseAddress; EFI_FIRMWARE_VOLUME_HEADER FvbInfo; @@ -19,7 +20,7 @@ typedef struct { } EFI_FVB2_MEDIA_INFO; =20 /** - Returns FVB media information for NV variable storage. + Returns FVB media information for a firmware volume. =20 @return FvbMediaInfo A pointer to an instance of FVB medi= a info produced by this function. The buffer is allocated internally t= o this function and it is the caller's @@ -100,8 +101,21 @@ FVB_MEDIA_INFO_= GENERATOR mFvbMediaInfoGenerators[] =3D { GenerateNvStorageFvbMediaInfo }; =20 +/** + Returns an empty firmware volume for the firmware volume at the given ba= se address. + + @param[in] FvBaseAddress The base address of the firmware volum= e requested. + @param[out] FvbInfo A pointer that will be set to a buffer= for the firmware volume header + at the given base address. The buffer = is a pool allocation made in this function. + + @retval EFI_SUCCESS The firmware volume was returned succe= ssfully. + @retval EFI_INVALID_PARAMETER The FvbInfo pointer argument is NULL. + @retval EFI_NOT_FOUND The firmware volume was not found for = the given base address. + @retval EFI_OUT_OF_RESOURCES Insufficient memory to allocate a buff= er to the hold the firmware volume. + +**/ EFI_STATUS -GetFvbInfo ( +GetGeneratedFvByAddress ( IN EFI_PHYSICAL_ADDRESS FvBaseAddress, OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo ) @@ -111,11 +125,19 @@ GetFvbInfo ( UINTN Index; EFI_FIRMWARE_VOLUME_HEADER *FvHeader; =20 + if (FvbInfo =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + for (Index =3D 0; Index < ARRAY_SIZE (mFvbMediaInfoGenerators); Index++)= { Status =3D mFvbMediaInfoGenerators[Index](&FvbMediaInfo); ASSERT_EFI_ERROR (Status); if (!EFI_ERROR (Status) && (FvbMediaInfo.BaseAddress =3D=3D FvBaseAddr= ess)) { FvHeader =3D AllocateCopyPool (FvbMediaInfo.FvbInfo.HeaderLength, &F= vbMediaInfo.FvbInfo); + if (FvHeader =3D=3D NULL) { + ASSERT (FvHeader !=3D NULL); + return EFI_OUT_OF_RESOURCES; + } =20 // // Update the checksum value of FV header. @@ -136,5 +158,6 @@ GetFvbInfo ( return EFI_SUCCESS; } } + return EFI_NOT_FOUND; } diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiF= vbServiceCommon.c b/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbServi= ce/SpiFvbServiceCommon.c index fcdc715263f2..e21113682f4f 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServi= ceCommon.c +++ b/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbSe +++ rviceCommon.c @@ -2,9 +2,9 @@ Common driver source for several Serial Flash devices which are compliant with the Intel(R) Serial Flash Interface Compatibili= ty Specification. =20 -Copyright (c) 2017, Intel Corporation. All rights reserved.
-Copyright= (c) Microsoft Corporation.
-SPDX-License-Identifier: BSD-2-Clause-Patent + Copyright (c) 2017, Intel Corporation. All rights reserved.
=20 + Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 @@ -92,13 +92,19 @@ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL mFvbProtocolTemplate= =3D { @param[in] FvbInstance The pointer to the EFI_FVB_INSTANCE. =20 @return Attributes of the FV identified by FvbInstance. + Zero is returned if the FvbInstance pointer is NULL. =20 **/ EFI_FVB_ATTRIBUTES_2 FvbGetVolumeAttributes ( - IN EFI_FVB_INSTANCE *FvbInstance + IN CONST EFI_FVB_INSTANCE *FvbInstance ) { + if (FvbInstance =3D=3D NULL) { + ASSERT (FvbInstance !=3D NULL); + return 0; + } + return FvbInstance->FvHeader.Attributes; } =20 @@ -109,24 +115,25 @@ FvbGetVolumeAttributes ( @param[in] FvbInstance The pointer to the EFI_FVB_INSTANCE. @param[in] Lba The logical block address @param[out] LbaAddress On output, contains the physical starting ad= dress - of the Lba - @param[out] LbaLength On output, contains the length of the block + of the Lba. This pointer is optional and may= be NULL. + @param[out] LbaLength On output, contains the length of the block. + This pointer is optional and may be NULL. @param[out] NumOfBlocks A pointer to a caller allocated UINTN in whi= ch the number of consecutive blocks starting with L= ba is returned. All blocks in this range have a si= ze of - BlockSize + BlockSize. This pointer is optional and may = be NULL. =20 - @retval EFI_SUCCESS Successfully returns - @retval EFI_INVALID_PARAMETER Instance not found + @retval EFI_SUCCESS Successfully returns + @retval EFI_INVALID_PARAMETER FvbInstance is NULL. =20 **/ EFI_STATUS FvbGetLbaAddress ( - IN EFI_FVB_INSTANCE *FvbInstance, + IN CONST EFI_FVB_INSTANCE *FvbInstance, IN EFI_LBA Lba, - OUT UINTN *LbaAddress, - OUT UINTN *LbaLength, - OUT UINTN *NumOfBlocks + OUT UINTN *LbaAddress OPTIONAL, + OUT UINTN *LbaLength OPTIONAL, + OUT UINTN *NumOfBlocks OPTIONAL ) { UINT32 NumBlocks; @@ -134,10 +141,15 @@ FvbGetLbaAddress ( UINTN Offset; EFI_LBA StartLba; EFI_LBA NextLba; - EFI_FV_BLOCK_MAP_ENTRY *BlockMap; + CONST EFI_FV_BLOCK_MAP_ENTRY *BlockMap; =20 StartLba =3D 0; Offset =3D 0; + + if (FvbInstance =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + BlockMap =3D &(FvbInstance->FvHeader.BlockMap[0]); =20 // @@ -158,15 +170,15 @@ FvbGetLbaAddress ( // if (Lba >=3D StartLba && Lba < NextLba) { Offset =3D Offset + (UINTN)MultU64x32((Lba - StartLba), BlockLength)= ; - if (LbaAddress ) { + if (LbaAddress !=3D NULL) { *LbaAddress =3D FvbInstance->FvBase + Offset; } =20 - if (LbaLength ) { + if (LbaLength !=3D NULL) { *LbaLength =3D BlockLength; } =20 - if (NumOfBlocks ) { + if (NumOfBlocks !=3D NULL) { *NumOfBlocks =3D (UINTN)(NextLba - Lba); } return EFI_SUCCESS; @@ -190,7 +202,6 @@ FvbGetLbaAddress ( @param[in] Buffer Pointer to a caller allocated buff= er that will be used to hold the data read =20 - @retval EFI_SUCCESS The firmware volume was read succe= ssfully and contents are in Buffer @retval EFI_BAD_BUFFER_SIZE Read attempted across a LBA bounda= ry. On output, @@ -199,16 +210,16 @@ FvbGetLbaAddress ( @retval EFI_ACCESS_DENIED The firmware volume is in the Read= Disabled state @retval EFI_DEVICE_ERROR The block device is not functionin= g correctly and could not be read - @retval EFI_INVALID_PARAMETER Instance not found, or NumBytes, B= uffer are NULL + @retval EFI_INVALID_PARAMETER FvbInstance, NumBytes, and/or Buff= er are NULL =20 **/ EFI_STATUS FvbReadBlock ( - IN EFI_FVB_INSTANCE *FvbInstance, - IN EFI_LBA Lba, - IN UINTN BlockOffset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer + IN CONST EFI_FVB_INSTANCE *FvbInstance, + IN EFI_LBA Lba, + IN UINTN BlockOffset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer ) { EFI_FVB_ATTRIBUTES_2 Attributes; @@ -217,9 +228,10 @@ FvbReadBlock ( EFI_STATUS Status; BOOLEAN BadBufferSize =3D FALSE; =20 - if ((NumBytes =3D=3D NULL) || (Buffer =3D=3D NULL)) { + if ((FvbInstance =3D=3D NULL) || (NumBytes =3D=3D NULL) || (Buffer =3D= =3D NULL))=20 + { return EFI_INVALID_PARAMETER; } + if (*NumBytes =3D=3D 0) { return EFI_INVALID_PARAMETER; } @@ -269,6 +281,7 @@ FvbReadBlock ( of bytes actually written @param[in] Buffer Pointer to a caller allocated buffer t= hat contains the source for the write + @retval EFI_SUCCESS The firmware volume was written succes= sfully @retval EFI_BAD_BUFFER_SIZE Write attempted across a LBA boundary.= On output, NumBytes contains the total number of = bytes @@ -276,16 +289,16 @@ FvbReadBlock ( @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDis= abled state @retval EFI_DEVICE_ERROR The block device is not functioning co= rrectly and could not be written - @retval EFI_INVALID_PARAMETER Instance not found, or NumBytes, Buffe= r are NULL + @retval EFI_INVALID_PARAMETER FvbInstance, NumBytes, and/or Buffer a= re NULL =20 **/ EFI_STATUS FvbWriteBlock ( - IN EFI_FVB_INSTANCE *FvbInstance, - IN EFI_LBA Lba, - IN UINTN BlockOffset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer + IN CONST EFI_FVB_INSTANCE *FvbInstance, + IN EFI_LBA Lba, + IN UINTN BlockOffset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer ) { EFI_FVB_ATTRIBUTES_2 Attributes; @@ -294,7 +307,7 @@ FvbWriteBlock ( EFI_STATUS Status; BOOLEAN BadBufferSize =3D FALSE; =20 - if ((NumBytes =3D=3D NULL) || (Buffer =3D=3D NULL)) { + if ((FvbInstance =3D=3D NULL) || (NumBytes =3D=3D NULL) || (Buffer =3D= =3D NULL))=20 + { return EFI_INVALID_PARAMETER; } if (*NumBytes =3D=3D 0) { @@ -350,8 +363,6 @@ FvbWriteBlock ( } } =20 - - /** Erases and initializes a firmware volume block. =20 @@ -363,13 +374,13 @@ FvbWriteBlock ( @retval EFI_DEVICE_ERROR The block device is not functioning corr= ectly and could not be written. Firmware device ma= y have been partially erased - @retval EFI_INVALID_PARAMETER Instance not found + @retval EFI_INVALID_PARAMETER FvbInstance is NULL =20 **/ EFI_STATUS FvbEraseBlock ( - IN EFI_FVB_INSTANCE *FvbInstance, - IN EFI_LBA Lba + IN CONST EFI_FVB_INSTANCE *FvbInstance, + IN EFI_LBA Lba ) { =20 @@ -378,6 +389,10 @@ FvbEraseBlock ( UINTN LbaLength; EFI_STATUS Status; =20 + if (FvbInstance =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + // // Check if the FV is write enabled // @@ -422,9 +437,9 @@ FvbEraseBlock ( =20 @retval EFI_SUCCESS Successfully returns @retval EFI_ACCESS_DENIED The volume setting is locked and canno= t be modified - @retval EFI_INVALID_PARAMETER Instance not found, or The attributes = requested are - in conflict with the capabilities as d= eclared in the - firmware volume header + @retval EFI_INVALID_PARAMETER FvbInstance or Attributes is NULL. + Or the attributes requested are in con= flict with the + capabilities as declared in the firmwa= re volume header. =20 **/ EFI_STATUS @@ -439,6 +454,10 @@ FvbSetVolumeAttributes ( UINT32 Capabilities; UINT32 OldStatus, NewStatus; =20 + if ((FvbInstance =3D=3D NULL) || (Attributes =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + AttribPtr =3D (EFI_FVB_ATTRIBUTES_2 *) &(FvbInstance->FvHeader.Attri= butes); OldAttributes =3D *AttribPtr; Capabilities =3D OldAttributes & EFI_FVB2_CAPABILITIES; @@ -554,6 +573,= 7 @@ GetVariableFvInfo ( ASSERT ((BaseAddress !=3D NULL) && (Length !=3D NULL)); return; } + *BaseAddress =3D 0; *Length =3D 0; =20 @@ -631,8 +651,9 @@ GetVariableFvInfo ( =20 @param[in] FvHeader A pointer to a firmware volume header =20 - @retval TRUE The firmware volume is consistent - @retval FALSE The firmware volume has corrupted. + @retval TRUE The firmware volume is consistent. + @retval FALSE The firmware volume has corrupted or an invali= d firmware + volume was provided. =20 **/ BOOLEAN @@ -644,6 +665,11 @@ IsFvHeaderValid ( EFI_PHYSICAL_ADDRESS NvStorageFvBaseAddress; UINT32 NvStorageSize; =20 + if (FvHeader =3D=3D NULL) { + ASSERT (FvHeader !=3D NULL); + return FALSE; + } + GetVariableFvInfo (&NvStorageFvBaseAddress, &NvStorageSize); =20 if (FvBase =3D=3D NvStorageFvBaseAddress) { @@ -679,18 +705,23 @@ IsFvHe= aderValid ( @param[in] This A pointer to EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL. @param[out] Address Output buffer containing the address. =20 - retval EFI_SUCCESS The function always return successfully. + @retval EFI_SUCCESS The function always return successfull= y. + @retval EFI_INVALID_PARAMETER A pointer argument provided is NULL. =20 **/ EFI_STATUS EFIAPI FvbProtocolGetPhysicalAddress ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_PHYSICAL_ADDRESS *Address + IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + OUT EFI_PHYSICAL_ADDRESS *Address ) { EFI_FVB_INSTANCE *FvbInstance; =20 + if ((This =3D=3D NULL) || (Address =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + FvbInstance =3D FVB_INSTANCE_FROM_THIS (This); =20 *Address =3D FvbInstance->FvBase; @@ -710,28 +741,34 @@ FvbProtocolGetPhysicalAddress ( returned. All blocks in this range have a size o= f BlockSize =20 - @retval EFI_SUCCESS The function always return successfully. + @retval EFI_SUCCESS The function always return successfu= lly. + @retval EFI_INVALID_PARAMETER A pointer argument provided is NULL. =20 **/ EFI_STATUS EFIAPI FvbProtocolGetBlockSize ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN EFI_LBA Lba, - OUT UINTN *BlockSize, - OUT UINTN *NumOfBlocks + IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + IN EFI_LBA Lba, + OUT UINTN *BlockSize, + OUT UINTN *NumOfBlocks ) { EFI_FVB_INSTANCE *FvbInstance; =20 + if ((This =3D=3D NULL) || (BlockSize =3D=3D NULL) || (NumOfBlocks =3D=3D= NULL)) { + return EFI_INVALID_PARAMETER; + } + FvbInstance =3D FVB_INSTANCE_FROM_THIS (This); =20 - DEBUG((DEBUG_INFO, + DEBUG (( + DEBUG_INFO, "FvbProtocolGetBlockSize: Lba: 0x%lx BlockSize: 0x%x NumOfBlocks: 0x%x= \n", Lba, - BlockSize, - NumOfBlocks) - ); + *BlockSize, + *NumOfBlocks + )); =20 return FvbGetLbaAddress ( FvbInstance, @@ -748,27 +785,33 @@ FvbProtocolGetBlockSize ( @param[in] This Calling context @param[out] Attributes Output buffer which contains attributes =20 - @retval EFI_SUCCESS The function always return successfully. + @retval EFI_SUCCESS The function always return success= fully. + @retval EFI_INVALID_PARAMETER A pointer argument provided is NUL= L. =20 **/ EFI_STATUS EFIAPI FvbProtocolGetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_FVB_ATTRIBUTES_2 *Attributes + IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + OUT EFI_FVB_ATTRIBUTES_2 *Attributes ) { EFI_FVB_INSTANCE *FvbInstance; =20 + if ((This =3D=3D NULL) || (Attributes =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + FvbInstance =3D FVB_INSTANCE_FROM_THIS (This); =20 *Attributes =3D FvbGetVolumeAttributes (FvbInstance); =20 - DEBUG ((DEBUG_INFO, + DEBUG (( + DEBUG_INFO, "FvbProtocolGetAttributes: This: 0x%x Attributes: 0x%x\n", This, - *Attributes) - ); + *Attributes + )); =20 return EFI_SUCCESS; } @@ -785,28 +828,34 @@ FvbProtocolGetAttributes ( EFI_STATUS EFIAPI FvbPr= otocolSetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes + IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes ) { EFI_STATUS Status; EFI_FVB_INSTANCE *FvbInstance; =20 - DEBUG((DEBUG_INFO, + if ((This =3D=3D NULL) || (Attributes =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + DEBUG (( + DEBUG_INFO, "FvbProtocolSetAttributes: Before SET - This: 0x%x Attributes: 0x%x\n= ", This, - *Attributes) - ); + *Attributes + )); =20 FvbInstance =3D FVB_INSTANCE_FROM_THIS (This); =20 Status =3D FvbSetVolumeAttributes (FvbInstance, Attributes); =20 - DEBUG((DEBUG_INFO, + DEBUG (( + DEBUG_INFO, "FvbProtocolSetAttributes: After SET - This: 0x%x Attributes: 0x%x\n"= , This, - *Attributes) - ); + *Attributes + )); =20 return Status; } @@ -823,17 +872,18 @@ FvbProtocolSetAttributes ( @param[in] ... Starting LBA followed by Number of Lba to erase. a -1 to terminate the list. =20 - @retval EFI_SUCCESS The erase request was successfully completed - @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled st= ate - @retval EFI_DEVICE_ERROR The block device is not functioning correctly = and - could not be written. Firmware device may have= been - partially erased + @retval EFI_SUCCESS The erase request was successfully compl= eted + @retval EFI_INVALID_PARAMETER A pointer argument provided is NULL. + @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisab= led state + @retval EFI_DEVICE_ERROR The block device is not functioning corr= ectly and + could not be written. Firmware device ma= y have been + partially erased =20 **/ EFI_STATUS EFIAPI FvbProtocolEraseBlocks ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, ... ) { @@ -846,6 +896,10 @@ FvbProtocolEraseBlocks ( =20 DEBUG((DEBUG_INFO, "FvbProtocolEraseBlocks: \n")); =20 + if (This =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + FvbInstance =3D FVB_INSTANCE_FROM_THIS (This); =20 NumOfBlocks =3D FvbInstance->NumOfBlocks; @@ -923,30 +977,35 @@ FvbProto= colEraseBlocks ( @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisable= d state @retval EFI_DEVICE_ERROR The block device is not functioning correc= tly and could not be written - @retval EFI_INVALID_PARAMETER NumBytes or Buffer are NULL + @retval EFI_INVALID_PARAMETER A pointer argument provided is NULL. =20 **/ EFI_STATUS EFIAPI FvbProtocolWrite ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer + IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer ) { EFI_FVB_INSTANCE *FvbInstance; =20 + if ((This =3D=3D NULL) || (NumBytes =3D=3D NULL) || (Buffer =3D=3D NULL)= ) { + return EFI_INVALID_PARAMETER; + } + FvbInstance =3D FVB_INSTANCE_FROM_THIS (This); =20 - DEBUG((DEBUG_INFO, + DEBUG (( + DEBUG_INFO, "FvbProtocolWrite: Lba: 0x%lx Offset: 0x%x NumBytes: 0x%x, Buffer: 0x%= x\n", Lba, Offset, *NumBytes, - Buffer) - ); + Buffer + )); =20 return FvbWriteBlock (FvbInstance, Lba, Offset, NumBytes, Buffer); } @@= -974,31 +1033,36 @@ FvbProtocolWrite ( @retval EFI_ACCESS_DENIED The firmware volume is in the ReadDisabled= state @retval EFI_DEVICE_ERROR The block device is not functioning correc= tly and could not be read - @retval EFI_INVALID_PARAMETER NumBytes or Buffer are NULL + @retval EFI_INVALID_PARAMETER A pointer argument provided is NULL. =20 **/ EFI_STATUS EFIAPI FvbProtocolRead ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN OUT UINTN *NumBytes, - OUT UINT8 *Buffer + IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + OUT UINT8 *Buffer ) { EFI_FVB_INSTANCE *FvbInstance; EFI_STATUS Status; =20 + if ((This =3D=3D NULL) || (NumBytes =3D=3D NULL) || (Buffer =3D=3D NULL)= ) { + return EFI_INVALID_PARAMETER; + } + FvbInstance =3D FVB_INSTANCE_FROM_THIS (This); Status =3D FvbReadBlock (FvbInstance, Lba, Offset, NumBytes, Buffer); - DEBUG((DEBUG_INFO, + DEBUG (( + DEBUG_INFO, "FvbProtocolRead: Lba: 0x%lx Offset: 0x%x NumBytes: 0x%x, Buffer: 0x%x= \n", Lba, Offset, *NumBytes, - Buffer) - ); + Buffer + )); =20 return Status; } diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiF= vbServiceMm.c b/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/S= piFvbServiceMm.c index f9543c5ba677..5d7591480319 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServi= ceMm.c +++ b/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbSe +++ rviceMm.c @@ -15,14 +15,11 @@ #include =20 /** - The function installs EFI_FIRMWARE_VOLUME_BLOCK protocol - for each FV in the system. + The function installs the given EFI_FIRMWARE_VOLUME_BLOCK protocol insta= nce. =20 @param[in] FvbInstance The pointer to a FW volume instance structure, which contains the information about one FV. =20 - @retval VOID - **/ VOID InstallFvbProtocol ( @@ -33,8 +30,8 @@ InstallFvbProtocol ( EFI_STATUS Status; EFI_HANDLE FvbHandle; =20 - ASSERT (FvbInstance !=3D NULL); if (FvbInstance =3D=3D NULL) { + ASSERT (FvbInstance !=3D NULL); return; } =20 @@ -48,14 +45,14 @@ InstallFvbProtocol ( // // Set up the devicepath // - DEBUG ((DEBUG_INFO, "FwBlockService.c: Setting up DevicePath for 0x%lx:\= n", FvbInstance->FvBase)); + DEBUG ((DEBUG_INFO, "SpiFvbServiceSmm.c: Setting up DevicePath for=20 + 0x%lx:\n", FvbInstance->FvBase)); if (FvHeader->ExtHeaderOffset =3D=3D 0) { // // FV does not contains extension header, then produce MEMMAP_DEVICE_P= ATH // FvbInstance->DevicePath =3D (EFI_DEVICE_PATH_PROTOCOL *) AllocateRunti= meCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH), &mFvMemmapDevicePathTemplate); if (FvbInstance->DevicePath =3D=3D NULL) { - DEBUG ((DEBUG_INFO, "SpiFvbServiceSmm.c: Memory allocation for MEMMA= P_DEVICE_PATH failed\n")); + DEBUG ((DEBUG_ERROR, "SpiFvbServiceSmm.c: Memory allocation for=20 + MEMMAP_DEVICE_PATH failed\n")); return; } ((FV_MEMMAP_DEVICE_PATH *) FvbInstance->DevicePath)->MemMapDevPath.Sta= rtingAddress =3D FvbInstance->FvBase; @@ -63,7 +60,7 @@ InstallFvbProtocol = ( } else { FvbInstance->DevicePath =3D (EFI_DEVICE_PATH_PROTOCOL *) AllocateRunti= meCopyPool (sizeof (FV_PIWG_DEVICE_PATH), &mFvPIWGDevicePathTemplate); if (FvbInstance->DevicePath =3D=3D NULL) { - DEBUG ((DEBUG_INFO, "SpiFvbServiceSmm.c: Memory allocation for FV_PI= WG_DEVICE_PATH failed\n")); + DEBUG ((DEBUG_ERROR, "SpiFvbServiceSmm.c: Memory allocation for=20 + FV_PIWG_DEVICE_PATH failed\n")); return; } CopyGuid ( @@ -96,7 +93,7 @@ InstallFvbProtocol ( =20 /** The function does the necessary initialization work for - Firmware Volume Block Driver. + the Firmware Volume Block Driver. =20 **/ VOID @@ -148,10 +145,6 @@ FvbInitialize ( mPlatformFvBaseAddress[1].FvBase =3D PcdGet32(PcdFlashMicrocodeFvBase); mPlatformFvBaseAddress[1].FvSize =3D PcdGet32(PcdFlashMicrocodeFvSize); =20 - // - // We will only continue with FVB installation if the - // SPI is the active BIOS state - // { // // Make sure all FVB are valid and/or fix if possible @@ -167,11 +160,= 20 @@ FvbInitialize ( if (!IsFvHeaderValid (BaseAddress, FvHeader)) { BytesWritten =3D 0; BytesErased =3D 0; - DEBUG ((DEBUG_ERROR, "ERROR - The FV in 0x%x is invalid!\n", FvHea= der)); + DEBUG ((DEBUG_ERROR, "ERROR - The FV at 0x%x is invalid!\n",=20 + FvHeader)); + + // + // Attempt to recover the FV + // FvHeader =3D NULL; - Status =3D GetFvbInfo (BaseAddress, &FvHeader); + Status =3D GetGeneratedFvByAddress (BaseAddress, &FvHeader); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_WARN, "ERROR - Can't recovery FV header at 0x%x. = GetFvbInfo Status %r\n", BaseAddress, Status)); + DEBUG (( + DEBUG_WARN | DEBUG_ERROR, + "ERROR - Can't recover FV header at 0x%x. GetGeneratedFvByAdd= ress Status %r\n", + BaseAddress, + Status + )); continue; } DEBUG ((DEBUG_INFO, "Rewriting FV header at 0x%X with static data\= n", BaseAddress)); @@ -181,15 +183,15 @@ FvbInitialize ( BytesErased =3D (UINTN) FvHeader->BlockMap->Length; Status =3D SpiFlashBlockErase( (UINTN) BaseAddress, &BytesErased); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_WARN, "ERROR - SpiFlashBlockErase Error %r\n", St= atus)); + DEBUG ((DEBUG_WARN | DEBUG_ERROR, "ERROR - SpiFlashBlockErase=20 + Error %r\n", Status)); if (FvHeader !=3D NULL) { FreePool (FvHeader); } continue; } if (BytesErased !=3D FvHeader->BlockMap->Length) { - DEBUG ((DEBUG_WARN, "ERROR - BytesErased !=3D FvHeader->BlockMap= ->Length\n")); - DEBUG ((DEBUG_INFO, " BytesErased =3D 0x%X\n Length =3D 0x%X\n",= BytesErased, FvHeader->BlockMap->Length)); + DEBUG ((DEBUG_WARN | DEBUG_ERROR, "ERROR - BytesErased !=3D FvHe= ader->BlockMap->Length\n")); + DEBUG ((DEBUG_ERROR, " BytesErased =3D 0x%X\n Length =3D 0x%X\n"= ,=20 + BytesErased, FvHeader->BlockMap->Length)); if (FvHeader !=3D NULL) { FreePool (FvHeader); } @@ -249,15 +251,15 @@ FvbInitialize ( } =20 if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_WARN, "ERROR - SpiFlashWrite Error %r\n", Status)= ); + DEBUG ((DEBUG_WARN | DEBUG_ERROR, "ERROR - SpiFlashWrite=20 + Error %r\n", Status)); if (FvHeader !=3D NULL) { FreePool (FvHeader); } continue; } if (BytesWritten !=3D ExpectedBytesWritten) { - DEBUG ((DEBUG_WARN, "ERROR - BytesWritten !=3D ExpectedBytesWrit= ten\n")); - DEBUG ((DEBUG_INFO, " BytesWritten =3D 0x%X\n ExpectedBytesWritt= en =3D 0x%X\n", BytesWritten, ExpectedBytesWritten)); + DEBUG ((DEBUG_WARN | DEBUG_ERROR, "ERROR - BytesWritten !=3D Exp= ectedBytesWritten\n")); + DEBUG ((DEBUG_ERROR, " BytesWritten =3D 0x%X\n=20 + ExpectedBytesWritten =3D 0x%X\n", BytesWritten, ExpectedBytesWritten)); if (FvHeader !=3D NULL) { FreePool (FvHeader); } @@ -265,13 +267,13 @@ FvbInitialize ( } Status =3D SpiFlashLock (); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_WARN, "ERROR - SpiFlashLock Error %r\n", Status))= ; + DEBUG ((DEBUG_WARN | DEBUG_ERROR, "ERROR - SpiFlashLock Error=20 + %r\n", Status)); if (FvHeader !=3D NULL) { FreePool (FvHeader); } continue; } - DEBUG ((DEBUG_INFO, "FV Header @ 0x%X restored with static data\n"= , BaseAddress)); + DEBUG ((DEBUG_ERROR, "FV Header @ 0x%X restored with static=20 + data\n", BaseAddress)); // // Clear cache for this range. // @@ -294,7 +296,7 @@ FvbInitialize ( FvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress; =20 if (!IsFvHeaderValid (BaseAddress, FvHeader)) { - DEBUG ((DEBUG_WARN, "ERROR - The FV in 0x%x is invalid!\n", FvHead= er)); + DEBUG ((DEBUG_WARN | DEBUG_ERROR, "ERROR - The FV in 0x%x is=20 + invalid!\n", FvHeader)); continue; } =20 @@ -322,7 +324,7 @@ FvbInitialize ( FvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress; =20 if (!IsFvHeaderValid (BaseAddress, FvHeader)) { - DEBUG ((DEBUG_WARN, "ERROR - The FV in 0x%x is invalid!\n", FvHead= er)); + DEBUG ((DEBUG_WARN | DEBUG_ERROR, "ERROR - The FV in 0x%x is=20 + invalid!\n", FvHeader)); continue; } =20 diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiF= vbServiceCommon.h b/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbServi= ce/SpiFvbServiceCommon.h index 7b0908b03fdc..7664670457a2 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServi= ceCommon.h +++ b/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbSe +++ rviceCommon.h @@ -1,14 +1,14 @@ /** @file Common source definitions used in serial flash drivers =20 -Copyright (c) 2017, Intel Corporation. All rights reserved.
-Copyright= (c) Microsoft Corporation.
-SPDX-License-Identifier: BSD-2-Clause-Patent + Copyright (c) 2017, Intel Corporation. All rights reserved.
=20 + Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 -#ifndef _SPI_FVB_SERVICE_COMMON_H -#define _SPI_FVB_SERVICE_COMMON_H +#ifndef SPI_FVB_SERVICE_COMMON_H_ +#define SPI_FVB_SERVICE_COMMON_H_ =20 #include #include @@ -61,7 +61,7 @@ typedef struct { } FVB_GLOBAL; =20 // -// Fvb Protocol instance data +// Firmware Volume Block (FVB) Protocol instance data // #define FVB_INSTANCE_FROM_THIS(a) CR(a, EFI_FVB_INSTANCE, FvbProtocol, FVB= _INSTANCE_SIGNATURE) =20 @@ -81,7 +81,7 @@ typedef struct { } FV_INFO; =20 // -// Protocol APIs +// Firmware Volume Block (FVB) Protocol APIs // EFI_STATUS EFIAPI @@ -146,8 +146,23 @@ IsFvHeaderValid ( IN CONST EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader ); =20 +// +// Module Local Functions +// + +/** + Returns an empty firmware volume for the firmware volume at the given ba= se address. + + @param[in] FvBaseAddress The base address of the firmware volum= e requested. + @param[out] FvbInfo A pointer that will be set to a buffer= for the firmware volume header + at the given base address. + + @retval EFI_SUCCESS The firmware volume was returned succe= ssfully. + @retval EFI_NOT_FOUND The firmware volume was not found for = the given base address. + +**/ EFI_STATUS -GetFvbInfo ( +GetGeneratedFvByAddress ( IN EFI_PHYSICAL_ADDRESS FvBaseAddress, OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo ); diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiF= vbServiceMm.h b/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/S= piFvbServiceMm.h index 36af1130c8ee..512844197a4d 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServi= ceMm.h +++ b/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbSe +++ rviceMm.h @@ -6,12 +6,12 @@ =20 **/ =20 -#ifndef _SPI_FVB_SERVICE_MM_H_ -#define _SPI_FVB_SERVICE_MM_H_ +#ifndef SPI_FVB_SERVICE_MM_H_ +#define SPI_FVB_SERVICE_MM_H_ =20 /** The function does the necessary initialization work for - Firmware Volume Block Driver. + the Firmware Volume Block Driver. =20 **/ VOID -- 2.41.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D Groups.io Links: You receive all messages sent to this group. View/Reply Online (#106553): https://edk2.groups.io/g/devel/message/106553 Mute This Topic: https://groups.io/mt/99866031/6226280 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [ashraf.ali.s@intel.com] = -=3D-=3D-=3D-=3D-=3D-=3D