diff options
Diffstat (limited to 'source')
32 files changed, 390 insertions, 107 deletions
diff --git a/source/common/dmtables.c b/source/common/dmtables.c index e5536ecf3979..2c779494b96f 100644 --- a/source/common/dmtables.c +++ b/source/common/dmtables.c @@ -508,6 +508,8 @@ AdParseTable ( AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)); ASL_CV_INIT_FILETREE(Table, AmlStart, AmlLength); + AcpiUtSetIntegerWidth (Table->Revision); + /* Create the root object */ AcpiGbl_ParseOpRoot = AcpiPsCreateScopeOp (AmlStart); @@ -543,7 +545,6 @@ AdParseTable ( } WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; - WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; Status = AcpiPsParseAml (WalkState); if (ACPI_FAILURE (Status)) diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index 9214cfdfc9ba..ce60b2dab958 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -220,6 +220,7 @@ CmDoCompile ( PrDoPreprocess (); AslGbl_CurrentLineNumber = 1; AslGbl_LogicalLineNumber = 1; + AslGbl_CurrentLineOffset = 0; if (AslGbl_PreprocessOnly) { @@ -282,25 +283,6 @@ CmDoCompile ( LsDumpParseTree (); - OpcGetIntegerWidth (AslGbl_ParseTreeRoot->Asl.Child); - UtEndEvent (Event); - - /* Pre-process parse tree for any operator transforms */ - - Event = UtBeginEvent ("Parse tree transforms"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n"); - TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, - TrAmlTransformWalkBegin, TrAmlTransformWalkEnd, NULL); - UtEndEvent (Event); - - /* Generate AML opcodes corresponding to the parse tokens */ - - Event = UtBeginEvent ("Generate AML opcodes"); - DbgPrint (ASL_DEBUG_OUTPUT, "Generating AML opcodes\n\n"); - TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, - OpcAmlOpcodeWalk, NULL); - UtEndEvent (Event); - UtEndEvent (FullCompile); return (AE_OK); @@ -331,6 +313,25 @@ CmDoAslMiddleAndBackEnd ( ACPI_STATUS Status; + OpcGetIntegerWidth (AslGbl_ParseTreeRoot->Asl.Child); + + /* Pre-process parse tree for any operator transforms */ + + Event = UtBeginEvent ("Parse tree transforms"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n"); + TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, + TrAmlTransformWalkBegin, TrAmlTransformWalkEnd, NULL); + UtEndEvent (Event); + + /* Generate AML opcodes corresponding to the parse tokens */ + + Event = UtBeginEvent ("Generate AML opcodes"); + DbgPrint (ASL_DEBUG_OUTPUT, "Generating AML opcodes\n\n"); + TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, + NULL, OpcAmlOpcodeWalk, NULL); + UtEndEvent (Event); + + /* Interpret and generate all compile-time constants */ Event = UtBeginEvent ("Constant folding via AML interpreter"); diff --git a/source/compiler/aslcompiler.y b/source/compiler/aslcompiler.y index c767c89a4337..8f0a512e8539 100644 --- a/source/compiler/aslcompiler.y +++ b/source/compiler/aslcompiler.y @@ -3442,7 +3442,7 @@ AddressKeyword ; AddressSpaceKeyword - : ByteConst {$$ = UtCheckIntegerRange ($1, 0x0A, 0xFF);} + : ByteConst {$$ = UtCheckIntegerRange ($1, ACPI_NUM_PREDEFINED_REGIONS, 0xFF);} | RegionSpaceKeyword {} ; @@ -4843,7 +4843,6 @@ OptionalXferSize /* Local support functions in C */ - /****************************************************************************** * * Local support functions @@ -4918,4 +4917,3 @@ UtGetOpName ( return ("[Unknown parser generator]"); #endif } - diff --git a/source/compiler/asldefine.h b/source/compiler/asldefine.h index 0ba08962047a..675a5870d56c 100644 --- a/source/compiler/asldefine.h +++ b/source/compiler/asldefine.h @@ -222,11 +222,11 @@ /* Misc */ -#define ASL_EXTERNAL_METHOD 255 -#define ASL_ABORT TRUE -#define ASL_NO_ABORT FALSE -#define ASL_EOF ACPI_UINT32_MAX -#define ASL_IGNORE_LINE (ACPI_UINT32_MAX -1) +#define ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS 255 +#define ASL_ABORT TRUE +#define ASL_NO_ABORT FALSE +#define ASL_EOF ACPI_UINT32_MAX +#define ASL_IGNORE_LINE (ACPI_UINT32_MAX -1) /* Listings */ diff --git a/source/compiler/aslerror.c b/source/compiler/aslerror.c index ae1f38acfe77..f6eab921e455 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -335,7 +335,7 @@ AeAddToErrorLog ( * PARAMETERS: OutputFile - Output file * Enode - Error node to print * PrematureEOF - True = PrematureEOF has been reached - * Total - Total legth of line + * Total - Total length of line * * RETURN: None * @@ -445,7 +445,7 @@ AeDecodeErrorMessageId ( * PARAMETERS: OutputFile - Output file * Enode - Error node to print * PrematureEOF - True = PrematureEOF has been reached - * Total - amount of characters printed so far + * Total - Number of characters printed so far * * * RETURN: Status @@ -527,6 +527,7 @@ AePrintErrorSourceLine ( fprintf (OutputFile, "\n"); return AE_OK; } + /* * Seek to the offset in the combined source file, * read the source line, and write it to the output. @@ -550,7 +551,8 @@ AePrintErrorSourceLine ( AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); return AE_IO_ERROR; } - /* Read/write the source line, up to the maximum line length */ + + /* Read/write the source line, up to the maximum line length */ while (RActual && SourceByte && (SourceByte != '\n')) { @@ -732,7 +734,7 @@ AePrintException ( * * RETURN: None * - * DESCRIPTION: Print the contents of an error nodes. This function is tailored + * DESCRIPTION: Print the contents of an error node. This function is tailored * to print error nodes that are SubErrors within ASL_ERROR_MSG * ******************************************************************************/ @@ -795,8 +797,8 @@ AePrintErrorLog ( * LogicalLineNumber - Cumulative line number * LogicalByteOffset - Byte offset in source file * Column - Column in current line - * Filename - source filename - * ExtraMessage - additional error message + * Filename - Source filename + * ExtraMessage - Additional error message * SourceLine - Line of error source code * SubError - SubError of this InputEnode * @@ -863,10 +865,17 @@ static void AslInitEnode ( Enode->FilenameLength = 6; } - FileNode = FlGetCurrentFileNode (); + /* + * Attempt to get the file node of the filename listed in the parse + * node. If the name doesn't exist in the global file node, it is + * because the file is included by #include or ASL include. In this + * case, get the current file node. The source output of the current + * file will contain the contents of the file listed in the parse node. + */ + FileNode = FlGetFileNode (ASL_FILE_INPUT, Filename); if (!FileNode) { - return; + FileNode = FlGetCurrentFileNode (); } Enode->SourceFilename = @@ -884,8 +893,8 @@ static void AslInitEnode ( * LineNumber - Actual file line number * Column - Column in current line * SourceLine - Actual source code line - * Filename - source filename - * ExtraMessage - additional error message + * Filename - Source filename + * ExtraMessage - Additional error message * * RETURN: None * @@ -918,8 +927,8 @@ AslCommonError2 ( * LogicalLineNumber - Cumulative line number * LogicalByteOffset - Byte offset in source file * Column - Column in current line - * Filename - source filename - * ExtraMessage - additional error message + * Filename - Source filename + * ExtraMessage - Additional error message * * RETURN: None * @@ -961,8 +970,8 @@ AslCommonError ( * LogicalLineNumber - Cumulative line number * LogicalByteOffset - Byte offset in source file * Column - Column in current line - * Filename - source filename - * Message - additional error message + * Filename - Source filename + * Message - Additional error message * SourceLine - Actual line of source code * SubError - Sub-error associated with this error * @@ -1025,7 +1034,7 @@ AslLogNewError ( * PARAMETERS: Level - Seriousness (Warning/error, etc.) * MessageId - Index into global message buffer * - * RETURN: UINT8 - modified level + * RETURN: UINT8 - Modified level * * DESCRIPTION: Get the modified level of exception codes that are reported as * errors from the -ww option. @@ -1369,7 +1378,7 @@ AslIsExceptionDisabled ( * MainMsg - Message pertaining to the MainOp * SubMsgId - Index into global message buffer * SubOp - Additional parse node for better message - * SubMsg - Message pertainint to SubOp + * SubMsg - Message pertaining to SubOp * * * RETURN: None @@ -1421,7 +1430,7 @@ AslDualParseOpError ( * PARAMETERS: Level - Seriousness (Warning/error, etc.) * MessageId - Index into global message buffer * Op - Parse node where error happened - * ExtraMessage - additional error message + * ExtraMessage - Additional error message * * RETURN: None * @@ -1459,7 +1468,7 @@ AslError ( * * PARAMETERS: Op - Parse node where error happened * Status - The ACPICA Exception - * ExtraMessage - additional error message + * ExtraMessage - Additional error message * Abort - TRUE -> Abort compilation * * RETURN: None diff --git a/source/compiler/aslfiles.c b/source/compiler/aslfiles.c index b9208c7c4492..dba05d35d33a 100644 --- a/source/compiler/aslfiles.c +++ b/source/compiler/aslfiles.c @@ -207,12 +207,6 @@ FlInitOneFile ( NewFileNode = ACPI_CAST_PTR (ASL_GLOBAL_FILE_NODE, UtLocalCacheCalloc (sizeof (ASL_GLOBAL_FILE_NODE))); - if (!NewFileNode) - { - AslError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, NULL, NULL); - return (AE_NO_MEMORY); - } - NewFileNode->ParserErrorDetected = FALSE; NewFileNode->Next = AslGbl_FilesList; @@ -420,8 +414,22 @@ ASL_GLOBAL_FILE_NODE * FlGetCurrentFileNode ( void) { - return (FlGetFileNode ( - ASL_FILE_INPUT,AslGbl_Files[ASL_FILE_INPUT].Filename)); + ASL_GLOBAL_FILE_NODE *FileNode = + FlGetFileNode (ASL_FILE_INPUT,AslGbl_Files[ASL_FILE_INPUT].Filename); + + + if (!FileNode) + { + /* + * If the current file node does not exist after initializing the file + * node structures, something went wrong and this is an unrecoverable + * condition. + */ + FlFileError (ASL_FILE_INPUT, ASL_MSG_COMPILER_INTERNAL); + AslAbort (); + } + + return (FileNode); } diff --git a/source/compiler/aslload.c b/source/compiler/aslload.c index db6c2d41eeef..6e3d7e7d99eb 100644 --- a/source/compiler/aslload.c +++ b/source/compiler/aslload.c @@ -357,7 +357,7 @@ LdLoadFieldElements ( * The name already exists in this scope * But continue processing the elements */ - AslDualParseOpError (ASL_WARNING, ASL_MSG_NAME_EXISTS, Child, + AslDualParseOpError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Child, Child->Asl.Value.String, ASL_MSG_FOUND_HERE, Node->Op, Node->Op->Asl.ExternalName); } @@ -986,12 +986,19 @@ FinishNode: Op->Asl.Node = Node; Node->Op = Op; - /* Set the actual data type if appropriate (EXTERNAL term only) */ - + /* + * Set the actual data type if appropriate (EXTERNAL term only) + * As of 11/19/2019, ASL External() does not support parameter + * counts. When an External method is loaded, the parameter count is + * unknown setting Node->Value to ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS + * indicates that the parameter count for this method is unknown. + * This information is used in ASL cross reference to help determine the + * parameter count through method calls. + */ if (ActualObjectType != ACPI_TYPE_ANY) { Node->Type = (UINT8) ActualObjectType; - Node->Value = ASL_EXTERNAL_METHOD; + Node->Value = ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS; } if (Op->Asl.ParseOpcode == PARSEOP_METHOD) diff --git a/source/compiler/aslmessages.c b/source/compiler/aslmessages.c index d132935234f2..ea118c0d43fc 100644 --- a/source/compiler/aslmessages.c +++ b/source/compiler/aslmessages.c @@ -368,7 +368,9 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_BUFFER_FIELD_OVERFLOW */ "Buffer field extends beyond end of target buffer", /* ASL_MSG_INVALID_SPECIAL_NAME */ "declaration of this named object outside root scope is illegal", /* ASL_MSG_INVALID_PROCESSOR_UID */ "_UID inside processor declaration must be an integer", -/* ASL_MSG_LEGACY_PROCESSOR_OP */ "Legacy Processor() keyword detected. Use Device() keyword instead." +/* ASL_MSG_LEGACY_PROCESSOR_OP */ "Legacy Processor() keyword detected. Use Device() keyword instead.", +/* ASL_MSG_NAMESTRING_LENGTH */ "NameString contains too many NameSegs (>255)", +/* ASL_MSG_CASE_FOUND_HERE */ "Original Case value below:" }; /* Table compiler */ diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index 47e5bf4314d8..385b730ff0c5 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -371,6 +371,8 @@ typedef enum ASL_MSG_INVALID_SPECIAL_NAME, ASL_MSG_INVALID_PROCESSOR_UID, ASL_MSG_LEGACY_PROCESSOR_OP, + ASL_MSG_NAMESTRING_LENGTH, + ASL_MSG_CASE_FOUND_HERE, /* These messages are used by the Data Table compiler only */ diff --git a/source/compiler/aslmethod.c b/source/compiler/aslmethod.c index 667eaaaf8a81..4b29fc9e7acd 100644 --- a/source/compiler/aslmethod.c +++ b/source/compiler/aslmethod.c @@ -586,7 +586,7 @@ MtMethodAnalysisWalkBegin ( /* Special typechecking for _HID */ - if (!strcmp (METHOD_NAME__HID, Op->Asl.NameSeg)) + if (ACPI_COMPARE_NAMESEG (METHOD_NAME__HID, Op->Asl.NameSeg)) { Next = Op->Asl.Child->Asl.Next; AnCheckId (Next, ASL_TYPE_HID); @@ -594,7 +594,7 @@ MtMethodAnalysisWalkBegin ( /* Special typechecking for _CID */ - else if (!strcmp (METHOD_NAME__CID, Op->Asl.NameSeg)) + else if (ACPI_COMPARE_NAMESEG (METHOD_NAME__CID, Op->Asl.NameSeg)) { Next = Op->Asl.Child->Asl.Next; diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index 7c17814966e4..7758610cfb35 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -219,7 +219,7 @@ AslCommandLine ( { exit (-1); } - exit (1); + exit (0); } /* Next parameter must be the input filename */ diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c index c43c1a9717dc..73c555a6749d 100644 --- a/source/compiler/aslstartup.c +++ b/source/compiler/aslstartup.c @@ -457,10 +457,6 @@ AslDoOneFile ( } FileNode = FlGetCurrentFileNode(); - if (!FileNode) - { - return (AE_ERROR); - } FileNode->OriginalInputFileSize = FlGetFileSize (ASL_FILE_INPUT); diff --git a/source/compiler/asltransform.c b/source/compiler/asltransform.c index 7dc642d880ac..c80afe3a6b44 100644 --- a/source/compiler/asltransform.c +++ b/source/compiler/asltransform.c @@ -151,6 +151,7 @@ #include "aslcompiler.h" #include "aslcompiler.y.h" +#include "acnamesp.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("asltransform") @@ -194,6 +195,16 @@ static void TrDoSwitch ( ACPI_PARSE_OBJECT *StartNode); +static void +TrCheckForDuplicateCase ( + ACPI_PARSE_OBJECT *CaseOp, + ACPI_PARSE_OBJECT *Predicate1); + +static BOOLEAN +TrCheckForBufferMatch ( + ACPI_PARSE_OBJECT *Next1, + ACPI_PARSE_OBJECT *Next2); + /******************************************************************************* * @@ -431,6 +442,7 @@ TrTransformSubtree ( ACPI_PARSE_OBJECT *Op) { ACPI_PARSE_OBJECT *MethodOp; + ACPI_NAMESTRING_INFO Info; if (Op->Asl.AmlOpcode == AML_RAW_DATA_BYTE) @@ -492,6 +504,22 @@ TrTransformSubtree ( Op->Asl.Value.String = "\\"; break; + case PARSEOP_NAMESTRING: + /* + * A NameString can be up to 255 (0xFF) individual NameSegs maximum + * (with 254 dot separators) - as per the ACPI specification. Note: + * Cannot check for NumSegments == 0 because things like + * Scope(\) are legal and OK. + */ + Info.ExternalName = Op->Asl.Value.String; + AcpiNsGetInternalNameLength (&Info); + + if (Info.NumSegments > 255) + { + AslError (ASL_ERROR, ASL_MSG_NAMESTRING_LENGTH, Op, NULL); + } + break; + case PARSEOP_UNLOAD: AslError (ASL_WARNING, ASL_MSG_UNLOAD, Op, NULL); @@ -510,7 +538,6 @@ TrTransformSubtree ( case PARSEOP_PROCESSOR: AslError (ASL_WARNING, ASL_MSG_LEGACY_PROCESSOR_OP, Op, Op->Asl.ExternalName); - break; default: @@ -646,6 +673,8 @@ TrDoSwitch ( if (Next->Asl.ParseOpcode == PARSEOP_CASE) { + TrCheckForDuplicateCase (Next, Next->Asl.Child); + if (CaseOp) { /* Add an ELSE to complete the previous CASE */ @@ -977,3 +1006,176 @@ TrDoSwitch ( BreakOp->Asl.Parent = StartNode; TrAmlInsertPeer (Conditional, BreakOp); } + + +/******************************************************************************* + * + * FUNCTION: TrCheckForDuplicateCase + * + * PARAMETERS: CaseOp - Parse node for first Case statement in list + * Predicate1 - Case value for the input CaseOp + * + * RETURN: None + * + * DESCRIPTION: Check for duplicate case values. Currently, only handles + * Integers, Strings and Buffers. No support for Package objects. + * + ******************************************************************************/ + +static void +TrCheckForDuplicateCase ( + ACPI_PARSE_OBJECT *CaseOp, + ACPI_PARSE_OBJECT *Predicate1) +{ + ACPI_PARSE_OBJECT *Next; + ACPI_PARSE_OBJECT *Predicate2; + + + /* Walk the list of CASE opcodes */ + + Next = CaseOp->Asl.Next; + while (Next) + { + if (Next->Asl.ParseOpcode == PARSEOP_CASE) + { + /* Emit error only once */ + + if (Next->Asl.CompileFlags & OP_IS_DUPLICATE) + { + goto NextCase; + } + + /* Check for a duplicate plain integer */ + + Predicate2 = Next->Asl.Child; + if ((Predicate1->Asl.ParseOpcode == PARSEOP_INTEGER) && + (Predicate2->Asl.ParseOpcode == PARSEOP_INTEGER)) + { + if (Predicate1->Asl.Value.Integer == Predicate2->Asl.Value.Integer) + { + goto FoundDuplicate; + } + } + + /* Check for pairs of the constants ZERO, ONE, ONES */ + + else if (((Predicate1->Asl.ParseOpcode == PARSEOP_ZERO) && + (Predicate2->Asl.ParseOpcode == PARSEOP_ZERO)) || + ((Predicate1->Asl.ParseOpcode == PARSEOP_ONE) && + (Predicate2->Asl.ParseOpcode == PARSEOP_ONE)) || + ((Predicate1->Asl.ParseOpcode == PARSEOP_ONES) && + (Predicate2->Asl.ParseOpcode == PARSEOP_ONES))) + { + goto FoundDuplicate; + } + + /* Check for a duplicate string constant (literal) */ + + else if ((Predicate1->Asl.ParseOpcode == PARSEOP_STRING_LITERAL) && + (Predicate2->Asl.ParseOpcode == PARSEOP_STRING_LITERAL)) + { + if (!strcmp (Predicate1->Asl.Value.String, + Predicate2->Asl.Value.String)) + { + goto FoundDuplicate; + } + } + + /* Check for a duplicate buffer constant */ + + else if ((Predicate1->Asl.ParseOpcode == PARSEOP_BUFFER) && + (Predicate2->Asl.ParseOpcode == PARSEOP_BUFFER)) + { + if (TrCheckForBufferMatch (Predicate1->Asl.Child, + Predicate2->Asl.Child)) + { + goto FoundDuplicate; + } + } + } + goto NextCase; + +FoundDuplicate: + /* Emit error message only once */ + + Next->Asl.CompileFlags |= OP_IS_DUPLICATE; + + AslDualParseOpError (ASL_ERROR, ASL_MSG_DUPLICATE_CASE, Next, + Next->Asl.Value.String, ASL_MSG_CASE_FOUND_HERE, CaseOp, + CaseOp->Asl.ExternalName); + +NextCase: + Next = Next->Asl.Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: TrCheckForBufferMatch + * + * PARAMETERS: Next1 - Parse node for first opcode in first buffer list + * (The DEFAULT_ARG or INTEGER node) + * Next2 - Parse node for first opcode in second buffer list + * (The DEFAULT_ARG or INTEGER node) + * + * RETURN: TRUE if buffers match, FALSE otherwise + * + * DESCRIPTION: Check for duplicate Buffer case values. + * + ******************************************************************************/ + +static BOOLEAN +TrCheckForBufferMatch ( + ACPI_PARSE_OBJECT *NextOp1, + ACPI_PARSE_OBJECT *NextOp2) +{ + + if (NextOp1->Asl.Value.Integer != NextOp2->Asl.Value.Integer) + { + return (FALSE); + } + + /* Start at the BYTECONST initializer node list */ + + NextOp1 = NextOp1->Asl.Next; + NextOp2 = NextOp2->Asl.Next; + + /* + * Walk both lists until either a mismatch is found, or one or more + * end-of-lists are found + */ + while (NextOp1 && NextOp2) + { + if ((NextOp1->Asl.ParseOpcode == PARSEOP_STRING_LITERAL) && + (NextOp2->Asl.ParseOpcode == PARSEOP_STRING_LITERAL)) + { + if (!strcmp (NextOp1->Asl.Value.String, NextOp2->Asl.Value.String)) + { + return (TRUE); + } + else + { + return (FALSE); + } + } + if ((UINT8) NextOp1->Asl.Value.Integer != (UINT8) NextOp2->Asl.Value.Integer) + { + return (FALSE); + } + + NextOp1 = NextOp1->Asl.Next; + NextOp2 = NextOp2->Asl.Next; + } + + /* Not a match if one of the lists is not at end-of-list */ + + if (NextOp1 || NextOp2) + { + return (FALSE); + } + + /* Otherwise, the buffers match */ + + return (TRUE); +} diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index 0faaec03dd8d..0ee94d6a927b 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -567,11 +567,6 @@ UtDisplayOneSummary ( /* Summary of main input and output files */ FileNode = FlGetCurrentFileNode (); - if (!FileNode) - { - fprintf (stderr, "Summary could not be generated"); - return; - } if (FileNode->ParserErrorDetected) { diff --git a/source/compiler/aslxref.c b/source/compiler/aslxref.c index d903ef1ba876..8a1f1a4c5e7f 100644 --- a/source/compiler/aslxref.c +++ b/source/compiler/aslxref.c @@ -1055,7 +1055,7 @@ XfNamespaceLocateBegin ( NextOp = NextOp->Asl.Next; } - if (Node->Value != ASL_EXTERNAL_METHOD && + if (Node->Value != ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS && Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL) { /* @@ -1064,8 +1064,17 @@ XfNamespaceLocateBegin ( */ if (PassedArgs != Node->Value) { - sprintf (AslGbl_MsgBuffer, "%s requires %u", Op->Asl.ExternalName, - Node->Value); + if (Node->Flags & ANOBJ_IS_EXTERNAL) + { + sprintf (AslGbl_MsgBuffer, + "according to previous use, %s requires %u", + Op->Asl.ExternalName, Node->Value); + } + else + { + sprintf (AslGbl_MsgBuffer, "%s requires %u", Op->Asl.ExternalName, + Node->Value); + } if (PassedArgs < Node->Value) { @@ -1077,6 +1086,22 @@ XfNamespaceLocateBegin ( } } } + + /* + * At this point, a method call to an external method has been + * detected. As of 11/19/2019, iASL does not support parameter counts + * for methods declared as external. Therefore, save the parameter + * count of the first method call and use this count check other + * method calls to ensure that the methods are being called with the + * same amount of parameters. + */ + else if (Node->Type == ACPI_TYPE_METHOD && + (Node->Flags & ANOBJ_IS_EXTERNAL) && + Node->Value == ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS && + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL) + { + Node->Value = PassedArgs; + } } /* 4) Check for an ASL Field definition */ diff --git a/source/compiler/dtcompile.c b/source/compiler/dtcompile.c index bdd8c1b70b8d..6c52f98987cd 100644 --- a/source/compiler/dtcompile.c +++ b/source/compiler/dtcompile.c @@ -261,25 +261,15 @@ DtDoCompile ( UtEndEvent (Event); FileNode = FlGetCurrentFileNode (); - if (!FileNode) - { - fprintf (stderr, "Summary for %s could not be generated", - AslGbl_Files[ASL_FILE_INPUT].Filename); - } - else - { - FileNode->TotalLineCount = AslGbl_CurrentLineNumber; - FileNode->OriginalInputFileSize = AslGbl_InputByteCount; - DbgPrint (ASL_PARSE_OUTPUT, "Line count: %u input file size: %u\n", - FileNode->TotalLineCount, FileNode->OriginalInputFileSize); - } + + FileNode->TotalLineCount = AslGbl_CurrentLineNumber; + FileNode->OriginalInputFileSize = AslGbl_InputByteCount; + DbgPrint (ASL_PARSE_OUTPUT, "Line count: %u input file size: %u\n", + FileNode->TotalLineCount, FileNode->OriginalInputFileSize); if (ACPI_FAILURE (Status)) { - if (FileNode) - { - FileNode->ParserErrorDetected = TRUE; - } + FileNode->ParserErrorDetected = TRUE; /* TBD: temporary error message. Msgs should come from function above */ @@ -306,11 +296,8 @@ DtDoCompile ( /* Save the compile time statistics to the current file node */ - if (FileNode) - { - FileNode->TotalFields = AslGbl_InputFieldCount; - FileNode->OutputByteLength = AslGbl_TableLength; - } + FileNode->TotalFields = AslGbl_InputFieldCount; + FileNode->OutputByteLength = AslGbl_TableLength; return (Status); } diff --git a/source/compiler/dtcompiler.h b/source/compiler/dtcompiler.h index 7c78b55bafa7..427051c31b92 100644 --- a/source/compiler/dtcompiler.h +++ b/source/compiler/dtcompiler.h @@ -459,7 +459,6 @@ DtCreateTableUnit ( UINT32 Column); - /* dtparser - lex/yacc files */ UINT64 DtCompilerParserResult; /* Expression return value */ diff --git a/source/compiler/dttable2.c b/source/compiler/dttable2.c index bbaaafaa763b..550cca131475 100644 --- a/source/compiler/dttable2.c +++ b/source/compiler/dttable2.c @@ -1662,6 +1662,7 @@ DtCompileSlit ( "Found %u entries, must match LocalityCount: %u", LocalityListLength, Localities); DtError (ASL_ERROR, ASL_MSG_ENTRY_LIST, EndOfFieldList, AslGbl_MsgBuffer); + ACPI_FREE (LocalityBuffer); return (AE_LIMIT); } diff --git a/source/components/debugger/dbinput.c b/source/components/debugger/dbinput.c index c854cb37a7fe..d498c9e0fec6 100644 --- a/source/components/debugger/dbinput.c +++ b/source/components/debugger/dbinput.c @@ -1019,7 +1019,7 @@ AcpiDbCommandDispatch ( if (ACPI_FAILURE (Status) || Temp64 >= ACPI_NUM_PREDEFINED_REGIONS) { AcpiOsPrintf ( - "Invalid adress space ID: must be between 0 and %u inclusive\n", + "Invalid address space ID: must be between 0 and %u inclusive\n", ACPI_NUM_PREDEFINED_REGIONS - 1); return (AE_OK); } diff --git a/source/components/debugger/dbnames.c b/source/components/debugger/dbnames.c index ac366ab04ca2..5521562ab73b 100644 --- a/source/components/debugger/dbnames.c +++ b/source/components/debugger/dbnames.c @@ -807,7 +807,6 @@ AcpiDbWalkForFields ( } - /******************************************************************************* * * FUNCTION: AcpiDbWalkForSpecificObjects diff --git a/source/components/dispatcher/dsfield.c b/source/components/dispatcher/dsfield.c index 5477686f1b5c..b81aaeb97d02 100644 --- a/source/components/dispatcher/dsfield.c +++ b/source/components/dispatcher/dsfield.c @@ -413,7 +413,7 @@ Cleanup: * FUNCTION: AcpiDsGetFieldNames * * PARAMETERS: Info - CreateField info structure - * ` WalkState - Current method state + * WalkState - Current method state * Arg - First parser arg for the field name list * * RETURN: Status diff --git a/source/components/dispatcher/dsopcode.c b/source/components/dispatcher/dsopcode.c index acf1ff4e1d19..526fc8470f8e 100644 --- a/source/components/dispatcher/dsopcode.c +++ b/source/components/dispatcher/dsopcode.c @@ -374,6 +374,7 @@ AcpiDsInitBufferField ( } ObjDesc->BufferField.BufferObj = BufferDesc; + ObjDesc->BufferField.IsCreateField = AmlOpcode == AML_CREATE_FIELD_OP; /* Reference count for BufferDesc inherits ObjDesc count */ diff --git a/source/components/dispatcher/dswload.c b/source/components/dispatcher/dswload.c index b55794281798..fa6b80e9a7a4 100644 --- a/source/components/dispatcher/dswload.c +++ b/source/components/dispatcher/dswload.c @@ -567,6 +567,28 @@ AcpiDsLoad1EndOp ( Op = WalkState->Op; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); + /* + * Disassembler: handle create field operators here. + * + * CreateBufferField is a deferred op that is typically processed in load + * pass 2. However, disassembly of control method contents walk the parse + * tree with ACPI_PARSE_LOAD_PASS1 and AML_CREATE operators are processed + * in a later walk. This is a problem when there is a control method that + * has the same name as the AML_CREATE object. In this case, any use of the + * name segment will be detected as a method call rather than a reference + * to a buffer field. + * + * This earlier creation during disassembly solves this issue by inserting + * the named object in the ACPI namespace so that references to this name + * would be a name string rather than a method call. + */ + if ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) && + (WalkState->OpInfo->Flags & AML_CREATE)) + { + Status = AcpiDsCreateBufferField (Op, WalkState); + return_ACPI_STATUS (Status); + } + /* We are only interested in opcodes that have an associated name */ if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD))) diff --git a/source/components/executer/exfield.c b/source/components/executer/exfield.c index b35e6a4ef4ae..dc97d40450eb 100644 --- a/source/components/executer/exfield.c +++ b/source/components/executer/exfield.c @@ -246,7 +246,8 @@ AcpiExGetProtocolBufferLength ( * RETURN: Status * * DESCRIPTION: Read from a named field. Returns either an Integer or a - * Buffer, depending on the size of the field. + * Buffer, depending on the size of the field and whether if a + * field is created by the CreateField() operator. * ******************************************************************************/ @@ -310,12 +311,17 @@ AcpiExReadDataFromField ( * the use of arithmetic operators on the returned value if the * field size is equal or smaller than an Integer. * + * However, all buffer fields created by CreateField operator needs to + * remain as a buffer to match other AML interpreter implementations. + * * Note: Field.length is in bits. */ BufferLength = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES ( ObjDesc->Field.BitLength); - if (BufferLength > AcpiGbl_IntegerByteWidth) + if (BufferLength > AcpiGbl_IntegerByteWidth || + (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD && + ObjDesc->BufferField.IsCreateField)) { /* Field is too large for an Integer, create a Buffer instead */ diff --git a/source/components/hardware/hwxfsleep.c b/source/components/hardware/hwxfsleep.c index 78dc19020334..6eff7f6adb76 100644 --- a/source/components/hardware/hwxfsleep.c +++ b/source/components/hardware/hwxfsleep.c @@ -192,7 +192,7 @@ static ACPI_SLEEP_FUNCTIONS AcpiSleepDispatch[] = ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacyWakePrep)), ACPI_STRUCT_INIT (ExtendedFunction, AcpiHwExtendedWakePrep) }, - {ACPI_STRUCT_INIT (Legacy_function, + {ACPI_STRUCT_INIT (LegacyFunction, ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacyWake)), ACPI_STRUCT_INIT (ExtendedFunction, AcpiHwExtendedWake) } diff --git a/source/components/utilities/utids.c b/source/components/utilities/utids.c index 513548c24a9e..5fcfbf66809e 100644 --- a/source/components/utilities/utids.c +++ b/source/components/utilities/utids.c @@ -466,8 +466,7 @@ AcpiUtExecute_CID ( { /* Copy the String CID from the returned object */ - AcpiUtSafeStrcpy (NextIdString, CidObjects[i]->String.Length + 1, - CidObjects[i]->String.Pointer); + strcpy (NextIdString, CidObjects[i]->String.Pointer); Length = CidObjects[i]->String.Length + 1; } diff --git a/source/include/acobject.h b/source/include/acobject.h index 74feb8d93da9..d04fe0c64cd7 100644 --- a/source/include/acobject.h +++ b/source/include/acobject.h @@ -489,6 +489,7 @@ typedef struct acpi_object_buffer_field { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO + BOOLEAN IsCreateField; /* Special case for objects created by CreateField() */ union acpi_operand_object *BufferObj; /* Containing Buffer object */ } ACPI_OBJECT_BUFFER_FIELD; diff --git a/source/include/acpixf.h b/source/include/acpixf.h index 62e379096783..15a02a306c59 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -154,7 +154,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20191018 +#define ACPI_CA_VERSION 0x20191213 #include "acconfig.h" #include "actypes.h" diff --git a/source/include/platform/acenv.h b/source/include/platform/acenv.h index 46eeb9df520c..bd6816a9b700 100644 --- a/source/include/platform/acenv.h +++ b/source/include/platform/acenv.h @@ -270,6 +270,21 @@ #define ACPI_DISASSEMBLER 1 #endif +/* + * acpisrc CR\LF support + * Unix file line endings do not include the carriage return. + * If the acpisrc utility is being built using a microsoft compiler, it means + * that it will be running on a windows machine which means that the output is + * expected to have CR/LF newlines. If the acpisrc utility is built with + * anything else, it will likely run on a system with LF newlines. This flag + * tells the acpisrc utility that newlines will be in the LF format. + */ +#if defined(ACPI_SRC_APP) && !defined(_MSC_VER) +#define ACPI_SRC_OS_LF_ONLY 1 +#else +#define ACPI_SRC_OS_LF_ONLY 0 +#endif + /*! [Begin] no source code translation */ /****************************************************************************** diff --git a/source/tools/acpinames/anstubs.c b/source/tools/acpinames/anstubs.c index 5b56cf1eaa01..e49dfaf75981 100644 --- a/source/tools/acpinames/anstubs.c +++ b/source/tools/acpinames/anstubs.c @@ -506,4 +506,3 @@ AcpiDsExecEndOp ( return (AE_NOT_IMPLEMENTED); } #endif - diff --git a/source/tools/acpisrc/asmain.c b/source/tools/acpisrc/asmain.c index 89b04bf968e7..aed3786c5914 100644 --- a/source/tools/acpisrc/asmain.c +++ b/source/tools/acpisrc/asmain.c @@ -562,6 +562,13 @@ main ( ConversionTable->SourceFunctions &= ~CVT_REMOVE_DEBUG_MACROS; } + /* + * Set LF only support. Note ACPI_SRC_OS_LF_ONLY indicates that newlines + * are represented as LF only rather than CR/LF + */ + ConversionTable->Flags |= ACPI_SRC_OS_LF_ONLY; + Gbl_IgnoreLoneLineFeeds = ACPI_SRC_OS_LF_ONLY; + /* Check source and target paths and files */ if (AsExaminePaths (ConversionTable, SourcePath, TargetPath, &FileType)) diff --git a/source/tools/acpisrc/astable.c b/source/tools/acpisrc/astable.c index b6706c3d58ea..2e4d8f40d86f 100644 --- a/source/tools/acpisrc/astable.c +++ b/source/tools/acpisrc/astable.c @@ -464,6 +464,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_RASF_PARAMETER_BLOCK", SRC_TYPE_STRUCT}, {"ACPI_RASF_PATROL_SCRUB_PARAMETER", SRC_TYPE_STRUCT}, {"ACPI_RASF_SHARED_MEMORY", SRC_TYPE_STRUCT}, + {"ACPI_REGION_WALK_INFO", SRC_TYPE_STRUCT}, {"ACPI_REPAIR_FUNCTION", SRC_TYPE_SIMPLE}, {"ACPI_REPAIR_INFO", SRC_TYPE_STRUCT}, {"ACPI_REG_WALK_INFO", SRC_TYPE_STRUCT}, |