diff options
author | jkim <jkim@FreeBSD.org> | 2016-09-30 22:40:58 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2016-09-30 22:40:58 +0000 |
commit | dba8c0a565199df70a86f6a036d00c92f0c7675f (patch) | |
tree | cf4924274c6e92898c01efb3c8ba31b34f0630f2 /sys/contrib/dev/acpica/components/executer | |
parent | 0f41551ef9dde560d9d191d7190af02904dbf611 (diff) | |
download | FreeBSD-src-dba8c0a565199df70a86f6a036d00c92f0c7675f.zip FreeBSD-src-dba8c0a565199df70a86f6a036d00c92f0c7675f.tar.gz |
MFC: r284583, r285797, r285799, r287168, r298714, r298720, r298838,
r300879
Merge ACPICA up to 20160527.
Requested by: mav
Diffstat (limited to 'sys/contrib/dev/acpica/components/executer')
26 files changed, 1648 insertions, 732 deletions
diff --git a/sys/contrib/dev/acpica/components/executer/exconcat.c b/sys/contrib/dev/acpica/components/executer/exconcat.c new file mode 100644 index 0000000..1814a5c --- /dev/null +++ b/sys/contrib/dev/acpica/components/executer/exconcat.c @@ -0,0 +1,460 @@ +/****************************************************************************** + * + * Module Name: exconcat - Concatenate-type AML operators + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * 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. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * 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 MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. + */ + +#include <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/include/accommon.h> +#include <contrib/dev/acpica/include/acinterp.h> +#include <contrib/dev/acpica/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, 16); + 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/sys/contrib/dev/acpica/components/executer/exconfig.c b/sys/contrib/dev/acpica/components/executer/exconfig.c index 0627f99..cf76bf1 100644 --- a/sys/contrib/dev/acpica/components/executer/exconfig.c +++ b/sys/contrib/dev/acpica/components/executer/exconfig.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -129,7 +129,10 @@ AcpiExAddTable ( /* Execute any module-level code that was found in the table */ AcpiExExitInterpreter (); - AcpiNsExecModuleCodeList (); + if (AcpiGbl_GroupModuleLevelCode) + { + AcpiNsExecModuleCodeList (); + } AcpiExEnterInterpreter (); /* @@ -178,21 +181,12 @@ AcpiExLoadTableOp ( ACPI_FUNCTION_TRACE (ExLoadTableOp); - /* Validate lengths for the Signature, OemId, and OemTableId strings */ - - if ((Operand[0]->String.Length > ACPI_NAME_SIZE) || - (Operand[1]->String.Length > ACPI_OEM_ID_SIZE) || - (Operand[2]->String.Length > ACPI_OEM_TABLE_ID_SIZE)) - { - return_ACPI_STATUS (AE_AML_STRING_LIMIT); - } - /* Find the ACPI table in the RSDT/XSDT */ Status = AcpiTbFindTable ( - Operand[0]->String.Pointer, - Operand[1]->String.Pointer, - Operand[2]->String.Pointer, &TableIndex); + Operand[0]->String.Pointer, + Operand[1]->String.Pointer, + Operand[2]->String.Pointer, &TableIndex); if (ACPI_FAILURE (Status)) { if (Status != AE_NOT_FOUND) @@ -226,7 +220,7 @@ AcpiExLoadTableOp ( * location within the namespace where the table will be loaded. */ Status = AcpiNsGetNode (StartNode, Operand[3]->String.Pointer, - ACPI_NS_SEARCH_PARENT, &ParentNode); + ACPI_NS_SEARCH_PARENT, &ParentNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -250,7 +244,7 @@ AcpiExLoadTableOp ( /* Find the node referenced by the ParameterPathString */ Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer, - ACPI_NS_SEARCH_PARENT, &ParameterNode); + ACPI_NS_SEARCH_PARENT, &ParameterNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -272,8 +266,7 @@ AcpiExLoadTableOp ( /* Store the parameter data into the optional parameter object */ Status = AcpiExStore (Operand[5], - ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), - WalkState); + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), WalkState); if (ACPI_FAILURE (Status)) { (void) AcpiExUnloadTable (DdbHandle); @@ -286,7 +279,7 @@ AcpiExLoadTableOp ( Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_SUCCESS (Status)) { - ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:")); + ACPI_INFO (("Dynamic OEM Table Load:")); AcpiTbPrintTableHeader (0, Table); } @@ -295,7 +288,7 @@ AcpiExLoadTableOp ( if (AcpiGbl_TableHandler) { (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, - AcpiGbl_TableHandlerContext); + AcpiGbl_TableHandlerContext); } *ReturnDesc = DdbHandle; @@ -335,7 +328,7 @@ AcpiExRegionRead ( for (i = 0; i < Length; i++) { Status = AcpiEvAddressSpaceDispatch (ObjDesc, NULL, ACPI_READ, - RegionOffset, 8, &Value); + RegionOffset, 8, &Value); if (ACPI_FAILURE (Status)) { return (Status); @@ -405,8 +398,8 @@ AcpiExLoadOp ( } /* - * If the Region Address and Length have not been previously evaluated, - * evaluate them now and save the results. + * 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)) { @@ -426,7 +419,7 @@ AcpiExLoadOp ( } Status = AcpiExRegionRead (ObjDesc, sizeof (ACPI_TABLE_HEADER), - ACPI_CAST_PTR (UINT8, TableHeader)); + ACPI_CAST_PTR (UINT8, TableHeader)); Length = TableHeader->Length; ACPI_FREE (TableHeader); @@ -469,7 +462,7 @@ AcpiExLoadOp ( /* Read the entire table */ Status = AcpiExRegionRead (ObjDesc, Length, - ACPI_CAST_PTR (UINT8, Table)); + ACPI_CAST_PTR (UINT8, Table)); if (ACPI_FAILURE (Status)) { ACPI_FREE (Table); @@ -491,7 +484,8 @@ AcpiExLoadOp ( /* Get the actual table length from the table header */ - TableHeader = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer); + TableHeader = ACPI_CAST_PTR ( + ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer); Length = TableHeader->Length; /* Table cannot extend beyond the buffer */ @@ -506,8 +500,8 @@ AcpiExLoadOp ( } /* - * Copy the table from the buffer because the buffer could be modified - * or even deleted in the future + * Copy the table from the buffer because the buffer could be + * modified or even deleted in the future */ Table = ACPI_ALLOCATE (Length); if (!Table) @@ -515,7 +509,7 @@ AcpiExLoadOp ( return_ACPI_STATUS (AE_NO_MEMORY); } - ACPI_MEMCPY (Table, TableHeader, Length); + memcpy (Table, TableHeader, Length); break; default: @@ -525,12 +519,12 @@ AcpiExLoadOp ( /* Install the new table into the local data structures */ - ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:")); + ACPI_INFO (("Dynamic OEM Table Load:")); (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); Status = AcpiTbInstallStandardTable (ACPI_PTR_TO_PHYSADDR (Table), - ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, TRUE, TRUE, - &TableIndex); + ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, TRUE, TRUE, + &TableIndex); (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); if (ACPI_FAILURE (Status)) @@ -545,7 +539,8 @@ AcpiExLoadOp ( * Note: Now table is "INSTALLED", it must be validated before * loading. */ - Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[TableIndex]); + Status = AcpiTbValidateTable ( + &AcpiGbl_RootTableList.Tables[TableIndex]); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -588,7 +583,7 @@ AcpiExLoadOp ( if (AcpiGbl_TableHandler) { (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, - AcpiGbl_TableHandlerContext); + AcpiGbl_TableHandlerContext); } return_ACPI_STATUS (Status); @@ -665,7 +660,7 @@ AcpiExUnloadTable ( if (ACPI_SUCCESS (Status)) { (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, Table, - AcpiGbl_TableHandlerContext); + AcpiGbl_TableHandlerContext); } } diff --git a/sys/contrib/dev/acpica/components/executer/exconvrt.c b/sys/contrib/dev/acpica/components/executer/exconvrt.c index 50ccf26..871e1e3 100644 --- a/sys/contrib/dev/acpica/components/executer/exconvrt.c +++ b/sys/contrib/dev/acpica/components/executer/exconvrt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -137,7 +137,8 @@ AcpiExConvertToInteger ( * of ACPI 3.0) is that the ToInteger() operator allows both decimal * and hexadecimal strings (hex prefixed with "0x"). */ - Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, &Result); + Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, + AcpiGbl_IntegerByteWidth, &Result); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -251,9 +252,7 @@ AcpiExConvertToBuffer ( /* Copy the integer to the buffer, LSB first */ NewBuf = ReturnDesc->Buffer.Pointer; - ACPI_MEMCPY (NewBuf, - &ObjDesc->Integer.Value, - AcpiGbl_IntegerByteWidth); + memcpy (NewBuf, &ObjDesc->Integer.Value, AcpiGbl_IntegerByteWidth); break; case ACPI_TYPE_STRING: @@ -266,8 +265,8 @@ AcpiExConvertToBuffer ( * ASL/AML code that depends on the null being transferred to the new * buffer. */ - ReturnDesc = AcpiUtCreateBufferObject ( - (ACPI_SIZE) ObjDesc->String.Length + 1); + ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) + ObjDesc->String.Length + 1); if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -276,7 +275,7 @@ AcpiExConvertToBuffer ( /* Copy the string to the buffer */ NewBuf = ReturnDesc->Buffer.Pointer; - ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer, + strncpy ((char *) NewBuf, (char *) ObjDesc->String.Pointer, ObjDesc->String.Length); break; @@ -390,7 +389,8 @@ AcpiExConvertToAscii ( { /* Get one hex digit, most significant digits first */ - String[k] = (UINT8) AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j)); + String[k] = (UINT8) + AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j)); k++; } break; @@ -491,8 +491,8 @@ AcpiExConvertToString ( /* Convert integer to string */ - StringLength = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, - NewBuf, AcpiGbl_IntegerByteWidth); + StringLength = AcpiExConvertToAscii ( + ObjDesc->Integer.Value, Base, NewBuf, AcpiGbl_IntegerByteWidth); /* Null terminate at the correct place */ @@ -581,8 +581,7 @@ AcpiExConvertToString ( for (i = 0; i < ObjDesc->Buffer.Length; i++) { NewBuf += AcpiExConvertToAscii ( - (UINT64) ObjDesc->Buffer.Pointer[i], Base, - NewBuf, 1); + (UINT64) ObjDesc->Buffer.Pointer[i], Base, NewBuf, 1); *NewBuf++ = Separator; /* each separated by a comma or space */ } @@ -673,6 +672,7 @@ AcpiExConvertToTargetType ( break; case ARGI_TARGETREF: + case ARGI_STORE_TARGET: switch (DestinationType) { @@ -684,8 +684,7 @@ AcpiExConvertToTargetType ( * These types require an Integer operand. We can convert * a Buffer or a String to an Integer if necessary. */ - Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, - 16); + Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, 16); break; case ACPI_TYPE_STRING: @@ -694,7 +693,7 @@ AcpiExConvertToTargetType ( * Integer or Buffer if necessary */ Status = AcpiExConvertToString (SourceDesc, ResultDesc, - ACPI_IMPLICIT_CONVERT_HEX); + ACPI_IMPLICIT_CONVERT_HEX); break; case ACPI_TYPE_BUFFER: @@ -707,7 +706,8 @@ AcpiExConvertToTargetType ( default: - ACPI_ERROR ((AE_INFO, "Bad destination type during conversion: 0x%X", + ACPI_ERROR ((AE_INFO, + "Bad destination type during conversion: 0x%X", DestinationType)); Status = AE_AML_INTERNAL; break; diff --git a/sys/contrib/dev/acpica/components/executer/excreate.c b/sys/contrib/dev/acpica/components/executer/excreate.c index a855f20..5c38a44 100644 --- a/sys/contrib/dev/acpica/components/executer/excreate.c +++ b/sys/contrib/dev/acpica/components/executer/excreate.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -147,7 +147,7 @@ AcpiExCreateAlias ( * target node or the alias Node */ Status = AcpiNsAttachObject (AliasNode, - AcpiNsGetAttachedObject (TargetNode), TargetNode->Type); + AcpiNsGetAttachedObject (TargetNode), TargetNode->Type); break; } @@ -192,7 +192,7 @@ AcpiExCreateEvent ( * that the event is created in an unsignalled state */ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, - &ObjDesc->Event.OsSemaphore); + &ObjDesc->Event.OsSemaphore); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -200,8 +200,9 @@ AcpiExCreateEvent ( /* Attach object to the Node */ - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], - ObjDesc, ACPI_TYPE_EVENT); + Status = AcpiNsAttachObject ( + (ACPI_NAMESPACE_NODE *) WalkState->Operands[0], + ObjDesc, ACPI_TYPE_EVENT); Cleanup: /* @@ -260,7 +261,8 @@ AcpiExCreateMutex ( 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); + Status = AcpiNsAttachObject ( + ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX); Cleanup: @@ -328,7 +330,8 @@ AcpiExCreateRegion ( * 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_ERROR ((AE_INFO, + "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId)); } ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n", @@ -347,9 +350,10 @@ AcpiExCreateRegion ( * Remember location in AML stream of address & length * operands since they need to be evaluated at run time. */ - RegionObj2 = ObjDesc->Common.NextObject; + 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; @@ -365,6 +369,10 @@ AcpiExCreateRegion ( ObjDesc->Region.Address = 0; ObjDesc->Region.Length = 0; 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 */ @@ -423,7 +431,7 @@ AcpiExCreateProcessor ( /* Install the processor object in the parent Node */ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_PROCESSOR); + ObjDesc, ACPI_TYPE_PROCESSOR); /* Remove local reference to the object */ @@ -474,7 +482,7 @@ AcpiExCreatePowerResource ( /* Install the power resource object in the parent Node */ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_POWER); + ObjDesc, ACPI_TYPE_POWER); /* Remove local reference to the object */ @@ -526,13 +534,15 @@ AcpiExCreateMethod ( 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); + ObjDesc->Method.ParamCount = (UINT8) + (MethodFlags & AML_METHOD_ARG_COUNT); /* * Get the SyncLevel. If method is serialized, a mutex will be @@ -553,7 +563,7 @@ AcpiExCreateMethod ( /* Attach the new object to the method Node */ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_METHOD); + ObjDesc, ACPI_TYPE_METHOD); /* Remove local reference to the object */ diff --git a/sys/contrib/dev/acpica/components/executer/exdebug.c b/sys/contrib/dev/acpica/components/executer/exdebug.c index 5e98fd5..24273f8 100644 --- a/sys/contrib/dev/acpica/components/executer/exdebug.c +++ b/sys/contrib/dev/acpica/components/executer/exdebug.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -81,6 +81,8 @@ AcpiExDoDebugObject ( { UINT32 i; UINT32 Timer; + ACPI_OPERAND_OBJECT *ObjectDesc; + UINT32 Value; ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); @@ -94,13 +96,20 @@ AcpiExDoDebugObject ( return_VOID; } - /* - * 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. - */ - Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */ - Timer &= 0x03FFFFFF; + /* Null string or 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 == 0) || + ((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 @@ -108,14 +117,31 @@ AcpiExDoDebugObject ( */ if (!((Level > 0) && Index == 0)) { - AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " "); + 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); + AcpiOsPrintf ("(%.2u) ", Index - 1); } if (!SourceDesc) @@ -126,7 +152,13 @@ AcpiExDoDebugObject ( if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) { - AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc)); + /* 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)) { @@ -136,9 +168,9 @@ AcpiExDoDebugObject ( } else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) { - AcpiOsPrintf ("%s: %p\n", + AcpiOsPrintf ("%s (Node %p)\n", AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type), - SourceDesc); + SourceDesc); return_VOID; } else @@ -176,13 +208,12 @@ AcpiExDoDebugObject ( case ACPI_TYPE_STRING: - AcpiOsPrintf ("[0x%.2X] \"%s\"\n", - SourceDesc->String.Length, SourceDesc->String.Pointer); + AcpiOsPrintf ("\"%s\"\n", SourceDesc->String.Pointer); break; case ACPI_TYPE_PACKAGE: - AcpiOsPrintf ("[Contains 0x%.2X Elements]\n", + AcpiOsPrintf ("(Contains 0x%.2X Elements):\n", SourceDesc->Package.Count); /* Output the entire contents of the package */ @@ -190,7 +221,7 @@ AcpiExDoDebugObject ( for (i = 0; i < SourceDesc->Package.Count; i++) { AcpiExDoDebugObject (SourceDesc->Package.Elements[i], - Level+4, i+1); + Level + 4, i + 1); } break; @@ -226,7 +257,7 @@ AcpiExDoDebugObject ( if (SourceDesc->Reference.Node) { if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) != - ACPI_DESC_TYPE_NAMED) + ACPI_DESC_TYPE_NAMED) { AcpiOsPrintf (" %p - Not a valid namespace node\n", SourceDesc->Reference.Node); @@ -251,7 +282,7 @@ AcpiExDoDebugObject ( default: AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object, - Level+4, 0); + Level + 4, 0); break; } } @@ -259,23 +290,61 @@ AcpiExDoDebugObject ( else if (SourceDesc->Reference.Object) { if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) == - ACPI_DESC_TYPE_NAMED) + ACPI_DESC_TYPE_NAMED) { - AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *) - SourceDesc->Reference.Object)->Object, - Level+4, 0); + /* Reference object is a namespace node */ + + AcpiExDoDebugObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, + SourceDesc->Reference.Object), + Level + 4, 0); } else { - AcpiExDoDebugObject (SourceDesc->Reference.Object, - Level+4, 0); + 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 ("%p\n", SourceDesc); + AcpiOsPrintf ("(Descriptor %p)\n", SourceDesc); break; } diff --git a/sys/contrib/dev/acpica/components/executer/exdump.c b/sys/contrib/dev/acpica/components/executer/exdump.c index 622dc14..3e6c089 100644 --- a/sys/contrib/dev/acpica/components/executer/exdump.c +++ b/sys/contrib/dev/acpica/components/executer/exdump.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -60,13 +60,13 @@ static void AcpiExOutString ( - char *Title, - char *Value); + const char *Title, + const char *Value); static void AcpiExOutPointer ( - char *Title, - void *Value); + const char *Title, + const void *Value); static void AcpiExDumpObject ( @@ -238,7 +238,7 @@ static ACPI_EXDUMP_INFO AcpiExDumpIndexField[5] = {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.DataObj), "Data Object"} }; -static ACPI_EXDUMP_INFO AcpiExDumpReference[8] = +static ACPI_EXDUMP_INFO AcpiExDumpReference[9] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpReference), NULL}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.Class), "Class"}, @@ -247,6 +247,7 @@ static ACPI_EXDUMP_INFO AcpiExDumpReference[8] = {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} }; @@ -379,8 +380,7 @@ AcpiExDumpObject ( ACPI_EXDUMP_INFO *Info) { UINT8 *Target; - char *Name; - const char *ReferenceName; + const char *Name; UINT8 Count; ACPI_OPERAND_OBJECT *Start; ACPI_OPERAND_OBJECT *Data = NULL; @@ -452,7 +452,8 @@ AcpiExDumpObject ( case ACPI_EXD_BUFFER: - ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); + ACPI_DUMP_BUFFER ( + ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); break; case ACPI_EXD_PACKAGE: @@ -470,8 +471,7 @@ AcpiExDumpObject ( case ACPI_EXD_REFERENCE: - ReferenceName = AcpiUtGetReferenceName (ObjDesc); - AcpiExOutString ("Class Name", ACPI_CAST_PTR (char, ReferenceName)); + AcpiExOutString ("Class Name", AcpiUtGetReferenceName (ObjDesc)); AcpiExDumpReferenceObj (ObjDesc); break; @@ -500,7 +500,8 @@ AcpiExDumpObject ( if ((Next == Start) || (Next == Data)) { - AcpiOsPrintf ("\n**** Error: Object list appears to be circular linked"); + AcpiOsPrintf ( + "\n**** Error: Object list appears to be circular linked"); break; } } @@ -518,7 +519,8 @@ AcpiExDumpObject ( if (Next) { AcpiOsPrintf ("(%s %2.2X)", - AcpiUtGetObjectTypeName (Next), Next->Common.Type); + AcpiUtGetObjectTypeName (Next), + Next->AddressSpace.SpaceId); while (Next->AddressSpace.Next) { @@ -530,11 +532,13 @@ AcpiExDumpObject ( Next = Next->AddressSpace.Next; AcpiOsPrintf ("->%p(%s %2.2X)", Next, - AcpiUtGetObjectTypeName (Next), Next->Common.Type); + AcpiUtGetObjectTypeName (Next), + Next->AddressSpace.SpaceId); if ((Next == Start) || (Next == Data)) { - AcpiOsPrintf ("\n**** Error: Handler list appears to be circular linked"); + AcpiOsPrintf ( + "\n**** Error: Handler list appears to be circular linked"); break; } } @@ -568,7 +572,8 @@ AcpiExDumpObject ( if ((Next == Start) || (Next == Data)) { - AcpiOsPrintf ("\n**** Error: Region list appears to be circular linked"); + AcpiOsPrintf ( + "\n**** Error: Region list appears to be circular linked"); break; } } @@ -676,7 +681,8 @@ AcpiExDumpOperand ( { case ACPI_TYPE_LOCAL_REFERENCE: - AcpiOsPrintf ("Reference: [%s] ", AcpiUtGetReferenceName (ObjDesc)); + AcpiOsPrintf ("Reference: [%s] ", + AcpiUtGetReferenceName (ObjDesc)); switch (ObjDesc->Reference.Class) { @@ -704,7 +710,8 @@ AcpiExDumpOperand ( case ACPI_REFCLASS_NAME: - AcpiOsPrintf ("- [%4.4s]\n", ObjDesc->Reference.Node->Name.Ascii); + AcpiOsPrintf ("- [%4.4s]\n", + ObjDesc->Reference.Node->Name.Ascii); break; case ACPI_REFCLASS_ARG: @@ -735,8 +742,8 @@ AcpiExDumpOperand ( Length = 128; } - AcpiOsPrintf ("Buffer Contents: (displaying length 0x%.2X)\n", - Length); + AcpiOsPrintf ( + "Buffer Contents: (displaying length 0x%.2X)\n", Length); ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, Length); } break; @@ -762,7 +769,8 @@ AcpiExDumpOperand ( { for (Index = 0; Index < ObjDesc->Package.Count; Index++) { - AcpiExDumpOperand (ObjDesc->Package.Elements[Index], Depth+1); + AcpiExDumpOperand ( + ObjDesc->Package.Elements[Index], Depth + 1); } } break; @@ -815,7 +823,7 @@ AcpiExDumpOperand ( ObjDesc->Field.BaseByteOffset, ObjDesc->Field.StartFieldBitOffset); - AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1); + AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth + 1); break; case ACPI_TYPE_LOCAL_INDEX_FIELD: @@ -835,13 +843,13 @@ AcpiExDumpOperand ( ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n")); } else if ((ObjDesc->BufferField.BufferObj)->Common.Type != - ACPI_TYPE_BUFFER) + ACPI_TYPE_BUFFER) { AcpiOsPrintf ("*not a Buffer*\n"); } else { - AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth+1); + AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth + 1); } break; @@ -960,16 +968,16 @@ AcpiExDumpOperands ( static void AcpiExOutString ( - char *Title, - char *Value) + const char *Title, + const char *Value) { AcpiOsPrintf ("%20s : %s\n", Title, Value); } static void AcpiExOutPointer ( - char *Title, - void *Value) + const char *Title, + const void *Value) { AcpiOsPrintf ("%20s : %p\n", Title, Value); } @@ -1038,7 +1046,8 @@ AcpiExDumpReferenceObj ( { AcpiOsPrintf (" %p ", ObjDesc->Reference.Node); - Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, &RetBuf); + Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, + &RetBuf, TRUE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf (" Could not convert name to pathname\n"); @@ -1053,16 +1062,18 @@ AcpiExDumpReferenceObj ( { if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) { - AcpiOsPrintf (" Target: %p", ObjDesc->Reference.Object); + AcpiOsPrintf ("%22s %p", "Target :", + ObjDesc->Reference.Object); if (ObjDesc->Reference.Class == ACPI_REFCLASS_TABLE) { - AcpiOsPrintf (" Table Index: %X\n", ObjDesc->Reference.Value); + AcpiOsPrintf (" Table Index: %X\n", + ObjDesc->Reference.Value); } else { - AcpiOsPrintf (" Target: %p [%s]\n", ObjDesc->Reference.Object, + AcpiOsPrintf (" [%s]\n", AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) - ObjDesc->Reference.Object)->Common.Type)); + ObjDesc->Reference.Object)->Common.Type)); } } else @@ -1138,7 +1149,8 @@ AcpiExDumpPackageObj ( AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length); if (ObjDesc->Buffer.Length) { - AcpiUtDebugDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), + AcpiUtDebugDumpBuffer ( + ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); } else @@ -1154,7 +1166,8 @@ AcpiExDumpPackageObj ( for (i = 0; i < ObjDesc->Package.Count; i++) { - AcpiExDumpPackageObj (ObjDesc->Package.Elements[i], Level+1, i); + AcpiExDumpPackageObj ( + ObjDesc->Package.Elements[i], Level + 1, i); } break; @@ -1252,7 +1265,8 @@ DumpObject: ObjDesc = ObjDesc->Common.NextObject; if (ObjDesc->Common.Type > ACPI_TYPE_LOCAL_MAX) { - AcpiOsPrintf ("Secondary object is not a known object type: %2.2X\n", + AcpiOsPrintf ( + "Secondary object is not a known object type: %2.2X\n", ObjDesc->Common.Type); return_VOID; diff --git a/sys/contrib/dev/acpica/components/executer/exfield.c b/sys/contrib/dev/acpica/components/executer/exfield.c index 836a378..aa71d6e 100644 --- a/sys/contrib/dev/acpica/components/executer/exfield.c +++ b/sys/contrib/dev/acpica/components/executer/exfield.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -184,28 +184,31 @@ AcpiExReadDataFromField ( ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) { /* - * This is an SMBus, GSBus or IPMI read. We must create a buffer to hold - * the data and then directly access the region handler. + * 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 + * Note: SMBus and GSBus protocol value is passed in upper 16-bits + * of Function */ - if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + if (ObjDesc->Field.RegionObj->Region.SpaceId == + ACPI_ADR_SPACE_SMBUS) { Length = ACPI_SMBUS_BUFFER_SIZE; Function = ACPI_READ | (ObjDesc->Field.Attribute << 16); } - else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) + else if (ObjDesc->Field.RegionObj->Region.SpaceId == + ACPI_ADR_SPACE_GSBUS) { AccessorType = ObjDesc->Field.Attribute; - Length = AcpiExGetSerialAccessLength (AccessorType, - ObjDesc->Field.AccessLength); + Length = AcpiExGetSerialAccessLength ( + AccessorType, ObjDesc->Field.AccessLength); /* * Add additional 2 bytes for the GenericSerialBus data buffer: * - * 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) + * 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) */ Length += 2; Function = ACPI_READ | (AccessorType << 16); @@ -229,8 +232,8 @@ AcpiExReadDataFromField ( /* Call the region handler for the read */ Status = AcpiExAccessRegion (ObjDesc, 0, - ACPI_CAST_PTR (UINT64, BufferDesc->Buffer.Pointer), - Function); + ACPI_CAST_PTR (UINT64, BufferDesc->Buffer.Pointer), Function); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); goto Exit; } @@ -245,7 +248,9 @@ AcpiExReadDataFromField ( * * Note: Field.length is in bits. */ - Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength); + Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES ( + ObjDesc->Field.BitLength); + if (Length > AcpiGbl_IntegerByteWidth) { /* Field is too large for an Integer, create a Buffer instead */ @@ -290,8 +295,9 @@ AcpiExReadDataFromField ( /* Perform the write */ - Status = AcpiExAccessRegion (ObjDesc, 0, - (UINT64 *) Buffer, ACPI_READ); + Status = AcpiExAccessRegion ( + ObjDesc, 0, (UINT64 *) Buffer, ACPI_READ); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); if (ACPI_FAILURE (Status)) { @@ -396,42 +402,47 @@ AcpiExWriteDataToField ( ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) { /* - * 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 bi-directional; on a write, - * return data is returned in the same buffer. + * 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 bi-directional; on a + * write, return data is returned in the same buffer. * * Source must be a buffer of sufficient size: - * ACPI_SMBUS_BUFFER_SIZE, ACPI_GSBUS_BUFFER_SIZE, or ACPI_IPMI_BUFFER_SIZE. + * ACPI_SMBUS_BUFFER_SIZE, ACPI_GSBUS_BUFFER_SIZE, or + * ACPI_IPMI_BUFFER_SIZE. * - * Note: SMBus and GSBus protocol type is passed in upper 16-bits of Function + * Note: SMBus and GSBus protocol type is passed in upper 16-bits + * of Function */ if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) { ACPI_ERROR ((AE_INFO, - "SMBus/IPMI/GenericSerialBus write requires Buffer, found type %s", + "SMBus/IPMI/GenericSerialBus write requires " + "Buffer, found type %s", AcpiUtGetObjectTypeName (SourceDesc))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } - if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + if (ObjDesc->Field.RegionObj->Region.SpaceId == + ACPI_ADR_SPACE_SMBUS) { Length = ACPI_SMBUS_BUFFER_SIZE; Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16); } - else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) + else if (ObjDesc->Field.RegionObj->Region.SpaceId == + ACPI_ADR_SPACE_GSBUS) { AccessorType = ObjDesc->Field.Attribute; - Length = AcpiExGetSerialAccessLength (AccessorType, - ObjDesc->Field.AccessLength); + Length = AcpiExGetSerialAccessLength ( + AccessorType, ObjDesc->Field.AccessLength); /* * Add additional 2 bytes for the GenericSerialBus data buffer: * - * 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) + * 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) */ Length += 2; Function = ACPI_WRITE | (AccessorType << 16); @@ -445,7 +456,8 @@ AcpiExWriteDataToField ( if (SourceDesc->Buffer.Length < Length) { ACPI_ERROR ((AE_INFO, - "SMBus/IPMI/GenericSerialBus write requires Buffer of length %u, found length %u", + "SMBus/IPMI/GenericSerialBus write requires " + "Buffer of length %u, found length %u", Length, SourceDesc->Buffer.Length)); return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); @@ -460,7 +472,7 @@ AcpiExWriteDataToField ( } Buffer = BufferDesc->Buffer.Pointer; - ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, Length); + memcpy (Buffer, SourceDesc->Buffer.Pointer, Length); /* Lock entire transaction if requested */ @@ -470,8 +482,8 @@ AcpiExWriteDataToField ( * Perform the write (returns status and perhaps data in the * same buffer) */ - Status = AcpiExAccessRegion (ObjDesc, 0, - (UINT64 *) Buffer, Function); + Status = AcpiExAccessRegion ( + ObjDesc, 0, (UINT64 *) Buffer, Function); AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); *ResultDesc = BufferDesc; @@ -494,7 +506,7 @@ AcpiExWriteDataToField ( } ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "GPIO FieldWrite [FROM]: (%s:%X), Val %.8X [TO]: Pin %u Bits %u\n", + "GPIO FieldWrite [FROM]: (%s:%X), Val %.8X [TO]: Pin %u Bits %u\n", AcpiUtGetTypeName (SourceDesc->Common.Type), SourceDesc->Common.Type, (UINT32) SourceDesc->Integer.Value, ObjDesc->Field.PinNumberIndex, ObjDesc->Field.BitLength)); @@ -507,8 +519,8 @@ AcpiExWriteDataToField ( /* Perform the write */ - Status = AcpiExAccessRegion (ObjDesc, 0, - (UINT64 *) Buffer, ACPI_WRITE); + Status = AcpiExAccessRegion ( + ObjDesc, 0, (UINT64 *) Buffer, ACPI_WRITE); AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/components/executer/exfldio.c b/sys/contrib/dev/acpica/components/executer/exfldio.c index 2908da4..e928881 100644 --- a/sys/contrib/dev/acpica/components/executer/exfldio.c +++ b/sys/contrib/dev/acpica/components/executer/exfldio.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -120,7 +120,8 @@ AcpiExSetupRegion ( if (!AcpiIsValidSpaceId (SpaceId)) { - ACPI_ERROR ((AE_INFO, "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId)); + ACPI_ERROR ((AE_INFO, + "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId)); return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); } @@ -170,8 +171,8 @@ AcpiExSetupRegion ( * (Region length is specified in bytes) */ if (RgnDesc->Region.Length < - (ObjDesc->CommonField.BaseByteOffset + FieldDatumByteOffset + - ObjDesc->CommonField.AccessByteWidth)) + (ObjDesc->CommonField.BaseByteOffset + FieldDatumByteOffset + + ObjDesc->CommonField.AccessByteWidth)) { if (AcpiGbl_EnableInterpreterSlack) { @@ -198,7 +199,8 @@ AcpiExSetupRegion ( * 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)", + "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), @@ -210,7 +212,8 @@ AcpiExSetupRegion ( * 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)", + "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, @@ -300,8 +303,8 @@ AcpiExAccessRegion ( /* Invoke the appropriate AddressSpace/OpRegion handler */ Status = AcpiEvAddressSpaceDispatch (RgnDesc, ObjDesc, - Function, RegionOffset, - ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); + Function, RegionOffset, + ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); if (ACPI_FAILURE (Status)) { @@ -456,7 +459,7 @@ AcpiExFieldDatumIo ( * Copy the data from the source buffer. * Length is the field width in bytes. */ - ACPI_MEMCPY (Value, + memcpy (Value, (ObjDesc->BufferField.BufferObj)->Buffer.Pointer + ObjDesc->BufferField.BaseByteOffset + FieldDatumByteOffset, @@ -468,7 +471,7 @@ AcpiExFieldDatumIo ( * Copy the data to the target buffer. * Length is the field width in bytes. */ - ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer + + memcpy ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer + ObjDesc->BufferField.BaseByteOffset + FieldDatumByteOffset, Value, ObjDesc->CommonField.AccessByteWidth); @@ -512,8 +515,8 @@ AcpiExFieldDatumIo ( * For simple RegionFields, we just directly access the owning * Operation Region. */ - Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value, - ReadWrite); + Status = AcpiExAccessRegion ( + ObjDesc, FieldDatumByteOffset, Value, ReadWrite); break; case ACPI_TYPE_LOCAL_INDEX_FIELD: @@ -536,8 +539,7 @@ AcpiExFieldDatumIo ( FieldDatumByteOffset)); Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj, - &FieldDatumByteOffset, - sizeof (FieldDatumByteOffset)); + &FieldDatumByteOffset, sizeof (FieldDatumByteOffset)); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -550,8 +552,8 @@ AcpiExFieldDatumIo ( ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Read from Data Register\n")); - Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj, - Value, sizeof (UINT64)); + Status = AcpiExExtractFromField ( + ObjDesc->IndexField.DataObj, Value, sizeof (UINT64)); } else { @@ -561,8 +563,8 @@ AcpiExFieldDatumIo ( "Write to Data Register: Value %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (*Value))); - Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj, - Value, sizeof (UINT64)); + Status = AcpiExInsertIntoField ( + ObjDesc->IndexField.DataObj, Value, sizeof (UINT64)); } break; @@ -644,14 +646,14 @@ AcpiExWriteWithUpdateRule ( * 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) + 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); + Status = AcpiExFieldDatumIo ( + ObjDesc, FieldDatumByteOffset, &CurrentValue, ACPI_READ); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -679,13 +681,15 @@ AcpiExWriteWithUpdateRule ( ACPI_ERROR ((AE_INFO, "Unknown UpdateRule value: 0x%X", - (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK))); + (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", + "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, @@ -694,8 +698,8 @@ AcpiExWriteWithUpdateRule ( /* Write the merged value */ - Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, - &MergedValue, ACPI_WRITE); + Status = AcpiExFieldDatumIo ( + ObjDesc, FieldDatumByteOffset, &MergedValue, ACPI_WRITE); return_ACPI_STATUS (Status); } @@ -748,7 +752,7 @@ AcpiExExtractFromField ( return_ACPI_STATUS (AE_BUFFER_OVERFLOW); } - ACPI_MEMSET (Buffer, 0, BufferLength); + memset (Buffer, 0, BufferLength); AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth); /* Handle the simple case here */ @@ -765,7 +769,7 @@ AcpiExExtractFromField ( /* Use RawDatum (UINT64) to handle buffers < 64 bits */ Status = AcpiExFieldDatumIo (ObjDesc, 0, &RawDatum, ACPI_READ); - ACPI_MEMCPY (Buffer, &RawDatum, BufferLength); + memcpy (Buffer, &RawDatum, BufferLength); } return_ACPI_STATUS (Status); @@ -806,8 +810,8 @@ AcpiExExtractFromField ( /* Get next input datum from the field */ FieldOffset += ObjDesc->CommonField.AccessByteWidth; - Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, - &RawDatum, ACPI_READ); + Status = AcpiExFieldDatumIo ( + ObjDesc, FieldOffset, &RawDatum, ACPI_READ); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -835,7 +839,7 @@ AcpiExExtractFromField ( /* Write merged datum to target buffer */ - ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + memcpy (((char *) Buffer) + BufferOffset, &MergedDatum, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, BufferLength - BufferOffset)); @@ -853,7 +857,7 @@ AcpiExExtractFromField ( /* Write the last datum to the buffer */ - ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + memcpy (((char *) Buffer) + BufferOffset, &MergedDatum, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, BufferLength - BufferOffset)); @@ -904,7 +908,8 @@ AcpiExInsertIntoField ( NewBuffer = NULL; RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES ( - ObjDesc->CommonField.BitLength); + 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 @@ -926,7 +931,7 @@ AcpiExInsertIntoField ( * at Byte zero. All unused (upper) bytes of the * buffer will be 0. */ - ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, BufferLength); + memcpy ((char *) NewBuffer, (char *) Buffer, BufferLength); Buffer = NewBuffer; BufferLength = RequiredLength; } @@ -969,7 +974,7 @@ AcpiExInsertIntoField ( /* Get initial Datum from the input buffer */ - ACPI_MEMCPY (&RawDatum, Buffer, + memcpy (&RawDatum, Buffer, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, BufferLength - BufferOffset)); @@ -982,8 +987,8 @@ AcpiExInsertIntoField ( /* Write merged datum to the target field */ MergedDatum &= Mask; - Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, - MergedDatum, FieldOffset); + Status = AcpiExWriteWithUpdateRule ( + ObjDesc, Mask, MergedDatum, FieldOffset); if (ACPI_FAILURE (Status)) { goto Exit; @@ -1021,7 +1026,7 @@ AcpiExInsertIntoField ( /* Get the next input datum from the buffer */ BufferOffset += ObjDesc->CommonField.AccessByteWidth; - ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset, + memcpy (&RawDatum, ((char *) Buffer) + BufferOffset, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, BufferLength - BufferOffset)); @@ -1040,8 +1045,8 @@ AcpiExInsertIntoField ( /* Write the last datum to the field */ MergedDatum &= Mask; - Status = AcpiExWriteWithUpdateRule (ObjDesc, - Mask, MergedDatum, FieldOffset); + Status = AcpiExWriteWithUpdateRule ( + ObjDesc, Mask, MergedDatum, FieldOffset); Exit: /* Free temporary buffer if we used one */ diff --git a/sys/contrib/dev/acpica/components/executer/exmisc.c b/sys/contrib/dev/acpica/components/executer/exmisc.c index d4e1a3b..1ba30f4 100644 --- a/sys/contrib/dev/acpica/components/executer/exmisc.c +++ b/sys/contrib/dev/acpica/components/executer/exmisc.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,6 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/acinterp.h> #include <contrib/dev/acpica/include/amlcode.h> -#include <contrib/dev/acpica/include/amlresrc.h> #define _COMPONENT ACPI_EXECUTER @@ -107,9 +106,9 @@ AcpiExGetObjectReference ( default: - ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X", + ACPI_ERROR ((AE_INFO, "Invalid Reference Class 0x%2.2X", ObjDesc->Reference.Class)); - return_ACPI_STATUS (AE_AML_INTERNAL); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } break; @@ -150,275 +149,6 @@ AcpiExGetObjectReference ( /******************************************************************************* * - * 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; - ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length0); - ACPI_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); -} - - -/******************************************************************************* - * - * 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 OF THE SAME TYPE. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExDoConcatenate ( - ACPI_OPERAND_OBJECT *Operand0, - ACPI_OPERAND_OBJECT *Operand1, - ACPI_OPERAND_OBJECT **ActualReturnDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; - ACPI_OPERAND_OBJECT *ReturnDesc; - char *NewBuf; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (ExDoConcatenate); - - - /* - * Convert the second operand if necessary. The first operand - * determines the type of the second operand, (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 (Operand0->Common.Type) - { - case ACPI_TYPE_INTEGER: - - Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); - 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: 0x%X", - Operand0->Common.Type)); - Status = AE_AML_INTERNAL; - } - - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* - * 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: - * - * 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 (Operand0->Common.Type) - { - 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; - } - - NewBuf = (char *) ReturnDesc->Buffer.Pointer; - - /* Copy the first integer, LSB first */ - - ACPI_MEMCPY (NewBuf, &Operand0->Integer.Value, - AcpiGbl_IntegerByteWidth); - - /* Copy the second integer (LSB first) after the first */ - - ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth, - &LocalOperand1->Integer.Value, - AcpiGbl_IntegerByteWidth); - break; - - case ACPI_TYPE_STRING: - - /* Result of two Strings is a String */ - - ReturnDesc = AcpiUtCreateStringObject ( - ((ACPI_SIZE) Operand0->String.Length + - LocalOperand1->String.Length)); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - NewBuf = ReturnDesc->String.Pointer; - - /* Concatenate the strings */ - - ACPI_STRCPY (NewBuf, Operand0->String.Pointer); - ACPI_STRCPY (NewBuf + Operand0->String.Length, - 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; - } - - NewBuf = (char *) ReturnDesc->Buffer.Pointer; - - /* Concatenate the buffers */ - - ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, - Operand0->Buffer.Length); - ACPI_MEMCPY (NewBuf + 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 (LocalOperand1 != Operand1) - { - AcpiUtRemoveReference (LocalOperand1); - } - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * * FUNCTION: AcpiExDoMathOp * * PARAMETERS: Opcode - AML opcode @@ -635,8 +365,8 @@ AcpiExDoLogicalOp ( case ACPI_TYPE_STRING: - Status = AcpiExConvertToString (Operand1, &LocalOperand1, - ACPI_IMPLICIT_CONVERT_HEX); + Status = AcpiExConvertToString ( + Operand1, &LocalOperand1, ACPI_IMPLICIT_CONVERT_HEX); break; case ACPI_TYPE_BUFFER: @@ -712,9 +442,9 @@ AcpiExDoLogicalOp ( /* Lexicographic compare: compare the data bytes */ - Compare = ACPI_MEMCMP (Operand0->Buffer.Pointer, - LocalOperand1->Buffer.Pointer, - (Length0 > Length1) ? Length1 : Length0); + Compare = memcmp (Operand0->Buffer.Pointer, + LocalOperand1->Buffer.Pointer, + (Length0 > Length1) ? Length1 : Length0); switch (Opcode) { diff --git a/sys/contrib/dev/acpica/components/executer/exmutex.c b/sys/contrib/dev/acpica/components/executer/exmutex.c index cf82b04..989cb29 100644 --- a/sys/contrib/dev/acpica/components/executer/exmutex.c +++ b/sys/contrib/dev/acpica/components/executer/exmutex.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -209,8 +209,7 @@ AcpiExAcquireMutexObject ( } else { - Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex, - Timeout); + Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex, Timeout); } if (ACPI_FAILURE (Status)) @@ -273,33 +272,48 @@ AcpiExAcquireMutex ( } /* - * Current sync level must be less than or equal to the sync level of the - * mutex. This mechanism provides some deadlock prevention + * 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)", + "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); + 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; + 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); } @@ -395,9 +409,9 @@ AcpiExReleaseMutex ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { - ACPI_STATUS Status = AE_OK; UINT8 PreviousSyncLevel; ACPI_THREAD_STATE *OwnerThread; + ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE (ExReleaseMutex); @@ -455,7 +469,8 @@ AcpiExReleaseMutex ( if (ObjDesc->Mutex.SyncLevel != OwnerThread->CurrentSyncLevel) { ACPI_ERROR ((AE_INFO, - "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %u current %u", + "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); @@ -469,6 +484,13 @@ AcpiExReleaseMutex ( 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)) { @@ -482,6 +504,12 @@ AcpiExReleaseMutex ( 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); } @@ -512,7 +540,7 @@ AcpiExReleaseAllMutexes ( ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_FUNCTION_NAME (ExReleaseAllMutexes); + ACPI_FUNCTION_TRACE (ExReleaseAllMutexes); /* Traverse the list of owned mutexes, releasing each one */ @@ -520,14 +548,10 @@ AcpiExReleaseAllMutexes ( while (Next) { ObjDesc = Next; - Next = ObjDesc->Mutex.Next; - - ObjDesc->Mutex.Prev = NULL; - ObjDesc->Mutex.Next = NULL; - ObjDesc->Mutex.AcquisitionDepth = 0; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Force-releasing held mutex: %p\n", ObjDesc)); + "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 */ @@ -542,13 +566,20 @@ AcpiExReleaseAllMutexes ( 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; - - /* Update Thread SyncLevel (Last mutex is the important one) */ - - Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; } + + return_VOID; } diff --git a/sys/contrib/dev/acpica/components/executer/exnames.c b/sys/contrib/dev/acpica/components/executer/exnames.c index b213165..13fe83f 100644 --- a/sys/contrib/dev/acpica/components/executer/exnames.c +++ b/sys/contrib/dev/acpica/components/executer/exnames.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -160,6 +160,7 @@ AcpiExAllocateNameString ( return_PTR (NameString); } + /******************************************************************************* * * FUNCTION: AcpiExNameSegment @@ -189,8 +190,8 @@ AcpiExNameSegment ( /* - * If first character is a digit, then we know that we aren't looking at a - * valid name segment + * If first character is a digit, then we know that we aren't looking + * at a valid name segment */ CharBuf[0] = *AmlAddress; @@ -203,7 +204,7 @@ AcpiExNameSegment ( ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n")); for (Index = 0; - (Index < ACPI_NAME_SIZE) && (AcpiUtValidAcpiChar (*AmlAddress, 0)); + (Index < ACPI_NAME_SIZE) && (AcpiUtValidNameChar (*AmlAddress, 0)); Index++) { CharBuf[Index] = *AmlAddress++; @@ -221,7 +222,7 @@ AcpiExNameSegment ( if (NameString) { - ACPI_STRCAT (NameString, CharBuf); + strcat (NameString, CharBuf); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Appended to - %s\n", NameString)); } @@ -394,7 +395,8 @@ AcpiExGetNameString ( AmlAddress++; NumSegments = *AmlAddress; - NameString = AcpiExAllocateNameString (PrefixCount, NumSegments); + NameString = AcpiExAllocateNameString ( + PrefixCount, NumSegments); if (!NameString) { Status = AE_NO_MEMORY; diff --git a/sys/contrib/dev/acpica/components/executer/exoparg1.c b/sys/contrib/dev/acpica/components/executer/exoparg1.c index dc35c171..5028fa2 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg1.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg1.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -331,7 +331,7 @@ AcpiExOpcode_1A_1T_1R ( * endian unsigned value, so this boundary condition is valid. */ for (Temp32 = 0; ReturnDesc->Integer.Value && - Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) { ReturnDesc->Integer.Value >>= 1; } @@ -348,7 +348,7 @@ AcpiExOpcode_1A_1T_1R ( * endian unsigned value, so this boundary condition is valid. */ for (Temp32 = 0; ReturnDesc->Integer.Value && - Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) { ReturnDesc->Integer.Value <<= 1; } @@ -454,7 +454,7 @@ AcpiExOpcode_1A_1T_1R ( /* Get the object reference, store it, and remove our reference */ Status = AcpiExGetObjectReference (Operand[0], - &ReturnDesc2, WalkState); + &ReturnDesc2, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -509,28 +509,30 @@ AcpiExOpcode_1A_1T_1R ( */ case AML_COPY_OP: /* Copy (Source, Target) */ - Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc, - WalkState); + Status = AcpiUtCopyIobjectToIobject ( + Operand[0], &ReturnDesc, WalkState); break; case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */ - Status = AcpiExConvertToString (Operand[0], &ReturnDesc, - ACPI_EXPLICIT_CONVERT_DECIMAL); + 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_HEXSTRING_OP: /* ToHexString (Data, Result) */ - Status = AcpiExConvertToString (Operand[0], &ReturnDesc, - ACPI_EXPLICIT_CONVERT_HEX); + 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; @@ -541,17 +543,19 @@ AcpiExOpcode_1A_1T_1R ( if (ReturnDesc == Operand[0]) { /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); } break; case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */ - Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, - ACPI_ANY_BASE); + Status = AcpiExConvertToInteger ( + Operand[0], &ReturnDesc, ACPI_ANY_BASE); if (ReturnDesc == Operand[0]) { /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); } break; @@ -702,11 +706,11 @@ AcpiExOpcode_1A_0T_1R ( */ if (WalkState->Opcode == AML_INCREMENT_OP) { - ReturnDesc->Integer.Value = TempDesc->Integer.Value +1; + ReturnDesc->Integer.Value = TempDesc->Integer.Value + 1; } else { - ReturnDesc->Integer.Value = TempDesc->Integer.Value -1; + ReturnDesc->Integer.Value = TempDesc->Integer.Value - 1; } /* Finished with this Integer object */ @@ -720,7 +724,7 @@ AcpiExOpcode_1A_0T_1R ( Status = AcpiExStore (ReturnDesc, Operand[0], WalkState); break; - case AML_TYPE_OP: /* ObjectType (SourceObject) */ + 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 @@ -754,8 +758,8 @@ AcpiExOpcode_1A_0T_1R ( /* Get the base object */ - Status = AcpiExResolveMultiple (WalkState, - Operand[0], &Type, &TempDesc); + Status = AcpiExResolveMultiple ( + WalkState, Operand[0], &Type, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -801,8 +805,10 @@ AcpiExOpcode_1A_0T_1R ( default: ACPI_ERROR ((AE_INFO, - "Operand must be Buffer/Integer/String/Package - found type %s", + "Operand must be Buffer/Integer/String/Package" + " - found type %s", AcpiUtGetTypeName (Type))); + Status = AE_AML_OPERAND_TYPE; goto Cleanup; } @@ -827,7 +833,8 @@ AcpiExOpcode_1A_0T_1R ( case AML_REF_OF_OP: /* RefOf (SourceObject) */ - Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState); + Status = AcpiExGetObjectReference ( + Operand[0], &ReturnDesc, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -874,9 +881,9 @@ AcpiExOpcode_1A_0T_1R ( /* Set Operand[0] to the value of the local/arg */ Status = AcpiDsMethodDataGetValue ( - Operand[0]->Reference.Class, - Operand[0]->Reference.Value, - WalkState, &TempDesc); + Operand[0]->Reference.Class, + Operand[0]->Reference.Value, + WalkState, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -930,19 +937,19 @@ AcpiExOpcode_1A_0T_1R ( * Field, so we need to resolve the node to a value. */ Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node, - Operand[0]->String.Pointer, - ACPI_NS_SEARCH_PARENT, - ACPI_CAST_INDIRECT_PTR ( - ACPI_NAMESPACE_NODE, &ReturnDesc)); + 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); + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc), + WalkState); goto Cleanup; } } @@ -958,7 +965,7 @@ AcpiExOpcode_1A_0T_1R ( * dereferenced above. */ ReturnDesc = AcpiNsGetAttachedObject ( - (ACPI_NAMESPACE_NODE *) Operand[0]); + (ACPI_NAMESPACE_NODE *) Operand[0]); AcpiUtAddReference (ReturnDesc); } else @@ -1025,6 +1032,7 @@ AcpiExOpcode_1A_0T_1R ( 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; } @@ -1055,8 +1063,8 @@ AcpiExOpcode_1A_0T_1R ( case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - Status = AcpiExReadDataFromField (WalkState, - ReturnDesc, &TempDesc); + Status = AcpiExReadDataFromField ( + WalkState, ReturnDesc, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -1091,6 +1099,7 @@ AcpiExOpcode_1A_0T_1R ( ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; goto Cleanup; } diff --git a/sys/contrib/dev/acpica/components/executer/exoparg2.c b/sys/contrib/dev/acpica/components/executer/exoparg2.c index da1eb6c..f223c8d 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg2.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg2.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -203,10 +203,11 @@ AcpiExOpcode_2A_2T_1R ( /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */ - Status = AcpiUtDivide (Operand[0]->Integer.Value, - Operand[1]->Integer.Value, - &ReturnDesc1->Integer.Value, - &ReturnDesc2->Integer.Value); + Status = AcpiUtDivide ( + Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + &ReturnDesc1->Integer.Value, + &ReturnDesc2->Integer.Value); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -217,6 +218,7 @@ AcpiExOpcode_2A_2T_1R ( ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; goto Cleanup; } @@ -301,9 +303,10 @@ AcpiExOpcode_2A_1T_1R ( goto Cleanup; } - ReturnDesc->Integer.Value = AcpiExDoMathOp (WalkState->Opcode, - Operand[0]->Integer.Value, - Operand[1]->Integer.Value); + ReturnDesc->Integer.Value = AcpiExDoMathOp ( + WalkState->Opcode, + Operand[0]->Integer.Value, + Operand[1]->Integer.Value); goto StoreResultToTarget; } @@ -320,16 +323,17 @@ AcpiExOpcode_2A_1T_1R ( /* ReturnDesc will contain the remainder */ - Status = AcpiUtDivide (Operand[0]->Integer.Value, - Operand[1]->Integer.Value, - NULL, - &ReturnDesc->Integer.Value); + Status = AcpiUtDivide ( + Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + NULL, + &ReturnDesc->Integer.Value); break; case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ - Status = AcpiExDoConcatenate (Operand[0], Operand[1], - &ReturnDesc, WalkState); + Status = AcpiExDoConcatenate ( + Operand[0], Operand[1], &ReturnDesc, WalkState); break; case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */ @@ -368,7 +372,7 @@ AcpiExOpcode_2A_1T_1R ( * Copy the raw buffer data with no transform. * (NULL terminated already) */ - ACPI_MEMCPY (ReturnDesc->String.Pointer, + memcpy (ReturnDesc->String.Pointer, Operand[0]->Buffer.Pointer, Length); break; @@ -376,8 +380,8 @@ AcpiExOpcode_2A_1T_1R ( /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */ - Status = AcpiExConcatTemplate (Operand[0], Operand[1], - &ReturnDesc, WalkState); + Status = AcpiExConcatTemplate ( + Operand[0], Operand[1], &ReturnDesc, WalkState); break; case AML_INDEX_OP: /* Index (Source Index Result) */ @@ -412,6 +416,8 @@ AcpiExOpcode_2A_1T_1R ( } ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + ReturnDesc->Reference.IndexPointer = + &(Operand[0]->Buffer.Pointer [Index]); break; case ACPI_TYPE_BUFFER: @@ -423,6 +429,8 @@ AcpiExOpcode_2A_1T_1R ( } ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + ReturnDesc->Reference.IndexPointer = + &(Operand[0]->Buffer.Pointer [Index]); break; case ACPI_TYPE_PACKAGE: @@ -434,7 +442,8 @@ AcpiExOpcode_2A_1T_1R ( } ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; - ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index]; + ReturnDesc->Reference.Where = + &Operand[0]->Package.Elements [Index]; break; default: @@ -555,8 +564,8 @@ AcpiExOpcode_2A_0T_1R ( /* LogicalOp (Operand0, Operand1) */ Status = AcpiExDoLogicalNumericOp (WalkState->Opcode, - Operand[0]->Integer.Value, Operand[1]->Integer.Value, - &LogicalResult); + Operand[0]->Integer.Value, Operand[1]->Integer.Value, + &LogicalResult); goto StoreLogicalResult; } else if (WalkState->OpInfo->Flags & AML_LOGICAL) @@ -564,7 +573,7 @@ AcpiExOpcode_2A_0T_1R ( /* LogicalOp (Operand0, Operand1) */ Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0], - Operand[1], &LogicalResult); + Operand[1], &LogicalResult); goto StoreLogicalResult; } @@ -595,6 +604,7 @@ AcpiExOpcode_2A_0T_1R ( ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; goto Cleanup; } diff --git a/sys/contrib/dev/acpica/components/executer/exoparg3.c b/sys/contrib/dev/acpica/components/executer/exoparg3.c index da873c3..8be4d59 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg3.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg3.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -105,7 +105,8 @@ AcpiExOpcode_3A_0T_0R ( case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", + "FatalOp: Type %X Code %X Arg %X " + "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", (UINT32) Operand[0]->Integer.Value, (UINT32) Operand[1]->Integer.Value, (UINT32) Operand[2]->Integer.Value)); @@ -113,8 +114,8 @@ AcpiExOpcode_3A_0T_0R ( 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->Type = (UINT32) Operand[0]->Integer.Value; + Fatal->Code = (UINT32) Operand[1]->Integer.Value; Fatal->Argument = (UINT32) Operand[2]->Integer.Value; } @@ -133,8 +134,10 @@ AcpiExOpcode_3A_0T_0R ( * 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. + * 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; @@ -142,6 +145,7 @@ AcpiExOpcode_3A_0T_0R ( ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; goto Cleanup; } @@ -189,7 +193,7 @@ AcpiExOpcode_3A_1T_1R ( * either a String or a Buffer, so just use its type. */ ReturnDesc = AcpiUtCreateInternalObject ( - (Operand[0])->Common.Type); + (Operand[0])->Common.Type); if (!ReturnDesc) { Status = AE_NO_MEMORY; @@ -214,8 +218,8 @@ AcpiExOpcode_3A_1T_1R ( else if ((Index + Length) > Operand[0]->String.Length) { - Length = (ACPI_SIZE) Operand[0]->String.Length - - (ACPI_SIZE) Index; + Length = + (ACPI_SIZE) Operand[0]->String.Length - (ACPI_SIZE) Index; } /* Strings always have a sub-pointer, not so for buffers */ @@ -261,8 +265,8 @@ AcpiExOpcode_3A_1T_1R ( { /* We have a buffer, copy the portion requested */ - ACPI_MEMCPY (Buffer, Operand[0]->String.Pointer + Index, - Length); + memcpy (Buffer, + Operand[0]->String.Pointer + Index, Length); } /* Set the length of the new String/Buffer */ @@ -279,6 +283,7 @@ AcpiExOpcode_3A_1T_1R ( ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; goto Cleanup; } @@ -296,12 +301,12 @@ Cleanup: AcpiUtRemoveReference (ReturnDesc); WalkState->ResultObj = NULL; } - - /* Set the return object and exit */ - else { + /* Set the return object and exit */ + WalkState->ResultObj = ReturnDesc; } + return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/components/executer/exoparg6.c b/sys/contrib/dev/acpica/components/executer/exoparg6.c index 4ff355c..09f0336 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg6.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg6.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -132,8 +132,8 @@ AcpiExDoMatch ( * True if equal: (P[i] == M) * Change to: (M == P[i]) */ - Status = AcpiExDoLogicalOp (AML_LEQUAL_OP, MatchObj, PackageObj, - &LogicalResult); + Status = AcpiExDoLogicalOp ( + AML_LEQUAL_OP, MatchObj, PackageObj, &LogicalResult); if (ACPI_FAILURE (Status)) { return (FALSE); @@ -145,8 +145,8 @@ AcpiExDoMatch ( * 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_LLESS_OP, MatchObj, PackageObj, - &LogicalResult); + Status = AcpiExDoLogicalOp ( + AML_LLESS_OP, MatchObj, PackageObj, &LogicalResult); if (ACPI_FAILURE (Status)) { return (FALSE); @@ -159,8 +159,8 @@ AcpiExDoMatch ( * True if less than: (P[i] < M) * Change to: (M > P[i]) */ - Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, - &LogicalResult); + Status = AcpiExDoLogicalOp ( + AML_LGREATER_OP, MatchObj, PackageObj, &LogicalResult); if (ACPI_FAILURE (Status)) { return (FALSE); @@ -172,8 +172,8 @@ AcpiExDoMatch ( * 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_LGREATER_OP, MatchObj, PackageObj, - &LogicalResult); + Status = AcpiExDoLogicalOp ( + AML_LGREATER_OP, MatchObj, PackageObj, &LogicalResult); if (ACPI_FAILURE (Status)) { return (FALSE); @@ -186,8 +186,8 @@ AcpiExDoMatch ( * True if greater than: (P[i] > M) * Change to: (M < P[i]) */ - Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, - &LogicalResult); + Status = AcpiExDoLogicalOp ( + AML_LLESS_OP, MatchObj, PackageObj, &LogicalResult); if (ACPI_FAILURE (Status)) { return (FALSE); @@ -303,13 +303,13 @@ AcpiExOpcode_6A_0T_1R ( * non-match. */ if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value, - ThisElement, Operand[2])) + ThisElement, Operand[2])) { continue; } if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value, - ThisElement, Operand[4])) + ThisElement, Operand[4])) { continue; } @@ -330,6 +330,7 @@ AcpiExOpcode_6A_0T_1R ( ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; goto Cleanup; } diff --git a/sys/contrib/dev/acpica/components/executer/exprep.c b/sys/contrib/dev/acpica/components/executer/exprep.c index c949d8a..9f59df3 100644 --- a/sys/contrib/dev/acpica/components/executer/exprep.c +++ b/sys/contrib/dev/acpica/components/executer/exprep.c @@ -1,11 +1,11 @@ /****************************************************************************** * - * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities + * Module Name: exprep - ACPI AML field prep utilities * *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,6 +69,7 @@ AcpiExGenerateAccess ( UINT32 FieldBitLength, UINT32 RegionLength); + /******************************************************************************* * * FUNCTION: AcpiExGenerateAccess @@ -113,10 +114,13 @@ AcpiExGenerateAccess ( /* 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; + 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", @@ -141,7 +145,8 @@ AcpiExGenerateAccess ( * are done. (This does not optimize for the perfectly aligned * case yet). */ - if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength) + if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= + RegionLength) { FieldStartOffset = ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) / @@ -165,7 +170,8 @@ AcpiExGenerateAccess ( if (Accesses <= 1) { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Entire field can be accessed with one operation of size %u\n", + "Entire field can be accessed " + "with one operation of size %u\n", AccessByteWidth)); return_VALUE (AccessByteWidth); } @@ -176,14 +182,15 @@ AcpiExGenerateAccess ( */ if (Accesses < MinimumAccesses) { - MinimumAccesses = Accesses; + MinimumAccesses = Accesses; MinimumAccessWidth = AccessByteWidth; } } else { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "AccessWidth %u end is NOT within region\n", AccessByteWidth)); + "AccessWidth %u end is NOT within region\n", + AccessByteWidth)); if (AccessByteWidth == 1) { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, @@ -211,6 +218,7 @@ AcpiExGenerateAccess ( */ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Cannot access field in one operation, using width 8\n")); + return_VALUE (8); } #endif /* ACPI_UNDER_DEVELOPMENT */ @@ -295,6 +303,7 @@ AcpiExDecodeFieldAccess ( ACPI_ERROR ((AE_INFO, "Unknown field access type 0x%X", Access)); + return_UINT32 (0); } @@ -374,8 +383,8 @@ AcpiExPrepCommonFieldObject ( * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is * the same (equivalent) as the ByteAlignment. */ - AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags, - &ByteAlignment); + AccessBitWidth = AcpiExDecodeFieldAccess ( + ObjDesc, FieldFlags, &ByteAlignment); if (!AccessBitWidth) { return_ACPI_STATUS (AE_AML_OPERAND_VALUE); @@ -471,8 +480,8 @@ AcpiExPrepFieldValue ( ObjDesc->CommonField.Node = Info->FieldNode; Status = AcpiExPrepCommonFieldObject (ObjDesc, - Info->FieldFlags, Info->Attribute, - Info->FieldBitPosition, Info->FieldBitLength); + Info->FieldFlags, Info->Attribute, + Info->FieldBitPosition, Info->FieldBitLength); if (ACPI_FAILURE (Status)) { AcpiUtDeleteObjectDesc (ObjDesc); @@ -504,8 +513,10 @@ AcpiExPrepFieldValue ( } } - ObjDesc->Field.ResourceBuffer = SecondDesc->Buffer.Pointer; - ObjDesc->Field.ResourceLength = (UINT16) SecondDesc->Buffer.Length; + ObjDesc->Field.ResourceBuffer = + SecondDesc->Buffer.Pointer; + ObjDesc->Field.ResourceLength = + (UINT16) SecondDesc->Buffer.Length; } else if (Info->ResourceBuffer) { @@ -527,7 +538,8 @@ AcpiExPrepFieldValue ( if (AccessByteWidth < 256) { - ObjDesc->CommonField.AccessByteWidth = (UINT8) AccessByteWidth; + ObjDesc->CommonField.AccessByteWidth = + (UINT8) AccessByteWidth; } } @@ -537,8 +549,10 @@ AcpiExPrepFieldValue ( 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)); + ObjDesc->Field.StartFieldBitOffset, + ObjDesc->Field.BaseByteOffset, + ObjDesc->Field.AccessByteWidth, + ObjDesc->Field.RegionObj)); break; case ACPI_TYPE_LOCAL_BANK_FIELD: @@ -618,7 +632,8 @@ AcpiExPrepFieldValue ( ObjDesc->IndexField.AccessByteWidth); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", + "IndexField: BitOff %X, Off %X, Value %X, " + "Gran %X, Index %p, Data %p\n", ObjDesc->IndexField.StartFieldBitOffset, ObjDesc->IndexField.BaseByteOffset, ObjDesc->IndexField.Value, @@ -638,10 +653,11 @@ AcpiExPrepFieldValue ( * Store the constructed descriptor (ObjDesc) into the parent Node, * preserving the current type of that NamedObj. */ - Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc, - AcpiNsGetType (Info->FieldNode)); + Status = AcpiNsAttachObject ( + Info->FieldNode, ObjDesc, AcpiNsGetType (Info->FieldNode)); - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n", + 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 */ diff --git a/sys/contrib/dev/acpica/components/executer/exregion.c b/sys/contrib/dev/acpica/components/executer/exregion.c index 59b4612..6f44915 100644 --- a/sys/contrib/dev/acpica/components/executer/exregion.c +++ b/sys/contrib/dev/acpica/components/executer/exregion.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -417,7 +417,8 @@ AcpiExPciConfigSpaceHandler ( 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", + "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)); @@ -426,14 +427,14 @@ AcpiExPciConfigSpaceHandler ( case ACPI_READ: *Value = 0; - Status = AcpiOsReadPciConfiguration (PciId, PciRegister, - Value, BitWidth); + Status = AcpiOsReadPciConfiguration ( + PciId, PciRegister, Value, BitWidth); break; case ACPI_WRITE: - Status = AcpiOsWritePciConfiguration (PciId, PciRegister, - *Value, BitWidth); + Status = AcpiOsWritePciConfiguration ( + PciId, PciRegister, *Value, BitWidth); break; default: @@ -558,13 +559,13 @@ AcpiExDataTableSpaceHandler ( { case ACPI_READ: - ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address), + memcpy (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address), ACPI_DIV_8 (BitWidth)); break; case ACPI_WRITE: - ACPI_MEMCPY (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value), + memcpy (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value), ACPI_DIV_8 (BitWidth)); break; diff --git a/sys/contrib/dev/acpica/components/executer/exresnte.c b/sys/contrib/dev/acpica/components/executer/exresnte.c index 99b64c2..3e878f6 100644 --- a/sys/contrib/dev/acpica/components/executer/exresnte.c +++ b/sys/contrib/dev/acpica/components/executer/exresnte.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -98,9 +98,9 @@ AcpiExResolveNodeToValue ( * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the * object that is attached to the Node. */ - Node = *ObjectPtr; + Node = *ObjectPtr; SourceDesc = AcpiNsGetAttachedObject (Node); - EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); + EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n", Node, SourceDesc, AcpiUtGetTypeName (EntryType))); @@ -110,15 +110,15 @@ AcpiExResolveNodeToValue ( { /* There is always exactly one level of indirection */ - Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); SourceDesc = AcpiNsGetAttachedObject (Node); - EntryType = AcpiNsGetType ((ACPI_HANDLE) 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 the Node + * 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. */ @@ -134,7 +134,7 @@ AcpiExResolveNodeToValue ( { ACPI_ERROR ((AE_INFO, "No object attached to node [%4.4s] %p", Node->Name.Ascii, Node)); - return_ACPI_STATUS (AE_AML_NO_OPERAND); + return_ACPI_STATUS (AE_AML_UNINITIALIZED_NODE); } /* diff --git a/sys/contrib/dev/acpica/components/executer/exresolv.c b/sys/contrib/dev/acpica/components/executer/exresolv.c index 32862a9..75c65d6 100644 --- a/sys/contrib/dev/acpica/components/executer/exresolv.c +++ b/sys/contrib/dev/acpica/components/executer/exresolv.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -119,8 +119,8 @@ AcpiExResolveToValue ( if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED) { Status = AcpiExResolveNodeToValue ( - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), - WalkState); + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), + WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -179,7 +179,7 @@ AcpiExResolveObjectToValue ( * Note: this increments the local's object reference count */ Status = AcpiDsMethodDataGetValue (RefType, - StackDesc->Reference.Value, WalkState, &ObjDesc); + StackDesc->Reference.Value, WalkState, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -225,7 +225,6 @@ AcpiExResolveObjectToValue ( * (i.e., dereference the package index) * Delete the ref object, increment the returned object */ - AcpiUtRemoveReference (StackDesc); AcpiUtAddReference (ObjDesc); *StackPtr = ObjDesc; } @@ -236,7 +235,8 @@ AcpiExResolveObjectToValue ( * the package, can't dereference it */ ACPI_ERROR ((AE_INFO, - "Attempt to dereference an Index to NULL package element Idx=%p", + "Attempt to dereference an Index to " + "NULL package element Idx=%p", StackDesc)); Status = AE_AML_UNINITIALIZED_ELEMENT; } @@ -287,7 +287,8 @@ AcpiExResolveObjectToValue ( default: ACPI_ERROR ((AE_INFO, - "Unknown Reference type 0x%X in %p", RefType, StackDesc)); + "Unknown Reference type 0x%X in %p", + RefType, StackDesc)); Status = AE_AML_INTERNAL; break; } @@ -308,7 +309,8 @@ AcpiExResolveObjectToValue ( case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "FieldRead SourceDesc=%p Type=%X\n", StackDesc, StackDesc->Common.Type)); Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc); @@ -351,8 +353,8 @@ AcpiExResolveMultiple ( ACPI_OBJECT_TYPE *ReturnType, ACPI_OPERAND_OBJECT **ReturnDesc) { - ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand; - ACPI_NAMESPACE_NODE *Node; + 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; @@ -372,14 +374,23 @@ AcpiExResolveMultiple ( case ACPI_DESC_TYPE_NAMED: Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; - ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + 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); + ObjDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) ObjDesc); + } + + if (!ObjDesc) + { + ACPI_ERROR ((AE_INFO, + "[%4.4s] Node is unresolved or uninitialized", + AcpiUtGetNodeName (Node))); + return_ACPI_STATUS (AE_AML_UNINITIALIZED_NODE); } break; @@ -485,7 +496,7 @@ AcpiExResolveMultiple ( if (ReturnDesc) { Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class, - ObjDesc->Reference.Value, WalkState, &ObjDesc); + ObjDesc->Reference.Value, WalkState, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -495,7 +506,7 @@ AcpiExResolveMultiple ( else { Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class, - ObjDesc->Reference.Value, WalkState, &Node); + ObjDesc->Reference.Value, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -520,7 +531,8 @@ AcpiExResolveMultiple ( default: ACPI_ERROR ((AE_INFO, - "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class)); + "Unknown Reference Class 0x%2.2X", + ObjDesc->Reference.Class)); return_ACPI_STATUS (AE_AML_INTERNAL); } } diff --git a/sys/contrib/dev/acpica/components/executer/exresop.c b/sys/contrib/dev/acpica/components/executer/exresop.c index 5171f56..7f7425f 100644 --- a/sys/contrib/dev/acpica/components/executer/exresop.c +++ b/sys/contrib/dev/acpica/components/executer/exresop.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -99,7 +99,8 @@ AcpiExCheckObjectType ( * specification, a store to a constant is a noop.) */ if ((ThisType == ACPI_TYPE_INTEGER) && - (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT)) + (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & + AOPOBJ_AML_CONSTANT)) { return (AE_OK); } @@ -216,7 +217,8 @@ AcpiExResolveOperands ( */ if (ObjectType == ACPI_TYPE_LOCAL_ALIAS) { - ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + ObjDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) ObjDesc); *StackPtr = ObjDesc; ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; } @@ -297,7 +299,8 @@ AcpiExResolveOperands ( { case ARGI_REF_OR_STRING: /* Can be a String or Reference */ - if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) && + if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == + ACPI_DESC_TYPE_OPERAND) && (ObjDesc->Common.Type == ACPI_TYPE_STRING)) { /* @@ -320,6 +323,8 @@ AcpiExResolveOperands ( 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 @@ -329,8 +334,8 @@ AcpiExResolveOperands ( goto NextOperand; } - Status = AcpiExCheckObjectType (ACPI_TYPE_LOCAL_REFERENCE, - ObjectType, ObjDesc); + Status = AcpiExCheckObjectType ( + ACPI_TYPE_LOCAL_REFERENCE, ObjectType, ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -481,8 +486,8 @@ AcpiExResolveOperands ( * But we can implicitly convert from a BUFFER or INTEGER * Aka - "Implicit Source Operand Conversion" */ - Status = AcpiExConvertToString (ObjDesc, StackPtr, - ACPI_IMPLICIT_CONVERT_HEX); + Status = AcpiExConvertToString ( + ObjDesc, StackPtr, ACPI_IMPLICIT_CONVERT_HEX); if (ACPI_FAILURE (Status)) { if (Status == AE_TYPE) @@ -615,8 +620,10 @@ AcpiExResolveOperands ( 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) */ - + /* + * Need an operand of type REGION or a BUFFER + * (which could be a resolved region field) + */ switch (ObjDesc->Common.Type) { case ACPI_TYPE_BUFFER: @@ -660,9 +667,9 @@ AcpiExResolveOperands ( 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. + * Enable original behavior of Store(), allowing any + * and all objects as the source operand. The ACPI + * spec does not allow this, however. */ break; } @@ -675,7 +682,8 @@ AcpiExResolveOperands ( } ACPI_ERROR ((AE_INFO, - "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p", + "Needed Integer/Buffer/String/Package/Ref/Ddb]" + ", found [%s] %p", AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -697,8 +705,8 @@ AcpiExResolveOperands ( * Make sure that the original object was resolved to the * required object type (Simple cases only). */ - Status = AcpiExCheckObjectType (TypeNeeded, - (*StackPtr)->Common.Type, *StackPtr); + Status = AcpiExCheckObjectType ( + TypeNeeded, (*StackPtr)->Common.Type, *StackPtr); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/executer/exstore.c b/sys/contrib/dev/acpica/components/executer/exstore.c index e14ab94..eb474a9 100644 --- a/sys/contrib/dev/acpica/components/executer/exstore.c +++ b/sys/contrib/dev/acpica/components/executer/exstore.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -117,8 +117,8 @@ AcpiExStore ( * Storing an object into a Named node. */ Status = AcpiExStoreObjectToNode (SourceDesc, - (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, - ACPI_IMPLICIT_CONVERSION); + (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, + ACPI_IMPLICIT_CONVERSION); return_ACPI_STATUS (Status); } @@ -147,7 +147,7 @@ AcpiExStore ( /* Destination is not a Reference object */ ACPI_ERROR ((AE_INFO, - "Target is not a Reference or Constant object - %s [%p]", + "Target is not a Reference or Constant object - [%s] %p", AcpiUtGetObjectTypeName (DestDesc), DestDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -168,8 +168,8 @@ AcpiExStore ( /* Storing an object into a Name "container" */ Status = AcpiExStoreObjectToNode (SourceDesc, - RefDesc->Reference.Object, - WalkState, ACPI_IMPLICIT_CONVERSION); + RefDesc->Reference.Object, + WalkState, ACPI_IMPLICIT_CONVERSION); break; case ACPI_REFCLASS_INDEX: @@ -185,7 +185,7 @@ AcpiExStore ( /* Store to a method local/arg */ Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class, - RefDesc->Reference.Value, SourceDesc, WalkState); + RefDesc->Reference.Value, SourceDesc, WalkState); break; case ACPI_REFCLASS_DEBUG: @@ -194,7 +194,7 @@ AcpiExStore ( * displayed and otherwise has no effect -- see ACPI Specification */ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "**** Write to Debug Object: Object %p %s ****:\n\n", + "**** Write to Debug Object: Object %p [%s] ****:\n\n", SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); ACPI_DEBUG_OBJECT (SourceDesc, 0, 0); @@ -274,7 +274,8 @@ AcpiExStoreObjectToIndex ( { /* Normal object, copy it */ - Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); + Status = AcpiUtCopyIobjectToIobject ( + SourceDesc, &NewDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -356,7 +357,7 @@ AcpiExStoreObjectToIndex ( /* All other types are invalid */ ACPI_ERROR ((AE_INFO, - "Source must be Integer/Buffer/String type, not %s", + "Source must be type [Integer/Buffer/String], found [%s]", AcpiUtGetObjectTypeName (SourceDesc))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } @@ -368,8 +369,8 @@ AcpiExStoreObjectToIndex ( default: ACPI_ERROR ((AE_INFO, - "Target is not a Package or BufferField")); - Status = AE_AML_OPERAND_TYPE; + "Target is not of type [Package/BufferField]")); + Status = AE_AML_TARGET_TYPE; break; } @@ -390,20 +391,20 @@ AcpiExStoreObjectToIndex ( * * 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. + * 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. + * 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. + * 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. + * Assumes parameters are already validated. * ******************************************************************************/ @@ -428,9 +429,75 @@ AcpiExStoreObjectToNode ( TargetType = AcpiNsGetType (Node); TargetDesc = AcpiNsGetAttachedObject (Node); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p (%s) to node %p (%s)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p [%s] to node %p [%s]\n", SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), - Node, AcpiUtGetTypeName (TargetType))); + Node, AcpiUtGetTypeName (TargetType))); + + /* Only limited target types possible for everything except CopyObject */ + + if (WalkState->Opcode != AML_COPY_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; + } + + /* 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 @@ -446,13 +513,13 @@ AcpiExStoreObjectToNode ( switch (TargetType) { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: /* * 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_OP) || !ImplicitConversion) @@ -462,8 +529,7 @@ AcpiExStoreObjectToNode ( * an implicit conversion, as per the ACPI specification. * A direct store is performed instead. */ - Status = AcpiExStoreDirectToNode (SourceDesc, Node, - WalkState); + Status = AcpiExStoreDirectToNode (SourceDesc, Node, WalkState); break; } @@ -487,11 +553,11 @@ AcpiExStoreObjectToNode ( * store has been performed such that the node/object type * has been changed. */ - Status = AcpiNsAttachObject (Node, NewDesc, - NewDesc->Common.Type); + Status = AcpiNsAttachObject ( + Node, NewDesc, NewDesc->Common.Type); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Store %s into %s via Convert/Attach\n", + "Store type [%s] into [%s] via Convert/Attach\n", AcpiUtGetObjectTypeName (SourceDesc), AcpiUtGetObjectTypeName (NewDesc))); } @@ -513,18 +579,14 @@ AcpiExStoreObjectToNode ( default: /* - * No conversions for all other types. Directly store a copy of - * the source object. This is the ACPI spec-defined behavior for - * the CopyObject operator. + * CopyObject operator: No conversions for all other types. + * Instead, directly store a copy of the source object. * - * NOTE: For the Store operator, this is a departure from the - * ACPI spec, which states "If conversion is impossible, abort - * the running control method". Instead, this code implements - * "If conversion is impossible, treat the Store operation as - * a CopyObject". + * 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); + Status = AcpiExStoreDirectToNode (SourceDesc, Node, WalkState); break; } diff --git a/sys/contrib/dev/acpica/components/executer/exstoren.c b/sys/contrib/dev/acpica/components/executer/exstoren.c index cc56fbd..25a499b86 100644 --- a/sys/contrib/dev/acpica/components/executer/exstoren.c +++ b/sys/contrib/dev/acpica/components/executer/exstoren.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -124,14 +124,15 @@ AcpiExResolveObject ( (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))) + (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)", + "Cannot assign type [%s] to [%s] (must be type Int/Str/Buf)", AcpiUtGetObjectTypeName (SourceDesc), AcpiUtGetTypeName (TargetType))); + Status = AE_AML_OPERAND_TYPE; } break; @@ -232,7 +233,7 @@ AcpiExStoreObjectToObject ( * converted object. */ Status = AcpiExConvertToTargetType (DestDesc->Common.Type, - SourceDesc, &ActualSrcDesc, WalkState); + SourceDesc, &ActualSrcDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -284,7 +285,7 @@ AcpiExStoreObjectToObject ( /* * All other types come here. */ - ACPI_WARNING ((AE_INFO, "Store into type %s not implemented", + ACPI_WARNING ((AE_INFO, "Store into type [%s] not implemented", AcpiUtGetObjectTypeName (DestDesc))); Status = AE_NOT_IMPLEMENTED; diff --git a/sys/contrib/dev/acpica/components/executer/exstorob.c b/sys/contrib/dev/acpica/components/executer/exstorob.c index c238310..981e261 100644 --- a/sys/contrib/dev/acpica/components/executer/exstorob.c +++ b/sys/contrib/dev/acpica/components/executer/exstorob.c @@ -1,11 +1,11 @@ /****************************************************************************** * - * Module Name: exstorob - AML Interpreter object store support, store to object + * Module Name: exstorob - AML object store support, store to object * *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -109,8 +109,8 @@ AcpiExStoreBufferToBuffer ( { /* Clear existing buffer and copy in the new one */ - ACPI_MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length); - ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length); + memset (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length); + memcpy (TargetDesc->Buffer.Pointer, Buffer, Length); #ifdef ACPI_OBSOLETE_BEHAVIOR /* @@ -139,7 +139,7 @@ AcpiExStoreBufferToBuffer ( { /* Truncate the source, copy only what will fit */ - ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, + memcpy (TargetDesc->Buffer.Pointer, Buffer, TargetDesc->Buffer.Length); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, @@ -203,9 +203,9 @@ AcpiExStoreStringToString ( * String will fit in existing non-static buffer. * Clear old string and copy in the new one */ - ACPI_MEMSET (TargetDesc->String.Pointer, 0, + memset (TargetDesc->String.Pointer, 0, (ACPI_SIZE) TargetDesc->String.Length + 1); - ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); + memcpy (TargetDesc->String.Pointer, Buffer, Length); } else { @@ -221,15 +221,16 @@ AcpiExStoreStringToString ( ACPI_FREE (TargetDesc->String.Pointer); } - TargetDesc->String.Pointer = ACPI_ALLOCATE_ZEROED ( - (ACPI_SIZE) Length + 1); + 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; - ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); + memcpy (TargetDesc->String.Pointer, Buffer, Length); } /* Set the new target length */ diff --git a/sys/contrib/dev/acpica/components/executer/exsystem.c b/sys/contrib/dev/acpica/components/executer/exsystem.c index aa661e7..6c1dcd3 100644 --- a/sys/contrib/dev/acpica/components/executer/exsystem.c +++ b/sys/contrib/dev/acpica/components/executer/exsystem.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -86,7 +86,6 @@ AcpiExSystemWaitSemaphore ( /* We must wait, so unlock the interpreter */ AcpiExExitInterpreter (); - Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, @@ -95,7 +94,7 @@ AcpiExSystemWaitSemaphore ( /* Reacquire the interpreter */ - AcpiExEnterInterpreter (); + AcpiExEnterInterpreter (); } return_ACPI_STATUS (Status); @@ -139,7 +138,6 @@ AcpiExSystemWaitMutex ( /* We must wait, so unlock the interpreter */ AcpiExExitInterpreter (); - Status = AcpiOsAcquireMutex (Mutex, Timeout); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, @@ -190,8 +188,8 @@ AcpiExSystemDoStall ( * (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)", - HowLong)); + ACPI_ERROR ((AE_INFO, + "Time parameter is too large (%u)", HowLong)); Status = AE_AML_OPERAND_VALUE; } else @@ -306,7 +304,7 @@ AcpiExSystemWaitEvent ( if (ObjDesc) { Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.OsSemaphore, - (UINT16) TimeDesc->Integer.Value); + (UINT16) TimeDesc->Integer.Value); } return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/executer/extrace.c b/sys/contrib/dev/acpica/components/executer/extrace.c new file mode 100644 index 0000000..ea675d9 --- /dev/null +++ b/sys/contrib/dev/acpica/components/executer/extrace.c @@ -0,0 +1,427 @@ +/****************************************************************************** + * + * Module Name: extrace - Support for interpreter execution tracing + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * 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. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * 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 MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. + */ + +#include <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/include/accommon.h> +#include <contrib/dev/acpica/include/acnamesp.h> +#include <contrib/dev/acpica/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) +{ + ACPI_STATUS Status; + char *Pathname = NULL; + BOOLEAN Enabled = FALSE; + + + ACPI_FUNCTION_NAME (ExStartTraceMethod); + + + if (MethodNode) + { + Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + 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; + } + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + +Exit: + 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) +{ + ACPI_STATUS Status; + char *Pathname = NULL; + BOOLEAN Enabled; + + + ACPI_FUNCTION_NAME (ExStopTraceMethod); + + + if (MethodNode) + { + Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto ExitPath; + } + + Enabled = AcpiExInterpreterTraceEnabled (NULL); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + if (Enabled) + { + ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, FALSE, + ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto ExitPath; + } + + /* 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; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + +ExitPath: + 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/sys/contrib/dev/acpica/components/executer/exutils.c b/sys/contrib/dev/acpica/components/executer/exutils.c index a55b171..cfe5d04 100644 --- a/sys/contrib/dev/acpica/components/executer/exutils.c +++ b/sys/contrib/dev/acpica/components/executer/exutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -187,8 +187,8 @@ AcpiExTruncateFor32bitTable ( (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 + * 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); @@ -232,7 +232,7 @@ AcpiExAcquireGlobalLock ( /* Attempt to get the global lock, wait forever */ Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER, - AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); + AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); if (ACPI_FAILURE (Status)) { @@ -341,8 +341,8 @@ AcpiExDigitsNeeded ( * * FUNCTION: AcpiExEisaIdToString * - * PARAMETERS: CompressedId - EISAID to be converted - * OutString - Where to put the converted string (8 bytes) + * PARAMETERS: OutString - Where to put the converted string (8 bytes) + * CompressedId - EISAID to be converted * * RETURN: None * @@ -369,7 +369,8 @@ AcpiExEisaIdToString ( if (CompressedId > ACPI_UINT32_MAX) { ACPI_WARNING ((AE_INFO, - "Expected EISAID is larger than 32 bits: 0x%8.8X%8.8X, truncating", + "Expected EISAID is larger than 32 bits: " + "0x%8.8X%8.8X, truncating", ACPI_FORMAT_UINT64 (CompressedId))); } @@ -399,7 +400,7 @@ AcpiExEisaIdToString ( * possible 64-bit integer. * Value - Value to be converted * - * RETURN: None, string + * 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 @@ -433,11 +434,48 @@ AcpiExIntegerToString ( /******************************************************************************* * + * 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 valid/supported ID. + * RETURN: TRUE if SpaceId is a valid/supported ID. * * DESCRIPTION: Validate an operation region SpaceID. * @@ -459,5 +497,4 @@ AcpiIsValidSpaceId ( return (TRUE); } - #endif |