From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web10.10817.1629643361585233662 for ; Sun, 22 Aug 2021 07:42:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=esUnm6gz; spf=temperror, err=temporary DNS error (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=08683aa5b8=abner.chang@hpe.com) Received: from pps.filterd (m0134425.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 17MEdPXr028852; Sun, 22 Aug 2021 14:42:39 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=NNbIv3qoXMkb4VaA9IVBAqavPhgd1NcUdWLcisMw4xU=; b=esUnm6gzes9fT01qONnewM2F4AiIjtEavW4L+wNy8L98Xo+oJbfPtvym5DEImhH4rI1z /zC8Oei56ziPI6WiIjwbKeDD3fs9sb/KdauifNoiHq5fEBnFaeyHAP0EZJgWQSwLOOQF cF2iytfClmMpS73RnpdhYeHA/NEmAzkDFsqcZUT1EDHgiUZoSFI7D8/iCxtCS8QTPdUj gJ1DLfQF3n88FaA2wpuIQNg2sN5KwEYimnhGPeH22RODyemEw65LA5fLD66IX2Hgt5Fu 7L0N9GSPutblyr7v5+kfwz8X8Pqk67sgbWwcFNUJS+sqxF54U8RFxeCtoGf++hpTihf5 VA== Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) by mx0b-002e3701.pphosted.com with ESMTP id 3ajtsvgd8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 22 Aug 2021 14:42:38 +0000 Received: from G9W8456.americas.hpqcorp.net (g9w8456.houston.hp.com [16.216.161.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g4t3426.houston.hpe.com (Postfix) with ESMTPS id 0C03B4F; Sun, 22 Aug 2021 14:42:38 +0000 (UTC) Received: from G9W8453.americas.hpqcorp.net (2002:10d8:a0d3::10d8:a0d3) by G9W8456.americas.hpqcorp.net (2002:10d8:a15f::10d8:a15f) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sun, 22 Aug 2021 14:42:37 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (15.241.52.10) by G9W8453.americas.hpqcorp.net (16.216.160.211) with Microsoft SMTP Server (TLS) id 15.0.1497.18 via Frontend Transport; Sun, 22 Aug 2021 14:42:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FSwvmdp4ZIK0q9TdxH57/vFC6IngukDS5R+RYxSMIhAPo3QdY9BVO1Zm9gesvEa3N24PjI+Kk7k2uvzxxBGKBHvmpcKPfdShi70Grz64RNFlp3m0KPY0jiiXuP4j86V4EvV3A1oFguus6PYXyEcVbXf7uAUQQPG7Kx9uG1uadKO36GpY38KaeiJvVF7NUq5Hwh75v4skREgS5ZM+XenJh2okKPFx/iW4SMY+c8HFQBRmnyUO8/UCoPsnWZVZrXVkWa59gRSlRohqSAHY3hEtflCSsDuxnPZT0lkvnbk/R1ofVb2zzCjR8qz96T4KOxhNfNh013CjXn+wnFVasQg49g== 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-SenderADCheck; bh=xS1I5lfDGoJvnCevXI43SaE4vOEw/0iSouTUBPa0nD0=; b=efPvr1aXxbZYNgSk5ya8n0CBlVs/oqVZ8Mgl8K7Kx9+SD7EqNGTJsNvAFCzMo+ilRcanqh9yczoTRDXZYYlDvxlRNbECRGYiN5N99OoGt9fl99Yvdb0+MQn55rkayZrmyVdsnANWz1dJ+nuv+Nnj42cjWikojWSWFiOQOVWSFPvvoCgL38cBjcXMZWKrsVFjSrR7SI2av1HG1YPlvsNwId34zVL8yhVLg7oS3oLpLi74mtLp/uprzir2BnnxuoNlZ6L2Eh9P9p84pgFUww7R3ChwM/ZpEqDlOCZuLVok90lkZYLY+pK6v6cua16Xk4FRLBq75huwahAtrNdevnFQQA== 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 CS1PR8401MB1286.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7514::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.21; Sun, 22 Aug 2021 14:42:36 +0000 Received: from CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::e5ca:7bef:3a1c:b46a]) by CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::e5ca:7bef:3a1c:b46a%11]) with mapi id 15.20.4436.024; Sun, 22 Aug 2021 14:42:36 +0000 From: "Abner Chang" To: Nhi Pham , "devel@edk2.groups.io" CC: "patches@amperecomputing.com" , Leif Lindholm , Ard Biesheuvel , "Schaefer, Daniel" Subject: Re: [PATCH 1/1] EmbeddedPkg/AcpiLib: Add more helper functions Thread-Topic: [PATCH 1/1] EmbeddedPkg/AcpiLib: Add more helper functions Thread-Index: AQHXk2uWER1ezWA20kq1mgSudJbJ5qt/nBHQ Date: Sun, 22 Aug 2021 14:42:35 +0000 Message-ID: References: <20210817132413.7621-1-nhi@os.amperecomputing.com> In-Reply-To: <20210817132413.7621-1-nhi@os.amperecomputing.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: os.amperecomputing.com; dkim=none (message not signed) header.d=none;os.amperecomputing.com; dmarc=none action=none header.from=hpe.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b152cb64-5097-410e-efba-08d9657b1538 x-ms-traffictypediagnostic: CS1PR8401MB1286: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: sjTF0BR7ARocMEZBksZQw24V5J7JQcZgDDAfinuaVxZQfpcsf3VezXA5R0Lu+8bSCztiFGWgDoy//+DBqDrvQPzWUso6isXG1mkoqWTyWhPoetlfplHhgN6TiAzRqD+CtNBK91xuZROgDX++Xon7zF9Dz0jsQq52fw05hJcztHaBr06fuEck4N3z7wMmyooRAQJ2oLOSZr69URqp4P41s38zI2wr9LTLatSjG1be7Qkleu+sJUAMPLgP70AgCPNy6RgPebwnmVkcJIxnYeP8QkRZFELgwI7ydZ28m76751zA/xQfPf8/+PIY2suwYp5iFv+4B8CK4rlcNPCGbyAsPFu3/6vNPVTDbqPENwHgcsaF8S64u648hddtgL07MCZQFJLGAthJkuX5/CVM6SuZaPpCfPR3r2BVD+nOzt8FwbwwHgDrILO+4Bx6YytEJmY1Q1HPCzwcHtl3ApkqH15iHHrwE6gwAj6HmOJQH9Unhd5lagIe7lOITh+123ZFWF+xJKQdrnyWhKmfQMdvWdU+AS7++D73Lz7EazuyYXZYFxGtG0ujHbKh8m8U0WOihdnp6KhAhXZmsGhgEuPmedjpI/e5s/EZnbenhboajkwJ/mOSzvQoTuxL4lerlCD3/IU61uSKokkhUCAcK8aKavWqu/EQBCnRWpoj6T1cDhuLU3BxwBgnXgpFw8D2gD8p1/kjaHg+4RBDWfRKkB6O2aru/Q== 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)(39860400002)(376002)(136003)(396003)(366004)(4326008)(66946007)(76116006)(7696005)(66476007)(9686003)(66556008)(33656002)(19627235002)(26005)(55016002)(71200400001)(186003)(52536014)(6506007)(53546011)(478600001)(66446008)(64756008)(5660300002)(86362001)(2906002)(54906003)(8676002)(83380400001)(316002)(8936002)(110136005)(38070700005)(38100700002)(122000001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ByeuFPyj4TnsIzw8N2Jvk5plJdlat7jD7MAD2sR/rITvIKHVtjFVrUkZjjZQ?= =?us-ascii?Q?gSsRgl7KOLohMEP8eMr/mKjWQr1tmDgbP8+x2nCbKxIdUZMob/ENaXXgrYev?= =?us-ascii?Q?WmcvzHgm8eyl2MyOIgTZLFRiIAwoJdGdRyyev+qF8/q4KsezZdRfXNqqzqOW?= =?us-ascii?Q?kr9nJ4WYCtqqWy/piW7lkQ60coR/zQNE9hogo8T1sSfXkLe3YeobkDxU7IF9?= =?us-ascii?Q?BCCH5x3BGE79ggOpLOkbSSpENSxxLQfels5abfn3om1P0hBbHQoWzh9YsyEG?= =?us-ascii?Q?karMttQ3yzrw5mdsa0w7UZ+E5kYxZ7GfH4YN+3k3VoYKWiToXS3GTebTvA8r?= =?us-ascii?Q?vaETQ90gUAJccESMXTqP5fOMVc0kYGrMIJvcH8KJgy53CEbJgUauhT5OWSR9?= =?us-ascii?Q?0S7lq1I35lZErBwLfmdnh+lbx+xX/tyC3eZjzF9uWeuQY9NtpMbqCVYc1Y5H?= =?us-ascii?Q?/veSsh7lvsfd2encWlJDOmOfKxajZMupBwow+inZDCygYa00u8dCbgk0lwqi?= =?us-ascii?Q?DhCrXPxGXEbxvUsIKPJORFjmju4n/O0+0UpwuBPG1CNGfoOE2HEI7xJUcn26?= =?us-ascii?Q?YSar1sumgezR6vC1M+rcYdYB00orxxO6gztdl17c6EILwbxpy8DE/TN36dPg?= =?us-ascii?Q?zT6fDjJCUEEpuboslk0td0WD5L1PpLcYv4+vxHPBS3irna/kZokfvSgUdYAR?= =?us-ascii?Q?EXXPACD9L214d37KG8zSspX7CH9JYkOdP7Wg6vzZuf0B9XqCZn00YYp9XaVd?= =?us-ascii?Q?tRcTyxU7NH0xvzjKkldmns2mzEFEwYoxkEjamEcKwfOqNandx40l59CGCUzr?= =?us-ascii?Q?pDtBd+yb1OwWow4axo2PYh2lSX0o3kuavyVv3DGNGkZCkWnDOi1fsNTlhKkh?= =?us-ascii?Q?QQaxLG81WN1i7zJSh5oJnkDlJmwnTqPC31R3k7rSgjL0b4BRK8ZHCLjjpWH+?= =?us-ascii?Q?W7bxgAko5/uzJ1VyIYbvRLCncaqFQmHeF+nEnLVgVYCaJ2wIbCV1mRyGcYvr?= =?us-ascii?Q?7NBDO/LR1bFuZ+DS74Cl3VEnFGiglLhd3rSTOg0qdBPyDvudiX9/H2X6u3nl?= =?us-ascii?Q?tGV0fFHyzvRcRNS5LaIFSTn0j0nGNd82oFdRIy7zh9L1fowgGkPBM0n6n/op?= =?us-ascii?Q?ebgGpYHInM63Hv4VA5ce852IVympSkQUoZhKSOqRKfz/m7sRo2Wxel/+/me3?= =?us-ascii?Q?RQ0J5001Ae0sqK8yMqODIlBjz/1nxv7ITseH7LaHJH4FBBYJjWG6E47MAYvc?= =?us-ascii?Q?zOluzAqfqxq/VPKUBSrB7U0UAETlj3jjPOyVBa5qqwZmyIl1sqpG5anZo/Pd?= =?us-ascii?Q?ENEPYI3tnMFaqzOB3plniO0i?= X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: b152cb64-5097-410e-efba-08d9657b1538 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Aug 2021 14:42:35.9442 (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: TzSU2xDaKkqg3eOKOyrmpC5MuJv9qvuN5V9HmGVVu5zI87Jr+db7X4FpufsJRVZXUnIQepGxk7iLqkJ+g2nfWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR8401MB1286 X-OriginatorOrg: hpe.com X-Proofpoint-GUID: tCCbIzF0t6pdqJHkM-yw_EbGFnr0OUab X-Proofpoint-ORIG-GUID: tCCbIzF0t6pdqJHkM-yw_EbGFnr0OUab X-Proofpoint-UnRewURL: 0 URL was 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-08-22_02:2021-08-20,2021-08-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 mlxlogscore=999 impostorscore=0 mlxscore=0 malwarescore=0 spamscore=0 phishscore=0 suspectscore=0 clxscore=1011 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108220101 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Pham, First at all, you have to update the copyright. Other comments are in below, > -----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 >=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 > --- > EmbeddedPkg/Library/AcpiLib/AcpiLib.inf | 2 + > EmbeddedPkg/Include/Library/AcpiLib.h | 68 ++++++++ > EmbeddedPkg/Library/AcpiLib/AcpiLib.c | 183 ++++++++++++++++++++ > 3 files changed, 253 insertions(+) >=20 > 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 >=20 > [LibraryClasses] > + BaseLib > + BaseMemoryLib > DebugLib > UefiBootServicesTableLib >=20 > 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 >=20 > #include > +#include >=20 > // > // Macros for the Generic Address Space > @@ -128,4 +129,71 @@ LocateAndInstallAcpiFromFv ( > IN CONST EFI_GUID* AcpiFile > ); >=20 > +/** > + 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 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..e07919ae323f 100644 > --- a/EmbeddedPkg/Library/AcpiLib/AcpiLib.c > +++ b/EmbeddedPkg/Library/AcpiLib/AcpiLib.c > @@ -9,9 +9,12 @@ > #include >=20 > #include > +#include > +#include > #include > #include >=20 > +#include > #include > #include >=20 > @@ -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 =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. > + > + 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 pointer= s and TableKeys, also another new parameter indicates how many tables are m= atched to the signature? How to use the array depends on the caller. > + > + @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 =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 0; > + 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; > + 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_DATA_TYPE DataType; > + UINT8 *Buffer; > + UINTN BufferSize; > + > + if (AcpiSdtProtocol =3D=3D NULL || AsciiObjectPath =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + Status =3D AcpiSdtProtocol->FindPath (TableHandle, AsciiObjectPath, > &ObjectHandle); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + Status =3D AcpiSdtProtocol->GetOption (ObjectHandle, 0, &DataType, (VO= ID We can use AML_OP_PARSE_INDEX_GET_OPCODE instead of '0', which is more read= able. > *)&Buffer, &BufferSize); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + if (Buffer[0] !=3D AML_NAME_OP) { > + return EFI_NOT_FOUND; > + } > + > + switch (Buffer[5]) { After getting the opcode from ACPI handle, the BufferSize suppose is in va= lue 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. Furthermo= re, can we leverage AcpiSdtProtocol ->SetOpion for updating value instead o= f having below code block? Abner > + case AML_ZERO_OP: > + case AML_ONE_OP: > + Buffer[5] =3D (UINT8)Value; > + break; > + > + case AML_BYTE_PREFIX: > + Buffer[6] =3D (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