From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) by mx.groups.io with SMTP id smtpd.web10.1675.1658535727039696177 for ; Fri, 22 Jul 2022 17:22:07 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kT9H+4pV; spf=pass (domain: gmail.com, ip: 209.85.160.180, mailfrom: benjamin.doron00@gmail.com) Received: by mail-qt1-f180.google.com with SMTP id h22so4655841qta.3 for ; Fri, 22 Jul 2022 17:22:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TSwmDjREr1Bic8SQkmNOgwaKbH+QCG1uQcQgIoMtuko=; b=kT9H+4pVAJ/+XaEGnODRDG/AJDY6FC+TNEJFatpBCz5w8O3TjoDEZFSbFhIZmkEXZo GiDyNnJPL+POvDwJiqNuWPBaCrpSzDpxAZxf9EmBXaSuiz3Ai5YVgNZ4VKb9J8xtgxiP PN/ohcbJ981FiypX9y2OQ8tIsVao3p8VY2hwg9WRoJVElnZoQiHYfk1HF8e5gIAe49mg iC73TtyGlvvtsNp33wUE/D9XxhaA+JcF92jiRZp9I4KfazE0l0tRReKecH0eIDYgdNWo XRFX9X4B6Cvr2I4Yd6h2rkRVCdYx5vA0yztTjcNHThahr2ccCKZVMig2rsAxtyogNR26 Ompw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TSwmDjREr1Bic8SQkmNOgwaKbH+QCG1uQcQgIoMtuko=; b=RiM/TJoCZafk2Yl+olOAnKtbgYVoBp3xcTt/soTOh+kaX0RWhQTiTKYdY6kuf3Yllu xmwp35vDmd8c/o881Iir47ycCXCXAlqmVz8yE0wldvwlwhaDEGk96/u30DdsVMNyLcAu hyJsW2EHHj9owH8NpS7fji07NL6l6ecfZgrUw99fiQSDruY7d0/k8Jc/ADlr1Cec/+ro oyas+OM9afX+7w9zk0CLjBAS6bqIuAx0Mvm81txRBQ2cV4DLbeLOXNTk6YhaF6dI6PYs rEnnrpgwCn0NW+o4JwnZ+JWq+HkqYUoxB6ymKQZmYM94q1KBQY/cUOlrJUBQYrk5HKY6 Epqg== X-Gm-Message-State: AJIora+fd77/7zhApjfY2VSCv/fRzfwLJTNTYy4oncrkmtccLLYIWtmu a8IWPw7835FmlP8b/csIYZLJ8Dd8MVM= X-Google-Smtp-Source: AGRyM1sUelqlC46Gk/ICanVtrndaMkcma+7VWnB1K1ZwHriT/L3xEYsW5svchrxvIPAaFJxp5NdCeg== X-Received: by 2002:a05:622a:4c9:b0:31f:dd6:93cf with SMTP id q9-20020a05622a04c900b0031f0dd693cfmr2251381qtx.665.1658535725850; Fri, 22 Jul 2022 17:22:05 -0700 (PDT) Return-Path: Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:39b7:8453:91b5:69bf]) by smtp.gmail.com with ESMTPSA id z8-20020ac84308000000b0031ee1f0c420sm3766705qtm.10.2022.07.22.17.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 17:22:05 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Nate DeSimone , Ankit Sinha , Ray Ni , Rangasai V Chaganty , Isaac Oram Subject: [PATCH v1 1/5] IntelSiliconPkg/Feature/PeiSmmAccessLibSmramc: Implement chipset support Date: Fri, 22 Jul 2022 20:19:57 -0400 Message-Id: <20220723002001.1309418-2-benjamin.doron00@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220723002001.1309418-1-benjamin.doron00@gmail.com> References: <20220723002001.1309418-1-benjamin.doron00@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable For proper S3 resume support, SMRAM must be opened first. For security purposes, SMRAM lock must be performed. 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 --- Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLibSmr= amc/PeiSmmAccessLib.c | 431 ++++++++++++++++++++ Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLibSmr= amc/PeiSmmAccessLib.inf | 42 ++ 2 files changed, 473 insertions(+) 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..d1cb9b2b0e8c --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessL= ibSmramc/PeiSmmAccessLib.c @@ -0,0 +1,431 @@ +/** @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 + UINT64 Address;=0D + UINT8 SmramControl;=0D + UINTN Index;=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 + UINTN Index;=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..7c2210ce9cdc --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessL= ibSmramc/PeiSmmAccessLib.inf @@ -0,0 +1,42 @@ +## @file=0D +# Library description file for the SmmAccess=0D +#=0D +# Copyright (c) 2019, Intel Corporation. All rights reserved.
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +=0D +[Defines]=0D +INF_VERSION =3D 0x00010017=0D +BASE_NAME =3D PeiSmmAccessLibSmramc=0D +FILE_GUID =3D 54020881-B594-442A-8377-A57AFF98C7CF=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.36.1