From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 881E2740034 for ; Mon, 8 Apr 2024 22:34:49 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=VQgdEhVT89dnC462DIqaoey9ZnVSuVJ5s/V06sKDIvI=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1712615688; v=1; b=06j63u9jKQ7lzsN+B1e2Wp1KlESNeM2ewCzreuJ17aOcRCYY2ObhmIjstLWx+0G9SRs/00CY oRf9//OfTiegXKc4CFH5FQRWeHu0Go8mzAR/kILSkLVNKKEgUfU6c1vh5XBn3e/u1P5g5lvV+79 0IhePNYQBFW8PFavb+tdBqWZ+0WegbkotJpImRFE55CUIjMMBXXqvyE0sCzatcOVQih5JI31KMv 2nnOpa6gZG8dhtdXNNP17oIdlcaHcSdlwkuOVPnnnVV2m9zvnLgaGad4w0Nh3SWUeG0j3oUY9IR COWhxxgT5EiZoagZARlWuJImjaxBS4/ls8PmrFttOyrZQ== X-Received: by 127.0.0.2 with SMTP id Y9ldYY7687511xx1YKFSu7j7; Mon, 08 Apr 2024 15:34:48 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by mx.groups.io with SMTP id smtpd.web10.122138.1712615687150896948 for ; Mon, 08 Apr 2024 15:34:47 -0700 X-CSE-ConnectionGUID: yPtf3vH9ThKK6GXmZLychA== X-CSE-MsgGUID: hSlUqsJCS2W0877zXbXk0g== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="19345692" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="19345692" X-Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 15:34:47 -0700 X-CSE-ConnectionGUID: sSfAlRDbTCO3FmRJiGtSgQ== X-CSE-MsgGUID: 1za7v7oXQryZXhoR7+JkFw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="20078836" X-Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmviesa009.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 08 Apr 2024 15:34:40 -0700 X-Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) 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.35; Mon, 8 Apr 2024 15:34:39 -0700 X-Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 8 Apr 2024 15:34:38 -0700 X-Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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.35 via Frontend Transport; Mon, 8 Apr 2024 15:34:38 -0700 X-Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.41) 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.35; Mon, 8 Apr 2024 15:34:38 -0700 X-Received: from MW4PR11MB5821.namprd11.prod.outlook.com (2603:10b6:303:184::5) by IA1PR11MB7270.namprd11.prod.outlook.com (2603:10b6:208:42a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.24; Mon, 8 Apr 2024 22:34:35 +0000 X-Received: from MW4PR11MB5821.namprd11.prod.outlook.com ([fe80::2769:a1e8:3236:e5a1]) by MW4PR11MB5821.namprd11.prod.outlook.com ([fe80::2769:a1e8:3236:e5a1%4]) with mapi id 15.20.7452.019; Mon, 8 Apr 2024 22:34:35 +0000 From: "Nate DeSimone" To: "devel@edk2.groups.io" , "Hsueh, DoraX" CC: "Chaganty, Rangasai V" , "Chuang, Rosen" , "Kasbekar, Saloni" , "Tang, Haoyu" Subject: Re: [edk2-devel] [PATCH] AlderlakeSiliconPkg: Update for SPI2 Protocol and Identify flash regions by GUID Thread-Topic: [edk2-devel] [PATCH] AlderlakeSiliconPkg: Update for SPI2 Protocol and Identify flash regions by GUID Thread-Index: AQHaVeW75uUVwM7MA029arIDzYzO/bFfXHNA Date: Mon, 8 Apr 2024 22:34:35 +0000 Message-ID: References: <68bd889bdb0b6ce4f2bad700403d07e21f73aa74.1706855436.git.dorax.hsueh@intel.com> In-Reply-To: <68bd889bdb0b6ce4f2bad700403d07e21f73aa74.1706855436.git.dorax.hsueh@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR11MB5821:EE_|IA1PR11MB7270:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: WkrKsnJ1MprQ94O2sH+GavGWSyATBwOuT1Q+2I6rhUvmHk4KAHWUTnrKybFcjSnEmo1PEdr4/vsebgOCxHefVyiuZCSwrjwVBbklnruFbdgRdQKIWrMyJ3G4/CiohlurZekKlNVvHlHGgTdK8qS8UEeTp31MHl9O1Zpacygvbf+44lETLXTct0AtUrbRRziLz9db1clO00KMmvaykd0/cib6H5w6Spr8bO4VfDIEAARlsL7IKGydW0vIMWzDxiH6KGMi2tv0aAHvNVdxo2vyoEjz6OYxOXpu5QTHM+gUDuazjxQ/H3qBDv5hXyxfViHVR4Yiy8nVKgobOplojH4MX+hQ9gfCcT7EsAJvZZODxi9JJ+gDeHuDwa+Zylfv+ESZlW3u5hZ1y/Dl1jl7+oXpsyxXWcWF2NonuxhzElVGxx48H+Fj5revyf4oYDNDpwIQySo30ltILC8dH7iDhRDVGdKlR2aPkF3JgPXr/nI1eJ78shHVfmAgWLmh5ky2MU5vdReFE8rWkrYV/5/sPXzRviUb3BJhRU1DIQc0ZItqoQJTe2uyUwOPyGZVmgV+4pIEC71cgIHLlk1lYQ2IiB6JnsmnvupM0iSZ5buh/52OGImtTlBD9v9AHZCxJYJ5a45+ x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?v8r239XYkt8Ld/U2cDmwQ4YUKOWZ5lsL26kxT+akvvb15yHhSIYMUsuCK6mQ?= =?us-ascii?Q?Ty14gEMnyfu/nSp+YPWUTkkuIdLD8Os6Hq9n0z8vvoIbKa8je7wuGG2H+v4z?= =?us-ascii?Q?DC/BMDhYqq+GorjHi/bnlNEAYeXlpzRSuwxefFcji13hnYr6kQkrI9qcrmw2?= =?us-ascii?Q?5b3MNqiHBHBK+izBHsu9OamP8LRSVTiyoi90I2RD7bMJCGWRVSKNl9oeOqxN?= =?us-ascii?Q?nG0noLpnaBkDAYnmXCYG6HdCpsayJiMkbvUnOZpskfV2zsDoECOtCLC2AF0Z?= =?us-ascii?Q?YNss9xTJzF8ubFD0jaD0vDrcUNJG7/1Ec0WqfYjgIYf1z/XZ6CvvYhssNhuH?= =?us-ascii?Q?nQ884fwhzgcpdBOfg7giafV/cDq3bLlDGDPGO2h1/C0E7kqNePoDPGPdwKwr?= =?us-ascii?Q?o6wOdWQAo6mvXiVCDVkI/gXulG1nncy9fSO/rDlUvwyiVcDXXw3mMWutG/TN?= =?us-ascii?Q?VMTdkWnD7Q1q/eS5EkTiM8XnQh2YriRXV7Tad3GMAIxA3lsO9oItxEbLyyyp?= =?us-ascii?Q?4iQ0wxGG+NPoUuVymM+DejF/w/UdglzzH1nOaJJr7vuTuOCqN3xY5mRCgJGJ?= =?us-ascii?Q?9Oqqac5w6zOI1Z1LtZJt+HRa3ujz3nOFCfOZ7l1NB82FNcsUB2HQG7RWim9M?= =?us-ascii?Q?ZBWYnILRX0mDNlP+kOJrxLwTs9nBtH8GavNmoQ1PMuwJ9v0Jz8jtxcn28NB7?= =?us-ascii?Q?AuBcO3XSYgMnnl81JaQAgVG6dOSkNuaZHEE3fT07Jh7VrsKHrdolRIUQCTjF?= =?us-ascii?Q?+ajzX3Uvgc4wkDG/0VDjZjDLO4o+w5tZvvXNs7xAiC+xtS54x9FYQF9U1OTJ?= =?us-ascii?Q?76gIZUuFGtOsJrq7dj6uXB9U5NF78DU136KOv+Si0btZ/auuiebAoQiM343P?= =?us-ascii?Q?SjhOlttBtnn6pcHyxeI3jMEqm2EME/Jlse2hR8lOh3cyBtANVE4INoQoDZj/?= =?us-ascii?Q?Z+QPE3JPfPdizean5tsR8w0zQO5T4dP4aUkmqEeE+XyI1N+zlQdEO4ZD5mop?= =?us-ascii?Q?1nA7dHHdQnRzn0tbpOf6wiCTkV1yGwxhuconVut9erOP35gFRyk/yVMM8aPI?= =?us-ascii?Q?SupDmh2dCsVJHlTTc55CziwRj1BxxHyHAttyuh1J4ZIM7yEmKU1w2blUITdm?= =?us-ascii?Q?pf9CW3soIP0n+Kzo6459lItDjH/IobvZQFuzer/iDEw8/F4gIbq3LVDDHGqg?= =?us-ascii?Q?TlJtY0Fxixp3EzOXWUaqbK420h3c18BRpIcFnlYBGOS39SMvyL2VnqoYiaA1?= =?us-ascii?Q?EtVO+OFVobjOPZZDui9tCN5o/v4NSyjboSNFZlDxCHLcbpccz2b3IJ7akf+x?= =?us-ascii?Q?/vyYfS/C751obSN2sSvTVyuHubtnbRRuoee2l1LnLKZfo86fB8H/AAsCq+ug?= =?us-ascii?Q?tMrIngUajulpfCVS6rQUdRHo9TG9xbhyrkNf59ADB0btuWpnCD1y++9HvhQb?= =?us-ascii?Q?9uOjIimryMKqzUhHelAyu2/N+oDbX91l5zOUu0Y20deG1dLBrI5uXMkaQPsR?= =?us-ascii?Q?eJbGtOdCqoeTegipEA9z9M5egaj3TnziP64AUe0nyyUkFyM7tyLyFTn8lOMH?= =?us-ascii?Q?ubD/xJJM6A7TXBOYF4N6aptY04f3pmN23deqjxrDku9I77ZYoGIxPW27CqQU?= =?us-ascii?Q?rw=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5821.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56f5347d-4a5b-4665-9e51-08dc581c1164 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2024 22:34:35.3751 (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: InAzEau6Z86usokPO0M4hcXfubZbW3YrxYiu8grVfS5+sWm8LHEMC0ALzzYkpA14PvzqMiMriluMl3TR34gIH6R6xgKDcJfCEZQoRf5MEV4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB7270 X-OriginatorOrg: intel.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Mon, 08 Apr 2024 15:34:47 -0700 Resent-From: nathaniel.l.desimone@intel.com Reply-To: devel@edk2.groups.io,nathaniel.l.desimone@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: rCnma1WU2HEYcP1DQwyOPRvpx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=06j63u9j; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Reviewed-by: Nate DeSimone > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of > dorax.hsueh@intel.com > Sent: Thursday, February 1, 2024 10:32 PM > To: devel@edk2.groups.io > Cc: Hsueh, DoraX ; Chaganty, Rangasai V > ; Chuang, Rosen ; > Kasbekar, Saloni ; Tang, Haoyu > > Subject: [edk2-devel] [PATCH] AlderlakeSiliconPkg: Update for SPI2 Protoc= ol > and Identify flash regions by GUID >=20 > From: DoraX Hsueh >=20 > https://bugzilla.tianocore.org/show_bug.cgi?id=3D4664 >=20 > 1. Updates references to the "PCH_SPI_PROTOCOL" to instead refer to > "PCH_SPI2_PROTOCOL". > 2. Updates the library to identify flash regions by GUID and internally > map the GUID entries to values specific to AlderlakeSiliconPkg. > 3. Libs/modules that need to reference IntelSiliconPkg are updated. > 4. Add gUsbConfigGuid to fix USB not working issue in OS. >=20 > Cc: Sai Chaganty > Cc: Rosen Chuang > Cc: Saloni Kasbekar > Cc: Haoyu Tang > Signed-off-by: DoraX Hsueh > --- > .../Cpu/Include/Register/CommonMsr.h | 4 + > .../Fru/AdlPch/CommonLib.dsc | 2 +- > .../AlderlakeSiliconPkg/Fru/AdlPch/PeiLib.dsc | 2 - > .../Include/Library/SpiAccessLib.h | 44 ++ > .../Include/Register/PttPtpRegs.h | 26 + > .../Include/Register/TcoRegs.h | 1 + > .../Spi/IncludePrivate/Library/SpiCommonLib.h | 60 +-- > .../Spi/IncludePrivate/Register/SpiRegs.h | 8 +- > .../PeiDxeSmmSpiAccessLib.inf | 33 ++ > .../PeiDxeSmmSpiAccessLib/SpiAccessLib.c | 75 +++ > .../IpBlock/Spi/Library/PeiSpiLib/PchSpi.c | 2 +- > .../Spi/Library/PeiSpiLib/PeiSpiLib.inf | 2 +- > .../BaseSpiCommonLib/BaseSpiCommonLib.inf | 19 +- > .../BaseSpiCommonLib/SpiCommon.c | 491 ++++++++++++------ > .../AlderlakeSiliconPkg/IpBlock/Spi/Smm/Spi.c | 30 +- > .../IpBlock/Spi/Smm/SpiSmm.inf | 5 +- > .../IncludePrivate/Library/SmmPchPrivateLib.h | 27 + > .../SmmPchPrivateLib/SmmPchPrivateLib.c | 61 +++ > .../SmmPchPrivateLib/SmmPchPrivateLib.inf | 32 ++ > .../Product/Alderlake/SiPkgDxeLib.dsc | 5 + > Silicon/Intel/AlderlakeSiliconPkg/SiPkg.dec | 4 +- > 21 files changed, 733 insertions(+), 200 deletions(-) > create mode 100644 Silicon/Intel/AlderlakeSiliconPkg/Include/Library/Spi= AccessLib.h > create mode 100644 Silicon/Intel/AlderlakeSiliconPkg/Include/Register/Pt= tPtpRegs.h > create mode 100644 Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library= /PeiDxeSmmSpiAccessLib/PeiDxeSmmSpiAccessLib.inf > create mode 100644 Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library= /PeiDxeSmmSpiAccessLib/SpiAccessLib.c > create mode 100644 Silicon/Intel/AlderlakeSiliconPkg/Pch/IncludePrivate/= Library/SmmPchPrivateLib.h > create mode 100644 Silicon/Intel/AlderlakeSiliconPkg/Pch/LibraryPrivate/= SmmPchPrivateLib/SmmPchPrivateLib.c > create mode 100644 Silicon/Intel/AlderlakeSiliconPkg/Pch/LibraryPrivate/= SmmPchPrivateLib/SmmPchPrivateLib.inf >=20 > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/Cpu/Include/Register/Commo= nMsr.h b/Silicon/Intel/AlderlakeSiliconPkg/Cpu/Include/Register/CommonMsr.h > index caa0e67b..44a476c0 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/Cpu/Include/Register/CommonMsr.h > +++ b/Silicon/Intel/AlderlakeSiliconPkg/Cpu/Include/Register/CommonMsr.h > @@ -56,5 +56,9 @@ typedef union { > =20 > } MSR_CORE_THREAD_COUNT_REGISTER; > =20 > +/** > + Special Chipset Usage MSR > +**/ > +#define MSR_SPCL_CHIPSET_USAGE 0x000001FE > =20 > #endif /* _COMMONMSR_h */ > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/Fru/AdlPch/CommonLib.dsc b= /Silicon/Intel/AlderlakeSiliconPkg/Fru/AdlPch/CommonLib.dsc > index 3f508f83..ee5800a9 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/Fru/AdlPch/CommonLib.dsc > +++ b/Silicon/Intel/AlderlakeSiliconPkg/Fru/AdlPch/CommonLib.dsc > @@ -11,7 +11,7 @@ > =20 > EspiLib|$(PLATFORM_SI_PACKAGE)/IpBlock/Espi/Library/PeiDxeSmmEspiLib/P= eiDxeSmmEspiLib.inf > =20 > - > + SpiAccessLib|$(PLATFORM_SI_PACKAGE)/IpBlock/Spi/Library/PeiDxeSmmSpiAc= cessLib/PeiDxeSmmSpiAccessLib.inf > PmcLib|$(PLATFORM_SI_PACKAGE)/IpBlock/Pmc/Library/PeiDxeSmmPmcLib/PeiD= xeSmmPmcLib.inf > PmcPrivateLib|$(PLATFORM_SI_PACKAGE)/IpBlock/Pmc/LibraryPrivate/PeiDxe= SmmPmcPrivateLib/PeiDxeSmmPmcPrivateLib.inf > SpiCommonLib|$(PLATFORM_SI_PACKAGE)/IpBlock/Spi/LibraryPrivate/BaseSpi= CommonLib/BaseSpiCommonLib.inf > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/Fru/AdlPch/PeiLib.dsc b/Si= licon/Intel/AlderlakeSiliconPkg/Fru/AdlPch/PeiLib.dsc > index ebe2bbfd..cbaf8e37 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/Fru/AdlPch/PeiLib.dsc > +++ b/Silicon/Intel/AlderlakeSiliconPkg/Fru/AdlPch/PeiLib.dsc > @@ -5,8 +5,6 @@ > # SPDX-License-Identifier: BSD-2-Clause-Patent > ## > =20 > - SpiLib|$(PLATFORM_SI_PACKAGE)/IpBlock/Spi/Library/PeiSpiLib/PeiSpiLib.= inf > - > GpioHelpersLib|$(PLATFORM_SI_PACKAGE)/IpBlock/Gpio/LibraryPrivate/PeiG= pioHelpersLib/PeiGpioHelpersLib.inf > =20 > =20 > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/Include/Library/SpiAccessL= ib.h b/Silicon/Intel/AlderlakeSiliconPkg/Include/Library/SpiAccessLib.h > new file mode 100644 > index 00000000..6e7f48fe > --- /dev/null > +++ b/Silicon/Intel/AlderlakeSiliconPkg/Include/Library/SpiAccessLib.h > @@ -0,0 +1,44 @@ > +/** @file > + SPI library header for abstraction of SPI HW registers accesses > + > + Copyright (c) 2023, Intel Corporation. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > +#ifndef _SPI_ACCESS_LIB_H_ > +#define _SPI_ACCESS_LIB_H_ > + > + > +/** > + Returns SPI BAR0 value > + > + @retval UINT32 PCH SPI BAR0 value > +**/ > +UINT32 > +SpiGetBar0 ( > + VOID > + ); > + > +/** > + Checks if PCH SPI Controler is present and available > + > + @retval TRUE PCH SPI controller is avaialable > + @retval FALSE PCH SPI controller is not available > +**/ > +BOOLEAN > +SpiIsControllerAvailable ( > + VOID > + ); > + > +/** > + Checks if Device Attached Flash (DAF) mode is active > + > + @retval TRUE SAF mode is active > + @retval FALSE SAF mode is not active > +**/ > +BOOLEAN > +SpiIsSafModeActive ( > + VOID > + ); > + > +#endif // _SPI_ACCESS_LIB_H_ > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/Include/Register/PttPtpReg= s.h b/Silicon/Intel/AlderlakeSiliconPkg/Include/Register/PttPtpRegs.h > new file mode 100644 > index 00000000..df9905a0 > --- /dev/null > +++ b/Silicon/Intel/AlderlakeSiliconPkg/Include/Register/PttPtpRegs.h > @@ -0,0 +1,26 @@ > +/** @file > + Register definitions for PTT HCI (Platform Trust Technology - Host Con= troller Interface). > + > + Conventions: > + > + - Prefixes: > + Definitions beginning with "R_" are registers > + Definitions beginning with "B_" are bits within registers > + Definitions beginning with "V_" are meaningful values of bits within= the registers > + Definitions beginning with "S_" are register sizes > + Definitions beginning with "N_" are the bit position > + > + Copyright (c) 2023, Intel Corporation. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > +#ifndef _PTT_HCI_REGS_H_ > +#define _PTT_HCI_REGS_H_ > + > +/// > +/// LT public space registers > +/// > +#define R_LT_UCS 0xFED30880 > + > + > +#endif > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/Include/Register/TcoRegs.h= b/Silicon/Intel/AlderlakeSiliconPkg/Include/Register/TcoRegs.h > index c3afcd50..081cf896 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/Include/Register/TcoRegs.h > +++ b/Silicon/Intel/AlderlakeSiliconPkg/Include/Register/TcoRegs.h > @@ -62,6 +62,7 @@ > =20 > #define R_TCO_IO_TCO1_CNT 0x08 > #define S_TCO_IO_TCO1_CNT 2 > +#define B_TCO_IO_TCO1_CNT_TMR_HLT BIT11 > #define N_TCO_IO_TCO1_CNT_NMI2SMI_EN 9 > =20 > #define R_TCO_IO_TCO2_CNT 0x0A > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/IncludePrivate= /Library/SpiCommonLib.h b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Inc= ludePrivate/Library/SpiCommonLib.h > index e13718c9..dc663198 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Librar= y/SpiCommonLib.h > +++ b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Librar= y/SpiCommonLib.h > @@ -7,7 +7,7 @@ > #ifndef _SPI_COMMON_LIB_H_ > #define _SPI_COMMON_LIB_H_ > =20 > -#include > +#include > =20 > // > // Maximum time allowed while waiting the SPI cycle to complete > @@ -49,7 +49,7 @@ typedef enum { > typedef struct { > UINT32 Signature; > EFI_HANDLE Handle; > - PCH_SPI_PROTOCOL SpiProtocol; > + PCH_SPI2_PROTOCOL SpiProtocol; > UINT16 PchAcpiBase; > UINT64 PchSpiBase; > UINT8 ReadPermission; > @@ -157,8 +157,8 @@ IsSpiControllerSaveRestoreEnabled ( > /** > Read data from the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > - @param[in] FlashRegionType The Flash Region type for flash cycle = which is listed in the Descriptor. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle = which corresponds to the type in the descriptor. > @param[in] Address The Flash Linear Address must fall wit= hin a region for which BIOS has access permissions. > @param[in] ByteCount Number of bytes in the data portion of= the SPI cycle. > @param[out] Buffer The Pointer to caller-allocated buffer= containing the dada received. > @@ -171,8 +171,8 @@ IsSpiControllerSaveRestoreEnabled ( > EFI_STATUS > EFIAPI > SpiProtocolFlashRead ( > - IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN PCH_SPI2_PROTOCOL *This, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount, > OUT UINT8 *Buffer > @@ -181,8 +181,8 @@ SpiProtocolFlashRead ( > /** > Write data to the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > - @param[in] FlashRegionType The Flash Region type for flash cycle = which is listed in the Descriptor. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle = which corresponds to the type in the descriptor. > @param[in] Address The Flash Linear Address must fall wit= hin a region for which BIOS has access permissions. > @param[in] ByteCount Number of bytes in the data portion of= the SPI cycle. > @param[in] Buffer Pointer to caller-allocated buffer con= taining the data sent during the SPI cycle. > @@ -194,8 +194,8 @@ SpiProtocolFlashRead ( > EFI_STATUS > EFIAPI > SpiProtocolFlashWrite ( > - IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN PCH_SPI2_PROTOCOL *This, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount, > IN UINT8 *Buffer > @@ -204,8 +204,8 @@ SpiProtocolFlashWrite ( > /** > Erase some area on the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > - @param[in] FlashRegionType The Flash Region type for flash cycle = which is listed in the Descriptor. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle = which corresponds to the type in the descriptor. > @param[in] Address The Flash Linear Address must fall wit= hin a region for which BIOS has access permissions. > @param[in] ByteCount Number of bytes in the data portion of= the SPI cycle. > =20 > @@ -216,8 +216,8 @@ SpiProtocolFlashWrite ( > EFI_STATUS > EFIAPI > SpiProtocolFlashErase ( > - IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN PCH_SPI2_PROTOCOL *This, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount > ); > @@ -225,7 +225,7 @@ SpiProtocolFlashErase ( > /** > Read SFDP data from the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > @param[in] ComponentNumber The Componen Number for chip select > @param[in] Address The starting byte address for SFDP dat= a read. > @param[in] ByteCount Number of bytes in SFDP data portion o= f the SPI cycle > @@ -239,7 +239,7 @@ SpiProtocolFlashErase ( > EFI_STATUS > EFIAPI > SpiProtocolFlashReadSfdp ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINT8 ComponentNumber, > IN UINT32 Address, > IN UINT32 ByteCount, > @@ -249,7 +249,7 @@ SpiProtocolFlashReadSfdp ( > /** > Read Jedec Id from the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > @param[in] ComponentNumber The Componen Number for chip select > @param[in] ByteCount Number of bytes in JedecId data portio= n of the SPI cycle, the data size is 3 typically > @param[out] JedecId The Pointer to caller-allocated buffer= containing JEDEC ID received > @@ -262,7 +262,7 @@ SpiProtocolFlashReadSfdp ( > EFI_STATUS > EFIAPI > SpiProtocolFlashReadJedecId ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINT8 ComponentNumber, > IN UINT32 ByteCount, > OUT UINT8 *JedecId > @@ -271,7 +271,7 @@ SpiProtocolFlashReadJedecId ( > /** > Write the status register in the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > @param[in] ByteCount Number of bytes in Status data portion= of the SPI cycle, the data size is 1 typically > @param[in] StatusValue The Pointer to caller-allocated buffer= containing the value of Status register writing > =20 > @@ -282,7 +282,7 @@ SpiProtocolFlashReadJedecId ( > EFI_STATUS > EFIAPI > SpiProtocolFlashWriteStatus ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINT32 ByteCount, > IN UINT8 *StatusValue > ); > @@ -290,7 +290,7 @@ SpiProtocolFlashWriteStatus ( > /** > Read status register in the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > @param[in] ByteCount Number of bytes in Status data portion= of the SPI cycle, the data size is 1 typically > @param[out] StatusValue The Pointer to caller-allocated buffer= containing the value of Status register received. > =20 > @@ -301,7 +301,7 @@ SpiProtocolFlashWriteStatus ( > EFI_STATUS > EFIAPI > SpiProtocolFlashReadStatus ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINT32 ByteCount, > OUT UINT8 *StatusValue > ); > @@ -309,8 +309,8 @@ SpiProtocolFlashReadStatus ( > /** > Get the SPI region base and size, based on the enum type > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > - @param[in] FlashRegionType The Flash Region type for for the base= address which is listed in the Descriptor. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle = which corresponds to the type in the descriptor. > @param[out] BaseAddress The Flash Linear Address for the Regio= n 'n' Base > @param[out] RegionSize The size for the Region 'n' > =20 > @@ -321,8 +321,8 @@ SpiProtocolFlashReadStatus ( > EFI_STATUS > EFIAPI > SpiProtocolGetRegionAddress ( > - IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN PCH_SPI2_PROTOCOL *This, > + IN EFI_GUID *FlashRegionGuid, > OUT UINT32 *BaseAddress, > OUT UINT32 *RegionSize > ); > @@ -330,7 +330,7 @@ SpiProtocolGetRegionAddress ( > /** > Read PCH Soft Strap Values > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > @param[in] SoftStrapAddr PCH Soft Strap address offset from FPS= BA. > @param[in] ByteCount Number of bytes in SoftStrap data port= ion of the SPI cycle > @param[out] SoftStrapValue The Pointer to caller-allocated buffer= containing PCH Soft Strap Value. > @@ -344,7 +344,7 @@ SpiProtocolGetRegionAddress ( > EFI_STATUS > EFIAPI > SpiProtocolReadPchSoftStrap ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINT32 SoftStrapAddr, > IN UINT32 ByteCount, > OUT VOID *SoftStrapValue > @@ -353,7 +353,7 @@ SpiProtocolReadPchSoftStrap ( > /** > Read CPU Soft Strap Values > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > @param[in] SoftStrapAddr CPU Soft Strap address offset from FCP= USBA. > @param[in] ByteCount Number of bytes in SoftStrap data port= ion of the SPI cycle. > @param[out] SoftStrapValue The Pointer to caller-allocated buffer= containing CPU Soft Strap Value. > @@ -367,7 +367,7 @@ SpiProtocolReadPchSoftStrap ( > EFI_STATUS > EFIAPI > SpiProtocolReadCpuSoftStrap ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINT32 SoftStrapAddr, > IN UINT32 ByteCount, > OUT VOID *SoftStrapValue > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/IncludePrivate= /Register/SpiRegs.h b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Include= Private/Register/SpiRegs.h > index 5cb47911..57e269e1 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Regist= er/SpiRegs.h > +++ b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Regist= er/SpiRegs.h > @@ -62,6 +62,7 @@ > // > // BIOS Flash Program Registers (based on SPI_BAR0) > // > +#define R_SPI_MEM_BFPR 0x00 = ///< BIOS Flash Primary Region Register(32bits), which is RO and contains= the same value from FREG1 > #define R_SPI_MEM_HSFSC 0x04 = ///< Hardware Sequencing Flash Status and Control Register(32bits) > #define B_SPI_MEM_HSFSC_FDBC_MASK 0x3F000000 = ///< Flash Data Byte Count ( <=3D 64), Count =3D (Value in this field) + = 1. > #define N_SPI_MEM_HSFSC_FDBC 24 > @@ -78,12 +79,8 @@ > #define B_SPI_MEM_HSFSC_CYCLE_FGO BIT16 = ///< Flash Cycle Go. > #define B_SPI_MEM_HSFSC_FDV BIT14 = ///< Flash Descriptor Valid, once valid software can use hareware sequenc= ing regs > #define B_SPI_MEM_HSFSC_WRSDIS BIT11 = ///< Write Status Disable > -#define B_SPI_MEM_HSFSC_SAF_CE BIT8 = ///< SAF ctype error > -#define B_SPI_MEM_HSFSC_SAF_LE BIT6 = ///< SAF link error > +#define B_SPI_MEM_HSFSC_SAF_MODE_ACTIVE BIT7 = ///< Indicates flash is attached either directly to the PCH via the SPI b= us or EC/BMC > #define B_SPI_MEM_HSFSC_SCIP BIT5 = ///< SPI cycle in progress > -#define B_SPI_MEM_HSFSC_SAF_DLE BIT4 = ///< SAF Data length error > -#define B_SPI_MEM_HSFSC_SAF_ERROR BIT3 = ///< SAF Error > -#define B_SPI_MEM_HSFSC_AEL BIT2 = ///< Access Error Log > #define B_SPI_MEM_HSFSC_FCERR BIT1 = ///< Flash Cycle Error > #define B_SPI_MEM_HSFSC_FDONE BIT0 = ///< Flash Cycle Done > #define R_SPI_MEM_FADDR 0x08 = ///< SPI Flash Address > @@ -113,4 +110,5 @@ > #define B_SPI_MEM_SFDPX_VSCCX_EO_64K BIT29 = ///< 64k Erase valid (EO_64k_valid) > #define R_SPI_MEM_SFDP1_VSCC1 0xC8 = ///< Vendor Specific Component Capabilities Register(32 bits) > =20 > + > #endif > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library/PeiDxe= SmmSpiAccessLib/PeiDxeSmmSpiAccessLib.inf b/Silicon/Intel/AlderlakeSiliconP= kg/IpBlock/Spi/Library/PeiDxeSmmSpiAccessLib/PeiDxeSmmSpiAccessLib.inf > new file mode 100644 > index 00000000..444c6b34 > --- /dev/null > +++ b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library/PeiDxeSmmSpiA= ccessLib/PeiDxeSmmSpiAccessLib.inf > @@ -0,0 +1,33 @@ > +## @file > +# Component description file for PCH SPI access library > +# > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > + > +[Defines] > +INF_VERSION =3D 0x00010017 > +BASE_NAME =3D PeiDxeSmmSpiAccessLib > +FILE_GUID =3D A6D4C05A-F6CB-46D5-4BA1-8C47B139DCA6 > +VERSION_STRING =3D 1.0 > +MODULE_TYPE =3D BASE > +LIBRARY_CLASS =3D SpiAccessLib > + > + > +[LibraryClasses] > +BaseLib > +IoLib > +DebugLib > +PciSegmentLib > +PchPciBdfLib > +PchPcrLib > + > +[Packages] > +MdePkg/MdePkg.dec > +AlderlakeSiliconPkg/SiPkg.dec > + > + > +[Sources] > +SpiAccessLib.c > \ No newline at end of file > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library/PeiDxe= SmmSpiAccessLib/SpiAccessLib.c b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/= Spi/Library/PeiDxeSmmSpiAccessLib/SpiAccessLib.c > new file mode 100644 > index 00000000..da8475ea > --- /dev/null > +++ b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library/PeiDxeSmmSpiA= ccessLib/SpiAccessLib.c > @@ -0,0 +1,75 @@ > +/** @file > + SPI library for abstraction of SPI HW registers accesses > + > + Copyright (c) 2023, Intel Corporation. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > + > +/** > + Checks if PCH SPI Controler is present and available > + > + @retval TRUE PCH SPI controller is avaialable > + @retval FALSE PCH SPI controller is not available > +**/ > +BOOLEAN > +SpiIsControllerAvailable ( > + VOID > + ) > +{ > + // > + // Checks for SPI controller > + // > + return (PciSegmentRead16 (SpiPciCfgBase () + PCI_VENDOR_ID_OFFSET) != =3D 0xFFFF); > +} > + > +/** > + Returns PCH SPI BAR0 value > + > + @retval UINT32 PCH SPI BAR0 value > +**/ > +UINT32 > +SpiGetBar0 ( > + VOID > + ) > +{ > + UINT32 SpiBar0; > + > + ASSERT (SpiIsControllerAvailable ()); > + SpiBar0 =3D PciSegmentRead32 (SpiPciCfgBase () + R_SPI_CFG_BAR0) & ~B_= SPI_CFG_BAR0_MASK; > + ASSERT (SpiBar0 !=3D 0); > + > + return SpiBar0; > +} > + > +/** > + Checks if device Attached Flash (DAF) mode is active > + > + @retval TRUE SAF mode is active > + @retval FALSE SAF mode is not active > +**/ > +BOOLEAN > +SpiIsSafModeActive ( > + VOID > + ) > +{ > + UINT32 SpiBar0; > + SpiBar0 =3D SpiGetBar0 (); > + > + return !!(MmioRead32 (SpiBar0 + R_SPI_MEM_HSFSC) & B_SPI_MEM_HSFSC_SAF= _MODE_ACTIVE); > +} > \ No newline at end of file > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library/PeiSpi= Lib/PchSpi.c b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library/PeiSpi= Lib/PchSpi.c > index aaf4e179..68031b4a 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library/PeiSpiLib/Pch= Spi.c > +++ b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library/PeiSpiLib/Pch= Spi.c > @@ -9,7 +9,7 @@ > #include > #include > #include > -#include > +#include > #include > #include > #include > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library/PeiSpi= Lib/PeiSpiLib.inf b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library/P= eiSpiLib/PeiSpiLib.inf > index c3bf6d02..e720eed2 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library/PeiSpiLib/Pei= SpiLib.inf > +++ b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Library/PeiSpiLib/Pei= SpiLib.inf > @@ -30,7 +30,7 @@ PchPciBdfLib > [Packages] > MdePkg/MdePkg.dec > AlderlakeSiliconPkg/SiPkg.dec > - > +IntelSiliconPkg/IntelSiliconPkg.dec > =20 > [Sources] > PchSpi.c > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/LibraryPrivate= /BaseSpiCommonLib/BaseSpiCommonLib.inf b/Silicon/Intel/AlderlakeSiliconPkg/= IpBlock/Spi/LibraryPrivate/BaseSpiCommonLib/BaseSpiCommonLib.inf > index 25ab9194..b38e149d 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSp= iCommonLib/BaseSpiCommonLib.inf > +++ b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSp= iCommonLib/BaseSpiCommonLib.inf > @@ -19,11 +19,28 @@ > [Packages] > MdePkg/MdePkg.dec > AlderlakeSiliconPkg/SiPkg.dec > + IntelSiliconPkg/IntelSiliconPkg.dec > =20 > [LibraryClasses] > IoLib > DebugLib > PmcLib > PchPciBdfLib > + SpiAccessLib > =20 > -[Pcd] > +[Guids] > + gFlashRegionDescriptorGuid > + gFlashRegionBiosGuid > + gFlashRegionMeGuid > + gFlashRegionGbeGuid > + gFlashRegionPlatformDataGuid > + gFlashRegionDerGuid > + gFlashRegionSecondaryBiosGuid > + gFlashRegionMicrocodePatchGuid > + gFlashRegionEcGuid > + gFlashRegionDeviceExpansionGuid > + gFlashRegionIeGuid > + gFlashRegion10GbeAGuid > + gFlashRegion10GbeBGuid > + gFlashRegionAllGuid > + gFlashRegionMaxGuid > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/LibraryPrivate= /BaseSpiCommonLib/SpiCommon.c b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/S= pi/LibraryPrivate/BaseSpiCommonLib/SpiCommon.c > index ab51521f..8d1c4785 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSp= iCommonLib/SpiCommon.c > +++ b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSp= iCommonLib/SpiCommon.c > @@ -12,17 +12,137 @@ > #include > #include > #include > -#include > +#include > #include > #include > #include > #include > #include > #include > +#include > =20 > #define DEFAULT_CPU_STRAP_BASE_OFFSET 0x300 // Default CPU Straps base o= ffset > #define B_SPI_MEM_HSFSC_SAVE_MASK (B_SPI_MEM_HSFSC_FDBC_MASK | B_SPI= _MEM_HSFSC_CYCLE_MASK) > =20 > +typedef enum { > + FlashRegionDescriptor, > + FlashRegionBios, > + FlashRegionMe, > + FlashRegionGbe, > + FlashRegionPlatformData, > + FlashRegionDer, > + FlashRegionSecondaryBios, > + FlashRegionMicrocodePatch, > + FlashRegionEc, > + FlashRegionDeviceExpansion, > + FlashRegionIe, > + FlashRegion10GbeA, > + FlashRegion10GbeB, > + FlashRegionAll =3D 16, > + FlashRegionMax > +} FLASH_REGION_TYPE; > + > +typedef struct { > + EFI_GUID *Guid; > + FLASH_REGION_TYPE Type; > +} FLASH_REGION_MAPPING; > + > +FLASH_REGION_MAPPING mFlashRegionTypes[] =3D { > + { > + &gFlashRegionDescriptorGuid, > + FlashRegionDescriptor > + }, > + { > + &gFlashRegionBiosGuid, > + FlashRegionBios > + }, > + { > + &gFlashRegionMeGuid, > + FlashRegionMe > + }, > + { > + &gFlashRegionGbeGuid, > + FlashRegionGbe > + }, > + { > + &gFlashRegionPlatformDataGuid, > + FlashRegionPlatformData > + }, > + { > + &gFlashRegionDerGuid, > + FlashRegionDer > + }, > + { > + &gFlashRegionSecondaryBiosGuid, > + FlashRegionSecondaryBios > + }, > + { > + &gFlashRegionMicrocodePatchGuid, > + FlashRegionMicrocodePatch > + }, > + { > + &gFlashRegionEcGuid, > + FlashRegionEc > + }, > + { > + &gFlashRegionDeviceExpansionGuid, > + FlashRegionDeviceExpansion > + }, > + { > + &gFlashRegionIeGuid, > + FlashRegionIe > + }, > + { > + &gFlashRegion10GbeAGuid, > + FlashRegion10GbeA > + }, > + { > + &gFlashRegion10GbeBGuid, > + FlashRegion10GbeB > + }, > + { > + &gFlashRegionAllGuid, > + FlashRegionAll > + }, > + { > + &gFlashRegionMaxGuid, > + FlashRegionMax > + } > +}; > + > +/** > + Returns the type of a flash region given its GUID. > + > + @param[in] FlashRegionGuid Pointer to the flash region GUID. > + @param[out] FlashRegionType Pointer to a buffer that will be set t= o the flash region type value. > + > + @retval EFI_SUCCESS The flash region type was found = for the given flash region GUID. > + @retval EFI_INVALID_PARAMETER A pointer argument passed to the= function is NULL. > + @retval EFI_NOT_FOUND The flash region type was not fo= und for the given flash region GUID. > + > +**/ > +EFI_STATUS > +GetFlashRegionType ( > + IN EFI_GUID *FlashRegionGuid, > + OUT FLASH_REGION_TYPE *FlashRegionType > + ) > +{ > + UINTN Index; > + > + if (FlashRegionGuid =3D=3D NULL || FlashRegionType =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + for (Index =3D 0; Index < ARRAY_SIZE (mFlashRegionTypes); Index++) { > + if (CompareGuid (mFlashRegionTypes[Index].Guid, FlashRegionGuid)) { > + *FlashRegionType =3D mFlashRegionTypes[Index].Type; > + return EFI_SUCCESS; > + } > + } > + > + return EFI_NOT_FOUND; > +} > + > /** > Initialize an SPI protocol instance. > =20 > @@ -184,7 +304,7 @@ SpiProtocolConstructor ( > // If CPU Strap base address is different than 0x300 need to add MDTBA= value for final location > // > if (SpiInstance->CpuStrapBaseAddr !=3D DEFAULT_CPU_STRAP_BASE_OFFSET) = { > - Status =3D SpiProtocolFlashRead (&(SpiInstance->SpiProtocol), FlashR= egionAll, R_FLASH_UMAP1, sizeof (Data32), (UINT8 *) (&Data32)); > + Status =3D SpiProtocolFlashRead (&(SpiInstance->SpiProtocol), &gFlas= hRegionAllGuid, R_FLASH_UMAP1, sizeof (Data32), (UINT8 *) (&Data32)); > ASSERT_EFI_ERROR (Status); > Mdtba =3D (UINT16)(((Data32 & B_FLASH_UMAP1_MDTBA) >> N_FLASH_UMAP1_= MDTBA) << N_FLASH_UMAP1_MDTBA_REPR); > DEBUG ((DEBUG_INFO, "Mdtba : %0x\n", Mdtba)); > @@ -279,7 +399,7 @@ PchPmTimerStallRuntimeSafe ( > STATIC > BOOLEAN > WaitForSpiCycleComplete ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINTN PchSpiBar0, > IN BOOLEAN ErrorCheck > ) > @@ -317,7 +437,7 @@ WaitForSpiCycleComplete ( > This function waits for a pending SPI transaction to complete without = clearing > status fields > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > @param[in] PchSpiBar0 SPI MMIO address > =20 > @retval TRUE SPI cycle completed on the interface. > @@ -327,7 +447,7 @@ WaitForSpiCycleComplete ( > BOOLEAN > STATIC > WaitForScipNoClear ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINTN PchSpiBar0 > ) > { > @@ -352,87 +472,11 @@ WaitForScipNoClear ( > return FALSE; > } > =20 > -/** > - This function sets the FDONE and optionally FCERR bits in the HSFS_CTL= register > - > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > - @param[in] PchSpiBar0 SPI MMIO address > - @param[in] SetErrorBit Set to TRUE to set the FCERR bit > - > -**/ > -VOID > -STATIC > -SetHsfscFdone ( > - IN PCH_SPI_PROTOCOL *This, > - IN UINTN PchSpiBar0, > - IN BOOLEAN SetFcErrorBit > - ) > -{ > - EFI_STATUS Status; > - UINT32 HardwareSpiAddr; > - UINT32 FlashRegionSize; > - UINT32 Index; > - UINT8 DataCount; > - > - Status =3D SpiProtocolGetRegionAddress (This, FlashRegionBios, &Hardwa= reSpiAddr, &FlashRegionSize); > - if (EFI_ERROR (Status)) { > - return; > - } > - > - // > - // Clear FDONE and FCERR > - // > - MmioWrite8 (PchSpiBar0 + R_SPI_MEM_HSFSC, B_SPI_MEM_HSFSC_FCERR | B_SP= I_MEM_HSFSC_FDONE); > - > - // > - // Fill data buffer > - // > - if (SetFcErrorBit) { > - for (Index =3D 0; Index < 64; Index +=3D sizeof (UINT32)) { > - MmioWrite32 (PchSpiBar0 + R_SPI_MEM_FDATA00 + Index, 0xFFFFFFFF); > - } > - } > - > - // > - // Set the Flash Address > - // > - MmioWrite32 ( > - (PchSpiBar0 + R_SPI_MEM_FADDR), > - (UINT32) (HardwareSpiAddr & B_SPI_MEM_FADDR_MASK) > - ); > - // > - // Set Data count, Flash cycle, and Set Go bit to start a cycle > - // > - if (SetFcErrorBit) { > - DataCount =3D 0x3F; > - } else { > - DataCount =3D 0; > - } > - MmioAndThenOr32 ( > - PchSpiBar0 + R_SPI_MEM_HSFSC, > - (UINT32) (~(B_SPI_MEM_HSFSC_FDBC_MASK | B_SPI_MEM_HSFSC_CYCLE_MASK))= , > - (UINT32) (((DataCount << N_SPI_MEM_HSFSC_FDBC) & B_SPI_MEM_HSFSC_FDB= C_MASK) | > - (V_SPI_MEM_HSFSC_CYCLE_READ << N_SPI_MEM_HSFSC_CYCLE) = | > - B_SPI_MEM_HSFSC_CYCLE_FGO) > - ); > - > - if (SetFcErrorBit) { > - // > - // Intentionally write to FDATA while a cycle is in progress to gene= rate an error > - // > - for (Index =3D 0; Index < 64; Index +=3D sizeof (UINT32)) { > - MmioWrite32 (PchSpiBar0 + R_SPI_MEM_FDATA00 + Index, 0x0); > - } > - } > - > - WaitForScipNoClear (This, PchSpiBar0); > -} > - > /** > This function sends the programmed SPI command to the device. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > - @param[in] SpiRegionType The SPI Region type for flash cycle wh= ich is listed in the Descriptor > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle = which corresponds to the type in the descriptor. > @param[in] FlashCycleType The Flash SPI cycle type list in HSFC = (Hardware Sequencing Flash Control Register) register > @param[in] Address The Flash Linear Address must fall wit= hin a region for which BIOS has access permissions. > @param[in] ByteCount Number of bytes in the data portion of= the SPI cycle. > @@ -446,8 +490,8 @@ SetHsfscFdone ( > STATIC > EFI_STATUS > SendSpiCmd ( > - IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN PCH_SPI2_PROTOCOL *This, > + IN EFI_GUID *FlashRegionGuid, > IN FLASH_CYCLE_TYPE FlashCycleType, > IN UINT32 Address, > IN UINT32 ByteCount, > @@ -564,7 +608,7 @@ SendSpiCmd ( > } > } > =20 > - Status =3D SpiProtocolGetRegionAddress (This, FlashRegionType, &Hardwa= reSpiAddr, &FlashRegionSize); > + Status =3D SpiProtocolGetRegionAddress (This, FlashRegionGuid, &Hardwa= reSpiAddr, &FlashRegionSize); > if (EFI_ERROR (Status)) { > goto SendSpiCmdEnd; > } > @@ -751,31 +795,6 @@ SendSpiCmd ( > } while (ByteCount > 0); > =20 > SendSpiCmdEnd: > - // > - // Restore SPI controller state > - // > - if (RestoreState) { > - if (HsfscFdoneSave) { > - SetHsfscFdone (This, PchSpiBar0, HsfscFcerrSave); > - } > - MmioAndThenOr32 ( > - PchSpiBar0 + R_SPI_MEM_HSFSC, > - (UINT32) ~(B_SPI_MEM_HSFSC_SAVE_MASK | > - B_SPI_MEM_HSFSC_SAF_CE | // This bit clears when = set to 1, ensure 0 is written > - B_SPI_MEM_HSFSC_SAF_LE | // This bit clears when = set to 1, ensure 0 is written > - B_SPI_MEM_HSFSC_SAF_DLE | // This bit clears when = set to 1, ensure 0 is written > - B_SPI_MEM_HSFSC_SAF_ERROR | // This bit clears when = set to 1, ensure 0 is written > - B_SPI_MEM_HSFSC_AEL | // This bit clears when = set to 1, ensure 0 is written > - B_SPI_MEM_HSFSC_FCERR | // This bit clears when = set to 1, ensure 0 is written > - B_SPI_MEM_HSFSC_FDONE), // This bit clears when = set to 1, ensure 0 is written > - HsfscSave > - ); > - MmioWrite32 (PchSpiBar0 + R_SPI_MEM_FADDR, FaddrSave); > - for (Index =3D 0; Index < 64; Index +=3D sizeof (UINT32)) { > - MmioWrite32 (PchSpiBar0 + R_SPI_MEM_FDATA00 + Index, FdataSave[Ind= ex >> 2]); > - } > - } > - > // > // Restore the settings for SPI Prefetching and Caching and enable BIO= S Write Protect > // > @@ -801,8 +820,8 @@ SendSpiCmdEnd: > /** > Read data from the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > - @param[in] FlashRegionType The Flash Region type for flash cycle = which is listed in the Descriptor. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle = which corresponds to the type in the descriptor. > @param[in] Address The Flash Linear Address must fall wit= hin a region for which BIOS has access permissions. > @param[in] ByteCount Number of bytes in the data portion of= the SPI cycle. > @param[out] Buffer The Pointer to caller-allocated buffer= containing the dada received. > @@ -815,8 +834,8 @@ SendSpiCmdEnd: > EFI_STATUS > EFIAPI > SpiProtocolFlashRead ( > - IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN PCH_SPI2_PROTOCOL *This, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount, > OUT UINT8 *Buffer > @@ -829,7 +848,7 @@ SpiProtocolFlashRead ( > // > Status =3D SendSpiCmd ( > This, > - FlashRegionType, > + FlashRegionGuid, > FlashCycleRead, > Address, > ByteCount, > @@ -841,8 +860,8 @@ SpiProtocolFlashRead ( > /** > Write data to the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > - @param[in] FlashRegionType The Flash Region type for flash cycle = which is listed in the Descriptor. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle = which corresponds to the type in the descriptor. > @param[in] Address The Flash Linear Address must fall wit= hin a region for which BIOS has access permissions. > @param[in] ByteCount Number of bytes in the data portion of= the SPI cycle. > @param[in] Buffer Pointer to caller-allocated buffer con= taining the data sent during the SPI cycle. > @@ -854,8 +873,8 @@ SpiProtocolFlashRead ( > EFI_STATUS > EFIAPI > SpiProtocolFlashWrite ( > - IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN PCH_SPI2_PROTOCOL *This, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount, > IN UINT8 *Buffer > @@ -868,7 +887,7 @@ SpiProtocolFlashWrite ( > // > Status =3D SendSpiCmd ( > This, > - FlashRegionType, > + FlashRegionGuid, > FlashCycleWrite, > Address, > ByteCount, > @@ -880,8 +899,8 @@ SpiProtocolFlashWrite ( > /** > Erase some area on the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > - @param[in] FlashRegionType The Flash Region type for flash cycle = which is listed in the Descriptor. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle = which corresponds to the type in the descriptor. > @param[in] Address The Flash Linear Address must fall wit= hin a region for which BIOS has access permissions. > @param[in] ByteCount Number of bytes in the data portion of= the SPI cycle. > =20 > @@ -892,8 +911,8 @@ SpiProtocolFlashWrite ( > EFI_STATUS > EFIAPI > SpiProtocolFlashErase ( > - IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN PCH_SPI2_PROTOCOL *This, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount > ) > @@ -905,7 +924,7 @@ SpiProtocolFlashErase ( > // > Status =3D SendSpiCmd ( > This, > - FlashRegionType, > + FlashRegionGuid, > FlashCycleErase, > Address, > ByteCount, > @@ -917,7 +936,7 @@ SpiProtocolFlashErase ( > /** > Read SFDP data from the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > @param[in] ComponentNumber The Componen Number for chip select > @param[in] Address The starting byte address for SFDP dat= a read. > @param[in] ByteCount Number of bytes in SFDP data portion o= f the SPI cycle > @@ -932,20 +951,53 @@ SpiProtocolFlashErase ( > EFI_STATUS > EFIAPI > SpiProtocolFlashReadSfdp ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINT8 ComponentNumber, > IN UINT32 Address, > IN UINT32 ByteCount, > OUT UINT8 *SfdpData > ) > { > - return EFI_SUCCESS; > + SPI_INSTANCE *SpiInstance; > + EFI_STATUS Status; > + UINT32 FlashAddress; > + > + if (SpiIsSafModeActive ()) { > + DEBUG ((DEBUG_ERROR, "Unallowed call to %a while SAF Mode is active.= \n", __FUNCTION__)); > + return EFI_UNSUPPORTED; > + } > + > + SpiInstance =3D SPI_INSTANCE_FROM_SPIPROTOCOL (This); > + Status =3D EFI_SUCCESS; > + > + if (ComponentNumber > SpiInstance->NumberOfComponents) { > + ASSERT (FALSE); > + return EFI_INVALID_PARAMETER; > + } > + > + FlashAddress =3D 0; > + if (ComponentNumber =3D=3D FlashComponent1) { > + FlashAddress =3D SpiInstance->Component1StartAddr; > + } > + FlashAddress +=3D Address; > + // > + // Sends the command to the SPI interface to execute. > + // > + Status =3D SendSpiCmd ( > + This, > + &gFlashRegionAllGuid, > + FlashCycleReadSfdp, > + FlashAddress, > + ByteCount, > + SfdpData > + ); > + return Status; > } > =20 > /** > Read Jedec Id from the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > @param[in] ComponentNumber The Componen Number for chip select > @param[in] ByteCount Number of bytes in JedecId data portio= n of the SPI cycle, the data size is 3 typically > @param[out] JedecId The Pointer to caller-allocated buffer= containing JEDEC ID received > @@ -959,19 +1011,52 @@ SpiProtocolFlashReadSfdp ( > EFI_STATUS > EFIAPI > SpiProtocolFlashReadJedecId ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINT8 ComponentNumber, > IN UINT32 ByteCount, > OUT UINT8 *JedecId > ) > { > - return EFI_SUCCESS; > + SPI_INSTANCE *SpiInstance; > + EFI_STATUS Status; > + UINT32 Address; > + > + if (SpiIsSafModeActive ()) { > + DEBUG ((DEBUG_ERROR, "Unallowed call to %a while SAF Mode is active.= \n", __FUNCTION__)); > + return EFI_UNSUPPORTED; > + } > + > + SpiInstance =3D SPI_INSTANCE_FROM_SPIPROTOCOL (This); > + Status =3D EFI_SUCCESS; > + > + if (ComponentNumber > SpiInstance->NumberOfComponents) { > + ASSERT (FALSE); > + return EFI_INVALID_PARAMETER; > + } > + > + Address =3D 0; > + if (ComponentNumber =3D=3D FlashComponent1) { > + Address =3D SpiInstance->Component1StartAddr; > + } > + > + // > + // Sends the command to the SPI interface to execute. > + // > + Status =3D SendSpiCmd ( > + This, > + &gFlashRegionAllGuid, > + FlashCycleReadJedecId, > + Address, > + ByteCount, > + JedecId > + ); > + return Status; > } > =20 > /** > Write the status register in the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > @param[in] ByteCount Number of bytes in Status data portion= of the SPI cycle, the data size is 1 typically > @param[in] StatusValue The Pointer to caller-allocated buffer= containing the value of Status register writing > =20 > @@ -983,18 +1068,36 @@ SpiProtocolFlashReadJedecId ( > EFI_STATUS > EFIAPI > SpiProtocolFlashWriteStatus ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINT32 ByteCount, > IN UINT8 *StatusValue > ) > { > - return EFI_SUCCESS; > + EFI_STATUS Status; > + > + if (SpiIsSafModeActive ()) { > + DEBUG ((DEBUG_ERROR, "Unallowed call to %a while SAF Mode is active.= \n", __FUNCTION__)); > + return EFI_UNSUPPORTED; > + } > + > + // > + // Sends the command to the SPI interface to execute. > + // > + Status =3D SendSpiCmd ( > + This, > + &gFlashRegionAllGuid, > + FlashCycleWriteStatus, > + 0, > + ByteCount, > + StatusValue > + ); > + return Status; > } > =20 > /** > Read status register in the flash part. > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > @param[in] ByteCount Number of bytes in Status data portion= of the SPI cycle, the data size is 1 typically > @param[out] StatusValue The Pointer to caller-allocated buffer= containing the value of Status register received. > =20 > @@ -1006,19 +1109,37 @@ SpiProtocolFlashWriteStatus ( > EFI_STATUS > EFIAPI > SpiProtocolFlashReadStatus ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINT32 ByteCount, > OUT UINT8 *StatusValue > ) > { > - return EFI_SUCCESS; > + EFI_STATUS Status; > + > + if (SpiIsSafModeActive ()) { > + DEBUG ((DEBUG_ERROR, "Unallowed call to %a while SAF Mode is active.= \n", __FUNCTION__)); > + return EFI_UNSUPPORTED; > + } > + > + // > + // Sends the command to the SPI interface to execute. > + // > + Status =3D SendSpiCmd ( > + This, > + &gFlashRegionAllGuid, > + FlashCycleReadStatus, > + 0, > + ByteCount, > + StatusValue > + ); > + return Status; > } > =20 > /** > Get the SPI region base and size, based on the enum type > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > - @param[in] FlashRegionType The Flash Region type for for the base= address which is listed in the Descriptor. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle = which corresponds to the type in the descriptor. > @param[out] BaseAddress The Flash Linear Address for the Regio= n 'n' Base > @param[out] RegionSize The size for the Region 'n' > =20 > @@ -1029,18 +1150,24 @@ SpiProtocolFlashReadStatus ( > EFI_STATUS > EFIAPI > SpiProtocolGetRegionAddress ( > - IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN PCH_SPI2_PROTOCOL *This, > + IN EFI_GUID *FlashRegionGuid, > OUT UINT32 *BaseAddress, > OUT UINT32 *RegionSize > ) > { > + EFI_STATUS Status; > + FLASH_REGION_TYPE FlashRegionType; > SPI_INSTANCE *SpiInstance; > UINTN PchSpiBar0; > UINT32 ReadValue; > =20 > SpiInstance =3D SPI_INSTANCE_FROM_SPIPROTOCOL (This); > =20 > + Status =3D GetFlashRegionType (FlashRegionGuid, &FlashRegionType); > + if (EFI_ERROR (Status)) { > + return EFI_INVALID_PARAMETER; > + } > if (FlashRegionType >=3D FlashRegionMax) { > return EFI_INVALID_PARAMETER; > } > @@ -1053,10 +1180,8 @@ SpiProtocolGetRegionAddress ( > =20 > PchSpiBar0 =3D AcquireSpiBar0 (SpiInstance); > =20 > - ReadValue =3D MmioRead32 (PchSpiBar0 + (R_SPI_MEM_FREG0_FLASHD + (S_SP= I_MEM_FREGX * ((UINT32) FlashRegionType)))); > - > ReleaseSpiBar0 (SpiInstance); > - > + ReadValue =3D MmioRead32 (PchSpiBar0 + (R_SPI_MEM_FREG0_FLASHD + (S_SP= I_MEM_FREGX * ((UINT32) FlashRegionType)))); > // > // If the region is not used, the Region Base is 7FFFh and Region Limi= t is 0000h > // > @@ -1077,7 +1202,7 @@ SpiProtocolGetRegionAddress ( > /** > Read PCH Soft Strap Values > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > @param[in] SoftStrapAddr PCH Soft Strap address offset from FPS= BA. > @param[in] ByteCount Number of bytes in SoftStrap data port= ion of the SPI cycle > @param[out] SoftStrapValue The Pointer to caller-allocated buffer= containing PCH Soft Strap Value. > @@ -1091,19 +1216,51 @@ SpiProtocolGetRegionAddress ( > EFI_STATUS > EFIAPI > SpiProtocolReadPchSoftStrap ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINT32 SoftStrapAddr, > IN UINT32 ByteCount, > OUT VOID *SoftStrapValue > ) > { > - return EFI_SUCCESS; > + SPI_INSTANCE *SpiInstance; > + UINT32 StrapFlashAddr; > + EFI_STATUS Status; > + > + SpiInstance =3D SPI_INSTANCE_FROM_SPIPROTOCOL (This); > + > + if (ByteCount =3D=3D 0) { > + *(UINT16 *) SoftStrapValue =3D SpiInstance->PchStrapSize; > + return EFI_SUCCESS; > + } > + > + if ((SoftStrapAddr + ByteCount) > (UINT32) SpiInstance->PchStrapSize) = { > + ASSERT (FALSE); > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // PCH Strap Flash Address =3D FPSBA + RamAddr > + // > + StrapFlashAddr =3D SpiInstance->PchStrapBaseAddr + SoftStrapAddr; > + > + // > + // Read PCH Soft straps from using execute command > + // > + Status =3D SendSpiCmd ( > + This, > + &gFlashRegionDescriptorGuid, > + FlashCycleRead, > + StrapFlashAddr, > + ByteCount, > + SoftStrapValue > + ); > + return Status; > } > =20 > /** > Read CPU Soft Strap Values > =20 > - @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. > + @param[in] This Pointer to the PCH_SPI2_PROTOCOL insta= nce. > @param[in] SoftStrapAddr CPU Soft Strap address offset from FCP= USBA. > @param[in] ByteCount Number of bytes in SoftStrap data port= ion of the SPI cycle. > @param[out] SoftStrapValue The Pointer to caller-allocated buffer= containing CPU Soft Strap Value. > @@ -1117,11 +1274,43 @@ SpiProtocolReadPchSoftStrap ( > EFI_STATUS > EFIAPI > SpiProtocolReadCpuSoftStrap ( > - IN PCH_SPI_PROTOCOL *This, > + IN PCH_SPI2_PROTOCOL *This, > IN UINT32 SoftStrapAddr, > IN UINT32 ByteCount, > OUT VOID *SoftStrapValue > ) > { > - return EFI_SUCCESS; > + SPI_INSTANCE *SpiInstance; > + UINT32 StrapFlashAddr; > + EFI_STATUS Status; > + > + SpiInstance =3D SPI_INSTANCE_FROM_SPIPROTOCOL (This); > + > + if (ByteCount =3D=3D 0) { > + *(UINT16 *) SoftStrapValue =3D SpiInstance->CpuStrapSize; > + return EFI_SUCCESS; > + } > + > + if ((SoftStrapAddr + ByteCount) > (UINT32) SpiInstance->CpuStrapSize) = { > + ASSERT (FALSE); > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // CPU Strap Flash Address =3D FCPUSBA + RamAddr > + // > + StrapFlashAddr =3D SpiInstance->CpuStrapBaseAddr + SoftStrapAddr; > + > + // > + // Read Cpu Soft straps from using execute command > + // > + Status =3D SendSpiCmd ( > + This, > + &gFlashRegionDescriptorGuid, > + FlashCycleRead, > + StrapFlashAddr, > + ByteCount, > + SoftStrapValue > + ); > + return Status; > } > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Smm/Spi.c b/Si= licon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Smm/Spi.c > index 2dd80eba..68190b2b 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Smm/Spi.c > +++ b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Smm/Spi.c > @@ -13,10 +13,11 @@ > #include > #include > #include > -#include > +#include > #include > #include > #include > +#include > #include > #include > #include > @@ -82,8 +83,8 @@ SpiExitBootServicesCallback ( > - Documented in System Management Mode Core Interface Specificatio= n . > =20 > - @result > - The SPI SMM driver produces @link _PCH_SPI_PROTOCOL PCH_SPI_PROTOCOL= @endlink with GUID > - gPchSmmSpiProtocolGuid which is different from SPI RUNTIME driver. > + The SPI SMM driver produces @link _PCH_SPI2_PROTOCOL PCH_SPI2_PROTOC= OL @endlink with GUID > + gPchSmmSpi2ProtocolGuid which is different from SPI RUNTIME driver. > =20 > - Integration Check List\n > - This driver supports Descriptor Mode only. > @@ -163,11 +164,11 @@ InstallPchSpi ( > } > =20 > // > - // Install the SMM PCH_SPI_PROTOCOL interface > + // Install the SMM PCH_SPI2_PROTOCOL interface > // > Status =3D gSmst->SmmInstallProtocolInterface ( > &(mSpiInstance->Handle), > - &gPchSmmSpiProtocolGuid, > + &gPchSmmSpi2ProtocolGuid, > EFI_NATIVE_INTERFACE, > &(mSpiInstance->SpiProtocol) > ); > @@ -303,6 +304,19 @@ DisableBiosWriteProtect ( > B_SPI_CFG_BC_WPD > ); > =20 > + /// > + /// the BIOS Region can only be updated by following the steps bellow: > + /// - Once all threads enter SMM > + /// - Read memory location FED30880h OR with 00000001h, place the res= ult in EAX, > + /// and write data to lower 32 bits of MSR 1FEh (sample code availa= ble) > + /// - Set BIOSWE bit (SPI PCI Offset DCh [0]) =3D 1b > + /// - Modify BIOS Region > + /// - Clear BIOSWE bit (SPI PCI Offset DCh [0]) =3D 0b > + /// > + if ((PciSegmentRead8 (SpiBaseAddress + R_SPI_CFG_BC) & B_SPI_CFG_BC_EI= SS) !=3D 0) { > + PchSetInSmmSts (); > + } > + > return EFI_SUCCESS; > } > =20 > @@ -327,6 +341,12 @@ EnableBiosWriteProtect ( > (UINT8) (~B_SPI_CFG_BC_WPD) > ); > =20 > + /// > + /// Check if EISS bit is set > + /// > + if (((PciSegmentRead8 (SpiBaseAddress + R_SPI_CFG_BC)) & B_SPI_CFG_BC_= EISS) =3D=3D B_SPI_CFG_BC_EISS) { > + PchClearInSmmSts (); > + } > } > =20 > /** > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Smm/SpiSmm.inf= b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Smm/SpiSmm.inf > index 78913423..445f4af8 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Smm/SpiSmm.inf > +++ b/Silicon/Intel/AlderlakeSiliconPkg/IpBlock/Spi/Smm/SpiSmm.inf > @@ -24,19 +24,20 @@ UefiBootServicesTableLib > BaseLib > SmmServicesTableLib > SpiCommonLib > +SmmPchPrivateLib > PchPciBdfLib > =20 > [Packages] > MdePkg/MdePkg.dec > AlderlakeSiliconPkg/SiPkg.dec > - > +IntelSiliconPkg/IntelSiliconPkg.dec > =20 > [Sources] > Spi.c > =20 > =20 > [Protocols] > -gPchSmmSpiProtocolGuid ## PRODUCES > +gPchSmmSpi2ProtocolGuid ## PRODUCES > gEfiSmmCpuProtocolGuid ## CONSUMES > gEdkiiSmmExitBootServicesProtocolGuid ## CONSUMES > =20 > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/Pch/IncludePrivate/Library= /SmmPchPrivateLib.h b/Silicon/Intel/AlderlakeSiliconPkg/Pch/IncludePrivate/= Library/SmmPchPrivateLib.h > new file mode 100644 > index 00000000..63857863 > --- /dev/null > +++ b/Silicon/Intel/AlderlakeSiliconPkg/Pch/IncludePrivate/Library/SmmPch= PrivateLib.h > @@ -0,0 +1,27 @@ > +/** @file > + Header file for private PCH SMM Lib. > + > + Copyright (c) 2023, Intel Corporation. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > +#ifndef _SMM_PCH_PRIVATE_LIB_H_ > +#define _SMM_PCH_PRIVATE_LIB_H_ > + > +/** > + Set InSmm.Sts bit > +**/ > +VOID > +PchSetInSmmSts ( > + VOID > + ); > + > +/** > + Clear InSmm.Sts bit > +**/ > +VOID > +PchClearInSmmSts ( > + VOID > + ); > + > +#endif // _SMM_PCH_PRIVATE_LIB_H_ > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/Pch/LibraryPrivate/SmmPchP= rivateLib/SmmPchPrivateLib.c b/Silicon/Intel/AlderlakeSiliconPkg/Pch/Librar= yPrivate/SmmPchPrivateLib/SmmPchPrivateLib.c > new file mode 100644 > index 00000000..0436a423 > --- /dev/null > +++ b/Silicon/Intel/AlderlakeSiliconPkg/Pch/LibraryPrivate/SmmPchPrivateL= ib/SmmPchPrivateLib.c > @@ -0,0 +1,61 @@ > +/** @file > + PCH SMM private lib. > + > + Copyright (c) 2023, Intel Corporation. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > + > +/** > + Set InSmm.Sts bit > +**/ > +VOID > +PchSetInSmmSts ( > + VOID > + ) > +{ > + UINT32 Data32; > + > + /// > + /// Read memory location FED30880h OR with 00000001h, place the result= in EAX, > + /// and write data to lower 32 bits of MSR 1FEh (sample code available= ) > + /// > + Data32 =3D MmioRead32 (R_LT_UCS); > + AsmWriteMsr32 (MSR_SPCL_CHIPSET_USAGE, Data32 | BIT0); > + /// > + /// Read FED30880h back to ensure the setting went through. > + /// > + Data32 =3D MmioRead32 (R_LT_UCS); > +} > + > +/** > + Clear InSmm.Sts bit > +**/ > +VOID > +PchClearInSmmSts ( > + VOID > + ) > +{ > + UINT32 Data32; > + > + /// > + /// Read memory location FED30880h AND with FFFFFFFEh, place the resul= t in EAX, > + /// and write data to lower 32 bits of MSR 1FEh (sample code available= ) > + /// > + Data32 =3D MmioRead32 (R_LT_UCS); > + AsmWriteMsr32 (MSR_SPCL_CHIPSET_USAGE, Data32 & (UINT32) (~BIT0)); > + /// > + /// Read FED30880h back to ensure the setting went through. > + /// > + Data32 =3D MmioRead32 (R_LT_UCS); > +} > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/Pch/LibraryPrivate/SmmPchP= rivateLib/SmmPchPrivateLib.inf b/Silicon/Intel/AlderlakeSiliconPkg/Pch/Libr= aryPrivate/SmmPchPrivateLib/SmmPchPrivateLib.inf > new file mode 100644 > index 00000000..3c62b9b8 > --- /dev/null > +++ b/Silicon/Intel/AlderlakeSiliconPkg/Pch/LibraryPrivate/SmmPchPrivateL= ib/SmmPchPrivateLib.inf > @@ -0,0 +1,32 @@ > +## @file > +# PCH SMM private lib. > +# > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > + > +[Defines] > +INF_VERSION =3D 0x00010017 > +BASE_NAME =3D SmmPchPrivateLib > +FILE_GUID =3D FE6495FB-7AA9-4A24-BF3E-4698F7BCE0EE > +VERSION_STRING =3D 1.0 > +MODULE_TYPE =3D DXE_SMM_DRIVER > +LIBRARY_CLASS =3D SmmPchPrivateLib > + > + > +[LibraryClasses] > +BaseLib > +IoLib > +DebugLib > +CpuPlatformLib > + > + > +[Packages] > +MdePkg/MdePkg.dec > +AlderlakeSiliconPkg/SiPkg.dec > + > + > +[Sources] > +SmmPchPrivateLib.c > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/Product/Alderlake/SiPkgDxe= Lib.dsc b/Silicon/Intel/AlderlakeSiliconPkg/Product/Alderlake/SiPkgDxeLib.d= sc > index 37876cbf..238473c2 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/Product/Alderlake/SiPkgDxeLib.dsc > +++ b/Silicon/Intel/AlderlakeSiliconPkg/Product/Alderlake/SiPkgDxeLib.dsc > @@ -11,6 +11,11 @@ > !include $(PLATFORM_SI_PACKAGE)/Fru/AdlCpu/DxeLib.dsc > !include $(PLATFORM_SI_PACKAGE)/Fru/AdlPch/DxeLib.dsc > =20 > +# > +# Pch > +# > + SmmPchPrivateLib|$(PLATFORM_SI_PACKAGE)/Pch/LibraryPrivate/SmmPchPrivat= eLib/SmmPchPrivateLib.inf > + > # > # Common > # > diff --git a/Silicon/Intel/AlderlakeSiliconPkg/SiPkg.dec b/Silicon/Intel/= AlderlakeSiliconPkg/SiPkg.dec > index ce9cfe59..aafce7a6 100644 > --- a/Silicon/Intel/AlderlakeSiliconPkg/SiPkg.dec > +++ b/Silicon/Intel/AlderlakeSiliconPkg/SiPkg.dec > @@ -33,6 +33,7 @@ IpBlock/HostBridge/IncludePrivate > =20 > # Cpu > Cpu/IncludePrivate > +Pch/IncludePrivate > =20 > IncludePrivate > =20 > @@ -355,6 +356,7 @@ PchInfoLib|Pch/Include/Library/PchInfoLib.h > PchPcieRpLib|Include/Library/PchPcieRpLib.h > PchPcrLib|Include/Library/PchPcrLib.h > PchSbiAccessLib|IpBlock/P2sb/IncludePrivate/Library/PchSbiAccessLib.h > +SmmPchPrivateLib|Pch/IncludePrivate/Library/SmmPchPrivateLib.h > PchPciBdfLib|Pch/Include/Library/PchPciBdfLib.h > PchRasLib|Pch/Include/Library/PchRasLib.h > PchRtcLib|Pch/Include/Library/PchRtcLib.h > @@ -394,7 +396,7 @@ OcPlatformLib|Include/Library/OcPlatformLib.h > PeiSpsPreMemPolicyLib|Include/Library/PeiSpsPreMemPolicyLib.h > PmcLib|Include/Library/PmcLib.h > PmcSsramLib|Include/Library/PmcSsramLib.h > -SpiLib|Include/Library/SpiLib.h > +SpiAccessLib|Include/Library/SpiAccessLib.h > SpsDxeLib|Include/Library/SpsDxeLib.h > SpsGetDxeConfigBlockLib|Include/Library/SpsGetDxeConfigBlock.h > MeGetPeiConfigBlock|Include/Library/MeGetConfigBlock.h > --=20 > 2.26.2.windows.1 >=20 >=20 >=20 > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#115051): > https://edk2.groups.io/g/devel/message/115051 > Mute This Topic: https://groups.io/mt/104120129/1767664 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub > [nathaniel.l.desimone@intel.com] > -=3D-=3D-=3D-=3D-=3D-=3D >=20 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117508): https://edk2.groups.io/g/devel/message/117508 Mute This Topic: https://groups.io/mt/104120129/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-