From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.5786.1661818726872337953 for ; Mon, 29 Aug 2022 17:18:47 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=K6ltdKyF; spf=permerror, err=too many SPF records (domain: intel.com, ip: 192.55.52.43, mailfrom: isaac.w.oram@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661818726; x=1693354726; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=dVCEn/FV7e+efei2N2K2ZMaCPRreL5XnHzGHsFXYKBw=; b=K6ltdKyF2G0vrAAdaULmaXM4uP0NZJ2XJtNhqyeA+xPgx9ALlYlGtzzv W2hYqfifTxMxzmeaXIqMawoEjLA26XJ4c2QhymK4qAfH31b6AQQDmMGd5 m2pEd1ZSjAl44GB39O1cj5sQE3Mw/ImSa6vWMyqouYoc4gYZDyiZSfwez V6ToIo3jxAIf1AIVXTGvfzc5f0z/e4vA48BpuUqxP1QSO2+B9qh9eE/Y+ V3wBTeXkzlY1WRH6lrwfh14/UGFzI0BvQJDRYh3AorpjglGetZWhZnP+O DjGLgHXPq3NEYCAzxP4+6poiRVaS7kw1l26V0Z2vZ6NtyikKbuzM7P3lC Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10454"; a="381335004" X-IronPort-AV: E=Sophos;i="5.93,273,1654585200"; d="scan'208";a="381335004" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2022 17:16:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,273,1654585200"; d="scan'208";a="607634794" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga007.jf.intel.com with ESMTP; 29 Aug 2022 17:16:28 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 29 Aug 2022 17:16:20 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 29 Aug 2022 17:16:19 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Mon, 29 Aug 2022 17:16:19 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.175) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Mon, 29 Aug 2022 17:16:19 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fJZ55P7yb3sM3Ale+yd0Oz/FUhpBdWQ/mqIGlBJFMtPr9pZGvmce+B8FmSnmUFBlQJJU4FCkQpwMEqmlzjOQ8hmJKESyZ+V+iVMma+JzVNG3+MLUNWgGL5C7WHtamMmiMSkgxe3ne0YZWEfjx9SU2DcUx61mAF6QJqHvtcA8OS1aBYvuEILYTT71Oiaq524GprScyowtsNVq5FMFRhpd/ZRMiPo1q9ehtMbYtXgCSNlWRV5XlzNvGDKUhAqNklYNTlnWEP5eQg2bj+G89V+DSM/nqqGWv5o1lZrDNkX+PWx4BRhrtQLCHZAsxq8kJuRjxSO/luqnDYchDAbUOfAn7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7Yun/hn/SA/T+jjR0vBTSCMh5OsBpVtLvIJYETKHzaU=; b=OTgdeF9m2VGpUhfjc0U6PTmfyrrWYHeeOJfsnbCUHrboTdZrYfScynusme/jxAeddrd+coapRku/6Mvnv6g6ZvGs5IAJQRE88UqLWy9NXv8MSVmC1LBTPMuM0azmzC8BWpn+zgMFOZZb/jzRpk13Sg8a0YnTNi8P8eq3uEpBCcagu70CcU0AUZ8gkOyTJw61zqZI+hSgh6WjWpq4/hzlkCvr8HyIUBkxJWcM7epuqlLkPqWpDVFFexlaXodLts50oX2MXqk/ofYVECh/UD/tExaXeqWeomKscGyS1ey6onsOMkmN9mrQKiZmFT1CFcvXrv5Z8OxLUBwAbHlxvFMGyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SA1PR11MB5801.namprd11.prod.outlook.com (2603:10b6:806:23d::13) by BL3PR11MB5746.namprd11.prod.outlook.com (2603:10b6:208:353::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Tue, 30 Aug 2022 00:16:16 +0000 Received: from SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::4149:e96e:480e:e1c3]) by SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::4149:e96e:480e:e1c3%6]) with mapi id 15.20.5566.021; Tue, 30 Aug 2022 00:16:16 +0000 From: "Oram, Isaac W" To: Benjamin Doron , "devel@edk2.groups.io" CC: "Desimone, Nathaniel L" , "Sinha, Ankit" , "Chaganty, Rangasai V" , "Gao, Liming" Subject: Re: [edk2-devel][edk2-platforms][PATCH v1 3/5] S3FeaturePkg: Implement working S3 resume Thread-Topic: [edk2-devel][edk2-platforms][PATCH v1 3/5] S3FeaturePkg: Implement working S3 resume Thread-Index: AQHYu+coxfU4E0W/Uk+3FQ3iwQW9H63Gg70A Date: Tue, 30 Aug 2022 00:16:16 +0000 Message-ID: References: <23fd6d63ba743cfbfa994dda115437719dbc2b4f.1661799519.git.benjamin.doron00@gmail.com> In-Reply-To: <23fd6d63ba743cfbfa994dda115437719dbc2b4f.1661799519.git.benjamin.doron00@gmail.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.500.17 dlp-reaction: no-action authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6116cd58-b272-49d8-a5f5-08da8a1cdb40 x-ms-traffictypediagnostic: BL3PR11MB5746:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ask9S/cNZq24JmBJMRyUwB5nogTBDyrEABYrpHMgZpBszii5jbytPjRVFUiLlX9Owr/uOQGoCiwJju+tlYrfzptB5br9Kwj9x79OuXB/1JY0c6yof3sCP12q9iCnOgE+iUWjEGZizWe9KYtu/7hFOZFV3Dtj7Vb3rhRHjXvtRAczs+Dk7yZ6gtfb/cryiMV6Tc5apD3OCLSfM6N3UVyEX0iBHiG0Vg6oImpHeS46Inm4sCzw0U2squr1ulon152fuWeoupeISLNWO6oDm0+PxkkaxAwOoHebxmwSjnL5Aqr6AliWgjGgvwzL4EX42tGK2tB0nHi11dG8QRdfX18BqYJpsfYuVzrchkPnYWowR3Gz9eclt6HpL7VpJiaEW3t9KmIL7bsALKXNpZBstnshbJLJRQmCZbtF/RQAE98PKbibJAYK0uhz6RxYLUuBXjtXfdAvD4qkk4rkkG6oUMpAZ3piGXY5kBrHJusw9TokOPJD29WaggUs9LJyQ0RVDZ7MmfeFvrn48LtQUVlsTS0KxUWPQJIjGIhdOIlhhRtuAdtDFnQxJg48K/Eqb5mj1LzjRkLOB9dyht+z0BQ+vD5xSm0Zuv63QNnCfDYBG8MzGpYrjq4usWPeQk8z6edWOLV+47Tig3lGW2rrYAzrCYtpiaPismdyEHATxL5obfCmbToRmsZ2Z/DqJKRNXlvBKaNuslKTzQaM2jX6iWvA3vY7AqHz+Jkh+Vsi+ArUnUPyl0+UUfvSag4XeQLOl8bX9fOs2eky+CA1ole3U/HTadSYSAowUCuYFs6PA052bMHEg7w= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR11MB5801.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39860400002)(376002)(136003)(346002)(396003)(366004)(5660300002)(8936002)(52536014)(41300700001)(55016003)(186003)(86362001)(7696005)(26005)(6506007)(30864003)(53546011)(9686003)(33656002)(83380400001)(2906002)(478600001)(71200400001)(122000001)(110136005)(19627235002)(316002)(54906003)(966005)(38100700002)(8676002)(4326008)(66946007)(66476007)(82960400001)(38070700005)(66556008)(66446008)(64756008)(76116006);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?RJlTC0Af6ZSvaoztpw+jfQjjy2KO0f9PL0IfLobSIHfztmk9jHOoG9+wVe76?= =?us-ascii?Q?29rEpBoHn28t3iFyC0T4CRMp/L9XXOC/vksPLHW8xuV26RDlhPGPQ/Jh6x9Q?= =?us-ascii?Q?+Giql9TlXyjRA/eHHRcKBUafifjBzfoEAIHBgN3fGn029NMZuBJnbAUKAIBI?= =?us-ascii?Q?H+vuaGgQ6fkGmyq6i1AUnXE7t8Gj0dwJEeveAPOAMI6WhkwXziMdzEvUJS0V?= =?us-ascii?Q?1efwHDdsuqoioGMj0wnHTh4q2DqXKpfx8f56/GalA/VExSNtrocOIWGlCQIC?= =?us-ascii?Q?GdfgCJsnHCeQi31ScU/eUUIjhR1EFKBpyTyY+Y0l9mwBU0rX+ZyRFShjSJsb?= =?us-ascii?Q?3k/TOmCbtvGGt72wptNnyyPsmAYccqo0Fn12K6n8f/Y9hD3IWOCHUkwoBwm7?= =?us-ascii?Q?Xsbq1h8+H9KBa2wbOQNLPvTujm1/7JqF/yg7Y4u55GDqJ6NG72Wp2XIkgRPH?= =?us-ascii?Q?27rfPhzqjorCGtTl/AUe44qQHR3UB7qkM39f40C0C42wDoXpYoxVAidb7B+7?= =?us-ascii?Q?Y3Pr1AbV/EHgnVi1XPT5UzpMHHkNYN3uvuS5c7ftxvz1oUiwqx0GfMzfKqkh?= =?us-ascii?Q?/calLeAeWbXcitQdN6YnwWdY79uuK2ql569+vzAsWYgWSKBSrx00v8LI305N?= =?us-ascii?Q?KChBammNsHbQBXGiy4ifFFZEWyJigkuI8OhLfQW+VHIKN8DVJejnZJtiFrcQ?= =?us-ascii?Q?Z7yUZBU5GhpFhOF2o/5HsLUqtOc9WsRDKKT9r7TwnbN3ibGXAykDFqG3Ibtz?= =?us-ascii?Q?jv7wPJMu/2wrKf5k5/sI84J5Dw4CBU9JQONT2Y7wOi+4tuhPEGXCsCRm69GR?= =?us-ascii?Q?XxX1XSBTJXOnD3nZEcVOh3pJYyNfJNdIaNnIKHryEhEm1kJctpVUUblWYTBY?= =?us-ascii?Q?OH3eGWALjthQnhJUqBsDv14nhc93dVfejK9lZwimO+ODmwgkPBPSJR80TIOQ?= =?us-ascii?Q?/qstPCFEOEfz9S0AJLRLJo8jIyDNcXwg2K8l8WgerNIGhE7nP50gL2GA2bwf?= =?us-ascii?Q?tVaOU9zesElBMaBFZ8yXrM1AgkvXLXQSCOF2nW1FBbuc+HvkUf7QvoUj4qUG?= =?us-ascii?Q?/j/BLqxJH+0+9evHzLv2SmcRY/31MqD5AfG5Vg6P6pWHoQHGUksMquadK3v6?= =?us-ascii?Q?1ks+nCmtnU3094zPIc8pueJMpcRzkc1oZqDI7LWDpQD0HXvZljwyTC8WA8s3?= =?us-ascii?Q?5R7RPapHNXbjgW2BdG9iQ24aUxaLyyQhkX+rqpE3tT3L1MVQfmd/V+68O9iE?= =?us-ascii?Q?uCCYQIblLMOot+ybmL4or0gKOrrmJrW/9oXVJWAc1ITN51aJ08caVlUY5orN?= =?us-ascii?Q?0Twmofjd+66BkOR30uEg1VhMb2V47n+1s6ZqpTrszbeXBGOYkoHMtHbC+Dli?= =?us-ascii?Q?//H7QPYdHA5MUvW1yI4atb/TUJxZsQC+PFYQyuZlX52kzL/Bh3ANef3rmtpQ?= =?us-ascii?Q?LdqizVVZR4lbh9GjNx7djv8xNwNF8kRiSo3mRhGyeWl17wRpemEAuBOditRd?= =?us-ascii?Q?/l40IVDmhGRELn9Qj3QY/qdRPwwjU98DiZAwx3xz3Xt7oOeE0VreHmjRm5dc?= =?us-ascii?Q?Fd9Ed/R6hJnI9R0D9vyVqhQb8+Dnmsh/LmLDywwd?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA1PR11MB5801.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6116cd58-b272-49d8-a5f5-08da8a1cdb40 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Aug 2022 00:16:16.8042 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 7QH1ZmS0RWId4iaTXPndwWeZG0rdKo9OQAiiUqzi9bVxaBVlBFCxqPP0KD1jUN6Buyocp24An32cxRgUPYORnQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR11MB5746 Return-Path: isaac.w.oram@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable S3Feature.dsc - remove commented out code # Add library instances here that are not included in package components = and should be tested # in the package build. - These comments don't make a lot of sense to me in the feature include DSC= . Looks like cut and paste propagation that is not appropriate here. Note= instances in Components.IA32 and Components.X64 sections. # NOTE: RSC will be after end-of-BS, use DebugLibSerialPort # - No gBS in SerialPortInitialize() # - No global assigns after ReadyToLock possible, due to LockBox copy - These comments also don't make sense to me S3Dxe.c - infromation should be "information" in multiple instances - GetPeiMemSize - Generally we would prefer #defines in .h or near top of t= he file after includes and before function prototypes and implementations. - Resolve ToDo S3Pei.c - Resolve ToDo and TODO/TEST Regards, Isaac -----Original Message----- From: Benjamin Doron =20 Sent: Monday, August 29, 2022 1:36 PM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L ; Sinha, Ankit ; Chaganty, Rangasai V = ; Oram, Isaac W ; Gao, Liming Subject: [edk2-devel][edk2-platforms][PATCH v1 3/5] S3FeaturePkg: Implement= working S3 resume Follow-up commits to MinPlatform (PeiFspWrapperHobProcessLib for memory) and FSP-related board libraries (policy overrides) required for suc= cessful S3 resume. Factored allocation logic into new module to avoid MinPlatform dependency o= n 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 | 15 ++ .../S3FeaturePkg/Include/PreMemory.fdf | 8 +- .../S3FeaturePkg/Include/S3Feature.dsc | 42 ++++- .../S3FeaturePkg/S3Dxe/S3Dxe.c | 156 ++++++++++++++++++ .../S3FeaturePkg/S3Dxe/S3Dxe.inf | 49 ++++++ .../S3FeaturePkg/S3Pei/S3Pei.c | 83 +++++++++- .../S3FeaturePkg/S3Pei/S3Pei.inf | 8 +- .../Include/AcpiS3MemoryNvData.h | 22 +++ 8 files changed, 375 insertions(+), 8 deletions(-) create mode 100644 Fea= tures/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..5d3d96f4f317 100644 --- a/Features/Intel/PowerManagement/S3FeaturePkg/Include/PostMemory.fdf +++ b/Features/Intel/PowerManagement/S3FeaturePkg/Include/PostMemory.fdf @@ -2,7 +2,22 @@ # FDF file for post-memory S3 advanced feature modules. # # Copyright (c)= 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2022, Ba= ruch Binyamin Doron.
# # SPDX-License-Identifier: BSD-2-Clause-Patent #= ##++## Dependencies+ INF UefiCpuPkg/PiSmmCommunication/PiSmmCommunication= Smm.inf+ INF MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf++## = Save-state module stack+ INF S3FeaturePkg/S3Dxe/S3Dxe.inf+ INF MdeModuleP= kg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf+ # FSP may perform CPU= finalisation, requires CpuInitDxe from closed code+ # - Presently, PiSmmC= puDxeSmm shall perform finalisation with this data+ INF UefiCpuPkg/CpuS3Da= taDxe/CpuS3DataDxe.inf++## Restore-state module stack+ INF MdeModulePkg/Un= iversal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.infdiff --git a/Fe= atures/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, Bar= uch Binyamin Doron.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # = ## -INF S3FeaturePkg/S3Pei/S3Pei.inf+## Dependencies+ INF S3FeaturePkg/S3P= ei/S3Pei.inf+ INF UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf+= +## Restore-state module stack+ INF UefiCpuPkg/Universal/Acpi/S3Resume2Pei= /S3Resume2Pei.infdiff --git a/Features/Intel/PowerManagement/S3FeaturePkg/I= nclude/S3Feature.dsc b/Features/Intel/PowerManagement/S3FeaturePkg/Include/= S3Feature.dsc index cc34e785076a..bf45b56258ff 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 Corpo= ration. All rights reserved.
+# Copyright (c) 2022, Baruch Binyamin Doro= n.
# # SPDX-License-Identifier: BSD-2-Clause-Patent #@@ -25,6 +26,10 @@ !error "DXE_ARCH must be specified to build this feature!" !endif +[= PcdsFixedAtBuild]+ # Attempts to improve performance at the cost of more D= RAM usage+ gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnS3Boot|TRUE+ ####= ###########################################################################= # # # Library Class section - list of all Library Classes needed by this fe= ature.@@ -32,7 +37,15 @@ ##########################################################################= ###### [LibraryClasses.common.PEIM]- SmmAccessLib|IntelSiliconPkg/Feature= /SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.inf+ #SmmAccessLib|Inte= lSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLibSmramc/PeiSmmAccessLib= .inf+ SmmControlLib|IntelSiliconPkg/Feature/SmmControl/Library/PeiSmmContr= olLib/PeiSmmControlLib.inf+ #IntelCompatShimLib|$(PLATFORM_SI_PACKAGE)/Lib= rary/BaseIntelCompatShimLibKbl/BaseIntelCompatShimLibKbl.inf++[LibraryClass= es.common.DXE_DRIVER, LibraryClasses.common.DXE_SMM_DRIVER]+ #############= ##########################+ # Edk2 Packages+ ############################= ###########+ S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/Dxe= S3BootScriptLib.inf ######################################################= ########################## #@@ -65,3 +78,30 @@ # Add components here that should be included in the package build. S= 3FeaturePkg/S3Pei/S3Pei.inf+ UefiCpuPkg/PiSmmCommunication/PiSmmCommunicat= ionPei.inf+ UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf++#+# F= eature DXE Components+#++# @todo: Change below line to [Components.$(DXE_AR= CH)] after https://bugzilla.tianocore.org/show_bug.cgi?id=3D2308+# i= s completed.+[Components.X64]+ #####################################+ # S= 3 Feature Package+ #####################################++ # Add library = instances here that are not included in package components and should be te= sted+ # in the package build.++ # Add components here that should be incl= uded in the package build.+ UefiCpuPkg/PiSmmCommunication/PiSmmCommunicati= onSmm.inf+ MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf+ S3Fe= aturePkg/S3Dxe/S3Dxe.inf+ MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3Sav= eStateDxe.inf+ UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf+ # NOTE: RSC will= be after end-of-BS, use DebugLibSerialPort+ # - No gBS in SerialPortIniti= alize()+ # - No global assigns after ReadyToLock possible, due to LockBox = copy+ MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutor= Dxe.infdiff --git a/Features/Intel/PowerManagement/S3FeaturePkg/S3Dxe/S3Dxe= .c b/Features/Intel/PowerManagement/S3FeaturePkg/S3Dxe/S3Dxe.c new file mode 100644 index 000000000000..b3fb63e2bc33 --- /dev/null +++ b/Features/Intel/PowerManagement/S3FeaturePkg/S3Dxe/S3Dxe.c @@ -0,0 +1,156 @@ +/** @file+ Source code file for S3 DXE module++Copyright (c) 2022, Baruch= Binyamin Doron.
+SPDX-License-Identifier: BSD-2-Clause-Patent++**/++#in= clude +#include +#include +#include +#include +#include +#include +#include +#include +#include ++/**+ Get the mem size in memory type= infromation table.++ @return the mem size in memory type infromation tabl= e.+**/+UINT64+EFIAPI+GetMemorySizeInMemoryTypeInformation (+ VOID+ )+{+ = EFI_STATUS Status;+ EFI_MEMORY_TYPE_INFORMATION *MemoryDa= ta;+ UINT8 Index;+ UINTN Temp= PageNum;++ Status =3D EfiGetSystemConfigurationTable (&gEfiMemoryTypeInfor= mationGuid, (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++) {+ //+ // Acc= umulate default memory size requirements+ //+ TempPageNum +=3D Memory= Data[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+EF= IAPI+GetPeiMemSize (+ VOID+ )+{+ #define PEI_ADDITIONAL_MEMORY_SIZE (= 16 * EFI_PAGE_SIZE)++ UINT64 Size;++ Size =3D GetMem= orySizeInMemoryTypeInformation ();++ return PcdGet32 (PcdPeiMinMemSize) + = Size + PEI_ADDITIONAL_MEMORY_SIZE;+}++/**+ Allocate EfiACPIMemoryNVS below= 4G memory address.++ This function allocates EfiACPIMemoryNVS below 4G me= mory address.++ @param Size Size of memory to allocate.++ @retur= n Allocated address for output.++**/+VOID *+EFIAPI+AllocateAcpiNvsMemoryBel= ow4G (+ IN UINTN Size+ )+{+ UINTN Pages;+ EFI_PHYSIC= AL_ADDRESS Address;+ EFI_STATUS Status;+ VOID = *Buffer;++ Pages =3D EFI_SIZE_TO_PAGES (Size);+ Address =3D 0xfffffff= f;++ 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 every DXE driver.++ @retval EFI_SUCCESS The func= tion completes successfully+ @retval EFI_OUT_OF_RESOURCES Insufficient= resources to create database+**/+EFI_STATUS+EFIAPI+S3DxeEntryPoint (+ IN = EFI_HANDLE ImageHandle,+ IN EFI_SYSTEM_TABLE *SystemTable+ )+{+ = UINT64 S3PeiMemSize;+ UINT64 S3PeiMemBase;+ ACPI_S3_MEM= ORY S3MemoryInfo;+ EFI_STATUS Status;++ DEBUG ((DEBUG_INFO, "%a() S= tart\n", __FUNCTION__));++ S3PeiMemSize =3D GetPeiMemSize ();+ S3PeiMemBa= se =3D (UINTN) AllocateAcpiNvsMemoryBelow4G (S3PeiMemSize);+ ASSERT (S3Pei= MemBase !=3D 0);++ S3MemoryInfo.S3PeiMemBase =3D S3PeiMemBase;+ S3MemoryI= nfo.S3PeiMemSize =3D S3PeiMemSize;++ DEBUG ((DEBUG_INFO, "S3PeiMemBase: 0x= %x\n", S3PeiMemBase));+ DEBUG ((DEBUG_INFO, "S3PeiMemSize: 0x%x\n", S3PeiM= emSize));++ // TODO: LockBox is potentially superior, though requires stat= ic location+ Status =3D gRT->SetVariable (+ ACPI_S3_MEMOR= Y_NV_NAME,+ &gEfiAcpiVariableGuid,+ EFI_V= ARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,+ s= izeof (S3MemoryInfo),+ &S3MemoryInfo+ );+= ASSERT_EFI_ERROR (Status);++ DEBUG ((DEBUG_INFO, "%a() End\n", __FUNCTIO= N__));+ return EFI_SUCCESS;+}diff --git a/Features/Intel/PowerManagement/S= 3FeaturePkg/S3Dxe/S3Dxe.inf b/Features/Intel/PowerManagement/S3FeaturePkg/S= 3Dxe/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.+#+# Copyrigh= t (c) 2022, Baruch Binyamin Doron.
+#+# SPDX-License-Identifier: BSD-2-C= lause-Patent+#+###++[Defines]+ INF_VERSION =3D 0x00010017+ BASE_NAM= E =3D S3Dxe+ FILE_GUID =3D 30926F92-CC83-4381-9F70-AC96EDB= 5BEE0+ VERSION_STRING =3D 1.0+ MODULE_TYPE =3D DXE_DRIVER+ ENTR= Y_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]+ gEfiMemoryTypeIn= formationGuid ## CONSUMES+ gEfiAcpiVariableGuid ## CONSUMES++[D= epex]+ gEfiVariableArchProtocolGuid AND+ gEfiVariableWriteArchProtoc= olGuiddiff --git a/Features/Intel/PowerManagement/S3FeaturePkg/S3Pei/S3Pei.= c b/Features/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 Copyright (c) 2019, Intel Corporatio= n. All rights reserved.
+Copyright (c) 2022, Baruch Binyamin Doron.
= SPDX-License-Identifier: BSD-2-Clause-Patent **/ +#include +#incl= ude +#include #include #include +#include ++// TODO: Finalise implementation factoring+#define R_SA_PAM0 (0x8= 0)+#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 P= ointer to PEI Services Table.+ @param[in] NotifyDesc Pointer to the de= scriptor for the Notification event that+ caused= this function to execute.+ @param[in] Ppi Pointer to the PPI d= ata associated with this function.++ @retval EFI_STATUS Always retu= rn EFI_SUCCESS+**/+EFI_STATUS+EFIAPI+FspSiliconInitDoneNotify (+ IN EFI_PE= I_SERVICES **PeiServices,+ IN EFI_PEI_NOTIFY_DESCRIPTOR *Notify= Desc,+ IN VOID *Ppi+ )+{+ EFI_STATUS Status;+ = EFI_BOOT_MODE BootMode;+ UINT64 MchBaseAddress;++ Status =3D Pe= iServicesGetBootMode (&BootMode);+ ASSERT_EFI_ERROR (Status);++ // Enable= PAM regions for AP wakeup vector (resume)+ // - CPU is finalised by PiSmm= CpuDxeSmm, not FSP. So, it's safe here?+ // TODO/TEST: coreboot does this = unconditionally, vendor FWs may not (test resume). Should we?+ // - It is = certainly interesting that only PAM0, PAM5 and PAM6 are defined for Kabylak= eSiliconPkg.+ // - Also note that 0xA0000-0xFFFFF is marked "reserved" in = FSP HOB - this does not mean+ // that the memory is unusable, perhaps th= is is precisely because it will 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);+ PciWri= te8 (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);+ PciWrit= e8 (MchBaseAddress + R_SA_PAM5, 0x33);+ PciWrite8 (MchBaseAddress + R_SA= _PAM6, 0x33);+ }++ //+ // Install EFI_PEI_MM_ACCESS_PPI for S3 resume ca= se+ //+ Status =3D PeiInstallSmmAccessPpi ();+ ASSERT_EFI_ERROR (Status)= ;++ //+ // Install EFI_PEI_MM_CONTROL_PPI for S3 resume case+ //+ Statu= s =3D PeiInstallSmmControlPpi ();+ ASSERT_EFI_ERROR (Status);++ return St= atus;+}++EFI_PEI_NOTIFY_DESCRIPTOR mFspSiliconInitDoneNotifyDesc =3D {+ (= EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_L= IST),+ &gFspSiliconInitDonePpiGuid,+ FspSiliconInitDoneNotify+}; /** S= 3 PEI module entry point@@ -25,12 +100,10 @@ S3PeiEntryPoint ( IN CONST EFI_PEI_SERVICES **PeiServices ) {- EFI_STATUS Status;+ = EFI_STATUS Status; - //- // Install EFI_PEI_MM_ACCESS_PPI for S3 resume= case- //- Status =3D PeiInstallSmmAccessPpi ();+ Status =3D PeiServices= NotifyPpi (&mFspSiliconInitDoneNotifyDesc);+ ASSERT_EFI_ERROR (Status); = return Status; }diff --git a/Features/Intel/PowerManagement/S3FeaturePkg/S= 3Pei/S3Pei.inf b/Features/Intel/PowerManagement/S3FeaturePkg/S3Pei/S3Pei.in= f 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 SmmAccessL= ib+ SmmControlLib [Packages] MdePkg/MdePkg.dec+ IntelFsp2WrapperPkg/In= telFsp2WrapperPkg.dec IntelSiliconPkg/IntelSiliconPkg.dec S3FeaturePkg/= S3FeaturePkg.dec @@ -31,5 +34,8 @@ [FeaturePcd] gS3FeaturePkgTokenSpaceGuid.PcdS3FeatureEnable +[Ppis]+ gF= spSiliconInitDonePpiGuid+ [Depex]- gEfiPeiMemoryDiscoveredPpiGuid+ TRUEdi= ff --git a/Platform/Intel/MinPlatformPkg/Include/AcpiS3MemoryNvData.h b/Pla= tform/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 -- 2.37.2