diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-30 18:04:07 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-30 18:04:07 +0100 |
| commit | 08eeda990be33db8048031df2a40ec28955e6430 (patch) | |
| tree | 95806a0189c32818b5d2a8a9a4cef0a844a883b9 /Private/acpiSDK/source/components/executer | |
| parent | 1be243700efc9e36060c5fb65c951d5db6b98e94 (diff) | |
Moved ACPI SDK into it's own repository.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/acpiSDK/source/components/executer')
27 files changed, 0 insertions, 18340 deletions
diff --git a/Private/acpiSDK/source/components/executer/exconcat.c b/Private/acpiSDK/source/components/executer/exconcat.c deleted file mode 100644 index f504bc0c..00000000 --- a/Private/acpiSDK/source/components/executer/exconcat.c +++ /dev/null @@ -1,570 +0,0 @@ -/****************************************************************************** - * - * Module Name: exconcat - Concatenate-type AML operators - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "amlresrc.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exconcat") - -/* Local Prototypes */ - -static ACPI_STATUS -AcpiExConvertToObjectTypeString ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ResultDesc); - - -/******************************************************************************* - * - * FUNCTION: AcpiExDoConcatenate - * - * PARAMETERS: Operand0 - First source object - * Operand1 - Second source object - * ActualReturnDesc - Where to place the return object - * WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Concatenate two objects with the ACPI-defined conversion - * rules as necessary. - * NOTE: - * Per the ACPI spec (up to 6.1), Concatenate only supports Integer, - * String, and Buffer objects. However, we support all objects here - * as an extension. This improves the usefulness of both Concatenate - * and the Printf/Fprintf macros. The extension returns a string - * describing the object type for the other objects. - * 02/2016. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExDoConcatenate ( - ACPI_OPERAND_OBJECT *Operand0, - ACPI_OPERAND_OBJECT *Operand1, - ACPI_OPERAND_OBJECT **ActualReturnDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT *LocalOperand0 = Operand0; - ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; - ACPI_OPERAND_OBJECT *TempOperand1 = NULL; - ACPI_OPERAND_OBJECT *ReturnDesc; - char *Buffer; - ACPI_OBJECT_TYPE Operand0Type; - ACPI_OBJECT_TYPE Operand1Type; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (ExDoConcatenate); - - - /* Operand 0 preprocessing */ - - switch (Operand0->Common.Type) - { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - - Operand0Type = Operand0->Common.Type; - break; - - default: - - /* For all other types, get the "object type" string */ - - Status = AcpiExConvertToObjectTypeString ( - Operand0, &LocalOperand0); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - Operand0Type = ACPI_TYPE_STRING; - break; - } - - /* Operand 1 preprocessing */ - - switch (Operand1->Common.Type) - { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - - Operand1Type = Operand1->Common.Type; - break; - - default: - - /* For all other types, get the "object type" string */ - - Status = AcpiExConvertToObjectTypeString ( - Operand1, &LocalOperand1); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - Operand1Type = ACPI_TYPE_STRING; - break; - } - - /* - * Convert the second operand if necessary. The first operand (0) - * determines the type of the second operand (1) (See the Data Types - * section of the ACPI specification). Both object types are - * guaranteed to be either Integer/String/Buffer by the operand - * resolution mechanism. - */ - switch (Operand0Type) - { - case ACPI_TYPE_INTEGER: - - Status = AcpiExConvertToInteger (LocalOperand1, &TempOperand1, - ACPI_IMPLICIT_CONVERSION); - break; - - case ACPI_TYPE_BUFFER: - - Status = AcpiExConvertToBuffer (LocalOperand1, &TempOperand1); - break; - - case ACPI_TYPE_STRING: - - switch (Operand1Type) - { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - - /* Other types have already been converted to string */ - - Status = AcpiExConvertToString ( - LocalOperand1, &TempOperand1, ACPI_IMPLICIT_CONVERT_HEX); - break; - - default: - - Status = AE_OK; - break; - } - break; - - default: - - ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X", - Operand0->Common.Type)); - Status = AE_AML_INTERNAL; - } - - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Take care with any newly created operand objects */ - - if ((LocalOperand1 != Operand1) && - (LocalOperand1 != TempOperand1)) - { - AcpiUtRemoveReference (LocalOperand1); - } - - LocalOperand1 = TempOperand1; - - /* - * Both operands are now known to be the same object type - * (Both are Integer, String, or Buffer), and we can now perform - * the concatenation. - * - * There are three cases to handle, as per the ACPI spec: - * - * 1) Two Integers concatenated to produce a new Buffer - * 2) Two Strings concatenated to produce a new String - * 3) Two Buffers concatenated to produce a new Buffer - */ - switch (Operand0Type) - { - case ACPI_TYPE_INTEGER: - - /* Result of two Integers is a Buffer */ - /* Need enough buffer space for two integers */ - - ReturnDesc = AcpiUtCreateBufferObject ( - (ACPI_SIZE) ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - Buffer = (char *) ReturnDesc->Buffer.Pointer; - - /* Copy the first integer, LSB first */ - - memcpy (Buffer, &Operand0->Integer.Value, - AcpiGbl_IntegerByteWidth); - - /* Copy the second integer (LSB first) after the first */ - - memcpy (Buffer + AcpiGbl_IntegerByteWidth, - &LocalOperand1->Integer.Value, AcpiGbl_IntegerByteWidth); - break; - - case ACPI_TYPE_STRING: - - /* Result of two Strings is a String */ - - ReturnDesc = AcpiUtCreateStringObject ( - ((ACPI_SIZE) LocalOperand0->String.Length + - LocalOperand1->String.Length)); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - Buffer = ReturnDesc->String.Pointer; - - /* Concatenate the strings */ - - strcpy (Buffer, LocalOperand0->String.Pointer); - strcat (Buffer, LocalOperand1->String.Pointer); - break; - - case ACPI_TYPE_BUFFER: - - /* Result of two Buffers is a Buffer */ - - ReturnDesc = AcpiUtCreateBufferObject ( - ((ACPI_SIZE) Operand0->Buffer.Length + - LocalOperand1->Buffer.Length)); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - Buffer = (char *) ReturnDesc->Buffer.Pointer; - - /* Concatenate the buffers */ - - memcpy (Buffer, Operand0->Buffer.Pointer, - Operand0->Buffer.Length); - memcpy (Buffer + Operand0->Buffer.Length, - LocalOperand1->Buffer.Pointer, - LocalOperand1->Buffer.Length); - break; - - default: - - /* Invalid object type, should not happen here */ - - ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X", - Operand0->Common.Type)); - Status = AE_AML_INTERNAL; - goto Cleanup; - } - - *ActualReturnDesc = ReturnDesc; - -Cleanup: - if (LocalOperand0 != Operand0) - { - AcpiUtRemoveReference (LocalOperand0); - } - - if (LocalOperand1 != Operand1) - { - AcpiUtRemoveReference (LocalOperand1); - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExConvertToObjectTypeString - * - * PARAMETERS: ObjDesc - Object to be converted - * ReturnDesc - Where to place the return object - * - * RETURN: Status - * - * DESCRIPTION: Convert an object of arbitrary type to a string object that - * contains the namestring for the object. Used for the - * concatenate operator. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiExConvertToObjectTypeString ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ResultDesc) -{ - ACPI_OPERAND_OBJECT *ReturnDesc; - const char *TypeString; - - - TypeString = AcpiUtGetTypeName (ObjDesc->Common.Type); - - ReturnDesc = AcpiUtCreateStringObject ( - ((ACPI_SIZE) strlen (TypeString) + 9)); /* 9 For "[ Object]" */ - if (!ReturnDesc) - { - return (AE_NO_MEMORY); - } - - strcpy (ReturnDesc->String.Pointer, "["); - strcat (ReturnDesc->String.Pointer, TypeString); - strcat (ReturnDesc->String.Pointer, " Object]"); - - *ResultDesc = ReturnDesc; - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExConcatTemplate - * - * PARAMETERS: Operand0 - First source object - * Operand1 - Second source object - * ActualReturnDesc - Where to place the return object - * WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Concatenate two resource templates - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExConcatTemplate ( - ACPI_OPERAND_OBJECT *Operand0, - ACPI_OPERAND_OBJECT *Operand1, - ACPI_OPERAND_OBJECT **ActualReturnDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ReturnDesc; - UINT8 *NewBuf; - UINT8 *EndTag; - ACPI_SIZE Length0; - ACPI_SIZE Length1; - ACPI_SIZE NewLength; - - - ACPI_FUNCTION_TRACE (ExConcatTemplate); - - - /* - * Find the EndTag descriptor in each resource template. - * Note1: returned pointers point TO the EndTag, not past it. - * Note2: zero-length buffers are allowed; treated like one EndTag - */ - - /* Get the length of the first resource template */ - - Status = AcpiUtGetResourceEndTag (Operand0, &EndTag); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer); - - /* Get the length of the second resource template */ - - Status = AcpiUtGetResourceEndTag (Operand1, &EndTag); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer); - - /* Combine both lengths, minimum size will be 2 for EndTag */ - - NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG); - - /* Create a new buffer object for the result (with one EndTag) */ - - ReturnDesc = AcpiUtCreateBufferObject (NewLength); - if (!ReturnDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* - * Copy the templates to the new buffer, 0 first, then 1 follows. One - * EndTag descriptor is copied from Operand1. - */ - NewBuf = ReturnDesc->Buffer.Pointer; - memcpy (NewBuf, Operand0->Buffer.Pointer, Length0); - memcpy (NewBuf + Length0, Operand1->Buffer.Pointer, Length1); - - /* Insert EndTag and set the checksum to zero, means "ignore checksum" */ - - NewBuf[NewLength - 1] = 0; - NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1; - - /* Return the completed resource template */ - - *ActualReturnDesc = ReturnDesc; - return_ACPI_STATUS (AE_OK); -} diff --git a/Private/acpiSDK/source/components/executer/exconfig.c b/Private/acpiSDK/source/components/executer/exconfig.c deleted file mode 100644 index ae95a920..00000000 --- a/Private/acpiSDK/source/components/executer/exconfig.c +++ /dev/null @@ -1,743 +0,0 @@ -/****************************************************************************** - * - * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes) - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "actables.h" -#include "acdispat.h" -#include "acevents.h" -#include "amlcode.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exconfig") - -/* Local prototypes */ - -static ACPI_STATUS -AcpiExAddTable ( - UINT32 TableIndex, - ACPI_OPERAND_OBJECT **DdbHandle); - -static ACPI_STATUS -AcpiExRegionRead ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 Length, - UINT8 *Buffer); - - -/******************************************************************************* - * - * FUNCTION: AcpiExAddTable - * - * PARAMETERS: Table - Pointer to raw table - * ParentNode - Where to load the table (scope) - * DdbHandle - Where to return the table handle. - * - * RETURN: Status - * - * DESCRIPTION: Common function to Install and Load an ACPI table with a - * returned table handle. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiExAddTable ( - UINT32 TableIndex, - ACPI_OPERAND_OBJECT **DdbHandle) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - - - ACPI_FUNCTION_TRACE (ExAddTable); - - - /* Create an object to be the table handle */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); - if (!ObjDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Init the table handle */ - - ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; - ObjDesc->Reference.Class = ACPI_REFCLASS_TABLE; - ObjDesc->Reference.Value = TableIndex; - *DdbHandle = ObjDesc; - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExLoadTableOp - * - * PARAMETERS: WalkState - Current state with operands - * ReturnDesc - Where to store the return object - * - * RETURN: Status - * - * DESCRIPTION: Load an ACPI table from the RSDT/XSDT - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExLoadTableOp ( - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT **ReturnDesc) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_NAMESPACE_NODE *ParentNode; - ACPI_NAMESPACE_NODE *StartNode; - ACPI_NAMESPACE_NODE *ParameterNode = NULL; - ACPI_OPERAND_OBJECT *ReturnObj; - ACPI_OPERAND_OBJECT *DdbHandle; - UINT32 TableIndex; - - - ACPI_FUNCTION_TRACE (ExLoadTableOp); - - - /* Create the return object */ - - ReturnObj = AcpiUtCreateIntegerObject ((UINT64) 0); - if (!ReturnObj) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - *ReturnDesc = ReturnObj; - - /* Find the ACPI table in the RSDT/XSDT */ - - AcpiExExitInterpreter (); - Status = AcpiTbFindTable ( - Operand[0]->String.Pointer, - Operand[1]->String.Pointer, - Operand[2]->String.Pointer, &TableIndex); - AcpiExEnterInterpreter (); - if (ACPI_FAILURE (Status)) - { - if (Status != AE_NOT_FOUND) - { - return_ACPI_STATUS (Status); - } - - /* Table not found, return an Integer=0 and AE_OK */ - - return_ACPI_STATUS (AE_OK); - } - - /* Default nodes */ - - StartNode = WalkState->ScopeInfo->Scope.Node; - ParentNode = AcpiGbl_RootNode; - - /* RootPath (optional parameter) */ - - if (Operand[3]->String.Length > 0) - { - /* - * Find the node referenced by the RootPathString. This is the - * location within the namespace where the table will be loaded. - */ - Status = AcpiNsGetNodeUnlocked (StartNode, - Operand[3]->String.Pointer, ACPI_NS_SEARCH_PARENT, - &ParentNode); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* ParameterPath (optional parameter) */ - - if (Operand[4]->String.Length > 0) - { - if ((Operand[4]->String.Pointer[0] != AML_ROOT_PREFIX) && - (Operand[4]->String.Pointer[0] != AML_PARENT_PREFIX)) - { - /* - * Path is not absolute, so it will be relative to the node - * referenced by the RootPathString (or the NS root if omitted) - */ - StartNode = ParentNode; - } - - /* Find the node referenced by the ParameterPathString */ - - Status = AcpiNsGetNodeUnlocked (StartNode, - Operand[4]->String.Pointer, ACPI_NS_SEARCH_PARENT, - &ParameterNode); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Load the table into the namespace */ - - ACPI_INFO (("Dynamic OEM Table Load:")); - AcpiExExitInterpreter (); - Status = AcpiTbLoadTable (TableIndex, ParentNode); - AcpiExEnterInterpreter (); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Status = AcpiExAddTable (TableIndex, &DdbHandle); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Complete the initialization/resolution of new objects */ - - AcpiExExitInterpreter(); - AcpiNsInitializeObjects(); - AcpiExEnterInterpreter(); - - /* Parameter Data (optional) */ - - if (ParameterNode) - { - /* Store the parameter data into the optional parameter object */ - - Status = AcpiExStore (Operand[5], - ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), WalkState); - if (ACPI_FAILURE (Status)) - { - (void) AcpiExUnloadTable (DdbHandle); - - AcpiUtRemoveReference (DdbHandle); - return_ACPI_STATUS (Status); - } - } - - /* Remove the reference to DdbHandle created by AcpiExAddTable above */ - - AcpiUtRemoveReference (DdbHandle); - - /* Return -1 (non-zero) indicates success */ - - ReturnObj->Integer.Value = 0xFFFFFFFFFFFFFFFF; - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExRegionRead - * - * PARAMETERS: ObjDesc - Region descriptor - * Length - Number of bytes to read - * Buffer - Pointer to where to put the data - * - * RETURN: Status - * - * DESCRIPTION: Read data from an operation region. The read starts from the - * beginning of the region. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiExRegionRead ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 Length, - UINT8 *Buffer) -{ - ACPI_STATUS Status; - UINT64 Value; - UINT32 RegionOffset = 0; - UINT32 i; - - - /* Bytewise reads */ - - for (i = 0; i < Length; i++) - { - Status = AcpiEvAddressSpaceDispatch (ObjDesc, NULL, ACPI_READ, - RegionOffset, 8, &Value); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - *Buffer = (UINT8) Value; - Buffer++; - RegionOffset++; - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExLoadOp - * - * PARAMETERS: ObjDesc - Region or Buffer/Field where the table will be - * obtained - * Target - Where the status of the load will be stored - * WalkState - Current state - * - * RETURN: Status - * - * DESCRIPTION: Load an ACPI table from a field or operation region - * - * NOTE: Region Fields (Field, BankField, IndexFields) are resolved to buffer - * objects before this code is reached. - * - * If source is an operation region, it must refer to SystemMemory, as - * per the ACPI specification. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExLoadOp ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT *Target, - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT *DdbHandle; - ACPI_TABLE_HEADER *TableHeader; - ACPI_TABLE_HEADER *Table; - UINT32 TableIndex; - ACPI_STATUS Status; - UINT32 Length; - - - ACPI_FUNCTION_TRACE (ExLoadOp); - - - if (Target->Common.DescriptorType == ACPI_DESC_TYPE_NAMED) - { - Target = AcpiNsGetAttachedObject (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Target)); - } - if (Target->Common.Type != ACPI_TYPE_INTEGER) - { - ACPI_ERROR ((AE_INFO, "Type not integer: %X", Target->Common.Type)); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - Target->Integer.Value = 0; - - /* Source Object can be either an OpRegion or a Buffer/Field */ - - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_REGION: - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Load table from Region %p\n", ObjDesc)); - - /* Region must be SystemMemory (from ACPI spec) */ - - if (ObjDesc->Region.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) - { - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - /* - * If the Region Address and Length have not been previously - * evaluated, evaluate them now and save the results. - */ - if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) - { - Status = AcpiDsGetRegionArguments (ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Get the table header first so we can get the table length */ - - TableHeader = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER)); - if (!TableHeader) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - Status = AcpiExRegionRead (ObjDesc, sizeof (ACPI_TABLE_HEADER), - ACPI_CAST_PTR (UINT8, TableHeader)); - Length = TableHeader->Length; - ACPI_FREE (TableHeader); - - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Must have at least an ACPI table header */ - - if (Length < sizeof (ACPI_TABLE_HEADER)) - { - return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); - } - - /* - * The original implementation simply mapped the table, with no copy. - * However, the memory region is not guaranteed to remain stable and - * we must copy the table to a local buffer. For example, the memory - * region is corrupted after suspend on some machines. Dynamically - * loaded tables are usually small, so this overhead is minimal. - * - * The latest implementation (5/2009) does not use a mapping at all. - * We use the low-level operation region interface to read the table - * instead of the obvious optimization of using a direct mapping. - * This maintains a consistent use of operation regions across the - * entire subsystem. This is important if additional processing must - * be performed in the (possibly user-installed) operation region - * handler. For example, AcpiExec and ASLTS depend on this. - */ - - /* Allocate a buffer for the table */ - - Table = ACPI_ALLOCATE (Length); - if (!Table) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Read the entire table */ - - Status = AcpiExRegionRead (ObjDesc, Length, - ACPI_CAST_PTR (UINT8, Table)); - if (ACPI_FAILURE (Status)) - { - ACPI_FREE (Table); - return_ACPI_STATUS (Status); - } - break; - - case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */ - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Load table from Buffer or Field %p\n", ObjDesc)); - - /* Must have at least an ACPI table header */ - - if (ObjDesc->Buffer.Length < sizeof (ACPI_TABLE_HEADER)) - { - return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); - } - - /* Get the actual table length from the table header */ - - TableHeader = ACPI_CAST_PTR ( - ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer); - Length = TableHeader->Length; - - /* Table cannot extend beyond the buffer */ - - if (Length > ObjDesc->Buffer.Length) - { - return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); - } - if (Length < sizeof (ACPI_TABLE_HEADER)) - { - return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); - } - - /* - * Copy the table from the buffer because the buffer could be - * modified or even deleted in the future - */ - Table = ACPI_ALLOCATE (Length); - if (!Table) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - memcpy (Table, TableHeader, Length); - break; - - default: - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - /* Install the new table into the local data structures */ - - ACPI_INFO (("Dynamic OEM Table Load:")); - AcpiExExitInterpreter (); - Status = AcpiTbInstallAndLoadTable (ACPI_PTR_TO_PHYSADDR (Table), - ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, Table, TRUE, &TableIndex); - AcpiExEnterInterpreter (); - if (ACPI_FAILURE (Status)) - { - /* Delete allocated table buffer */ - - ACPI_FREE (Table); - return_ACPI_STATUS (Status); - } - - /* - * Add the table to the namespace. - * - * Note: Load the table objects relative to the root of the namespace. - * This appears to go against the ACPI specification, but we do it for - * compatibility with other ACPI implementations. - */ - Status = AcpiExAddTable (TableIndex, &DdbHandle); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Complete the initialization/resolution of new objects */ - - AcpiExExitInterpreter (); - AcpiNsInitializeObjects (); - AcpiExEnterInterpreter (); - - /* Remove the reference to DdbHandle created by AcpiExAddTable above */ - - AcpiUtRemoveReference (DdbHandle); - - /* Return -1 (non-zero) indicates success */ - - Target->Integer.Value = 0xFFFFFFFFFFFFFFFF; - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExUnloadTable - * - * PARAMETERS: DdbHandle - Handle to a previously loaded table - * - * RETURN: Status - * - * DESCRIPTION: Unload an ACPI table - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExUnloadTable ( - ACPI_OPERAND_OBJECT *DdbHandle) -{ - ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *TableDesc = DdbHandle; - UINT32 TableIndex; - - - ACPI_FUNCTION_TRACE (ExUnloadTable); - - - /* - * Temporarily emit a warning so that the ASL for the machine can be - * hopefully obtained. This is to say that the Unload() operator is - * extremely rare if not completely unused. - */ - ACPI_WARNING ((AE_INFO, - "Received request to unload an ACPI table")); - - /* - * May 2018: Unload is no longer supported for the following reasons: - * 1) A correct implementation on some hosts may not be possible. - * 2) Other ACPI implementations do not correctly/fully support it. - * 3) It requires host device driver support which does not exist. - * (To properly support namespace unload out from underneath.) - * 4) This AML operator has never been seen in the field. - */ - ACPI_EXCEPTION ((AE_INFO, AE_NOT_IMPLEMENTED, - "AML Unload operator is not supported")); - - /* - * Validate the handle - * Although the handle is partially validated in AcpiExReconfiguration() - * when it calls AcpiExResolveOperands(), the handle is more completely - * validated here. - * - * Handle must be a valid operand object of type reference. Also, the - * DdbHandle must still be marked valid (table has not been previously - * unloaded) - */ - if ((!DdbHandle) || - (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) || - (DdbHandle->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) || - (!(DdbHandle->Common.Flags & AOPOBJ_DATA_VALID))) - { - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - /* Get the table index from the DdbHandle */ - - TableIndex = TableDesc->Reference.Value; - - /* - * Release the interpreter lock so that the table lock won't have - * strict order requirement against it. - */ - AcpiExExitInterpreter (); - Status = AcpiTbUnloadTable (TableIndex); - AcpiExEnterInterpreter (); - - /* - * Invalidate the handle. We do this because the handle may be stored - * in a named object and may not be actually deleted until much later. - */ - if (ACPI_SUCCESS (Status)) - { - DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID; - } - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exconvrt.c b/Private/acpiSDK/source/components/executer/exconvrt.c deleted file mode 100644 index 3382b520..00000000 --- a/Private/acpiSDK/source/components/executer/exconvrt.c +++ /dev/null @@ -1,882 +0,0 @@ -/****************************************************************************** - * - * Module Name: exconvrt - Object conversion routines - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "amlcode.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exconvrt") - -/* Local prototypes */ - -static UINT32 -AcpiExConvertToAscii ( - UINT64 Integer, - UINT16 Base, - UINT8 *String, - UINT8 MaxLength); - - -/******************************************************************************* - * - * FUNCTION: AcpiExConvertToInteger - * - * PARAMETERS: ObjDesc - Object to be converted. Must be an - * Integer, Buffer, or String - * ResultDesc - Where the new Integer object is returned - * ImplicitConversion - Used for string conversion - * - * RETURN: Status - * - * DESCRIPTION: Convert an ACPI Object to an integer. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExConvertToInteger ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ResultDesc, - UINT32 ImplicitConversion) -{ - ACPI_OPERAND_OBJECT *ReturnDesc; - UINT8 *Pointer; - UINT64 Result; - UINT32 i; - UINT32 Count; - - - ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc); - - - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_INTEGER: - - /* No conversion necessary */ - - *ResultDesc = ObjDesc; - return_ACPI_STATUS (AE_OK); - - case ACPI_TYPE_BUFFER: - case ACPI_TYPE_STRING: - - /* Note: Takes advantage of common buffer/string fields */ - - Pointer = ObjDesc->Buffer.Pointer; - Count = ObjDesc->Buffer.Length; - break; - - default: - - return_ACPI_STATUS (AE_TYPE); - } - - /* - * Convert the buffer/string to an integer. Note that both buffers and - * strings are treated as raw data - we don't convert ascii to hex for - * strings. - * - * There are two terminating conditions for the loop: - * 1) The size of an integer has been reached, or - * 2) The end of the buffer or string has been reached - */ - Result = 0; - - /* String conversion is different than Buffer conversion */ - - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_STRING: - /* - * Convert string to an integer - for most cases, the string must be - * hexadecimal as per the ACPI specification. The only exception (as - * of ACPI 3.0) is that the ToInteger() operator allows both decimal - * and hexadecimal strings (hex prefixed with "0x"). - * - * Explicit conversion is used only by ToInteger. - * All other string-to-integer conversions are implicit conversions. - */ - if (ImplicitConversion) - { - Result = AcpiUtImplicitStrtoul64 (ACPI_CAST_PTR (char, Pointer)); - } - else - { - Result = AcpiUtExplicitStrtoul64 (ACPI_CAST_PTR (char, Pointer)); - } - break; - - case ACPI_TYPE_BUFFER: - - /* Check for zero-length buffer */ - - if (!Count) - { - return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); - } - - /* Transfer no more than an integer's worth of data */ - - if (Count > AcpiGbl_IntegerByteWidth) - { - Count = AcpiGbl_IntegerByteWidth; - } - - /* - * Convert buffer to an integer - we simply grab enough raw data - * from the buffer to fill an integer - */ - for (i = 0; i < Count; i++) - { - /* - * Get next byte and shift it into the Result. - * Little endian is used, meaning that the first byte of the buffer - * is the LSB of the integer - */ - Result |= (((UINT64) Pointer[i]) << (i * 8)); - } - break; - - default: - - /* No other types can get here */ - - break; - } - - /* Create a new integer */ - - ReturnDesc = AcpiUtCreateIntegerObject (Result); - if (!ReturnDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Result))); - - /* Save the Result */ - - (void) AcpiExTruncateFor32bitTable (ReturnDesc); - *ResultDesc = ReturnDesc; - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExConvertToBuffer - * - * PARAMETERS: ObjDesc - Object to be converted. Must be an - * Integer, Buffer, or String - * ResultDesc - Where the new buffer object is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an ACPI Object to a Buffer - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExConvertToBuffer ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ResultDesc) -{ - ACPI_OPERAND_OBJECT *ReturnDesc; - UINT8 *NewBuf; - - - ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc); - - - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_BUFFER: - - /* No conversion necessary */ - - *ResultDesc = ObjDesc; - return_ACPI_STATUS (AE_OK); - - - case ACPI_TYPE_INTEGER: - /* - * Create a new Buffer object. - * Need enough space for one integer - */ - ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth); - if (!ReturnDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Copy the integer to the buffer, LSB first */ - - NewBuf = ReturnDesc->Buffer.Pointer; - memcpy (NewBuf, &ObjDesc->Integer.Value, AcpiGbl_IntegerByteWidth); - break; - - case ACPI_TYPE_STRING: - /* - * Create a new Buffer object - * Size will be the string length - * - * NOTE: Add one to the string length to include the null terminator. - * The ACPI spec is unclear on this subject, but there is existing - * ASL/AML code that depends on the null being transferred to the new - * buffer. - */ - ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) - ObjDesc->String.Length + 1); - if (!ReturnDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Copy the string to the buffer */ - - NewBuf = ReturnDesc->Buffer.Pointer; - strncpy ((char *) NewBuf, (char *) ObjDesc->String.Pointer, - ObjDesc->String.Length); - break; - - default: - - return_ACPI_STATUS (AE_TYPE); - } - - /* Mark buffer initialized */ - - ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID; - *ResultDesc = ReturnDesc; - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExConvertToAscii - * - * PARAMETERS: Integer - Value to be converted - * Base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX - * String - Where the string is returned - * DataWidth - Size of data item to be converted, in bytes - * - * RETURN: Actual string length - * - * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string - * - ******************************************************************************/ - -static UINT32 -AcpiExConvertToAscii ( - UINT64 Integer, - UINT16 Base, - UINT8 *String, - UINT8 DataWidth) -{ - UINT64 Digit; - UINT32 i; - UINT32 j; - UINT32 k = 0; - UINT32 HexLength; - UINT32 DecimalLength; - UINT32 Remainder; - BOOLEAN SupressZeros; - - - ACPI_FUNCTION_ENTRY (); - - - switch (Base) - { - case 10: - - /* Setup max length for the decimal number */ - - switch (DataWidth) - { - case 1: - - DecimalLength = ACPI_MAX8_DECIMAL_DIGITS; - break; - - case 4: - - DecimalLength = ACPI_MAX32_DECIMAL_DIGITS; - break; - - case 8: - default: - - DecimalLength = ACPI_MAX64_DECIMAL_DIGITS; - break; - } - - SupressZeros = TRUE; /* No leading zeros */ - Remainder = 0; - - for (i = DecimalLength; i > 0; i--) - { - /* Divide by nth factor of 10 */ - - Digit = Integer; - for (j = 0; j < i; j++) - { - (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder); - } - - /* Handle leading zeros */ - - if (Remainder != 0) - { - SupressZeros = FALSE; - } - - if (!SupressZeros) - { - String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder); - k++; - } - } - break; - - case 16: - - /* HexLength: 2 ascii hex chars per data byte */ - - HexLength = (DataWidth * 2); - for (i = 0, j = (HexLength-1); i < HexLength; i++, j--) - { - /* Get one hex digit, most significant digits first */ - - String[k] = (UINT8) - AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j)); - k++; - } - break; - - default: - return (0); - } - - /* - * Since leading zeros are suppressed, we must check for the case where - * the integer equals 0 - * - * Finally, null terminate the string and return the length - */ - if (!k) - { - String [0] = ACPI_ASCII_ZERO; - k = 1; - } - - String [k] = 0; - return ((UINT32) k); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExConvertToString - * - * PARAMETERS: ObjDesc - Object to be converted. Must be an - * Integer, Buffer, or String - * ResultDesc - Where the string object is returned - * Type - String flags (base and conversion type) - * - * RETURN: Status - * - * DESCRIPTION: Convert an ACPI Object to a string. Supports both implicit - * and explicit conversions and related rules. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExConvertToString ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ResultDesc, - UINT32 Type) -{ - ACPI_OPERAND_OBJECT *ReturnDesc; - UINT8 *NewBuf; - UINT32 i; - UINT32 StringLength = 0; - UINT16 Base = 16; - UINT8 Separator = ','; - - - ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc); - - - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_STRING: - - /* No conversion necessary */ - - *ResultDesc = ObjDesc; - return_ACPI_STATUS (AE_OK); - - case ACPI_TYPE_INTEGER: - - switch (Type) - { - case ACPI_EXPLICIT_CONVERT_DECIMAL: - /* - * From ToDecimalString, integer source. - * - * Make room for the maximum decimal number size - */ - StringLength = ACPI_MAX_DECIMAL_DIGITS; - Base = 10; - break; - - default: - - /* Two hex string characters for each integer byte */ - - StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth); - break; - } - - /* - * Create a new String - * Need enough space for one ASCII integer (plus null terminator) - */ - ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength); - if (!ReturnDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - NewBuf = ReturnDesc->Buffer.Pointer; - - /* Convert integer to string */ - - StringLength = AcpiExConvertToAscii ( - ObjDesc->Integer.Value, Base, NewBuf, AcpiGbl_IntegerByteWidth); - - /* Null terminate at the correct place */ - - ReturnDesc->String.Length = StringLength; - NewBuf [StringLength] = 0; - break; - - case ACPI_TYPE_BUFFER: - - /* Setup string length, base, and separator */ - - switch (Type) - { - case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */ - /* - * Explicit conversion from the ToDecimalString ASL operator. - * - * From ACPI: "If the input is a buffer, it is converted to a - * a string of decimal values separated by commas." - */ - Base = 10; - - /* - * Calculate the final string length. Individual string values - * are variable length (include separator for each) - */ - for (i = 0; i < ObjDesc->Buffer.Length; i++) - { - if (ObjDesc->Buffer.Pointer[i] >= 100) - { - StringLength += 4; - } - else if (ObjDesc->Buffer.Pointer[i] >= 10) - { - StringLength += 3; - } - else - { - StringLength += 2; - } - } - break; - - case ACPI_IMPLICIT_CONVERT_HEX: - /* - * Implicit buffer-to-string conversion - * - * From the ACPI spec: - * "The entire contents of the buffer are converted to a string of - * two-character hexadecimal numbers, each separated by a space." - * - * Each hex number is prefixed with 0x (11/2018) - */ - Separator = ' '; - StringLength = (ObjDesc->Buffer.Length * 5); - break; - - case ACPI_EXPLICIT_CONVERT_HEX: - /* - * Explicit conversion from the ToHexString ASL operator. - * - * From ACPI: "If Data is a buffer, it is converted to a string of - * hexadecimal values separated by commas." - * - * Each hex number is prefixed with 0x (11/2018) - */ - Separator = ','; - StringLength = (ObjDesc->Buffer.Length * 5); - break; - - default: - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* - * Create a new string object and string buffer - * (-1 because of extra separator included in StringLength from above) - * Allow creation of zero-length strings from zero-length buffers. - */ - if (StringLength) - { - StringLength--; - } - - ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength); - if (!ReturnDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - NewBuf = ReturnDesc->Buffer.Pointer; - - /* - * Convert buffer bytes to hex or decimal values - * (separated by commas or spaces) - */ - for (i = 0; i < ObjDesc->Buffer.Length; i++) - { - if (Base == 16) - { - /* Emit 0x prefix for explicit/implicit hex conversion */ - - *NewBuf++ = '0'; - *NewBuf++ = 'x'; - } - - NewBuf += AcpiExConvertToAscii ( - (UINT64) ObjDesc->Buffer.Pointer[i], Base, NewBuf, 1); - - /* Each digit is separated by either a comma or space */ - - *NewBuf++ = Separator; - } - - /* - * Null terminate the string - * (overwrites final comma/space from above) - */ - if (ObjDesc->Buffer.Length) - { - NewBuf--; - } - *NewBuf = 0; - break; - - default: - - return_ACPI_STATUS (AE_TYPE); - } - - *ResultDesc = ReturnDesc; - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExConvertToTargetType - * - * PARAMETERS: DestinationType - Current type of the destination - * SourceDesc - Source object to be converted. - * ResultDesc - Where the converted object is returned - * WalkState - Current method state - * - * RETURN: Status - * - * DESCRIPTION: Implements "implicit conversion" rules for storing an object. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExConvertToTargetType ( - ACPI_OBJECT_TYPE DestinationType, - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT **ResultDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE (ExConvertToTargetType); - - - /* Default behavior */ - - *ResultDesc = SourceDesc; - - /* - * If required by the target, - * perform implicit conversion on the source before we store it. - */ - switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs)) - { - case ARGI_SIMPLE_TARGET: - case ARGI_FIXED_TARGET: - case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */ - - switch (DestinationType) - { - case ACPI_TYPE_LOCAL_REGION_FIELD: - /* - * Named field can always handle conversions - */ - break; - - default: - - /* No conversion allowed for these types */ - - if (DestinationType != SourceDesc->Common.Type) - { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Explicit operator, will store (%s) over existing type (%s)\n", - AcpiUtGetObjectTypeName (SourceDesc), - AcpiUtGetTypeName (DestinationType))); - Status = AE_TYPE; - } - } - break; - - case ARGI_TARGETREF: - case ARGI_STORE_TARGET: - - switch (DestinationType) - { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_BUFFER_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: - /* - * These types require an Integer operand. We can convert - * a Buffer or a String to an Integer if necessary. - */ - Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, - ACPI_IMPLICIT_CONVERSION); - break; - - case ACPI_TYPE_STRING: - /* - * The operand must be a String. We can convert an - * Integer or Buffer if necessary - */ - Status = AcpiExConvertToString (SourceDesc, ResultDesc, - ACPI_IMPLICIT_CONVERT_HEX); - break; - - case ACPI_TYPE_BUFFER: - /* - * The operand must be a Buffer. We can convert an - * Integer or String if necessary - */ - Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc); - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Bad destination type during conversion: 0x%X", - DestinationType)); - Status = AE_AML_INTERNAL; - break; - } - break; - - case ARGI_REFERENCE: - /* - * CreateXxxxField cases - we are storing the field object into the name - */ - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s", - GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs), - WalkState->Opcode, AcpiUtGetTypeName (DestinationType))); - Status = AE_AML_INTERNAL; - } - - /* - * Source-to-Target conversion semantics: - * - * If conversion to the target type cannot be performed, then simply - * overwrite the target with the new object and type. - */ - if (Status == AE_TYPE) - { - Status = AE_OK; - } - - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/excreate.c b/Private/acpiSDK/source/components/executer/excreate.c deleted file mode 100644 index 56355726..00000000 --- a/Private/acpiSDK/source/components/executer/excreate.c +++ /dev/null @@ -1,660 +0,0 @@ -/****************************************************************************** - * - * Module Name: excreate - Named object creation - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acnamesp.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("excreate") - - -/******************************************************************************* - * - * FUNCTION: AcpiExCreateAlias - * - * PARAMETERS: WalkState - Current state, contains operands - * - * RETURN: Status - * - * DESCRIPTION: Create a new named alias - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExCreateAlias ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_NAMESPACE_NODE *TargetNode; - ACPI_NAMESPACE_NODE *AliasNode; - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE (ExCreateAlias); - - - /* Get the source/alias operands (both namespace nodes) */ - - AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; - TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1]; - - if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) || - (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) - { - /* - * Dereference an existing alias so that we don't create a chain - * of aliases. With this code, we guarantee that an alias is - * always exactly one level of indirection away from the - * actual aliased name. - */ - TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object); - } - - /* Ensure that the target node is valid */ - - if (!TargetNode) - { - return_ACPI_STATUS (AE_NULL_OBJECT); - } - - /* Construct the alias object (a namespace node) */ - - switch (TargetNode->Type) - { - case ACPI_TYPE_METHOD: - /* - * Control method aliases need to be differentiated with - * a special type - */ - AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS; - break; - - default: - /* - * All other object types. - * - * The new alias has the type ALIAS and points to the original - * NS node, not the object itself. - */ - AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS; - AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); - break; - } - - /* Since both operands are Nodes, we don't need to delete them */ - - AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExCreateEvent - * - * PARAMETERS: WalkState - Current state - * - * RETURN: Status - * - * DESCRIPTION: Create a new event object - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExCreateEvent ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; - - - ACPI_FUNCTION_TRACE (ExCreateEvent); - - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* - * Create the actual OS semaphore, with zero initial units -- meaning - * that the event is created in an unsignalled state - */ - Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, - &ObjDesc->Event.OsSemaphore); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Attach object to the Node */ - - Status = AcpiNsAttachObject ( - (ACPI_NAMESPACE_NODE *) WalkState->Operands[0], - ObjDesc, ACPI_TYPE_EVENT); - -Cleanup: - /* - * Remove local reference to the object (on error, will cause deletion - * of both object and semaphore if present.) - */ - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExCreateMutex - * - * PARAMETERS: WalkState - Current state - * - * RETURN: Status - * - * DESCRIPTION: Create a new mutex object - * - * Mutex (Name[0], SyncLevel[1]) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExCreateMutex ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *ObjDesc; - - - ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS); - - - /* Create the new mutex object */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Create the actual OS Mutex */ - - Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Init object and attach to NS node */ - - ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value; - ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; - - Status = AcpiNsAttachObject ( - ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX); - - -Cleanup: - /* - * Remove local reference to the object (on error, will cause deletion - * of both object and semaphore if present.) - */ - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExCreateRegion - * - * PARAMETERS: AmlStart - Pointer to the region declaration AML - * AmlLength - Max length of the declaration AML - * SpaceId - Address space ID for the region - * WalkState - Current state - * - * RETURN: Status - * - * DESCRIPTION: Create a new operation region object - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExCreateRegion ( - UINT8 *AmlStart, - UINT32 AmlLength, - UINT8 SpaceId, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_NAMESPACE_NODE *Node; - ACPI_OPERAND_OBJECT *RegionObj2; - - - ACPI_FUNCTION_TRACE (ExCreateRegion); - - - /* Get the Namespace Node */ - - Node = WalkState->Op->Common.Node; - - /* - * If the region object is already attached to this node, - * just return - */ - if (AcpiNsGetAttachedObject (Node)) - { - return_ACPI_STATUS (AE_OK); - } - - /* - * Space ID must be one of the predefined IDs, or in the user-defined - * range - */ - if (!AcpiIsValidSpaceId (SpaceId)) - { - /* - * Print an error message, but continue. We don't want to abort - * a table load for this exception. Instead, if the region is - * actually used at runtime, abort the executing method. - */ - ACPI_ERROR ((AE_INFO, - "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId)); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n", - AcpiUtGetRegionName (SpaceId), SpaceId)); - - /* Create the region descriptor */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* - * Remember location in AML stream of address & length - * operands since they need to be evaluated at run time. - */ - RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc); - RegionObj2->Extra.AmlStart = AmlStart; - RegionObj2->Extra.AmlLength = AmlLength; - RegionObj2->Extra.Method_REG = NULL; - if (WalkState->ScopeInfo) - { - RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node; - } - else - { - RegionObj2->Extra.ScopeNode = Node; - } - - /* Init the region from the operands */ - - ObjDesc->Region.SpaceId = SpaceId; - ObjDesc->Region.Address = 0; - ObjDesc->Region.Length = 0; - ObjDesc->Region.Pointer = NULL; - ObjDesc->Region.Node = Node; - ObjDesc->Region.Handler = NULL; - ObjDesc->Common.Flags &= - ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_REG_CONNECTED | - AOPOBJ_OBJECT_INITIALIZED); - - /* Install the new region object in the parent Node */ - - Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); - - -Cleanup: - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExCreateProcessor - * - * PARAMETERS: WalkState - Current state - * - * RETURN: Status - * - * DESCRIPTION: Create a new processor object and populate the fields - * - * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExCreateProcessor ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState); - - - /* Create the processor object */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR); - if (!ObjDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Initialize the processor object from the operands */ - - ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; - ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; - ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value; - - /* Install the processor object in the parent Node */ - - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_PROCESSOR); - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExCreatePowerResource - * - * PARAMETERS: WalkState - Current state - * - * RETURN: Status - * - * DESCRIPTION: Create a new PowerResource object and populate the fields - * - * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExCreatePowerResource ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; - - - ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState); - - - /* Create the power resource object */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER); - if (!ObjDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Initialize the power object from the operands */ - - ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value; - ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value; - - /* Install the power resource object in the parent Node */ - - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_POWER); - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExCreateMethod - * - * PARAMETERS: AmlStart - First byte of the method's AML - * AmlLength - AML byte count for this method - * WalkState - Current state - * - * RETURN: Status - * - * DESCRIPTION: Create a new method object - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExCreateMethod ( - UINT8 *AmlStart, - UINT32 AmlLength, - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; - UINT8 MethodFlags; - - - ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState); - - - /* Create a new method object */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto Exit; - } - - /* Save the method's AML pointer and length */ - - ObjDesc->Method.AmlStart = AmlStart; - ObjDesc->Method.AmlLength = AmlLength; - ObjDesc->Method.Node = Operand[0]; - - /* - * Disassemble the method flags. Split off the ArgCount, Serialized - * flag, and SyncLevel for efficiency. - */ - MethodFlags = (UINT8) Operand[1]->Integer.Value; - ObjDesc->Method.ParamCount = (UINT8) - (MethodFlags & AML_METHOD_ARG_COUNT); - - /* - * Get the SyncLevel. If method is serialized, a mutex will be - * created for this method when it is parsed. - */ - if (MethodFlags & AML_METHOD_SERIALIZED) - { - ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED; - - /* - * ACPI 1.0: SyncLevel = 0 - * ACPI 2.0: SyncLevel = SyncLevel in method declaration - */ - ObjDesc->Method.SyncLevel = (UINT8) - ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); - } - - /* Attach the new object to the method Node */ - - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_METHOD); - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); - -Exit: - /* Remove a reference to the operand */ - - AcpiUtRemoveReference (Operand[1]); - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exdebug.c b/Private/acpiSDK/source/components/executer/exdebug.c deleted file mode 100644 index 5ccfccdb..00000000 --- a/Private/acpiSDK/source/components/executer/exdebug.c +++ /dev/null @@ -1,461 +0,0 @@ -/****************************************************************************** - * - * Module Name: exdebug - Support for stores to the AML Debug Object - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exdebug") - - -#ifndef ACPI_NO_ERROR_MESSAGES -/******************************************************************************* - * - * FUNCTION: AcpiExDoDebugObject - * - * PARAMETERS: SourceDesc - Object to be output to "Debug Object" - * Level - Indentation level (used for packages) - * Index - Current package element, zero if not pkg - * - * RETURN: None - * - * DESCRIPTION: Handles stores to the AML Debug Object. For example: - * Store(INT1, Debug) - * - * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set. - * - * This function is only enabled if AcpiGbl_EnableAmlDebugObject is set, or - * if ACPI_LV_DEBUG_OBJECT is set in the AcpiDbgLevel. Thus, in the normal - * operational case, stores to the debug object are ignored but can be easily - * enabled if necessary. - * - ******************************************************************************/ - -void -AcpiExDoDebugObject ( - ACPI_OPERAND_OBJECT *SourceDesc, - UINT32 Level, - UINT32 Index) -{ - UINT32 i; - UINT32 Timer; - ACPI_OPERAND_OBJECT *ObjectDesc; - UINT32 Value; - - - ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); - - - /* Output must be enabled via the DebugObject global or the DbgLevel */ - - if (!AcpiGbl_EnableAmlDebugObject && - !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT)) - { - return_VOID; - } - - /* Newline -- don't emit the line header */ - - if (SourceDesc && - (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) && - (SourceDesc->Common.Type == ACPI_TYPE_STRING)) - { - if ((SourceDesc->String.Length == 1) && - (*SourceDesc->String.Pointer == '\n')) - { - AcpiOsPrintf ("\n"); - return_VOID; - } - } - - /* - * Print line header as long as we are not in the middle of an - * object display - */ - if (!((Level > 0) && Index == 0)) - { - if (AcpiGbl_DisplayDebugTimer) - { - /* - * We will emit the current timer value (in microseconds) with each - * debug output. Only need the lower 26 bits. This allows for 67 - * million microseconds or 67 seconds before rollover. - * - * Convert 100 nanosecond units to microseconds - */ - Timer = ((UINT32) AcpiOsGetTimer () / 10); - Timer &= 0x03FFFFFF; - - AcpiOsPrintf ("ACPI Debug: T=0x%8.8X %*s", Timer, Level, " "); - } - else - { - AcpiOsPrintf ("ACPI Debug: %*s", Level, " "); - } - } - - /* Display the index for package output only */ - - if (Index > 0) - { - AcpiOsPrintf ("(%.2u) ", Index - 1); - } - - if (!SourceDesc) - { - AcpiOsPrintf ("[Null Object]\n"); - return_VOID; - } - - if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) - { - /* No object type prefix needed for integers and strings */ - - if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) && - (SourceDesc->Common.Type != ACPI_TYPE_STRING)) - { - AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc)); - } - - if (!AcpiUtValidInternalObject (SourceDesc)) - { - AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc); - return_VOID; - } - } - else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) - { - AcpiOsPrintf ("%s (Node %p)\n", - AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type), - SourceDesc); - return_VOID; - } - else - { - return_VOID; - } - - /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */ - - switch (SourceDesc->Common.Type) - { - case ACPI_TYPE_INTEGER: - - /* Output correct integer width */ - - if (AcpiGbl_IntegerByteWidth == 4) - { - AcpiOsPrintf ("0x%8.8X\n", - (UINT32) SourceDesc->Integer.Value); - } - else - { - AcpiOsPrintf ("0x%8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value)); - } - break; - - case ACPI_TYPE_BUFFER: - - AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length); - AcpiUtDumpBuffer (SourceDesc->Buffer.Pointer, - (SourceDesc->Buffer.Length < 256) ? - SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY, 0); - break; - - case ACPI_TYPE_STRING: - - AcpiOsPrintf ("\"%s\"\n", SourceDesc->String.Pointer); - break; - - case ACPI_TYPE_PACKAGE: - - AcpiOsPrintf ("(Contains 0x%.2X Elements):\n", - SourceDesc->Package.Count); - - /* Output the entire contents of the package */ - - for (i = 0; i < SourceDesc->Package.Count; i++) - { - AcpiExDoDebugObject (SourceDesc->Package.Elements[i], - Level + 4, i + 1); - } - break; - - case ACPI_TYPE_LOCAL_REFERENCE: - - AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc)); - - /* Decode the reference */ - - switch (SourceDesc->Reference.Class) - { - case ACPI_REFCLASS_INDEX: - - AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value); - break; - - case ACPI_REFCLASS_TABLE: - - /* Case for DdbHandle */ - - AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value); - return_VOID; - - default: - - break; - } - - AcpiOsPrintf (" "); - - /* Check for valid node first, then valid object */ - - if (SourceDesc->Reference.Node) - { - if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) != - ACPI_DESC_TYPE_NAMED) - { - AcpiOsPrintf (" %p - Not a valid namespace node\n", - SourceDesc->Reference.Node); - } - else - { - AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node, - (SourceDesc->Reference.Node)->Name.Ascii); - - switch ((SourceDesc->Reference.Node)->Type) - { - /* These types have no attached object */ - - case ACPI_TYPE_DEVICE: - AcpiOsPrintf ("Device\n"); - break; - - case ACPI_TYPE_THERMAL: - AcpiOsPrintf ("Thermal Zone\n"); - break; - - default: - - AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object, - Level + 4, 0); - break; - } - } - } - else if (SourceDesc->Reference.Object) - { - if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) == - ACPI_DESC_TYPE_NAMED) - { - /* Reference object is a namespace node */ - - AcpiExDoDebugObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, - SourceDesc->Reference.Object), - Level + 4, 0); - } - else - { - ObjectDesc = SourceDesc->Reference.Object; - Value = SourceDesc->Reference.Value; - - switch (ObjectDesc->Common.Type) - { - case ACPI_TYPE_BUFFER: - - AcpiOsPrintf ("Buffer[%u] = 0x%2.2X\n", - Value, *SourceDesc->Reference.IndexPointer); - break; - - case ACPI_TYPE_STRING: - - AcpiOsPrintf ("String[%u] = \"%c\" (0x%2.2X)\n", - Value, *SourceDesc->Reference.IndexPointer, - *SourceDesc->Reference.IndexPointer); - break; - - case ACPI_TYPE_PACKAGE: - - AcpiOsPrintf ("Package[%u] = ", Value); - if (!(*SourceDesc->Reference.Where)) - { - AcpiOsPrintf ("[Uninitialized Package Element]\n"); - } - else - { - AcpiExDoDebugObject (*SourceDesc->Reference.Where, - Level+4, 0); - } - break; - - default: - - AcpiOsPrintf ("Unknown Reference object type %X\n", - ObjectDesc->Common.Type); - break; - } - } - } - break; - - default: - - AcpiOsPrintf ("(Descriptor %p)\n", SourceDesc); - break; - } - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); - return_VOID; -} -#endif diff --git a/Private/acpiSDK/source/components/executer/exdump.c b/Private/acpiSDK/source/components/executer/exdump.c deleted file mode 100644 index 7a2c4a81..00000000 --- a/Private/acpiSDK/source/components/executer/exdump.c +++ /dev/null @@ -1,1420 +0,0 @@ -/****************************************************************************** - * - * Module Name: exdump - Interpreter debug output routines - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acnamesp.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exdump") - -/* - * The following routines are used for debug output only - */ -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) - -/* Local prototypes */ - -static void -AcpiExOutString ( - const char *Title, - const char *Value); - -static void -AcpiExOutPointer ( - const char *Title, - const void *Value); - -static void -AcpiExDumpObject ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_EXDUMP_INFO *Info); - -static void -AcpiExDumpReferenceObj ( - ACPI_OPERAND_OBJECT *ObjDesc); - -static void -AcpiExDumpPackageObj ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 Level, - UINT32 Index); - - -/******************************************************************************* - * - * Object Descriptor info tables - * - * Note: The first table entry must be an INIT opcode and must contain - * the table length (number of table entries) - * - ******************************************************************************/ - -static ACPI_EXDUMP_INFO AcpiExDumpInteger[2] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpInteger), NULL}, - {ACPI_EXD_UINT64, ACPI_EXD_OFFSET (Integer.Value), "Value"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpString[4] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpString), NULL}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (String.Length), "Length"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (String.Pointer), "Pointer"}, - {ACPI_EXD_STRING, 0, NULL} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpBuffer[5] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBuffer), NULL}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Buffer.Length), "Length"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Pointer), "Pointer"}, - {ACPI_EXD_NODE, ACPI_EXD_OFFSET (Buffer.Node), "Parent Node"}, - {ACPI_EXD_BUFFER, 0, NULL} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpPackage[6] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPackage), NULL}, - {ACPI_EXD_NODE, ACPI_EXD_OFFSET (Package.Node), "Parent Node"}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Package.Flags), "Flags"}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Package.Count), "Element Count"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Package.Elements), "Element List"}, - {ACPI_EXD_PACKAGE, 0, NULL} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpDevice[4] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpDevice), NULL}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.NotifyList[0]), "System Notify"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.NotifyList[1]), "Device Notify"}, - {ACPI_EXD_HDLR_LIST,ACPI_EXD_OFFSET (Device.Handler), "Handler"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpEvent[2] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpEvent), NULL}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Event.OsSemaphore), "OsSemaphore"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpMethod[9] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMethod), NULL}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.InfoFlags), "Info Flags"}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ParamCount), "Parameter Count"}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.SyncLevel), "Sync Level"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.Mutex), "Mutex"}, - {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Method.OwnerId), "Owner Id"}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ThreadCount), "Thread Count"}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Method.AmlLength), "Aml Length"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.AmlStart), "Aml Start"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpMutex[6] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMutex), NULL}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Mutex.SyncLevel), "Sync Level"}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Mutex.OriginalSyncLevel), "Original Sync Level"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OwnerThread), "Owner Thread"}, - {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Mutex.AcquisitionDepth), "Acquire Depth"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OsMutex), "OsMutex"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpRegion[8] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegion), NULL}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.SpaceId), "Space Id"}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.Flags), "Flags"}, - {ACPI_EXD_NODE, ACPI_EXD_OFFSET (Region.Node), "Parent Node"}, - {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Region.Address), "Address"}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Region.Length), "Length"}, - {ACPI_EXD_HDLR_LIST,ACPI_EXD_OFFSET (Region.Handler), "Handler"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Next), "Next"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpPower[6] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPower), NULL}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.SystemLevel), "System Level"}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.ResourceOrder), "Resource Order"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.NotifyList[0]), "System Notify"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.NotifyList[1]), "Device Notify"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.Handler), "Handler"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpProcessor[7] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpProcessor), NULL}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Processor.ProcId), "Processor ID"}, - {ACPI_EXD_UINT8 , ACPI_EXD_OFFSET (Processor.Length), "Length"}, - {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Processor.Address), "Address"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.NotifyList[0]), "System Notify"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.NotifyList[1]), "Device Notify"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.Handler), "Handler"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpThermal[4] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpThermal), NULL}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.NotifyList[0]), "System Notify"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.NotifyList[1]), "Device Notify"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.Handler), "Handler"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpBufferField[3] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBufferField), NULL}, - {ACPI_EXD_FIELD, 0, NULL}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BufferField.BufferObj), "Buffer Object"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpRegionField[5] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegionField), NULL}, - {ACPI_EXD_FIELD, 0, NULL}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Field.AccessLength), "AccessLength"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Field.RegionObj), "Region Object"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Field.ResourceBuffer), "ResourceBuffer"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpBankField[5] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL}, - {ACPI_EXD_FIELD, 0, NULL}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (BankField.Value), "Value"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.RegionObj), "Region Object"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.BankObj), "Bank Object"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpIndexField[5] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL}, - {ACPI_EXD_FIELD, 0, NULL}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (IndexField.Value), "Value"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.IndexObj), "Index Object"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.DataObj), "Data Object"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpReference[9] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpReference), NULL}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.Class), "Class"}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.TargetType), "Target Type"}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Reference.Value), "Value"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Object), "Object Desc"}, - {ACPI_EXD_NODE, ACPI_EXD_OFFSET (Reference.Node), "Node"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Where), "Where"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.IndexPointer), "Index Pointer"}, - {ACPI_EXD_REFERENCE,0, NULL} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpAddressHandler[6] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpAddressHandler), NULL}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (AddressSpace.SpaceId), "Space Id"}, - {ACPI_EXD_HDLR_LIST,ACPI_EXD_OFFSET (AddressSpace.Next), "Next"}, - {ACPI_EXD_RGN_LIST, ACPI_EXD_OFFSET (AddressSpace.RegionList), "Region List"}, - {ACPI_EXD_NODE, ACPI_EXD_OFFSET (AddressSpace.Node), "Node"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Context), "Context"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpNotify[7] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNotify), NULL}, - {ACPI_EXD_NODE, ACPI_EXD_OFFSET (Notify.Node), "Node"}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Notify.HandlerType), "Handler Type"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Handler), "Handler"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Context), "Context"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Next[0]), "Next System Notify"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Next[1]), "Next Device Notify"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpExtra[6] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpExtra), NULL}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Extra.Method_REG), "_REG Method"}, - {ACPI_EXD_NODE, ACPI_EXD_OFFSET (Extra.ScopeNode), "Scope Node"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Extra.RegionContext), "Region Context"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Extra.AmlStart), "Aml Start"}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Extra.AmlLength), "Aml Length"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpData[3] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpData), NULL}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Data.Handler), "Handler"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Data.Pointer), "Raw Data"} -}; - -/* Miscellaneous tables */ - -static ACPI_EXDUMP_INFO AcpiExDumpCommon[5] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpCommon), NULL}, - {ACPI_EXD_TYPE , 0, NULL}, - {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Common.ReferenceCount), "Reference Count"}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Common.Flags), "Flags"}, - {ACPI_EXD_LIST, ACPI_EXD_OFFSET (Common.NextObject), "Object List"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpFieldCommon[7] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpFieldCommon), NULL}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.FieldFlags), "Field Flags"}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.AccessByteWidth), "Access Byte Width"}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BitLength), "Bit Length"}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.StartFieldBitOffset),"Field Bit Offset"}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BaseByteOffset), "Base Byte Offset"}, - {ACPI_EXD_NODE, ACPI_EXD_OFFSET (CommonField.Node), "Parent Node"} -}; - -static ACPI_EXDUMP_INFO AcpiExDumpNode[7] = -{ - {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNode), NULL}, - {ACPI_EXD_UINT16, ACPI_EXD_NSOFFSET (Flags), "Flags"}, - {ACPI_EXD_UINT16, ACPI_EXD_NSOFFSET (OwnerId), "Owner Id"}, - {ACPI_EXD_LIST, ACPI_EXD_NSOFFSET (Object), "Object List"}, - {ACPI_EXD_NODE, ACPI_EXD_NSOFFSET (Parent), "Parent"}, - {ACPI_EXD_NODE, ACPI_EXD_NSOFFSET (Child), "Child"}, - {ACPI_EXD_NODE, ACPI_EXD_NSOFFSET (Peer), "Peer"} -}; - - -/* Dispatch table, indexed by object type */ - -static ACPI_EXDUMP_INFO *AcpiExDumpInfo[] = -{ - NULL, - AcpiExDumpInteger, - AcpiExDumpString, - AcpiExDumpBuffer, - AcpiExDumpPackage, - NULL, - AcpiExDumpDevice, - AcpiExDumpEvent, - AcpiExDumpMethod, - AcpiExDumpMutex, - AcpiExDumpRegion, - AcpiExDumpPower, - AcpiExDumpProcessor, - AcpiExDumpThermal, - AcpiExDumpBufferField, - NULL, - NULL, - AcpiExDumpRegionField, - AcpiExDumpBankField, - AcpiExDumpIndexField, - AcpiExDumpReference, - NULL, - NULL, - AcpiExDumpNotify, - AcpiExDumpAddressHandler, - NULL, - NULL, - NULL, - AcpiExDumpExtra, - AcpiExDumpData -}; - - -/******************************************************************************* - * - * FUNCTION: AcpiExDumpObject - * - * PARAMETERS: ObjDesc - Descriptor to dump - * Info - Info table corresponding to this object - * type - * - * RETURN: None - * - * DESCRIPTION: Walk the info table for this object - * - ******************************************************************************/ - -static void -AcpiExDumpObject ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_EXDUMP_INFO *Info) -{ - UINT8 *Target; - const char *Name; - UINT8 Count; - ACPI_OPERAND_OBJECT *Start; - ACPI_OPERAND_OBJECT *Data = NULL; - ACPI_OPERAND_OBJECT *Next; - ACPI_NAMESPACE_NODE *Node; - - - if (!Info) - { - AcpiOsPrintf ( - "ExDumpObject: Display not implemented for object type %s\n", - AcpiUtGetObjectTypeName (ObjDesc)); - return; - } - - /* First table entry must contain the table length (# of table entries) */ - - Count = Info->Offset; - - while (Count) - { - if (!ObjDesc) - { - return; - } - - Target = ACPI_ADD_PTR (UINT8, ObjDesc, Info->Offset); - Name = Info->Name; - - switch (Info->Opcode) - { - case ACPI_EXD_INIT: - - break; - - case ACPI_EXD_TYPE: - - AcpiOsPrintf ("%20s : %2.2X [%s]\n", "Type", - ObjDesc->Common.Type, - AcpiUtGetObjectTypeName (ObjDesc)); - break; - - case ACPI_EXD_UINT8: - - AcpiOsPrintf ("%20s : %2.2X\n", Name, *Target); - break; - - case ACPI_EXD_UINT16: - - AcpiOsPrintf ("%20s : %4.4X\n", Name, ACPI_GET16 (Target)); - break; - - case ACPI_EXD_UINT32: - - AcpiOsPrintf ("%20s : %8.8X\n", Name, ACPI_GET32 (Target)); - break; - - case ACPI_EXD_UINT64: - - AcpiOsPrintf ("%20s : %8.8X%8.8X\n", "Value", - ACPI_FORMAT_UINT64 (ACPI_GET64 (Target))); - break; - - case ACPI_EXD_POINTER: - case ACPI_EXD_ADDRESS: - - AcpiExOutPointer (Name, *ACPI_CAST_PTR (void *, Target)); - break; - - case ACPI_EXD_STRING: - - AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); - AcpiOsPrintf ("\n"); - break; - - case ACPI_EXD_BUFFER: - - ACPI_DUMP_BUFFER ( - ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); - break; - - case ACPI_EXD_PACKAGE: - - /* Dump the package contents */ - - AcpiOsPrintf ("\nPackage Contents:\n"); - AcpiExDumpPackageObj (ObjDesc, 0, 0); - break; - - case ACPI_EXD_FIELD: - - AcpiExDumpObject (ObjDesc, AcpiExDumpFieldCommon); - break; - - case ACPI_EXD_REFERENCE: - - AcpiExOutString ("Class Name", AcpiUtGetReferenceName (ObjDesc)); - AcpiExDumpReferenceObj (ObjDesc); - break; - - case ACPI_EXD_LIST: - - Start = *ACPI_CAST_PTR (void *, Target); - Next = Start; - - AcpiOsPrintf ("%20s : %p ", Name, Next); - if (Next) - { - AcpiOsPrintf ("%s (Type %2.2X)", - AcpiUtGetObjectTypeName (Next), Next->Common.Type); - - while (Next->Common.NextObject) - { - if ((Next->Common.Type == ACPI_TYPE_LOCAL_DATA) && - !Data) - { - Data = Next; - } - - Next = Next->Common.NextObject; - AcpiOsPrintf ("->%p(%s %2.2X)", Next, - AcpiUtGetObjectTypeName (Next), Next->Common.Type); - - if ((Next == Start) || (Next == Data)) - { - AcpiOsPrintf ( - "\n**** Error: Object list appears to be circular linked"); - break; - } - } - } - else - { - AcpiOsPrintf ("- No attached objects"); - } - - AcpiOsPrintf ("\n"); - break; - - case ACPI_EXD_HDLR_LIST: - - Start = *ACPI_CAST_PTR (void *, Target); - Next = Start; - - AcpiOsPrintf ("%20s : %p", Name, Next); - if (Next) - { - AcpiOsPrintf ("(%s %2.2X)", - AcpiUtGetObjectTypeName (Next), - Next->AddressSpace.SpaceId); - - while (Next->AddressSpace.Next) - { - if ((Next->Common.Type == ACPI_TYPE_LOCAL_DATA) && - !Data) - { - Data = Next; - } - - Next = Next->AddressSpace.Next; - AcpiOsPrintf ("->%p(%s %2.2X)", Next, - AcpiUtGetObjectTypeName (Next), - Next->AddressSpace.SpaceId); - - if ((Next == Start) || (Next == Data)) - { - AcpiOsPrintf ( - "\n**** Error: Handler list appears to be circular linked"); - break; - } - } - } - - AcpiOsPrintf ("\n"); - break; - - case ACPI_EXD_RGN_LIST: - - Start = *ACPI_CAST_PTR (void *, Target); - Next = Start; - - AcpiOsPrintf ("%20s : %p", Name, Next); - if (Next) - { - AcpiOsPrintf ("(%s %2.2X)", - AcpiUtGetObjectTypeName (Next), Next->Common.Type); - - while (Next->Region.Next) - { - if ((Next->Common.Type == ACPI_TYPE_LOCAL_DATA) && - !Data) - { - Data = Next; - } - - Next = Next->Region.Next; - AcpiOsPrintf ("->%p(%s %2.2X)", Next, - AcpiUtGetObjectTypeName (Next), Next->Common.Type); - - if ((Next == Start) || (Next == Data)) - { - AcpiOsPrintf ( - "\n**** Error: Region list appears to be circular linked"); - break; - } - } - } - - AcpiOsPrintf ("\n"); - break; - - case ACPI_EXD_NODE: - - Node = *ACPI_CAST_PTR (ACPI_NAMESPACE_NODE *, Target); - - AcpiOsPrintf ("%20s : %p", Name, Node); - if (Node) - { - AcpiOsPrintf (" [%4.4s]", Node->Name.Ascii); - } - AcpiOsPrintf ("\n"); - break; - - default: - - AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n", - Info->Opcode); - return; - } - - Info++; - Count--; - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExDumpOperand - * - * PARAMETERS: *ObjDesc - Pointer to entry to be dumped - * Depth - Current nesting depth - * - * RETURN: None - * - * DESCRIPTION: Dump an operand object - * - ******************************************************************************/ - -void -AcpiExDumpOperand ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 Depth) -{ - UINT32 Length; - UINT32 Index; - - - ACPI_FUNCTION_NAME (ExDumpOperand); - - - /* Check if debug output enabled */ - - if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_EXEC, _COMPONENT)) - { - return; - } - - if (!ObjDesc) - { - /* This could be a null element of a package */ - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); - return; - } - - if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", ObjDesc)); - ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_EXEC); - return; - } - - if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "%p is not a node or operand object: [%s]\n", - ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); - ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)); - return; - } - - /* ObjDesc is a valid object */ - - if (Depth > 0) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p Refs=%u ", - Depth, " ", Depth, ObjDesc, ObjDesc->Common.ReferenceCount)); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Refs=%u ", - ObjDesc, ObjDesc->Common.ReferenceCount)); - } - - /* Decode object type */ - - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_LOCAL_REFERENCE: - - AcpiOsPrintf ("Reference: [%s] ", - AcpiUtGetReferenceName (ObjDesc)); - - switch (ObjDesc->Reference.Class) - { - case ACPI_REFCLASS_DEBUG: - - AcpiOsPrintf ("\n"); - break; - - case ACPI_REFCLASS_INDEX: - - AcpiOsPrintf ("%p\n", ObjDesc->Reference.Object); - break; - - case ACPI_REFCLASS_TABLE: - - AcpiOsPrintf ("Table Index %X\n", ObjDesc->Reference.Value); - break; - - case ACPI_REFCLASS_REFOF: - - AcpiOsPrintf ("%p [%s]\n", ObjDesc->Reference.Object, - AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) - ObjDesc->Reference.Object)->Common.Type)); - break; - - case ACPI_REFCLASS_NAME: - - AcpiUtRepairName (ObjDesc->Reference.Node->Name.Ascii); - AcpiOsPrintf ("- [%4.4s] (Node %p)\n", - ObjDesc->Reference.Node->Name.Ascii, - ObjDesc->Reference.Node); - break; - - case ACPI_REFCLASS_ARG: - case ACPI_REFCLASS_LOCAL: - - AcpiOsPrintf ("%X\n", ObjDesc->Reference.Value); - break; - - default: /* Unknown reference class */ - - AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class); - break; - } - break; - - case ACPI_TYPE_BUFFER: - - AcpiOsPrintf ("Buffer length %.2X @ %p\n", - ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer); - - /* Debug only -- dump the buffer contents */ - - if (ObjDesc->Buffer.Pointer) - { - Length = ObjDesc->Buffer.Length; - if (Length > 128) - { - Length = 128; - } - - AcpiOsPrintf ( - "Buffer Contents: (displaying length 0x%.2X)\n", Length); - ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, Length); - } - break; - - case ACPI_TYPE_INTEGER: - - AcpiOsPrintf ("Integer %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); - break; - - case ACPI_TYPE_PACKAGE: - - AcpiOsPrintf ("Package [Len %X] ElementArray %p\n", - ObjDesc->Package.Count, ObjDesc->Package.Elements); - - /* - * If elements exist, package element pointer is valid, - * and debug_level exceeds 1, dump package's elements. - */ - if (ObjDesc->Package.Count && - ObjDesc->Package.Elements && - AcpiDbgLevel > 1) - { - for (Index = 0; Index < ObjDesc->Package.Count; Index++) - { - AcpiExDumpOperand ( - ObjDesc->Package.Elements[Index], Depth + 1); - } - } - break; - - case ACPI_TYPE_REGION: - - AcpiOsPrintf ("Region %s (%X)", - AcpiUtGetRegionName (ObjDesc->Region.SpaceId), - ObjDesc->Region.SpaceId); - - /* - * If the address and length have not been evaluated, - * don't print them. - */ - if (!(ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)) - { - AcpiOsPrintf ("\n"); - } - else - { - AcpiOsPrintf (" base %8.8X%8.8X Length %X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), - ObjDesc->Region.Length); - } - break; - - case ACPI_TYPE_STRING: - - AcpiOsPrintf ("String length %X @ %p ", - ObjDesc->String.Length, - ObjDesc->String.Pointer); - - AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); - AcpiOsPrintf ("\n"); - break; - - case ACPI_TYPE_LOCAL_BANK_FIELD: - - AcpiOsPrintf ("BankField\n"); - break; - - case ACPI_TYPE_LOCAL_REGION_FIELD: - - AcpiOsPrintf ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at " - "byte=%X bit=%X of below:\n", - ObjDesc->Field.BitLength, - ObjDesc->Field.AccessByteWidth, - ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK, - ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK, - ObjDesc->Field.BaseByteOffset, - ObjDesc->Field.StartFieldBitOffset); - - AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth + 1); - break; - - case ACPI_TYPE_LOCAL_INDEX_FIELD: - - AcpiOsPrintf ("IndexField\n"); - break; - - case ACPI_TYPE_BUFFER_FIELD: - - AcpiOsPrintf ("BufferField: %X bits at byte %X bit %X of\n", - ObjDesc->BufferField.BitLength, - ObjDesc->BufferField.BaseByteOffset, - ObjDesc->BufferField.StartFieldBitOffset); - - if (!ObjDesc->BufferField.BufferObj) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n")); - } - else if ((ObjDesc->BufferField.BufferObj)->Common.Type != - ACPI_TYPE_BUFFER) - { - AcpiOsPrintf ("*not a Buffer*\n"); - } - else - { - AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth + 1); - } - break; - - case ACPI_TYPE_EVENT: - - AcpiOsPrintf ("Event\n"); - break; - - case ACPI_TYPE_METHOD: - - AcpiOsPrintf ("Method(%X) @ %p:%X\n", - ObjDesc->Method.ParamCount, - ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength); - break; - - case ACPI_TYPE_MUTEX: - - AcpiOsPrintf ("Mutex\n"); - break; - - case ACPI_TYPE_DEVICE: - - AcpiOsPrintf ("Device\n"); - break; - - case ACPI_TYPE_POWER: - - AcpiOsPrintf ("Power\n"); - break; - - case ACPI_TYPE_PROCESSOR: - - AcpiOsPrintf ("Processor\n"); - break; - - case ACPI_TYPE_THERMAL: - - AcpiOsPrintf ("Thermal\n"); - break; - - default: - - /* Unknown Type */ - - AcpiOsPrintf ("Unknown Type %X\n", ObjDesc->Common.Type); - break; - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExDumpOperands - * - * PARAMETERS: Operands - A list of Operand objects - * OpcodeName - AML opcode name - * NumOperands - Operand count for this opcode - * - * DESCRIPTION: Dump the operands associated with the opcode - * - ******************************************************************************/ - -void -AcpiExDumpOperands ( - ACPI_OPERAND_OBJECT **Operands, - const char *OpcodeName, - UINT32 NumOperands) -{ - ACPI_FUNCTION_TRACE (ExDumpOperands); - - - if (!OpcodeName) - { - OpcodeName = "UNKNOWN"; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "**** Start operand dump for opcode [%s], %u operands\n", - OpcodeName, NumOperands)); - - if (NumOperands == 0) - { - NumOperands = 1; - } - - /* Dump the individual operands */ - - while (NumOperands) - { - AcpiExDumpOperand (*Operands, 0); - Operands++; - NumOperands--; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "**** End operand dump for [%s]\n", OpcodeName)); - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExOut* functions - * - * PARAMETERS: Title - Descriptive text - * Value - Value to be displayed - * - * DESCRIPTION: Object dump output formatting functions. These functions - * reduce the number of format strings required and keeps them - * all in one place for easy modification. - * - ******************************************************************************/ - -static void -AcpiExOutString ( - const char *Title, - const char *Value) -{ - AcpiOsPrintf ("%20s : %s\n", Title, Value); -} - -static void -AcpiExOutPointer ( - const char *Title, - const void *Value) -{ - AcpiOsPrintf ("%20s : %p\n", Title, Value); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExDumpNamespaceNode - * - * PARAMETERS: Node - Descriptor to dump - * Flags - Force display if TRUE - * - * DESCRIPTION: Dumps the members of the given.Node - * - ******************************************************************************/ - -void -AcpiExDumpNamespaceNode ( - ACPI_NAMESPACE_NODE *Node, - UINT32 Flags) -{ - - ACPI_FUNCTION_ENTRY (); - - - if (!Flags) - { - /* Check if debug output enabled */ - - if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_OBJECTS, _COMPONENT)) - { - return; - } - } - - AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node)); - AcpiOsPrintf ("%20s : %2.2X [%s]\n", "Type", - Node->Type, AcpiUtGetTypeName (Node->Type)); - - AcpiExDumpObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node), - AcpiExDumpNode); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExDumpReferenceObj - * - * PARAMETERS: Object - Descriptor to dump - * - * DESCRIPTION: Dumps a reference object - * - ******************************************************************************/ - -static void -AcpiExDumpReferenceObj ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_BUFFER RetBuf; - ACPI_STATUS Status; - - - RetBuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - - if (ObjDesc->Reference.Class == ACPI_REFCLASS_NAME) - { - AcpiOsPrintf (" %p ", ObjDesc->Reference.Node); - - Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, - &RetBuf, TRUE); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf (" Could not convert name to pathname: %s\n", - AcpiFormatException (Status)); - } - else - { - AcpiOsPrintf ("%s: %s\n", - AcpiUtGetTypeName (ObjDesc->Reference.Node->Type), - (char *) RetBuf.Pointer); - ACPI_FREE (RetBuf.Pointer); - } - } - else if (ObjDesc->Reference.Object) - { - if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) - { - AcpiOsPrintf ("%22s %p", "Target :", - ObjDesc->Reference.Object); - if (ObjDesc->Reference.Class == ACPI_REFCLASS_TABLE) - { - AcpiOsPrintf (" Table Index: %X\n", - ObjDesc->Reference.Value); - } - else - { - AcpiOsPrintf (" [%s]\n", - AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) - ObjDesc->Reference.Object)->Common.Type)); - } - } - else - { - AcpiOsPrintf (" Target: %p\n", ObjDesc->Reference.Object); - } - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExDumpPackageObj - * - * PARAMETERS: ObjDesc - Descriptor to dump - * Level - Indentation Level - * Index - Package index for this object - * - * DESCRIPTION: Dumps the elements of the package - * - ******************************************************************************/ - -static void -AcpiExDumpPackageObj ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 Level, - UINT32 Index) -{ - UINT32 i; - - - /* Indentation and index output */ - - if (Level > 0) - { - for (i = 0; i < Level; i++) - { - AcpiOsPrintf (" "); - } - - AcpiOsPrintf ("[%.2d] ", Index); - } - - AcpiOsPrintf ("%p ", ObjDesc); - - /* Null package elements are allowed */ - - if (!ObjDesc) - { - AcpiOsPrintf ("[Null Object]\n"); - return; - } - - /* Packages may only contain a few object types */ - - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_INTEGER: - - AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); - break; - - case ACPI_TYPE_STRING: - - AcpiOsPrintf ("[String] Value: "); - AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); - AcpiOsPrintf ("\n"); - break; - - case ACPI_TYPE_BUFFER: - - AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length); - if (ObjDesc->Buffer.Length) - { - AcpiUtDebugDumpBuffer ( - ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), - ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); - } - else - { - AcpiOsPrintf ("\n"); - } - break; - - case ACPI_TYPE_PACKAGE: - - AcpiOsPrintf ("[Package] Contains %u Elements:\n", - ObjDesc->Package.Count); - - for (i = 0; i < ObjDesc->Package.Count; i++) - { - AcpiExDumpPackageObj ( - ObjDesc->Package.Elements[i], Level + 1, i); - } - break; - - case ACPI_TYPE_LOCAL_REFERENCE: - - AcpiOsPrintf ("[Object Reference] Class [%s]", - AcpiUtGetReferenceName (ObjDesc)); - AcpiExDumpReferenceObj (ObjDesc); - break; - - default: - - AcpiOsPrintf ("[%s] Type: %2.2X\n", - AcpiUtGetTypeName (ObjDesc->Common.Type), ObjDesc->Common.Type); - break; - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExDumpObjectDescriptor - * - * PARAMETERS: ObjDesc - Descriptor to dump - * Flags - Force display if TRUE - * - * DESCRIPTION: Dumps the members of the object descriptor given. - * - ******************************************************************************/ - -void -AcpiExDumpObjectDescriptor ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 Flags) -{ - ACPI_FUNCTION_TRACE (ExDumpObjectDescriptor); - - - if (!ObjDesc) - { - return_VOID; - } - - if (!Flags) - { - /* Check if debug output enabled */ - - if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_OBJECTS, _COMPONENT)) - { - return_VOID; - } - } - - if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) - { - AcpiExDumpNamespaceNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags); - - ObjDesc = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object; - if (!ObjDesc) - { - return_VOID; - } - - AcpiOsPrintf ("\nAttached Object %p", ObjDesc); - if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) - { - AcpiOsPrintf (" - Namespace Node"); - } - - AcpiOsPrintf (":\n"); - goto DumpObject; - } - - if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) - { - AcpiOsPrintf ( - "%p is not an ACPI operand object: [%s]\n", - ObjDesc, AcpiUtGetDescriptorName (ObjDesc)); - return_VOID; - } - - /* Validate the object type */ - - if (ObjDesc->Common.Type > ACPI_TYPE_LOCAL_MAX) - { - AcpiOsPrintf ("Not a known object type: %2.2X\n", - ObjDesc->Common.Type); - return_VOID; - } - - -DumpObject: - - if (!ObjDesc) - { - return_VOID; - } - - /* Common Fields */ - - AcpiExDumpObject (ObjDesc, AcpiExDumpCommon); - - /* Object-specific fields */ - - AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]); - - if (ObjDesc->Common.Type == ACPI_TYPE_REGION) - { - ObjDesc = ObjDesc->Common.NextObject; - if (ObjDesc->Common.Type > ACPI_TYPE_LOCAL_MAX) - { - AcpiOsPrintf ( - "Secondary object is not a known object type: %2.2X\n", - ObjDesc->Common.Type); - - return_VOID; - } - - AcpiOsPrintf ("\nExtra attached Object (%p):\n", ObjDesc); - AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]); - } - - return_VOID; -} - -#endif diff --git a/Private/acpiSDK/source/components/executer/exfield.c b/Private/acpiSDK/source/components/executer/exfield.c deleted file mode 100644 index f7d09206..00000000 --- a/Private/acpiSDK/source/components/executer/exfield.c +++ /dev/null @@ -1,561 +0,0 @@ -/****************************************************************************** - * - * Module Name: exfield - AML execution - FieldUnit read/write - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acdispat.h" -#include "acinterp.h" -#include "amlcode.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exfield") - - -/* - * This table maps the various Attrib protocols to the byte transfer - * length. Used for the generic serial bus. - */ -#define ACPI_INVALID_PROTOCOL_ID 0x80 -#define ACPI_MAX_PROTOCOL_ID 0x0F - -static const UINT8 AcpiProtocolLengths[] = -{ - ACPI_INVALID_PROTOCOL_ID, /* 0 - reserved */ - ACPI_INVALID_PROTOCOL_ID, /* 1 - reserved */ - 0x00, /* 2 - ATTRIB_QUICK */ - ACPI_INVALID_PROTOCOL_ID, /* 3 - reserved */ - 0x01, /* 4 - ATTRIB_SEND_RECEIVE */ - ACPI_INVALID_PROTOCOL_ID, /* 5 - reserved */ - 0x01, /* 6 - ATTRIB_BYTE */ - ACPI_INVALID_PROTOCOL_ID, /* 7 - reserved */ - 0x02, /* 8 - ATTRIB_WORD */ - ACPI_INVALID_PROTOCOL_ID, /* 9 - reserved */ - 0xFF, /* A - ATTRIB_BLOCK */ - 0xFF, /* B - ATTRIB_BYTES */ - 0x02, /* C - ATTRIB_PROCESS_CALL */ - 0xFF, /* D - ATTRIB_BLOCK_PROCESS_CALL */ - 0xFF, /* E - ATTRIB_RAW_BYTES */ - 0xFF /* F - ATTRIB_RAW_PROCESS_BYTES */ -}; - -#define PCC_MASTER_SUBSPACE 3 - -/* - * The following macros determine a given offset is a COMD field. - * According to the specification, generic subspaces (types 0-2) contains a - * 2-byte COMD field at offset 4 and master subspaces (type 3) contains a 4-byte - * COMD field starting at offset 12. - */ -#define GENERIC_SUBSPACE_COMMAND(a) (4 == a || a == 5) -#define MASTER_SUBSPACE_COMMAND(a) (12 <= a && a <= 15) - - -/******************************************************************************* - * - * FUNCTION: AcpiExGetProtocolBufferLength - * - * PARAMETERS: ProtocolId - The type of the protocol indicated by region - * field access attributes - * ReturnLength - Where the protocol byte transfer length is - * returned - * - * RETURN: Status and decoded byte transfer length - * - * DESCRIPTION: This routine returns the length of the GenericSerialBus - * protocol bytes - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExGetProtocolBufferLength ( - UINT32 ProtocolId, - UINT32 *ReturnLength) -{ - - if ((ProtocolId > ACPI_MAX_PROTOCOL_ID) || - (AcpiProtocolLengths[ProtocolId] == ACPI_INVALID_PROTOCOL_ID)) - { - ACPI_ERROR ((AE_INFO, - "Invalid Field/AccessAs protocol ID: 0x%4.4X", ProtocolId)); - - return (AE_AML_PROTOCOL); - } - - *ReturnLength = AcpiProtocolLengths[ProtocolId]; - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExReadDataFromField - * - * PARAMETERS: WalkState - Current execution state - * ObjDesc - The named field - * RetBufferDesc - Where the return data object is stored - * - * RETURN: Status - * - * DESCRIPTION: Read from a named field. Returns either an Integer or a - * Buffer, depending on the size of the field and whether if a - * field is created by the CreateField() operator. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExReadDataFromField ( - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **RetBufferDesc) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *BufferDesc; - void *Buffer; - UINT32 BufferLength; - - - ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc); - - - /* Parameter validation */ - - if (!ObjDesc) - { - return_ACPI_STATUS (AE_AML_NO_OPERAND); - } - if (!RetBufferDesc) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) - { - /* - * If the BufferField arguments have not been previously evaluated, - * evaluate them now and save the results. - */ - if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) - { - Status = AcpiDsGetBufferFieldArguments (ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - } - else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && - (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || - ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS || - ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI || - ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_RT || - ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE)) - { - /* SMBus, GSBus, IPMI serial */ - - Status = AcpiExReadSerialBus (ObjDesc, RetBufferDesc); - return_ACPI_STATUS (Status); - } - - /* - * Allocate a buffer for the contents of the field. - * - * If the field is larger than the current integer width, create - * a BUFFER to hold it. Otherwise, use an INTEGER. This allows - * the use of arithmetic operators on the returned value if the - * field size is equal or smaller than an Integer. - * - * However, all buffer fields created by CreateField operator needs to - * remain as a buffer to match other AML interpreter implementations. - * - * Note: Field.length is in bits. - */ - BufferLength = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES ( - ObjDesc->Field.BitLength); - - if (BufferLength > AcpiGbl_IntegerByteWidth || - (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD && - ObjDesc->BufferField.IsCreateField)) - { - /* Field is too large for an Integer, create a Buffer instead */ - - BufferDesc = AcpiUtCreateBufferObject (BufferLength); - if (!BufferDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - Buffer = BufferDesc->Buffer.Pointer; - } - else - { - /* Field will fit within an Integer (normal case) */ - - BufferDesc = AcpiUtCreateIntegerObject ((UINT64) 0); - if (!BufferDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - BufferLength = AcpiGbl_IntegerByteWidth; - Buffer = &BufferDesc->Integer.Value; - } - - if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && - (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GPIO)) - { - /* General Purpose I/O */ - - Status = AcpiExReadGpio (ObjDesc, Buffer); - goto Exit; - } - else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && - (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM)) - { - /* - * Reading from a PCC field unit does not require the handler because - * it only requires reading from the InternalPccBuffer. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "PCC FieldRead bits %u\n", ObjDesc->Field.BitLength)); - - memcpy (Buffer, ObjDesc->Field.RegionObj->Field.InternalPccBuffer + - ObjDesc->Field.BaseByteOffset, (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES ( - ObjDesc->Field.BitLength)); - - *RetBufferDesc = BufferDesc; - return AE_OK; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n", - ObjDesc, ObjDesc->Common.Type, Buffer, BufferLength)); - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n", - ObjDesc->CommonField.BitLength, - ObjDesc->CommonField.StartFieldBitOffset, - ObjDesc->CommonField.BaseByteOffset)); - - /* Lock entire transaction if requested */ - - AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); - - /* Read from the field */ - - Status = AcpiExExtractFromField (ObjDesc, Buffer, BufferLength); - AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); - - -Exit: - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (BufferDesc); - } - else - { - *RetBufferDesc = BufferDesc; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExWriteDataToField - * - * PARAMETERS: SourceDesc - Contains data to write - * ObjDesc - The named field - * ResultDesc - Where the return value is returned, if any - * - * RETURN: Status - * - * DESCRIPTION: Write to a named field - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExWriteDataToField ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ResultDesc) -{ - ACPI_STATUS Status; - UINT32 BufferLength; - UINT32 DataLength; - void *Buffer; - - - ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc); - - - /* Parameter validation */ - - if (!SourceDesc || !ObjDesc) - { - return_ACPI_STATUS (AE_AML_NO_OPERAND); - } - - if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) - { - /* - * If the BufferField arguments have not been previously evaluated, - * evaluate them now and save the results. - */ - if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) - { - Status = AcpiDsGetBufferFieldArguments (ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - } - else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && - (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GPIO)) - { - /* General Purpose I/O */ - - Status = AcpiExWriteGpio (SourceDesc, ObjDesc, ResultDesc); - return_ACPI_STATUS (Status); - } - else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && - (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || - ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS || - ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI || - ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_RT || - ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE)) - { - /* SMBus, GSBus, IPMI serial */ - - Status = AcpiExWriteSerialBus (SourceDesc, ObjDesc, ResultDesc); - return_ACPI_STATUS (Status); - } - else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && - (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM)) - { - /* - * According to the spec a write to the COMD field will invoke the - * region handler. Otherwise, write to the PccInternal buffer. This - * implementation will use the offsets specified rather than the name - * of the field. This is considered safer because some firmware tools - * are known to obfiscate named objects. - */ - DataLength = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES ( - ObjDesc->Field.BitLength); - memcpy (ObjDesc->Field.RegionObj->Field.InternalPccBuffer + - ObjDesc->Field.BaseByteOffset, - SourceDesc->Buffer.Pointer, DataLength); - - if (MASTER_SUBSPACE_COMMAND (ObjDesc->Field.BaseByteOffset)) - { - /* Perform the write */ - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "PCC COMD field has been written. Invoking PCC handler now.\n")); - - Status = AcpiExAccessRegion ( - ObjDesc, 0, (UINT64 *) ObjDesc->Field.RegionObj->Field.InternalPccBuffer, - ACPI_WRITE); - return_ACPI_STATUS (Status); - } - return (AE_OK); - } - - - /* Get a pointer to the data to be written */ - - switch (SourceDesc->Common.Type) - { - case ACPI_TYPE_INTEGER: - - Buffer = &SourceDesc->Integer.Value; - BufferLength = sizeof (SourceDesc->Integer.Value); - break; - - case ACPI_TYPE_BUFFER: - - Buffer = SourceDesc->Buffer.Pointer; - BufferLength = SourceDesc->Buffer.Length; - break; - - case ACPI_TYPE_STRING: - - Buffer = SourceDesc->String.Pointer; - BufferLength = SourceDesc->String.Length; - break; - - default: - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n", - SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type), - SourceDesc->Common.Type, Buffer, BufferLength)); - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n", - ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type), - ObjDesc->Common.Type, - ObjDesc->CommonField.BitLength, - ObjDesc->CommonField.StartFieldBitOffset, - ObjDesc->CommonField.BaseByteOffset)); - - /* Lock entire transaction if requested */ - - AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); - - /* Write to the field */ - - Status = AcpiExInsertIntoField (ObjDesc, Buffer, BufferLength); - AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exfldio.c b/Private/acpiSDK/source/components/executer/exfldio.c deleted file mode 100644 index c29cd0e8..00000000 --- a/Private/acpiSDK/source/components/executer/exfldio.c +++ /dev/null @@ -1,1156 +0,0 @@ -/****************************************************************************** - * - * Module Name: exfldio - Aml Field I/O - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acevents.h" -#include "acdispat.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exfldio") - -/* Local prototypes */ - -static ACPI_STATUS -AcpiExFieldDatumIo ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 FieldDatumByteOffset, - UINT64 *Value, - UINT32 ReadWrite); - -static BOOLEAN -AcpiExRegisterOverflow ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT64 Value); - -static ACPI_STATUS -AcpiExSetupRegion ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 FieldDatumByteOffset); - - -/******************************************************************************* - * - * FUNCTION: AcpiExSetupRegion - * - * PARAMETERS: ObjDesc - Field to be read or written - * FieldDatumByteOffset - Byte offset of this datum within the - * parent field - * - * RETURN: Status - * - * DESCRIPTION: Common processing for AcpiExExtractFromField and - * AcpiExInsertIntoField. Initialize the Region if necessary and - * validate the request. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiExSetupRegion ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 FieldDatumByteOffset) -{ - ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *RgnDesc; - UINT8 SpaceId; - - - ACPI_FUNCTION_TRACE_U32 (ExSetupRegion, FieldDatumByteOffset); - - - RgnDesc = ObjDesc->CommonField.RegionObj; - - /* We must have a valid region */ - - if (RgnDesc->Common.Type != ACPI_TYPE_REGION) - { - ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)", - RgnDesc->Common.Type, - AcpiUtGetObjectTypeName (RgnDesc))); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - SpaceId = RgnDesc->Region.SpaceId; - - /* Validate the Space ID */ - - if (!AcpiIsValidSpaceId (SpaceId)) - { - ACPI_ERROR ((AE_INFO, - "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId)); - return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); - } - - /* - * If the Region Address and Length have not been previously evaluated, - * evaluate them now and save the results. - */ - if (!(RgnDesc->Common.Flags & AOPOBJ_DATA_VALID)) - { - Status = AcpiDsGetRegionArguments (RgnDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* - * Exit now for SMBus, GSBus or IPMI address space, it has a non-linear - * address space and the request cannot be directly validated - */ - if (SpaceId == ACPI_ADR_SPACE_SMBUS || - SpaceId == ACPI_ADR_SPACE_GSBUS || - SpaceId == ACPI_ADR_SPACE_IPMI) - { - /* SMBus or IPMI has a non-linear address space */ - - return_ACPI_STATUS (AE_OK); - } - -#ifdef ACPI_UNDER_DEVELOPMENT - /* - * If the Field access is AnyAcc, we can now compute the optimal - * access (because we know the length of the parent region) - */ - if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) - { - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } -#endif - - /* - * Validate the request. The entire request from the byte offset for a - * length of one field datum (access width) must fit within the region. - * (Region length is specified in bytes) - */ - if (RgnDesc->Region.Length < - (ObjDesc->CommonField.BaseByteOffset + FieldDatumByteOffset + - ObjDesc->CommonField.AccessByteWidth)) - { - if (AcpiGbl_EnableInterpreterSlack) - { - /* - * Slack mode only: We will go ahead and allow access to this - * field if it is within the region length rounded up to the next - * access width boundary. ACPI_SIZE cast for 64-bit compile. - */ - if (ACPI_ROUND_UP (RgnDesc->Region.Length, - ObjDesc->CommonField.AccessByteWidth) >= - ((ACPI_SIZE) ObjDesc->CommonField.BaseByteOffset + - ObjDesc->CommonField.AccessByteWidth + - FieldDatumByteOffset)) - { - return_ACPI_STATUS (AE_OK); - } - } - - if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth) - { - /* - * This is the case where the AccessType (AccWord, etc.) is wider - * than the region itself. For example, a region of length one - * byte, and a field with Dword access specified. - */ - ACPI_ERROR ((AE_INFO, - "Field [%4.4s] access width (%u bytes) " - "too large for region [%4.4s] (length %u)", - AcpiUtGetNodeName (ObjDesc->CommonField.Node), - ObjDesc->CommonField.AccessByteWidth, - AcpiUtGetNodeName (RgnDesc->Region.Node), - RgnDesc->Region.Length)); - } - - /* - * Offset rounded up to next multiple of field width - * exceeds region length, indicate an error - */ - ACPI_ERROR ((AE_INFO, - "Field [%4.4s] Base+Offset+Width %u+%u+%u " - "is beyond end of region [%4.4s] (length %u)", - AcpiUtGetNodeName (ObjDesc->CommonField.Node), - ObjDesc->CommonField.BaseByteOffset, - FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth, - AcpiUtGetNodeName (RgnDesc->Region.Node), - RgnDesc->Region.Length)); - - return_ACPI_STATUS (AE_AML_REGION_LIMIT); - } - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExAccessRegion - * - * PARAMETERS: ObjDesc - Field to be read - * FieldDatumByteOffset - Byte offset of this datum within the - * parent field - * Value - Where to store value (must at least - * 64 bits) - * Function - Read or Write flag plus other region- - * dependent flags - * - * RETURN: Status - * - * DESCRIPTION: Read or Write a single field datum to an Operation Region. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExAccessRegion ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 FieldDatumByteOffset, - UINT64 *Value, - UINT32 Function) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *RgnDesc; - UINT32 RegionOffset; - - - ACPI_FUNCTION_TRACE (ExAccessRegion); - - - /* - * Ensure that the region operands are fully evaluated and verify - * the validity of the request - */ - Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* - * The physical address of this field datum is: - * - * 1) The base of the region, plus - * 2) The base offset of the field, plus - * 3) The current offset into the field - */ - RgnDesc = ObjDesc->CommonField.RegionObj; - RegionOffset = - ObjDesc->CommonField.BaseByteOffset + - FieldDatumByteOffset; - - if ((Function & ACPI_IO_MASK) == ACPI_READ) - { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]")); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]")); - } - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD, - " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %8.8X%8.8X\n", - AcpiUtGetRegionName (RgnDesc->Region.SpaceId), - RgnDesc->Region.SpaceId, - ObjDesc->CommonField.AccessByteWidth, - ObjDesc->CommonField.BaseByteOffset, - FieldDatumByteOffset, - ACPI_FORMAT_UINT64 (RgnDesc->Region.Address + RegionOffset))); - - /* Invoke the appropriate AddressSpace/OpRegion handler */ - - Status = AcpiEvAddressSpaceDispatch (RgnDesc, ObjDesc, - Function, RegionOffset, - ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); - - if (ACPI_FAILURE (Status)) - { - if (Status == AE_NOT_IMPLEMENTED) - { - ACPI_ERROR ((AE_INFO, - "Region %s (ID=%u) not implemented", - AcpiUtGetRegionName (RgnDesc->Region.SpaceId), - RgnDesc->Region.SpaceId)); - } - else if (Status == AE_NOT_EXIST) - { - ACPI_ERROR ((AE_INFO, - "Region %s (ID=%u) has no handler", - AcpiUtGetRegionName (RgnDesc->Region.SpaceId), - RgnDesc->Region.SpaceId)); - } - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExRegisterOverflow - * - * PARAMETERS: ObjDesc - Register(Field) to be written - * Value - Value to be stored - * - * RETURN: TRUE if value overflows the field, FALSE otherwise - * - * DESCRIPTION: Check if a value is out of range of the field being written. - * Used to check if the values written to Index and Bank registers - * are out of range. Normally, the value is simply truncated - * to fit the field, but this case is most likely a serious - * coding error in the ASL. - * - ******************************************************************************/ - -static BOOLEAN -AcpiExRegisterOverflow ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT64 Value) -{ - - if (ObjDesc->CommonField.BitLength >= ACPI_INTEGER_BIT_SIZE) - { - /* - * The field is large enough to hold the maximum integer, so we can - * never overflow it. - */ - return (FALSE); - } - - if (Value >= ((UINT64) 1 << ObjDesc->CommonField.BitLength)) - { - /* - * The Value is larger than the maximum value that can fit into - * the register. - */ - ACPI_ERROR ((AE_INFO, - "Index value 0x%8.8X%8.8X overflows field width 0x%X", - ACPI_FORMAT_UINT64 (Value), - ObjDesc->CommonField.BitLength)); - - return (TRUE); - } - - /* The Value will fit into the field with no truncation */ - - return (FALSE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExFieldDatumIo - * - * PARAMETERS: ObjDesc - Field to be read - * FieldDatumByteOffset - Byte offset of this datum within the - * parent field - * Value - Where to store value (must be 64 bits) - * ReadWrite - Read or Write flag - * - * RETURN: Status - * - * DESCRIPTION: Read or Write a single datum of a field. The FieldType is - * demultiplexed here to handle the different types of fields - * (BufferField, RegionField, IndexField, BankField) - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiExFieldDatumIo ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 FieldDatumByteOffset, - UINT64 *Value, - UINT32 ReadWrite) -{ - ACPI_STATUS Status; - UINT64 LocalValue; - - - ACPI_FUNCTION_TRACE_U32 (ExFieldDatumIo, FieldDatumByteOffset); - - - if (ReadWrite == ACPI_READ) - { - if (!Value) - { - LocalValue = 0; - - /* To support reads without saving return value */ - Value = &LocalValue; - } - - /* Clear the entire return buffer first, [Very Important!] */ - - *Value = 0; - } - - /* - * The four types of fields are: - * - * BufferField - Read/write from/to a Buffer - * RegionField - Read/write from/to a Operation Region. - * BankField - Write to a Bank Register, then read/write from/to an - * OperationRegion - * IndexField - Write to an Index Register, then read/write from/to a - * Data Register - */ - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_BUFFER_FIELD: - /* - * If the BufferField arguments have not been previously evaluated, - * evaluate them now and save the results. - */ - if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) - { - Status = AcpiDsGetBufferFieldArguments (ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - if (ReadWrite == ACPI_READ) - { - /* - * Copy the data from the source buffer. - * Length is the field width in bytes. - */ - memcpy (Value, - (ObjDesc->BufferField.BufferObj)->Buffer.Pointer + - ObjDesc->BufferField.BaseByteOffset + - FieldDatumByteOffset, - ObjDesc->CommonField.AccessByteWidth); - } - else - { - /* - * Copy the data to the target buffer. - * Length is the field width in bytes. - */ - memcpy ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer + - ObjDesc->BufferField.BaseByteOffset + - FieldDatumByteOffset, - Value, ObjDesc->CommonField.AccessByteWidth); - } - - Status = AE_OK; - break; - - case ACPI_TYPE_LOCAL_BANK_FIELD: - /* - * Ensure that the BankValue is not beyond the capacity of - * the register - */ - if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj, - (UINT64) ObjDesc->BankField.Value)) - { - return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); - } - - /* - * For BankFields, we must write the BankValue to the BankRegister - * (itself a RegionField) before we can access the data. - */ - Status = AcpiExInsertIntoField (ObjDesc->BankField.BankObj, - &ObjDesc->BankField.Value, - sizeof (ObjDesc->BankField.Value)); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* - * Now that the Bank has been selected, fall through to the - * RegionField case and write the datum to the Operation Region - */ - - ACPI_FALLTHROUGH; - - case ACPI_TYPE_LOCAL_REGION_FIELD: - /* - * For simple RegionFields, we just directly access the owning - * Operation Region. - */ - Status = AcpiExAccessRegion ( - ObjDesc, FieldDatumByteOffset, Value, ReadWrite); - break; - - case ACPI_TYPE_LOCAL_INDEX_FIELD: - /* - * Ensure that the IndexValue is not beyond the capacity of - * the register - */ - if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj, - (UINT64) ObjDesc->IndexField.Value)) - { - return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); - } - - /* Write the index value to the IndexRegister (itself a RegionField) */ - - FieldDatumByteOffset += ObjDesc->IndexField.Value; - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Write to Index Register: Value %8.8X\n", - FieldDatumByteOffset)); - - Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj, - &FieldDatumByteOffset, sizeof (FieldDatumByteOffset)); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - if (ReadWrite == ACPI_READ) - { - /* Read the datum from the DataRegister */ - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Read from Data Register\n")); - - Status = AcpiExExtractFromField ( - ObjDesc->IndexField.DataObj, Value, sizeof (UINT64)); - } - else - { - /* Write the datum to the DataRegister */ - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Write to Data Register: Value %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (*Value))); - - Status = AcpiExInsertIntoField ( - ObjDesc->IndexField.DataObj, Value, sizeof (UINT64)); - } - break; - - default: - - ACPI_ERROR ((AE_INFO, "Wrong object type in field I/O %u", - ObjDesc->Common.Type)); - Status = AE_AML_INTERNAL; - break; - } - - if (ACPI_SUCCESS (Status)) - { - if (ReadWrite == ACPI_READ) - { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Value Read %8.8X%8.8X, Width %u\n", - ACPI_FORMAT_UINT64 (*Value), - ObjDesc->CommonField.AccessByteWidth)); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Value Written %8.8X%8.8X, Width %u\n", - ACPI_FORMAT_UINT64 (*Value), - ObjDesc->CommonField.AccessByteWidth)); - } - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExWriteWithUpdateRule - * - * PARAMETERS: ObjDesc - Field to be written - * Mask - bitmask within field datum - * FieldValue - Value to write - * FieldDatumByteOffset - Offset of datum within field - * - * RETURN: Status - * - * DESCRIPTION: Apply the field update rule to a field write - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExWriteWithUpdateRule ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT64 Mask, - UINT64 FieldValue, - UINT32 FieldDatumByteOffset) -{ - ACPI_STATUS Status = AE_OK; - UINT64 MergedValue; - UINT64 CurrentValue; - - - ACPI_FUNCTION_TRACE_U32 (ExWriteWithUpdateRule, Mask); - - - /* Start with the new bits */ - - MergedValue = FieldValue; - - /* If the mask is all ones, we don't need to worry about the update rule */ - - if (Mask != ACPI_UINT64_MAX) - { - /* Decode the update rule */ - - switch (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK) - { - case AML_FIELD_UPDATE_PRESERVE: - /* - * Check if update rule needs to be applied (not if mask is all - * ones) The left shift drops the bits we want to ignore. - */ - if ((~Mask << (ACPI_MUL_8 (sizeof (Mask)) - - ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0) - { - /* - * Read the current contents of the byte/word/dword containing - * the field, and merge with the new field value. - */ - Status = AcpiExFieldDatumIo ( - ObjDesc, FieldDatumByteOffset, &CurrentValue, ACPI_READ); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - MergedValue |= (CurrentValue & ~Mask); - } - break; - - case AML_FIELD_UPDATE_WRITE_AS_ONES: - - /* Set positions outside the field to all ones */ - - MergedValue |= ~Mask; - break; - - case AML_FIELD_UPDATE_WRITE_AS_ZEROS: - - /* Set positions outside the field to all zeros */ - - MergedValue &= Mask; - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Unknown UpdateRule value: 0x%X", - (ObjDesc->CommonField.FieldFlags & - AML_FIELD_UPDATE_RULE_MASK))); - return_ACPI_STATUS (AE_AML_OPERAND_VALUE); - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Mask %8.8X%8.8X, DatumOffset %X, Width %X, " - "Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Mask), - FieldDatumByteOffset, - ObjDesc->CommonField.AccessByteWidth, - ACPI_FORMAT_UINT64 (FieldValue), - ACPI_FORMAT_UINT64 (MergedValue))); - - /* Write the merged value */ - - Status = AcpiExFieldDatumIo ( - ObjDesc, FieldDatumByteOffset, &MergedValue, ACPI_WRITE); - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExExtractFromField - * - * PARAMETERS: ObjDesc - Field to be read - * Buffer - Where to store the field data - * BufferLength - Length of Buffer - * - * RETURN: Status - * - * DESCRIPTION: Retrieve the current value of the given field - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExExtractFromField ( - ACPI_OPERAND_OBJECT *ObjDesc, - void *Buffer, - UINT32 BufferLength) -{ - ACPI_STATUS Status; - UINT64 RawDatum; - UINT64 MergedDatum; - UINT32 FieldOffset = 0; - UINT32 BufferOffset = 0; - UINT32 BufferTailBits; - UINT32 DatumCount; - UINT32 FieldDatumCount; - UINT32 AccessBitWidth; - UINT32 i; - - - ACPI_FUNCTION_TRACE (ExExtractFromField); - - - /* Validate target buffer and clear it */ - - if (BufferLength < - ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength)) - { - ACPI_ERROR ((AE_INFO, - "Field size %u (bits) is too large for buffer (%u)", - ObjDesc->CommonField.BitLength, BufferLength)); - - return_ACPI_STATUS (AE_BUFFER_OVERFLOW); - } - - memset (Buffer, 0, BufferLength); - AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth); - - /* Handle the simple case here */ - - if ((ObjDesc->CommonField.StartFieldBitOffset == 0) && - (ObjDesc->CommonField.BitLength == AccessBitWidth)) - { - if (BufferLength >= sizeof (UINT64)) - { - Status = AcpiExFieldDatumIo (ObjDesc, 0, Buffer, ACPI_READ); - } - else - { - /* Use RawDatum (UINT64) to handle buffers < 64 bits */ - - Status = AcpiExFieldDatumIo (ObjDesc, 0, &RawDatum, ACPI_READ); - memcpy (Buffer, &RawDatum, BufferLength); - } - - return_ACPI_STATUS (Status); - } - -/* TBD: Move to common setup code */ - - /* Field algorithm is limited to sizeof(UINT64), truncate if needed */ - - if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64)) - { - ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64); - AccessBitWidth = sizeof (UINT64) * 8; - } - - /* Compute the number of datums (access width data items) */ - - DatumCount = ACPI_ROUND_UP_TO ( - ObjDesc->CommonField.BitLength, AccessBitWidth); - - FieldDatumCount = ACPI_ROUND_UP_TO ( - ObjDesc->CommonField.BitLength + - ObjDesc->CommonField.StartFieldBitOffset, AccessBitWidth); - - /* Priming read from the field */ - - Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, &RawDatum, ACPI_READ); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset; - - /* Read the rest of the field */ - - for (i = 1; i < FieldDatumCount; i++) - { - /* Get next input datum from the field */ - - FieldOffset += ObjDesc->CommonField.AccessByteWidth; - Status = AcpiExFieldDatumIo ( - ObjDesc, FieldOffset, &RawDatum, ACPI_READ); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* - * Merge with previous datum if necessary. - * - * Note: Before the shift, check if the shift value will be larger than - * the integer size. If so, there is no need to perform the operation. - * This avoids the differences in behavior between different compilers - * concerning shift values larger than the target data width. - */ - if (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset < - ACPI_INTEGER_BIT_SIZE) - { - MergedDatum |= RawDatum << - (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset); - } - - if (i == DatumCount) - { - break; - } - - /* Write merged datum to target buffer */ - - memcpy (((char *) Buffer) + BufferOffset, &MergedDatum, - ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, - BufferLength - BufferOffset)); - - BufferOffset += ObjDesc->CommonField.AccessByteWidth; - MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset; - } - - /* Mask off any extra bits in the last datum */ - - BufferTailBits = ObjDesc->CommonField.BitLength % AccessBitWidth; - if (BufferTailBits) - { - MergedDatum &= ACPI_MASK_BITS_ABOVE (BufferTailBits); - } - - /* Write the last datum to the buffer */ - - memcpy (((char *) Buffer) + BufferOffset, &MergedDatum, - ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, - BufferLength - BufferOffset)); - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExInsertIntoField - * - * PARAMETERS: ObjDesc - Field to be written - * Buffer - Data to be written - * BufferLength - Length of Buffer - * - * RETURN: Status - * - * DESCRIPTION: Store the Buffer contents into the given field - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExInsertIntoField ( - ACPI_OPERAND_OBJECT *ObjDesc, - void *Buffer, - UINT32 BufferLength) -{ - void *NewBuffer; - ACPI_STATUS Status; - UINT64 Mask; - UINT64 WidthMask; - UINT64 MergedDatum; - UINT64 RawDatum = 0; - UINT32 FieldOffset = 0; - UINT32 BufferOffset = 0; - UINT32 BufferTailBits; - UINT32 DatumCount; - UINT32 FieldDatumCount; - UINT32 AccessBitWidth; - UINT32 RequiredLength; - UINT32 i; - - - ACPI_FUNCTION_TRACE (ExInsertIntoField); - - - /* Validate input buffer */ - - NewBuffer = NULL; - RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES ( - ObjDesc->CommonField.BitLength); - - /* - * We must have a buffer that is at least as long as the field - * we are writing to. This is because individual fields are - * indivisible and partial writes are not supported -- as per - * the ACPI specification. - */ - if (BufferLength < RequiredLength) - { - /* We need to create a new buffer */ - - NewBuffer = ACPI_ALLOCATE_ZEROED (RequiredLength); - if (!NewBuffer) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* - * Copy the original data to the new buffer, starting - * at Byte zero. All unused (upper) bytes of the - * buffer will be 0. - */ - memcpy ((char *) NewBuffer, (char *) Buffer, BufferLength); - Buffer = NewBuffer; - BufferLength = RequiredLength; - } - -/* TBD: Move to common setup code */ - - /* Algo is limited to sizeof(UINT64), so cut the AccessByteWidth */ - if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64)) - { - ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64); - } - - AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth); - - /* Create the bitmasks used for bit insertion */ - - WidthMask = ACPI_MASK_BITS_ABOVE_64 (AccessBitWidth); - Mask = WidthMask & - ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); - - /* Compute the number of datums (access width data items) */ - - DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength, - AccessBitWidth); - - FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength + - ObjDesc->CommonField.StartFieldBitOffset, - AccessBitWidth); - - /* Get initial Datum from the input buffer */ - - memcpy (&RawDatum, Buffer, - ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, - BufferLength - BufferOffset)); - - MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset; - - /* Write the entire field */ - - for (i = 1; i < FieldDatumCount; i++) - { - /* Write merged datum to the target field */ - - MergedDatum &= Mask; - Status = AcpiExWriteWithUpdateRule ( - ObjDesc, Mask, MergedDatum, FieldOffset); - if (ACPI_FAILURE (Status)) - { - goto Exit; - } - - FieldOffset += ObjDesc->CommonField.AccessByteWidth; - - /* - * Start new output datum by merging with previous input datum - * if necessary. - * - * Note: Before the shift, check if the shift value will be larger than - * the integer size. If so, there is no need to perform the operation. - * This avoids the differences in behavior between different compilers - * concerning shift values larger than the target data width. - */ - if ((AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset) < - ACPI_INTEGER_BIT_SIZE) - { - MergedDatum = RawDatum >> - (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset); - } - else - { - MergedDatum = 0; - } - - Mask = WidthMask; - - if (i == DatumCount) - { - break; - } - - /* Get the next input datum from the buffer */ - - BufferOffset += ObjDesc->CommonField.AccessByteWidth; - memcpy (&RawDatum, ((char *) Buffer) + BufferOffset, - ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, - BufferLength - BufferOffset)); - - MergedDatum |= RawDatum << ObjDesc->CommonField.StartFieldBitOffset; - } - - /* Mask off any extra bits in the last datum */ - - BufferTailBits = (ObjDesc->CommonField.BitLength + - ObjDesc->CommonField.StartFieldBitOffset) % AccessBitWidth; - if (BufferTailBits) - { - Mask &= ACPI_MASK_BITS_ABOVE (BufferTailBits); - } - - /* Write the last datum to the field */ - - MergedDatum &= Mask; - Status = AcpiExWriteWithUpdateRule ( - ObjDesc, Mask, MergedDatum, FieldOffset); - -Exit: - /* Free temporary buffer if we used one */ - - if (NewBuffer) - { - ACPI_FREE (NewBuffer); - } - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exmisc.c b/Private/acpiSDK/source/components/executer/exmisc.c deleted file mode 100644 index 9b6608ba..00000000 --- a/Private/acpiSDK/source/components/executer/exmisc.c +++ /dev/null @@ -1,643 +0,0 @@ -/****************************************************************************** - * - * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "amlcode.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exmisc") - - -/******************************************************************************* - * - * FUNCTION: AcpiExGetObjectReference - * - * PARAMETERS: ObjDesc - Create a reference to this object - * ReturnDesc - Where to store the reference - * WalkState - Current state - * - * RETURN: Status - * - * DESCRIPTION: Obtain and return a "reference" to the target object - * Common code for the RefOfOp and the CondRefOfOp. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExGetObjectReference ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ReturnDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT *ReferenceObj; - ACPI_OPERAND_OBJECT *ReferencedObj; - - - ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc); - - - *ReturnDesc = NULL; - - switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) - { - case ACPI_DESC_TYPE_OPERAND: - - if (ObjDesc->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) - { - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - /* - * Must be a reference to a Local or Arg - */ - switch (ObjDesc->Reference.Class) - { - case ACPI_REFCLASS_LOCAL: - case ACPI_REFCLASS_ARG: - case ACPI_REFCLASS_DEBUG: - - /* The referenced object is the pseudo-node for the local/arg */ - - ReferencedObj = ObjDesc->Reference.Object; - break; - - default: - - ACPI_ERROR ((AE_INFO, "Invalid Reference Class 0x%2.2X", - ObjDesc->Reference.Class)); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - break; - - case ACPI_DESC_TYPE_NAMED: - /* - * A named reference that has already been resolved to a Node - */ - ReferencedObj = ObjDesc; - break; - - default: - - ACPI_ERROR ((AE_INFO, "Invalid descriptor type 0x%X", - ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))); - return_ACPI_STATUS (AE_TYPE); - } - - - /* Create a new reference object */ - - ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); - if (!ReferenceObj) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - ReferenceObj->Reference.Class = ACPI_REFCLASS_REFOF; - ReferenceObj->Reference.Object = ReferencedObj; - *ReturnDesc = ReferenceObj; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Object %p Type [%s], returning Reference %p\n", - ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc)); - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExDoMathOp - * - * PARAMETERS: Opcode - AML opcode - * Integer0 - Integer operand #0 - * Integer1 - Integer operand #1 - * - * RETURN: Integer result of the operation - * - * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the - * math functions here is to prevent a lot of pointer dereferencing - * to obtain the operands. - * - ******************************************************************************/ - -UINT64 -AcpiExDoMathOp ( - UINT16 Opcode, - UINT64 Integer0, - UINT64 Integer1) -{ - - ACPI_FUNCTION_ENTRY (); - - - switch (Opcode) - { - case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */ - - return (Integer0 + Integer1); - - case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */ - - return (Integer0 & Integer1); - - case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */ - - return (~(Integer0 & Integer1)); - - case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */ - - return (Integer0 | Integer1); - - case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */ - - return (~(Integer0 | Integer1)); - - case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */ - - return (Integer0 ^ Integer1); - - case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */ - - return (Integer0 * Integer1); - - case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/ - - /* - * We need to check if the shiftcount is larger than the integer bit - * width since the behavior of this is not well-defined in the C language. - */ - if (Integer1 >= AcpiGbl_IntegerBitWidth) - { - return (0); - } - return (Integer0 << Integer1); - - case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */ - - /* - * We need to check if the shiftcount is larger than the integer bit - * width since the behavior of this is not well-defined in the C language. - */ - if (Integer1 >= AcpiGbl_IntegerBitWidth) - { - return (0); - } - return (Integer0 >> Integer1); - - case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */ - - return (Integer0 - Integer1); - - default: - - return (0); - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExDoLogicalNumericOp - * - * PARAMETERS: Opcode - AML opcode - * Integer0 - Integer operand #0 - * Integer1 - Integer operand #1 - * LogicalResult - TRUE/FALSE result of the operation - * - * RETURN: Status - * - * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric - * operators (LAnd and LOr), both operands must be integers. - * - * Note: cleanest machine code seems to be produced by the code - * below, rather than using statements of the form: - * Result = (Integer0 && Integer1); - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExDoLogicalNumericOp ( - UINT16 Opcode, - UINT64 Integer0, - UINT64 Integer1, - BOOLEAN *LogicalResult) -{ - ACPI_STATUS Status = AE_OK; - BOOLEAN LocalResult = FALSE; - - - ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp); - - - switch (Opcode) - { - case AML_LOGICAL_AND_OP: /* LAnd (Integer0, Integer1) */ - - if (Integer0 && Integer1) - { - LocalResult = TRUE; - } - break; - - case AML_LOGICAL_OR_OP: /* LOr (Integer0, Integer1) */ - - if (Integer0 || Integer1) - { - LocalResult = TRUE; - } - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Invalid numeric logical opcode: %X", Opcode)); - Status = AE_AML_INTERNAL; - break; - } - - /* Return the logical result and status */ - - *LogicalResult = LocalResult; - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExDoLogicalOp - * - * PARAMETERS: Opcode - AML opcode - * Operand0 - operand #0 - * Operand1 - operand #1 - * LogicalResult - TRUE/FALSE result of the operation - * - * RETURN: Status - * - * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the - * functions here is to prevent a lot of pointer dereferencing - * to obtain the operands and to simplify the generation of the - * logical value. For the Numeric operators (LAnd and LOr), both - * operands must be integers. For the other logical operators, - * operands can be any combination of Integer/String/Buffer. The - * first operand determines the type to which the second operand - * will be converted. - * - * Note: cleanest machine code seems to be produced by the code - * below, rather than using statements of the form: - * Result = (Operand0 == Operand1); - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExDoLogicalOp ( - UINT16 Opcode, - ACPI_OPERAND_OBJECT *Operand0, - ACPI_OPERAND_OBJECT *Operand1, - BOOLEAN *LogicalResult) -{ - ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; - UINT64 Integer0; - UINT64 Integer1; - UINT32 Length0; - UINT32 Length1; - ACPI_STATUS Status = AE_OK; - BOOLEAN LocalResult = FALSE; - int Compare; - - - ACPI_FUNCTION_TRACE (ExDoLogicalOp); - - - /* - * Convert the second operand if necessary. The first operand - * determines the type of the second operand, (See the Data Types - * section of the ACPI 3.0+ specification.) Both object types are - * guaranteed to be either Integer/String/Buffer by the operand - * resolution mechanism. - */ - switch (Operand0->Common.Type) - { - case ACPI_TYPE_INTEGER: - - Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, - ACPI_IMPLICIT_CONVERSION); - break; - - case ACPI_TYPE_STRING: - - Status = AcpiExConvertToString ( - Operand1, &LocalOperand1, ACPI_IMPLICIT_CONVERT_HEX); - break; - - case ACPI_TYPE_BUFFER: - - Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1); - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Invalid object type for logical operator: %X", - Operand0->Common.Type)); - Status = AE_AML_INTERNAL; - break; - } - - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* - * Two cases: 1) Both Integers, 2) Both Strings or Buffers - */ - if (Operand0->Common.Type == ACPI_TYPE_INTEGER) - { - /* - * 1) Both operands are of type integer - * Note: LocalOperand1 may have changed above - */ - Integer0 = Operand0->Integer.Value; - Integer1 = LocalOperand1->Integer.Value; - - switch (Opcode) - { - case AML_LOGICAL_EQUAL_OP: /* LEqual (Operand0, Operand1) */ - - if (Integer0 == Integer1) - { - LocalResult = TRUE; - } - break; - - case AML_LOGICAL_GREATER_OP: /* LGreater (Operand0, Operand1) */ - - if (Integer0 > Integer1) - { - LocalResult = TRUE; - } - break; - - case AML_LOGICAL_LESS_OP: /* LLess (Operand0, Operand1) */ - - if (Integer0 < Integer1) - { - LocalResult = TRUE; - } - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Invalid comparison opcode: %X", Opcode)); - Status = AE_AML_INTERNAL; - break; - } - } - else - { - /* - * 2) Both operands are Strings or both are Buffers - * Note: Code below takes advantage of common Buffer/String - * object fields. LocalOperand1 may have changed above. Use - * memcmp to handle nulls in buffers. - */ - Length0 = Operand0->Buffer.Length; - Length1 = LocalOperand1->Buffer.Length; - - /* Lexicographic compare: compare the data bytes */ - - Compare = memcmp (Operand0->Buffer.Pointer, - LocalOperand1->Buffer.Pointer, - (Length0 > Length1) ? Length1 : Length0); - - switch (Opcode) - { - case AML_LOGICAL_EQUAL_OP: /* LEqual (Operand0, Operand1) */ - - /* Length and all bytes must be equal */ - - if ((Length0 == Length1) && - (Compare == 0)) - { - /* Length and all bytes match ==> TRUE */ - - LocalResult = TRUE; - } - break; - - case AML_LOGICAL_GREATER_OP: /* LGreater (Operand0, Operand1) */ - - if (Compare > 0) - { - LocalResult = TRUE; - goto Cleanup; /* TRUE */ - } - if (Compare < 0) - { - goto Cleanup; /* FALSE */ - } - - /* Bytes match (to shortest length), compare lengths */ - - if (Length0 > Length1) - { - LocalResult = TRUE; - } - break; - - case AML_LOGICAL_LESS_OP: /* LLess (Operand0, Operand1) */ - - if (Compare > 0) - { - goto Cleanup; /* FALSE */ - } - if (Compare < 0) - { - LocalResult = TRUE; - goto Cleanup; /* TRUE */ - } - - /* Bytes match (to shortest length), compare lengths */ - - if (Length0 < Length1) - { - LocalResult = TRUE; - } - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Invalid comparison opcode: %X", Opcode)); - Status = AE_AML_INTERNAL; - break; - } - } - -Cleanup: - - /* New object was created if implicit conversion performed - delete */ - - if (LocalOperand1 != Operand1) - { - AcpiUtRemoveReference (LocalOperand1); - } - - /* Return the logical result and status */ - - *LogicalResult = LocalResult; - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exmutex.c b/Private/acpiSDK/source/components/executer/exmutex.c deleted file mode 100644 index 3abac6a8..00000000 --- a/Private/acpiSDK/source/components/executer/exmutex.c +++ /dev/null @@ -1,693 +0,0 @@ -/****************************************************************************** - * - * Module Name: exmutex - ASL Mutex Acquire/Release functions - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "acevents.h" - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exmutex") - -/* Local prototypes */ - -static void -AcpiExLinkMutex ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_THREAD_STATE *Thread); - - -/******************************************************************************* - * - * FUNCTION: AcpiExUnlinkMutex - * - * PARAMETERS: ObjDesc - The mutex to be unlinked - * - * RETURN: None - * - * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list - * - ******************************************************************************/ - -void -AcpiExUnlinkMutex ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_THREAD_STATE *Thread = ObjDesc->Mutex.OwnerThread; - - - if (!Thread) - { - return; - } - - /* Doubly linked list */ - - if (ObjDesc->Mutex.Next) - { - (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev; - } - - if (ObjDesc->Mutex.Prev) - { - (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next; - - /* - * Migrate the previous sync level associated with this mutex to - * the previous mutex on the list so that it may be preserved. - * This handles the case where several mutexes have been acquired - * at the same level, but are not released in opposite order. - */ - (ObjDesc->Mutex.Prev)->Mutex.OriginalSyncLevel = - ObjDesc->Mutex.OriginalSyncLevel; - } - else - { - Thread->AcquiredMutexList = ObjDesc->Mutex.Next; - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExLinkMutex - * - * PARAMETERS: ObjDesc - The mutex to be linked - * Thread - Current executing thread object - * - * RETURN: None - * - * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk - * - ******************************************************************************/ - -static void -AcpiExLinkMutex ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_THREAD_STATE *Thread) -{ - ACPI_OPERAND_OBJECT *ListHead; - - - ListHead = Thread->AcquiredMutexList; - - /* This object will be the first object in the list */ - - ObjDesc->Mutex.Prev = NULL; - ObjDesc->Mutex.Next = ListHead; - - /* Update old first object to point back to this object */ - - if (ListHead) - { - ListHead->Mutex.Prev = ObjDesc; - } - - /* Update list head */ - - Thread->AcquiredMutexList = ObjDesc; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExAcquireMutexObject - * - * PARAMETERS: Timeout - Timeout in milliseconds - * ObjDesc - Mutex object - * ThreadId - Current thread state - * - * RETURN: Status - * - * DESCRIPTION: Acquire an AML mutex, low-level interface. Provides a common - * path that supports multiple acquires by the same thread. - * - * MUTEX: Interpreter must be locked - * - * NOTE: This interface is called from three places: - * 1) From AcpiExAcquireMutex, via an AML Acquire() operator - * 2) From AcpiExAcquireGlobalLock when an AML Field access requires the - * global lock - * 3) From the external interface, AcpiAcquireGlobalLock - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExAcquireMutexObject ( - UINT16 Timeout, - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_THREAD_ID ThreadId) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_PTR (ExAcquireMutexObject, ObjDesc); - - - if (!ObjDesc) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Support for multiple acquires by the owning thread */ - - if (ObjDesc->Mutex.ThreadId == ThreadId) - { - /* - * The mutex is already owned by this thread, just increment the - * acquisition depth - */ - ObjDesc->Mutex.AcquisitionDepth++; - return_ACPI_STATUS (AE_OK); - } - - /* Acquire the mutex, wait if necessary. Special case for Global Lock */ - - if (ObjDesc == AcpiGbl_GlobalLockMutex) - { - Status = AcpiEvAcquireGlobalLock (Timeout); - } - else - { - Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex, Timeout); - } - - if (ACPI_FAILURE (Status)) - { - /* Includes failure from a timeout on TimeDesc */ - - return_ACPI_STATUS (Status); - } - - /* Acquired the mutex: update mutex object */ - - ObjDesc->Mutex.ThreadId = ThreadId; - ObjDesc->Mutex.AcquisitionDepth = 1; - ObjDesc->Mutex.OriginalSyncLevel = 0; - ObjDesc->Mutex.OwnerThread = NULL; /* Used only for AML Acquire() */ - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExAcquireMutex - * - * PARAMETERS: TimeDesc - Timeout integer - * ObjDesc - Mutex object - * WalkState - Current method execution state - * - * RETURN: Status - * - * DESCRIPTION: Acquire an AML mutex - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExAcquireMutex ( - ACPI_OPERAND_OBJECT *TimeDesc, - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_PTR (ExAcquireMutex, ObjDesc); - - - if (!ObjDesc) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Must have a valid thread state struct */ - - if (!WalkState->Thread) - { - ACPI_ERROR ((AE_INFO, - "Cannot acquire Mutex [%4.4s], null thread info", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); - return_ACPI_STATUS (AE_AML_INTERNAL); - } - - /* - * Current sync level must be less than or equal to the sync level - * of the mutex. This mechanism provides some deadlock prevention. - */ - if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel) - { - ACPI_ERROR ((AE_INFO, - "Cannot acquire Mutex [%4.4s], " - "current SyncLevel is too large (%u)", - AcpiUtGetNodeName (ObjDesc->Mutex.Node), - WalkState->Thread->CurrentSyncLevel)); - return_ACPI_STATUS (AE_AML_MUTEX_ORDER); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Acquiring: Mutex SyncLevel %u, Thread SyncLevel %u, " - "Depth %u TID %p\n", - ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel, - ObjDesc->Mutex.AcquisitionDepth, WalkState->Thread)); - - Status = AcpiExAcquireMutexObject ((UINT16) TimeDesc->Integer.Value, - ObjDesc, WalkState->Thread->ThreadId); - - if (ACPI_SUCCESS (Status) && ObjDesc->Mutex.AcquisitionDepth == 1) - { - /* Save Thread object, original/current sync levels */ - - ObjDesc->Mutex.OwnerThread = WalkState->Thread; - ObjDesc->Mutex.OriginalSyncLevel = - WalkState->Thread->CurrentSyncLevel; - WalkState->Thread->CurrentSyncLevel = - ObjDesc->Mutex.SyncLevel; - - /* Link the mutex to the current thread for force-unlock at method exit */ - - AcpiExLinkMutex (ObjDesc, WalkState->Thread); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Acquired: Mutex SyncLevel %u, Thread SyncLevel %u, Depth %u\n", - ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel, - ObjDesc->Mutex.AcquisitionDepth)); - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExReleaseMutexObject - * - * PARAMETERS: ObjDesc - The object descriptor for this op - * - * RETURN: Status - * - * DESCRIPTION: Release a previously acquired Mutex, low level interface. - * Provides a common path that supports multiple releases (after - * previous multiple acquires) by the same thread. - * - * MUTEX: Interpreter must be locked - * - * NOTE: This interface is called from three places: - * 1) From AcpiExReleaseMutex, via an AML Acquire() operator - * 2) From AcpiExReleaseGlobalLock when an AML Field access requires the - * global lock - * 3) From the external interface, AcpiReleaseGlobalLock - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExReleaseMutexObject ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE (ExReleaseMutexObject); - - - if (ObjDesc->Mutex.AcquisitionDepth == 0) - { - return_ACPI_STATUS (AE_NOT_ACQUIRED); - } - - /* Match multiple Acquires with multiple Releases */ - - ObjDesc->Mutex.AcquisitionDepth--; - if (ObjDesc->Mutex.AcquisitionDepth != 0) - { - /* Just decrement the depth and return */ - - return_ACPI_STATUS (AE_OK); - } - - if (ObjDesc->Mutex.OwnerThread) - { - /* Unlink the mutex from the owner's list */ - - AcpiExUnlinkMutex (ObjDesc); - ObjDesc->Mutex.OwnerThread = NULL; - } - - /* Release the mutex, special case for Global Lock */ - - if (ObjDesc == AcpiGbl_GlobalLockMutex) - { - Status = AcpiEvReleaseGlobalLock (); - } - else - { - AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex); - } - - /* Clear mutex info */ - - ObjDesc->Mutex.ThreadId = 0; - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExReleaseMutex - * - * PARAMETERS: ObjDesc - The object descriptor for this op - * WalkState - Current method execution state - * - * RETURN: Status - * - * DESCRIPTION: Release a previously acquired Mutex. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExReleaseMutex ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_WALK_STATE *WalkState) -{ - UINT8 PreviousSyncLevel; - ACPI_THREAD_STATE *OwnerThread; - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE (ExReleaseMutex); - - - if (!ObjDesc) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - OwnerThread = ObjDesc->Mutex.OwnerThread; - - /* The mutex must have been previously acquired in order to release it */ - - if (!OwnerThread) - { - ACPI_ERROR ((AE_INFO, - "Cannot release Mutex [%4.4s], not acquired", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); - return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED); - } - - /* Must have a valid thread ID */ - - if (!WalkState->Thread) - { - ACPI_ERROR ((AE_INFO, - "Cannot release Mutex [%4.4s], null thread info", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); - return_ACPI_STATUS (AE_AML_INTERNAL); - } - - /* - * The Mutex is owned, but this thread must be the owner. - * Special case for Global Lock, any thread can release - */ - if ((OwnerThread->ThreadId != WalkState->Thread->ThreadId) && - (ObjDesc != AcpiGbl_GlobalLockMutex)) - { - ACPI_ERROR ((AE_INFO, - "Thread %u cannot release Mutex [%4.4s] acquired by thread %u", - (UINT32) WalkState->Thread->ThreadId, - AcpiUtGetNodeName (ObjDesc->Mutex.Node), - (UINT32) OwnerThread->ThreadId)); - return_ACPI_STATUS (AE_AML_NOT_OWNER); - } - - /* - * The sync level of the mutex must be equal to the current sync level. In - * other words, the current level means that at least one mutex at that - * level is currently being held. Attempting to release a mutex of a - * different level can only mean that the mutex ordering rule is being - * violated. This behavior is clarified in ACPI 4.0 specification. - */ - if (ObjDesc->Mutex.SyncLevel != OwnerThread->CurrentSyncLevel) - { - ACPI_ERROR ((AE_INFO, - "Cannot release Mutex [%4.4s], SyncLevel mismatch: " - "mutex %u current %u", - AcpiUtGetNodeName (ObjDesc->Mutex.Node), - ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel)); - return_ACPI_STATUS (AE_AML_MUTEX_ORDER); - } - - /* - * Get the previous SyncLevel from the head of the acquired mutex list. - * This handles the case where several mutexes at the same level have been - * acquired, but are not released in reverse order. - */ - PreviousSyncLevel = - OwnerThread->AcquiredMutexList->Mutex.OriginalSyncLevel; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Releasing: Object SyncLevel %u, Thread SyncLevel %u, " - "Prev SyncLevel %u, Depth %u TID %p\n", - ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel, - PreviousSyncLevel, ObjDesc->Mutex.AcquisitionDepth, - WalkState->Thread)); - - Status = AcpiExReleaseMutexObject (ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - if (ObjDesc->Mutex.AcquisitionDepth == 0) - { - /* Restore the previous SyncLevel */ - - OwnerThread->CurrentSyncLevel = PreviousSyncLevel; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Released: Object SyncLevel %u, Thread SyncLevel, %u, " - "Prev SyncLevel %u, Depth %u\n", - ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel, - PreviousSyncLevel, ObjDesc->Mutex.AcquisitionDepth)); - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExReleaseAllMutexes - * - * PARAMETERS: Thread - Current executing thread object - * - * RETURN: Status - * - * DESCRIPTION: Release all mutexes held by this thread - * - * NOTE: This function is called as the thread is exiting the interpreter. - * Mutexes are not released when an individual control method is exited, but - * only when the parent thread actually exits the interpreter. This allows one - * method to acquire a mutex, and a different method to release it, as long as - * this is performed underneath a single parent control method. - * - ******************************************************************************/ - -void -AcpiExReleaseAllMutexes ( - ACPI_THREAD_STATE *Thread) -{ - ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList; - ACPI_OPERAND_OBJECT *ObjDesc; - - - ACPI_FUNCTION_TRACE (ExReleaseAllMutexes); - - - /* Traverse the list of owned mutexes, releasing each one */ - - while (Next) - { - ObjDesc = Next; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Mutex [%4.4s] force-release, SyncLevel %u Depth %u\n", - ObjDesc->Mutex.Node->Name.Ascii, ObjDesc->Mutex.SyncLevel, - ObjDesc->Mutex.AcquisitionDepth)); - - /* Release the mutex, special case for Global Lock */ - - if (ObjDesc == AcpiGbl_GlobalLockMutex) - { - /* Ignore errors */ - - (void) AcpiEvReleaseGlobalLock (); - } - else - { - AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex); - } - - /* Update Thread SyncLevel (Last mutex is the important one) */ - - Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; - - /* Mark mutex unowned */ - - Next = ObjDesc->Mutex.Next; - - ObjDesc->Mutex.Prev = NULL; - ObjDesc->Mutex.Next = NULL; - ObjDesc->Mutex.AcquisitionDepth = 0; - ObjDesc->Mutex.OwnerThread = NULL; - ObjDesc->Mutex.ThreadId = 0; - } - - return_VOID; -} diff --git a/Private/acpiSDK/source/components/executer/exnames.c b/Private/acpiSDK/source/components/executer/exnames.c deleted file mode 100644 index af68c82f..00000000 --- a/Private/acpiSDK/source/components/executer/exnames.c +++ /dev/null @@ -1,585 +0,0 @@ -/****************************************************************************** - * - * Module Name: exnames - interpreter/scanner name load/execute - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "amlcode.h" - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exnames") - -/* Local prototypes */ - -static char * -AcpiExAllocateNameString ( - UINT32 PrefixCount, - UINT32 NumNameSegs); - -static ACPI_STATUS -AcpiExNameSegment ( - UINT8 **InAmlAddress, - char *NameString); - - -/******************************************************************************* - * - * FUNCTION: AcpiExAllocateNameString - * - * PARAMETERS: PrefixCount - Count of parent levels. Special cases: - * (-1)==root, 0==none - * NumNameSegs - count of 4-character name segments - * - * RETURN: A pointer to the allocated string segment. This segment must - * be deleted by the caller. - * - * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name - * string is long enough, and set up prefix if any. - * - ******************************************************************************/ - -static char * -AcpiExAllocateNameString ( - UINT32 PrefixCount, - UINT32 NumNameSegs) -{ - char *TempPtr; - char *NameString; - UINT32 SizeNeeded; - - ACPI_FUNCTION_TRACE (ExAllocateNameString); - - - /* - * Allow room for all \ and ^ prefixes, all segments and a MultiNamePrefix. - * Also, one byte for the null terminator. - * This may actually be somewhat longer than needed. - */ - if (PrefixCount == ACPI_UINT32_MAX) - { - /* Special case for root */ - - SizeNeeded = 1 + (ACPI_NAMESEG_SIZE * NumNameSegs) + 2 + 1; - } - else - { - SizeNeeded = PrefixCount + (ACPI_NAMESEG_SIZE * NumNameSegs) + 2 + 1; - } - - /* - * Allocate a buffer for the name. - * This buffer must be deleted by the caller! - */ - NameString = ACPI_ALLOCATE (SizeNeeded); - if (!NameString) - { - ACPI_ERROR ((AE_INFO, - "Could not allocate size %u", SizeNeeded)); - return_PTR (NULL); - } - - TempPtr = NameString; - - /* Set up Root or Parent prefixes if needed */ - - if (PrefixCount == ACPI_UINT32_MAX) - { - *TempPtr++ = AML_ROOT_PREFIX; - } - else - { - while (PrefixCount--) - { - *TempPtr++ = AML_PARENT_PREFIX; - } - } - - - /* Set up Dual or Multi prefixes if needed */ - - if (NumNameSegs > 2) - { - /* Set up multi prefixes */ - - *TempPtr++ = AML_MULTI_NAME_PREFIX; - *TempPtr++ = (char) NumNameSegs; - } - else if (2 == NumNameSegs) - { - /* Set up dual prefixes */ - - *TempPtr++ = AML_DUAL_NAME_PREFIX; - } - - /* - * Terminate string following prefixes. AcpiExNameSegment() will - * append the segment(s) - */ - *TempPtr = 0; - - return_PTR (NameString); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExNameSegment - * - * PARAMETERS: InAmlAddress - Pointer to the name in the AML code - * NameString - Where to return the name. The name is appended - * to any existing string to form a namepath - * - * RETURN: Status - * - * DESCRIPTION: Extract an ACPI name (4 bytes) from the AML byte stream - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiExNameSegment ( - UINT8 **InAmlAddress, - char *NameString) -{ - char *AmlAddress = (void *) *InAmlAddress; - ACPI_STATUS Status = AE_OK; - UINT32 Index; - char CharBuf[5]; - - - ACPI_FUNCTION_TRACE (ExNameSegment); - - - /* - * If first character is a digit, then we know that we aren't looking - * at a valid name segment - */ - CharBuf[0] = *AmlAddress; - - if ('0' <= CharBuf[0] && CharBuf[0] <= '9') - { - ACPI_ERROR ((AE_INFO, "Invalid leading digit: %c", CharBuf[0])); - return_ACPI_STATUS (AE_CTRL_PENDING); - } - - for (Index = 0; - (Index < ACPI_NAMESEG_SIZE) && (AcpiUtValidNameChar (*AmlAddress, 0)); - Index++) - { - CharBuf[Index] = *AmlAddress++; - } - - - /* Valid name segment */ - - if (Index == 4) - { - /* Found 4 valid characters */ - - CharBuf[4] = '\0'; - - if (NameString) - { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Appending NameSeg %s\n", CharBuf)); - strcat (NameString, CharBuf); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "No Name string - %s\n", CharBuf)); - } - } - else if (Index == 0) - { - /* - * First character was not a valid name character, - * so we are looking at something other than a name. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Leading character is not alpha: %02Xh (not a name)\n", - CharBuf[0])); - Status = AE_CTRL_PENDING; - } - else - { - /* - * Segment started with one or more valid characters, but fewer than - * the required 4 - */ - Status = AE_AML_BAD_NAME; - ACPI_ERROR ((AE_INFO, - "Bad character 0x%02x in name, at %p", - *AmlAddress, AmlAddress)); - } - - *InAmlAddress = ACPI_CAST_PTR (UINT8, AmlAddress); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExGetNameString - * - * PARAMETERS: DataType - Object type to be associated with this - * name - * InAmlAddress - Pointer to the namestring in the AML code - * OutNameString - Where the namestring is returned - * OutNameLength - Length of the returned string - * - * RETURN: Status, namestring and length - * - * DESCRIPTION: Extract a full namepath from the AML byte stream, - * including any prefixes. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExGetNameString ( - ACPI_OBJECT_TYPE DataType, - UINT8 *InAmlAddress, - char **OutNameString, - UINT32 *OutNameLength) -{ - ACPI_STATUS Status = AE_OK; - UINT8 *AmlAddress = InAmlAddress; - char *NameString = NULL; - UINT32 NumSegments; - UINT32 PrefixCount = 0; - BOOLEAN HasPrefix = FALSE; - - - ACPI_FUNCTION_TRACE_PTR (ExGetNameString, AmlAddress); - - - if (ACPI_TYPE_LOCAL_REGION_FIELD == DataType || - ACPI_TYPE_LOCAL_BANK_FIELD == DataType || - ACPI_TYPE_LOCAL_INDEX_FIELD == DataType) - { - /* Disallow prefixes for types associated with FieldUnit names */ - - NameString = AcpiExAllocateNameString (0, 1); - if (!NameString) - { - Status = AE_NO_MEMORY; - } - else - { - Status = AcpiExNameSegment (&AmlAddress, NameString); - } - } - else - { - /* - * DataType is not a field name. - * Examine first character of name for root or parent prefix operators - */ - switch (*AmlAddress) - { - case AML_ROOT_PREFIX: - - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n", - AmlAddress)); - - /* - * Remember that we have a RootPrefix -- - * see comment in AcpiExAllocateNameString() - */ - AmlAddress++; - PrefixCount = ACPI_UINT32_MAX; - HasPrefix = TRUE; - break; - - case AML_PARENT_PREFIX: - - /* Increment past possibly multiple parent prefixes */ - - do - { - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n", - AmlAddress)); - - AmlAddress++; - PrefixCount++; - - } while (*AmlAddress == AML_PARENT_PREFIX); - - HasPrefix = TRUE; - break; - - default: - - /* Not a prefix character */ - - break; - } - - /* Examine first character of name for name segment prefix operator */ - - switch (*AmlAddress) - { - case AML_DUAL_NAME_PREFIX: - - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n", - AmlAddress)); - - AmlAddress++; - NameString = AcpiExAllocateNameString (PrefixCount, 2); - if (!NameString) - { - Status = AE_NO_MEMORY; - break; - } - - /* Indicate that we processed a prefix */ - - HasPrefix = TRUE; - - Status = AcpiExNameSegment (&AmlAddress, NameString); - if (ACPI_SUCCESS (Status)) - { - Status = AcpiExNameSegment (&AmlAddress, NameString); - } - break; - - case AML_MULTI_NAME_PREFIX: - - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n", - AmlAddress)); - - /* Fetch count of segments remaining in name path */ - - AmlAddress++; - NumSegments = *AmlAddress; - - NameString = AcpiExAllocateNameString ( - PrefixCount, NumSegments); - if (!NameString) - { - Status = AE_NO_MEMORY; - break; - } - - /* Indicate that we processed a prefix */ - - AmlAddress++; - HasPrefix = TRUE; - - while (NumSegments && - (Status = AcpiExNameSegment (&AmlAddress, NameString)) == - AE_OK) - { - NumSegments--; - } - - break; - - case 0: - - /* NullName valid as of 8-12-98 ASL/AML Grammar Update */ - - if (PrefixCount == ACPI_UINT32_MAX) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "NameSeg is \"\\\" followed by NULL\n")); - } - - /* Consume the NULL byte */ - - AmlAddress++; - NameString = AcpiExAllocateNameString (PrefixCount, 0); - if (!NameString) - { - Status = AE_NO_MEMORY; - break; - } - - break; - - default: - - /* Name segment string */ - - NameString = AcpiExAllocateNameString (PrefixCount, 1); - if (!NameString) - { - Status = AE_NO_MEMORY; - break; - } - - Status = AcpiExNameSegment (&AmlAddress, NameString); - break; - } - } - - if (AE_CTRL_PENDING == Status && HasPrefix) - { - /* Ran out of segments after processing a prefix */ - - ACPI_ERROR ((AE_INFO, - "Malformed Name at %p", NameString)); - Status = AE_AML_BAD_NAME; - } - - if (ACPI_FAILURE (Status)) - { - if (NameString) - { - ACPI_FREE (NameString); - } - return_ACPI_STATUS (Status); - } - - *OutNameString = NameString; - *OutNameLength = (UINT32) (AmlAddress - InAmlAddress); - - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exoparg1.c b/Private/acpiSDK/source/components/executer/exoparg1.c deleted file mode 100644 index 82250ff6..00000000 --- a/Private/acpiSDK/source/components/executer/exoparg1.c +++ /dev/null @@ -1,1269 +0,0 @@ -/****************************************************************************** - * - * Module Name: exoparg1 - AML execution - opcodes with 1 argument - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acparser.h" -#include "acdispat.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acnamesp.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exoparg1") - - -/*! - * Naming convention for AML interpreter execution routines. - * - * The routines that begin execution of AML opcodes are named with a common - * convention based upon the number of arguments, the number of target operands, - * and whether or not a value is returned: - * - * AcpiExOpcode_xA_yT_zR - * - * Where: - * - * xA - ARGUMENTS: The number of arguments (input operands) that are - * required for this opcode type (0 through 6 args). - * yT - TARGETS: The number of targets (output operands) that are required - * for this opcode type (0, 1, or 2 targets). - * zR - RETURN VALUE: Indicates whether this opcode type returns a value - * as the function return (0 or 1). - * - * The AcpiExOpcode* functions are called via the Dispatcher component with - * fully resolved operands. -!*/ - -/******************************************************************************* - * - * FUNCTION: AcpiExOpcode_0A_0T_1R - * - * PARAMETERS: WalkState - Current state (contains AML opcode) - * - * RETURN: Status - * - * DESCRIPTION: Execute operator with no operands, one return value - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExOpcode_0A_0T_1R ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - - - ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R, - AcpiPsGetOpcodeName (WalkState->Opcode)); - - - /* Examine the AML opcode */ - - switch (WalkState->Opcode) - { - case AML_TIMER_OP: /* Timer () */ - - /* Create a return object of type Integer */ - - ReturnDesc = AcpiUtCreateIntegerObject (AcpiOsGetTimer ()); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - break; - - default: /* Unknown opcode */ - - ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", - WalkState->Opcode)); - Status = AE_AML_BAD_OPCODE; - break; - } - -Cleanup: - - /* Delete return object on error */ - - if ((ACPI_FAILURE (Status)) || WalkState->ResultObj) - { - AcpiUtRemoveReference (ReturnDesc); - WalkState->ResultObj = NULL; - } - else - { - /* Save the return value */ - - WalkState->ResultObj = ReturnDesc; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExOpcode_1A_0T_0R - * - * PARAMETERS: WalkState - Current state (contains AML opcode) - * - * RETURN: Status - * - * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on - * object stack - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExOpcode_1A_0T_0R ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R, - AcpiPsGetOpcodeName (WalkState->Opcode)); - - - /* Examine the AML opcode */ - - switch (WalkState->Opcode) - { - case AML_RELEASE_OP: /* Release (MutexObject) */ - - Status = AcpiExReleaseMutex (Operand[0], WalkState); - break; - - case AML_RESET_OP: /* Reset (EventObject) */ - - Status = AcpiExSystemResetEvent (Operand[0]); - break; - - case AML_SIGNAL_OP: /* Signal (EventObject) */ - - Status = AcpiExSystemSignalEvent (Operand[0]); - break; - - case AML_SLEEP_OP: /* Sleep (MsecTime) */ - - Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value); - break; - - case AML_STALL_OP: /* Stall (UsecTime) */ - - Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value); - break; - - case AML_UNLOAD_OP: /* Unload (Handle) */ - - Status = AcpiExUnloadTable (Operand[0]); - break; - - default: /* Unknown opcode */ - - ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", - WalkState->Opcode)); - Status = AE_AML_BAD_OPCODE; - break; - } - - return_ACPI_STATUS (Status); -} - - -#ifdef _OBSOLETE_CODE /* Was originally used for Load() operator */ -/******************************************************************************* - * - * FUNCTION: AcpiExOpcode_1A_1T_0R - * - * PARAMETERS: WalkState - Current state (contains AML opcode) - * - * RETURN: Status - * - * DESCRIPTION: Execute opcode with one argument, one target, and no - * return value. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExOpcode_1A_1T_0R ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - - - ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R, - AcpiPsGetOpcodeName (WalkState->Opcode)); - - - /* Examine the AML opcode */ - - switch (WalkState->Opcode) - { -#ifdef _OBSOLETE_CODE - case AML_LOAD_OP: - - Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState); - break; -#endif - - default: /* Unknown opcode */ - - ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", - WalkState->Opcode)); - Status = AE_AML_BAD_OPCODE; - goto Cleanup; - } - - -Cleanup: - - return_ACPI_STATUS (Status); -} -#endif - -/******************************************************************************* - * - * FUNCTION: AcpiExOpcode_1A_1T_1R - * - * PARAMETERS: WalkState - Current state (contains AML opcode) - * - * RETURN: Status - * - * DESCRIPTION: Execute opcode with one argument, one target, and a - * return value. - * January 2022: Added Load operator, with new ACPI 6.4 - * semantics. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExOpcode_1A_1T_1R ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; - UINT32 Temp32; - UINT32 i; - UINT64 PowerOfTen; - UINT64 Digit; - - - ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R, - AcpiPsGetOpcodeName (WalkState->Opcode)); - - - /* Examine the AML opcode */ - - switch (WalkState->Opcode) - { - case AML_BIT_NOT_OP: - case AML_FIND_SET_LEFT_BIT_OP: - case AML_FIND_SET_RIGHT_BIT_OP: - case AML_FROM_BCD_OP: - case AML_LOAD_OP: - case AML_TO_BCD_OP: - case AML_CONDITIONAL_REF_OF_OP: - - /* Create a return object of type Integer for these opcodes */ - - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - switch (WalkState->Opcode) - { - case AML_BIT_NOT_OP: /* Not (Operand, Result) */ - - ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value; - break; - - case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */ - - ReturnDesc->Integer.Value = Operand[0]->Integer.Value; - - /* - * Acpi specification describes Integer type as a little - * endian unsigned value, so this boundary condition is valid. - */ - for (Temp32 = 0; ReturnDesc->Integer.Value && - Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) - { - ReturnDesc->Integer.Value >>= 1; - } - - ReturnDesc->Integer.Value = Temp32; - break; - - case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */ - - ReturnDesc->Integer.Value = Operand[0]->Integer.Value; - - /* - * The Acpi specification describes Integer type as a little - * endian unsigned value, so this boundary condition is valid. - */ - for (Temp32 = 0; ReturnDesc->Integer.Value && - Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) - { - ReturnDesc->Integer.Value <<= 1; - } - - /* Since the bit position is one-based, subtract from 33 (65) */ - - ReturnDesc->Integer.Value = - Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32; - break; - - case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */ - /* - * The 64-bit ACPI integer can hold 16 4-bit BCD characters - * (if table is 32-bit, integer can hold 8 BCD characters) - * Convert each 4-bit BCD value - */ - PowerOfTen = 1; - ReturnDesc->Integer.Value = 0; - Digit = Operand[0]->Integer.Value; - - /* Convert each BCD digit (each is one nybble wide) */ - - for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++) - { - /* Get the least significant 4-bit BCD digit */ - - Temp32 = ((UINT32) Digit) & 0xF; - - /* Check the range of the digit */ - - if (Temp32 > 9) - { - ACPI_ERROR ((AE_INFO, - "BCD digit too large (not decimal): 0x%X", - Temp32)); - - Status = AE_AML_NUMERIC_OVERFLOW; - goto Cleanup; - } - - /* Sum the digit into the result with the current power of 10 */ - - ReturnDesc->Integer.Value += - (((UINT64) Temp32) * PowerOfTen); - - /* Shift to next BCD digit */ - - Digit >>= 4; - - /* Next power of 10 */ - - PowerOfTen *= 10; - } - break; - - case AML_LOAD_OP: /* Result1 = Load (Operand[0], Result1) */ - - ReturnDesc->Integer.Value = 0; - Status = AcpiExLoadOp (Operand[0], ReturnDesc, WalkState); - if (ACPI_SUCCESS (Status)) - { - /* Return -1 (non-zero) indicates success */ - - ReturnDesc->Integer.Value = 0xFFFFFFFFFFFFFFFF; - } - break; - - case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */ - - ReturnDesc->Integer.Value = 0; - Digit = Operand[0]->Integer.Value; - - /* Each BCD digit is one nybble wide */ - - for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++) - { - (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32); - - /* - * Insert the BCD digit that resides in the - * remainder from above - */ - ReturnDesc->Integer.Value |= - (((UINT64) Temp32) << ACPI_MUL_4 (i)); - } - - /* Overflow if there is any data left in Digit */ - - if (Digit > 0) - { - ACPI_ERROR ((AE_INFO, - "Integer too large to convert to BCD: 0x%8.8X%8.8X", - ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value))); - Status = AE_AML_NUMERIC_OVERFLOW; - goto Cleanup; - } - break; - - case AML_CONDITIONAL_REF_OF_OP: /* CondRefOf (SourceObject, Result) */ - /* - * This op is a little strange because the internal return value is - * different than the return value stored in the result descriptor - * (There are really two return values) - */ - if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode) - { - /* - * This means that the object does not exist in the namespace, - * return FALSE - */ - ReturnDesc->Integer.Value = 0; - goto Cleanup; - } - - /* Get the object reference, store it, and remove our reference */ - - Status = AcpiExGetObjectReference (Operand[0], - &ReturnDesc2, WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState); - AcpiUtRemoveReference (ReturnDesc2); - - /* The object exists in the namespace, return TRUE */ - - ReturnDesc->Integer.Value = ACPI_UINT64_MAX; - goto Cleanup; - - - default: - - /* No other opcodes get here */ - - break; - } - break; - - case AML_STORE_OP: /* Store (Source, Target) */ - /* - * A store operand is typically a number, string, buffer or lvalue - * Be careful about deleting the source object, - * since the object itself may have been stored. - */ - Status = AcpiExStore (Operand[0], Operand[1], WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* It is possible that the Store already produced a return object */ - - if (!WalkState->ResultObj) - { - /* - * Normally, we would remove a reference on the Operand[0] - * parameter; But since it is being used as the internal return - * object (meaning we would normally increment it), the two - * cancel out, and we simply don't do anything. - */ - WalkState->ResultObj = Operand[0]; - WalkState->Operands[0] = NULL; /* Prevent deletion */ - } - return_ACPI_STATUS (Status); - - /* - * ACPI 2.0 Opcodes - */ - case AML_COPY_OBJECT_OP: /* CopyObject (Source, Target) */ - - Status = AcpiUtCopyIobjectToIobject ( - Operand[0], &ReturnDesc, WalkState); - break; - - case AML_TO_DECIMAL_STRING_OP: /* ToDecimalString (Data, Result) */ - - Status = AcpiExConvertToString ( - Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_DECIMAL); - if (ReturnDesc == Operand[0]) - { - /* No conversion performed, add ref to handle return value */ - - AcpiUtAddReference (ReturnDesc); - } - break; - - case AML_TO_HEX_STRING_OP: /* ToHexString (Data, Result) */ - - Status = AcpiExConvertToString ( - Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_HEX); - if (ReturnDesc == Operand[0]) - { - /* No conversion performed, add ref to handle return value */ - - AcpiUtAddReference (ReturnDesc); - } - break; - - case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */ - - Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc); - if (ReturnDesc == Operand[0]) - { - /* No conversion performed, add ref to handle return value */ - - AcpiUtAddReference (ReturnDesc); - } - break; - - case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */ - - /* Perform "explicit" conversion */ - - Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, 0); - if (ReturnDesc == Operand[0]) - { - /* No conversion performed, add ref to handle return value */ - - AcpiUtAddReference (ReturnDesc); - } - break; - - case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */ - case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */ - - /* These are two obsolete opcodes */ - - ACPI_ERROR ((AE_INFO, - "%s is obsolete and not implemented", - AcpiPsGetOpcodeName (WalkState->Opcode))); - Status = AE_SUPPORT; - goto Cleanup; - - default: /* Unknown opcode */ - - ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", - WalkState->Opcode)); - Status = AE_AML_BAD_OPCODE; - goto Cleanup; - } - - if (ACPI_SUCCESS (Status)) - { - /* Store the return value computed above into the target object */ - - Status = AcpiExStore (ReturnDesc, Operand[1], WalkState); - } - - -Cleanup: - - /* Delete return object on error */ - - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (ReturnDesc); - } - - /* Save return object on success */ - - else if (!WalkState->ResultObj) - { - WalkState->ResultObj = ReturnDesc; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExOpcode_1A_0T_1R - * - * PARAMETERS: WalkState - Current state (contains AML opcode) - * - * RETURN: Status - * - * DESCRIPTION: Execute opcode with one argument, no target, and a return value - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExOpcode_1A_0T_1R ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *TempDesc; - ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - ACPI_STATUS Status = AE_OK; - UINT32 Type; - UINT64 Value; - - - ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R, - AcpiPsGetOpcodeName (WalkState->Opcode)); - - - /* Examine the AML opcode */ - - switch (WalkState->Opcode) - { - case AML_LOGICAL_NOT_OP: /* LNot (Operand) */ - - ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* - * Set result to ONES (TRUE) if Value == 0. Note: - * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above. - */ - if (!Operand[0]->Integer.Value) - { - ReturnDesc->Integer.Value = ACPI_UINT64_MAX; - } - break; - - case AML_DECREMENT_OP: /* Decrement (Operand) */ - case AML_INCREMENT_OP: /* Increment (Operand) */ - /* - * Create a new integer. Can't just get the base integer and - * increment it because it may be an Arg or Field. - */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* - * Since we are expecting a Reference operand, it can be either a - * NS Node or an internal object. - */ - TempDesc = Operand[0]; - if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND) - { - /* Internal reference object - prevent deletion */ - - AcpiUtAddReference (TempDesc); - } - - /* - * Convert the Reference operand to an Integer (This removes a - * reference on the Operand[0] object) - * - * NOTE: We use LNOT_OP here in order to force resolution of the - * reference operand to an actual integer. - */ - Status = AcpiExResolveOperands (AML_LOGICAL_NOT_OP, - &TempDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "While resolving operands for [%s]", - AcpiPsGetOpcodeName (WalkState->Opcode))); - - goto Cleanup; - } - - /* - * TempDesc is now guaranteed to be an Integer object -- - * Perform the actual increment or decrement - */ - if (WalkState->Opcode == AML_INCREMENT_OP) - { - ReturnDesc->Integer.Value = TempDesc->Integer.Value + 1; - } - else - { - ReturnDesc->Integer.Value = TempDesc->Integer.Value - 1; - } - - /* Finished with this Integer object */ - - AcpiUtRemoveReference (TempDesc); - - /* - * Store the result back (indirectly) through the original - * Reference object - */ - Status = AcpiExStore (ReturnDesc, Operand[0], WalkState); - break; - - case AML_OBJECT_TYPE_OP: /* ObjectType (SourceObject) */ - /* - * Note: The operand is not resolved at this point because we want to - * get the associated object, not its value. For example, we don't - * want to resolve a FieldUnit to its value, we want the actual - * FieldUnit object. - */ - - /* Get the type of the base object */ - - Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Allocate a descriptor to hold the type. */ - - ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - break; - - case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */ - /* - * Note: The operand is not resolved at this point because we want to - * get the associated object, not its value. - */ - - /* Get the base object */ - - Status = AcpiExResolveMultiple ( - WalkState, Operand[0], &Type, &TempDesc); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* - * The type of the base object must be integer, buffer, string, or - * package. All others are not supported. - * - * NOTE: Integer is not specifically supported by the ACPI spec, - * but is supported implicitly via implicit operand conversion. - * rather than bother with conversion, we just use the byte width - * global (4 or 8 bytes). - */ - switch (Type) - { - case ACPI_TYPE_INTEGER: - - Value = AcpiGbl_IntegerByteWidth; - break; - - case ACPI_TYPE_STRING: - - Value = TempDesc->String.Length; - break; - - case ACPI_TYPE_BUFFER: - - /* Buffer arguments may not be evaluated at this point */ - - Status = AcpiDsGetBufferArguments (TempDesc); - Value = TempDesc->Buffer.Length; - break; - - case ACPI_TYPE_PACKAGE: - - /* Package arguments may not be evaluated at this point */ - - Status = AcpiDsGetPackageArguments (TempDesc); - Value = TempDesc->Package.Count; - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Operand must be Buffer/Integer/String/Package" - " - found type %s", - AcpiUtGetTypeName (Type))); - - Status = AE_AML_OPERAND_TYPE; - goto Cleanup; - } - - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* - * Now that we have the size of the object, create a result - * object to hold the value - */ - ReturnDesc = AcpiUtCreateIntegerObject (Value); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - break; - - - case AML_REF_OF_OP: /* RefOf (SourceObject) */ - - Status = AcpiExGetObjectReference ( - Operand[0], &ReturnDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - break; - - - case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */ - - /* Check for a method local or argument, or standalone String */ - - if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED) - { - TempDesc = AcpiNsGetAttachedObject ( - (ACPI_NAMESPACE_NODE *) Operand[0]); - if (TempDesc && - ((TempDesc->Common.Type == ACPI_TYPE_STRING) || - (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE))) - { - Operand[0] = TempDesc; - AcpiUtAddReference (TempDesc); - } - else - { - Status = AE_AML_OPERAND_TYPE; - goto Cleanup; - } - } - else - { - switch ((Operand[0])->Common.Type) - { - case ACPI_TYPE_LOCAL_REFERENCE: - /* - * This is a DerefOf (LocalX | ArgX) - * - * Must resolve/dereference the local/arg reference first - */ - switch (Operand[0]->Reference.Class) - { - case ACPI_REFCLASS_LOCAL: - case ACPI_REFCLASS_ARG: - - /* Set Operand[0] to the value of the local/arg */ - - Status = AcpiDsMethodDataGetValue ( - Operand[0]->Reference.Class, - Operand[0]->Reference.Value, - WalkState, &TempDesc); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* - * Delete our reference to the input object and - * point to the object just retrieved - */ - AcpiUtRemoveReference (Operand[0]); - Operand[0] = TempDesc; - break; - - case ACPI_REFCLASS_REFOF: - - /* Get the object to which the reference refers */ - - TempDesc = Operand[0]->Reference.Object; - AcpiUtRemoveReference (Operand[0]); - Operand[0] = TempDesc; - break; - - default: - - /* Must be an Index op - handled below */ - break; - } - break; - - case ACPI_TYPE_STRING: - - break; - - default: - - Status = AE_AML_OPERAND_TYPE; - goto Cleanup; - } - } - - if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED) - { - if ((Operand[0])->Common.Type == ACPI_TYPE_STRING) - { - /* - * This is a DerefOf (String). The string is a reference - * to a named ACPI object. - * - * 1) Find the owning Node - * 2) Dereference the node to an actual object. Could be a - * Field, so we need to resolve the node to a value. - */ - Status = AcpiNsGetNodeUnlocked (WalkState->ScopeInfo->Scope.Node, - Operand[0]->String.Pointer, - ACPI_NS_SEARCH_PARENT, - ACPI_CAST_INDIRECT_PTR ( - ACPI_NAMESPACE_NODE, &ReturnDesc)); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - Status = AcpiExResolveNodeToValue ( - ACPI_CAST_INDIRECT_PTR ( - ACPI_NAMESPACE_NODE, &ReturnDesc), - WalkState); - goto Cleanup; - } - } - - /* Operand[0] may have changed from the code above */ - - if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED) - { - /* - * This is a DerefOf (ObjectReference) - * Get the actual object from the Node (This is the dereference). - * This case may only happen when a LocalX or ArgX is - * dereferenced above, or for references to device and - * thermal objects. - */ - switch (((ACPI_NAMESPACE_NODE *) Operand[0])->Type) - { - case ACPI_TYPE_DEVICE: - case ACPI_TYPE_THERMAL: - - /* These types have no node subobject, return the NS node */ - - ReturnDesc = Operand[0]; - break; - - default: - /* For most types, get the object attached to the node */ - - ReturnDesc = AcpiNsGetAttachedObject ( - (ACPI_NAMESPACE_NODE *) Operand[0]); - AcpiUtAddReference (ReturnDesc); - break; - } - } - else - { - /* - * This must be a reference object produced by either the - * Index() or RefOf() operator - */ - switch (Operand[0]->Reference.Class) - { - case ACPI_REFCLASS_INDEX: - /* - * The target type for the Index operator must be - * either a Buffer or a Package - */ - switch (Operand[0]->Reference.TargetType) - { - case ACPI_TYPE_BUFFER_FIELD: - - TempDesc = Operand[0]->Reference.Object; - - /* - * Create a new object that contains one element of the - * buffer -- the element pointed to by the index. - * - * NOTE: index into a buffer is NOT a pointer to a - * sub-buffer of the main buffer, it is only a pointer to a - * single element (byte) of the buffer! - * - * Since we are returning the value of the buffer at the - * indexed location, we don't need to add an additional - * reference to the buffer itself. - */ - ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) - TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - break; - - case ACPI_TYPE_PACKAGE: - /* - * Return the referenced element of the package. We must - * add another reference to the referenced object, however. - */ - ReturnDesc = *(Operand[0]->Reference.Where); - if (!ReturnDesc) - { - /* - * Element is NULL, do not allow the dereference. - * This provides compatibility with other ACPI - * implementations. - */ - return_ACPI_STATUS (AE_AML_UNINITIALIZED_ELEMENT); - } - - AcpiUtAddReference (ReturnDesc); - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Unknown Index TargetType 0x%X in reference object %p", - Operand[0]->Reference.TargetType, Operand[0])); - - Status = AE_AML_OPERAND_TYPE; - goto Cleanup; - } - break; - - case ACPI_REFCLASS_REFOF: - - ReturnDesc = Operand[0]->Reference.Object; - - if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == - ACPI_DESC_TYPE_NAMED) - { - ReturnDesc = AcpiNsGetAttachedObject ( - (ACPI_NAMESPACE_NODE *) ReturnDesc); - if (!ReturnDesc) - { - break; - } - - /* - * June 2013: - * BufferFields/FieldUnits require additional resolution - */ - switch (ReturnDesc->Common.Type) - { - case ACPI_TYPE_BUFFER_FIELD: - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: - - Status = AcpiExReadDataFromField ( - WalkState, ReturnDesc, &TempDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - ReturnDesc = TempDesc; - break; - - default: - - /* Add another reference to the object */ - - AcpiUtAddReference (ReturnDesc); - break; - } - } - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Unknown class in reference(%p) - 0x%2.2X", - Operand[0], Operand[0]->Reference.Class)); - - Status = AE_TYPE; - goto Cleanup; - } - } - break; - - default: - - ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", - WalkState->Opcode)); - - Status = AE_AML_BAD_OPCODE; - goto Cleanup; - } - - -Cleanup: - - /* Delete return object on error */ - - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (ReturnDesc); - } - - /* Save return object on success */ - - else - { - WalkState->ResultObj = ReturnDesc; - } - - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exoparg2.c b/Private/acpiSDK/source/components/executer/exoparg2.c deleted file mode 100644 index 29d9dc7e..00000000 --- a/Private/acpiSDK/source/components/executer/exoparg2.c +++ /dev/null @@ -1,750 +0,0 @@ -/****************************************************************************** - * - * Module Name: exoparg2 - AML execution - opcodes with 2 arguments - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acparser.h" -#include "acinterp.h" -#include "acevents.h" -#include "amlcode.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exoparg2") - - -/*! - * Naming convention for AML interpreter execution routines. - * - * The routines that begin execution of AML opcodes are named with a common - * convention based upon the number of arguments, the number of target operands, - * and whether or not a value is returned: - * - * AcpiExOpcode_xA_yT_zR - * - * Where: - * - * xA - ARGUMENTS: The number of arguments (input operands) that are - * required for this opcode type (1 through 6 args). - * yT - TARGETS: The number of targets (output operands) that are required - * for this opcode type (0, 1, or 2 targets). - * zR - RETURN VALUE: Indicates whether this opcode type returns a value - * as the function return (0 or 1). - * - * The AcpiExOpcode* functions are called via the Dispatcher component with - * fully resolved operands. -!*/ - - -/******************************************************************************* - * - * FUNCTION: AcpiExOpcode_2A_0T_0R - * - * PARAMETERS: WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Execute opcode with two arguments, no target, and no return - * value. - * - * ALLOCATION: Deletes both operands - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExOpcode_2A_0T_0R ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_NAMESPACE_NODE *Node; - UINT32 Value; - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_0R, - AcpiPsGetOpcodeName (WalkState->Opcode)); - - - /* Examine the opcode */ - - switch (WalkState->Opcode) - { - case AML_NOTIFY_OP: /* Notify (NotifyObject, NotifyValue) */ - - /* The first operand is a namespace node */ - - Node = (ACPI_NAMESPACE_NODE *) Operand[0]; - - /* Second value is the notify value */ - - Value = (UINT32) Operand[1]->Integer.Value; - - /* Are notifies allowed on this object? */ - - if (!AcpiEvIsNotifyObject (Node)) - { - ACPI_ERROR ((AE_INFO, - "Unexpected notify object type [%s]", - AcpiUtGetTypeName (Node->Type))); - - Status = AE_AML_OPERAND_TYPE; - break; - } - - /* - * Dispatch the notify to the appropriate handler - * NOTE: the request is queued for execution after this method - * completes. The notify handlers are NOT invoked synchronously - * from this thread -- because handlers may in turn run other - * control methods. - */ - Status = AcpiEvQueueNotifyRequest (Node, Value); - break; - - default: - - ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", - WalkState->Opcode)); - Status = AE_AML_BAD_OPCODE; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExOpcode_2A_2T_1R - * - * PARAMETERS: WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Execute a dyadic operator (2 operands) with 2 output targets - * and one implicit return value. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExOpcode_2A_2T_1R ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ReturnDesc1 = NULL; - ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_2T_1R, - AcpiPsGetOpcodeName (WalkState->Opcode)); - - - /* Execute the opcode */ - - switch (WalkState->Opcode) - { - case AML_DIVIDE_OP: - - /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */ - - ReturnDesc1 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!ReturnDesc1) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - ReturnDesc2 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!ReturnDesc2) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */ - - Status = AcpiUtDivide ( - Operand[0]->Integer.Value, - Operand[1]->Integer.Value, - &ReturnDesc1->Integer.Value, - &ReturnDesc2->Integer.Value); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - break; - - default: - - ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", - WalkState->Opcode)); - - Status = AE_AML_BAD_OPCODE; - goto Cleanup; - } - - /* Store the results to the target reference operands */ - - Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - Status = AcpiExStore (ReturnDesc1, Operand[3], WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - -Cleanup: - /* - * Since the remainder is not returned indirectly, remove a reference to - * it. Only the quotient is returned indirectly. - */ - AcpiUtRemoveReference (ReturnDesc2); - - if (ACPI_FAILURE (Status)) - { - /* Delete the return object */ - - AcpiUtRemoveReference (ReturnDesc1); - } - - /* Save return object (the remainder) on success */ - - else - { - WalkState->ResultObj = ReturnDesc1; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExOpcode_2A_1T_1R - * - * PARAMETERS: WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Execute opcode with two arguments, one target, and a return - * value. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExOpcode_2A_1T_1R ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - UINT64 Index; - ACPI_STATUS Status = AE_OK; - ACPI_SIZE Length = 0; - - - ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R, - AcpiPsGetOpcodeName (WalkState->Opcode)); - - - /* Execute the opcode */ - - if (WalkState->OpInfo->Flags & AML_MATH) - { - /* All simple math opcodes (add, etc.) */ - - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - ReturnDesc->Integer.Value = AcpiExDoMathOp ( - WalkState->Opcode, - Operand[0]->Integer.Value, - Operand[1]->Integer.Value); - goto StoreResultToTarget; - } - - switch (WalkState->Opcode) - { - case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */ - - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* ReturnDesc will contain the remainder */ - - Status = AcpiUtDivide ( - Operand[0]->Integer.Value, - Operand[1]->Integer.Value, - NULL, - &ReturnDesc->Integer.Value); - break; - - case AML_CONCATENATE_OP: /* Concatenate (Data1, Data2, Result) */ - - Status = AcpiExDoConcatenate ( - Operand[0], Operand[1], &ReturnDesc, WalkState); - break; - - case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */ - /* - * Input object is guaranteed to be a buffer at this point (it may have - * been converted.) Copy the raw buffer data to a new object of - * type String. - */ - - /* - * Get the length of the new string. It is the smallest of: - * 1) Length of the input buffer - * 2) Max length as specified in the ToString operator - * 3) Length of input buffer up to a zero byte (null terminator) - * - * NOTE: A length of zero is ok, and will create a zero-length, null - * terminated string. - */ - while ((Length < Operand[0]->Buffer.Length) && /* Length of input buffer */ - (Length < Operand[1]->Integer.Value) && /* Length operand */ - (Operand[0]->Buffer.Pointer[Length])) /* Null terminator */ - { - Length++; - } - - /* Allocate a new string object */ - - ReturnDesc = AcpiUtCreateStringObject (Length); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* - * Copy the raw buffer data with no transform. - * (NULL terminated already) - */ - memcpy (ReturnDesc->String.Pointer, - Operand[0]->Buffer.Pointer, Length); - break; - - case AML_CONCATENATE_TEMPLATE_OP: - - /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */ - - Status = AcpiExConcatTemplate ( - Operand[0], Operand[1], &ReturnDesc, WalkState); - break; - - case AML_INDEX_OP: /* Index (Source Index Result) */ - - /* Create the internal return object */ - - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Initialize the Index reference object */ - - Index = Operand[1]->Integer.Value; - ReturnDesc->Reference.Value = (UINT32) Index; - ReturnDesc->Reference.Class = ACPI_REFCLASS_INDEX; - - /* - * At this point, the Source operand is a String, Buffer, or Package. - * Verify that the index is within range. - */ - switch ((Operand[0])->Common.Type) - { - case ACPI_TYPE_STRING: - - if (Index >= Operand[0]->String.Length) - { - Length = Operand[0]->String.Length; - Status = AE_AML_STRING_LIMIT; - } - - ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; - ReturnDesc->Reference.IndexPointer = - &(Operand[0]->Buffer.Pointer [Index]); - break; - - case ACPI_TYPE_BUFFER: - - if (Index >= Operand[0]->Buffer.Length) - { - Length = Operand[0]->Buffer.Length; - Status = AE_AML_BUFFER_LIMIT; - } - - ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; - ReturnDesc->Reference.IndexPointer = - &(Operand[0]->Buffer.Pointer [Index]); - break; - - case ACPI_TYPE_PACKAGE: - - if (Index >= Operand[0]->Package.Count) - { - Length = Operand[0]->Package.Count; - Status = AE_AML_PACKAGE_LIMIT; - } - - ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; - ReturnDesc->Reference.Where = - &Operand[0]->Package.Elements [Index]; - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Invalid object type: %X", (Operand[0])->Common.Type)); - Status = AE_AML_INTERNAL; - goto Cleanup; - } - - /* Failure means that the Index was beyond the end of the object */ - - if (ACPI_FAILURE (Status)) - { - ACPI_BIOS_EXCEPTION ((AE_INFO, Status, - "Index (0x%X%8.8X) is beyond end of object (length 0x%X)", - ACPI_FORMAT_UINT64 (Index), (UINT32) Length)); - goto Cleanup; - } - - /* - * Save the target object and add a reference to it for the life - * of the index - */ - ReturnDesc->Reference.Object = Operand[0]; - AcpiUtAddReference (Operand[0]); - - /* Store the reference to the Target */ - - Status = AcpiExStore (ReturnDesc, Operand[2], WalkState); - - /* Return the reference */ - - WalkState->ResultObj = ReturnDesc; - goto Cleanup; - - default: - - ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", - WalkState->Opcode)); - Status = AE_AML_BAD_OPCODE; - break; - } - - -StoreResultToTarget: - - if (ACPI_SUCCESS (Status)) - { - /* - * Store the result of the operation (which is now in ReturnDesc) into - * the Target descriptor. - */ - Status = AcpiExStore (ReturnDesc, Operand[2], WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - if (!WalkState->ResultObj) - { - WalkState->ResultObj = ReturnDesc; - } - } - - -Cleanup: - - /* Delete return object on error */ - - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (ReturnDesc); - WalkState->ResultObj = NULL; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExOpcode_2A_0T_1R - * - * PARAMETERS: WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExOpcode_2A_0T_1R ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - ACPI_STATUS Status = AE_OK; - BOOLEAN LogicalResult = FALSE; - - - ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R, - AcpiPsGetOpcodeName (WalkState->Opcode)); - - - /* Create the internal return object */ - - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Execute the Opcode */ - - if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC) - { - /* LogicalOp (Operand0, Operand1) */ - - Status = AcpiExDoLogicalNumericOp (WalkState->Opcode, - Operand[0]->Integer.Value, Operand[1]->Integer.Value, - &LogicalResult); - goto StoreLogicalResult; - } - else if (WalkState->OpInfo->Flags & AML_LOGICAL) - { - /* LogicalOp (Operand0, Operand1) */ - - Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0], - Operand[1], &LogicalResult); - goto StoreLogicalResult; - } - - switch (WalkState->Opcode) - { - case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */ - - Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState); - if (Status == AE_TIME) - { - LogicalResult = TRUE; /* TRUE = Acquire timed out */ - Status = AE_OK; - } - break; - - - case AML_WAIT_OP: /* Wait (EventObject, Timeout) */ - - Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]); - if (Status == AE_TIME) - { - LogicalResult = TRUE; /* TRUE, Wait timed out */ - Status = AE_OK; - } - break; - - default: - - ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", - WalkState->Opcode)); - - Status = AE_AML_BAD_OPCODE; - goto Cleanup; - } - - -StoreLogicalResult: - /* - * Set return value to according to LogicalResult. logical TRUE (all ones) - * Default is FALSE (zero) - */ - if (LogicalResult) - { - ReturnDesc->Integer.Value = ACPI_UINT64_MAX; - } - -Cleanup: - - /* Delete return object on error */ - - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (ReturnDesc); - } - - /* Save return object on success */ - - else - { - WalkState->ResultObj = ReturnDesc; - } - - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exoparg3.c b/Private/acpiSDK/source/components/executer/exoparg3.c deleted file mode 100644 index a22b7257..00000000 --- a/Private/acpiSDK/source/components/executer/exoparg3.c +++ /dev/null @@ -1,421 +0,0 @@ -/****************************************************************************** - * - * Module Name: exoparg3 - AML execution - opcodes with 3 arguments - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "acparser.h" -#include "amlcode.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exoparg3") - - -/*! - * Naming convention for AML interpreter execution routines. - * - * The routines that begin execution of AML opcodes are named with a common - * convention based upon the number of arguments, the number of target operands, - * and whether or not a value is returned: - * - * AcpiExOpcode_xA_yT_zR - * - * Where: - * - * xA - ARGUMENTS: The number of arguments (input operands) that are - * required for this opcode type (1 through 6 args). - * yT - TARGETS: The number of targets (output operands) that are required - * for this opcode type (0, 1, or 2 targets). - * zR - RETURN VALUE: Indicates whether this opcode type returns a value - * as the function return (0 or 1). - * - * The AcpiExOpcode* functions are called via the Dispatcher component with - * fully resolved operands. -!*/ - - -/******************************************************************************* - * - * FUNCTION: AcpiExOpcode_3A_0T_0R - * - * PARAMETERS: WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Execute Triadic operator (3 operands) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExOpcode_3A_0T_0R ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_SIGNAL_FATAL_INFO *Fatal; - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_0T_0R, - AcpiPsGetOpcodeName (WalkState->Opcode)); - - - switch (WalkState->Opcode) - { - case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "FatalOp: Type %X Code %X Arg %X " - "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", - (UINT32) Operand[0]->Integer.Value, - (UINT32) Operand[1]->Integer.Value, - (UINT32) Operand[2]->Integer.Value)); - - Fatal = ACPI_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO)); - if (Fatal) - { - Fatal->Type = (UINT32) Operand[0]->Integer.Value; - Fatal->Code = (UINT32) Operand[1]->Integer.Value; - Fatal->Argument = (UINT32) Operand[2]->Integer.Value; - } - - /* Always signal the OS! */ - - Status = AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal); - - /* Might return while OS is shutting down, just continue */ - - ACPI_FREE (Fatal); - goto Cleanup; - - case AML_EXTERNAL_OP: - /* - * If the interpreter sees this opcode, just ignore it. The External - * op is intended for use by disassemblers in order to properly - * disassemble control method invocations. The opcode or group of - * opcodes should be surrounded by an "if (0)" clause to ensure that - * AML interpreters never see the opcode. Thus, something is - * wrong if an external opcode ever gets here. - */ - ACPI_ERROR ((AE_INFO, "Executed External Op")); - Status = AE_OK; - goto Cleanup; - - default: - - ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", - WalkState->Opcode)); - - Status = AE_AML_BAD_OPCODE; - goto Cleanup; - } - - -Cleanup: - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExOpcode_3A_1T_1R - * - * PARAMETERS: WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Execute Triadic operator (3 operands) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExOpcode_3A_1T_1R ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - char *Buffer = NULL; - ACPI_STATUS Status = AE_OK; - UINT64 Index; - ACPI_SIZE Length; - - - ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_1T_1R, - AcpiPsGetOpcodeName (WalkState->Opcode)); - - - switch (WalkState->Opcode) - { - case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ - /* - * Create the return object. The Source operand is guaranteed to be - * either a String or a Buffer, so just use its type. - */ - ReturnDesc = AcpiUtCreateInternalObject ( - (Operand[0])->Common.Type); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Get the Integer values from the objects */ - - Index = Operand[1]->Integer.Value; - Length = (ACPI_SIZE) Operand[2]->Integer.Value; - - /* - * If the index is beyond the length of the String/Buffer, or if the - * requested length is zero, return a zero-length String/Buffer - */ - if (Index >= Operand[0]->String.Length) - { - Length = 0; - } - - /* Truncate request if larger than the actual String/Buffer */ - - else if ((Index + Length) > Operand[0]->String.Length) - { - Length = - (ACPI_SIZE) Operand[0]->String.Length - (ACPI_SIZE) Index; - } - - /* Strings always have a sub-pointer, not so for buffers */ - - switch ((Operand[0])->Common.Type) - { - case ACPI_TYPE_STRING: - - /* Always allocate a new buffer for the String */ - - Buffer = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1); - if (!Buffer) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - break; - - case ACPI_TYPE_BUFFER: - - /* If the requested length is zero, don't allocate a buffer */ - - if (Length > 0) - { - /* Allocate a new buffer for the Buffer */ - - Buffer = ACPI_ALLOCATE_ZEROED (Length); - if (!Buffer) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - } - break; - - default: /* Should not happen */ - - Status = AE_AML_OPERAND_TYPE; - goto Cleanup; - } - - if (Buffer) - { - /* We have a buffer, copy the portion requested */ - - memcpy (Buffer, - Operand[0]->String.Pointer + Index, Length); - } - - /* Set the length of the new String/Buffer */ - - ReturnDesc->String.Pointer = Buffer; - ReturnDesc->String.Length = (UINT32) Length; - - /* Mark buffer initialized */ - - ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; - break; - - default: - - ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", - WalkState->Opcode)); - - Status = AE_AML_BAD_OPCODE; - goto Cleanup; - } - - /* Store the result in the target */ - - Status = AcpiExStore (ReturnDesc, Operand[3], WalkState); - -Cleanup: - - /* Delete return object on error */ - - if (ACPI_FAILURE (Status) || WalkState->ResultObj) - { - AcpiUtRemoveReference (ReturnDesc); - WalkState->ResultObj = NULL; - } - else - { - /* Set the return object and exit */ - - WalkState->ResultObj = ReturnDesc; - } - - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exoparg6.c b/Private/acpiSDK/source/components/executer/exoparg6.c deleted file mode 100644 index ad69405e..00000000 --- a/Private/acpiSDK/source/components/executer/exoparg6.c +++ /dev/null @@ -1,465 +0,0 @@ -/****************************************************************************** - * - * Module Name: exoparg6 - AML execution - opcodes with 6 arguments - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "acparser.h" -#include "amlcode.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exoparg6") - - -/*! - * Naming convention for AML interpreter execution routines. - * - * The routines that begin execution of AML opcodes are named with a common - * convention based upon the number of arguments, the number of target operands, - * and whether or not a value is returned: - * - * AcpiExOpcode_xA_yT_zR - * - * Where: - * - * xA - ARGUMENTS: The number of arguments (input operands) that are - * required for this opcode type (1 through 6 args). - * yT - TARGETS: The number of targets (output operands) that are required - * for this opcode type (0, 1, or 2 targets). - * zR - RETURN VALUE: Indicates whether this opcode type returns a value - * as the function return (0 or 1). - * - * The AcpiExOpcode* functions are called via the Dispatcher component with - * fully resolved operands. -!*/ - -/* Local prototypes */ - -static BOOLEAN -AcpiExDoMatch ( - UINT32 MatchOp, - ACPI_OPERAND_OBJECT *PackageObj, - ACPI_OPERAND_OBJECT *MatchObj); - - -/******************************************************************************* - * - * FUNCTION: AcpiExDoMatch - * - * PARAMETERS: MatchOp - The AML match operand - * PackageObj - Object from the target package - * MatchObj - Object to be matched - * - * RETURN: TRUE if the match is successful, FALSE otherwise - * - * DESCRIPTION: Implements the low-level match for the ASL Match operator. - * Package elements will be implicitly converted to the type of - * the match object (Integer/Buffer/String). - * - ******************************************************************************/ - -static BOOLEAN -AcpiExDoMatch ( - UINT32 MatchOp, - ACPI_OPERAND_OBJECT *PackageObj, - ACPI_OPERAND_OBJECT *MatchObj) -{ - BOOLEAN LogicalResult = TRUE; - ACPI_STATUS Status; - - - /* - * Note: Since the PackageObj/MatchObj ordering is opposite to that of - * the standard logical operators, we have to reverse them when we call - * DoLogicalOp in order to make the implicit conversion rules work - * correctly. However, this means we have to flip the entire equation - * also. A bit ugly perhaps, but overall, better than fussing the - * parameters around at runtime, over and over again. - * - * Below, P[i] refers to the package element, M refers to the Match object. - */ - switch (MatchOp) - { - case MATCH_MTR: - - /* Always true */ - - break; - - case MATCH_MEQ: - /* - * True if equal: (P[i] == M) - * Change to: (M == P[i]) - */ - Status = AcpiExDoLogicalOp ( - AML_LOGICAL_EQUAL_OP, MatchObj, PackageObj, &LogicalResult); - if (ACPI_FAILURE (Status)) - { - return (FALSE); - } - break; - - case MATCH_MLE: - /* - * True if less than or equal: (P[i] <= M) (P[i] NotGreater than M) - * Change to: (M >= P[i]) (M NotLess than P[i]) - */ - Status = AcpiExDoLogicalOp ( - AML_LOGICAL_LESS_OP, MatchObj, PackageObj, &LogicalResult); - if (ACPI_FAILURE (Status)) - { - return (FALSE); - } - LogicalResult = (BOOLEAN) !LogicalResult; - break; - - case MATCH_MLT: - /* - * True if less than: (P[i] < M) - * Change to: (M > P[i]) - */ - Status = AcpiExDoLogicalOp ( - AML_LOGICAL_GREATER_OP, MatchObj, PackageObj, &LogicalResult); - if (ACPI_FAILURE (Status)) - { - return (FALSE); - } - break; - - case MATCH_MGE: - /* - * True if greater than or equal: (P[i] >= M) (P[i] NotLess than M) - * Change to: (M <= P[i]) (M NotGreater than P[i]) - */ - Status = AcpiExDoLogicalOp ( - AML_LOGICAL_GREATER_OP, MatchObj, PackageObj, &LogicalResult); - if (ACPI_FAILURE (Status)) - { - return (FALSE); - } - LogicalResult = (BOOLEAN)!LogicalResult; - break; - - case MATCH_MGT: - /* - * True if greater than: (P[i] > M) - * Change to: (M < P[i]) - */ - Status = AcpiExDoLogicalOp ( - AML_LOGICAL_LESS_OP, MatchObj, PackageObj, &LogicalResult); - if (ACPI_FAILURE (Status)) - { - return (FALSE); - } - break; - - default: - - /* Undefined */ - - return (FALSE); - } - - return (LogicalResult); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExOpcode_6A_0T_1R - * - * PARAMETERS: WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExOpcode_6A_0T_1R ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - ACPI_STATUS Status = AE_OK; - UINT64 Index; - ACPI_OPERAND_OBJECT *ThisElement; - - - ACPI_FUNCTION_TRACE_STR (ExOpcode_6A_0T_1R, - AcpiPsGetOpcodeName (WalkState->Opcode)); - - - switch (WalkState->Opcode) - { - case AML_MATCH_OP: - /* - * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2], - * MatchOp2[3], MatchObj2[4], StartIndex[5]) - */ - - /* Validate both Match Term Operators (MTR, MEQ, etc.) */ - - if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) || - (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR)) - { - ACPI_ERROR ((AE_INFO, "Match operator out of range")); - Status = AE_AML_OPERAND_VALUE; - goto Cleanup; - } - - /* Get the package StartIndex, validate against the package length */ - - Index = Operand[5]->Integer.Value; - if (Index >= Operand[0]->Package.Count) - { - ACPI_ERROR ((AE_INFO, - "Index (0x%8.8X%8.8X) beyond package end (0x%X)", - ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count)); - Status = AE_AML_PACKAGE_LIMIT; - goto Cleanup; - } - - /* Create an integer for the return value */ - /* Default return value is ACPI_UINT64_MAX if no match found */ - - ReturnDesc = AcpiUtCreateIntegerObject (ACPI_UINT64_MAX); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - - } - - /* - * Examine each element until a match is found. Both match conditions - * must be satisfied for a match to occur. Within the loop, - * "continue" signifies that the current element does not match - * and the next should be examined. - * - * Upon finding a match, the loop will terminate via "break" at - * the bottom. If it terminates "normally", MatchValue will be - * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no - * match was found. - */ - for ( ; Index < Operand[0]->Package.Count; Index++) - { - /* Get the current package element */ - - ThisElement = Operand[0]->Package.Elements[Index]; - - /* Treat any uninitialized (NULL) elements as non-matching */ - - if (!ThisElement) - { - continue; - } - - /* - * Both match conditions must be satisfied. Execution of a continue - * (proceed to next iteration of enclosing for loop) signifies a - * non-match. - */ - if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value, - ThisElement, Operand[2])) - { - continue; - } - - if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value, - ThisElement, Operand[4])) - { - continue; - } - - /* Match found: Index is the return value */ - - ReturnDesc->Integer.Value = Index; - break; - } - break; - - case AML_LOAD_TABLE_OP: - - Status = AcpiExLoadTableOp (WalkState, &ReturnDesc); - break; - - default: - - ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", - WalkState->Opcode)); - - Status = AE_AML_BAD_OPCODE; - goto Cleanup; - } - - -Cleanup: - - /* Delete return object on error */ - - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (ReturnDesc); - } - - /* Save return object on success */ - - else - { - WalkState->ResultObj = ReturnDesc; - } - - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exprep.c b/Private/acpiSDK/source/components/executer/exprep.c deleted file mode 100644 index 678ee8a1..00000000 --- a/Private/acpiSDK/source/components/executer/exprep.c +++ /dev/null @@ -1,771 +0,0 @@ -/****************************************************************************** - * - * Module Name: exprep - ACPI AML field prep utilities - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acdispat.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exprep") - -/* Local prototypes */ - -static UINT32 -AcpiExDecodeFieldAccess ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT8 FieldFlags, - UINT32 *ReturnByteAlignment); - - -#ifdef ACPI_UNDER_DEVELOPMENT - -static UINT32 -AcpiExGenerateAccess ( - UINT32 FieldBitOffset, - UINT32 FieldBitLength, - UINT32 RegionLength); - - -/******************************************************************************* - * - * FUNCTION: AcpiExGenerateAccess - * - * PARAMETERS: FieldBitOffset - Start of field within parent region/buffer - * FieldBitLength - Length of field in bits - * RegionLength - Length of parent in bytes - * - * RETURN: Field granularity (8, 16, 32 or 64) and - * ByteAlignment (1, 2, 3, or 4) - * - * DESCRIPTION: Generate an optimal access width for fields defined with the - * AnyAcc keyword. - * - * NOTE: Need to have the RegionLength in order to check for boundary - * conditions (end-of-region). However, the RegionLength is a deferred - * operation. Therefore, to complete this implementation, the generation - * of this access width must be deferred until the region length has - * been evaluated. - * - ******************************************************************************/ - -static UINT32 -AcpiExGenerateAccess ( - UINT32 FieldBitOffset, - UINT32 FieldBitLength, - UINT32 RegionLength) -{ - UINT32 FieldByteLength; - UINT32 FieldByteOffset; - UINT32 FieldByteEndOffset; - UINT32 AccessByteWidth; - UINT32 FieldStartOffset; - UINT32 FieldEndOffset; - UINT32 MinimumAccessWidth = 0xFFFFFFFF; - UINT32 MinimumAccesses = 0xFFFFFFFF; - UINT32 Accesses; - - - ACPI_FUNCTION_TRACE (ExGenerateAccess); - - - /* Round Field start offset and length to "minimal" byte boundaries */ - - FieldByteOffset = ACPI_DIV_8 ( - ACPI_ROUND_DOWN (FieldBitOffset, 8)); - - FieldByteEndOffset = ACPI_DIV_8 ( - ACPI_ROUND_UP (FieldBitLength + FieldBitOffset, 8)); - - FieldByteLength = FieldByteEndOffset - FieldByteOffset; - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Bit length %u, Bit offset %u\n", - FieldBitLength, FieldBitOffset)); - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Byte Length %u, Byte Offset %u, End Offset %u\n", - FieldByteLength, FieldByteOffset, FieldByteEndOffset)); - - /* - * Iterative search for the maximum access width that is both aligned - * and does not go beyond the end of the region - * - * Start at ByteAcc and work upwards to QwordAcc max. (1,2,4,8 bytes) - */ - for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1) - { - /* - * 1) Round end offset up to next access boundary and make sure that - * this does not go beyond the end of the parent region. - * 2) When the Access width is greater than the FieldByteLength, we - * are done. (This does not optimize for the perfectly aligned - * case yet). - */ - if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= - RegionLength) - { - FieldStartOffset = - ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) / - AccessByteWidth; - - FieldEndOffset = - ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset), - AccessByteWidth) / AccessByteWidth; - - Accesses = FieldEndOffset - FieldStartOffset; - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "AccessWidth %u end is within region\n", AccessByteWidth)); - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Field Start %u, Field End %u -- requires %u accesses\n", - FieldStartOffset, FieldEndOffset, Accesses)); - - /* Single access is optimal */ - - if (Accesses <= 1) - { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Entire field can be accessed " - "with one operation of size %u\n", - AccessByteWidth)); - return_VALUE (AccessByteWidth); - } - - /* - * Fits in the region, but requires more than one read/write. - * try the next wider access on next iteration - */ - if (Accesses < MinimumAccesses) - { - MinimumAccesses = Accesses; - MinimumAccessWidth = AccessByteWidth; - } - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "AccessWidth %u end is NOT within region\n", - AccessByteWidth)); - if (AccessByteWidth == 1) - { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Field goes beyond end-of-region!\n")); - - /* Field does not fit in the region at all */ - - return_VALUE (0); - } - - /* - * This width goes beyond the end-of-region, back off to - * previous access - */ - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Backing off to previous optimal access width of %u\n", - MinimumAccessWidth)); - return_VALUE (MinimumAccessWidth); - } - } - - /* - * Could not read/write field with one operation, - * just use max access width - */ - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Cannot access field in one operation, using width 8\n")); - - return_VALUE (8); -} -#endif /* ACPI_UNDER_DEVELOPMENT */ - - -/******************************************************************************* - * - * FUNCTION: AcpiExDecodeFieldAccess - * - * PARAMETERS: ObjDesc - Field object - * FieldFlags - Encoded fieldflags (contains access bits) - * ReturnByteAlignment - Where the byte alignment is returned - * - * RETURN: Field granularity (8, 16, 32 or 64) and - * ByteAlignment (1, 2, 3, or 4) - * - * DESCRIPTION: Decode the AccessType bits of a field definition. - * - ******************************************************************************/ - -static UINT32 -AcpiExDecodeFieldAccess ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT8 FieldFlags, - UINT32 *ReturnByteAlignment) -{ - UINT32 Access; - UINT32 ByteAlignment; - UINT32 BitLength; - - - ACPI_FUNCTION_TRACE (ExDecodeFieldAccess); - - - Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK); - - switch (Access) - { - case AML_FIELD_ACCESS_ANY: - -#ifdef ACPI_UNDER_DEVELOPMENT - ByteAlignment = - AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset, - ObjDesc->CommonField.BitLength, - 0xFFFFFFFF /* Temp until we pass RegionLength as parameter */); - BitLength = ByteAlignment * 8; -#endif - - ByteAlignment = 1; - BitLength = 8; - break; - - case AML_FIELD_ACCESS_BYTE: - case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */ - - ByteAlignment = 1; - BitLength = 8; - break; - - case AML_FIELD_ACCESS_WORD: - - ByteAlignment = 2; - BitLength = 16; - break; - - case AML_FIELD_ACCESS_DWORD: - - ByteAlignment = 4; - BitLength = 32; - break; - - case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ - - ByteAlignment = 8; - BitLength = 64; - break; - - default: - - /* Invalid field access type */ - - ACPI_ERROR ((AE_INFO, - "Unknown field access type 0x%X", - Access)); - - return_UINT32 (0); - } - - if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) - { - /* - * BufferField access can be on any byte boundary, so the - * ByteAlignment is always 1 byte -- regardless of any ByteAlignment - * implied by the field access type. - */ - ByteAlignment = 1; - } - - *ReturnByteAlignment = ByteAlignment; - return_UINT32 (BitLength); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExPrepCommonFieldObject - * - * PARAMETERS: ObjDesc - The field object - * FieldFlags - Access, LockRule, and UpdateRule. - * The format of a FieldFlag is described - * in the ACPI specification - * FieldAttribute - Special attributes (not used) - * FieldBitPosition - Field start position - * FieldBitLength - Field length in number of bits - * - * RETURN: Status - * - * DESCRIPTION: Initialize the areas of the field object that are common - * to the various types of fields. Note: This is very "sensitive" - * code because we are solving the general case for field - * alignment. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExPrepCommonFieldObject ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT8 FieldFlags, - UINT8 FieldAttribute, - UINT32 FieldBitPosition, - UINT32 FieldBitLength) -{ - UINT32 AccessBitWidth; - UINT32 ByteAlignment; - UINT32 NearestByteAddress; - - - ACPI_FUNCTION_TRACE (ExPrepCommonFieldObject); - - - /* - * Note: the structure being initialized is the - * ACPI_COMMON_FIELD_INFO; No structure fields outside of the common - * area are initialized by this procedure. - */ - ObjDesc->CommonField.FieldFlags = FieldFlags; - ObjDesc->CommonField.Attribute = FieldAttribute; - ObjDesc->CommonField.BitLength = FieldBitLength; - - /* - * Decode the access type so we can compute offsets. The access type gives - * two pieces of information - the width of each field access and the - * necessary ByteAlignment (address granularity) of the access. - * - * For AnyAcc, the AccessBitWidth is the largest width that is both - * necessary and possible in an attempt to access the whole field in one - * I/O operation. However, for AnyAcc, the ByteAlignment is always one - * byte. - * - * For all Buffer Fields, the ByteAlignment is always one byte. - * - * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is - * the same (equivalent) as the ByteAlignment. - */ - AccessBitWidth = AcpiExDecodeFieldAccess ( - ObjDesc, FieldFlags, &ByteAlignment); - if (!AccessBitWidth) - { - return_ACPI_STATUS (AE_AML_OPERAND_VALUE); - } - - /* Setup width (access granularity) fields (values are: 1, 2, 4, 8) */ - - ObjDesc->CommonField.AccessByteWidth = (UINT8) - ACPI_DIV_8 (AccessBitWidth); - - /* - * BaseByteOffset is the address of the start of the field within the - * region. It is the byte address of the first *datum* (field-width data - * unit) of the field. (i.e., the first datum that contains at least the - * first *bit* of the field.) - * - * Note: ByteAlignment is always either equal to the AccessBitWidth or 8 - * (Byte access), and it defines the addressing granularity of the parent - * region or buffer. - */ - NearestByteAddress = - ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition); - ObjDesc->CommonField.BaseByteOffset = (UINT32) - ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment); - - /* - * StartFieldBitOffset is the offset of the first bit of the field within - * a field datum. - */ - ObjDesc->CommonField.StartFieldBitOffset = (UINT8) - (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset)); - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExPrepFieldValue - * - * PARAMETERS: Info - Contains all field creation info - * - * RETURN: Status - * - * DESCRIPTION: Construct an object of type ACPI_OPERAND_OBJECT with a - * subtype of DefField and connect it to the parent Node. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExPrepFieldValue ( - ACPI_CREATE_FIELD_INFO *Info) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *SecondDesc = NULL; - ACPI_STATUS Status; - UINT32 AccessByteWidth; - UINT32 Type; - - - ACPI_FUNCTION_TRACE (ExPrepFieldValue); - - - /* Parameter validation */ - - if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD) - { - if (!Info->RegionNode) - { - ACPI_ERROR ((AE_INFO, "Null RegionNode")); - return_ACPI_STATUS (AE_AML_NO_OPERAND); - } - - Type = AcpiNsGetType (Info->RegionNode); - if (Type != ACPI_TYPE_REGION) - { - ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)", - Type, AcpiUtGetTypeName (Type))); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - } - - /* Allocate a new field object */ - - ObjDesc = AcpiUtCreateInternalObject (Info->FieldType); - if (!ObjDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Initialize areas of the object that are common to all fields */ - - ObjDesc->CommonField.Node = Info->FieldNode; - Status = AcpiExPrepCommonFieldObject (ObjDesc, - Info->FieldFlags, Info->Attribute, - Info->FieldBitPosition, Info->FieldBitLength); - if (ACPI_FAILURE (Status)) - { - AcpiUtDeleteObjectDesc (ObjDesc); - return_ACPI_STATUS (Status); - } - - /* Initialize areas of the object that are specific to the field type */ - - switch (Info->FieldType) - { - case ACPI_TYPE_LOCAL_REGION_FIELD: - - ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); - - /* Fields specific to GenericSerialBus fields */ - - ObjDesc->Field.AccessLength = Info->AccessLength; - - if (Info->ConnectionNode) - { - SecondDesc = Info->ConnectionNode->Object; - if (!(SecondDesc->Common.Flags & AOPOBJ_DATA_VALID)) - { - Status = AcpiDsGetBufferArguments (SecondDesc); - if (ACPI_FAILURE (Status)) - { - AcpiUtDeleteObjectDesc (ObjDesc); - return_ACPI_STATUS (Status); - } - } - - ObjDesc->Field.ResourceBuffer = - SecondDesc->Buffer.Pointer; - ObjDesc->Field.ResourceLength = - (UINT16) SecondDesc->Buffer.Length; - } - else if (Info->ResourceBuffer) - { - ObjDesc->Field.ResourceBuffer = Info->ResourceBuffer; - ObjDesc->Field.ResourceLength = Info->ResourceLength; - } - - ObjDesc->Field.PinNumberIndex = Info->PinNumberIndex; - - /* Allow full data read from EC address space */ - - if ((ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_EC) && - (ObjDesc->CommonField.BitLength > 8)) - { - AccessByteWidth = ACPI_ROUND_BITS_UP_TO_BYTES ( - ObjDesc->CommonField.BitLength); - - /* Maximum byte width supported is 255 */ - - if (AccessByteWidth < 256) - { - ObjDesc->CommonField.AccessByteWidth = - (UINT8) AccessByteWidth; - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", - ObjDesc->Field.StartFieldBitOffset, - ObjDesc->Field.BaseByteOffset, - ObjDesc->Field.AccessByteWidth, - ObjDesc->Field.RegionObj)); - break; - - case ACPI_TYPE_LOCAL_BANK_FIELD: - - ObjDesc->BankField.Value = Info->BankValue; - ObjDesc->BankField.RegionObj = - AcpiNsGetAttachedObject (Info->RegionNode); - ObjDesc->BankField.BankObj = - AcpiNsGetAttachedObject (Info->RegisterNode); - - /* An additional reference for the attached objects */ - - AcpiUtAddReference (ObjDesc->BankField.RegionObj); - AcpiUtAddReference (ObjDesc->BankField.BankObj); - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n", - ObjDesc->BankField.StartFieldBitOffset, - ObjDesc->BankField.BaseByteOffset, - ObjDesc->Field.AccessByteWidth, - ObjDesc->BankField.RegionObj, - ObjDesc->BankField.BankObj)); - - /* - * Remember location in AML stream of the field unit - * opcode and operands -- since the BankValue - * operands must be evaluated. - */ - SecondDesc = ObjDesc->Common.NextObject; - SecondDesc->Extra.AmlStart = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, - Info->DataRegisterNode)->Named.Data; - SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, - Info->DataRegisterNode)->Named.Length; - - break; - - case ACPI_TYPE_LOCAL_INDEX_FIELD: - - /* Get the Index and Data registers */ - - ObjDesc->IndexField.IndexObj = - AcpiNsGetAttachedObject (Info->RegisterNode); - ObjDesc->IndexField.DataObj = - AcpiNsGetAttachedObject (Info->DataRegisterNode); - - if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj) - { - ACPI_ERROR ((AE_INFO, "Null Index Object during field prep")); - AcpiUtDeleteObjectDesc (ObjDesc); - return_ACPI_STATUS (AE_AML_INTERNAL); - } - - /* An additional reference for the attached objects */ - - AcpiUtAddReference (ObjDesc->IndexField.DataObj); - AcpiUtAddReference (ObjDesc->IndexField.IndexObj); - - /* - * April 2006: Changed to match MS behavior - * - * The value written to the Index register is the byte offset of the - * target field in units of the granularity of the IndexField - * - * Previously, the value was calculated as an index in terms of the - * width of the Data register, as below: - * - * ObjDesc->IndexField.Value = (UINT32) - * (Info->FieldBitPosition / ACPI_MUL_8 ( - * ObjDesc->Field.AccessByteWidth)); - * - * February 2006: Tried value as a byte offset: - * ObjDesc->IndexField.Value = (UINT32) - * ACPI_DIV_8 (Info->FieldBitPosition); - */ - ObjDesc->IndexField.Value = (UINT32) ACPI_ROUND_DOWN ( - ACPI_DIV_8 (Info->FieldBitPosition), - ObjDesc->IndexField.AccessByteWidth); - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "IndexField: BitOff %X, Off %X, Value %X, " - "Gran %X, Index %p, Data %p\n", - ObjDesc->IndexField.StartFieldBitOffset, - ObjDesc->IndexField.BaseByteOffset, - ObjDesc->IndexField.Value, - ObjDesc->Field.AccessByteWidth, - ObjDesc->IndexField.IndexObj, - ObjDesc->IndexField.DataObj)); - break; - - default: - - /* No other types should get here */ - - break; - } - - /* - * Store the constructed descriptor (ObjDesc) into the parent Node, - * preserving the current type of that NamedObj. - */ - Status = AcpiNsAttachObject ( - Info->FieldNode, ObjDesc, AcpiNsGetType (Info->FieldNode)); - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Set NamedObj %p [%4.4s], ObjDesc %p\n", - Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc)); - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exregion.c b/Private/acpiSDK/source/components/executer/exregion.c deleted file mode 100644 index 858d31fe..00000000 --- a/Private/acpiSDK/source/components/executer/exregion.c +++ /dev/null @@ -1,728 +0,0 @@ -/****************************************************************************** - * - * Module Name: exregion - ACPI default OpRegion (address space) handlers - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exregion") - - -/******************************************************************************* - * - * FUNCTION: AcpiExSystemMemorySpaceHandler - * - * PARAMETERS: Function - Read or Write operation - * Address - Where in the space to read or write - * BitWidth - Field width in bits (8, 16, or 32) - * Value - Pointer to in or out value - * HandlerContext - Pointer to Handler's context - * RegionContext - Pointer to context specific to the - * accessed region - * - * RETURN: Status - * - * DESCRIPTION: Handler for the System Memory address space (Op Region) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExSystemMemorySpaceHandler ( - UINT32 Function, - ACPI_PHYSICAL_ADDRESS Address, - UINT32 BitWidth, - UINT64 *Value, - void *HandlerContext, - void *RegionContext) -{ - ACPI_STATUS Status = AE_OK; - void *LogicalAddrPtr = NULL; - ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext; - ACPI_MEM_MAPPING *Mm = MemInfo->CurMm; - UINT32 Length; - ACPI_SIZE MapLength; - ACPI_SIZE PageBoundaryMapLength; -#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED - UINT32 Remainder; -#endif - - - ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler); - - - /* Validate and translate the bit width */ - - switch (BitWidth) - { - case 8: - - Length = 1; - break; - - case 16: - - Length = 2; - break; - - case 32: - - Length = 4; - break; - - case 64: - - Length = 8; - break; - - default: - - ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %u", - BitWidth)); - return_ACPI_STATUS (AE_AML_OPERAND_VALUE); - } - -#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED - /* - * Hardware does not support non-aligned data transfers, we must verify - * the request. - */ - (void) AcpiUtShortDivide ((UINT64) Address, Length, NULL, &Remainder); - if (Remainder != 0) - { - return_ACPI_STATUS (AE_AML_ALIGNMENT); - } -#endif - - /* - * Does the request fit into the cached memory mapping? - * Is 1) Address below the current mapping? OR - * 2) Address beyond the current mapping? - */ - if (!Mm || (Address < Mm->PhysicalAddress) || - ((UINT64) Address + Length > (UINT64) Mm->PhysicalAddress + Mm->Length)) - { - /* - * The request cannot be resolved by the current memory mapping. - * - * Look for an existing saved mapping covering the address range - * at hand. If found, save it as the current one and carry out - * the access. - */ - for (Mm = MemInfo->FirstMm; Mm; Mm = Mm->NextMm) - { - if (Mm == MemInfo->CurMm) - { - continue; - } - - if (Address < Mm->PhysicalAddress) - { - continue; - } - - if ((UINT64) Address + Length > (UINT64) Mm->PhysicalAddress + Mm->Length) - { - continue; - } - - MemInfo->CurMm = Mm; - goto access; - } - - /* Create a new mappings list entry */ - - Mm = ACPI_ALLOCATE_ZEROED(sizeof(*Mm)); - if (!Mm) - { - ACPI_ERROR((AE_INFO, - "Unable to save memory mapping at 0x%8.8X%8.8X, size %u", - ACPI_FORMAT_UINT64(Address), Length)); - return_ACPI_STATUS(AE_NO_MEMORY); - } - - /* - * October 2009: Attempt to map from the requested address to the - * end of the region. However, we will never map more than one - * page, nor will we cross a page boundary. - */ - MapLength = (ACPI_SIZE) - ((MemInfo->Address + MemInfo->Length) - Address); - - /* - * If mapping the entire remaining portion of the region will cross - * a page boundary, just map up to the page boundary, do not cross. - * On some systems, crossing a page boundary while mapping regions - * can cause warnings if the pages have different attributes - * due to resource management. - * - * This has the added benefit of constraining a single mapping to - * one page, which is similar to the original code that used a 4k - * maximum window. - */ - PageBoundaryMapLength = (ACPI_SIZE) - (ACPI_ROUND_UP (Address, ACPI_DEFAULT_PAGE_SIZE) - Address); - if (PageBoundaryMapLength == 0) - { - PageBoundaryMapLength = ACPI_DEFAULT_PAGE_SIZE; - } - - if (MapLength > PageBoundaryMapLength) - { - MapLength = PageBoundaryMapLength; - } - - /* Create a new mapping starting at the address given */ - - LogicalAddrPtr = AcpiOsMapMemory(Address, MapLength); - if (!LogicalAddrPtr) - { - ACPI_ERROR ((AE_INFO, - "Could not map memory at 0x%8.8X%8.8X, size %u", - ACPI_FORMAT_UINT64 (Address), (UINT32) MapLength)); - ACPI_FREE(Mm); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Save the physical address and mapping size */ - - Mm->LogicalAddress = LogicalAddrPtr; - Mm->PhysicalAddress = Address; - Mm->Length = MapLength; - - /* - * Add the new entry to the mappigs list and save it as the - * current mapping. - */ - Mm->NextMm = MemInfo->FirstMm; - MemInfo->FirstMm = Mm; - MemInfo->CurMm = Mm; - } - -access: - /* - * Generate a logical pointer corresponding to the address we want to - * access - */ - LogicalAddrPtr = Mm->LogicalAddress + - ((UINT64) Address - (UINT64) Mm->PhysicalAddress); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n", - BitWidth, Function, ACPI_FORMAT_UINT64 (Address))); - - /* - * Perform the memory read or write - * - * Note: For machines that do not support non-aligned transfers, the target - * address was checked for alignment above. We do not attempt to break the - * transfer up into smaller (byte-size) chunks because the AML specifically - * asked for a transfer width that the hardware may require. - */ - switch (Function) - { - case ACPI_READ: - - *Value = 0; - switch (BitWidth) - { - case 8: - - *Value = (UINT64) ACPI_GET8 (LogicalAddrPtr); - break; - - case 16: - - *Value = (UINT64) ACPI_GET16 (LogicalAddrPtr); - break; - - case 32: - - *Value = (UINT64) ACPI_GET32 (LogicalAddrPtr); - break; - - case 64: - - *Value = (UINT64) ACPI_GET64 (LogicalAddrPtr); - break; - - default: - - /* BitWidth was already validated */ - - break; - } - break; - - case ACPI_WRITE: - - switch (BitWidth) - { - case 8: - - ACPI_SET8 (LogicalAddrPtr, *Value); - break; - - case 16: - - ACPI_SET16 (LogicalAddrPtr, *Value); - break; - - case 32: - - ACPI_SET32 (LogicalAddrPtr, *Value); - break; - - case 64: - - ACPI_SET64 (LogicalAddrPtr, *Value); - break; - - default: - - /* BitWidth was already validated */ - - break; - } - break; - - default: - - Status = AE_BAD_PARAMETER; - break; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExSystemIoSpaceHandler - * - * PARAMETERS: Function - Read or Write operation - * Address - Where in the space to read or write - * BitWidth - Field width in bits (8, 16, or 32) - * Value - Pointer to in or out value - * HandlerContext - Pointer to Handler's context - * RegionContext - Pointer to context specific to the - * accessed region - * - * RETURN: Status - * - * DESCRIPTION: Handler for the System IO address space (Op Region) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExSystemIoSpaceHandler ( - UINT32 Function, - ACPI_PHYSICAL_ADDRESS Address, - UINT32 BitWidth, - UINT64 *Value, - void *HandlerContext, - void *RegionContext) -{ - ACPI_STATUS Status = AE_OK; - UINT32 Value32; - - - ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler); - - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n", - BitWidth, Function, ACPI_FORMAT_UINT64 (Address))); - - /* Decode the function parameter */ - - switch (Function) - { - case ACPI_READ: - - Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address, - &Value32, BitWidth); - *Value = Value32; - break; - - case ACPI_WRITE: - - Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address, - (UINT32) *Value, BitWidth); - break; - - default: - - Status = AE_BAD_PARAMETER; - break; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExPciConfigSpaceHandler - * - * PARAMETERS: Function - Read or Write operation - * Address - Where in the space to read or write - * BitWidth - Field width in bits (8, 16, or 32) - * Value - Pointer to in or out value - * HandlerContext - Pointer to Handler's context - * RegionContext - Pointer to context specific to the - * accessed region - * - * RETURN: Status - * - * DESCRIPTION: Handler for the PCI Config address space (Op Region) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExPciConfigSpaceHandler ( - UINT32 Function, - ACPI_PHYSICAL_ADDRESS Address, - UINT32 BitWidth, - UINT64 *Value, - void *HandlerContext, - void *RegionContext) -{ - ACPI_STATUS Status = AE_OK; - ACPI_PCI_ID *PciId; - UINT16 PciRegister; - - - ACPI_FUNCTION_TRACE (ExPciConfigSpaceHandler); - - - /* - * The arguments to AcpiOs(Read|Write)PciConfiguration are: - * - * PciSegment is the PCI bus segment range 0-31 - * PciBus is the PCI bus number range 0-255 - * PciDevice is the PCI device number range 0-31 - * PciFunction is the PCI device function number - * PciRegister is the Config space register range 0-255 bytes - * - * Value - input value for write, output address for read - * - */ - PciId = (ACPI_PCI_ID *) RegionContext; - PciRegister = (UINT16) (UINT32) Address; - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Pci-Config %u (%u) Seg(%04x) Bus(%04x) " - "Dev(%04x) Func(%04x) Reg(%04x)\n", - Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device, - PciId->Function, PciRegister)); - - switch (Function) - { - case ACPI_READ: - - *Value = 0; - Status = AcpiOsReadPciConfiguration ( - PciId, PciRegister, Value, BitWidth); - break; - - case ACPI_WRITE: - - Status = AcpiOsWritePciConfiguration ( - PciId, PciRegister, *Value, BitWidth); - break; - - default: - - Status = AE_BAD_PARAMETER; - break; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExCmosSpaceHandler - * - * PARAMETERS: Function - Read or Write operation - * Address - Where in the space to read or write - * BitWidth - Field width in bits (8, 16, or 32) - * Value - Pointer to in or out value - * HandlerContext - Pointer to Handler's context - * RegionContext - Pointer to context specific to the - * accessed region - * - * RETURN: Status - * - * DESCRIPTION: Handler for the CMOS address space (Op Region) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExCmosSpaceHandler ( - UINT32 Function, - ACPI_PHYSICAL_ADDRESS Address, - UINT32 BitWidth, - UINT64 *Value, - void *HandlerContext, - void *RegionContext) -{ - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE (ExCmosSpaceHandler); - - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExPciBarSpaceHandler - * - * PARAMETERS: Function - Read or Write operation - * Address - Where in the space to read or write - * BitWidth - Field width in bits (8, 16, or 32) - * Value - Pointer to in or out value - * HandlerContext - Pointer to Handler's context - * RegionContext - Pointer to context specific to the - * accessed region - * - * RETURN: Status - * - * DESCRIPTION: Handler for the PCI BarTarget address space (Op Region) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExPciBarSpaceHandler ( - UINT32 Function, - ACPI_PHYSICAL_ADDRESS Address, - UINT32 BitWidth, - UINT64 *Value, - void *HandlerContext, - void *RegionContext) -{ - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE (ExPciBarSpaceHandler); - - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExDataTableSpaceHandler - * - * PARAMETERS: Function - Read or Write operation - * Address - Where in the space to read or write - * BitWidth - Field width in bits (8, 16, or 32) - * Value - Pointer to in or out value - * HandlerContext - Pointer to Handler's context - * RegionContext - Pointer to context specific to the - * accessed region - * - * RETURN: Status - * - * DESCRIPTION: Handler for the Data Table address space (Op Region) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExDataTableSpaceHandler ( - UINT32 Function, - ACPI_PHYSICAL_ADDRESS Address, - UINT32 BitWidth, - UINT64 *Value, - void *HandlerContext, - void *RegionContext) -{ - ACPI_DATA_TABLE_MAPPING *Mapping; - char *Pointer; - - - ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler); - - - Mapping = (ACPI_DATA_TABLE_MAPPING *) RegionContext; - Pointer = ACPI_CAST_PTR (char, Mapping->Pointer) + - (Address - ACPI_PTR_TO_PHYSADDR (Mapping->Pointer)); - - /* - * Perform the memory read or write. The BitWidth was already - * validated. - */ - switch (Function) - { - case ACPI_READ: - - memcpy (ACPI_CAST_PTR (char, Value), Pointer, ACPI_DIV_8 (BitWidth)); - break; - - case ACPI_WRITE: - - memcpy (Pointer, ACPI_CAST_PTR (char, Value), ACPI_DIV_8 (BitWidth)); - break; - - default: - - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - return_ACPI_STATUS (AE_OK); -} diff --git a/Private/acpiSDK/source/components/executer/exresnte.c b/Private/acpiSDK/source/components/executer/exresnte.c deleted file mode 100644 index b5dc24c6..00000000 --- a/Private/acpiSDK/source/components/executer/exresnte.c +++ /dev/null @@ -1,400 +0,0 @@ -/****************************************************************************** - * - * Module Name: exresnte - AML Interpreter object resolution - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acdispat.h" -#include "acinterp.h" -#include "acnamesp.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exresnte") - - -/******************************************************************************* - * - * FUNCTION: AcpiExResolveNodeToValue - * - * PARAMETERS: ObjectPtr - Pointer to a location that contains - * a pointer to a NS node, and will receive a - * pointer to the resolved object. - * WalkState - Current state. Valid only if executing AML - * code. NULL if simply resolving an object - * - * RETURN: Status - * - * DESCRIPTION: Resolve a Namespace node to a valued object - * - * Note: for some of the data types, the pointer attached to the Node - * can be either a pointer to an actual internal object or a pointer into the - * AML stream itself. These types are currently: - * - * ACPI_TYPE_INTEGER - * ACPI_TYPE_STRING - * ACPI_TYPE_BUFFER - * ACPI_TYPE_MUTEX - * ACPI_TYPE_PACKAGE - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExResolveNodeToValue ( - ACPI_NAMESPACE_NODE **ObjectPtr, - ACPI_WALK_STATE *WalkState) - -{ - ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *SourceDesc; - ACPI_OPERAND_OBJECT *ObjDesc = NULL; - ACPI_NAMESPACE_NODE *Node; - ACPI_OBJECT_TYPE EntryType; - - - ACPI_FUNCTION_TRACE (ExResolveNodeToValue); - - - /* - * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the - * object that is attached to the Node. - */ - Node = *ObjectPtr; - SourceDesc = AcpiNsGetAttachedObject (Node); - EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n", - Node, SourceDesc, AcpiUtGetTypeName (EntryType))); - - if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) || - (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS)) - { - /* There is always exactly one level of indirection */ - - Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); - SourceDesc = AcpiNsGetAttachedObject (Node); - EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); - *ObjectPtr = Node; - } - - /* - * Several object types require no further processing: - * 1) Device/Thermal objects don't have a "real" subobject, return Node - * 2) Method locals and arguments have a pseudo-Node - * 3) 10/2007: Added method type to assist with Package construction. - */ - if ((EntryType == ACPI_TYPE_DEVICE) || - (EntryType == ACPI_TYPE_THERMAL) || - (EntryType == ACPI_TYPE_METHOD) || - (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) - { - return_ACPI_STATUS (AE_OK); - } - - if (!SourceDesc) - { - ACPI_ERROR ((AE_INFO, "No object attached to node [%4.4s] %p", - Node->Name.Ascii, Node)); - return_ACPI_STATUS (AE_AML_UNINITIALIZED_NODE); - } - - /* - * Action is based on the type of the Node, which indicates the type - * of the attached object or pointer - */ - switch (EntryType) - { - case ACPI_TYPE_PACKAGE: - - if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE) - { - ACPI_ERROR ((AE_INFO, "Object not a Package, type %s", - AcpiUtGetObjectTypeName (SourceDesc))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - Status = AcpiDsGetPackageArguments (SourceDesc); - if (ACPI_SUCCESS (Status)) - { - /* Return an additional reference to the object */ - - ObjDesc = SourceDesc; - AcpiUtAddReference (ObjDesc); - } - break; - - case ACPI_TYPE_BUFFER: - - if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) - { - ACPI_ERROR ((AE_INFO, "Object not a Buffer, type %s", - AcpiUtGetObjectTypeName (SourceDesc))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - Status = AcpiDsGetBufferArguments (SourceDesc); - if (ACPI_SUCCESS (Status)) - { - /* Return an additional reference to the object */ - - ObjDesc = SourceDesc; - AcpiUtAddReference (ObjDesc); - } - break; - - case ACPI_TYPE_STRING: - - if (SourceDesc->Common.Type != ACPI_TYPE_STRING) - { - ACPI_ERROR ((AE_INFO, "Object not a String, type %s", - AcpiUtGetObjectTypeName (SourceDesc))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - /* Return an additional reference to the object */ - - ObjDesc = SourceDesc; - AcpiUtAddReference (ObjDesc); - break; - - case ACPI_TYPE_INTEGER: - - if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER) - { - ACPI_ERROR ((AE_INFO, "Object not a Integer, type %s", - AcpiUtGetObjectTypeName (SourceDesc))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - /* Return an additional reference to the object */ - - ObjDesc = SourceDesc; - AcpiUtAddReference (ObjDesc); - break; - - case ACPI_TYPE_BUFFER_FIELD: - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "FieldRead Node=%p SourceDesc=%p Type=%X\n", - Node, SourceDesc, EntryType)); - - Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc); - break; - - /* For these objects, just return the object attached to the Node */ - - case ACPI_TYPE_MUTEX: - case ACPI_TYPE_POWER: - case ACPI_TYPE_PROCESSOR: - case ACPI_TYPE_EVENT: - case ACPI_TYPE_REGION: - - /* Return an additional reference to the object */ - - ObjDesc = SourceDesc; - AcpiUtAddReference (ObjDesc); - break; - - /* TYPE_ANY is untyped, and thus there is no object associated with it */ - - case ACPI_TYPE_ANY: - - ACPI_ERROR ((AE_INFO, - "Untyped entry %p, no attached object!", Node)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ - - case ACPI_TYPE_LOCAL_REFERENCE: - - switch (SourceDesc->Reference.Class) - { - case ACPI_REFCLASS_TABLE: /* This is a DdbHandle */ - case ACPI_REFCLASS_REFOF: - case ACPI_REFCLASS_INDEX: - - /* Return an additional reference to the object */ - - ObjDesc = SourceDesc; - AcpiUtAddReference (ObjDesc); - break; - - default: - - /* No named references are allowed here */ - - ACPI_ERROR ((AE_INFO, - "Unsupported Reference type 0x%X", - SourceDesc->Reference.Class)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - break; - - default: - - /* Default case is for unknown types */ - - ACPI_ERROR ((AE_INFO, - "Node %p - Unknown object type 0x%X", - Node, EntryType)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - - } /* switch (EntryType) */ - - - /* Return the object descriptor */ - - *ObjectPtr = (void *) ObjDesc; - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exresolv.c b/Private/acpiSDK/source/components/executer/exresolv.c deleted file mode 100644 index 460c6d77..00000000 --- a/Private/acpiSDK/source/components/executer/exresolv.c +++ /dev/null @@ -1,701 +0,0 @@ -/****************************************************************************** - * - * Module Name: exresolv - AML Interpreter object resolution - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "amlcode.h" -#include "acdispat.h" -#include "acinterp.h" -#include "acnamesp.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exresolv") - -/* Local prototypes */ - -static ACPI_STATUS -AcpiExResolveObjectToValue ( - ACPI_OPERAND_OBJECT **StackPtr, - ACPI_WALK_STATE *WalkState); - - -/******************************************************************************* - * - * FUNCTION: AcpiExResolveToValue - * - * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can - * be either an (ACPI_OPERAND_OBJECT *) - * or an ACPI_HANDLE. - * WalkState - Current method state - * - * RETURN: Status - * - * DESCRIPTION: Convert Reference objects to values - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExResolveToValue ( - ACPI_OPERAND_OBJECT **StackPtr, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr); - - - if (!StackPtr || !*StackPtr) - { - ACPI_ERROR ((AE_INFO, "Internal - null pointer")); - return_ACPI_STATUS (AE_AML_NO_OPERAND); - } - - /* - * The entity pointed to by the StackPtr can be either - * 1) A valid ACPI_OPERAND_OBJECT, or - * 2) A ACPI_NAMESPACE_NODE (NamedObj) - */ - if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND) - { - Status = AcpiExResolveObjectToValue (StackPtr, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - if (!*StackPtr) - { - ACPI_ERROR ((AE_INFO, "Internal - null pointer")); - return_ACPI_STATUS (AE_AML_NO_OPERAND); - } - } - - /* - * Object on the stack may have changed if AcpiExResolveObjectToValue() - * was called (i.e., we can't use an _else_ here.) - */ - if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED) - { - Status = AcpiExResolveNodeToValue ( - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), - WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr)); - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExResolveObjectToValue - * - * PARAMETERS: StackPtr - Pointer to an internal object - * WalkState - Current method state - * - * RETURN: Status - * - * DESCRIPTION: Retrieve the value from an internal object. The Reference type - * uses the associated AML opcode to determine the value. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiExResolveObjectToValue ( - ACPI_OPERAND_OBJECT **StackPtr, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *StackDesc; - ACPI_OPERAND_OBJECT *ObjDesc = NULL; - UINT8 RefType; - - - ACPI_FUNCTION_TRACE (ExResolveObjectToValue); - - - StackDesc = *StackPtr; - - /* This is an object of type ACPI_OPERAND_OBJECT */ - - switch (StackDesc->Common.Type) - { - case ACPI_TYPE_LOCAL_REFERENCE: - - RefType = StackDesc->Reference.Class; - - switch (RefType) - { - case ACPI_REFCLASS_LOCAL: - case ACPI_REFCLASS_ARG: - /* - * Get the local from the method's state info - * Note: this increments the local's object reference count - */ - Status = AcpiDsMethodDataGetValue (RefType, - StackDesc->Reference.Value, WalkState, &ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n", - StackDesc->Reference.Value, ObjDesc)); - - /* - * Now we can delete the original Reference Object and - * replace it with the resolved value - */ - AcpiUtRemoveReference (StackDesc); - *StackPtr = ObjDesc; - break; - - case ACPI_REFCLASS_INDEX: - - switch (StackDesc->Reference.TargetType) - { - case ACPI_TYPE_BUFFER_FIELD: - - /* Just return - do not dereference */ - break; - - case ACPI_TYPE_PACKAGE: - - /* If method call or CopyObject - do not dereference */ - - if ((WalkState->Opcode == AML_INT_METHODCALL_OP) || - (WalkState->Opcode == AML_COPY_OBJECT_OP)) - { - break; - } - - /* Otherwise, dereference the PackageIndex to a package element */ - - ObjDesc = *StackDesc->Reference.Where; - if (ObjDesc) - { - /* - * Valid object descriptor, copy pointer to return value - * (i.e., dereference the package index) - * Delete the ref object, increment the returned object - */ - AcpiUtAddReference (ObjDesc); - *StackPtr = ObjDesc; - } - else - { - /* - * A NULL object descriptor means an uninitialized element of - * the package, can't dereference it - */ - ACPI_ERROR ((AE_INFO, - "Attempt to dereference an Index to " - "NULL package element Idx=%p", - StackDesc)); - Status = AE_AML_UNINITIALIZED_ELEMENT; - } - break; - - default: - - /* Invalid reference object */ - - ACPI_ERROR ((AE_INFO, - "Unknown TargetType 0x%X in Index/Reference object %p", - StackDesc->Reference.TargetType, StackDesc)); - Status = AE_AML_INTERNAL; - break; - } - break; - - case ACPI_REFCLASS_REFOF: - case ACPI_REFCLASS_DEBUG: - case ACPI_REFCLASS_TABLE: - - /* Just leave the object as-is, do not dereference */ - - break; - - case ACPI_REFCLASS_NAME: /* Reference to a named object */ - - /* Dereference the name */ - - if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) || - (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL)) - { - /* These node types do not have 'real' subobjects */ - - *StackPtr = (void *) StackDesc->Reference.Node; - } - else - { - /* Get the object pointed to by the namespace node */ - - *StackPtr = (StackDesc->Reference.Node)->Object; - AcpiUtAddReference (*StackPtr); - } - - AcpiUtRemoveReference (StackDesc); - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Unknown Reference type 0x%X in %p", - RefType, StackDesc)); - Status = AE_AML_INTERNAL; - break; - } - break; - - case ACPI_TYPE_BUFFER: - - Status = AcpiDsGetBufferArguments (StackDesc); - break; - - case ACPI_TYPE_PACKAGE: - - Status = AcpiDsGetPackageArguments (StackDesc); - break; - - case ACPI_TYPE_BUFFER_FIELD: - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "FieldRead SourceDesc=%p Type=%X\n", - StackDesc, StackDesc->Common.Type)); - - Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc); - - /* Remove a reference to the original operand, then override */ - - AcpiUtRemoveReference (*StackPtr); - *StackPtr = (void *) ObjDesc; - break; - - default: - - break; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExResolveMultiple - * - * PARAMETERS: WalkState - Current state (contains AML opcode) - * Operand - Starting point for resolution - * ReturnType - Where the object type is returned - * ReturnDesc - Where the resolved object is returned - * - * RETURN: Status - * - * DESCRIPTION: Return the base object and type. Traverse a reference list if - * necessary to get to the base object. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExResolveMultiple ( - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT *Operand, - ACPI_OBJECT_TYPE *ReturnType, - ACPI_OPERAND_OBJECT **ReturnDesc) -{ - ACPI_OPERAND_OBJECT *ObjDesc = ACPI_CAST_PTR (void, Operand); - ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Operand); - ACPI_OBJECT_TYPE Type; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (AcpiExResolveMultiple); - - - /* Operand can be either a namespace node or an operand descriptor */ - - switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) - { - case ACPI_DESC_TYPE_OPERAND: - - Type = ObjDesc->Common.Type; - break; - - case ACPI_DESC_TYPE_NAMED: - - Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; - ObjDesc = AcpiNsGetAttachedObject (Node); - - /* If we had an Alias node, use the attached object for type info */ - - if (Type == ACPI_TYPE_LOCAL_ALIAS) - { - Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; - ObjDesc = AcpiNsGetAttachedObject ( - (ACPI_NAMESPACE_NODE *) ObjDesc); - } - - switch (Type) - { - case ACPI_TYPE_DEVICE: - case ACPI_TYPE_THERMAL: - - /* These types have no attached subobject */ - break; - - default: - - /* All other types require a subobject */ - - if (!ObjDesc) - { - ACPI_ERROR ((AE_INFO, - "[%4.4s] Node is unresolved or uninitialized", - AcpiUtGetNodeName (Node))); - return_ACPI_STATUS (AE_AML_UNINITIALIZED_NODE); - } - break; - } - break; - - default: - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - /* If type is anything other than a reference, we are done */ - - if (Type != ACPI_TYPE_LOCAL_REFERENCE) - { - goto Exit; - } - - /* - * For reference objects created via the RefOf, Index, or Load/LoadTable - * operators, we need to get to the base object (as per the ACPI - * specification of the ObjectType and SizeOf operators). This means - * traversing the list of possibly many nested references. - */ - while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) - { - switch (ObjDesc->Reference.Class) - { - case ACPI_REFCLASS_REFOF: - case ACPI_REFCLASS_NAME: - - /* Dereference the reference pointer */ - - if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF) - { - Node = ObjDesc->Reference.Object; - } - else /* AML_INT_NAMEPATH_OP */ - { - Node = ObjDesc->Reference.Node; - } - - /* All "References" point to a NS node */ - - if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) - { - ACPI_ERROR ((AE_INFO, - "Not a namespace node %p [%s]", - Node, AcpiUtGetDescriptorName (Node))); - return_ACPI_STATUS (AE_AML_INTERNAL); - } - - /* Get the attached object */ - - ObjDesc = AcpiNsGetAttachedObject (Node); - if (!ObjDesc) - { - /* No object, use the NS node type */ - - Type = AcpiNsGetType (Node); - goto Exit; - } - - /* Check for circular references */ - - if (ObjDesc == Operand) - { - return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); - } - break; - - case ACPI_REFCLASS_INDEX: - - /* Get the type of this reference (index into another object) */ - - Type = ObjDesc->Reference.TargetType; - if (Type != ACPI_TYPE_PACKAGE) - { - goto Exit; - } - - /* - * The main object is a package, we want to get the type - * of the individual package element that is referenced by - * the index. - * - * This could of course in turn be another reference object. - */ - ObjDesc = *(ObjDesc->Reference.Where); - if (!ObjDesc) - { - /* NULL package elements are allowed */ - - Type = 0; /* Uninitialized */ - goto Exit; - } - break; - - case ACPI_REFCLASS_TABLE: - - Type = ACPI_TYPE_DDB_HANDLE; - goto Exit; - - case ACPI_REFCLASS_LOCAL: - case ACPI_REFCLASS_ARG: - - if (ReturnDesc) - { - Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class, - ObjDesc->Reference.Value, WalkState, &ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - AcpiUtRemoveReference (ObjDesc); - } - else - { - Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class, - ObjDesc->Reference.Value, WalkState, &Node); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - ObjDesc = AcpiNsGetAttachedObject (Node); - if (!ObjDesc) - { - Type = ACPI_TYPE_ANY; - goto Exit; - } - } - break; - - case ACPI_REFCLASS_DEBUG: - - /* The Debug Object is of type "DebugObject" */ - - Type = ACPI_TYPE_DEBUG_OBJECT; - goto Exit; - - default: - - ACPI_ERROR ((AE_INFO, - "Unknown Reference Class 0x%2.2X", - ObjDesc->Reference.Class)); - return_ACPI_STATUS (AE_AML_INTERNAL); - } - } - - /* - * Now we are guaranteed to have an object that has not been created - * via the RefOf or Index operators. - */ - Type = ObjDesc->Common.Type; - - -Exit: - /* Convert internal types to external types */ - - switch (Type) - { - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: - - Type = ACPI_TYPE_FIELD_UNIT; - break; - - case ACPI_TYPE_LOCAL_SCOPE: - - /* Per ACPI Specification, Scope is untyped */ - - Type = ACPI_TYPE_ANY; - break; - - default: - - /* No change to Type required */ - - break; - } - - *ReturnType = Type; - if (ReturnDesc) - { - *ReturnDesc = ObjDesc; - } - return_ACPI_STATUS (AE_OK); -} diff --git a/Private/acpiSDK/source/components/executer/exresop.c b/Private/acpiSDK/source/components/executer/exresop.c deleted file mode 100644 index f4734d89..00000000 --- a/Private/acpiSDK/source/components/executer/exresop.c +++ /dev/null @@ -1,840 +0,0 @@ -/****************************************************************************** - * - * Module Name: exresop - AML Interpreter operand/object resolution - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "amlcode.h" -#include "acparser.h" -#include "acinterp.h" -#include "acnamesp.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exresop") - -/* Local prototypes */ - -static ACPI_STATUS -AcpiExCheckObjectType ( - ACPI_OBJECT_TYPE TypeNeeded, - ACPI_OBJECT_TYPE ThisType, - void *Object); - - -/******************************************************************************* - * - * FUNCTION: AcpiExCheckObjectType - * - * PARAMETERS: TypeNeeded Object type needed - * ThisType Actual object type - * Object Object pointer - * - * RETURN: Status - * - * DESCRIPTION: Check required type against actual type - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiExCheckObjectType ( - ACPI_OBJECT_TYPE TypeNeeded, - ACPI_OBJECT_TYPE ThisType, - void *Object) -{ - ACPI_FUNCTION_ENTRY (); - - - if (TypeNeeded == ACPI_TYPE_ANY) - { - /* All types OK, so we don't perform any typechecks */ - - return (AE_OK); - } - - if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE) - { - /* - * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference - * objects and thus allow them to be targets. (As per the ACPI - * specification, a store to a constant is a noop.) - */ - if ((ThisType == ACPI_TYPE_INTEGER) && - (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & - AOPOBJ_AML_CONSTANT)) - { - return (AE_OK); - } - } - - if (TypeNeeded != ThisType) - { - ACPI_ERROR ((AE_INFO, - "Needed type [%s], found [%s] %p", - AcpiUtGetTypeName (TypeNeeded), - AcpiUtGetTypeName (ThisType), Object)); - - return (AE_AML_OPERAND_TYPE); - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExResolveOperands - * - * PARAMETERS: Opcode - Opcode being interpreted - * StackPtr - Pointer to the operand stack to be - * resolved - * WalkState - Current state - * - * RETURN: Status - * - * DESCRIPTION: Convert multiple input operands to the types required by the - * target operator. - * - * Each 5-bit group in ArgTypes represents one required - * operand and indicates the required Type. The corresponding operand - * will be converted to the required type if possible, otherwise we - * abort with an exception. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExResolveOperands ( - UINT16 Opcode, - ACPI_OPERAND_OBJECT **StackPtr, - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status = AE_OK; - UINT8 ObjectType; - UINT32 ArgTypes; - const ACPI_OPCODE_INFO *OpInfo; - UINT32 ThisArgType; - ACPI_OBJECT_TYPE TypeNeeded; - UINT16 TargetOp = 0; - - - ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode); - - - OpInfo = AcpiPsGetOpcodeInfo (Opcode); - if (OpInfo->Class == AML_CLASS_UNKNOWN) - { - return_ACPI_STATUS (AE_AML_BAD_OPCODE); - } - - ArgTypes = OpInfo->RuntimeArgs; - if (ArgTypes == ARGI_INVALID_OPCODE) - { - ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", - Opcode)); - - return_ACPI_STATUS (AE_AML_INTERNAL); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Opcode %X [%s] RequiredOperandTypes=%8.8X\n", - Opcode, OpInfo->Name, ArgTypes)); - - /* - * Normal exit is with (ArgTypes == 0) at end of argument list. - * Function will return an exception from within the loop upon - * finding an entry which is not (or cannot be converted - * to) the required type; if stack underflows; or upon - * finding a NULL stack entry (which should not happen). - */ - while (GET_CURRENT_ARG_TYPE (ArgTypes)) - { - if (!StackPtr || !*StackPtr) - { - ACPI_ERROR ((AE_INFO, "Null stack entry at %p", - StackPtr)); - - return_ACPI_STATUS (AE_AML_INTERNAL); - } - - /* Extract useful items */ - - ObjDesc = *StackPtr; - - /* Decode the descriptor type */ - - switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) - { - case ACPI_DESC_TYPE_NAMED: - - /* Namespace Node */ - - ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; - - /* - * Resolve an alias object. The construction of these objects - * guarantees that there is only one level of alias indirection; - * thus, the attached object is always the aliased namespace node - */ - if (ObjectType == ACPI_TYPE_LOCAL_ALIAS) - { - ObjDesc = AcpiNsGetAttachedObject ( - (ACPI_NAMESPACE_NODE *) ObjDesc); - *StackPtr = ObjDesc; - ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; - } - break; - - case ACPI_DESC_TYPE_OPERAND: - - /* ACPI internal object */ - - ObjectType = ObjDesc->Common.Type; - - /* Check for bad ACPI_OBJECT_TYPE */ - - if (!AcpiUtValidObjectType (ObjectType)) - { - ACPI_ERROR ((AE_INFO, - "Bad operand object type [0x%X]", ObjectType)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE) - { - /* Validate the Reference */ - - switch (ObjDesc->Reference.Class) - { - case ACPI_REFCLASS_DEBUG: - - TargetOp = AML_DEBUG_OP; - - ACPI_FALLTHROUGH; - - case ACPI_REFCLASS_ARG: - case ACPI_REFCLASS_LOCAL: - case ACPI_REFCLASS_INDEX: - case ACPI_REFCLASS_REFOF: - case ACPI_REFCLASS_TABLE: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ - case ACPI_REFCLASS_NAME: /* Reference to a named object */ - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Operand is a Reference, Class [%s] %2.2X\n", - AcpiUtGetReferenceName (ObjDesc), - ObjDesc->Reference.Class)); - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Unknown Reference Class 0x%2.2X in %p", - ObjDesc->Reference.Class, ObjDesc)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - } - break; - - default: - - /* Invalid descriptor */ - - ACPI_ERROR ((AE_INFO, "Invalid descriptor %p [%s]", - ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - /* Get one argument type, point to the next */ - - ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes); - INCREMENT_ARG_LIST (ArgTypes); - - /* - * Handle cases where the object does not need to be - * resolved to a value - */ - switch (ThisArgType) - { - case ARGI_REF_OR_STRING: /* Can be a String or Reference */ - - if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == - ACPI_DESC_TYPE_OPERAND) && - (ObjDesc->Common.Type == ACPI_TYPE_STRING)) - { - /* - * String found - the string references a named object and - * must be resolved to a node - */ - goto NextOperand; - } - - /* - * Else not a string - fall through to the normal Reference - * case below - */ - ACPI_FALLTHROUGH; - - case ARGI_REFERENCE: /* References: */ - case ARGI_INTEGER_REF: - case ARGI_OBJECT_REF: - case ARGI_DEVICE_REF: - case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ - case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ - case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ - case ARGI_STORE_TARGET: - - /* - * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE - * A Namespace Node is OK as-is - */ - if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) - { - goto NextOperand; - } - - Status = AcpiExCheckObjectType ( - ACPI_TYPE_LOCAL_REFERENCE, ObjectType, ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - goto NextOperand; - - case ARGI_DATAREFOBJ: /* Store operator only */ - /* - * We don't want to resolve IndexOp reference objects during - * a store because this would be an implicit DeRefOf operation. - * Instead, we just want to store the reference object. - * -- All others must be resolved below. - */ - if ((Opcode == AML_STORE_OP) && - ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && - ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX)) - { - goto NextOperand; - } - break; - - default: - - /* All cases covered above */ - - break; - } - - /* - * Resolve this object to a value - */ - Status = AcpiExResolveToValue (StackPtr, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Get the resolved object */ - - ObjDesc = *StackPtr; - - /* - * Check the resulting object (value) type - */ - switch (ThisArgType) - { - /* - * For the simple cases, only one type of resolved object - * is allowed - */ - case ARGI_MUTEX: - - /* Need an operand of type ACPI_TYPE_MUTEX */ - - TypeNeeded = ACPI_TYPE_MUTEX; - break; - - case ARGI_EVENT: - - /* Need an operand of type ACPI_TYPE_EVENT */ - - TypeNeeded = ACPI_TYPE_EVENT; - break; - - case ARGI_PACKAGE: /* Package */ - - /* Need an operand of type ACPI_TYPE_PACKAGE */ - - TypeNeeded = ACPI_TYPE_PACKAGE; - break; - - case ARGI_ANYTYPE: - - /* Any operand type will do */ - - TypeNeeded = ACPI_TYPE_ANY; - break; - - case ARGI_DDBHANDLE: - - /* Need an operand of type ACPI_TYPE_DDB_HANDLE */ - - TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE; - break; - - - /* - * The more complex cases allow multiple resolved object types - */ - case ARGI_INTEGER: - - /* - * Need an operand of type ACPI_TYPE_INTEGER, but we can - * implicitly convert from a STRING or BUFFER. - * - * Known as "Implicit Source Operand Conversion" - */ - Status = AcpiExConvertToInteger (ObjDesc, StackPtr, - ACPI_IMPLICIT_CONVERSION); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_TYPE) - { - ACPI_ERROR ((AE_INFO, - "Needed [Integer/String/Buffer], found [%s] %p", - AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - return_ACPI_STATUS (Status); - } - - if (ObjDesc != *StackPtr) - { - AcpiUtRemoveReference (ObjDesc); - } - goto NextOperand; - - case ARGI_BUFFER: - /* - * Need an operand of type ACPI_TYPE_BUFFER, - * But we can implicitly convert from a STRING or INTEGER - * Aka - "Implicit Source Operand Conversion" - */ - Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_TYPE) - { - ACPI_ERROR ((AE_INFO, - "Needed [Integer/String/Buffer], found [%s] %p", - AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - return_ACPI_STATUS (Status); - } - - if (ObjDesc != *StackPtr) - { - AcpiUtRemoveReference (ObjDesc); - } - goto NextOperand; - - case ARGI_STRING: - /* - * Need an operand of type ACPI_TYPE_STRING, - * But we can implicitly convert from a BUFFER or INTEGER - * Aka - "Implicit Source Operand Conversion" - */ - Status = AcpiExConvertToString ( - ObjDesc, StackPtr, ACPI_IMPLICIT_CONVERT_HEX); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_TYPE) - { - ACPI_ERROR ((AE_INFO, - "Needed [Integer/String/Buffer], found [%s] %p", - AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - return_ACPI_STATUS (Status); - } - - if (ObjDesc != *StackPtr) - { - AcpiUtRemoveReference (ObjDesc); - } - goto NextOperand; - - case ARGI_COMPUTEDATA: - - /* Need an operand of type INTEGER, STRING or BUFFER */ - - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - - /* Valid operand */ - break; - - default: - ACPI_ERROR ((AE_INFO, - "Needed [Integer/String/Buffer], found [%s] %p", - AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - goto NextOperand; - - case ARGI_BUFFER_OR_STRING: - - /* Need an operand of type STRING or BUFFER */ - - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - - /* Valid operand */ - break; - - case ACPI_TYPE_INTEGER: - - /* Highest priority conversion is to type Buffer */ - - Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - if (ObjDesc != *StackPtr) - { - AcpiUtRemoveReference (ObjDesc); - } - break; - - default: - ACPI_ERROR ((AE_INFO, - "Needed [Integer/String/Buffer], found [%s] %p", - AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - goto NextOperand; - - case ARGI_DATAOBJECT: - /* - * ARGI_DATAOBJECT is only used by the SizeOf operator. - * Need a buffer, string, package, or RefOf reference. - * - * The only reference allowed here is a direct reference to - * a namespace node. - */ - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_PACKAGE: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - case ACPI_TYPE_LOCAL_REFERENCE: - - /* Valid operand */ - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Needed [Buffer/String/Package/Reference], found [%s] %p", - AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - goto NextOperand; - - case ARGI_COMPLEXOBJ: - - /* Need a buffer or package or (ACPI 2.0) String */ - - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_PACKAGE: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - - /* Valid operand */ - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Needed [Buffer/String/Package], found [%s] %p", - AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - goto NextOperand; - - case ARGI_REGION_OR_BUFFER: /* Used by Load() only */ - - /* - * Need an operand of type REGION or a BUFFER - * (which could be a resolved region field) - */ - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_BUFFER: - case ACPI_TYPE_REGION: - - /* Valid operand */ - break; - - default: - - ACPI_ERROR ((AE_INFO, - "Needed [Region/Buffer], found [%s] %p", - AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - goto NextOperand; - - case ARGI_DATAREFOBJ: - - /* Used by the Store() operator only */ - - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_PACKAGE: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - case ACPI_TYPE_BUFFER_FIELD: - case ACPI_TYPE_LOCAL_REFERENCE: - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: - case ACPI_TYPE_DDB_HANDLE: - - /* Valid operand */ - break; - - default: - - if (AcpiGbl_EnableInterpreterSlack) - { - /* - * Enable original behavior of Store(), allowing any - * and all objects as the source operand. The ACPI - * spec does not allow this, however. - */ - break; - } - - if (TargetOp == AML_DEBUG_OP) - { - /* Allow store of any object to the Debug object */ - - break; - } - - ACPI_ERROR ((AE_INFO, - "Needed Integer/Buffer/String/Package/Ref/Ddb]" - ", found [%s] %p", - AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - goto NextOperand; - - default: - - /* Unknown type */ - - ACPI_ERROR ((AE_INFO, - "Internal - Unknown ARGI (required operand) type 0x%X", - ThisArgType)); - - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* - * Make sure that the original object was resolved to the - * required object type (Simple cases only). - */ - Status = AcpiExCheckObjectType ( - TypeNeeded, (*StackPtr)->Common.Type, *StackPtr); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - -NextOperand: - /* - * If more operands needed, decrement StackPtr to point - * to next operand on stack - */ - if (GET_CURRENT_ARG_TYPE (ArgTypes)) - { - StackPtr--; - } - } - - ACPI_DUMP_OPERANDS (WalkState->Operands, - AcpiPsGetOpcodeName (Opcode), WalkState->NumOperands); - - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exserial.c b/Private/acpiSDK/source/components/executer/exserial.c deleted file mode 100644 index f51047f9..00000000 --- a/Private/acpiSDK/source/components/executer/exserial.c +++ /dev/null @@ -1,525 +0,0 @@ -/****************************************************************************** - * - * Module Name: exserial - FieldUnit support for serial address spaces - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acdispat.h" -#include "acinterp.h" -#include "amlcode.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exserial") - - -/******************************************************************************* - * - * FUNCTION: AcpiExReadGpio - * - * PARAMETERS: ObjDesc - The named field to read - * Buffer - Where the return data is returned - * - * RETURN: Status - * - * DESCRIPTION: Read from a named field that references a Generic Serial Bus - * field - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExReadGpio ( - ACPI_OPERAND_OBJECT *ObjDesc, - void *Buffer) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_PTR (ExReadGpio, ObjDesc); - - - /* - * For GPIO (GeneralPurposeIo), the Address will be the bit offset - * from the previous Connection() operator, making it effectively a - * pin number index. The BitLength is the length of the field, which - * is thus the number of pins. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "GPIO FieldRead [FROM]: Pin %u Bits %u\n", - ObjDesc->Field.PinNumberIndex, ObjDesc->Field.BitLength)); - - /* Lock entire transaction if requested */ - - AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); - - /* Perform the read */ - - Status = AcpiExAccessRegion ( - ObjDesc, 0, (UINT64 *) Buffer, ACPI_READ); - - AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExWriteGpio - * - * PARAMETERS: SourceDesc - Contains data to write. Expect to be - * an Integer object. - * ObjDesc - The named field - * ResultDesc - Where the return value is returned, if any - * - * RETURN: Status - * - * DESCRIPTION: Write to a named field that references a General Purpose I/O - * field. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExWriteGpio ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ReturnBuffer) -{ - ACPI_STATUS Status; - void *Buffer; - - - ACPI_FUNCTION_TRACE_PTR (ExWriteGpio, ObjDesc); - - - /* - * For GPIO (GeneralPurposeIo), we will bypass the entire field - * mechanism and handoff the bit address and bit width directly to - * the handler. The Address will be the bit offset - * from the previous Connection() operator, making it effectively a - * pin number index. The BitLength is the length of the field, which - * is thus the number of pins. - */ - if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER) - { - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "GPIO FieldWrite [FROM]: (%s:%X), Value %.8X [TO]: Pin %u Bits %u\n", - AcpiUtGetTypeName (SourceDesc->Common.Type), - SourceDesc->Common.Type, (UINT32) SourceDesc->Integer.Value, - ObjDesc->Field.PinNumberIndex, ObjDesc->Field.BitLength)); - - Buffer = &SourceDesc->Integer.Value; - - /* Lock entire transaction if requested */ - - AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); - - /* Perform the write */ - - Status = AcpiExAccessRegion ( - ObjDesc, 0, (UINT64 *) Buffer, ACPI_WRITE); - AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExReadSerialBus - * - * PARAMETERS: ObjDesc - The named field to read - * ReturnBuffer - Where the return value is returned, if any - * - * RETURN: Status - * - * DESCRIPTION: Read from a named field that references a serial bus - * (SMBus, IPMI, or GSBus). - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExReadSerialBus ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ReturnBuffer) -{ - ACPI_STATUS Status; - UINT32 BufferLength; - ACPI_OPERAND_OBJECT *BufferDesc; - UINT32 Function; - UINT16 AccessorType; - - - ACPI_FUNCTION_TRACE_PTR (ExReadSerialBus, ObjDesc); - - - /* - * This is an SMBus, GSBus or IPMI read. We must create a buffer to - * hold the data and then directly access the region handler. - * - * Note: SMBus and GSBus protocol value is passed in upper 16-bits - * of Function - * - * Common buffer format: - * Status; (Byte 0 of the data buffer) - * Length; (Byte 1 of the data buffer) - * Data[x-1]: (Bytes 2-x of the arbitrary length data buffer) - */ - switch (ObjDesc->Field.RegionObj->Region.SpaceId) - { - case ACPI_ADR_SPACE_SMBUS: - - BufferLength = ACPI_SMBUS_BUFFER_SIZE; - Function = ACPI_READ | (ObjDesc->Field.Attribute << 16); - break; - - case ACPI_ADR_SPACE_IPMI: - - BufferLength = ACPI_IPMI_BUFFER_SIZE; - Function = ACPI_READ; - break; - - case ACPI_ADR_SPACE_GSBUS: - - AccessorType = ObjDesc->Field.Attribute; - if (AccessorType == AML_FIELD_ATTRIB_RAW_PROCESS_BYTES) - { - ACPI_ERROR ((AE_INFO, - "Invalid direct read using bidirectional write-then-read protocol")); - - return_ACPI_STATUS (AE_AML_PROTOCOL); - } - - Status = AcpiExGetProtocolBufferLength (AccessorType, &BufferLength); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, - "Invalid protocol ID for GSBus: 0x%4.4X", AccessorType)); - - return_ACPI_STATUS (Status); - } - - /* Add header length to get the full size of the buffer */ - - BufferLength += ACPI_SERIAL_HEADER_SIZE; - Function = ACPI_READ | (AccessorType << 16); - break; - - case ACPI_ADR_SPACE_PLATFORM_RT: - - BufferLength = ACPI_PRM_INPUT_BUFFER_SIZE; - Function = ACPI_READ; - break; - - default: - return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); - } - - /* Create the local transfer buffer that is returned to the caller */ - - BufferDesc = AcpiUtCreateBufferObject (BufferLength); - if (!BufferDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Lock entire transaction if requested */ - - AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); - - /* Call the region handler for the write-then-read */ - - Status = AcpiExAccessRegion (ObjDesc, 0, - ACPI_CAST_PTR (UINT64, BufferDesc->Buffer.Pointer), Function); - AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); - - *ReturnBuffer = BufferDesc; - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExWriteSerialBus - * - * PARAMETERS: SourceDesc - Contains data to write - * ObjDesc - The named field - * ReturnBuffer - Where the return value is returned, if any - * - * RETURN: Status - * - * DESCRIPTION: Write to a named field that references a serial bus - * (SMBus, IPMI, GSBus). - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExWriteSerialBus ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ReturnBuffer) -{ - ACPI_STATUS Status; - UINT32 BufferLength; - UINT32 DataLength; - void *Buffer; - ACPI_OPERAND_OBJECT *BufferDesc; - UINT32 Function; - UINT16 AccessorType; - - - ACPI_FUNCTION_TRACE_PTR (ExWriteSerialBus, ObjDesc); - - - /* - * This is an SMBus, GSBus or IPMI write. We will bypass the entire - * field mechanism and handoff the buffer directly to the handler. - * For these address spaces, the buffer is bidirectional; on a - * write, return data is returned in the same buffer. - * - * Source must be a buffer of sufficient size, these are fixed size: - * ACPI_SMBUS_BUFFER_SIZE, or ACPI_IPMI_BUFFER_SIZE. - * - * Note: SMBus and GSBus protocol type is passed in upper 16-bits - * of Function - * - * Common buffer format: - * Status; (Byte 0 of the data buffer) - * Length; (Byte 1 of the data buffer) - * Data[x-1]: (Bytes 2-x of the arbitrary length data buffer) - */ - if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) - { - ACPI_ERROR ((AE_INFO, - "SMBus/IPMI/GenericSerialBus write requires " - "Buffer, found type %s", - AcpiUtGetObjectTypeName (SourceDesc))); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - switch (ObjDesc->Field.RegionObj->Region.SpaceId) - { - case ACPI_ADR_SPACE_SMBUS: - - BufferLength = ACPI_SMBUS_BUFFER_SIZE; - Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16); - break; - - case ACPI_ADR_SPACE_IPMI: - - BufferLength = ACPI_IPMI_BUFFER_SIZE; - Function = ACPI_WRITE; - break; - - case ACPI_ADR_SPACE_GSBUS: - - AccessorType = ObjDesc->Field.Attribute; - Status = AcpiExGetProtocolBufferLength (AccessorType, &BufferLength); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, - "Invalid protocol ID for GSBus: 0x%4.4X", AccessorType)); - - return_ACPI_STATUS (Status); - } - - /* Add header length to get the full size of the buffer */ - - BufferLength += ACPI_SERIAL_HEADER_SIZE; - Function = ACPI_WRITE | (AccessorType << 16); - break; - - case ACPI_ADR_SPACE_PLATFORM_RT: - - BufferLength = ACPI_PRM_INPUT_BUFFER_SIZE; - Function = ACPI_WRITE; - break; - - case ACPI_ADR_SPACE_FIXED_HARDWARE: - - BufferLength = ACPI_FFH_INPUT_BUFFER_SIZE; - Function = ACPI_WRITE; - break; - - default: - return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); - } - - /* Create the transfer/bidirectional/return buffer */ - - BufferDesc = AcpiUtCreateBufferObject (BufferLength); - if (!BufferDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Copy the input buffer data to the transfer buffer */ - - Buffer = BufferDesc->Buffer.Pointer; - DataLength = ACPI_MIN (BufferLength, SourceDesc->Buffer.Length); - memcpy (Buffer, SourceDesc->Buffer.Pointer, DataLength); - - /* Lock entire transaction if requested */ - - AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); - - /* - * Perform the write (returns status and perhaps data in the - * same buffer) - */ - Status = AcpiExAccessRegion ( - ObjDesc, 0, (UINT64 *) Buffer, Function); - AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); - - *ReturnBuffer = BufferDesc; - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exstore.c b/Private/acpiSDK/source/components/executer/exstore.c deleted file mode 100644 index 95bb19af..00000000 --- a/Private/acpiSDK/source/components/executer/exstore.c +++ /dev/null @@ -1,752 +0,0 @@ -/****************************************************************************** - * - * Module Name: exstore - AML Interpreter object store support - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acdispat.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acnamesp.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exstore") - -/* Local prototypes */ - -static ACPI_STATUS -AcpiExStoreObjectToIndex ( - ACPI_OPERAND_OBJECT *ValDesc, - ACPI_OPERAND_OBJECT *DestDesc, - ACPI_WALK_STATE *WalkState); - -static ACPI_STATUS -AcpiExStoreDirectToNode ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_NAMESPACE_NODE *Node, - ACPI_WALK_STATE *WalkState); - - -/******************************************************************************* - * - * FUNCTION: AcpiExStore - * - * PARAMETERS: *SourceDesc - Value to be stored - * *DestDesc - Where to store it. Must be an NS node - * or ACPI_OPERAND_OBJECT of type - * Reference; - * WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Store the value described by SourceDesc into the location - * described by DestDesc. Called by various interpreter - * functions to store the result of an operation into - * the destination operand -- not just simply the actual "Store" - * ASL operator. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExStore ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *DestDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *RefDesc = DestDesc; - - - ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc); - - - /* Validate parameters */ - - if (!SourceDesc || !DestDesc) - { - ACPI_ERROR ((AE_INFO, "Null parameter")); - return_ACPI_STATUS (AE_AML_NO_OPERAND); - } - - /* DestDesc can be either a namespace node or an ACPI object */ - - if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED) - { - /* - * Dest is a namespace node, - * Storing an object into a Named node. - */ - Status = AcpiExStoreObjectToNode (SourceDesc, - (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, - ACPI_IMPLICIT_CONVERSION); - - return_ACPI_STATUS (Status); - } - - /* Destination object must be a Reference or a Constant object */ - - switch (DestDesc->Common.Type) - { - case ACPI_TYPE_LOCAL_REFERENCE: - - break; - - case ACPI_TYPE_INTEGER: - - /* Allow stores to Constants -- a Noop as per ACPI spec */ - - if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT) - { - return_ACPI_STATUS (AE_OK); - } - - ACPI_FALLTHROUGH; - - default: - - /* Destination is not a Reference object */ - - ACPI_ERROR ((AE_INFO, - "Target is not a Reference or Constant object - [%s] %p", - AcpiUtGetObjectTypeName (DestDesc), DestDesc)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - /* - * Examine the Reference class. These cases are handled: - * - * 1) Store to Name (Change the object associated with a name) - * 2) Store to an indexed area of a Buffer or Package - * 3) Store to a Method Local or Arg - * 4) Store to the debug object - */ - switch (RefDesc->Reference.Class) - { - case ACPI_REFCLASS_REFOF: - - /* Storing an object into a Name "container" */ - - Status = AcpiExStoreObjectToNode (SourceDesc, - RefDesc->Reference.Object, - WalkState, ACPI_IMPLICIT_CONVERSION); - break; - - case ACPI_REFCLASS_INDEX: - - /* Storing to an Index (pointer into a packager or buffer) */ - - Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState); - break; - - case ACPI_REFCLASS_LOCAL: - case ACPI_REFCLASS_ARG: - - /* Store to a method local/arg */ - - Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class, - RefDesc->Reference.Value, SourceDesc, WalkState); - break; - - case ACPI_REFCLASS_DEBUG: - /* - * Storing to the Debug object causes the value stored to be - * displayed and otherwise has no effect -- see ACPI Specification - */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "**** Write to Debug Object: Object %p [%s] ****:\n\n", - SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); - - ACPI_DEBUG_OBJECT (SourceDesc, 0, 0); - break; - - default: - - ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X", - RefDesc->Reference.Class)); - ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO); - - Status = AE_AML_INTERNAL; - break; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExStoreObjectToIndex - * - * PARAMETERS: *SourceDesc - Value to be stored - * *DestDesc - Named object to receive the value - * WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Store the object to indexed Buffer or Package element - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiExStoreObjectToIndex ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *IndexDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *NewDesc; - UINT8 Value = 0; - UINT32 i; - - - ACPI_FUNCTION_TRACE (ExStoreObjectToIndex); - - - /* - * Destination must be a reference pointer, and - * must point to either a buffer or a package - */ - switch (IndexDesc->Reference.TargetType) - { - case ACPI_TYPE_PACKAGE: - /* - * Storing to a package element. Copy the object and replace - * any existing object with the new object. No implicit - * conversion is performed. - * - * The object at *(IndexDesc->Reference.Where) is the - * element within the package that is to be modified. - * The parent package object is at IndexDesc->Reference.Object - */ - ObjDesc = *(IndexDesc->Reference.Where); - - if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE && - SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) - { - /* This is a DDBHandle, just add a reference to it */ - - AcpiUtAddReference (SourceDesc); - NewDesc = SourceDesc; - } - else - { - /* Normal object, copy it */ - - Status = AcpiUtCopyIobjectToIobject ( - SourceDesc, &NewDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - if (ObjDesc) - { - /* Decrement reference count by the ref count of the parent package */ - - for (i = 0; - i < ((ACPI_OPERAND_OBJECT *) - IndexDesc->Reference.Object)->Common.ReferenceCount; - i++) - { - AcpiUtRemoveReference (ObjDesc); - } - } - - *(IndexDesc->Reference.Where) = NewDesc; - - /* Increment ref count by the ref count of the parent package-1 */ - - for (i = 1; - i < ((ACPI_OPERAND_OBJECT *) - IndexDesc->Reference.Object)->Common.ReferenceCount; - i++) - { - AcpiUtAddReference (NewDesc); - } - - break; - - case ACPI_TYPE_BUFFER_FIELD: - /* - * Store into a Buffer or String (not actually a real BufferField) - * at a location defined by an Index. - * - * The first 8-bit element of the source object is written to the - * 8-bit Buffer location defined by the Index destination object, - * according to the ACPI 2.0 specification. - */ - - /* - * Make sure the target is a Buffer or String. An error should - * not happen here, since the ReferenceObject was constructed - * by the INDEX_OP code. - */ - ObjDesc = IndexDesc->Reference.Object; - if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) && - (ObjDesc->Common.Type != ACPI_TYPE_STRING)) - { - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - /* - * The assignment of the individual elements will be slightly - * different for each source type. - */ - switch (SourceDesc->Common.Type) - { - case ACPI_TYPE_INTEGER: - - /* Use the least-significant byte of the integer */ - - Value = (UINT8) (SourceDesc->Integer.Value); - break; - - case ACPI_TYPE_BUFFER: - case ACPI_TYPE_STRING: - - /* Note: Takes advantage of common string/buffer fields */ - - Value = SourceDesc->Buffer.Pointer[0]; - break; - - default: - - /* All other types are invalid */ - - ACPI_ERROR ((AE_INFO, - "Source must be type [Integer/Buffer/String], found [%s]", - AcpiUtGetObjectTypeName (SourceDesc))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - /* Store the source value into the target buffer byte */ - - ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value; - break; - - default: - ACPI_ERROR ((AE_INFO, - "Target is not of type [Package/BufferField]")); - Status = AE_AML_TARGET_TYPE; - break; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExStoreObjectToNode - * - * PARAMETERS: SourceDesc - Value to be stored - * Node - Named object to receive the value - * WalkState - Current walk state - * ImplicitConversion - Perform implicit conversion (yes/no) - * - * RETURN: Status - * - * DESCRIPTION: Store the object to the named object. - * - * The assignment of an object to a named object is handled here. - * The value passed in will replace the current value (if any) - * with the input value. - * - * When storing into an object the data is converted to the - * target object type then stored in the object. This means - * that the target object type (for an initialized target) will - * not be changed by a store operation. A CopyObject can change - * the target type, however. - * - * The ImplicitConversion flag is set to NO/FALSE only when - * storing to an ArgX -- as per the rules of the ACPI spec. - * - * Assumes parameters are already validated. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExStoreObjectToNode ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_NAMESPACE_NODE *Node, - ACPI_WALK_STATE *WalkState, - UINT8 ImplicitConversion) -{ - ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *TargetDesc; - ACPI_OPERAND_OBJECT *NewDesc; - ACPI_OBJECT_TYPE TargetType; - - - ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc); - - - /* Get current type of the node, and object attached to Node */ - - TargetType = AcpiNsGetType (Node); - TargetDesc = AcpiNsGetAttachedObject (Node); - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p [%s] to node %p [%s]\n", - SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), - Node, AcpiUtGetTypeName (TargetType))); - - /* Only limited target types possible for everything except CopyObject */ - - if (WalkState->Opcode != AML_COPY_OBJECT_OP) - { - /* - * Only CopyObject allows all object types to be overwritten. For - * TargetRef(s), there are restrictions on the object types that - * are allowed. - * - * Allowable operations/typing for Store: - * - * 1) Simple Store - * Integer --> Integer (Named/Local/Arg) - * String --> String (Named/Local/Arg) - * Buffer --> Buffer (Named/Local/Arg) - * Package --> Package (Named/Local/Arg) - * - * 2) Store with implicit conversion - * Integer --> String or Buffer (Named) - * String --> Integer or Buffer (Named) - * Buffer --> Integer or String (Named) - */ - switch (TargetType) - { - case ACPI_TYPE_PACKAGE: - /* - * Here, can only store a package to an existing package. - * Storing a package to a Local/Arg is OK, and handled - * elsewhere. - */ - if (WalkState->Opcode == AML_STORE_OP) - { - if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE) - { - ACPI_ERROR ((AE_INFO, - "Cannot assign type [%s] to [Package] " - "(source must be type Pkg)", - AcpiUtGetObjectTypeName (SourceDesc))); - - return_ACPI_STATUS (AE_AML_TARGET_TYPE); - } - break; - } - - ACPI_FALLTHROUGH; - - case ACPI_TYPE_DEVICE: - case ACPI_TYPE_EVENT: - case ACPI_TYPE_MUTEX: - case ACPI_TYPE_REGION: - case ACPI_TYPE_POWER: - case ACPI_TYPE_PROCESSOR: - case ACPI_TYPE_THERMAL: - - ACPI_ERROR ((AE_INFO, - "Target must be [Buffer/Integer/String/Reference]" - ", found [%s] (%4.4s)", - AcpiUtGetTypeName (Node->Type), Node->Name.Ascii)); - - return_ACPI_STATUS (AE_AML_TARGET_TYPE); - - default: - break; - } - } - - /* - * Resolve the source object to an actual value - * (If it is a reference object) - */ - Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Do the actual store operation */ - - switch (TargetType) - { - /* - * The simple data types all support implicit source operand - * conversion before the store. - */ - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - - if ((WalkState->Opcode == AML_COPY_OBJECT_OP) || - !ImplicitConversion) - { - /* - * However, CopyObject and Stores to ArgX do not perform - * an implicit conversion, as per the ACPI specification. - * A direct store is performed instead. - */ - Status = AcpiExStoreDirectToNode (SourceDesc, Node, WalkState); - break; - } - - /* Store with implicit source operand conversion support */ - - Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, - &NewDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - if (NewDesc != TargetDesc) - { - /* - * Store the new NewDesc as the new value of the Name, and set - * the Name's type to that of the value being stored in it. - * SourceDesc reference count is incremented by AttachObject. - * - * Note: This may change the type of the node if an explicit - * store has been performed such that the node/object type - * has been changed. - */ - Status = AcpiNsAttachObject ( - Node, NewDesc, NewDesc->Common.Type); - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Store type [%s] into [%s] via Convert/Attach\n", - AcpiUtGetObjectTypeName (SourceDesc), - AcpiUtGetObjectTypeName (NewDesc))); - } - break; - - case ACPI_TYPE_BUFFER_FIELD: - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: - /* - * For all fields, always write the source data to the target - * field. Any required implicit source operand conversion is - * performed in the function below as necessary. Note, field - * objects must retain their original type permanently. - */ - Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, - &WalkState->ResultObj); - break; - - default: - /* - * CopyObject operator: No conversions for all other types. - * Instead, directly store a copy of the source object. - * - * This is the ACPI spec-defined behavior for the CopyObject - * operator. (Note, for this default case, all normal - * Store/Target operations exited above with an error). - */ - Status = AcpiExStoreDirectToNode (SourceDesc, Node, WalkState); - break; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExStoreDirectToNode - * - * PARAMETERS: SourceDesc - Value to be stored - * Node - Named object to receive the value - * WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: "Store" an object directly to a node. This involves a copy - * and an attach. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiExStoreDirectToNode ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_NAMESPACE_NODE *Node, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *NewDesc; - - - ACPI_FUNCTION_TRACE (ExStoreDirectToNode); - - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Storing [%s] (%p) directly into node [%s] (%p)" - " with no implicit conversion\n", - AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, - AcpiUtGetTypeName (Node->Type), Node)); - - /* Copy the source object to a new object */ - - Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Attach the new object to the node */ - - Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); - AcpiUtRemoveReference (NewDesc); - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exstoren.c b/Private/acpiSDK/source/components/executer/exstoren.c deleted file mode 100644 index 628592f2..00000000 --- a/Private/acpiSDK/source/components/executer/exstoren.c +++ /dev/null @@ -1,412 +0,0 @@ -/****************************************************************************** - * - * Module Name: exstoren - AML Interpreter object store support, - * Store to Node (namespace object) - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "amlcode.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exstoren") - - -/******************************************************************************* - * - * FUNCTION: AcpiExResolveObject - * - * PARAMETERS: SourceDescPtr - Pointer to the source object - * TargetType - Current type of the target - * WalkState - Current walk state - * - * RETURN: Status, resolved object in SourceDescPtr. - * - * DESCRIPTION: Resolve an object. If the object is a reference, dereference - * it and return the actual object in the SourceDescPtr. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExResolveObject ( - ACPI_OPERAND_OBJECT **SourceDescPtr, - ACPI_OBJECT_TYPE TargetType, - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr; - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE (ExResolveObject); - - - /* Ensure we have a Target that can be stored to */ - - switch (TargetType) - { - case ACPI_TYPE_BUFFER_FIELD: - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: - /* - * These cases all require only Integers or values that - * can be converted to Integers (Strings or Buffers) - */ - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - /* - * Stores into a Field/Region or into a Integer/Buffer/String - * are all essentially the same. This case handles the - * "interchangeable" types Integer, String, and Buffer. - */ - if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) - { - /* Resolve a reference object first */ - - Status = AcpiExResolveToValue (SourceDescPtr, WalkState); - if (ACPI_FAILURE (Status)) - { - break; - } - } - - /* For CopyObject, no further validation necessary */ - - if (WalkState->Opcode == AML_COPY_OBJECT_OP) - { - break; - } - - /* Must have a Integer, Buffer, or String */ - - if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) && - (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) && - (SourceDesc->Common.Type != ACPI_TYPE_STRING) && - !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && - (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE))) - { - /* Conversion successful but still not a valid type */ - - ACPI_ERROR ((AE_INFO, - "Cannot assign type [%s] to [%s] (must be type Int/Str/Buf)", - AcpiUtGetObjectTypeName (SourceDesc), - AcpiUtGetTypeName (TargetType))); - - Status = AE_AML_OPERAND_TYPE; - } - break; - - case ACPI_TYPE_LOCAL_ALIAS: - case ACPI_TYPE_LOCAL_METHOD_ALIAS: - /* - * All aliases should have been resolved earlier, during the - * operand resolution phase. - */ - ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object")); - Status = AE_AML_INTERNAL; - break; - - case ACPI_TYPE_PACKAGE: - default: - /* - * All other types than Alias and the various Fields come here, - * including the untyped case - ACPI_TYPE_ANY. - */ - break; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExStoreObjectToObject - * - * PARAMETERS: SourceDesc - Object to store - * DestDesc - Object to receive a copy of the source - * NewDesc - New object if DestDesc is obsoleted - * WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: "Store" an object to another object. This may include - * converting the source type to the target type (implicit - * conversion), and a copy of the value of the source to - * the target. - * - * The Assignment of an object to another (not named) object - * is handled here. - * The Source passed in will replace the current value (if any) - * with the input value. - * - * When storing into an object the data is converted to the - * target object type then stored in the object. This means - * that the target object type (for an initialized target) will - * not be changed by a store operation. - * - * This module allows destination types of Number, String, - * Buffer, and Package. - * - * Assumes parameters are already validated. NOTE: SourceDesc - * resolution (from a reference object) must be performed by - * the caller if necessary. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExStoreObjectToObject ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *DestDesc, - ACPI_OPERAND_OBJECT **NewDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT *ActualSrcDesc; - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToObject, SourceDesc); - - - ActualSrcDesc = SourceDesc; - if (!DestDesc) - { - /* - * There is no destination object (An uninitialized node or - * package element), so we can simply copy the source object - * creating a new destination object - */ - Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, NewDesc, WalkState); - return_ACPI_STATUS (Status); - } - - if (SourceDesc->Common.Type != DestDesc->Common.Type) - { - /* - * The source type does not match the type of the destination. - * Perform the "implicit conversion" of the source to the current type - * of the target as per the ACPI specification. - * - * If no conversion performed, ActualSrcDesc = SourceDesc. - * Otherwise, ActualSrcDesc is a temporary object to hold the - * converted object. - */ - Status = AcpiExConvertToTargetType (DestDesc->Common.Type, - SourceDesc, &ActualSrcDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - if (SourceDesc == ActualSrcDesc) - { - /* - * No conversion was performed. Return the SourceDesc as the - * new object. - */ - *NewDesc = SourceDesc; - return_ACPI_STATUS (AE_OK); - } - } - - /* - * We now have two objects of identical types, and we can perform a - * copy of the *value* of the source object. - */ - switch (DestDesc->Common.Type) - { - case ACPI_TYPE_INTEGER: - - DestDesc->Integer.Value = ActualSrcDesc->Integer.Value; - - /* Truncate value if we are executing from a 32-bit ACPI table */ - - (void) AcpiExTruncateFor32bitTable (DestDesc); - break; - - case ACPI_TYPE_STRING: - - Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc); - break; - - case ACPI_TYPE_BUFFER: - - Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc); - break; - - case ACPI_TYPE_PACKAGE: - - Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc, - WalkState); - break; - - default: - /* - * All other types come here. - */ - ACPI_WARNING ((AE_INFO, "Store into type [%s] not implemented", - AcpiUtGetObjectTypeName (DestDesc))); - - Status = AE_NOT_IMPLEMENTED; - break; - } - - if (ActualSrcDesc != SourceDesc) - { - /* Delete the intermediate (temporary) source object */ - - AcpiUtRemoveReference (ActualSrcDesc); - } - - *NewDesc = DestDesc; - return_ACPI_STATUS (Status); -} diff --git a/Private/acpiSDK/source/components/executer/exstorob.c b/Private/acpiSDK/source/components/executer/exstorob.c deleted file mode 100644 index f318f027..00000000 --- a/Private/acpiSDK/source/components/executer/exstorob.c +++ /dev/null @@ -1,348 +0,0 @@ -/****************************************************************************** - * - * Module Name: exstorob - AML object store support, store to object - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exstorob") - - -/******************************************************************************* - * - * FUNCTION: AcpiExStoreBufferToBuffer - * - * PARAMETERS: SourceDesc - Source object to copy - * TargetDesc - Destination object of the copy - * - * RETURN: Status - * - * DESCRIPTION: Copy a buffer object to another buffer object. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExStoreBufferToBuffer ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *TargetDesc) -{ - UINT32 Length; - UINT8 *Buffer; - - - ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc); - - - /* If Source and Target are the same, just return */ - - if (SourceDesc == TargetDesc) - { - return_ACPI_STATUS (AE_OK); - } - - /* We know that SourceDesc is a buffer by now */ - - Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->Buffer.Pointer); - Length = SourceDesc->Buffer.Length; - - /* - * If target is a buffer of length zero or is a static buffer, - * allocate a new buffer of the proper length - */ - if ((TargetDesc->Buffer.Length == 0) || - (TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)) - { - TargetDesc->Buffer.Pointer = ACPI_ALLOCATE (Length); - if (!TargetDesc->Buffer.Pointer) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - TargetDesc->Buffer.Length = Length; - } - - /* Copy source buffer to target buffer */ - - if (Length <= TargetDesc->Buffer.Length) - { - /* Clear existing buffer and copy in the new one */ - - memset (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length); - memcpy (TargetDesc->Buffer.Pointer, Buffer, Length); - -#ifdef ACPI_OBSOLETE_BEHAVIOR - /* - * NOTE: ACPI versions up to 3.0 specified that the buffer must be - * truncated if the string is smaller than the buffer. However, "other" - * implementations of ACPI never did this and thus became the defacto - * standard. ACPI 3.0A changes this behavior such that the buffer - * is no longer truncated. - */ - - /* - * OBSOLETE BEHAVIOR: - * If the original source was a string, we must truncate the buffer, - * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer - * copy must not truncate the original buffer. - */ - if (OriginalSrcType == ACPI_TYPE_STRING) - { - /* Set the new length of the target */ - - TargetDesc->Buffer.Length = Length; - } -#endif - } - else - { - /* Truncate the source, copy only what will fit */ - - memcpy (TargetDesc->Buffer.Pointer, Buffer, - TargetDesc->Buffer.Length); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Truncating source buffer from %X to %X\n", - Length, TargetDesc->Buffer.Length)); - } - - /* Copy flags */ - - TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags; - TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExStoreStringToString - * - * PARAMETERS: SourceDesc - Source object to copy - * TargetDesc - Destination object of the copy - * - * RETURN: Status - * - * DESCRIPTION: Copy a String object to another String object - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExStoreStringToString ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *TargetDesc) -{ - UINT32 Length; - UINT8 *Buffer; - - - ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc); - - - /* If Source and Target are the same, just return */ - - if (SourceDesc == TargetDesc) - { - return_ACPI_STATUS (AE_OK); - } - - /* We know that SourceDesc is a string by now */ - - Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->String.Pointer); - Length = SourceDesc->String.Length; - - /* - * Replace existing string value if it will fit and the string - * pointer is not a static pointer (part of an ACPI table) - */ - if ((Length < TargetDesc->String.Length) && - (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) - { - /* - * String will fit in existing non-static buffer. - * Clear old string and copy in the new one - */ - memset (TargetDesc->String.Pointer, 0, - (ACPI_SIZE) TargetDesc->String.Length + 1); - memcpy (TargetDesc->String.Pointer, Buffer, Length); - } - else - { - /* - * Free the current buffer, then allocate a new buffer - * large enough to hold the value - */ - if (TargetDesc->String.Pointer && - (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) - { - /* Only free if not a pointer into the DSDT */ - - ACPI_FREE (TargetDesc->String.Pointer); - } - - TargetDesc->String.Pointer = - ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1); - - if (!TargetDesc->String.Pointer) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; - memcpy (TargetDesc->String.Pointer, Buffer, Length); - } - - /* Set the new target length */ - - TargetDesc->String.Length = Length; - return_ACPI_STATUS (AE_OK); -} diff --git a/Private/acpiSDK/source/components/executer/exsystem.c b/Private/acpiSDK/source/components/executer/exsystem.c deleted file mode 100644 index 68a074be..00000000 --- a/Private/acpiSDK/source/components/executer/exsystem.c +++ /dev/null @@ -1,462 +0,0 @@ -/****************************************************************************** - * - * Module Name: exsystem - Interface to OS services - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exsystem") - - -/******************************************************************************* - * - * FUNCTION: AcpiExSystemWaitSemaphore - * - * PARAMETERS: Semaphore - Semaphore to wait on - * Timeout - Max time to wait - * - * RETURN: Status - * - * DESCRIPTION: Implements a semaphore wait with a check to see if the - * semaphore is available immediately. If it is not, the - * interpreter is released before waiting. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExSystemWaitSemaphore ( - ACPI_SEMAPHORE Semaphore, - UINT16 Timeout) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (ExSystemWaitSemaphore); - - - Status = AcpiOsWaitSemaphore (Semaphore, 1, ACPI_DO_NOT_WAIT); - if (ACPI_SUCCESS (Status)) - { - return_ACPI_STATUS (Status); - } - - if (Status == AE_TIME) - { - /* We must wait, so unlock the interpreter */ - - AcpiExExitInterpreter (); - Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout); - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "*** Thread awake after blocking, %s\n", - AcpiFormatException (Status))); - - /* Reacquire the interpreter */ - - AcpiExEnterInterpreter (); - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExSystemWaitMutex - * - * PARAMETERS: Mutex - Mutex to wait on - * Timeout - Max time to wait - * - * RETURN: Status - * - * DESCRIPTION: Implements a mutex wait with a check to see if the - * mutex is available immediately. If it is not, the - * interpreter is released before waiting. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExSystemWaitMutex ( - ACPI_MUTEX Mutex, - UINT16 Timeout) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (ExSystemWaitMutex); - - - Status = AcpiOsAcquireMutex (Mutex, ACPI_DO_NOT_WAIT); - if (ACPI_SUCCESS (Status)) - { - return_ACPI_STATUS (Status); - } - - if (Status == AE_TIME) - { - /* We must wait, so unlock the interpreter */ - - AcpiExExitInterpreter (); - Status = AcpiOsAcquireMutex (Mutex, Timeout); - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "*** Thread awake after blocking, %s\n", - AcpiFormatException (Status))); - - /* Reacquire the interpreter */ - - AcpiExEnterInterpreter (); - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExSystemDoStall - * - * PARAMETERS: HowLongUs - The amount of time to stall, - * in microseconds - * - * RETURN: Status - * - * DESCRIPTION: Suspend running thread for specified amount of time. - * Note: ACPI specification requires that Stall() does not - * relinquish the processor, and delays longer than 100 usec - * should use Sleep() instead. We allow stalls up to 255 usec - * for compatibility with other interpreters and existing BIOSs. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExSystemDoStall ( - UINT32 HowLongUs) -{ - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_ENTRY (); - - - if (HowLongUs > 255) - { - /* - * Longer than 255 microseconds, this is an error - * - * (ACPI specifies 100 usec as max, but this gives some slack in - * order to support existing BIOSs) - */ - ACPI_ERROR ((AE_INFO, - "Time parameter is too large (%u)", HowLongUs)); - Status = AE_AML_OPERAND_VALUE; - } - else - { - if (HowLongUs > 100) - { - ACPI_WARNING ((AE_INFO, - "Time parameter %u us > 100 us violating ACPI spec, please fix the firmware.", HowLongUs)); - } - AcpiOsStall (HowLongUs); - } - - return (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExSystemDoSleep - * - * PARAMETERS: HowLongMs - The amount of time to sleep, - * in milliseconds - * - * RETURN: None - * - * DESCRIPTION: Sleep the running thread for specified amount of time. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExSystemDoSleep ( - UINT64 HowLongMs) -{ - ACPI_FUNCTION_ENTRY (); - - - /* Since this thread will sleep, we must release the interpreter */ - - AcpiExExitInterpreter (); - - /* - * For compatibility with other ACPI implementations and to prevent - * accidental deep sleeps, limit the sleep time to something reasonable. - */ - if (HowLongMs > ACPI_MAX_SLEEP) - { - HowLongMs = ACPI_MAX_SLEEP; - } - - AcpiOsSleep (HowLongMs); - - /* And now we must get the interpreter again */ - - AcpiExEnterInterpreter (); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExSystemSignalEvent - * - * PARAMETERS: ObjDesc - The object descriptor for this op - * - * RETURN: Status - * - * DESCRIPTION: Provides an access point to perform synchronization operations - * within the AML. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExSystemSignalEvent ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE (ExSystemSignalEvent); - - - if (ObjDesc) - { - Status = AcpiOsSignalSemaphore (ObjDesc->Event.OsSemaphore, 1); - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExSystemWaitEvent - * - * PARAMETERS: TimeDesc - The 'time to delay' object descriptor - * ObjDesc - The object descriptor for this op - * - * RETURN: Status - * - * DESCRIPTION: Provides an access point to perform synchronization operations - * within the AML. This operation is a request to wait for an - * event. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExSystemWaitEvent ( - ACPI_OPERAND_OBJECT *TimeDesc, - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE (ExSystemWaitEvent); - - - if (ObjDesc) - { - Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.OsSemaphore, - (UINT16) TimeDesc->Integer.Value); - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExSystemResetEvent - * - * PARAMETERS: ObjDesc - The object descriptor for this op - * - * RETURN: Status - * - * DESCRIPTION: Reset an event to a known state. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExSystemResetEvent ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_STATUS Status = AE_OK; - ACPI_SEMAPHORE TempSemaphore; - - - ACPI_FUNCTION_ENTRY (); - - - /* - * We are going to simply delete the existing semaphore and - * create a new one! - */ - Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &TempSemaphore); - if (ACPI_SUCCESS (Status)) - { - (void) AcpiOsDeleteSemaphore (ObjDesc->Event.OsSemaphore); - ObjDesc->Event.OsSemaphore = TempSemaphore; - } - - return (Status); -} diff --git a/Private/acpiSDK/source/components/executer/extrace.c b/Private/acpiSDK/source/components/executer/extrace.c deleted file mode 100644 index e574e489..00000000 --- a/Private/acpiSDK/source/components/executer/extrace.c +++ /dev/null @@ -1,507 +0,0 @@ -/****************************************************************************** - * - * Module Name: extrace - Support for interpreter execution tracing - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" -#include "acinterp.h" - - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("extrace") - - -static ACPI_OPERAND_OBJECT *AcpiGbl_TraceMethodObject = NULL; - -/* Local prototypes */ - -#ifdef ACPI_DEBUG_OUTPUT -static const char * -AcpiExGetTraceEventName ( - ACPI_TRACE_EVENT_TYPE Type); -#endif - - -/******************************************************************************* - * - * FUNCTION: AcpiExInterpreterTraceEnabled - * - * PARAMETERS: Name - Whether method name should be matched, - * this should be checked before starting - * the tracer - * - * RETURN: TRUE if interpreter trace is enabled. - * - * DESCRIPTION: Check whether interpreter trace is enabled - * - ******************************************************************************/ - -static BOOLEAN -AcpiExInterpreterTraceEnabled ( - char *Name) -{ - - /* Check if tracing is enabled */ - - if (!(AcpiGbl_TraceFlags & ACPI_TRACE_ENABLED)) - { - return (FALSE); - } - - /* - * Check if tracing is filtered: - * - * 1. If the tracer is started, AcpiGbl_TraceMethodObject should have - * been filled by the trace starter - * 2. If the tracer is not started, AcpiGbl_TraceMethodName should be - * matched if it is specified - * 3. If the tracer is oneshot style, AcpiGbl_TraceMethodName should - * not be cleared by the trace stopper during the first match - */ - if (AcpiGbl_TraceMethodObject) - { - return (TRUE); - } - - if (Name && - (AcpiGbl_TraceMethodName && - strcmp (AcpiGbl_TraceMethodName, Name))) - { - return (FALSE); - } - - if ((AcpiGbl_TraceFlags & ACPI_TRACE_ONESHOT) && - !AcpiGbl_TraceMethodName) - { - return (FALSE); - } - - return (TRUE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExGetTraceEventName - * - * PARAMETERS: Type - Trace event type - * - * RETURN: Trace event name. - * - * DESCRIPTION: Used to obtain the full trace event name. - * - ******************************************************************************/ - -#ifdef ACPI_DEBUG_OUTPUT - -static const char * -AcpiExGetTraceEventName ( - ACPI_TRACE_EVENT_TYPE Type) -{ - - switch (Type) - { - case ACPI_TRACE_AML_METHOD: - - return "Method"; - - case ACPI_TRACE_AML_OPCODE: - - return "Opcode"; - - case ACPI_TRACE_AML_REGION: - - return "Region"; - - default: - - return ""; - } -} - -#endif - - -/******************************************************************************* - * - * FUNCTION: AcpiExTracePoint - * - * PARAMETERS: Type - Trace event type - * Begin - TRUE if before execution - * Aml - Executed AML address - * Pathname - Object path - * - * RETURN: None - * - * DESCRIPTION: Internal interpreter execution trace. - * - ******************************************************************************/ - -void -AcpiExTracePoint ( - ACPI_TRACE_EVENT_TYPE Type, - BOOLEAN Begin, - UINT8 *Aml, - char *Pathname) -{ - - ACPI_FUNCTION_NAME (ExTracePoint); - - - if (Pathname) - { - ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT, - "%s %s [0x%p:%s] execution.\n", - AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End", - Aml, Pathname)); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT, - "%s %s [0x%p] execution.\n", - AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End", - Aml)); - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExStartTraceMethod - * - * PARAMETERS: MethodNode - Node of the method - * ObjDesc - The method object - * WalkState - current state, NULL if not yet executing - * a method. - * - * RETURN: None - * - * DESCRIPTION: Start control method execution trace - * - ******************************************************************************/ - -void -AcpiExStartTraceMethod ( - ACPI_NAMESPACE_NODE *MethodNode, - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_WALK_STATE *WalkState) -{ - char *Pathname = NULL; - BOOLEAN Enabled = FALSE; - - - ACPI_FUNCTION_NAME (ExStartTraceMethod); - - - if (MethodNode) - { - Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE); - } - - Enabled = AcpiExInterpreterTraceEnabled (Pathname); - if (Enabled && !AcpiGbl_TraceMethodObject) - { - AcpiGbl_TraceMethodObject = ObjDesc; - AcpiGbl_OriginalDbgLevel = AcpiDbgLevel; - AcpiGbl_OriginalDbgLayer = AcpiDbgLayer; - AcpiDbgLevel = ACPI_TRACE_LEVEL_ALL; - AcpiDbgLayer = ACPI_TRACE_LAYER_ALL; - - if (AcpiGbl_TraceDbgLevel) - { - AcpiDbgLevel = AcpiGbl_TraceDbgLevel; - } - - if (AcpiGbl_TraceDbgLayer) - { - AcpiDbgLayer = AcpiGbl_TraceDbgLayer; - } - } - - if (Enabled) - { - ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, TRUE, - ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname); - } - - if (Pathname) - { - ACPI_FREE (Pathname); - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExStopTraceMethod - * - * PARAMETERS: MethodNode - Node of the method - * ObjDesc - The method object - * WalkState - current state, NULL if not yet executing - * a method. - * - * RETURN: None - * - * DESCRIPTION: Stop control method execution trace - * - ******************************************************************************/ - -void -AcpiExStopTraceMethod ( - ACPI_NAMESPACE_NODE *MethodNode, - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_WALK_STATE *WalkState) -{ - char *Pathname = NULL; - BOOLEAN Enabled; - - - ACPI_FUNCTION_NAME (ExStopTraceMethod); - - - if (MethodNode) - { - Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE); - } - - Enabled = AcpiExInterpreterTraceEnabled (NULL); - - if (Enabled) - { - ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, FALSE, - ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname); - } - - /* Check whether the tracer should be stopped */ - - if (AcpiGbl_TraceMethodObject == ObjDesc) - { - /* Disable further tracing if type is one-shot */ - - if (AcpiGbl_TraceFlags & ACPI_TRACE_ONESHOT) - { - AcpiGbl_TraceMethodName = NULL; - } - - AcpiDbgLevel = AcpiGbl_OriginalDbgLevel; - AcpiDbgLayer = AcpiGbl_OriginalDbgLayer; - AcpiGbl_TraceMethodObject = NULL; - } - - if (Pathname) - { - ACPI_FREE (Pathname); - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExStartTraceOpcode - * - * PARAMETERS: Op - The parser opcode object - * WalkState - current state, NULL if not yet executing - * a method. - * - * RETURN: None - * - * DESCRIPTION: Start opcode execution trace - * - ******************************************************************************/ - -void -AcpiExStartTraceOpcode ( - ACPI_PARSE_OBJECT *Op, - ACPI_WALK_STATE *WalkState) -{ - - ACPI_FUNCTION_NAME (ExStartTraceOpcode); - - - if (AcpiExInterpreterTraceEnabled (NULL) && - (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE)) - { - ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, TRUE, - Op->Common.Aml, Op->Common.AmlOpName); - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExStopTraceOpcode - * - * PARAMETERS: Op - The parser opcode object - * WalkState - current state, NULL if not yet executing - * a method. - * - * RETURN: None - * - * DESCRIPTION: Stop opcode execution trace - * - ******************************************************************************/ - -void -AcpiExStopTraceOpcode ( - ACPI_PARSE_OBJECT *Op, - ACPI_WALK_STATE *WalkState) -{ - - ACPI_FUNCTION_NAME (ExStopTraceOpcode); - - - if (AcpiExInterpreterTraceEnabled (NULL) && - (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE)) - { - ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, FALSE, - Op->Common.Aml, Op->Common.AmlOpName); - } -} diff --git a/Private/acpiSDK/source/components/executer/exutils.c b/Private/acpiSDK/source/components/executer/exutils.c deleted file mode 100644 index 3d9dd4fa..00000000 --- a/Private/acpiSDK/source/components/executer/exutils.c +++ /dev/null @@ -1,615 +0,0 @@ -/****************************************************************************** - * - * Module Name: exutils - interpreter/scanner utilities - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - ***************************************************************************** - * - * Alternatively, you may choose to be licensed under the terms of the - * following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, you may choose to be licensed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - *****************************************************************************/ - -/* - * DEFINE_AML_GLOBALS is tested in amlcode.h - * to determine whether certain global names should be "defined" or only - * "declared" in the current compilation. This enhances maintainability - * by enabling a single header file to embody all knowledge of the names - * in question. - * - * Exactly one module of any executable should #define DEFINE_GLOBALS - * before #including the header files which use this convention. The - * names in question will be defined and initialized in that module, - * and declared as extern in all other modules which #include those - * header files. - */ - -#define DEFINE_AML_GLOBALS - -#include "acpi.h" -#include "accommon.h" -#include "acinterp.h" -#include "amlcode.h" - -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exutils") - -/* Local prototypes */ - -static UINT32 -AcpiExDigitsNeeded ( - UINT64 Value, - UINT32 Base); - - -/******************************************************************************* - * - * FUNCTION: AcpiExEnterInterpreter - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Enter the interpreter execution region. Failure to enter - * the interpreter region is a fatal system error. Used in - * conjunction with ExitInterpreter. - * - ******************************************************************************/ - -void -AcpiExEnterInterpreter ( - void) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (ExEnterInterpreter); - - - Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex")); - } - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, "Could not acquire AML Namespace mutex")); - } - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExExitInterpreter - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Exit the interpreter execution region. This is the top level - * routine used to exit the interpreter when all processing has - * been completed, or when the method blocks. - * - * Cases where the interpreter is unlocked internally: - * 1) Method will be blocked on a Sleep() AML opcode - * 2) Method will be blocked on an Acquire() AML opcode - * 3) Method will be blocked on a Wait() AML opcode - * 4) Method will be blocked to acquire the global lock - * 5) Method will be blocked waiting to execute a serialized control - * method that is currently executing - * 6) About to invoke a user-installed opregion handler - * - ******************************************************************************/ - -void -AcpiExExitInterpreter ( - void) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (ExExitInterpreter); - - - Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, "Could not release AML Namespace mutex")); - } - Status = AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, "Could not release AML Interpreter mutex")); - } - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExTruncateFor32bitTable - * - * PARAMETERS: ObjDesc - Object to be truncated - * - * RETURN: TRUE if a truncation was performed, FALSE otherwise. - * - * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is - * 32-bit, as determined by the revision of the DSDT. - * - ******************************************************************************/ - -BOOLEAN -AcpiExTruncateFor32bitTable ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - - ACPI_FUNCTION_ENTRY (); - - - /* - * Object must be a valid number and we must be executing - * a control method. Object could be NS node for AML_INT_NAMEPATH_OP. - */ - if ((!ObjDesc) || - (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) || - (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) - { - return (FALSE); - } - - if ((AcpiGbl_IntegerByteWidth == 4) && - (ObjDesc->Integer.Value > (UINT64) ACPI_UINT32_MAX)) - { - /* - * We are executing in a 32-bit ACPI table. Truncate - * the value to 32 bits by zeroing out the upper 32-bit field - */ - ObjDesc->Integer.Value &= (UINT64) ACPI_UINT32_MAX; - return (TRUE); - } - - return (FALSE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExAcquireGlobalLock - * - * PARAMETERS: FieldFlags - Flags with Lock rule: - * AlwaysLock or NeverLock - * - * RETURN: None - * - * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field - * flags specify that it is to be obtained before field access. - * - ******************************************************************************/ - -void -AcpiExAcquireGlobalLock ( - UINT32 FieldFlags) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (ExAcquireGlobalLock); - - - /* Only use the lock if the AlwaysLock bit is set */ - - if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) - { - return_VOID; - } - - /* Attempt to get the global lock, wait forever */ - - Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER, - AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); - - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not acquire Global Lock")); - } - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExReleaseGlobalLock - * - * PARAMETERS: FieldFlags - Flags with Lock rule: - * AlwaysLock or NeverLock - * - * RETURN: None - * - * DESCRIPTION: Release the ACPI hardware Global Lock - * - ******************************************************************************/ - -void -AcpiExReleaseGlobalLock ( - UINT32 FieldFlags) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (ExReleaseGlobalLock); - - - /* Only use the lock if the AlwaysLock bit is set */ - - if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) - { - return_VOID; - } - - /* Release the global lock */ - - Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex); - if (ACPI_FAILURE (Status)) - { - /* Report the error, but there isn't much else we can do */ - - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not release Global Lock")); - } - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExDigitsNeeded - * - * PARAMETERS: Value - Value to be represented - * Base - Base of representation - * - * RETURN: The number of digits. - * - * DESCRIPTION: Calculate the number of digits needed to represent the Value - * in the given Base (Radix) - * - ******************************************************************************/ - -static UINT32 -AcpiExDigitsNeeded ( - UINT64 Value, - UINT32 Base) -{ - UINT32 NumDigits; - UINT64 CurrentValue; - - - ACPI_FUNCTION_TRACE (ExDigitsNeeded); - - - /* UINT64 is unsigned, so we don't worry about a '-' prefix */ - - if (Value == 0) - { - return_UINT32 (1); - } - - CurrentValue = Value; - NumDigits = 0; - - /* Count the digits in the requested base */ - - while (CurrentValue) - { - (void) AcpiUtShortDivide (CurrentValue, Base, &CurrentValue, NULL); - NumDigits++; - } - - return_UINT32 (NumDigits); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExEisaIdToString - * - * PARAMETERS: OutString - Where to put the converted string (8 bytes) - * CompressedId - EISAID to be converted - * - * RETURN: None - * - * DESCRIPTION: Convert a numeric EISAID to string representation. Return - * buffer must be large enough to hold the string. The string - * returned is always exactly of length ACPI_EISAID_STRING_SIZE - * (includes null terminator). The EISAID is always 32 bits. - * - ******************************************************************************/ - -void -AcpiExEisaIdToString ( - char *OutString, - UINT64 CompressedId) -{ - UINT32 SwappedId; - - - ACPI_FUNCTION_ENTRY (); - - - /* The EISAID should be a 32-bit integer */ - - if (CompressedId > ACPI_UINT32_MAX) - { - ACPI_WARNING ((AE_INFO, - "Expected EISAID is larger than 32 bits: " - "0x%8.8X%8.8X, truncating", - ACPI_FORMAT_UINT64 (CompressedId))); - } - - /* Swap ID to big-endian to get contiguous bits */ - - SwappedId = AcpiUtDwordByteSwap ((UINT32) CompressedId); - - /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */ - - OutString[0] = (char) (0x40 + (((unsigned long) SwappedId >> 26) & 0x1F)); - OutString[1] = (char) (0x40 + ((SwappedId >> 21) & 0x1F)); - OutString[2] = (char) (0x40 + ((SwappedId >> 16) & 0x1F)); - OutString[3] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 12); - OutString[4] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 8); - OutString[5] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 4); - OutString[6] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 0); - OutString[7] = 0; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExIntegerToString - * - * PARAMETERS: OutString - Where to put the converted string. At least - * 21 bytes are needed to hold the largest - * possible 64-bit integer. - * Value - Value to be converted - * - * RETURN: Converted string in OutString - * - * DESCRIPTION: Convert a 64-bit integer to decimal string representation. - * Assumes string buffer is large enough to hold the string. The - * largest string is (ACPI_MAX64_DECIMAL_DIGITS + 1). - * - ******************************************************************************/ - -void -AcpiExIntegerToString ( - char *OutString, - UINT64 Value) -{ - UINT32 Count; - UINT32 DigitsNeeded; - UINT32 Remainder; - - - ACPI_FUNCTION_ENTRY (); - - - DigitsNeeded = AcpiExDigitsNeeded (Value, 10); - OutString[DigitsNeeded] = 0; - - for (Count = DigitsNeeded; Count > 0; Count--) - { - (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder); - OutString[Count-1] = (char) ('0' + Remainder);\ - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExPciClsToString - * - * PARAMETERS: OutString - Where to put the converted string (7 bytes) - * ClassCode - PCI class code to be converted (3 bytes) - * - * RETURN: Converted string in OutString - * - * DESCRIPTION: Convert 3-bytes PCI class code to string representation. - * Return buffer must be large enough to hold the string. The - * string returned is always exactly of length - * ACPI_PCICLS_STRING_SIZE (includes null terminator). - * - ******************************************************************************/ - -void -AcpiExPciClsToString ( - char *OutString, - UINT8 ClassCode[3]) -{ - - ACPI_FUNCTION_ENTRY (); - - - /* All 3 bytes are hexadecimal */ - - OutString[0] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[0], 4); - OutString[1] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[0], 0); - OutString[2] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[1], 4); - OutString[3] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[1], 0); - OutString[4] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[2], 4); - OutString[5] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[2], 0); - OutString[6] = 0; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiIsValidSpaceId - * - * PARAMETERS: SpaceId - ID to be validated - * - * RETURN: TRUE if SpaceId is a valid/supported ID. - * - * DESCRIPTION: Validate an operation region SpaceID. - * - ******************************************************************************/ - -BOOLEAN -AcpiIsValidSpaceId ( - UINT8 SpaceId) -{ - - if ((SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) && - (SpaceId < ACPI_USER_REGION_BEGIN) && - (SpaceId != ACPI_ADR_SPACE_DATA_TABLE) && - (SpaceId != ACPI_ADR_SPACE_FIXED_HARDWARE)) - { - return (FALSE); - } - - return (TRUE); -} |
