From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web08.5642.1624844330885738727 for ; Sun, 27 Jun 2021 18:38:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=jvhtYroK; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: chasel.chiu@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10028"; a="187561144" X-IronPort-AV: E=Sophos;i="5.83,304,1616482800"; d="scan'208";a="187561144" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2021 18:38:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,304,1616482800"; d="scan'208";a="625080196" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by orsmga005.jf.intel.com with ESMTP; 27 Jun 2021 18:38:42 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Sun, 27 Jun 2021 18:38:42 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4 via Frontend Transport; Sun, 27 Jun 2021 18:38:42 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.173) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.4; Sun, 27 Jun 2021 18:38:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BzespqCZsfsQI3WU/nzWTU5EQHArjOjDTO9Xo6fH7u6gsC8Qx4wwwYElFL4jOvpmSk52XkpcU8kgiJ/MappZf8wCE2CnGkTTJdnbPoRNx65ZT7U8woUenTsd0vZjQ0T4EXuVcaZW0yaPyj3YjzqulA2ANiN73bg3F+ZrCgQc4wbEggsyjmFJ5aUvUQR+gFr4U6myv5WB0Ktsy/AkKi8AiDfK3I4UJOCnrft7ETIm0uQXnULbYEPSYtVakz2BmZV296a31o48iZ/xjC9oBsAVhloORvyIBWzmkv32LNCcbiP+lmRdmCzBDhbMdHgW4331ULsr/uZIBAz5Q4jV+G/e9w== 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-SenderADCheck; bh=JA+L3Rog6kViH+8yXuLtxbZAITL1nM+n/v/lkWuhFCk=; b=KjJGGdmYs48+Yt76y1mseFFDxTgC3JnoFbWh+ViGediLZSo8igiZ6XAhnAP8tUfGUdkrKLe+fDGVCS59nFlA/2PMyXeLWpARxwdvCeHbBrUw9Eu8tewekMFRcK5B76CKnpGL2houZi1PLKJ/NwPtvGkpwJ/NP0l0qrWhSscbhQMWM1bDmyUzix2XsIzcdDX5n2TclJslwOhGE4zHsAKpbeSbZGB8bLFBw7WtwIZVkW79VxBI4JjJ6pxasb8MDRMVCXGMJfenfNMKvBcLJhNuTLoAkIM/dZbOewL/v+tcOAFWEOO8fZOhfX5pQpYfbAjnoBJqm/7mv9AXjv90hQMLrQ== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JA+L3Rog6kViH+8yXuLtxbZAITL1nM+n/v/lkWuhFCk=; b=jvhtYroK7GzASRv3GPyyID3TdwjP7Le5057wMxas6mRhwl2V9EPJrbzLj7bUD5Ye3gu5AxK5fTu6vGam1tyMTbPtaa7YsMuj4lek+/CVjYBtoRwJjsoXc3dm1LHYsLSJRf89CqwAF8yQkFxdkmqvGkeDTpXhvShh0YV4jNc2lX0= Received: from BN9PR11MB5483.namprd11.prod.outlook.com (2603:10b6:408:104::10) by BN8PR11MB3572.namprd11.prod.outlook.com (2603:10b6:408:82::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.23; Mon, 28 Jun 2021 01:38:40 +0000 Received: from BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::2162:be61:a479:4168]) by BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::2162:be61:a479:4168%7]) with mapi id 15.20.4264.026; Mon, 28 Jun 2021 01:38:40 +0000 From: "Chiu, Chasel" To: "devel@edk2.groups.io" , "mikuback@linux.microsoft.com" CC: "Chaganty, Rangasai V" , "Desimone, Nathaniel L" Subject: Re: [edk2-devel] [edk2-platforms][PATCH v4 39/41] KabylakeSiliconPkg: Identify flash regions by GUID Thread-Topic: [edk2-devel] [edk2-platforms][PATCH v4 39/41] KabylakeSiliconPkg: Identify flash regions by GUID Thread-Index: AQHXaghQ8UOiQDTtkU+IVqL2rOALoasoqIWg Date: Mon, 28 Jun 2021 01:38:40 +0000 Message-ID: References: <20210625212120.235-1-mikuback@linux.microsoft.com> <20210625212120.235-40-mikuback@linux.microsoft.com> In-Reply-To: <20210625212120.235-40-mikuback@linux.microsoft.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-originating-ip: [114.43.34.211] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b4443ff2-483a-4a23-9dbf-08d939d5752e x-ms-traffictypediagnostic: BN8PR11MB3572: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: S+gWl62SUvZSfAd9CQwWwHoH422tfWk+rnEDCXN6BZErP2QeOBqGJNy7NASlvcK8Q07E3rQxucE1pryrcZhn4BsneJ5C7hOb6UEwQH9AbwXDG1HzbFPjBEuvu9/YbyCyV1XWuVkKdKbpU7xndDV2BL2JYLbzUYlKdbR+Q64QALBtbe+5nw0uSIVpOB+7gzzRWbT6smBhXjtM/kQym6wdR2PXa5UQepLMjb9PPmqpuu4wk2uw/+tN5s1kOZzihk8lkQSbLc4hpHh4P9bTT5hESyu6c0fi6R0PldevXzCEJHPw4KqPMaZzEPndHzTrnMZPlakYuhdOm287CNrsxAzisoQcd0LUs3OC3SEyXL7H43GWDtQwW3mNcKyG75EwKto/bF7v+HEQtUFV+MX2kQaOIC1I03EN0d9eA+OZ3WO4vWh5A9O0WsBeFyTiDH0gf9zQXK21szQj95GCYuUv0Qv/eURFKn8qQCYWbnTglP3rgKqFDyWhzWU3WBTM6EXvEwVvZeE3p5wfhv87cXoqAcreXCJFYpilDoK0rhC2GYv+i4EwQDLHENqSTvzMV4X1v1EvgseZLfZzO5mS7fOTsOZVlOMT0dSlI946MHQ8yJZHmbA77ji4tgnaqLHDeIRfV7jeKo9tEWVMDBPiE+Ugdw/jjAn7CFSckAGsjM1v1m5RIHD/CXrRs0WhBuvUQfOMhtMwhR4KqwdTT9/R0K4KOCXn+0xwSax2iJAf74hnCcFT4YBwJsfIjNkF9ujC533LNSUyNg/0E0vASmw+andlxtz5RiRcutPoeaqmQVS0e/uODDYWAfPP0a9U2AVMIfn2auaH42fPqxM2c4MKIkTqKg9fRpA5qaXw8saM8tStZcXsW8c= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN9PR11MB5483.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(39860400002)(346002)(376002)(136003)(396003)(316002)(7696005)(33656002)(5660300002)(478600001)(66556008)(107886003)(54906003)(64756008)(66476007)(66446008)(83380400001)(52536014)(186003)(66946007)(4326008)(76116006)(26005)(2906002)(53546011)(122000001)(38100700002)(8936002)(8676002)(71200400001)(86362001)(110136005)(45080400002)(55016002)(6506007)(30864003)(966005)(9686003)(11716005)(559001)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ORSD/aI1KjxJuyfmY/EaPgQnCuEICQhl1DxnYkm6yyX7Hb3oi/pxHblDGWex?= =?us-ascii?Q?lXu1Xqo1YuihHEF0fRUNfPUFO6MA09tXmk95se3l0CBxU2G2LbhQHwhL6Hba?= =?us-ascii?Q?HgmoHidqC9Y5MqHY/g01f5f+hM004iuNgprP+niL2GFuFW2OiKlCdgWk3rBV?= =?us-ascii?Q?U1gX+GZXuuZ5CNmIskEdc//Nx9ns89NN/JR7HluVoKis0pIwu7KmvKCXgIn+?= =?us-ascii?Q?E1IeQXwUdXFdTFof36qCYr6acigzbydKCfbnIj7xdcCFBetm8zE1rACN2a+c?= =?us-ascii?Q?F0mQtjvmt3HwG/F+WFIEdHl35kAyCfPtGarrQqAZABb+9BlOHVoNuAnpI7aX?= =?us-ascii?Q?prEDS4e0xk2tS3jlFubfpFuMVOU0hY8coxb0WtIL1Eua1BNRM8bj6jUx31JB?= =?us-ascii?Q?Rl7ZMKkLojcaMA5DTs+zGs8L6xXQPFiVyv2sMevzsdXcfO3znCnCgX5D0HuN?= =?us-ascii?Q?swYnCXn1FPhqlPj6Z+I78xqJl+IqkdOQ/MEX2S1zo8RJBHQgYByGHqZsZc9y?= =?us-ascii?Q?HPKpbJ+/wwizuZT+Yc1VBICp/oCQuBYTlEbYI8YmdRZc5G3JjH4hWyMtsL92?= =?us-ascii?Q?iyCVR5gP08Qa8cfFi2VMhmAjReYWIDXD1tuYbjbE+V6slxh0MuGMAez/ZiBv?= =?us-ascii?Q?4BU5TNicswMvPX39g85ZIDhWyJncDhcIror4gX0n+nL9IfPRBkcS/nu4QKZr?= =?us-ascii?Q?rSiBCi6nC/YFx82TU2w3NQgBJgJHeUOAqNzE4YY57hQztSrFzDDfdDEHDF9X?= =?us-ascii?Q?v4LVMuI9lr9c2ukdUbesOnuC6JI7Gux/JBZWeildGKlH8bzGXWJuT7/W4tbD?= =?us-ascii?Q?JUTzfMlZr0tFvW/sV3TrYzDqA76uyGE+2nQZNys3vuBayQLqa+DFOtVCEPYM?= =?us-ascii?Q?WXw7JQLlC/dFsQ/CtGTOVm2MJTahgCE8JdmtrjEYloBg4qH4tKh5GWOcizHI?= =?us-ascii?Q?KmmzssXaK7CwX4du/fZhdJMFydgTiYEhyaWreRqnQA5vlWuTnO0Czi38ifRL?= =?us-ascii?Q?NACBMl9uhh/d7MmjZKppWwvN25PmFJgOIZ7DXfsGXXLPjicNh06ZZVAmts8O?= =?us-ascii?Q?U91HZ27/OrxDOigIB3ANvsp/ngXXuwQDg99/D7eFs3b/QQaQMUiasQNTeae0?= =?us-ascii?Q?4IIOXanVDMT58RJcWpZWieFQb2LrNzBa4DjfOz3sJ48shKiYeECYxsilOGs4?= =?us-ascii?Q?AmNQNMuEX74Ww5f2mqU0olZBYpZLl7YICvcsjrkvO8WTwCsxercLy7JZXi5s?= =?us-ascii?Q?bIMYOzEW/I8UG5DjF9fId7yLNHSwZa89bnnTCul4KDKRszlS/P8ByHHj9Zaf?= =?us-ascii?Q?newh0Lm0/TToR1jQzTMvZAzA?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN9PR11MB5483.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4443ff2-483a-4a23-9dbf-08d939d5752e X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jun 2021 01:38:40.5098 (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: VN+H17vp2vFIc5Ddif2JWeC19sASnvNbhy/n2+hKtbtIvDy81gU52Ju8EaKuK8VDLQkLp7b94J8a5+Vr5iWhvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR11MB3572 Return-Path: chasel.chiu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Chasel Chiu > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Michael > Kubacki > Sent: Saturday, June 26, 2021 5:21 AM > To: devel@edk2.groups.io > Cc: Chiu, Chasel ; Chaganty, Rangasai V > ; Desimone, Nathaniel L > > Subject: [edk2-devel] [edk2-platforms][PATCH v4 39/41] KabylakeSiliconPkg= : > Identify flash regions by GUID >=20 > From: Michael Kubacki >=20 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3307 >=20 > Updates the code to identify flash regions by GUID and internally map the= GUID > entries to values specific to KabylakeSiliconPkg. >=20 > Cc: Chasel Chiu > Cc: Rangasai V Chaganty > Cc: Nate DeSimone > Signed-off-by: Michael Kubacki > Reviewed-by: Chasel Chiu > --- > Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/SecureMemoryMapConfiguration.c > | 106 ++++++++++++++- >=20 > Silicon/Intel/KabylakeSiliconPkg/Pch/LibraryPrivate/BasePchSpiCommonLib/S= piC > ommon.c | 140 ++++++++++++++++---- > Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/HstiSiliconDxe.inf > | 9 ++ >=20 > Silicon/Intel/KabylakeSiliconPkg/Pch/IncludePrivate/Library/PchSpiCommonL= ib. > h | 20 +-- >=20 > Silicon/Intel/KabylakeSiliconPkg/Pch/LibraryPrivate/BasePchSpiCommonLib/B= as > ePchSpiCommonLib.inf | 11 ++ > 5 files changed, 247 insertions(+), 39 deletions(-) >=20 > diff --git > a/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/SecureMemoryMapConfiguration.= c > b/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/SecureMemoryMapConfiguration.= c > index a3c9bbebeaa9..ccf63b216f70 100644 > --- > a/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/SecureMemoryMapConfiguration.= c > +++ b/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/SecureMemoryMapConfigura > +++ tion.c > @@ -2,11 +2,14 @@ > This file contains the tests for the SecureMemoryMapConfiguration bit >=20 > Copyright (c) 2017, Intel Corporation. All rights reserved.
> +Copyright (c) Microsoft Corporation.
> + > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ >=20 > #include "HstiSiliconDxe.h" > +#include >=20 > typedef struct { > UINT64 Base; > @@ -100,6 +103,90 @@ MEMORY_RANGE > mNonLockableMemoryRange[NonLockableMemoryRangeMax] =3D { // 14. > SPI_BAR0 (BDF 0:31:5 + 0x10) }; >=20 > +typedef enum { > + FlashRegionDescriptor, > + FlashRegionBios, > + FlashRegionMe, > + FlashRegionGbe, > + FlashRegionPlatformData, > + FlashRegionDer, > + FlashRegionAll, > + 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 > + }, > + { > + &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; > +} > + > /** > Check for overlaps in single range array >=20 > @@ -224,7 +311,7 @@ AcquireSpiBar0 ( > { > UINT32 SpiBar0; > UINTN PchSpiBase; > - > + > // > // Init PCH spi reserved MMIO address. > // > @@ -270,7 +357,7 @@ ReleaseSpiBar0 ( > 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] FlashRegionGuid The Flash Region GUID for the base add= ress > 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 > @@ -281,13 +368,20 @@ ReleaseSpiBar0 ( > EFI_STATUS > EFIAPI > GetRegionAddress ( > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > OUT UINT32 *BaseAddress, > OUT UINT32 *RegionSize > ) > { > - UINTN PchSpiBar0; > - UINT32 ReadValue; > + EFI_STATUS Status; > + FLASH_REGION_TYPE FlashRegionType; > + UINTN PchSpiBar0; > + UINT32 ReadValue; > + > + Status =3D GetFlashRegionType (FlashRegionGuid, &FlashRegionType); if > + (EFI_ERROR (Status)) { > + return EFI_INVALID_PARAMETER; > + } >=20 > if (FlashRegionType >=3D FlashRegionMax) { > return EFI_INVALID_PARAMETER; > @@ -484,7 +578,7 @@ CheckSecureMemoryMapConfiguration ( > // > // Locate BIOS region size to update High bios base address > // > - GetRegionAddress (FlashRegionBios, &BaseAddress, &RegionSize); > + GetRegionAddress (&gFlashRegionBiosGuid, &BaseAddress, > + &RegionSize); > DEBUG ((DEBUG_INFO, "Bios Region Size %x:\n", RegionSize)); > mLockableMemoryRange[LockableMemoryRangeHighBios].Base =3D SIZE_4GB > - RegionSize; > mLockableMemoryRange[LockableMemoryRangeLowDram].End =3D > (MmioRead32 (MmPciBase (0,SA_MC_DEV,SA_MC_FUN) + R_SA_TOLUD) & > B_SA_TOLUD_TOLUD_MASK) - 1; diff --git > a/Silicon/Intel/KabylakeSiliconPkg/Pch/LibraryPrivate/BasePchSpiCommonLib= /S > piCommon.c > b/Silicon/Intel/KabylakeSiliconPkg/Pch/LibraryPrivate/BasePchSpiCommonLib= /S > piCommon.c > index 58757a8cba39..d2eb8324bf58 100644 > --- > a/Silicon/Intel/KabylakeSiliconPkg/Pch/LibraryPrivate/BasePchSpiCommonLib= /S > piCommon.c > +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/LibraryPrivate/BasePchSpiComm > +++ onLib/SpiCommon.c > @@ -2,10 +2,13 @@ > PCH SPI Common Driver implements the SPI Host Controller Compatibility > Interface. >=20 > Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
> +Copyright (c) Microsoft Corporation.
> + > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ > #include > +#include > #include > #include > #include > @@ -16,6 +19,90 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include > #include >=20 > +typedef enum { > + FlashRegionDescriptor, > + FlashRegionBios, > + FlashRegionMe, > + FlashRegionGbe, > + FlashRegionPlatformData, > + FlashRegionDer, > + FlashRegionAll, > + 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 > + }, > + { > + &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 > @@ -249,7 +336,7 @@ PchPmTimerStallRuntimeSafe ( > 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] 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. > @@ -263,7 +350,7 @@ EFI_STATUS > EFIAPI > SpiProtocolFlashRead ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount, > OUT UINT8 *Buffer > @@ -276,7 +363,7 @@ SpiProtocolFlashRead ( > // > Status =3D SendSpiCmd ( > This, > - FlashRegionType, > + FlashRegionGuid, > FlashCycleRead, > Address, > ByteCount, > @@ -289,7 +376,7 @@ 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] 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. > @@ -302,7 +389,7 @@ EFI_STATUS > EFIAPI > SpiProtocolFlashWrite ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount, > IN UINT8 *Buffer > @@ -315,7 +402,7 @@ SpiProtocolFlashWrite ( > // > Status =3D SendSpiCmd ( > This, > - FlashRegionType, > + FlashRegionGuid, > FlashCycleWrite, > Address, > ByteCount, > @@ -328,7 +415,7 @@ 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] 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 > @@ -340,7 +427,7 @@ EFI_STATUS > EFIAPI > SpiProtocolFlashErase ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount > ) > @@ -352,7 +439,7 @@ SpiProtocolFlashErase ( > // > Status =3D SendSpiCmd ( > This, > - FlashRegionType, > + FlashRegionGuid, > FlashCycleErase, > Address, > ByteCount, > @@ -407,7 +494,7 @@ SpiProtocolFlashReadSfdp ( > // > Status =3D SendSpiCmd ( > This, > - FlashRegionAll, > + &gFlashRegionAllGuid, > FlashCycleReadSfdp, > FlashAddress, > ByteCount, > @@ -460,7 +547,7 @@ SpiProtocolFlashReadJedecId ( > // > Status =3D SendSpiCmd ( > This, > - FlashRegionAll, > + &gFlashRegionAllGuid, > FlashCycleReadJedecId, > Address, > ByteCount, > @@ -495,7 +582,7 @@ SpiProtocolFlashWriteStatus ( > // > Status =3D SendSpiCmd ( > This, > - FlashRegionAll, > + &gFlashRegionAllGuid, > FlashCycleWriteStatus, > 0, > ByteCount, > @@ -530,7 +617,7 @@ SpiProtocolFlashReadStatus ( > // > Status =3D SendSpiCmd ( > This, > - FlashRegionAll, > + &gFlashRegionAllGuid, > FlashCycleReadStatus, > 0, > ByteCount, > @@ -543,7 +630,7 @@ 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] FlashRegionGuid The Flash Region GUID for the base add= ress > 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 > @@ -555,17 +642,24 @@ EFI_STATUS > EFIAPI > SpiProtocolGetRegionAddress ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > OUT UINT32 *BaseAddress, > OUT UINT32 *RegionSize > ) > { > - SPI_INSTANCE *SpiInstance; > - UINTN PchSpiBar0; > - UINT32 ReadValue; > + 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; > } > @@ -646,7 +740,7 @@ SpiProtocolReadPchSoftStrap ( > // > Status =3D SendSpiCmd ( > This, > - FlashRegionDescriptor, > + &gFlashRegionDescriptorGuid, > FlashCycleRead, > StrapFlashAddr, > ByteCount, > @@ -704,7 +798,7 @@ SpiProtocolReadCpuSoftStrap ( > // > Status =3D SendSpiCmd ( > This, > - FlashRegionDescriptor, > + &gFlashRegionDescriptorGuid, > FlashCycleRead, > StrapFlashAddr, > ByteCount, > @@ -717,7 +811,7 @@ SpiProtocolReadCpuSoftStrap ( > This function sends the programmed SPI command to the slave 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] 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. > @@ -731,7 +825,7 @@ SpiProtocolReadCpuSoftStrap ( EFI_STATUS > SendSpiCmd ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN FLASH_CYCLE_TYPE FlashCycleType, > IN UINT32 Address, > IN UINT32 ByteCount, > @@ -795,7 +889,7 @@ SendSpiCmd ( > goto SendSpiCmdEnd; > } >=20 > - Status =3D SpiProtocolGetRegionAddress (This, FlashRegionType, > &HardwareSpiAddr, &FlashRegionSize); > + Status =3D SpiProtocolGetRegionAddress (This, FlashRegionGuid, > + &HardwareSpiAddr, &FlashRegionSize); > if (EFI_ERROR (Status)) { > goto SendSpiCmdEnd; > } > diff --git a/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/HstiSiliconDxe.inf > b/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/HstiSiliconDxe.inf > index bd12fa691d40..09826cdfdf39 100644 > --- a/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/HstiSiliconDxe.inf > +++ b/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/HstiSiliconDxe.inf > @@ -2,6 +2,7 @@ > # Component description file for Hsti Silicon Driver # # Copyright (c= ) 2017, > Intel Corporation. All rights reserved.
> +# Copyright (c) Microsoft Corporation.
> # > # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -86,6 +87,14 @@ > [LibraryClasses] [Guids] > gEfiEndOfDxeEventGroupGuid > gSiMemoryPlatformDataGuid ## CONSUMES > + gFlashRegionDescriptorGuid > + gFlashRegionBiosGuid > + gFlashRegionMeGuid > + gFlashRegionGbeGuid > + gFlashRegionPlatformDataGuid > + gFlashRegionDerGuid > + gFlashRegionAllGuid > + gFlashRegionMaxGuid >=20 > [Protocols] > gEfiDxeSmmReadyToLockProtocolGuid ## CONSUMES diff --git > a/Silicon/Intel/KabylakeSiliconPkg/Pch/IncludePrivate/Library/PchSpiCommo= nLi > b.h > b/Silicon/Intel/KabylakeSiliconPkg/Pch/IncludePrivate/Library/PchSpiCommo= nLi > b.h > index d408289ea253..fd991de96016 100644 > --- > a/Silicon/Intel/KabylakeSiliconPkg/Pch/IncludePrivate/Library/PchSpiCommo= nLi > b.h > +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/IncludePrivate/Library/PchSpi > +++ CommonLib.h > @@ -134,7 +134,7 @@ ReleaseSpiBar0 ( > 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] 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. > @@ -148,7 +148,7 @@ EFI_STATUS > EFIAPI > SpiProtocolFlashRead ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount, > OUT UINT8 *Buffer > @@ -158,7 +158,7 @@ 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] 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. > @@ -171,7 +171,7 @@ EFI_STATUS > EFIAPI > SpiProtocolFlashWrite ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount, > IN UINT8 *Buffer > @@ -181,7 +181,7 @@ 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] 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 > @@ -193,7 +193,7 @@ EFI_STATUS > EFIAPI > SpiProtocolFlashErase ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount > ); > @@ -286,7 +286,7 @@ 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] 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 > @@ -298,7 +298,7 @@ EFI_STATUS > EFIAPI > SpiProtocolGetRegionAddress ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > OUT UINT32 *BaseAddress, > OUT UINT32 *RegionSize > ); > @@ -353,7 +353,7 @@ SpiProtocolReadCpuSoftStrap ( > This function sends the programmed SPI command to the slave 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] 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. > @@ -367,7 +367,7 @@ SpiProtocolReadCpuSoftStrap ( EFI_STATUS > SendSpiCmd ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN FLASH_CYCLE_TYPE FlashCycleType, > IN UINT32 Address, > IN UINT32 ByteCount, > diff --git > a/Silicon/Intel/KabylakeSiliconPkg/Pch/LibraryPrivate/BasePchSpiCommonLib= /B > asePchSpiCommonLib.inf > b/Silicon/Intel/KabylakeSiliconPkg/Pch/LibraryPrivate/BasePchSpiCommonLib= /B > asePchSpiCommonLib.inf > index 51e2d25a7f8b..67176c879de5 100644 > --- > a/Silicon/Intel/KabylakeSiliconPkg/Pch/LibraryPrivate/BasePchSpiCommonLib= /B > asePchSpiCommonLib.inf > +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/LibraryPrivate/BasePchSpiComm > +++ onLib/BasePchSpiCommonLib.inf > @@ -2,6 +2,7 @@ > # Component description file for the PchSpiCommonLib # # Copyright (c= ) 2017 > - 2020 Intel Corporation. All rights reserved.
> +# Copyright (c) Microsoft Corporation.
> # > # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -28,3 +29,13 @@ > [LibraryClasses] > IoLib > DebugLib > PchCycleDecodingLib > + > +[Guids] > + gFlashRegionDescriptorGuid > + gFlashRegionBiosGuid > + gFlashRegionMeGuid > + gFlashRegionGbeGuid > + gFlashRegionPlatformDataGuid > + gFlashRegionDerGuid > + gFlashRegionAllGuid > + gFlashRegionMaxGuid > -- > 2.28.0.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 (#77136): https://edk2.groups.io/g/devel/message/77136 > Mute This Topic: https://groups.io/mt/83794828/1777047 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [chasel.chiu@intel.com] > -=3D-=3D-=3D-=3D-=3D-=3D >=20