From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.24683.1688158040744004755 for ; Fri, 30 Jun 2023 13:47:21 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=HJ4SWPhb; spf=pass (domain: intel.com, ip: 192.55.52.120, 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=1688158040; x=1719694040; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=xK0OAA6qlZ4Snik7cRD3iVcAFm7n6tzrvQfI+DvY//o=; b=HJ4SWPhbcReWckUBdOYEf++8BjG3JWmbI+Pkkb3JNCAWvn7ShNstBKmv kLpUFkRXdd7v+PY9iIY3HuaMtcvDUpXQdJEtaZMHO7W46EErtquSKpiNW LT3bmdaDcxCTzCs+GXLcB87GX/qI9PsK9jiDnpW4DpYdTKi/G8/KgBZVU sd8WPeQ75ae26ywETEIZk7Qnb7duMZqfNVIAhOqw10ZPdcIAAZGphz4E9 J/lmzoZX8ihALUdbu7Yu74kao1LwvOr17/2Y9Tf67iRbqOufBLmlIpuK4 NVdDVaVsR54WSSxzc58O0EsQb4psMgCSuRcFk8VcOQnadsKfsGKZeAVCO w==; X-IronPort-AV: E=McAfee;i="6600,9927,10757"; a="361340817" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="361340817" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2023 13:47:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10757"; a="807908807" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="807908807" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jun 2023 13:47:08 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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 13:47:07 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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:47:07 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.175) 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 13:47:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eTULTAxCJ0OewfnJGfkztX36RavxIA/ymXGNNGeAJW4wCV2bQ18N6b1z6pVjCXXTrBlNA9/qaArwUxNP6jjqRlT459nykBiWT/lpqssfnkhrhfXyfTEzAENlZRuoytICSPebKsXG/Te48yTv4pYJoR1oZVReCI/cKASzvDc5qLz46WmZZlV/5EDviIXp0x/xwkLCLSH3q7TEW3BfaDcKISDBB4jP17NmSXvH2NYjjaHGJa5rvlveHVSza1YyFiMPp/pOjakzTgTSqQnsdAvSf8vKob41cajUVVdb/fF3ZoEt4v1pjH/Ds7WWpahGYeNQ+VqLmNpTaDo4o+6jcp9RlA== 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=tXrbl3E4Rr+5DvFhGnNpIb2SGi8aouw9e/opX/K6I1E=; b=Mg/ZJT17z7Ef9Y8ecjLCRfIgqGHwzaNwdvdzUmKda+rgC9CuZoHXgQ3QZfIx0CWrUnwLGrRNHyx4nwNrM9g+kiyUKj6qrxV9clPru/xba/IuBaaJQUmcn787FgI1zDvfhzSVYIUawvxXAirt7U9ETZs6AvGpjl4GsXA0hSoWJIBMH8l/QgjrFDe+JNpKNLoLNh9nBdAG30AQKsNOLzLlXwp9zd6xauTPCtAjbq9OfBhWvMkmJXHIoy/7TqCv/EP/86b0PsPgcHBuVS6/XtWU9ZkTcEVx5zFzxJ2lR5LVjQMFYeyZVhyL6Lu5BCqvz4zwLabzOJzuWv3GeW71zRr31w== 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 BN9PR11MB5402.namprd11.prod.outlook.com (2603:10b6:408:11b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.15; Fri, 30 Jun 2023 20:47:02 +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:47:02 +0000 From: "Isaac Oram" To: "devel@edk2.groups.io" , "Oram, Isaac W" , "S, Ashraf Ali" , "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+js1mAgAATiVCAAAsUAA== Date: Fri, 30 Jun 2023 20:47:02 +0000 Message-ID: References: <20230630023236.746-1-mikuback@linux.microsoft.com> <176D896904216960.17093@groups.io> In-Reply-To: <176D896904216960.17093@groups.io> 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_|BN9PR11MB5402:EE_ x-ms-office365-filtering-correlation-id: b24054dc-4e5d-48e7-a80d-08db79ab2868 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: CBbnqTsggryneLWxVRNNkbastZNMdCHfChbojq7voCAJ20O+cj0Pek0BmQhPY+JaxWNIh8tZqJrDjw7nsA6fR95XSkB+f413GZ9Rq0PiGrdVpBqtW8O7bX4sOooqbacYg4N44uYNvqsS5BF/kPETIY/pbrYbC09qH1UdcnSO5WFIU/LvSPNBgj5O98sygCaupy/aUOSWsq4pCllhpmSqN1TAaE1VxA1eFOA6rMRA2sYZ6UI7l1f7+sdOJVmlOQ//2om5AGLM7icKFw8dl6Yzb8txchaCHlQFoB29lNJD0/Oak4gKAn8hy5wA2QK3nmz1mYlVdoskHynnH/4bCCeCq/NPQl70HqNRh1e8TSS45BJXKW4ShHtTaz4nRG3PULfjmQ8ky0foPKsia8DQ8I2pv6ER6GKlbFuFcyxtdkxJH2W4bv9DIQ5XtABzJTzGj6dp5pZ1UFPqopP8tQA6IzVJujo00TR3WQU73sHHVdyZC2IhjxBQUsH7vnj6qGHw0FB+i157yTmmzvybG4IPvyaYao/a+6Sm908w2Rrwf4pE9aGBa8kOWLz4WT3wo+1Hi+he1AWPIh5AKaf1Hedsqww+UOFbjKvw6Q8VIfh74l7i5j88NrtA1KDUgu5BaRKpKkpfHyYgQtArzbzJAdY4Ns10qg== 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)(346002)(39860400002)(396003)(366004)(136003)(451199021)(66899021)(76116006)(66946007)(45080400002)(66476007)(66556008)(107886003)(478600001)(64756008)(66446008)(110136005)(54906003)(4326008)(83380400001)(38100700002)(82960400001)(86362001)(122000001)(55016003)(41300700001)(2906002)(7696005)(53546011)(8936002)(966005)(8676002)(71200400001)(26005)(186003)(9686003)(316002)(33656002)(6506007)(38070700005)(30864003)(52536014)(5660300002)(579004)(559001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?IkW2QbIpMo4ocQZ5pbvw6Aq/xogPz2zdWg6OdFzQUEwh4pQuv9vileTskpbf?= =?us-ascii?Q?8woFTjpnItEJMMGWVtcuq7B5qEGPtKFszTYf0HLiwSl0V0LcZylbm140I2FY?= =?us-ascii?Q?WknwTyzwRsJJqWfZU13JusGPOCMvj84m1JcjpOLKzBW/jjEplflXZnUag8pO?= =?us-ascii?Q?+sd31D2LMxV+tiPWDY7VDTDZyqI+Ir89Qd8Y7jX5Z2KVDRGyzho+e9FrLOGt?= =?us-ascii?Q?6XuvSnaPFJrq/i4Ocrmlir6SMx2q6S1yaMewnJCQE31TPzD+xlXLb3NNBRCp?= =?us-ascii?Q?4Epv8ecBzSPrdNWTU2sXZSeIrWrtJpSC/018ZgvUy4Swl2SslWosaQnHKPxa?= =?us-ascii?Q?5tdk/LiOu9tbxt9SiNOqsmAtwRC0eKnUVDhsmtQgVeKCqhBfatpF/jqA4vJR?= =?us-ascii?Q?jIfIagYcChut7TcLR+ND3ZhnQLRx5cqgzFJMJpYMppNvw9NleOeDvf2HvWh1?= =?us-ascii?Q?HNv+pp+LHclCypC8tll1L55xVZ+783W9hBZHGYw0VfAMfETUn1Ajztar9M6b?= =?us-ascii?Q?xvfyAoFBYIDs7CqvhOm5quOaiIqSzsO5giaMhJ/lu63impYPmOPtzZhKs/c/?= =?us-ascii?Q?5vXb15nCkpsPHBTf5qIa25HphqkhhX61XO0F2PInfFlPLwgoHQ6hNq+WG8VH?= =?us-ascii?Q?cVxg/GOcyPMlulfQ2f1TOq4fwr3svQw/DFVJHfNCtCFjFVr/iI0ZNAT/yNM7?= =?us-ascii?Q?1TTIT93J8IZjmkLfP+GENBunvQwZ65WweRenzag0gc42dukizBNL0r07Xj1K?= =?us-ascii?Q?l8GynLvBOY4zqwNHpOAXBZZ/+AkZpIE0anpxcbJ3adM8GLKxRtHd29A2slEc?= =?us-ascii?Q?MhRrPketyfdhBdP5g2wrFoaYO39fkl9nibbF4Xf8zmwEu71/2hYKdNgAVBuV?= =?us-ascii?Q?SOLTINT30X1lkTTstkO38oAnvmvbIbKlYXv2sZASUq25iHes5to++Q4i8lqD?= =?us-ascii?Q?hAhp7vI4j8N3a3+qGC4xcEP6X9zZXuUNylS67Y6sTPYriTSYOSO4wzfi15Ke?= =?us-ascii?Q?4r/Cugv0fX7xk5BTjFTq+F6hOyhOpJlQ03PwJCUE7V+pvhvetIU8KU1yAytL?= =?us-ascii?Q?S8fBsv3cs3TbFBPgN9n4kH/7bj260GfO9vaD+sfuiR1G0iCfxNZMFdpHSbAl?= =?us-ascii?Q?kK8h79bJLJyCi+zmzCueSHng1nkSKxdbUsRE6Thy6ePk0kNIUUBKH374GeE3?= =?us-ascii?Q?PqSskqT0rnVgru+ZvtFfRKXPNXKalql6YaG2z+9Nyr+SOcAAv2Kc6lHfOcMv?= =?us-ascii?Q?BMd5HC5hIB9uda9rhM+GUIuj3rbhsmyOKDDb7vJSLDWn5sNfKIQlwj1nxiUm?= =?us-ascii?Q?A8WBE8W+3iJ4hOkTEOlPukYy5WDjswKF92FQ8KlEB96hvzappZCYgmPL7WWK?= =?us-ascii?Q?8sFqU/WFf2HCyRUplI2GwkwcV4NdbCjzpsnYgc5zD0N9U8rSKwV5LtWKAJo3?= =?us-ascii?Q?syan2okxYpOtpJZi3tzL7qz3/qRjBq1KkwbzXu0ToGWoOiFok8q0KiKjJA/v?= =?us-ascii?Q?+m3wKyKR4Qe83i38M9HJIw7Ud+YeyPKUg7QOD8rbEo9mc+e5uRjc3E8ompqm?= =?us-ascii?Q?yyoEIYpi4qDO4DDZZwXSudasuIucN+q9Qku5Zosz?= 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: b24054dc-4e5d-48e7-a80d-08db79ab2868 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jun 2023 20:47:02.7294 (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: XuGRkr8mxH3sw+CNNu7sENnWwzOxHhNq8qQI540gOFsNADfVR2GmqY4hDAVu7Bz5yq4xCbrxLpowScwGutrPDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5402 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 Pushed as 1befeabcc8..dd09609ec9 -----Original Message----- From: devel@edk2.groups.io On Behalf Of Isaac Oram Sent: Friday, June 30, 2023 1:22 PM 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/Sp= iFvbService: Non-functional cleanup 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 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