153289f6aSNate Lawson /******************************************************************************
253289f6aSNate Lawson *
3efcc2a30SJung-uk Kim * Module Name: asllookup- Namespace lookup functions
453289f6aSNate Lawson *
553289f6aSNate Lawson *****************************************************************************/
653289f6aSNate Lawson
70d84335fSJung-uk Kim /******************************************************************************
80d84335fSJung-uk Kim *
90d84335fSJung-uk Kim * 1. Copyright Notice
100d84335fSJung-uk Kim *
11*722b1667SJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp.
1253289f6aSNate Lawson * All rights reserved.
1353289f6aSNate Lawson *
140d84335fSJung-uk Kim * 2. License
150d84335fSJung-uk Kim *
160d84335fSJung-uk Kim * 2.1. This is your license from Intel Corp. under its intellectual property
170d84335fSJung-uk Kim * rights. You may have additional license terms from the party that provided
180d84335fSJung-uk Kim * you this software, covering your right to use that party's intellectual
190d84335fSJung-uk Kim * property rights.
200d84335fSJung-uk Kim *
210d84335fSJung-uk Kim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220d84335fSJung-uk Kim * copy of the source code appearing in this file ("Covered Code") an
230d84335fSJung-uk Kim * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240d84335fSJung-uk Kim * base code distributed originally by Intel ("Original Intel Code") to copy,
250d84335fSJung-uk Kim * make derivatives, distribute, use and display any portion of the Covered
260d84335fSJung-uk Kim * Code in any form, with the right to sublicense such rights; and
270d84335fSJung-uk Kim *
280d84335fSJung-uk Kim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290d84335fSJung-uk Kim * license (with the right to sublicense), under only those claims of Intel
300d84335fSJung-uk Kim * patents that are infringed by the Original Intel Code, to make, use, sell,
310d84335fSJung-uk Kim * offer to sell, and import the Covered Code and derivative works thereof
320d84335fSJung-uk Kim * solely to the minimum extent necessary to exercise the above copyright
330d84335fSJung-uk Kim * license, and in no event shall the patent license extend to any additions
340d84335fSJung-uk Kim * to or modifications of the Original Intel Code. No other license or right
350d84335fSJung-uk Kim * is granted directly or by implication, estoppel or otherwise;
360d84335fSJung-uk Kim *
370d84335fSJung-uk Kim * The above copyright and patent license is granted only if the following
380d84335fSJung-uk Kim * conditions are met:
390d84335fSJung-uk Kim *
400d84335fSJung-uk Kim * 3. Conditions
410d84335fSJung-uk Kim *
420d84335fSJung-uk Kim * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered
440d84335fSJung-uk Kim * Code or modification with rights to further distribute source must include
450d84335fSJung-uk Kim * the above Copyright Notice, the above License, this list of Conditions,
460d84335fSJung-uk Kim * and the following Disclaimer and Export Compliance provision. In addition,
470d84335fSJung-uk Kim * Licensee must cause all Covered Code to which Licensee contributes to
480d84335fSJung-uk Kim * contain a file documenting the changes Licensee made to create that Covered
490d84335fSJung-uk Kim * Code and the date of any change. Licensee must include in that file the
500d84335fSJung-uk Kim * documentation of any changes made by any predecessor Licensee. Licensee
510d84335fSJung-uk Kim * must include a prominent statement that the modification is derived,
520d84335fSJung-uk Kim * directly or indirectly, from Original Intel Code.
530d84335fSJung-uk Kim *
540d84335fSJung-uk Kim * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered
560d84335fSJung-uk Kim * Code or modification without rights to further distribute source must
570d84335fSJung-uk Kim * include the following Disclaimer and Export Compliance provision in the
580d84335fSJung-uk Kim * documentation and/or other materials provided with distribution. In
590d84335fSJung-uk Kim * addition, Licensee may not authorize further sublicense of source of any
600d84335fSJung-uk Kim * portion of the Covered Code, and must include terms to the effect that the
610d84335fSJung-uk Kim * license from Licensee to its licensee is limited to the intellectual
620d84335fSJung-uk Kim * property embodied in the software Licensee provides to its licensee, and
630d84335fSJung-uk Kim * not to intellectual property embodied in modifications its licensee may
640d84335fSJung-uk Kim * make.
650d84335fSJung-uk Kim *
660d84335fSJung-uk Kim * 3.3. Redistribution of Executable. Redistribution in executable form of any
670d84335fSJung-uk Kim * substantial portion of the Covered Code or modification must reproduce the
680d84335fSJung-uk Kim * above Copyright Notice, and the following Disclaimer and Export Compliance
690d84335fSJung-uk Kim * provision in the documentation and/or other materials provided with the
700d84335fSJung-uk Kim * distribution.
710d84335fSJung-uk Kim *
720d84335fSJung-uk Kim * 3.4. Intel retains all right, title, and interest in and to the Original
730d84335fSJung-uk Kim * Intel Code.
740d84335fSJung-uk Kim *
750d84335fSJung-uk Kim * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760d84335fSJung-uk Kim * Intel shall be used in advertising or otherwise to promote the sale, use or
770d84335fSJung-uk Kim * other dealings in products derived from or relating to the Covered Code
780d84335fSJung-uk Kim * without prior written authorization from Intel.
790d84335fSJung-uk Kim *
800d84335fSJung-uk Kim * 4. Disclaimer and Export Compliance
810d84335fSJung-uk Kim *
820d84335fSJung-uk Kim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830d84335fSJung-uk Kim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840d84335fSJung-uk Kim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850d84335fSJung-uk Kim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860d84335fSJung-uk Kim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870d84335fSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880d84335fSJung-uk Kim * PARTICULAR PURPOSE.
890d84335fSJung-uk Kim *
900d84335fSJung-uk Kim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910d84335fSJung-uk Kim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920d84335fSJung-uk Kim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930d84335fSJung-uk Kim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940d84335fSJung-uk Kim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950d84335fSJung-uk Kim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960d84335fSJung-uk Kim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970d84335fSJung-uk Kim * LIMITED REMEDY.
980d84335fSJung-uk Kim *
990d84335fSJung-uk Kim * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000d84335fSJung-uk Kim * software or system incorporating such software without first obtaining any
1010d84335fSJung-uk Kim * required license or other approval from the U. S. Department of Commerce or
1020d84335fSJung-uk Kim * any other agency or department of the United States Government. In the
1030d84335fSJung-uk Kim * event Licensee exports any such software from the United States or
1040d84335fSJung-uk Kim * re-exports any such software from a foreign destination, Licensee shall
1050d84335fSJung-uk Kim * ensure that the distribution and export/re-export of the software is in
1060d84335fSJung-uk Kim * compliance with all laws, regulations, orders, or other restrictions of the
1070d84335fSJung-uk Kim * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080d84335fSJung-uk Kim * any of its subsidiaries will export/re-export any technical data, process,
1090d84335fSJung-uk Kim * software, or service, directly or indirectly, to any country for which the
1100d84335fSJung-uk Kim * United States government or any agency thereof requires an export license,
1110d84335fSJung-uk Kim * other governmental approval, or letter of assurance, without first obtaining
1120d84335fSJung-uk Kim * such license, approval or letter.
1130d84335fSJung-uk Kim *
1140d84335fSJung-uk Kim *****************************************************************************
1150d84335fSJung-uk Kim *
1160d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the
1170d84335fSJung-uk Kim * following license:
1180d84335fSJung-uk Kim *
119d244b227SJung-uk Kim * Redistribution and use in source and binary forms, with or without
120d244b227SJung-uk Kim * modification, are permitted provided that the following conditions
121d244b227SJung-uk Kim * are met:
122d244b227SJung-uk Kim * 1. Redistributions of source code must retain the above copyright
123d244b227SJung-uk Kim * notice, this list of conditions, and the following disclaimer,
124d244b227SJung-uk Kim * without modification.
125d244b227SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126d244b227SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below
127d244b227SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon
128d244b227SJung-uk Kim * including a substantially similar Disclaimer requirement for further
129d244b227SJung-uk Kim * binary redistribution.
130d244b227SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names
131d244b227SJung-uk Kim * of any contributors may be used to endorse or promote products derived
132d244b227SJung-uk Kim * from this software without specific prior written permission.
13353289f6aSNate Lawson *
1340d84335fSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1350d84335fSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1360d84335fSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1370d84335fSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1380d84335fSJung-uk Kim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1390d84335fSJung-uk Kim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1400d84335fSJung-uk Kim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1410d84335fSJung-uk Kim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1420d84335fSJung-uk Kim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1430d84335fSJung-uk Kim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1440d84335fSJung-uk Kim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1450d84335fSJung-uk Kim *
1460d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the
147d244b227SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free
148d244b227SJung-uk Kim * Software Foundation.
14953289f6aSNate Lawson *
1500d84335fSJung-uk Kim *****************************************************************************/
15153289f6aSNate Lawson
152ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h>
15353289f6aSNate Lawson #include "aslcompiler.y.h"
154ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acparser.h>
155ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/amlcode.h>
156ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h>
157ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acdispat.h>
15853289f6aSNate Lawson
15953289f6aSNate Lawson
16053289f6aSNate Lawson #define _COMPONENT ACPI_COMPILER
16153289f6aSNate Lawson ACPI_MODULE_NAME ("asllookup")
16253289f6aSNate Lawson
163fba7fc7eSJung-uk Kim /* Local prototypes */
164fba7fc7eSJung-uk Kim
165fba7fc7eSJung-uk Kim static ACPI_STATUS
1661a39cfb0SJung-uk Kim LkIsObjectUsed (
1671a39cfb0SJung-uk Kim ACPI_HANDLE ObjHandle,
1681a39cfb0SJung-uk Kim UINT32 Level,
1691a39cfb0SJung-uk Kim void *Context,
1701a39cfb0SJung-uk Kim void **ReturnValue);
1711a39cfb0SJung-uk Kim
17242fecd12SJung-uk Kim static ACPI_PARSE_OBJECT *
173a9f12690SJung-uk Kim LkGetNameOp (
174a9f12690SJung-uk Kim ACPI_PARSE_OBJECT *Op);
175a9f12690SJung-uk Kim
17653289f6aSNate Lawson
17753289f6aSNate Lawson /*******************************************************************************
17853289f6aSNate Lawson *
179efcc2a30SJung-uk Kim * FUNCTION: LkFindUnreferencedObjects
18053289f6aSNate Lawson *
181efcc2a30SJung-uk Kim * PARAMETERS: None
182a9f12690SJung-uk Kim *
183a9f12690SJung-uk Kim * RETURN: None
184a9f12690SJung-uk Kim *
185efcc2a30SJung-uk Kim * DESCRIPTION: Namespace walk to find objects that are not referenced in any
186efcc2a30SJung-uk Kim * way. Must be called after the namespace has been cross
187efcc2a30SJung-uk Kim * referenced.
188a9f12690SJung-uk Kim *
189a9f12690SJung-uk Kim ******************************************************************************/
190a9f12690SJung-uk Kim
1911a39cfb0SJung-uk Kim void
LkFindUnreferencedObjects(void)192efcc2a30SJung-uk Kim LkFindUnreferencedObjects (
19353289f6aSNate Lawson void)
19453289f6aSNate Lawson {
19553289f6aSNate Lawson
19653289f6aSNate Lawson /* Walk entire namespace from the supplied root */
19753289f6aSNate Lawson
198efcc2a30SJung-uk Kim (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
199efcc2a30SJung-uk Kim ACPI_UINT32_MAX, FALSE, LkIsObjectUsed, NULL,
200efcc2a30SJung-uk Kim NULL, NULL);
2011a39cfb0SJung-uk Kim }
2021a39cfb0SJung-uk Kim
2031a39cfb0SJung-uk Kim
2041a39cfb0SJung-uk Kim /*******************************************************************************
2051a39cfb0SJung-uk Kim *
2061a39cfb0SJung-uk Kim * FUNCTION: LkIsObjectUsed
2071a39cfb0SJung-uk Kim *
2081a39cfb0SJung-uk Kim * PARAMETERS: ACPI_WALK_CALLBACK
2091a39cfb0SJung-uk Kim *
2101a39cfb0SJung-uk Kim * RETURN: Status
2111a39cfb0SJung-uk Kim *
2121a39cfb0SJung-uk Kim * DESCRIPTION: Check for an unreferenced namespace object and emit a warning.
2131a39cfb0SJung-uk Kim * We have to be careful, because some types and names are
2141a39cfb0SJung-uk Kim * typically or always unreferenced, we don't want to issue
215313a0c13SJung-uk Kim * excessive warnings. Note: Names that are declared within a
216313a0c13SJung-uk Kim * control method are temporary, so we always issue a remark
217313a0c13SJung-uk Kim * if they are not referenced.
2181a39cfb0SJung-uk Kim *
2191a39cfb0SJung-uk Kim ******************************************************************************/
2201a39cfb0SJung-uk Kim
2211a39cfb0SJung-uk Kim static ACPI_STATUS
LkIsObjectUsed(ACPI_HANDLE ObjHandle,UINT32 Level,void * Context,void ** ReturnValue)2221a39cfb0SJung-uk Kim LkIsObjectUsed (
2231a39cfb0SJung-uk Kim ACPI_HANDLE ObjHandle,
2241a39cfb0SJung-uk Kim UINT32 Level,
2251a39cfb0SJung-uk Kim void *Context,
2261a39cfb0SJung-uk Kim void **ReturnValue)
2271a39cfb0SJung-uk Kim {
2281a39cfb0SJung-uk Kim ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
229313a0c13SJung-uk Kim ACPI_NAMESPACE_NODE *Next;
230fe0f0bbbSJung-uk Kim ASL_METHOD_LOCAL *MethodLocals;
231fe0f0bbbSJung-uk Kim ASL_METHOD_LOCAL *MethodArgs;
232fe0f0bbbSJung-uk Kim UINT32 i;
2331a39cfb0SJung-uk Kim
2341a39cfb0SJung-uk Kim
235fe0f0bbbSJung-uk Kim if (Node->Type == ACPI_TYPE_METHOD)
236fe0f0bbbSJung-uk Kim {
237fe0f0bbbSJung-uk Kim if (!Node->Op || !Node->MethodLocals)
238fe0f0bbbSJung-uk Kim {
239fe0f0bbbSJung-uk Kim return (AE_OK);
240fe0f0bbbSJung-uk Kim }
241fe0f0bbbSJung-uk Kim
242fe0f0bbbSJung-uk Kim MethodLocals = (ASL_METHOD_LOCAL *) Node->MethodLocals;
243fe0f0bbbSJung-uk Kim MethodArgs = (ASL_METHOD_LOCAL *) Node->MethodArgs;
244fe0f0bbbSJung-uk Kim
245fe0f0bbbSJung-uk Kim /*
246fe0f0bbbSJung-uk Kim * Analysis of LocalX variables
247fe0f0bbbSJung-uk Kim */
248fe0f0bbbSJung-uk Kim for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
249fe0f0bbbSJung-uk Kim {
250fe0f0bbbSJung-uk Kim /* Warn for Locals that are set but never referenced */
251fe0f0bbbSJung-uk Kim
252fe0f0bbbSJung-uk Kim if ((MethodLocals[i].Flags & ASL_LOCAL_INITIALIZED) &&
253fe0f0bbbSJung-uk Kim (!(MethodLocals[i].Flags & ASL_LOCAL_REFERENCED)))
254fe0f0bbbSJung-uk Kim {
2556f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, "Local%u", i);
256fe0f0bbbSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_LOCAL_NOT_USED,
2576f1f1a63SJung-uk Kim MethodLocals[i].Op, AslGbl_MsgBuffer);
258fe0f0bbbSJung-uk Kim }
259fe0f0bbbSJung-uk Kim }
260fe0f0bbbSJung-uk Kim
261fe0f0bbbSJung-uk Kim /*
262fe0f0bbbSJung-uk Kim * Analysis of ArgX variables (standard method arguments,
263fe0f0bbbSJung-uk Kim * and remaining unused ArgX can also be used as locals)
264fe0f0bbbSJung-uk Kim */
265fe0f0bbbSJung-uk Kim for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
266fe0f0bbbSJung-uk Kim {
267fe0f0bbbSJung-uk Kim if (MethodArgs[i].Flags & ASL_ARG_IS_LOCAL)
268fe0f0bbbSJung-uk Kim {
269fe0f0bbbSJung-uk Kim /* Warn if ArgX is being used as a local, but not referenced */
270fe0f0bbbSJung-uk Kim
271fe0f0bbbSJung-uk Kim if ((MethodArgs[i].Flags & ASL_ARG_INITIALIZED) &&
272fe0f0bbbSJung-uk Kim (!(MethodArgs[i].Flags & ASL_ARG_REFERENCED)))
273fe0f0bbbSJung-uk Kim {
2746f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, "Arg%u", i);
275fe0f0bbbSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_ARG_AS_LOCAL_NOT_USED,
2766f1f1a63SJung-uk Kim MethodArgs[i].Op, AslGbl_MsgBuffer);
277fe0f0bbbSJung-uk Kim }
278fe0f0bbbSJung-uk Kim }
279fe0f0bbbSJung-uk Kim else
280fe0f0bbbSJung-uk Kim {
281fe0f0bbbSJung-uk Kim /*
282fe0f0bbbSJung-uk Kim * Remark if a normal method ArgX is not referenced.
283fe0f0bbbSJung-uk Kim * We ignore the predefined methods since often, not
284fe0f0bbbSJung-uk Kim * all arguments are needed or used.
285fe0f0bbbSJung-uk Kim */
286fe0f0bbbSJung-uk Kim if ((Node->Name.Ascii[0] != '_') &&
287fe0f0bbbSJung-uk Kim (!(MethodArgs[i].Flags & ASL_ARG_REFERENCED)))
288fe0f0bbbSJung-uk Kim {
2896f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, "Arg%u", i);
290fe0f0bbbSJung-uk Kim AslError (ASL_REMARK, ASL_MSG_ARG_NOT_USED,
2916f1f1a63SJung-uk Kim MethodArgs[i].Op, AslGbl_MsgBuffer);
292fe0f0bbbSJung-uk Kim }
293fe0f0bbbSJung-uk Kim }
294fe0f0bbbSJung-uk Kim }
295fe0f0bbbSJung-uk Kim }
296fe0f0bbbSJung-uk Kim
2971a39cfb0SJung-uk Kim /* Referenced flag is set during the namespace xref */
2981a39cfb0SJung-uk Kim
2991a39cfb0SJung-uk Kim if (Node->Flags & ANOBJ_IS_REFERENCED)
3001a39cfb0SJung-uk Kim {
3011a39cfb0SJung-uk Kim return (AE_OK);
3021a39cfb0SJung-uk Kim }
3031a39cfb0SJung-uk Kim
304313a0c13SJung-uk Kim if (!Node->Op)
3051a39cfb0SJung-uk Kim {
3061a39cfb0SJung-uk Kim return (AE_OK);
3071a39cfb0SJung-uk Kim }
3081a39cfb0SJung-uk Kim
309313a0c13SJung-uk Kim /* These types are typically never directly referenced, ignore them */
3101a39cfb0SJung-uk Kim
3111a39cfb0SJung-uk Kim switch (Node->Type)
3121a39cfb0SJung-uk Kim {
3131a39cfb0SJung-uk Kim case ACPI_TYPE_DEVICE:
3141a39cfb0SJung-uk Kim case ACPI_TYPE_PROCESSOR:
3151a39cfb0SJung-uk Kim case ACPI_TYPE_POWER:
316313a0c13SJung-uk Kim case ACPI_TYPE_THERMAL:
3171a39cfb0SJung-uk Kim case ACPI_TYPE_LOCAL_RESOURCE:
318f8146b88SJung-uk Kim case ACPI_TYPE_LOCAL_RESOURCE_FIELD: /* Names assigned to descriptor elements */
319a9d8d09cSJung-uk Kim
3201a39cfb0SJung-uk Kim return (AE_OK);
3211a39cfb0SJung-uk Kim
3221a39cfb0SJung-uk Kim default:
323a9d8d09cSJung-uk Kim
3241a39cfb0SJung-uk Kim break;
3251a39cfb0SJung-uk Kim }
3261a39cfb0SJung-uk Kim
327313a0c13SJung-uk Kim /* Determine if the name is within a control method */
3281a39cfb0SJung-uk Kim
329313a0c13SJung-uk Kim Next = Node->Parent;
330313a0c13SJung-uk Kim while (Next)
3311a39cfb0SJung-uk Kim {
332313a0c13SJung-uk Kim if (Next->Type == ACPI_TYPE_METHOD)
333313a0c13SJung-uk Kim {
334313a0c13SJung-uk Kim /*
335313a0c13SJung-uk Kim * Name is within a method, therefore it is temporary.
336313a0c13SJung-uk Kim * Issue a remark even if it is a reserved name (starts
337313a0c13SJung-uk Kim * with an underscore).
338313a0c13SJung-uk Kim */
3396f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, "Name [%4.4s] is within a method [%4.4s]",
340f8146b88SJung-uk Kim Node->Name.Ascii, Next->Name.Ascii);
341313a0c13SJung-uk Kim AslError (ASL_REMARK, ASL_MSG_NOT_REFERENCED,
3426f1f1a63SJung-uk Kim LkGetNameOp (Node->Op), AslGbl_MsgBuffer);
343313a0c13SJung-uk Kim return (AE_OK);
3441a39cfb0SJung-uk Kim }
345313a0c13SJung-uk Kim
346313a0c13SJung-uk Kim Next = Next->Parent;
347313a0c13SJung-uk Kim }
348313a0c13SJung-uk Kim
349313a0c13SJung-uk Kim /* The name is not within a control method */
350313a0c13SJung-uk Kim
351313a0c13SJung-uk Kim /*
352313a0c13SJung-uk Kim * Ignore names that start with an underscore. These are the reserved
353313a0c13SJung-uk Kim * ACPI names and are typically not referenced since they are meant
354313a0c13SJung-uk Kim * to be called by the host OS.
355313a0c13SJung-uk Kim */
356313a0c13SJung-uk Kim if (Node->Name.Ascii[0] == '_')
357313a0c13SJung-uk Kim {
358313a0c13SJung-uk Kim return (AE_OK);
359313a0c13SJung-uk Kim }
360313a0c13SJung-uk Kim
361313a0c13SJung-uk Kim /*
362313a0c13SJung-uk Kim * What remains is an unresolved user name that is not within a method.
363313a0c13SJung-uk Kim * However, the object could be referenced via another table, so issue
364313a0c13SJung-uk Kim * the warning at level 2.
365313a0c13SJung-uk Kim */
366313a0c13SJung-uk Kim AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED,
367313a0c13SJung-uk Kim LkGetNameOp (Node->Op), NULL);
3681a39cfb0SJung-uk Kim return (AE_OK);
3691a39cfb0SJung-uk Kim }
3701a39cfb0SJung-uk Kim
3711a39cfb0SJung-uk Kim
3721a39cfb0SJung-uk Kim /*******************************************************************************
3731a39cfb0SJung-uk Kim *
374efcc2a30SJung-uk Kim * FUNCTION: LkGetNameOp
3751a39cfb0SJung-uk Kim *
376efcc2a30SJung-uk Kim * PARAMETERS: Op - Current Op
3771a39cfb0SJung-uk Kim *
378efcc2a30SJung-uk Kim * RETURN: NameOp associated with the input op
3791a39cfb0SJung-uk Kim *
380efcc2a30SJung-uk Kim * DESCRIPTION: Find the name declaration op associated with the operator
3811a39cfb0SJung-uk Kim *
3821a39cfb0SJung-uk Kim ******************************************************************************/
3831a39cfb0SJung-uk Kim
384efcc2a30SJung-uk Kim static ACPI_PARSE_OBJECT *
LkGetNameOp(ACPI_PARSE_OBJECT * Op)385efcc2a30SJung-uk Kim LkGetNameOp (
386efcc2a30SJung-uk Kim ACPI_PARSE_OBJECT *Op)
3871a39cfb0SJung-uk Kim {
38853289f6aSNate Lawson const ACPI_OPCODE_INFO *OpInfo;
389efcc2a30SJung-uk Kim ACPI_PARSE_OBJECT *NameOp = Op;
39053289f6aSNate Lawson
39153289f6aSNate Lawson
39253289f6aSNate Lawson OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
39353289f6aSNate Lawson
39453289f6aSNate Lawson
39553289f6aSNate Lawson /* Get the NamePath from the appropriate place */
39653289f6aSNate Lawson
39753289f6aSNate Lawson if (OpInfo->Flags & AML_NAMED)
39853289f6aSNate Lawson {
3991a39cfb0SJung-uk Kim /* For nearly all NAMED operators, the name reference is the first child */
40053289f6aSNate Lawson
401efcc2a30SJung-uk Kim NameOp = Op->Asl.Child;
40253289f6aSNate Lawson if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
40353289f6aSNate Lawson {
40453289f6aSNate Lawson /*
40553289f6aSNate Lawson * ALIAS is the only oddball opcode, the name declaration
40653289f6aSNate Lawson * (alias name) is the second operand
40753289f6aSNate Lawson */
408efcc2a30SJung-uk Kim NameOp = Op->Asl.Child->Asl.Next;
40953289f6aSNate Lawson }
41053289f6aSNate Lawson }
41153289f6aSNate Lawson else if (OpInfo->Flags & AML_CREATE)
41253289f6aSNate Lawson {
41353289f6aSNate Lawson /* Name must appear as the last parameter */
41453289f6aSNate Lawson
415efcc2a30SJung-uk Kim NameOp = Op->Asl.Child;
4165f9b24faSJung-uk Kim while (!(NameOp->Asl.CompileFlags & OP_IS_NAME_DECLARATION))
41753289f6aSNate Lawson {
418efcc2a30SJung-uk Kim NameOp = NameOp->Asl.Next;
41953289f6aSNate Lawson }
42053289f6aSNate Lawson }
42153289f6aSNate Lawson
422efcc2a30SJung-uk Kim return (NameOp);
42353289f6aSNate Lawson }
424