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.web10.2768.1662594646114892313 for ; Wed, 07 Sep 2022 16:50:46 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=I8mQq8kr; 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=1662594646; x=1694130646; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=8e2qcJFp3DBQhdkx3VhoRYGL32lJL0mRI+ioGx5qAv8=; b=I8mQq8krX++F4ow/o7/meYQGMYLcOY/bhtWFgpdy7bX9mbpZThLiJnSY uVGZiw+aZFyJOIf3nKQipEk+Ur60HubALRxoQuQK6OQGxbZH8fsxoN6aF yMsgxdHaFKWfcY2S5ntD1T2bhSNSbFiG2CpvIefpTb2uJqvzjcWJNLogz VPTwrfcZIjDKC7V3i5jBFbSZC0qAljC+cgOxIqx0C2054rwPL3EnhoE6+ aeXvqybx62EJ2UuT15iR0L0pyJE/Nj0m2Vk4KwothLXOKcUesBHc4BjrB /rFczee85hh/nlrTs+mnBZjYZjcCLcUW27Ayz2m/eGFkutMJC0dhFx8F2 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10463"; a="383317645" X-IronPort-AV: E=Sophos;i="5.93,298,1654585200"; d="scan'208";a="383317645" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2022 16:50:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,298,1654585200"; d="scan'208";a="790236037" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga005.jf.intel.com with ESMTP; 07 Sep 2022 16:50:43 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 7 Sep 2022 16:50:42 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 7 Sep 2022 16:50:41 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Wed, 7 Sep 2022 16:50:41 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.172) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Wed, 7 Sep 2022 16:50:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V7sPyqrxM/EdlBEl3bL8Cw+EqZQRi+D3xHErLwYNNJL9V9RaH8ralJ2liWOOSeibZWIdgwFQLH2bkyBOgK33raykijd99V1+DDVJftb39lPN8sgVVAeNPOVI7xVgdcybdVoRCAwm2VOz8ySjLq0C8a3lFyhjqt7nkwxU6kAvPOAQHSxKATwcVeZ2OE4EXKHIzPWXV7ljkaBteJI2BtYvUZgrLO7XzVS4MLiumWUtyjui11rJLl4Cn6FM7VwoVKNwQF1VZLqc1BN7u1SjiLlSYo9OGQ9fLqNQLsoBXoj7GUBjpiS7PFycS27ilG/iDyLIfXYMGBCixYRi1iv04Crf7A== 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=nII4uSPHymYHoDroUdUOsxUg7ntFhIYcCYl8GN5zM7A=; b=P2BeC8k7WaF4JFT/olwDo4IvJ0JCjHqdnuo7fQshPZTyAFLv0kJwrMTOHydgjOITwQvEOmoj/Iruz1cpFxoPVS4j8hYRerrfshzFvUDCgaGEbO6O99Vmv02PU9+6b9OtZHzVo6IjovrXgEmFfouPYWbAQqdvvzeew3WPeEkG9GAPpy37G/9uOLPaGTAbPRkxVODIZTkFE2II914Pziv+pBsBKssDxQZq5o2s4QYPL6864WIqRhpzpEobzk1JC6Fnnx6T5SN6uOFoS6ZF+IyZJ6rmi/YDk2KK5q88xwik7VBvF1dujmXq2WadKWfdEUBQGvwtVKnAczpjbbDFBF0Xig== 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 DM4PR11MB7205.namprd11.prod.outlook.com (2603:10b6:8:113::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.16; Wed, 7 Sep 2022 23:50:39 +0000 Received: from SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::4149:e96e:480e:e1c3]) by SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::4149:e96e:480e:e1c3%5]) with mapi id 15.20.5588.010; Wed, 7 Sep 2022 23:50:39 +0000 From: "Isaac Oram" To: Benjamin Doron , "devel@edk2.groups.io" CC: "Desimone, Nathaniel L" , "Sinha, Ankit" , "Ni, Ray" , "Chaganty, Rangasai V" Subject: Re: [edk2-devel][edk2-platforms][PATCH v2 3/6] IntelSiliconPkg/Feature/SmmControl: Implement PPI with chipset support Thread-Topic: [edk2-devel][edk2-platforms][PATCH v2 3/6] IntelSiliconPkg/Feature/SmmControl: Implement PPI with chipset support Thread-Index: AQHYwhL+87l4fyvmQUSctJhq+1jWN63UpMAg Date: Wed, 7 Sep 2022 23:50:39 +0000 Message-ID: References: <8dffa2473dfd2871443632ab2ba32a787471dafd.1662483691.git.benjamin.doron00@gmail.com> In-Reply-To: <8dffa2473dfd2871443632ab2ba32a787471dafd.1662483691.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: e1635366-3451-4316-dd4c-08da912bc473 x-ms-traffictypediagnostic: DM4PR11MB7205:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: s5W3asRquNHqCCHcKzW7UOsJ7eD793/WWmiOJA7fTTu1b/q8MQcZIy+jk5tJIgQfuPD1bJxobphLGBcfVaU/Q9FAM7QRfryV+4UGgRUKYPmTZWrXtRUP+H3t1ozyprcyMgT9UJEpke1985sq1yimRN6cfm/BB0QA4rebyoli2rKvyTx4Yg27ljFsbDl9FyBPcqQaZEP13tyWQEbL/HRjkKu0vWjktWHVFV8tr+tyBXHK4cK57Uy+W1ymY+6WW2sagpvAXdAlUjIdxa78r/YVMWap69M1B07OlgHp8FvHfc9CAKa/bywKzWgUIyNthwjWmCnC9OGn7wNPX/0go3KjS9HC7t8Ifn8tPZ2a9YPFxTihEjfumWQxMOTJDOFbaOxwYhEvQGDerr0n3t4IYL4KD2Tk8TN6kogJ19VlbOaKXPXrTEzxQiycKqk1A7KkfwwkW1KksQ3DNJBs0hyZBU9XUkqO4hI26+7SRg2x/n7B43O5UJCCGscygJvvk1wSeAOss7D3y9qfIGA9qIMu3ejRPTJ1xiZ7eXlTia7Ripdr1W27tOpLOG7Z9Uq+CBMJHkK62D1QkUOvWaivcpVV4mibbN5JhFkN1yD/N5JJkkFLICCr+IRDLZ/YIf3AJ4dzXhSjm30r/MXwZhza4MNO/3fPBUu+FEGBnuSAIt5Vx7haMx1cT8LvJvyyLf2EKlrpOGavvXMt676ecO/01OTI5FdyPcH79sqQlVPK/DV/8aItgYtu7q60BI0czUL2XCu44c+uyc8xGxRwLxSJAZD3Pajz+w== 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)(366004)(39860400002)(396003)(136003)(346002)(376002)(66446008)(478600001)(71200400001)(64756008)(4326008)(8676002)(122000001)(110136005)(38070700005)(33656002)(54906003)(82960400001)(86362001)(66476007)(76116006)(66946007)(66556008)(38100700002)(107886003)(30864003)(5660300002)(186003)(316002)(26005)(9686003)(8936002)(53546011)(6506007)(7696005)(55016003)(83380400001)(52536014)(2906002)(41300700001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?xtEjhh4fzPYeqPB8pGVTBJQa/Ylmd5MAdazMTRmUY4waI5MCeXt+GMXGFe28?= =?us-ascii?Q?PAjl+9e9izvgwqznRzR6d8RsXIJdAxjEls3QcUfroaG4GcvHTsbp7XbZ8fgE?= =?us-ascii?Q?lmjEg7XBEKavK+JsRA/kLL9sxwQDFRGuRfh9L2gmv9cOPQhAKqJYBWtkFdcz?= =?us-ascii?Q?1LYaZFDmkQVBUXC0XvV+ljnsvtincnmJe+FiGrSxL03MoDtvyFhHfZ4l1n8W?= =?us-ascii?Q?CEL03hjoCNS+vVyNLXMsMWLY5ZjSYmrJRyhNpTkxQ4TnKA9viae6RmfcIKsR?= =?us-ascii?Q?f0N0jSk8H1rJemKF5InHyXwbVF8mfz8cJs8D2B7ESS/SC0vEbUIIFlr21JKv?= =?us-ascii?Q?ey2avPsOqMtItkNpuVXPVu9FgKOWo3y8QWrxC1nf0llyWXKMy1iYS6oVxWD3?= =?us-ascii?Q?OWh7ltBQq+yvsL613kw1M1b5poPCyzpItXBQFp+fpY3kojHung0fKTAn7kOh?= =?us-ascii?Q?axntaO3YbdLo1DNH9uF18rTqetbWKWqt7MExkPbk0H3cPMFtVhZcalOSU6At?= =?us-ascii?Q?5gVZhqq1npblLmrLougR5stB8Yv+dUMTXn9gFyYcM2l63OF0DJP67ykqrC8E?= =?us-ascii?Q?I1nTzbzh8NbMkB6G3czat6Yuv/EBUaiitlTzYoE2VyWnD1pe8kl78d8fwRQl?= =?us-ascii?Q?QybZQ5i6UznsRFvKtk6lmICKFUVBESdsvanhvg7bpatRG226j5Oc3kCBvCu+?= =?us-ascii?Q?9+iIgImtrdYqU7qUtzC4W+bIOelFBlgzY6HsT562DEcpFIlo7w/UoXe7NtXE?= =?us-ascii?Q?XDbsnu9BwCbPbHLyFxh7osUmFAQA+lvNUrynrGmOPWwEBjrU14wb/O4UDG5O?= =?us-ascii?Q?tjjS4siwBygfTdBAL3485yfDyKd15zEmA006S/3CLmugvl2IfCDNzm5/JLh0?= =?us-ascii?Q?vXWsLAVIBbOTCHMSAb8v/jw19RizvelQUs8Ps8gNbd1CM1AZUhBe3qDVfQU3?= =?us-ascii?Q?4lnOrftd2+x7WXyASNMBvXnXIeKWWAO41o1h+FHXI8lM2PhvgWpxdqKJBx7K?= =?us-ascii?Q?H/WwS5tDwyZWvi0L5Ke0cu0AadDrhIsojmCOf/5s4+v/J0TB/UzqSJfDBZEg?= =?us-ascii?Q?yDpP7v6YRg7tbJhZFTpGyftimJS8LCfDOPFPUj5ZsA7e3QYFn9aniW44w+JR?= =?us-ascii?Q?GoCNPAG0ZBU4/PXFX1ZKpxs5z6XqxSiFYuxnyAAos9Ha/ue+GzoH5OGlSBxw?= =?us-ascii?Q?Lja5gMOiAM2nBOesPmvuzsppKiXx66V0b/arilLhLUmSFy+0NYYliPWmQcAe?= =?us-ascii?Q?U82+LaZVppv6EkQwu879dvPmpqeKjOQOUiVOMq94OA0MtbEQki1qZKDVL3+y?= =?us-ascii?Q?T8HtOlsNyncGuWggww2HaG1oYGenW7WOHkJ5veUs2ngPvmXYynb2ZDF28JNA?= =?us-ascii?Q?WjxAAAwQV1fCRTrmHrA7QxKBqyb041xodq2O/OO2ImtoyrYrH+TRMv1+BGdW?= =?us-ascii?Q?BFvtw0+TUPHACMGlZNDMgLF+ZuBmZiXS1gL5rqywICXzdZs+0DKhxAh8SU3f?= =?us-ascii?Q?ebxVaT35PdUSFTZPW+z342tjZRAxDp7VODXLAaWQl4OTNK5C46n2EOeq9zVA?= =?us-ascii?Q?1TUPawS7l2A1jjjq1kQyjQzPPOesef7b80bIH+CH?= 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: e1635366-3451-4316-dd4c-08da912bc473 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Sep 2022 23:50:39.1269 (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: outPLdX8LlLxA4UIIyqpp/9U2jCAo9Qn8Z2YZvNnsGkUaBtmb8VteDJ/oz89Jt2rwlUhjmjMbMOdLWIEfWk8pw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB7205 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 Reviewed-by: Isaac Oram -----Original Message----- From: Benjamin Doron =20 Sent: Tuesday, September 6, 2022 10:02 AM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L ; Sinha, Ankit ; Ni, Ray ; Chaganty, Rangasai V ; Oram, Isaac W Subject: [edk2-devel][edk2-platforms][PATCH v2 3/6] IntelSiliconPkg/Feature= /SmmControl: Implement PPI with chipset support S3 resume may require communication with SMM, for which we need the SmmCont= rol PPI. Therefore, port the DXE drivers to a library, like there is for SM= M Access. Tested, working on Kabylake. Further testing required after the refactor fo= r compatibility. Cc: Nate DeSimone Cc: Ankit Sinha Cc: Ray Ni Cc: Rangasai V Chaganty Cc: Isaac Oram Signed-off-by: Benjamin Doron --- .../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/PeiSmmCon +++ trolLib/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 +#inclu= de +#include +#include +#include +#include ++#include +#include ++#def= ine 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, \+ SmmContr= ol, \+ 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 com= pletes 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 S= MI+ ///+ IoWrite8 (+ (UINTN) OutputPort,+ (UINT8) (OutputData)+ = );++ return EFI_SUCCESS;+}++/**+ Clear the SMI status+++ @retval EFI_SUC= CESS The function completes successfully+ @retval EFI_DEVICE_E= RROR Something error occurred+**/+EFI_STATUS+EFIAPI+SmmClear (+ VOI= D+ )+{+ UINT16 ABase;+ UINT32 OutputData;+ UINT32 OutputPort;++ ABa= se =3D FixedPcdGet16 (PcdAcpiBaseAddress);++ ///+ /// Clear the Power But= ton Override Status Bit, it gates EOS from being set.+ ///+ OutputPort = =3D ABase + R_PCH_ACPI_PM1_STS;+ OutputData =3D B_PCH_ACPI_PM1_STS_PRBTNO= R;+ DEBUG (+ (DEBUG_EVENT,+ "The PM1 Status Port at address %x will= be written to %x.\n",+ OutputPort,+ OutputData)+ );+ IoWrite16= (+ (UINTN) OutputPort,+ (UINT16) (OutputData)+ );++ ///+ /// Cl= ear the APM SMI Status Bit+ ///+ OutputPort =3D ABase + R_PCH_SMI_STS;+ = OutputData =3D B_PCH_SMI_STS_APM;+ DEBUG (+ (DEBUG_EVENT,+ "The S= MI Status Port at address %x will be written to %x.\n",+ OutputPort,+ = OutputData)+ );+ IoWrite32 (+ (UINTN) OutputPort,+ (UINT32) (O= utputData)+ );++ ///+ /// Set the EOS Bit+ ///+ OutputPort =3D ABas= e + R_PCH_SMI_EN;+ OutputData =3D IoRead32 ((UINTN) OutputPort);+ Output= Data |=3D B_PCH_SMI_EN_EOS;+ DEBUG (+ (DEBUG_EVENT,+ "The SMI Contr= ol Port at address %x will be written to %x.\n",+ OutputPort,+ Outp= utData)+ );+ IoWrite32 (+ (UINTN) OutputPort,+ (UINT32) (OutputDa= ta)+ );++ ///+ /// There is no need to read EOS back and check if it i= s set.+ /// This can lead to a reading of zero if an SMI occurs right afte= r 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 sources a= re processed.+ ///+ return EFI_SUCCESS;+}++/**+ This routine generates a= n SMI++ @param[in] This The EFI SMM Control protocol= instance+ @param[in, out] ArgumentBuffer The buffer of argument+ = @param[in, out] ArgumentBufferSize The size of the argument buffer+ @pa= ram[in] Periodic Periodic or not+ @param[in] ActivationI= nterval Interval of periodic SMI++ @retval EFI Status = Describing the result of the operation+ @retval EFI_INVALID_PARAMET= ER Some parameter value passed is not supported+**/+EFI_STATUS+EFIA= PI+Activate (+ IN EFI_PEI_SERVICES **PeiServices,+ IN EFI_PEI_MM_C= ONTROL_PPI * This,+ IN OUT INT8 *ArgumentBuffer OPTIONAL,+= IN OUT UINTN *ArgumentBufferSize OPTIONAL,+ IN BOOLEAN = Periodic OPTIONAL,+ IN UINTN ActivationInte= rval OPTIONAL+ )+{+ EFI_STATUS Status;+ UINT8 Data;++ if (Period= ic) {+ DEBUG ((DEBUG_WARN, "Invalid parameter\n"));+ return EFI_INVAL= ID_PARAMETER;+ }++ // NOTE: Copied from Quark. Matches the usage in PiSmm= CommunicationPei+ if (ArgumentBuffer =3D=3D NULL) {+ Data =3D 0xFF;+ }= else {+ if (ArgumentBufferSize =3D=3D NULL || *ArgumentBufferSize !=3D = 1) {+ return EFI_INVALID_PARAMETER;+ }++ Data =3D *ArgumentBuffe= r;+ }+ ///+ /// Clear any pending the APM SMI+ ///+ Status =3D SmmClea= r ();+ if (EFI_ERROR (Status)) {+ return Status;+ }++ return SmmTrigg= er (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 resul= t of the operation+ @retval EFI_INVALID_PARAMETER Some parameter value p= assed is not supported+**/+EFI_STATUS+EFIAPI+Deactivate (+ IN EFI_PEI_SERV= ICES **PeiServices,+ IN EFI_PEI_MM_CONTROL_PPI * This,+ IN BOOLEA= N 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 provides a standard+ wa= y 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 n= ot have enough resources to initialize the driver.+**/+EFI_STATUS+EFIAPI+Pe= iInstallSmmControlPpi (+ VOID+ )+{+ EFI_STATUS Stat= us;+ EFI_PEI_PPI_DESCRIPTOR *PpiList;+ SMM_CONTROL_PRIVATE_DATA = *SmmControlPrivate;++ //+ // Initialize private data+ //+ SmmCon= trolPrivate =3D AllocateZeroPool (sizeof (*SmmControlPrivate));+ ASSERT (= SmmControlPrivate !=3D NULL);+ if (SmmControlPrivate =3D=3D NULL) {+ re= turn EFI_OUT_OF_RESOURCES;+ }+ PpiList =3D AllocateZeroPool (si= zeof (*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;+ SmmControlPriva= te->SmmControl.Clear =3D Deactivate;++ //+ // Install PPI+ //+ PpiLi= st->Flags =3D (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINA= TE_LIST);+ PpiList->Guid =3D &gEfiPeiMmControlPpiGuid;+ PpiList->Ppi = =3D &SmmControlPrivate->SmmControl;++ Status =3D PeiServicesInst= allPpi (PpiList);+ ASSERT_EFI_ERROR (Status);++ // Unlike driver, do not = disable SMIs as S3 resume continues+ return EFI_SUCCESS;+}diff --git a/Sil= icon/Intel/IntelSiliconPkg/Feature/SmmControl/Library/PeiSmmControlLib/PeiS= mmControlLib.inf b/Silicon/Intel/IntelSiliconPkg/Feature/SmmControl/Library= /PeiSmmControlLib/PeiSmmControlLib.inf new file mode 100644 index 000000000000..91c761366446 --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Feature/SmmControl/Library/PeiSmmCon +++ trolLib/PeiSmmControlLib.inf @@ -0,0 +1,34 @@ +## @file+# Library description file for the SmmControl PPI+#+# Copyright (= c) 2019, Intel Corporation. All rights reserved.
+# SPDX-License-Identif= ier: BSD-2-Clause-Patent+#+##++[Defines]+ INF_VERSION = =3D 0x00010017+ BASE_NAME =3D PeiSmmControlLib+ FILE= _GUID =3D F45D521A-C0DF-4283-A3CA-65AD01B479E7+ VERSI= ON_STRING =3D 1.0+ MODULE_TYPE =3D PEIM= + LIBRARY_CLASS =3D SmmControlLib++[LibraryClasses]+ IoL= ib+ DebugLib+ MemoryAllocationLib+ PeiServicesLib++[Packages]+ MdePkg/M= dePkg.dec+ IntelSiliconPkg/IntelSiliconPkg.dec++[Sources]+ PeiSmmControlL= ib.c++[Pcd]+ gIntelSiliconPkgTokenSpaceGuid.PcdAcpiBaseAddress ## CONSUME= S++[Ppis]+ gEfiPeiMmControlPpiGuid ## PRODUCESd= iff --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_CO= NTROL_PPI. This PPI provides a standard+ way for other modules to trigge= r software SMIs.++ @retval EFI_SUCCESS - Ppi successfully star= ted and installed.+ @retval EFI_NOT_FOUND - Ppi can't be found.+= @retval EFI_OUT_OF_RESOURCES - Ppi does not have enough resources to i= nitialize the driver.+**/+EFI_STATUS+EFIAPI+PeiInstallSmmControlPpi (+ VOI= D+ );+#endifdiff --git a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec= b/Silicon/Intel/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 + ## @libraryclass Prov= ides services to trigger SMI+ #+ SmmControlLib|Include/Library/SmmControl= Lib.h+ ## @libraryclass Provides services to access config block # Co= nfigBlockLib|Include/Library/ConfigBlockLib.h--=20 2.37.2