From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.2275.1583877101203874152 for ; Tue, 10 Mar 2020 14:51:41 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: nathaniel.l.desimone@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Mar 2020 14:51:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,538,1574150400"; d="scan'208";a="443331760" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by fmsmga006.fm.intel.com with ESMTP; 10 Mar 2020 14:51:40 -0700 Received: from orsmsx122.amr.corp.intel.com (10.22.225.227) by ORSMSX104.amr.corp.intel.com (10.22.225.131) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 10 Mar 2020 14:51:39 -0700 Received: from orsmsx114.amr.corp.intel.com ([169.254.8.140]) by ORSMSX122.amr.corp.intel.com ([169.254.11.66]) with mapi id 14.03.0439.000; Tue, 10 Mar 2020 14:51:38 -0700 From: "Nate DeSimone" To: "devel@edk2.groups.io" , "Shindo, Miki" CC: "Chaganty, Rangasai V" , "Chiu, Chasel" , "Agyeman, Prince" , "Ni, Ray" Subject: Re: [edk2-devel] [edk2-platform:PATCH v2] IntelSiliconPkg/DxeAslUpdateLib: Add DxeAslUpdateLib support Thread-Topic: [edk2-devel] [edk2-platform:PATCH v2] IntelSiliconPkg/DxeAslUpdateLib: Add DxeAslUpdateLib support Thread-Index: AQHV8zt2tYYzAQPsM0urb15S4wuKJKhC2wKA Date: Tue, 10 Mar 2020 21:51:37 +0000 Message-ID: <20200310215133.GA2781@nate-virtualbox> References: <20200305221423.24224-1-miki.shindo@intel.com> In-Reply-To: <20200305221423.24224-1-miki.shindo@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.7.159.63] MIME-Version: 1.0 Return-Path: nathaniel.l.desimone@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: <4920F3147A07054A84CE14847B6FC50C@intel.com> Content-Transfer-Encoding: quoted-printable Hi Miki, Please see my feedback inline. Thanks, Nate On Thu, Mar 05, 2020 at 10:14:23PM +0000, Shindo, Miki wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2536 >=20 > This commit adds DxeAslUpdateLib library support in IntelSiliconPkg, > which allows AML to be updated in DXE. >=20 > Signed-off-by: Miki Shindo > Cc: Sai Chaganty > Cc: Chasel Chiu > Cc: Nate DeSimone > Cc: Prince Agyeman > Cc: Ray Ni > Reviewed-by: Chasel Chiu > --- > Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c= | 553 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++ > Silicon/Intel/IntelSiliconPkg/Include/Library/AslUpdateLib.h = | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++ > Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec = | 4 ++++ > Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.i= nf | 42 ++++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 777 insertions(+) >=20 > diff --git a/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAs= lUpdateLib.c b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAsl= UpdateLib.c > new file mode 100644 > index 0000000000..1eae8bca62 > --- /dev/null > +++ b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdate= Lib.c > @@ -0,0 +1,553 @@ > +/** @file > + Boot service DXE ASL update library implementation. > + Note that the current version of the library updates AML. > + > + These functions in this file can be called during DXE and cannot be c= alled during runtime > + or in SMM which should use a RT or SMM library. > + > + This library uses the ACPI Support protocol. > + > + Copyright (c) 2020, Intel Corporation. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +// > +// Function implemenations > +// > +static EFI_ACPI_SDT_PROTOCOL *mAcpiSdt =3D NULL; > +static EFI_ACPI_TABLE_PROTOCOL *mAcpiTable =3D NULL; > + > +/** > + Initialize the ASL update library state. > + This must be called prior to invoking other library functions. > + > + @retval EFI_SUCCESS - The function completed successfully. > +**/ > +EFI_STATUS > +InitializeAslUpdateLib ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + > + /// > + /// Locate ACPI tables > + /// > + Status =3D gBS->LocateProtocol (&gEfiAcpiSdtProtocolGuid, NULL, (VOID= **) &mAcpiSdt); > + ASSERT_EFI_ERROR (Status); > + Status =3D gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VO= ID **) &mAcpiTable); > + ASSERT_EFI_ERROR (Status); > + return Status; > +} > + > +/** > + This function calculates and updates an UINT8 checksum. > + > + @param Buffer Pointer to buffer to checksum > + @param Size Number of bytes to checksum > + @param ChecksumOffset Offset to place the checksum result in > + > + @return EFI_SUCCESS The function completed successfully. > + > +**/ > +EFI_STATUS > +AcpiPlatformChecksum ( > + IN VOID *Buffer, > + IN UINTN Size, > + IN UINTN ChecksumOffset > + ) > +{ > + UINT8 Sum; > + UINT8 *Ptr; > + > + Sum =3D 0; > + // > + // Initialize pointer > + // > + Ptr =3D Buffer; > + > + // > + // set checksum to 0 first > + // > + Ptr[ChecksumOffset] =3D 0; > + > + // > + // add all content of buffer > + // > + while ((Size--) !=3D 0) { > + Sum =3D (UINT8) (Sum + (*Ptr++)); > + } > + // > + // set checksum > + // > + Ptr =3D Buffer; > + Ptr[ChecksumOffset] =3D (UINT8) (0xff - Sum + 1); > + > + return EFI_SUCCESS; > +} > + > +/** > + This procedure will update immediate value assigned to a Name > + > + @param[in] AslSignature - The signature of Operation Region that= we want to update. > + @param[in] Buffer - source of data to be written over orig= inal aml > + @param[in] Length - length of data to be overwritten > + > + @retval EFI_SUCCESS - The function completed successfully. > + @retval EFI_NOT_FOUND - Failed to locate AcpiTable. > +**/ > +EFI_STATUS > +UpdateNameAslCode ( > + IN UINT32 AslSignature, > + IN VOID *Buffer, > + IN UINTN Length > + ) > +{ > + EFI_STATUS Status; > + EFI_ACPI_DESCRIPTION_HEADER *Table; > + UINT8 *CurrPtr; > + UINT8 *EndPtr; > + UINT32 *Signature; > + UINT8 *DsdtPointer; > + UINTN Handle; > + UINT8 DataSize; > + > + if (mAcpiTable =3D=3D NULL) { > + InitializeAslUpdateLib (); > + if (mAcpiTable =3D=3D NULL) { > + return EFI_NOT_READY; > + } > + } > + > + /// > + /// Locate table with matching ID > + /// > + Handle =3D 0; > + Status =3D LocateAcpiTableBySignature ( > + EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNA= TURE, > + (EFI_ACPI_DESCRIPTION_HEADER **) &Table, > + &Handle > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + /// > + /// Point to the beginning of the DSDT table > + /// > + CurrPtr =3D (UINT8 *) Table; > + if (CurrPtr =3D=3D NULL) { > + return EFI_NOT_FOUND; > + } > + > + // > + // EndPtr =3D beginning of table + length of table > + // > + EndPtr =3D CurrPtr + ((EFI_ACPI_COMMON_HEADER *) CurrPtr)->Length; > + > + /// > + /// Loop through the ASL looking for values that we must fix up. > + /// > + for (DsdtPointer =3D CurrPtr; DsdtPointer < EndPtr; DsdtPointer++) { > + /// > + /// Get a pointer to compare for signature > + /// > + Signature =3D (UINT32 *) DsdtPointer; > + /// > + /// Check if this is the Device Object signature we are looking for > + /// > + if ((*Signature) =3D=3D AslSignature) { > + /// > + /// Look for Name Encoding > + /// > + if (*(DsdtPointer-1) =3D=3D AML_NAME_OP) { > + /// > + /// Check if size of new and old data is the same > + /// > + DataSize =3D *(DsdtPointer+4); > + if ((Length =3D=3D 1 && DataSize =3D=3D 0xA) || > + (Length =3D=3D 2 && DataSize =3D=3D 0xB) || > + (Length =3D=3D 4 && DataSize =3D=3D 0xC)) { > + CopyMem (DsdtPointer+5, Buffer, Length); > + } else if (Length =3D=3D 1 && ((*(UINT8*) Buffer) =3D=3D 0 || (= *(UINT8*) Buffer) =3D=3D 1) && (DataSize =3D=3D 0 || DataSize =3D=3D 1)) { > + CopyMem (DsdtPointer+4, Buffer, Length); > + } else { > + FreePool (Table); > + return EFI_BAD_BUFFER_SIZE; > + } > + Status =3D mAcpiTable->UninstallAcpiTable ( > + mAcpiTable, > + Handle > + ); > + Handle =3D 0; > + Status =3D mAcpiTable->InstallAcpiTable ( > + mAcpiTable, > + Table, > + Table->Length, > + &Handle > + ); > + FreePool (Table); > + return Status; > + } > + } > + } > + return EFI_NOT_FOUND; > +} > + > +/** > + This procedure will update immediate value assigned to a Name in SSDT= table > + > + @param[in] TableId - Pointer to an ASCII string containing = the OEM Table ID from the ACPI table header > + @param[in] TableIdSize - Length of the TableId to match. Table= ID are 8 bytes long, this function > + @param[in] Buffer - source of data to be written over orig= inal aml > + @param[in] Length - length of data to be overwritten > + > + @retval EFI_SUCCESS - The function completed successfully. > + @retval EFI_NOT_FOUND - Failed to locate AcpiTable. > +**/ > +EFI_STATUS > +UpdateSsdtNameAslCode ( > + IN UINT8 *TableId, > + IN UINT8 TableIdSize, > + IN UINT32 AslSignature, > + IN VOID *Buffer, > + IN UINTN Length > + ) > +{ > + EFI_STATUS Status; > + EFI_ACPI_DESCRIPTION_HEADER *Table; > + UINT8 *CurrPtr; > + UINT32 *Signature; > + UINT8 *SsdtPointer; > + UINTN Handle; > + UINT8 DataSize; > + > + if (mAcpiTable =3D=3D NULL) { > + InitializeAslUpdateLib (); > + if (mAcpiTable =3D=3D NULL) { > + return EFI_NOT_READY; > + } > + } > + > + /// > + /// Locate table with matching ID > + /// > + Handle =3D 0; > + Status =3D LocateAcpiTableByOemTableId ( > + TableId, > + TableIdSize, > + (EFI_ACPI_DESCRIPTION_HEADER **) &Table, > + &Handle > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + /// > + /// Point to the beginning of the DSDT table > + /// > + CurrPtr =3D (UINT8 *) Table; > + if (CurrPtr =3D=3D NULL) { > + return EFI_NOT_FOUND; > + } > + > + /// > + /// Loop through the ASL looking for values that we must fix up. > + /// > + for (SsdtPointer =3D CurrPtr; SsdtPointer <=3D (CurrPtr + ((EFI_ACPI_= COMMON_HEADER *) CurrPtr)->Length); SsdtPointer++) { > + /// > + /// Get a pointer to compare for signature > + /// > + Signature =3D (UINT32 *) SsdtPointer; > + /// > + /// Check if this is the Device Object signature we are looking for > + /// > + if ((*Signature) =3D=3D AslSignature) { > + /// > + /// Look for Name Encoding > + /// > + if (*(SsdtPointer-1) =3D=3D AML_NAME_OP) { > + /// > + /// Check if size of new and old data is the same > + /// > + DataSize =3D *(SsdtPointer+4); > + if ((Length =3D=3D 1 && DataSize =3D=3D 0xA) || > + (Length =3D=3D 2 && DataSize =3D=3D 0xB) || > + (Length =3D=3D 4 && DataSize =3D=3D 0xC)) { > + CopyMem (SsdtPointer+5, Buffer, Length); > + } else if (Length =3D=3D 1 && ((*(UINT8*) Buffer) =3D=3D 0 || (= *(UINT8*) Buffer) =3D=3D 1) && (DataSize =3D=3D 0 || DataSize =3D=3D 1)) { > + CopyMem (SsdtPointer+4, Buffer, Length); > + } else { > + return EFI_BAD_BUFFER_SIZE; > + } > + AcpiPlatformChecksum ( > + Table, > + Table->Length, > + OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, > + Checksum) > + ); > + return Status; > + } > + } > + } > + return EFI_NOT_FOUND; > +} > + > +/** > + This procedure will update the name of ASL Method > + > + @param[in] AslSignature - The signature of Operation Region that= we want to update. > + @param[in] Buffer - source of data to be written over orig= inal aml > + @param[in] Length - length of data to be overwritten > + > + @retval EFI_SUCCESS - The function completed successfully. > + @retval EFI_NOT_FOUND - Failed to locate AcpiTable. > +**/ > +EFI_STATUS > +UpdateMethodAslCode ( > + IN UINT32 AslSignature, > + IN VOID *Buffer, > + IN UINTN Length > + ) > +{ > + EFI_STATUS Status; > + EFI_ACPI_DESCRIPTION_HEADER *Table; > + UINT8 *CurrPtr; > + UINT32 *Signature; > + UINT8 *DsdtPointer; > + UINTN Handle; > + > + if (mAcpiTable =3D=3D NULL) { > + InitializeAslUpdateLib (); > + if (mAcpiTable =3D=3D NULL) { > + return EFI_NOT_READY; > + } > + } > + > + /// > + /// Locate table with matching ID > + /// > + Handle =3D 0; > + Status =3D LocateAcpiTableBySignature ( > + EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNA= TURE, > + (EFI_ACPI_DESCRIPTION_HEADER **) &Table, > + &Handle > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + /// > + /// Point to the beginning of the DSDT table > + /// > + CurrPtr =3D (UINT8 *) Table; > + if (CurrPtr =3D=3D NULL) { > + return EFI_NOT_FOUND; > + } > + > + /// > + /// Loop through the ASL looking for values that we must fix up. > + /// > + for (DsdtPointer =3D CurrPtr; DsdtPointer <=3D (CurrPtr + ((EFI_ACPI_= COMMON_HEADER *) CurrPtr)->Length); DsdtPointer++) { > + /// > + /// Get a pointer to compare for signature > + /// > + Signature =3D (UINT32 *) DsdtPointer; > + /// > + /// Check if this is the Device Object signature we are looking for > + /// > + if ((*Signature) =3D=3D AslSignature) { > + /// > + /// Look for Name Encoding > + /// > + if ((*(DsdtPointer-3) =3D=3D AML_METHOD_OP) > + || (*(DsdtPointer-2) =3D=3D AML_METHOD_OP) > + ) > + { > + CopyMem (DsdtPointer, Buffer, Length); > + Status =3D mAcpiTable->UninstallAcpiTable ( > + mAcpiTable, > + Handle > + ); > + Handle =3D 0; > + Status =3D mAcpiTable->InstallAcpiTable ( > + mAcpiTable, > + Table, > + Table->Length, > + &Handle > + ); > + FreePool (Table); > + return Status; > + } > + } > + } > + return EFI_NOT_FOUND; > +} > + > +/** > + This function uses the ACPI SDT protocol to locate an ACPI table. > + It is really only useful for finding tables that only have a single i= nstance, > + e.g. FADT, FACS, MADT, etc. It is not good for locating SSDT, etc. > + > + @param[in] Signature - Pointer to an ASCII string containin= g the OEM Table ID from the ACPI table header > + @param[in, out] Table - Updated with a pointer to the table > + @param[in, out] Handle - AcpiSupport protocol table handle fo= r the table found > + @param[in, out] Version - The version of the table desired > + > + @retval EFI_SUCCESS - The function completed successfully. > +**/ > +EFI_STATUS > +LocateAcpiTableBySignature ( > + IN UINT32 Signature, > + IN OUT EFI_ACPI_DESCRIPTION_HEADER **Table, > + IN OUT UINTN *Handle > + ) > +{ > + EFI_STATUS Status; > + INTN Index; > + EFI_ACPI_TABLE_VERSION Version; > + EFI_ACPI_DESCRIPTION_HEADER *OrgTable; > + > + if (mAcpiSdt =3D=3D NULL) { > + InitializeAslUpdateLib (); > + if (mAcpiSdt =3D=3D NULL) { > + return EFI_NOT_READY; > + } > + } > + > + /// > + /// Locate table with matching ID > + /// > + Version =3D 0; > + Index =3D 0; > + do { > + Status =3D mAcpiSdt->GetAcpiTable (Index, (EFI_ACPI_SDT_HEADER **)&= OrgTable, &Version, Handle); > + if (Status =3D=3D EFI_NOT_FOUND) { > + break; > + } > + ASSERT_EFI_ERROR (Status); > + Index++; > + } while (OrgTable->Signature !=3D Signature); > + > + if (Status !=3D EFI_NOT_FOUND) { > + *Table =3D AllocateCopyPool (OrgTable->Length, OrgTable); > + ASSERT (*Table); > + } > + > + /// > + /// If we found the table, there will be no error. > + /// > + return Status; > +} > + > +/** > + This function uses the ACPI SDT protocol to locate an ACPI SSDT table= . > + > + @param[in] TableId - Pointer to an ASCII string containing = the OEM Table ID from the ACPI table header > + @param[in] TableIdSize - Length of the TableId to match. Table= ID are 8 bytes long, this function > + will consider it a match if the first = TableIdSize bytes match > + @param[in, out] Table - Updated with a pointer to the table > + @param[in, out] Handle - AcpiSupport protocol table handle for = the table found > + @param[in, out] Version - See AcpiSupport protocol, GetAcpiTable= function for use > + > + @retval EFI_SUCCESS - The function completed successfully. > +**/ > +EFI_STATUS > +LocateAcpiTableByOemTableId ( > + IN UINT8 *TableId, > + IN UINT8 TableIdSize, > + IN OUT EFI_ACPI_DESCRIPTION_HEADER **Table, > + IN OUT UINTN *Handle > + ) > +{ > + EFI_STATUS Status; > + INTN Index; > + EFI_ACPI_TABLE_VERSION Version; > + EFI_ACPI_DESCRIPTION_HEADER *OrgTable; > + > + if (mAcpiSdt =3D=3D NULL) { > + InitializeAslUpdateLib (); > + if (mAcpiSdt =3D=3D NULL) { > + return EFI_NOT_READY; > + } > + } > + /// > + /// Locate table with matching ID > + /// > + Version =3D 0; > + Index =3D 0; > + do { > + Status =3D mAcpiSdt->GetAcpiTable (Index, (EFI_ACPI_SDT_HEADER **)&= OrgTable, &Version, Handle); > + if (Status =3D=3D EFI_NOT_FOUND) { > + break; > + } > + ASSERT_EFI_ERROR (Status); > + Index++; > + } while (CompareMem (&(OrgTable->OemTableId), TableId, TableIdSize)); > + > + if (Status !=3D EFI_NOT_FOUND) { > + *Table =3D OrgTable; > + ASSERT (*Table); > + } > + > + /// > + /// If we found the table, there will be no error. > + /// > + return Status; > +} > + > +/** > + This function calculates and updates an UINT8 checksum. > + > + @param[in] Buffer Pointer to buffer to checksum > + @param[in] Size Number of bytes to checksum > + @param[in] ChecksumOffset Offset to place the checksum result in > + > + @retval EFI_SUCCESS The function completed successfully. > +**/ > +EFI_STATUS > +AcpiChecksum ( > + IN VOID *Buffer, > + IN UINTN Size, > + IN UINTN ChecksumOffset > + ) > +{ > + UINT8 Sum; > + UINT8 *Ptr; > + > + Sum =3D 0; > + /// > + /// Initialize pointer > + /// > + Ptr =3D Buffer; > + > + /// > + /// set checksum to 0 first > + /// > + Ptr[ChecksumOffset] =3D 0; > + > + /// > + /// add all content of buffer > + /// > + while (Size--) { > + Sum =3D (UINT8) (Sum + (*Ptr++)); > + } > + /// > + /// set checksum > + /// > + Ptr =3D Buffer; > + Ptr[ChecksumOffset] =3D (UINT8) (0xff - Sum + 1); > + > + return EFI_SUCCESS; > +} > diff --git a/Silicon/Intel/IntelSiliconPkg/Include/Library/AslUpdateLib.= h b/Silicon/Intel/IntelSiliconPkg/Include/Library/AslUpdateLib.h > new file mode 100644 > index 0000000000..108bb52413 > --- /dev/null > +++ b/Silicon/Intel/IntelSiliconPkg/Include/Library/AslUpdateLib.h > @@ -0,0 +1,178 @@ > +/** @file > + ASL dynamic update library definitions. > + > + This library provides dymanic update to various ASL structures. There is a mis-spelling here. It should be "dynamic" not "dymanic". > + There may be different libraries for different environments (PEI, BS,= RT, SMM). > + Make sure you meet the requirements for the library (protocol depende= ncies, use > + restrictions, etc). > + > + Note that the current version of the library updates AML. > + > + Copyright (c) 2020 Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > +#ifndef _ASL_UPDATE_LIB_H_ > +#define _ASL_UPDATE_LIB_H_ > + > +// > +// Include files > +// > +#include > +#include > +#include > + > +// > +// AML parsing definitions > +// > +#define AML_RESRC_TEMP_END_TAG 0x0079 > + > +// > +// ASL PSS package structure layout > +// > +#pragma pack (1) > +typedef struct { > + UINT8 NameOp; // 12h ;First opcode is a NameOp. > + UINT8 PackageLead; // 20h ;First opcode is a NameOp. > + UINT8 NumEntries; // 06h ;First opcode is a NameOp. > + UINT8 DwordPrefix1; // 0Ch > + UINT32 CoreFrequency; // 00h > + UINT8 DwordPrefix2; // 0Ch > + UINT32 Power; // 00h > + UINT8 DwordPrefix3; // 0Ch > + UINT32 TransLatency; // 00h > + UINT8 DwordPrefix4; // 0Ch > + UINT32 BmLatency; // 00h > + UINT8 DwordPrefix5; // 0Ch > + UINT32 Control; // 00h > + UINT8 DwordPrefix6; // 0Ch > + UINT32 Status; // 00h > +} PSS_PACKAGE_LAYOUT; > +#pragma pack() > + > +/** > + Initialize the ASL update library state. > + This must be called prior to invoking other library functions. > + > + > + @retval EFI_SUCCESS The function completed successf= ully. > +**/ > +EFI_STATUS > +InitializeAslUpdateLib ( > + VOID > + ); > + > +/** > + This procedure will update immediate value assigned to a Name > + > + @param[in] AslSignature The signature of Operation Regi= on that we want to update. > + @param[in] Buffer source of data to be written ov= er original aml > + @param[in] Length length of data to be overwritte= n > + > + @retval EFI_SUCCESS The function completed successf= ully. > +**/ > +EFI_STATUS > +UpdateNameAslCode( > + IN UINT32 AslSignature, > + IN VOID *Buffer, > + IN UINTN Length > + ); > + > +/** > + This procedure will update the name of ASL Method > + > + @param[in] AslSignature - The signature of Operation Region that= we want to update. > + @param[in] Buffer - source of data to be written over orig= inal aml > + @param[in] Length - length of data to be overwritten > + > + @retval EFI_SUCCESS - The function completed successfully. > + @retval EFI_NOT_FOUND - Failed to locate AcpiTable. > +**/ > +EFI_STATUS > +UpdateSsdtNameAslCode ( > + IN UINT8 *TableId, > + IN UINT8 TableIdSize, > + IN UINT32 AslSignature, > + IN VOID *Buffer, > + IN UINTN Length > + ); > + > +/** > + This procedure will update the name of ASL Method > + > + @param[in] AslSignature - The signature of Operation Region that= we want to update. > + @param[in] Buffer - source of data to be written over orig= inal aml > + @param[in] Length - length of data to be overwritten > + > + @retval EFI_SUCCESS - The function completed successfully. > + @retval EFI_NOT_FOUND - Failed to locate AcpiTable. > +**/ > +EFI_STATUS > +UpdateMethodAslCode ( > + IN UINT32 AslSignature, > + IN VOID *Buffer, > + IN UINTN Length > + ); > + > +/** > + This function uses the ACPI support protocol to locate an ACPI table = using the . > + It is really only useful for finding tables that only have a single i= nstance, > + e.g. FADT, FACS, MADT, etc. It is not good for locating SSDT, etc. > + Matches are determined by finding the table with ACPI table that has > + a matching signature and version. > + > + @param[in] Signature Pointer to an ASCII string cont= aining the Signature to match > + @param[in, out] Table Updated with a pointer to the t= able > + @param[in, out] Handle AcpiSupport protocol table hand= le for the table found > + @param[in, out] Version On input, the version of the ta= ble desired, > + on output, the versions the tab= le belongs to > + @see AcpiSupport protocol for d= etails > + > + @retval EFI_SUCCESS The function completed successf= ully. > +**/ > +EFI_STATUS > +LocateAcpiTableBySignature ( > + IN UINT32 Signature, > + IN OUT EFI_ACPI_DESCRIPTION_HEADER **Table, > + IN OUT UINTN *Handle > + ); > + > +/** > + This function uses the ACPI support protocol to locate an ACPI SSDT t= able. > + The table is located by searching for a matching OEM Table ID field. > + Partial match searches are supported via the TableIdSize parameter. > + > + @param[in] TableId Pointer to an ASCII string cont= aining the OEM Table ID from the ACPI table header > + @param[in] TableIdSize Length of the TableId to match.= Table ID are 8 bytes long, this function > + will consider it a match if the= first TableIdSize bytes match > + @param[in, out] Table Updated with a pointer to the t= able > + @param[in, out] Handle AcpiSupport protocol table hand= le for the table found > + @param[in, out] Version See AcpiSupport protocol, GetAc= piTable function for use > + > + @retval EFI_SUCCESS The function completed successf= ully. > +**/ > +EFI_STATUS > +LocateAcpiTableByOemTableId ( > + IN UINT8 *TableId, > + IN UINT8 TableIdSize, > + IN OUT EFI_ACPI_DESCRIPTION_HEADER **Table, > + IN OUT UINTN *Handle > + ); > + > +/** > + This function calculates and updates an UINT8 checksum. > + > + @param[in] Buffer Pointer to buffer to checksum > + @param[in] Size Number of bytes to checksum > + @param[in] ChecksumOffset Offset to place the checksum re= sult in > + > + @retval EFI_SUCCESS The function completed successf= ully. > +**/ > +EFI_STATUS > +AcpiChecksum ( > + IN VOID *Buffer, > + IN UINTN Size, > + IN UINTN ChecksumOffset > + ); > + > +#endif > diff --git a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec b/Silicon= /Intel/IntelSiliconPkg/IntelSiliconPkg.dec > index 3c49fb289c..d5debbf0da 100644 > --- a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec > +++ b/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec > @@ -30,6 +30,10 @@ > # > PeiGetVtdPmrAlignmentLib|Include/Library/PeiGetVtdPmrAlignmentLib.h > > + ## @libraryclass Provides services to update AML in DXE > + # > + AslUpdateLib|Include/Library/AslUpdateLib.h > + > [Guids] > ## GUID for Package token space > # {A9F8D54E-1107-4F0A-ADD0-4587E7A4A735} > diff --git a/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAs= lUpdateLib.inf b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeA= slUpdateLib.inf > new file mode 100644 > index 0000000000..1183b320d5 > --- /dev/null > +++ b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdate= Lib.inf > @@ -0,0 +1,42 @@ > +## @file > +# Provides services to update ASL tables. > +# Note that the current version of the library updates AML. > +# > +# Copyright (c) 2020, Intel Corporation. All rights reserved.
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > + > + > +[Defines] > +INF_VERSION =3D 0x00010017 > +BASE_NAME =3D DxeAslUpdateLib > +FILE_GUID =3D 8621697D-4E3A-4bf2-ADB0-3E2FF06559CA > +VERSION_STRING =3D 1.0 > +MODULE_TYPE =3D BASE > +LIBRARY_CLASS =3D AslUpdateLib > + > + > +[LibraryClasses] > +BaseLib > +IoLib > +DebugLib > +PcdLib > +BaseMemoryLib > +UefiLib > +MemoryAllocationLib > + > + > +[Packages] > +MdePkg/MdePkg.dec > +IntelSiliconPkg/IntelSiliconPkg.dec > + > +[Sources] > +DxeAslUpdateLib.c > + > + > +[Protocols] > +gEfiAcpiTableProtocolGuid ## CONSUMES > +gEfiAcpiSdtProtocolGuid ## CONSUMES > --=20 > 2.16.2.windows.1 >=20 >=20 >=20 >