From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.22065.1688151431089950025 for ; Fri, 30 Jun 2023 11:57:11 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=OlrfjbLR; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: ashraf.ali.s@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688151431; x=1719687431; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=3M0zuKhpl6i9o77B4bobJappgE1joh2iL8mhLyy4BPo=; b=OlrfjbLRXXLnV75ruyBQEJskJlHmLgnJDm9Vquiz+RnmaTeGL9DGjUk4 fE0NuReJA39O/PqXMnYgimpKaiMu5lfPII/bKTZY5GHGSKKvfUCsZSoy5 zOSy6sdvajWuqqDFmlte0l/AgiIJXo37uxHhc+m3dzcVCU+aGCdUAZ7ky VnR+NsU+PdbMj2mSqO//yEvqppD9DtoWpNCBDLtMjsWWXWaVbvLHJrLcF jq4UBQehex5J2puWDI6Y12udITXH6DdoD7+r2cnnf728c6Sd7AQ+Qd9dw tg95TJCNWAhucccJfDd9oO2NBIzMQ1r09zWlLBZplYC63zuUaVSgENloH Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10757"; a="393194115" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="393194115" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2023 11:57:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10757"; a="841955277" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="841955277" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga004.jf.intel.com with ESMTP; 30 Jun 2023 11:57:09 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx601.amr.corp.intel.com (10.18.126.81) 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 11:57:08 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx602.amr.corp.intel.com (10.18.126.82) 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 11:57:08 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.176) by edgegateway.intel.com (192.55.55.68) 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 11:57:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C9MYWTC25gWsAaXvKga758Qs2Un0VsWRSSUdiPHyrBD2EoOMwnSNJwr/LCjMnxl/stUuqM82BJ5Gs9DoHaV3fYc/Th6R7g6J8/rR/wVn5ENT1zvmKRNCzzH284hfNmI2J2qcZo5PhJdrAOnALNJSjXl2JVz3bU8J607/bO7nQRZLxOlUjWe/6QiWwp6m5A/GH9fL9TOFMlD2t/ZodDSOnwFkmHP51QoEek8YqzsqLMKRXzZrZCrH1kDui4B/IJywwKmtKnk1nvQiH9rbhByjwvQhDWqGH9jnf5kLGl3gEEcV3uAIjI66GfZLtj5emd7BSL1eHuJiyWzygKWQno/lEg== 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=J59x9LydzjGI0Ac/ID2gvuQ91pgGw6CFQ4xGBqrkVDw=; b=BZYHLhC35OHM49KbwVh63x+2b8pnscHCSXV1/zzNtO8Locl6PE3lcyldvVHQKVpboRIjTmK8D//s27YJmIyHK2ERWE9nfYjVzUvJff2TX7y8Epe91iQifzkadUJ154gRo2T90RBNzdoeFFSPsOjfBjeP7cruO4Kd7yD5QWsqdVgB98CPK19bKqbx3aOAn3WIf/aiK7jR7wMW+uRDufmBTcTWdk4KUkDNN1vfq3dC+OY8hYxT5GZbWc0Npm7frcTmldJiYueU+UKY91HhazuxP7UQR2OEkN/GZpkETB/95STxmbvDadVobCwXQgNwIcDD8vQD8MLT3moMfqnAxEigKw== 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 DM4PR11MB5280.namprd11.prod.outlook.com (2603:10b6:5:38b::18) by PH8PR11MB7989.namprd11.prod.outlook.com (2603:10b6:510:258::13) 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 18:57:04 +0000 Received: from DM4PR11MB5280.namprd11.prod.outlook.com ([fe80::32d0:b03a:e6ea:b7cd]) by DM4PR11MB5280.namprd11.prod.outlook.com ([fe80::32d0:b03a:e6ea:b7cd%4]) with mapi id 15.20.6544.019; Fri, 30 Jun 2023 18:57:04 +0000 From: "Ashraf Ali S" 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/SpiFvbService: Non-functional cleanup Thread-Topic: [edk2-devel] [edk2-platforms][PATCH v1 1/1] IntelSiliconPkg/SpiFvbService: Non-functional cleanup Thread-Index: AQHZqvs4/e3HSALfbEqOsnWtAk2D2K+jswLA Date: Fri, 30 Jun 2023 18:57:03 +0000 Message-ID: References: <20230630023236.746-1-mikuback@linux.microsoft.com> In-Reply-To: <20230630023236.746-1-mikuback@linux.microsoft.com> 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: DM4PR11MB5280:EE_|PH8PR11MB7989:EE_ x-ms-office365-filtering-correlation-id: e7de3cfc-690a-48a7-52da-08db799bcb3b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: SPKyYobZzM3yrKe/8GFvTPEmoS8NzPzUfChlzQznt7qLKRwhLhwxl4pUcIL8yp41jzopqDw8HxeSbSLGx37nC8xx+o0igD0LXZBY5AdsNLFrA7CdvV+UOt4jj/MWd8s2Vse1+JfyTzTZSvx4B0q2TJyXLEpT5ngsKof5+a3OdBAyvwQnigGNnx+4Lr2Cez8+P/1BC1WSUM5uiUzOKfecUQf42BPV0u2yiu3BMlvZrzQKUo7ehLtIF46LNGQB9fsK14NatLiB6PrwZj2IMKu2GEwlcqeB+IUuFyQJQsgnS64bIiyYWFBazgFEIdI1ieVThmYKkqOAHrP9CBR4dwa3hee4yk1gnNCbk3cSqXe/d0PhOgulR0vCeczc4A0XgchsE+a+iYC4Wu/9koYq/G2VZpp9WcX177OCCk1S+yHFq3XSvyVCqmrF1Ortc0DvMNDLBBRMqkTw9563v6YpqAlxA2e7rk5Jj9RQSrk5igxh6pHz7JF5uFsLFC5s6zgmPDEniK0MlARhJ/GeTUEmrj/Tg4W7fz45zBQ/veQBsJTGKomWFt8H5B8u3l/60zatStBlyuzgBzZVX47Kv8/Ier0IqmqJU4cBOlwE5tuAC9iulhzP0uB6E6p4Hu5Vw/zrmYjaTxdjDtuoocu5BwsKhrXDAg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB5280.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(366004)(136003)(376002)(346002)(39860400002)(451199021)(26005)(54906003)(110136005)(2906002)(45080400002)(7696005)(82960400001)(186003)(107886003)(83380400001)(38100700002)(53546011)(6506007)(122000001)(9686003)(71200400001)(86362001)(55016003)(966005)(41300700001)(30864003)(64756008)(478600001)(38070700005)(66476007)(66446008)(316002)(4326008)(76116006)(66556008)(33656002)(8936002)(66946007)(52536014)(66899021)(8676002)(5660300002)(579004)(559001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Vbeayhdlqz3qfAbbg6dPP6j1lr1SWLKqC/OoVSBKp637OBmWT64CkXidjpPT?= =?us-ascii?Q?HVQqYdj4R+OjYKa0aYvqwZHIsXzVl+O/ABvVf/Nq3SrBITTW4gLqrWcV6W7Q?= =?us-ascii?Q?b4uUFw64ysOioTb8vjEOjXozjVY8wYVxVTKqPRk5oEDaL839LXUX+DvZsPg1?= =?us-ascii?Q?ENTlmzI8UiEb/BsVwCRMh3Nk2K/pRp7ghFQZOTDLaWoJaNAwN1nGoqL5uekc?= =?us-ascii?Q?BgzM9RFuqRgmZrFxpI1Z/kVeqLFz8/Ty0HPHnust0zFCqXWfjEx7hJtJnSzG?= =?us-ascii?Q?bCtoounVTyQNo3vFXVV0H0nPuUKtNaUao7tPxdm44M8n6tkcGmd4wls2OeNS?= =?us-ascii?Q?cx2a6bpzpN/5Ww5+m7pLrK5PN6f8fEIQ7jgVDiZlgqV9bY9vesUpPmsZDPT2?= =?us-ascii?Q?netUCU0ZmK/M8/hcd7ua2hKgecmIpErz0PRWG+dQBqXAItpt2XNTk4hXOjr6?= =?us-ascii?Q?K+hmgqGncO7hc2tFdeAbfddl+TkB3QLVwzem3103WWUrI5pEoUbEz5KdASic?= =?us-ascii?Q?BYBUZB7TL4qF4/c0YKemTr1QhL37q0qMZx8ogJuyPt8b3bbv3pdXZ4xjR9vf?= =?us-ascii?Q?h9tUxIlCadcySVHI1iorHAJYsn9/A0QpZISrmk0IIRhwHt6OsLenYPdEpDGX?= =?us-ascii?Q?kUkhz0hpIRzuiC0ybi0Fquf11+/ZEmrqNod3TkVqvYN846kHNMyjrbAdj6H+?= =?us-ascii?Q?+5jm9bMgWcWujM1b5YWTfrZoUT+q21XqAPnnozWnn2WwZBNXwdIt7oZVWkJT?= =?us-ascii?Q?U8EkiiKbAcOc+SS4CloWVWsKVz+GxUzJ6Il77NEWz7Fu7Rdm4RNCFRtvDVuL?= =?us-ascii?Q?EdtN5kgCYJ33FT7pGEgrJXXz1Bw0xuLcFuvHQN0nlDsOmMusS3ey+y1BuoU9?= =?us-ascii?Q?dgEnmceywrr2mQaj0EcH1pssHPKzJ42nz3l1ixnQeQIVjCzogOQ0b8IyTtLv?= =?us-ascii?Q?5F1KPY/Z0wpoGByhXegn+kSSdGi1TaVwTnQWlfiNx5o58gYZXjwT94BmhyXi?= =?us-ascii?Q?8sT9Hy1VhfjCCmK8fEci5wiNjD5zaO+DMjBgqduKj/yLr5MeRfjfq0hXYC40?= =?us-ascii?Q?uUFhGd5kxElsZxVw1laLE6qh+VHcM06tyTfAE4scam9lVwxrd6Nk02A25oka?= =?us-ascii?Q?whH+ZmAA+HuNOPMz/R5NtVQ0IwkmMOZanUn8Evkx4tWcYhDOQVQj5BbxHd87?= =?us-ascii?Q?Wcopab2OzeoC4kFTPqqcUWeWKoQ5O7qdutDm9MNpeEhQ/Erl2rZv3BgNNnJw?= =?us-ascii?Q?GvkL0nEEEYqxMhP+F6pVssCwdgMeQwhSODqlKxEjuUBOlM5qFa/ZbJ/kdE2t?= =?us-ascii?Q?cPZulR9vjGnxmDwdg/eK9ldt1DYFbsH6JXAqbACugigbf+o5V8x02HDuMgee?= =?us-ascii?Q?CotciiSjM+Ei3gxiAsDBjGn1kr8x2uEDdEjoY6EWUEKcWEi0gziDozIBHdZl?= =?us-ascii?Q?RKuWuKki0mXbMxWT2KURSt94MgRKn1FIeXZL+CoNj+5gmuIruPZn04q+lYyC?= =?us-ascii?Q?3SXwXjq6fS/tUOCXKwFhsMso5I7uAeBPjkxrFqGIK4j8NWANY9egFd21yK1z?= =?us-ascii?Q?LGxrqcGJ7CGeoby6a1JzNkHcp7lx6LvwmR29j94y?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5280.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7de3cfc-690a-48a7-52da-08db799bcb3b X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jun 2023 18:57:03.9135 (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: zkHB9sdfyjr6+7fOd8Npu2XEafoNu8n0DnYSvXjz0ARX8hBwh2AZ3KxktE/n+l1WU3lScejrDG0VuOmMGPw5iA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR11MB7989 Return-Path: ashraf.ali.s@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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