adwalk.c revision 1.1.1.2.2.2 1 1.1.1.2.2.2 bouyer /******************************************************************************
2 1.1.1.2.2.2 bouyer *
3 1.1.1.2.2.2 bouyer * Module Name: adwalk - Application-level disassembler parse tree walk routines
4 1.1.1.2.2.2 bouyer *
5 1.1.1.2.2.2 bouyer *****************************************************************************/
6 1.1.1.2.2.2 bouyer
7 1.1.1.2.2.2 bouyer /*
8 1.1.1.2.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.2.2 bouyer * All rights reserved.
10 1.1.1.2.2.2 bouyer *
11 1.1.1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.1.1.2.2.2 bouyer * are met:
14 1.1.1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.2.2 bouyer * without modification.
17 1.1.1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.2.2 bouyer * binary redistribution.
22 1.1.1.2.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.2.2 bouyer * from this software without specific prior written permission.
25 1.1.1.2.2.2 bouyer *
26 1.1.1.2.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.2.2 bouyer * Software Foundation.
29 1.1.1.2.2.2 bouyer *
30 1.1.1.2.2.2 bouyer * NO WARRANTY
31 1.1.1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.2.2 bouyer */
43 1.1.1.2.2.2 bouyer
44 1.1.1.2.2.2 bouyer
45 1.1.1.2.2.2 bouyer #include "acpi.h"
46 1.1.1.2.2.2 bouyer #include "accommon.h"
47 1.1.1.2.2.2 bouyer #include "acparser.h"
48 1.1.1.2.2.2 bouyer #include "amlcode.h"
49 1.1.1.2.2.2 bouyer #include "acdisasm.h"
50 1.1.1.2.2.2 bouyer #include "acdispat.h"
51 1.1.1.2.2.2 bouyer #include "acnamesp.h"
52 1.1.1.2.2.2 bouyer #include "acapps.h"
53 1.1.1.2.2.2 bouyer
54 1.1.1.2.2.2 bouyer
55 1.1.1.2.2.2 bouyer #define _COMPONENT ACPI_TOOLS
56 1.1.1.2.2.2 bouyer ACPI_MODULE_NAME ("adwalk")
57 1.1.1.2.2.2 bouyer
58 1.1.1.2.2.2 bouyer /*
59 1.1.1.2.2.2 bouyer * aslmap - opcode mappings and reserved method names
60 1.1.1.2.2.2 bouyer */
61 1.1.1.2.2.2 bouyer ACPI_OBJECT_TYPE
62 1.1.1.2.2.2 bouyer AslMapNamedOpcodeToDataType (
63 1.1.1.2.2.2 bouyer UINT16 Opcode);
64 1.1.1.2.2.2 bouyer
65 1.1.1.2.2.2 bouyer /* Local prototypes */
66 1.1.1.2.2.2 bouyer
67 1.1.1.2.2.2 bouyer static ACPI_STATUS
68 1.1.1.2.2.2 bouyer AcpiDmFindOrphanDescending (
69 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
70 1.1.1.2.2.2 bouyer UINT32 Level,
71 1.1.1.2.2.2 bouyer void *Context);
72 1.1.1.2.2.2 bouyer
73 1.1.1.2.2.2 bouyer static ACPI_STATUS
74 1.1.1.2.2.2 bouyer AcpiDmDumpDescending (
75 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
76 1.1.1.2.2.2 bouyer UINT32 Level,
77 1.1.1.2.2.2 bouyer void *Context);
78 1.1.1.2.2.2 bouyer
79 1.1.1.2.2.2 bouyer static ACPI_STATUS
80 1.1.1.2.2.2 bouyer AcpiDmXrefDescendingOp (
81 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
82 1.1.1.2.2.2 bouyer UINT32 Level,
83 1.1.1.2.2.2 bouyer void *Context);
84 1.1.1.2.2.2 bouyer
85 1.1.1.2.2.2 bouyer static ACPI_STATUS
86 1.1.1.2.2.2 bouyer AcpiDmCommonAscendingOp (
87 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
88 1.1.1.2.2.2 bouyer UINT32 Level,
89 1.1.1.2.2.2 bouyer void *Context);
90 1.1.1.2.2.2 bouyer
91 1.1.1.2.2.2 bouyer static ACPI_STATUS
92 1.1.1.2.2.2 bouyer AcpiDmLoadDescendingOp (
93 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
94 1.1.1.2.2.2 bouyer UINT32 Level,
95 1.1.1.2.2.2 bouyer void *Context);
96 1.1.1.2.2.2 bouyer
97 1.1.1.2.2.2 bouyer static UINT32
98 1.1.1.2.2.2 bouyer AcpiDmInspectPossibleArgs (
99 1.1.1.2.2.2 bouyer UINT32 CurrentOpArgCount,
100 1.1.1.2.2.2 bouyer UINT32 TargetCount,
101 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op);
102 1.1.1.2.2.2 bouyer
103 1.1.1.2.2.2 bouyer static ACPI_STATUS
104 1.1.1.2.2.2 bouyer AcpiDmResourceDescendingOp (
105 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
106 1.1.1.2.2.2 bouyer UINT32 Level,
107 1.1.1.2.2.2 bouyer void *Context);
108 1.1.1.2.2.2 bouyer
109 1.1.1.2.2.2 bouyer
110 1.1.1.2.2.2 bouyer /*******************************************************************************
111 1.1.1.2.2.2 bouyer *
112 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmDumpTree
113 1.1.1.2.2.2 bouyer *
114 1.1.1.2.2.2 bouyer * PARAMETERS: Origin - Starting object
115 1.1.1.2.2.2 bouyer *
116 1.1.1.2.2.2 bouyer * RETURN: None
117 1.1.1.2.2.2 bouyer *
118 1.1.1.2.2.2 bouyer * DESCRIPTION: Parse tree walk to format and output the nodes
119 1.1.1.2.2.2 bouyer *
120 1.1.1.2.2.2 bouyer ******************************************************************************/
121 1.1.1.2.2.2 bouyer
122 1.1.1.2.2.2 bouyer void
123 1.1.1.2.2.2 bouyer AcpiDmDumpTree (
124 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Origin)
125 1.1.1.2.2.2 bouyer {
126 1.1.1.2.2.2 bouyer ACPI_OP_WALK_INFO Info;
127 1.1.1.2.2.2 bouyer
128 1.1.1.2.2.2 bouyer
129 1.1.1.2.2.2 bouyer if (!Origin)
130 1.1.1.2.2.2 bouyer {
131 1.1.1.2.2.2 bouyer return;
132 1.1.1.2.2.2 bouyer }
133 1.1.1.2.2.2 bouyer
134 1.1.1.2.2.2 bouyer AcpiOsPrintf ("/*\nAML Parse Tree\n\n");
135 1.1.1.2.2.2 bouyer Info.Flags = 0;
136 1.1.1.2.2.2 bouyer Info.Count = 0;
137 1.1.1.2.2.2 bouyer Info.Level = 0;
138 1.1.1.2.2.2 bouyer Info.WalkState = NULL;
139 1.1.1.2.2.2 bouyer AcpiDmWalkParseTree (Origin, AcpiDmDumpDescending, NULL, &Info);
140 1.1.1.2.2.2 bouyer AcpiOsPrintf ("*/\n\n");
141 1.1.1.2.2.2 bouyer }
142 1.1.1.2.2.2 bouyer
143 1.1.1.2.2.2 bouyer
144 1.1.1.2.2.2 bouyer /*******************************************************************************
145 1.1.1.2.2.2 bouyer *
146 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmFindOrphanMethods
147 1.1.1.2.2.2 bouyer *
148 1.1.1.2.2.2 bouyer * PARAMETERS: Origin - Starting object
149 1.1.1.2.2.2 bouyer *
150 1.1.1.2.2.2 bouyer * RETURN: None
151 1.1.1.2.2.2 bouyer *
152 1.1.1.2.2.2 bouyer * DESCRIPTION: Parse tree walk to find "orphaned" method invocations -- methods
153 1.1.1.2.2.2 bouyer * that are not resolved in the namespace
154 1.1.1.2.2.2 bouyer *
155 1.1.1.2.2.2 bouyer ******************************************************************************/
156 1.1.1.2.2.2 bouyer
157 1.1.1.2.2.2 bouyer void
158 1.1.1.2.2.2 bouyer AcpiDmFindOrphanMethods (
159 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Origin)
160 1.1.1.2.2.2 bouyer {
161 1.1.1.2.2.2 bouyer ACPI_OP_WALK_INFO Info;
162 1.1.1.2.2.2 bouyer
163 1.1.1.2.2.2 bouyer
164 1.1.1.2.2.2 bouyer if (!Origin)
165 1.1.1.2.2.2 bouyer {
166 1.1.1.2.2.2 bouyer return;
167 1.1.1.2.2.2 bouyer }
168 1.1.1.2.2.2 bouyer
169 1.1.1.2.2.2 bouyer Info.Flags = 0;
170 1.1.1.2.2.2 bouyer Info.Level = 0;
171 1.1.1.2.2.2 bouyer Info.WalkState = NULL;
172 1.1.1.2.2.2 bouyer AcpiDmWalkParseTree (Origin, AcpiDmFindOrphanDescending, NULL, &Info);
173 1.1.1.2.2.2 bouyer }
174 1.1.1.2.2.2 bouyer
175 1.1.1.2.2.2 bouyer
176 1.1.1.2.2.2 bouyer /*******************************************************************************
177 1.1.1.2.2.2 bouyer *
178 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmFinishNamespaceLoad
179 1.1.1.2.2.2 bouyer *
180 1.1.1.2.2.2 bouyer * PARAMETERS: ParseTreeRoot - Root of the parse tree
181 1.1.1.2.2.2 bouyer * NamespaceRoot - Root of the internal namespace
182 1.1.1.2.2.2 bouyer * OwnerId - OwnerId of the table to be disassembled
183 1.1.1.2.2.2 bouyer *
184 1.1.1.2.2.2 bouyer * RETURN: None
185 1.1.1.2.2.2 bouyer *
186 1.1.1.2.2.2 bouyer * DESCRIPTION: Load all namespace items that are created within control
187 1.1.1.2.2.2 bouyer * methods. Used before namespace cross reference
188 1.1.1.2.2.2 bouyer *
189 1.1.1.2.2.2 bouyer ******************************************************************************/
190 1.1.1.2.2.2 bouyer
191 1.1.1.2.2.2 bouyer void
192 1.1.1.2.2.2 bouyer AcpiDmFinishNamespaceLoad (
193 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *ParseTreeRoot,
194 1.1.1.2.2.2 bouyer ACPI_NAMESPACE_NODE *NamespaceRoot,
195 1.1.1.2.2.2 bouyer ACPI_OWNER_ID OwnerId)
196 1.1.1.2.2.2 bouyer {
197 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
198 1.1.1.2.2.2 bouyer ACPI_OP_WALK_INFO Info;
199 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState;
200 1.1.1.2.2.2 bouyer
201 1.1.1.2.2.2 bouyer
202 1.1.1.2.2.2 bouyer if (!ParseTreeRoot)
203 1.1.1.2.2.2 bouyer {
204 1.1.1.2.2.2 bouyer return;
205 1.1.1.2.2.2 bouyer }
206 1.1.1.2.2.2 bouyer
207 1.1.1.2.2.2 bouyer /* Create and initialize a new walk state */
208 1.1.1.2.2.2 bouyer
209 1.1.1.2.2.2 bouyer WalkState = AcpiDsCreateWalkState (OwnerId, ParseTreeRoot, NULL, NULL);
210 1.1.1.2.2.2 bouyer if (!WalkState)
211 1.1.1.2.2.2 bouyer {
212 1.1.1.2.2.2 bouyer return;
213 1.1.1.2.2.2 bouyer }
214 1.1.1.2.2.2 bouyer
215 1.1.1.2.2.2 bouyer Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, WalkState);
216 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
217 1.1.1.2.2.2 bouyer {
218 1.1.1.2.2.2 bouyer return;
219 1.1.1.2.2.2 bouyer }
220 1.1.1.2.2.2 bouyer
221 1.1.1.2.2.2 bouyer Info.Flags = 0;
222 1.1.1.2.2.2 bouyer Info.Level = 0;
223 1.1.1.2.2.2 bouyer Info.WalkState = WalkState;
224 1.1.1.2.2.2 bouyer AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmLoadDescendingOp,
225 1.1.1.2.2.2 bouyer AcpiDmCommonAscendingOp, &Info);
226 1.1.1.2.2.2 bouyer ACPI_FREE (WalkState);
227 1.1.1.2.2.2 bouyer }
228 1.1.1.2.2.2 bouyer
229 1.1.1.2.2.2 bouyer
230 1.1.1.2.2.2 bouyer /*******************************************************************************
231 1.1.1.2.2.2 bouyer *
232 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmCrossReferenceNamespace
233 1.1.1.2.2.2 bouyer *
234 1.1.1.2.2.2 bouyer * PARAMETERS: ParseTreeRoot - Root of the parse tree
235 1.1.1.2.2.2 bouyer * NamespaceRoot - Root of the internal namespace
236 1.1.1.2.2.2 bouyer * OwnerId - OwnerId of the table to be disassembled
237 1.1.1.2.2.2 bouyer *
238 1.1.1.2.2.2 bouyer * RETURN: None
239 1.1.1.2.2.2 bouyer *
240 1.1.1.2.2.2 bouyer * DESCRIPTION: Cross reference the namespace to create externals
241 1.1.1.2.2.2 bouyer *
242 1.1.1.2.2.2 bouyer ******************************************************************************/
243 1.1.1.2.2.2 bouyer
244 1.1.1.2.2.2 bouyer void
245 1.1.1.2.2.2 bouyer AcpiDmCrossReferenceNamespace (
246 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *ParseTreeRoot,
247 1.1.1.2.2.2 bouyer ACPI_NAMESPACE_NODE *NamespaceRoot,
248 1.1.1.2.2.2 bouyer ACPI_OWNER_ID OwnerId)
249 1.1.1.2.2.2 bouyer {
250 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
251 1.1.1.2.2.2 bouyer ACPI_OP_WALK_INFO Info;
252 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState;
253 1.1.1.2.2.2 bouyer
254 1.1.1.2.2.2 bouyer
255 1.1.1.2.2.2 bouyer if (!ParseTreeRoot)
256 1.1.1.2.2.2 bouyer {
257 1.1.1.2.2.2 bouyer return;
258 1.1.1.2.2.2 bouyer }
259 1.1.1.2.2.2 bouyer
260 1.1.1.2.2.2 bouyer /* Create and initialize a new walk state */
261 1.1.1.2.2.2 bouyer
262 1.1.1.2.2.2 bouyer WalkState = AcpiDsCreateWalkState (OwnerId, ParseTreeRoot, NULL, NULL);
263 1.1.1.2.2.2 bouyer if (!WalkState)
264 1.1.1.2.2.2 bouyer {
265 1.1.1.2.2.2 bouyer return;
266 1.1.1.2.2.2 bouyer }
267 1.1.1.2.2.2 bouyer
268 1.1.1.2.2.2 bouyer Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, WalkState);
269 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
270 1.1.1.2.2.2 bouyer {
271 1.1.1.2.2.2 bouyer return;
272 1.1.1.2.2.2 bouyer }
273 1.1.1.2.2.2 bouyer
274 1.1.1.2.2.2 bouyer Info.Flags = 0;
275 1.1.1.2.2.2 bouyer Info.Level = 0;
276 1.1.1.2.2.2 bouyer Info.WalkState = WalkState;
277 1.1.1.2.2.2 bouyer AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmXrefDescendingOp,
278 1.1.1.2.2.2 bouyer AcpiDmCommonAscendingOp, &Info);
279 1.1.1.2.2.2 bouyer ACPI_FREE (WalkState);
280 1.1.1.2.2.2 bouyer }
281 1.1.1.2.2.2 bouyer
282 1.1.1.2.2.2 bouyer
283 1.1.1.2.2.2 bouyer /*******************************************************************************
284 1.1.1.2.2.2 bouyer *
285 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmConvertResourceIndexes
286 1.1.1.2.2.2 bouyer *
287 1.1.1.2.2.2 bouyer * PARAMETERS: ParseTreeRoot - Root of the parse tree
288 1.1.1.2.2.2 bouyer * NamespaceRoot - Root of the internal namespace
289 1.1.1.2.2.2 bouyer *
290 1.1.1.2.2.2 bouyer * RETURN: None
291 1.1.1.2.2.2 bouyer *
292 1.1.1.2.2.2 bouyer * DESCRIPTION: Convert fixed-offset references to resource descriptors to
293 1.1.1.2.2.2 bouyer * symbolic references. Should only be called after namespace has
294 1.1.1.2.2.2 bouyer * been cross referenced.
295 1.1.1.2.2.2 bouyer *
296 1.1.1.2.2.2 bouyer ******************************************************************************/
297 1.1.1.2.2.2 bouyer
298 1.1.1.2.2.2 bouyer void
299 1.1.1.2.2.2 bouyer AcpiDmConvertResourceIndexes (
300 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *ParseTreeRoot,
301 1.1.1.2.2.2 bouyer ACPI_NAMESPACE_NODE *NamespaceRoot)
302 1.1.1.2.2.2 bouyer {
303 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
304 1.1.1.2.2.2 bouyer ACPI_OP_WALK_INFO Info;
305 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState;
306 1.1.1.2.2.2 bouyer
307 1.1.1.2.2.2 bouyer
308 1.1.1.2.2.2 bouyer if (!ParseTreeRoot)
309 1.1.1.2.2.2 bouyer {
310 1.1.1.2.2.2 bouyer return;
311 1.1.1.2.2.2 bouyer }
312 1.1.1.2.2.2 bouyer
313 1.1.1.2.2.2 bouyer /* Create and initialize a new walk state */
314 1.1.1.2.2.2 bouyer
315 1.1.1.2.2.2 bouyer WalkState = AcpiDsCreateWalkState (0, ParseTreeRoot, NULL, NULL);
316 1.1.1.2.2.2 bouyer if (!WalkState)
317 1.1.1.2.2.2 bouyer {
318 1.1.1.2.2.2 bouyer return;
319 1.1.1.2.2.2 bouyer }
320 1.1.1.2.2.2 bouyer
321 1.1.1.2.2.2 bouyer Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, WalkState);
322 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
323 1.1.1.2.2.2 bouyer {
324 1.1.1.2.2.2 bouyer return;
325 1.1.1.2.2.2 bouyer }
326 1.1.1.2.2.2 bouyer
327 1.1.1.2.2.2 bouyer Info.Flags = 0;
328 1.1.1.2.2.2 bouyer Info.Level = 0;
329 1.1.1.2.2.2 bouyer Info.WalkState = WalkState;
330 1.1.1.2.2.2 bouyer AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmResourceDescendingOp,
331 1.1.1.2.2.2 bouyer AcpiDmCommonAscendingOp, &Info);
332 1.1.1.2.2.2 bouyer ACPI_FREE (WalkState);
333 1.1.1.2.2.2 bouyer return;
334 1.1.1.2.2.2 bouyer }
335 1.1.1.2.2.2 bouyer
336 1.1.1.2.2.2 bouyer
337 1.1.1.2.2.2 bouyer /*******************************************************************************
338 1.1.1.2.2.2 bouyer *
339 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmDumpDescending
340 1.1.1.2.2.2 bouyer *
341 1.1.1.2.2.2 bouyer * PARAMETERS: ASL_WALK_CALLBACK
342 1.1.1.2.2.2 bouyer *
343 1.1.1.2.2.2 bouyer * RETURN: Status
344 1.1.1.2.2.2 bouyer *
345 1.1.1.2.2.2 bouyer * DESCRIPTION: Format and print contents of one parse Op.
346 1.1.1.2.2.2 bouyer *
347 1.1.1.2.2.2 bouyer ******************************************************************************/
348 1.1.1.2.2.2 bouyer
349 1.1.1.2.2.2 bouyer static ACPI_STATUS
350 1.1.1.2.2.2 bouyer AcpiDmDumpDescending (
351 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
352 1.1.1.2.2.2 bouyer UINT32 Level,
353 1.1.1.2.2.2 bouyer void *Context)
354 1.1.1.2.2.2 bouyer {
355 1.1.1.2.2.2 bouyer ACPI_OP_WALK_INFO *Info = Context;
356 1.1.1.2.2.2 bouyer char *Path;
357 1.1.1.2.2.2 bouyer
358 1.1.1.2.2.2 bouyer
359 1.1.1.2.2.2 bouyer if (!Op)
360 1.1.1.2.2.2 bouyer {
361 1.1.1.2.2.2 bouyer return (AE_OK);
362 1.1.1.2.2.2 bouyer }
363 1.1.1.2.2.2 bouyer
364 1.1.1.2.2.2 bouyer /* Most of the information (count, level, name) here */
365 1.1.1.2.2.2 bouyer
366 1.1.1.2.2.2 bouyer Info->Count++;
367 1.1.1.2.2.2 bouyer AcpiOsPrintf ("% 5d [%2.2d] ", Info->Count, Level);
368 1.1.1.2.2.2 bouyer AcpiDmIndent (Level);
369 1.1.1.2.2.2 bouyer AcpiOsPrintf ("%-28s", AcpiPsGetOpcodeName (Op->Common.AmlOpcode));
370 1.1.1.2.2.2 bouyer
371 1.1.1.2.2.2 bouyer /* Extra info is helpful */
372 1.1.1.2.2.2 bouyer
373 1.1.1.2.2.2 bouyer switch (Op->Common.AmlOpcode)
374 1.1.1.2.2.2 bouyer {
375 1.1.1.2.2.2 bouyer case AML_BYTE_OP:
376 1.1.1.2.2.2 bouyer case AML_WORD_OP:
377 1.1.1.2.2.2 bouyer case AML_DWORD_OP:
378 1.1.1.2.2.2 bouyer AcpiOsPrintf ("%X", (UINT32) Op->Common.Value.Integer);
379 1.1.1.2.2.2 bouyer break;
380 1.1.1.2.2.2 bouyer
381 1.1.1.2.2.2 bouyer case AML_INT_NAMEPATH_OP:
382 1.1.1.2.2.2 bouyer if (Op->Common.Value.String)
383 1.1.1.2.2.2 bouyer {
384 1.1.1.2.2.2 bouyer AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Common.Value.String,
385 1.1.1.2.2.2 bouyer NULL, &Path);
386 1.1.1.2.2.2 bouyer AcpiOsPrintf ("%s %p", Path, Op->Common.Node);
387 1.1.1.2.2.2 bouyer ACPI_FREE (Path);
388 1.1.1.2.2.2 bouyer }
389 1.1.1.2.2.2 bouyer else
390 1.1.1.2.2.2 bouyer {
391 1.1.1.2.2.2 bouyer AcpiOsPrintf ("[NULL]");
392 1.1.1.2.2.2 bouyer }
393 1.1.1.2.2.2 bouyer break;
394 1.1.1.2.2.2 bouyer
395 1.1.1.2.2.2 bouyer case AML_NAME_OP:
396 1.1.1.2.2.2 bouyer case AML_METHOD_OP:
397 1.1.1.2.2.2 bouyer case AML_DEVICE_OP:
398 1.1.1.2.2.2 bouyer case AML_INT_NAMEDFIELD_OP:
399 1.1.1.2.2.2 bouyer AcpiOsPrintf ("%4.4s", ACPI_CAST_PTR (char, &Op->Named.Name));
400 1.1.1.2.2.2 bouyer break;
401 1.1.1.2.2.2 bouyer
402 1.1.1.2.2.2 bouyer default:
403 1.1.1.2.2.2 bouyer break;
404 1.1.1.2.2.2 bouyer }
405 1.1.1.2.2.2 bouyer
406 1.1.1.2.2.2 bouyer AcpiOsPrintf ("\n");
407 1.1.1.2.2.2 bouyer return (AE_OK);
408 1.1.1.2.2.2 bouyer }
409 1.1.1.2.2.2 bouyer
410 1.1.1.2.2.2 bouyer
411 1.1.1.2.2.2 bouyer /*******************************************************************************
412 1.1.1.2.2.2 bouyer *
413 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmFindOrphanDescending
414 1.1.1.2.2.2 bouyer *
415 1.1.1.2.2.2 bouyer * PARAMETERS: ASL_WALK_CALLBACK
416 1.1.1.2.2.2 bouyer *
417 1.1.1.2.2.2 bouyer * RETURN: Status
418 1.1.1.2.2.2 bouyer *
419 1.1.1.2.2.2 bouyer * DESCRIPTION: Check namepath Ops for orphaned method invocations
420 1.1.1.2.2.2 bouyer *
421 1.1.1.2.2.2 bouyer * Note: Experimental.
422 1.1.1.2.2.2 bouyer *
423 1.1.1.2.2.2 bouyer ******************************************************************************/
424 1.1.1.2.2.2 bouyer
425 1.1.1.2.2.2 bouyer static ACPI_STATUS
426 1.1.1.2.2.2 bouyer AcpiDmFindOrphanDescending (
427 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
428 1.1.1.2.2.2 bouyer UINT32 Level,
429 1.1.1.2.2.2 bouyer void *Context)
430 1.1.1.2.2.2 bouyer {
431 1.1.1.2.2.2 bouyer const ACPI_OPCODE_INFO *OpInfo;
432 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *ChildOp;
433 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *NextOp;
434 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *ParentOp;
435 1.1.1.2.2.2 bouyer UINT32 ArgCount;
436 1.1.1.2.2.2 bouyer
437 1.1.1.2.2.2 bouyer
438 1.1.1.2.2.2 bouyer if (!Op)
439 1.1.1.2.2.2 bouyer {
440 1.1.1.2.2.2 bouyer return (AE_OK);
441 1.1.1.2.2.2 bouyer }
442 1.1.1.2.2.2 bouyer
443 1.1.1.2.2.2 bouyer OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
444 1.1.1.2.2.2 bouyer
445 1.1.1.2.2.2 bouyer switch (Op->Common.AmlOpcode)
446 1.1.1.2.2.2 bouyer {
447 1.1.1.2.2.2 bouyer #ifdef ACPI_UNDER_DEVELOPMENT
448 1.1.1.2.2.2 bouyer case AML_ADD_OP:
449 1.1.1.2.2.2 bouyer ChildOp = Op->Common.Value.Arg;
450 1.1.1.2.2.2 bouyer if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
451 1.1.1.2.2.2 bouyer !ChildOp->Common.Node)
452 1.1.1.2.2.2 bouyer {
453 1.1.1.2.2.2 bouyer AcpiNsExternalizeName (ACPI_UINT32_MAX, ChildOp->Common.Value.String,
454 1.1.1.2.2.2 bouyer NULL, &Path);
455 1.1.1.2.2.2 bouyer AcpiOsPrintf ("/* %-16s A-NAMEPATH: %s */\n", Op->Common.AmlOpName, Path);
456 1.1.1.2.2.2 bouyer ACPI_FREE (Path);
457 1.1.1.2.2.2 bouyer
458 1.1.1.2.2.2 bouyer NextOp = Op->Common.Next;
459 1.1.1.2.2.2 bouyer if (!NextOp)
460 1.1.1.2.2.2 bouyer {
461 1.1.1.2.2.2 bouyer /* This NamePath has no args, assume it is an integer */
462 1.1.1.2.2.2 bouyer
463 1.1.1.2.2.2 bouyer AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0);
464 1.1.1.2.2.2 bouyer return (AE_OK);
465 1.1.1.2.2.2 bouyer }
466 1.1.1.2.2.2 bouyer
467 1.1.1.2.2.2 bouyer ArgCount = AcpiDmInspectPossibleArgs (3, 1, NextOp);
468 1.1.1.2.2.2 bouyer AcpiOsPrintf ("/* A-CHILDREN: %u Actual %u */\n", ArgCount, AcpiDmCountChildren (Op));
469 1.1.1.2.2.2 bouyer
470 1.1.1.2.2.2 bouyer if (ArgCount < 1)
471 1.1.1.2.2.2 bouyer {
472 1.1.1.2.2.2 bouyer /* One Arg means this is just a Store(Name,Target) */
473 1.1.1.2.2.2 bouyer
474 1.1.1.2.2.2 bouyer AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0);
475 1.1.1.2.2.2 bouyer return (AE_OK);
476 1.1.1.2.2.2 bouyer }
477 1.1.1.2.2.2 bouyer
478 1.1.1.2.2.2 bouyer AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount);
479 1.1.1.2.2.2 bouyer }
480 1.1.1.2.2.2 bouyer break;
481 1.1.1.2.2.2 bouyer #endif
482 1.1.1.2.2.2 bouyer
483 1.1.1.2.2.2 bouyer case AML_STORE_OP:
484 1.1.1.2.2.2 bouyer
485 1.1.1.2.2.2 bouyer ChildOp = Op->Common.Value.Arg;
486 1.1.1.2.2.2 bouyer if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
487 1.1.1.2.2.2 bouyer !ChildOp->Common.Node)
488 1.1.1.2.2.2 bouyer {
489 1.1.1.2.2.2 bouyer NextOp = Op->Common.Next;
490 1.1.1.2.2.2 bouyer if (!NextOp)
491 1.1.1.2.2.2 bouyer {
492 1.1.1.2.2.2 bouyer /* This NamePath has no args, assume it is an integer */
493 1.1.1.2.2.2 bouyer
494 1.1.1.2.2.2 bouyer AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0);
495 1.1.1.2.2.2 bouyer return (AE_OK);
496 1.1.1.2.2.2 bouyer }
497 1.1.1.2.2.2 bouyer
498 1.1.1.2.2.2 bouyer ArgCount = AcpiDmInspectPossibleArgs (2, 1, NextOp);
499 1.1.1.2.2.2 bouyer if (ArgCount <= 1)
500 1.1.1.2.2.2 bouyer {
501 1.1.1.2.2.2 bouyer /* One Arg means this is just a Store(Name,Target) */
502 1.1.1.2.2.2 bouyer
503 1.1.1.2.2.2 bouyer AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0);
504 1.1.1.2.2.2 bouyer return (AE_OK);
505 1.1.1.2.2.2 bouyer }
506 1.1.1.2.2.2 bouyer
507 1.1.1.2.2.2 bouyer AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount);
508 1.1.1.2.2.2 bouyer }
509 1.1.1.2.2.2 bouyer break;
510 1.1.1.2.2.2 bouyer
511 1.1.1.2.2.2 bouyer case AML_INT_NAMEPATH_OP:
512 1.1.1.2.2.2 bouyer
513 1.1.1.2.2.2 bouyer /* Must examine parent to see if this namepath is an argument */
514 1.1.1.2.2.2 bouyer
515 1.1.1.2.2.2 bouyer ParentOp = Op->Common.Parent;
516 1.1.1.2.2.2 bouyer OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode);
517 1.1.1.2.2.2 bouyer
518 1.1.1.2.2.2 bouyer if ((OpInfo->Class != AML_CLASS_EXECUTE) &&
519 1.1.1.2.2.2 bouyer (OpInfo->Class != AML_CLASS_CREATE) &&
520 1.1.1.2.2.2 bouyer (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) &&
521 1.1.1.2.2.2 bouyer !Op->Common.Node)
522 1.1.1.2.2.2 bouyer {
523 1.1.1.2.2.2 bouyer ArgCount = AcpiDmInspectPossibleArgs (0, 0, Op->Common.Next);
524 1.1.1.2.2.2 bouyer
525 1.1.1.2.2.2 bouyer /*
526 1.1.1.2.2.2 bouyer * Check if namepath is a predicate for if/while or lone parameter to
527 1.1.1.2.2.2 bouyer * a return.
528 1.1.1.2.2.2 bouyer */
529 1.1.1.2.2.2 bouyer if (ArgCount == 0)
530 1.1.1.2.2.2 bouyer {
531 1.1.1.2.2.2 bouyer if (((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
532 1.1.1.2.2.2 bouyer (ParentOp->Common.AmlOpcode == AML_WHILE_OP) ||
533 1.1.1.2.2.2 bouyer (ParentOp->Common.AmlOpcode == AML_RETURN_OP)) &&
534 1.1.1.2.2.2 bouyer
535 1.1.1.2.2.2 bouyer /* And namepath is the first argument */
536 1.1.1.2.2.2 bouyer (ParentOp->Common.Value.Arg == Op))
537 1.1.1.2.2.2 bouyer {
538 1.1.1.2.2.2 bouyer AcpiDmAddToExternalList (Op, Op->Common.Value.String, ACPI_TYPE_INTEGER, 0);
539 1.1.1.2.2.2 bouyer break;
540 1.1.1.2.2.2 bouyer }
541 1.1.1.2.2.2 bouyer }
542 1.1.1.2.2.2 bouyer
543 1.1.1.2.2.2 bouyer /*
544 1.1.1.2.2.2 bouyer * This is a standalone namestring (not a parameter to another
545 1.1.1.2.2.2 bouyer * operator) - it *must* be a method invocation, nothing else is
546 1.1.1.2.2.2 bouyer * grammatically possible.
547 1.1.1.2.2.2 bouyer */
548 1.1.1.2.2.2 bouyer AcpiDmAddToExternalList (Op, Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount);
549 1.1.1.2.2.2 bouyer
550 1.1.1.2.2.2 bouyer }
551 1.1.1.2.2.2 bouyer break;
552 1.1.1.2.2.2 bouyer
553 1.1.1.2.2.2 bouyer default:
554 1.1.1.2.2.2 bouyer break;
555 1.1.1.2.2.2 bouyer }
556 1.1.1.2.2.2 bouyer
557 1.1.1.2.2.2 bouyer return (AE_OK);
558 1.1.1.2.2.2 bouyer }
559 1.1.1.2.2.2 bouyer
560 1.1.1.2.2.2 bouyer
561 1.1.1.2.2.2 bouyer /*******************************************************************************
562 1.1.1.2.2.2 bouyer *
563 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmLoadDescendingOp
564 1.1.1.2.2.2 bouyer *
565 1.1.1.2.2.2 bouyer * PARAMETERS: ASL_WALK_CALLBACK
566 1.1.1.2.2.2 bouyer *
567 1.1.1.2.2.2 bouyer * RETURN: Status
568 1.1.1.2.2.2 bouyer *
569 1.1.1.2.2.2 bouyer * DESCRIPTION: Descending handler for namespace control method object load
570 1.1.1.2.2.2 bouyer *
571 1.1.1.2.2.2 bouyer ******************************************************************************/
572 1.1.1.2.2.2 bouyer
573 1.1.1.2.2.2 bouyer static ACPI_STATUS
574 1.1.1.2.2.2 bouyer AcpiDmLoadDescendingOp (
575 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
576 1.1.1.2.2.2 bouyer UINT32 Level,
577 1.1.1.2.2.2 bouyer void *Context)
578 1.1.1.2.2.2 bouyer {
579 1.1.1.2.2.2 bouyer ACPI_OP_WALK_INFO *Info = Context;
580 1.1.1.2.2.2 bouyer const ACPI_OPCODE_INFO *OpInfo;
581 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState;
582 1.1.1.2.2.2 bouyer ACPI_OBJECT_TYPE ObjectType;
583 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
584 1.1.1.2.2.2 bouyer char *Path = NULL;
585 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *NextOp;
586 1.1.1.2.2.2 bouyer ACPI_NAMESPACE_NODE *Node;
587 1.1.1.2.2.2 bouyer char FieldPath[5];
588 1.1.1.2.2.2 bouyer BOOLEAN PreDefined = FALSE;
589 1.1.1.2.2.2 bouyer UINT8 PreDefineIndex = 0;
590 1.1.1.2.2.2 bouyer
591 1.1.1.2.2.2 bouyer
592 1.1.1.2.2.2 bouyer WalkState = Info->WalkState;
593 1.1.1.2.2.2 bouyer OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
594 1.1.1.2.2.2 bouyer ObjectType = OpInfo->ObjectType;
595 1.1.1.2.2.2 bouyer ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
596 1.1.1.2.2.2 bouyer
597 1.1.1.2.2.2 bouyer /* Only interested in operators that create new names */
598 1.1.1.2.2.2 bouyer
599 1.1.1.2.2.2 bouyer if (!(OpInfo->Flags & AML_NAMED) &&
600 1.1.1.2.2.2 bouyer !(OpInfo->Flags & AML_CREATE))
601 1.1.1.2.2.2 bouyer {
602 1.1.1.2.2.2 bouyer goto Exit;
603 1.1.1.2.2.2 bouyer }
604 1.1.1.2.2.2 bouyer
605 1.1.1.2.2.2 bouyer /* Get the NamePath from the appropriate place */
606 1.1.1.2.2.2 bouyer
607 1.1.1.2.2.2 bouyer if (OpInfo->Flags & AML_NAMED)
608 1.1.1.2.2.2 bouyer {
609 1.1.1.2.2.2 bouyer /* For all named operators, get the new name */
610 1.1.1.2.2.2 bouyer
611 1.1.1.2.2.2 bouyer Path = (char *) Op->Named.Path;
612 1.1.1.2.2.2 bouyer
613 1.1.1.2.2.2 bouyer if (!Path && Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
614 1.1.1.2.2.2 bouyer {
615 1.1.1.2.2.2 bouyer *ACPI_CAST_PTR (UINT32, &FieldPath[0]) = Op->Named.Name;
616 1.1.1.2.2.2 bouyer FieldPath[4] = 0;
617 1.1.1.2.2.2 bouyer Path = FieldPath;
618 1.1.1.2.2.2 bouyer }
619 1.1.1.2.2.2 bouyer }
620 1.1.1.2.2.2 bouyer else if (OpInfo->Flags & AML_CREATE)
621 1.1.1.2.2.2 bouyer {
622 1.1.1.2.2.2 bouyer /* New name is the last child */
623 1.1.1.2.2.2 bouyer
624 1.1.1.2.2.2 bouyer NextOp = Op->Common.Value.Arg;
625 1.1.1.2.2.2 bouyer
626 1.1.1.2.2.2 bouyer while (NextOp->Common.Next)
627 1.1.1.2.2.2 bouyer {
628 1.1.1.2.2.2 bouyer NextOp = NextOp->Common.Next;
629 1.1.1.2.2.2 bouyer }
630 1.1.1.2.2.2 bouyer Path = NextOp->Common.Value.String;
631 1.1.1.2.2.2 bouyer }
632 1.1.1.2.2.2 bouyer
633 1.1.1.2.2.2 bouyer if (!Path)
634 1.1.1.2.2.2 bouyer {
635 1.1.1.2.2.2 bouyer goto Exit;
636 1.1.1.2.2.2 bouyer }
637 1.1.1.2.2.2 bouyer
638 1.1.1.2.2.2 bouyer /* Insert the name into the namespace */
639 1.1.1.2.2.2 bouyer
640 1.1.1.2.2.2 bouyer Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
641 1.1.1.2.2.2 bouyer ACPI_IMODE_LOAD_PASS2, ACPI_NS_DONT_OPEN_SCOPE,
642 1.1.1.2.2.2 bouyer WalkState, &Node);
643 1.1.1.2.2.2 bouyer
644 1.1.1.2.2.2 bouyer Op->Common.Node = Node;
645 1.1.1.2.2.2 bouyer
646 1.1.1.2.2.2 bouyer if (ACPI_SUCCESS (Status))
647 1.1.1.2.2.2 bouyer {
648 1.1.1.2.2.2 bouyer /* Check if it's a predefined node */
649 1.1.1.2.2.2 bouyer
650 1.1.1.2.2.2 bouyer while (AcpiGbl_PreDefinedNames[PreDefineIndex].Name)
651 1.1.1.2.2.2 bouyer {
652 1.1.1.2.2.2 bouyer if (!ACPI_STRNCMP (Node->Name.Ascii,
653 1.1.1.2.2.2 bouyer AcpiGbl_PreDefinedNames[PreDefineIndex].Name, 4))
654 1.1.1.2.2.2 bouyer {
655 1.1.1.2.2.2 bouyer PreDefined = TRUE;
656 1.1.1.2.2.2 bouyer break;
657 1.1.1.2.2.2 bouyer }
658 1.1.1.2.2.2 bouyer
659 1.1.1.2.2.2 bouyer PreDefineIndex++;
660 1.1.1.2.2.2 bouyer }
661 1.1.1.2.2.2 bouyer
662 1.1.1.2.2.2 bouyer /*
663 1.1.1.2.2.2 bouyer * Set node owner id if it satisfies all the following conditions:
664 1.1.1.2.2.2 bouyer * 1) Not a predefined node, _SB_ etc
665 1.1.1.2.2.2 bouyer * 2) Not the root node
666 1.1.1.2.2.2 bouyer * 3) Not a node created by Scope
667 1.1.1.2.2.2 bouyer */
668 1.1.1.2.2.2 bouyer
669 1.1.1.2.2.2 bouyer if (!PreDefined && Node != AcpiGbl_RootNode &&
670 1.1.1.2.2.2 bouyer Op->Common.AmlOpcode != AML_SCOPE_OP)
671 1.1.1.2.2.2 bouyer {
672 1.1.1.2.2.2 bouyer Node->OwnerId = WalkState->OwnerId;
673 1.1.1.2.2.2 bouyer }
674 1.1.1.2.2.2 bouyer }
675 1.1.1.2.2.2 bouyer
676 1.1.1.2.2.2 bouyer
677 1.1.1.2.2.2 bouyer Exit:
678 1.1.1.2.2.2 bouyer
679 1.1.1.2.2.2 bouyer if (AcpiNsOpensScope (ObjectType))
680 1.1.1.2.2.2 bouyer {
681 1.1.1.2.2.2 bouyer if (Op->Common.Node)
682 1.1.1.2.2.2 bouyer {
683 1.1.1.2.2.2 bouyer Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, WalkState);
684 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
685 1.1.1.2.2.2 bouyer {
686 1.1.1.2.2.2 bouyer return (Status);
687 1.1.1.2.2.2 bouyer }
688 1.1.1.2.2.2 bouyer }
689 1.1.1.2.2.2 bouyer }
690 1.1.1.2.2.2 bouyer
691 1.1.1.2.2.2 bouyer return (AE_OK);
692 1.1.1.2.2.2 bouyer }
693 1.1.1.2.2.2 bouyer
694 1.1.1.2.2.2 bouyer
695 1.1.1.2.2.2 bouyer /*******************************************************************************
696 1.1.1.2.2.2 bouyer *
697 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmXrefDescendingOp
698 1.1.1.2.2.2 bouyer *
699 1.1.1.2.2.2 bouyer * PARAMETERS: ASL_WALK_CALLBACK
700 1.1.1.2.2.2 bouyer *
701 1.1.1.2.2.2 bouyer * RETURN: Status
702 1.1.1.2.2.2 bouyer *
703 1.1.1.2.2.2 bouyer * DESCRIPTION: Descending handler for namespace cross reference
704 1.1.1.2.2.2 bouyer *
705 1.1.1.2.2.2 bouyer ******************************************************************************/
706 1.1.1.2.2.2 bouyer
707 1.1.1.2.2.2 bouyer static ACPI_STATUS
708 1.1.1.2.2.2 bouyer AcpiDmXrefDescendingOp (
709 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
710 1.1.1.2.2.2 bouyer UINT32 Level,
711 1.1.1.2.2.2 bouyer void *Context)
712 1.1.1.2.2.2 bouyer {
713 1.1.1.2.2.2 bouyer ACPI_OP_WALK_INFO *Info = Context;
714 1.1.1.2.2.2 bouyer const ACPI_OPCODE_INFO *OpInfo;
715 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState;
716 1.1.1.2.2.2 bouyer ACPI_OBJECT_TYPE ObjectType;
717 1.1.1.2.2.2 bouyer ACPI_OBJECT_TYPE ObjectType2;
718 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
719 1.1.1.2.2.2 bouyer char *Path = NULL;
720 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *NextOp;
721 1.1.1.2.2.2 bouyer ACPI_NAMESPACE_NODE *Node;
722 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT *Object;
723 1.1.1.2.2.2 bouyer UINT32 ParamCount = 0;
724 1.1.1.2.2.2 bouyer
725 1.1.1.2.2.2 bouyer
726 1.1.1.2.2.2 bouyer WalkState = Info->WalkState;
727 1.1.1.2.2.2 bouyer OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
728 1.1.1.2.2.2 bouyer ObjectType = OpInfo->ObjectType;
729 1.1.1.2.2.2 bouyer ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
730 1.1.1.2.2.2 bouyer
731 1.1.1.2.2.2 bouyer if ((!(OpInfo->Flags & AML_NAMED)) &&
732 1.1.1.2.2.2 bouyer (!(OpInfo->Flags & AML_CREATE)) &&
733 1.1.1.2.2.2 bouyer (Op->Common.AmlOpcode != AML_INT_NAMEPATH_OP))
734 1.1.1.2.2.2 bouyer {
735 1.1.1.2.2.2 bouyer goto Exit;
736 1.1.1.2.2.2 bouyer }
737 1.1.1.2.2.2 bouyer
738 1.1.1.2.2.2 bouyer /* Get the NamePath from the appropriate place */
739 1.1.1.2.2.2 bouyer
740 1.1.1.2.2.2 bouyer if (OpInfo->Flags & AML_NAMED)
741 1.1.1.2.2.2 bouyer {
742 1.1.1.2.2.2 bouyer if ((Op->Common.AmlOpcode == AML_ALIAS_OP) ||
743 1.1.1.2.2.2 bouyer (Op->Common.AmlOpcode == AML_SCOPE_OP))
744 1.1.1.2.2.2 bouyer {
745 1.1.1.2.2.2 bouyer /*
746 1.1.1.2.2.2 bouyer * Only these two operators refer to an existing name,
747 1.1.1.2.2.2 bouyer * first argument
748 1.1.1.2.2.2 bouyer */
749 1.1.1.2.2.2 bouyer Path = (char *) Op->Named.Path;
750 1.1.1.2.2.2 bouyer }
751 1.1.1.2.2.2 bouyer }
752 1.1.1.2.2.2 bouyer else if (OpInfo->Flags & AML_CREATE)
753 1.1.1.2.2.2 bouyer {
754 1.1.1.2.2.2 bouyer /* Referenced Buffer Name is the first child */
755 1.1.1.2.2.2 bouyer
756 1.1.1.2.2.2 bouyer NextOp = Op->Common.Value.Arg;
757 1.1.1.2.2.2 bouyer if (NextOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
758 1.1.1.2.2.2 bouyer {
759 1.1.1.2.2.2 bouyer Path = NextOp->Common.Value.String;
760 1.1.1.2.2.2 bouyer }
761 1.1.1.2.2.2 bouyer }
762 1.1.1.2.2.2 bouyer else
763 1.1.1.2.2.2 bouyer {
764 1.1.1.2.2.2 bouyer Path = Op->Common.Value.String;
765 1.1.1.2.2.2 bouyer }
766 1.1.1.2.2.2 bouyer
767 1.1.1.2.2.2 bouyer if (!Path)
768 1.1.1.2.2.2 bouyer {
769 1.1.1.2.2.2 bouyer goto Exit;
770 1.1.1.2.2.2 bouyer }
771 1.1.1.2.2.2 bouyer
772 1.1.1.2.2.2 bouyer /*
773 1.1.1.2.2.2 bouyer * Lookup the name in the namespace. Name must exist at this point, or it
774 1.1.1.2.2.2 bouyer * is an invalid reference.
775 1.1.1.2.2.2 bouyer *
776 1.1.1.2.2.2 bouyer * The namespace is also used as a lookup table for references to resource
777 1.1.1.2.2.2 bouyer * descriptors and the fields within them.
778 1.1.1.2.2.2 bouyer */
779 1.1.1.2.2.2 bouyer Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY,
780 1.1.1.2.2.2 bouyer ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
781 1.1.1.2.2.2 bouyer WalkState, &Node);
782 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
783 1.1.1.2.2.2 bouyer {
784 1.1.1.2.2.2 bouyer if (Status == AE_NOT_FOUND)
785 1.1.1.2.2.2 bouyer {
786 1.1.1.2.2.2 bouyer AcpiDmAddToExternalList (Op, Path, (UINT8) ObjectType, 0);
787 1.1.1.2.2.2 bouyer
788 1.1.1.2.2.2 bouyer /*
789 1.1.1.2.2.2 bouyer * We could install this into the namespace, but we catch duplicate
790 1.1.1.2.2.2 bouyer * externals when they are added to the list.
791 1.1.1.2.2.2 bouyer */
792 1.1.1.2.2.2 bouyer #if 0
793 1.1.1.2.2.2 bouyer Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY,
794 1.1.1.2.2.2 bouyer ACPI_IMODE_LOAD_PASS1, ACPI_NS_DONT_OPEN_SCOPE,
795 1.1.1.2.2.2 bouyer WalkState, &Node);
796 1.1.1.2.2.2 bouyer #endif
797 1.1.1.2.2.2 bouyer }
798 1.1.1.2.2.2 bouyer }
799 1.1.1.2.2.2 bouyer
800 1.1.1.2.2.2 bouyer /*
801 1.1.1.2.2.2 bouyer * Found the node in external table, add it to external list
802 1.1.1.2.2.2 bouyer * Node->OwnerId == 0 indicates built-in ACPI Names, _OS_ etc
803 1.1.1.2.2.2 bouyer */
804 1.1.1.2.2.2 bouyer else if (Node->OwnerId && WalkState->OwnerId != Node->OwnerId)
805 1.1.1.2.2.2 bouyer {
806 1.1.1.2.2.2 bouyer ObjectType2 = ObjectType;
807 1.1.1.2.2.2 bouyer
808 1.1.1.2.2.2 bouyer Object = AcpiNsGetAttachedObject (Node);
809 1.1.1.2.2.2 bouyer if (Object)
810 1.1.1.2.2.2 bouyer {
811 1.1.1.2.2.2 bouyer ObjectType2 = Object->Common.Type;
812 1.1.1.2.2.2 bouyer if (ObjectType2 == ACPI_TYPE_METHOD)
813 1.1.1.2.2.2 bouyer {
814 1.1.1.2.2.2 bouyer ParamCount = Object->Method.ParamCount;
815 1.1.1.2.2.2 bouyer }
816 1.1.1.2.2.2 bouyer }
817 1.1.1.2.2.2 bouyer
818 1.1.1.2.2.2 bouyer AcpiDmAddToExternalList (Op, Path, (UINT8) ObjectType2, ParamCount);
819 1.1.1.2.2.2 bouyer Op->Common.Node = Node;
820 1.1.1.2.2.2 bouyer }
821 1.1.1.2.2.2 bouyer else
822 1.1.1.2.2.2 bouyer {
823 1.1.1.2.2.2 bouyer Op->Common.Node = Node;
824 1.1.1.2.2.2 bouyer }
825 1.1.1.2.2.2 bouyer
826 1.1.1.2.2.2 bouyer
827 1.1.1.2.2.2 bouyer Exit:
828 1.1.1.2.2.2 bouyer /* Open new scope if necessary */
829 1.1.1.2.2.2 bouyer
830 1.1.1.2.2.2 bouyer if (AcpiNsOpensScope (ObjectType))
831 1.1.1.2.2.2 bouyer {
832 1.1.1.2.2.2 bouyer if (Op->Common.Node)
833 1.1.1.2.2.2 bouyer {
834 1.1.1.2.2.2 bouyer Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, WalkState);
835 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
836 1.1.1.2.2.2 bouyer {
837 1.1.1.2.2.2 bouyer return (Status);
838 1.1.1.2.2.2 bouyer }
839 1.1.1.2.2.2 bouyer }
840 1.1.1.2.2.2 bouyer }
841 1.1.1.2.2.2 bouyer
842 1.1.1.2.2.2 bouyer return (AE_OK);
843 1.1.1.2.2.2 bouyer }
844 1.1.1.2.2.2 bouyer
845 1.1.1.2.2.2 bouyer
846 1.1.1.2.2.2 bouyer /*******************************************************************************
847 1.1.1.2.2.2 bouyer *
848 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmResourceDescendingOp
849 1.1.1.2.2.2 bouyer *
850 1.1.1.2.2.2 bouyer * PARAMETERS: ASL_WALK_CALLBACK
851 1.1.1.2.2.2 bouyer *
852 1.1.1.2.2.2 bouyer * RETURN: None
853 1.1.1.2.2.2 bouyer *
854 1.1.1.2.2.2 bouyer * DESCRIPTION: Process one parse op during symbolic resource index conversion.
855 1.1.1.2.2.2 bouyer *
856 1.1.1.2.2.2 bouyer ******************************************************************************/
857 1.1.1.2.2.2 bouyer
858 1.1.1.2.2.2 bouyer static ACPI_STATUS
859 1.1.1.2.2.2 bouyer AcpiDmResourceDescendingOp (
860 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
861 1.1.1.2.2.2 bouyer UINT32 Level,
862 1.1.1.2.2.2 bouyer void *Context)
863 1.1.1.2.2.2 bouyer {
864 1.1.1.2.2.2 bouyer ACPI_OP_WALK_INFO *Info = Context;
865 1.1.1.2.2.2 bouyer const ACPI_OPCODE_INFO *OpInfo;
866 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState;
867 1.1.1.2.2.2 bouyer ACPI_OBJECT_TYPE ObjectType;
868 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
869 1.1.1.2.2.2 bouyer
870 1.1.1.2.2.2 bouyer
871 1.1.1.2.2.2 bouyer WalkState = Info->WalkState;
872 1.1.1.2.2.2 bouyer OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
873 1.1.1.2.2.2 bouyer
874 1.1.1.2.2.2 bouyer /* Open new scope if necessary */
875 1.1.1.2.2.2 bouyer
876 1.1.1.2.2.2 bouyer ObjectType = OpInfo->ObjectType;
877 1.1.1.2.2.2 bouyer if (AcpiNsOpensScope (ObjectType))
878 1.1.1.2.2.2 bouyer {
879 1.1.1.2.2.2 bouyer if (Op->Common.Node)
880 1.1.1.2.2.2 bouyer {
881 1.1.1.2.2.2 bouyer
882 1.1.1.2.2.2 bouyer Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, WalkState);
883 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
884 1.1.1.2.2.2 bouyer {
885 1.1.1.2.2.2 bouyer return (Status);
886 1.1.1.2.2.2 bouyer }
887 1.1.1.2.2.2 bouyer }
888 1.1.1.2.2.2 bouyer }
889 1.1.1.2.2.2 bouyer
890 1.1.1.2.2.2 bouyer /*
891 1.1.1.2.2.2 bouyer * Check if this operator contains a reference to a resource descriptor.
892 1.1.1.2.2.2 bouyer * If so, convert the reference into a symbolic reference.
893 1.1.1.2.2.2 bouyer */
894 1.1.1.2.2.2 bouyer AcpiDmCheckResourceReference (Op, WalkState);
895 1.1.1.2.2.2 bouyer return (AE_OK);
896 1.1.1.2.2.2 bouyer }
897 1.1.1.2.2.2 bouyer
898 1.1.1.2.2.2 bouyer
899 1.1.1.2.2.2 bouyer /*******************************************************************************
900 1.1.1.2.2.2 bouyer *
901 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmCommonAscendingOp
902 1.1.1.2.2.2 bouyer *
903 1.1.1.2.2.2 bouyer * PARAMETERS: ASL_WALK_CALLBACK
904 1.1.1.2.2.2 bouyer *
905 1.1.1.2.2.2 bouyer * RETURN: None
906 1.1.1.2.2.2 bouyer *
907 1.1.1.2.2.2 bouyer * DESCRIPTION: Ascending handler for combined parse/namespace walks. Closes
908 1.1.1.2.2.2 bouyer * scope if necessary.
909 1.1.1.2.2.2 bouyer *
910 1.1.1.2.2.2 bouyer ******************************************************************************/
911 1.1.1.2.2.2 bouyer
912 1.1.1.2.2.2 bouyer static ACPI_STATUS
913 1.1.1.2.2.2 bouyer AcpiDmCommonAscendingOp (
914 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
915 1.1.1.2.2.2 bouyer UINT32 Level,
916 1.1.1.2.2.2 bouyer void *Context)
917 1.1.1.2.2.2 bouyer {
918 1.1.1.2.2.2 bouyer ACPI_OP_WALK_INFO *Info = Context;
919 1.1.1.2.2.2 bouyer const ACPI_OPCODE_INFO *OpInfo;
920 1.1.1.2.2.2 bouyer ACPI_OBJECT_TYPE ObjectType;
921 1.1.1.2.2.2 bouyer
922 1.1.1.2.2.2 bouyer
923 1.1.1.2.2.2 bouyer /* Close scope if necessary */
924 1.1.1.2.2.2 bouyer
925 1.1.1.2.2.2 bouyer OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
926 1.1.1.2.2.2 bouyer ObjectType = OpInfo->ObjectType;
927 1.1.1.2.2.2 bouyer ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
928 1.1.1.2.2.2 bouyer
929 1.1.1.2.2.2 bouyer if (AcpiNsOpensScope (ObjectType))
930 1.1.1.2.2.2 bouyer {
931 1.1.1.2.2.2 bouyer (void) AcpiDsScopeStackPop (Info->WalkState);
932 1.1.1.2.2.2 bouyer }
933 1.1.1.2.2.2 bouyer
934 1.1.1.2.2.2 bouyer return (AE_OK);
935 1.1.1.2.2.2 bouyer }
936 1.1.1.2.2.2 bouyer
937 1.1.1.2.2.2 bouyer
938 1.1.1.2.2.2 bouyer /*******************************************************************************
939 1.1.1.2.2.2 bouyer *
940 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmInspectPossibleArgs
941 1.1.1.2.2.2 bouyer *
942 1.1.1.2.2.2 bouyer * PARAMETERS: CurrentOpArgCount - Which arg of the current op was the
943 1.1.1.2.2.2 bouyer * possible method invocation found
944 1.1.1.2.2.2 bouyer * TargetCount - Number of targets (0,1,2) for this op
945 1.1.1.2.2.2 bouyer * Op - Parse op
946 1.1.1.2.2.2 bouyer *
947 1.1.1.2.2.2 bouyer * RETURN: Status
948 1.1.1.2.2.2 bouyer *
949 1.1.1.2.2.2 bouyer * DESCRIPTION: Examine following args and next ops for possible arguments
950 1.1.1.2.2.2 bouyer * for an unrecognized method invocation.
951 1.1.1.2.2.2 bouyer *
952 1.1.1.2.2.2 bouyer ******************************************************************************/
953 1.1.1.2.2.2 bouyer
954 1.1.1.2.2.2 bouyer static UINT32
955 1.1.1.2.2.2 bouyer AcpiDmInspectPossibleArgs (
956 1.1.1.2.2.2 bouyer UINT32 CurrentOpArgCount,
957 1.1.1.2.2.2 bouyer UINT32 TargetCount,
958 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op)
959 1.1.1.2.2.2 bouyer {
960 1.1.1.2.2.2 bouyer const ACPI_OPCODE_INFO *OpInfo;
961 1.1.1.2.2.2 bouyer UINT32 i;
962 1.1.1.2.2.2 bouyer UINT32 Last = 0;
963 1.1.1.2.2.2 bouyer UINT32 Lookahead;
964 1.1.1.2.2.2 bouyer
965 1.1.1.2.2.2 bouyer
966 1.1.1.2.2.2 bouyer Lookahead = (ACPI_METHOD_NUM_ARGS + TargetCount) - CurrentOpArgCount;
967 1.1.1.2.2.2 bouyer
968 1.1.1.2.2.2 bouyer /* Lookahead for the maximum number of possible arguments */
969 1.1.1.2.2.2 bouyer
970 1.1.1.2.2.2 bouyer for (i = 0; i < Lookahead; i++)
971 1.1.1.2.2.2 bouyer {
972 1.1.1.2.2.2 bouyer if (!Op)
973 1.1.1.2.2.2 bouyer {
974 1.1.1.2.2.2 bouyer break;
975 1.1.1.2.2.2 bouyer }
976 1.1.1.2.2.2 bouyer
977 1.1.1.2.2.2 bouyer OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
978 1.1.1.2.2.2 bouyer
979 1.1.1.2.2.2 bouyer /*
980 1.1.1.2.2.2 bouyer * Any one of these operators is "very probably" not a method arg
981 1.1.1.2.2.2 bouyer */
982 1.1.1.2.2.2 bouyer if ((Op->Common.AmlOpcode == AML_STORE_OP) ||
983 1.1.1.2.2.2 bouyer (Op->Common.AmlOpcode == AML_NOTIFY_OP))
984 1.1.1.2.2.2 bouyer {
985 1.1.1.2.2.2 bouyer break;
986 1.1.1.2.2.2 bouyer }
987 1.1.1.2.2.2 bouyer
988 1.1.1.2.2.2 bouyer if ((OpInfo->Class != AML_CLASS_EXECUTE) &&
989 1.1.1.2.2.2 bouyer (OpInfo->Class != AML_CLASS_CONTROL))
990 1.1.1.2.2.2 bouyer {
991 1.1.1.2.2.2 bouyer Last = i+1;
992 1.1.1.2.2.2 bouyer }
993 1.1.1.2.2.2 bouyer
994 1.1.1.2.2.2 bouyer Op = Op->Common.Next;
995 1.1.1.2.2.2 bouyer }
996 1.1.1.2.2.2 bouyer
997 1.1.1.2.2.2 bouyer return (Last);
998 1.1.1.2.2.2 bouyer }
999 1.1.1.2.2.2 bouyer
1000 1.1.1.2.2.2 bouyer
1001