From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web12.7441.1631076816094134282 for ; Tue, 07 Sep 2021 21:53:44 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=HG2DqE/5; spf=temperror, err=temporary DNS error (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=08858f7fb0=abner.chang@hpe.com) Received: from pps.filterd (m0134421.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1884rNfn018560; Wed, 8 Sep 2021 04:53:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pps0720; bh=aNsHJtiPx5WXdK5AxjPlKXa3YR9e6Wjc0Vi6WfL02LY=; b=HG2DqE/5vU0ecSUniHcdXvwOS7RwJfhJLn10eQxSZStxuUSBCC/xaGb3qgxrx2skWqrz T+kUPT4Uc0lHZkCX86FmbVghQgMKHpnC4yjUxO8tkkLM/1k7hVykS4VvBnDhYs4fxMpl DUu6pqChWfd8nZwByP+b+96wz2Q2TmQhugq8TokoMazUWDlJ0BNDZSg5b1OvIfogcdYl rcCCPyKAEt4+IQlJFKqr9zBnCRG6w8e4U/whFWLYVrNlwH4dIOtFwjWE+j4bM5GIvZ6I C7ZN34bQyOlr1zb4z+t7Cs/GZh5ZGfyRsOInbDRKB1UbwA23KMD2E4uHzH0SXALKNLzW Iw== Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0b-002e3701.pphosted.com with ESMTP id 3axcpvujk1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Sep 2021 04:53:33 +0000 Received: from G9W8453.americas.hpqcorp.net (g9w8453.houston.hp.com [16.216.160.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g2t2352.austin.hpe.com (Postfix) with ESMTPS id 61756B0; Wed, 8 Sep 2021 04:53:32 +0000 (UTC) Received: from G9W8456.americas.hpqcorp.net (2002:10d8:a15f::10d8:a15f) by G9W8453.americas.hpqcorp.net (2002:10d8:a0d3::10d8:a0d3) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 8 Sep 2021 04:53:32 +0000 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (15.241.52.11) by G9W8456.americas.hpqcorp.net (16.216.161.95) with Microsoft SMTP Server (TLS) id 15.0.1497.18 via Frontend Transport; Wed, 8 Sep 2021 04:53:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WlqwNaYT/68tepAqF1/YfZKR+HqXLuds6u2VMqvMhh6LRYrpKG9NsYugL57rXQtt+PjMTRoIboEI5jkGCNIGYmE3V8I5JO5lczv/FBLRCCgGmkYpLnEtCzySVmLdJjo7YkPMfAH/bY6OEgxFov8t09BtlIq++0F4I4ybYfH0qw9TZm3NXb/RmARFgC9pHoyJESbCCtDaEY01oTVpGP7Eh7qJNfYhFEHDV3CjsodftbnqVLFMBDFdpxs9W2QCNNzOcfUdu2pkswxEjffp96EuWSDglUOVb5BkBl/gEQuFY6V6iWL+4BAv0kp+1vSNkM8aLB7ON2xET90YxjQD30GktQ== 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=+htRpkpLX+IbjyFLa0rAYcLcFtoRFt5dMFJlOK/zSc8=; b=BljtIED41hfIo3JPL0tOPXK+xgNt1o7wuLKYCFLQo/WLUPBFGFZ+69J2mO7g140dfYENWAWe+WcljBjpm0yh65LmAZVmTjSYumqs4Tr6ootk2xzBWM/9iIh3ezXfIgQSW7C4z05O/z7K2eFlzQagdQ5yOMysh1J5LUR/naxoYmenFSZ7ujedmBwY648gvMnAPV8KkePleVgNqFpvB6pAlcuRqqDORxTKEPelRDGr4jSaBWZRmqDx3rCKwSbzv7ur7RaqBxc3TMDP1lC6hCAKxRg0sKeMnYvmYn71NHirmhCCBkFUqP68CkDPiMOuE65vyxbw9FXu8AHhl2/VuMVAKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7508::16) by CS1PR8401MB0952.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7512::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Wed, 8 Sep 2021 04:53:30 +0000 Received: from CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::b88a:7fe7:6294:683f]) by CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::b88a:7fe7:6294:683f%9]) with mapi id 15.20.4478.025; Wed, 8 Sep 2021 04:53:30 +0000 From: "Abner Chang" To: "devel@edk2.groups.io" , "nhi@os.amperecomputing.com" CC: "patches@amperecomputing.com" , Leif Lindholm , Ard Biesheuvel , "Schaefer, Daniel" Subject: Re: [edk2-devel] [PATCH v2 1/1] EmbeddedPkg/AcpiLib: Add more helper functions Thread-Topic: [edk2-devel] [PATCH v2 1/1] EmbeddedPkg/AcpiLib: Add more helper functions Thread-Index: AQHXoNrlxQv+lP2XpUG7XXtiLc9xxKuZkWjA Date: Wed, 8 Sep 2021 04:53:30 +0000 Message-ID: References: <20210903154423.32619-1-nhi@os.amperecomputing.com> In-Reply-To: <20210903154423.32619-1-nhi@os.amperecomputing.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=hpe.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 503c73d5-1c40-4a33-7de7-08d972849aaf x-ms-traffictypediagnostic: CS1PR8401MB0952: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4303; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wxmjqIBhPZEf1gVIg6f/sWQVgzCr70cUBCUzi75dwoGL8azRfkkrJdBVxaov9Ey0IBMx3i7Idfwd2ltPlhtDkKPRO+LeCEAZPnkYNJriJSNw6Cz/qjSRw2Ck+RZOD6A6j+CdoxjepnLOVhrXp43UcCCSEjSNj7cwFO59jDmhaRyZG2t3AOO8mLgTcVuoQpWm2PLDn6cGKva0ipV/HToEUgL9Udu86h9+ji79eKKVAjorUXp5au2Tv5dcBj9LCkgenVE7zrrXgBRRlVSsf7P50qvKohKlay/Lby7LZCXbMi5W+9+xonxhEcb0j7t4yoQr2WtVlfi/tRwK5rPbi02a7lkPkewl4eglTpugdjk6YzHoQgAB90VSqwH1yJpyEZikf0S3UVI+qZQZRcAVpDo9EahBwVeo6BH7hsm/uykY4omOPOgQUPGbiRft9NHJ/xbQHQyylID5XFewNpy0BTlCJEopC+UNI/gALkGlQqbWTTPhvNNUe0u4xqWWCHP7vAKqkt8lDhh/X/nTrwRAtQQBrGMaQeQsd9oDfRAq2784j3pbbfB+8NTOzlOCvoVb8RWE0ACUvaeDe2jZTjmPq8MNz9jt8uUmsAO7iYOq0cOwOjyzi4j2O2ovjUDS177jsnjyr/shDNabWXI1NRZubeppgnuk1NSHmXyBSxNuIsyGnxAVm7sDYeAuy/Tywvov4A3bXIGVIdvItpTZ4P917/j9Xe52pAg6b+pk9UJHXJa2uoh/lpqTZVKQbsowDKIY5HDn5Kaf8vqbUe4EA6SgTRY6HjT9BgnZl0kvemMNPel4fDDQKX121e+52vhjDvj93JtFE+7Ptm1+xy7AMM1DiHrohg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(346002)(376002)(366004)(39860400002)(136003)(396003)(8936002)(186003)(55016002)(33656002)(110136005)(478600001)(30864003)(19627235002)(26005)(54906003)(86362001)(8676002)(9686003)(2906002)(316002)(52536014)(53546011)(66476007)(76116006)(64756008)(66556008)(7696005)(5660300002)(66446008)(6506007)(71200400001)(966005)(55236004)(122000001)(38100700002)(83380400001)(38070700005)(66946007)(4326008);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?7tBayYfeCpjyQgI6oSwC0Bm+MP+C1Z4wBMWVLvAIc0lZBvrCPuSq7pZSMYjV?= =?us-ascii?Q?KjIY2UtNIeiSKHz2m4FGwYbglZa+yS4gkVH+nrpscvi1SMzlet+8QZaSK4dF?= =?us-ascii?Q?QqlW7ePYZnR1+pD77aMVetWu52nZlG/zjEf1fs2aFUS4KNJ3dY4aNIPVqBSy?= =?us-ascii?Q?U9M5i8VZOb2cdBzMa6OXVEzFGXgQuGe2zXYEzPP/mm6tEktIt25kQ9zya5up?= =?us-ascii?Q?UYGX1w2NdJZWcOe3tAfBDk1IipKmz7WD8Uu9eqtvoM1R5htwA1B6+bgMtZzN?= =?us-ascii?Q?ncAoMpVDifCKIGYl3bFBmzmkv6PLB3uEvLHUUkOY/Iq7CT4t9jk1tF6kFsAB?= =?us-ascii?Q?JyaUWcaN7ZF7NGp2t/gMUUWO5ZcnYAjsvyBVkzY2VAQ944ho3VfDIs9xZuol?= =?us-ascii?Q?fV7WxMS9LvmC/V9an+ZCYnbZDwzKZ3Wdl5FbqY1qXpSKsSRA3tzqT5XbIug+?= =?us-ascii?Q?xyeuiYe9iULzbtAiso0Jk1sS/Wl5c3jsU8Fne2zuHicHy0INLxmcey+fYtHL?= =?us-ascii?Q?ggsZxtW+yvozp0+WW0gjmyL7d6ev2pofm4+V2rNqBtrx6CBxyppkCvngY8qm?= =?us-ascii?Q?nV4LQPkgpsLHA+xzyoQzBSu2ObiFKVUc6InuDBeLHRRouwVkuUKGmwJ6XqOS?= =?us-ascii?Q?rvBUQxmKzCltdKvEdBbjE070v6l/Of+zWxLXClOKN2t/fSxemQyEfysagf50?= =?us-ascii?Q?9/VRZSA0FgU1ig/8Unu62HrzwnwflGM9k9pH/O2uDW2belT2SEC+N8cp9qVM?= =?us-ascii?Q?SRqgGxS07LORC6deDYsqvRoqwNQWtEZaHWmK9RtycgA5PJ51hap5YmiIZDDs?= =?us-ascii?Q?i1tn/EW6Bi3eMw+pEfC2Ox72WadBizgBhnnQRLeQE1qkV+n5rhdphxOKJ94z?= =?us-ascii?Q?CJpLYRjKN0JdVwe6rGMVxWcljYKlFyEQ6Gvb8X1ib4w8b4rYjUuwOOK4xxQ6?= =?us-ascii?Q?vAG8wVyBH+NlYkxhUOWHedxKyhdk0CKJiJbDo3xV4CwnNQNA7M0wPWBfeRNZ?= =?us-ascii?Q?GHJkxUD7woOgr+QMDqWEbM6ljTm/K2Wae+v2nUemsUFtonODngEEPMiv2iMG?= =?us-ascii?Q?4DKLmVPtpeBiw5c0PKkzrLx4Ro2nt+CodjQ7i/yfe4D9Pu3PcWO2vg4Dc0vx?= =?us-ascii?Q?PP6ssbHMrDwfRSYr8QknqNnR11tJxgUHi+OyiBXLrFub4/iL8VKQe+jY2tI5?= =?us-ascii?Q?4H/mXCKEfeOzFjJtcP82LS7cXdpq6AaXI5j5pyWXc4KhXog9V/QQuHVx3+sK?= =?us-ascii?Q?2U6MG8TaNLoiutaLxYLiI2jLzkGvdK2nRWx0cNqxUNrBS71PQZEhxRmOTpbw?= =?us-ascii?Q?oLIcLyeI1SE5GAVs4IgJaPYL?= X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 503c73d5-1c40-4a33-7de7-08d972849aaf X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Sep 2021 04:53:30.4598 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 99odEHJ88E+cFUr6j1Yd2lFuetgSjes+67G8qpyUuYeVlwkO7AKPAgpOmRMDR5jUBfXJMB/SPVOZw+3rAkWgQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR8401MB0952 X-OriginatorOrg: hpe.com X-Proofpoint-GUID: EOZRQYJz89CESDtuvBQLorE3OW9D-Cd1 X-Proofpoint-ORIG-GUID: EOZRQYJz89CESDtuvBQLorE3OW9D-Cd1 X-Proofpoint-UnRewURL: 2 URL's were un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-09-08_01:2021-09-07,2021-09-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 adultscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 clxscore=1011 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109080030 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 >=20 > This adds more helper functions that assist in calculating the checksum, > locating an ACPI table by signature, and updating an AML integer object. >=20 > 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] >=20 > EmbeddedPkg/Library/AcpiLib/AcpiLib.inf | 3 + > EmbeddedPkg/Include/Library/AcpiLib.h | 69 +++++++ > EmbeddedPkg/Library/AcpiLib/AcpiLib.c | 214 ++++++++++++++++++++ > 3 files changed, 286 insertions(+) >=20 > 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 >=20 > [LibraryClasses] > + BaseLib > + BaseMemoryLib > DebugLib > UefiBootServicesTableLib >=20 > 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 >=20 > Copyright (c) 2014-2016, ARM Ltd. All rights reserved. > + Copyright (c) 2021, Ampere Computing LLC. All rights reserved. >=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -13,6 +14,7 @@ > #include >=20 > #include > +#include >=20 > // > // Macros for the Generic Address Space > @@ -128,4 +130,71 @@ LocateAndInstallAcpiFromFv ( > IN CONST EFI_GUID* AcpiFile > ); >=20 > +/** > + 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 wher= e 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 s= tarting > 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 v= alue. > + @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 >=20 > #include > +#include > +#include > #include > #include >=20 > +#include > #include > #include >=20 > @@ -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 =3D=3D NULL || Size =3D=3D 0) { > + return EFI_INVALID_PARAMETER; > + } > + > + ChecksumOffset =3D OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, > Checksum); > + > + // > + // Set checksum to 0 first > + // > + Buffer[ChecksumOffset] =3D 0; > + > + // > + // Update checksum value > + // > + Buffer[ChecksumOffset] =3D 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 wher= e to > search the table. Could you please mention that the index will be updated to the next instanc= e=20 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 =3D=3D NULL > + || Table =3D=3D NULL > + || TableKey =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + Status =3D EFI_SUCCESS; > + > + // > + // Search for ACPI Table with matching signature > + // > + TableVersion =3D 0; > + TableIndex =3D *Index; > + while (!EFI_ERROR (Status)) { > + Status =3D AcpiSdtProtocol->GetAcpiTable ( > + TableIndex, > + &TempTable, > + &TableVersion, > + TableKey > + ); > + if (!EFI_ERROR (Status)) { > + TableIndex++; > + > + if (((EFI_ACPI_DESCRIPTION_HEADER *)TempTable)->Signature =3D=3D > TableSignature) { > + *Table =3D (EFI_ACPI_DESCRIPTION_HEADER *)TempTable; > + *Index =3D 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 s= tarting > 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 v= alue. > + @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 =3D=3D NULL || AsciiObjectPath =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + ObjectHandle =3D NULL; > + Status =3D AcpiSdtProtocol->FindPath (TableHandle, AsciiObjectPath, > &ObjectHandle); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + Status =3D AcpiSdtProtocol->GetOption (ObjectHandle, 0, &DataType, (VO= ID > *)&Buffer, &BufferSize); > + if (EFI_ERROR (Status)) { > + Status =3D EFI_NOT_FOUND; > + goto Exit; > + } > + ASSERT (DataType =3D=3D EFI_ACPI_DATA_TYPE_OPCODE); > + ASSERT (Buffer !=3D NULL); > + > + if (Buffer[0] !=3D AML_NAME_OP) { > + Status =3D EFI_NOT_FOUND; > + goto Exit; > + } > + > + // > + // Get handle of data object > + // > + DataHandle =3D NULL; > + Status =3D AcpiSdtProtocol->GetChild (ObjectHandle, &DataHandle); > + ASSERT_EFI_ERROR (Status); > + > + Status =3D AcpiSdtProtocol->GetOption (DataHandle, 0, &DataType, (VOID Ok, that is fine to use 0 as you mentioned AML_OP_PARSE_INDEX_GET_OPCODE wa= s defined privately. The better way is to define this in EmbeddedPkg/Library/AcpiLib.h. Sorry I don't have chan= ce to reply your last mail. Abner > *)&Buffer, &BufferSize); > + ASSERT (DataType =3D=3D EFI_ACPI_DATA_TYPE_OPCODE); > + ASSERT (Buffer !=3D NULL); > + > + if (Buffer[0] =3D=3D AML_ZERO_OP || Buffer[0] =3D=3D AML_ONE_OP) { > + Status =3D 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 =3D sizeof (UINT8); > + break; > + > + case AML_WORD_PREFIX: > + DataSize =3D sizeof (UINT16); > + break; > + > + case AML_DWORD_PREFIX: > + DataSize =3D sizeof (UINT32); > + break; > + > + case AML_QWORD_PREFIX: > + DataSize =3D sizeof (UINT64); > + break; > + > + default: > + // The data type of the ACPI object is not an integer > + Status =3D EFI_INVALID_PARAMETER; > + goto Exit; > + } > + > + Status =3D AcpiSdtProtocol->SetOption (DataHandle, 1, (VOID *)&Value= , > DataSize); > + ASSERT_EFI_ERROR (Status); > + } > + > +Exit: > + AcpiSdtProtocol->Close (DataHandle); > + AcpiSdtProtocol->Close (ObjectHandle); > + > + return Status; > +} > -- > 2.17.1 >=20 >=20 >=20 >=20 >=20