From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.65]) by mx.groups.io with SMTP id smtpd.web09.5091.1663624895659658816 for ; Mon, 19 Sep 2022 15:01:35 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nvidia.com header.s=selector2 header.b=Nhssj7r9; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.243.65, mailfrom: jbrasen@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=etjSI7wAjWqKM/DVVppcOsWDL8/qass6H95st49ZlleJwsccxntNgwFJT/hQQRCkEQ6bZnsaL4keYYYiW9ZabVlpohkkBdhBPmnR4uDr4kALcTJYgsNOo+rabXG9IJKU3GHo2/xB1zl/iWG8hOfi2FCz18l+pFcYeISX8dN0FtLBhR8sxsMHS/VditlxrUOyd9ZDlueOl53CUM967jDiVF78CNX1Uxr7UD4s71ZYD80hEnQFak5SDVcHl/25HhoWXCbafXQ6tz6swbvQFRCwXj1AXC5oagAFhgNMiFfmBd154BG0xDJtR3f6LF5iERyW9bhUTMS5QeUM668VkbHprA== 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=7FcRuaJIptU3NU7lFyYtl3wMRPAEvv51ZBKl5BcaSrs=; b=ViMvi/zBYF5a4hZbl6w07i6Btuc+j9kHOxhIhFCrKUFZp5FTdyARE9eAhaZXexuzN0mXdfgOcoJcPHSt605yXvRwuMXbMGpWdKzFC6NZocW53IB2zOJCSJ7PGF1uoOW/1nVFEw+UdWV+K2xb673GM4VlxgE0vmJKG3WbWtR8YNRxc8eB+lWxw/8z7HhKPkmM/vjms22hVz2dvYM2xat80IiJoev+GnOQw5bPY/Vlh1xl3qFIEnSS6CQnelPpPbFxwh0Un2SQEPBWDsUJudhZJ50JrNBOzeM9gfGS/M7ztAFznCg2wcNp+2T4QEuVotQ4C38KJselMZEjeI+VnT02EA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7FcRuaJIptU3NU7lFyYtl3wMRPAEvv51ZBKl5BcaSrs=; b=Nhssj7r9yL3lQkPfRZSxAG3DEvKvyRDb3bk4MK5zUpvwxbne4z/LDUWwyOLSzbomP40ignTBEp4E3tdG2GMyG9r98BlafnxcnwiCZYZke54CgBQtw65kW6+e+mTgBzBYXLEp3uaoo53Y53YpFZgT9Usj2YrJF6KCCj9PQ9dWo0f4Ir3YmrWN9IfzmiPq2Q1zm7Rufv+37mlYw+FInZCdqwUH/bcNrqtEkGvpVVj91bLPC3uPnV02KzsAB7WuJ66FZ8jN6Dn5VkowJFOfkQuW7Sa07yy+cgfTTch2cXn9id4vRyKsTyULAwtyuvNhdGHcnrbqT9u1pw+reh/RRkRlfA== Received: from BN9PR03CA0108.namprd03.prod.outlook.com (2603:10b6:408:fd::23) by BL1PR12MB5285.namprd12.prod.outlook.com (2603:10b6:208:31f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.21; Mon, 19 Sep 2022 22:01:33 +0000 Received: from BN8NAM11FT109.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fd:cafe::fe) by BN9PR03CA0108.outlook.office365.com (2603:10b6:408:fd::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.21 via Frontend Transport; Mon, 19 Sep 2022 22:01:33 +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 (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 Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT109.mail.protection.outlook.com (10.13.176.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12 via Frontend Transport; Mon, 19 Sep 2022 22:01:32 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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; Mon, 19 Sep 2022 15:01:19 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Mon, 19 Sep 2022 15:01:18 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Mon, 19 Sep 2022 15:01:18 -0700 Received: from f153882e4be8.nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Mon, 19 Sep 2022 15:01:17 -0700 From: "Jeff Brasen" To: CC: , , , , , Jeff Brasen Subject: [PATCH v4 2/3] DynamicTablesPkg: AML Code generation to add _CPC entries Date: Mon, 19 Sep 2022 16:01:10 -0600 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-NVConfidentiality: public Return-Path: jbrasen@nvidia.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT109:EE_|BL1PR12MB5285:EE_ X-MS-Office365-Filtering-Correlation-Id: f8d82985-dd77-467a-8509-08da9a8a8394 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a9DUZ571Q0DEeCHX287TF0vHoBvo5p7taj+hdJROrjOsZkkwNE1IpYEUaxnbkaggDm7kXm4KrH4riuAs9YeimMqVrZ0PoI66XXVemr0jdGjodoK0P02X47Up3H2U47QR7tgHFm3NycjmEHIJeWC6KV3WmaqQNJzUWZM2FW7rILPk0HG5IkzThennAZpMtChAuY5AU2ywVTOK4Wn1ElsVdfAK4MNYjmzQc3ckdvWbJNLThFmi+8lZeSH/feDhLG5zCaGiX+OAyd7SN0JwqczY0f6RKr8XiH42bScEgH59keRhSjA0XswwbkFGdFyE2TQFuOERJSGj0nYuu8Ymy4KFMTGh/AvwcW3iRQquSiowhUSoLdwk4lCNqkSrVxZd6gXZTnq2ZputC9ZqHwrARslaooiWnhfnpj13v14mUthak+q0RrUSHt9zeAeM5jJKqlT7uju+5Db7ifbA9D372koyDT1TqHiVk1GfqyXmlSRdY3Wd+J78V178aWHH5NsEYM4p3QO+/br7ytuj8AFJH0KFMpco7r6EJgFhTxJxhwTMxYqA9uG8A8+auzkl6KS65T5+JmELJatQB6r6MVcSeWw1NZNTNBMzBCvlJGO+RyLfJyGSQBU4DBWRD6qui2MkUbofjuXrb13lgCuYrZ2j313bc61bibWSOFuTU/xCwqFm176V9xxl59sf35Wr264tTXlrsQEVAo1AL+aJCw7qj67V7djJsRf9yRxrv0F9leXK1n0K+E3tHDmK2X/mP8veMqoNSVvH7bma0kGmkL2Kw94VRGuUTRpPspf8TV2rpKNyzBk= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(376002)(346002)(396003)(451199015)(46966006)(36840700001)(40470700004)(36860700001)(8936002)(36756003)(7636003)(86362001)(82740400003)(40480700001)(356005)(40460700003)(6916009)(19627235002)(316002)(8676002)(70206006)(54906003)(30864003)(2906002)(70586007)(4326008)(5660300002)(2616005)(41300700001)(83380400001)(426003)(336012)(82310400005)(186003)(47076005)(6666004)(107886003)(478600001)(26005)(7696005)(44824005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2022 22:01:32.7872 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f8d82985-dd77-467a-8509-08da9a8a8394 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: BN8NAM11FT109.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5285 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain _CPC entries can describe CPU performance information.=0D The object is described in ACPI 6.4 s8.4.7.1.=0D "_CPC (Continuous Performance Control)".=0D =0D Add AmlCreateCpcNode() helper function to add _CPC entries to an=0D existing CPU object.=0D =0D Signed-off-by: Jeff Brasen =0D ---=0D .../Include/Library/AmlLib/AmlLib.h | 54 ++=0D .../Common/AmlLib/CodeGen/AmlCodeGen.c | 476 ++++++++++++++++++=0D 2 files changed, 530 insertions(+)=0D =0D diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h=0D index 39968660f2..ebaccba811 100644=0D --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h=0D +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h=0D @@ -37,6 +37,7 @@=0D */=0D =0D #include =0D +#include =0D =0D #ifndef AML_HANDLE=0D =0D @@ -1336,6 +1337,59 @@ AmlAddNameIntegerPackage (=0D IN AML_OBJECT_NODE_HANDLE PackageNode=0D );=0D =0D +/** Create a _CPC node.=0D +=0D + Creates and optionally adds the following node=0D + Name(_CPC, Package()=0D + {=0D + NumEntries, // Integer=0D + Revision, // Integer=0D + HighestPerformance, // Integer or Buffer (Resourc= e Descriptor)=0D + NominalPerformance, // Integer or Buffer (Resourc= e Descriptor)=0D + LowestNonlinearPerformance, // Integer or Buffer (Resourc= e Descriptor)=0D + LowestPerformance, // Integer or Buffer (Resourc= e Descriptor)=0D + GuaranteedPerformanceRegister, // Buffer (Resource Descripto= r)=0D + DesiredPerformanceRegister , // Buffer (Resource Descripto= r)=0D + MinimumPerformanceRegister , // Buffer (Resource Descripto= r)=0D + MaximumPerformanceRegister , // Buffer (Resource Descripto= r)=0D + PerformanceReductionToleranceRegister, // Buffer (Resource Descripto= r)=0D + TimeWindowRegister, // Buffer (Resource Descripto= r)=0D + CounterWraparoundTime, // Integer or Buffer (Resourc= e Descriptor)=0D + ReferencePerformanceCounterRegister, // Buffer (Resource Descripto= r)=0D + DeliveredPerformanceCounterRegister, // Buffer (Resource Descripto= r)=0D + PerformanceLimitedRegister, // Buffer (Resource Descripto= r)=0D + CPPCEnableRegister // Buffer (Resource Descripto= r)=0D + AutonomousSelectionEnable, // Integer or Buffer (Resourc= e Descriptor)=0D + AutonomousActivityWindowRegister, // Buffer (Resource Descripto= r)=0D + EnergyPerformancePreferenceRegister, // Buffer (Resource Descripto= r)=0D + ReferencePerformance // Integer or Buffer (Resourc= e Descriptor)=0D + LowestFrequency, // Integer or Buffer (Resourc= e Descriptor)=0D + NominalFrequency // Integer or Buffer (Resourc= e Descriptor)=0D + })=0D +=0D + If resource buffer is NULL then integer will be used.=0D +=0D + Cf. ACPI 6.4, s8.4.7.1 _CPC (Continuous Performance Control)=0D +=0D + @ingroup CodeGenApis=0D +=0D + @param [in] CpcInfo CpcInfo object=0D + @param [in] ParentNode If provided, set ParentNode as the pa= rent=0D + of the node created.=0D + @param [out] NewCpcNode If success and provided, contains the= created node.=0D +=0D + @retval EFI_SUCCESS The function completed successfully.=0D + @retval EFI_INVALID_PARAMETER Invalid parameter.=0D + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +AmlCreateCpcNode (=0D + IN AML_CPC_INFO *CpcInfo,=0D + IN AML_NODE_HANDLE ParentNode OPTIONAL,=0D + OUT AML_OBJECT_NODE_HANDLE *NewCpcNode OPTIONAL=0D + );=0D +=0D // DEPRECATED APIS=0D #ifndef DISABLE_NEW_DEPRECATED_INTERFACES=0D =0D diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c=0D index 5fb39d077b..fc85c467ec 100644=0D --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c=0D +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c=0D @@ -14,6 +14,7 @@=0D #include =0D #include =0D #include =0D +#include =0D #include =0D #include =0D #include =0D @@ -2850,3 +2851,478 @@ error_handler:=0D =0D return Status;=0D }=0D +=0D +/** Adds a register to the package=0D +=0D + @ingroup CodeGenApis=0D +=0D + @param [in] Register If provided, register that will be added to pa= ckage.=0D + otherwise NULL register will be added=0D + @param [in] PackageNode Package to add value to=0D +=0D + @retval EFI_SUCCESS The function completed successfully.=0D + @retval EFI_INVALID_PARAMETER Invalid parameter.=0D + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +EFIAPI=0D +AmlAddRegisterToPackage (=0D + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Register OPTIONAL,=0D + IN AML_OBJECT_NODE_HANDLE PackageNode=0D + )=0D +{=0D + EFI_STATUS Status;=0D + AML_DATA_NODE_HANDLE RdNode;=0D + AML_OBJECT_NODE_HANDLE ResourceTemplateNode;=0D +=0D + RdNode =3D NULL;=0D +=0D + Status =3D AmlCodeGenResourceTemplate (&ResourceTemplateNode);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + return Status;=0D + }=0D +=0D + if (Register !=3D NULL) {=0D + Status =3D AmlCodeGenRdRegister (=0D + Register->AddressSpaceId,=0D + Register->RegisterBitWidth,=0D + Register->RegisterBitOffset,=0D + Register->Address,=0D + Register->AccessSize,=0D + NULL,=0D + &RdNode=0D + );=0D + } else {=0D + Status =3D AmlCodeGenRdRegister (=0D + EFI_ACPI_6_4_SYSTEM_MEMORY,=0D + 0,=0D + 0,=0D + 0,=0D + 0,=0D + NULL,=0D + &RdNode=0D + );=0D + }=0D +=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAppendRdNode (ResourceTemplateNode, RdNode);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + RdNode =3D NULL;=0D +=0D + Status =3D AmlVarListAddTail (=0D + (AML_NODE_HANDLE)PackageNode,=0D + (AML_NODE_HANDLE)ResourceTemplateNode=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + return Status;=0D +=0D +error_handler:=0D + if (RdNode !=3D NULL) {=0D + AmlDeleteTree ((AML_NODE_HANDLE)RdNode);=0D + }=0D +=0D + if (ResourceTemplateNode !=3D NULL) {=0D + AmlDeleteTree ((AML_NODE_HANDLE)ResourceTemplateNode);=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/** Utility function to check if generic address points to NULL=0D +=0D + @param [in] Address Pointer to the Generic address=0D +=0D + @retval TRUE Address is system memory with an Address of 0.=0D + @retval FALSE Address does not point to NULL.=0D +**/=0D +STATIC=0D +BOOLEAN=0D +EFIAPI=0D +IsNullGenericAddress (=0D + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Address=0D + )=0D +{=0D + if ((Address =3D=3D NULL) ||=0D + ((Address->AddressSpaceId =3D=3D EFI_ACPI_6_4_SYSTEM_MEMORY) &&=0D + (Address->Address =3D=3D 0x0)))=0D + {=0D + return TRUE;=0D + }=0D +=0D + return FALSE;=0D +}=0D +=0D +/** Adds an integer or register to the package=0D +=0D + @ingroup CodeGenApis=0D +=0D + @param [in] Register If provided, register that will be added to pa= ckage=0D + @param [in] Integer If Register is NULL, integer that will be adde= d to the package=0D + @param [in] PackageNode Package to add value to=0D +=0D + @retval EFI_SUCCESS The function completed successfully.=0D + @retval EFI_INVALID_PARAMETER Invalid parameter.=0D + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +EFIAPI=0D +AmlAddRegisterOrIntegerToPackage (=0D + IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Register OPTIONAL,=0D + IN UINT32 Integer,=0D + IN AML_OBJECT_NODE_HANDLE PackageNode=0D + )=0D +{=0D + EFI_STATUS Status;=0D + AML_OBJECT_NODE_HANDLE IntegerNode;=0D +=0D + IntegerNode =3D NULL;=0D +=0D + if ((Register !=3D NULL) && !IsNullGenericAddress (Register)) {=0D + Status =3D AmlAddRegisterToPackage (Register, PackageNode);=0D + } else {=0D + Status =3D AmlCodeGenInteger (Integer, &IntegerNode);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + return Status;=0D + }=0D +=0D + Status =3D AmlVarListAddTail (=0D + (AML_NODE_HANDLE)PackageNode,=0D + (AML_NODE_HANDLE)IntegerNode=0D + );=0D + }=0D +=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + if (IntegerNode !=3D NULL) {=0D + AmlDeleteTree ((AML_NODE_HANDLE)IntegerNode);=0D + }=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/** Create a _CPC node.=0D +=0D + Creates and optionally adds the following node=0D + Name(_CPC, Package()=0D + {=0D + NumEntries, // Integer=0D + Revision, // Integer=0D + HighestPerformance, // Integer or Buffer (Resourc= e Descriptor)=0D + NominalPerformance, // Integer or Buffer (Resourc= e Descriptor)=0D + LowestNonlinearPerformance, // Integer or Buffer (Resourc= e Descriptor)=0D + LowestPerformance, // Integer or Buffer (Resourc= e Descriptor)=0D + GuaranteedPerformanceRegister, // Buffer (Resource Descripto= r)=0D + DesiredPerformanceRegister , // Buffer (Resource Descripto= r)=0D + MinimumPerformanceRegister , // Buffer (Resource Descripto= r)=0D + MaximumPerformanceRegister , // Buffer (Resource Descripto= r)=0D + PerformanceReductionToleranceRegister, // Buffer (Resource Descripto= r)=0D + TimeWindowRegister, // Buffer (Resource Descripto= r)=0D + CounterWraparoundTime, // Integer or Buffer (Resourc= e Descriptor)=0D + ReferencePerformanceCounterRegister, // Buffer (Resource Descripto= r)=0D + DeliveredPerformanceCounterRegister, // Buffer (Resource Descripto= r)=0D + PerformanceLimitedRegister, // Buffer (Resource Descripto= r)=0D + CPPCEnableRegister // Buffer (Resource Descripto= r)=0D + AutonomousSelectionEnable, // Integer or Buffer (Resourc= e Descriptor)=0D + AutonomousActivityWindowRegister, // Buffer (Resource Descripto= r)=0D + EnergyPerformancePreferenceRegister, // Buffer (Resource Descripto= r)=0D + ReferencePerformance // Integer or Buffer (Resourc= e Descriptor)=0D + LowestFrequency, // Integer or Buffer (Resourc= e Descriptor)=0D + NominalFrequency // Integer or Buffer (Resourc= e Descriptor)=0D + })=0D +=0D + If resource buffer is NULL then integer will be used.=0D +=0D + Cf. ACPI 6.4, s8.4.7.1 _CPC (Continuous Performance Control)=0D +=0D + @ingroup CodeGenApis=0D +=0D + @param [in] CpcInfo CpcInfo object=0D + @param [in] ParentNode If provided, set ParentNode as the pa= rent=0D + of the node created.=0D + @param [out] NewCpcNode If success and provided, contains the= created node.=0D +=0D + @retval EFI_SUCCESS The function completed successfully.=0D + @retval EFI_INVALID_PARAMETER Invalid parameter.=0D + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +AmlCreateCpcNode (=0D + IN AML_CPC_INFO *CpcInfo,=0D + IN AML_NODE_HANDLE ParentNode OPTIONAL,=0D + OUT AML_OBJECT_NODE_HANDLE *NewCpcNode OPTIONAL=0D + )=0D +{=0D + EFI_STATUS Status;=0D + AML_OBJECT_NODE_HANDLE CpcNode;=0D + AML_OBJECT_NODE_HANDLE CpcPackage;=0D + UINT32 NumberOfEntries;=0D +=0D + if ((CpcInfo =3D=3D NULL) ||=0D + ((ParentNode =3D=3D NULL) && (NewCpcNode =3D=3D NULL)))=0D + {=0D + ASSERT (0);=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + // Revision 3 per ACPI 6.4 specification=0D + if (CpcInfo->Revision =3D=3D 3) {=0D + // NumEntries 23 per ACPI 6.4 specification=0D + NumberOfEntries =3D 23;=0D + } else {=0D + ASSERT (0);=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if ((CpcInfo =3D=3D NULL) ||=0D + (IsNullGenericAddress (&CpcInfo->HighestPerformanceBuffer) &&=0D + (CpcInfo->HighestPerformanceInteger =3D=3D 0)) ||=0D + (IsNullGenericAddress (&CpcInfo->NominalPerformanceBuffer) &&=0D + (CpcInfo->NominalPerformanceInteger =3D=3D 0)) ||=0D + (IsNullGenericAddress (&CpcInfo->LowestNonlinearPerformanceBuffer) &= &=0D + (CpcInfo->LowestNonlinearPerformanceInteger =3D=3D 0)) ||=0D + (IsNullGenericAddress (&CpcInfo->LowestPerformanceBuffer) &&=0D + (CpcInfo->LowestPerformanceInteger =3D=3D 0)) ||=0D + IsNullGenericAddress (&CpcInfo->DesiredPerformanceRegister) ||=0D + IsNullGenericAddress (&CpcInfo->ReferencePerformanceCounterRegister)= ||=0D + IsNullGenericAddress (&CpcInfo->DeliveredPerformanceCounterRegister)= ||=0D + IsNullGenericAddress (&CpcInfo->PerformanceLimitedRegister))=0D + {=0D + ASSERT (0);=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + CpcPackage =3D NULL;=0D +=0D + Status =3D AmlCodeGenNamePackage ("_CPC", NULL, &CpcNode);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + return Status;=0D + }=0D +=0D + // Get the Package object node of the _CPC node,=0D + // which is the 2nd fixed argument (i.e. index 1).=0D + CpcPackage =3D (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument (=0D + CpcNode,=0D + EAmlParseIndexTerm1=0D + );=0D + if ((CpcPackage =3D=3D NULL) = ||=0D + (AmlGetNodeType ((AML_NODE_HANDLE)CpcPackage) !=3D EAmlNodeObject) = ||=0D + (!AmlNodeHasOpCode (CpcPackage, AML_PACKAGE_OP, 0)))=0D + {=0D + ASSERT (0);=0D + Status =3D EFI_INVALID_PARAMETER;=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterOrIntegerToPackage (=0D + NULL,=0D + NumberOfEntries,=0D + CpcPackage=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterOrIntegerToPackage (=0D + NULL,=0D + CpcInfo->Revision,=0D + CpcPackage=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterOrIntegerToPackage (=0D + &CpcInfo->HighestPerformanceBuffer,=0D + CpcInfo->HighestPerformanceInteger,=0D + CpcPackage=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterOrIntegerToPackage (=0D + &CpcInfo->NominalPerformanceBuffer,=0D + CpcInfo->NominalPerformanceInteger,=0D + CpcPackage=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterOrIntegerToPackage (=0D + &CpcInfo->LowestNonlinearPerformanceBuffer,=0D + CpcInfo->LowestNonlinearPerformanceInteger,=0D + CpcPackage=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterOrIntegerToPackage (=0D + &CpcInfo->LowestPerformanceBuffer,=0D + CpcInfo->LowestPerformanceInteger,=0D + CpcPackage=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterToPackage (&CpcInfo->GuaranteedPerformanceRegis= ter, CpcPackage);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterToPackage (&CpcInfo->DesiredPerformanceRegister= , CpcPackage);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterToPackage (&CpcInfo->MinimumPerformanceRegister= , CpcPackage);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterToPackage (&CpcInfo->MaximumPerformanceRegister= , CpcPackage);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterToPackage (&CpcInfo->PerformanceReductionTolera= nceRegister, CpcPackage);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterToPackage (&CpcInfo->TimeWindowRegister, CpcPac= kage);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterOrIntegerToPackage (=0D + &CpcInfo->CounterWraparoundTimeBuffer,=0D + CpcInfo->CounterWraparoundTimeInteger,=0D + CpcPackage=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterToPackage (&CpcInfo->ReferencePerformanceCounte= rRegister, CpcPackage);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterToPackage (&CpcInfo->DeliveredPerformanceCounte= rRegister, CpcPackage);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterToPackage (&CpcInfo->PerformanceLimitedRegister= , CpcPackage);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterToPackage (&CpcInfo->CPPCEnableRegister, CpcPac= kage);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterOrIntegerToPackage (=0D + &CpcInfo->AutonomousSelectionEnableBuffer,=0D + CpcInfo->AutonomousSelectionEnableInteger,=0D + CpcPackage=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterToPackage (&CpcInfo->AutonomousActivityWindowRe= gister, CpcPackage);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterToPackage (&CpcInfo->EnergyPerformancePreferenc= eRegister, CpcPackage);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterOrIntegerToPackage (=0D + &CpcInfo->ReferencePerformanceBuffer,=0D + CpcInfo->ReferencePerformanceInteger,=0D + CpcPackage=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterOrIntegerToPackage (=0D + &CpcInfo->LowestFrequencyBuffer,=0D + CpcInfo->LowestFrequencyInteger,=0D + CpcPackage=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlAddRegisterOrIntegerToPackage (=0D + &CpcInfo->NominalFrequencyBuffer,=0D + CpcInfo->NominalFrequencyInteger,=0D + CpcPackage=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D LinkNode (CpcNode, ParentNode, NewCpcNode);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + return Status;=0D +=0D +error_handler:=0D + AmlDeleteTree ((AML_NODE_HANDLE)CpcNode);=0D + return Status;=0D +}=0D -- =0D 2.25.1=0D =0D