Deleted Added
full compact
dbstats.c (126372) dbstats.c (151600)
1/*******************************************************************************
2 *
3 * Module Name: dbstats - Generation and display of ACPI table statistics
4 * $Revision: 70 $
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2004, 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
1/*******************************************************************************
2 *
3 * Module Name: dbstats - Generation and display of ACPI table statistics
4 * $Revision: 70 $
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2004, 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 "acdebug.h"
120#include "acnamesp.h"
118#include <contrib/dev/acpica/acpi.h>
119#include <contrib/dev/acpica/acdebug.h>
120#include <contrib/dev/acpica/acnamesp.h>
121
122#ifdef ACPI_DEBUGGER
123
124#define _COMPONENT ACPI_CA_DEBUGGER
125 ACPI_MODULE_NAME ("dbstats")
126
127/*
128 * Statistics subcommands
129 */
130static ARGUMENT_INFO AcpiDbStatTypes [] =
131{
132 {"ALLOCATIONS"},
133 {"OBJECTS"},
134 {"MEMORY"},
135 {"MISC"},
136 {"TABLES"},
137 {"SIZES"},
138 {"STACK"},
139 {NULL} /* Must be null terminated */
140};
141
142#define CMD_STAT_ALLOCATIONS 0
143#define CMD_STAT_OBJECTS 1
144#define CMD_STAT_MEMORY 2
145#define CMD_STAT_MISC 3
146#define CMD_STAT_TABLES 4
147#define CMD_STAT_SIZES 5
148#define CMD_STAT_STACK 6
149
150
151/*******************************************************************************
152 *
153 * FUNCTION: AcpiDbEnumerateObject
154 *
155 * PARAMETERS: ObjDesc - Object to be counted
156 *
157 * RETURN: None
158 *
159 * DESCRIPTION: Add this object to the global counts, by object type.
160 * Limited recursion handles subobjects and packages, and this
161 * is probably acceptable within the AML debugger only.
162 *
163 ******************************************************************************/
164
165void
166AcpiDbEnumerateObject (
167 ACPI_OPERAND_OBJECT *ObjDesc)
168{
169 UINT32 i;
170
171
172 if (!ObjDesc)
173 {
174 return;
175 }
176
177
178 /* Enumerate this object first */
179
180 AcpiGbl_NumObjects++;
181
182 if (ACPI_GET_OBJECT_TYPE (ObjDesc) > ACPI_TYPE_NS_NODE_MAX)
183 {
184 AcpiGbl_ObjTypeCountMisc++;
185 }
186 else
187 {
188 AcpiGbl_ObjTypeCount [ACPI_GET_OBJECT_TYPE (ObjDesc)]++;
189 }
190
191 /* Count the sub-objects */
192
193 switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
194 {
195 case ACPI_TYPE_PACKAGE:
196
197 for (i = 0; i < ObjDesc->Package.Count; i++)
198 {
199 AcpiDbEnumerateObject (ObjDesc->Package.Elements[i]);
200 }
201 break;
202
203 case ACPI_TYPE_DEVICE:
204
205 AcpiDbEnumerateObject (ObjDesc->Device.SystemNotify);
206 AcpiDbEnumerateObject (ObjDesc->Device.DeviceNotify);
207 AcpiDbEnumerateObject (ObjDesc->Device.Handler);
208 break;
209
210 case ACPI_TYPE_BUFFER_FIELD:
211
212 if (AcpiNsGetSecondaryObject (ObjDesc))
213 {
214 AcpiGbl_ObjTypeCount [ACPI_TYPE_BUFFER_FIELD]++;
215 }
216 break;
217
218 case ACPI_TYPE_REGION:
219
220 AcpiGbl_ObjTypeCount [ACPI_TYPE_LOCAL_REGION_FIELD ]++;
221 AcpiDbEnumerateObject (ObjDesc->Region.Handler);
222 break;
223
224 case ACPI_TYPE_POWER:
225
226 AcpiDbEnumerateObject (ObjDesc->PowerResource.SystemNotify);
227 AcpiDbEnumerateObject (ObjDesc->PowerResource.DeviceNotify);
228 break;
229
230 case ACPI_TYPE_PROCESSOR:
231
232 AcpiDbEnumerateObject (ObjDesc->Processor.SystemNotify);
233 AcpiDbEnumerateObject (ObjDesc->Processor.DeviceNotify);
234 AcpiDbEnumerateObject (ObjDesc->Processor.Handler);
235 break;
236
237 case ACPI_TYPE_THERMAL:
238
239 AcpiDbEnumerateObject (ObjDesc->ThermalZone.SystemNotify);
240 AcpiDbEnumerateObject (ObjDesc->ThermalZone.DeviceNotify);
241 AcpiDbEnumerateObject (ObjDesc->ThermalZone.Handler);
242 break;
243
244 default:
245 break;
246 }
247}
248
249
250/*******************************************************************************
251 *
252 * FUNCTION: AcpiDbClassifyOneObject
253 *
254 * PARAMETERS: Callback for WalkNamespace
255 *
256 * RETURN: Status
257 *
258 * DESCRIPTION: Enumerate both the object descriptor (including subobjects) and
259 * the parent namespace node.
260 *
261 ******************************************************************************/
262
263ACPI_STATUS
264AcpiDbClassifyOneObject (
265 ACPI_HANDLE ObjHandle,
266 UINT32 NestingLevel,
267 void *Context,
268 void **ReturnValue)
269{
270 ACPI_NAMESPACE_NODE *Node;
271 ACPI_OPERAND_OBJECT *ObjDesc;
272 UINT32 Type;
273
274
275 AcpiGbl_NumNodes++;
276
277 Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
278 ObjDesc = AcpiNsGetAttachedObject (Node);
279
280 AcpiDbEnumerateObject (ObjDesc);
281
282 Type = Node->Type;
283 if (Type > ACPI_TYPE_NS_NODE_MAX)
284 {
285 AcpiGbl_NodeTypeCountMisc++;
286 }
287
288 else
289 {
290 AcpiGbl_NodeTypeCount [Type]++;
291 }
292
293 return AE_OK;
294
295
296 /* TBD: These need to be counted during the initial parsing phase */
297 /*
298 if (AcpiPsIsNamedOp (Op->Opcode))
299 {
300 NumNodes++;
301 }
302
303 if (IsMethod)
304 {
305 NumMethodElements++;
306 }
307
308 NumGrammarElements++;
309 Op = AcpiPsGetDepthNext (Root, Op);
310
311 SizeOfParseTree = (NumGrammarElements - NumMethodElements) * (UINT32) sizeof (ACPI_PARSE_OBJECT);
312 SizeOfMethodTrees = NumMethodElements * (UINT32) sizeof (ACPI_PARSE_OBJECT);
313 SizeOfNodeEntries = NumNodes * (UINT32) sizeof (ACPI_NAMESPACE_NODE);
314 SizeOfAcpiObjects = NumNodes * (UINT32) sizeof (ACPI_OPERAND_OBJECT);
315
316 */
317}
318
319
320/*******************************************************************************
321 *
322 * FUNCTION: AcpiDbCountNamespaceObjects
323 *
324 * PARAMETERS: None
325 *
326 * RETURN: Status
327 *
328 * DESCRIPTION: Count and classify the entire namespace, including all
329 * namespace nodes and attached objects.
330 *
331 ******************************************************************************/
332
333void
334AcpiDbCountNamespaceObjects (
335 void)
336{
337 UINT32 i;
338
339
340 AcpiGbl_NumNodes = 0;
341 AcpiGbl_NumObjects = 0;
342
343 AcpiGbl_ObjTypeCountMisc = 0;
344 for (i = 0; i < (ACPI_TYPE_NS_NODE_MAX -1); i++)
345 {
346 AcpiGbl_ObjTypeCount [i] = 0;
347 AcpiGbl_NodeTypeCount [i] = 0;
348 }
349
350 (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
351 FALSE, AcpiDbClassifyOneObject, NULL, NULL);
352}
353
354
355/*******************************************************************************
356 *
357 * FUNCTION: AcpiDbDisplayStatistics
358 *
359 * PARAMETERS: TypeArg - Subcommand
360 *
361 * RETURN: Status
362 *
363 * DESCRIPTION: Display various statistics
364 *
365 ******************************************************************************/
366
367ACPI_STATUS
368AcpiDbDisplayStatistics (
369 char *TypeArg)
370{
371 UINT32 i;
372 UINT32 Type;
373 UINT32 Size;
374#ifdef ACPI_DBG_TRACK_ALLOCATIONS
375 UINT32 Outstanding;
376#endif
377
378
379 if (!AcpiGbl_DSDT)
380 {
381 AcpiOsPrintf ("*** Warning: There is no DSDT loaded\n");
382 }
383
384 if (!TypeArg)
385 {
386 AcpiOsPrintf ("The following subcommands are available:\n ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n");
387 return (AE_OK);
388 }
389
390 ACPI_STRUPR (TypeArg);
391 Type = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes);
392 if (Type == (UINT32) -1)
393 {
394 AcpiOsPrintf ("Invalid or unsupported argument\n");
395 return (AE_OK);
396 }
397
398
399 switch (Type)
400 {
401 case CMD_STAT_ALLOCATIONS:
402#ifdef ACPI_DBG_TRACK_ALLOCATIONS
403 AcpiUtDumpAllocationInfo ();
404#endif
405 break;
406
407 case CMD_STAT_TABLES:
408
409 AcpiOsPrintf ("ACPI Table Information:\n\n");
410 if (AcpiGbl_DSDT)
411 {
412 AcpiOsPrintf ("DSDT Length:................% 7ld (%X)\n", AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length);
413 }
414 break;
415
416 case CMD_STAT_OBJECTS:
417
418 AcpiDbCountNamespaceObjects ();
419
420 AcpiOsPrintf ("\nObjects defined in the current namespace:\n\n");
421
422 AcpiOsPrintf ("%16.16s %10.10s %10.10s\n", "ACPI_TYPE", "NODES", "OBJECTS");
423
424 for (i = 0; i < ACPI_TYPE_NS_NODE_MAX; i++)
425 {
426 AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", AcpiUtGetTypeName (i),
427 AcpiGbl_NodeTypeCount [i], AcpiGbl_ObjTypeCount [i]);
428 }
429 AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", "Misc/Unknown",
430 AcpiGbl_NodeTypeCountMisc, AcpiGbl_ObjTypeCountMisc);
431
432 AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", "TOTALS:",
433 AcpiGbl_NumNodes, AcpiGbl_NumObjects);
434 break;
435
436 case CMD_STAT_MEMORY:
437
438#ifdef ACPI_DBG_TRACK_ALLOCATIONS
439 AcpiOsPrintf ("\n----Object and Cache Statistics---------------------------------------------\n");
440
441 for (i = 0; i < ACPI_NUM_MEM_LISTS; i++)
442 {
443 AcpiOsPrintf ("\n%s\n", AcpiGbl_MemoryLists[i].ListName);
444
445 if (AcpiGbl_MemoryLists[i].MaxCacheDepth > 0)
446 {
447 AcpiOsPrintf (" Cache: [Depth Max Avail Size] % 7d % 7d % 7d % 7d B\n",
448 AcpiGbl_MemoryLists[i].CacheDepth,
449 AcpiGbl_MemoryLists[i].MaxCacheDepth,
450 AcpiGbl_MemoryLists[i].MaxCacheDepth - AcpiGbl_MemoryLists[i].CacheDepth,
451 (AcpiGbl_MemoryLists[i].CacheDepth * AcpiGbl_MemoryLists[i].ObjectSize));
452
453 AcpiOsPrintf (" Cache: [Requests Hits Misses ObjSize] % 7d % 7d % 7d % 7d B\n",
454 AcpiGbl_MemoryLists[i].CacheRequests,
455 AcpiGbl_MemoryLists[i].CacheHits,
456 AcpiGbl_MemoryLists[i].CacheRequests - AcpiGbl_MemoryLists[i].CacheHits,
457 AcpiGbl_MemoryLists[i].ObjectSize);
458 }
459
460 Outstanding = AcpiGbl_MemoryLists[i].TotalAllocated -
461 AcpiGbl_MemoryLists[i].TotalFreed -
462 AcpiGbl_MemoryLists[i].CacheDepth;
463
464 if (AcpiGbl_MemoryLists[i].ObjectSize)
465 {
466 Size = ACPI_ROUND_UP_TO_1K (Outstanding * AcpiGbl_MemoryLists[i].ObjectSize);
467 }
468 else
469 {
470 Size = ACPI_ROUND_UP_TO_1K (AcpiGbl_MemoryLists[i].CurrentTotalSize);
471 }
472
473 AcpiOsPrintf (" Mem: [Alloc Free Outstanding Size] % 7d % 7d % 7d % 7d Kb\n",
474 AcpiGbl_MemoryLists[i].TotalAllocated,
475 AcpiGbl_MemoryLists[i].TotalFreed,
476 Outstanding, Size);
477 }
478#endif
479
480 break;
481
482 case CMD_STAT_MISC:
483
484 AcpiOsPrintf ("\nMiscellaneous Statistics:\n\n");
485 AcpiOsPrintf ("Calls to AcpiPsFind:.. ........% 7ld\n", AcpiGbl_PsFindCount);
486 AcpiOsPrintf ("Calls to AcpiNsLookup:..........% 7ld\n", AcpiGbl_NsLookupCount);
487
488 AcpiOsPrintf ("\n");
489
490 AcpiOsPrintf ("Mutex usage:\n\n");
491 for (i = 0; i < NUM_MUTEX; i++)
492 {
493 AcpiOsPrintf ("%-28s: % 7ld\n", AcpiUtGetMutexName (i), AcpiGbl_MutexInfo[i].UseCount);
494 }
495 break;
496
497
498 case CMD_STAT_SIZES:
499
500 AcpiOsPrintf ("\nInternal object sizes:\n\n");
501
502 AcpiOsPrintf ("Common %3d\n", sizeof (ACPI_OBJECT_COMMON));
503 AcpiOsPrintf ("Number %3d\n", sizeof (ACPI_OBJECT_INTEGER));
504 AcpiOsPrintf ("String %3d\n", sizeof (ACPI_OBJECT_STRING));
505 AcpiOsPrintf ("Buffer %3d\n", sizeof (ACPI_OBJECT_BUFFER));
506 AcpiOsPrintf ("Package %3d\n", sizeof (ACPI_OBJECT_PACKAGE));
507 AcpiOsPrintf ("BufferField %3d\n", sizeof (ACPI_OBJECT_BUFFER_FIELD));
508 AcpiOsPrintf ("Device %3d\n", sizeof (ACPI_OBJECT_DEVICE));
509 AcpiOsPrintf ("Event %3d\n", sizeof (ACPI_OBJECT_EVENT));
510 AcpiOsPrintf ("Method %3d\n", sizeof (ACPI_OBJECT_METHOD));
511 AcpiOsPrintf ("Mutex %3d\n", sizeof (ACPI_OBJECT_MUTEX));
512 AcpiOsPrintf ("Region %3d\n", sizeof (ACPI_OBJECT_REGION));
513 AcpiOsPrintf ("PowerResource %3d\n", sizeof (ACPI_OBJECT_POWER_RESOURCE));
514 AcpiOsPrintf ("Processor %3d\n", sizeof (ACPI_OBJECT_PROCESSOR));
515 AcpiOsPrintf ("ThermalZone %3d\n", sizeof (ACPI_OBJECT_THERMAL_ZONE));
516 AcpiOsPrintf ("RegionField %3d\n", sizeof (ACPI_OBJECT_REGION_FIELD));
517 AcpiOsPrintf ("BankField %3d\n", sizeof (ACPI_OBJECT_BANK_FIELD));
518 AcpiOsPrintf ("IndexField %3d\n", sizeof (ACPI_OBJECT_INDEX_FIELD));
519 AcpiOsPrintf ("Reference %3d\n", sizeof (ACPI_OBJECT_REFERENCE));
520 AcpiOsPrintf ("Notify %3d\n", sizeof (ACPI_OBJECT_NOTIFY_HANDLER));
521 AcpiOsPrintf ("AddressSpace %3d\n", sizeof (ACPI_OBJECT_ADDR_HANDLER));
522 AcpiOsPrintf ("Extra %3d\n", sizeof (ACPI_OBJECT_EXTRA));
523 AcpiOsPrintf ("Data %3d\n", sizeof (ACPI_OBJECT_DATA));
524
525 AcpiOsPrintf ("\n");
526
527 AcpiOsPrintf ("ParseObject %3d\n", sizeof (ACPI_PARSE_OBJ_COMMON));
528 AcpiOsPrintf ("ParseObjectNamed %3d\n", sizeof (ACPI_PARSE_OBJ_NAMED));
529 AcpiOsPrintf ("ParseObjectAsl %3d\n", sizeof (ACPI_PARSE_OBJ_ASL));
530 AcpiOsPrintf ("OperandObject %3d\n", sizeof (ACPI_OPERAND_OBJECT));
531 AcpiOsPrintf ("NamespaceNode %3d\n", sizeof (ACPI_NAMESPACE_NODE));
532
533 break;
534
535
536 case CMD_STAT_STACK:
537#if defined(ACPI_DEBUG_OUTPUT)
538
539 Size = (UINT32) (AcpiGbl_EntryStackPointer - AcpiGbl_LowestStackPointer);
540
541 AcpiOsPrintf ("\nSubsystem Stack Usage:\n\n");
542 AcpiOsPrintf ("Entry Stack Pointer %X\n", AcpiGbl_EntryStackPointer);
543 AcpiOsPrintf ("Lowest Stack Pointer %X\n", AcpiGbl_LowestStackPointer);
544 AcpiOsPrintf ("Stack Use %X (%d)\n", Size, Size);
545 AcpiOsPrintf ("Deepest Procedure Nesting %d\n", AcpiGbl_DeepestNesting);
546#endif
547 break;
548
549 default:
550 break;
551 }
552
553 AcpiOsPrintf ("\n");
554 return (AE_OK);
555}
556
557
558#endif /* ACPI_DEBUGGER */
121
122#ifdef ACPI_DEBUGGER
123
124#define _COMPONENT ACPI_CA_DEBUGGER
125 ACPI_MODULE_NAME ("dbstats")
126
127/*
128 * Statistics subcommands
129 */
130static ARGUMENT_INFO AcpiDbStatTypes [] =
131{
132 {"ALLOCATIONS"},
133 {"OBJECTS"},
134 {"MEMORY"},
135 {"MISC"},
136 {"TABLES"},
137 {"SIZES"},
138 {"STACK"},
139 {NULL} /* Must be null terminated */
140};
141
142#define CMD_STAT_ALLOCATIONS 0
143#define CMD_STAT_OBJECTS 1
144#define CMD_STAT_MEMORY 2
145#define CMD_STAT_MISC 3
146#define CMD_STAT_TABLES 4
147#define CMD_STAT_SIZES 5
148#define CMD_STAT_STACK 6
149
150
151/*******************************************************************************
152 *
153 * FUNCTION: AcpiDbEnumerateObject
154 *
155 * PARAMETERS: ObjDesc - Object to be counted
156 *
157 * RETURN: None
158 *
159 * DESCRIPTION: Add this object to the global counts, by object type.
160 * Limited recursion handles subobjects and packages, and this
161 * is probably acceptable within the AML debugger only.
162 *
163 ******************************************************************************/
164
165void
166AcpiDbEnumerateObject (
167 ACPI_OPERAND_OBJECT *ObjDesc)
168{
169 UINT32 i;
170
171
172 if (!ObjDesc)
173 {
174 return;
175 }
176
177
178 /* Enumerate this object first */
179
180 AcpiGbl_NumObjects++;
181
182 if (ACPI_GET_OBJECT_TYPE (ObjDesc) > ACPI_TYPE_NS_NODE_MAX)
183 {
184 AcpiGbl_ObjTypeCountMisc++;
185 }
186 else
187 {
188 AcpiGbl_ObjTypeCount [ACPI_GET_OBJECT_TYPE (ObjDesc)]++;
189 }
190
191 /* Count the sub-objects */
192
193 switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
194 {
195 case ACPI_TYPE_PACKAGE:
196
197 for (i = 0; i < ObjDesc->Package.Count; i++)
198 {
199 AcpiDbEnumerateObject (ObjDesc->Package.Elements[i]);
200 }
201 break;
202
203 case ACPI_TYPE_DEVICE:
204
205 AcpiDbEnumerateObject (ObjDesc->Device.SystemNotify);
206 AcpiDbEnumerateObject (ObjDesc->Device.DeviceNotify);
207 AcpiDbEnumerateObject (ObjDesc->Device.Handler);
208 break;
209
210 case ACPI_TYPE_BUFFER_FIELD:
211
212 if (AcpiNsGetSecondaryObject (ObjDesc))
213 {
214 AcpiGbl_ObjTypeCount [ACPI_TYPE_BUFFER_FIELD]++;
215 }
216 break;
217
218 case ACPI_TYPE_REGION:
219
220 AcpiGbl_ObjTypeCount [ACPI_TYPE_LOCAL_REGION_FIELD ]++;
221 AcpiDbEnumerateObject (ObjDesc->Region.Handler);
222 break;
223
224 case ACPI_TYPE_POWER:
225
226 AcpiDbEnumerateObject (ObjDesc->PowerResource.SystemNotify);
227 AcpiDbEnumerateObject (ObjDesc->PowerResource.DeviceNotify);
228 break;
229
230 case ACPI_TYPE_PROCESSOR:
231
232 AcpiDbEnumerateObject (ObjDesc->Processor.SystemNotify);
233 AcpiDbEnumerateObject (ObjDesc->Processor.DeviceNotify);
234 AcpiDbEnumerateObject (ObjDesc->Processor.Handler);
235 break;
236
237 case ACPI_TYPE_THERMAL:
238
239 AcpiDbEnumerateObject (ObjDesc->ThermalZone.SystemNotify);
240 AcpiDbEnumerateObject (ObjDesc->ThermalZone.DeviceNotify);
241 AcpiDbEnumerateObject (ObjDesc->ThermalZone.Handler);
242 break;
243
244 default:
245 break;
246 }
247}
248
249
250/*******************************************************************************
251 *
252 * FUNCTION: AcpiDbClassifyOneObject
253 *
254 * PARAMETERS: Callback for WalkNamespace
255 *
256 * RETURN: Status
257 *
258 * DESCRIPTION: Enumerate both the object descriptor (including subobjects) and
259 * the parent namespace node.
260 *
261 ******************************************************************************/
262
263ACPI_STATUS
264AcpiDbClassifyOneObject (
265 ACPI_HANDLE ObjHandle,
266 UINT32 NestingLevel,
267 void *Context,
268 void **ReturnValue)
269{
270 ACPI_NAMESPACE_NODE *Node;
271 ACPI_OPERAND_OBJECT *ObjDesc;
272 UINT32 Type;
273
274
275 AcpiGbl_NumNodes++;
276
277 Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
278 ObjDesc = AcpiNsGetAttachedObject (Node);
279
280 AcpiDbEnumerateObject (ObjDesc);
281
282 Type = Node->Type;
283 if (Type > ACPI_TYPE_NS_NODE_MAX)
284 {
285 AcpiGbl_NodeTypeCountMisc++;
286 }
287
288 else
289 {
290 AcpiGbl_NodeTypeCount [Type]++;
291 }
292
293 return AE_OK;
294
295
296 /* TBD: These need to be counted during the initial parsing phase */
297 /*
298 if (AcpiPsIsNamedOp (Op->Opcode))
299 {
300 NumNodes++;
301 }
302
303 if (IsMethod)
304 {
305 NumMethodElements++;
306 }
307
308 NumGrammarElements++;
309 Op = AcpiPsGetDepthNext (Root, Op);
310
311 SizeOfParseTree = (NumGrammarElements - NumMethodElements) * (UINT32) sizeof (ACPI_PARSE_OBJECT);
312 SizeOfMethodTrees = NumMethodElements * (UINT32) sizeof (ACPI_PARSE_OBJECT);
313 SizeOfNodeEntries = NumNodes * (UINT32) sizeof (ACPI_NAMESPACE_NODE);
314 SizeOfAcpiObjects = NumNodes * (UINT32) sizeof (ACPI_OPERAND_OBJECT);
315
316 */
317}
318
319
320/*******************************************************************************
321 *
322 * FUNCTION: AcpiDbCountNamespaceObjects
323 *
324 * PARAMETERS: None
325 *
326 * RETURN: Status
327 *
328 * DESCRIPTION: Count and classify the entire namespace, including all
329 * namespace nodes and attached objects.
330 *
331 ******************************************************************************/
332
333void
334AcpiDbCountNamespaceObjects (
335 void)
336{
337 UINT32 i;
338
339
340 AcpiGbl_NumNodes = 0;
341 AcpiGbl_NumObjects = 0;
342
343 AcpiGbl_ObjTypeCountMisc = 0;
344 for (i = 0; i < (ACPI_TYPE_NS_NODE_MAX -1); i++)
345 {
346 AcpiGbl_ObjTypeCount [i] = 0;
347 AcpiGbl_NodeTypeCount [i] = 0;
348 }
349
350 (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
351 FALSE, AcpiDbClassifyOneObject, NULL, NULL);
352}
353
354
355/*******************************************************************************
356 *
357 * FUNCTION: AcpiDbDisplayStatistics
358 *
359 * PARAMETERS: TypeArg - Subcommand
360 *
361 * RETURN: Status
362 *
363 * DESCRIPTION: Display various statistics
364 *
365 ******************************************************************************/
366
367ACPI_STATUS
368AcpiDbDisplayStatistics (
369 char *TypeArg)
370{
371 UINT32 i;
372 UINT32 Type;
373 UINT32 Size;
374#ifdef ACPI_DBG_TRACK_ALLOCATIONS
375 UINT32 Outstanding;
376#endif
377
378
379 if (!AcpiGbl_DSDT)
380 {
381 AcpiOsPrintf ("*** Warning: There is no DSDT loaded\n");
382 }
383
384 if (!TypeArg)
385 {
386 AcpiOsPrintf ("The following subcommands are available:\n ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n");
387 return (AE_OK);
388 }
389
390 ACPI_STRUPR (TypeArg);
391 Type = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes);
392 if (Type == (UINT32) -1)
393 {
394 AcpiOsPrintf ("Invalid or unsupported argument\n");
395 return (AE_OK);
396 }
397
398
399 switch (Type)
400 {
401 case CMD_STAT_ALLOCATIONS:
402#ifdef ACPI_DBG_TRACK_ALLOCATIONS
403 AcpiUtDumpAllocationInfo ();
404#endif
405 break;
406
407 case CMD_STAT_TABLES:
408
409 AcpiOsPrintf ("ACPI Table Information:\n\n");
410 if (AcpiGbl_DSDT)
411 {
412 AcpiOsPrintf ("DSDT Length:................% 7ld (%X)\n", AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length);
413 }
414 break;
415
416 case CMD_STAT_OBJECTS:
417
418 AcpiDbCountNamespaceObjects ();
419
420 AcpiOsPrintf ("\nObjects defined in the current namespace:\n\n");
421
422 AcpiOsPrintf ("%16.16s %10.10s %10.10s\n", "ACPI_TYPE", "NODES", "OBJECTS");
423
424 for (i = 0; i < ACPI_TYPE_NS_NODE_MAX; i++)
425 {
426 AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", AcpiUtGetTypeName (i),
427 AcpiGbl_NodeTypeCount [i], AcpiGbl_ObjTypeCount [i]);
428 }
429 AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", "Misc/Unknown",
430 AcpiGbl_NodeTypeCountMisc, AcpiGbl_ObjTypeCountMisc);
431
432 AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", "TOTALS:",
433 AcpiGbl_NumNodes, AcpiGbl_NumObjects);
434 break;
435
436 case CMD_STAT_MEMORY:
437
438#ifdef ACPI_DBG_TRACK_ALLOCATIONS
439 AcpiOsPrintf ("\n----Object and Cache Statistics---------------------------------------------\n");
440
441 for (i = 0; i < ACPI_NUM_MEM_LISTS; i++)
442 {
443 AcpiOsPrintf ("\n%s\n", AcpiGbl_MemoryLists[i].ListName);
444
445 if (AcpiGbl_MemoryLists[i].MaxCacheDepth > 0)
446 {
447 AcpiOsPrintf (" Cache: [Depth Max Avail Size] % 7d % 7d % 7d % 7d B\n",
448 AcpiGbl_MemoryLists[i].CacheDepth,
449 AcpiGbl_MemoryLists[i].MaxCacheDepth,
450 AcpiGbl_MemoryLists[i].MaxCacheDepth - AcpiGbl_MemoryLists[i].CacheDepth,
451 (AcpiGbl_MemoryLists[i].CacheDepth * AcpiGbl_MemoryLists[i].ObjectSize));
452
453 AcpiOsPrintf (" Cache: [Requests Hits Misses ObjSize] % 7d % 7d % 7d % 7d B\n",
454 AcpiGbl_MemoryLists[i].CacheRequests,
455 AcpiGbl_MemoryLists[i].CacheHits,
456 AcpiGbl_MemoryLists[i].CacheRequests - AcpiGbl_MemoryLists[i].CacheHits,
457 AcpiGbl_MemoryLists[i].ObjectSize);
458 }
459
460 Outstanding = AcpiGbl_MemoryLists[i].TotalAllocated -
461 AcpiGbl_MemoryLists[i].TotalFreed -
462 AcpiGbl_MemoryLists[i].CacheDepth;
463
464 if (AcpiGbl_MemoryLists[i].ObjectSize)
465 {
466 Size = ACPI_ROUND_UP_TO_1K (Outstanding * AcpiGbl_MemoryLists[i].ObjectSize);
467 }
468 else
469 {
470 Size = ACPI_ROUND_UP_TO_1K (AcpiGbl_MemoryLists[i].CurrentTotalSize);
471 }
472
473 AcpiOsPrintf (" Mem: [Alloc Free Outstanding Size] % 7d % 7d % 7d % 7d Kb\n",
474 AcpiGbl_MemoryLists[i].TotalAllocated,
475 AcpiGbl_MemoryLists[i].TotalFreed,
476 Outstanding, Size);
477 }
478#endif
479
480 break;
481
482 case CMD_STAT_MISC:
483
484 AcpiOsPrintf ("\nMiscellaneous Statistics:\n\n");
485 AcpiOsPrintf ("Calls to AcpiPsFind:.. ........% 7ld\n", AcpiGbl_PsFindCount);
486 AcpiOsPrintf ("Calls to AcpiNsLookup:..........% 7ld\n", AcpiGbl_NsLookupCount);
487
488 AcpiOsPrintf ("\n");
489
490 AcpiOsPrintf ("Mutex usage:\n\n");
491 for (i = 0; i < NUM_MUTEX; i++)
492 {
493 AcpiOsPrintf ("%-28s: % 7ld\n", AcpiUtGetMutexName (i), AcpiGbl_MutexInfo[i].UseCount);
494 }
495 break;
496
497
498 case CMD_STAT_SIZES:
499
500 AcpiOsPrintf ("\nInternal object sizes:\n\n");
501
502 AcpiOsPrintf ("Common %3d\n", sizeof (ACPI_OBJECT_COMMON));
503 AcpiOsPrintf ("Number %3d\n", sizeof (ACPI_OBJECT_INTEGER));
504 AcpiOsPrintf ("String %3d\n", sizeof (ACPI_OBJECT_STRING));
505 AcpiOsPrintf ("Buffer %3d\n", sizeof (ACPI_OBJECT_BUFFER));
506 AcpiOsPrintf ("Package %3d\n", sizeof (ACPI_OBJECT_PACKAGE));
507 AcpiOsPrintf ("BufferField %3d\n", sizeof (ACPI_OBJECT_BUFFER_FIELD));
508 AcpiOsPrintf ("Device %3d\n", sizeof (ACPI_OBJECT_DEVICE));
509 AcpiOsPrintf ("Event %3d\n", sizeof (ACPI_OBJECT_EVENT));
510 AcpiOsPrintf ("Method %3d\n", sizeof (ACPI_OBJECT_METHOD));
511 AcpiOsPrintf ("Mutex %3d\n", sizeof (ACPI_OBJECT_MUTEX));
512 AcpiOsPrintf ("Region %3d\n", sizeof (ACPI_OBJECT_REGION));
513 AcpiOsPrintf ("PowerResource %3d\n", sizeof (ACPI_OBJECT_POWER_RESOURCE));
514 AcpiOsPrintf ("Processor %3d\n", sizeof (ACPI_OBJECT_PROCESSOR));
515 AcpiOsPrintf ("ThermalZone %3d\n", sizeof (ACPI_OBJECT_THERMAL_ZONE));
516 AcpiOsPrintf ("RegionField %3d\n", sizeof (ACPI_OBJECT_REGION_FIELD));
517 AcpiOsPrintf ("BankField %3d\n", sizeof (ACPI_OBJECT_BANK_FIELD));
518 AcpiOsPrintf ("IndexField %3d\n", sizeof (ACPI_OBJECT_INDEX_FIELD));
519 AcpiOsPrintf ("Reference %3d\n", sizeof (ACPI_OBJECT_REFERENCE));
520 AcpiOsPrintf ("Notify %3d\n", sizeof (ACPI_OBJECT_NOTIFY_HANDLER));
521 AcpiOsPrintf ("AddressSpace %3d\n", sizeof (ACPI_OBJECT_ADDR_HANDLER));
522 AcpiOsPrintf ("Extra %3d\n", sizeof (ACPI_OBJECT_EXTRA));
523 AcpiOsPrintf ("Data %3d\n", sizeof (ACPI_OBJECT_DATA));
524
525 AcpiOsPrintf ("\n");
526
527 AcpiOsPrintf ("ParseObject %3d\n", sizeof (ACPI_PARSE_OBJ_COMMON));
528 AcpiOsPrintf ("ParseObjectNamed %3d\n", sizeof (ACPI_PARSE_OBJ_NAMED));
529 AcpiOsPrintf ("ParseObjectAsl %3d\n", sizeof (ACPI_PARSE_OBJ_ASL));
530 AcpiOsPrintf ("OperandObject %3d\n", sizeof (ACPI_OPERAND_OBJECT));
531 AcpiOsPrintf ("NamespaceNode %3d\n", sizeof (ACPI_NAMESPACE_NODE));
532
533 break;
534
535
536 case CMD_STAT_STACK:
537#if defined(ACPI_DEBUG_OUTPUT)
538
539 Size = (UINT32) (AcpiGbl_EntryStackPointer - AcpiGbl_LowestStackPointer);
540
541 AcpiOsPrintf ("\nSubsystem Stack Usage:\n\n");
542 AcpiOsPrintf ("Entry Stack Pointer %X\n", AcpiGbl_EntryStackPointer);
543 AcpiOsPrintf ("Lowest Stack Pointer %X\n", AcpiGbl_LowestStackPointer);
544 AcpiOsPrintf ("Stack Use %X (%d)\n", Size, Size);
545 AcpiOsPrintf ("Deepest Procedure Nesting %d\n", AcpiGbl_DeepestNesting);
546#endif
547 break;
548
549 default:
550 break;
551 }
552
553 AcpiOsPrintf ("\n");
554 return (AE_OK);
555}
556
557
558#endif /* ACPI_DEBUGGER */