summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg/Include
diff options
context:
space:
mode:
authorNhi Pham <nhi@os.amperecomputing.com>2021-09-09 15:24:26 +0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-17 15:53:06 +0000
commitc63a10ecb7d66904f04fe65b0cef49c095ce49a6 (patch)
treed6bdeba6456012f4bfdbef4eb3acf338eecc4905 /EmbeddedPkg/Include
parentab5ab2f60348138a4b7b1c95ad6f5d0954fb96f1 (diff)
downloadedk2-c63a10ecb7d66904f04fe65b0cef49c095ce49a6.tar.gz
edk2-c63a10ecb7d66904f04fe65b0cef49c095ce49a6.tar.bz2
edk2-c63a10ecb7d66904f04fe65b0cef49c095ce49a6.zip
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: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Daniel Schaefer <daniel.schaefer@hpe.com> Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com> Acked-by: Leif Lindholm <leif@nuviainc.com> Reviewed-by: Abner Chang <abner.chang@hpe.com>
Diffstat (limited to 'EmbeddedPkg/Include')
-rw-r--r--EmbeddedPkg/Include/Library/AcpiLib.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/EmbeddedPkg/Include/Library/AcpiLib.h b/EmbeddedPkg/Include/Library/AcpiLib.h
index 4f2001bfc8..9dbacd85b0 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 <Uefi.h>
#include <IndustryStandard/Acpi10.h>
+#include <Protocol/AcpiSystemDescriptionTable.h>
//
// Macros for the Generic Address Space
@@ -128,4 +130,73 @@ 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 search an ACPI table
+ with a given signature.
+
+ @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.
+ 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
+ );
+
+/**
+ 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__