From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) by mx.groups.io with SMTP id smtpd.web08.3375.1661805421708539112 for ; Mon, 29 Aug 2022 13:37:01 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mAucnWz3; spf=pass (domain: gmail.com, ip: 209.85.219.52, mailfrom: benjamin.doron00@gmail.com) Received: by mail-qv1-f52.google.com with SMTP id jy14so1433121qvb.12 for ; Mon, 29 Aug 2022 13:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=CQSFEeAc7AobmXSQWtYByQMdTnDpn3redrqiKKcNKtw=; b=mAucnWz3OCB8FqaR7IIvwZwADC9sRGZX75nVg10kZDn0ja5JBcAqXYh/EBUtXrX3fI F34LMfNNpbd/ud5GxFxeEnmwXD5rhE1BKOVzW45uS0e2kjmWtL9M5vnJ3FNDJ6f8VHmf JR5Otp/O3ehKdf+c8i2YYdwFSnVnLslNIPsTzYGTgvrX9JEm0rNoS5g0IDYs3PJQpRnF 1XvrZ2jDJlrsPTEAceMn5FWB6en1+Qg+Q69iUdGw2T9aP8BuhiObI3prSTy2nFW3q3Ea qLmic4vox3A03/hb/lXIxApyGEkuHsKdfyxOQMZxJrQgYvzclMytkxs4VAHtNs//NhmZ Dd8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=CQSFEeAc7AobmXSQWtYByQMdTnDpn3redrqiKKcNKtw=; b=6ng91TzQ+MQEwrwWzu0KM7cqTbueN+XX5qCIot8Bv/uuqEPexQZg/KF3qnvDTQ7al/ ejwTJcPZelk5y1sESHhBQmnFmKQhhdmI9w6Lb0kMtca3y7dYeSfvMdPQOTxLuWvJX8ez JEM3GfOtiWX+Z9DzlEBlkwLHjCPuXZdrW3f7j46kEsq+ZMNE1t4ca5E1vA69hApIEhwG 9xsKelZCHc2eIaJS4+Ay0YS+L1s5ga2x1kZwHNnsJfvuCF11wSpfoAEiiZRlwqs06TtF dNYly5nNDfFFqK89IrNIcI+0DIlrDHsYQuM0x4eJup6NdsfMArEMcEb02BgPr4k66p24 W40w== X-Gm-Message-State: ACgBeo2N1IfB886dYJxWTvjoQ+qHf4tKmCCQ1olGxB6sr608GKLevhdZ zSfLyDu2F+FYcewaGBVXswCVDJVtiYM0rA== X-Google-Smtp-Source: AA6agR6+60tUhCurwNVNbo1Hdxa6w7Dxn0/6VxmnQpRjAhy4G5keb9jvcxeP1iKqJpr47B+383qI2A== X-Received: by 2002:a05:6214:3010:b0:496:e381:e33 with SMTP id ke16-20020a056214301000b00496e3810e33mr12326125qvb.2.1661805420378; Mon, 29 Aug 2022 13:37:00 -0700 (PDT) Return-Path: Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:da1:4180:8030:1a92]) by smtp.gmail.com with ESMTPSA id bp6-20020a05620a458600b006bbda80595asm6846218qkb.5.2022.08.29.13.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 13:36:59 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Nate DeSimone , Ankit Sinha , Ray Ni , Rangasai V Chaganty , Isaac Oram Subject: [edk2-devel][edk2-platforms][PATCH v1 1/5] IntelSiliconPkg/Feature/PeiSmmAccessLibSmramc: Implement chipset support Date: Mon, 29 Aug 2022 16:36:16 -0400 Message-Id: X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable SMRAM must be opened to retrieve the lockbox for S3, and SMM communication depends on this PPI. For security purposes, SMRAM lock must be performed before EndOfPei (although FSP notify performs lockdown too). It seems to me that this library is generic and applicable to all Intel platforms in the tree using the MCH SMRAMC register. Cc: Nate DeSimone Cc: Ankit Sinha Cc: Ray Ni Cc: Rangasai V Chaganty Cc: Isaac Oram Signed-off-by: Benjamin Doron --- .../PeiSmmAccessLibSmramc/PeiSmmAccessLib.c | 430 ++++++++++++++++++ .../PeiSmmAccessLibSmramc/PeiSmmAccessLib.inf | 41 ++ 2 files changed, 471 insertions(+) create mode 100644 Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library= /PeiSmmAccessLibSmramc/PeiSmmAccessLib.c create mode 100644 Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library= /PeiSmmAccessLibSmramc/PeiSmmAccessLib.inf diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmm= AccessLibSmramc/PeiSmmAccessLib.c b/Silicon/Intel/IntelSiliconPkg/Feature/S= mmAccess/Library/PeiSmmAccessLibSmramc/PeiSmmAccessLib.c new file mode 100644 index 000000000000..5b472bf86abf --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessL= ibSmramc/PeiSmmAccessLib.c @@ -0,0 +1,430 @@ +/** @file=0D + This is to publish the SMM Access Ppi instance.=0D +=0D + Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#include =0D +#include =0D +=0D +#define SMM_ACCESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('4', '5', 's', 'a'= )=0D +=0D +///=0D +/// Private data=0D +///=0D +typedef struct {=0D + UINTN Signature;=0D + EFI_HANDLE Handle;=0D + EFI_PEI_MM_ACCESS_PPI SmmAccess;=0D + //=0D + // Local Data for SMM Access interface goes here=0D + //=0D + UINTN NumberRegions;=0D + EFI_SMRAM_DESCRIPTOR *SmramDesc;=0D +} SMM_ACCESS_PRIVATE_DATA;=0D +=0D +#define SMM_ACCESS_PRIVATE_DATA_FROM_THIS(a) \=0D + CR (a, \=0D + SMM_ACCESS_PRIVATE_DATA, \=0D + SmmAccess, \=0D + SMM_ACCESS_PRIVATE_DATA_SIGNATURE \=0D + )=0D +=0D +//=0D +// Common registers:=0D +//=0D +// DEVICE 0 (Memory Controller Hub)=0D +//=0D +#define SA_MC_BUS 0x00=0D +#define SA_MC_DEV 0x00=0D +#define SA_MC_FUN 0x00=0D +///=0D +/// Description:=0D +/// The SMRAMC register controls how accesses to Compatible SMRAM spaces = are treated. The Open, Close and Lock bits function only when G_SMRAME bit= is set to 1. Also, the Open bit must be reset before the Lock bit is set.= =0D +///=0D +#define R_SA_SMRAMC (0x88)=0D +#define B_SA_SMRAMC_D_LCK_MASK (0x10)=0D +#define B_SA_SMRAMC_D_CLS_MASK (0x20)=0D +#define B_SA_SMRAMC_D_OPEN_MASK (0x40)=0D +=0D +/**=0D + This routine accepts a request to "open" a region of SMRAM. The=0D + region could be legacy ABSEG, HSEG, or TSEG near top of physical memory.= =0D + The use of "open" means that the memory is visible from all PEIM=0D + and SMM agents.=0D +=0D + @param[in] PeiServices - General purpose services available to = every PEIM.=0D + @param[in] This - Pointer to the SMM Access Interface.=0D + @param[in] DescriptorIndex - Region of SMRAM to Open.=0D +=0D + @retval EFI_SUCCESS - The region was successfully opened.=0D + @retval EFI_DEVICE_ERROR - The region could not be opened because= locked by=0D + chipset.=0D + @retval EFI_INVALID_PARAMETER - The descriptor index was out of bounds= .=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +Open (=0D + IN EFI_PEI_SERVICES **PeiServices,=0D + IN EFI_PEI_MM_ACCESS_PPI *This,=0D + IN UINTN DescriptorIndex=0D + )=0D +{=0D + SMM_ACCESS_PRIVATE_DATA *SmmAccess;=0D + UINT8 Index;=0D + UINT64 Address;=0D + UINT8 SmramControl;=0D +=0D + SmmAccess =3D SMM_ACCESS_PRIVATE_DATA_FROM_THIS (This);=0D + if (DescriptorIndex >=3D SmmAccess->NumberRegions) {=0D + DEBUG ((DEBUG_WARN, "SMRAM region out of range\n"));=0D +=0D + return EFI_INVALID_PARAMETER;=0D + } else if (SmmAccess->SmramDesc[DescriptorIndex].RegionState & EFI_SMRAM= _LOCKED) {=0D + //=0D + // Cannot open a "locked" region=0D + //=0D + DEBUG ((DEBUG_WARN, "Cannot open a locked SMRAM region\n"));=0D +=0D + return EFI_DEVICE_ERROR;=0D + }=0D +=0D + ///=0D + /// BEGIN CHIPSET CODE=0D + ///=0D + ///=0D + /// SMRAM register is PCI 0:0:0:88, SMRAMC (8 bit)=0D + ///=0D + Address =3D PCI_SEGMENT_LIB_ADDRESS (0, SA_MC_BUS, SA_MC_DEV, SA_MC_FUN,= R_SA_SMRAMC);=0D + SmramControl =3D PciSegmentRead8 (Address);=0D + ///=0D + /// Is SMRAM locked?=0D + ///=0D + if ((SmramControl & B_SA_SMRAMC_D_LCK_MASK) !=3D 0) {=0D + ///=0D + /// Cannot Open a locked region=0D + ///=0D + for (Index =3D 0; Index < SmmAccess->NumberRegions; Index++) {=0D + SmmAccess->SmramDesc[Index].RegionState |=3D EFI_SMRAM_LOCKED;=0D + }=0D + DEBUG ((DEBUG_WARN, "Cannot open a locked SMRAM region\n"));=0D + return EFI_DEVICE_ERROR;=0D + }=0D + ///=0D + /// Open SMRAM region=0D + ///=0D + SmramControl |=3D B_SA_SMRAMC_D_OPEN_MASK;=0D + SmramControl &=3D ~(B_SA_SMRAMC_D_CLS_MASK);=0D +=0D + PciSegmentWrite8 (Address, SmramControl);=0D + ///=0D + /// END CHIPSET CODE=0D + ///=0D +=0D + SmmAccess->SmramDesc[DescriptorIndex].RegionState &=3D (UINT64) ~(EFI_SM= RAM_CLOSED | EFI_ALLOCATED);=0D + SmmAccess->SmramDesc[DescriptorIndex].RegionState |=3D (UINT64) EFI_SMRA= M_OPEN;=0D + SmmAccess->SmmAccess.OpenState =3D TRUE;=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + This routine accepts a request to "close" a region of SMRAM. This is va= lid for=0D + compatible SMRAM region.=0D +=0D + @param[in] PeiServices - General purpose services available to = every PEIM.=0D + @param[in] This - Pointer to the SMM Access Interface.=0D + @param[in] DescriptorIndex - Region of SMRAM to Close.=0D +=0D + @retval EFI_SUCCESS - The region was successfully closed.=0D + @retval EFI_DEVICE_ERROR - The region could not be closed because= locked by=0D + chipset.=0D + @retval EFI_INVALID_PARAMETER - The descriptor index was out of bounds= .=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +Close (=0D + IN EFI_PEI_SERVICES **PeiServices,=0D + IN EFI_PEI_MM_ACCESS_PPI *This,=0D + IN UINTN DescriptorIndex=0D + )=0D +{=0D + SMM_ACCESS_PRIVATE_DATA *SmmAccess;=0D + BOOLEAN OpenState;=0D + UINT8 Index;=0D + UINT64 Address;=0D + UINT8 SmramControl;=0D +=0D + SmmAccess =3D SMM_ACCESS_PRIVATE_DATA_FROM_THIS (This);=0D + if (DescriptorIndex >=3D SmmAccess->NumberRegions) {=0D + DEBUG ((DEBUG_WARN, "SMRAM region out of range\n"));=0D +=0D + return EFI_INVALID_PARAMETER;=0D + } else if (SmmAccess->SmramDesc[DescriptorIndex].RegionState & EFI_SMRAM= _LOCKED) {=0D + //=0D + // Cannot close a "locked" region=0D + //=0D + DEBUG ((DEBUG_WARN, "Cannot close a locked SMRAM region\n"));=0D +=0D + return EFI_DEVICE_ERROR;=0D + }=0D +=0D + if (SmmAccess->SmramDesc[DescriptorIndex].RegionState & EFI_SMRAM_CLOSED= ) {=0D + return EFI_DEVICE_ERROR;=0D + }=0D +=0D + ///=0D + /// BEGIN CHIPSET CODE=0D + ///=0D + ///=0D + /// SMRAM register is PCI 0:0:0:88, SMRAMC (8 bit)=0D + ///=0D + Address =3D PCI_SEGMENT_LIB_ADDRESS (0, SA_MC_BUS, SA_MC_DEV, SA_MC_FUN,= R_SA_SMRAMC);=0D + SmramControl =3D PciSegmentRead8 (Address);=0D + ///=0D + /// Is SMRAM locked?=0D + ///=0D + if ((SmramControl & B_SA_SMRAMC_D_LCK_MASK) !=3D 0) {=0D + ///=0D + /// Cannot Close a locked region=0D + ///=0D + for (Index =3D 0; Index < SmmAccess->NumberRegions; Index++) {=0D + SmmAccess->SmramDesc[Index].RegionState |=3D EFI_SMRAM_LOCKED;=0D + }=0D + DEBUG ((DEBUG_WARN, "Cannot close a locked SMRAM region\n"));=0D + return EFI_DEVICE_ERROR;=0D + }=0D + ///=0D + /// Close SMRAM region=0D + ///=0D + SmramControl &=3D ~(B_SA_SMRAMC_D_OPEN_MASK);=0D +=0D + PciSegmentWrite8 (Address, SmramControl);=0D + ///=0D + /// END CHIPSET CODE=0D + ///=0D +=0D + SmmAccess->SmramDesc[DescriptorIndex].RegionState &=3D (UINT64) ~EFI_SMR= AM_OPEN;=0D + SmmAccess->SmramDesc[DescriptorIndex].RegionState |=3D (UINT64) (EFI_SMR= AM_CLOSED | EFI_ALLOCATED);=0D +=0D + //=0D + // Find out if any regions are still open=0D + //=0D + OpenState =3D FALSE;=0D + for (Index =3D 0; Index < SmmAccess->NumberRegions; Index++) {=0D + if ((SmmAccess->SmramDesc[Index].RegionState & EFI_SMRAM_OPEN) =3D=3D = EFI_SMRAM_OPEN) {=0D + OpenState =3D TRUE;=0D + }=0D + }=0D +=0D + SmmAccess->SmmAccess.OpenState =3D OpenState;=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + This routine accepts a request to "lock" SMRAM. The=0D + region could be legacy AB or TSEG near top of physical memory.=0D + The use of "lock" means that the memory can no longer be opened=0D + to PEIM.=0D +=0D + @param[in] PeiServices - General purpose services available to e= very PEIM.=0D + @param[in] This - Pointer to the SMM Access Interface.=0D + @param[in] DescriptorIndex - Region of SMRAM to Lock.=0D +=0D + @retval EFI_SUCCESS - The region was successfully locked.=0D + @retval EFI_DEVICE_ERROR - The region could not be locked because= at least=0D + one range is still open.=0D + @retval EFI_INVALID_PARAMETER - The descriptor index was out of bounds= .=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +Lock (=0D + IN EFI_PEI_SERVICES **PeiServices,=0D + IN EFI_PEI_MM_ACCESS_PPI *This,=0D + IN UINTN DescriptorIndex=0D + )=0D +{=0D + SMM_ACCESS_PRIVATE_DATA *SmmAccess;=0D + UINT64 Address;=0D + UINT8 SmramControl;=0D +=0D + SmmAccess =3D SMM_ACCESS_PRIVATE_DATA_FROM_THIS (This);=0D + if (DescriptorIndex >=3D SmmAccess->NumberRegions) {=0D + DEBUG ((DEBUG_WARN, "SMRAM region out of range\n"));=0D +=0D + return EFI_INVALID_PARAMETER;=0D + } else if (SmmAccess->SmmAccess.OpenState) {=0D + DEBUG ((DEBUG_WARN, "Cannot lock SMRAM when SMRAM regions are still op= en\n"));=0D +=0D + return EFI_DEVICE_ERROR;=0D + }=0D +=0D + SmmAccess->SmramDesc[DescriptorIndex].RegionState |=3D (UINT64) EFI_SMRA= M_LOCKED;=0D + SmmAccess->SmmAccess.LockState =3D TRUE;=0D +=0D + ///=0D + /// BEGIN CHIPSET CODE=0D + ///=0D + ///=0D + /// SMRAM register is PCI 0:0:0:88, SMRAMC (8 bit)=0D + ///=0D + Address =3D PCI_SEGMENT_LIB_ADDRESS (0, SA_MC_BUS, SA_MC_DEV, SA_MC_FUN,= R_SA_SMRAMC);=0D + SmramControl =3D PciSegmentRead8 (Address);=0D +=0D + ///=0D + /// Lock the SMRAM=0D + ///=0D + SmramControl |=3D B_SA_SMRAMC_D_LCK_MASK;=0D +=0D + PciSegmentWrite8 (Address, SmramControl);=0D + ///=0D + /// END CHIPSET CODE=0D + ///=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + This routine services a user request to discover the SMRAM=0D + capabilities of this platform. This will report the possible=0D + ranges that are possible for SMRAM access, based upon the=0D + memory controller capabilities.=0D +=0D + @param[in] PeiServices - General purpose services available to ev= ery PEIM.=0D + @param[in] This - Pointer to the SMRAM Access Interface.= =0D + @param[in, out] SmramMapSize - Pointer to the variable containing size= of the=0D + buffer to contain the description infor= mation.=0D + @param[in, out] SmramMap - Buffer containing the data describing t= he Smram=0D + region descriptors.=0D +=0D + @retval EFI_BUFFER_TOO_SMALL - The user did not provide a sufficient b= uffer.=0D + @retval EFI_SUCCESS - The user provided a sufficiently-sized = buffer.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +GetCapabilities (=0D + IN EFI_PEI_SERVICES **PeiServices,=0D + IN EFI_PEI_MM_ACCESS_PPI *This,=0D + IN OUT UINTN *SmramMapSize,=0D + IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap=0D + )=0D +{=0D + EFI_STATUS Status;=0D + SMM_ACCESS_PRIVATE_DATA *SmmAccess;=0D + UINTN NecessaryBufferSize;=0D +=0D + SmmAccess =3D SMM_ACCESS_PRIVATE_DATA_FROM_THIS (This);=0D + NecessaryBufferSize =3D SmmAccess->NumberRegions * sizeof (EFI_SMRAM_DES= CRIPTOR);=0D + if (*SmramMapSize < NecessaryBufferSize) {=0D + DEBUG ((DEBUG_WARN, "SMRAM Map Buffer too small\n"));=0D +=0D + Status =3D EFI_BUFFER_TOO_SMALL;=0D + } else {=0D + CopyMem (SmramMap, SmmAccess->SmramDesc, NecessaryBufferSize);=0D + Status =3D EFI_SUCCESS;=0D + }=0D +=0D + *SmramMapSize =3D NecessaryBufferSize;=0D + return Status;=0D +}=0D +=0D +/**=0D + This function is to install an SMM Access PPI=0D + - Introduction \n=0D + An API to install an instance of EFI_PEI_MM_ACCESS_PPI. This PPI is co= mmonly used to control SMM mode memory access for S3 resume.=0D +=0D + @retval EFI_SUCCESS - Ppi successfully started and installed= .=0D + @retval EFI_NOT_FOUND - Ppi can't be found.=0D + @retval EFI_OUT_OF_RESOURCES - Ppi does not have enough resources to = initialize the driver.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +PeiInstallSmmAccessPpi (=0D + VOID=0D + )=0D +{=0D + EFI_STATUS Status;=0D + UINTN Index;=0D + EFI_PEI_PPI_DESCRIPTOR *PpiList;=0D + EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *DescriptorBlock;=0D + SMM_ACCESS_PRIVATE_DATA *SmmAccessPrivate;=0D + VOID *HobList;=0D +=0D + //=0D + // Initialize private data=0D + //=0D + SmmAccessPrivate =3D AllocateZeroPool (sizeof (*SmmAccessPrivate));=0D + ASSERT (SmmAccessPrivate !=3D NULL);=0D + if (SmmAccessPrivate =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D + PpiList =3D AllocateZeroPool (sizeof (*PpiList));=0D + ASSERT (PpiList !=3D NULL);=0D + if (PpiList =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + SmmAccessPrivate->Signature =3D SMM_ACCESS_PRIVATE_DATA_SIGNATURE;=0D + SmmAccessPrivate->Handle =3D NULL;=0D +=0D + //=0D + // Get Hob list=0D + //=0D + HobList =3D GetFirstGuidHob (&gEfiSmmSmramMemoryGuid);=0D + if (HobList =3D=3D NULL) {=0D + DEBUG ((DEBUG_WARN, "SmramMemoryReserve HOB not found\n"));=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + DescriptorBlock =3D (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *) ((UINT8 *) HobLis= t + sizeof (EFI_HOB_GUID_TYPE));=0D +=0D + //=0D + // Alloc space for SmmAccessPrivate->SmramDesc=0D + //=0D + SmmAccessPrivate->SmramDesc =3D AllocateZeroPool ((DescriptorBlock->Numb= erOfSmmReservedRegions) * sizeof (EFI_SMRAM_DESCRIPTOR));=0D + if (SmmAccessPrivate->SmramDesc =3D=3D NULL) {=0D + DEBUG ((DEBUG_WARN, "Alloc SmmAccessPrivate->SmramDesc fail.\n"));=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + DEBUG ((DEBUG_INFO, "Alloc SmmAccessPrivate->SmramDesc success.\n"));=0D +=0D + //=0D + // use the hob to publish SMRAM capabilities=0D + //=0D + for (Index =3D 0; Index < DescriptorBlock->NumberOfSmmReservedRegions; I= ndex++) {=0D + SmmAccessPrivate->SmramDesc[Index].PhysicalStart =3D DescriptorBlock-= >Descriptor[Index].PhysicalStart;=0D + SmmAccessPrivate->SmramDesc[Index].CpuStart =3D DescriptorBlock-= >Descriptor[Index].CpuStart;=0D + SmmAccessPrivate->SmramDesc[Index].PhysicalSize =3D DescriptorBlock-= >Descriptor[Index].PhysicalSize;=0D + SmmAccessPrivate->SmramDesc[Index].RegionState =3D DescriptorBlock-= >Descriptor[Index].RegionState;=0D + }=0D +=0D + SmmAccessPrivate->NumberRegions =3D Index;=0D + SmmAccessPrivate->SmmAccess.Open =3D Open;=0D + SmmAccessPrivate->SmmAccess.Close =3D Close;=0D + SmmAccessPrivate->SmmAccess.Lock =3D Lock;=0D + SmmAccessPrivate->SmmAccess.GetCapabilities =3D GetCapabilities;=0D + SmmAccessPrivate->SmmAccess.LockState =3D FALSE;=0D + SmmAccessPrivate->SmmAccess.OpenState =3D FALSE;=0D +=0D + //=0D + // Install PPI=0D + //=0D + PpiList->Flags =3D (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR= _TERMINATE_LIST);=0D + PpiList->Guid =3D &gEfiPeiMmAccessPpiGuid;=0D + PpiList->Ppi =3D &SmmAccessPrivate->SmmAccess;=0D +=0D + Status =3D PeiServicesInstallPpi (PpiList);=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmm= AccessLibSmramc/PeiSmmAccessLib.inf b/Silicon/Intel/IntelSiliconPkg/Feature= /SmmAccess/Library/PeiSmmAccessLibSmramc/PeiSmmAccessLib.inf new file mode 100644 index 000000000000..916346aacff3 --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessL= ibSmramc/PeiSmmAccessLib.inf @@ -0,0 +1,41 @@ +## @file=0D +# Library description file for the SmmAccess PPI=0D +#=0D +# Copyright (c) 2019, Intel Corporation. All rights reserved.
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D +INF_VERSION =3D 0x00010017=0D +BASE_NAME =3D PeiSmmAccessLibSmramc=0D +FILE_GUID =3D 3D28FD4B-F46F-4E24-88AA-9DA09C51BE87=0D +VERSION_STRING =3D 1.0=0D +MODULE_TYPE =3D PEIM=0D +LIBRARY_CLASS =3D SmmAccessLib=0D +=0D +=0D +[LibraryClasses]=0D +BaseMemoryLib=0D +MemoryAllocationLib=0D +DebugLib=0D +HobLib=0D +PciSegmentLib=0D +PeiServicesLib=0D +=0D +=0D +[Packages]=0D +MdePkg/MdePkg.dec=0D +IntelSiliconPkg/IntelSiliconPkg.dec=0D +=0D +=0D +[Sources]=0D +PeiSmmAccessLib.c=0D +=0D +=0D +[Ppis]=0D +gEfiPeiMmAccessPpiGuid ## PRODUCES=0D +=0D +=0D +[Guids]=0D +gEfiSmmSmramMemoryGuid=0D --=20 2.37.2