1 /*******************************************************************************
3 * Module Name: dbstats - Generation and display of ACPI table statistics
6 ******************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13 * All rights reserved.
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
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
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;
38 * The above copyright and patent license is granted only if the following
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.
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
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
73 * 3.4. Intel retains all right, title, and interest in and to the Original
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.
81 * 4. Disclaimer and Export Compliance
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
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
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.
115 *****************************************************************************/
120 #include "acnamesp.h"
124 #define _COMPONENT ACPI_CA_DEBUGGER
125 ACPI_MODULE_NAME ("dbstats")
127 /* Local prototypes */
130 AcpiDbCountNamespaceObjects (
134 AcpiDbEnumerateObject (
135 ACPI_OPERAND_OBJECT
*ObjDesc
);
138 AcpiDbClassifyOneObject (
139 ACPI_HANDLE ObjHandle
,
146 ACPI_MEMORY_LIST
*List
);
150 * Statistics subcommands
152 static ARGUMENT_INFO AcpiDbStatTypes
[] =
161 {NULL
} /* Must be null terminated */
164 #define CMD_STAT_ALLOCATIONS 0
165 #define CMD_STAT_OBJECTS 1
166 #define CMD_STAT_MEMORY 2
167 #define CMD_STAT_MISC 3
168 #define CMD_STAT_TABLES 4
169 #define CMD_STAT_SIZES 5
170 #define CMD_STAT_STACK 6
173 #if defined ACPI_DBG_TRACK_ALLOCATIONS || defined ACPI_USE_LOCAL_CACHE
175 /*******************************************************************************
177 * FUNCTION: AcpiDbListInfo
179 * PARAMETERS: List - Memory list/cache to be displayed
183 * DESCRIPTION: Display information about the input memory list or cache.
185 ******************************************************************************/
189 ACPI_MEMORY_LIST
*List
)
191 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
196 AcpiOsPrintf ("\n%s\n", List
->ListName
);
198 /* MaxDepth > 0 indicates a cache object */
200 if (List
->MaxDepth
> 0)
203 " Cache: [Depth Max Avail Size] % 7d % 7d % 7d % 7d B\n",
206 List
->MaxDepth
- List
->CurrentDepth
,
207 (List
->CurrentDepth
* List
->ObjectSize
));
210 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
211 if (List
->MaxDepth
> 0)
214 " Cache: [Requests Hits Misses ObjSize] % 7d % 7d % 7d % 7d B\n",
217 List
->Requests
- List
->Hits
,
221 Outstanding
= List
->TotalAllocated
-
225 if (List
->ObjectSize
)
227 Temp
= ACPI_ROUND_UP_TO_1K (Outstanding
* List
->ObjectSize
);
231 Temp
= ACPI_ROUND_UP_TO_1K (List
->CurrentTotalSize
);
235 " Mem: [Alloc Free Outstanding Size] % 7d % 7d % 7d % 7d Kb\n",
236 List
->TotalAllocated
,
244 /*******************************************************************************
246 * FUNCTION: AcpiDbEnumerateObject
248 * PARAMETERS: ObjDesc - Object to be counted
252 * DESCRIPTION: Add this object to the global counts, by object type.
253 * Limited recursion handles subobjects and packages, and this
254 * is probably acceptable within the AML debugger only.
256 ******************************************************************************/
259 AcpiDbEnumerateObject (
260 ACPI_OPERAND_OBJECT
*ObjDesc
)
270 /* Enumerate this object first */
272 AcpiGbl_NumObjects
++;
274 if (ACPI_GET_OBJECT_TYPE (ObjDesc
) > ACPI_TYPE_NS_NODE_MAX
)
276 AcpiGbl_ObjTypeCountMisc
++;
280 AcpiGbl_ObjTypeCount
[ACPI_GET_OBJECT_TYPE (ObjDesc
)]++;
283 /* Count the sub-objects */
285 switch (ACPI_GET_OBJECT_TYPE (ObjDesc
))
287 case ACPI_TYPE_PACKAGE
:
289 for (i
= 0; i
< ObjDesc
->Package
.Count
; i
++)
291 AcpiDbEnumerateObject (ObjDesc
->Package
.Elements
[i
]);
295 case ACPI_TYPE_DEVICE
:
297 AcpiDbEnumerateObject (ObjDesc
->Device
.SystemNotify
);
298 AcpiDbEnumerateObject (ObjDesc
->Device
.DeviceNotify
);
299 AcpiDbEnumerateObject (ObjDesc
->Device
.Handler
);
302 case ACPI_TYPE_BUFFER_FIELD
:
304 if (AcpiNsGetSecondaryObject (ObjDesc
))
306 AcpiGbl_ObjTypeCount
[ACPI_TYPE_BUFFER_FIELD
]++;
310 case ACPI_TYPE_REGION
:
312 AcpiGbl_ObjTypeCount
[ACPI_TYPE_LOCAL_REGION_FIELD
]++;
313 AcpiDbEnumerateObject (ObjDesc
->Region
.Handler
);
316 case ACPI_TYPE_POWER
:
318 AcpiDbEnumerateObject (ObjDesc
->PowerResource
.SystemNotify
);
319 AcpiDbEnumerateObject (ObjDesc
->PowerResource
.DeviceNotify
);
322 case ACPI_TYPE_PROCESSOR
:
324 AcpiDbEnumerateObject (ObjDesc
->Processor
.SystemNotify
);
325 AcpiDbEnumerateObject (ObjDesc
->Processor
.DeviceNotify
);
326 AcpiDbEnumerateObject (ObjDesc
->Processor
.Handler
);
329 case ACPI_TYPE_THERMAL
:
331 AcpiDbEnumerateObject (ObjDesc
->ThermalZone
.SystemNotify
);
332 AcpiDbEnumerateObject (ObjDesc
->ThermalZone
.DeviceNotify
);
333 AcpiDbEnumerateObject (ObjDesc
->ThermalZone
.Handler
);
342 /*******************************************************************************
344 * FUNCTION: AcpiDbClassifyOneObject
346 * PARAMETERS: Callback for WalkNamespace
350 * DESCRIPTION: Enumerate both the object descriptor (including subobjects) and
351 * the parent namespace node.
353 ******************************************************************************/
356 AcpiDbClassifyOneObject (
357 ACPI_HANDLE ObjHandle
,
362 ACPI_NAMESPACE_NODE
*Node
;
363 ACPI_OPERAND_OBJECT
*ObjDesc
;
369 Node
= (ACPI_NAMESPACE_NODE
*) ObjHandle
;
370 ObjDesc
= AcpiNsGetAttachedObject (Node
);
372 AcpiDbEnumerateObject (ObjDesc
);
375 if (Type
> ACPI_TYPE_NS_NODE_MAX
)
377 AcpiGbl_NodeTypeCountMisc
++;
381 AcpiGbl_NodeTypeCount
[Type
]++;
387 #ifdef ACPI_FUTURE_IMPLEMENTATION
389 /* TBD: These need to be counted during the initial parsing phase */
391 if (AcpiPsIsNamedOp (Op
->Opcode
))
401 NumGrammarElements
++;
402 Op
= AcpiPsGetDepthNext (Root
, Op
);
404 SizeOfParseTree
= (NumGrammarElements
- NumMethodElements
) *
405 (UINT32
) sizeof (ACPI_PARSE_OBJECT
);
406 SizeOfMethodTrees
= NumMethodElements
* (UINT32
) sizeof (ACPI_PARSE_OBJECT
);
407 SizeOfNodeEntries
= NumNodes
* (UINT32
) sizeof (ACPI_NAMESPACE_NODE
);
408 SizeOfAcpiObjects
= NumNodes
* (UINT32
) sizeof (ACPI_OPERAND_OBJECT
);
413 /*******************************************************************************
415 * FUNCTION: AcpiDbCountNamespaceObjects
421 * DESCRIPTION: Count and classify the entire namespace, including all
422 * namespace nodes and attached objects.
424 ******************************************************************************/
427 AcpiDbCountNamespaceObjects (
433 AcpiGbl_NumNodes
= 0;
434 AcpiGbl_NumObjects
= 0;
436 AcpiGbl_ObjTypeCountMisc
= 0;
437 for (i
= 0; i
< (ACPI_TYPE_NS_NODE_MAX
-1); i
++)
439 AcpiGbl_ObjTypeCount
[i
] = 0;
440 AcpiGbl_NodeTypeCount
[i
] = 0;
443 (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
,
444 ACPI_UINT32_MAX
, FALSE
, AcpiDbClassifyOneObject
, NULL
, NULL
);
448 /*******************************************************************************
450 * FUNCTION: AcpiDbDisplayStatistics
452 * PARAMETERS: TypeArg - Subcommand
456 * DESCRIPTION: Display various statistics
458 ******************************************************************************/
461 AcpiDbDisplayStatistics (
470 AcpiOsPrintf ("The following subcommands are available:\n ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n");
474 AcpiUtStrupr (TypeArg
);
475 Temp
= AcpiDbMatchArgument (TypeArg
, AcpiDbStatTypes
);
476 if (Temp
== (UINT32
) -1)
478 AcpiOsPrintf ("Invalid or unsupported argument\n");
485 case CMD_STAT_ALLOCATIONS
:
487 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
488 AcpiUtDumpAllocationInfo ();
492 case CMD_STAT_TABLES
:
494 AcpiOsPrintf ("ACPI Table Information (not implemented):\n\n");
497 case CMD_STAT_OBJECTS
:
499 AcpiDbCountNamespaceObjects ();
501 AcpiOsPrintf ("\nObjects defined in the current namespace:\n\n");
503 AcpiOsPrintf ("%16.16s %10.10s %10.10s\n",
504 "ACPI_TYPE", "NODES", "OBJECTS");
506 for (i
= 0; i
< ACPI_TYPE_NS_NODE_MAX
; i
++)
508 AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", AcpiUtGetTypeName (i
),
509 AcpiGbl_NodeTypeCount
[i
], AcpiGbl_ObjTypeCount
[i
]);
511 AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", "Misc/Unknown",
512 AcpiGbl_NodeTypeCountMisc
, AcpiGbl_ObjTypeCountMisc
);
514 AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", "TOTALS:",
515 AcpiGbl_NumNodes
, AcpiGbl_NumObjects
);
518 case CMD_STAT_MEMORY
:
520 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
521 AcpiOsPrintf ("\n----Object and Cache Statistics---------------------------------------------\n");
523 AcpiDbListInfo (AcpiGbl_GlobalList
);
524 AcpiDbListInfo (AcpiGbl_NsNodeList
);
526 #ifdef ACPI_USE_LOCAL_CACHE
527 AcpiDbListInfo (AcpiGbl_OperandCache
);
528 AcpiDbListInfo (AcpiGbl_PsNodeCache
);
529 AcpiDbListInfo (AcpiGbl_PsNodeExtCache
);
530 AcpiDbListInfo (AcpiGbl_StateCache
);
538 AcpiOsPrintf ("\nMiscellaneous Statistics:\n\n");
539 AcpiOsPrintf ("Calls to AcpiPsFind:.. ........% 7ld\n",
540 AcpiGbl_PsFindCount
);
541 AcpiOsPrintf ("Calls to AcpiNsLookup:..........% 7ld\n",
542 AcpiGbl_NsLookupCount
);
546 AcpiOsPrintf ("Mutex usage:\n\n");
547 for (i
= 0; i
< ACPI_NUM_MUTEX
; i
++)
549 AcpiOsPrintf ("%-28s: % 7ld\n",
550 AcpiUtGetMutexName (i
), AcpiGbl_MutexInfo
[i
].UseCount
);
557 AcpiOsPrintf ("\nInternal object sizes:\n\n");
559 AcpiOsPrintf ("Common %3d\n", sizeof (ACPI_OBJECT_COMMON
));
560 AcpiOsPrintf ("Number %3d\n", sizeof (ACPI_OBJECT_INTEGER
));
561 AcpiOsPrintf ("String %3d\n", sizeof (ACPI_OBJECT_STRING
));
562 AcpiOsPrintf ("Buffer %3d\n", sizeof (ACPI_OBJECT_BUFFER
));
563 AcpiOsPrintf ("Package %3d\n", sizeof (ACPI_OBJECT_PACKAGE
));
564 AcpiOsPrintf ("BufferField %3d\n", sizeof (ACPI_OBJECT_BUFFER_FIELD
));
565 AcpiOsPrintf ("Device %3d\n", sizeof (ACPI_OBJECT_DEVICE
));
566 AcpiOsPrintf ("Event %3d\n", sizeof (ACPI_OBJECT_EVENT
));
567 AcpiOsPrintf ("Method %3d\n", sizeof (ACPI_OBJECT_METHOD
));
568 AcpiOsPrintf ("Mutex %3d\n", sizeof (ACPI_OBJECT_MUTEX
));
569 AcpiOsPrintf ("Region %3d\n", sizeof (ACPI_OBJECT_REGION
));
570 AcpiOsPrintf ("PowerResource %3d\n", sizeof (ACPI_OBJECT_POWER_RESOURCE
));
571 AcpiOsPrintf ("Processor %3d\n", sizeof (ACPI_OBJECT_PROCESSOR
));
572 AcpiOsPrintf ("ThermalZone %3d\n", sizeof (ACPI_OBJECT_THERMAL_ZONE
));
573 AcpiOsPrintf ("RegionField %3d\n", sizeof (ACPI_OBJECT_REGION_FIELD
));
574 AcpiOsPrintf ("BankField %3d\n", sizeof (ACPI_OBJECT_BANK_FIELD
));
575 AcpiOsPrintf ("IndexField %3d\n", sizeof (ACPI_OBJECT_INDEX_FIELD
));
576 AcpiOsPrintf ("Reference %3d\n", sizeof (ACPI_OBJECT_REFERENCE
));
577 AcpiOsPrintf ("Notify %3d\n", sizeof (ACPI_OBJECT_NOTIFY_HANDLER
));
578 AcpiOsPrintf ("AddressSpace %3d\n", sizeof (ACPI_OBJECT_ADDR_HANDLER
));
579 AcpiOsPrintf ("Extra %3d\n", sizeof (ACPI_OBJECT_EXTRA
));
580 AcpiOsPrintf ("Data %3d\n", sizeof (ACPI_OBJECT_DATA
));
584 AcpiOsPrintf ("ParseObject %3d\n", sizeof (ACPI_PARSE_OBJ_COMMON
));
585 AcpiOsPrintf ("ParseObjectNamed %3d\n", sizeof (ACPI_PARSE_OBJ_NAMED
));
586 AcpiOsPrintf ("ParseObjectAsl %3d\n", sizeof (ACPI_PARSE_OBJ_ASL
));
587 AcpiOsPrintf ("OperandObject %3d\n", sizeof (ACPI_OPERAND_OBJECT
));
588 AcpiOsPrintf ("NamespaceNode %3d\n", sizeof (ACPI_NAMESPACE_NODE
));
594 #if defined(ACPI_DEBUG_OUTPUT)
596 Temp
= (UINT32
) (AcpiGbl_EntryStackPointer
- AcpiGbl_LowestStackPointer
);
598 AcpiOsPrintf ("\nSubsystem Stack Usage:\n\n");
599 AcpiOsPrintf ("Entry Stack Pointer %X\n", AcpiGbl_EntryStackPointer
);
600 AcpiOsPrintf ("Lowest Stack Pointer %X\n", AcpiGbl_LowestStackPointer
);
601 AcpiOsPrintf ("Stack Use %X (%d)\n", Temp
, Temp
);
602 AcpiOsPrintf ("Deepest Procedure Nesting %d\n", AcpiGbl_DeepestNesting
);
614 #endif /* ACPI_DEBUGGER */