From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.109]) by mx.groups.io with SMTP id smtpd.web11.6240.1630683990198838870 for ; Fri, 03 Sep 2021 08:46:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=UzBDp0cG; spf=pass (domain: os.amperecomputing.com, ip: 40.107.223.109, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NCyHWxzChnyAfD/9QIbEE195LrbA4ldOIjIfKo0dVgQLIQNTL0H0+9TE3OE63hHca/0IQC0u2/3Jql+H/OY30Y6GOPRI7JdCRdwop1NjIRAsn9OzR06YyYIqidZpix+xiI5lN9PQdyQddQPRFfdRKd32V9dz3W0ynGDCA+6MPmS6aOdGsp5hHu8L4V3hy5SsjHgcCvP7jcAuI8pZYeFHlEWlu14iUwAxoMxUeuUUCLwLPezgNaEC3nQIu+JWHCuMDXcoHOadJUiFvOHBoO3ZJXCNqk5OjpNDi8mFd+snJTSnHPpk5SvKw93/gb5mNen39Kgw/ea/1BA+lfCKdOVgNg== 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=Ke7YeBAiw00ednuNeeRonAAHWQVF1QnDJxk33BqS9AI=; b=ib9kt95A/HNEuGbA+KE7oGYWQZnQWzEhUd4nGuAEKpCXpXPicwdlzC+STV7fkwY2VUL8V4shYEtFuCaPHKpo16flprDXkjEw5OyMlYkg9YP7extA5+BNLthFgb9Br/hk1caxkWqJtMABnSgaDupYOZLISM14+8zhXMSHVH3YSg5ntlt7SvU3jH3wgDtPBRHHpup1V9mnROJCpapj+xReNSXlit6v/bwWAeSWfHV5ZYI4fmO87BZowwbXQXsIaIKW9FmIUPCPAg5GnjO2SxOYpdj4YgetzCkDiX5abpH6Z3lYSl1dQoBdWvSUwKDay3BaEhOpzIg5eiHByHehMtU7RQ== 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=Ke7YeBAiw00ednuNeeRonAAHWQVF1QnDJxk33BqS9AI=; b=UzBDp0cG5GH+pExxBHkR6XOXVjg7c0v3J93yNszlsiyyCB2chbxfPkSmK01Vu6Yioslw7wCj3+cZjIS6guoHAQWp1YyOHzo7UNZHga8KUMcKU4W9mr/fNgpolN55njDR/ZudDt2lmPHqxY/Spevt71AnawPttkYUDCv5IZjhdIg= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) by DM6PR01MB4731.prod.exchangelabs.com (2603:10b6:5:65::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.21; Fri, 3 Sep 2021 15:46:26 +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 15:46:26 +0000 From: "Nhi Pham" To: devel@edk2.groups.io Cc: patches@amperecomputing.com, Nhi Pham , Leif Lindholm , Ard Biesheuvel , Abner Chang , Daniel Schaefer Subject: [PATCH v2 1/1] EmbeddedPkg/AcpiLib: Add more helper functions Date: Fri, 3 Sep 2021 22:44:23 +0700 Message-Id: <20210903154423.32619-1-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: HK2PR03CA0065.apcprd03.prod.outlook.com (2603:1096:202:17::35) To DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 Received: from localhost.localdomain (118.69.219.201) by HK2PR03CA0065.apcprd03.prod.outlook.com (2603:1096:202:17::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.7 via Frontend Transport; Fri, 3 Sep 2021 15:46:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f0985d98-3d19-4f20-a673-08d96ef1fca0 X-MS-TrafficTypeDiagnostic: DM6PR01MB4731: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u1if24Omh9jLTs0w8F89ZPGALHBrd1MTd2eHv2uBoKMnAOHm84vemhCpJ+yi6k3rXQ4Hvdn9iPjmzmWvJ537Nl089Fin99/y7WdebpaUtVevoNCkw8y7sd9dr7mdax6YSqN0/biaJU1PniAuYI94NCZr4yca64Y+C9sputvTl4JswZ5DJ91C9JFMHlMViNBZByiEZ9eGkTK/u03ifhz1LISVbhwRAl/SmWHoG/fYty7goQso88nehj1nf+a9k05cHUlKWnatQ1QxLooiLqMvxDXRmKoTgtXjx9J0Kfa54axWU6tCNfl1IePD0h/jhnoYa31E5msojUMUPT7W88NMsiq2YFx5wqRC9BOxO/thoBpEEUfTYQO3EnrPvLdLllQBLAO2Rk9jSX3CZQ0sPq44eGKfqgr/NIdeovZhM+XI3qEDA36Mq0cOFlbYEmIPPMhnxNqlfFlR/8dTKhXYt3A6T/J3EvNk7zEqrOfbT+lVvKHyyAd4CtKY2Ma4dFOKA4Mnw3ArdR9dquo4yIeKYO1Lq/uC2TenwRkRRwygr5futWnaclqsGxg/BMEd6IwzUIhkGsXYrcpUP+BMicL1j5s09qLQ+vfmI5LV1IDW9z3+LSVX0wORVLnhtupU/JbS26ymR/SJwf5cwIseTXb7vBU8Vul8u5hNXeg8tW8w3mWX01EHiMo2RuluDEHj4V6X1VviokQf1v4PQ6iE79hCPRiZPA== 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)(136003)(39850400004)(396003)(366004)(316002)(86362001)(6506007)(1076003)(66946007)(38100700002)(54906003)(5660300002)(8936002)(8676002)(83380400001)(52116002)(30864003)(6512007)(956004)(6916009)(2616005)(38350700002)(4326008)(6486002)(26005)(478600001)(19627235002)(66556008)(66476007)(2906002)(186003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?5xfVKuCYPvgT1WDlE+c01jmfJmW8mDXUXAo9Q5mkDVXU9ayPufLFtBOps9nA?= =?us-ascii?Q?Gl4h9jAZyKSY7qHsgMo+TR910lKkwcTaZA24SJfWejy+9Vt4az2qxIPvTEqa?= =?us-ascii?Q?WGcIpUyQ8OgOAbZ/LpI8l4MH+H4fIxS01JyTsq31aTQtSxcqlJ9LuYEwdv74?= =?us-ascii?Q?nUdqzCFQKAee3UbgP08ZNHWBEMZq3USBU1h1cfB5vzd0MqQr+K1TzRTh72nB?= =?us-ascii?Q?Y0ldRCMbcRgi2SDGwvH/OOlT09ZvU4ij+x9Z584sVyKo2A+H2qjJG0p4hJhV?= =?us-ascii?Q?9oSkOwZxpV1EtF+zJqxn932qIRe29qHw5AL6q7rT+OjouLCDT630dFHZNTMB?= =?us-ascii?Q?esOs6QD32HQDMgGt1WM0eDYgyIxC79LwVE+MmAo9OoTmvUr+fHjk8bk3lDKR?= =?us-ascii?Q?HbAtzQvynKWZ6FurTTnmK5OCZ94Zw4XKLWOKyh2M0K2rs6xsrxbQLrMY/9L8?= =?us-ascii?Q?mb1w2HwW+wGlIQSvycQjYlEvZL7d2Aq32B+APMTZNShc5MR/4ba9QG55419i?= =?us-ascii?Q?yc6YysC74uD/U+GZIZzlPw8H8zmlhyAMPPYNt9bleWLzpnTCzt0wm7i4VyPH?= =?us-ascii?Q?LoQgKaOMqlGhFZizpvFQjFFDBn3XrB3w0oD6O+SdZu35gmoJcuD5MnfXMhK8?= =?us-ascii?Q?V/wC4OlRgiD9/saIrNJr+MaDXtnkjmB6Hm0ThhjeTde13e0zbdQj9qZjZOeA?= =?us-ascii?Q?ONk2uRamPQ7yTnGivYtxdlu9l/KckGxOA/yeJnUS5R0jgKanXV74oyyzB9J0?= =?us-ascii?Q?BG8Yj0YHIblmkHnzTDdq/Crl1w7yP+/TCOfV0esOBLyT9Tg/85mvNNwsqOq7?= =?us-ascii?Q?i5lTw0MHJDdl7auERtnvwEt4onmFCFqa1pESDTnrTd+k7yrwHcuBaOv9haj9?= =?us-ascii?Q?Y9tFroLuC04p31Qm3+iLNbLMIvVrkZUaIv1mXKgTtC6siovRP+Hr5dtRErC3?= =?us-ascii?Q?RXM157J4M/oN31T5OHcwFS6LCelPP6IkLiICAJ88EWzn4lYmKHVe0eUdlNGk?= =?us-ascii?Q?0eJ/7sSRNKPOm0imkqoGeASxwIUa7nUVeb9oLBt0FNIIuoIFaJnYa94QT2Sh?= =?us-ascii?Q?GiC7yFYbuA/6sFt4+C/cUbdVzipLxWkHtqC/1GCMAE4NhcAeWXuTPlDipK1I?= =?us-ascii?Q?DgvTeP9dbRC2x1+ZRM8eji0KeYxNtAxywz/0Xw4PjAg8fYE6q5kn+AbF52e3?= =?us-ascii?Q?rTQszRx0e5DlAe957PiFNsmePAXVtlLXChPuKlznnyFFk7j7TLgzjeRl0u6y?= =?us-ascii?Q?om0SEfeGOPTJwcDmrUqkNjPjRfAGLtGHqQdZ7kUGsHcsFT+siN+HP6iaah3c?= =?us-ascii?Q?Eg/+1fde1UYIW5cSovabYKP9?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0985d98-3d19-4f20-a673-08d96ef1fca0 X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5849.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 15:46:26.3401 (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: Q3jZcgX/b4AKm1rz8wGHPtuDhxOb/L8gZSrVybn1VarfHJj/6cQ7rV7hP9g5VuuI69jBxrUBhjIyATceCk7f66uiggT27zm5aTWh25nZbzc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB4731 Content-Type: text/plain 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. + + @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 + ) +{ + 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 *)&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