Deleted Added
full compact
dbcmds.c (102550) dbcmds.c (104470)
1/*******************************************************************************
2 *
3 * Module Name: dbcmds - debug commands and output routines
1/*******************************************************************************
2 *
3 * Module Name: dbcmds - debug commands and output routines
4 * $Revision: 87 $
4 * $Revision: 88 $
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117
118#include "acpi.h"
119#include "acdispat.h"
120#include "amlcode.h"
121#include "acnamesp.h"
122#include "acevents.h"
123#include "acdebug.h"
124#include "acresrc.h"
125#include "acdisasm.h"
126
127#ifdef ACPI_DEBUGGER
128
129#define _COMPONENT ACPI_CA_DEBUGGER
130 ACPI_MODULE_NAME ("dbcmds")
131
132
133/*
134 * Arguments for the Objects command
135 * These object types map directly to the ACPI_TYPES
136 */
137
138static ARGUMENT_INFO AcpiDbObjectTypes [] =
139{
140 {"ANY"},
141 {"NUMBERS"},
142 {"STRINGS"},
143 {"BUFFERS"},
144 {"PACKAGES"},
145 {"FIELDS"},
146 {"DEVICES"},
147 {"EVENTS"},
148 {"METHODS"},
149 {"MUTEXES"},
150 {"REGIONS"},
151 {"POWERRESOURCES"},
152 {"PROCESSORS"},
153 {"THERMALZONES"},
154 {"BUFFERFIELDS"},
155 {"DDBHANDLES"},
156 {NULL} /* Must be null terminated */
157};
158
159
160/*******************************************************************************
161 *
162 * FUNCTION: AcpiDbWalkForReferences
163 *
164 * PARAMETERS: Callback from WalkNamespace
165 *
166 * RETURN: Status
167 *
168 * DESCRIPTION: Check if this namespace object refers to the target object
169 * that is passed in as the context value.
170 *
171 * Note: Currently doesn't check subobjects within the Node's object
172 *
173 ******************************************************************************/
174
175ACPI_STATUS
176AcpiDbWalkForReferences (
177 ACPI_HANDLE ObjHandle,
178 UINT32 NestingLevel,
179 void *Context,
180 void **ReturnValue)
181{
182 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context;
183 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
184
185
186 /* Check for match against the namespace node itself */
187
188 if (Node == (void *) ObjDesc)
189 {
190 AcpiOsPrintf ("Object is a Node [%4.4s]\n", Node->Name.Ascii);
191 }
192
193 /* Check for match against the object attached to the node */
194
195 if (AcpiNsGetAttachedObject (Node) == ObjDesc)
196 {
197 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", Node, Node->Name.Ascii);
198 }
199
200 return (AE_OK);
201}
202
203
204/*******************************************************************************
205 *
206 * FUNCTION: AcpiDbFindReferences
207 *
208 * PARAMETERS: ObjectArg - String with hex value of the object
209 *
210 * RETURN: None
211 *
212 * DESCRIPTION: Search namespace for all references to the input object
213 *
214 ******************************************************************************/
215
216void
217AcpiDbFindReferences (
218 NATIVE_CHAR *ObjectArg)
219{
220 ACPI_OPERAND_OBJECT *ObjDesc;
221
222
223 /* Convert string to object pointer */
224
225 ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
226
227 /* Search all nodes in namespace */
228
229 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
230 AcpiDbWalkForReferences, (void *) ObjDesc, NULL);
231}
232
233
234/*******************************************************************************
235 *
236 * FUNCTION: AcpiDbDisplayLocks
237 *
238 * PARAMETERS: None
239 *
240 * RETURN: None
241 *
242 * DESCRIPTION: Display information about internal mutexes.
243 *
244 ******************************************************************************/
245
246void
247AcpiDbDisplayLocks (void)
248{
249 UINT32 i;
250
251
252 for (i = 0; i < MAX_MTX; i++)
253 {
254 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
255 AcpiGbl_AcpiMutexInfo[i].OwnerId == ACPI_MUTEX_NOT_ACQUIRED
256 ? "Locked" : "Unlocked");
257 }
258}
259
260
261/*******************************************************************************
262 *
263 * FUNCTION: AcpiDbDisplayTableInfo
264 *
265 * PARAMETERS: TableArg - String with name of table to be displayed
266 *
267 * RETURN: None
268 *
269 * DESCRIPTION: Display information about loaded tables. Current
270 * implementation displays all loaded tables.
271 *
272 ******************************************************************************/
273
274void
275AcpiDbDisplayTableInfo (
276 NATIVE_CHAR *TableArg)
277{
278 UINT32 i;
279
280
281 for (i = 0; i < NUM_ACPI_TABLES; i++)
282 {
283 if (AcpiGbl_AcpiTables[i].Pointer)
284 {
285 AcpiOsPrintf ("%s at %p length %X\n", AcpiGbl_AcpiTableData[i].Name,
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117
118#include "acpi.h"
119#include "acdispat.h"
120#include "amlcode.h"
121#include "acnamesp.h"
122#include "acevents.h"
123#include "acdebug.h"
124#include "acresrc.h"
125#include "acdisasm.h"
126
127#ifdef ACPI_DEBUGGER
128
129#define _COMPONENT ACPI_CA_DEBUGGER
130 ACPI_MODULE_NAME ("dbcmds")
131
132
133/*
134 * Arguments for the Objects command
135 * These object types map directly to the ACPI_TYPES
136 */
137
138static ARGUMENT_INFO AcpiDbObjectTypes [] =
139{
140 {"ANY"},
141 {"NUMBERS"},
142 {"STRINGS"},
143 {"BUFFERS"},
144 {"PACKAGES"},
145 {"FIELDS"},
146 {"DEVICES"},
147 {"EVENTS"},
148 {"METHODS"},
149 {"MUTEXES"},
150 {"REGIONS"},
151 {"POWERRESOURCES"},
152 {"PROCESSORS"},
153 {"THERMALZONES"},
154 {"BUFFERFIELDS"},
155 {"DDBHANDLES"},
156 {NULL} /* Must be null terminated */
157};
158
159
160/*******************************************************************************
161 *
162 * FUNCTION: AcpiDbWalkForReferences
163 *
164 * PARAMETERS: Callback from WalkNamespace
165 *
166 * RETURN: Status
167 *
168 * DESCRIPTION: Check if this namespace object refers to the target object
169 * that is passed in as the context value.
170 *
171 * Note: Currently doesn't check subobjects within the Node's object
172 *
173 ******************************************************************************/
174
175ACPI_STATUS
176AcpiDbWalkForReferences (
177 ACPI_HANDLE ObjHandle,
178 UINT32 NestingLevel,
179 void *Context,
180 void **ReturnValue)
181{
182 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context;
183 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
184
185
186 /* Check for match against the namespace node itself */
187
188 if (Node == (void *) ObjDesc)
189 {
190 AcpiOsPrintf ("Object is a Node [%4.4s]\n", Node->Name.Ascii);
191 }
192
193 /* Check for match against the object attached to the node */
194
195 if (AcpiNsGetAttachedObject (Node) == ObjDesc)
196 {
197 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", Node, Node->Name.Ascii);
198 }
199
200 return (AE_OK);
201}
202
203
204/*******************************************************************************
205 *
206 * FUNCTION: AcpiDbFindReferences
207 *
208 * PARAMETERS: ObjectArg - String with hex value of the object
209 *
210 * RETURN: None
211 *
212 * DESCRIPTION: Search namespace for all references to the input object
213 *
214 ******************************************************************************/
215
216void
217AcpiDbFindReferences (
218 NATIVE_CHAR *ObjectArg)
219{
220 ACPI_OPERAND_OBJECT *ObjDesc;
221
222
223 /* Convert string to object pointer */
224
225 ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
226
227 /* Search all nodes in namespace */
228
229 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
230 AcpiDbWalkForReferences, (void *) ObjDesc, NULL);
231}
232
233
234/*******************************************************************************
235 *
236 * FUNCTION: AcpiDbDisplayLocks
237 *
238 * PARAMETERS: None
239 *
240 * RETURN: None
241 *
242 * DESCRIPTION: Display information about internal mutexes.
243 *
244 ******************************************************************************/
245
246void
247AcpiDbDisplayLocks (void)
248{
249 UINT32 i;
250
251
252 for (i = 0; i < MAX_MTX; i++)
253 {
254 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
255 AcpiGbl_AcpiMutexInfo[i].OwnerId == ACPI_MUTEX_NOT_ACQUIRED
256 ? "Locked" : "Unlocked");
257 }
258}
259
260
261/*******************************************************************************
262 *
263 * FUNCTION: AcpiDbDisplayTableInfo
264 *
265 * PARAMETERS: TableArg - String with name of table to be displayed
266 *
267 * RETURN: None
268 *
269 * DESCRIPTION: Display information about loaded tables. Current
270 * implementation displays all loaded tables.
271 *
272 ******************************************************************************/
273
274void
275AcpiDbDisplayTableInfo (
276 NATIVE_CHAR *TableArg)
277{
278 UINT32 i;
279
280
281 for (i = 0; i < NUM_ACPI_TABLES; i++)
282 {
283 if (AcpiGbl_AcpiTables[i].Pointer)
284 {
285 AcpiOsPrintf ("%s at %p length %X\n", AcpiGbl_AcpiTableData[i].Name,
286 AcpiGbl_AcpiTables[i].Pointer, AcpiGbl_AcpiTables[i].Length);
286 AcpiGbl_AcpiTables[i].Pointer,
287 (UINT32) AcpiGbl_AcpiTables[i].Length);
287 }
288 }
289}
290
291
292/*******************************************************************************
293 *
294 * FUNCTION: AcpiDbUnloadAcpiTable
295 *
296 * PARAMETERS: TableArg - Name of the table to be unloaded
297 * InstanceArg - Which instance of the table to unload (if
298 * there are multiple tables of the same type)
299 *
300 * RETURN: Nonde
301 *
302 * DESCRIPTION: Unload an ACPI table.
303 * Instance is not implemented
304 *
305 ******************************************************************************/
306
307void
308AcpiDbUnloadAcpiTable (
309 NATIVE_CHAR *TableArg,
310 NATIVE_CHAR *InstanceArg)
311{
312 UINT32 i;
313 ACPI_STATUS Status;
314
315
316 /* Search all tables for the target type */
317
318 for (i = 0; i < NUM_ACPI_TABLES; i++)
319 {
320 if (!ACPI_STRNCMP (TableArg, AcpiGbl_AcpiTableData[i].Signature,
321 AcpiGbl_AcpiTableData[i].SigLength))
322 {
323 /* Found the table, unload it */
324
325 Status = AcpiUnloadTable (i);
326 if (ACPI_SUCCESS (Status))
327 {
328 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
329 }
330 else
331 {
332 AcpiOsPrintf ("%s, while unloading [%s]\n",
333 AcpiFormatException (Status), TableArg);
334 }
335
336 return;
337 }
338 }
339
340 AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
341}
342
343
344/*******************************************************************************
345 *
346 * FUNCTION: AcpiDbSetMethodBreakpoint
347 *
348 * PARAMETERS: Location - AML offset of breakpoint
349 * WalkState - Current walk info
350 * Op - Current Op (from parse walk)
351 *
352 * RETURN: None
353 *
354 * DESCRIPTION: Set a breakpoint in a control method at the specified
355 * AML offset
356 *
357 ******************************************************************************/
358
359void
360AcpiDbSetMethodBreakpoint (
361 NATIVE_CHAR *Location,
362 ACPI_WALK_STATE *WalkState,
363 ACPI_PARSE_OBJECT *Op)
364{
365 UINT32 Address;
366
367
368 if (!Op)
369 {
370 AcpiOsPrintf ("There is no method currently executing\n");
371 return;
372 }
373
374 /* Get and verify the breakpoint address */
375
376 Address = ACPI_STRTOUL (Location, NULL, 16);
377 if (Address <= Op->Common.AmlOffset)
378 {
379 AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", Address, Op->Common.AmlOffset);
380 }
381
382 /* Save breakpoint in current walk */
383
384 WalkState->UserBreakpoint = Address;
385 AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
386}
387
388
389/*******************************************************************************
390 *
391 * FUNCTION: AcpiDbSetMethodCallBreakpoint
392 *
393 * PARAMETERS: Op - Current Op (from parse walk)
394 *
395 * RETURN: None
396 *
397 * DESCRIPTION: Set a breakpoint in a control method at the specified
398 * AML offset
399 *
400 ******************************************************************************/
401
402void
403AcpiDbSetMethodCallBreakpoint (
404 ACPI_PARSE_OBJECT *Op)
405{
406
407
408 if (!Op)
409 {
410 AcpiOsPrintf ("There is no method currently executing\n");
411 return;
412 }
413
414
415 AcpiGbl_StepToNextCall = TRUE;
416}
417
418
419/*******************************************************************************
420 *
421 * FUNCTION: AcpiDbDisassembleAml
422 *
423 * PARAMETERS: Statements - Number of statements to disassemble
424 * Op - Current Op (from parse walk)
425 *
426 * RETURN: None
427 *
428 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
429 * of statements specified.
430 *
431 ******************************************************************************/
432
433void
434AcpiDbDisassembleAml (
435 NATIVE_CHAR *Statements,
436 ACPI_PARSE_OBJECT *Op)
437{
438 UINT32 NumStatements = 8;
439
440
441 if (!Op)
442 {
443 AcpiOsPrintf ("There is no method currently executing\n");
444 return;
445 }
446
447 if (Statements)
448 {
449 NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
450 }
451
452 AcpiDmDisassemble (NULL, Op, NumStatements);
453}
454
455
456/*******************************************************************************
457 *
458 * FUNCTION: AcpiDbDumpNamespace
459 *
460 * PARAMETERS: StartArg - Node to begin namespace dump
461 * DepthArg - Maximum tree depth to be dumped
462 *
463 * RETURN: None
464 *
465 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
466 * with type and other information.
467 *
468 ******************************************************************************/
469
470void
471AcpiDbDumpNamespace (
472 NATIVE_CHAR *StartArg,
473 NATIVE_CHAR *DepthArg)
474{
475 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
476 UINT32 MaxDepth = ACPI_UINT32_MAX;
477
478
479 /* No argument given, just start at the root and dump entire namespace */
480
481 if (StartArg)
482 {
483 /* Check if numeric argument, must be a Node */
484
485 if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39))
486 {
487 SubtreeEntry = ACPI_TO_POINTER (ACPI_STRTOUL (StartArg, NULL, 16));
488 if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE)))
489 {
490 AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry);
491 return;
492 }
493
494 if (ACPI_GET_DESCRIPTOR_TYPE (SubtreeEntry) != ACPI_DESC_TYPE_NAMED)
495 {
496 AcpiOsPrintf ("Address %p is not a valid Named object\n", SubtreeEntry);
497 return;
498 }
499 }
500
501 /* Alpha argument */
502
503 else
504 {
505 /* The parameter is a name string that must be resolved to a Named obj*/
506
507 SubtreeEntry = AcpiDbLocalNsLookup (StartArg);
508 if (!SubtreeEntry)
509 {
510 SubtreeEntry = AcpiGbl_RootNode;
511 }
512 }
513
514 /* Now we can check for the depth argument */
515
516 if (DepthArg)
517 {
518 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
519 }
520 }
521
522 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
523 AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry);
524
525 /* Display the subtree */
526
527 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
528 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry);
529 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
530}
531
532
533/*******************************************************************************
534 *
535 * FUNCTION: AcpiDbDumpNamespaceByOwner
536 *
537 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed
538 * DepthArg - Maximum tree depth to be dumped
539 *
540 * RETURN: None
541 *
542 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
543 *
544 ******************************************************************************/
545
546void
547AcpiDbDumpNamespaceByOwner (
548 NATIVE_CHAR *OwnerArg,
549 NATIVE_CHAR *DepthArg)
550{
551 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
552 UINT32 MaxDepth = ACPI_UINT32_MAX;
553 UINT16 OwnerId;
554
555
556 OwnerId = (UINT16) ACPI_STRTOUL (OwnerArg, NULL, 0);
557
558 /* Now we can check for the depth argument */
559
560 if (DepthArg)
561 {
562 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
563 }
564
565 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
566 AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
567
568 /* Display the subtree */
569
570 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
571 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, SubtreeEntry);
572 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
573}
574
575
576/*******************************************************************************
577 *
578 * FUNCTION: AcpiDbSendNotify
579 *
580 * PARAMETERS: Name - Name of ACPI object to send the notify to
581 * Value - Value of the notify to send.
582 *
583 * RETURN: None
584 *
585 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
586 * named object as an ACPI notify.
587 *
588 ******************************************************************************/
589
590void
591AcpiDbSendNotify (
592 NATIVE_CHAR *Name,
593 UINT32 Value)
594{
595 ACPI_NAMESPACE_NODE *Node;
596 ACPI_STATUS Status;
597
598
599 /* Translate name to an Named object */
600
601 Node = AcpiDbLocalNsLookup (Name);
602 if (!Node)
603 {
604 return;
605 }
606
607 /* Decode Named object type */
608
609 switch (Node->Type)
610 {
611 case ACPI_TYPE_DEVICE:
612 case ACPI_TYPE_THERMAL:
613
614 /* Send the notify */
615
616 Status = AcpiEvQueueNotifyRequest (Node, Value);
617 if (ACPI_FAILURE (Status))
618 {
619 AcpiOsPrintf ("Could not queue notify\n");
620 }
621 break;
622
623 default:
624 AcpiOsPrintf ("Named object is not a device or a thermal object\n");
625 break;
626 }
627
628}
629
630
631/*******************************************************************************
632 *
633 * FUNCTION: AcpiDbSetMethodData
634 *
635 * PARAMETERS: TypeArg - L for local, A for argument
636 * IndexArg - which one
637 * ValueArg - Value to set.
638 *
639 * RETURN: None
640 *
641 * DESCRIPTION: Set a local or argument for the running control method.
642 * NOTE: only object supported is Number.
643 *
644 ******************************************************************************/
645
646void
647AcpiDbSetMethodData (
648 NATIVE_CHAR *TypeArg,
649 NATIVE_CHAR *IndexArg,
650 NATIVE_CHAR *ValueArg)
651{
652 NATIVE_CHAR Type;
653 UINT32 Index;
654 UINT32 Value;
655 ACPI_WALK_STATE *WalkState;
656 ACPI_OPERAND_OBJECT *ObjDesc;
657 ACPI_STATUS Status;
658
659
660 /* Validate TypeArg */
661
662 ACPI_STRUPR (TypeArg);
663 Type = TypeArg[0];
664 if ((Type != 'L') &&
665 (Type != 'A'))
666 {
667 AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
668 return;
669 }
670
671 /* Get the index and value */
672
673 Index = ACPI_STRTOUL (IndexArg, NULL, 16);
674 Value = ACPI_STRTOUL (ValueArg, NULL, 16);
675
676 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
677 if (!WalkState)
678 {
679 AcpiOsPrintf ("There is no method currently executing\n");
680 return;
681 }
682
683
684 /* Create and initialize the new object */
685
686 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
687 if (!ObjDesc)
688 {
689 AcpiOsPrintf ("Could not create an internal object\n");
690 return;
691 }
692
693 ObjDesc->Integer.Value = Value;
694
695
696 /* Store the new object into the target */
697
698 switch (Type)
699 {
700 case 'A':
701
702 /* Set a method argument */
703
704 if (Index > MTH_MAX_ARG)
705 {
706 AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
707 return;
708 }
709
710 Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, WalkState);
711 if (ACPI_FAILURE (Status))
712 {
713 return;
714 }
715
716 ObjDesc = WalkState->Arguments[Index].Object;
717
718 AcpiOsPrintf ("Arg%d: ", Index);
719 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
720 break;
721
722 case 'L':
723
724 /* Set a method local */
725
726 if (Index > MTH_MAX_LOCAL)
727 {
728 AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
729 return;
730 }
731
732 Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, WalkState);
733 if (ACPI_FAILURE (Status))
734 {
735 return;
736 }
737
738 ObjDesc = WalkState->LocalVariables[Index].Object;
739
740 AcpiOsPrintf ("Local%d: ", Index);
741 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
742 break;
743
744 default:
745 break;
746 }
747}
748
749
750/*******************************************************************************
751 *
752 * FUNCTION: AcpiDbWalkForSpecificObjects
753 *
754 * PARAMETERS: Callback from WalkNamespace
755 *
756 * RETURN: Status
757 *
758 * DESCRIPTION: Display short info about objects in the namespace
759 *
760 ******************************************************************************/
761
762ACPI_STATUS
763AcpiDbWalkForSpecificObjects (
764 ACPI_HANDLE ObjHandle,
765 UINT32 NestingLevel,
766 void *Context,
767 void **ReturnValue)
768{
769 ACPI_OPERAND_OBJECT *ObjDesc;
770 ACPI_STATUS Status;
771 ACPI_BUFFER Buffer;
772
773
774 ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjHandle);
775
776 /* Get and display the full pathname to this object */
777
778 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
779 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
780 if (ACPI_FAILURE (Status))
781 {
782 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
783 return (AE_OK);
784 }
785
288 }
289 }
290}
291
292
293/*******************************************************************************
294 *
295 * FUNCTION: AcpiDbUnloadAcpiTable
296 *
297 * PARAMETERS: TableArg - Name of the table to be unloaded
298 * InstanceArg - Which instance of the table to unload (if
299 * there are multiple tables of the same type)
300 *
301 * RETURN: Nonde
302 *
303 * DESCRIPTION: Unload an ACPI table.
304 * Instance is not implemented
305 *
306 ******************************************************************************/
307
308void
309AcpiDbUnloadAcpiTable (
310 NATIVE_CHAR *TableArg,
311 NATIVE_CHAR *InstanceArg)
312{
313 UINT32 i;
314 ACPI_STATUS Status;
315
316
317 /* Search all tables for the target type */
318
319 for (i = 0; i < NUM_ACPI_TABLES; i++)
320 {
321 if (!ACPI_STRNCMP (TableArg, AcpiGbl_AcpiTableData[i].Signature,
322 AcpiGbl_AcpiTableData[i].SigLength))
323 {
324 /* Found the table, unload it */
325
326 Status = AcpiUnloadTable (i);
327 if (ACPI_SUCCESS (Status))
328 {
329 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
330 }
331 else
332 {
333 AcpiOsPrintf ("%s, while unloading [%s]\n",
334 AcpiFormatException (Status), TableArg);
335 }
336
337 return;
338 }
339 }
340
341 AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
342}
343
344
345/*******************************************************************************
346 *
347 * FUNCTION: AcpiDbSetMethodBreakpoint
348 *
349 * PARAMETERS: Location - AML offset of breakpoint
350 * WalkState - Current walk info
351 * Op - Current Op (from parse walk)
352 *
353 * RETURN: None
354 *
355 * DESCRIPTION: Set a breakpoint in a control method at the specified
356 * AML offset
357 *
358 ******************************************************************************/
359
360void
361AcpiDbSetMethodBreakpoint (
362 NATIVE_CHAR *Location,
363 ACPI_WALK_STATE *WalkState,
364 ACPI_PARSE_OBJECT *Op)
365{
366 UINT32 Address;
367
368
369 if (!Op)
370 {
371 AcpiOsPrintf ("There is no method currently executing\n");
372 return;
373 }
374
375 /* Get and verify the breakpoint address */
376
377 Address = ACPI_STRTOUL (Location, NULL, 16);
378 if (Address <= Op->Common.AmlOffset)
379 {
380 AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", Address, Op->Common.AmlOffset);
381 }
382
383 /* Save breakpoint in current walk */
384
385 WalkState->UserBreakpoint = Address;
386 AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
387}
388
389
390/*******************************************************************************
391 *
392 * FUNCTION: AcpiDbSetMethodCallBreakpoint
393 *
394 * PARAMETERS: Op - Current Op (from parse walk)
395 *
396 * RETURN: None
397 *
398 * DESCRIPTION: Set a breakpoint in a control method at the specified
399 * AML offset
400 *
401 ******************************************************************************/
402
403void
404AcpiDbSetMethodCallBreakpoint (
405 ACPI_PARSE_OBJECT *Op)
406{
407
408
409 if (!Op)
410 {
411 AcpiOsPrintf ("There is no method currently executing\n");
412 return;
413 }
414
415
416 AcpiGbl_StepToNextCall = TRUE;
417}
418
419
420/*******************************************************************************
421 *
422 * FUNCTION: AcpiDbDisassembleAml
423 *
424 * PARAMETERS: Statements - Number of statements to disassemble
425 * Op - Current Op (from parse walk)
426 *
427 * RETURN: None
428 *
429 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
430 * of statements specified.
431 *
432 ******************************************************************************/
433
434void
435AcpiDbDisassembleAml (
436 NATIVE_CHAR *Statements,
437 ACPI_PARSE_OBJECT *Op)
438{
439 UINT32 NumStatements = 8;
440
441
442 if (!Op)
443 {
444 AcpiOsPrintf ("There is no method currently executing\n");
445 return;
446 }
447
448 if (Statements)
449 {
450 NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
451 }
452
453 AcpiDmDisassemble (NULL, Op, NumStatements);
454}
455
456
457/*******************************************************************************
458 *
459 * FUNCTION: AcpiDbDumpNamespace
460 *
461 * PARAMETERS: StartArg - Node to begin namespace dump
462 * DepthArg - Maximum tree depth to be dumped
463 *
464 * RETURN: None
465 *
466 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
467 * with type and other information.
468 *
469 ******************************************************************************/
470
471void
472AcpiDbDumpNamespace (
473 NATIVE_CHAR *StartArg,
474 NATIVE_CHAR *DepthArg)
475{
476 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
477 UINT32 MaxDepth = ACPI_UINT32_MAX;
478
479
480 /* No argument given, just start at the root and dump entire namespace */
481
482 if (StartArg)
483 {
484 /* Check if numeric argument, must be a Node */
485
486 if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39))
487 {
488 SubtreeEntry = ACPI_TO_POINTER (ACPI_STRTOUL (StartArg, NULL, 16));
489 if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE)))
490 {
491 AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry);
492 return;
493 }
494
495 if (ACPI_GET_DESCRIPTOR_TYPE (SubtreeEntry) != ACPI_DESC_TYPE_NAMED)
496 {
497 AcpiOsPrintf ("Address %p is not a valid Named object\n", SubtreeEntry);
498 return;
499 }
500 }
501
502 /* Alpha argument */
503
504 else
505 {
506 /* The parameter is a name string that must be resolved to a Named obj*/
507
508 SubtreeEntry = AcpiDbLocalNsLookup (StartArg);
509 if (!SubtreeEntry)
510 {
511 SubtreeEntry = AcpiGbl_RootNode;
512 }
513 }
514
515 /* Now we can check for the depth argument */
516
517 if (DepthArg)
518 {
519 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
520 }
521 }
522
523 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
524 AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry);
525
526 /* Display the subtree */
527
528 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
529 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry);
530 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
531}
532
533
534/*******************************************************************************
535 *
536 * FUNCTION: AcpiDbDumpNamespaceByOwner
537 *
538 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed
539 * DepthArg - Maximum tree depth to be dumped
540 *
541 * RETURN: None
542 *
543 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
544 *
545 ******************************************************************************/
546
547void
548AcpiDbDumpNamespaceByOwner (
549 NATIVE_CHAR *OwnerArg,
550 NATIVE_CHAR *DepthArg)
551{
552 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
553 UINT32 MaxDepth = ACPI_UINT32_MAX;
554 UINT16 OwnerId;
555
556
557 OwnerId = (UINT16) ACPI_STRTOUL (OwnerArg, NULL, 0);
558
559 /* Now we can check for the depth argument */
560
561 if (DepthArg)
562 {
563 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
564 }
565
566 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
567 AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
568
569 /* Display the subtree */
570
571 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
572 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, SubtreeEntry);
573 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
574}
575
576
577/*******************************************************************************
578 *
579 * FUNCTION: AcpiDbSendNotify
580 *
581 * PARAMETERS: Name - Name of ACPI object to send the notify to
582 * Value - Value of the notify to send.
583 *
584 * RETURN: None
585 *
586 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
587 * named object as an ACPI notify.
588 *
589 ******************************************************************************/
590
591void
592AcpiDbSendNotify (
593 NATIVE_CHAR *Name,
594 UINT32 Value)
595{
596 ACPI_NAMESPACE_NODE *Node;
597 ACPI_STATUS Status;
598
599
600 /* Translate name to an Named object */
601
602 Node = AcpiDbLocalNsLookup (Name);
603 if (!Node)
604 {
605 return;
606 }
607
608 /* Decode Named object type */
609
610 switch (Node->Type)
611 {
612 case ACPI_TYPE_DEVICE:
613 case ACPI_TYPE_THERMAL:
614
615 /* Send the notify */
616
617 Status = AcpiEvQueueNotifyRequest (Node, Value);
618 if (ACPI_FAILURE (Status))
619 {
620 AcpiOsPrintf ("Could not queue notify\n");
621 }
622 break;
623
624 default:
625 AcpiOsPrintf ("Named object is not a device or a thermal object\n");
626 break;
627 }
628
629}
630
631
632/*******************************************************************************
633 *
634 * FUNCTION: AcpiDbSetMethodData
635 *
636 * PARAMETERS: TypeArg - L for local, A for argument
637 * IndexArg - which one
638 * ValueArg - Value to set.
639 *
640 * RETURN: None
641 *
642 * DESCRIPTION: Set a local or argument for the running control method.
643 * NOTE: only object supported is Number.
644 *
645 ******************************************************************************/
646
647void
648AcpiDbSetMethodData (
649 NATIVE_CHAR *TypeArg,
650 NATIVE_CHAR *IndexArg,
651 NATIVE_CHAR *ValueArg)
652{
653 NATIVE_CHAR Type;
654 UINT32 Index;
655 UINT32 Value;
656 ACPI_WALK_STATE *WalkState;
657 ACPI_OPERAND_OBJECT *ObjDesc;
658 ACPI_STATUS Status;
659
660
661 /* Validate TypeArg */
662
663 ACPI_STRUPR (TypeArg);
664 Type = TypeArg[0];
665 if ((Type != 'L') &&
666 (Type != 'A'))
667 {
668 AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
669 return;
670 }
671
672 /* Get the index and value */
673
674 Index = ACPI_STRTOUL (IndexArg, NULL, 16);
675 Value = ACPI_STRTOUL (ValueArg, NULL, 16);
676
677 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
678 if (!WalkState)
679 {
680 AcpiOsPrintf ("There is no method currently executing\n");
681 return;
682 }
683
684
685 /* Create and initialize the new object */
686
687 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
688 if (!ObjDesc)
689 {
690 AcpiOsPrintf ("Could not create an internal object\n");
691 return;
692 }
693
694 ObjDesc->Integer.Value = Value;
695
696
697 /* Store the new object into the target */
698
699 switch (Type)
700 {
701 case 'A':
702
703 /* Set a method argument */
704
705 if (Index > MTH_MAX_ARG)
706 {
707 AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
708 return;
709 }
710
711 Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, WalkState);
712 if (ACPI_FAILURE (Status))
713 {
714 return;
715 }
716
717 ObjDesc = WalkState->Arguments[Index].Object;
718
719 AcpiOsPrintf ("Arg%d: ", Index);
720 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
721 break;
722
723 case 'L':
724
725 /* Set a method local */
726
727 if (Index > MTH_MAX_LOCAL)
728 {
729 AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
730 return;
731 }
732
733 Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, WalkState);
734 if (ACPI_FAILURE (Status))
735 {
736 return;
737 }
738
739 ObjDesc = WalkState->LocalVariables[Index].Object;
740
741 AcpiOsPrintf ("Local%d: ", Index);
742 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
743 break;
744
745 default:
746 break;
747 }
748}
749
750
751/*******************************************************************************
752 *
753 * FUNCTION: AcpiDbWalkForSpecificObjects
754 *
755 * PARAMETERS: Callback from WalkNamespace
756 *
757 * RETURN: Status
758 *
759 * DESCRIPTION: Display short info about objects in the namespace
760 *
761 ******************************************************************************/
762
763ACPI_STATUS
764AcpiDbWalkForSpecificObjects (
765 ACPI_HANDLE ObjHandle,
766 UINT32 NestingLevel,
767 void *Context,
768 void **ReturnValue)
769{
770 ACPI_OPERAND_OBJECT *ObjDesc;
771 ACPI_STATUS Status;
772 ACPI_BUFFER Buffer;
773
774
775 ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjHandle);
776
777 /* Get and display the full pathname to this object */
778
779 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
780 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
781 if (ACPI_FAILURE (Status))
782 {
783 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
784 return (AE_OK);
785 }
786
786 AcpiOsPrintf ("%32s", Buffer.Pointer);
787 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
787 ACPI_MEM_FREE (Buffer.Pointer);
788
789
790 /* Display short information about the object */
791
792 if (ObjDesc)
793 {
794 switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
795 {
796 case ACPI_TYPE_METHOD:
788 ACPI_MEM_FREE (Buffer.Pointer);
789
790
791 /* Display short information about the object */
792
793 if (ObjDesc)
794 {
795 switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
796 {
797 case ACPI_TYPE_METHOD:
797 AcpiOsPrintf (" #Args %d Concurrency %X", ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency);
798 AcpiOsPrintf (" #Args %d Concurrency %X",
799 ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency);
798 break;
799
800 case ACPI_TYPE_INTEGER:
800 break;
801
802 case ACPI_TYPE_INTEGER:
801 AcpiOsPrintf (" Value %X", ObjDesc->Integer.Value);
803 AcpiOsPrintf (" Value %8.8X%8.8X",
804 ACPI_HIDWORD (ObjDesc->Integer.Value),
805 ACPI_LODWORD (ObjDesc->Integer.Value));
802 break;
803
804 case ACPI_TYPE_STRING:
805 AcpiOsPrintf (" \"%s\"", ObjDesc->String.Pointer);
806 break;
807
808 case ACPI_TYPE_REGION:
806 break;
807
808 case ACPI_TYPE_STRING:
809 AcpiOsPrintf (" \"%s\"", ObjDesc->String.Pointer);
810 break;
811
812 case ACPI_TYPE_REGION:
809 AcpiOsPrintf (" SpaceId %X Address %X Length %X", ObjDesc->Region.SpaceId, ObjDesc->Region.Address, ObjDesc->Region.Length);
813 AcpiOsPrintf (" SpaceId %X Length %X Address %8.8X%8.8X",
814 ObjDesc->Region.SpaceId,
815 ObjDesc->Region.Length,
816 ACPI_HIDWORD (ObjDesc->Region.Address),
817 ACPI_LODWORD (ObjDesc->Region.Address));
810 break;
811
812 case ACPI_TYPE_PACKAGE:
813 AcpiOsPrintf (" #Elements %X", ObjDesc->Package.Count);
814 break;
815
816 case ACPI_TYPE_BUFFER:
817 AcpiOsPrintf (" Length %X", ObjDesc->Buffer.Length);
818 break;
819
820 default:
821 /* Ignore other object types */
822 break;
823 }
824 }
825
826 AcpiOsPrintf ("\n");
827 return (AE_OK);
828}
829
830
831/*******************************************************************************
832 *
833 * FUNCTION: AcpiDbDisplayObjects
834 *
835 * PARAMETERS: ObjTypeArg - Type of object to display
836 * DisplayCountArg - Max depth to display
837 *
838 * RETURN: None
839 *
840 * DESCRIPTION: Display objects in the namespace of the requested type
841 *
842 ******************************************************************************/
843
844ACPI_STATUS
845AcpiDbDisplayObjects (
846 NATIVE_CHAR *ObjTypeArg,
847 NATIVE_CHAR *DisplayCountArg)
848{
849 ACPI_OBJECT_TYPE Type;
850
851
852 /* Get the object type */
853
854 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
855 if (Type == ACPI_TYPE_NOT_FOUND)
856 {
857 AcpiOsPrintf ("Invalid or unsupported argument\n");
858 return (AE_OK);
859 }
860
861 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
862 AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n",
863 AcpiUtGetTypeName (Type));
864
865 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
866
867 /* Walk the namespace from the root */
868
869 (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
870 AcpiDbWalkForSpecificObjects, (void *) &Type, NULL);
871
872 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
873 return (AE_OK);
874}
875
876
877/*******************************************************************************
878 *
879 * FUNCTION: AcpiDbWalkAndMatchName
880 *
881 * PARAMETERS: Callback from WalkNamespace
882 *
883 * RETURN: Status
884 *
885 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
886 * are supported -- '?' matches any character.
887 *
888 ******************************************************************************/
889
890ACPI_STATUS
891AcpiDbWalkAndMatchName (
892 ACPI_HANDLE ObjHandle,
893 UINT32 NestingLevel,
894 void *Context,
895 void **ReturnValue)
896{
897 ACPI_STATUS Status;
898 NATIVE_CHAR *RequestedName = (NATIVE_CHAR *) Context;
899 UINT32 i;
900 ACPI_BUFFER Buffer;
901
902
903 /* Check for a name match */
904
905 for (i = 0; i < 4; i++)
906 {
907 /* Wildcard support */
908
909 if ((RequestedName[i] != '?') &&
910 (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
911 {
912 /* No match, just exit */
913
914 return (AE_OK);
915 }
916 }
917
918
919 /* Get the full pathname to this object */
920
921 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
922 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
923 if (ACPI_FAILURE (Status))
924 {
925 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
926 }
927 else
928 {
818 break;
819
820 case ACPI_TYPE_PACKAGE:
821 AcpiOsPrintf (" #Elements %X", ObjDesc->Package.Count);
822 break;
823
824 case ACPI_TYPE_BUFFER:
825 AcpiOsPrintf (" Length %X", ObjDesc->Buffer.Length);
826 break;
827
828 default:
829 /* Ignore other object types */
830 break;
831 }
832 }
833
834 AcpiOsPrintf ("\n");
835 return (AE_OK);
836}
837
838
839/*******************************************************************************
840 *
841 * FUNCTION: AcpiDbDisplayObjects
842 *
843 * PARAMETERS: ObjTypeArg - Type of object to display
844 * DisplayCountArg - Max depth to display
845 *
846 * RETURN: None
847 *
848 * DESCRIPTION: Display objects in the namespace of the requested type
849 *
850 ******************************************************************************/
851
852ACPI_STATUS
853AcpiDbDisplayObjects (
854 NATIVE_CHAR *ObjTypeArg,
855 NATIVE_CHAR *DisplayCountArg)
856{
857 ACPI_OBJECT_TYPE Type;
858
859
860 /* Get the object type */
861
862 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
863 if (Type == ACPI_TYPE_NOT_FOUND)
864 {
865 AcpiOsPrintf ("Invalid or unsupported argument\n");
866 return (AE_OK);
867 }
868
869 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
870 AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n",
871 AcpiUtGetTypeName (Type));
872
873 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
874
875 /* Walk the namespace from the root */
876
877 (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
878 AcpiDbWalkForSpecificObjects, (void *) &Type, NULL);
879
880 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
881 return (AE_OK);
882}
883
884
885/*******************************************************************************
886 *
887 * FUNCTION: AcpiDbWalkAndMatchName
888 *
889 * PARAMETERS: Callback from WalkNamespace
890 *
891 * RETURN: Status
892 *
893 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
894 * are supported -- '?' matches any character.
895 *
896 ******************************************************************************/
897
898ACPI_STATUS
899AcpiDbWalkAndMatchName (
900 ACPI_HANDLE ObjHandle,
901 UINT32 NestingLevel,
902 void *Context,
903 void **ReturnValue)
904{
905 ACPI_STATUS Status;
906 NATIVE_CHAR *RequestedName = (NATIVE_CHAR *) Context;
907 UINT32 i;
908 ACPI_BUFFER Buffer;
909
910
911 /* Check for a name match */
912
913 for (i = 0; i < 4; i++)
914 {
915 /* Wildcard support */
916
917 if ((RequestedName[i] != '?') &&
918 (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
919 {
920 /* No match, just exit */
921
922 return (AE_OK);
923 }
924 }
925
926
927 /* Get the full pathname to this object */
928
929 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
930 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
931 if (ACPI_FAILURE (Status))
932 {
933 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
934 }
935 else
936 {
929 AcpiOsPrintf ("%32s (%p) - %s\n", Buffer.Pointer, ObjHandle,
937 AcpiOsPrintf ("%32s (%p) - %s\n", (char *) Buffer.Pointer, ObjHandle,
930 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type));
931 ACPI_MEM_FREE (Buffer.Pointer);
932 }
933
934 return (AE_OK);
935}
936
937
938/*******************************************************************************
939 *
940 * FUNCTION: AcpiDbFindNameInNamespace
941 *
942 * PARAMETERS: NameArg - The 4-character ACPI name to find.
943 * wildcards are supported.
944 *
945 * RETURN: None
946 *
947 * DESCRIPTION: Search the namespace for a given name (with wildcards)
948 *
949 ******************************************************************************/
950
951ACPI_STATUS
952AcpiDbFindNameInNamespace (
953 NATIVE_CHAR *NameArg)
954{
955
956 if (ACPI_STRLEN (NameArg) > 4)
957 {
958 AcpiOsPrintf ("Name must be no longer than 4 characters\n");
959 return (AE_OK);
960 }
961
962 /* Walk the namespace from the root */
963
964 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
965 AcpiDbWalkAndMatchName, NameArg, NULL);
966
967 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
968 return (AE_OK);
969}
970
971
972/*******************************************************************************
973 *
974 * FUNCTION: AcpiDbSetScope
975 *
976 * PARAMETERS: Name - New scope path
977 *
978 * RETURN: Status
979 *
980 * DESCRIPTION: Set the "current scope" as maintained by this utility.
981 * The scope is used as a prefix to ACPI paths.
982 *
983 ******************************************************************************/
984
985void
986AcpiDbSetScope (
987 NATIVE_CHAR *Name)
988{
989 ACPI_STATUS Status;
990 ACPI_NAMESPACE_NODE *Node;
991
992
993 if (!Name || Name[0] == 0)
994 {
995 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
996 return;
997 }
998
999 AcpiDbPrepNamestring (Name);
1000
1001
1002 if (Name[0] == '\\')
1003 {
1004 /* Validate new scope from the root */
1005
1006 Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode, ACPI_NS_NO_UPSEARCH, &Node);
1007 if (ACPI_FAILURE (Status))
1008 {
1009 goto ErrorExit;
1010 }
1011
1012 ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
1013 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1014 }
1015 else
1016 {
1017 /* Validate new scope relative to old scope */
1018
1019 Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode, ACPI_NS_NO_UPSEARCH, &Node);
1020 if (ACPI_FAILURE (Status))
1021 {
1022 goto ErrorExit;
1023 }
1024
1025 ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
1026 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1027 }
1028
1029 AcpiGbl_DbScopeNode = Node;
1030 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
1031 return;
1032
1033
1034ErrorExit:
1035
1036 AcpiOsPrintf ("Could not attach scope: %s, %s\n", Name, AcpiFormatException (Status));
1037}
1038
1039
1040/*******************************************************************************
1041 *
1042 * FUNCTION: AcpiDbDisplayResources
1043 *
1044 * PARAMETERS: ObjectArg - String with hex value of the object
1045 *
1046 * RETURN: None
1047 *
1048 * DESCRIPTION:
1049 *
1050 ******************************************************************************/
1051
1052void
1053AcpiDbDisplayResources (
1054 NATIVE_CHAR *ObjectArg)
1055{
1056#if ACPI_MACHINE_WIDTH != 16
1057
1058 ACPI_OPERAND_OBJECT *ObjDesc;
1059 ACPI_STATUS Status;
1060 ACPI_BUFFER ReturnObj;
1061
1062
1063 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1064 AcpiDbgLevel |= ACPI_LV_RESOURCES;
1065
1066 /* Convert string to object pointer */
1067
1068 ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
1069
1070 /* Prepare for a return object of arbitrary size */
1071
1072 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1073 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1074
1075 /* _PRT */
1076
1077 AcpiOsPrintf ("Evaluating _PRT\n");
1078
1079 Status = AcpiEvaluateObject (ObjDesc, "_PRT", NULL, &ReturnObj);
1080 if (ACPI_FAILURE (Status))
1081 {
1082 AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiFormatException (Status));
1083 goto GetCrs;
1084 }
1085
1086 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1087 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1088
1089 Status = AcpiGetIrqRoutingTable (ObjDesc, &ReturnObj);
1090 if (ACPI_FAILURE (Status))
1091 {
1092 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiFormatException (Status));
1093 }
1094
1095 else
1096 {
1097 AcpiRsDumpIrqList ((UINT8 *) AcpiGbl_DbBuffer);
1098 }
1099
1100
1101 /* _CRS */
1102
1103GetCrs:
1104 AcpiOsPrintf ("Evaluating _CRS\n");
1105
1106 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1107 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1108
1109 Status = AcpiEvaluateObject (ObjDesc, "_CRS", NULL, &ReturnObj);
1110 if (ACPI_FAILURE (Status))
1111 {
1112 AcpiOsPrintf ("Could not obtain _CRS: %s\n", AcpiFormatException (Status));
1113 goto GetPrs;
1114 }
1115
1116 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1117 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1118
1119 Status = AcpiGetCurrentResources (ObjDesc, &ReturnObj);
1120 if (ACPI_FAILURE (Status))
1121 {
1122 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", AcpiFormatException (Status));
1123 goto GetPrs;
1124 }
1125
1126 else
1127 {
1128 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1129 }
1130
1131 Status = AcpiSetCurrentResources (ObjDesc, &ReturnObj);
1132 if (ACPI_FAILURE (Status))
1133 {
1134 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", AcpiFormatException (Status));
1135 goto GetPrs;
1136 }
1137
1138
1139 /* _PRS */
1140
1141GetPrs:
1142 AcpiOsPrintf ("Evaluating _PRS\n");
1143
1144 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1145 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1146
1147 Status = AcpiEvaluateObject (ObjDesc, "_PRS", NULL, &ReturnObj);
1148 if (ACPI_FAILURE (Status))
1149 {
1150 AcpiOsPrintf ("Could not obtain _PRS: %s\n", AcpiFormatException (Status));
1151 goto Cleanup;
1152 }
1153
1154 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1155 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1156
1157 Status = AcpiGetPossibleResources (ObjDesc, &ReturnObj);
1158 if (ACPI_FAILURE (Status))
1159 {
1160 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", AcpiFormatException (Status));
1161 }
1162
1163 else
1164 {
1165 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1166 }
1167
1168
1169Cleanup:
1170
1171 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1172 return;
1173#endif
1174
1175}
1176
1177
1178typedef struct
1179{
1180 UINT32 Nodes;
1181 UINT32 Objects;
1182} ACPI_INTEGRITY_INFO;
1183
1184/*******************************************************************************
1185 *
1186 * FUNCTION: AcpiDbIntegrityWalk
1187 *
1188 * PARAMETERS: Callback from WalkNamespace
1189 *
1190 * RETURN: Status
1191 *
1192 * DESCRIPTION: Examine one NS node for valid values.
1193 *
1194 ******************************************************************************/
1195
1196ACPI_STATUS
1197AcpiDbIntegrityWalk (
1198 ACPI_HANDLE ObjHandle,
1199 UINT32 NestingLevel,
1200 void *Context,
1201 void **ReturnValue)
1202{
1203 ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context;
1204 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1205 ACPI_OPERAND_OBJECT *Object;
1206
1207
1208 Info->Nodes++;
1209 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
1210 {
1211 AcpiOsPrintf ("Invalid Descriptor Type for Node %p, Type = %X\n",
1212 Node, ACPI_GET_DESCRIPTOR_TYPE (Node));
1213 }
1214
1215 if (Node->Type > INTERNAL_TYPE_MAX)
1216 {
1217 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
1218 Node, Node->Type);
1219 }
1220
1221 if (!AcpiUtValidAcpiName (Node->Name.Integer))
1222 {
1223 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
1224 }
1225
1226 Object = AcpiNsGetAttachedObject (Node);
1227 if (Object)
1228 {
1229 Info->Objects++;
1230 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
1231 {
1232 AcpiOsPrintf ("Invalid Descriptor Type for Object %p, Type = %X\n",
1233 Object, ACPI_GET_DESCRIPTOR_TYPE (Object));
1234 }
1235 }
1236
1237
1238 return (AE_OK);
1239}
1240
1241
1242/*******************************************************************************
1243 *
1244 * FUNCTION: AcpiDbCheckIntegrity
1245 *
1246 * PARAMETERS: None
1247 *
1248 * RETURN: None
1249 *
1250 * DESCRIPTION: Check entire namespace for data structure integrity
1251 *
1252 ******************************************************************************/
1253
1254void
1255AcpiDbCheckIntegrity (void)
1256{
1257 ACPI_INTEGRITY_INFO Info = {0,0};
1258
1259 /* Search all nodes in namespace */
1260
1261 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1262 AcpiDbIntegrityWalk, (void *) &Info, NULL);
1263
1264 AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", Info.Nodes, Info.Objects);
1265
1266}
1267
1268#endif /* ACPI_DEBUGGER */
938 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type));
939 ACPI_MEM_FREE (Buffer.Pointer);
940 }
941
942 return (AE_OK);
943}
944
945
946/*******************************************************************************
947 *
948 * FUNCTION: AcpiDbFindNameInNamespace
949 *
950 * PARAMETERS: NameArg - The 4-character ACPI name to find.
951 * wildcards are supported.
952 *
953 * RETURN: None
954 *
955 * DESCRIPTION: Search the namespace for a given name (with wildcards)
956 *
957 ******************************************************************************/
958
959ACPI_STATUS
960AcpiDbFindNameInNamespace (
961 NATIVE_CHAR *NameArg)
962{
963
964 if (ACPI_STRLEN (NameArg) > 4)
965 {
966 AcpiOsPrintf ("Name must be no longer than 4 characters\n");
967 return (AE_OK);
968 }
969
970 /* Walk the namespace from the root */
971
972 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
973 AcpiDbWalkAndMatchName, NameArg, NULL);
974
975 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
976 return (AE_OK);
977}
978
979
980/*******************************************************************************
981 *
982 * FUNCTION: AcpiDbSetScope
983 *
984 * PARAMETERS: Name - New scope path
985 *
986 * RETURN: Status
987 *
988 * DESCRIPTION: Set the "current scope" as maintained by this utility.
989 * The scope is used as a prefix to ACPI paths.
990 *
991 ******************************************************************************/
992
993void
994AcpiDbSetScope (
995 NATIVE_CHAR *Name)
996{
997 ACPI_STATUS Status;
998 ACPI_NAMESPACE_NODE *Node;
999
1000
1001 if (!Name || Name[0] == 0)
1002 {
1003 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
1004 return;
1005 }
1006
1007 AcpiDbPrepNamestring (Name);
1008
1009
1010 if (Name[0] == '\\')
1011 {
1012 /* Validate new scope from the root */
1013
1014 Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode, ACPI_NS_NO_UPSEARCH, &Node);
1015 if (ACPI_FAILURE (Status))
1016 {
1017 goto ErrorExit;
1018 }
1019
1020 ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
1021 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1022 }
1023 else
1024 {
1025 /* Validate new scope relative to old scope */
1026
1027 Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode, ACPI_NS_NO_UPSEARCH, &Node);
1028 if (ACPI_FAILURE (Status))
1029 {
1030 goto ErrorExit;
1031 }
1032
1033 ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
1034 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1035 }
1036
1037 AcpiGbl_DbScopeNode = Node;
1038 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
1039 return;
1040
1041
1042ErrorExit:
1043
1044 AcpiOsPrintf ("Could not attach scope: %s, %s\n", Name, AcpiFormatException (Status));
1045}
1046
1047
1048/*******************************************************************************
1049 *
1050 * FUNCTION: AcpiDbDisplayResources
1051 *
1052 * PARAMETERS: ObjectArg - String with hex value of the object
1053 *
1054 * RETURN: None
1055 *
1056 * DESCRIPTION:
1057 *
1058 ******************************************************************************/
1059
1060void
1061AcpiDbDisplayResources (
1062 NATIVE_CHAR *ObjectArg)
1063{
1064#if ACPI_MACHINE_WIDTH != 16
1065
1066 ACPI_OPERAND_OBJECT *ObjDesc;
1067 ACPI_STATUS Status;
1068 ACPI_BUFFER ReturnObj;
1069
1070
1071 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1072 AcpiDbgLevel |= ACPI_LV_RESOURCES;
1073
1074 /* Convert string to object pointer */
1075
1076 ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
1077
1078 /* Prepare for a return object of arbitrary size */
1079
1080 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1081 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1082
1083 /* _PRT */
1084
1085 AcpiOsPrintf ("Evaluating _PRT\n");
1086
1087 Status = AcpiEvaluateObject (ObjDesc, "_PRT", NULL, &ReturnObj);
1088 if (ACPI_FAILURE (Status))
1089 {
1090 AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiFormatException (Status));
1091 goto GetCrs;
1092 }
1093
1094 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1095 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1096
1097 Status = AcpiGetIrqRoutingTable (ObjDesc, &ReturnObj);
1098 if (ACPI_FAILURE (Status))
1099 {
1100 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiFormatException (Status));
1101 }
1102
1103 else
1104 {
1105 AcpiRsDumpIrqList ((UINT8 *) AcpiGbl_DbBuffer);
1106 }
1107
1108
1109 /* _CRS */
1110
1111GetCrs:
1112 AcpiOsPrintf ("Evaluating _CRS\n");
1113
1114 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1115 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1116
1117 Status = AcpiEvaluateObject (ObjDesc, "_CRS", NULL, &ReturnObj);
1118 if (ACPI_FAILURE (Status))
1119 {
1120 AcpiOsPrintf ("Could not obtain _CRS: %s\n", AcpiFormatException (Status));
1121 goto GetPrs;
1122 }
1123
1124 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1125 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1126
1127 Status = AcpiGetCurrentResources (ObjDesc, &ReturnObj);
1128 if (ACPI_FAILURE (Status))
1129 {
1130 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", AcpiFormatException (Status));
1131 goto GetPrs;
1132 }
1133
1134 else
1135 {
1136 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1137 }
1138
1139 Status = AcpiSetCurrentResources (ObjDesc, &ReturnObj);
1140 if (ACPI_FAILURE (Status))
1141 {
1142 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", AcpiFormatException (Status));
1143 goto GetPrs;
1144 }
1145
1146
1147 /* _PRS */
1148
1149GetPrs:
1150 AcpiOsPrintf ("Evaluating _PRS\n");
1151
1152 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1153 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1154
1155 Status = AcpiEvaluateObject (ObjDesc, "_PRS", NULL, &ReturnObj);
1156 if (ACPI_FAILURE (Status))
1157 {
1158 AcpiOsPrintf ("Could not obtain _PRS: %s\n", AcpiFormatException (Status));
1159 goto Cleanup;
1160 }
1161
1162 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1163 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1164
1165 Status = AcpiGetPossibleResources (ObjDesc, &ReturnObj);
1166 if (ACPI_FAILURE (Status))
1167 {
1168 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", AcpiFormatException (Status));
1169 }
1170
1171 else
1172 {
1173 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1174 }
1175
1176
1177Cleanup:
1178
1179 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1180 return;
1181#endif
1182
1183}
1184
1185
1186typedef struct
1187{
1188 UINT32 Nodes;
1189 UINT32 Objects;
1190} ACPI_INTEGRITY_INFO;
1191
1192/*******************************************************************************
1193 *
1194 * FUNCTION: AcpiDbIntegrityWalk
1195 *
1196 * PARAMETERS: Callback from WalkNamespace
1197 *
1198 * RETURN: Status
1199 *
1200 * DESCRIPTION: Examine one NS node for valid values.
1201 *
1202 ******************************************************************************/
1203
1204ACPI_STATUS
1205AcpiDbIntegrityWalk (
1206 ACPI_HANDLE ObjHandle,
1207 UINT32 NestingLevel,
1208 void *Context,
1209 void **ReturnValue)
1210{
1211 ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context;
1212 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1213 ACPI_OPERAND_OBJECT *Object;
1214
1215
1216 Info->Nodes++;
1217 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
1218 {
1219 AcpiOsPrintf ("Invalid Descriptor Type for Node %p, Type = %X\n",
1220 Node, ACPI_GET_DESCRIPTOR_TYPE (Node));
1221 }
1222
1223 if (Node->Type > INTERNAL_TYPE_MAX)
1224 {
1225 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
1226 Node, Node->Type);
1227 }
1228
1229 if (!AcpiUtValidAcpiName (Node->Name.Integer))
1230 {
1231 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
1232 }
1233
1234 Object = AcpiNsGetAttachedObject (Node);
1235 if (Object)
1236 {
1237 Info->Objects++;
1238 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
1239 {
1240 AcpiOsPrintf ("Invalid Descriptor Type for Object %p, Type = %X\n",
1241 Object, ACPI_GET_DESCRIPTOR_TYPE (Object));
1242 }
1243 }
1244
1245
1246 return (AE_OK);
1247}
1248
1249
1250/*******************************************************************************
1251 *
1252 * FUNCTION: AcpiDbCheckIntegrity
1253 *
1254 * PARAMETERS: None
1255 *
1256 * RETURN: None
1257 *
1258 * DESCRIPTION: Check entire namespace for data structure integrity
1259 *
1260 ******************************************************************************/
1261
1262void
1263AcpiDbCheckIntegrity (void)
1264{
1265 ACPI_INTEGRITY_INFO Info = {0,0};
1266
1267 /* Search all nodes in namespace */
1268
1269 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1270 AcpiDbIntegrityWalk, (void *) &Info, NULL);
1271
1272 AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", Info.Nodes, Info.Objects);
1273
1274}
1275
1276#endif /* ACPI_DEBUGGER */