From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.102]) by mx.groups.io with SMTP id smtpd.web10.4472.1630676103468369267 for ; Fri, 03 Sep 2021 06:35:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=sUf4jLdx; spf=pass (domain: os.amperecomputing.com, ip: 40.107.237.102, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E9IM+TkH1Fw+PhV9tTONm9RXlywL2P9TFXzWixYIDcXVnBTZcf3Si6NJhCZ9jRMfPVaosxPCLIsP7yTInGxhThlVoeznkrJChnho9lxWaXBIT/v7WfVXFYcJVyLL2qPdaIuy4PUWniJ1Yqwls5CYPyeuvPrDtsIGw4eV1z5J52bZsPnKgT0/I+jOMsPXeCC4HtGC41UN3hY0QU/+2+LVcExkCdnECGfuXlJgQIRJKqxbJa2BWYzABT/YTJpqNmVg6n1iEAEKvRXOclMmDpT4JmUyjRJr60UZT6KbNR+ao+tIJcWea348GI0IutPVdoXZac/9l+aLUC1//jcv5zY67g== 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; bh=WBaZEzM/R/ueLNKSj/ha6nQS35SyAG3avuiBQ/4uy8g=; b=G07on4kknKg6AUvpP+3xuahlRdbibQaiv804biWivLeZdnr5TUD8J61C0ehYhhPC2DmDW+Wv1AcLD5RR/x3oKqidm+RRkdI7D3F/757owcxu2wPgNT1tHEIZs9nd2DY4fYROVF/Mcbn2mh+Hf3fTigmqFJ26Gxdfz4u0+qiM2ayajjt8pdMVpVNoN9ZCgeO1SVzh2glUwp+bKGcYsNjAje5cP0niRH3WtXp++V5A+iYaEaawLB6CSk0OVAv/u0p4iEABdZ/VOsyEG/vSuX/Nf5WkAeEjeNRkaed5RbKh0pLZDOhVXkPPIRqQqkotjTdzKuNLEEX2Vqpx+iEZ5mSO2w== 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=WBaZEzM/R/ueLNKSj/ha6nQS35SyAG3avuiBQ/4uy8g=; b=sUf4jLdxsuCRPhMPNCOEWRVbiHOn3s2CNrDmBNNIkwXGFa6bimmoBPIswzk7Un2nWbym+hQ2fNSZeB7yANIEbvY8QV7kg9CykD1kyfhUvyggbwDYqr+PUDZwT6cJ3HYitsibKyAag5hDrworElI1SPVvRg+BXVOvRTmZ3coHdTs= Authentication-Results: hpe.com; dkim=none (message not signed) header.d=none;hpe.com; dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) by DM6PR01MB4652.prod.exchangelabs.com (2603:10b6:5:63::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Fri, 3 Sep 2021 13:35:00 +0000 Received: from DM6PR01MB5849.prod.exchangelabs.com ([fe80::8eb:704f:2ba7:9bc3]) by DM6PR01MB5849.prod.exchangelabs.com ([fe80::8eb:704f:2ba7:9bc3%4]) with mapi id 15.20.4478.022; Fri, 3 Sep 2021 13:35:00 +0000 From: "Nhi Pham" Subject: Re: [PATCH 1/1] EmbeddedPkg/AcpiLib: Add more helper functions To: "Chang, Abner (HPS SW/FW Technologist)" , "devel@edk2.groups.io" Cc: "patches@amperecomputing.com" , Leif Lindholm , Ard Biesheuvel , "Schaefer, Daniel" References: <20210817132413.7621-1-nhi@os.amperecomputing.com> Message-ID: <7663051e-c5c1-2a71-f3e9-6bff63f95dc7@os.amperecomputing.com> Date: Fri, 3 Sep 2021 20:34:40 +0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 In-Reply-To: X-ClientProxiedBy: HK2PR04CA0047.apcprd04.prod.outlook.com (2603:1096:202:14::15) To DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 Received: from [192.168.1.7] (116.110.42.117) by HK2PR04CA0047.apcprd04.prod.outlook.com (2603:1096:202:14::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 3 Sep 2021 13:34:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18356a19-9129-4cc2-35ed-08d96edfa074 X-MS-TrafficTypeDiagnostic: DM6PR01MB4652: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OHhAH3Ttv8xWX/HRPnyBPKmom8hw3Sg5SZWkNPtjW8gAFX2viJJiefDMVYpRM1bYEDNObHhlp4PbjKdiwqqZDU3aQH7x1CvczeEzWl/8UkPWfx2xBmtpPgC240z58OA9LgFX9r9cyej5meThTeVmMOMPTOIWhq0XEq0/qZPYIi4FT0mTTFfpfwzsknPZI/IjGIsT9D7dbFIY6Th0Has5IzdYAconIUUzKMkd4XnxAlKACkx7ffSZCw0l5ZGIjhc4jmH3aQAYEYodVHqTo/9H2wt0YrmsWT01S719vTxVne0QzRc3EfC1J5fXck5ySJzV6MJRTU9KHaBXEjCSNil7SBU7h+7EsS/9ub+6640lj1KHqAzjj8yWYUFbhQ3lWa1P8M/L+iiuVYbVxkuuJj5iHvrQD4SWenKxhTHIethmYX5Znh327DYemMSn697Uh/wvy5P9gT6GkkbQGwUQz9xgsZLfebc6RgBgORx36hiKWF1fOlUlO2xvVWtomId6HnSGvdQu34bMaafcEWtQ/LZ8d9KUcAVV3fLW8W/GRv/n4CEtbjRNJ50aIk8lCTAyfiKbK6tTbQHprhObXW9mSfwK1k5yu6UiAy2Rj/N/BShmeNP0BRY7H2M7pcwzSy0GA+y5CuEDOvAk14LI5HOPUG0jQfmtMuZSB3Y0j5n0S1Y6QV+OBabaWlsX8E3eydXA8KkO2wDUKUeGv6u9xjfNsziV9iRlrgaGlLkhbjte7T/JQ24tjViir0W9EiBQYIrS8HyUaLM4V36OrEwkkgCN72ThSg== 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)(366004)(4326008)(31686004)(5660300002)(8936002)(508600001)(6666004)(186003)(53546011)(54906003)(110136005)(2616005)(19627235002)(16576012)(316002)(296002)(30864003)(52116002)(2906002)(31696002)(38350700002)(86362001)(8676002)(956004)(66946007)(26005)(66556008)(6486002)(66476007)(38100700002)(83380400001)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?K0xnY2srMzd0S0h6a29lNSt4M1Vsa0VoVklhaHQ2ekpRRFI3QVdaZUNxVWZI?= =?utf-8?B?ZG9RakxvKyt0YnV3LzlIUERnWlg2dGltR3cycjl1M0R0M2t3RGtPUVhuSUgr?= =?utf-8?B?MStmSnhxYUNZcFZkVUxKYkNnMHRzcnJ4empmazNaVGx5eUt4WmY5bjFMMEpH?= =?utf-8?B?cVRZRTBzaW10clpZQk9RU3N3MmhDeXhwU1NPV2Y2em1sakh3QUNEMzFaOThO?= =?utf-8?B?aUtNWVUvWTFORkI5bzdqSUd6SkpISS96MDdNSjhRUllFVTBTdklQMzBBVmFq?= =?utf-8?B?R0pYNUVGTU1EZUg1eDRtQ2NJT08xLzl2a1Q3dE5zMzNYcTQ1Q0o1dEcxaXRj?= =?utf-8?B?YVJPeGFUbDZtUGdWTHNycmoyS2I2M0J1ZU5YcERVNGRXMG1EcG9HQlF2Zm5H?= =?utf-8?B?Y0tMaHJja3c0cDdBK0ZIVFB2K3kwUTRLWkpBT2lLSTA5R0hTM0RWR2k2dFRL?= =?utf-8?B?M0xCeEt5bU1lQTZtcGQrKzg3c1ExOXNMMksrR0ZZbFI4SVdCQWM3alV5dGlH?= =?utf-8?B?anVFQmRQeS9mNlEya1lLM3hXME1qb3RaVVJlNmhlaU9RbjVVd0lnSkV0dDdW?= =?utf-8?B?Tk1mWE9kYlVzQnlJTThkSmVTMnVmQVNnbnNWYXliNS9oOHhYSVdFRGE5TzZq?= =?utf-8?B?TVdFVnVhVUthcWhIazlZTzJUWG5TTThMcXJjTENOdGZ2SXVHS2V0eHpRUUIx?= =?utf-8?B?WUpwU09YSExOSHRrWmVBbG9pUmRjdWNOK1ArN0p3R01qb0o2V21za0l3c0E5?= =?utf-8?B?QUJiS295SnFYTThabGdaMzJNOE5weGFmSzdBSmllclNNRi8xSmdxb2kyTEJS?= =?utf-8?B?TWVWMFM5b3g2OUd6d0xOZld0QjIxbVRWNUxLcXVmSkVCaUYvMXRXMFZyZHlC?= =?utf-8?B?L3hQeW1GcmtzSGVkelRpWWpEZ3drd0xWcHVTT01BbVlNTEhMOWRhdmJaOUdu?= =?utf-8?B?WU5HcGxSZStpcnkvU1NyVXhJaHJZd3hNc3dGQWozTTd0Wk9HR0lXaWJrSEdZ?= =?utf-8?B?ZnpxT1dhSjVEODVjZklzbXVCWFd0OUFVWU5YYzZBUE80RXN3ekJwSGErSzZB?= =?utf-8?B?NHlRaEtvUjlBL3Z5NE1UeFB2aGFvOWNWNkZybzlqOEJYSW4xZDFzbHptUHpY?= =?utf-8?B?djhJejBBeHBCRDh5SVBiN2dIWGkzTkNjeEZXSy9oemd0YXdkSEUzUlptVWRI?= =?utf-8?B?cm9KaDMxdTYxaDIrMWNyQUZIUUpUeTRkVWlwYmVmTGxmaHNkZ3FIWUNHV3lK?= =?utf-8?B?bEpiMW5VbGkwdlJFQnJSUWRFLzM3b01WVGpMTC80ek40b2llaU5oTlM0WU1H?= =?utf-8?B?QmhtVjNIWCs2MGNrRWhFZUtrMml6Nm5BUnBkVWYxRXlMenVrVm9zUnIyUHU2?= =?utf-8?B?a0FyanlTVUdHdXBmNVBhb1Y2RVVWMnQwMmpqYmhWS3g1cUxoU2NnK1lpcGky?= =?utf-8?B?bE9ocEk1N2t2eXZvaVM1N1ZSNlhrMUd4bFB2OGNQWllOUkhmZHIzcDRxTFc5?= =?utf-8?B?cUlHMzdmbUg4L1dRQTZXMEthNmV2ZXJxdXd5VmQ0cGtqVjYxeWxlc3FJTzUv?= =?utf-8?B?aVdLWDlrTTVQQTZ5ZzlISUJBdzRMN3FMSGpkeXRiZ1dON2gybXdacDZ2SVNR?= =?utf-8?B?Ly83bHJQQ1Q3NUdqdWVhVXBpNXEwZzdMTEJTSThwN1NqUVR5bGZJYnZVcFdl?= =?utf-8?B?a3QwNmtQUStBNjJSTS92akpqQmVOSHdMUUhXUEVUYWdCbCtwbUptMlJ1Q2tm?= =?utf-8?Q?keuCWgAxx0DpopZVfqenNr2h7IiWCTfBkbLMzCI?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18356a19-9129-4cc2-35ed-08d96edfa074 X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5849.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 13:35:00.1326 (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: gFPowRU+tZIenlhbKMfWtdVtRFJj6wj/t6hY3V8maeGuf05qukQwlBMwbNorQQbgJMQ8rogfkPzMPhiw9uJYwAlYyFOjnHlekfPKrV8gli4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB4652 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Hi Abner, Thank you so much for reviewing this patch. On 22/08/2021 21:42, Chang, Abner (HPS SW/FW Technologist) wrote: > Hi Pham, > First at all, you have to update the copyright. Other comments are in below, Will update. >> -----Original Message----- >> From: Nhi Pham [mailto:nhi@os.amperecomputing.com] >> Sent: Tuesday, August 17, 2021 9:24 PM >> To:devel@edk2.groups.io >> Cc:patches@amperecomputing.com; Nhi Pham >> ; Leif Lindholm; Ard >> Biesheuvel; Chang, Abner (HPS SW/FW >> Technologist); Schaefer, Daniel >> >> Subject: [PATCH 1/1] EmbeddedPkg/AcpiLib: Add more helper functions >> >> This adds more helper functions that assist in calculating the checksum, >> locating an ACPI table by signature, and updating an AML integer object. >> >> Cc: Leif Lindholm >> Cc: Ard Biesheuvel >> Cc: Abner Chang >> Cc: Daniel Schaefer >> Signed-off-by: Nhi Pham >> --- >> EmbeddedPkg/Library/AcpiLib/AcpiLib.inf | 2 + >> EmbeddedPkg/Include/Library/AcpiLib.h | 68 ++++++++ >> EmbeddedPkg/Library/AcpiLib/AcpiLib.c | 183 ++++++++++++++++++++ >> 3 files changed, 253 insertions(+) >> >> diff --git a/EmbeddedPkg/Library/AcpiLib/AcpiLib.inf >> b/EmbeddedPkg/Library/AcpiLib/AcpiLib.inf >> index 538fe09cca29..154cb1eebc80 100644 >> --- a/EmbeddedPkg/Library/AcpiLib/AcpiLib.inf >> +++ b/EmbeddedPkg/Library/AcpiLib/AcpiLib.inf >> @@ -23,6 +23,8 @@ [Packages] >> EmbeddedPkg/EmbeddedPkg.dec >> >> [LibraryClasses] >> + BaseLib >> + BaseMemoryLib >> DebugLib >> UefiBootServicesTableLib >> >> diff --git a/EmbeddedPkg/Include/Library/AcpiLib.h >> b/EmbeddedPkg/Include/Library/AcpiLib.h >> index c142446d9d59..cdb6ea410c54 100644 >> --- a/EmbeddedPkg/Include/Library/AcpiLib.h >> +++ b/EmbeddedPkg/Include/Library/AcpiLib.h >> @@ -13,6 +13,7 @@ >> #include >> >> #include >> +#include >> >> // >> // Macros for the Generic Address Space >> @@ -128,4 +129,71 @@ LocateAndInstallAcpiFromFv ( >> IN CONST EFI_GUID* AcpiFile >> ); >> >> +/** >> + This function calculates and updates an UINT8 checksum. >> + >> + @param Buffer Pointer to buffer to checksum >> + @param Size Number of bytes to checksum >> + >> + @retval EFI_SUCCESS The function completed successfully. >> + @retval EFI_INVALID_PARAMETER Invalid parameter. >> + >> +**/ >> +EFI_STATUS >> +EFIAPI >> +AcpiUpdateChecksum ( >> + IN UINT8 *Buffer, >> + IN UINTN Size >> + ); >> + >> +/** >> + This function uses the ACPI SDT protocol to locate an ACPI table >> + with a given signature that only have a single instance. >> + >> + Caution: This function does not act correctly with tables having >> + more than 2 instances like SSDT table. >> + >> + @param AcpiTableSdtProtocol Pointer to ACPI SDT protocol. >> + @param TableSignature ACPI table signature. >> + @param Table Pointer to the table. >> + @param TableKey Pointer to the table key. >> + >> + @return EFI_SUCCESS The function completed successfully. >> + @return EFI_INVALID_PARAMETER At least one of parameters is invalid. >> + @retval EFI_NOT_FOUND The requested index is too large and a >> table was not found. >> + >> +**/ >> +EFI_STATUS >> +EFIAPI >> +AcpiLocateTableBySignature ( >> + IN EFI_ACPI_SDT_PROTOCOL *AcpiSdtProtocol, >> + IN UINT32 TableSignature, >> + OUT EFI_ACPI_DESCRIPTION_HEADER **Table, >> + OUT UINTN *TableKey >> + ); >> + >> +/** >> + This function updates the integer value of an AML Object. >> + >> + @param AcpiTableSdtProtocol Pointer to ACPI SDT protocol. >> + @param TableHandle Points to the table representing the starting >> point >> + for the object path search. >> + @param AsciiObjectPath Pointer to the ACPI path of the object being >> updated. >> + @param Value New value to write to the object. >> + >> + @return EFI_SUCCESS The function completed successfully. >> + @return EFI_INVALID_PARAMETER At least one of parameters is invalid >> or the data type >> + of the ACPI object is not an integer value. >> + @retval EFI_NOT_FOUND The object is not found with the given path. >> + >> +**/ >> +EFI_STATUS >> +EFIAPI >> +AcpiAmlObjectUpdateInteger ( >> + IN EFI_ACPI_SDT_PROTOCOL *AcpiSdtProtocol, >> + IN EFI_ACPI_HANDLE TableHandle, >> + IN CHAR8 *AsciiObjectPath, >> + IN UINTN Value >> + ); >> + >> #endif // __ACPI_LIB_H__ >> diff --git a/EmbeddedPkg/Library/AcpiLib/AcpiLib.c >> b/EmbeddedPkg/Library/AcpiLib/AcpiLib.c >> index ff7d678433d5..e07919ae323f 100644 >> --- a/EmbeddedPkg/Library/AcpiLib/AcpiLib.c >> +++ b/EmbeddedPkg/Library/AcpiLib/AcpiLib.c >> @@ -9,9 +9,12 @@ >> #include >> >> #include >> +#include >> +#include >> #include >> #include >> >> +#include >> #include >> #include >> >> @@ -170,3 +173,183 @@ LocateAndInstallAcpiFromFv ( >> { >> return LocateAndInstallAcpiFromFvConditional (AcpiFile, NULL); >> } >> + >> +/** >> + This function calculates and updates an UINT8 checksum. >> + >> + @param Buffer Pointer to buffer to checksum >> + @param Size Number of bytes to checksum >> + >> + @retval EFI_SUCCESS The function completed successfully. >> + @retval EFI_INVALID_PARAMETER Invalid parameter. >> + >> +**/ >> +EFI_STATUS >> +EFIAPI >> +AcpiUpdateChecksum ( >> + IN UINT8 *Buffer, >> + IN UINTN Size >> + ) >> +{ >> + UINTN ChecksumOffset; >> + >> + if (Buffer == NULL || Size == 0) { >> + return EFI_INVALID_PARAMETER; >> + } >> + >> + ChecksumOffset = OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, >> Checksum); >> + >> + // >> + // Set checksum to 0 first >> + // >> + Buffer[ChecksumOffset] = 0; >> + >> + // >> + // Update checksum value >> + // >> + Buffer[ChecksumOffset] = CalculateCheckSum8 (Buffer, Size); >> + >> + return EFI_SUCCESS; >> +} >> + >> +/** >> + This function uses the ACPI SDT protocol to locate an ACPI table >> + with a given signature that only have a single instance. >> + >> + Caution: This function does not act correctly with tables having >> + more than 2 instances like SSDT table. > Instead of having this caution, why not returning an array of table pointers and TableKeys, also another new parameter indicates how many tables are matched to the signature? > How to use the array depends on the caller. Thank you for a good idea. So, I was intended to add a new EFI_ACPI_TABLE_WITH_KEY structure your suggestion. But it looks more complicated in consuming. Only the SSDT table is happy with that. Well, now my idea is that, to remove the caution, I want to add one more IN/OUT parameter "*Index", which is the ACPI table index where to search, to this API function. So, consumers can rely on this index to search continuously the tables if there are multiple ACPI table instances installed like SSDT. Does it look good to you? >> + >> + @param AcpiTableSdtProtocol Pointer to ACPI SDT protocol. >> + @param TableSignature ACPI table signature. >> + @param Table Pointer to the table. >> + @param TableKey Pointer to the table key. >> + >> + @return EFI_SUCCESS The function completed successfully. >> + @return EFI_INVALID_PARAMETER At least one of parameters is invalid. >> + @retval EFI_NOT_FOUND The requested index is too large and a >> table was not found. >> + >> +**/ >> +EFI_STATUS >> +EFIAPI >> +AcpiLocateTableBySignature ( >> + IN EFI_ACPI_SDT_PROTOCOL *AcpiSdtProtocol, >> + IN UINT32 TableSignature, >> + OUT EFI_ACPI_DESCRIPTION_HEADER **Table, >> + OUT UINTN *TableKey >> + ) >> +{ >> + EFI_STATUS Status; >> + EFI_ACPI_SDT_HEADER *TempTable; >> + EFI_ACPI_TABLE_VERSION TableVersion; >> + UINTN TableIndex; >> + >> + if (AcpiSdtProtocol == NULL >> + || Table == NULL >> + || TableKey == NULL) { >> + return EFI_INVALID_PARAMETER; >> + } >> + >> + Status = EFI_SUCCESS; >> + >> + // >> + // Search for ACPI Table with matching signature >> + // >> + TableVersion = 0; >> + TableIndex = 0; >> + while (!EFI_ERROR (Status)) { >> + Status = AcpiSdtProtocol->GetAcpiTable ( >> + TableIndex, >> + &TempTable, >> + &TableVersion, >> + TableKey >> + ); >> + if (!EFI_ERROR (Status)) { >> + TableIndex++; >> + >> + if (((EFI_ACPI_DESCRIPTION_HEADER *)TempTable)->Signature == >> TableSignature) { >> + *Table = (EFI_ACPI_DESCRIPTION_HEADER *)TempTable; >> + break; >> + } >> + } >> + } >> + >> + return Status; >> +} >> + >> +/** >> + This function updates the integer value of an AML Object. >> + >> + @param AcpiTableSdtProtocol Pointer to ACPI SDT protocol. >> + @param TableHandle Points to the table representing the starting >> point >> + for the object path search. >> + @param AsciiObjectPath Pointer to the ACPI path of the object being >> updated. >> + @param Value New value to write to the object. >> + >> + @return EFI_SUCCESS The function completed successfully. >> + @return EFI_INVALID_PARAMETER At least one of parameters is invalid >> or the data type >> + of the ACPI object is not an integer value. >> + @retval EFI_NOT_FOUND The object is not found with the given path. >> + >> +**/ >> +EFI_STATUS >> +EFIAPI >> +AcpiAmlObjectUpdateInteger ( >> + IN EFI_ACPI_SDT_PROTOCOL *AcpiSdtProtocol, >> + IN EFI_ACPI_HANDLE TableHandle, >> + IN CHAR8 *AsciiObjectPath, >> + IN UINTN Value >> + ) >> +{ >> + EFI_STATUS Status; >> + EFI_ACPI_HANDLE ObjectHandle; >> + EFI_ACPI_DATA_TYPE DataType; >> + UINT8 *Buffer; >> + UINTN BufferSize; >> + >> + if (AcpiSdtProtocol == NULL || AsciiObjectPath == NULL) { >> + return EFI_INVALID_PARAMETER; >> + } >> + >> + Status = AcpiSdtProtocol->FindPath (TableHandle, AsciiObjectPath, >> &ObjectHandle); >> + if (EFI_ERROR (Status)) { >> + return Status; >> + } >> + >> + Status = AcpiSdtProtocol->GetOption (ObjectHandle, 0, &DataType, (VOID > We can use AML_OP_PARSE_INDEX_GET_OPCODE instead of '0', which is more readable. I find the AML_OP_PARSE_INDEX_GET_OPCODE is defined for private use in the MdeModulePkg/Universal/Acpi/AcpiTableDxe module. Do we need to make a copy for usage in the AcpiLib? >> *)&Buffer, &BufferSize); >> + if (EFI_ERROR (Status)) { >> + return Status; >> + } >> + >> + if (Buffer[0] != AML_NAME_OP) { >> + return EFI_NOT_FOUND; >> + } >> + >> + switch (Buffer[5]) { > After getting the opcode from ACPI handle, the BufferSize suppose is in value of 1 or 2 if I interpret the code correctly. You can access to Buffer[5] because the buffer points the AML node. > Below can be executed correctly but seems to me not quite proper. Furthermore, can we leverage AcpiSdtProtocol ->SetOpion for updating value instead of having below code block? Yes, thank you. Let me update it to use the SDT->SetOption function for updating the data object in an AML name object. Best regards, Nhi > > Abner > >> + case AML_ZERO_OP: >> + case AML_ONE_OP: >> + Buffer[5] = (UINT8)Value; >> + break; >> + >> + case AML_BYTE_PREFIX: >> + Buffer[6] = (UINT8)Value; >> + break; >> + >> + case AML_WORD_PREFIX: >> + CopyMem ((VOID *)&Buffer[6], (VOID *)&Buffer, sizeof (UINT16)); >> + break; >> + >> + case AML_DWORD_PREFIX: >> + CopyMem ((VOID *)&Buffer[6], (VOID *)&Buffer, sizeof (UINT32)); >> + break; >> + >> + case AML_QWORD_PREFIX: >> + CopyMem ((VOID *)&Buffer[6], (VOID *)&Buffer, sizeof (UINT64)); >> + break; >> + >> + default: >> + // The data type of the ACPI object is not an integer value. >> + return EFI_INVALID_PARAMETER; >> + } >> + >> + return Status; >> +} >> -- >> 2.17.1