Fixed compatibility of output.
[AROS.git] / arch / all-pc / acpica / source / compiler / asllookup.c
blobe965f1812b6f7639006407a584d578703fc4056e
1 /******************************************************************************
3 * Module Name: asllookup- Namespace lookup functions
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
45 #include "aslcompiler.h"
46 #include "aslcompiler.y.h"
47 #include "acparser.h"
48 #include "amlcode.h"
49 #include "acnamesp.h"
50 #include "acdispat.h"
53 #define _COMPONENT ACPI_COMPILER
54 ACPI_MODULE_NAME ("asllookup")
56 /* Local prototypes */
58 static ACPI_STATUS
59 LkIsObjectUsed (
60 ACPI_HANDLE ObjHandle,
61 UINT32 Level,
62 void *Context,
63 void **ReturnValue);
65 static ACPI_PARSE_OBJECT *
66 LkGetNameOp (
67 ACPI_PARSE_OBJECT *Op);
70 /*******************************************************************************
72 * FUNCTION: LkFindUnreferencedObjects
74 * PARAMETERS: None
76 * RETURN: None
78 * DESCRIPTION: Namespace walk to find objects that are not referenced in any
79 * way. Must be called after the namespace has been cross
80 * referenced.
82 ******************************************************************************/
84 void
85 LkFindUnreferencedObjects (
86 void)
89 /* Walk entire namespace from the supplied root */
91 (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
92 ACPI_UINT32_MAX, FALSE, LkIsObjectUsed, NULL,
93 NULL, NULL);
97 /*******************************************************************************
99 * FUNCTION: LkIsObjectUsed
101 * PARAMETERS: ACPI_WALK_CALLBACK
103 * RETURN: Status
105 * DESCRIPTION: Check for an unreferenced namespace object and emit a warning.
106 * We have to be careful, because some types and names are
107 * typically or always unreferenced, we don't want to issue
108 * excessive warnings.
110 ******************************************************************************/
112 static ACPI_STATUS
113 LkIsObjectUsed (
114 ACPI_HANDLE ObjHandle,
115 UINT32 Level,
116 void *Context,
117 void **ReturnValue)
119 ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
122 /* Referenced flag is set during the namespace xref */
124 if (Node->Flags & ANOBJ_IS_REFERENCED)
126 return (AE_OK);
130 * Ignore names that start with an underscore,
131 * these are the reserved ACPI names and are typically not referenced,
132 * they are called by the host OS.
134 if (Node->Name.Ascii[0] == '_')
136 return (AE_OK);
139 /* There are some types that are typically not referenced, ignore them */
141 switch (Node->Type)
143 case ACPI_TYPE_DEVICE:
144 case ACPI_TYPE_PROCESSOR:
145 case ACPI_TYPE_POWER:
146 case ACPI_TYPE_LOCAL_RESOURCE:
148 return (AE_OK);
150 default:
152 break;
155 /* All others are valid unreferenced namespace objects */
157 if (Node->Op)
159 AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED, LkGetNameOp (Node->Op), NULL);
161 return (AE_OK);
165 /*******************************************************************************
167 * FUNCTION: LkGetNameOp
169 * PARAMETERS: Op - Current Op
171 * RETURN: NameOp associated with the input op
173 * DESCRIPTION: Find the name declaration op associated with the operator
175 ******************************************************************************/
177 static ACPI_PARSE_OBJECT *
178 LkGetNameOp (
179 ACPI_PARSE_OBJECT *Op)
181 const ACPI_OPCODE_INFO *OpInfo;
182 ACPI_PARSE_OBJECT *NameOp = Op;
185 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
188 /* Get the NamePath from the appropriate place */
190 if (OpInfo->Flags & AML_NAMED)
192 /* For nearly all NAMED operators, the name reference is the first child */
194 NameOp = Op->Asl.Child;
195 if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
198 * ALIAS is the only oddball opcode, the name declaration
199 * (alias name) is the second operand
201 NameOp = Op->Asl.Child->Asl.Next;
204 else if (OpInfo->Flags & AML_CREATE)
206 /* Name must appear as the last parameter */
208 NameOp = Op->Asl.Child;
209 while (!(NameOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))
211 NameOp = NameOp->Asl.Next;
215 return (NameOp);