From nobody Fri Dec 19 22:04:35 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93829+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663247488029110.2218452982886; Thu, 15 Sep 2022 06:11:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id BRZFYY1788612xdMDG73PWhx; Thu, 15 Sep 2022 06:11:27 -0700 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.51]) by mx.groups.io with SMTP id smtpd.web08.9917.1663247486935227083 for ; Thu, 15 Sep 2022 06:11:27 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Iv/MhmLHbPQ+4cwFtP2DcbxtfhZD8Q5lKWvnZu5h1Ca9kjHpYQbv2FxWzA1osb1AzwymmM5e1L41Ue5RTyVepLpGRiXLMr0qkm99trvxLNUnWzN4g3gL88mejUNAVZcylpt53e0GyAs8Y16LHa8r0tmASYAc/bIREXyQtubyLSbKu6esPJUTY+VmQTpUglc5ctZtdTL4nmAS8Uav2qOwodxwgcmd78v2aRPj5YK7tcH52aEGymqISPeFcyIMKEot/QJo2cVxaGxWVpJzhx3cHH6JpqiiJOBSVPKBFRPskBRbgnHc33HHVeo77sGoYxRQARZxJ8HRfaxBTtD+1Wqgvw== 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=iY6ZS2Rai0svUmUYq2JKTZoWQ+vi1mM7DOqTbxnX/vI=; b=D05NpieLHAvP+Z4Bq5pmbrMDlNDcR3GJ/iwTaTb39NRwibDjRzS25whHTukKhksTYlqCQoqOkO3za3FZQMniLCHWqyEMo2OhDMNDc7jBtZNpfKOA7c5Yqm9NluB4BKe64okjK7Ztymu3MYMfR2bVKwlezKUbfvv4JQ7AbUtDH1JJ9bgSTAJlFMiF5xF80ASS/7Rlm0ZTBKyi+FuuWHftu2xKz/IKk+f4fUcmp+h+2qS3UrchS9xJn+vvow1mIE/dXU4X5RMWHB5//6tq+q3Uw/YrVdtQfJH0HrTcomd0IP1eHfj5g3CWMOx/1S+yCbU0npY9fCLLx5NHH2okkBadAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from MW4PR04CA0040.namprd04.prod.outlook.com (2603:10b6:303:6a::15) by CH3PR12MB7667.namprd12.prod.outlook.com (2603:10b6:610:14f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.22; Thu, 15 Sep 2022 13:11:23 +0000 X-Received: from CO1NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6a:cafe::33) by MW4PR04CA0040.outlook.office365.com (2603:10b6:303:6a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.19 via Frontend Transport; Thu, 15 Sep 2022 13:11:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93829+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT038.mail.protection.outlook.com (10.13.174.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12 via Frontend Transport; Thu, 15 Sep 2022 13:11:22 +0000 X-Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 15 Sep 2022 06:10:56 -0700 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 15 Sep 2022 06:10:56 -0700 X-Received: from f153882e4be8.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Thu, 15 Sep 2022 06:10:55 -0700 From: "Jeff Brasen via groups.io" To: CC: , , , , Jeff Brasen Subject: [edk2-devel] [PATCH v3 2/3] DynamicTablesPkg: AML Code generation to add _CPC entries Date: Thu, 15 Sep 2022 07:10:51 -0600 Message-ID: <2bc2acdd897dae6fab193cc4a92595e41be586ca.1663247185.git.jbrasen@nvidia.com> In-Reply-To: References: MIME-Version: 1.0 X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT038:EE_|CH3PR12MB7667:EE_ X-MS-Office365-Filtering-Correlation-Id: 4783b436-04f1-459f-0feb-08da971bc9a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: tABhjCPNVkq8dl3i+wgnXtH+cj4tRQ+SuCyC0zhpFkoK0aMtwwtIjBaZQuHP+Uar2yocp/xGV9ZRMkg/dwkTE/3PHnyOs0slkAWT8ZVLAUWsg9z2Q1PCTc+UpeVqb0PxBvkhNqIPb9lOxbqJKBLvbOOo/94NgyuE39HKMBEh7Rkc4bhUsQQ2QqMKZ2ZYbzafxFKNSJw8jbctEylSiF7rjr/fYhZsPBoD2SH5cBAMoW1a5j2NBy5yyKbrygPKLeFKqoV5K78Jg9m541hdRF0jwPMK/0m9JBJvjCVZqOEV/IqGT+AQIqPc7Bga1PeCF2Stqynkzc0UUuy6SSwt1g5awGNjl5HhVfL/ihsnz0AE+NdUTKzcSghsYX02O9RsKq8aWvLXVjgMkMwrsWWabfJWjTna27XyLlnQTuHzmRwlECLChLUMDKHM5Mssk2I03OVgT39X33HAKOrb9NpTDdv4ptTzcKfzv0pfGh5F5SDXkvEYWfsdOWsSghG6Ejh3+IXkC0zRUDuoMNc3pMpqajAyxebMb2/7n1TCO7f49FhiZ2DtptvjuzBy1yzdfoSTvMUEMdrmwICZVxJYyAkcAI5tuXc0sQimhDfn5iue1xXS3U/1KzaAtKwwss+PdQ3nqC8OHo+v8fyx0+2lZg2beQSuSJqdgw1mC+WB20zdXRxkQoLNAJK7d3S3Qqj4F1hhFTXHcwRkqGwSr4ZBCnESGi+qU908j/eJR+0mVuPlmOVc9Epsvv+gcsW/yyeQI6lURAPhUM7fLeHnrc9Ec55/xP3r9g== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2022 13:11:22.7602 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4783b436-04f1-459f-0feb-08da971bc9a3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7667 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jbrasen@nvidia.com X-Gm-Message-State: iEjr6gYqiniyfK7ZlPcaQKThx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663247487; bh=c/cml1C4lOtYvwHa6cYK43RNg7oJENtNY/PORfBvxoo=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=WiTlkp6wnHnmrIXZGCaxbQUQawEWWaE/MCd6lCMkDikDSUzwcTBfgwG9G8BIApCmKhw Hf1Al7cdnuXw8otyugp9Jrdrqm/0O5z9fozJmju3SuSXiTZUY1liiZ1jcPF6dyEpVWDr7 QK+CpA1/oIsJF4911lv/cRkTEr57S2WiL8c= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663247490023100003 Content-Type: text/plain; charset="utf-8" _CPC entries can describe CPU performance information. The object is described in ACPI 6.4 s8.4.7.1. "_CPC (Continuous Performance Control)". Add AmlCreateCpcNode() helper function to add _CPC entries to an existing CPU object. Signed-off-by: Jeff Brasen --- .../Include/Library/AmlLib/AmlLib.h | 156 +++++ .../Common/AmlLib/CodeGen/AmlCodeGen.c | 543 ++++++++++++++++++ 2 files changed, 699 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h index 39968660f2..3fafa6b0e8 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -1336,6 +1336,162 @@ AmlAddNameIntegerPackage ( IN AML_OBJECT_NODE_HANDLE PackageNode ); =20 +/** Create a _CPC node. + + Creates and optionally adds the following node + Name(_CPC, Package() + { + NumEntries, // Integer + Revision, // Integer + HighestPerformance, // Integer or Buffer (Resourc= e Descriptor) + NominalPerformance, // Integer or Buffer (Resourc= e Descriptor) + LowestNonlinearPerformance, // Integer or Buffer (Resourc= e Descriptor) + LowestPerformance, // Integer or Buffer (Resourc= e Descriptor) + GuaranteedPerformanceRegister, // Buffer (Resource Descripto= r) + DesiredPerformanceRegister , // Buffer (Resource Descripto= r) + MinimumPerformanceRegister , // Buffer (Resource Descripto= r) + MaximumPerformanceRegister , // Buffer (Resource Descripto= r) + PerformanceReductionToleranceRegister, // Buffer (Resource Descripto= r) + TimeWindowRegister, // Buffer (Resource Descripto= r) + CounterWraparoundTime, // Integer or Buffer (Resourc= e Descriptor) + ReferencePerformanceCounterRegister, // Buffer (Resource Descripto= r) + DeliveredPerformanceCounterRegister, // Buffer (Resource Descripto= r) + PerformanceLimitedRegister, // Buffer (Resource Descripto= r) + CPPCEnableRegister // Buffer (Resource Descripto= r) + AutonomousSelectionEnable, // Integer or Buffer (Resourc= e Descriptor) + AutonomousActivityWindowRegister, // Buffer (Resource Descripto= r) + EnergyPerformancePreferenceRegister, // Buffer (Resource Descripto= r) + ReferencePerformance // Integer or Buffer (Resourc= e Descriptor) + LowestFrequency, // Integer or Buffer (Resourc= e Descriptor) + NominalFrequency // Integer or Buffer (Resourc= e Descriptor) + }) + + If resource buffer is NULL then integer will be used. + + Cf. ACPI 6.4, s8.4.7.1 _CPC (Continuous Performance Control) + + @ingroup CodeGenApis + + @param [in] HighestPerformanceBuffer If provided, buffer = that indicates the highest level + of performance the p= rocessor. + @param [in] HighestPerformanceInteger Indicates the highes= t level of performance the processor, + used if buffer is NU= LL. + @param [in] NominalPerformanceBuffer If provided buffer t= hat indicates the highest sustained + performance level of= the processor. + @param [in] NominalPerformanceInteger Indicates the highes= t sustained performance level + of the processor, us= ed if buffer is NULL. + @param [in] LowestNonlinearPerformanceBuffer If provided, buffer = that indicates the lowest performance level + of the processor wit= h non-linear power savings. + @param [in] LowestNonlinearPerformanceInteger Indicates the lowest= performance level of the processor with + non-linear power sav= ings, used if buffer is NULL. + @param [in] LowestPerformanceBuffer If provided, buffer = that indicates the + lowest performance l= evel of the processor. + @param [in] LowestPerformanceInteger Indicates the lowest= performance level of the processor, + used if buffer is NU= LL. + @param [in] GuaranteedPerformanceRegister If provided, Guarant= eed Performance Register Buffer. + @param [in] DesiredPerformanceRegister If provided, Desired= Performance Register Buffer. + @param [in] MinimumPerformanceRegister If provided, Minimum= Performance Register Buffer. + @param [in] MaximumPerformanceRegister If provided, Maximum= Performance Register Buffer. + @param [in] PerformanceReductionToleranceRegister If provided, Perform= ance Reduction Tolerance Register. + @param [in] TimeWindowRegister If provided, Time Wi= ndow Register. + @param [in] CounterWraparoundTimeBuffer If provided, Counter= Wraparound Time buffer. + @param [in] CounterWraparoundTimeInteger Counter Wraparound T= ime, used if buffer is NULL. + @param [in] ReferencePerformanceCounterRegister Reference Performanc= e Counter Register. + @param [in] DeliveredPerformanceCounterRegister Delivered Performanc= e Counter Register. + @param [in] PerformanceLimitedRegister Performance Limited = Register. + @param [in] CPPCEnableRegister If provided, CPPC En= ableRegister. + @param [in] AutonomousSelectionEnableBuffer If provided, Autonom= ous Selection Enable buffer. + @param [in] AutonomousSelectionEnableInteger Autonomous Selection= Enable, used if buffer is NULL. + @param [in] AutonomousActivityWindowRegister If provided, Autonom= ousActivity-WindowRegister. + @param [in] EnergyPerformancePreferenceRegister If provided, EnergyP= erformance-PreferenceRegister. + @param [in] ReferencePerformanceBuffer If provided, Referen= ce Performance buffer. + @param [in] ReferencePerformanceInteger Reference Performanc= e, used if buffer is NULL. + @param [in] LowestFrequencyBuffer If provided, Lowest = Frequency buffer. + @param [in] LowestFrequencyInteger Lowest Frequency, us= ed if buffer is NULL. + @param [in] NominalFrequencyBuffer If provided, Nominal= FrequencyBuffer buffer. + @param [in] NominalFrequencyInteger NominalFrequencyBuff= er, used if buffer is NULL. + @param [in] ParentNode If provided, set Par= entNode as the parent + of the node created. + @param [out] NewCpcNode If success and provi= ded, contains the created node. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCreateCpcNode ( + /// The revision number of the _CPC package format. + IN UINT32 Revision, + /// Indicates the highest level of performance the processor + /// is theoretically capable of achieving. + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *HighestPerformanceBuffer OP= TIONAL, + IN UINT32 HighestPerformanceInteger, + /// Indicates the highest sustained performance level of the processor. + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *NominalPerformanceBuffer OP= TIONAL, + IN UINT32 NominalPerformanceInteger, + /// Indicates the lowest performance level of the processor with non-lin= ear power savings. + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *LowestNonlinearPerformanceB= uffer OPTIONAL, + IN UINT32 LowestNonlinearPerformanceIn= teger, + /// Indicates the lowest performance level of the processor.. + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *LowestPerformanceBuffer OPT= IONAL, + IN UINT32 LowestPerformanceInteger, + /// Guaranteed Performance Register Buffer. + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *GuaranteedPerformanceRegist= er OPTIONAL, + /// Desired Performance Register Buffer. + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *DesiredPerformanceRegister, + /// Minimum Performance Register Buffer. + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *MinimumPerformanceRegister = OPTIONAL, + /// Maximum Performance Register Buffer. + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *MaximumPerformanceRegister = OPTIONAL, + /// Performance Reduction Tolerance Register. + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *PerformanceReductionToleran= ceRegister OPTIONAL, + /// Time Window Register. + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *TimeWindowRegister OPTIONAL, + /// Counter Wraparound Time + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *CounterWraparoundTimeBuffer= OPTIONAL, + IN UINT32 CounterWraparoundTimeInteger, + /// Reference Performance Counter Register + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *ReferencePerformanceCounter= Register, + /// Delivered Performance Counter Register + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *DeliveredPerformanceCounter= Register, + /// Performance Limited Register + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *PerformanceLimitedRegister, + /// CPPC EnableRegister + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *CPPCEnableRegister OPTIONAL, + /// Autonomous Selection Enable + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *AutonomousSelectionEnableBu= ffer OPTIONAL, + IN UINT32 AutonomousSelectionEnableInt= eger, + /// AutonomousActivity-WindowRegister + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *AutonomousActivityWindowReg= ister OPTIONAL, + /// EnergyPerformance-PreferenceRegister + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *EnergyPerformancePreference= Register OPTIONAL, + /// Reference Performance + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *ReferencePerformanceBuffer = OPTIONAL, + IN UINT32 ReferencePerformanceInteger, + /// Lowest Frequency + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *LowestFrequencyBuffer OPTIO= NAL, + IN UINT32 LowestFrequencyInteger, + /// Nominal Frequency + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *NominalFrequencyBuffer OPTI= ONAL, + IN UINT32 NominalFrequencyInteger, + IN AML_NODE_HANDLE ParentNode OPTIONAL, + OUT AML_OBJECT_NODE_HANDLE *NewCpcNode OPTIONAL + ); + // DEPRECATED APIS #ifndef DISABLE_NEW_DEPRECATED_INTERFACES =20 diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index 5fb39d077b..42f0d0002c 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -2850,3 +2850,546 @@ error_handler: =20 return Status; } + +/** Adds a register to the package + + @ingroup CodeGenApis + + @param [in] Register If provided, register that will be added to pa= ckage. + otherwise NULL register will be added + @param [in] PackageNode Package to add value to + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +AmlAddRegisterToPackage ( + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Register OPTIONAL, + IN AML_OBJECT_NODE_HANDLE PackageNode + ) +{ + EFI_STATUS Status; + AML_DATA_NODE_HANDLE RdNode; + AML_OBJECT_NODE_HANDLE ResourceTemplateNode; + + RdNode =3D NULL; + + Status =3D AmlCodeGenResourceTemplate (&ResourceTemplateNode); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + + if (Register !=3D NULL) { + Status =3D AmlCodeGenRdRegister ( + Register->AddressSpaceId, + Register->RegisterBitWidth, + Register->RegisterBitOffset, + Register->Address, + Register->AccessSize, + NULL, + &RdNode + ); + } else { + Status =3D AmlCodeGenRdRegister ( + EFI_ACPI_6_4_SYSTEM_MEMORY, + 0, + 0, + 0, + 0, + NULL, + &RdNode + ); + } + + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAppendRdNode (ResourceTemplateNode, RdNode); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + RdNode =3D NULL; + + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)PackageNode, + (AML_NODE_HANDLE)ResourceTemplateNode + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + return Status; + +error_handler: + if (RdNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)RdNode); + } + + if (ResourceTemplateNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)ResourceTemplateNode); + } + + return Status; +} + +/** Adds an integer or register to the package + + @ingroup CodeGenApis + + @param [in] Register If provided, register that will be added to pa= ckage + @param [in] Integer If Register is NULL, integer that will be adde= d to the package + @param [in] PackageNode Package to add value to + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +AmlAddRegisterOrIntegerToPackage ( + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Register OPTIONAL, + IN UINT32 Integer, + IN AML_OBJECT_NODE_HANDLE PackageNode + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE_HANDLE IntegerNode; + + IntegerNode =3D NULL; + + if (Register !=3D NULL) { + Status =3D AmlAddRegisterToPackage (Register, PackageNode); + } else { + Status =3D AmlCodeGenInteger (Integer, &IntegerNode); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)PackageNode, + (AML_NODE_HANDLE)IntegerNode + ); + } + + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + if (IntegerNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)IntegerNode); + } + } + + return Status; +} + +/** Create a _CPC node. + + Creates and optionally adds the following node + Name(_CPC, Package() + { + NumEntries, // Integer + Revision, // Integer + HighestPerformance, // Integer or Buffer (Resourc= e Descriptor) + NominalPerformance, // Integer or Buffer (Resourc= e Descriptor) + LowestNonlinearPerformance, // Integer or Buffer (Resourc= e Descriptor) + LowestPerformance, // Integer or Buffer (Resourc= e Descriptor) + GuaranteedPerformanceRegister, // Buffer (Resource Descripto= r) + DesiredPerformanceRegister , // Buffer (Resource Descripto= r) + MinimumPerformanceRegister , // Buffer (Resource Descripto= r) + MaximumPerformanceRegister , // Buffer (Resource Descripto= r) + PerformanceReductionToleranceRegister, // Buffer (Resource Descripto= r) + TimeWindowRegister, // Buffer (Resource Descripto= r) + CounterWraparoundTime, // Integer or Buffer (Resourc= e Descriptor) + ReferencePerformanceCounterRegister, // Buffer (Resource Descripto= r) + DeliveredPerformanceCounterRegister, // Buffer (Resource Descripto= r) + PerformanceLimitedRegister, // Buffer (Resource Descripto= r) + CPPCEnableRegister // Buffer (Resource Descripto= r) + AutonomousSelectionEnable, // Integer or Buffer (Resourc= e Descriptor) + AutonomousActivityWindowRegister, // Buffer (Resource Descripto= r) + EnergyPerformancePreferenceRegister, // Buffer (Resource Descripto= r) + ReferencePerformance // Integer or Buffer (Resourc= e Descriptor) + LowestFrequency, // Integer or Buffer (Resourc= e Descriptor) + NominalFrequency // Integer or Buffer (Resourc= e Descriptor) + }) + + If resource buffer is NULL then integer will be used. + + Cf. ACPI 6.4, s8.4.7.1 _CPC (Continuous Performance Control) + + @ingroup CodeGenApis + + @param [in] HighestPerformanceBuffer If provided, buffer = that indicates the highest level + of performance the p= rocessor. + @param [in] HighestPerformanceInteger Indicates the highes= t level of performance the processor, + used if buffer is NU= LL. + @param [in] NominalPerformanceBuffer If provided buffer t= hat indicates the highest sustained + performance level of= the processor. + @param [in] NominalPerformanceInteger Indicates the highes= t sustained performance level + of the processor, us= ed if buffer is NULL. + @param [in] LowestNonlinearPerformanceBuffer If provided, buffer = that indicates the lowest performance level + of the processor wit= h non-linear power savings. + @param [in] LowestNonlinearPerformanceInteger Indicates the lowest= performance level of the processor with + non-linear power sav= ings, used if buffer is NULL. + @param [in] LowestPerformanceBuffer If provided, buffer = that indicates the + lowest performance l= evel of the processor. + @param [in] LowestPerformanceInteger Indicates the lowest= performance level of the processor, + used if buffer is NU= LL. + @param [in] GuaranteedPerformanceRegister If provided, Guarant= eed Performance Register Buffer. + @param [in] DesiredPerformanceRegister If provided, Desired= Performance Register Buffer. + @param [in] MinimumPerformanceRegister If provided, Minimum= Performance Register Buffer. + @param [in] MaximumPerformanceRegister If provided, Maximum= Performance Register Buffer. + @param [in] PerformanceReductionToleranceRegister If provided, Perform= ance Reduction Tolerance Register. + @param [in] TimeWindowRegister If provided, Time Wi= ndow Register. + @param [in] CounterWraparoundTimeBuffer If provided, Counter= Wraparound Time buffer. + @param [in] CounterWraparoundTimeInteger Counter Wraparound T= ime, used if buffer is NULL. + @param [in] ReferencePerformanceCounterRegister Reference Performanc= e Counter Register. + @param [in] DeliveredPerformanceCounterRegister Delivered Performanc= e Counter Register. + @param [in] PerformanceLimitedRegister Performance Limited = Register. + @param [in] CPPCEnableRegister If provided, CPPC En= ableRegister. + @param [in] AutonomousSelectionEnableBuffer If provided, Autonom= ous Selection Enable buffer. + @param [in] AutonomousSelectionEnableInteger Autonomous Selection= Enable, used if buffer is NULL. + @param [in] AutonomousActivityWindowRegister If provided, Autonom= ousActivity-WindowRegister. + @param [in] EnergyPerformancePreferenceRegister If provided, EnergyP= erformance-PreferenceRegister. + @param [in] ReferencePerformanceBuffer If provided, Referen= ce Performance buffer. + @param [in] ReferencePerformanceInteger Reference Performanc= e, used if buffer is NULL. + @param [in] LowestFrequencyBuffer If provided, Lowest = Frequency buffer. + @param [in] LowestFrequencyInteger Lowest Frequency, us= ed if buffer is NULL. + @param [in] NominalFrequencyBuffer If provided, Nominal= FrequencyBuffer buffer. + @param [in] NominalFrequencyInteger NominalFrequencyBuff= er, used if buffer is NULL. + @param [in] ParentNode If provided, set Par= entNode as the parent + of the node created. + @param [out] NewCpcNode If success and provi= ded, contains the created node. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCreateCpcNode ( + /// The revision number of the _CPC package format. + IN UINT32 Revision, + /// Indicates the highest level of performance the processor + /// is theoretically capable of achieving. + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *HighestPerformanceBuffer OPT= IONAL, + IN UINT32 HighestPerformanceInteger, + /// Indicates the highest sustained performance level of the processor. + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *NominalPerformanceBuffer OPT= IONAL, + IN UINT32 NominalPerformanceInteger, + /// Indicates the lowest performance level of the processor with non-lin= ear power savings. + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *LowestNonlinearPerformanceBu= ffer OPTIONAL, + IN UINT32 LowestNonlinearPerformanceInt= eger, + /// Indicates the lowest performance level of the processor.. + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *LowestPerformanceBuffer OPTI= ONAL, + IN UINT32 LowestPerformanceInteger, + /// Guaranteed Performance Register Buffer. + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *GuaranteedPerformanceRegiste= r OPTIONAL, + /// Desired Performance Register Buffer. + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *DesiredPerformanceRegister, + /// Minimum Performance Register Buffer. + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *MinimumPerformanceRegister O= PTIONAL, + /// Maximum Performance Register Buffer. + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *MaximumPerformanceRegister O= PTIONAL, + /// Performance Reduction Tolerance Register. + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *PerformanceReductionToleranc= eRegister OPTIONAL, + /// Time Window Register. + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *TimeWindowRegister OPTIONAL, + /// Counter Wraparound Time + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *CounterWraparoundTimeBuffer = OPTIONAL, + IN UINT32 CounterWraparoundTimeInteger, + /// Reference Performance Counter Register + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *ReferencePerformanceCounterR= egister, + /// Delivered Performance Counter Register + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *DeliveredPerformanceCounterR= egister, + /// Performance Limited Register + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *PerformanceLimitedRegister, + /// CPPC EnableRegister + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *CPPCEnableRegister OPTIONAL, + /// Autonomous Selection Enable + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *AutonomousSelectionEnableBuf= fer OPTIONAL, + IN UINT32 AutonomousSelectionEnableInte= ger, + /// AutonomousActivity-WindowRegister + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *AutonomousActivityWindowRegi= ster OPTIONAL, + /// EnergyPerformance-PreferenceRegister + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *EnergyPerformancePreferenceR= egister OPTIONAL, + /// Reference Performance + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *ReferencePerformanceBuffer O= PTIONAL, + IN UINT32 ReferencePerformanceInteger, + /// Lowest Frequency + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *LowestFrequencyBuffer OPTION= AL, + IN UINT32 LowestFrequencyInteger, + /// Nominal Frequency + /// Optional + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *NominalFrequencyBuffer OPTIO= NAL, + IN UINT32 NominalFrequencyInteger, + IN AML_NODE_HANDLE ParentNode OPTIONAL, + OUT AML_OBJECT_NODE_HANDLE *NewCpcNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE_HANDLE CpcNode; + AML_OBJECT_NODE_HANDLE CpcPackage; + UINT32 NumberOfEntries; + + // Revision 3 per ACPI 6.4 specification + if (Revision =3D=3D 3) { + // NumEntries 23 per ACPI 6.4 specification + NumberOfEntries =3D 23; + } else { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + if (((HighestPerformanceBuffer =3D=3D NULL) && (HighestPerformanceIntege= r =3D=3D 0)) || + ((NominalPerformanceBuffer =3D=3D NULL) && (NominalPerformanceIntege= r =3D=3D 0)) || + ((LowestNonlinearPerformanceBuffer =3D=3D NULL) && (LowestNonlinearP= erformanceInteger =3D=3D 0)) || + ((LowestPerformanceBuffer =3D=3D NULL) && (LowestPerformanceInteger = =3D=3D 0)) || + (DesiredPerformanceRegister =3D=3D NULL) || + (ReferencePerformanceCounterRegister =3D=3D NULL) || + (DeliveredPerformanceCounterRegister =3D=3D NULL) || + (PerformanceLimitedRegister =3D=3D NULL) || + ((ParentNode =3D=3D NULL) && (NewCpcNode =3D=3D NULL))) + { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + CpcPackage =3D NULL; + + Status =3D AmlCodeGenNamePackage ("_CPC", NULL, &CpcNode); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + + // Get the Package object node of the _CPC node, + // which is the 2nd fixed argument (i.e. index 1). + CpcPackage =3D (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( + CpcNode, + EAmlParseIndexTerm1 + ); + if ((CpcPackage =3D=3D NULL) = || + (AmlGetNodeType ((AML_NODE_HANDLE)CpcPackage) !=3D EAmlNodeObject) = || + (!AmlNodeHasOpCode (CpcPackage, AML_PACKAGE_OP, 0))) + { + ASSERT (0); + Status =3D EFI_INVALID_PARAMETER; + goto error_handler; + } + + Status =3D AmlAddRegisterOrIntegerToPackage ( + NULL, + NumberOfEntries, + CpcPackage + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterOrIntegerToPackage ( + NULL, + Revision, + CpcPackage + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterOrIntegerToPackage ( + HighestPerformanceBuffer, + HighestPerformanceInteger, + CpcPackage + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterOrIntegerToPackage ( + NominalPerformanceBuffer, + NominalPerformanceInteger, + CpcPackage + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterOrIntegerToPackage ( + LowestNonlinearPerformanceBuffer, + LowestNonlinearPerformanceInteger, + CpcPackage + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterOrIntegerToPackage ( + LowestPerformanceBuffer, + LowestPerformanceInteger, + CpcPackage + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterToPackage (GuaranteedPerformanceRegister, CpcPa= ckage); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterToPackage (DesiredPerformanceRegister, CpcPacka= ge); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterToPackage (MinimumPerformanceRegister, CpcPacka= ge); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterToPackage (MaximumPerformanceRegister, CpcPacka= ge); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterToPackage (PerformanceReductionToleranceRegiste= r, CpcPackage); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterToPackage (TimeWindowRegister, CpcPackage); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterOrIntegerToPackage ( + CounterWraparoundTimeBuffer, + CounterWraparoundTimeInteger, + CpcPackage + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterToPackage (ReferencePerformanceCounterRegister,= CpcPackage); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterToPackage (DeliveredPerformanceCounterRegister,= CpcPackage); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterToPackage (PerformanceLimitedRegister, CpcPacka= ge); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterToPackage (CPPCEnableRegister, CpcPackage); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterOrIntegerToPackage ( + AutonomousSelectionEnableBuffer, + AutonomousSelectionEnableInteger, + CpcPackage + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterToPackage (AutonomousActivityWindowRegister, Cp= cPackage); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterToPackage (EnergyPerformancePreferenceRegister,= CpcPackage); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterOrIntegerToPackage ( + ReferencePerformanceBuffer, + ReferencePerformanceInteger, + CpcPackage + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterOrIntegerToPackage ( + LowestFrequencyBuffer, + LowestFrequencyInteger, + CpcPackage + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D AmlAddRegisterOrIntegerToPackage ( + NominalFrequencyBuffer, + NominalFrequencyInteger, + CpcPackage + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + Status =3D LinkNode (CpcNode, ParentNode, NewCpcNode); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + return Status; + +error_handler: + AmlDeleteTree ((AML_NODE_HANDLE)CpcNode); + return Status; +} --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93829): https://edk2.groups.io/g/devel/message/93829 Mute This Topic: https://groups.io/mt/93699443/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-