From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.100]) by mx.groups.io with SMTP id smtpd.web12.9725.1637167867918179256 for ; Wed, 17 Nov 2021 08:51:08 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@os.amperecomputing.com header.s=selector2 header.b=JRMxU6m4; spf=pass (domain: os.amperecomputing.com, ip: 40.107.220.100, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A8bxAc8v9Qx3s6iRWAqnG+SJ7Yc+HqchRzBCgp/4N7FfuVcWRnTcCX9pwUoXrePksW4MH6QtGPwRIzqhW+JJfZyy7SHDC6IdCq4nEoBpVDImEvmPNDT1/v+pFnZi7dUrfkc+HCOPL72fVEz4Ffsl+xBKcMggVKMcwn0z8XNjmsGLzqDiLNcWtRomA6Hiy1VW+zQaqWhihhu/efjzO2AZ9OiC9uz3wyQB2yu0vxlukN6bc7o7zoTU1u9krxQQRCFHalVd1XJbTjfng76lbiyZgI85XQrpT1mwNZQcWD7O3RHpXjMPPiGWB9cZ1Njj++PQAhKQFfY3rufEPp5t0OuktQ== 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=eqdaIIyzyY9BKffZ9JdEkMqNFo1yXc7sm3oyOP9WtOs=; b=kdQqvPGen3/cF8jmZuJPoJIMGuaC+qKYt/XaoTuaqvV8k8g6kHHTU9BopZZ/ZMRvRzDSlXfY7pn8by7haImR1spy0l0ijuzxFuxVCRQjUncZXgoz4pD0/h0m4BkiUUvRAKWc3TqE9bVGkAGUyGNV8dyumBAdm68E2NzZR1L7hQhX1ygcLAXhtXwZMpPsj9KCxn3Q7cjV7mmG4etHH/VynyIz0u1n2FkB8DFNRgxACyzbXB2KNWgKdhcsPOaI9YJhEFm35Jcqa3IiC3qt8jncNKT9CjDFjXi0atY7rt7VXkmeafuQw3bcCKRoy9q4JmGly9isD4rXplAvUn7xkp+/vA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eqdaIIyzyY9BKffZ9JdEkMqNFo1yXc7sm3oyOP9WtOs=; b=JRMxU6m4I+Y2xS70nsOzeSGVjBniOa8+dkmO1cdOfpmaYq8UAiRv30JdX3Jr++PCFuhbTHHvfwDlWhYrNlqZiFsZ7O8T0T+/GvKhiK6R03y/6prtwxezQstiwTkYXywGfpME5mQsYqXkpN1BMM93yu759lZ2gdJc8Q1xDFqrJnU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) by PH0PR01MB7400.prod.exchangelabs.com (2603:10b6:510:10b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19; Wed, 17 Nov 2021 16:51:06 +0000 Received: from PH0PR01MB7287.prod.exchangelabs.com ([fe80::254c:9533:7f35:aee]) by PH0PR01MB7287.prod.exchangelabs.com ([fe80::254c:9533:7f35:aee%4]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 16:51:06 +0000 From: "Nhi Pham" To: devel@edk2.groups.io CC: patches@amperecomputing.com, nhi@os.amperecomputing.com, vunguyen@os.amperecomputing.com, Thang Nguyen , Chuong Tran , Phong Vo , Leif Lindholm , Michael D Kinney , Ard Biesheuvel , Nate DeSimone Subject: [edk2-platforms][PATCH v5 28/30] AmpereAltraPkg: Add configuration screen for ACPI Date: Wed, 17 Nov 2021 23:47:25 +0700 Message-ID: <20211117164727.10922-29-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211117164727.10922-1-nhi@os.amperecomputing.com> References: <20211117164727.10922-1-nhi@os.amperecomputing.com> X-ClientProxiedBy: HKAPR04CA0001.apcprd04.prod.outlook.com (2603:1096:203:d0::11) To PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 Received: from sw004.amperecomputing.com (118.69.219.201) by HKAPR04CA0001.apcprd04.prod.outlook.com (2603:1096:203:d0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.21 via Frontend Transport; Wed, 17 Nov 2021 16:51:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 82c740c1-c55a-4106-2073-08d9a9ea7282 X-MS-TrafficTypeDiagnostic: PH0PR01MB7400: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:207; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vN00aELO/g8y+PrACeuGS5U4cR4EMAhrOeyeu/EGTD/pNXd95lSbxJHLuxKEM+NDsjuY2/kSwiGx/Ed9fk82OGweNasfMmR3oAyT8b9uPhWM4OHV/KPL6Ivi/Amw+1iT9yEgm2MjbZHrbExWI1B89eUv3RB3fZpdOmxBjAgOpjVM8yC5erPNDH+n3BcW/DPqrIXtRZMYzhpwtgohw29keR5Eop9BRrX1+nQnj0fovdpeagzx5IyRnsYiTJTHRA1ZFglk1xvslh1fpQmFNE3W2yjTk5TmbuaEiWSHatCdUBsBNAdxOMj/PPgcGqTsFaNL5LN3Op0DTFuN4d23MRKkJkVQUFQAT2mG9OH6jYBJeGMPfNhZ0UV0RdzbDkw9bDohFBo+WQautXSUE+TLQ+H6p9pf8ekohrk5qOjXLJRjZHqPAPPL1mImxD6GY631FNqmxq2DkxX6s/D8lNMA27vyJ0eN/C1zyP+gsQkdYDLJEJvgFNLZiUQZGx5TYYSrK8tfvQ/MddY8UdP6BEp62yHKJXq6B0uXMFl/atIXOrDgzEiswnrt6dW/vqbSw0RBIPMVzCc1zVky3VWlHh84j1c++wCZey3cqXy8V5yRhQW5yffTP97Qyp19+WCWpMserSX4FwAyUbNLlBot981ZtiCRXvY/R7x89chvjY/8ureVjralkZKQOKLEPcyIdxGvK+OrgH+O1VYZyjOwCUO5ecYBoUINUkJQnJ8ZvV5ZiFN9aEIaZKDUcyVJYXpZ8a3uKSyxicxq7WzDfykiY/fOWw7qEg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR01MB7287.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(30864003)(956004)(508600001)(186003)(38100700002)(6666004)(83380400001)(6486002)(52116002)(66574015)(66476007)(66946007)(2616005)(66556008)(1076003)(54906003)(8676002)(38350700002)(4326008)(316002)(19627235002)(6512007)(8936002)(2906002)(6916009)(5660300002)(6506007)(86362001)(26005)(290074003)(44824005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?GtaUFl47wQxQLD5nlWNE7KYBYCp3qYq8OAnUal6adz/BgX07+ajBwpKrSykG?= =?us-ascii?Q?MT7NRtg1cFlrfeeU/uKcYKumzQKkH9nOMorYF6SsM+12AFk3jGgbzvpo3UBZ?= =?us-ascii?Q?ibjjtiw95OEgNNo/x6LyzjHbeUheOP9Ht/q0XT1oR9+VRxUrL/aTRz5xd5dU?= =?us-ascii?Q?wvA0/8amkg06foDTctPB08b/IK+xOq8Zdu4HHg3Fygw8jimEJ2D9Y0D3jJoP?= =?us-ascii?Q?9uEUalojogohTNhUShvU+PMJDJ9o06njUxt2BwbxNeFvxlbdGm+LIcuxu+SA?= =?us-ascii?Q?lWwsK6ThU1+xa2+xs7TOqFgqwz1Lbxlhmr2HqJ91cf016GZAyRYimnKitGra?= =?us-ascii?Q?que6kjoolcUcfrksiscwSuUwBJctYE7Xshi+qU3F9BkK1VST06kKW9iqrx1u?= =?us-ascii?Q?QoB47w30yBYD6Yh/xqi66Ak0Ai2rIam16Fc9kMyZxTVFH6vf0IxnstnjJvuP?= =?us-ascii?Q?+pGyngpjXJkVwJkos9MrRCk0WvMXOMfgndqMmaz+1l8GSx9+6aeK4Bn92IIE?= =?us-ascii?Q?7Y+SYlrt6kzj3yumB/eryrP1ASWClKO9fHnJxBtEBvQVCjmumMLS5P8OrvzI?= =?us-ascii?Q?+rTj0legVqcgPNFMfrUo2k1aGkQT/uJizNs4HXr/NB6uu1Pfr1/6paWwrmjV?= =?us-ascii?Q?CH6yI95pQWwguML08Js9EOYahUsYvzlhc/wRo4OBFUWhDyBapYeNG2NiFKyk?= =?us-ascii?Q?zoXprqKxe0TCOG9FQZ5VARsVzRxcN8TdBzufTjV70Ag/nHEfRiescmptN7Ke?= =?us-ascii?Q?GmPwqx4dZkOXELKYNBq8xfrDgaXAu405InzlqhJX9cP4kKxdkg7MwRQ6Pk4r?= =?us-ascii?Q?QHmCLKUC3ugdCh2Gusqol06wdvWLfvsdXdIs0qdzsDQ8ALvCfulIdkv8s1QV?= =?us-ascii?Q?Ely0xr1PGUngQf8YFug+bb8vYqe0yHVDMEKhvWiIeiKuruExeNwkMPJbe/yR?= =?us-ascii?Q?8EaS48EJQeI34U/d2KfFK1N8H6As4mcJxCtZyXBadAmSMcZVolhA7LU0QQU0?= =?us-ascii?Q?OkzVjFiHaq554HBWfaLk+oFfPyb6VPMP9mI62MwONK1/0006sbMUUL1ujyVi?= =?us-ascii?Q?o0UxXaNCkijLJhhE0hxcJkSPIYoYpxhlCphXUpAzzQU7W97Udkz/9qmZOTlY?= =?us-ascii?Q?iFi3N7g8F6BvZUj2FT6zR3U6h+5Mf109bLLe3tgJ8X3ZirGB9RZMXBiMbIH9?= =?us-ascii?Q?gZmoYajn8nAKypzGp/RubfDUFeZrnYyG0lvrL8uaDlFH3U0e/MMnm7/xIHuS?= =?us-ascii?Q?M2gSMHxJPCtKbXviTX3L0tKzEnfdXNJU7XA+s8DYCIXt5QD983MEAix3B35D?= =?us-ascii?Q?dD8I/Re+drgh+IWYR6R3GRHxTRW6z8dlXyeOWYxlGVQZvKL4RYFj+XY2uxjS?= =?us-ascii?Q?Nz18OkoiJH7TsBBYC5cQzQOr6z2h2vpSatVacaSw+VodluHVje+A9I8Hk6bO?= =?us-ascii?Q?2gU0hEiP27NH3roVY1F9hgCil6po7yjWt914K3PluaU8Z4/vcy1gIYDAYULQ?= =?us-ascii?Q?zox48RPZtPi9E8IgJ6Ir5hIyJTp1WfXyhVKZ2vkYs0yoENh7U2XUbMbfG9of?= =?us-ascii?Q?BIx5yPH7fEETOS0gr/0dPp45qXuS7x15u8SZSxeQuCmOmFkjpGjvkgc+BlRd?= =?us-ascii?Q?j7mvzqJ96Onc6gaZ3SPgzeGsIaczhbz8v43s++HtCJEsFlGEoEi3Wl6wdW/R?= =?us-ascii?Q?kNYDAd1aMUarj5m7xBB5dys3bXk=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82c740c1-c55a-4106-2073-08d9a9ea7282 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7287.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 16:51:06.0557 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lrBLV9A/Smvx/aXVbQk8xPfvGwqmjOKrJ+FkAR/wDC9CHVmTAKEoHfbx2HP9AknmMcQI55J52V56KsUJMGM4yeZfrKUKObalocSIgCNF06s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR01MB7400 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain This supports: * Enable/Disable APEI Support * Enable/Disable CPPC Support * Enable/Disable LPI support * Enable/Disable Max Performance Mode Cc: Thang Nguyen Cc: Chuong Tran Cc: Phong Vo Cc: Leif Lindholm Cc: Michael D Kinney Cc: Ard Biesheuvel Cc: Nate DeSimone Signed-off-by: Nhi Pham Reviewed-by: Leif Lindholm --- Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec = | 3 + Platform/Ampere/JadePkg/Jade.dsc = | 1 + Platform/Ampere/JadePkg/Jade.fdf = | 1 + Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf = | 1 + Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.inf = | 58 ++ Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.h = | 2 + Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.h = | 62 ++ Silicon/Ampere/AmpereAltraPkg/Include/AcpiConfigNVDataStruct.h = | 28 + Silicon/Ampere/AmpereAltraPkg/Include/Guid/AcpiConfigHii.h = | 19 + Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigVfr.vfr = | 69 ++ Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.c = | 23 +- Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.c = | 728 ++++++++++++++++++++ Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigStrings.uni = | 27 + 13 files changed, 1020 insertions(+), 2 deletions(-) diff --git a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec b/Silicon/Amp= ere/AmpereAltraPkg/AmpereAltraPkg.dec index 68e235b06c0c..d795c9229691 100644 --- a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec +++ b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec @@ -67,3 +67,6 @@ [Guids] =20 ## Include/Guid/CpuConfigHii.h gCpuConfigFormSetGuid =3D { 0x43FAA144, 0xA2DF, 0x4050, { 0xA7, 0= xFD, 0xEE, 0x17, 0xC9, 0xB8, 0x88, 0x8E } } + + ## Include/Guid/AcpiConfigHii.h + gAcpiConfigFormSetGuid =3D { 0x0ceb6764, 0xd415, 0x4b01, { 0xa8, 0x43, 0= xd1, 0x01, 0xbc, 0xb0, 0xd8, 0x29 } } diff --git a/Platform/Ampere/JadePkg/Jade.dsc b/Platform/Ampere/JadePkg/Jad= e.dsc index 4dff28de920a..b476bc05a600 100644 --- a/Platform/Ampere/JadePkg/Jade.dsc +++ b/Platform/Ampere/JadePkg/Jade.dsc @@ -189,3 +189,4 @@ [Components.common] Silicon/Ampere/AmpereAltraPkg/Drivers/PlatformInfoDxe/PlatformInfoDxe.in= f Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.inf Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.inf + Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.inf diff --git a/Platform/Ampere/JadePkg/Jade.fdf b/Platform/Ampere/JadePkg/Jad= e.fdf index 869d802eccd4..87b04faa9e9a 100644 --- a/Platform/Ampere/JadePkg/Jade.fdf +++ b/Platform/Ampere/JadePkg/Jade.fdf @@ -355,5 +355,6 @@ [FV.FvMain] INF Silicon/Ampere/AmpereAltraPkg/Drivers/PlatformInfoDxe/PlatformInfoDx= e.inf INF Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.inf INF Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.inf + INF Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.in= f =20 !include Silicon/Ampere/AmpereSiliconPkg/FvRules.fdf.inc diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDx= e.inf b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf index 804e761a1524..8ab6a790ce07 100644 --- a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf +++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf @@ -69,6 +69,7 @@ [Guids] gArmMpCoreInfoGuid gEfiAcpiTableGuid gEfiEventReadyToBootGuid + gAcpiConfigFormSetGuid gPlatformInfoHobGuid gRootComplexInfoHobGuid gRootComplexConfigFormSetGuid diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfig= Dxe.inf b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe= .inf new file mode 100644 index 000000000000..005ab65e39f8 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.inf @@ -0,0 +1,58 @@ +## @file +# +# Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D AcpiConfigDxe + FILE_GUID =3D F36685AE-2623-4231-ABC0-2C151451E6B7 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D AcpiConfigEntryPoint + +[Sources.common] + AcpiConfigDxe.c + AcpiConfigDxe.h + AcpiConfigVfr.vfr + AcpiConfigStrings.uni + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec + Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec + +[LibraryClasses] + AcpiLib + BaseLib + BaseMemoryLib + DebugLib + DevicePathLib + HiiLib + HobLib + MemoryAllocationLib + SystemFirmwareInterfaceLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + +[Guids] + gPlatformManagerFormsetGuid + gAcpiConfigFormSetGuid + gEfiEventReadyToBootGuid + gPlatformInfoHobGuid + +[Protocols] + gEfiAcpiSdtProtocolGuid ## COMSUMES + gEfiDevicePathProtocolGuid ## CONSUMES + gEfiHiiConfigRoutingProtocolGuid ## CONSUMES + gEfiHiiConfigAccessProtocolGuid ## PRODUCES + +[Depex] + gEfiVariableArchProtocolGuid AND + gEfiVariableWriteArchProtocolGuid diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.h b/P= latform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.h index 61648f107efe..4a3b99d481bb 100644 --- a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.h +++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.h @@ -9,7 +9,9 @@ #ifndef ACPI_APEI_H_ #define ACPI_APEI_H_ =20 +#include #include +#include #include #include #include diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfig= Dxe.h b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.h new file mode 100644 index 000000000000..8a2cc2f5e679 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.h @@ -0,0 +1,62 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef ACPI_CONFIG_DXE_H_ +#define ACPI_CONFIG_DXE_H_ + +// +// This is the generated IFR binary data for each formset defined in VFR. +// +extern UINT8 AcpiConfigVfrBin[]; + +// +// This is the generated String package data for all .UNI files. +// +extern UINT8 AcpiConfigDxeStrings[]; + +// +// Signature: Ampere Computing ACPI Configuration +// +#define ACPI_CONFIG_PRIVATE_SIGNATURE SIGNATURE_32 ('A', 'C', 'A', 'C') + +typedef struct { + UINTN Signature; + + EFI_HANDLE DriverHandle; + EFI_HII_HANDLE HiiHandle; + ACPI_CONFIG_VARSTORE_DATA Configuration; + PLATFORM_INFO_HOB *PlatformHob; + EFI_ACPI_SDT_PROTOCOL *AcpiSdtProtocol; + EFI_ACPI_HANDLE AcpiTableHandle; + + // + // Consumed protocol + // + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + + // + // Produced protocol + // + EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess; +} ACPI_CONFIG_PRIVATE_DATA; + +#define ACPI_CONFIG_PRIVATE_FROM_THIS(a) CR (a, ACPI_CONFIG_PRIVATE_DATA,= ConfigAccess, ACPI_CONFIG_PRIVATE_SIGNATURE) + +#pragma pack(1) + +/// +/// HII specific Vendor Device Path definition. +/// +typedef struct { + VENDOR_DEVICE_PATH VendorDevicePath; + EFI_DEVICE_PATH_PROTOCOL End; +} HII_VENDOR_DEVICE_PATH; + +#pragma pack() + +#endif diff --git a/Silicon/Ampere/AmpereAltraPkg/Include/AcpiConfigNVDataStruct.h= b/Silicon/Ampere/AmpereAltraPkg/Include/AcpiConfigNVDataStruct.h new file mode 100644 index 000000000000..a56bfa9aa694 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Include/AcpiConfigNVDataStruct.h @@ -0,0 +1,28 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef ACPI_CONFIG_NV_DATA_STRUC_H_ +#define ACPI_CONFIG_NV_DATA_STRUC_H_ + +#pragma pack(1) + +// +// ACPI Configuration NV data structure definition +// +typedef struct { + UINT32 EnableApeiSupport; + UINT32 AcpiCppcEnable; + UINT32 AcpiLpiEnable; + UINT32 AcpiTurboSupport; + UINT32 AcpiTurboMode; + UINT32 Reserved[4]; +} ACPI_CONFIG_VARSTORE_DATA; + +#pragma pack() + +#endif /* ACPI_CONFIG_NV_DATA_STRUC_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Include/Guid/AcpiConfigHii.h b/S= ilicon/Ampere/AmpereAltraPkg/Include/Guid/AcpiConfigHii.h new file mode 100644 index 000000000000..1779a4543769 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Include/Guid/AcpiConfigHii.h @@ -0,0 +1,19 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef ACPI_CONFIG_FORMSET_GUID_H_ +#define ACPI_CONFIG_FORMSET_GUID_H_ + +#define ACPI_CONFIGURATION_FORMSET_GUID \ + { \ + 0x0ceb6764, 0xd415, 0x4b01, { 0xa8, 0x43, 0xd1, 0x01, 0xbc, 0xb0, 0xd8= , 0x29 } \ + } + +extern EFI_GUID gAcpiConfigFormSetGuid; + +#endif /* ACPI_CONFIG_FORMSET_GUID_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfig= Vfr.vfr b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigVfr= .vfr new file mode 100644 index 000000000000..3962aa227037 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigVfr.vfr @@ -0,0 +1,69 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + + +#include +#include + +#define ACPI_CONFIG_FORM_ID 1 + +formset + guid =3D ACPI_CONFIGURATION_FORMSET_GUID, + title =3D STRING_TOKEN(STR_ACPI_FORM), + help =3D STRING_TOKEN(STR_ACPI_FORM_HELP), + classguid =3D gPlatformManagerFormsetGuid, + + varstore ACPI_CONFIG_VARSTORE_DATA, + name =3D AcpiConfigNVData, + guid =3D ACPI_CONFIGURATION_FORMSET_GUID; + + form + formid =3D ACPI_CONFIG_FORM_ID, + title =3D STRING_TOKEN(STR_ACPI_FORM); + subtitle text =3D STRING_TOKEN(STR_ACPI_FORM_HELP); + + oneof + varid =3D AcpiConfigNVData.EnableApeiSupport, + prompt =3D STRING_TOKEN(STR_ACPI_APEI_SUPPORT_PROMPT), + help =3D STRING_TOKEN(STR_ACPI_APEI_SUPPORT_HELP), + option text =3D STRING_TOKEN(STR_ACPI_COMMON_DISABLE), value =3D 0, = flags =3D 0; + option text =3D STRING_TOKEN(STR_ACPI_COMMON_ENABLE), value =3D 1, f= lags =3D DEFAULT; + endoneof; + + oneof + varid =3D AcpiConfigNVData.AcpiCppcEnable, + prompt =3D STRING_TOKEN(STR_ACPI_CPPC_PROMPT), + help =3D STRING_TOKEN(STR_ACPI_CPPC_HELP), + option text =3D STRING_TOKEN(STR_ACPI_COMMON_DISABLE), value =3D 0, = flags =3D 0; + option text =3D STRING_TOKEN(STR_ACPI_COMMON_ENABLE), value =3D 1, f= lags =3D DEFAULT; + endoneof; + + oneof + varid =3D AcpiConfigNVData.AcpiLpiEnable, + prompt =3D STRING_TOKEN(STR_ACPI_LPI_PROMPT), + help =3D STRING_TOKEN(STR_ACPI_LPI_HELP), + option text =3D STRING_TOKEN(STR_ACPI_COMMON_DISABLE), value =3D 0, = flags =3D 0; + option text =3D STRING_TOKEN(STR_ACPI_COMMON_ENABLE), value =3D 1, f= lags =3D DEFAULT; + endoneof; + + grayoutif ideqval AcpiConfigNVData.AcpiTurboSupport =3D=3D 0; + oneof + varid =3D AcpiConfigNVData.AcpiTurboMode, + prompt =3D STRING_TOKEN(STR_ACPI_TURBO_PROMPT), + help =3D STRING_TOKEN(STR_ACPI_TURBO_HELP), + option text =3D STRING_TOKEN(STR_ACPI_COMMON_ENABLE), value =3D 1,= flags =3D DEFAULT; + option text =3D STRING_TOKEN(STR_ACPI_COMMON_DISABLE), value =3D 0= , flags =3D 0; + suppressif ideqval AcpiConfigNVData.AcpiTurboSupport > 0; + option text =3D STRING_TOKEN(STR_ACPI_UNSUPPORTED), value =3D 2, f= lags =3D 0; + endif; + endoneof; + endif; + + endform; + +endformset; diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.c b/P= latform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.c index 58c511db99a7..aec96e6aec04 100644 --- a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.c +++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.c @@ -423,8 +423,27 @@ AcpiApeiUpdate ( VOID ) { - if (!IsSlaveSocketActive ()) { - AcpiApeiHestUpdateTable1P (); + EFI_STATUS Status; + ACPI_CONFIG_VARSTORE_DATA AcpiConfigData; + UINTN BufferSize; + + BufferSize =3D sizeof (ACPI_CONFIG_VARSTORE_DATA); + Status =3D gRT->GetVariable ( + L"AcpiConfigNVData", + &gAcpiConfigFormSetGuid, + NULL, + &BufferSize, + &AcpiConfigData + ); + if (!EFI_ERROR (Status) && (AcpiConfigData.EnableApeiSupport =3D=3D 0)) = { + AcpiApeiUninstallTable (EFI_ACPI_6_3_BOOT_ERROR_RECORD_TABLE_SIGNATURE= ); + AcpiApeiUninstallTable (EFI_ACPI_6_3_HARDWARE_ERROR_SOURCE_TABLE_SIGNA= TURE); + AcpiApeiUninstallTable (EFI_ACPI_6_3_SOFTWARE_DELEGATED_EXCEPTIONS_INT= ERFACE_TABLE_SIGNATURE); + AcpiApeiUninstallTable (EFI_ACPI_6_3_ERROR_INJECTION_TABLE_SIGNATURE); + } else { + if (!IsSlaveSocketActive ()) { + AcpiApeiHestUpdateTable1P (); + } } =20 if (!IsSdeiEnabled ()) { diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfig= Dxe.c b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.c new file mode 100644 index 000000000000..6ba39ad4409b --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.c @@ -0,0 +1,728 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "AcpiConfigDxe.h" + +#define ACPI_VARSTORE_ATTRIBUTES EFI_VARIABLE_BOOTSERVICE_ACCESS | \ + EFI_VARIABLE_RUNTIME_ACCESS | \ + EFI_VARIABLE_NON_VOLATILE + +CHAR16 AcpiVarstoreDataName[] =3D L"AcpiConfigNVData"; + +EFI_HANDLE mDriverHandle =3D NULL; +ACPI_CONFIG_PRIVATE_DATA *mPrivateData =3D NULL; + +HII_VENDOR_DEVICE_PATH mAcpiConfigHiiVendorDevicePath =3D { + { + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { + (UINT8)(sizeof (VENDOR_DEVICE_PATH)), + (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8) + } + }, + ACPI_CONFIGURATION_FORMSET_GUID + }, + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + (UINT8)(END_DEVICE_PATH_LENGTH), + (UINT8)((END_DEVICE_PATH_LENGTH) >> 8) + } + } +}; + +/** + This function allows a caller to extract the current configuration for o= ne + or more named elements from the target driver. + + @param This Points to the EFI_HII_CONFIG_ACCESS_PROTO= COL. + @param Request A null-terminated Unicode string in + format. + @param Progress On return, points to a character in the R= equest + string. Points to the string's null termi= nator if + request was successful. Points to the mos= t recent + '&' before the first failing name/value p= air (or + the beginning of the string if the failur= e is in + the first name/value pair) if the request= was not + successful. + @param Results A null-terminated Unicode string in + format which has all valu= es filled + in for the names in the Request string. S= tring to + be allocated by the called function. + + @retval EFI_SUCCESS The Results is filled with the requested = values. + @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results. + @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown nam= e. + @retval EFI_NOT_FOUND Routing data doesn't match any storage in= this + driver. + +**/ +EFI_STATUS +EFIAPI +ExtractConfig ( + IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, + IN CONST EFI_STRING Request, + OUT EFI_STRING *Progress, + OUT EFI_STRING *Results + ) +{ + EFI_STATUS Status; + UINTN BufferSize; + ACPI_CONFIG_PRIVATE_DATA *PrivateData; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + EFI_STRING ConfigRequest; + EFI_STRING ConfigRequestHdr; + UINTN Size; + BOOLEAN AllocatedRequest; + + if (Progress =3D=3D NULL || Results =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Initialize the local variables. + // + ConfigRequestHdr =3D NULL; + ConfigRequest =3D NULL; + Size =3D 0; + *Progress =3D Request; + AllocatedRequest =3D FALSE; + + if ((Request !=3D NULL) && !HiiIsConfigHdrMatch (Request, &gAcpiConfigFo= rmSetGuid, AcpiVarstoreDataName)) { + return EFI_NOT_FOUND; + } + + PrivateData =3D ACPI_CONFIG_PRIVATE_FROM_THIS (This); + HiiConfigRouting =3D PrivateData->HiiConfigRouting; + + // + // Get Buffer Storage data from EFI variable. + // Try to get the current setting from variable. + // + BufferSize =3D sizeof (ACPI_CONFIG_VARSTORE_DATA); + Status =3D gRT->GetVariable ( + AcpiVarstoreDataName, + &gAcpiConfigFormSetGuid, + NULL, + &BufferSize, + &PrivateData->Configuration + ); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + // + // Convert buffer data to by helper function BlockToConfig(= ) + // + BufferSize =3D sizeof (ACPI_CONFIG_VARSTORE_DATA); + ConfigRequest =3D Request; + if ((Request =3D=3D NULL) || (StrStr (Request, L"OFFSET") =3D=3D NULL)) = { + // + // Request has no request element, construct full request string. + // Allocate and fill a buffer large enough to hold the tem= plate + // followed by "&OFFSET=3D0&WIDTH=3DWWWWWWWWWWWWWWWW" followed by a Nu= ll-terminator + // + ConfigRequestHdr =3D HiiConstructConfigHdr ( + &gAcpiConfigFormSetGuid, + AcpiVarstoreDataName, + PrivateData->DriverHandle + ); + Size =3D (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); + ConfigRequest =3D AllocateZeroPool (Size); + ASSERT (ConfigRequest !=3D NULL); + if (ConfigRequest =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + AllocatedRequest =3D TRUE; + UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=3D0&WIDTH=3D%016LX", C= onfigRequestHdr, (UINT64)BufferSize); + FreePool (ConfigRequestHdr); + } + + // + // Convert buffer data to by helper function BlockToConfig(= ) + // + Status =3D HiiConfigRouting->BlockToConfig ( + HiiConfigRouting, + ConfigRequest, + (UINT8 *)&PrivateData->Configuration, + BufferSize, + Results, + Progress + ); + + // + // Free the allocated config request string. + // + if (AllocatedRequest) { + FreePool (ConfigRequest); + ConfigRequest =3D NULL; + } + + // + // Set Progress string to the original request string. + // + if (Request =3D=3D NULL) { + *Progress =3D NULL; + } else if (StrStr (Request, L"OFFSET") =3D=3D NULL) { + *Progress =3D Request + StrLen (Request); + } + + return Status; +} + +/** + This function processes the results of changes in configuration. + + @param This Points to the EFI_HII_CONFIG_ACCESS_PROTO= COL. + @param Configuration A null-terminated Unicode string in + format. + @param Progress A pointer to a string filled in with the = offset of + the most recent '&' before the first fail= ing + name/value pair (or the beginning of the = string if + the failure is in the first name/value pa= ir) or + the terminating NULL if all was successfu= l. + + @retval EFI_SUCCESS The Results is processed successfully. + @retval EFI_INVALID_PARAMETER Configuration is NULL. + @retval EFI_NOT_FOUND Routing data doesn't match any storage in= this + driver. + +**/ +EFI_STATUS +EFIAPI +RouteConfig ( + IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, + IN CONST EFI_STRING Configuration, + OUT EFI_STRING *Progress + ) +{ + EFI_STATUS Status; + UINTN BufferSize; + ACPI_CONFIG_PRIVATE_DATA *PrivateData; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + + if (Configuration =3D=3D NULL || Progress =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + PrivateData =3D ACPI_CONFIG_PRIVATE_FROM_THIS (This); + HiiConfigRouting =3D PrivateData->HiiConfigRouting; + *Progress =3D Configuration; + + // + // Check routing data in . + // Note: if only one Storage is used, then this checking could be skippe= d. + // + if (!HiiIsConfigHdrMatch (Configuration, &gAcpiConfigFormSetGuid, AcpiVa= rstoreDataName)) { + return EFI_NOT_FOUND; + } + + // + // Get Buffer Storage data from EFI variable + // + BufferSize =3D sizeof (ACPI_CONFIG_VARSTORE_DATA); + Status =3D gRT->GetVariable ( + AcpiVarstoreDataName, + &gAcpiConfigFormSetGuid, + NULL, + &BufferSize, + &PrivateData->Configuration + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Convert to buffer data by helper function ConfigToBlock(= ) + // + BufferSize =3D sizeof (ACPI_CONFIG_VARSTORE_DATA); + Status =3D HiiConfigRouting->ConfigToBlock ( + HiiConfigRouting, + Configuration, + (UINT8 *)&PrivateData->Configuration, + &BufferSize, + Progress + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Store Buffer Storage back to EFI variable + // + Status =3D gRT->SetVariable ( + AcpiVarstoreDataName, + &gAcpiConfigFormSetGuid, + ACPI_VARSTORE_ATTRIBUTES, + sizeof (ACPI_CONFIG_VARSTORE_DATA), + &PrivateData->Configuration + ); + + return Status; +} + +/** + This function processes the results of changes in configuration. + + @param This Points to the EFI_HII_CONFIG_ACCESS_PROTO= COL. + @param Action Specifies the type of action taken by the= browser. + @param QuestionId A unique value which is sent to the origi= nal + exporting driver so that it can identify = the type + of data to expect. + @param Type The type of value for the question. + @param Value A pointer to the data being sent to the o= riginal + exporting driver. + @param ActionRequest On return, points to the action requested= by the + callback function. + + @retval EFI_SUCCESS The callback successfully handled the act= ion. + @retval EFI_INVALID_PARAMETER The setup browser call this function with= invalid parameters. + +**/ +EFI_STATUS +EFIAPI +DriverCallback ( + IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, + IN EFI_BROWSER_ACTION Action, + IN EFI_QUESTION_ID QuestionId, + IN UINT8 Type, + IN EFI_IFR_TYPE_VALUE *Value, + OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest + ) +{ + if (Action !=3D EFI_BROWSER_ACTION_CHANGING) { + // + // Do nothing for other UEFI Action. Only do call back when data is ch= anged. + // + return EFI_UNSUPPORTED; + } + if (((Value =3D=3D NULL) + && (Action !=3D EFI_BROWSER_ACTION_FORM_OPEN) + && (Action !=3D EFI_BROWSER_ACTION_FORM_CLOSE)) + || (ActionRequest =3D=3D NULL)) + { + return EFI_INVALID_PARAMETER; + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +AcpiNVDataUpdate ( + IN ACPI_CONFIG_PRIVATE_DATA *PrivateData + ) +{ + EFI_STATUS Status; + PLATFORM_INFO_HOB *PlatformHob; + UINT32 TurboSupport; + + ASSERT (PrivateData !=3D NULL); + + PlatformHob =3D PrivateData->PlatformHob; + TurboSupport =3D PlatformHob->TurboCapability[0] + PlatformHob->TurboCap= ability[1]; + + if (TurboSupport =3D=3D 0) { + PrivateData->Configuration.AcpiTurboMode =3D 2; // Unsupported mode + PrivateData->Configuration.AcpiTurboSupport =3D 0; + } else { + PrivateData->Configuration.AcpiTurboSupport =3D 1; + } + + Status =3D gRT->SetVariable ( + AcpiVarstoreDataName, + &gAcpiConfigFormSetGuid, + ACPI_VARSTORE_ATTRIBUTES, + sizeof (ACPI_CONFIG_VARSTORE_DATA), + &PrivateData->Configuration + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a %d gRT->SetVariable() failed \n", __FUNCTION_= _, __LINE__)); + return Status; + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +UpdateTurboModeConfig ( + IN ACPI_CONFIG_PRIVATE_DATA *PrivateData + ) +{ + EFI_STATUS Status; + PLATFORM_INFO_HOB *PlatformHob; + BOOLEAN EnableTurbo; + + ASSERT (PrivateData !=3D NULL); + + if (PrivateData->Configuration.AcpiTurboSupport !=3D 0) { + PlatformHob =3D PrivateData->PlatformHob; + EnableTurbo =3D (PrivateData->Configuration.AcpiTurboMode !=3D 0) ? TR= UE : FALSE; + + if (PlatformHob->TurboCapability[0] !=3D 0) { + Status =3D MailboxMsgTurboConfig (0, EnableTurbo); + if (EFI_ERROR (Status)) { + return Status; + } + } + + if (PlatformHob->TurboCapability[1] !=3D 0) { + Status =3D MailboxMsgTurboConfig (1, EnableTurbo); + if (EFI_ERROR (Status)) { + return Status; + } + } + } else { + DEBUG ((DEBUG_INFO, "%a: Turbo mode is unsupported! \n", __FUNCTION__)= ); + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +UpdateCPPCConfig ( + IN ACPI_CONFIG_PRIVATE_DATA *PrivateData + ) +{ + EFI_STATUS Status; + CHAR8 Buffer[64]; + + ASSERT (PrivateData !=3D NULL); + + AsciiSPrint (Buffer, sizeof (Buffer), "\\_SB.CPCE"); + Status =3D AcpiAmlObjectUpdateInteger ( + PrivateData->AcpiSdtProtocol, + PrivateData->AcpiTableHandle, + Buffer, + PrivateData->Configuration.AcpiCppcEnable + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} + +STATIC +EFI_STATUS +UpdateLPIConfig ( + IN ACPI_CONFIG_PRIVATE_DATA *PrivateData + ) +{ + EFI_STATUS Status; + CHAR8 Buffer[64]; + + ASSERT (PrivateData !=3D NULL); + + AsciiSPrint (Buffer, sizeof (Buffer), "\\_SB.LPIE"); + Status =3D AcpiAmlObjectUpdateInteger ( + PrivateData->AcpiSdtProtocol, + PrivateData->AcpiTableHandle, + Buffer, + PrivateData->Configuration.AcpiLpiEnable + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} + +STATIC +VOID +UpdateAcpiOnReadyToBoot ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_ACPI_SDT_PROTOCOL *AcpiSdtProtocol; + EFI_ACPI_DESCRIPTION_HEADER *Table; + EFI_ACPI_HANDLE TableHandle; + UINTN TableKey; + UINTN TableIndex; + + ASSERT (mPrivateData !=3D NULL); + + // + // Find the AcpiTable protocol + // + Status =3D gBS->LocateProtocol ( + &gEfiAcpiSdtProtocolGuid, + NULL, + (VOID **)&AcpiSdtProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Unable to locate ACPI table protocol\n")); + return; + } + + mPrivateData->AcpiSdtProtocol =3D AcpiSdtProtocol; + + TableIndex =3D 0; + Status =3D AcpiLocateTableBySignature ( + AcpiSdtProtocol, + EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATUR= E, + &TableIndex, + &Table, + &TableKey + ); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return; + } + + Status =3D AcpiSdtProtocol->OpenSdt (TableKey, &TableHandle); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return; + } + + mPrivateData->AcpiTableHandle =3D TableHandle; + + Status =3D UpdateCPPCConfig (mPrivateData); + if (EFI_ERROR (Status)) { + return; + } + + Status =3D UpdateLPIConfig (mPrivateData); + if (EFI_ERROR (Status)) { + return; + } + + Status =3D UpdateTurboModeConfig (mPrivateData); + if (EFI_ERROR (Status)) { + return; + } + + // + // Close DSDT Table + // + AcpiSdtProtocol->Close (TableHandle); + AcpiUpdateChecksum ((UINT8 *)Table, Table->Length); +} + +STATIC +EFI_STATUS +AcpiConfigUnload ( + VOID + ) +{ + ASSERT (mPrivateData !=3D NULL); + + if (mDriverHandle !=3D NULL) { + gBS->UninstallMultipleProtocolInterfaces ( + mDriverHandle, + &gEfiDevicePathProtocolGuid, + &mAcpiConfigHiiVendorDevicePath, + &gEfiHiiConfigAccessProtocolGuid, + &mPrivateData->ConfigAccess, + NULL + ); + mDriverHandle =3D NULL; + } + + if (mPrivateData->HiiHandle !=3D NULL) { + HiiRemovePackages (mPrivateData->HiiHandle); + } + + FreePool (mPrivateData); + mPrivateData =3D NULL; + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +AcpiConfigEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HII_HANDLE HiiHandle; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + UINTN BufferSize; + ACPI_CONFIG_VARSTORE_DATA *Configuration; + BOOLEAN ActionFlag; + EFI_STRING ConfigRequestHdr; + EFI_EVENT ReadyToBootEvent; + PLATFORM_INFO_HOB *PlatformHob; + VOID *Hob; + + // + // Initialize the local variables. + // + ConfigRequestHdr =3D NULL; + + // + // Initialize driver private data + // + mPrivateData =3D AllocateZeroPool (sizeof (ACPI_CONFIG_PRIVATE_DATA)); + if (mPrivateData =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + mPrivateData->Signature =3D ACPI_CONFIG_PRIVATE_SIGNATURE; + + mPrivateData->ConfigAccess.ExtractConfig =3D ExtractConfig; + mPrivateData->ConfigAccess.RouteConfig =3D RouteConfig; + mPrivateData->ConfigAccess.Callback =3D DriverCallback; + + // + // Get the Platform HOB + // + Hob =3D GetFirstGuidHob (&gPlatformInfoHobGuid); + ASSERT (Hob !=3D NULL); + if (Hob =3D=3D NULL) { + AcpiConfigUnload (); + return EFI_DEVICE_ERROR; + } + PlatformHob =3D (PLATFORM_INFO_HOB *)GET_GUID_HOB_DATA (Hob); + + mPrivateData->PlatformHob =3D PlatformHob; + + // + // Locate ConfigRouting protocol + // + Status =3D gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL,= (VOID **)&HiiConfigRouting); + if (EFI_ERROR (Status)) { + return Status; + } + mPrivateData->HiiConfigRouting =3D HiiConfigRouting; + + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &mDriverHandle, + &gEfiDevicePathProtocolGuid, + &mAcpiConfigHiiVendorDevicePath, + &gEfiHiiConfigAccessProtocolGuid, + &mPrivateData->ConfigAccess, + NULL + ); + ASSERT_EFI_ERROR (Status); + + mPrivateData->DriverHandle =3D mDriverHandle; + + // + // Publish our HII data + // + HiiHandle =3D HiiAddPackages ( + &gAcpiConfigFormSetGuid, + mDriverHandle, + AcpiConfigDxeStrings, + AcpiConfigVfrBin, + NULL + ); + if (HiiHandle =3D=3D NULL) { + gBS->UninstallMultipleProtocolInterfaces ( + mDriverHandle, + &gEfiDevicePathProtocolGuid, + &mAcpiConfigHiiVendorDevicePath, + &gEfiHiiConfigAccessProtocolGuid, + &mPrivateData->ConfigAccess, + NULL + ); + return EFI_OUT_OF_RESOURCES; + } + + mPrivateData->HiiHandle =3D HiiHandle; + + // + // Initialize configuration data + // + Configuration =3D &mPrivateData->Configuration; + ZeroMem (Configuration, sizeof (ACPI_CONFIG_VARSTORE_DATA)); + + // + // Try to read NV config EFI variable first + // + ConfigRequestHdr =3D HiiConstructConfigHdr (&gAcpiConfigFormSetGuid, Acp= iVarstoreDataName, mDriverHandle); + ASSERT (ConfigRequestHdr !=3D NULL); + + BufferSize =3D sizeof (ACPI_CONFIG_VARSTORE_DATA); + Status =3D gRT->GetVariable (AcpiVarstoreDataName, &gAcpiConfigFormSetGu= id, NULL, &BufferSize, Configuration); + if (EFI_ERROR (Status)) { + // + // Store zero data Buffer Storage to EFI variable + // + Status =3D gRT->SetVariable ( + AcpiVarstoreDataName, + &gAcpiConfigFormSetGuid, + ACPI_VARSTORE_ATTRIBUTES, + sizeof (ACPI_CONFIG_VARSTORE_DATA), + Configuration + ); + if (EFI_ERROR (Status)) { + AcpiConfigUnload (); + return Status; + } + // + // EFI variable for NV config doesn't exit, we should build this varia= ble + // based on default values stored in IFR + // + ActionFlag =3D HiiSetToDefaults (ConfigRequestHdr, EFI_HII_DEFAULT_CLA= SS_STANDARD); + if (!ActionFlag) { + AcpiConfigUnload (); + return EFI_INVALID_PARAMETER; + } + } else { + // + // EFI variable does exist and Validate Current Setting + // + ActionFlag =3D HiiValidateSettings (ConfigRequestHdr); + if (!ActionFlag) { + AcpiConfigUnload (); + return EFI_INVALID_PARAMETER; + } + } + FreePool (ConfigRequestHdr); + + Status =3D gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + UpdateAcpiOnReadyToBoot, + NULL, + &gEfiEventReadyToBootGuid, + &ReadyToBootEvent + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Fail to create ready to boot event %r!\n", Statu= s)); + return Status; + } + + Status =3D AcpiNVDataUpdate (mPrivateData); + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfig= Strings.uni b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfi= gStrings.uni new file mode 100644 index 000000000000..21a6188518fd --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigStrings= .uni @@ -0,0 +1,27 @@ +// +// Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// + +#langdef en-US "English" + +#string STR_ACPI_FORM #language en-US "ACPI= Configuration" +#string STR_ACPI_FORM_HELP #language en-US "ACPI= Configuration" + +#string STR_ACPI_FORM_SEPERATE_LINE #language en-US "" +#string STR_ACPI_COMMON_ENABLE #language en-US "Enab= led" +#string STR_ACPI_COMMON_DISABLE #language en-US "Disa= bled" +#string STR_ACPI_UNSUPPORTED #language en-US "Unsu= pported" + +#string STR_ACPI_APEI_SUPPORT_PROMPT #language en-US "APEI= Support" +#string STR_ACPI_APEI_SUPPORT_HELP #language en-US "Enab= le/Disable ACPI Platform Error Interface support" + +#string STR_ACPI_CPPC_PROMPT #language en-US "CPPC= Support" +#string STR_ACPI_CPPC_HELP #language en-US "Enab= les or Disables System ability to CPPC (Collaborative Processor Performance= Control)" + +#string STR_ACPI_LPI_PROMPT #language en-US "LPI = Support" +#string STR_ACPI_LPI_HELP #language en-US "Enab= les or Disables System ability to LPI (Lower Power Idle)" + +#string STR_ACPI_TURBO_PROMPT #language en-US "Max = Performance" +#string STR_ACPI_TURBO_HELP #language en-US "Enab= les or Disables System ability to Max Performance" --=20 2.17.1