dbutils.c revision 1.3.2.2 1 1.3.2.2 bouyer /*******************************************************************************
2 1.3.2.2 bouyer *
3 1.3.2.2 bouyer * Module Name: dbutils - AML debugger utilities
4 1.3.2.2 bouyer *
5 1.3.2.2 bouyer ******************************************************************************/
6 1.3.2.2 bouyer
7 1.3.2.2 bouyer /*
8 1.3.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.3.2.2 bouyer * All rights reserved.
10 1.3.2.2 bouyer *
11 1.3.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.3.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.3.2.2 bouyer * are met:
14 1.3.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.3.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.3.2.2 bouyer * without modification.
17 1.3.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.3.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.3.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.3.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.3.2.2 bouyer * binary redistribution.
22 1.3.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.3.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.3.2.2 bouyer * from this software without specific prior written permission.
25 1.3.2.2 bouyer *
26 1.3.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.3.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.3.2.2 bouyer * Software Foundation.
29 1.3.2.2 bouyer *
30 1.3.2.2 bouyer * NO WARRANTY
31 1.3.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.3.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.3.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.3.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.3.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.3.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.3.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.3.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.3.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.3.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.3.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.3.2.2 bouyer */
43 1.3.2.2 bouyer
44 1.3.2.2 bouyer
45 1.3.2.2 bouyer #include "acpi.h"
46 1.3.2.2 bouyer #include "accommon.h"
47 1.3.2.2 bouyer #include "acnamesp.h"
48 1.3.2.2 bouyer #include "acdebug.h"
49 1.3.2.2 bouyer #include "acdisasm.h"
50 1.3.2.2 bouyer
51 1.3.2.2 bouyer
52 1.3.2.2 bouyer #ifdef ACPI_DEBUGGER
53 1.3.2.2 bouyer
54 1.3.2.2 bouyer #define _COMPONENT ACPI_CA_DEBUGGER
55 1.3.2.2 bouyer ACPI_MODULE_NAME ("dbutils")
56 1.3.2.2 bouyer
57 1.3.2.2 bouyer /* Local prototypes */
58 1.3.2.2 bouyer
59 1.3.2.2 bouyer #ifdef ACPI_OBSOLETE_FUNCTIONS
60 1.3.2.2 bouyer ACPI_STATUS
61 1.3.2.2 bouyer AcpiDbSecondPassParse (
62 1.3.2.2 bouyer ACPI_PARSE_OBJECT *Root);
63 1.3.2.2 bouyer
64 1.3.2.2 bouyer void
65 1.3.2.2 bouyer AcpiDbDumpBuffer (
66 1.3.2.2 bouyer UINT32 Address);
67 1.3.2.2 bouyer #endif
68 1.3.2.2 bouyer
69 1.3.2.2 bouyer static const char *Converter = "0123456789ABCDEF";
70 1.3.2.2 bouyer
71 1.3.2.2 bouyer
72 1.3.2.2 bouyer /*******************************************************************************
73 1.3.2.2 bouyer *
74 1.3.2.2 bouyer * FUNCTION: AcpiDbMatchArgument
75 1.3.2.2 bouyer *
76 1.3.2.2 bouyer * PARAMETERS: UserArgument - User command line
77 1.3.2.2 bouyer * Arguments - Array of commands to match against
78 1.3.2.2 bouyer *
79 1.3.2.2 bouyer * RETURN: Index into command array or ACPI_TYPE_NOT_FOUND if not found
80 1.3.2.2 bouyer *
81 1.3.2.2 bouyer * DESCRIPTION: Search command array for a command match
82 1.3.2.2 bouyer *
83 1.3.2.2 bouyer ******************************************************************************/
84 1.3.2.2 bouyer
85 1.3.2.2 bouyer ACPI_OBJECT_TYPE
86 1.3.2.2 bouyer AcpiDbMatchArgument (
87 1.3.2.2 bouyer char *UserArgument,
88 1.3.2.2 bouyer ARGUMENT_INFO *Arguments)
89 1.3.2.2 bouyer {
90 1.3.2.2 bouyer UINT32 i;
91 1.3.2.2 bouyer
92 1.3.2.2 bouyer
93 1.3.2.2 bouyer if (!UserArgument || UserArgument[0] == 0)
94 1.3.2.2 bouyer {
95 1.3.2.2 bouyer return (ACPI_TYPE_NOT_FOUND);
96 1.3.2.2 bouyer }
97 1.3.2.2 bouyer
98 1.3.2.2 bouyer for (i = 0; Arguments[i].Name; i++)
99 1.3.2.2 bouyer {
100 1.3.2.2 bouyer if (ACPI_STRSTR (Arguments[i].Name, UserArgument) == Arguments[i].Name)
101 1.3.2.2 bouyer {
102 1.3.2.2 bouyer return (i);
103 1.3.2.2 bouyer }
104 1.3.2.2 bouyer }
105 1.3.2.2 bouyer
106 1.3.2.2 bouyer /* Argument not recognized */
107 1.3.2.2 bouyer
108 1.3.2.2 bouyer return (ACPI_TYPE_NOT_FOUND);
109 1.3.2.2 bouyer }
110 1.3.2.2 bouyer
111 1.3.2.2 bouyer
112 1.3.2.2 bouyer /*******************************************************************************
113 1.3.2.2 bouyer *
114 1.3.2.2 bouyer * FUNCTION: AcpiDbSetOutputDestination
115 1.3.2.2 bouyer *
116 1.3.2.2 bouyer * PARAMETERS: OutputFlags - Current flags word
117 1.3.2.2 bouyer *
118 1.3.2.2 bouyer * RETURN: None
119 1.3.2.2 bouyer *
120 1.3.2.2 bouyer * DESCRIPTION: Set the current destination for debugger output. Also sets
121 1.3.2.2 bouyer * the debug output level accordingly.
122 1.3.2.2 bouyer *
123 1.3.2.2 bouyer ******************************************************************************/
124 1.3.2.2 bouyer
125 1.3.2.2 bouyer void
126 1.3.2.2 bouyer AcpiDbSetOutputDestination (
127 1.3.2.2 bouyer UINT32 OutputFlags)
128 1.3.2.2 bouyer {
129 1.3.2.2 bouyer
130 1.3.2.2 bouyer AcpiGbl_DbOutputFlags = (UINT8) OutputFlags;
131 1.3.2.2 bouyer
132 1.3.2.2 bouyer if ((OutputFlags & ACPI_DB_REDIRECTABLE_OUTPUT) && AcpiGbl_DbOutputToFile)
133 1.3.2.2 bouyer {
134 1.3.2.2 bouyer AcpiDbgLevel = AcpiGbl_DbDebugLevel;
135 1.3.2.2 bouyer }
136 1.3.2.2 bouyer else
137 1.3.2.2 bouyer {
138 1.3.2.2 bouyer AcpiDbgLevel = AcpiGbl_DbConsoleDebugLevel;
139 1.3.2.2 bouyer }
140 1.3.2.2 bouyer }
141 1.3.2.2 bouyer
142 1.3.2.2 bouyer
143 1.3.2.2 bouyer /*******************************************************************************
144 1.3.2.2 bouyer *
145 1.3.2.2 bouyer * FUNCTION: AcpiDbDumpExternalObject
146 1.3.2.2 bouyer *
147 1.3.2.2 bouyer * PARAMETERS: ObjDesc - External ACPI object to dump
148 1.3.2.2 bouyer * Level - Nesting level.
149 1.3.2.2 bouyer *
150 1.3.2.2 bouyer * RETURN: None
151 1.3.2.2 bouyer *
152 1.3.2.2 bouyer * DESCRIPTION: Dump the contents of an ACPI external object
153 1.3.2.2 bouyer *
154 1.3.2.2 bouyer ******************************************************************************/
155 1.3.2.2 bouyer
156 1.3.2.2 bouyer void
157 1.3.2.2 bouyer AcpiDbDumpExternalObject (
158 1.3.2.2 bouyer ACPI_OBJECT *ObjDesc,
159 1.3.2.2 bouyer UINT32 Level)
160 1.3.2.2 bouyer {
161 1.3.2.2 bouyer UINT32 i;
162 1.3.2.2 bouyer
163 1.3.2.2 bouyer
164 1.3.2.2 bouyer if (!ObjDesc)
165 1.3.2.2 bouyer {
166 1.3.2.2 bouyer AcpiOsPrintf ("[Null Object]\n");
167 1.3.2.2 bouyer return;
168 1.3.2.2 bouyer }
169 1.3.2.2 bouyer
170 1.3.2.2 bouyer for (i = 0; i < Level; i++)
171 1.3.2.2 bouyer {
172 1.3.2.2 bouyer AcpiOsPrintf (" ");
173 1.3.2.2 bouyer }
174 1.3.2.2 bouyer
175 1.3.2.2 bouyer switch (ObjDesc->Type)
176 1.3.2.2 bouyer {
177 1.3.2.2 bouyer case ACPI_TYPE_ANY:
178 1.3.2.2 bouyer
179 1.3.2.2 bouyer AcpiOsPrintf ("[Null Object] (Type=0)\n");
180 1.3.2.2 bouyer break;
181 1.3.2.2 bouyer
182 1.3.2.2 bouyer
183 1.3.2.2 bouyer case ACPI_TYPE_INTEGER:
184 1.3.2.2 bouyer
185 1.3.2.2 bouyer AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n",
186 1.3.2.2 bouyer ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
187 1.3.2.2 bouyer break;
188 1.3.2.2 bouyer
189 1.3.2.2 bouyer
190 1.3.2.2 bouyer case ACPI_TYPE_STRING:
191 1.3.2.2 bouyer
192 1.3.2.2 bouyer AcpiOsPrintf ("[String] Length %.2X = ", ObjDesc->String.Length);
193 1.3.2.2 bouyer for (i = 0; i < ObjDesc->String.Length; i++)
194 1.3.2.2 bouyer {
195 1.3.2.2 bouyer AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]);
196 1.3.2.2 bouyer }
197 1.3.2.2 bouyer AcpiOsPrintf ("\n");
198 1.3.2.2 bouyer break;
199 1.3.2.2 bouyer
200 1.3.2.2 bouyer
201 1.3.2.2 bouyer case ACPI_TYPE_BUFFER:
202 1.3.2.2 bouyer
203 1.3.2.2 bouyer AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length);
204 1.3.2.2 bouyer if (ObjDesc->Buffer.Length)
205 1.3.2.2 bouyer {
206 1.3.2.2 bouyer if (ObjDesc->Buffer.Length > 16)
207 1.3.2.2 bouyer {
208 1.3.2.2 bouyer AcpiOsPrintf ("\n");
209 1.3.2.2 bouyer }
210 1.3.2.2 bouyer AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer),
211 1.3.2.2 bouyer ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT);
212 1.3.2.2 bouyer }
213 1.3.2.2 bouyer else
214 1.3.2.2 bouyer {
215 1.3.2.2 bouyer AcpiOsPrintf ("\n");
216 1.3.2.2 bouyer }
217 1.3.2.2 bouyer break;
218 1.3.2.2 bouyer
219 1.3.2.2 bouyer
220 1.3.2.2 bouyer case ACPI_TYPE_PACKAGE:
221 1.3.2.2 bouyer
222 1.3.2.2 bouyer AcpiOsPrintf ("[Package] Contains %u Elements:\n",
223 1.3.2.2 bouyer ObjDesc->Package.Count);
224 1.3.2.2 bouyer
225 1.3.2.2 bouyer for (i = 0; i < ObjDesc->Package.Count; i++)
226 1.3.2.2 bouyer {
227 1.3.2.2 bouyer AcpiDbDumpExternalObject (&ObjDesc->Package.Elements[i], Level+1);
228 1.3.2.2 bouyer }
229 1.3.2.2 bouyer break;
230 1.3.2.2 bouyer
231 1.3.2.2 bouyer
232 1.3.2.2 bouyer case ACPI_TYPE_LOCAL_REFERENCE:
233 1.3.2.2 bouyer
234 1.3.2.2 bouyer AcpiOsPrintf ("[Object Reference] = ");
235 1.3.2.2 bouyer AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL);
236 1.3.2.2 bouyer break;
237 1.3.2.2 bouyer
238 1.3.2.2 bouyer
239 1.3.2.2 bouyer case ACPI_TYPE_PROCESSOR:
240 1.3.2.2 bouyer
241 1.3.2.2 bouyer AcpiOsPrintf ("[Processor]\n");
242 1.3.2.2 bouyer break;
243 1.3.2.2 bouyer
244 1.3.2.2 bouyer
245 1.3.2.2 bouyer case ACPI_TYPE_POWER:
246 1.3.2.2 bouyer
247 1.3.2.2 bouyer AcpiOsPrintf ("[Power Resource]\n");
248 1.3.2.2 bouyer break;
249 1.3.2.2 bouyer
250 1.3.2.2 bouyer
251 1.3.2.2 bouyer default:
252 1.3.2.2 bouyer
253 1.3.2.2 bouyer AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Type);
254 1.3.2.2 bouyer break;
255 1.3.2.2 bouyer }
256 1.3.2.2 bouyer }
257 1.3.2.2 bouyer
258 1.3.2.2 bouyer
259 1.3.2.2 bouyer /*******************************************************************************
260 1.3.2.2 bouyer *
261 1.3.2.2 bouyer * FUNCTION: AcpiDbPrepNamestring
262 1.3.2.2 bouyer *
263 1.3.2.2 bouyer * PARAMETERS: Name - String to prepare
264 1.3.2.2 bouyer *
265 1.3.2.2 bouyer * RETURN: None
266 1.3.2.2 bouyer *
267 1.3.2.2 bouyer * DESCRIPTION: Translate all forward slashes and dots to backslashes.
268 1.3.2.2 bouyer *
269 1.3.2.2 bouyer ******************************************************************************/
270 1.3.2.2 bouyer
271 1.3.2.2 bouyer void
272 1.3.2.2 bouyer AcpiDbPrepNamestring (
273 1.3.2.2 bouyer char *Name)
274 1.3.2.2 bouyer {
275 1.3.2.2 bouyer
276 1.3.2.2 bouyer if (!Name)
277 1.3.2.2 bouyer {
278 1.3.2.2 bouyer return;
279 1.3.2.2 bouyer }
280 1.3.2.2 bouyer
281 1.3.2.2 bouyer AcpiUtStrupr (Name);
282 1.3.2.2 bouyer
283 1.3.2.2 bouyer /* Convert a leading forward slash to a backslash */
284 1.3.2.2 bouyer
285 1.3.2.2 bouyer if (*Name == '/')
286 1.3.2.2 bouyer {
287 1.3.2.2 bouyer *Name = '\\';
288 1.3.2.2 bouyer }
289 1.3.2.2 bouyer
290 1.3.2.2 bouyer /* Ignore a leading backslash, this is the root prefix */
291 1.3.2.2 bouyer
292 1.3.2.2 bouyer if (*Name == '\\')
293 1.3.2.2 bouyer {
294 1.3.2.2 bouyer Name++;
295 1.3.2.2 bouyer }
296 1.3.2.2 bouyer
297 1.3.2.2 bouyer /* Convert all slash path separators to dots */
298 1.3.2.2 bouyer
299 1.3.2.2 bouyer while (*Name)
300 1.3.2.2 bouyer {
301 1.3.2.2 bouyer if ((*Name == '/') ||
302 1.3.2.2 bouyer (*Name == '\\'))
303 1.3.2.2 bouyer {
304 1.3.2.2 bouyer *Name = '.';
305 1.3.2.2 bouyer }
306 1.3.2.2 bouyer
307 1.3.2.2 bouyer Name++;
308 1.3.2.2 bouyer }
309 1.3.2.2 bouyer }
310 1.3.2.2 bouyer
311 1.3.2.2 bouyer
312 1.3.2.2 bouyer /*******************************************************************************
313 1.3.2.2 bouyer *
314 1.3.2.2 bouyer * FUNCTION: AcpiDbLocalNsLookup
315 1.3.2.2 bouyer *
316 1.3.2.2 bouyer * PARAMETERS: Name - Name to lookup
317 1.3.2.2 bouyer *
318 1.3.2.2 bouyer * RETURN: Pointer to a namespace node, null on failure
319 1.3.2.2 bouyer *
320 1.3.2.2 bouyer * DESCRIPTION: Lookup a name in the ACPI namespace
321 1.3.2.2 bouyer *
322 1.3.2.2 bouyer * Note: Currently begins search from the root. Could be enhanced to use
323 1.3.2.2 bouyer * the current prefix (scope) node as the search beginning point.
324 1.3.2.2 bouyer *
325 1.3.2.2 bouyer ******************************************************************************/
326 1.3.2.2 bouyer
327 1.3.2.2 bouyer ACPI_NAMESPACE_NODE *
328 1.3.2.2 bouyer AcpiDbLocalNsLookup (
329 1.3.2.2 bouyer char *Name)
330 1.3.2.2 bouyer {
331 1.3.2.2 bouyer char *InternalPath;
332 1.3.2.2 bouyer ACPI_STATUS Status;
333 1.3.2.2 bouyer ACPI_NAMESPACE_NODE *Node = NULL;
334 1.3.2.2 bouyer
335 1.3.2.2 bouyer
336 1.3.2.2 bouyer AcpiDbPrepNamestring (Name);
337 1.3.2.2 bouyer
338 1.3.2.2 bouyer /* Build an internal namestring */
339 1.3.2.2 bouyer
340 1.3.2.2 bouyer Status = AcpiNsInternalizeName (Name, &InternalPath);
341 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
342 1.3.2.2 bouyer {
343 1.3.2.2 bouyer AcpiOsPrintf ("Invalid namestring: %s\n", Name);
344 1.3.2.2 bouyer return (NULL);
345 1.3.2.2 bouyer }
346 1.3.2.2 bouyer
347 1.3.2.2 bouyer /*
348 1.3.2.2 bouyer * Lookup the name.
349 1.3.2.2 bouyer * (Uses root node as the search starting point)
350 1.3.2.2 bouyer */
351 1.3.2.2 bouyer Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
352 1.3.2.2 bouyer ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
353 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
354 1.3.2.2 bouyer {
355 1.3.2.2 bouyer AcpiOsPrintf ("Could not locate name: %s, %s\n",
356 1.3.2.2 bouyer Name, AcpiFormatException (Status));
357 1.3.2.2 bouyer }
358 1.3.2.2 bouyer
359 1.3.2.2 bouyer ACPI_FREE (InternalPath);
360 1.3.2.2 bouyer return (Node);
361 1.3.2.2 bouyer }
362 1.3.2.2 bouyer
363 1.3.2.2 bouyer
364 1.3.2.2 bouyer /*******************************************************************************
365 1.3.2.2 bouyer *
366 1.3.2.2 bouyer * FUNCTION: AcpiDbUInt32ToHexString
367 1.3.2.2 bouyer *
368 1.3.2.2 bouyer * PARAMETERS: Value - The value to be converted to string
369 1.3.2.2 bouyer * Buffer - Buffer for result (not less than 11 bytes)
370 1.3.2.2 bouyer *
371 1.3.2.2 bouyer * RETURN: None
372 1.3.2.2 bouyer *
373 1.3.2.2 bouyer * DESCRIPTION: Convert the unsigned 32-bit value to the hexadecimal image
374 1.3.2.2 bouyer *
375 1.3.2.2 bouyer * NOTE: It is the caller's responsibility to ensure that the length of buffer
376 1.3.2.2 bouyer * is sufficient.
377 1.3.2.2 bouyer *
378 1.3.2.2 bouyer ******************************************************************************/
379 1.3.2.2 bouyer
380 1.3.2.2 bouyer void
381 1.3.2.2 bouyer AcpiDbUInt32ToHexString (
382 1.3.2.2 bouyer UINT32 Value,
383 1.3.2.2 bouyer char *Buffer)
384 1.3.2.2 bouyer {
385 1.3.2.2 bouyer UINT8 i;
386 1.3.2.2 bouyer
387 1.3.2.2 bouyer
388 1.3.2.2 bouyer if (Value == 0)
389 1.3.2.2 bouyer {
390 1.3.2.2 bouyer ACPI_STRCPY (Buffer, "0");
391 1.3.2.2 bouyer return;
392 1.3.2.2 bouyer }
393 1.3.2.2 bouyer
394 1.3.2.2 bouyer ACPI_STRCPY (Buffer, "0x");
395 1.3.2.2 bouyer Buffer[10] = '\0';
396 1.3.2.2 bouyer
397 1.3.2.2 bouyer for (i = 9; i > 1; i--)
398 1.3.2.2 bouyer {
399 1.3.2.2 bouyer Buffer[i] = Converter [Value & 0x0F];
400 1.3.2.2 bouyer Value = Value >> 4;
401 1.3.2.2 bouyer }
402 1.3.2.2 bouyer }
403 1.3.2.2 bouyer
404 1.3.2.2 bouyer
405 1.3.2.2 bouyer #ifdef ACPI_OBSOLETE_FUNCTIONS
406 1.3.2.2 bouyer /*******************************************************************************
407 1.3.2.2 bouyer *
408 1.3.2.2 bouyer * FUNCTION: AcpiDbSecondPassParse
409 1.3.2.2 bouyer *
410 1.3.2.2 bouyer * PARAMETERS: Root - Root of the parse tree
411 1.3.2.2 bouyer *
412 1.3.2.2 bouyer * RETURN: Status
413 1.3.2.2 bouyer *
414 1.3.2.2 bouyer * DESCRIPTION: Second pass parse of the ACPI tables. We need to wait until
415 1.3.2.2 bouyer * second pass to parse the control methods
416 1.3.2.2 bouyer *
417 1.3.2.2 bouyer ******************************************************************************/
418 1.3.2.2 bouyer
419 1.3.2.2 bouyer ACPI_STATUS
420 1.3.2.2 bouyer AcpiDbSecondPassParse (
421 1.3.2.2 bouyer ACPI_PARSE_OBJECT *Root)
422 1.3.2.2 bouyer {
423 1.3.2.2 bouyer ACPI_PARSE_OBJECT *Op = Root;
424 1.3.2.2 bouyer ACPI_PARSE_OBJECT *Method;
425 1.3.2.2 bouyer ACPI_PARSE_OBJECT *SearchOp;
426 1.3.2.2 bouyer ACPI_PARSE_OBJECT *StartOp;
427 1.3.2.2 bouyer ACPI_STATUS Status = AE_OK;
428 1.3.2.2 bouyer UINT32 BaseAmlOffset;
429 1.3.2.2 bouyer ACPI_WALK_STATE *WalkState;
430 1.3.2.2 bouyer
431 1.3.2.2 bouyer
432 1.3.2.2 bouyer ACPI_FUNCTION_ENTRY ();
433 1.3.2.2 bouyer
434 1.3.2.2 bouyer
435 1.3.2.2 bouyer AcpiOsPrintf ("Pass two parse ....\n");
436 1.3.2.2 bouyer
437 1.3.2.2 bouyer while (Op)
438 1.3.2.2 bouyer {
439 1.3.2.2 bouyer if (Op->Common.AmlOpcode == AML_METHOD_OP)
440 1.3.2.2 bouyer {
441 1.3.2.2 bouyer Method = Op;
442 1.3.2.2 bouyer
443 1.3.2.2 bouyer /* Create a new walk state for the parse */
444 1.3.2.2 bouyer
445 1.3.2.2 bouyer WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
446 1.3.2.2 bouyer if (!WalkState)
447 1.3.2.2 bouyer {
448 1.3.2.2 bouyer return (AE_NO_MEMORY);
449 1.3.2.2 bouyer }
450 1.3.2.2 bouyer
451 1.3.2.2 bouyer /* Init the Walk State */
452 1.3.2.2 bouyer
453 1.3.2.2 bouyer WalkState->ParserState.Aml =
454 1.3.2.2 bouyer WalkState->ParserState.AmlStart = Method->Named.Data;
455 1.3.2.2 bouyer WalkState->ParserState.AmlEnd =
456 1.3.2.2 bouyer WalkState->ParserState.PkgEnd = Method->Named.Data +
457 1.3.2.2 bouyer Method->Named.Length;
458 1.3.2.2 bouyer WalkState->ParserState.StartScope = Op;
459 1.3.2.2 bouyer
460 1.3.2.2 bouyer WalkState->DescendingCallback = AcpiDsLoad1BeginOp;
461 1.3.2.2 bouyer WalkState->AscendingCallback = AcpiDsLoad1EndOp;
462 1.3.2.2 bouyer
463 1.3.2.2 bouyer /* Perform the AML parse */
464 1.3.2.2 bouyer
465 1.3.2.2 bouyer Status = AcpiPsParseAml (WalkState);
466 1.3.2.2 bouyer
467 1.3.2.2 bouyer BaseAmlOffset = (Method->Common.Value.Arg)->Common.AmlOffset + 1;
468 1.3.2.2 bouyer StartOp = (Method->Common.Value.Arg)->Common.Next;
469 1.3.2.2 bouyer SearchOp = StartOp;
470 1.3.2.2 bouyer
471 1.3.2.2 bouyer while (SearchOp)
472 1.3.2.2 bouyer {
473 1.3.2.2 bouyer SearchOp->Common.AmlOffset += BaseAmlOffset;
474 1.3.2.2 bouyer SearchOp = AcpiPsGetDepthNext (StartOp, SearchOp);
475 1.3.2.2 bouyer }
476 1.3.2.2 bouyer }
477 1.3.2.2 bouyer
478 1.3.2.2 bouyer if (Op->Common.AmlOpcode == AML_REGION_OP)
479 1.3.2.2 bouyer {
480 1.3.2.2 bouyer /* TBD: [Investigate] this isn't quite the right thing to do! */
481 1.3.2.2 bouyer /*
482 1.3.2.2 bouyer *
483 1.3.2.2 bouyer * Method = (ACPI_DEFERRED_OP *) Op;
484 1.3.2.2 bouyer * Status = AcpiPsParseAml (Op, Method->Body, Method->BodyLength);
485 1.3.2.2 bouyer */
486 1.3.2.2 bouyer }
487 1.3.2.2 bouyer
488 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
489 1.3.2.2 bouyer {
490 1.3.2.2 bouyer break;
491 1.3.2.2 bouyer }
492 1.3.2.2 bouyer
493 1.3.2.2 bouyer Op = AcpiPsGetDepthNext (Root, Op);
494 1.3.2.2 bouyer }
495 1.3.2.2 bouyer
496 1.3.2.2 bouyer return (Status);
497 1.3.2.2 bouyer }
498 1.3.2.2 bouyer
499 1.3.2.2 bouyer
500 1.3.2.2 bouyer /*******************************************************************************
501 1.3.2.2 bouyer *
502 1.3.2.2 bouyer * FUNCTION: AcpiDbDumpBuffer
503 1.3.2.2 bouyer *
504 1.3.2.2 bouyer * PARAMETERS: Address - Pointer to the buffer
505 1.3.2.2 bouyer *
506 1.3.2.2 bouyer * RETURN: None
507 1.3.2.2 bouyer *
508 1.3.2.2 bouyer * DESCRIPTION: Print a portion of a buffer
509 1.3.2.2 bouyer *
510 1.3.2.2 bouyer ******************************************************************************/
511 1.3.2.2 bouyer
512 1.3.2.2 bouyer void
513 1.3.2.2 bouyer AcpiDbDumpBuffer (
514 1.3.2.2 bouyer UINT32 Address)
515 1.3.2.2 bouyer {
516 1.3.2.2 bouyer
517 1.3.2.2 bouyer AcpiOsPrintf ("\nLocation %X:\n", Address);
518 1.3.2.2 bouyer
519 1.3.2.2 bouyer AcpiDbgLevel |= ACPI_LV_TABLES;
520 1.3.2.2 bouyer AcpiUtDumpBuffer (ACPI_TO_POINTER (Address), 64, DB_BYTE_DISPLAY,
521 1.3.2.2 bouyer ACPI_UINT32_MAX);
522 1.3.2.2 bouyer }
523 1.3.2.2 bouyer #endif
524 1.3.2.2 bouyer
525 1.3.2.2 bouyer #endif /* ACPI_DEBUGGER */
526 1.3.2.2 bouyer
527 1.3.2.2 bouyer
528