From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.41]) by mx.groups.io with SMTP id smtpd.web08.10038.1633703405697049604 for ; Fri, 08 Oct 2021 07:30:06 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=5UNEHGrd; spf=pass (domain: arm.com, ip: 40.107.22.41, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4LHAPUWWe2sqqFNr6IP8ymEW1aRilZBD+vxfHT2fUgI=; b=5UNEHGrd84Clh50twN5xAwaj0NgVite0Pu+K9MSjQO++VjC3518f0OOIW42h2cRxlVx6x392NhZ+lCgXRYXCwwpP/u/FUhbszlIQpxXUSFaYbzEEaJFz8svxdSjEhLvGUboJwJSsKAPRWAi4TZKANPB271Zx8RWlHG8SFviRBwg= Received: from DB6PR0601CA0003.eurprd06.prod.outlook.com (2603:10a6:4:7b::13) by DBBPR08MB6057.eurprd08.prod.outlook.com (2603:10a6:10:1f5::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.19; Fri, 8 Oct 2021 14:30:02 +0000 Received: from DB5EUR03FT019.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:7b:cafe::4c) by DB6PR0601CA0003.outlook.office365.com (2603:10a6:4:7b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.21 via Frontend Transport; Fri, 8 Oct 2021 14:30:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT019.mail.protection.outlook.com (10.152.20.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Fri, 8 Oct 2021 14:30:02 +0000 Received: ("Tessian outbound a8bfe25d7364:v103"); Fri, 08 Oct 2021 14:30:02 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d614e04c3b1f2d79 X-CR-MTA-TID: 64aa7808 Received: from e530a7be35a0.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 53D2452B-1505-44D8-B603-F3124E8DCE68.1; Fri, 08 Oct 2021 14:29:51 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e530a7be35a0.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 08 Oct 2021 14:29:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IIBkgnnc0eK3IOhGkZcZfixJ4Fsfe5VMWO6EJAJXwcwtBKs9/LCdT+d9zbRVO4mowGhCrvdBinCPKQknZ2gRvlvkLxci7TYIb4MnmDcT+/JFppH2af1+EOLQL7GaSIZCVc2rwNtmPuojTRQCyFU8feT0C9AIVYWeBfhrsP/oj78KV6RwRRic1iqzYPL6kqzys3+2Iocbo2D2r+8gYUazGJNgBUdpuU3C0SkkFyTkl/sSSPdxdUy+qjmgaB6Z82Y6BOwdKnvS5H2UE0yF/B66eqwK26imGH+uBgNxbGncKJgjvvkELe0M/B176EYn5DYCnUgX1v6k67PM8G5Y4d193g== 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=4LHAPUWWe2sqqFNr6IP8ymEW1aRilZBD+vxfHT2fUgI=; b=aij4CHQErtJsEJb013wrqO++6S+taY67MGbAeafSEpnu1J5/RXpqdOIFIFQy5Zj0KuukG2701W/dl09QzxcFakNVVf9nvg7x63IhJ+wKLkfV+B440rTpUgqXJtbtqly6PH3VeAmOFtUqqbmDZiaut4DfGut+q8iRrI+LwNVoVNHOuL61/t/yv5sathML+BCx9KnvKOcS6W1gm9MJn0oHUVXTNFSPpoJjjGNWlZFDrPf+TyoyjRFkuptn5hdFNzephe0sQlCbYUk3RNvLkhfniTB+upn390L85FLv9C7aC1t0GQgZVu0iAIhrFp94LfnpeOhElDG3yNBB6UJjSJW5vQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4LHAPUWWe2sqqFNr6IP8ymEW1aRilZBD+vxfHT2fUgI=; b=5UNEHGrd84Clh50twN5xAwaj0NgVite0Pu+K9MSjQO++VjC3518f0OOIW42h2cRxlVx6x392NhZ+lCgXRYXCwwpP/u/FUhbszlIQpxXUSFaYbzEEaJFz8svxdSjEhLvGUboJwJSsKAPRWAi4TZKANPB271Zx8RWlHG8SFviRBwg= Authentication-Results-Original: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) by AS8PR08MB6102.eurprd08.prod.outlook.com (2603:10a6:20b:23d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.21; Fri, 8 Oct 2021 14:29:42 +0000 Received: from AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::54b5:239d:9896:ee65]) by AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::54b5:239d:9896:ee65%4]) with mapi id 15.20.4587.022; Fri, 8 Oct 2021 14:29:42 +0000 Subject: Re: [PATCH v2 19/21] DynamicTablesPkg: AML code generation to add an _LPI state To: Pierre.Gondois@arm.com, devel@edk2.groups.io, Alexei.Fedorov@arm.com, nd References: <20211007153210.26608-1-Pierre.Gondois@arm.com> <20211007153210.26608-20-Pierre.Gondois@arm.com> From: "Sami Mujawar" Message-ID: <5cde8407-0099-b783-bb3e-335ab4d4110a@arm.com> Date: Fri, 8 Oct 2021 15:29:48 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 In-Reply-To: <20211007153210.26608-20-Pierre.Gondois@arm.com> X-ClientProxiedBy: LO2P265CA0440.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::20) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 Received: from [10.1.196.43] (217.140.106.52) by LO2P265CA0440.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.21 via Frontend Transport; Fri, 8 Oct 2021 14:29:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 69aa6c96-1f3e-4bd0-5e6e-08d98a681d92 X-MS-TrafficTypeDiagnostic: AS8PR08MB6102:|DBBPR08MB6057: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:1468;OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: dqvO7eXcYC6DKdlhuUICWrtJ7gSzL1ojHxeMa9gpeJiJZ92UhqrSD7Yoi/G4JYvolZPoBr+E/Dxo5npTJoLHQQmw8zcqljDoNRyG54FS4I3FADukGa3hyqEc04erYqmCPvl6znMLlmRiLYTZSr1tLPopNutZE73j3nWiofQgA+uytMj4bi3Db/jkMib/OUi0oa2Gy8mq6E6hd7hJju6NSpjRTOSD8s7KA5QYZOpRnWT0DGy+apxVFwdg1lX2nb+ido2mj3zcQAZ+xzLKXSig4jyq/Q187Jb1wX68EeAZqEY0rvAB66cD1PYNtJ6eLarR9KBd1y2vkMdLvZGhE8aUFmmiz9DypkrVez2mNokfyAfxy1oaInfxLOYmcCO2PcusKIuffLz5/KDyRmyLE88tVxsrXAklTPKiewb2HGEa7ba3sEBD0VpYy0zlD5SMEQM5LrLmFui+4yxaXl9QvH7U+xLQbY4uwAwMr2MBe1u8ZMp9IUfkrhPtN9NyUklmnnZIq9OcrRL2tUrlmpGtpPvnMmFV54VCDUNFEANPe30xs7dD6+ltoe7VQhXjuonmfZ6ApVqXmFUr1OZIyN5Vwx2/9SoMuVcFYMg33B16Ur7xTJlr/RPu5K0anMKB1Eq17b8l0vstG8fBiLFyY8fsz1JWf5Ub/0NAAgi2ZTZaG9EuBXzMUG91ecIDy4YFmwavxuTEIkg2tRRYGfh/i4NwxvZ4TnrjE9KTd8ylJQpkVZ/g2gDUDjOWc3OL47IyLXayQRHOwLzJAGeOePb+c9rrIbPYEw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR08MB6806.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(30864003)(8676002)(83380400001)(2906002)(6486002)(44832011)(36756003)(6862004)(31696002)(8936002)(37006003)(16576012)(19627235002)(66476007)(66556008)(6636002)(316002)(186003)(38100700002)(86362001)(956004)(2616005)(5660300002)(52116002)(26005)(508600001)(53546011)(66946007)(38350700002)(31686004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6102 Original-Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 480ebf19-aee9-47c8-26f5-08d98a681179 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 30dO8XLPfLTWXF1vY9tBmxRpv6AGMiAkrBIYaX4Qw0tWgJlsU+E3Q+8PrMUiu3u5ZXQS/IWbOpLYGL1zeNsq2uMZsds9Gn6HQNIPze6FcTrTTMe7gFj12qnElVMTwZwTe28dvVt1kFwz6Bp5HmIXoEV/e18YMwqbNql43qZ+Kas6mr0s7TuSSt+7VVPbIIRZArXYIzWEHBcPiSZybJsCVgOYdiI/x9y1/d/6yxMOBKMw4aMU7s6C2y/B2omCDFs9nZqf2o3808KMl7DZnGdyS14rr+snHves/nOMlQ4BE8gmzPmKrFa862RIQbNtepkKEkjvsy9dohNs1r8YEm4azM6MIiSDdIF2uwpGH9x/EH7+ntOECSzZp8HRUndj6sCmCmgW4axQp6PWksK9TRvGLoULlxkCO6G0Xy3NxF7K7PaqoWh3dzDUXT1Fg6HYm/YOxVvLo83a8RdgVX3wYy4dspThE9g/pBoZTf/jA9F3iuiJWUZ+9IAi2qZP5f4Gss4sZ5GajO1i4wLjoX1CzmI2HG+hytJBCfucVDmkd94P9fC8R2tWI/CjeE2SykiO+PDf0HGKoS4wGCX+i+w//Cs3G7JHtaOCCqwyc+YoOosBiZPSlhaOJ07vLAEp8PNuTjTg4wjz1sgD7TBA64C97BjUTxD9CsKV8bfhoGLOBITMSi1z992yLUwgrzEvf252vSS5qToJIhVH83r97frmVi+7dm2cqrD/A4ced1scFeKn1rM= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(36860700001)(26005)(81166007)(31696002)(8676002)(336012)(2616005)(956004)(70586007)(86362001)(8936002)(36756003)(31686004)(37006003)(316002)(83380400001)(16576012)(70206006)(186003)(19627235002)(508600001)(356005)(53546011)(2906002)(82310400003)(44832011)(47076005)(6636002)(6862004)(30864003)(5660300002)(6486002)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2021 14:30:02.6919 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69aa6c96-1f3e-4bd0-5e6e-08d98a681d92 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB6057 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-GB Hi Pierre, This patch looks good to me. Reviewed-by: Sami Mujawar Regards, Sami Mujawar On 07/10/2021 04:32 PM, Pierre.Gondois@arm.com wrote: > From: Pierre Gondois > > Add AmlAddLpiState() to generates AML code to add an _LPI state > to an _LPI object created using AmlCreateLpiNode(). > > AmlAddLpiState increments the count of LPI states in the LPI > node by one, and adds the following package: > Package() { > MinResidency, > WorstCaseWakeLatency, > Flags, > ArchFlags, > ResCntFreq, > EnableParentState, > (GenericRegisterDescriptor !=3D NULL) ? // Entry method. I= f a > ResourceTemplate(GenericRegisterDescriptor) : // Register is given= , > Integer, // use it. Use the > // Integer otherwise > ResourceTemplate() { // NULL Residency > Register (SystemMemory, 0, 0, 0, 0) // Counter > }, > ResourceTemplate() { // NULL Usage Counte= r > Register (SystemMemory, 0, 0, 0, 0) > }, > "" // NULL State Name > }, > > Signed-off-by: Pierre Gondois > --- > .../Include/Library/AmlLib/AmlLib.h | 71 +++ > .../Common/AmlLib/CodeGen/AmlCodeGen.c | 459 ++++++++++++++++++ > 2 files changed, 530 insertions(+) > > diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTa= blesPkg/Include/Library/AmlLib/AmlLib.h > index 40c45073d303..4932f6fd9c8b 100644 > --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h > +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h > @@ -716,6 +716,77 @@ AmlCreateLpiNode ( > OUT AML_OBJECT_NODE_HANDLE * NewLpiNode OPTIONAL > ); > > +/** Add an _LPI state to a LPI node created using AmlCreateLpiNode (). > + > + AmlAddLpiState () increments the Count of LPI states in the LPI node b= y one, > + and adds the following package: > + Package() { > + MinResidency, > + WorstCaseWakeLatency, > + Flags, > + ArchFlags, > + ResCntFreq, > + EnableParentState, > + (GenericRegisterDescriptor !=3D NULL) ? // Entry method.= If a > + ResourceTemplate(GenericRegisterDescriptor) : // Register is giv= en, > + Integer, // use it. Use the > + // Integer otherwi= se. > + ResourceTemplate() { // NULL Residency = Counter > + Register (SystemMemory, 0, 0, 0, 0) > + }, > + ResourceTemplate() { // NULL Usage Coun= ter > + Register (SystemMemory, 0, 0, 0, 0) > + }, > + "" // NULL State Name > + }, > + > + Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States". > + > + @ingroup CodeGenApis > + > + @param [in] MinResidency Minimum Residency. > + @param [in] WorstCaseWakeLatency Worst case wake-up latency. > + @param [in] Flags Flags. > + @param [in] ArchFlags Architectural flags. > + @param [in] ResCntFreq Residency Counter Frequency. > + @param [in] EnableParentState Enabled Parent State. > + @param [in] GenericRegisterDescriptor Entry Method. > + If not NULL, use this Register= to > + describe the entry method addr= ess. > + @param [in] Integer Entry Method. > + If GenericRegisterDescriptor i= s NULL, > + take this value. > + @param [in] ResidencyCounterRegister If not NULL, use it to populat= e the > + residency counter register. > + @param [in] UsageCounterRegister If not NULL, use it to populat= e the > + usage counter register. > + @param [in] StateName If not NULL, use it to populat= e the > + state name. > + @param [in] LpiNode Lpi node created with the func= tion > + AmlCreateLpiNode to which the = new LPI > + state is appended. > + > + @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 > +AmlAddLpiState ( > + IN UINT32 MinResidency, > + IN UINT32 WorstCaseWakeLatency, > + IN UINT32 Flags, > + IN UINT32 ArchFlags, > + IN UINT32 ResCntFreq, > + IN UINT32 EnableParentState, > + IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * GenericRegisterDescripto= r, OPTIONAL > + IN UINT64 Integer, = OPTIONAL > + IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * ResidencyCounterRegister= , OPTIONAL > + IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * UsageCounterRegister, = OPTIONAL > + IN CHAR8 * StateName, = OPTIONAL > + IN AML_OBJECT_NODE_HANDLE LpiNode > + ); > + > // DEPRECATED APIS > #ifndef DISABLE_NEW_DEPRECATED_INTERFACES > > diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c = b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c > index 2223e4bcfef9..36c908863983 100644 > --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c > +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c > @@ -12,6 +12,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -1575,3 +1576,461 @@ error_handler: > } > return Status; > } > + > +/** Add an _LPI state to a LPI node created using AmlCreateLpiNode. > + > + AmlAddLpiState increments the Count of LPI states in the LPI node by o= ne, > + and adds the following package: > + Package() { > + MinResidency, > + WorstCaseWakeLatency, > + Flags, > + ArchFlags, > + ResCntFreq, > + EnableParentState, > + (GenericRegisterDescriptor !=3D NULL) ? // Entry method.= If a > + ResourceTemplate(GenericRegisterDescriptor) : // Register is giv= en, > + Integer, // use it. Use the > + // Integer otherwi= se. > + ResourceTemplate() { // NULL Residency = Counter > + Register (SystemMemory, 0, 0, 0, 0) > + }, > + ResourceTemplate() { // NULL Usage Coun= ter > + Register (SystemMemory, 0, 0, 0, 0) > + }, > + "" // NULL State Name > + }, > + > + Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States". > + > + @param [in] MinResidency Minimum Residency. > + @param [in] WorstCaseWakeLatency Worst case wake-up latency. > + @param [in] Flags Flags. > + @param [in] ArchFlags Architectural flags. > + @param [in] ResCntFreq Residency Counter Frequency. > + @param [in] EnableParentState Enabled Parent State. > + @param [in] GenericRegisterDescriptor Entry Method. > + If not NULL, use this Register= to > + describe the entry method addr= ess. > + @param [in] Integer Entry Method. > + If GenericRegisterDescriptor i= s NULL, > + take this value. > + @param [in] ResidencyCounterRegister If not NULL, use it to populat= e the > + residency counter register. > + @param [in] UsageCounterRegister If not NULL, use it to populat= e the > + usage counter register. > + @param [in] StateName If not NULL, use it to populat= e the > + state name. > + @param [in] LpiNode Lpi node created with the func= tion > + AmlCreateLpiNode to which the = new LPI > + state is appended. > + > + @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 > +AmlAddLpiState ( > + IN UINT32 MinResidency, > + IN UINT32 WorstCaseWakeLatency, > + IN UINT32 Flags, > + IN UINT32 ArchFlags, > + IN UINT32 ResCntFreq, > + IN UINT32 EnableParentState, > + IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * GenericRegisterDescripto= r, OPTIONAL > + IN UINT64 Integer, = OPTIONAL > + IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * ResidencyCounterRegister= , OPTIONAL > + IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * UsageCounterRegister, = OPTIONAL > + IN CHAR8 * StateName, = OPTIONAL > + IN AML_OBJECT_NODE_HANDLE LpiNode > + ) > +{ > + EFI_STATUS Status; > + AML_DATA_NODE_HANDLE RdNode; > + AML_OBJECT_NODE_HANDLE PackageNode; > + AML_OBJECT_NODE_HANDLE IntegerNode; > + AML_OBJECT_NODE_HANDLE StringNode; > + AML_OBJECT_NODE_HANDLE NewLpiPackageNode; > + AML_OBJECT_NODE_HANDLE ResourceTemplateNode; > + > + UINT32 Index; > + AML_OBJECT_NODE_HANDLE CountNode; > + UINT64 Count; > + > + if ((LpiNode =3D=3D NULL) = || > + (AmlGetNodeType ((AML_NODE_HANDLE)LpiNode) !=3D EAmlNodeObject) |= | > + (!AmlNodeHasOpCode (LpiNode, AML_NAME_OP, 0))) { > + ASSERT (0); > + return EFI_INVALID_PARAMETER; > + } > + > + RdNode =3D 0; > + StringNode =3D NULL; > + IntegerNode =3D NULL; > + ResourceTemplateNode =3D NULL; > + > + // AmlCreateLpiNode () created a LPI container such as: > + // Name (_LPI, Package ( > + // 0, // Revision > + // 1, // LevelId > + // 0 // Count > + // )) > + // Get the LPI container, a PackageOp object node stored as the 2nd fi= xed > + // argument (i.e. index 1) of LpiNode. > + PackageNode =3D (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( > + LpiNode, > + EAmlParseIndexTerm1 > + ); > + if ((PackageNode =3D=3D NULL) = || > + (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) !=3D EAmlNodeObject= ) || > + (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0))) { > + ASSERT (0); > + return EFI_INVALID_PARAMETER; > + } > + > + CountNode =3D NULL; > + // The third variable argument is the LPI Count node. > + for (Index =3D 0; Index < 3; Index++) { > + CountNode =3D (AML_OBJECT_NODE_HANDLE)AmlGetNextVariableArgument ( > + (AML_NODE_HANDLE)PackageNode, > + (AML_NODE_HANDLE)CountNode > + ); > + if (CountNode =3D=3D NULL) { > + ASSERT (0); > + return EFI_INVALID_PARAMETER; > + } > + } > + > + Status =3D AmlNodeGetIntegerValue (CountNode, &Count); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + return Status; > + } > + Status =3D AmlUpdateInteger (CountNode, Count + 1); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + return Status; > + } > + > + Status =3D AmlCodeGenPackage (&NewLpiPackageNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + return Status; > + } > + > + // MinResidency > + Status =3D AmlCodeGenInteger (MinResidency, &IntegerNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + IntegerNode =3D NULL; > + goto error_handler; > + } > + Status =3D AmlVarListAddTail ( > + (AML_NODE_HANDLE)NewLpiPackageNode, > + (AML_NODE_HANDLE)IntegerNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + IntegerNode =3D NULL; > + > + // WorstCaseWakeLatency > + Status =3D AmlCodeGenInteger (WorstCaseWakeLatency, &IntegerNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + IntegerNode =3D NULL; > + goto error_handler; > + } > + Status =3D AmlVarListAddTail ( > + (AML_NODE_HANDLE)NewLpiPackageNode, > + (AML_NODE_HANDLE)IntegerNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + IntegerNode =3D NULL; > + > + // Flags > + Status =3D AmlCodeGenInteger (Flags, &IntegerNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + IntegerNode =3D NULL; > + goto error_handler; > + } > + Status =3D AmlVarListAddTail ( > + (AML_NODE_HANDLE)NewLpiPackageNode, > + (AML_NODE_HANDLE)IntegerNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + IntegerNode =3D NULL; > + > + // ArchFlags > + Status =3D AmlCodeGenInteger (ArchFlags, &IntegerNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + IntegerNode =3D NULL; > + goto error_handler; > + } > + Status =3D AmlVarListAddTail ( > + (AML_NODE_HANDLE)NewLpiPackageNode, > + (AML_NODE_HANDLE)IntegerNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + IntegerNode =3D NULL; > + > + // ResCntFreq > + Status =3D AmlCodeGenInteger (ResCntFreq, &IntegerNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + IntegerNode =3D NULL; > + goto error_handler; > + } > + Status =3D AmlVarListAddTail ( > + (AML_NODE_HANDLE)NewLpiPackageNode, > + (AML_NODE_HANDLE)IntegerNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + IntegerNode =3D NULL; > + > + // EnableParentState > + Status =3D AmlCodeGenInteger (EnableParentState, &IntegerNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + IntegerNode =3D NULL; > + goto error_handler; > + } > + Status =3D AmlVarListAddTail ( > + (AML_NODE_HANDLE)NewLpiPackageNode, > + (AML_NODE_HANDLE)IntegerNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + IntegerNode =3D NULL; > + > + // Entry Method > + if (GenericRegisterDescriptor !=3D NULL) { > + // Entry Method: As a Register resource data > + Status =3D AmlCodeGenResourceTemplate (&ResourceTemplateNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + ResourceTemplateNode =3D NULL; > + goto error_handler; > + } > + Status =3D AmlCodeGenRdRegister ( > + GenericRegisterDescriptor->AddressSpaceId, > + GenericRegisterDescriptor->RegisterBitWidth, > + GenericRegisterDescriptor->RegisterBitOffset, > + GenericRegisterDescriptor->Address, > + GenericRegisterDescriptor->AccessSize, > + NULL, > + &RdNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + RdNode =3D NULL; > + goto error_handler; > + } > + > + Status =3D AmlAppendRdNode (ResourceTemplateNode, RdNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + RdNode =3D NULL; > + > + Status =3D AmlVarListAddTail ( > + (AML_NODE_HANDLE)NewLpiPackageNode, > + (AML_NODE_HANDLE)ResourceTemplateNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + ResourceTemplateNode =3D NULL; > + } else { > + // Entry Method: As an integer > + Status =3D AmlCodeGenInteger (Integer, &IntegerNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + IntegerNode =3D NULL; > + goto error_handler; > + } > + Status =3D AmlVarListAddTail ( > + (AML_NODE_HANDLE)NewLpiPackageNode, > + (AML_NODE_HANDLE)IntegerNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + IntegerNode =3D NULL; > + } > + > + // Residency Counter Register. > + Status =3D AmlCodeGenResourceTemplate (&ResourceTemplateNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + ResourceTemplateNode =3D NULL; > + goto error_handler; > + } > + if (ResidencyCounterRegister !=3D NULL) { > + Status =3D AmlCodeGenRdRegister ( > + ResidencyCounterRegister->AddressSpaceId, > + ResidencyCounterRegister->RegisterBitWidth, > + ResidencyCounterRegister->RegisterBitOffset, > + ResidencyCounterRegister->Address, > + ResidencyCounterRegister->AccessSize, > + NULL, > + &RdNode > + ); > + } else { > + Status =3D AmlCodeGenRdRegister ( > + EFI_ACPI_6_4_SYSTEM_MEMORY, > + 0, > + 0, > + 0, > + 0, > + NULL, > + &RdNode > + ); > + } > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + RdNode =3D NULL; > + goto error_handler; > + } > + > + Status =3D AmlAppendRdNode (ResourceTemplateNode, RdNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + RdNode =3D NULL; > + > + Status =3D AmlVarListAddTail ( > + (AML_NODE_HANDLE)NewLpiPackageNode, > + (AML_NODE_HANDLE)ResourceTemplateNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + ResourceTemplateNode =3D NULL; > + > + // Usage Counter Register. > + Status =3D AmlCodeGenResourceTemplate (&ResourceTemplateNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + ResourceTemplateNode =3D NULL; > + goto error_handler; > + } > + if (UsageCounterRegister !=3D NULL) { > + Status =3D AmlCodeGenRdRegister ( > + UsageCounterRegister->AddressSpaceId, > + UsageCounterRegister->RegisterBitWidth, > + UsageCounterRegister->RegisterBitOffset, > + UsageCounterRegister->Address, > + UsageCounterRegister->AccessSize, > + NULL, > + &RdNode > + ); > + } else { > + Status =3D AmlCodeGenRdRegister ( > + EFI_ACPI_6_4_SYSTEM_MEMORY, > + 0, > + 0, > + 0, > + 0, > + NULL, > + &RdNode > + ); > + } > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + RdNode =3D NULL; > + goto error_handler; > + } > + > + Status =3D AmlAppendRdNode (ResourceTemplateNode, RdNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + RdNode =3D NULL; > + > + Status =3D AmlVarListAddTail ( > + (AML_NODE_HANDLE)NewLpiPackageNode, > + (AML_NODE_HANDLE)ResourceTemplateNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + ResourceTemplateNode =3D NULL; > + > + // State name. > + if (UsageCounterRegister !=3D NULL) { > + Status =3D AmlCodeGenString (StateName, &StringNode); > + } else { > + Status =3D AmlCodeGenString ("", &StringNode); > + } > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + StringNode =3D NULL; > + goto error_handler; > + } > + Status =3D AmlVarListAddTail ( > + (AML_NODE_HANDLE)NewLpiPackageNode, > + (AML_NODE_HANDLE)StringNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + StringNode =3D NULL; > + > + // Add the new LPI state to the LpiNode. > + Status =3D AmlVarListAddTail ( > + (AML_NODE_HANDLE)PackageNode, > + (AML_NODE_HANDLE)NewLpiPackageNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + > + return Status; > + > +error_handler: > + if (RdNode !=3D NULL) { > + AmlDeleteTree ((AML_NODE_HANDLE)RdNode); > + } > + if (NewLpiPackageNode !=3D NULL) { > + AmlDeleteTree ((AML_NODE_HANDLE)NewLpiPackageNode); > + } > + if (StringNode !=3D NULL) { > + AmlDeleteTree ((AML_NODE_HANDLE)StringNode); > + } > + if (IntegerNode !=3D NULL) { > + AmlDeleteTree ((AML_NODE_HANDLE)IntegerNode); > + } > + if (ResourceTemplateNode !=3D NULL) { > + AmlDeleteTree ((AML_NODE_HANDLE)ResourceTemplateNode); > + } > + > + return Status; > +} IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you.