From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.117]) by mx.groups.io with SMTP id smtpd.web11.5406.1622023952029971074 for ; Wed, 26 May 2021 03:12:32 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@os.amperecomputing.com header.s=selector2 header.b=sRkNwWpR; spf=pass (domain: os.amperecomputing.com, ip: 40.107.94.117, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kSisGVZx78w8GrjcwaP+xoP+vRcT+ol15zNhqGS1sn5VhEVx7gYgb3y7xg3nM+eyBs+6hEPp3foqxMDfdmrWHbGzFCmEkpyHMmBjDTI08+zGGf7xNhiHDCPccgiNiZA7UL1k+OO+aYaMyr3mtWuBl0k4LFEUEGfRpch2awp2OtI3b4WFglPtSmCFRQ2rSNS09skTP1T3uedjdhbTStI3lgiaL7np//PAHNiiiU7dOUe2gB7bqyHdJFGL+ueM2byVw95Z5cGnTSdLx7w+s4zayIn0kGbtr1vq3Pbg3Fil54vmdV4CHyzuH5Zw6qOOM2X4fbqC3utLjbHRRD05bfPe9A== 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-SenderADCheck; bh=gGgH4qOwju9230fQ1J00x67HZo3r7c9pCTSr0YGK6Eo=; b=SaePLOWKl3lvADrER0JzyINgzBFcXoaN4+AOm/3/1JCkqwZLzlvlRUNoEaZyokU7ZTxaenF9mh/V602Y2EWTPB5fDBlgtZfy8TnJfWyLAZFU89sn0hdiOpS9Ws7lhTU1yVdq7MOW0GG12125ch7KdamcLNjgdnSoq3LA/ZzroNIc/FjqhM/SC6/cqUV1fC8Z0TtibnNbR4BxsFBQOAJc0X89rjeVQ5nxSPNVptsXuBEtM88Hft7oVvwG8cqVauVgB1NQ89jWVzjNx7vSNChd9dJ7AJIa94NftpR+DA52+QRX+Wv8HPBOI9pMRMb2hZ14mOOT/lCZPbIOAMufJhutfQ== 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=gGgH4qOwju9230fQ1J00x67HZo3r7c9pCTSr0YGK6Eo=; b=sRkNwWpRCUUnxCXmcEH4W9uvIEZNuyUzqewRNHe3jYM90BIrz9BzSS+eFC5Gfbcg4CZio72EJiUcQ2j8ISF9DBtsojeir5tc6WpO6YIDxvzEZG1SikAd4hNA6Mf+PaJDZYGXTibSduEdFzI5rbgsohxkogPr1ORcI0hhVNN0+ro= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) by DM5PR01MB2426.prod.exchangelabs.com (2603:10b6:3:3b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.27; Wed, 26 May 2021 10:12:30 +0000 Received: from DM6PR01MB5849.prod.exchangelabs.com ([fe80::60d2:86dd:1f1c:51dd]) by DM6PR01MB5849.prod.exchangelabs.com ([fe80::60d2:86dd:1f1c:51dd%7]) with mapi id 15.20.4173.020; Wed, 26 May 2021 10:12:30 +0000 From: "Nhi Pham" To: devel@edk2.groups.io CC: Nhi Pham , Thang Nguyen , Chuong Tran , Phong Vo , Leif Lindholm , Michael D Kinney , Ard Biesheuvel , Nate DeSimone Subject: [edk2-platforms][PATCH v2 25/32] AmpereAltraPkg: Add configuration screen for ACPI Date: Wed, 26 May 2021 17:07:17 +0700 Message-ID: <20210526100724.5359-27-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210526100724.5359-1-nhi@os.amperecomputing.com> References: <20210526100724.5359-1-nhi@os.amperecomputing.com> X-Originating-IP: [118.69.219.201] X-ClientProxiedBy: HKAPR04CA0008.apcprd04.prod.outlook.com (2603:1096:203:d0::18) To DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (118.69.219.201) by HKAPR04CA0008.apcprd04.prod.outlook.com (2603:1096:203:d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Wed, 26 May 2021 10:12:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e67c6bb8-0e83-4a27-e2c6-08d9202ec540 X-MS-TrafficTypeDiagnostic: DM5PR01MB2426: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:207; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SLnOkpiqSX2pj5IcyOjzujWkTrb+xEZL1TYFRKJTPk0o+Y3S9tEUMry5mELXL8owmI1gm7s2PnsgxGPmIk9IE94F8sOapqwTtjO3YAN8F6Fn8mNqqjf2sfVOeBd9kfJbIXRyqqpX1APc975xtyGvMrvi65YtySWowxd8cJC6Rv5dk7oKgN9/t4bESRpswALTpNyN2aaXkebUx1wfXyQfAUCXplnoab8+L0TYIKWSRnANFoEqbRpen9KOgFr+6DCVS4DemhPd33rwgI/5dtzoGNlZS8cZlPUp70/jJMRgixhx8IGwHw9rMQOqJ8uM7OTcURs3NXHhj1/6FsxM6nrt7KN+BmQyxPzw7irGRKQ9DrYEXRmjg1uCEFzSGvLj0BUGJQr59tySRX+2+/37GH5oYOXKuI0yj7spdZipNMO9p7FV4kxDCdAkuVKhFyQbRdUmMSoFEnO6oEx1wmKx1XbXvyvE2NWsQsYwtDXeLsYLLo6Ex8IEb/z16cmY9M8xH5y/6e0vNNTIwlKx6ex2+m0UJBTz1Xd0rpoI6EFdMBVTt5K0FSwsgF9cir5mrlMCSFn6q771GG4eA2fhX/19GEtT0bNgaYapJijD6gn0/hSFHtaMTsFZALuPF+IzV6900kICUeXIdF1C311Qluh1PxnSH4qyLkvogpsPkxPZPhBlm5rhC3JdTlgEmNwabYY01Ubl/TItwM5751nn51IjKb0B0hLtWo5xDquPvxAwzr3eXd5v8i5ksVCUBbyayXs8UdHD X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR01MB5849.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(39850400004)(136003)(346002)(366004)(376002)(186003)(66476007)(6506007)(2616005)(6486002)(66946007)(52116002)(6916009)(16526019)(66574015)(19627235002)(38100700002)(38350700002)(1076003)(83380400001)(30864003)(66556008)(6512007)(956004)(316002)(478600001)(6666004)(4326008)(8676002)(5660300002)(26005)(86362001)(2906002)(8936002)(54906003)(69590400013)(290074003)(579004)(44824005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?Y/fzMBEWRyDpXm32IYktofyVf3QZ/zXN8lOAqHmN/pMS32T713g+hzdmreBO?= =?us-ascii?Q?/+wcY7wIDPcA53cvgAHyizQkdTi9CCMcFxdb9BKV5+p2QPFgLDXTVwQ4Lm04?= =?us-ascii?Q?FVFLobR62e6M/rDT9M+jca8YRBQdlQrTlRoeh9tNcD+gqMdU8Wu3u7ed8kWA?= =?us-ascii?Q?XNsEAWiID081EQq6D2vXv0QLtEuw9q7zfG1IVWgBjZnol+ZdnMlzPG1/Gc7L?= =?us-ascii?Q?thN088y1ddYmYB0YwjpDl8MHRU+hiTrT9jYwOmhfqy5OER/MzGWgb0VZeMPx?= =?us-ascii?Q?lzO80se0de8vbFheIZ3gcbUz/Dq5e/WKgNH7tev+vjsb3uMa2a2ajvVrlLMk?= =?us-ascii?Q?nxfy4mnd3hyrkZR+qsgvVjBjirs/fZkOfvOX5T4EMeQsm5yqgMCnNXqNK+A5?= =?us-ascii?Q?yEImAudH6kzpPtsAH6Rdch+en9W1RMw0U8vP5vTDd3+2zP6hPWcNjesNwvwX?= =?us-ascii?Q?xeWozWptmwiJOS5XS1yOFn7OY8Zx3cnBxUT5u7lSwO7a3ux8JE0UTkmoyWW7?= =?us-ascii?Q?TsUvyfO7pEZ4OVBh7LLmwHKvOivB+uqY8tM838JmOoBY6RS0Wa+H7Uq4VoHj?= =?us-ascii?Q?x4yoKP8F+N2uQut+DtSp+BqOtuuL7t63k59t2lcoa64+WQ8PqrcAhfN1MmH8?= =?us-ascii?Q?H+DdNDLNshY2h0sUJayVoaxaQkTMrE1FTTMrRQkWwGQ8HbxTRtxmqeeP3l1q?= =?us-ascii?Q?wpQv3C4t6qcm3etScyATbelvJmjz8XQ6BXlFZA82vDqeulu2T7KYOuj2HUzi?= =?us-ascii?Q?VgZNYSbplx8VzUzwP8DtWHy7c8CgJkEmZBtZ6G7kxQAqoYw0BnvmSnkSQHG3?= =?us-ascii?Q?XNzBspRMakTjnOWO/DxhxMrF/4tKITqQvsliLtX0y00MHzjhHGfa35iX4wOx?= =?us-ascii?Q?CTzonK0lx+PabFXet8o/7G6Uku2mBFs4Wp4rP5SMoITpqoybpbm/ADaBp/fp?= =?us-ascii?Q?k+CIYBP24hyd2naMGoFeTW3y7T4KcZTpjEvq8Q3PSwXnC54ftpa6k+LKqrjg?= =?us-ascii?Q?+ewy6LSpW9XpwfIMcrpZMvKdxxLLFWkDn36Zij6fO+UxhDSuJWk6n/dCUb/Y?= =?us-ascii?Q?kz9omDRg7fmi7lmxzNDziMIxznypfCXi43arvt1g0+hD4UJUPZ+RWWGv/9XW?= =?us-ascii?Q?T/snq4F6e6WzcsHuwSjm0x+hIBJIWiU/g/muMMUSwLuxFG+J/4LyqltMH5zs?= =?us-ascii?Q?nmxsJHNEC5GPF4kMtAyfpngxZJzdIDMn1+wSX0N0zGTbyjaqUlpaUtDCq64U?= =?us-ascii?Q?mFpWEugO17QvpH5dSak8fuY7vhKWis+W9LTB8aCr7CBGYx9rF5L2cW8zU3u5?= =?us-ascii?Q?9KojxsPKc4/lLrjlR2RpxppJ?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: e67c6bb8-0e83-4a27-e2c6-08d9202ec540 X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5849.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2021 10:12:30.2712 (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: TexijJxMH4QGwPfMWPIuwJ8ZbouHkdhfsl92z7VDhyMA4GcZPwP2ZXOoImkIclwa5n4nZzz95vSseWMaL3LavOMCvnqYwr5jWF9SvEPgCxo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR01MB2426 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 --- 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 | 5= 6 ++ Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.h | = 2 + Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.h | 8= 5 +++ Silicon/Ampere/AmpereAltraPkg/Include/AcpiNVDataStruc.h | 2= 8 + Silicon/Ampere/AmpereAltraPkg/Include/Guid/AcpiConfigFormSet.h | 1= 9 + Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/Vfr.vfr | 6= 9 ++ Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.c | 2= 3 +- Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.c | 73= 3 ++++++++++++++++++++ Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/VfrStrings.uni | 2= 7 + 13 files changed, 1046 insertions(+), 2 deletions(-) diff --git a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec b/Silicon/Amp= ere/AmpereAltraPkg/AmpereAltraPkg.dec index 05b4e8576836..ede85d3a3421 100644 --- a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec +++ b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec @@ -53,6 +53,9 @@ [Guids] # GUID for the CPU HII configuration form gCpuConfigFormSetGuid =3D { 0x43FAA144, 0xA2DF, 0x4050, { 0xA7, 0= xFD, 0xEE, 0x17, 0xC9, 0xB8, 0x88, 0x8E } } =20 + # GUID for the ACPI HII configuration form + gAcpiConfigFormSetGuid =3D { 0x0ceb6764, 0xd415, 0x4b01, { 0xa8, 0x43, 0= xd1, 0x01, 0xbc, 0xb0, 0xd8, 0x29 } } + ## NVParam MM GUID gNVParamMmGuid =3D { 0xE4AC5024, 0x29BE, 0x4ADC, { 0x93, 0= x36, 0x87, 0xB5, 0xA0, 0x76, 0x23, 0x2D } } =20 diff --git a/Platform/Ampere/JadePkg/Jade.dsc b/Platform/Ampere/JadePkg/Jad= e.dsc index 547fbb68b4e3..e82b0cce691a 100755 --- a/Platform/Ampere/JadePkg/Jade.dsc +++ b/Platform/Ampere/JadePkg/Jade.dsc @@ -181,3 +181,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 b8342fde9d72..ddd601075f19 100755 --- a/Platform/Ampere/JadePkg/Jade.fdf +++ b/Platform/Ampere/JadePkg/Jade.fdf @@ -356,5 +356,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 Platform/Ampere/AmperePlatformPkg/FvRules.fdf.inc diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDx= e.inf b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf index a1a323eee472..287b4eadbf4a 100644 --- a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf +++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf @@ -64,6 +64,7 @@ [Guids] gArmMpCoreInfoGuid gEfiAcpiTableGuid gEfiEventReadyToBootGuid + gAcpiConfigFormSetGuid gPlatformHobGuid =20 [Protocols] 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..bc2fbebc84d1 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.inf @@ -0,0 +1,56 @@ +## @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 + Vfr.vfr + VfrStrings.uni + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec + Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec + +[LibraryClasses] + AcpiHelperLib + BaseLib + BaseMemoryLib + DebugLib + DevicePathLib + HiiLib + HobLib + MemoryAllocationLib + SystemFirmwareInterfaceLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + +[Guids] + gPlatformManagerFormsetGuid + gAcpiConfigFormSetGuid + gEfiEventReadyToBootGuid + gPlatformHobGuid + +[Protocols] + 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 c207142459ad..5a0ce9dcc69a 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..45cb08e01f7b --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.h @@ -0,0 +1,85 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef DRIVER_SAMPLE_H_ +#define DRIVER_SAMPLE_H_ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// +// This is the generated IFR binary data for each formset defined in VFR. +// +extern UINT8 VfrBin[]; + +// +// This is the generated String package data for all .UNI files. +// +extern UINT8 AcpiConfigDxeStrings[]; + +#define ACPI_CONFIG_PRIVATE_SIGNATURE SIGNATURE_32 ('A', 'C', 'P', 'I') + +typedef struct { + UINTN Signature; + + EFI_HANDLE DriverHandle; + EFI_HII_HANDLE HiiHandle; + ACPI_CONFIG_VARSTORE_DATA Configuration; + PLATFORM_INFO_HOB *PlatformHob; + EFI_ACPI_SDT_PROTOCOL *AcpiTableProtocol; + 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/AcpiNVDataStruc.h b/Sili= con/Ampere/AmpereAltraPkg/Include/AcpiNVDataStruc.h new file mode 100644 index 000000000000..17f80113797d --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Include/AcpiNVDataStruc.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_NV_DATA_STRUC_H_ +#define ACPI_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_NV_DATA_STRUC_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Include/Guid/AcpiConfigFormSet.h= b/Silicon/Ampere/AmpereAltraPkg/Include/Guid/AcpiConfigFormSet.h new file mode 100644 index 000000000000..1779a4543769 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Include/Guid/AcpiConfigFormSet.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/Vfr.vfr b/= Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/Vfr.vfr new file mode 100644 index 000000000000..6cbd896987b5 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/Vfr.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 fa188c7776db..3ec63250a5de 100644 --- a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.c +++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.c @@ -445,8 +445,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..ea9004ef2e3c --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.c @@ -0,0 +1,733 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#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; + EFI_ACPI_HANDLE ChildHandle; + CHAR8 Buffer[64]; + EFI_ACPI_DATA_TYPE DataType; + UINTN DataSize; + UINT8 *Data; + EFI_ACPI_SDT_PROTOCOL *AcpiTableProtocol; + + ASSERT (PrivateData !=3D NULL); + + AcpiTableProtocol =3D PrivateData->AcpiTableProtocol; + + AsciiSPrint (Buffer, sizeof (Buffer), "\\_SB.CPCE"); + Status =3D AcpiTableProtocol->FindPath ( + PrivateData->AcpiTableHandle, + (VOID *)Buffer, + &ChildHandle + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to find path CPCE\n")); + AcpiTableProtocol->Close (PrivateData->AcpiTableHandle); + return Status; + } + + Status =3D AcpiTableProtocol->GetOption ( + ChildHandle, + 2, + &DataType, + (VOID *)&Data, + &DataSize + ); + if (EFI_ERROR (Status)) { + return Status; + } + Data[0] =3D PrivateData->Configuration.AcpiCppcEnable; + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +UpdateLPIConfig ( + IN ACPI_CONFIG_PRIVATE_DATA *PrivateData + ) +{ + EFI_STATUS Status; + EFI_ACPI_HANDLE ChildHandle; + CHAR8 Buffer[64]; + EFI_ACPI_DATA_TYPE DataType; + UINTN DataSize; + UINT8 *Data; + EFI_ACPI_SDT_PROTOCOL *AcpiTableProtocol; + + ASSERT (PrivateData !=3D NULL); + + AcpiTableProtocol =3D PrivateData->AcpiTableProtocol; + + AsciiSPrint (Buffer, sizeof (Buffer), "\\_SB.LPIE"); + Status =3D AcpiTableProtocol->FindPath ( + PrivateData->AcpiTableHandle, + (VOID *)Buffer, + &ChildHandle + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Fail to find path LPIE\n")); + AcpiTableProtocol->Close (PrivateData->AcpiTableHandle); + return Status; + } + + Status =3D AcpiTableProtocol->GetOption ( + ChildHandle, + 2, + &DataType, + (VOID *)&Data, + &DataSize + ); + if (EFI_ERROR (Status)) { + return Status; + } + Data[0] =3D PrivateData->Configuration.AcpiLpiEnable; + + return EFI_SUCCESS; +} + +STATIC +VOID +UpdateAcpiOnReadyToBoot ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_ACPI_SDT_PROTOCOL *AcpiTableProtocol; + EFI_ACPI_HANDLE TableHandle; + + ASSERT (mPrivateData !=3D NULL); + + // + // Find the AcpiTable protocol + // + Status =3D gBS->LocateProtocol ( + &gEfiAcpiSdtProtocolGuid, + NULL, + (VOID **)&AcpiTableProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Unable to locate ACPI table protocol\n")); + return; + } + + mPrivateData->AcpiTableProtocol =3D AcpiTableProtocol; + + Status =3D AcpiOpenDSDT (AcpiTableProtocol, &TableHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Unable to locate DSDT table protocol\n")); + 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 + // + AcpiTableProtocol->Close (TableHandle); + + AcpiDSDTUpdateChecksum (AcpiTableProtocol); +} + +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 (&gPlatformHobGuid); + 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, + VfrBin, + 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/VfrStrings= .uni b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/VfrStrings.uni new file mode 100644 index 000000000000..21a6188518fd --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/VfrStrings.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