diff options
Diffstat (limited to 'source/components')
38 files changed, 990 insertions, 683 deletions
diff --git a/source/components/debugger/dbconvert.c b/source/components/debugger/dbconvert.c index 01cb37a228323..47d2889a66935 100644 --- a/source/components/debugger/dbconvert.c +++ b/source/components/debugger/dbconvert.c @@ -321,7 +321,8 @@ AcpiDbConvertToObject ( default: Object->Type = ACPI_TYPE_INTEGER; - Status = AcpiUtStrtoul64 (String, 16, &Object->Integer.Value); + Status = AcpiUtStrtoul64 (String, 16, AcpiGbl_IntegerByteWidth, + &Object->Integer.Value); break; } diff --git a/source/components/debugger/dbinput.c b/source/components/debugger/dbinput.c index 06d066cef16db..9a71beb1f98f6 100644 --- a/source/components/debugger/dbinput.c +++ b/source/components/debugger/dbinput.c @@ -69,7 +69,7 @@ AcpiDbSingleThread ( static void AcpiDbDisplayCommandInfo ( - char *Command, + const char *Command, BOOLEAN DisplayAll); static void @@ -78,7 +78,7 @@ AcpiDbDisplayHelp ( static BOOLEAN AcpiDbMatchCommandHelp ( - char *Command, + const char *Command, const ACPI_DB_COMMAND_HELP *Help); @@ -358,7 +358,7 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = static BOOLEAN AcpiDbMatchCommandHelp ( - char *Command, + const char *Command, const ACPI_DB_COMMAND_HELP *Help) { char *Invocation = Help->Invocation; @@ -420,7 +420,7 @@ AcpiDbMatchCommandHelp ( static void AcpiDbDisplayCommandInfo ( - char *Command, + const char *Command, BOOLEAN DisplayAll) { const ACPI_DB_COMMAND_HELP *Next; @@ -720,7 +720,8 @@ AcpiDbMatchCommand ( for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++) { - if (strstr (AcpiGbl_DbCommands[i].Name, UserCommand) == + if (strstr ( + ACPI_CAST_PTR (char, AcpiGbl_DbCommands[i].Name), UserCommand) == AcpiGbl_DbCommands[i].Name) { return (i); diff --git a/source/components/debugger/dbutils.c b/source/components/debugger/dbutils.c index 4cabc8b182ee2..ad242fa03cd0a 100644 --- a/source/components/debugger/dbutils.c +++ b/source/components/debugger/dbutils.c @@ -63,8 +63,6 @@ AcpiDbDumpBuffer ( UINT32 Address); #endif -static char *Gbl_HexToAscii = "0123456789ABCDEF"; - /******************************************************************************* * @@ -94,7 +92,9 @@ AcpiDbMatchArgument ( for (i = 0; Arguments[i].Name; i++) { - if (strstr (Arguments[i].Name, UserArgument) == Arguments[i].Name) + if (strstr ( + ACPI_CAST_PTR (char, Arguments[i].Name), + ACPI_CAST_PTR (char, UserArgument)) == Arguments[i].Name) { return (i); } @@ -386,7 +386,7 @@ AcpiDbUint32ToHexString ( for (i = 7; i >= 0; i--) { - Buffer[i] = Gbl_HexToAscii [Value & 0x0F]; + Buffer[i] = AcpiGbl_UpperHexDigits [Value & 0x0F]; Value = Value >> 4; } } diff --git a/source/components/disassembler/dmbuffer.c b/source/components/disassembler/dmbuffer.c index f8fdbaa5dd357..79c37e2e3ea80 100644 --- a/source/components/disassembler/dmbuffer.c +++ b/source/components/disassembler/dmbuffer.c @@ -73,53 +73,13 @@ AcpiDmPldBuffer ( UINT8 *ByteData, UINT32 ByteCount); +static const char * +AcpiDmFindNameByIndex ( + UINT64 Index, + const char **List); -#define ACPI_BUFFER_BYTES_PER_LINE 8 - - -/* Strings for ToPld */ - -static char *DmPanelList[] = -{ - "TOP", - "BOTTOM", - "LEFT", - "RIGHT", - "FRONT", - "BACK", - "UNKNOWN", - NULL -}; - -static char *DmVerticalPositionList[] = -{ - "UPPER", - "CENTER", - "LOWER", - NULL -}; - -static char *DmHorizontalPositionList[] = -{ - "LEFT", - "CENTER", - "RIGHT", - NULL -}; -static char *DmShapeList[] = -{ - "ROUND", - "OVAL", - "SQUARE", - "VERTICALRECTANGLE", - "HORIZONTALRECTANGLE", - "VERTICALTRAPEZOID", - "HORIZONTALTRAPEZOID", - "UNKNOWN", - "CHAMFERED", - NULL -}; +#define ACPI_BUFFER_BYTES_PER_LINE 8 /******************************************************************************* @@ -653,24 +613,24 @@ AcpiDmIsPldBuffer ( * ******************************************************************************/ -static char * +static const char * AcpiDmFindNameByIndex ( UINT64 Index, - char **List) + const char **List) { - char *Str; - UINT32 i; + const char *NameString; + UINT32 i; /* Bounds check */ - Str = List[0]; + NameString = List[0]; i = 0; - while(Str) + while (NameString) { i++; - Str = List[i]; + NameString = List[i]; } if (Index >= i) @@ -698,12 +658,12 @@ AcpiDmFindNameByIndex ( * ******************************************************************************/ -#define ACPI_PLD_OUTPUT08 "%*.s%-18s = 0x%X,\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUT08P "%*.s%-18s = 0x%X)\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUT16 "%*.s%-18s = 0x%X,\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUT16P "%*.s%-18s = 0x%X)\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUT24 "%*.s%-18s = 0x%X,\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUTSTR "%*.s%-18s = \"%s\",\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT08 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT08P "%*.s%-22s = 0x%X)\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT16 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT16P "%*.s%-22s = 0x%X)\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT24 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUTSTR "%*.s%-22s = \"%s\",\n", ACPI_MUL_4 (Level), " " static void AcpiDmPldBuffer ( @@ -751,16 +711,16 @@ AcpiDmPldBuffer ( AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Dock", PldInfo->Dock); AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Lid", PldInfo->Lid); AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_Panel", - AcpiDmFindNameByIndex(PldInfo->Panel, DmPanelList)); + AcpiDmFindNameByIndex(PldInfo->Panel, AcpiGbl_PldPanelList)); AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_VerticalPosition", - AcpiDmFindNameByIndex(PldInfo->VerticalPosition, DmVerticalPositionList)); + AcpiDmFindNameByIndex(PldInfo->VerticalPosition, AcpiGbl_PldVerticalPositionList)); AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_HorizontalPosition", - AcpiDmFindNameByIndex(PldInfo->HorizontalPosition, DmHorizontalPositionList)); + AcpiDmFindNameByIndex(PldInfo->HorizontalPosition, AcpiGbl_PldHorizontalPositionList)); AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_Shape", - AcpiDmFindNameByIndex(PldInfo->Shape, DmShapeList)); + AcpiDmFindNameByIndex(PldInfo->Shape, AcpiGbl_PldShapeList)); AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_GroupOrientation", PldInfo->GroupOrientation); AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_GroupToken", PldInfo->GroupToken); diff --git a/source/components/disassembler/dmopcode.c b/source/components/disassembler/dmopcode.c index 20d7ce5fc6119..8f163ca7e5e2e 100644 --- a/source/components/disassembler/dmopcode.c +++ b/source/components/disassembler/dmopcode.c @@ -646,8 +646,8 @@ AcpiDmMatchKeyword ( } else { - AcpiOsPrintf ("%s", ACPI_CAST_PTR (char, - AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer])); + AcpiOsPrintf ("%s", + AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer]); } } diff --git a/source/components/disassembler/dmresrc.c b/source/components/disassembler/dmresrc.c index 8bfab99045616..a486f1d892087 100644 --- a/source/components/disassembler/dmresrc.c +++ b/source/components/disassembler/dmresrc.c @@ -145,7 +145,7 @@ AcpiDmDescriptorName ( void AcpiDmDumpInteger8 ( UINT8 Value, - char *Name) + const char *Name) { AcpiOsPrintf ("0x%2.2X, // %s\n", Value, Name); } @@ -153,7 +153,7 @@ AcpiDmDumpInteger8 ( void AcpiDmDumpInteger16 ( UINT16 Value, - char *Name) + const char *Name) { AcpiOsPrintf ("0x%4.4X, // %s\n", Value, Name); } @@ -161,7 +161,7 @@ AcpiDmDumpInteger16 ( void AcpiDmDumpInteger32 ( UINT32 Value, - char *Name) + const char *Name) { AcpiOsPrintf ("0x%8.8X, // %s\n", Value, Name); } @@ -169,7 +169,7 @@ AcpiDmDumpInteger32 ( void AcpiDmDumpInteger64 ( UINT64 Value, - char *Name) + const char *Name) { AcpiOsPrintf ("0x%8.8X%8.8X, // %s\n", ACPI_FORMAT_UINT64 (Value), Name); } diff --git a/source/components/disassembler/dmresrcl.c b/source/components/disassembler/dmresrcl.c index 89071c649c762..52fd3356b8d88 100644 --- a/source/components/disassembler/dmresrcl.c +++ b/source/components/disassembler/dmresrcl.c @@ -52,7 +52,7 @@ /* Common names for address and memory descriptors */ -static char *AcpiDmAddressNames[] = +static const char *AcpiDmAddressNames[] = { "Granularity", "Range Minimum", @@ -61,7 +61,7 @@ static char *AcpiDmAddressNames[] = "Length" }; -static char *AcpiDmMemoryNames[] = +static const char *AcpiDmMemoryNames[] = { "Range Minimum", "Range Maximum", @@ -1028,7 +1028,7 @@ AcpiDmInterruptDescriptor ( void AcpiDmVendorCommon ( - char *Name, + const char *Name, UINT8 *ByteData, UINT32 Length, UINT32 Level) diff --git a/source/components/disassembler/dmutils.c b/source/components/disassembler/dmutils.c index 9e2371b85b912..2a82e1e3f4395 100644 --- a/source/components/disassembler/dmutils.c +++ b/source/components/disassembler/dmutils.c @@ -227,7 +227,7 @@ AcpiDmIndent ( return; } - AcpiOsPrintf ("%*.s", ACPI_MUL_4 (Level), " "); + AcpiOsPrintf ("%*.s", (Level * 4), " "); } diff --git a/source/components/events/evregion.c b/source/components/events/evregion.c index 0853a324f3794..673d44d191261 100644 --- a/source/components/events/evregion.c +++ b/source/components/events/evregion.c @@ -551,58 +551,6 @@ AcpiEvAttachRegion ( /******************************************************************************* * - * FUNCTION: AcpiEvAssociateRegMethod - * - * PARAMETERS: RegionObj - Region object - * - * RETURN: Status - * - * DESCRIPTION: Find and associate _REG method to a region - * - ******************************************************************************/ - -void -AcpiEvAssociateRegMethod ( - ACPI_OPERAND_OBJECT *RegionObj) -{ - ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; - ACPI_NAMESPACE_NODE *MethodNode; - ACPI_NAMESPACE_NODE *Node; - ACPI_OPERAND_OBJECT *RegionObj2; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (EvAssociateRegMethod); - - - RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); - if (!RegionObj2) - { - return_VOID; - } - - Node = RegionObj->Region.Node->Parent; - - /* Find any "_REG" method associated with this region definition */ - - Status = AcpiNsSearchOneScope ( - *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); - if (ACPI_SUCCESS (Status)) - { - /* - * The _REG method is optional and there can be only one per region - * definition. This will be executed when the handler is attached - * or removed - */ - RegionObj2->Extra.Method_REG = MethodNode; - } - - return_VOID; -} - - -/******************************************************************************* - * * FUNCTION: AcpiEvExecuteRegMethod * * PARAMETERS: RegionObj - Region object @@ -622,21 +570,45 @@ AcpiEvExecuteRegMethod ( ACPI_EVALUATE_INFO *Info; ACPI_OPERAND_OBJECT *Args[3]; ACPI_OPERAND_OBJECT *RegionObj2; + const ACPI_NAME *RegNamePtr = ACPI_CAST_PTR (ACPI_NAME, METHOD_NAME__REG); + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_FUNCTION_TRACE (EvExecuteRegMethod); + if (!AcpiGbl_NamespaceInitialized || + RegionObj->Region.Handler == NULL) + { + return_ACPI_STATUS (AE_OK); + } + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); if (!RegionObj2) { return_ACPI_STATUS (AE_NOT_EXIST); } - if (RegionObj2->Extra.Method_REG == NULL || - RegionObj->Region.Handler == NULL || - !AcpiGbl_NamespaceInitialized) + /* + * Find any "_REG" method associated with this region definition. + * The method should always be updated as this function may be + * invoked after a namespace change. + */ + Node = RegionObj->Region.Node->Parent; + Status = AcpiNsSearchOneScope ( + *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); + if (ACPI_SUCCESS (Status)) + { + /* + * The _REG method is optional and there can be only one per + * region definition. This will be executed when the handler is + * attached or removed. + */ + RegionObj2->Extra.Method_REG = MethodNode; + } + if (RegionObj2->Extra.Method_REG == NULL) { return_ACPI_STATUS (AE_OK); } diff --git a/source/components/events/evrgnini.c b/source/components/events/evrgnini.c index 5bb177a209ae9..a9e6be03919f5 100644 --- a/source/components/events/evrgnini.c +++ b/source/components/events/evrgnini.c @@ -582,7 +582,6 @@ AcpiEvInitializeRegion ( return_ACPI_STATUS (AE_OK); } - AcpiEvAssociateRegMethod (RegionObj); RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED; Node = RegionObj->Region.Node->Parent; diff --git a/source/components/executer/exconcat.c b/source/components/executer/exconcat.c new file mode 100644 index 0000000000000..49b279ad05d18 --- /dev/null +++ b/source/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 "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlresrc.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exconcat") + +/* Local Prototypes */ + +static ACPI_STATUS +AcpiExConvertToObjectTypeString ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc); + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoConcatenate + * + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object + * ActualReturnDesc - Where to place the return object + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two objects with the ACPI-defined conversion + * rules as necessary. + * NOTE: + * Per the ACPI spec (up to 6.1), Concatenate only supports Integer, + * String, and Buffer objects. However, we support all objects here + * as an extension. This improves the usefulness of both Concatenate + * and the Printf/Fprintf macros. The extension returns a string + * describing the object type for the other objects. + * 02/2016. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoConcatenate ( + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *LocalOperand0 = Operand0; + ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; + ACPI_OPERAND_OBJECT *TempOperand1 = NULL; + ACPI_OPERAND_OBJECT *ReturnDesc; + char *Buffer; + ACPI_OBJECT_TYPE Operand0Type; + ACPI_OBJECT_TYPE Operand1Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExDoConcatenate); + + + /* Operand 0 preprocessing */ + + switch (Operand0->Common.Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + Operand0Type = Operand0->Common.Type; + break; + + default: + + /* For all other types, get the "object type" string */ + + Status = AcpiExConvertToObjectTypeString ( + Operand0, &LocalOperand0); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Operand0Type = ACPI_TYPE_STRING; + break; + } + + /* Operand 1 preprocessing */ + + switch (Operand1->Common.Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + Operand1Type = Operand1->Common.Type; + break; + + default: + + /* For all other types, get the "object type" string */ + + Status = AcpiExConvertToObjectTypeString ( + Operand1, &LocalOperand1); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Operand1Type = ACPI_TYPE_STRING; + break; + } + + /* + * Convert the second operand if necessary. The first operand (0) + * determines the type of the second operand (1) (See the Data Types + * section of the ACPI specification). Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (Operand0Type) + { + case ACPI_TYPE_INTEGER: + + Status = AcpiExConvertToInteger (LocalOperand1, &TempOperand1, 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/source/components/executer/exconfig.c b/source/components/executer/exconfig.c index 7a78e3c2c6227..bb0d2bb411d15 100644 --- a/source/components/executer/exconfig.c +++ b/source/components/executer/exconfig.c @@ -129,7 +129,10 @@ AcpiExAddTable ( /* Execute any module-level code that was found in the table */ AcpiExExitInterpreter (); - AcpiNsExecModuleCodeList (); + if (AcpiGbl_GroupModuleLevelCode) + { + AcpiNsExecModuleCodeList (); + } AcpiExEnterInterpreter (); /* diff --git a/source/components/executer/exconvrt.c b/source/components/executer/exconvrt.c index 6f756d7e5fc6e..ea6f82620dd12 100644 --- a/source/components/executer/exconvrt.c +++ b/source/components/executer/exconvrt.c @@ -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); diff --git a/source/components/executer/exdump.c b/source/components/executer/exdump.c index 5dae1f4bcab3d..f5d5fd03a5071 100644 --- a/source/components/executer/exdump.c +++ b/source/components/executer/exdump.c @@ -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 ( @@ -380,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; @@ -472,9 +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; @@ -971,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); } diff --git a/source/components/executer/exmisc.c b/source/components/executer/exmisc.c index c1dd227b3a65f..a8e5497a9de7c 100644 --- a/source/components/executer/exmisc.c +++ b/source/components/executer/exmisc.c @@ -45,7 +45,6 @@ #include "accommon.h" #include "acinterp.h" #include "amlcode.h" -#include "amlresrc.h" #define _COMPONENT ACPI_EXECUTER @@ -150,307 +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; - 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); -} - - -/******************************************************************************* - * - * 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; - const char *TypeString; - 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: - /* - * Per the ACPI spec, Concatenate only supports int/str/buf. - * However, we support all objects here as an extension. - * This improves the usefulness of the Printf() macro. - * 12/2015. - */ - switch (Operand1->Common.Type) - { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - - Status = AcpiExConvertToString ( - Operand1, &LocalOperand1, ACPI_IMPLICIT_CONVERT_HEX); - break; - - default: - /* - * Just emit a string containing the object type. - */ - TypeString = AcpiUtGetTypeName (Operand1->Common.Type); - - LocalOperand1 = AcpiUtCreateStringObject ( - ((ACPI_SIZE) strlen (TypeString) + 9)); /* 9 For "[Object]" */ - if (!LocalOperand1) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - strcpy (LocalOperand1->String.Pointer, "["); - strcat (LocalOperand1->String.Pointer, TypeString); - strcat (LocalOperand1->String.Pointer, " Object]"); - Status = AE_OK; - break; - } - 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 */ - - memcpy (NewBuf, &Operand0->Integer.Value, - AcpiGbl_IntegerByteWidth); - - /* Copy the second integer (LSB first) after the first */ - - 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 */ - - strcpy (NewBuf, Operand0->String.Pointer); - strcat (NewBuf, 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 */ - - memcpy (NewBuf, Operand0->Buffer.Pointer, - Operand0->Buffer.Length); - 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 diff --git a/source/components/executer/exsystem.c b/source/components/executer/exsystem.c index 17eff66ddc551..a215e8012dc86 100644 --- a/source/components/executer/exsystem.c +++ b/source/components/executer/exsystem.c @@ -94,7 +94,7 @@ AcpiExSystemWaitSemaphore ( /* Reacquire the interpreter */ - AcpiExEnterInterpreter (); + AcpiExEnterInterpreter (); } return_ACPI_STATUS (Status); diff --git a/source/components/executer/exutils.c b/source/components/executer/exutils.c index a570ad6fe7e9b..4843a20891439 100644 --- a/source/components/executer/exutils.c +++ b/source/components/executer/exutils.c @@ -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 * @@ -400,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 @@ -437,9 +437,9 @@ AcpiExIntegerToString ( * FUNCTION: AcpiExPciClsToString * * PARAMETERS: OutString - Where to put the converted string (7 bytes) - * PARAMETERS: ClassCode - PCI class code to be converted (3 bytes) + * ClassCode - PCI class code to be converted (3 bytes) * - * RETURN: None + * 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 @@ -475,7 +475,7 @@ AcpiExPciClsToString ( * * 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. * diff --git a/source/components/hardware/hwregs.c b/source/components/hardware/hwregs.c index bc85c96b553f6..55cdd07be670d 100644 --- a/source/components/hardware/hwregs.c +++ b/source/components/hardware/hwregs.c @@ -91,6 +91,9 @@ AcpiHwValidateRegister ( UINT8 MaxBitWidth, UINT64 *Address) { + UINT8 BitWidth; + UINT8 AccessWidth; + /* Must have a valid pointer to a GAS structure */ @@ -120,24 +123,26 @@ AcpiHwValidateRegister ( return (AE_SUPPORT); } - /* Validate the BitWidth */ + /* Validate the AccessWidth */ - if ((Reg->BitWidth != 8) && - (Reg->BitWidth != 16) && - (Reg->BitWidth != 32) && - (Reg->BitWidth != MaxBitWidth)) + if (Reg->AccessWidth > 4) { ACPI_ERROR ((AE_INFO, - "Unsupported register bit width: 0x%X", Reg->BitWidth)); + "Unsupported register access width: 0x%X", Reg->AccessWidth)); return (AE_SUPPORT); } - /* Validate the BitOffset. Just a warning for now. */ + /* Validate the BitWidth, convert AccessWidth into number of bits */ - if (Reg->BitOffset != 0) + AccessWidth = Reg->AccessWidth ? Reg->AccessWidth : 1; + AccessWidth = 1 << (AccessWidth + 2); + BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth); + if (MaxBitWidth < BitWidth) { ACPI_WARNING ((AE_INFO, - "Unsupported register bit offset: 0x%X", Reg->BitOffset)); + "Requested bit width 0x%X is smaller than register bit width 0x%X", + MaxBitWidth, BitWidth)); + return (AE_SUPPORT); } return (AE_OK); @@ -158,10 +163,7 @@ AcpiHwValidateRegister ( * 64-bit values is not needed. * * LIMITATIONS: <These limitations also apply to AcpiHwWrite> - * BitWidth must be exactly 8, 16, or 32. * SpaceID must be SystemMemory or SystemIO. - * BitOffset and AccessWidth are currently ignored, as there has - * not been a need to implement these. * ******************************************************************************/ @@ -171,7 +173,12 @@ AcpiHwRead ( ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; + UINT8 AccessWidth; + UINT32 BitWidth; + UINT8 BitOffset; UINT64 Value64; + UINT32 Value32; + UINT8 Index; ACPI_STATUS Status; @@ -186,30 +193,65 @@ AcpiHwRead ( return (Status); } - /* Initialize entire 32-bit return value to zero */ - + /* + * Initialize entire 32-bit return value to zero, convert AccessWidth + * into number of bits based + */ *Value = 0; + AccessWidth = Reg->AccessWidth ? Reg->AccessWidth : 1; + AccessWidth = 1 << (AccessWidth + 2); + BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth); + BitOffset = Reg->BitOffset; /* * Two address spaces supported: Memory or IO. PCI_Config is * not supported here because the GAS structure is insufficient */ - if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + Index = 0; + while (BitWidth) { - Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) - Address, &Value64, Reg->BitWidth); + if (BitOffset > AccessWidth) + { + Value32 = 0; + BitOffset -= AccessWidth; + } + else + { + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + &Value64, AccessWidth); + Value32 = (UINT32) Value64; + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + &Value32, AccessWidth); + } - *Value = (UINT32) Value64; - } - else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ - { - Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) - Address, Value, Reg->BitWidth); + if (BitOffset) + { + Value32 &= ACPI_MASK_BITS_BELOW (BitOffset); + BitOffset = 0; + } + if (BitWidth < AccessWidth) + { + Value32 &= ACPI_MASK_BITS_ABOVE (BitWidth); + } + } + + ACPI_SET_BITS (Value, Index * AccessWidth, + ((1 << AccessWidth) - 1), Value32); + + BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth; + Index++; } ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", - *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + *Value, AccessWidth, ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); @@ -237,6 +279,12 @@ AcpiHwWrite ( ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; + UINT8 AccessWidth; + UINT32 BitWidth; + UINT8 BitOffset; + UINT64 Value64; + UINT32 NewValue32, OldValue32; + UINT8 Index; ACPI_STATUS Status; @@ -251,24 +299,110 @@ AcpiHwWrite ( return (Status); } + /* Convert AccessWidth into number of bits based */ + + AccessWidth = Reg->AccessWidth ? Reg->AccessWidth : 1; + AccessWidth = 1 << (AccessWidth + 2); + BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth); + BitOffset = Reg->BitOffset; + /* * Two address spaces supported: Memory or IO. PCI_Config is * not supported here because the GAS structure is insufficient */ - if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) - { - Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) - Address, (UINT64) Value, Reg->BitWidth); - } - else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + Index = 0; + while (BitWidth) { - Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) - Address, Value, Reg->BitWidth); + NewValue32 = ACPI_GET_BITS (&Value, (Index * AccessWidth), + ((1 << AccessWidth) - 1)); + + if (BitOffset > AccessWidth) + { + BitOffset -= AccessWidth; + } + else + { + if (BitOffset) + { + NewValue32 &= ACPI_MASK_BITS_BELOW (BitOffset); + } + + if (BitWidth < AccessWidth) + { + NewValue32 &= ACPI_MASK_BITS_ABOVE (BitWidth); + } + + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + if (BitOffset || BitWidth < AccessWidth) + { + /* + * Read old values in order not to modify the bits that + * are beyond the register BitWidth/BitOffset setting. + */ + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + &Value64, AccessWidth); + OldValue32 = (UINT32) Value64; + + if (BitOffset) + { + OldValue32 &= ACPI_MASK_BITS_ABOVE (BitOffset + 1); + BitOffset = 0; + } + + if (BitWidth < AccessWidth) + { + OldValue32 &= ACPI_MASK_BITS_BELOW (BitWidth - 1); + } + + NewValue32 |= OldValue32; + } + + Value64 = (UINT64) NewValue32; + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + Value64, AccessWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + if (BitOffset || BitWidth < AccessWidth) + { + /* + * Read old values in order not to modify the bits that + * are beyond the register BitWidth/BitOffset setting. + */ + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + &OldValue32, AccessWidth); + + if (BitOffset) + { + OldValue32 &= ACPI_MASK_BITS_ABOVE (BitOffset + 1); + BitOffset = 0; + } + + if (BitWidth < AccessWidth) + { + OldValue32 &= ACPI_MASK_BITS_BELOW (BitWidth - 1); + } + + NewValue32 |= OldValue32; + } + + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + NewValue32, AccessWidth); + } + } + + BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth; + Index++; } ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", - Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + Value, AccessWidth, ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); diff --git a/source/components/hardware/hwxface.c b/source/components/hardware/hwxface.c index e8b2fe6554cda..f5d4fca6b94cc 100644 --- a/source/components/hardware/hwxface.c +++ b/source/components/hardware/hwxface.c @@ -565,8 +565,7 @@ AcpiGetSleepTypeData ( * Evaluate the \_Sx namespace object containing the register values * for this state */ - Info->RelativePathname = ACPI_CAST_PTR (char, - AcpiGbl_SleepStateNames[SleepState]); + Info->RelativePathname = AcpiGbl_SleepStateNames[SleepState]; Status = AcpiNsEvaluate (Info); if (ACPI_FAILURE (Status)) diff --git a/source/components/namespace/nsaccess.c b/source/components/namespace/nsaccess.c index 64db3a9ea2a74..42a6d807a2c30 100644 --- a/source/components/namespace/nsaccess.c +++ b/source/components/namespace/nsaccess.c @@ -116,7 +116,7 @@ AcpiNsRootInitialize ( continue; } - Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type, + Status = AcpiNsLookup (NULL, (char *) InitVal->Name, InitVal->Type, ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, NULL, &NewNode); if (ACPI_FAILURE (Status)) diff --git a/source/components/namespace/nsconvert.c b/source/components/namespace/nsconvert.c index 8cccf99afc4f5..2fa182eddcff1 100644 --- a/source/components/namespace/nsconvert.c +++ b/source/components/namespace/nsconvert.c @@ -84,7 +84,7 @@ AcpiNsConvertToInteger ( /* String-to-Integer conversion */ Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer, - ACPI_ANY_BASE, &Value); + ACPI_ANY_BASE, AcpiGbl_IntegerByteWidth, &Value); if (ACPI_FAILURE (Status)) { return (Status); diff --git a/source/components/namespace/nsdump.c b/source/components/namespace/nsdump.c index 72ef07eca36f5..776653fc43ecd 100644 --- a/source/components/namespace/nsdump.c +++ b/source/components/namespace/nsdump.c @@ -99,7 +99,7 @@ AcpiNsGetMaxDepth ( void AcpiNsPrintPathname ( UINT32 NumSegments, - char *Pathname) + const char *Pathname) { UINT32 i; @@ -139,6 +139,9 @@ AcpiNsPrintPathname ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/* Not used at this time, perhaps later */ + /******************************************************************************* * * FUNCTION: AcpiNsDumpPathname @@ -158,7 +161,7 @@ AcpiNsPrintPathname ( void AcpiNsDumpPathname ( ACPI_HANDLE Handle, - char *Msg, + const char *Msg, UINT32 Level, UINT32 Component) { @@ -179,7 +182,7 @@ AcpiNsDumpPathname ( AcpiOsPrintf ("\n"); return_VOID; } - +#endif /******************************************************************************* * diff --git a/source/components/namespace/nsinit.c b/source/components/namespace/nsinit.c index 99f1527e028d8..067dffe1fd3d8 100644 --- a/source/components/namespace/nsinit.c +++ b/source/components/namespace/nsinit.c @@ -99,6 +99,8 @@ AcpiNsInitializeObjects ( ACPI_FUNCTION_TRACE (NsInitializeObjects); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Completing Initialization of ACPI Objects\n")); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "**** Starting initialization of namespace objects ****\n")); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, @@ -156,6 +158,7 @@ AcpiNsInitializeDevices ( { ACPI_STATUS Status = AE_OK; ACPI_DEVICE_WALK_INFO Info; + ACPI_HANDLE Handle; ACPI_FUNCTION_TRACE (NsInitializeDevices); @@ -209,6 +212,27 @@ AcpiNsInitializeDevices ( { Info.Num_INI++; } + + /* + * Execute \_SB._INI. + * There appears to be a strict order requirement for \_SB._INI, + * which should be evaluated before any _REG evaluations. + */ + Status = AcpiGetHandle (NULL, "\\_SB", &Handle); + if (ACPI_SUCCESS (Status)) + { + memset (Info.EvaluateInfo, 0, sizeof (ACPI_EVALUATE_INFO)); + Info.EvaluateInfo->PrefixNode = Handle; + Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI; + Info.EvaluateInfo->Parameters = NULL; + Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info.EvaluateInfo); + if (ACPI_SUCCESS (Status)) + { + Info.Num_INI++; + } + } } /* @@ -217,6 +241,12 @@ AcpiNsInitializeDevices ( * Note: Any objects accessed by the _REG methods will be automatically * initialized, even if they contain executable AML (see the call to * AcpiNsInitializeObjects below). + * + * Note: According to the ACPI specification, we actually needn't execute + * _REG for SystemMemory/SystemIo operation regions, but for PCI_Config + * operation regions, it is required to evaluate _REG for those on a PCI + * root bus that doesn't contain _BBN object. So this code is kept here + * in order not to break things. */ if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) { @@ -640,33 +670,37 @@ AcpiNsInitOneDevice ( * Note: We know there is an _INI within this subtree, but it may not be * under this particular device, it may be lower in the branch. */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( - ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); + if (!ACPI_COMPARE_NAME (DeviceNode->Name.Ascii, "_SB_") || + DeviceNode->Parent != AcpiGbl_RootNode) + { + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); - memset (Info, 0, sizeof (ACPI_EVALUATE_INFO)); - Info->PrefixNode = DeviceNode; - Info->RelativePathname = METHOD_NAME__INI; - Info->Parameters = NULL; - Info->Flags = ACPI_IGNORE_RETURN_VALUE; + memset (Info, 0, sizeof (ACPI_EVALUATE_INFO)); + Info->PrefixNode = DeviceNode; + Info->RelativePathname = METHOD_NAME__INI; + Info->Parameters = NULL; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; - Status = AcpiNsEvaluate (Info); - if (ACPI_SUCCESS (Status)) - { - WalkInfo->Num_INI++; - } + Status = AcpiNsEvaluate (Info); + if (ACPI_SUCCESS (Status)) + { + WalkInfo->Num_INI++; + } #ifdef ACPI_DEBUG_OUTPUT - else if (Status != AE_NOT_FOUND) - { - /* Ignore error and move on to next device */ + else if (Status != AE_NOT_FOUND) + { + /* Ignore error and move on to next device */ - char *ScopeName = AcpiNsGetNormalizedPathname (DeviceNode, TRUE); + char *ScopeName = AcpiNsGetNormalizedPathname (DeviceNode, TRUE); - ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", - ScopeName)); - ACPI_FREE (ScopeName); - } + ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", + ScopeName)); + ACPI_FREE (ScopeName); + } #endif + } /* Ignore errors from above */ diff --git a/source/components/namespace/nsload.c b/source/components/namespace/nsload.c index 5cfadf365b79d..9c899e7846192 100644 --- a/source/components/namespace/nsload.c +++ b/source/components/namespace/nsload.c @@ -140,8 +140,8 @@ AcpiNsLoadTable ( (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); AcpiNsDeleteNamespaceByOwner ( AcpiGbl_RootTableList.Tables[TableIndex].OwnerId); - AcpiTbReleaseOwnerId (TableIndex); + AcpiTbReleaseOwnerId (TableIndex); return_ACPI_STATUS (Status); } diff --git a/source/components/namespace/nsprepkg.c b/source/components/namespace/nsprepkg.c index 3cc9f536046f9..141251f8519e2 100644 --- a/source/components/namespace/nsprepkg.c +++ b/source/components/namespace/nsprepkg.c @@ -188,6 +188,7 @@ AcpiNsCheckPackage ( { return (Status); } + Elements++; } break; @@ -232,6 +233,7 @@ AcpiNsCheckPackage ( return (Status); } } + Elements++; } break; @@ -342,7 +344,7 @@ AcpiNsCheckPackage ( while (Count > 0) { Status = AcpiNsCheckObjectType(Info, Elements, - Package->RetInfo.ObjectType1, 0); + Package->RetInfo.ObjectType1, 0); if (ACPI_FAILURE(Status)) { return (Status); @@ -358,7 +360,7 @@ AcpiNsCheckPackage ( } Status = AcpiNsCheckObjectType(Info, Elements + 1, - Package->RetInfo.ObjectType2, 0); + Package->RetInfo.ObjectType2, 0); if (ACPI_FAILURE(Status)) { return (Status); @@ -366,8 +368,8 @@ AcpiNsCheckPackage ( Elements += 2; Count -= 2; - } - break; + } + break; default: @@ -442,7 +444,7 @@ AcpiNsCheckPackageList ( /* Each sub-object must be of type Package */ Status = AcpiNsCheckObjectType (Info, &SubPackage, - ACPI_RTYPE_PACKAGE, i); + ACPI_RTYPE_PACKAGE, i); if (ACPI_FAILURE (Status)) { return (Status); @@ -466,10 +468,10 @@ AcpiNsCheckPackageList ( } Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, - Package->RetInfo.Count2, 0); + Package->RetInfo.ObjectType1, + Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, + Package->RetInfo.Count2, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -488,10 +490,10 @@ AcpiNsCheckPackageList ( } Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, - SubPackage->Package.Count - Package->RetInfo.Count1, 0); + Package->RetInfo.ObjectType1, + Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, + SubPackage->Package.Count - Package->RetInfo.Count1, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -519,7 +521,7 @@ AcpiNsCheckPackageList ( for (j = 0; j < ExpectedCount; j++) { Status = AcpiNsCheckObjectType (Info, &SubElements[j], - Package->RetInfo2.ObjectType[j], j); + Package->RetInfo2.ObjectType[j], j); if (ACPI_FAILURE (Status)) { return (Status); @@ -540,8 +542,8 @@ AcpiNsCheckPackageList ( /* Check the type of each subpackage element */ Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - SubPackage->Package.Count, 0, 0, 0); + Package->RetInfo.ObjectType1, + SubPackage->Package.Count, 0, 0, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -554,7 +556,7 @@ AcpiNsCheckPackageList ( * the count field (the ACPI name is NumElements) */ Status = AcpiNsCheckObjectType (Info, SubElements, - ACPI_RTYPE_INTEGER, 0); + ACPI_RTYPE_INTEGER, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -569,11 +571,13 @@ AcpiNsCheckPackageList ( { goto PackageTooSmall; } + if (SubPackage->Package.Count < Package->RetInfo.Count1) { ExpectedCount = Package->RetInfo.Count1; goto PackageTooSmall; } + if (ExpectedCount == 0) { /* @@ -589,8 +593,8 @@ AcpiNsCheckPackageList ( /* Check the type of each subpackage element */ Status = AcpiNsCheckPackageElements (Info, (SubElements + 1), - Package->RetInfo.ObjectType1, - (ExpectedCount - 1), 0, 0, 1); + Package->RetInfo.ObjectType1, + (ExpectedCount - 1), 0, 0, 1); if (ACPI_FAILURE (Status)) { return (Status); @@ -662,22 +666,24 @@ AcpiNsCheckPackageElements ( for (i = 0; i < Count1; i++) { Status = AcpiNsCheckObjectType (Info, ThisElement, - Type1, i + StartIndex); + Type1, i + StartIndex); if (ACPI_FAILURE (Status)) { return (Status); } + ThisElement++; } for (i = 0; i < Count2; i++) { Status = AcpiNsCheckObjectType (Info, ThisElement, - Type2, (i + Count1 + StartIndex)); + Type2, (i + Count1 + StartIndex)); if (ACPI_FAILURE (Status)) { return (Status); } + ThisElement++; } diff --git a/source/components/parser/psopinfo.c b/source/components/parser/psopinfo.c index 28fa0ed2911b5..324d87a93f0f1 100644 --- a/source/components/parser/psopinfo.c +++ b/source/components/parser/psopinfo.c @@ -165,7 +165,7 @@ AcpiPsGetOpcodeInfo ( * ******************************************************************************/ -char * +const char * AcpiPsGetOpcodeName ( UINT16 Opcode) { diff --git a/source/components/resources/rsdump.c b/source/components/resources/rsdump.c index c0421cd243c4f..e7948850bcc29 100644 --- a/source/components/resources/rsdump.c +++ b/source/components/resources/rsdump.c @@ -56,32 +56,32 @@ static void AcpiRsOutString ( - char *Title, - char *Value); + const char *Title, + const char *Value); static void AcpiRsOutInteger8 ( - char *Title, + const char *Title, UINT8 Value); static void AcpiRsOutInteger16 ( - char *Title, + const char *Title, UINT16 Value); static void AcpiRsOutInteger32 ( - char *Title, + const char *Title, UINT32 Value); static void AcpiRsOutInteger64 ( - char *Title, + const char *Title, UINT64 Value); static void AcpiRsOutTitle ( - char *Title); + const char *Title); static void AcpiRsDumpByteList ( @@ -263,8 +263,8 @@ AcpiRsDumpDescriptor ( { UINT8 *Target = NULL; UINT8 *PreviousTarget; - char *Name; - UINT8 Count; + const char *Name; + UINT8 Count; /* First table entry must contain the table length (# of table entries) */ @@ -307,8 +307,7 @@ AcpiRsDumpDescriptor ( if (Table->Pointer) { - AcpiRsOutString (Name, ACPI_CAST_PTR (char, - Table->Pointer [*Target])); + AcpiRsOutString (Name, Table->Pointer [*Target]); } else { @@ -335,20 +334,17 @@ AcpiRsDumpDescriptor ( case ACPI_RSD_1BITFLAG: - AcpiRsOutString (Name, ACPI_CAST_PTR (char, - Table->Pointer [*Target & 0x01])); + AcpiRsOutString (Name, Table->Pointer [*Target & 0x01]); break; case ACPI_RSD_2BITFLAG: - AcpiRsOutString (Name, ACPI_CAST_PTR (char, - Table->Pointer [*Target & 0x03])); + AcpiRsOutString (Name, Table->Pointer [*Target & 0x03]); break; case ACPI_RSD_3BITFLAG: - AcpiRsOutString (Name, ACPI_CAST_PTR (char, - Table->Pointer [*Target & 0x07])); + AcpiRsOutString (Name, Table->Pointer [*Target & 0x07]); break; case ACPI_RSD_SHORTLIST: @@ -542,8 +538,8 @@ AcpiRsDumpAddressCommon ( static void AcpiRsOutString ( - char *Title, - char *Value) + const char *Title, + const char *Value) { AcpiOsPrintf ("%27s : %s", Title, Value); @@ -556,7 +552,7 @@ AcpiRsOutString ( static void AcpiRsOutInteger8 ( - char *Title, + const char *Title, UINT8 Value) { AcpiOsPrintf ("%27s : %2.2X\n", Title, Value); @@ -564,7 +560,7 @@ AcpiRsOutInteger8 ( static void AcpiRsOutInteger16 ( - char *Title, + const char *Title, UINT16 Value) { @@ -573,7 +569,7 @@ AcpiRsOutInteger16 ( static void AcpiRsOutInteger32 ( - char *Title, + const char *Title, UINT32 Value) { @@ -582,7 +578,7 @@ AcpiRsOutInteger32 ( static void AcpiRsOutInteger64 ( - char *Title, + const char *Title, UINT64 Value) { @@ -592,7 +588,7 @@ AcpiRsOutInteger64 ( static void AcpiRsOutTitle ( - char *Title) + const char *Title) { AcpiOsPrintf ("%27s : ", Title); diff --git a/source/components/resources/rsutils.c b/source/components/resources/rsutils.c index fbd1c46622abb..cec4180bfd151 100644 --- a/source/components/resources/rsutils.c +++ b/source/components/resources/rsutils.c @@ -740,7 +740,7 @@ AcpiRsGetAeiMethodData ( ACPI_STATUS AcpiRsGetMethodData ( ACPI_HANDLE Handle, - char *Path, + const char *Path, ACPI_BUFFER *RetBuffer) { ACPI_OPERAND_OBJECT *ObjDesc; diff --git a/source/components/tables/tbfadt.c b/source/components/tables/tbfadt.c index 2bcecedf94662..51eb49b42acfd 100644 --- a/source/components/tables/tbfadt.c +++ b/source/components/tables/tbfadt.c @@ -56,7 +56,7 @@ AcpiTbInitGenericAddress ( UINT8 SpaceId, UINT8 ByteWidth, UINT64 Address, - char *RegisterName, + const char *RegisterName, UINT8 Flags); static void @@ -78,7 +78,7 @@ AcpiTbSelectAddress ( typedef struct acpi_fadt_info { - char *Name; + const char *Name; UINT16 Address64; UINT16 Address32; UINT16 Length; @@ -212,7 +212,7 @@ AcpiTbInitGenericAddress ( UINT8 SpaceId, UINT8 ByteWidth, UINT64 Address, - char *RegisterName, + const char *RegisterName, UINT8 Flags) { UINT8 BitWidth; @@ -420,15 +420,16 @@ AcpiTbCreateLocalFadt ( /* * Check if the FADT is larger than the largest table that we expect - * (the ACPI 5.0 version). If so, truncate the table, and issue - * a warning. + * (typically the current ACPI specification version). If so, truncate + * the table, and issue a warning. */ if (Length > sizeof (ACPI_TABLE_FADT)) { ACPI_BIOS_WARNING ((AE_INFO, - "FADT (revision %u) is longer than ACPI 5.0 version, " + "FADT (revision %u) is longer than %s length, " "truncating length %u to %u", - Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT))); + Table->Revision, ACPI_FADT_CONFORMANCE, Length, + (UINT32) sizeof (ACPI_TABLE_FADT))); } /* Clear the entire local FADT */ @@ -506,7 +507,7 @@ static void AcpiTbConvertFadt ( void) { - char *Name; + const char *Name; ACPI_GENERIC_ADDRESS *Address64; UINT32 Address32; UINT8 Length; @@ -676,9 +677,11 @@ AcpiTbConvertFadt ( (!Address64->Address && Length)) { ACPI_BIOS_WARNING ((AE_INFO, - "Optional FADT field %s has zero address or length: " - "0x%8.8X%8.8X/0x%X", - Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); + "Optional FADT field %s has valid %s but zero %s: " + "0x%8.8X%8.8X/0x%X", Name, + (Length ? "Length" : "Address"), + (Length ? "Address": "Length"), + ACPI_FORMAT_UINT64 (Address64->Address), Length)); } } } diff --git a/source/components/tables/tbxfload.c b/source/components/tables/tbxfload.c index 0302eb94a02a9..645b9d57acdd6 100644 --- a/source/components/tables/tbxfload.c +++ b/source/components/tables/tbxfload.c @@ -87,14 +87,11 @@ AcpiLoadTables ( * between AcpiInitializeSubsystem() and AcpiLoadTables() to use * their customized default region handlers. */ - if (AcpiGbl_GroupModuleLevelCode) + Status = AcpiEvInstallRegionHandlers (); + if (ACPI_FAILURE (Status)) { - Status = AcpiEvInstallRegionHandlers (); - if (ACPI_FAILURE (Status) && Status != AE_ALREADY_EXISTS) - { - ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization")); - return_ACPI_STATUS (Status); - } + ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization")); + return_ACPI_STATUS (Status); } /* Load the namespace from the tables */ @@ -114,6 +111,22 @@ AcpiLoadTables ( "While loading namespace from ACPI tables")); } + if (!AcpiGbl_GroupModuleLevelCode) + { + /* + * Initialize the objects that remain uninitialized. This + * runs the executable AML that may be part of the + * declaration of these objects: + * OperationRegions, BufferFields, Buffers, and Packages. + */ + Status = AcpiNsInitializeObjects (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + AcpiGbl_NamespaceInitialized = TRUE; return_ACPI_STATUS (Status); } diff --git a/source/components/utilities/utdebug.c b/source/components/utilities/utdebug.c index ccdca57bff578..b6ae2c73356b6 100644 --- a/source/components/utilities/utdebug.c +++ b/source/components/utilities/utdebug.c @@ -53,15 +53,9 @@ #ifdef ACPI_DEBUG_OUTPUT -static ACPI_THREAD_ID AcpiGbl_PrevThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF; -static char *AcpiGbl_FnEntryStr = "----Entry"; -static char *AcpiGbl_FnExitStr = "----Exit-"; - -/* Local prototypes */ - -static const char * -AcpiUtTrimFunctionName ( - const char *FunctionName); +static ACPI_THREAD_ID AcpiGbl_PreviousThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF; +static const char *AcpiGbl_FunctionEntryPrefix = "----Entry"; +static const char *AcpiGbl_FunctionExitPrefix = "----Exit-"; /******************************************************************************* @@ -201,16 +195,16 @@ AcpiDebugPrint ( * Thread tracking and context switch notification */ ThreadId = AcpiOsGetThreadId (); - if (ThreadId != AcpiGbl_PrevThreadId) + if (ThreadId != AcpiGbl_PreviousThreadId) { if (ACPI_LV_THREADS & AcpiDbgLevel) { AcpiOsPrintf ( "\n**** Context Switch from TID %u to TID %u ****\n\n", - (UINT32) AcpiGbl_PrevThreadId, (UINT32) ThreadId); + (UINT32) AcpiGbl_PreviousThreadId, (UINT32) ThreadId); } - AcpiGbl_PrevThreadId = ThreadId; + AcpiGbl_PreviousThreadId = ThreadId; AcpiGbl_NestingLevel = 0; } @@ -325,7 +319,7 @@ AcpiUtTrace ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s\n", AcpiGbl_FnEntryStr); + "%s\n", AcpiGbl_FunctionEntryPrefix); } } @@ -355,7 +349,7 @@ AcpiUtTracePtr ( const char *FunctionName, const char *ModuleName, UINT32 ComponentId, - void *Pointer) + const void *Pointer) { AcpiGbl_NestingLevel++; @@ -367,7 +361,7 @@ AcpiUtTracePtr ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %p\n", AcpiGbl_FnEntryStr, Pointer); + "%s %p\n", AcpiGbl_FunctionEntryPrefix, Pointer); } } @@ -395,7 +389,7 @@ AcpiUtTraceStr ( const char *FunctionName, const char *ModuleName, UINT32 ComponentId, - char *String) + const char *String) { AcpiGbl_NestingLevel++; @@ -407,7 +401,7 @@ AcpiUtTraceStr ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %s\n", AcpiGbl_FnEntryStr, String); + "%s %s\n", AcpiGbl_FunctionEntryPrefix, String); } } @@ -447,7 +441,7 @@ AcpiUtTraceU32 ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %08X\n", AcpiGbl_FnEntryStr, Integer); + "%s %08X\n", AcpiGbl_FunctionEntryPrefix, Integer); } } @@ -482,7 +476,7 @@ AcpiUtExit ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s\n", AcpiGbl_FnExitStr); + "%s\n", AcpiGbl_FunctionExitPrefix); } if (AcpiGbl_NestingLevel) @@ -528,14 +522,14 @@ AcpiUtStatusExit ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %s\n", AcpiGbl_FnExitStr, + "%s %s\n", AcpiGbl_FunctionExitPrefix, AcpiFormatException (Status)); } else { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s ****Exception****: %s\n", AcpiGbl_FnExitStr, + "%s ****Exception****: %s\n", AcpiGbl_FunctionExitPrefix, AcpiFormatException (Status)); } } @@ -581,7 +575,7 @@ AcpiUtValueExit ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr, + "%s %8.8X%8.8X\n", AcpiGbl_FunctionExitPrefix, ACPI_FORMAT_UINT64 (Value)); } @@ -626,7 +620,7 @@ AcpiUtPtrExit ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %p\n", AcpiGbl_FnExitStr, Ptr); + "%s %p\n", AcpiGbl_FunctionExitPrefix, Ptr); } if (AcpiGbl_NestingLevel) diff --git a/source/components/utilities/uteval.c b/source/components/utilities/uteval.c index bdde513884c07..d4864f3813c4a 100644 --- a/source/components/utilities/uteval.c +++ b/source/components/utilities/uteval.c @@ -72,7 +72,7 @@ ACPI_STATUS AcpiUtEvaluateObject ( ACPI_NAMESPACE_NODE *PrefixNode, - char *Path, + const char *Path, UINT32 ExpectedReturnBtypes, ACPI_OPERAND_OBJECT **ReturnDesc) { @@ -219,7 +219,7 @@ Cleanup: ACPI_STATUS AcpiUtEvaluateNumericObject ( - char *ObjectName, + const char *ObjectName, ACPI_NAMESPACE_NODE *DeviceNode, UINT64 *Value) { diff --git a/source/components/utilities/utglobal.c b/source/components/utilities/utglobal.c index ed3a171eeb066..0d8dff88c912e 100644 --- a/source/components/utilities/utglobal.c +++ b/source/components/utilities/utglobal.c @@ -87,6 +87,12 @@ const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] = }; +/* Hex-to-ascii */ + +const char AcpiGbl_LowerHexDigits[] = "0123456789abcdef"; +const char AcpiGbl_UpperHexDigits[] = "0123456789ABCDEF"; + + /******************************************************************************* * * Namespace globals @@ -179,6 +185,55 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = }; #endif /* !ACPI_REDUCED_HARDWARE */ + +#if defined (ACPI_DISASSEMBLER) || defined (ACPI_ASL_COMPILER) + +/* ToPld macro: compile/disassemble strings */ + +const char *AcpiGbl_PldPanelList[] = +{ + "TOP", + "BOTTOM", + "LEFT", + "RIGHT", + "FRONT", + "BACK", + "UNKNOWN", + NULL +}; + +const char *AcpiGbl_PldVerticalPositionList[] = +{ + "UPPER", + "CENTER", + "LOWER", + NULL +}; + +const char *AcpiGbl_PldHorizontalPositionList[] = +{ + "LEFT", + "CENTER", + "RIGHT", + NULL +}; + +const char *AcpiGbl_PldShapeList[] = +{ + "ROUND", + "OVAL", + "SQUARE", + "VERTICALRECTANGLE", + "HORIZONTALRECTANGLE", + "VERTICALTRAPEZOID", + "HORIZONTALTRAPEZOID", + "UNKNOWN", + "CHAMFERED", + NULL +}; +#endif + + /* Public globals */ ACPI_EXPORT_SYMBOL (AcpiGbl_FADT) diff --git a/source/components/utilities/utmisc.c b/source/components/utilities/utmisc.c index e35a0ef502ef7..ce8f25426d7f0 100644 --- a/source/components/utilities/utmisc.c +++ b/source/components/utilities/utmisc.c @@ -401,7 +401,7 @@ void AcpiUtDisplayInitPathname ( UINT8 Type, ACPI_NAMESPACE_NODE *ObjHandle, - char *Path) + const char *Path) { ACPI_STATUS Status; ACPI_BUFFER Buffer; diff --git a/source/components/utilities/utnonansi.c b/source/components/utilities/utnonansi.c index 572d24a6b6c3c..70fb33e64c0c8 100644 --- a/source/components/utilities/utnonansi.c +++ b/source/components/utilities/utnonansi.c @@ -244,41 +244,44 @@ AcpiUtSafeStrncat ( * * FUNCTION: AcpiUtStrtoul64 * - * PARAMETERS: String - Null terminated string - * Base - Radix of the string: 16 or ACPI_ANY_BASE; - * ACPI_ANY_BASE means 'in behalf of ToInteger' - * RetInteger - Where the converted integer is returned + * PARAMETERS: String - Null terminated string + * Base - Radix of the string: 16 or 10 or + * ACPI_ANY_BASE + * MaxIntegerByteWidth - Maximum allowable integer,in bytes: + * 4 or 8 (32 or 64 bits) + * RetInteger - Where the converted integer is + * returned * * RETURN: Status and Converted value * * DESCRIPTION: Convert a string into an unsigned value. Performs either a - * 32-bit or 64-bit conversion, depending on the current mode - * of the interpreter. + * 32-bit or 64-bit conversion, depending on the input integer + * size (often the current mode of the interpreter). * - * NOTES: AcpiGbl_IntegerByteWidth should be set to the proper width. + * NOTES: Negative numbers are not supported, as they are not supported + * by ACPI. + * + * AcpiGbl_IntegerByteWidth should be set to the proper width. * For the core ACPICA code, this width depends on the DSDT - * version. For iASL, the default byte width is always 8. + * version. For iASL, the default byte width is always 8 for the + * parser, but error checking is performed later to flag cases + * where a 64-bit constant is defined in a 32-bit DSDT/SSDT. * * Does not support Octal strings, not needed at this time. * - * There is an earlier version of the function after this one, - * below. It is slightly different than this one, and the two - * may eventually may need to be merged. (01/2016). - * ******************************************************************************/ ACPI_STATUS AcpiUtStrtoul64 ( char *String, UINT32 Base, + UINT32 MaxIntegerByteWidth, UINT64 *RetInteger) { UINT32 ThisDigit = 0; UINT64 ReturnValue = 0; UINT64 Quotient; UINT64 Dividend; - UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE); - UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4); UINT8 ValidDigits = 0; UINT8 SignOf0x = 0; UINT8 Term = 0; @@ -290,6 +293,7 @@ AcpiUtStrtoul64 ( switch (Base) { case ACPI_ANY_BASE: + case 10: case 16: break; @@ -313,10 +317,10 @@ AcpiUtStrtoul64 ( String++; } - if (ToIntegerOp) + if (Base == ACPI_ANY_BASE) { /* - * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. + * Base equal to ACPI_ANY_BASE means 'Either decimal or hex'. * We need to determine if it is decimal or hexadecimal. */ if ((*String == '0') && (tolower ((int) *(String + 1)) == 'x')) @@ -337,7 +341,7 @@ AcpiUtStrtoul64 ( if (!(*String) || isspace ((int) *String) || *String == '\t') { - if (ToIntegerOp) + if (Base == ACPI_ANY_BASE) { goto ErrorExit; } @@ -348,10 +352,11 @@ AcpiUtStrtoul64 ( } /* - * Perform a 32-bit or 64-bit conversion, depending upon the current - * execution mode of the interpreter + * Perform a 32-bit or 64-bit conversion, depending upon the input + * byte width */ - Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; + Dividend = (MaxIntegerByteWidth <= ACPI_MAX32_BYTE_WIDTH) ? + ACPI_UINT32_MAX : ACPI_UINT64_MAX; /* Main loop: convert the string to a 32- or 64-bit integer */ @@ -386,7 +391,7 @@ AcpiUtStrtoul64 ( if (Term) { - if (ToIntegerOp) + if (Base == ACPI_ANY_BASE) { goto ErrorExit; } @@ -404,11 +409,12 @@ AcpiUtStrtoul64 ( ValidDigits++; - if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32))) + if (SignOf0x && ((ValidDigits > 16) || + ((ValidDigits > 8) && (MaxIntegerByteWidth <= ACPI_MAX32_BYTE_WIDTH)))) { /* * This is ToInteger operation case. - * No any restrictions for string-to-integer conversion, + * No restrictions for string-to-integer conversion, * see ACPI spec. */ goto ErrorExit; @@ -421,7 +427,7 @@ AcpiUtStrtoul64 ( if (ReturnValue > Quotient) { - if (ToIntegerOp) + if (Base == ACPI_ANY_BASE) { goto ErrorExit; } @@ -448,7 +454,8 @@ AllDone: ErrorExit: - /* Base was set/validated above */ + + /* Base was set/validated above (10 or 16) */ if (Base == 10) { @@ -460,9 +467,9 @@ ErrorExit: } } + #ifdef _OBSOLETE_FUNCTIONS -/* TBD: use version in ACPICA main code base? */ -/* DONE: 01/2016 */ +/* Removed: 01/2016 */ /******************************************************************************* * diff --git a/source/components/utilities/utprint.c b/source/components/utilities/utprint.c index 7656924d0f4d7..e01f1734a94ff 100644 --- a/source/components/utilities/utprint.c +++ b/source/components/utilities/utprint.c @@ -88,12 +88,6 @@ AcpiUtPutNumber ( BOOLEAN Upper); -/* Module globals */ - -static const char AcpiGbl_LowerHexDigits[] = "0123456789abcdef"; -static const char AcpiGbl_UpperHexDigits[] = "0123456789ABCDEF"; - - /******************************************************************************* * * FUNCTION: AcpiUtBoundStringLength diff --git a/source/components/utilities/uttrack.c b/source/components/utilities/uttrack.c index b6d6a33639bc6..9efa9d6ec75d8 100644 --- a/source/components/utilities/uttrack.c +++ b/source/components/utilities/uttrack.c @@ -100,7 +100,7 @@ AcpiUtRemoveAllocation ( ACPI_STATUS AcpiUtCreateList ( - char *ListName, + const char *ListName, UINT16 ObjectSize, ACPI_MEMORY_LIST **ReturnCache) { diff --git a/source/components/utilities/utxfinit.c b/source/components/utilities/utxfinit.c index a8ea3fdf49f45..2a518bc82d99f 100644 --- a/source/components/utilities/utxfinit.c +++ b/source/components/utilities/utxfinit.c @@ -168,25 +168,6 @@ AcpiEnableSubsystem ( */ AcpiGbl_EarlyInitialization = FALSE; - /* - * Install the default operation region handlers. These are the - * handlers that are defined by the ACPI specification to be - * "always accessible" -- namely, SystemMemory, SystemIO, and - * PCI_Config. This also means that no _REG methods need to be - * run for these address spaces. We need to have these handlers - * installed before any AML code can be executed, especially any - * module-level code (11/2015). - */ - if (!AcpiGbl_GroupModuleLevelCode) - { - Status = AcpiEvInstallRegionHandlers (); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization")); - return_ACPI_STATUS (Status); - } - } - #if (!ACPI_REDUCED_HARDWARE) /* Enable ACPI mode */ @@ -315,27 +296,23 @@ AcpiInitializeObjects ( if (AcpiGbl_GroupModuleLevelCode) { AcpiNsExecModuleCodeList (); - } - /* - * Initialize the objects that remain uninitialized. This runs the - * executable AML that may be part of the declaration of these objects: - * OperationRegions, BufferFields, Buffers, and Packages. - */ - if (!(Flags & ACPI_NO_OBJECT_INIT)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Completing Initialization of ACPI Objects\n")); - - Status = AcpiNsInitializeObjects (); - if (ACPI_FAILURE (Status)) + /* + * Initialize the objects that remain uninitialized. This + * runs the executable AML that may be part of the + * declaration of these objects: + * OperationRegions, BufferFields, Buffers, and Packages. + */ + if (!(Flags & ACPI_NO_OBJECT_INIT)) { - return_ACPI_STATUS (Status); + Status = AcpiNsInitializeObjects (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } } } - AcpiGbl_NamespaceInitialized = TRUE; - /* * Initialize all device/region objects in the namespace. This runs * the device _STA and _INI methods and region _REG methods. |
