From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.103]) by mx.groups.io with SMTP id smtpd.web08.14763.1631120566149338107 for ; Wed, 08 Sep 2021 10:02:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=RPRDMbxE; spf=pass (domain: os.amperecomputing.com, ip: 40.107.220.103, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Iwv9PP6AhBkLktu+5z59ov6I0xUevTHqn+/k+9BVW0XsGsHQ1tOIbgPYVd/DKVfFvLiCJWZBb9gjhmG5FfjA+m4To9jmnggkzxPqBDi0I05RG64UCLdbctraalLyNAcY08SeGV0bUxrYyWRGsM4hxQZU5qMDtY29c3KEIZJm4ui7niRL/o1K1+uD5Yiji/pw2WrOEtLU0EP6z3a799HAAgXYODXa8JTCkCxmmlb7I5ImGk9u3PO7NvG14NsR8C6jIS/DERMoY3Pi2cN1XiG6wilV6GJ1WrlKF5A3nTLnYJl/rrRP2delv5aMW7JyF7W0KCh1o0nn4HZTjkx7o708OA== 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=g1dE7rtc07AN/+VfmsIiw57V2KnNjpP20pm/G1Y8uXo=; b=TSqbVYRfV2jcFhbc1hc1UUAVjlHmXnPG/gdMPNDn4BjLeIQXIoNJR5hMUihQEHeBHrO7kDR2MUNDAvOu4csl8dT+7f+T4PnOoY8b+XH7nqRVAgc5cdITuXS5EO/GoWjH3DMWwEM/zDp6PGckc6O0wmJv8Mfq6NFxJ0nCLzANuNT2t/HxDOu2npdlqS2w2WRaSUHjGftjwaQB7SXJjYPiz6/w1HhUz1CeZPglZ4Mi1EfL0olt5j14ou8XToxqwyHL+XtgBJlpVET7zqK3y0DKZ7jmhRYf5WLwo4jBFhRymG/qSwBg0JgYDdUZUC/83J6qoQKZAm3qJ5pOWHXcKrjS2A== 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=g1dE7rtc07AN/+VfmsIiw57V2KnNjpP20pm/G1Y8uXo=; b=RPRDMbxEpAYfioZCJX9cpOtWFlw3z7kVAcbh7df5sHqE/ezzQeS4dI2KZ5Sji9SDnlHpYjso5ByNb1zkmlf4Xw/jXHr6dJeZcrb4lAxGN1NtlzjFm/AM+xEVBZQEWsackdJvqUuxVfBlVglVlgmVg6p602fQniKZD83IYlUmg/Q= 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 DM8PR01MB6965.prod.exchangelabs.com (2603:10b6:8:16::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.21; Wed, 8 Sep 2021 17:02:43 +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.4500.015; Wed, 8 Sep 2021 17:02:43 +0000 Subject: Re: [edk2-devel] [PATCH v2 1/1] EmbeddedPkg/AcpiLib: Add more helper functions To: "Chang, Abner (HPS SW/FW Technologist)" Cc: "devel@edk2.groups.io" , "patches@amperecomputing.com" , Leif Lindholm , Ard Biesheuvel , "Schaefer, Daniel" References: <20210903154423.32619-1-nhi@os.amperecomputing.com> From: "Nhi Pham" Message-ID: <4cc27fb8-6640-f9f8-374d-4424c789a98c@os.amperecomputing.com> Date: Thu, 9 Sep 2021 00:02:36 +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: HK2PR02CA0131.apcprd02.prod.outlook.com (2603:1096:202:16::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 HK2PR02CA0131.apcprd02.prod.outlook.com (2603:1096:202:16::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16 via Frontend Transport; Wed, 8 Sep 2021 17:02:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d3e61656-05ac-496c-d75b-08d972ea7969 X-MS-TrafficTypeDiagnostic: DM8PR01MB6965: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 02E5jXGdafML7gaouxolbrFQbwofiPBlm7LdVKJ52yLZSGdTf2tzVo3qT1yGkcW6mvhz5uo9W3mW3fPFY9HoGqeXIV9ksRWvATCeX0HO54ff01rCzZPEt90KbslUrIIElLIz8TaJ+u85rYBfMrUE/+0dL9tWzCG/6RmGG8cOQupq1ZAwxk4tOugQhkv4T/FQng7CHdtNfl25ssdHgjM7kfhBL1OK9wMEZY2fT88TYTJS39yZzCkyrg+fdUhr1Flm/7QIXICkspU5QX84auW9JoIKsRnUyjUQDbCX6+UuEZLjHUnHHOOQcEyVOF6WMtjZXnjMMI0hnL6pgGZoscZ1HqCUwhFcKY3ceiWyv02d1JA6I8bpCY4Eb0D33ftMEUNwzpDe0nWSKfrQvmdjMXRQtE7fTorMYBGX+gJXHpdaQoc2MTqZvSJcsAGDhISR825H0lLQ5nS9QvLmtiI/ItgYWevX+XVZbzCiuAkHwavNO6+8t3tFkPHCs7jkgNB9vWlYOr2QLWvSBUIxpHFGJ61DOY7wdsd4SwBO3tpJ34RDaMjYZJyJAmbHPuM363vnCAnwtcDqH2RqOJzaOXLoyo3psnoOFrvoMFW6v959UlIirKNJVrWGyVRv6WFS6bYGbSfnEKfMgQeTK6bP7Wp4HknrljvGPBXB/j4FxiAwdxyDukvOAy5bLyUEZ68vP3ZMFhkICPmBLGGHRxo08vqlg3BgCICVru2ulJKlsoBtdJLRKGhyHm/01hqd3FreVtWCoiQgm+Ox/4MZXw+0UT/Ih6yo0HlFtHE+Gt6QeCVGb3ei2uK8SOE5uUeL/MlDFLpB+6XWDrRZajRZmpH984c7J+Ii3KJBlKCY8DV/XQC6sdSvXMs= 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)(346002)(376002)(396003)(39850400004)(136003)(366004)(316002)(53546011)(296002)(8676002)(83380400001)(66556008)(966005)(66946007)(52116002)(19627235002)(956004)(31686004)(38350700002)(6916009)(16576012)(4326008)(478600001)(6666004)(54906003)(2906002)(26005)(2616005)(86362001)(8936002)(5660300002)(31696002)(30864003)(66476007)(6486002)(38100700002)(186003)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eERZNis1b001MmZYSGFCQ0RwK0pJTjVUeFlyMlM2TEk4SGFZVXZlL1VBblow?= =?utf-8?B?eE9nQ0Z1QUEvck52QlQ4dHA4TlhkOFNFbFpobDZkQ0dKMlJPaTlQRGdWK3ZX?= =?utf-8?B?ZmF6NWZuTWNuck5IRllROHR5S2puVnRpUCtqYktwNTFhYVQ0MDBaeElMdm9F?= =?utf-8?B?eWlTandJN0IzL25iWi9rT0JPRXFCd3RSZU5kTXJvTCtlc0IxazZaYnAxQnlW?= =?utf-8?B?c1NubGsxNklaUkROUjA2L1R0UkR4K1paY1RWNEc1K1pmRHlJVTNIQmRKOHUw?= =?utf-8?B?OVBIOVFWUDZ5OExEOUd6SUZlbngvQ0E1dU5HaWdBYWRtSDdvemw2OG1LcExr?= =?utf-8?B?Z2ZXbVhiNGxMWEFVNmNxNlNJNnJTZFlHeGFMSHYrWERsVEROOHRMVW1WdzZ2?= =?utf-8?B?b1BvWUtocmtYR2FjVkRqL1lMWG1TR0RpelkvNVpaSElQdXpTSklKSWcyL05R?= =?utf-8?B?MWtKWktTbXQ1TmxqbDVJV25JNmtybkVVOWIvSGYyeEJaVkV5WGxIT3pKN2Ix?= =?utf-8?B?Nk5mLzloM3grektjTURyZVRrWEJFTzd4Y1hTY2I5elg0clFYREF5WFhsb1hm?= =?utf-8?B?UFdVRkJpMDJ6eEFLVTE0UEw5MURXa2pXQTMzOVlxWk9iWFV1MXoxT1ZRdUFq?= =?utf-8?B?ZkJmbVE0ZDl2dkxzeTFiNVN4MUlLZHZsQWpkMHY1MnMyNU1PTDd5djR1V25U?= =?utf-8?B?Uk5nd2NNTlJsR1VNWDJkQUZaanNVaXM0ZXk0cTZiN3VkYUd0OWZSMmdOb0c5?= =?utf-8?B?Nkk1eE5QTzZNSEZ5RHdOY2h1L01PNWZjM3lCTEQrdm9RRGlBUUgyb1hubCtl?= =?utf-8?B?NVY1OFBiekZDUkxPMVZIQUpUQ3JLN1RHRldvWlJ1QzNnYkZqc1pyMjg4TEU2?= =?utf-8?B?QTUyTkp2MGxndi9EMDV6MVB5VVJGT0F3MksydEdaWHNCcEVtMUsrbThQZTlr?= =?utf-8?B?MjdoUGw2eWpnVjh3UTRLYU5WQ1BHZ215MkNXSzFwVXNUaFE0NUdzQXpKcUVr?= =?utf-8?B?NEE4MmRLYVJEeC9sb3ZXMlZ3VGM0aG96cENnR2JjMEdsWmdZa1l4Qk9BQ2xI?= =?utf-8?B?UEtKcEVDRUtoaXBqampvNmlNN1MrT2dRaGpNWXVZbSsxVGFNR3JROVY1UXhr?= =?utf-8?B?YVRvTkxZM3hZeVJEeGJ1bGZERjRKc2R4bG9Rc1VFeEt3Q0JmbElCRDVkc3Ay?= =?utf-8?B?eVNaMCt1WExuMm5lcDZ5bnI1MTQxK1RTdmRjQWpBd1VlTFdnc0UxZUpETFBU?= =?utf-8?B?NVlQNEgrYzJNNG1obGtYWEdzVEp6M2lIRzlvcW9ocU9RYVRiSnhQS2pLY2ZL?= =?utf-8?B?ZUR5eDhid0t0cGRWQ3NRcURPMHVRR3p6ZHdCeU90V0dIcEtRNEh1WGNwbWVT?= =?utf-8?B?L3dRcmJyS3dIaFlWR0FqL2Vmd0x0MVJKeTBYSk94aDRuYnc5eE83cXVSbDFD?= =?utf-8?B?U1dKakpWNGhtQ1hidXduM2libk5XeHluSXBicW5KL0RxLzQ2TTA2bEhTOG1p?= =?utf-8?B?cnlFMXc1ZFo2V0RmOHhlMzJQZEpmNWFTc3dPemRzYjRJWTNYV1d6cmp2Wktq?= =?utf-8?B?d3ppK3ZaUGtXODNLNWQvVTE3RGxmVkYyamsrdW9weDlzbXMrUFV3U2NjV1Rm?= =?utf-8?B?SG01V1A1V0VOUDNkbk9pSVQ4Q2JzcENVc1h2bENLK3VRaXdIc1RibUhueUp4?= =?utf-8?B?Rnd6MUMvYlBTb1dWNG1JcUxQb1RaS25obzdmWUdyQ2lVa1BiQW1ESkFlTm1O?= =?utf-8?Q?LKBHJO+qAFNMFnw5gmpIOjoIXBYAwLgc8Duvklu?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3e61656-05ac-496c-d75b-08d972ea7969 X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5849.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2021 17:02:43.7507 (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: l4Tyd4Zi8RwqtFSqQEVBDbqWmnEqfCD6mqLZ8zJBHFVMfUjWQ0wBs59X6MqjMMfQTquv5X9IzEiBK4C4DIOu8F+ZcZcTb/vkwfZZXBabxN0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR01MB6965 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Thanks Abner. I will correct the description for the function AcpiLocateTableBySignature in the v3. Best regards, Nhi On 08/09/2021 11:53, Chang, Abner (HPS SW/FW Technologist) wrote: > After below comments are addressed, > > Reviewed-by: Abner Chang > >> -----Original Message----- >> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of >> Nhi Pham via groups.io >> Sent: Friday, September 3, 2021 11:44 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: [edk2-devel] [PATCH v2 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 >> --- >> Changes since v1: >> + Add copyright [Abner] >> + Improve the AcpiLocateTableBySignature function to remove the caution >> for the usage of SSDT table. [Abner] >> + AcpiAmlObjectUpdateInteger: Use the AcpiSdtProtocol->SetOption to >> update >> the value of data object. [Abner] >> >> EmbeddedPkg/Library/AcpiLib/AcpiLib.inf | 3 + >> EmbeddedPkg/Include/Library/AcpiLib.h | 69 +++++++ >> EmbeddedPkg/Library/AcpiLib/AcpiLib.c | 214 ++++++++++++++++++++ >> 3 files changed, 286 insertions(+) >> >> diff --git a/EmbeddedPkg/Library/AcpiLib/AcpiLib.inf >> b/EmbeddedPkg/Library/AcpiLib/AcpiLib.inf >> index 538fe09cca29..01b12c9423a9 100644 >> --- a/EmbeddedPkg/Library/AcpiLib/AcpiLib.inf >> +++ b/EmbeddedPkg/Library/AcpiLib/AcpiLib.inf >> @@ -1,6 +1,7 @@ >> #/** @file >> # >> # Copyright (c) 2014, ARM Ltd. All rights reserved. >> +# Copyright (c) 2021, Ampere Computing LLC. All rights reserved. >> # >> # SPDX-License-Identifier: BSD-2-Clause-Patent >> # >> @@ -23,6 +24,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..933582b7f607 100644 >> --- a/EmbeddedPkg/Include/Library/AcpiLib.h >> +++ b/EmbeddedPkg/Include/Library/AcpiLib.h >> @@ -2,6 +2,7 @@ >> Helper Library for ACPI >> >> Copyright (c) 2014-2016, ARM Ltd. All rights reserved. >> + Copyright (c) 2021, Ampere Computing LLC. All rights reserved. >> >> SPDX-License-Identifier: BSD-2-Clause-Patent >> >> @@ -13,6 +14,7 @@ >> #include >> >> #include >> +#include >> >> // >> // Macros for the Generic Address Space >> @@ -128,4 +130,71 @@ LocateAndInstallAcpiFromFv ( >> IN CONST EFI_GUID* AcpiFile >> ); >> >> +/** >> + This function calculates and updates a UINT8 checksum >> + in an ACPI description table header. >> + >> + @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 OUT 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. >> + >> + @param AcpiTableSdtProtocol Pointer to ACPI SDT protocol. >> + @param TableSignature ACPI table signature. >> + @param Index The zero-based index of the table where to >> search the table. >> + @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, >> + IN OUT UINTN *Index, >> + 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..393133f54381 100644 >> --- a/EmbeddedPkg/Library/AcpiLib/AcpiLib.c >> +++ b/EmbeddedPkg/Library/AcpiLib/AcpiLib.c >> @@ -1,6 +1,7 @@ >> /** @file >> * >> * Copyright (c) 2014-2015, ARM Limited. All rights reserved. >> +* Copyright (c) 2021, Ampere Computing LLC. All rights reserved. >> * >> * SPDX-License-Identifier: BSD-2-Clause-Patent >> * >> @@ -9,9 +10,12 @@ >> #include >> >> #include >> +#include >> +#include >> #include >> #include >> >> +#include >> #include >> #include >> >> @@ -170,3 +174,213 @@ LocateAndInstallAcpiFromFv ( >> { >> return LocateAndInstallAcpiFromFvConditional (AcpiFile, NULL); >> } >> + >> +/** >> + This function calculates and updates a UINT8 checksum >> + in an ACPI description table header. >> + >> + @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 OUT 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. > Is the description correct? I think this function can be used to search > the given signature which could have multiple instances, right? > >> + >> + @param AcpiTableSdtProtocol Pointer to ACPI SDT protocol. >> + @param TableSignature ACPI table signature. >> + @param Index The zero-based index of the table where to >> search the table. > Could you please mention that the index will be updated to the next instance > if the table is found with the matched TableSignature? > > >> + @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, >> + IN OUT UINTN *Index, >> + 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 = *Index; >> + 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; >> + *Index = TableIndex; >> + 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_HANDLE DataHandle; >> + EFI_ACPI_DATA_TYPE DataType; >> + UINT8 *Buffer; >> + UINTN BufferSize; >> + UINTN DataSize; >> + >> + if (AcpiSdtProtocol == NULL || AsciiObjectPath == NULL) { >> + return EFI_INVALID_PARAMETER; >> + } >> + >> + ObjectHandle = NULL; >> + Status = AcpiSdtProtocol->FindPath (TableHandle, AsciiObjectPath, >> &ObjectHandle); >> + if (EFI_ERROR (Status)) { >> + return Status; >> + } >> + >> + Status = AcpiSdtProtocol->GetOption (ObjectHandle, 0, &DataType, (VOID >> *)&Buffer, &BufferSize); >> + if (EFI_ERROR (Status)) { >> + Status = EFI_NOT_FOUND; >> + goto Exit; >> + } >> + ASSERT (DataType == EFI_ACPI_DATA_TYPE_OPCODE); >> + ASSERT (Buffer != NULL); >> + >> + if (Buffer[0] != AML_NAME_OP) { >> + Status = EFI_NOT_FOUND; >> + goto Exit; >> + } >> + >> + // >> + // Get handle of data object >> + // >> + DataHandle = NULL; >> + Status = AcpiSdtProtocol->GetChild (ObjectHandle, &DataHandle); >> + ASSERT_EFI_ERROR (Status); >> + >> + Status = AcpiSdtProtocol->GetOption (DataHandle, 0, &DataType, (VOID > Ok, that is fine to use 0 as you mentioned AML_OP_PARSE_INDEX_GET_OPCODE was defined privately. The better way > is to define this in EmbeddedPkg/Library/AcpiLib.h. Sorry I don't have chance to reply your last mail. > > Abner > >> *)&Buffer, &BufferSize); >> + ASSERT (DataType == EFI_ACPI_DATA_TYPE_OPCODE); >> + ASSERT (Buffer != NULL); >> + >> + if (Buffer[0] == AML_ZERO_OP || Buffer[0] == AML_ONE_OP) { >> + Status = AcpiSdtProtocol->SetOption (DataHandle, 0, (VOID *)&Value, >> sizeof (UINT8)); >> + ASSERT_EFI_ERROR (Status); >> + } else { >> + // >> + // Check the size of data object >> + // >> + switch (Buffer[0]) { >> + case AML_BYTE_PREFIX: >> + DataSize = sizeof (UINT8); >> + break; >> + >> + case AML_WORD_PREFIX: >> + DataSize = sizeof (UINT16); >> + break; >> + >> + case AML_DWORD_PREFIX: >> + DataSize = sizeof (UINT32); >> + break; >> + >> + case AML_QWORD_PREFIX: >> + DataSize = sizeof (UINT64); >> + break; >> + >> + default: >> + // The data type of the ACPI object is not an integer >> + Status = EFI_INVALID_PARAMETER; >> + goto Exit; >> + } >> + >> + Status = AcpiSdtProtocol->SetOption (DataHandle, 1, (VOID *)&Value, >> DataSize); >> + ASSERT_EFI_ERROR (Status); >> + } >> + >> +Exit: >> + AcpiSdtProtocol->Close (DataHandle); >> + AcpiSdtProtocol->Close (ObjectHandle); >> + >> + return Status; >> +} >> -- >> 2.17.1 >> >> >> >> >>