2 /******************************************************************************
4 * Module Name: aslanalyze.c - check for semantic errors
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
73 * 3.4. Intel retains all right, title, and interest in and to the Original
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
118 #include <contrib/dev/acpica/compiler/aslcompiler.h>
119 #include "aslcompiler.y.h"
120 #include <contrib/dev/acpica/include/acparser.h>
121 #include <contrib/dev/acpica/include/amlcode.h>
123 #define _COMPONENT ACPI_COMPILER
124 ACPI_MODULE_NAME ("aslanalyze")
126 /* Local prototypes */
129 AnMapArgTypeToBtype (
143 ACPI_PARSE_OBJECT *Op);
146 AnMapObjTypeToBtype (
147 ACPI_PARSE_OBJECT *Op);
150 AnLastStatementIsReturn (
151 ACPI_PARSE_OBJECT *Op);
154 AnCheckMethodReturnValue (
155 ACPI_PARSE_OBJECT *Op,
156 const ACPI_OPCODE_INFO *OpInfo,
157 ACPI_PARSE_OBJECT *ArgOp,
158 UINT32 RequiredBtypes,
159 UINT32 ThisNodeBtype);
163 ACPI_PARSE_OBJECT *Op);
166 AnGetInternalMethodReturnType (
167 ACPI_PARSE_OBJECT *Op);
171 ACPI_PARSE_OBJECT *Op);
174 /*******************************************************************************
176 * FUNCTION: AnIsInternalMethod
178 * PARAMETERS: Op - Current op
182 * DESCRIPTION: Check for an internal control method.
184 ******************************************************************************/
188 ACPI_PARSE_OBJECT *Op)
191 if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) ||
192 (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI")))
201 /*******************************************************************************
203 * FUNCTION: AnGetInternalMethodReturnType
205 * PARAMETERS: Op - Current op
209 * DESCRIPTION: Get the return type of an internal method
211 ******************************************************************************/
214 AnGetInternalMethodReturnType (
215 ACPI_PARSE_OBJECT *Op)
218 if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) ||
219 (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI")))
221 return (ACPI_BTYPE_STRING);
228 /*******************************************************************************
230 * FUNCTION: AnMapArgTypeToBtype
232 * PARAMETERS: ArgType - The ARGI required type(s) for this argument,
233 * from the opcode info table
235 * RETURN: The corresponding Bit-encoded types
237 * DESCRIPTION: Convert an encoded ARGI required argument type code into a
238 * bitfield type code. Implements the implicit source conversion
241 ******************************************************************************/
244 AnMapArgTypeToBtype (
254 return (ACPI_BTYPE_OBJECTS_AND_REFS);
257 return (ACPI_BTYPE_PACKAGE);
260 return (ACPI_BTYPE_EVENT);
263 return (ACPI_BTYPE_MUTEX);
267 * DDBHandleObject := SuperName
268 * ACPI_BTYPE_REFERENCE: Index reference as parameter of Load/Unload
270 return (ACPI_BTYPE_DDB_HANDLE | ACPI_BTYPE_REFERENCE);
272 /* Interchangeable types */
274 * Source conversion rules:
275 * Integer, String, and Buffer are all interchangeable
280 case ARGI_BUFFER_OR_STRING:
281 case ARGI_COMPUTEDATA:
282 return (ACPI_BTYPE_COMPUTE_DATA);
286 case ARGI_INTEGER_REF:
287 return (ACPI_BTYPE_INTEGER);
289 case ARGI_OBJECT_REF:
290 return (ACPI_BTYPE_ALL_OBJECTS);
292 case ARGI_DEVICE_REF:
293 return (ACPI_BTYPE_DEVICE_OBJECTS);
296 return (ACPI_BTYPE_REFERENCE);
299 case ARGI_FIXED_TARGET:
300 case ARGI_SIMPLE_TARGET:
301 return (ACPI_BTYPE_OBJECTS_AND_REFS);
305 case ARGI_DATAOBJECT:
308 * Buffer, string, package or reference to a Op -
309 * Used only by SizeOf operator
311 return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER |
312 ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE);
314 case ARGI_COMPLEXOBJ:
316 /* Buffer, String, or package */
318 return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | ACPI_BTYPE_PACKAGE);
320 case ARGI_REF_OR_STRING:
321 return (ACPI_BTYPE_STRING | ACPI_BTYPE_REFERENCE);
323 case ARGI_REGION_OR_BUFFER:
325 /* Used by Load() only. Allow buffers in addition to regions/fields */
327 return (ACPI_BTYPE_REGION | ACPI_BTYPE_BUFFER | ACPI_BTYPE_FIELD_UNIT);
329 case ARGI_DATAREFOBJ:
330 return (ACPI_BTYPE_INTEGER |ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER |
331 ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE);
337 return (ACPI_BTYPE_OBJECTS_AND_REFS);
341 /*******************************************************************************
343 * FUNCTION: AnMapEtypeToBtype
345 * PARAMETERS: Etype - Encoded ACPI Type
347 * RETURN: Btype corresponding to the Etype
349 * DESCRIPTION: Convert an encoded ACPI type to a bitfield type applying the
350 * operand conversion rules. In other words, returns the type(s)
351 * this Etype is implicitly converted to during interpretation.
353 ******************************************************************************/
361 if (Etype == ACPI_TYPE_ANY)
363 return ACPI_BTYPE_OBJECTS_AND_REFS;
366 /* Try the standard ACPI data types */
368 if (Etype <= ACPI_TYPE_EXTERNAL_MAX)
371 * This switch statement implements the allowed operand conversion
372 * rules as per the "ASL Data Types" section of the ACPI
377 case ACPI_TYPE_INTEGER:
378 return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_DDB_HANDLE);
380 case ACPI_TYPE_STRING:
381 case ACPI_TYPE_BUFFER:
382 return (ACPI_BTYPE_COMPUTE_DATA);
384 case ACPI_TYPE_PACKAGE:
385 return (ACPI_BTYPE_PACKAGE);
387 case ACPI_TYPE_FIELD_UNIT:
388 return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT);
390 case ACPI_TYPE_BUFFER_FIELD:
391 return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_BUFFER_FIELD);
393 case ACPI_TYPE_DDB_HANDLE:
394 return (ACPI_BTYPE_INTEGER | ACPI_BTYPE_DDB_HANDLE);
396 case ACPI_BTYPE_DEBUG_OBJECT:
398 /* Cannot be used as a source operand */
403 return (1 << (Etype - 1));
407 /* Try the internal data types */
411 case ACPI_TYPE_LOCAL_REGION_FIELD:
412 case ACPI_TYPE_LOCAL_BANK_FIELD:
413 case ACPI_TYPE_LOCAL_INDEX_FIELD:
415 /* Named fields can be either Integer/Buffer/String */
417 return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT);
419 case ACPI_TYPE_LOCAL_ALIAS:
421 return (ACPI_BTYPE_INTEGER);
424 case ACPI_TYPE_LOCAL_RESOURCE:
425 case ACPI_TYPE_LOCAL_RESOURCE_FIELD:
427 return (ACPI_BTYPE_REFERENCE);
430 printf ("Unhandled encoded type: %X\n", Etype);
436 /*******************************************************************************
438 * FUNCTION: AnFormatBtype
440 * PARAMETERS: Btype - Bitfield of ACPI types
441 * Buffer - Where to put the ascii string
445 * DESCRIPTION: Convert a Btype to a string of ACPI types
447 ******************************************************************************/
455 BOOLEAN First = TRUE;
462 strcat (Buffer, "NoReturnValue");
466 for (Type = 1; Type <= ACPI_TYPE_EXTERNAL_MAX; Type++)
468 if (Btype & 0x00000001)
472 strcat (Buffer, "|");
475 strcat (Buffer, AcpiUtGetTypeName (Type));
480 if (Btype & 0x00000001)
484 strcat (Buffer, "|");
487 strcat (Buffer, "Reference");
491 if (Btype & 0x00000001)
495 strcat (Buffer, "|");
498 strcat (Buffer, "Resource");
503 /*******************************************************************************
505 * FUNCTION: AnGetBtype
507 * PARAMETERS: Op - Parse node whose type will be returned.
509 * RETURN: The Btype associated with the Op.
511 * DESCRIPTION: Get the (bitfield) ACPI type associated with the parse node.
512 * Handles the case where the node is a name or method call and
513 * the actual type must be obtained from the namespace node.
515 ******************************************************************************/
519 ACPI_PARSE_OBJECT *Op)
521 ACPI_NAMESPACE_NODE *Node;
522 ACPI_PARSE_OBJECT *ReferencedNode;
523 UINT32 ThisNodeBtype = 0;
526 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
527 (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
528 (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
533 DbgPrint (ASL_DEBUG_OUTPUT,
534 "No attached Nsnode: [%s] at line %d name [%s], ignoring typecheck\n",
535 Op->Asl.ParseOpName, Op->Asl.LineNumber,
536 Op->Asl.ExternalName);
537 return ACPI_UINT32_MAX;
540 ThisNodeBtype = AnMapEtypeToBtype (Node->Type);
543 AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
544 "could not map type");
548 * Since it was a named reference, enable the
551 ThisNodeBtype |= ACPI_BTYPE_REFERENCE;
553 if (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)
555 ReferencedNode = Node->Op;
558 /* Check for an internal method */
560 if (AnIsInternalMethod (Op))
562 return (AnGetInternalMethodReturnType (Op));
565 AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
567 return ACPI_UINT32_MAX;
570 if (ReferencedNode->Asl.CompileFlags & NODE_METHOD_TYPED)
572 ThisNodeBtype = ReferencedNode->Asl.AcpiBtype;
576 return (ACPI_UINT32_MAX -1);
582 ThisNodeBtype = Op->Asl.AcpiBtype;
585 return (ThisNodeBtype);
589 /*******************************************************************************
591 * FUNCTION: AnMapObjTypeToBtype
593 * PARAMETERS: Op - A parse node
597 * DESCRIPTION: Map object to the associated "Btype"
599 ******************************************************************************/
602 AnMapObjTypeToBtype (
603 ACPI_PARSE_OBJECT *Op)
606 switch (Op->Asl.ParseOpcode)
608 case PARSEOP_OBJECTTYPE_BFF: /* "BuffFieldObj" */
609 return (ACPI_BTYPE_BUFFER_FIELD);
611 case PARSEOP_OBJECTTYPE_BUF: /* "BuffObj" */
612 return (ACPI_BTYPE_BUFFER);
614 case PARSEOP_OBJECTTYPE_DDB: /* "DDBHandleObj" */
615 return (ACPI_BTYPE_DDB_HANDLE);
617 case PARSEOP_OBJECTTYPE_DEV: /* "DeviceObj" */
618 return (ACPI_BTYPE_DEVICE);
620 case PARSEOP_OBJECTTYPE_EVT: /* "EventObj" */
621 return (ACPI_BTYPE_EVENT);
623 case PARSEOP_OBJECTTYPE_FLD: /* "FieldUnitObj" */
624 return (ACPI_BTYPE_FIELD_UNIT);
626 case PARSEOP_OBJECTTYPE_INT: /* "IntObj" */
627 return (ACPI_BTYPE_INTEGER);
629 case PARSEOP_OBJECTTYPE_MTH: /* "MethodObj" */
630 return (ACPI_BTYPE_METHOD);
632 case PARSEOP_OBJECTTYPE_MTX: /* "MutexObj" */
633 return (ACPI_BTYPE_MUTEX);
635 case PARSEOP_OBJECTTYPE_OPR: /* "OpRegionObj" */
636 return (ACPI_BTYPE_REGION);
638 case PARSEOP_OBJECTTYPE_PKG: /* "PkgObj" */
639 return (ACPI_BTYPE_PACKAGE);
641 case PARSEOP_OBJECTTYPE_POW: /* "PowerResObj" */
642 return (ACPI_BTYPE_POWER);
644 case PARSEOP_OBJECTTYPE_STR: /* "StrObj" */
645 return (ACPI_BTYPE_STRING);
647 case PARSEOP_OBJECTTYPE_THZ: /* "ThermalZoneObj" */
648 return (ACPI_BTYPE_THERMAL);
650 case PARSEOP_OBJECTTYPE_UNK: /* "UnknownObj" */
651 return (ACPI_BTYPE_OBJECTS_AND_REFS);
659 /*******************************************************************************
661 * FUNCTION: AnMethodAnalysisWalkBegin
663 * PARAMETERS: ASL_WALK_CALLBACK
667 * DESCRIPTION: Descending callback for the analysis walk. Check methods for:
668 * 1) Initialized local variables
672 ******************************************************************************/
675 AnMethodAnalysisWalkBegin (
676 ACPI_PARSE_OBJECT *Op,
680 ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context;
681 ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack;
682 ACPI_PARSE_OBJECT *Next;
683 UINT32 RegisterNumber;
685 char LocalName[] = "Local0";
686 char ArgName[] = "Arg0";
687 ACPI_PARSE_OBJECT *ArgNode;
688 ACPI_PARSE_OBJECT *NextType;
689 ACPI_PARSE_OBJECT *NextParamType;
690 UINT8 ActualArgs = 0;
693 switch (Op->Asl.ParseOpcode)
699 /* Create and init method info */
701 MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO));
702 MethodInfo->Next = WalkInfo->MethodStack;
705 WalkInfo->MethodStack = MethodInfo;
707 /* Get the name node, ignored here */
709 Next = Op->Asl.Child;
711 /* Get the NumArguments node */
713 Next = Next->Asl.Next;
714 MethodInfo->NumArguments = (UINT8)
715 (((UINT8) Next->Asl.Value.Integer) & 0x07);
717 /* Get the SerializeRule and SyncLevel nodes, ignored here */
719 Next = Next->Asl.Next;
720 Next = Next->Asl.Next;
723 /* Get the ReturnType node */
725 Next = Next->Asl.Next;
727 NextType = Next->Asl.Child;
730 /* Get and map each of the ReturnTypes */
732 MethodInfo->ValidReturnTypes |= AnMapObjTypeToBtype (NextType);
733 NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
734 NextType = NextType->Asl.Next;
737 /* Get the ParameterType node */
739 Next = Next->Asl.Next;
741 NextType = Next->Asl.Child;
744 if (NextType->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
746 NextParamType = NextType->Asl.Child;
747 while (NextParamType)
749 MethodInfo->ValidArgTypes[ActualArgs] |= AnMapObjTypeToBtype (NextParamType);
750 NextParamType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
751 NextParamType = NextParamType->Asl.Next;
756 MethodInfo->ValidArgTypes[ActualArgs] =
757 AnMapObjTypeToBtype (NextType);
758 NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
762 NextType = NextType->Asl.Next;
765 if ((MethodInfo->NumArguments) &&
766 (MethodInfo->NumArguments != ActualArgs))
768 /* error: Param list did not match number of args */
771 /* Allow numarguments == 0 for Function() */
773 if ((!MethodInfo->NumArguments) && (ActualArgs))
775 MethodInfo->NumArguments = ActualArgs;
776 ArgNode->Asl.Value.Integer |= ActualArgs;
780 * Actual arguments are initialized at method entry.
781 * All other ArgX "registers" can be used as locals, so we
782 * track their initialization.
784 for (i = 0; i < MethodInfo->NumArguments; i++)
786 MethodInfo->ArgInitialized[i] = TRUE;
791 case PARSEOP_METHODCALL:
794 (Op->Asl.Node == MethodInfo->Op->Asl.Node))
796 AslError (ASL_REMARK, ASL_MSG_RECURSION, Op, Op->Asl.ExternalName);
813 * Local was used outside a control method, or there was an error
814 * in the method declaration.
816 AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName);
820 RegisterNumber = (Op->Asl.AmlOpcode & 0x000F);
823 * If the local is being used as a target, mark the local
826 if (Op->Asl.CompileFlags & NODE_IS_TARGET)
828 MethodInfo->LocalInitialized[RegisterNumber] = TRUE;
832 * Otherwise, this is a reference, check if the local
833 * has been previously initialized.
835 * The only operator that accepts an uninitialized value is ObjectType()
837 else if ((!MethodInfo->LocalInitialized[RegisterNumber]) &&
838 (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE))
840 LocalName[strlen (LocalName) -1] = (char) (RegisterNumber + 0x30);
841 AslError (ASL_ERROR, ASL_MSG_LOCAL_INIT, Op, LocalName);
857 * Arg was used outside a control method, or there was an error
858 * in the method declaration.
860 AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName);
864 RegisterNumber = (Op->Asl.AmlOpcode & 0x000F) - 8;
865 ArgName[strlen (ArgName) -1] = (char) (RegisterNumber + 0x30);
868 * If the Arg is being used as a target, mark the local
871 if (Op->Asl.CompileFlags & NODE_IS_TARGET)
873 MethodInfo->ArgInitialized[RegisterNumber] = TRUE;
877 * Otherwise, this is a reference, check if the Arg
878 * has been previously initialized.
880 * The only operator that accepts an uninitialized value is ObjectType()
882 else if ((!MethodInfo->ArgInitialized[RegisterNumber]) &&
883 (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE))
885 AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName);
888 /* Flag this arg if it is not a "real" argument to the method */
890 if (RegisterNumber >= MethodInfo->NumArguments)
892 AslError (ASL_REMARK, ASL_MSG_NOT_PARAMETER, Op, ArgName);
902 * Probably was an error in the method declaration,
903 * no additional error here
905 ACPI_WARNING ((AE_INFO, "%p, No parent method", Op));
909 /* Child indicates a return value */
911 if ((Op->Asl.Child) &&
912 (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
914 MethodInfo->NumReturnWithValue++;
918 MethodInfo->NumReturnNoValue++;
924 case PARSEOP_CONTINUE:
926 Next = Op->Asl.Parent;
929 if (Next->Asl.ParseOpcode == PARSEOP_WHILE)
933 Next = Next->Asl.Parent;
938 AslError (ASL_ERROR, ASL_MSG_NO_WHILE, Op, NULL);
945 /* We can range check if the argument is an integer */
947 if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) &&
948 (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX))
950 AslError (ASL_ERROR, ASL_MSG_INVALID_TIME, Op, NULL);
958 case PARSEOP_OPERATIONREGION:
959 case PARSEOP_POWERRESOURCE:
960 case PARSEOP_PROCESSOR:
961 case PARSEOP_THERMALZONE:
964 * The first operand is a name to be created in the namespace.
965 * Check against the reserved list.
967 i = ApCheckForPredefinedName (Op, Op->Asl.NameSeg);
968 if (i < ACPI_VALID_RESERVED_NAME_MAX)
970 AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, Op, Op->Asl.ExternalName);
977 /* Typecheck any predefined names statically defined with Name() */
979 ApCheckForPredefinedObject (Op, Op->Asl.NameSeg);
981 /* Special typechecking for _HID */
983 if (!ACPI_STRCMP (METHOD_NAME__HID, Op->Asl.NameSeg))
985 Next = Op->Asl.Child->Asl.Next;
986 if (Next->Asl.ParseOpcode == PARSEOP_STRING_LITERAL)
989 * _HID is a string, all characters must be alphanumeric.
990 * One of the things we want to catch here is the use of
991 * a leading asterisk in the string.
993 for (i = 0; Next->Asl.Value.String[i]; i++)
995 if (!isalnum ((int) Next->Asl.Value.String[i]))
997 AslError (ASL_ERROR, ASL_MSG_ALPHANUMERIC_STRING,
998 Next, Next->Asl.Value.String);
1015 /*******************************************************************************
1017 * FUNCTION: AnLastStatementIsReturn
1019 * PARAMETERS: Op - A method parse node
1021 * RETURN: TRUE if last statement is an ASL RETURN. False otherwise
1023 * DESCRIPTION: Walk down the list of top level statements within a method
1024 * to find the last one. Check if that last statement is in
1025 * fact a RETURN statement.
1027 ******************************************************************************/
1030 AnLastStatementIsReturn (
1031 ACPI_PARSE_OBJECT *Op)
1033 ACPI_PARSE_OBJECT *Next;
1037 * Check if last statement is a return
1039 Next = ASL_GET_CHILD_NODE (Op);
1042 if ((!Next->Asl.Next) &&
1043 (Next->Asl.ParseOpcode == PARSEOP_RETURN))
1048 Next = ASL_GET_PEER_NODE (Next);
1055 /*******************************************************************************
1057 * FUNCTION: AnMethodAnalysisWalkEnd
1059 * PARAMETERS: ASL_WALK_CALLBACK
1063 * DESCRIPTION: Ascending callback for analysis walk. Complete method
1066 ******************************************************************************/
1069 AnMethodAnalysisWalkEnd (
1070 ACPI_PARSE_OBJECT *Op,
1074 ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context;
1075 ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack;
1078 switch (Op->Asl.ParseOpcode)
1080 case PARSEOP_METHOD:
1081 case PARSEOP_RETURN:
1084 printf ("No method info for method! [%s]\n", Op->Asl.Namepath);
1085 AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
1086 "No method info for this method");
1087 CmCleanupAndExit ();
1088 return (AE_AML_INTERNAL);
1096 switch (Op->Asl.ParseOpcode)
1098 case PARSEOP_METHOD:
1100 WalkInfo->MethodStack = MethodInfo->Next;
1103 * Check if there is no return statement at the end of the
1104 * method AND we can actually get there -- i.e., the execution
1105 * of the method can possibly terminate without a return statement.
1107 if ((!AnLastStatementIsReturn (Op)) &&
1108 (!(Op->Asl.CompileFlags & NODE_HAS_NO_EXIT)))
1111 * No return statement, and execution can possibly exit
1112 * via this path. This is equivalent to Return ()
1114 MethodInfo->NumReturnNoValue++;
1118 * Check for case where some return statements have a return value
1119 * and some do not. Exit without a return statement is a return with
1122 if (MethodInfo->NumReturnNoValue &&
1123 MethodInfo->NumReturnWithValue)
1125 AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op,
1126 Op->Asl.ExternalName);
1130 * If there are any RETURN() statements with no value, or there is a
1131 * control path that allows the method to exit without a return value,
1132 * we mark the method as a method that does not return a value. This
1133 * knowledge can be used to check method invocations that expect a
1136 if (MethodInfo->NumReturnNoValue)
1138 if (MethodInfo->NumReturnWithValue)
1140 Op->Asl.CompileFlags |= NODE_METHOD_SOME_NO_RETVAL;
1144 Op->Asl.CompileFlags |= NODE_METHOD_NO_RETVAL;
1149 * Check predefined method names for correct return behavior
1150 * and correct number of arguments
1152 ApCheckForPredefinedMethod (Op, MethodInfo);
1153 ACPI_FREE (MethodInfo);
1157 case PARSEOP_RETURN:
1160 * If the parent is a predefined method name, attempt to typecheck
1161 * the return value. Only static types can be validated.
1163 ApCheckPredefinedReturnValue (Op, MethodInfo);
1166 * The parent block does not "exit" and continue execution -- the
1167 * method is terminated here with the Return() statement.
1169 Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT;
1171 /* Used in the "typing" pass later */
1173 Op->Asl.ParentMethod = MethodInfo->Op;
1176 * If there is a peer node after the return statement, then this
1177 * node is unreachable code -- i.e., it won't be executed because of
1178 * the preceeding Return() statement.
1182 AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE, Op->Asl.Next, NULL);
1189 if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) &&
1191 (Op->Asl.Next->Asl.ParseOpcode == PARSEOP_ELSE))
1194 * This IF has a corresponding ELSE. The IF block has no exit,
1195 * (it contains an unconditional Return)
1196 * mark the ELSE block to remember this fact.
1198 Op->Asl.Next->Asl.CompileFlags |= NODE_IF_HAS_NO_EXIT;
1205 if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) &&
1206 (Op->Asl.CompileFlags & NODE_IF_HAS_NO_EXIT))
1209 * This ELSE block has no exit and the corresponding IF block
1210 * has no exit either. Therefore, the parent node has no exit.
1212 Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT;
1219 if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) &&
1222 /* If this node has no exit, then the parent has no exit either */
1224 Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT;
1233 /*******************************************************************************
1235 * FUNCTION: AnMethodTypingWalkBegin
1237 * PARAMETERS: ASL_WALK_CALLBACK
1241 * DESCRIPTION: Descending callback for the typing walk.
1243 ******************************************************************************/
1246 AnMethodTypingWalkBegin (
1247 ACPI_PARSE_OBJECT *Op,
1256 /*******************************************************************************
1258 * FUNCTION: AnMethodTypingWalkEnd
1260 * PARAMETERS: ASL_WALK_CALLBACK
1264 * DESCRIPTION: Ascending callback for typing walk. Complete the method
1265 * return analysis. Check methods for:
1266 * 1) Initialized local variables
1267 * 2) Valid arguments
1270 ******************************************************************************/
1273 AnMethodTypingWalkEnd (
1274 ACPI_PARSE_OBJECT *Op,
1278 UINT32 ThisNodeBtype;
1281 switch (Op->Asl.ParseOpcode)
1283 case PARSEOP_METHOD:
1285 Op->Asl.CompileFlags |= NODE_METHOD_TYPED;
1288 case PARSEOP_RETURN:
1290 if ((Op->Asl.Child) &&
1291 (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
1293 ThisNodeBtype = AnGetBtype (Op->Asl.Child);
1295 if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_METHODCALL) &&
1296 (ThisNodeBtype == (ACPI_UINT32_MAX -1)))
1299 * The called method is untyped at this time (typically a
1300 * forward reference).
1302 * Check for a recursive method call first.
1304 if (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op)
1306 /* We must type the method here */
1308 TrWalkParseTree (Op->Asl.Child->Asl.Node->Op,
1309 ASL_WALK_VISIT_TWICE, AnMethodTypingWalkBegin,
1310 AnMethodTypingWalkEnd, NULL);
1312 ThisNodeBtype = AnGetBtype (Op->Asl.Child);
1316 /* Returns a value, save the value type */
1318 if (Op->Asl.ParentMethod)
1320 Op->Asl.ParentMethod->Asl.AcpiBtype |= ThisNodeBtype;
1333 /*******************************************************************************
1335 * FUNCTION: AnCheckMethodReturnValue
1337 * PARAMETERS: Op - Parent
1338 * OpInfo - Parent info
1339 * ArgOp - Method invocation op
1340 * RequiredBtypes - What caller requires
1341 * ThisNodeBtype - What this node returns (if anything)
1345 * DESCRIPTION: Check a method invocation for 1) A return value and if it does
1346 * in fact return a value, 2) check the type of the return value.
1348 ******************************************************************************/
1351 AnCheckMethodReturnValue (
1352 ACPI_PARSE_OBJECT *Op,
1353 const ACPI_OPCODE_INFO *OpInfo,
1354 ACPI_PARSE_OBJECT *ArgOp,
1355 UINT32 RequiredBtypes,
1356 UINT32 ThisNodeBtype)
1358 ACPI_PARSE_OBJECT *OwningOp;
1359 ACPI_NAMESPACE_NODE *Node;
1362 Node = ArgOp->Asl.Node;
1365 /* Examine the parent op of this method */
1367 OwningOp = Node->Op;
1368 if (OwningOp->Asl.CompileFlags & NODE_METHOD_NO_RETVAL)
1370 /* Method NEVER returns a value */
1372 AslError (ASL_ERROR, ASL_MSG_NO_RETVAL, Op, Op->Asl.ExternalName);
1374 else if (OwningOp->Asl.CompileFlags & NODE_METHOD_SOME_NO_RETVAL)
1376 /* Method SOMETIMES returns a value, SOMETIMES not */
1378 AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, Op, Op->Asl.ExternalName);
1380 else if (!(ThisNodeBtype & RequiredBtypes))
1382 /* Method returns a value, but the type is wrong */
1384 AnFormatBtype (StringBuffer, ThisNodeBtype);
1385 AnFormatBtype (StringBuffer2, RequiredBtypes);
1389 * The case where the method does not return any value at all
1390 * was already handled in the namespace cross reference
1391 * -- Only issue an error if the method in fact returns a value,
1392 * but it is of the wrong type
1394 if (ThisNodeBtype != 0)
1397 "Method returns [%s], %s operator requires [%s]",
1398 StringBuffer, OpInfo->Name, StringBuffer2);
1400 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer);
1406 /*******************************************************************************
1408 * FUNCTION: AnOperandTypecheckWalkBegin
1410 * PARAMETERS: ASL_WALK_CALLBACK
1414 * DESCRIPTION: Descending callback for the analysis walk. Check methods for:
1415 * 1) Initialized local variables
1416 * 2) Valid arguments
1419 ******************************************************************************/
1422 AnOperandTypecheckWalkBegin (
1423 ACPI_PARSE_OBJECT *Op,
1432 /*******************************************************************************
1434 * FUNCTION: AnOperandTypecheckWalkEnd
1436 * PARAMETERS: ASL_WALK_CALLBACK
1440 * DESCRIPTION: Ascending callback for analysis walk. Complete method
1443 ******************************************************************************/
1446 AnOperandTypecheckWalkEnd (
1447 ACPI_PARSE_OBJECT *Op,
1451 const ACPI_OPCODE_INFO *OpInfo;
1452 UINT32 RuntimeArgTypes;
1453 UINT32 RuntimeArgTypes2;
1454 UINT32 RequiredBtypes;
1455 UINT32 ThisNodeBtype;
1456 UINT32 CommonBtypes;
1458 ACPI_PARSE_OBJECT *ArgOp;
1462 switch (Op->Asl.AmlOpcode)
1464 case AML_RAW_DATA_BYTE:
1465 case AML_RAW_DATA_WORD:
1466 case AML_RAW_DATA_DWORD:
1467 case AML_RAW_DATA_QWORD:
1468 case AML_RAW_DATA_BUFFER:
1469 case AML_RAW_DATA_CHAIN:
1470 case AML_PACKAGE_LENGTH:
1471 case AML_UNASSIGNED_OPCODE:
1472 case AML_DEFAULT_ARG_OP:
1474 /* Ignore the internal (compiler-only) AML opcodes */
1482 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
1488 ArgOp = Op->Asl.Child;
1489 RuntimeArgTypes = OpInfo->RuntimeArgs;
1490 OpcodeClass = OpInfo->Class;
1492 #ifdef ASL_ERROR_NAMED_OBJECT_IN_WHILE
1494 * Update 11/2008: In practice, we can't perform this check. A simple
1495 * analysis is not sufficient. Also, it can cause errors when compiling
1496 * disassembled code because of the way Switch operators are implemented
1497 * (a While(One) loop with a named temp variable created within.)
1501 * If we are creating a named object, check if we are within a while loop
1502 * by checking if the parent is a WHILE op. This is a simple analysis, but
1503 * probably sufficient for many cases.
1505 * Allow Scope(), Buffer(), and Package().
1507 if (((OpcodeClass == AML_CLASS_NAMED_OBJECT) && (Op->Asl.AmlOpcode != AML_SCOPE_OP)) ||
1508 ((OpcodeClass == AML_CLASS_CREATE) && (OpInfo->Flags & AML_NSNODE)))
1510 if (Op->Asl.Parent->Asl.AmlOpcode == AML_WHILE_OP)
1512 AslError (ASL_ERROR, ASL_MSG_NAMED_OBJECT_IN_WHILE, Op, NULL);
1518 * Special case for control opcodes IF/RETURN/WHILE since they
1519 * have no runtime arg list (at this time)
1521 switch (Op->Asl.AmlOpcode)
1527 if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL)
1529 /* Check for an internal method */
1531 if (AnIsInternalMethod (ArgOp))
1536 /* The lone arg is a method call, check it */
1538 RequiredBtypes = AnMapArgTypeToBtype (ARGI_INTEGER);
1539 if (Op->Asl.AmlOpcode == AML_RETURN_OP)
1541 RequiredBtypes = 0xFFFFFFFF;
1544 ThisNodeBtype = AnGetBtype (ArgOp);
1545 if (ThisNodeBtype == ACPI_UINT32_MAX)
1549 AnCheckMethodReturnValue (Op, OpInfo, ArgOp,
1550 RequiredBtypes, ThisNodeBtype);
1558 /* Ignore the non-executable opcodes */
1560 if (RuntimeArgTypes == ARGI_INVALID_OPCODE)
1565 switch (OpcodeClass)
1567 case AML_CLASS_EXECUTE:
1568 case AML_CLASS_CREATE:
1569 case AML_CLASS_CONTROL:
1570 case AML_CLASS_RETURN_VALUE:
1572 /* TBD: Change class or fix typechecking for these */
1574 if ((Op->Asl.AmlOpcode == AML_BUFFER_OP) ||
1575 (Op->Asl.AmlOpcode == AML_PACKAGE_OP) ||
1576 (Op->Asl.AmlOpcode == AML_VAR_PACKAGE_OP))
1581 /* Reverse the runtime argument list */
1583 RuntimeArgTypes2 = 0;
1584 while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes)))
1586 RuntimeArgTypes2 <<= ARG_TYPE_WIDTH;
1587 RuntimeArgTypes2 |= ArgType;
1588 INCREMENT_ARG_LIST (RuntimeArgTypes);
1591 while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes2)))
1593 RequiredBtypes = AnMapArgTypeToBtype (ArgType);
1595 ThisNodeBtype = AnGetBtype (ArgOp);
1596 if (ThisNodeBtype == ACPI_UINT32_MAX)
1601 /* Examine the arg based on the required type of the arg */
1605 case ARGI_TARGETREF:
1607 if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO)
1609 /* ZERO is the placeholder for "don't store result" */
1611 ThisNodeBtype = RequiredBtypes;
1615 if (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER)
1618 * This is the case where an original reference to a resource
1619 * descriptor field has been replaced by an (Integer) offset.
1620 * These named fields are supported at compile-time only;
1621 * the names are not passed to the interpreter (via the AML).
1623 if ((ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) ||
1624 (ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE))
1626 AslError (ASL_ERROR, ASL_MSG_RESOURCE_FIELD, ArgOp, NULL);
1630 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, NULL);
1635 if ((ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) ||
1636 (ArgOp->Asl.ParseOpcode == PARSEOP_DEREFOF))
1641 ThisNodeBtype = RequiredBtypes;
1645 case ARGI_REFERENCE: /* References */
1646 case ARGI_INTEGER_REF:
1647 case ARGI_OBJECT_REF:
1648 case ARGI_DEVICE_REF:
1650 switch (ArgOp->Asl.ParseOpcode)
1652 case PARSEOP_LOCAL0:
1653 case PARSEOP_LOCAL1:
1654 case PARSEOP_LOCAL2:
1655 case PARSEOP_LOCAL3:
1656 case PARSEOP_LOCAL4:
1657 case PARSEOP_LOCAL5:
1658 case PARSEOP_LOCAL6:
1659 case PARSEOP_LOCAL7:
1661 /* TBD: implement analysis of current value (type) of the local */
1662 /* For now, just treat any local as a typematch */
1664 /*ThisNodeBtype = RequiredBtypes;*/
1675 /* Hard to analyze argument types, sow we won't */
1676 /* For now, just treat any arg as a typematch */
1678 /* ThisNodeBtype = RequiredBtypes; */
1698 CommonBtypes = ThisNodeBtype & RequiredBtypes;
1700 if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL)
1702 if (AnIsInternalMethod (ArgOp))
1707 /* Check a method call for a valid return value */
1709 AnCheckMethodReturnValue (Op, OpInfo, ArgOp,
1710 RequiredBtypes, ThisNodeBtype);
1714 * Now check if the actual type(s) match at least one
1715 * bit to the required type
1717 else if (!CommonBtypes)
1719 /* No match -- this is a type mismatch error */
1721 AnFormatBtype (StringBuffer, ThisNodeBtype);
1722 AnFormatBtype (StringBuffer2, RequiredBtypes);
1724 sprintf (MsgBuffer, "[%s] found, %s operator requires [%s]",
1725 StringBuffer, OpInfo->Name, StringBuffer2);
1727 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer);
1731 ArgOp = ArgOp->Asl.Next;
1732 INCREMENT_ARG_LIST (RuntimeArgTypes2);
1744 /*******************************************************************************
1746 * FUNCTION: AnIsResultUsed
1748 * PARAMETERS: Op - Parent op for the operator
1750 * RETURN: TRUE if result from this operation is actually consumed
1752 * DESCRIPTION: Determine if the function result value from an operator is
1755 ******************************************************************************/
1759 ACPI_PARSE_OBJECT *Op)
1761 ACPI_PARSE_OBJECT *Parent;
1764 switch (Op->Asl.ParseOpcode)
1766 case PARSEOP_INCREMENT:
1767 case PARSEOP_DECREMENT:
1769 /* These are standalone operators, no return value */
1777 /* Examine parent to determine if the return value is used */
1779 Parent = Op->Asl.Parent;
1780 switch (Parent->Asl.ParseOpcode)
1782 /* If/While - check if the operator is the predicate */
1787 /* First child is the predicate */
1789 if (Parent->Asl.Child == Op)
1795 /* Not used if one of these is the parent */
1797 case PARSEOP_METHOD:
1798 case PARSEOP_DEFINITIONBLOCK:
1804 /* Any other type of parent means that the result is used */
1811 /*******************************************************************************
1813 * FUNCTION: AnOtherSemanticAnalysisWalkBegin
1815 * PARAMETERS: ASL_WALK_CALLBACK
1819 * DESCRIPTION: Descending callback for the analysis walk. Checks for
1820 * miscellaneous issues in the code.
1822 ******************************************************************************/
1825 AnOtherSemanticAnalysisWalkBegin (
1826 ACPI_PARSE_OBJECT *Op,
1830 ACPI_PARSE_OBJECT *ArgNode;
1831 ACPI_PARSE_OBJECT *PrevArgNode = NULL;
1832 const ACPI_OPCODE_INFO *OpInfo;
1835 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
1838 * Determine if an execution class operator actually does something by
1839 * checking if it has a target and/or the function return value is used.
1840 * (Target is optional, so a standalone statement can actually do nothing.)
1842 if ((OpInfo->Class == AML_CLASS_EXECUTE) &&
1843 (OpInfo->Flags & AML_HAS_RETVAL) &&
1844 (!AnIsResultUsed (Op)))
1846 if (OpInfo->Flags & AML_HAS_TARGET)
1849 * Find the target node, it is always the last child. If the traget
1850 * is not specified in the ASL, a default node of type Zero was
1851 * created by the parser.
1853 ArgNode = Op->Asl.Child;
1854 while (ArgNode->Asl.Next)
1856 PrevArgNode = ArgNode;
1857 ArgNode = ArgNode->Asl.Next;
1860 /* Divide() is the only weird case, it has two targets */
1862 if (Op->Asl.AmlOpcode == AML_DIVIDE_OP)
1864 if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) &&
1865 (PrevArgNode->Asl.ParseOpcode == PARSEOP_ZERO))
1867 AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName);
1870 else if (ArgNode->Asl.ParseOpcode == PARSEOP_ZERO)
1872 AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName);
1878 * Has no target and the result is not used. Only a couple opcodes
1879 * can have this combination.
1881 switch (Op->Asl.ParseOpcode)
1883 case PARSEOP_ACQUIRE:
1885 case PARSEOP_LOADTABLE:
1889 AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName);
1897 * Semantic checks for individual ASL operators
1899 switch (Op->Asl.ParseOpcode)
1901 case PARSEOP_ACQUIRE:
1904 * Emit a warning if the timeout parameter for these operators is not
1905 * ACPI_WAIT_FOREVER, and the result value from the operator is not
1906 * checked, meaning that a timeout could happen, but the code
1907 * would not know about it.
1910 /* First child is the namepath, 2nd child is timeout */
1912 ArgNode = Op->Asl.Child;
1913 ArgNode = ArgNode->Asl.Next;
1916 * Check for the WAIT_FOREVER case - defined by the ACPI spec to be
1919 if (((ArgNode->Asl.ParseOpcode == PARSEOP_WORDCONST) ||
1920 (ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER)) &&
1921 (ArgNode->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER))
1927 * The operation could timeout. If the return value is not used
1928 * (indicates timeout occurred), issue a warning
1930 if (!AnIsResultUsed (Op))
1932 AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgNode, Op->Asl.ExternalName);
1936 case PARSEOP_CREATEFIELD:
1938 * Check for a zero Length (NumBits) operand. NumBits is the 3rd operand
1940 ArgNode = Op->Asl.Child;
1941 ArgNode = ArgNode->Asl.Next;
1942 ArgNode = ArgNode->Asl.Next;
1944 if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) ||
1945 ((ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER) &&
1946 (ArgNode->Asl.Value.Integer == 0)))
1948 AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgNode, NULL);
1960 /*******************************************************************************
1962 * FUNCTION: AnOtherSemanticAnalysisWalkEnd
1964 * PARAMETERS: ASL_WALK_CALLBACK
1968 * DESCRIPTION: Ascending callback for analysis walk. Complete method
1971 ******************************************************************************/
1974 AnOtherSemanticAnalysisWalkEnd (
1975 ACPI_PARSE_OBJECT *Op,
1985 #ifdef ACPI_OBSOLETE_FUNCTIONS
1986 /*******************************************************************************
1988 * FUNCTION: AnMapBtypeToEtype
1990 * PARAMETERS: Btype - Bitfield of ACPI types
1992 * RETURN: The Etype corresponding the the Btype
1994 * DESCRIPTION: Convert a bitfield type to an encoded type
1996 ******************************************************************************/
2012 for (i = 1; i < Btype; i *= 2)