From nobody Tue May 14 10:07:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93255+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93255+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1662483766; cv=none; d=zohomail.com; s=zohoarc; b=HjXjsIUj0OSoTRl6QL54je52ey4/o3aqDtgXssvgAS7IkrzQXmouIr0UQ9ddzfqiThwnD+ii4kDPxM+3KJe7YS38qpE63H5B2Ovjm2tQZUalHmY/Slj0qpswYJy0HEbjr1D7j7TOysTHN2Ksu8idzSgwp0hazAYqtGp4tvE69uQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662483766; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=KUjA8Zhx9CuzCOh79Jfg8K5ouFSQrCYNKz5TTul4RGc=; b=hbnsxmJPjpbzIcQuvANu1bBC2g0Tsqbxvp4hw3WuQTXhXeA3+o4WHlF+6hmlhnOxamGrDwIOfgEgUNE/Dj3k7HvNol/vgfGgHZXASzSnrqnZmAkbOdzs5hln7IzxKfMq8If7YWMCzNVpfyeZ7ziagxIbFWHIrkFzIwpTpIaNNFs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93255+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1662483766665554.2968753175941; Tue, 6 Sep 2022 10:02:46 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id U6tZYY1788612xFjKGPJSEYh; Tue, 06 Sep 2022 10:02:46 -0700 X-Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by mx.groups.io with SMTP id smtpd.web10.1843.1662483765564695111 for ; Tue, 06 Sep 2022 10:02:45 -0700 X-Received: by mail-qk1-f172.google.com with SMTP id a10so8607438qkl.13 for ; Tue, 06 Sep 2022 10:02:45 -0700 (PDT) X-Gm-Message-State: 5qDIf27tnkwOOJ0AH6haaI1xx1787277AA= X-Google-Smtp-Source: AA6agR5vLndkn0I5TQp8y+Rjqn3/j7o1hb9GukBrfoYCVnyvXJJNj7jXKsgQs51DS0jo3mG+4ZqXfg== X-Received: by 2002:a05:620a:2408:b0:6bb:d31d:cb64 with SMTP id d8-20020a05620a240800b006bbd31dcb64mr35511020qkn.343.1662483763025; Tue, 06 Sep 2022 10:02:43 -0700 (PDT) X-Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:46bc:db07:bbf3:df6d]) by smtp.gmail.com with ESMTPSA id bi13-20020a05620a318d00b006b59f02224asm10895809qkb.60.2022.09.06.10.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:02:42 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Rangasai V Chaganty , Isaac Oram , Nate DeSimone , Ankit Sinha , Ray Ni , Chasel Chiu , Heng Luo Subject: [edk2-devel][edk2-platforms][PATCH v2 1/6] {Platform,Silicon}/Intel: Move PcdAcpiBaseAddress definition Date: Tue, 6 Sep 2022 13:02:23 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,benjamin.doron00@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662483766; bh=Bu1SB7g4DWu0PhzDFdY+/iED9dJk0fO7RpzrBOabsMQ=; h=Cc:Date:From:Reply-To:Subject:To; b=BZruO9OM0aajBG2uU28w2f9CzM4z+sPDew4x2fLOoN1761BzYreBDeIEqxv6yo5CARM AEJuvgicDho9ED+Tku9uy1Qz0VT/TT1wecnyPwc3Pz0e3iOYVDzrMonD6KhUh84y5xtyX FtIuoGhF8dnnGkFme7ZcOFIZk//pHxAZ6GU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662483767370100001 Content-Type: text/plain; charset="utf-8" All these platforms have an ABase, so move the definition to enable common silicon code in IntelSiliconPkg. Otherwise, library shims would be required, because PCDs are GUID-ed and package DEC specific. Cc: Rangasai V Chaganty Cc: Isaac Oram Cc: Nate DeSimone Cc: Ankit Sinha Cc: Ray Ni Cc: Chasel Chiu Cc: Sai Chaganty Cc: Heng Luo Signed-off-by: Benjamin Doron Reviewed-by: Isaac Oram Reviewed-by: Sai Chaganty --- .../CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkgPcd.dsc | 1 + .../Features/Tbt/TbtInit/Smm/TbtSmm.inf | 2 +- .../AspireVn7Dash572G/OpenBoardPkgPcd.dsc | 1 + .../KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Smm/TbtSmm.inf | 2 +- .../Library/BasePlatformHookLib/BasePlatformHookLib.inf | 2 +- .../KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc | 1 + .../Library/BasePlatformHookLib/BasePlatformHookLib.inf | 2 +- .../KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc | 1 + .../TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkgPcd.dsc | 1 + .../Features/Tbt/TbtInit/Smm/TbtSmm.inf | 2 +- .../WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkgPcd.dsc | 1 + .../WhiskeylakeURvp/OpenBoardPkgPcd.dsc | 1 + Silicon/Intel/CoffeelakeSiliconPkg/CoffeelakeSiliconPkg.dsc | 1 + .../Library/PeiSiliconInitLib/PeiSiliconInitLib.inf | 5 +++-- .../Pch/Library/PeiDxeSmmPmcLib/PeiDxeSmmPmcLib.inf | 3 ++- .../PeiDxeSmmPmcPrivateLib/PeiDxeSmmPmcPrivateLibCnl.inf | 2 +- Silicon/Intel/CoffeelakeSiliconPkg/SiPkg.dec | 1 - Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec | 4 ++++ Silicon/Intel/KabylakeSiliconPkg/KabylakeSiliconPkg.dsc | 1 + .../Library/PeiSiliconInitLib/PeiSiliconInitLib.inf | 2 +- .../Pch/Library/PeiDxeSmmPchPmcLib/PeiDxeSmmPchPmcLib.inf | 3 ++- .../Pch/Library/PeiPchPolicyLib/PeiPchPolicyLib.inf | 2 +- .../KabylakeSiliconPkg/Pch/Library/PeiSpiLib/PeiSpiLib.inf | 2 +- Silicon/Intel/KabylakeSiliconPkg/SiPkg.dec | 1 - .../IpBlock/Pmc/Library/PeiDxeSmmPmcLib/PeiDxeSmmPmcLib.inf | 3 ++- .../PeiDxeSmmPmcPrivateLib/PeiDxeSmmPmcPrivateLibVer2.inf | 3 ++- Silicon/Intel/TigerlakeSiliconPkg/SiPkg.dec | 1 - Silicon/Intel/TigerlakeSiliconPkg/TigerlakeSiliconPkg.dsc | 1 + 28 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPk= gPcd.dsc b/Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkgP= cd.dsc index 79924f1fda7f..81dc0747fab8 100644 --- a/Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkgPcd.dsc @@ -65,6 +65,7 @@ =20 gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000 gMinPlatformPkgTokenSpaceGuid.PcdPciExpressRegionLength|0x10000000 + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress|0x1800 # # PCIe Reserved Memory Space Range # diff --git a/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Smm/= TbtSmm.inf b/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Smm/= TbtSmm.inf index e3fdd3981653..c4dd863c3ee8 100644 --- a/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Smm/TbtSmm.= inf +++ b/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Smm/TbtSmm.= inf @@ -49,7 +49,7 @@ gMinPlatformPkgTokenSpaceGuid.PcdPciExpressRegionLength ## CONSUMES =20 [FixedPcd] - gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUMES + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUMES =20 [Sources] TbtSmiHandler.h diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoar= dPkgPcd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoa= rdPkgPcd.dsc index a4ea524e26bc..3ed7aa0a2b10 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd= .dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd= .dsc @@ -241,6 +241,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries|140 !endif gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000 + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress|0x1800 =20 gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdBrowserFieldTextColor|0x01 diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Smm/T= btSmm.inf b/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Smm/Tb= tSmm.inf index e6c185a4bd91..13116488eaa0 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Smm/TbtSmm.i= nf +++ b/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Smm/TbtSmm.i= nf @@ -46,7 +46,7 @@ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdSwSmiDTbtEnumerate ## CONSUMES =20 [FixedPcd] - gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUMES + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUMES =20 [Sources] TbtSmiHandler.h diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BasePla= tformHookLib/BasePlatformHookLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/= GalagoPro3/Library/BasePlatformHookLib/BasePlatformHookLib.inf index 1de10aa0080f..5f65f02a9f64 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BasePlatformHo= okLib/BasePlatformHookLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BasePlatformHo= okLib/BasePlatformHookLib.inf @@ -35,7 +35,7 @@ KabylakeSiliconPkg/SiPkg.dec =20 [Pcd] - gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSU= MES + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSU= MES gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLpcSioIndexPort ## CONSU= MES gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLpcSioDataPort ## CONSU= MES gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLpcSioIndexDefaultPort ## CONSU= MES diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd= .dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc index c6b9df842936..ec23c691b2fe 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc @@ -194,6 +194,7 @@ gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07 !endif gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000 + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress|0x1800 !if gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable =3D=3D TRUE gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0x1 !endif diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BaseP= latformHookLib/BasePlatformHookLib.inf b/Platform/Intel/KabylakeOpenBoardPk= g/KabylakeRvp3/Library/BasePlatformHookLib/BasePlatformHookLib.inf index 7a5e290657f2..8bdf13b1ce11 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BasePlatform= HookLib/BasePlatformHookLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BasePlatform= HookLib/BasePlatformHookLib.inf @@ -35,7 +35,7 @@ KabylakeSiliconPkg/SiPkg.dec =20 [Pcd] - gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSU= MES + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSU= MES gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLpcSioIndexPort ## CONSU= MES gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLpcSioDataPort ## CONSU= MES gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLpcSioIndexDefaultPort ## CONSU= MES diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgP= cd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.d= sc index 2f7765e58a69..cfd032814850 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc @@ -194,6 +194,7 @@ gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07 !endif gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000 + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress|0x1800 !if gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable =3D=3D TRUE gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0x1 !endif diff --git a/Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPk= gPcd.dsc b/Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkgP= cd.dsc index 2fd6d0c50e05..2fb2e1ce58f4 100644 --- a/Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkgPcd.dsc @@ -117,6 +117,7 @@ #!if gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection =3D=3D 1 gMinPlatformPkgTokenSpaceGuid.PcdPciExpressRegionLength|0x10000000 #!endif + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress|0x1800 gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize|0x40000 =20 # diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Sm= m/TbtSmm.inf b/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/= Smm/TbtSmm.inf index bfe299d73374..83ebc790aeb4 100644 --- a/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Smm/TbtSm= m.inf +++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Smm/TbtSm= m.inf @@ -49,7 +49,7 @@ gMinPlatformPkgTokenSpaceGuid.PcdPciExpressRegionLength ## CONSUMES =20 [FixedPcd] - gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUMES + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUMES =20 [Sources] TbtSmiHandler.h diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkgPc= d.dsc b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkgPcd.dsc index a7e9a41e2c34..dbe068d0c123 100644 --- a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkgPcd.dsc @@ -65,6 +65,7 @@ =20 gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000 gMinPlatformPkgTokenSpaceGuid.PcdPciExpressRegionLength|0x10000000 + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress|0x1800 =20 [PcdsFeatureFlag.common] ###################################### diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoa= rdPkgPcd.dsc b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenB= oardPkgPcd.dsc index daf5411ac358..451926d67190 100644 --- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkgPc= d.dsc +++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkgPc= d.dsc @@ -65,6 +65,7 @@ =20 gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000 gMinPlatformPkgTokenSpaceGuid.PcdPciExpressRegionLength|0x10000000 + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress|0x1800 =20 [PcdsFeatureFlag.common] ###################################### diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/CoffeelakeSiliconPkg.dsc b/= Silicon/Intel/CoffeelakeSiliconPkg/CoffeelakeSiliconPkg.dsc index c5f10492edc8..e62e37cda036 100644 --- a/Silicon/Intel/CoffeelakeSiliconPkg/CoffeelakeSiliconPkg.dsc +++ b/Silicon/Intel/CoffeelakeSiliconPkg/CoffeelakeSiliconPkg.dsc @@ -42,6 +42,7 @@ gSiPkgTokenSpaceGuid.PcdSiCatalogDebugEnable |FAL= SE [PcdsFixedAtBuild.common] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress |0xE0000000 gSiPkgTokenSpaceGuid.PcdTemporaryPciExpressRegionLength |0x10000000 +gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress |0x1800 =20 gSiPkgTokenSpaceGuid.PcdSiliconInitTempPciBusMin |10 gSiPkgTokenSpaceGuid.PcdSiliconInitTempPciBusMax |18 diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/Library/PeiSiliconInitLib/P= eiSiliconInitLib.inf b/Silicon/Intel/CoffeelakeSiliconPkg/Library/PeiSilico= nInitLib/PeiSiliconInitLib.inf index 1534a24dd240..432d4c0c2656 100644 --- a/Silicon/Intel/CoffeelakeSiliconPkg/Library/PeiSiliconInitLib/PeiSilic= onInitLib.inf +++ b/Silicon/Intel/CoffeelakeSiliconPkg/Library/PeiSiliconInitLib/PeiSilic= onInitLib.inf @@ -32,6 +32,7 @@ =20 [Packages] MdePkg/MdePkg.dec + IntelSiliconPkg/IntelSiliconPkg.dec CoffeelakeSiliconPkg/SiPkg.dec =20 [Sources] @@ -42,5 +43,5 @@ gTcoWdtHobGuid ## CONSUMES =20 [Pcd] - gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUMES - gSiPkgTokenSpaceGuid.PcdTcoBaseAddress ## CONSUMES + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUMES + gSiPkgTokenSpaceGuid.PcdTcoBaseAddress ## CONSUMES diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/PeiDxeSmmPmcLib= /PeiDxeSmmPmcLib.inf b/Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/PeiDx= eSmmPmcLib/PeiDxeSmmPmcLib.inf index 78e212eeb0fd..61778ed5a066 100644 --- a/Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/PeiDxeSmmPmcLib/PeiDxe= SmmPmcLib.inf +++ b/Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/PeiDxeSmmPmcLib/PeiDxe= SmmPmcLib.inf @@ -32,11 +32,12 @@ BaseMemoryLib =20 [Packages] MdePkg/MdePkg.dec +IntelSiliconPkg/IntelSiliconPkg.dec CoffeelakeSiliconPkg/SiPkg.dec =20 =20 [Pcd] -gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress +gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress =20 =20 [Sources] diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/Private/PeiDxeS= mmPmcPrivateLib/PeiDxeSmmPmcPrivateLibCnl.inf b/Silicon/Intel/CoffeelakeSil= iconPkg/Pch/Library/Private/PeiDxeSmmPmcPrivateLib/PeiDxeSmmPmcPrivateLibCn= l.inf index 573acfc25e31..1f84337afafb 100644 --- a/Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/Private/PeiDxeSmmPmcPr= ivateLib/PeiDxeSmmPmcPrivateLibCnl.inf +++ b/Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/Private/PeiDxeSmmPmcPr= ivateLib/PeiDxeSmmPmcPrivateLibCnl.inf @@ -39,7 +39,7 @@ CoffeelakeSiliconPkg/SiPkg.dec IntelSiliconPkg/IntelSiliconPkg.dec =20 [Pcd] -gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress +gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress =20 =20 [Sources] diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SiPkg.dec b/Silicon/Intel/C= offeelakeSiliconPkg/SiPkg.dec index efc2d8788168..ca3e83bd61da 100644 --- a/Silicon/Intel/CoffeelakeSiliconPkg/SiPkg.dec +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SiPkg.dec @@ -516,7 +516,6 @@ gSiPkgTokenSpaceGuid.PcdMchBaseAddress|0xFED10000|UINT6= 4|0x00010030 ## This value is used to set the base address of PCH devices gSiPkgTokenSpaceGuid.PcdSmbusBaseAddress|0x0000EFA0|UINT16|0x00010031 gSiPkgTokenSpaceGuid.PcdTcoBaseAddress|0x0400|UINT16|0x00010034 -gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress|0x1800|UINT16|0x00010035 =20 ## 32KB window gSiPkgTokenSpaceGuid.PcdMchMmioSize|0x8000|UINT32|0x50000000 diff --git a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec b/Silicon/In= tel/IntelSiliconPkg/IntelSiliconPkg.dec index c36d130a0197..deefdc55b5d6 100644 --- a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec +++ b/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec @@ -147,6 +147,10 @@ # @Prompt Error code for VTd error. gIntelSiliconPkgTokenSpaceGuid.PcdErrorCodeVTdError|0x02008000|UINT32|0x= 00000005 =20 + ## ABase I/O address.

+ # @Prompt ABase I/O address. + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress|0x0|UINT16|0x0000000D + [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] ## This is the GUID of the FFS which contains the Graphics Video BIOS Ta= ble (VBT) # The VBT content is stored as a RAW section which is consumed by GOP PE= I/UEFI driver. diff --git a/Silicon/Intel/KabylakeSiliconPkg/KabylakeSiliconPkg.dsc b/Sili= con/Intel/KabylakeSiliconPkg/KabylakeSiliconPkg.dsc index d980a2c5369a..ff7728279a08 100644 --- a/Silicon/Intel/KabylakeSiliconPkg/KabylakeSiliconPkg.dsc +++ b/Silicon/Intel/KabylakeSiliconPkg/KabylakeSiliconPkg.dsc @@ -48,6 +48,7 @@ gSiPkgTokenSpaceGuid.PcdSiCatalogDebugEnable |FAL= SE [PcdsFixedAtBuild.common] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress |0xE0000000 gSiPkgTokenSpaceGuid.PcdSiPciExpressRegionLength |0x10000000 +gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress |0x1800 # # This DSC mainly for GreenH Silicon code build so PciExpressBaseAddress c= an be FixedAtBuild # diff --git a/Silicon/Intel/KabylakeSiliconPkg/Library/PeiSiliconInitLib/Pei= SiliconInitLib.inf b/Silicon/Intel/KabylakeSiliconPkg/Library/PeiSiliconIni= tLib/PeiSiliconInitLib.inf index 3b94a02e6bf4..32205bb04f64 100644 --- a/Silicon/Intel/KabylakeSiliconPkg/Library/PeiSiliconInitLib/PeiSilicon= InitLib.inf +++ b/Silicon/Intel/KabylakeSiliconPkg/Library/PeiSiliconInitLib/PeiSilicon= InitLib.inf @@ -46,7 +46,7 @@ SiliconInitPreMem.c =20 [Pcd] - gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUMES + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUMES gSiPkgTokenSpaceGuid.PcdTcoBaseAddress ## CONSUMES =20 =20 diff --git a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchPmcLi= b/PeiDxeSmmPchPmcLib.inf b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/Pei= DxeSmmPchPmcLib/PeiDxeSmmPchPmcLib.inf index 1e6103f4ca38..5ae3b4d6256a 100644 --- a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchPmcLib/PeiDx= eSmmPchPmcLib.inf +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchPmcLib/PeiDx= eSmmPchPmcLib.inf @@ -30,11 +30,12 @@ PchCycleDecodingLib =20 [Packages] MdePkg/MdePkg.dec +IntelSiliconPkg/IntelSiliconPkg.dec KabylakeSiliconPkg/SiPkg.dec =20 =20 [Pcd] -gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress +gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress =20 =20 [Sources] diff --git a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiPchPolicyLib/P= eiPchPolicyLib.inf b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiPchPol= icyLib/PeiPchPolicyLib.inf index a5ccf4698b7d..41eaffe52e66 100644 --- a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiPchPolicyLib/PeiPchPo= licyLib.inf +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiPchPolicyLib/PeiPchPo= licyLib.inf @@ -35,7 +35,7 @@ KabylakeSiliconPkg/SiPkg.dec IntelSiliconPkg/IntelSiliconPkg.dec =20 [Pcd] -gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress +gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress gSiPkgTokenSpaceGuid.PcdSmbusBaseAddress gSiPkgTokenSpaceGuid.PcdSerialIoUartDebugEnable gSiPkgTokenSpaceGuid.PcdSerialIoUartNumber diff --git a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiSpiLib/PeiSpiL= ib.inf b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiSpiLib/PeiSpiLib.i= nf index ba57c44e1e12..f912d6e76d4a 100644 --- a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiSpiLib/PeiSpiLib.inf +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiSpiLib/PeiSpiLib.inf @@ -39,7 +39,7 @@ PeiSpiLib.c =20 [Pcd] - gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUMES + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUMES =20 [Ppis] gPchSpi2PpiGuid ## PRODUCES diff --git a/Silicon/Intel/KabylakeSiliconPkg/SiPkg.dec b/Silicon/Intel/Kab= ylakeSiliconPkg/SiPkg.dec index d9ae9f6dfd91..6c9af567f5ee 100644 --- a/Silicon/Intel/KabylakeSiliconPkg/SiPkg.dec +++ b/Silicon/Intel/KabylakeSiliconPkg/SiPkg.dec @@ -497,7 +497,6 @@ gSiPkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries|40|= UINT8|0x0001002f gSiPkgTokenSpaceGuid.PcdMchBaseAddress|0xFED10000|UINT64|0x00010030 gSiPkgTokenSpaceGuid.PcdSmbusBaseAddress|0x0000EFA0|UINT16|0x00010031 gSiPkgTokenSpaceGuid.PcdTcoBaseAddress|0x0400|UINT16|0x00010034 -gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress|0x1800|UINT16|0x00010035 =20 ## 32KB window gSiPkgTokenSpaceGuid.PcdMchMmioSize|0x8000|UINT32|0x50000000 diff --git a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Pmc/Library/PeiDxeSm= mPmcLib/PeiDxeSmmPmcLib.inf b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Pmc= /Library/PeiDxeSmmPmcLib/PeiDxeSmmPmcLib.inf index eba6db767c5c..c52a157c7d39 100644 --- a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Pmc/Library/PeiDxeSmmPmcLib= /PeiDxeSmmPmcLib.inf +++ b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Pmc/Library/PeiDxeSmmPmcLib= /PeiDxeSmmPmcLib.inf @@ -31,11 +31,12 @@ BaseMemoryLib =20 [Packages] MdePkg/MdePkg.dec +IntelSiliconPkg/IntelSiliconPkg.dec TigerlakeSiliconPkg/SiPkg.dec =20 =20 [Pcd] -gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress +gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress gSiPkgTokenSpaceGuid.PcdTcoBaseAddress =20 [Sources] diff --git a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Pmc/LibraryPrivate/P= eiDxeSmmPmcPrivateLib/PeiDxeSmmPmcPrivateLibVer2.inf b/Silicon/Intel/Tigerl= akeSiliconPkg/IpBlock/Pmc/LibraryPrivate/PeiDxeSmmPmcPrivateLib/PeiDxeSmmPm= cPrivateLibVer2.inf index 2bd57b79f035..32a4e9a07a76 100644 --- a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Pmc/LibraryPrivate/PeiDxeSm= mPmcPrivateLib/PeiDxeSmmPmcPrivateLibVer2.inf +++ b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Pmc/LibraryPrivate/PeiDxeSm= mPmcPrivateLib/PeiDxeSmmPmcPrivateLibVer2.inf @@ -27,11 +27,12 @@ PmcLib =20 [Packages] MdePkg/MdePkg.dec +IntelSiliconPkg/IntelSiliconPkg.dec TigerlakeSiliconPkg/SiPkg.dec =20 =20 [Pcd] -gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress +gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress =20 [FixedPcd] =20 diff --git a/Silicon/Intel/TigerlakeSiliconPkg/SiPkg.dec b/Silicon/Intel/Ti= gerlakeSiliconPkg/SiPkg.dec index 7cdbb3748155..991ca1555bf7 100644 --- a/Silicon/Intel/TigerlakeSiliconPkg/SiPkg.dec +++ b/Silicon/Intel/TigerlakeSiliconPkg/SiPkg.dec @@ -976,7 +976,6 @@ gMeConfigSpaceGuid.PcdHeciTimeoutsEnabled|TRUE|BOOLEAN|= 0x50000002 ## This value is used to set the base address of PCH devices gSiPkgTokenSpaceGuid.PcdSmbusBaseAddress|0x0000EFA0|UINT16|0x00010031 gSiPkgTokenSpaceGuid.PcdTcoBaseAddress|0x0400|UINT16|0x00010033 -gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress|0x1800|UINT16|0x00010035 =20 =20 ## Stack size in the temporary RAM. diff --git a/Silicon/Intel/TigerlakeSiliconPkg/TigerlakeSiliconPkg.dsc b/Si= licon/Intel/TigerlakeSiliconPkg/TigerlakeSiliconPkg.dsc index 36df41f09fb4..f11305d266cb 100644 --- a/Silicon/Intel/TigerlakeSiliconPkg/TigerlakeSiliconPkg.dsc +++ b/Silicon/Intel/TigerlakeSiliconPkg/TigerlakeSiliconPkg.dsc @@ -60,6 +60,7 @@ gSiPkgTokenSpaceGuid.PcdSpaEnable |FAL= SE gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress |0xC0000000 gSiPkgTokenSpaceGuid.PcdSiPciExpressBaseAddress |gEfiMdePkgTokenSp= aceGuid.PcdPciExpressBaseAddress gSiPkgTokenSpaceGuid.PcdTemporaryPciExpressRegionLength |0x10000000 +gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress |0x1800 =20 [PcdsDynamicDefault.common] gSiPkgTokenSpaceGuid.PcdPciExpressRegionLength |0x10000000 --=20 2.37.2 -=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 (#93255): https://edk2.groups.io/g/devel/message/93255 Mute This Topic: https://groups.io/mt/93506106/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue May 14 10:07:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93256+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93256+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1662483767; cv=none; d=zohomail.com; s=zohoarc; b=C3unVKOa2nS+kkjbTyskDkcng7LcP6J9t0vhq8OadNbF70kr0Uz2nglg3NXShhg0rqd7r5LkDKQqWtQVF8HRzMj6dBbSocVJWEht28e+OI1DKqLmh0Fhjn/oXmdjKfnfZ4tg/8dKYZ2R6MMwFVHu52KV0K/BHNZkkeUDdyUiZBs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662483767; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=tbsYntPjMc84hFWBlpDa7M2A2bCoqVqyqnX/5lBb038=; b=lVuXfrks5Gktubsudex8kDM2AjCWgREJx9hF1QdyQ/DkBRVhrwNHR6qmZb8jF1OGIwV2Tr0snqfvca3OtvhkM3IWph2tqyTj64jBlX5yDpwlfDnVq1p/MMLhfrtVXHUya/nb+BmFAIT2cOHpSHEkinyoy/C2ckFURezR1TDG5oM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93256+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1662483767271478.4929359207972; Tue, 6 Sep 2022 10:02:47 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5uqvYY1788612x88sfe3au3Q; Tue, 06 Sep 2022 10:02:46 -0700 X-Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) by mx.groups.io with SMTP id smtpd.web10.1844.1662483765832467326 for ; Tue, 06 Sep 2022 10:02:46 -0700 X-Received: by mail-qk1-f175.google.com with SMTP id j6so8620909qkl.10 for ; Tue, 06 Sep 2022 10:02:45 -0700 (PDT) X-Gm-Message-State: OikevVcz1NpyJGL6AZWm0wl0x1787277AA= X-Google-Smtp-Source: AA6agR5uiiyZYOPBMDFwZ3VvmNCXA+7pRdmH5+GwhrqssWpWN0AwLHjkZA1SPRQqJXDgPZcSZ/VHRQ== X-Received: by 2002:a05:620a:198f:b0:6bc:5329:5831 with SMTP id bm15-20020a05620a198f00b006bc53295831mr37659157qkb.500.1662483764473; Tue, 06 Sep 2022 10:02:44 -0700 (PDT) X-Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:46bc:db07:bbf3:df6d]) by smtp.gmail.com with ESMTPSA id bi13-20020a05620a318d00b006b59f02224asm10895809qkb.60.2022.09.06.10.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:02:43 -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 v2 2/6] IntelSiliconPkg/Feature/SmmAccess: Implement PPI with chipset support Date: Tue, 6 Sep 2022 13:02:24 -0400 Message-Id: <2c1e044f0d9236a43f77c5dc8bc9d7dd39bf7612.1662483691.git.benjamin.doron00@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,benjamin.doron00@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662483766; bh=PCSafT9BD/Hhh0OTbxnSj0nKf0lZ1NAULQXrU7jLA6Y=; h=Cc:Date:From:Reply-To:Subject:To; b=Vod49VRmUa7sXoEDx80axrJp4NMGLx6ltvTdaDk0dyN2PeJRD05rP2jbxUjWsJS/kEM WCmt0L3qh9I0Ah/SxVP8yL352oVvaGJrcN2gKBnsbUTlJGUtqetw1FHv7F6lmnSCT3jk/ WmlyQ0A+t+oAwIk9eGbiXM9uSw/d6Ep2ajU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662483769335100007 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Isaac Oram --- .../PeiSmmAccessLibSmramc/PeiSmmAccessLib.c | 430 ++++++++++++++++++ .../PeiSmmAccessLibSmramc/PeiSmmAccessLib.inf | 36 ++ 2 files changed, 466 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 + This is to publish the SMM Access Ppi instance. + + Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define SMM_ACCESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('4', '5', 's', 'a') + +/// +/// Private data +/// +typedef struct { + UINTN Signature; + EFI_HANDLE Handle; + EFI_PEI_MM_ACCESS_PPI SmmAccess; + // + // Local Data for SMM Access interface goes here + // + UINTN NumberRegions; + EFI_SMRAM_DESCRIPTOR *SmramDesc; +} SMM_ACCESS_PRIVATE_DATA; + +#define SMM_ACCESS_PRIVATE_DATA_FROM_THIS(a) \ + CR (a, \ + SMM_ACCESS_PRIVATE_DATA, \ + SmmAccess, \ + SMM_ACCESS_PRIVATE_DATA_SIGNATURE \ + ) + +// +// Common registers: +// +// DEVICE 0 (Memory Controller Hub) +// +#define SA_MC_BUS 0x00 +#define SA_MC_DEV 0x00 +#define SA_MC_FUN 0x00 +/// +/// Description: +/// 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. +/// +#define R_SA_SMRAMC (0x88) +#define B_SA_SMRAMC_D_LCK_MASK (0x10) +#define B_SA_SMRAMC_D_CLS_MASK (0x20) +#define B_SA_SMRAMC_D_OPEN_MASK (0x40) + +/** + This routine accepts a request to "open" a region of SMRAM. The + region could be legacy ABSEG, HSEG, or TSEG near top of physical memory. + The use of "open" means that the memory is visible from all PEIM + and SMM agents. + + @param[in] PeiServices - General purpose services available to = every PEIM. + @param[in] This - Pointer to the SMM Access Interface. + @param[in] DescriptorIndex - Region of SMRAM to Open. + + @retval EFI_SUCCESS - The region was successfully opened. + @retval EFI_DEVICE_ERROR - The region could not be opened because= locked by + chipset. + @retval EFI_INVALID_PARAMETER - The descriptor index was out of bounds. +**/ +EFI_STATUS +EFIAPI +Open ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MM_ACCESS_PPI *This, + IN UINTN DescriptorIndex + ) +{ + SMM_ACCESS_PRIVATE_DATA *SmmAccess; + UINT8 Index; + UINT64 Address; + UINT8 SmramControl; + + SmmAccess =3D SMM_ACCESS_PRIVATE_DATA_FROM_THIS (This); + if (DescriptorIndex >=3D SmmAccess->NumberRegions) { + DEBUG ((DEBUG_WARN, "SMRAM region out of range\n")); + + return EFI_INVALID_PARAMETER; + } else if (SmmAccess->SmramDesc[DescriptorIndex].RegionState & EFI_SMRAM= _LOCKED) { + // + // Cannot open a "locked" region + // + DEBUG ((DEBUG_WARN, "Cannot open a locked SMRAM region\n")); + + return EFI_DEVICE_ERROR; + } + + /// + /// BEGIN CHIPSET CODE + /// + /// + /// SMRAM register is PCI 0:0:0:88, SMRAMC (8 bit) + /// + Address =3D PCI_SEGMENT_LIB_ADDRESS (0, SA_MC_BUS, SA_MC_DEV, SA_MC_FUN,= R_SA_SMRAMC); + SmramControl =3D PciSegmentRead8 (Address); + /// + /// Is SMRAM locked? + /// + if ((SmramControl & B_SA_SMRAMC_D_LCK_MASK) !=3D 0) { + /// + /// Cannot Open a locked region + /// + for (Index =3D 0; Index < SmmAccess->NumberRegions; Index++) { + SmmAccess->SmramDesc[Index].RegionState |=3D EFI_SMRAM_LOCKED; + } + DEBUG ((DEBUG_WARN, "Cannot open a locked SMRAM region\n")); + return EFI_DEVICE_ERROR; + } + /// + /// Open SMRAM region + /// + SmramControl |=3D B_SA_SMRAMC_D_OPEN_MASK; + SmramControl &=3D ~(B_SA_SMRAMC_D_CLS_MASK); + + PciSegmentWrite8 (Address, SmramControl); + /// + /// END CHIPSET CODE + /// + + SmmAccess->SmramDesc[DescriptorIndex].RegionState &=3D (UINT64) ~(EFI_SM= RAM_CLOSED | EFI_ALLOCATED); + SmmAccess->SmramDesc[DescriptorIndex].RegionState |=3D (UINT64) EFI_SMRA= M_OPEN; + SmmAccess->SmmAccess.OpenState =3D TRUE; + return EFI_SUCCESS; +} + +/** + This routine accepts a request to "close" a region of SMRAM. This is va= lid for + compatible SMRAM region. + + @param[in] PeiServices - General purpose services available to = every PEIM. + @param[in] This - Pointer to the SMM Access Interface. + @param[in] DescriptorIndex - Region of SMRAM to Close. + + @retval EFI_SUCCESS - The region was successfully closed. + @retval EFI_DEVICE_ERROR - The region could not be closed because= locked by + chipset. + @retval EFI_INVALID_PARAMETER - The descriptor index was out of bounds. +**/ +EFI_STATUS +EFIAPI +Close ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MM_ACCESS_PPI *This, + IN UINTN DescriptorIndex + ) +{ + SMM_ACCESS_PRIVATE_DATA *SmmAccess; + BOOLEAN OpenState; + UINT8 Index; + UINT64 Address; + UINT8 SmramControl; + + SmmAccess =3D SMM_ACCESS_PRIVATE_DATA_FROM_THIS (This); + if (DescriptorIndex >=3D SmmAccess->NumberRegions) { + DEBUG ((DEBUG_WARN, "SMRAM region out of range\n")); + + return EFI_INVALID_PARAMETER; + } else if (SmmAccess->SmramDesc[DescriptorIndex].RegionState & EFI_SMRAM= _LOCKED) { + // + // Cannot close a "locked" region + // + DEBUG ((DEBUG_WARN, "Cannot close a locked SMRAM region\n")); + + return EFI_DEVICE_ERROR; + } + + if (SmmAccess->SmramDesc[DescriptorIndex].RegionState & EFI_SMRAM_CLOSED= ) { + return EFI_DEVICE_ERROR; + } + + /// + /// BEGIN CHIPSET CODE + /// + /// + /// SMRAM register is PCI 0:0:0:88, SMRAMC (8 bit) + /// + Address =3D PCI_SEGMENT_LIB_ADDRESS (0, SA_MC_BUS, SA_MC_DEV, SA_MC_FUN,= R_SA_SMRAMC); + SmramControl =3D PciSegmentRead8 (Address); + /// + /// Is SMRAM locked? + /// + if ((SmramControl & B_SA_SMRAMC_D_LCK_MASK) !=3D 0) { + /// + /// Cannot Close a locked region + /// + for (Index =3D 0; Index < SmmAccess->NumberRegions; Index++) { + SmmAccess->SmramDesc[Index].RegionState |=3D EFI_SMRAM_LOCKED; + } + DEBUG ((DEBUG_WARN, "Cannot close a locked SMRAM region\n")); + return EFI_DEVICE_ERROR; + } + /// + /// Close SMRAM region + /// + SmramControl &=3D ~(B_SA_SMRAMC_D_OPEN_MASK); + + PciSegmentWrite8 (Address, SmramControl); + /// + /// END CHIPSET CODE + /// + + SmmAccess->SmramDesc[DescriptorIndex].RegionState &=3D (UINT64) ~EFI_SMR= AM_OPEN; + SmmAccess->SmramDesc[DescriptorIndex].RegionState |=3D (UINT64) (EFI_SMR= AM_CLOSED | EFI_ALLOCATED); + + // + // Find out if any regions are still open + // + OpenState =3D FALSE; + for (Index =3D 0; Index < SmmAccess->NumberRegions; Index++) { + if ((SmmAccess->SmramDesc[Index].RegionState & EFI_SMRAM_OPEN) =3D=3D = EFI_SMRAM_OPEN) { + OpenState =3D TRUE; + } + } + + SmmAccess->SmmAccess.OpenState =3D OpenState; + return EFI_SUCCESS; +} + +/** + This routine accepts a request to "lock" SMRAM. The + region could be legacy AB or TSEG near top of physical memory. + The use of "lock" means that the memory can no longer be opened + to PEIM. + + @param[in] PeiServices - General purpose services available to e= very PEIM. + @param[in] This - Pointer to the SMM Access Interface. + @param[in] DescriptorIndex - Region of SMRAM to Lock. + + @retval EFI_SUCCESS - The region was successfully locked. + @retval EFI_DEVICE_ERROR - The region could not be locked because= at least + one range is still open. + @retval EFI_INVALID_PARAMETER - The descriptor index was out of bounds. +**/ +EFI_STATUS +EFIAPI +Lock ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MM_ACCESS_PPI *This, + IN UINTN DescriptorIndex + ) +{ + SMM_ACCESS_PRIVATE_DATA *SmmAccess; + UINT64 Address; + UINT8 SmramControl; + + SmmAccess =3D SMM_ACCESS_PRIVATE_DATA_FROM_THIS (This); + if (DescriptorIndex >=3D SmmAccess->NumberRegions) { + DEBUG ((DEBUG_WARN, "SMRAM region out of range\n")); + + return EFI_INVALID_PARAMETER; + } else if (SmmAccess->SmmAccess.OpenState) { + DEBUG ((DEBUG_WARN, "Cannot lock SMRAM when SMRAM regions are still op= en\n")); + + return EFI_DEVICE_ERROR; + } + + SmmAccess->SmramDesc[DescriptorIndex].RegionState |=3D (UINT64) EFI_SMRA= M_LOCKED; + SmmAccess->SmmAccess.LockState =3D TRUE; + + /// + /// BEGIN CHIPSET CODE + /// + /// + /// SMRAM register is PCI 0:0:0:88, SMRAMC (8 bit) + /// + Address =3D PCI_SEGMENT_LIB_ADDRESS (0, SA_MC_BUS, SA_MC_DEV, SA_MC_FUN,= R_SA_SMRAMC); + SmramControl =3D PciSegmentRead8 (Address); + + /// + /// Lock the SMRAM + /// + SmramControl |=3D B_SA_SMRAMC_D_LCK_MASK; + + PciSegmentWrite8 (Address, SmramControl); + /// + /// END CHIPSET CODE + /// + + return EFI_SUCCESS; +} + +/** + This routine services a user request to discover the SMRAM + capabilities of this platform. This will report the possible + ranges that are possible for SMRAM access, based upon the + memory controller capabilities. + + @param[in] PeiServices - General purpose services available to ev= ery PEIM. + @param[in] This - Pointer to the SMRAM Access Interface. + @param[in, out] SmramMapSize - Pointer to the variable containing size= of the + buffer to contain the description infor= mation. + @param[in, out] SmramMap - Buffer containing the data describing t= he Smram + region descriptors. + + @retval EFI_BUFFER_TOO_SMALL - The user did not provide a sufficient b= uffer. + @retval EFI_SUCCESS - The user provided a sufficiently-sized = buffer. +**/ +EFI_STATUS +EFIAPI +GetCapabilities ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MM_ACCESS_PPI *This, + IN OUT UINTN *SmramMapSize, + IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap + ) +{ + EFI_STATUS Status; + SMM_ACCESS_PRIVATE_DATA *SmmAccess; + UINTN NecessaryBufferSize; + + SmmAccess =3D SMM_ACCESS_PRIVATE_DATA_FROM_THIS (This); + NecessaryBufferSize =3D SmmAccess->NumberRegions * sizeof (EFI_SMRAM_DES= CRIPTOR); + if (*SmramMapSize < NecessaryBufferSize) { + DEBUG ((DEBUG_WARN, "SMRAM Map Buffer too small\n")); + + Status =3D EFI_BUFFER_TOO_SMALL; + } else { + CopyMem (SmramMap, SmmAccess->SmramDesc, NecessaryBufferSize); + Status =3D EFI_SUCCESS; + } + + *SmramMapSize =3D NecessaryBufferSize; + return Status; +} + +/** + This function is to install an SMM Access PPI + - Introduction \n + 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. + + @retval EFI_SUCCESS - Ppi successfully started and installed. + @retval EFI_NOT_FOUND - Ppi can't be found. + @retval EFI_OUT_OF_RESOURCES - Ppi does not have enough resources to = initialize the driver. +**/ +EFI_STATUS +EFIAPI +PeiInstallSmmAccessPpi ( + VOID + ) +{ + EFI_STATUS Status; + UINTN Index; + EFI_PEI_PPI_DESCRIPTOR *PpiList; + EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *DescriptorBlock; + SMM_ACCESS_PRIVATE_DATA *SmmAccessPrivate; + VOID *HobList; + + // + // Initialize private data + // + SmmAccessPrivate =3D AllocateZeroPool (sizeof (*SmmAccessPrivate)); + ASSERT (SmmAccessPrivate !=3D NULL); + if (SmmAccessPrivate =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + PpiList =3D AllocateZeroPool (sizeof (*PpiList)); + ASSERT (PpiList !=3D NULL); + if (PpiList =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + SmmAccessPrivate->Signature =3D SMM_ACCESS_PRIVATE_DATA_SIGNATURE; + SmmAccessPrivate->Handle =3D NULL; + + // + // Get Hob list + // + HobList =3D GetFirstGuidHob (&gEfiSmmSmramMemoryGuid); + if (HobList =3D=3D NULL) { + DEBUG ((DEBUG_WARN, "SmramMemoryReserve HOB not found\n")); + return EFI_NOT_FOUND; + } + + DescriptorBlock =3D (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *) ((UINT8 *) HobLis= t + sizeof (EFI_HOB_GUID_TYPE)); + + // + // Alloc space for SmmAccessPrivate->SmramDesc + // + SmmAccessPrivate->SmramDesc =3D AllocateZeroPool ((DescriptorBlock->Numb= erOfSmmReservedRegions) * sizeof (EFI_SMRAM_DESCRIPTOR)); + if (SmmAccessPrivate->SmramDesc =3D=3D NULL) { + DEBUG ((DEBUG_WARN, "Alloc SmmAccessPrivate->SmramDesc fail.\n")); + return EFI_OUT_OF_RESOURCES; + } + + DEBUG ((DEBUG_INFO, "Alloc SmmAccessPrivate->SmramDesc success.\n")); + + // + // use the hob to publish SMRAM capabilities + // + for (Index =3D 0; Index < DescriptorBlock->NumberOfSmmReservedRegions; I= ndex++) { + SmmAccessPrivate->SmramDesc[Index].PhysicalStart =3D DescriptorBlock-= >Descriptor[Index].PhysicalStart; + SmmAccessPrivate->SmramDesc[Index].CpuStart =3D DescriptorBlock-= >Descriptor[Index].CpuStart; + SmmAccessPrivate->SmramDesc[Index].PhysicalSize =3D DescriptorBlock-= >Descriptor[Index].PhysicalSize; + SmmAccessPrivate->SmramDesc[Index].RegionState =3D DescriptorBlock-= >Descriptor[Index].RegionState; + } + + SmmAccessPrivate->NumberRegions =3D Index; + SmmAccessPrivate->SmmAccess.Open =3D Open; + SmmAccessPrivate->SmmAccess.Close =3D Close; + SmmAccessPrivate->SmmAccess.Lock =3D Lock; + SmmAccessPrivate->SmmAccess.GetCapabilities =3D GetCapabilities; + SmmAccessPrivate->SmmAccess.LockState =3D FALSE; + SmmAccessPrivate->SmmAccess.OpenState =3D FALSE; + + // + // Install PPI + // + PpiList->Flags =3D (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR= _TERMINATE_LIST); + PpiList->Guid =3D &gEfiPeiMmAccessPpiGuid; + PpiList->Ppi =3D &SmmAccessPrivate->SmmAccess; + + Status =3D PeiServicesInstallPpi (PpiList); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} 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..160210d429d9 --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessL= ibSmramc/PeiSmmAccessLib.inf @@ -0,0 +1,36 @@ +## @file +# Library description file for the SmmAccess PPI +# +# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D PeiSmmAccessLibSmramc + FILE_GUID =3D 3D28FD4B-F46F-4E24-88AA-9DA09C51BE87 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D PEIM + LIBRARY_CLASS =3D SmmAccessLib + +[LibraryClasses] + BaseMemoryLib + MemoryAllocationLib + DebugLib + HobLib + PciSegmentLib + PeiServicesLib + +[Packages] + MdePkg/MdePkg.dec + IntelSiliconPkg/IntelSiliconPkg.dec + +[Sources] + PeiSmmAccessLib.c + +[Ppis] + gEfiPeiMmAccessPpiGuid ## PRODUCES + +[Guids] + gEfiSmmSmramMemoryGuid --=20 2.37.2 -=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 (#93256): https://edk2.groups.io/g/devel/message/93256 Mute This Topic: https://groups.io/mt/93506107/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue May 14 10:07:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93257+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93257+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1662483768; cv=none; d=zohomail.com; s=zohoarc; b=Y1ON/4lao6A4RjN3YBZhOV308DBsLCDKQnd/pPT6KehkVzMEuoLwslDZ+zkcvQwHDyl9hIGJ5IgGqKwGl9NHBArug1aCORX0aio4hOLU4PfJgK+iVCWuN9+1DnqqHafhYZxPx5iPJ+xcos6m/3plA5XXGD9RmFU1JnhOPcpTo6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662483768; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=VZLCt0VVauJfO4sIIDZEVwEfn71KCkzke24dN87Ep+A=; b=GO6yy1Rp7J1GMkU93K+Jt7QvMbt/62IkTGdi+hYK4mZd1n5wJkcXXkKLKRmlRl+FuOvyACbvmlULzpEEBt/UXAZwN2SCgsX9OrLjk9kwiOYwHtIt5gw4aU0PJzkO3GlEmVN2HSYs/ip57aWRho4CDhwPX3gPFmCDZK9YJ0AQGUA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93257+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1662483768329254.05566416857096; Tue, 6 Sep 2022 10:02:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vsQnYY1788612xEc9Vtuktr5; Tue, 06 Sep 2022 10:02:48 -0700 X-Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by mx.groups.io with SMTP id smtpd.web11.1760.1662483767124653270 for ; Tue, 06 Sep 2022 10:02:47 -0700 X-Received: by mail-qt1-f169.google.com with SMTP id w28so8516892qtc.7 for ; Tue, 06 Sep 2022 10:02:47 -0700 (PDT) X-Gm-Message-State: ZcpnSZloaiNcxJ1RGfqiseZnx1787277AA= X-Google-Smtp-Source: AA6agR5aQwGGGBFm3AhApO7awHw/ZbOhvtukoZiPFm1JP754J+3WC1cqlut9TjLh05NyuFfOw63e7g== X-Received: by 2002:a05:622a:254:b0:343:55c0:1d84 with SMTP id c20-20020a05622a025400b0034355c01d84mr44111327qtx.225.1662483765927; Tue, 06 Sep 2022 10:02:45 -0700 (PDT) X-Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:46bc:db07:bbf3:df6d]) by smtp.gmail.com with ESMTPSA id bi13-20020a05620a318d00b006b59f02224asm10895809qkb.60.2022.09.06.10.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:02:45 -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 v2 3/6] IntelSiliconPkg/Feature/SmmControl: Implement PPI with chipset support Date: Tue, 6 Sep 2022 13:02:25 -0400 Message-Id: <8dffa2473dfd2871443632ab2ba32a787471dafd.1662483691.git.benjamin.doron00@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,benjamin.doron00@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662483768; bh=tDpwABGncjmng+wQnTjWYOYO4ry4sHPZTbCTYa+9AqY=; h=Cc:Date:From:Reply-To:Subject:To; b=UMUFDwUJOeVVccMweGpwHH8BPVSSDMsA7VJ2gmVU0Olrp+x9y5HuqAOrlX6iEu3Uq65 hDQHconhdor4CRjLGZFu22zODialmBoFOhCX1VsGexJ3DsTIBEYPzwu3zgJJk997K0SV3 tnVjnpJxyQoPtI4U5V44oEXtmzd3G41hd3s= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662483769348100008 Content-Type: text/plain; charset="utf-8" S3 resume may require communication with SMM, for which we need the SmmControl PPI. Therefore, port the DXE drivers to a library, like there is for SMM Access. Tested, working on Kabylake. Further testing required after the refactor for compatibility. Cc: Nate DeSimone Cc: Ankit Sinha Cc: Ray Ni Cc: Rangasai V Chaganty Cc: Isaac Oram Signed-off-by: Benjamin Doron Reviewed-by: Isaac Oram --- .../PeiSmmControlLib/PeiSmmControlLib.c | 309 ++++++++++++++++++ .../PeiSmmControlLib/PeiSmmControlLib.inf | 34 ++ .../Include/Library/SmmControlLib.h | 26 ++ .../Intel/IntelSiliconPkg/IntelSiliconPkg.dec | 4 + 4 files changed, 373 insertions(+) create mode 100644 Silicon/Intel/IntelSiliconPkg/Feature/SmmControl/Librar= y/PeiSmmControlLib/PeiSmmControlLib.c create mode 100644 Silicon/Intel/IntelSiliconPkg/Feature/SmmControl/Librar= y/PeiSmmControlLib/PeiSmmControlLib.inf create mode 100644 Silicon/Intel/IntelSiliconPkg/Include/Library/SmmContro= lLib.h diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/SmmControl/Library/PeiSm= mControlLib/PeiSmmControlLib.c b/Silicon/Intel/IntelSiliconPkg/Feature/SmmC= ontrol/Library/PeiSmmControlLib/PeiSmmControlLib.c new file mode 100644 index 000000000000..cc6c7f8fe672 --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Feature/SmmControl/Library/PeiSmmContro= lLib/PeiSmmControlLib.c @@ -0,0 +1,309 @@ +/** @file + This is to publish the SMM Control Ppi instance. + + Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include +#include +#include +#include + +#include +#include + +#define SMM_CONTROL_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('i', '4', 's', '= c') + +typedef struct { + UINTN Signature; + EFI_HANDLE Handle; + EFI_PEI_MM_CONTROL_PPI SmmControl; +} SMM_CONTROL_PRIVATE_DATA; + +#define SMM_CONTROL_PRIVATE_DATA_FROM_THIS(a) \ + CR (a, \ + SMM_CONTROL_PRIVATE_DATA, \ + SmmControl, \ + SMM_CONTROL_DEV_SIGNATURE \ + ) + +// +// Common registers: +// +// +// APM Registers +// +#define R_PCH_APM_CNT 0xB2 +// +// ACPI and legacy I/O register offsets from ACPIBASE +// +#define R_PCH_ACPI_PM1_STS 0x00 +#define B_PCH_ACPI_PM1_STS_PRBTNOR BIT11 + +#define R_PCH_SMI_EN 0x30 + +#define R_PCH_SMI_STS 0x34 +#define B_PCH_SMI_STS_APM BIT5 +#define B_PCH_SMI_EN_APMC BIT5 +#define B_PCH_SMI_EN_EOS BIT1 +#define B_PCH_SMI_EN_GBL_SMI BIT0 + +/** + Trigger the software SMI + + @param[in] Data The value to be set on the software SMI = data port + + @retval EFI_SUCCESS Function completes successfully +**/ +EFI_STATUS +EFIAPI +SmmTrigger ( + UINT8 Data + ) +{ + UINT16 ABase; + UINT32 OutputData; + UINT32 OutputPort; + + ABase =3D FixedPcdGet16 (PcdAcpiBaseAddress); + + /// + /// Enable the APMC SMI + /// + OutputPort =3D ABase + R_PCH_SMI_EN; + OutputData =3D IoRead32 ((UINTN) OutputPort); + OutputData |=3D (B_PCH_SMI_EN_APMC | B_PCH_SMI_EN_GBL_SMI); + DEBUG ( + (DEBUG_EVENT, + "The SMI Control Port at address %x will be written to %x.\n", + OutputPort, + OutputData) + ); + IoWrite32 ( + (UINTN) OutputPort, + (UINT32) (OutputData) + ); + + OutputPort =3D R_PCH_APM_CNT; + OutputData =3D Data; + + /// + /// Generate the APMC SMI + /// + IoWrite8 ( + (UINTN) OutputPort, + (UINT8) (OutputData) + ); + + return EFI_SUCCESS; +} + +/** + Clear the SMI status + + + @retval EFI_SUCCESS The function completes successfully + @retval EFI_DEVICE_ERROR Something error occurred +**/ +EFI_STATUS +EFIAPI +SmmClear ( + VOID + ) +{ + UINT16 ABase; + UINT32 OutputData; + UINT32 OutputPort; + + ABase =3D FixedPcdGet16 (PcdAcpiBaseAddress); + + /// + /// Clear the Power Button Override Status Bit, it gates EOS from being = set. + /// + OutputPort =3D ABase + R_PCH_ACPI_PM1_STS; + OutputData =3D B_PCH_ACPI_PM1_STS_PRBTNOR; + DEBUG ( + (DEBUG_EVENT, + "The PM1 Status Port at address %x will be written to %x.\n", + OutputPort, + OutputData) + ); + IoWrite16 ( + (UINTN) OutputPort, + (UINT16) (OutputData) + ); + + /// + /// Clear the APM SMI Status Bit + /// + OutputPort =3D ABase + R_PCH_SMI_STS; + OutputData =3D B_PCH_SMI_STS_APM; + DEBUG ( + (DEBUG_EVENT, + "The SMI Status Port at address %x will be written to %x.\n", + OutputPort, + OutputData) + ); + IoWrite32 ( + (UINTN) OutputPort, + (UINT32) (OutputData) + ); + + /// + /// Set the EOS Bit + /// + OutputPort =3D ABase + R_PCH_SMI_EN; + OutputData =3D IoRead32 ((UINTN) OutputPort); + OutputData |=3D B_PCH_SMI_EN_EOS; + DEBUG ( + (DEBUG_EVENT, + "The SMI Control Port at address %x will be written to %x.\n", + OutputPort, + OutputData) + ); + IoWrite32 ( + (UINTN) OutputPort, + (UINT32) (OutputData) + ); + + /// + /// There is no need to read EOS back and check if it is set. + /// This can lead to a reading of zero if an SMI occurs right after the = SMI_EN port read + /// but before the data is returned to the CPU. + /// SMM Dispatcher should make sure that EOS is set after all SMI source= s are processed. + /// + return EFI_SUCCESS; +} + +/** + This routine generates an SMI + + @param[in] This The EFI SMM Control protocol insta= nce + @param[in, out] ArgumentBuffer The buffer of argument + @param[in, out] ArgumentBufferSize The size of the argument buffer + @param[in] Periodic Periodic or not + @param[in] ActivationInterval Interval of periodic SMI + + @retval EFI Status Describing the result of the opera= tion + @retval EFI_INVALID_PARAMETER Some parameter value passed is not= supported +**/ +EFI_STATUS +EFIAPI +Activate ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MM_CONTROL_PPI * This, + IN OUT INT8 *ArgumentBuffer OPTIONAL, + IN OUT UINTN *ArgumentBufferSize OPTIONAL, + IN BOOLEAN Periodic OPTIONAL, + IN UINTN ActivationInterval OPTIONAL + ) +{ + EFI_STATUS Status; + UINT8 Data; + + if (Periodic) { + DEBUG ((DEBUG_WARN, "Invalid parameter\n")); + return EFI_INVALID_PARAMETER; + } + + // NOTE: Copied from Quark. Matches the usage in PiSmmCommunicationPei + if (ArgumentBuffer =3D=3D NULL) { + Data =3D 0xFF; + } else { + if (ArgumentBufferSize =3D=3D NULL || *ArgumentBufferSize !=3D 1) { + return EFI_INVALID_PARAMETER; + } + + Data =3D *ArgumentBuffer; + } + /// + /// Clear any pending the APM SMI + /// + Status =3D SmmClear (); + if (EFI_ERROR (Status)) { + return Status; + } + + return SmmTrigger (Data); +} + +/** + This routine clears an SMI + + @param[in] This The EFI SMM Control protocol instance + @param[in] Periodic Periodic or not + + @retval EFI Status Describing the result of the operation + @retval EFI_INVALID_PARAMETER Some parameter value passed is not suppo= rted +**/ +EFI_STATUS +EFIAPI +Deactivate ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MM_CONTROL_PPI * This, + IN BOOLEAN Periodic OPTIONAL + ) +{ + if (Periodic) { + return EFI_INVALID_PARAMETER; + } + + return SmmClear (); +} + +/** + This function is to install an SMM Control PPI + - Introduction \n + An API to install an instance of EFI_PEI_MM_CONTROL_PPI. This PPI prov= ides a standard + way for other modules to trigger software SMIs. + + @retval EFI_SUCCESS - Ppi successfully started and installed. + @retval EFI_NOT_FOUND - Ppi can't be found. + @retval EFI_OUT_OF_RESOURCES - Ppi does not have enough resources to = initialize the driver. +**/ +EFI_STATUS +EFIAPI +PeiInstallSmmControlPpi ( + VOID + ) +{ + EFI_STATUS Status; + EFI_PEI_PPI_DESCRIPTOR *PpiList; + SMM_CONTROL_PRIVATE_DATA *SmmControlPrivate; + + // + // Initialize private data + // + SmmControlPrivate =3D AllocateZeroPool (sizeof (*SmmControlPrivate)); + ASSERT (SmmControlPrivate !=3D NULL); + if (SmmControlPrivate =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + PpiList =3D AllocateZeroPool (sizeof (*PpiList)); + ASSERT (PpiList !=3D NULL); + if (PpiList =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + SmmControlPrivate->Signature =3D SMM_CONTROL_PRIVATE_DATA_SIGNATURE; + SmmControlPrivate->Handle =3D NULL; + + SmmControlPrivate->SmmControl.Trigger =3D Activate; + SmmControlPrivate->SmmControl.Clear =3D Deactivate; + + // + // Install PPI + // + PpiList->Flags =3D (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR= _TERMINATE_LIST); + PpiList->Guid =3D &gEfiPeiMmControlPpiGuid; + PpiList->Ppi =3D &SmmControlPrivate->SmmControl; + + Status =3D PeiServicesInstallPpi (PpiList); + ASSERT_EFI_ERROR (Status); + + // Unlike driver, do not disable SMIs as S3 resume continues + return EFI_SUCCESS; +} diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/SmmControl/Library/PeiSm= mControlLib/PeiSmmControlLib.inf b/Silicon/Intel/IntelSiliconPkg/Feature/Sm= mControl/Library/PeiSmmControlLib/PeiSmmControlLib.inf new file mode 100644 index 000000000000..91c761366446 --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Feature/SmmControl/Library/PeiSmmContro= lLib/PeiSmmControlLib.inf @@ -0,0 +1,34 @@ +## @file +# Library description file for the SmmControl PPI +# +# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D PeiSmmControlLib + FILE_GUID =3D F45D521A-C0DF-4283-A3CA-65AD01B479E7 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D PEIM + LIBRARY_CLASS =3D SmmControlLib + +[LibraryClasses] + IoLib + DebugLib + MemoryAllocationLib + PeiServicesLib + +[Packages] + MdePkg/MdePkg.dec + IntelSiliconPkg/IntelSiliconPkg.dec + +[Sources] + PeiSmmControlLib.c + +[Pcd] + gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUMES + +[Ppis] + gEfiPeiMmControlPpiGuid ## PRODUCES diff --git a/Silicon/Intel/IntelSiliconPkg/Include/Library/SmmControlLib.h = b/Silicon/Intel/IntelSiliconPkg/Include/Library/SmmControlLib.h new file mode 100644 index 000000000000..b532dd13f373 --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Include/Library/SmmControlLib.h @@ -0,0 +1,26 @@ +/** @file + This is to publish the SMM Control Ppi instance. + + Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#ifndef _SMM_CONTROL_LIB_H_ +#define _SMM_CONTROL_LIB_H_ + +/** + This function is to install an SMM Control PPI + - Introduction \n + An API to install an instance of EFI_PEI_MM_CONTROL_PPI. This PPI prov= ides a standard + way for other modules to trigger software SMIs. + + @retval EFI_SUCCESS - Ppi successfully started and installed. + @retval EFI_NOT_FOUND - Ppi can't be found. + @retval EFI_OUT_OF_RESOURCES - Ppi does not have enough resources to = initialize the driver. +**/ +EFI_STATUS +EFIAPI +PeiInstallSmmControlPpi ( + VOID + ); +#endif diff --git a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec b/Silicon/In= tel/IntelSiliconPkg/IntelSiliconPkg.dec index deefdc55b5d6..440c7d0255ce 100644 --- a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec +++ b/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec @@ -35,6 +35,10 @@ # SmmAccessLib|Include/Library/SmmAccessLib.h =20 + ## @libraryclass Provides services to trigger SMI + # + SmmControlLib|Include/Library/SmmControlLib.h + ## @libraryclass Provides services to access config block # ConfigBlockLib|Include/Library/ConfigBlockLib.h --=20 2.37.2 -=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 (#93257): https://edk2.groups.io/g/devel/message/93257 Mute This Topic: https://groups.io/mt/93506109/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue May 14 10:07:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93258+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93258+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1662483770; cv=none; d=zohomail.com; s=zohoarc; b=EIW7AF4DPun6EztayZ9VnazYyt5XZq0jqPa4MxogPFGCT0rbq3EHebwcAnr1DNbk/DS8c5utNoKATMSbcpXNKRpFcryT4sHXZFkOXgAVMdi98MoV/uokKsgS/yDXPWC+6lqctJVN8753N/aY9onJ7DWnopq8FX8FvdUVQ1m8g4U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662483770; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=p6zmvzqX6DUVmO52vr0wLq4jeL/KvrZUwhWhDh5aijc=; b=QvoM6+TU+IPuRroV4XAU2QPvmm6Mh3mvH4u1J7E1tqRvAuQa4+UgFaRglC9nV4asWdhvaWKvJpFzQBtMove2sNrINz+FPe1oK13m3cSrY16G5rxmh6cZcjrPD526Dwaunp2FLOldbwkfKfy9A79WtcHY8Zg2D2/M4VDbv1pkyTU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93258+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1662483770077540.0211968894897; Tue, 6 Sep 2022 10:02:50 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id lGHoYY1788612xdIjvyQbMFn; Tue, 06 Sep 2022 10:02:49 -0700 X-Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) by mx.groups.io with SMTP id smtpd.web09.1861.1662483769040593115 for ; Tue, 06 Sep 2022 10:02:49 -0700 X-Received: by mail-qt1-f177.google.com with SMTP id y18so8524848qtv.5 for ; Tue, 06 Sep 2022 10:02:48 -0700 (PDT) X-Gm-Message-State: J4r7DFSAgLPe9FpjTaMATUdZx1787277AA= X-Google-Smtp-Source: AA6agR7xOkRg8wS1UB623b+O9Lw04f59vAMKO0SLbQ2k8ta+Alp620hCyNPrH0pae1l+cYXQcMRmzg== X-Received: by 2002:a05:622a:607:b0:343:4f06:fdd4 with SMTP id z7-20020a05622a060700b003434f06fdd4mr44226047qta.321.1662483767548; Tue, 06 Sep 2022 10:02:47 -0700 (PDT) X-Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:46bc:db07:bbf3:df6d]) by smtp.gmail.com with ESMTPSA id bi13-20020a05620a318d00b006b59f02224asm10895809qkb.60.2022.09.06.10.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:02:47 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Nate DeSimone , Ankit Sinha , Sai Chaganty , Isaac Oram , Liming Gao Subject: [edk2-devel][edk2-platforms][PATCH v2 4/6] S3FeaturePkg: Implement working S3 resume Date: Tue, 6 Sep 2022 13:02:26 -0400 Message-Id: <7984cecbfb1970a28dc483788a7a8a9dc4175ccd.1662483691.git.benjamin.doron00@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,benjamin.doron00@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662483769; bh=TuIGGUexIg+M0V2j6wrlNiKSrEHbcwBmhQ8OwHWqH74=; h=Cc:Date:From:Reply-To:Subject:To; b=ak6IDPGaf9mdFgJGMCjWQXH7DbVclRDWV8SYDPXyV3nh+xi+Za/lEtQKxqagpT0h6uG gPLaahsVKOZ8zp5J3GWIoYduVgVL9d7RSHw9jlklppAGz+Zp3F0t0DsTeydWX61D9XhqU fUB8+ddv05gTLGZZ7FqjLcSRnkOL0M7/Tog= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662483771564100013 Content-Type: text/plain; charset="utf-8" Follow-up commits to MinPlatform (PeiFspWrapperHobProcessLib for memory) and FSP-related board libraries (policy overrides) required for successful S3 resume. Factored allocation logic into new module to avoid MinPlatform dependency on S3Feature package. TODO: Can optimise required size. Cc: Nate DeSimone Cc: Ankit Sinha Cc: Sai Chaganty Cc: Isaac Oram Cc: Liming Gao Signed-off-by: Benjamin Doron --- .../S3FeaturePkg/Include/PostMemory.fdf | 13 ++ .../S3FeaturePkg/Include/PreMemory.fdf | 8 +- .../S3FeaturePkg/Include/S3Feature.dsc | 38 ++++- .../S3FeaturePkg/S3Dxe/S3Dxe.c | 155 ++++++++++++++++++ .../S3FeaturePkg/S3Dxe/S3Dxe.inf | 49 ++++++ .../S3FeaturePkg/S3Pei/S3Pei.c | 83 +++++++++- .../S3FeaturePkg/S3Pei/S3Pei.inf | 8 +- .../Include/AcpiS3MemoryNvData.h | 22 +++ 8 files changed, 365 insertions(+), 11 deletions(-) create mode 100644 Features/Intel/PowerManagement/S3FeaturePkg/S3Dxe/S3Dxe= .c create mode 100644 Features/Intel/PowerManagement/S3FeaturePkg/S3Dxe/S3Dxe= .inf create mode 100644 Platform/Intel/MinPlatformPkg/Include/AcpiS3MemoryNvDat= a.h diff --git a/Features/Intel/PowerManagement/S3FeaturePkg/Include/PostMemory= .fdf b/Features/Intel/PowerManagement/S3FeaturePkg/Include/PostMemory.fdf index 9e17f853c630..7f630908fa2c 100644 --- a/Features/Intel/PowerManagement/S3FeaturePkg/Include/PostMemory.fdf +++ b/Features/Intel/PowerManagement/S3FeaturePkg/Include/PostMemory.fdf @@ -2,7 +2,20 @@ # FDF file for post-memory S3 advanced feature modules. # # Copyright (c) 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2022, Baruch Binyamin Doron.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # ## + +## Dependencies + INF UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf + INF MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf + +## Save-state module stack + INF S3FeaturePkg/S3Dxe/S3Dxe.inf + INF MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf + INF UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf + +## Restore-state module stack + INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutor= Dxe.inf diff --git a/Features/Intel/PowerManagement/S3FeaturePkg/Include/PreMemory.= fdf b/Features/Intel/PowerManagement/S3FeaturePkg/Include/PreMemory.fdf index fdd16a4e0356..e130fa5f098d 100644 --- a/Features/Intel/PowerManagement/S3FeaturePkg/Include/PreMemory.fdf +++ b/Features/Intel/PowerManagement/S3FeaturePkg/Include/PreMemory.fdf @@ -2,9 +2,15 @@ # FDF file for pre-memory S3 advanced feature modules. # # Copyright (c) 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2022, Baruch Binyamin Doron.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # ## =20 -INF S3FeaturePkg/S3Pei/S3Pei.inf +## Dependencies + INF S3FeaturePkg/S3Pei/S3Pei.inf + INF UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf + +## Restore-state module stack + INF UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf diff --git a/Features/Intel/PowerManagement/S3FeaturePkg/Include/S3Feature.= dsc b/Features/Intel/PowerManagement/S3FeaturePkg/Include/S3Feature.dsc index cc34e785076a..d8bfc7909413 100644 --- a/Features/Intel/PowerManagement/S3FeaturePkg/Include/S3Feature.dsc +++ b/Features/Intel/PowerManagement/S3FeaturePkg/Include/S3Feature.dsc @@ -7,6 +7,7 @@ # for the build infrastructure. # # Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2022, Baruch Binyamin Doron.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -25,6 +26,10 @@ !error "DXE_ARCH must be specified to build this feature!" !endif =20 +[PcdsFixedAtBuild] + # Attempts to improve performance at the cost of more DRAM usage + gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnS3Boot|TRUE + ##########################################################################= ###### # # Library Class section - list of all Library Classes needed by this featu= re. @@ -32,7 +37,14 @@ ##########################################################################= ###### =20 [LibraryClasses.common.PEIM] - SmmAccessLib|IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/P= eiSmmAccessLib.inf + #SmmAccessLib|IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLibS= mramc/PeiSmmAccessLib.inf + SmmControlLib|IntelSiliconPkg/Feature/SmmControl/Library/PeiSmmControlLi= b/PeiSmmControlLib.inf + +[LibraryClasses.common.DXE_DRIVER, LibraryClasses.common.DXE_SMM_DRIVER] + ####################################### + # Edk2 Packages + ####################################### + S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScrip= tLib.inf =20 ##########################################################################= ###### # @@ -60,8 +72,26 @@ # S3 Feature Package ##################################### =20 - # Add library instances here that are not included in package components= and should be tested - # in the package build. - # Add components here that should be included in the package build. S3FeaturePkg/S3Pei/S3Pei.inf + UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf + UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf + +# +# Feature DXE Components +# + +# @todo: Change below line to [Components.$(DXE_ARCH)] after https://bugzi= lla.tianocore.org/show_bug.cgi?id=3D2308 +# is completed. +[Components.X64] + ##################################### + # S3 Feature Package + ##################################### + + # Add components here that should be included in the package build. + UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf + MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf + S3FeaturePkg/S3Dxe/S3Dxe.inf + MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf + UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf + MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.= inf diff --git a/Features/Intel/PowerManagement/S3FeaturePkg/S3Dxe/S3Dxe.c b/Fe= atures/Intel/PowerManagement/S3FeaturePkg/S3Dxe/S3Dxe.c new file mode 100644 index 000000000000..1a7ccb8eedab --- /dev/null +++ b/Features/Intel/PowerManagement/S3FeaturePkg/S3Dxe/S3Dxe.c @@ -0,0 +1,155 @@ +/** @file + Source code file for S3 DXE module + +Copyright (c) 2022, Baruch Binyamin Doron.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PEI_ADDITIONAL_MEMORY_SIZE (16 * EFI_PAGE_SIZE) + +/** + Get the mem size in memory type information table. + + @return the mem size in memory type information table. +**/ +UINT64 +EFIAPI +GetMemorySizeInMemoryTypeInformation ( + VOID + ) +{ + EFI_STATUS Status; + EFI_MEMORY_TYPE_INFORMATION *MemoryData; + UINT8 Index; + UINTN TempPageNum; + + Status =3D EfiGetSystemConfigurationTable (&gEfiMemoryTypeInformationGui= d, (VOID **) &MemoryData); + + if (EFI_ERROR (Status) || MemoryData =3D=3D NULL) { + return 0; + } + + TempPageNum =3D 0; + for (Index =3D 0; MemoryData[Index].Type !=3D EfiMaxMemoryType; Index++)= { + // + // Accumulate default memory size requirements + // + TempPageNum +=3D MemoryData[Index].NumberOfPages; + } + + return TempPageNum * EFI_PAGE_SIZE; +} + +/** + Get the mem size need to be consumed and reserved for PEI phase resume. + + @return the mem size to be reserved for PEI phase resume. +**/ +UINT64 +EFIAPI +GetPeiMemSize ( + VOID + ) +{ + UINT64 Size; + + Size =3D GetMemorySizeInMemoryTypeInformation (); + + return PcdGet32 (PcdPeiMinMemSize) + Size + PEI_ADDITIONAL_MEMORY_SIZE; +} + +/** + Allocate EfiACPIMemoryNVS below 4G memory address. + + This function allocates EfiACPIMemoryNVS below 4G memory address. + + @param Size Size of memory to allocate. + + @return Allocated address for output. + +**/ +VOID * +EFIAPI +AllocateAcpiNvsMemoryBelow4G ( + IN UINTN Size + ) +{ + UINTN Pages; + EFI_PHYSICAL_ADDRESS Address; + EFI_STATUS Status; + VOID *Buffer; + + Pages =3D EFI_SIZE_TO_PAGES (Size); + Address =3D 0xffffffff; + + Status =3D gBS->AllocatePages ( + AllocateMaxAddress, + EfiACPIMemoryNVS, + Pages, + &Address + ); + ASSERT_EFI_ERROR (Status); + + Buffer =3D (VOID *)(UINTN)Address; + ZeroMem (Buffer, Size); + + return Buffer; +} + +/** + Allocates memory to use on S3 resume. + + @param[in] ImageHandle Not used. + @param[in] SystemTable General purpose services available to e= very DXE driver. + + @retval EFI_SUCCESS The function completes successfully + @retval EFI_OUT_OF_RESOURCES Insufficient resources to create databa= se +**/ +EFI_STATUS +EFIAPI +S3DxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + UINT64 S3PeiMemSize; + UINT64 S3PeiMemBase; + ACPI_S3_MEMORY S3MemoryInfo; + EFI_STATUS Status; + + DEBUG ((DEBUG_INFO, "%a() Start\n", __FUNCTION__)); + + S3PeiMemSize =3D GetPeiMemSize (); + S3PeiMemBase =3D (UINTN) AllocateAcpiNvsMemoryBelow4G (S3PeiMemSize); + ASSERT (S3PeiMemBase !=3D 0); + + S3MemoryInfo.S3PeiMemBase =3D S3PeiMemBase; + S3MemoryInfo.S3PeiMemSize =3D S3PeiMemSize; + + DEBUG ((DEBUG_INFO, "S3PeiMemBase: 0x%x\n", S3PeiMemBase)); + DEBUG ((DEBUG_INFO, "S3PeiMemSize: 0x%x\n", S3PeiMemSize)); + + Status =3D gRT->SetVariable ( + ACPI_S3_MEMORY_NV_NAME, + &gEfiAcpiVariableGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACC= ESS, + sizeof (S3MemoryInfo), + &S3MemoryInfo + ); + ASSERT_EFI_ERROR (Status); + + DEBUG ((DEBUG_INFO, "%a() End\n", __FUNCTION__)); + return EFI_SUCCESS; +} diff --git a/Features/Intel/PowerManagement/S3FeaturePkg/S3Dxe/S3Dxe.inf b/= Features/Intel/PowerManagement/S3FeaturePkg/S3Dxe/S3Dxe.inf new file mode 100644 index 000000000000..28589c2c869b --- /dev/null +++ b/Features/Intel/PowerManagement/S3FeaturePkg/S3Dxe/S3Dxe.inf @@ -0,0 +1,49 @@ +### @file +# Component information file for the S3 DXE module. +# +# Copyright (c) 2022, Baruch Binyamin Doron.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +### + +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D S3Dxe + FILE_GUID =3D 30926F92-CC83-4381-9F70-AC96EDB5BEE0 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_DRIVER + ENTRY_POINT =3D S3DxeEntryPoint + +[LibraryClasses] + UefiDriverEntryPoint + UefiBootServicesTableLib + UefiRuntimeServicesTableLib + BaseMemoryLib + DebugLib + PcdLib + UefiLib + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + MinPlatformPkg/MinPlatformPkg.dec + IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec + S3FeaturePkg/S3FeaturePkg.dec + +[Sources] + S3Dxe.c + +[Pcd] + gIntelFsp2WrapperTokenSpaceGuid.PcdPeiMinMemSize + +[FeaturePcd] + gS3FeaturePkgTokenSpaceGuid.PcdS3FeatureEnable + +[Guids] + gEfiMemoryTypeInformationGuid ## CONSUMES + gEfiAcpiVariableGuid ## CONSUMES + +[Depex] + gEfiVariableArchProtocolGuid AND + gEfiVariableWriteArchProtocolGuid diff --git a/Features/Intel/PowerManagement/S3FeaturePkg/S3Pei/S3Pei.c b/Fe= atures/Intel/PowerManagement/S3FeaturePkg/S3Pei/S3Pei.c index b0aaa04962c8..6acb894b6fc9 100644 --- a/Features/Intel/PowerManagement/S3FeaturePkg/S3Pei/S3Pei.c +++ b/Features/Intel/PowerManagement/S3FeaturePkg/S3Pei/S3Pei.c @@ -2,12 +2,87 @@ Source code file for S3 PEI module =20 Copyright (c) 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2022, Baruch Binyamin Doron.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 +#include +#include +#include #include #include +#include + +// TODO: Finalise implementation factoring +#define R_SA_PAM0 (0x80) +#define R_SA_PAM5 (0x85) +#define R_SA_PAM6 (0x86) + +/** + This function is called after FspSiliconInitDone installed PPI. + For FSP API mode, this is when FSP-M HOBs are installed into EDK2. + + @param[in] PeiServices Pointer to PEI Services Table. + @param[in] NotifyDesc Pointer to the descriptor for the Notification= event that + caused this function to execute. + @param[in] Ppi Pointer to the PPI data associated with this f= unction. + + @retval EFI_STATUS Always return EFI_SUCCESS +**/ +EFI_STATUS +EFIAPI +FspSiliconInitDoneNotify ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc, + IN VOID *Ppi + ) +{ + EFI_STATUS Status; + EFI_BOOT_MODE BootMode; + UINT64 MchBaseAddress; + + Status =3D PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + + // Enable PAM regions for AP wakeup vector (resume) + // - CPU is finalised by PiSmmCpuDxeSmm, not FSP. So, it's safe here? + // TODO/TEST: coreboot does this unconditionally, vendor FWs may not (te= st resume). Should we? + // - It is certainly interesting that only PAM0, PAM5 and PAM6 are defin= ed for KabylakeSiliconPkg. + // - Also note that 0xA0000-0xFFFFF is marked "reserved" in FSP HOB - th= is does not mean + // that the memory is unusable, perhaps this is precisely because it w= ill contain + // the AP wakeup vector. + if (BootMode =3D=3D BOOT_ON_S3_RESUME) { + MchBaseAddress =3D PCI_LIB_ADDRESS (0, 0, 0, 0); + PciWrite8 (MchBaseAddress + R_SA_PAM0, 0x30); + PciWrite8 (MchBaseAddress + (R_SA_PAM0 + 1), 0x33); + PciWrite8 (MchBaseAddress + (R_SA_PAM0 + 2), 0x33); + PciWrite8 (MchBaseAddress + (R_SA_PAM0 + 3), 0x33); + PciWrite8 (MchBaseAddress + (R_SA_PAM0 + 4), 0x33); + PciWrite8 (MchBaseAddress + R_SA_PAM5, 0x33); + PciWrite8 (MchBaseAddress + R_SA_PAM6, 0x33); + } + + // + // Install EFI_PEI_MM_ACCESS_PPI for S3 resume case + // + Status =3D PeiInstallSmmAccessPpi (); + ASSERT_EFI_ERROR (Status); + + // + // Install EFI_PEI_MM_CONTROL_PPI for S3 resume case + // + Status =3D PeiInstallSmmControlPpi (); + ASSERT_EFI_ERROR (Status); + + return Status; +} + +EFI_PEI_NOTIFY_DESCRIPTOR mFspSiliconInitDoneNotifyDesc =3D { + (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINA= TE_LIST), + &gFspSiliconInitDonePpiGuid, + FspSiliconInitDoneNotify +}; =20 /** S3 PEI module entry point @@ -25,12 +100,10 @@ S3PeiEntryPoint ( IN CONST EFI_PEI_SERVICES **PeiServices ) { - EFI_STATUS Status; + EFI_STATUS Status; =20 - // - // Install EFI_PEI_MM_ACCESS_PPI for S3 resume case - // - Status =3D PeiInstallSmmAccessPpi (); + Status =3D PeiServicesNotifyPpi (&mFspSiliconInitDoneNotifyDesc); + ASSERT_EFI_ERROR (Status); =20 return Status; } diff --git a/Features/Intel/PowerManagement/S3FeaturePkg/S3Pei/S3Pei.inf b/= Features/Intel/PowerManagement/S3FeaturePkg/S3Pei/S3Pei.inf index e485eac9521f..173919bb881e 100644 --- a/Features/Intel/PowerManagement/S3FeaturePkg/S3Pei/S3Pei.inf +++ b/Features/Intel/PowerManagement/S3FeaturePkg/S3Pei/S3Pei.inf @@ -18,10 +18,13 @@ [LibraryClasses] PeimEntryPoint PeiServicesLib + DebugLib SmmAccessLib + SmmControlLib =20 [Packages] MdePkg/MdePkg.dec + IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec IntelSiliconPkg/IntelSiliconPkg.dec S3FeaturePkg/S3FeaturePkg.dec =20 @@ -31,5 +34,8 @@ [FeaturePcd] gS3FeaturePkgTokenSpaceGuid.PcdS3FeatureEnable =20 +[Ppis] + gFspSiliconInitDonePpiGuid + [Depex] - gEfiPeiMemoryDiscoveredPpiGuid + TRUE diff --git a/Platform/Intel/MinPlatformPkg/Include/AcpiS3MemoryNvData.h b/P= latform/Intel/MinPlatformPkg/Include/AcpiS3MemoryNvData.h new file mode 100644 index 000000000000..0d75af8e9a03 --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/Include/AcpiS3MemoryNvData.h @@ -0,0 +1,22 @@ +/** @file + Header file for NV data structure definition. + +Copyright (c) 2021, Baruch Binyamin Doron +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __ACPI_S3_MEMORY_NV_DATA_H__ +#define __ACPI_S3_MEMORY_NV_DATA_H__ + +// +// NV data structure +// +typedef struct { + UINT64 S3PeiMemBase; + UINT64 S3PeiMemSize; +} ACPI_S3_MEMORY; + +#define ACPI_S3_MEMORY_NV_NAME L"S3MemoryInfo" + +#endif --=20 2.37.2 -=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 (#93258): https://edk2.groups.io/g/devel/message/93258 Mute This Topic: https://groups.io/mt/93506111/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue May 14 10:07:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93259+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93259+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1662483771; cv=none; d=zohomail.com; s=zohoarc; b=KzL0/VEQYhvRfyLNHhoNElEMq8cU1wjxFcpPakehiooCvG5ui7zdIWNjW6y/UujSGXxsWZV7Zq7S7CzAI8UB8SfYRFzt7dRHG/QDcfaulW3vZaA0pscOmNVzRzVewlYDhzCiVe/J4py/qpXUvfXC71CjuGspnERDFppgwOQb0wY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662483771; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=A1YpWaIJNVKgZvhfX+K0q/Lf4kDBxp53+U9UN8CIIJg=; b=MXSpE3sXqneESbjFw3kKpfG1oKKUzTfVFUc0EaOBlb5yZb9YebXqL+W3+m2kllBETwq1D+sHMWsL0nv2Cg3yBUPC2XoJTQDS76byccJSPe8w9KP2yo4sz4g+wE3npWXdua12ocoVD3SWR5XdsPxEQXN21zv2OWTFTOrTdck3Utg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93259+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1662483771653404.66269730609986; Tue, 6 Sep 2022 10:02:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id xBwAYY1788612xWA17C4NxWy; Tue, 06 Sep 2022 10:02:51 -0700 X-Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by mx.groups.io with SMTP id smtpd.web08.1836.1662483770425426824 for ; Tue, 06 Sep 2022 10:02:50 -0700 X-Received: by mail-qk1-f181.google.com with SMTP id f4so8636471qkl.7 for ; Tue, 06 Sep 2022 10:02:50 -0700 (PDT) X-Gm-Message-State: Fz8weUbuS4JsjN0Y7nKnaraMx1787277AA= X-Google-Smtp-Source: AA6agR61C5/ZMbXQ23uEr7oT9suAp2x96M2+BQhG76l2xh7wvfTcIJwqH5P9tEpwLe1W50oEOmTxMg== X-Received: by 2002:a05:620a:bc6:b0:6bc:644b:8e94 with SMTP id s6-20020a05620a0bc600b006bc644b8e94mr36147313qki.321.1662483769052; Tue, 06 Sep 2022 10:02:49 -0700 (PDT) X-Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:46bc:db07:bbf3:df6d]) by smtp.gmail.com with ESMTPSA id bi13-20020a05620a318d00b006b59f02224asm10895809qkb.60.2022.09.06.10.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:02:48 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Ankit Sinha , Isaac Oram , Liming Gao , Eric Dong Subject: [edk2-devel][edk2-platforms][PATCH v2 5/6] MinPlatformPkg: Implement working S3 resume Date: Tue, 6 Sep 2022 13:02:27 -0400 Message-Id: <0e97006ee5e35e8399bd8fe1b463664c301c5644.1662483691.git.benjamin.doron00@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,benjamin.doron00@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662483771; bh=nS4dcJn1whKLroyTWlTEse3R+fwfkC1cs/VF/14GkVw=; h=Cc:Date:From:Reply-To:Subject:To; b=h9X5rR0si0TksV1FBuqFKjkXRm7aR5bCe87dIcC/7b7ms+XzTe7f+Y1kRfYOA0pmdKe eQk9hQp/pVZK/QWn4/EXHc+qYngKYzStF/A5eVH63SXozsgkvCBNqwe7K6Jwe5DQgdwqg 6oMGRp68XlZktHg05LGpY8l8UZMJO4658+c= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662483773349100019 Content-Type: text/plain; charset="utf-8" Consume S3 resume memory allocation on resume flow. Also, include complementary FirmwarePerformanceDataTablePei module in MinPlatform FV for S3 resume performance measurement. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Ankit Sinha Cc: Isaac Oram Cc: Liming Gao Cc: Eric Dong Signed-off-by: Benjamin Doron --- .../FspWrapperHobProcessLib.c | 69 ++++++++++++++++++- .../PeiFspWrapperHobProcessLib.inf | 2 + .../Include/Dsc/CorePeiInclude.dsc | 2 + .../Include/Fdf/CorePostMemoryInclude.fdf | 2 + 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapper= HobProcessLib/FspWrapperHobProcessLib.c b/Platform/Intel/MinPlatformPkg/Fsp= Wrapper/Library/PeiFspWrapperHobProcessLib/FspWrapperHobProcessLib.c index 7ee4d3a31c49..9bd6fe6290c5 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperHobProc= essLib/FspWrapperHobProcessLib.c +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperHobProc= essLib/FspWrapperHobProcessLib.c @@ -16,14 +16,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include #include #include #include +#include =20 #include +#include =20 // // Additional pages are used by DXE memory manager. @@ -130,6 +133,55 @@ GetPeiMemSize ( return MinSize + Size + PEI_ADDITIONAL_MEMORY_SIZE; } =20 +/** + Get S3 PEI memory information. + + @note At this point, memory is ready, and PeiServices are available to u= se. + Platform can get some data from SMRAM directly. + + @param[out] S3PeiMemSize PEI memory size to be installed in S3 phase. + @param[out] S3PeiMemBase PEI memory base to be installed in S3 phase. + + @return If S3 PEI memory information is got successfully. +**/ +EFI_STATUS +EFIAPI +GetS3MemoryInfo ( + OUT UINT64 *S3PeiMemSize, + OUT EFI_PHYSICAL_ADDRESS *S3PeiMemBase + ) +{ + EFI_STATUS Status; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariablePpi; + UINTN DataSize; + ACPI_S3_MEMORY S3MemoryInfo; + + *S3PeiMemBase =3D 0; + *S3PeiMemSize =3D 0; + + Status =3D PeiServicesLocatePpi (&gEfiPeiReadOnlyVariable2PpiGuid, 0, NU= LL, (VOID **) &VariablePpi); + ASSERT_EFI_ERROR (Status); + + DataSize =3D sizeof (S3MemoryInfo); + Status =3D VariablePpi->GetVariable ( + VariablePpi, + ACPI_S3_MEMORY_NV_NAME, + &gEfiAcpiVariableGuid, + NULL, + &DataSize, + &S3MemoryInfo + ); + ASSERT_EFI_ERROR (Status); + + if (EFI_ERROR (Status)) { + return Status; + } + + *S3PeiMemBase =3D S3MemoryInfo.S3PeiMemBase; + *S3PeiMemSize =3D S3MemoryInfo.S3PeiMemSize; + return EFI_SUCCESS; +} + /** Post FSP-M HOB process for Memory Resource Descriptor. =20 @@ -280,7 +332,7 @@ PostFspmHobProcess ( 0x1000 ); =20 - + if (BootMode !=3D BOOT_ON_S3_RESUME) { // // Capsule mode // @@ -337,7 +389,22 @@ PostFspmHobProcess ( if (Capsule !=3D NULL) { Status =3D Capsule->CreateState ((EFI_PEI_SERVICES **)PeiServices, C= apsuleBuffer, CapsuleBufferLength); } + } else { + Status =3D GetS3MemoryInfo (&PeiMemSize, &PeiMemBase); + ASSERT_EFI_ERROR (Status); =20 + DEBUG ((DEBUG_INFO, "S3 resume PeiMemBase : 0x%08x\n", PeiMemBa= se)); + DEBUG ((DEBUG_INFO, "S3 resume PeiMemSize : 0x%08x\n", PeiMemSi= ze)); + + // + // Install efi memory + // + Status =3D PeiServicesInstallPeiMemory ( + PeiMemBase, + PeiMemSize + ); + ASSERT_EFI_ERROR (Status); + } =20 // // Create a memory allocation HOB at fixed location for MP Services PPI = AP wait loop. diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapper= HobProcessLib/PeiFspWrapperHobProcessLib.inf b/Platform/Intel/MinPlatformPk= g/FspWrapper/Library/PeiFspWrapperHobProcessLib/PeiFspWrapperHobProcessLib.= inf index b846e7af1d2d..e2aac36bf018 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperHobProc= essLib/PeiFspWrapperHobProcessLib.inf +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperHobProc= essLib/PeiFspWrapperHobProcessLib.inf @@ -75,7 +75,9 @@ gZeroGuid gEfiGraphicsInfoHobGuid gEfiGraphicsDeviceInfoHobGuid + gEfiAcpiVariableGuid =20 [Ppis] gEfiPeiCapsulePpiGuid ## CONSUMES + gEfiPeiReadOnlyVariable2PpiGuid ## CONSUMES gEdkiiSiliconInitializedPpiGuid ## PRODUCES diff --git a/Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiInclude.dsc b= /Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiInclude.dsc index 08e50cac075f..f271fb26b189 100644 --- a/Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiInclude.dsc +++ b/Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiInclude.dsc @@ -41,3 +41,5 @@ NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256= .inf } !endif + + MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerf= ormancePei.inf diff --git a/Platform/Intel/MinPlatformPkg/Include/Fdf/CorePostMemoryInclud= e.fdf b/Platform/Intel/MinPlatformPkg/Include/Fdf/CorePostMemoryInclude.fdf index 3c2716d6728a..160f02650a8c 100644 --- a/Platform/Intel/MinPlatformPkg/Include/Fdf/CorePostMemoryInclude.fdf +++ b/Platform/Intel/MinPlatformPkg/Include/Fdf/CorePostMemoryInclude.fdf @@ -6,3 +6,5 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent # ## + + INF MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/Firmwar= ePerformancePei.inf --=20 2.37.2 -=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 (#93259): https://edk2.groups.io/g/devel/message/93259 Mute This Topic: https://groups.io/mt/93506112/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue May 14 10:07:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93260+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93260+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1662483774; cv=none; d=zohomail.com; s=zohoarc; b=bbjRHzmtcDyp99djLMvXHu8IHwcblZvKE7qHzgPk5119Gp5/EQzyGK5ypTY+wePNhKibsnP8qnIA6hxm6zPEOCnfSmVVCsOq17SbwwoQnJjyY5z28TrJgOtFhr3e2FUX9AySZghcaTGqhQy8NCgA2WNg9P8srxJTKB1cily1ZZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662483774; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=VRH5TyKkPhKgz7N8WJDcFcuoZqQ2oRKmSOdwRHFUiEc=; b=fvOGkQn5QYO2b8a2bcp+Z+tr112+Whj/UhSDF3hPICKUHV0G2dYxV7FDzLQDyEUhyMUXKzB5LLCO8NqTIoiCWdqp+QbZFHODYhcdcSTZutz3i3IvX8mIEBnY+QWDI/DfGWvdXkPCQiyFJc5L9+Z4+qsJf4Xbu+KP5olC7/YfQ3g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93260+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1662483774179662.0756587712008; Tue, 6 Sep 2022 10:02:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 1uYgYY1788612x1VAWtxkfWF; Tue, 06 Sep 2022 10:02:52 -0700 X-Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) by mx.groups.io with SMTP id smtpd.web11.1763.1662483771895019112 for ; Tue, 06 Sep 2022 10:02:52 -0700 X-Received: by mail-qk1-f179.google.com with SMTP id g16so8613314qkl.11 for ; Tue, 06 Sep 2022 10:02:51 -0700 (PDT) X-Gm-Message-State: A7j3ZRnqdFqmgBfk2VLCC93Mx1787277AA= X-Google-Smtp-Source: AA6agR5sMn6dYxoca6v7y4awcJzj2h44lxuCrwpLcn2VZo2Ivivg/9uDfZsBAz6YPP1zgm/qOxnhNQ== X-Received: by 2002:a05:620a:468e:b0:6bb:1974:ef78 with SMTP id bq14-20020a05620a468e00b006bb1974ef78mr36300487qkb.87.1662483770574; Tue, 06 Sep 2022 10:02:50 -0700 (PDT) X-Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:46bc:db07:bbf3:df6d]) by smtp.gmail.com with ESMTPSA id bi13-20020a05620a318d00b006b59f02224asm10895809qkb.60.2022.09.06.10.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:02:50 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Nate DeSimone , Ankit Sinha , Chasel Chiu , Jeremy Soller , Sai Chaganty , Isaac Oram Subject: [edk2-devel][edk2-platforms][PATCH v2 6/6] KabylakeOpenBoardPkg: Example of board S3 Date: Tue, 6 Sep 2022 13:02:28 -0400 Message-Id: <057e815e2d8215be6b422b71ddc733f077cc3132.1662483691.git.benjamin.doron00@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,benjamin.doron00@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662483772; bh=YUSTyrKu9qkVx1fQ3Bn29NyF4dyR+kZ5uah7gurWQB8=; h=Cc:Date:From:Reply-To:Subject:To; b=LzRTL3RNKOkF3eQhRpVJzPfRX/BC7CkpFwVBTCuS6EFUvQZv/5j0XooVXfh80MBr6N9 QIHTjxejZ6w6D2WAVtko1GXFfwCHZsEm9JYWEEZD62KQWoLzM9rvTa/SibsnX9z1XV3Ny lFpsLIACvzsOAu8l4NNTHeuCurPIMu/VRAM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662483775440100021 Content-Type: text/plain; charset="utf-8" Use silicon code to detect S3 resume state. Apply some relevant policy modifications. PcdPeiMemSize must be in common scope, for a DXE module to allocate required memory. Libraries that produce required PPIs are defined. BootScriptExecutorDxe should only be linked against a functionally compatible debug stack. Cc: Nate DeSimone Cc: Ankit Sinha Cc: Chasel Chiu Cc: Jeremy Soller Cc: Sai Chaganty Cc: Isaac Oram Signed-off-by: Benjamin Doron --- .../PeiFspMiscUpdUpdateLib.c | 12 +++- .../PeiSaPolicyUpdate.c | 12 +++- .../PeiAspireVn7Dash572GInitPreMemLib.c | 61 ++++++++++++++----- .../BoardInitLib/PeiBoardInitPreMemLib.inf | 3 + .../AspireVn7Dash572G/OpenBoardPkg.dsc | 21 +++++++ .../AspireVn7Dash572G/OpenBoardPkgPcd.dsc | 16 ++--- .../PeiSiliconPolicyUpdateLib.c | 11 +++- .../PeiSiliconPolicyUpdateLib.inf | 1 + .../PeiFspMiscUpdUpdateLib.c | 11 +++- .../PeiSaPolicyUpdate.c | 12 +++- .../BoardInitLib/PeiBoardInitPreMemLib.inf | 1 + .../BoardInitLib/PeiGalagoPro3InitPreMemLib.c | 27 +++++++- .../PeiMultiBoardInitPreMemLib.inf | 1 + .../GalagoPro3/OpenBoardPkg.dsc | 15 +++++ .../GalagoPro3/OpenBoardPkgPcd.dsc | 2 +- .../PeiFspMiscUpdUpdateLib.c | 12 +++- .../PeiSaPolicyUpdate.c | 12 +++- .../BoardInitLib/PeiBoardInitPreMemLib.inf | 1 + .../PeiKabylakeRvp3InitPreMemLib.c | 27 +++++++- .../PeiMultiBoardInitPreMemLib.inf | 1 + .../KabylakeRvp3/OpenBoardPkg.dsc | 12 ++++ .../KabylakeRvp3/OpenBoardPkgPcd.dsc | 2 +- .../PeiSiliconPolicyUpdateLib.c | 11 +++- .../PeiSiliconPolicyUpdateLib.inf | 1 + 24 files changed, 245 insertions(+), 40 deletions(-) diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapp= er/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform= /Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSilicon= PolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c index a9b7e446c8d6..7e4194bf4fe6 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Libr= ary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Libr= ary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c @@ -11,6 +11,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include + #include #include #include @@ -32,11 +34,15 @@ PeiFspMiscUpdUpdatePreMem ( ) { EFI_STATUS Status; + EFI_BOOT_MODE BootMode; UINTN VariableSize; VOID *FspNvsBufferPtr; UINT8 MorControl; VOID *MorControlPtr; =20 + Status =3D PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + // // Initialize S3 Data variable (S3DataPtr). It may be used for warm and = fast boot paths. // @@ -70,7 +76,11 @@ PeiFspMiscUpdUpdatePreMem ( &VariableSize ); DEBUG ((DEBUG_INFO, "MorControl - 0x%x (%r)\n", MorControl, Status)); - if (MOR_CLEAR_MEMORY_VALUE (MorControl)) { + // + // Do not set CleanMemory on S3 resume + // TODO: Handle advanced features later - capsule update is in-memory li= st + // + if (MOR_CLEAR_MEMORY_VALUE (MorControl) && BootMode !=3D BOOT_ON_S3_RESU= ME) { FspmUpd->FspmConfig.CleanMemory =3D (BOOLEAN)(MorControl & MOR_CLEAR_M= EMORY_BIT_MASK); } =20 diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapp= er/Library/PeiSiliconPolicyUpdateLibFsp/PeiSaPolicyUpdate.c b/Platform/Inte= l/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolic= yUpdateLibFsp/PeiSaPolicyUpdate.c index 4621cbd3ca3a..1299bf504fbd 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Libr= ary/PeiSiliconPolicyUpdateLibFsp/PeiSaPolicyUpdate.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Libr= ary/PeiSiliconPolicyUpdateLibFsp/PeiSaPolicyUpdate.c @@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 /** Performs FSP SA PEI Policy initialization. @@ -27,12 +28,17 @@ PeiFspSaPolicyUpdate ( IN OUT FSPS_UPD *FspsUpd ) { + EFI_STATUS Status; + EFI_BOOT_MODE BootMode; VOID *Buffer; VOID *MemBuffer; UINT32 Size; =20 DEBUG((DEBUG_INFO, "\nUpdating SA Policy in Post Mem\n")); =20 + Status =3D PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + FspsUpd->FspsConfig.PeiGraphicsPeimInit =3D 1; =20 Size =3D 0; @@ -40,7 +46,11 @@ PeiFspSaPolicyUpdate ( PeiGetSectionFromAnyFv (PcdGetPtr (PcdGraphicsVbtGuid), EFI_SECTION_RA= W, 0, &Buffer, &Size); if (Buffer =3D=3D NULL) { DEBUG((DEBUG_WARN, "Could not locate VBT\n")); - } else { + // + // Graphics initialisation is unnecessary, + // OS has present framebuffer. + // + } else if (BootMode !=3D BOOT_ON_S3_RESUME) { MemBuffer =3D (VOID *)AllocatePages (EFI_SIZE_TO_PAGES ((UINTN)Size)= ); if ((MemBuffer !=3D NULL) && (Buffer !=3D NULL)) { CopyMem (MemBuffer, (VOID *)Buffer, (UINTN)Size); diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/= BoardInitLib/PeiAspireVn7Dash572GInitPreMemLib.c b/Platform/Intel/KabylakeO= penBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/PeiAspireVn7Dash572GInit= PreMemLib.c index 1c9a65399b54..1b4c6b484b43 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardIn= itLib/PeiAspireVn7Dash572GInitPreMemLib.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardIn= itLib/PeiAspireVn7Dash572GInitPreMemLib.c @@ -11,7 +11,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include +#include #include #include #include @@ -248,6 +250,8 @@ AspireVn7Dash572GBoardDebugInit ( VOID ) { + UINT16 ABase; + /// /// Do Early PCH init /// @@ -258,6 +262,16 @@ AspireVn7Dash572GBoardDebugInit ( // - Alternatively, move the preceding calls to BoardDetect() AspireVn7Dash572GBoardDetect (); =20 + // Dump relevant registers + // - TODO: Remove after debugging + DEBUG ((DEBUG_INFO, "PMC GEN_PMCON_A=3D 0x%x\n", PciRead32 ((UINTN)PCI_L= IB_ADDRESS (0, PCI_DEVICE_NUMBER_PCH_PMC, PCI_FUNCTION_NUMBER_PCH_PMC, R_PC= H_PMC_GEN_PMCON_A)))); + DEBUG ((DEBUG_INFO, "PMC GEN_PMCON_B=3D 0x%x\n", PciRead32 ((UINTN)PCI_L= IB_ADDRESS (0, PCI_DEVICE_NUMBER_PCH_PMC, PCI_FUNCTION_NUMBER_PCH_PMC, R_PC= H_PMC_GEN_PMCON_B)))); + + PchAcpiBaseGet (&ABase); + DEBUG ((DEBUG_INFO, "ABase PM1_STS=3D 0x%x\n", IoRead16 (ABase))); + DEBUG ((DEBUG_INFO, "ABase PM1_EN=3D 0x%x\n", IoRead16 (ABase + R_PCH_AC= PI_PM1_EN))); + DEBUG ((DEBUG_INFO, "ABase PM1_CNT=3D 0x%x\n", IoRead32 (ABase + R_PCH_A= CPI_PM1_CNT))); + return EFI_SUCCESS; } =20 @@ -267,25 +281,42 @@ AspireVn7Dash572GBoardBootModeDetect ( VOID ) { - UINT16 ABase; + EFI_BOOT_MODE BootMode; UINT32 SleepType; + UINT16 ABase; =20 DEBUG ((DEBUG_INFO, "Performing boot mode detection\n")); =20 - // TODO: Perform advanced detection (recovery/capsule) - // FIXME: This violates PI specification? But BOOT_WITH* would always ta= ke precedence - // over BOOT_ON_S{4,5}... - PchAcpiBaseGet (&ABase); - SleepType =3D IoRead32 (ABase + R_PCH_ACPI_PM1_CNT) & B_PCH_ACPI_PM1_CNT= _SLP_TYP; + // Known sane defaults; TODO: Consider "default"? + BootMode =3D BOOT_WITH_FULL_CONFIGURATION; =20 - switch (SleepType) { - case V_PCH_ACPI_PM1_CNT_S3: - return BOOT_ON_S3_RESUME; - case V_PCH_ACPI_PM1_CNT_S4: - return BOOT_ON_S4_RESUME; -// case V_PCH_ACPI_PM1_CNT_S5: -// return BOOT_ON_S5_RESUME; - default: - return BOOT_WITH_FULL_CONFIGURATION; + // TODO: Perform advanced detection (capsule/recovery) + // TODO: Perform "IsFirstBoot" test with VariablePpi for "minimal"/"assu= me" + if (GetSleepTypeAfterWakeup (&SleepType)) { + switch (SleepType) { + case V_PCH_ACPI_PM1_CNT_S3: + BootMode =3D BOOT_ON_S3_RESUME; + break; + case V_PCH_ACPI_PM1_CNT_S4: + BootMode =3D BOOT_ON_S4_RESUME; + break; + case V_PCH_ACPI_PM1_CNT_S5: + BootMode =3D BOOT_ON_S5_RESUME; + break; + } } + + DEBUG ((DEBUG_INFO, "BootMode is 0x%x\n", BootMode)); + + // Dump relevant registers + // - TODO: Remove after debugging + DEBUG ((DEBUG_INFO, "PMC GEN_PMCON_A=3D 0x%x\n", PciRead32 ((UINTN)PCI_L= IB_ADDRESS (0, PCI_DEVICE_NUMBER_PCH_PMC, PCI_FUNCTION_NUMBER_PCH_PMC, R_PC= H_PMC_GEN_PMCON_A)))); + DEBUG ((DEBUG_INFO, "PMC GEN_PMCON_B=3D 0x%x\n", PciRead32 ((UINTN)PCI_L= IB_ADDRESS (0, PCI_DEVICE_NUMBER_PCH_PMC, PCI_FUNCTION_NUMBER_PCH_PMC, R_PC= H_PMC_GEN_PMCON_B)))); + + PchAcpiBaseGet (&ABase); + DEBUG ((DEBUG_INFO, "ABase PM1_STS=3D 0x%x\n", IoRead16 (ABase))); + DEBUG ((DEBUG_INFO, "ABase PM1_EN=3D 0x%x\n", IoRead16 (ABase + R_PCH_AC= PI_PM1_EN))); + DEBUG ((DEBUG_INFO, "ABase PM1_CNT=3D 0x%x\n", IoRead32 (ABase + R_PCH_A= CPI_PM1_CNT))); + + return BootMode; } diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/= BoardInitLib/PeiBoardInitPreMemLib.inf b/Platform/Intel/KabylakeOpenBoardPk= g/AspireVn7Dash572G/Library/BoardInitLib/PeiBoardInitPreMemLib.inf index cd9f979d313c..c53114e15450 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardIn= itLib/PeiBoardInitPreMemLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardIn= itLib/PeiBoardInitPreMemLib.inf @@ -25,11 +25,14 @@ TimerLib PchCycleDecodingLib PchResetLib + PciLib IoLib EcLib BoardEcLib GpioLib PeiLib + PeiServicesLib + PchPmcLib =20 [Packages] MinPlatformPkg/MinPlatformPkg.dec diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoar= dPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardP= kg.dsc index c71b7169a38a..f4552ee83d6b 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc @@ -248,6 +248,7 @@ # Silicon Package ####################################### ReportCpuHobLib|IntelSiliconPkg/Library/ReportCpuHobLib/ReportCpuHobLib.= inf + SmmAccessLib|IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLibSm= ramc/PeiSmmAccessLib.inf =20 ####################################### # Platform Package @@ -711,6 +712,26 @@ !endif } =20 +!if gS3FeaturePkgTokenSpaceGuid.PcdS3FeatureEnable =3D=3D TRUE + MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.= inf { + + # On S3 resume, RSC is in end-of-BS state + # - Moreover: Library cannot effectively use some end-of-BS events + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPor= t.inf + SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLib= Null.inf + # Reverse-ranked priority list +# TODO: Requires testing +# - Strongly suspect DebugLibSerialPort constructor presents PeiDxeSerialP= ortLibMem dependency on services as a bug +!if FALSE # $(USE_MEMORY_LOGGING) =3D=3D TRUE + SerialPortLib|MdeModulePkg/Library/PeiDxeSerialPortLibMem/DxeSerialP= ortLibMem.inf +!endif + # Also, can debug CpuExceptionHandlerLib +!if $(USE_HDMI_DEBUG_PORT) =3D=3D TRUE + SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPo= rtLib/BootScriptExecutorDxeI2cHdmiDebugSerialPortLib.inf +!endif + } +!endif + !endif =20 ####################################### diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoar= dPkgPcd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoa= rdPkgPcd.dsc index 3ed7aa0a2b10..490c3ee6bf76 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd= .dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd= .dsc @@ -127,10 +127,7 @@ # PcdIpmiFeatureEnable will not be enabled (no BMC) # TODO: Can be build-time (user) choice gNetworkFeaturePkgTokenSpaceGuid.PcdNetworkFeatureEnable = |FALSE - # TODO: Continue developing support. Broken at present. - # - PeiSmmAccessLib in IntelSiliconPkg seems like a stub - # - May require a PeiSmmControlLib to SMM communicate - gS3FeaturePkgTokenSpaceGuid.PcdS3FeatureEnable = |FALSE + gS3FeaturePkgTokenSpaceGuid.PcdS3FeatureEnable = |TRUE # TODO: Definitions (now added SmbiosDxe) gSmbiosFeaturePkgTokenSpaceGuid.PcdSmbiosFeatureEnable = |TRUE # Requires actual hook-up @@ -335,6 +332,7 @@ gMinPlatformPkgTokenSpaceGuid.PcdMaxCpuCoreCount|4 gMinPlatformPkgTokenSpaceGuid.PcdMaxCpuThreadCount|2 gMinPlatformPkgTokenSpaceGuid.PcdPciExpressRegionLength|0x10000000 + gIntelFsp2WrapperTokenSpaceGuid.PcdPeiMinMemSize|0x3800000 =20 # # The PCDs are used to control the Windows SMM Security Mitigations Tabl= e - Protection Flags @@ -360,13 +358,8 @@ # 0x7F, 0xFF, 0x04, 0x00}
gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleInputDevicePath|{0x02, 0x= 01, 0x0C, 0x00, 0xd0, 0x41, 0x03, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01= , 0x06, 0x00, 0x00, 0x1F, 0x02, 0x01, 0x0C, 0x00, 0xd0, 0x41, 0x03, 0x03,= 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x04, 0x00} =20 -!if $(TARGET) =3D=3D RELEASE - gMinPlatformPkgTokenSpaceGuid.PcdPlatformEfiReservedMemorySize|0x800 -!else - gMinPlatformPkgTokenSpaceGuid.PcdPlatformEfiReservedMemorySize|0x188B #= TODO -!endif - # TODO: Consider using reserved space instead for debug log - gMinPlatformPkgTokenSpaceGuid.PcdPlatformEfiRtDataMemorySize|0x200 + gMinPlatformPkgTokenSpaceGuid.PcdPlatformEfiAcpiNvsMemorySize|0x4800 + gMinPlatformPkgTokenSpaceGuid.PcdPlatformEfiRtDataMemorySize|0x100 !if $(TARGET) =3D=3D RELEASE gMinPlatformPkgTokenSpaceGuid.PcdPlatformEfiRtCodeMemorySize|0x70 !else @@ -447,7 +440,6 @@ # Edk2 Configuration ###################################### gIntelFsp2PkgTokenSpaceGuid.PcdGlobalDataPointerAddress|0xFED00148 - gIntelFsp2WrapperTokenSpaceGuid.PcdPeiMinMemSize|0x3800000 =20 ###################################### # Platform Configuration diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/L= ibrary/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c b/Platform/Int= el/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUp= dateLib/PeiSiliconPolicyUpdateLib.c index 3764f7c3ac09..ab8abac6be1c 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/= PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/= PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c @@ -20,6 +20,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include @@ -549,6 +550,7 @@ SiliconPolicyUpdatePostMem ( ) { EFI_STATUS Status; + EFI_BOOT_MODE BootMode; VOID *Buffer; VOID *MemBuffer; UINT32 Size; @@ -557,6 +559,9 @@ SiliconPolicyUpdatePostMem ( =20 DEBUG((DEBUG_INFO, "\nUpdating Policy in Post Mem\n")); =20 + Status =3D PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + GtConfig =3D NULL; Status =3D GetConfigBlock ((VOID *) Policy, &gGraphicsPeiConfigGuid, (VO= ID *)&GtConfig); ASSERT_EFI_ERROR (Status); @@ -571,7 +576,11 @@ SiliconPolicyUpdatePostMem ( PeiGetSectionFromAnyFv (PcdGetPtr (PcdGraphicsVbtGuid), EFI_SECTION_RA= W, 0, &Buffer, &Size); if (Buffer =3D=3D NULL) { DEBUG((DEBUG_WARN, "Could not locate VBT\n")); - } else { + // + // Graphics initialisation is unnecessary, + // OS has present framebuffer. + // + } else if (BootMode !=3D BOOT_ON_S3_RESUME) { MemBuffer =3D (VOID *)AllocatePages (EFI_SIZE_TO_PAGES ((UINTN)Size)= ); if ((MemBuffer !=3D NULL) && (Buffer !=3D NULL)) { CopyMem (MemBuffer, (VOID *)Buffer, (UINTN)Size); diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/L= ibrary/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf b/Platform/I= ntel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicy= UpdateLib/PeiSiliconPolicyUpdateLib.inf index 1ce26fc3dcec..31a45292209d 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/= PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/= PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf @@ -23,6 +23,7 @@ BaseMemoryLib MemoryAllocationLib PeiLib + PeiServicesLib CpuPlatformLib PchPcieRpLib PchInfoLib diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Libr= ary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel/= KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLi= bFsp/PeiFspMiscUpdUpdateLib.c index dbc84631acaa..ce309bd378d2 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/Pei= SiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/Pei= SiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c @@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 #include #include @@ -36,11 +37,15 @@ PeiFspMiscUpdUpdatePreMem ( ) { EFI_STATUS Status; + EFI_BOOT_MODE BootMode; UINTN VariableSize; VOID *FspNvsBufferPtr; UINT8 MorControl; VOID *MorControlPtr; =20 + Status =3D PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + // // Initialize S3 Data variable (S3DataPtr). It may be used for warm and = fast boot paths. // @@ -75,7 +80,11 @@ PeiFspMiscUpdUpdatePreMem ( &VariableSize ); DEBUG ((DEBUG_INFO, "MorControl - 0x%x (%r)\n", MorControl, Status)); - if (MOR_CLEAR_MEMORY_VALUE (MorControl)) { + // + // Do not set CleanMemory on S3 resume + // TODO: Handle advanced features later - capsule update is in-memory li= st + // + if (MOR_CLEAR_MEMORY_VALUE (MorControl) && BootMode !=3D BOOT_ON_S3_RESU= ME) { FspmUpd->FspmConfig.CleanMemory =3D (BOOLEAN)(MorControl & MOR_CLEAR_M= EMORY_BIT_MASK); } =20 diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Libr= ary/PeiSiliconPolicyUpdateLibFsp/PeiSaPolicyUpdate.c b/Platform/Intel/Kabyl= akeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/= PeiSaPolicyUpdate.c index 133b8c963f65..48899aa63b4f 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/Pei= SiliconPolicyUpdateLibFsp/PeiSaPolicyUpdate.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/Pei= SiliconPolicyUpdateLibFsp/PeiSaPolicyUpdate.c @@ -17,6 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 /** Performs FSP SA PEI Policy initialization. @@ -33,12 +34,17 @@ PeiFspSaPolicyUpdate ( IN OUT FSPS_UPD *FspsUpd ) { + EFI_STATUS Status; + EFI_BOOT_MODE BootMode; VOID *Buffer; VOID *MemBuffer; UINT32 Size; =20 DEBUG((DEBUG_INFO, "\nUpdating SA Policy in Post Mem\n")); =20 + Status =3D PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + FspsUpd->FspsConfig.PeiGraphicsPeimInit =3D 1; =20 Size =3D 0; @@ -46,7 +52,11 @@ PeiFspSaPolicyUpdate ( PeiGetSectionFromAnyFv (PcdGetPtr (PcdGraphicsVbtGuid), EFI_SECTION_RA= W, 0, &Buffer, &Size); if (Buffer =3D=3D NULL) { DEBUG((DEBUG_WARN, "Could not locate VBT\n")); - } else { + // + // Graphics initialisation is unnecessary, + // OS has present framebuffer. + // + } else if (BootMode !=3D BOOT_ON_S3_RESUME) { MemBuffer =3D (VOID *)AllocatePages (EFI_SIZE_TO_PAGES ((UINTN)Size)= ); if ((MemBuffer !=3D NULL) && (Buffer !=3D NULL)) { CopyMem (MemBuffer, (VOID *)Buffer, (UINTN)Size); diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardIn= itLib/PeiBoardInitPreMemLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Galag= oPro3/Library/BoardInitLib/PeiBoardInitPreMemLib.inf index d6c91cd2b94b..5b3a6921d0ee 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/P= eiBoardInitPreMemLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/P= eiBoardInitPreMemLib.inf @@ -23,6 +23,7 @@ PcdLib SiliconInitLib PchResetLib + PchPmcLib =20 [Packages] MinPlatformPkg/MinPlatformPkg.dec diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardIn= itLib/PeiGalagoPro3InitPreMemLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Ga= lagoPro3/Library/BoardInitLib/PeiGalagoPro3InitPreMemLib.c index 051dac0b204d..1cd2baf4a4dd 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/P= eiGalagoPro3InitPreMemLib.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/P= eiGalagoPro3InitPreMemLib.c @@ -14,6 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include @@ -236,5 +237,29 @@ GalagoPro3BoardBootModeDetect ( VOID ) { - return BOOT_WITH_FULL_CONFIGURATION; + EFI_BOOT_MODE BootMode; + UINT32 SleepType; + + DEBUG ((DEBUG_INFO, "Performing boot mode detection\n")); + + // Known sane defaults + BootMode =3D BOOT_WITH_FULL_CONFIGURATION; + + if (GetSleepTypeAfterWakeup (&SleepType)) { + switch (SleepType) { + case V_PCH_ACPI_PM1_CNT_S3: + BootMode =3D BOOT_ON_S3_RESUME; + break; + case V_PCH_ACPI_PM1_CNT_S4: + BootMode =3D BOOT_ON_S4_RESUME; + break; + case V_PCH_ACPI_PM1_CNT_S5: + BootMode =3D BOOT_ON_S5_RESUME; + break; + } + } + + DEBUG ((DEBUG_INFO, "BootMode is 0x%x\n", BootMode)); + + return BootMode; } diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardIn= itLib/PeiMultiBoardInitPreMemLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/= GalagoPro3/Library/BoardInitLib/PeiMultiBoardInitPreMemLib.inf index fe31f421356e..20ddac1d994d 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/P= eiMultiBoardInitPreMemLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/P= eiMultiBoardInitPreMemLib.inf @@ -25,6 +25,7 @@ SiliconInitLib MultiBoardInitSupportLib PchResetLib + PchPmcLib =20 [Packages] MinPlatformPkg/MinPlatformPkg.dec diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.ds= c b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc index 2e3c6d3ca506..1cab167e6580 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc @@ -177,6 +177,7 @@ # Silicon Package ####################################### ReportCpuHobLib|IntelSiliconPkg/Library/ReportCpuHobLib/ReportCpuHobLib.= inf + SmmAccessLib|IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLibSm= ramc/PeiSmmAccessLib.inf =20 ####################################### # Platform Package @@ -488,6 +489,20 @@ NULL|$(PROJECT)/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.i= nf !endif } + +!if gS3FeaturePkgTokenSpaceGuid.PcdS3FeatureEnable =3D=3D TRUE + MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.= inf { + + # On S3 resume, RSC is in end-of-BS state + # - Moreover: Libraries cannot effectively use some end-of-BS events + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPor= t.inf + SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLib= Null.inf + # Reverse-ranked priority list +!if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable =3D=3D T= RUE + SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPo= rtLib/BootScriptExecutorDxeI2cHdmiDebugSerialPortLib.inf +!endif + } +!endif MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCodeRouter= Smm.inf { DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd= .dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc index ec23c691b2fe..4d0ea7ac43ad 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc @@ -279,6 +279,7 @@ gMinPlatformPkgTokenSpaceGuid.PcdMaxCpuCoreCount|8 gMinPlatformPkgTokenSpaceGuid.PcdMaxCpuThreadCount|2 gMinPlatformPkgTokenSpaceGuid.PcdPciExpressRegionLength|0x10000000 + gIntelFsp2WrapperTokenSpaceGuid.PcdPeiMinMemSize|0x3800000 =20 # # The PCDs are used to control the Windows SMM Security Mitigations Tabl= e - Protection Flags @@ -379,7 +380,6 @@ ###################################### gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0 gIntelFsp2PkgTokenSpaceGuid.PcdGlobalDataPointerAddress|0xFED00148 - gIntelFsp2WrapperTokenSpaceGuid.PcdPeiMinMemSize|0x3800000 =20 ###################################### # Platform Configuration diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Li= brary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Inte= l/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpda= teLibFsp/PeiFspMiscUpdUpdateLib.c index 699f4297fad6..71b03f2da464 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/P= eiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/P= eiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c @@ -11,11 +11,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 #include #include #include - #include #include #include @@ -36,11 +36,15 @@ PeiFspMiscUpdUpdatePreMem ( ) { EFI_STATUS Status; + EFI_BOOT_MODE BootMode; UINTN VariableSize; VOID *FspNvsBufferPtr; UINT8 MorControl; VOID *MorControlPtr; =20 + Status =3D PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + // // Initialize S3 Data variable (S3DataPtr). It may be used for warm and = fast boot paths. // @@ -73,7 +77,11 @@ PeiFspMiscUpdUpdatePreMem ( &VariableSize ); DEBUG ((DEBUG_INFO, "MorControl - 0x%x (%r)\n", MorControl, Status)); - if (MOR_CLEAR_MEMORY_VALUE (MorControl)) { + // + // Do not set CleanMemory on S3 resume + // TODO: Handle advanced features later - capsule update is in-memory li= st + // + if (MOR_CLEAR_MEMORY_VALUE (MorControl) && BootMode !=3D BOOT_ON_S3_RESU= ME) { FspmUpd->FspmConfig.CleanMemory =3D (BOOLEAN)(MorControl & MOR_CLEAR_M= EMORY_BIT_MASK); } =20 diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Li= brary/PeiSiliconPolicyUpdateLibFsp/PeiSaPolicyUpdate.c b/Platform/Intel/Kab= ylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLib= Fsp/PeiSaPolicyUpdate.c index d6ec3e38dd7e..b69abd11cbce 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/P= eiSiliconPolicyUpdateLibFsp/PeiSaPolicyUpdate.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/P= eiSiliconPolicyUpdateLibFsp/PeiSaPolicyUpdate.c @@ -17,6 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 /** Performs FSP SA PEI Policy initialization. @@ -33,12 +34,17 @@ PeiFspSaPolicyUpdate ( IN OUT FSPS_UPD *FspsUpd ) { + EFI_STATUS Status; + EFI_BOOT_MODE BootMode; VOID *Buffer; VOID *MemBuffer; UINT32 Size; =20 DEBUG((DEBUG_INFO, "\nUpdating SA Policy in Post Mem\n")); =20 + Status =3D PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + FspsUpd->FspsConfig.PeiGraphicsPeimInit =3D 1; =20 Size =3D 0; @@ -46,7 +52,11 @@ PeiFspSaPolicyUpdate ( PeiGetSectionFromAnyFv (PcdGetPtr (PcdGraphicsVbtGuid), EFI_SECTION_RA= W, 0, &Buffer, &Size); if (Buffer =3D=3D NULL) { DEBUG((DEBUG_WARN, "Could not locate VBT\n")); - } else { + // + // Graphics initialisation is unnecessary, + // OS has present framebuffer. + // + } else if (BootMode !=3D BOOT_ON_S3_RESUME) { MemBuffer =3D (VOID *)AllocatePages (EFI_SIZE_TO_PAGES ((UINTN)Size)= ); if ((MemBuffer !=3D NULL) && (Buffer !=3D NULL)) { CopyMem (MemBuffer, (VOID *)Buffer, (UINTN)Size); diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/Board= InitLib/PeiBoardInitPreMemLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Kab= ylakeRvp3/Library/BoardInitLib/PeiBoardInitPreMemLib.inf index 850fc514188b..e0022e8d6118 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardInitLib= /PeiBoardInitPreMemLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardInitLib= /PeiBoardInitPreMemLib.inf @@ -24,6 +24,7 @@ SiliconInitLib EcLib PchResetLib + PchPmcLib =20 [Packages] MinPlatformPkg/MinPlatformPkg.dec diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/Board= InitLib/PeiKabylakeRvp3InitPreMemLib.c b/Platform/Intel/KabylakeOpenBoardPk= g/KabylakeRvp3/Library/BoardInitLib/PeiKabylakeRvp3InitPreMemLib.c index 87ae3b531ed6..02cd37227e50 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardInitLib= /PeiKabylakeRvp3InitPreMemLib.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardInitLib= /PeiKabylakeRvp3InitPreMemLib.c @@ -13,6 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include @@ -330,5 +331,29 @@ KabylakeRvp3BoardBootModeDetect ( VOID ) { - return BOOT_WITH_FULL_CONFIGURATION; + EFI_BOOT_MODE BootMode; + UINT32 SleepType; + + DEBUG ((DEBUG_INFO, "Performing boot mode detection\n")); + + // Known sane defaults + BootMode =3D BOOT_WITH_FULL_CONFIGURATION; + + if (GetSleepTypeAfterWakeup (&SleepType)) { + switch (SleepType) { + case V_PCH_ACPI_PM1_CNT_S3: + BootMode =3D BOOT_ON_S3_RESUME; + break; + case V_PCH_ACPI_PM1_CNT_S4: + BootMode =3D BOOT_ON_S4_RESUME; + break; + case V_PCH_ACPI_PM1_CNT_S5: + BootMode =3D BOOT_ON_S5_RESUME; + break; + } + } + + DEBUG ((DEBUG_INFO, "BootMode is 0x%x\n", BootMode)); + + return BootMode; } diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/Board= InitLib/PeiMultiBoardInitPreMemLib.inf b/Platform/Intel/KabylakeOpenBoardPk= g/KabylakeRvp3/Library/BoardInitLib/PeiMultiBoardInitPreMemLib.inf index 23fe6b6f03c5..0112bf84a193 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardInitLib= /PeiMultiBoardInitPreMemLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardInitLib= /PeiMultiBoardInitPreMemLib.inf @@ -26,6 +26,7 @@ MultiBoardInitSupportLib EcLib PchResetLib + PchPmcLib =20 [Packages] MinPlatformPkg/MinPlatformPkg.dec diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.= dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc index 26a54b0dc7cc..7c640ecb1559 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc @@ -201,6 +201,7 @@ # Silicon Package ####################################### ReportCpuHobLib|IntelSiliconPkg/Library/ReportCpuHobLib/ReportCpuHobLib.= inf + SmmAccessLib|IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLibSm= ramc/PeiSmmAccessLib.inf =20 ####################################### # Platform Package @@ -505,6 +506,17 @@ !endif } =20 +!if gS3FeaturePkgTokenSpaceGuid.PcdS3FeatureEnable =3D=3D TRUE + MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.= inf { + + # On S3 resume, RSC is in end-of-BS state + # - Moreover: Libraries cannot effectively use some end-of-BS events + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPor= t.inf + SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLib= Null.inf + # TODO: Insert a reverse-ranked priority list of compatible librarie= s here + } +!endif + !endif =20 ####################################### diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgP= cd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.d= sc index cfd032814850..87510748783f 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc @@ -279,6 +279,7 @@ gMinPlatformPkgTokenSpaceGuid.PcdMaxCpuCoreCount|8 gMinPlatformPkgTokenSpaceGuid.PcdMaxCpuThreadCount|2 gMinPlatformPkgTokenSpaceGuid.PcdPciExpressRegionLength|0x10000000 + gIntelFsp2WrapperTokenSpaceGuid.PcdPeiMinMemSize|0x3800000 =20 # # The PCDs are used to control the Windows SMM Security Mitigations Tabl= e - Protection Flags @@ -349,7 +350,6 @@ ###################################### gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0 gIntelFsp2PkgTokenSpaceGuid.PcdGlobalDataPointerAddress|0xFED00148 - gIntelFsp2WrapperTokenSpaceGuid.PcdPeiMinMemSize|0x3800000 =20 ###################################### # Platform Configuration diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Librar= y/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c b/Platform/Intel/Ka= bylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/Pe= iSiliconPolicyUpdateLib.c index 22aadc0221df..2061efb2445c 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSi= liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSi= liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c @@ -20,6 +20,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include @@ -513,6 +514,7 @@ SiliconPolicyUpdatePostMem ( ) { EFI_STATUS Status; + EFI_BOOT_MODE BootMode; VOID *Buffer; VOID *MemBuffer; UINT32 Size; @@ -521,6 +523,9 @@ SiliconPolicyUpdatePostMem ( =20 DEBUG((DEBUG_INFO, "\nUpdating Policy in Post Mem\n")); =20 + Status =3D PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + GtConfig =3D NULL; Status =3D GetConfigBlock ((VOID *) Policy, &gGraphicsPeiConfigGuid, (VO= ID *)&GtConfig); ASSERT_EFI_ERROR (Status); @@ -535,7 +540,11 @@ SiliconPolicyUpdatePostMem ( PeiGetSectionFromAnyFv (PcdGetPtr (PcdGraphicsVbtGuid), EFI_SECTION_RA= W, 0, &Buffer, &Size); if (Buffer =3D=3D NULL) { DEBUG((DEBUG_WARN, "Could not locate VBT\n")); - } else { + // + // Graphics initialisation is unnecessary, + // OS has present framebuffer. + // + } else if (BootMode !=3D BOOT_ON_S3_RESUME) { MemBuffer =3D (VOID *)AllocatePages (EFI_SIZE_TO_PAGES ((UINTN)Size)= ); if ((MemBuffer !=3D NULL) && (Buffer !=3D NULL)) { CopyMem (MemBuffer, (VOID *)Buffer, (UINTN)Size); diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Librar= y/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf b/Platform/Intel/= KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/= PeiSiliconPolicyUpdateLib.inf index 25eae88f5989..e9a23593e133 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSi= liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSi= liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf @@ -23,6 +23,7 @@ BaseMemoryLib MemoryAllocationLib PeiLib + PeiServicesLib CpuPlatformLib PchPcieRpLib PchInfoLib --=20 2.37.2 -=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 (#93260): https://edk2.groups.io/g/devel/message/93260 Mute This Topic: https://groups.io/mt/93506116/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-