aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utilities
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2006-03-17 16:44:00 -0500
committerLen Brown <len.brown@intel.com>2006-06-14 01:22:20 -0400
commit61686124f47d7c4b78610346c5f8f9d8a6d46bb5 (patch)
tree6fd91b2c1749907e58ef136107e53d634d7978c4 /drivers/acpi/utilities
parent144c87b4e03759214c362d267e01c2905f1ab095 (diff)
[ACPI] ACPICA 20060317
Implemented the use of a cache object for all internal namespace nodes. Since there are about 1000 static nodes in a typical system, this will decrease memory use for cache implementations that minimize per-allocation overhead (such as a slab allocator.) Removed the reference count mechanism for internal namespace nodes, since it was deemed unnecessary. This reduces the size of each namespace node by about 5%-10% on all platforms. Nodes are now 20 bytes for the 32-bit case, and 32 bytes for the 64-bit case. Optimized several internal data structures to reduce object size on 64-bit platforms by packing data within the 64-bit alignment. This includes the frequently used ACPI_OPERAND_OBJECT, of which there can be ~1000 static instances corresponding to the namespace objects. Added two new strings for the predefined _OSI method: "Windows 2001.1 SP1" and "Windows 2006". Split the allocation tracking mechanism out to a separate file, from utalloc.c to uttrack.c. This mechanism appears to be only useful for application-level code. Kernels may wish to not include uttrack.c in distributions. Removed all remnants of the obsolete ACPI_REPORT_* macros and the associated code. (These macros have been replaced by the ACPI_ERROR and ACPI_WARNING macros.) Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/utilities')
-rw-r--r--drivers/acpi/utilities/utalloc.c590
-rw-r--r--drivers/acpi/utilities/utcache.c6
-rw-r--r--drivers/acpi/utilities/utdelete.c3
-rw-r--r--drivers/acpi/utilities/utglobal.c8
-rw-r--r--drivers/acpi/utilities/utmisc.c33
-rw-r--r--drivers/acpi/utilities/utresrc.c150
-rw-r--r--drivers/acpi/utilities/utstate.c10
7 files changed, 148 insertions, 652 deletions
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index 7b35eb84d058..3b29aecaaca5 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -46,24 +46,6 @@
46#define _COMPONENT ACPI_UTILITIES 46#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utalloc") 47ACPI_MODULE_NAME("utalloc")
48 48
49/* Local prototypes */
50#ifdef ACPI_DBG_TRACK_ALLOCATIONS
51static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation);
52
53static acpi_status
54acpi_ut_track_allocation(struct acpi_debug_mem_block *address,
55 acpi_size size,
56 u8 alloc_type, u32 component, char *module, u32 line);
57
58static acpi_status
59acpi_ut_remove_allocation(struct acpi_debug_mem_block *address,
60 u32 component, char *module, u32 line);
61
62static acpi_status
63acpi_ut_create_list(char *list_name,
64 u16 object_size, struct acpi_memory_list **return_cache);
65#endif
66
67/******************************************************************************* 49/*******************************************************************************
68 * 50 *
69 * FUNCTION: acpi_ut_create_caches 51 * FUNCTION: acpi_ut_create_caches
@@ -75,7 +57,6 @@ acpi_ut_create_list(char *list_name,
75 * DESCRIPTION: Create all local caches 57 * DESCRIPTION: Create all local caches
76 * 58 *
77 ******************************************************************************/ 59 ******************************************************************************/
78
79acpi_status acpi_ut_create_caches(void) 60acpi_status acpi_ut_create_caches(void)
80{ 61{
81 acpi_status status; 62 acpi_status status;
@@ -101,7 +82,16 @@ acpi_status acpi_ut_create_caches(void)
101 /* Object Caches, for frequently used objects */ 82 /* Object Caches, for frequently used objects */
102 83
103 status = 84 status =
104 acpi_os_create_cache("acpi_state", sizeof(union acpi_generic_state), 85 acpi_os_create_cache("Acpi-Namespace",
86 sizeof(struct acpi_namespace_node),
87 ACPI_MAX_NAMESPACE_CACHE_DEPTH,
88 &acpi_gbl_namespace_cache);
89 if (ACPI_FAILURE(status)) {
90 return (status);
91 }
92
93 status =
94 acpi_os_create_cache("Acpi-State", sizeof(union acpi_generic_state),
105 ACPI_MAX_STATE_CACHE_DEPTH, 95 ACPI_MAX_STATE_CACHE_DEPTH,
106 &acpi_gbl_state_cache); 96 &acpi_gbl_state_cache);
107 if (ACPI_FAILURE(status)) { 97 if (ACPI_FAILURE(status)) {
@@ -109,7 +99,7 @@ acpi_status acpi_ut_create_caches(void)
109 } 99 }
110 100
111 status = 101 status =
112 acpi_os_create_cache("acpi_parse", 102 acpi_os_create_cache("Acpi-Parse",
113 sizeof(struct acpi_parse_obj_common), 103 sizeof(struct acpi_parse_obj_common),
114 ACPI_MAX_PARSE_CACHE_DEPTH, 104 ACPI_MAX_PARSE_CACHE_DEPTH,
115 &acpi_gbl_ps_node_cache); 105 &acpi_gbl_ps_node_cache);
@@ -118,7 +108,7 @@ acpi_status acpi_ut_create_caches(void)
118 } 108 }
119 109
120 status = 110 status =
121 acpi_os_create_cache("acpi_parse_ext", 111 acpi_os_create_cache("Acpi-parse_ext",
122 sizeof(struct acpi_parse_obj_named), 112 sizeof(struct acpi_parse_obj_named),
123 ACPI_MAX_EXTPARSE_CACHE_DEPTH, 113 ACPI_MAX_EXTPARSE_CACHE_DEPTH,
124 &acpi_gbl_ps_node_ext_cache); 114 &acpi_gbl_ps_node_ext_cache);
@@ -127,7 +117,7 @@ acpi_status acpi_ut_create_caches(void)
127 } 117 }
128 118
129 status = 119 status =
130 acpi_os_create_cache("acpi_operand", 120 acpi_os_create_cache("Acpi-Operand",
131 sizeof(union acpi_operand_object), 121 sizeof(union acpi_operand_object),
132 ACPI_MAX_OBJECT_CACHE_DEPTH, 122 ACPI_MAX_OBJECT_CACHE_DEPTH,
133 &acpi_gbl_operand_cache); 123 &acpi_gbl_operand_cache);
@@ -153,6 +143,9 @@ acpi_status acpi_ut_create_caches(void)
153acpi_status acpi_ut_delete_caches(void) 143acpi_status acpi_ut_delete_caches(void)
154{ 144{
155 145
146 (void)acpi_os_delete_cache(acpi_gbl_namespace_cache);
147 acpi_gbl_namespace_cache = NULL;
148
156 (void)acpi_os_delete_cache(acpi_gbl_state_cache); 149 (void)acpi_os_delete_cache(acpi_gbl_state_cache);
157 acpi_gbl_state_cache = NULL; 150 acpi_gbl_state_cache = NULL;
158 151
@@ -288,7 +281,7 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
288 * 281 *
289 * RETURN: Address of the allocated memory on success, NULL on failure. 282 * RETURN: Address of the allocated memory on success, NULL on failure.
290 * 283 *
291 * DESCRIPTION: The subsystem's equivalent of malloc. 284 * DESCRIPTION: Subsystem equivalent of malloc.
292 * 285 *
293 ******************************************************************************/ 286 ******************************************************************************/
294 287
@@ -301,8 +294,8 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
301 /* Check for an inadvertent size of zero bytes */ 294 /* Check for an inadvertent size of zero bytes */
302 295
303 if (!size) { 296 if (!size) {
304 ACPI_ERROR((module, line, 297 ACPI_WARNING((module, line,
305 "ut_allocate: Attempt to allocate zero bytes, allocating 1 byte")); 298 "Attempt to allocate zero bytes, allocating 1 byte"));
306 size = 1; 299 size = 1;
307 } 300 }
308 301
@@ -311,9 +304,8 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
311 304
312 /* Report allocation error */ 305 /* Report allocation error */
313 306
314 ACPI_ERROR((module, line, 307 ACPI_WARNING((module, line,
315 "ut_allocate: Could not allocate size %X", 308 "Could not allocate size %X", (u32) size));
316 (u32) size));
317 309
318 return_PTR(NULL); 310 return_PTR(NULL);
319 } 311 }
@@ -323,7 +315,7 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
323 315
324/******************************************************************************* 316/*******************************************************************************
325 * 317 *
326 * FUNCTION: acpi_ut_callocate 318 * FUNCTION: acpi_ut_allocate_zeroed
327 * 319 *
328 * PARAMETERS: Size - Size of the allocation 320 * PARAMETERS: Size - Size of the allocation
329 * Component - Component type of caller 321 * Component - Component type of caller
@@ -332,546 +324,24 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
332 * 324 *
333 * RETURN: Address of the allocated memory on success, NULL on failure. 325 * RETURN: Address of the allocated memory on success, NULL on failure.
334 * 326 *
335 * DESCRIPTION: Subsystem equivalent of calloc. 327 * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory.
336 * 328 *
337 ******************************************************************************/ 329 ******************************************************************************/
338 330
339void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line) 331void *acpi_ut_allocate_zeroed(acpi_size size,
332 u32 component, char *module, u32 line)
340{ 333{
341 void *allocation; 334 void *allocation;
342 335
343 ACPI_FUNCTION_TRACE_U32("ut_callocate", size);
344
345 /* Check for an inadvertent size of zero bytes */
346
347 if (!size) {
348 ACPI_ERROR((module, line,
349 "Attempt to allocate zero bytes, allocating 1 byte"));
350 size = 1;
351 }
352
353 allocation = acpi_os_allocate(size);
354 if (!allocation) {
355
356 /* Report allocation error */
357
358 ACPI_ERROR((module, line,
359 "Could not allocate size %X", (u32) size));
360 return_PTR(NULL);
361 }
362
363 /* Clear the memory block */
364
365 ACPI_MEMSET(allocation, 0, size);
366 return_PTR(allocation);
367}
368
369#ifdef ACPI_DBG_TRACK_ALLOCATIONS
370/*
371 * These procedures are used for tracking memory leaks in the subsystem, and
372 * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
373 *
374 * Each memory allocation is tracked via a doubly linked list. Each
375 * element contains the caller's component, module name, function name, and
376 * line number. acpi_ut_allocate and acpi_ut_callocate call
377 * acpi_ut_track_allocation to add an element to the list; deletion
378 * occurs in the body of acpi_ut_free.
379 */
380
381/*******************************************************************************
382 *
383 * FUNCTION: acpi_ut_create_list
384 *
385 * PARAMETERS: cache_name - Ascii name for the cache
386 * object_size - Size of each cached object
387 * return_cache - Where the new cache object is returned
388 *
389 * RETURN: Status
390 *
391 * DESCRIPTION: Create a local memory list for tracking purposed
392 *
393 ******************************************************************************/
394
395static acpi_status
396acpi_ut_create_list(char *list_name,
397 u16 object_size, struct acpi_memory_list **return_cache)
398{
399 struct acpi_memory_list *cache;
400
401 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
402 if (!cache) {
403 return (AE_NO_MEMORY);
404 }
405
406 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
407
408 cache->list_name = list_name;
409 cache->object_size = object_size;
410
411 *return_cache = cache;
412 return (AE_OK);
413}
414
415/*******************************************************************************
416 *
417 * FUNCTION: acpi_ut_allocate_and_track
418 *
419 * PARAMETERS: Size - Size of the allocation
420 * Component - Component type of caller
421 * Module - Source file name of caller
422 * Line - Line number of caller
423 *
424 * RETURN: Address of the allocated memory on success, NULL on failure.
425 *
426 * DESCRIPTION: The subsystem's equivalent of malloc.
427 *
428 ******************************************************************************/
429
430void *acpi_ut_allocate_and_track(acpi_size size,
431 u32 component, char *module, u32 line)
432{
433 struct acpi_debug_mem_block *allocation;
434 acpi_status status;
435
436 allocation =
437 acpi_ut_allocate(size + sizeof(struct acpi_debug_mem_header),
438 component, module, line);
439 if (!allocation) {
440 return (NULL);
441 }
442
443 status = acpi_ut_track_allocation(allocation, size,
444 ACPI_MEM_MALLOC, component, module,
445 line);
446 if (ACPI_FAILURE(status)) {
447 acpi_os_free(allocation);
448 return (NULL);
449 }
450
451 acpi_gbl_global_list->total_allocated++;
452 acpi_gbl_global_list->current_total_size += (u32) size;
453
454 return ((void *)&allocation->user_space);
455}
456
457/*******************************************************************************
458 *
459 * FUNCTION: acpi_ut_callocate_and_track
460 *
461 * PARAMETERS: Size - Size of the allocation
462 * Component - Component type of caller
463 * Module - Source file name of caller
464 * Line - Line number of caller
465 *
466 * RETURN: Address of the allocated memory on success, NULL on failure.
467 *
468 * DESCRIPTION: Subsystem equivalent of calloc.
469 *
470 ******************************************************************************/
471
472void *acpi_ut_callocate_and_track(acpi_size size,
473 u32 component, char *module, u32 line)
474{
475 struct acpi_debug_mem_block *allocation;
476 acpi_status status;
477
478 allocation =
479 acpi_ut_callocate(size + sizeof(struct acpi_debug_mem_header),
480 component, module, line);
481 if (!allocation) {
482
483 /* Report allocation error */
484
485 ACPI_ERROR((module, line,
486 "Could not allocate size %X", (u32) size));
487 return (NULL);
488 }
489
490 status = acpi_ut_track_allocation(allocation, size,
491 ACPI_MEM_CALLOC, component, module,
492 line);
493 if (ACPI_FAILURE(status)) {
494 acpi_os_free(allocation);
495 return (NULL);
496 }
497
498 acpi_gbl_global_list->total_allocated++;
499 acpi_gbl_global_list->current_total_size += (u32) size;
500
501 return ((void *)&allocation->user_space);
502}
503
504/*******************************************************************************
505 *
506 * FUNCTION: acpi_ut_free_and_track
507 *
508 * PARAMETERS: Allocation - Address of the memory to deallocate
509 * Component - Component type of caller
510 * Module - Source file name of caller
511 * Line - Line number of caller
512 *
513 * RETURN: None
514 *
515 * DESCRIPTION: Frees the memory at Allocation
516 *
517 ******************************************************************************/
518
519void
520acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line)
521{
522 struct acpi_debug_mem_block *debug_block;
523 acpi_status status;
524
525 ACPI_FUNCTION_TRACE_PTR("ut_free", allocation);
526
527 if (NULL == allocation) {
528 ACPI_ERROR((module, line, "Attempt to delete a NULL address"));
529
530 return_VOID;
531 }
532
533 debug_block = ACPI_CAST_PTR(struct acpi_debug_mem_block,
534 (((char *)allocation) -
535 sizeof(struct acpi_debug_mem_header)));
536
537 acpi_gbl_global_list->total_freed++;
538 acpi_gbl_global_list->current_total_size -= debug_block->size;
539
540 status = acpi_ut_remove_allocation(debug_block,
541 component, module, line);
542 if (ACPI_FAILURE(status)) {
543 ACPI_EXCEPTION((AE_INFO, status, "Could not free memory"));
544 }
545
546 acpi_os_free(debug_block);
547 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation));
548 return_VOID;
549}
550
551/*******************************************************************************
552 *
553 * FUNCTION: acpi_ut_find_allocation
554 *
555 * PARAMETERS: Allocation - Address of allocated memory
556 *
557 * RETURN: A list element if found; NULL otherwise.
558 *
559 * DESCRIPTION: Searches for an element in the global allocation tracking list.
560 *
561 ******************************************************************************/
562
563static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation)
564{
565 struct acpi_debug_mem_block *element;
566
567 ACPI_FUNCTION_ENTRY(); 336 ACPI_FUNCTION_ENTRY();
568 337
569 element = acpi_gbl_global_list->list_head; 338 allocation = acpi_ut_allocate(size, component, module, line);
570 339 if (allocation) {
571 /* Search for the address. */
572
573 while (element) {
574 if (element == allocation) {
575 return (element);
576 }
577
578 element = element->next;
579 }
580
581 return (NULL);
582}
583
584/*******************************************************************************
585 *
586 * FUNCTION: acpi_ut_track_allocation
587 *
588 * PARAMETERS: Allocation - Address of allocated memory
589 * Size - Size of the allocation
590 * alloc_type - MEM_MALLOC or MEM_CALLOC
591 * Component - Component type of caller
592 * Module - Source file name of caller
593 * Line - Line number of caller
594 *
595 * RETURN: None.
596 *
597 * DESCRIPTION: Inserts an element into the global allocation tracking list.
598 *
599 ******************************************************************************/
600
601static acpi_status
602acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation,
603 acpi_size size,
604 u8 alloc_type, u32 component, char *module, u32 line)
605{
606 struct acpi_memory_list *mem_list;
607 struct acpi_debug_mem_block *element;
608 acpi_status status = AE_OK;
609
610 ACPI_FUNCTION_TRACE_PTR("ut_track_allocation", allocation);
611
612 mem_list = acpi_gbl_global_list;
613 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
614 if (ACPI_FAILURE(status)) {
615 return_ACPI_STATUS(status);
616 }
617
618 /*
619 * Search list for this address to make sure it is not already on the list.
620 * This will catch several kinds of problems.
621 */
622 element = acpi_ut_find_allocation(allocation);
623 if (element) {
624 ACPI_ERROR((AE_INFO,
625 "ut_track_allocation: Allocation already present in list! (%p)",
626 allocation));
627 340
628 ACPI_ERROR((AE_INFO, "Element %p Address %p", 341 /* Clear the memory block */
629 element, allocation));
630 342
631 goto unlock_and_exit; 343 ACPI_MEMSET(allocation, 0, size);
632 } 344 }
633 345
634 /* Fill in the instance data. */ 346 return (allocation);
635
636 allocation->size = (u32) size;
637 allocation->alloc_type = alloc_type;
638 allocation->component = component;
639 allocation->line = line;
640
641 ACPI_STRNCPY(allocation->module, module, ACPI_MAX_MODULE_NAME);
642 allocation->module[ACPI_MAX_MODULE_NAME - 1] = 0;
643
644 /* Insert at list head */
645
646 if (mem_list->list_head) {
647 ((struct acpi_debug_mem_block *)(mem_list->list_head))->
648 previous = allocation;
649 }
650
651 allocation->next = mem_list->list_head;
652 allocation->previous = NULL;
653
654 mem_list->list_head = allocation;
655
656 unlock_and_exit:
657 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
658 return_ACPI_STATUS(status);
659} 347}
660
661/*******************************************************************************
662 *
663 * FUNCTION: acpi_ut_remove_allocation
664 *
665 * PARAMETERS: Allocation - Address of allocated memory
666 * Component - Component type of caller
667 * Module - Source file name of caller
668 * Line - Line number of caller
669 *
670 * RETURN:
671 *
672 * DESCRIPTION: Deletes an element from the global allocation tracking list.
673 *
674 ******************************************************************************/
675
676static acpi_status
677acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
678 u32 component, char *module, u32 line)
679{
680 struct acpi_memory_list *mem_list;
681 acpi_status status;
682
683 ACPI_FUNCTION_TRACE("ut_remove_allocation");
684
685 mem_list = acpi_gbl_global_list;
686 if (NULL == mem_list->list_head) {
687
688 /* No allocations! */
689
690 ACPI_ERROR((module, line,
691 "Empty allocation list, nothing to free!"));
692
693 return_ACPI_STATUS(AE_OK);
694 }
695
696 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
697 if (ACPI_FAILURE(status)) {
698 return_ACPI_STATUS(status);
699 }
700
701 /* Unlink */
702
703 if (allocation->previous) {
704 (allocation->previous)->next = allocation->next;
705 } else {
706 mem_list->list_head = allocation->next;
707 }
708
709 if (allocation->next) {
710 (allocation->next)->previous = allocation->previous;
711 }
712
713 /* Mark the segment as deleted */
714
715 ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size);
716
717 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
718 allocation->size));
719
720 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
721 return_ACPI_STATUS(status);
722}
723
724/*******************************************************************************
725 *
726 * FUNCTION: acpi_ut_dump_allocation_info
727 *
728 * PARAMETERS:
729 *
730 * RETURN: None
731 *
732 * DESCRIPTION: Print some info about the outstanding allocations.
733 *
734 ******************************************************************************/
735
736#ifdef ACPI_FUTURE_USAGE
737void acpi_ut_dump_allocation_info(void)
738{
739/*
740 struct acpi_memory_list *mem_list;
741*/
742
743 ACPI_FUNCTION_TRACE("ut_dump_allocation_info");
744
745/*
746 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
747 ("%30s: %4d (%3d Kb)\n", "Current allocations",
748 mem_list->current_count,
749 ROUND_UP_TO_1K (mem_list->current_size)));
750
751 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
752 ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
753 mem_list->max_concurrent_count,
754 ROUND_UP_TO_1K (mem_list->max_concurrent_size)));
755
756 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
757 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
758 running_object_count,
759 ROUND_UP_TO_1K (running_object_size)));
760
761 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
762 ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
763 running_alloc_count,
764 ROUND_UP_TO_1K (running_alloc_size)));
765
766 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
767 ("%30s: %4d (%3d Kb)\n", "Current Nodes",
768 acpi_gbl_current_node_count,
769 ROUND_UP_TO_1K (acpi_gbl_current_node_size)));
770
771 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
772 ("%30s: %4d (%3d Kb)\n", "Max Nodes",
773 acpi_gbl_max_concurrent_node_count,
774 ROUND_UP_TO_1K ((acpi_gbl_max_concurrent_node_count *
775 sizeof (struct acpi_namespace_node)))));
776*/
777 return_VOID;
778}
779#endif /* ACPI_FUTURE_USAGE */
780
781/*******************************************************************************
782 *
783 * FUNCTION: acpi_ut_dump_allocations
784 *
785 * PARAMETERS: Component - Component(s) to dump info for.
786 * Module - Module to dump info for. NULL means all.
787 *
788 * RETURN: None
789 *
790 * DESCRIPTION: Print a list of all outstanding allocations.
791 *
792 ******************************************************************************/
793
794void acpi_ut_dump_allocations(u32 component, char *module)
795{
796 struct acpi_debug_mem_block *element;
797 union acpi_descriptor *descriptor;
798 u32 num_outstanding = 0;
799
800 ACPI_FUNCTION_TRACE("ut_dump_allocations");
801
802 /*
803 * Walk the allocation list.
804 */
805 if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_MEMORY))) {
806 return;
807 }
808
809 element = acpi_gbl_global_list->list_head;
810 while (element) {
811 if ((element->component & component) &&
812 ((module == NULL)
813 || (0 == ACPI_STRCMP(module, element->module)))) {
814
815 /* Ignore allocated objects that are in a cache */
816
817 descriptor =
818 ACPI_CAST_PTR(union acpi_descriptor,
819 &element->user_space);
820 if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) {
821 acpi_os_printf("%p Len %04X %9.9s-%d [%s] ",
822 descriptor, element->size,
823 element->module, element->line,
824 acpi_ut_get_descriptor_name
825 (descriptor));
826
827 /* Most of the elements will be Operand objects. */
828
829 switch (ACPI_GET_DESCRIPTOR_TYPE(descriptor)) {
830 case ACPI_DESC_TYPE_OPERAND:
831 acpi_os_printf("%12.12s R%hd",
832 acpi_ut_get_type_name
833 (descriptor->object.
834 common.type),
835 descriptor->object.
836 common.reference_count);
837 break;
838
839 case ACPI_DESC_TYPE_PARSER:
840 acpi_os_printf("aml_opcode %04hX",
841 descriptor->op.asl.
842 aml_opcode);
843 break;
844
845 case ACPI_DESC_TYPE_NAMED:
846 acpi_os_printf("%4.4s",
847 acpi_ut_get_node_name
848 (&descriptor->node));
849 break;
850
851 default:
852 break;
853 }
854
855 acpi_os_printf("\n");
856 num_outstanding++;
857 }
858 }
859 element = element->next;
860 }
861
862 (void)acpi_ut_release_mutex(ACPI_MTX_MEMORY);
863
864 /* Print summary */
865
866 if (!num_outstanding) {
867 ACPI_INFO((AE_INFO, "No outstanding allocations"));
868 } else {
869 ACPI_ERROR((AE_INFO,
870 "%d(%X) Outstanding allocations",
871 num_outstanding, num_outstanding));
872 }
873
874 return_VOID;
875}
876
877#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */
diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c
index 5d2f4b2802a5..593b08ccd6bf 100644
--- a/drivers/acpi/utilities/utcache.c
+++ b/drivers/acpi/utilities/utcache.c
@@ -272,9 +272,9 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache)
272 cache->current_depth--; 272 cache->current_depth--;
273 273
274 ACPI_MEM_TRACKING(cache->hits++); 274 ACPI_MEM_TRACKING(cache->hits++);
275 ACPI_MEM_TRACKING(ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 275 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
276 "Object %p from %s cache\n", 276 "Object %p from %s cache\n", object,
277 object, cache->list_name))); 277 cache->list_name));
278 278
279 status = acpi_ut_release_mutex(ACPI_MTX_CACHES); 279 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
280 if (ACPI_FAILURE(status)) { 280 if (ACPI_FAILURE(status)) {
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index 9c6867fcf009..51356e8eb999 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -200,8 +200,7 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
200 */ 200 */
201 handler_desc = object->region.handler; 201 handler_desc = object->region.handler;
202 if (handler_desc) { 202 if (handler_desc) {
203 if (handler_desc->address_space. 203 if (handler_desc->address_space.handler_flags &
204 hflags &
205 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { 204 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
206 obj_pointer = 205 obj_pointer =
207 second_desc->extra.region_context; 206 second_desc->extra.region_context;
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 5bc8da7acc6c..8a05bb5ef4fe 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -191,12 +191,14 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = {
191 "Linux", 191 "Linux",
192 "Windows 2000", 192 "Windows 2000",
193 "Windows 2001", 193 "Windows 2001",
194 "Windows 2001.1",
195 "Windows 2001 SP0", 194 "Windows 2001 SP0",
196 "Windows 2001 SP1", 195 "Windows 2001 SP1",
197 "Windows 2001 SP2", 196 "Windows 2001 SP2",
198 "Windows 2001 SP3", 197 "Windows 2001 SP3",
199 "Windows 2001 SP4", 198 "Windows 2001 SP4",
199 "Windows 2001.1",
200 "Windows 2001.1 SP1", /* Added 03/2006 */
201 "Windows 2006", /* Added 03/2006 */
200 202
201 /* Feature Group Strings */ 203 /* Feature Group Strings */
202 204
@@ -633,7 +635,7 @@ char *acpi_ut_get_node_name(void *object)
633 635
634 /* Descriptor must be a namespace node */ 636 /* Descriptor must be a namespace node */
635 637
636 if (node->descriptor != ACPI_DESC_TYPE_NAMED) { 638 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
637 return ("####"); 639 return ("####");
638 } 640 }
639 641
@@ -855,7 +857,7 @@ void acpi_ut_init_globals(void)
855 857
856 acpi_gbl_root_node = NULL; 858 acpi_gbl_root_node = NULL;
857 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; 859 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
858 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED; 860 acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
859 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; 861 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
860 acpi_gbl_root_node_struct.child = NULL; 862 acpi_gbl_root_node_struct.child = NULL;
861 acpi_gbl_root_node_struct.peer = NULL; 863 acpi_gbl_root_node_struct.peer = NULL;
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index 77268ba86291..017a87ebc40b 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -881,36 +881,3 @@ acpi_ut_info(char *module_name, u32 line_number, char *format, ...)
881 acpi_os_vprintf(format, args); 881 acpi_os_vprintf(format, args);
882 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); 882 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
883} 883}
884
885/*******************************************************************************
886 *
887 * FUNCTION: acpi_ut_report_error, Warning, Info
888 *
889 * PARAMETERS: module_name - Caller's module name (for error output)
890 * line_number - Caller's line number (for error output)
891 *
892 * RETURN: None
893 *
894 * DESCRIPTION: Print error message
895 *
896 * Note: Legacy only, should be removed when no longer used by drivers.
897 *
898 ******************************************************************************/
899
900void acpi_ut_report_error(char *module_name, u32 line_number)
901{
902
903 acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
904}
905
906void acpi_ut_report_warning(char *module_name, u32 line_number)
907{
908
909 acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number);
910}
911
912void acpi_ut_report_info(char *module_name, u32 line_number)
913{
914
915 acpi_os_printf("ACPI (%s-%04d): ", module_name, line_number);
916}
diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c
index 27158dd0f877..4c24e6d5400a 100644
--- a/drivers/acpi/utilities/utresrc.c
+++ b/drivers/acpi/utilities/utresrc.c
@@ -240,6 +240,104 @@ static const u8 acpi_gbl_resource_types[] = {
240 240
241/******************************************************************************* 241/*******************************************************************************
242 * 242 *
243 * FUNCTION: acpi_ut_walk_aml_resources
244 *
245 * PARAMETERS: Aml - Pointer to the raw AML resource template
246 * aml_length - Length of the entire template
247 * user_function - Called once for each descriptor found. If
248 * NULL, a pointer to the end_tag is returned
249 * Context - Passed to user_function
250 *
251 * RETURN: Status
252 *
253 * DESCRIPTION: Walk a raw AML resource list(buffer). User function called
254 * once for each resource found.
255 *
256 ******************************************************************************/
257
258acpi_status
259acpi_ut_walk_aml_resources(u8 * aml,
260 acpi_size aml_length,
261 acpi_walk_aml_callback user_function, void *context)
262{
263 acpi_status status;
264 u8 *end_aml;
265 u8 resource_index;
266 u32 length;
267 u32 offset = 0;
268
269 ACPI_FUNCTION_TRACE("ut_walk_aml_resources");
270
271 /* The absolute minimum resource template is one end_tag descriptor */
272
273 if (aml_length < sizeof(struct aml_resource_end_tag)) {
274 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
275 }
276
277 /* Point to the end of the resource template buffer */
278
279 end_aml = aml + aml_length;
280
281 /* Walk the byte list, abort on any invalid descriptor type or length */
282
283 while (aml < end_aml) {
284
285 /* Validate the Resource Type and Resource Length */
286
287 status = acpi_ut_validate_resource(aml, &resource_index);
288 if (ACPI_FAILURE(status)) {
289 return_ACPI_STATUS(status);
290 }
291
292 /* Get the length of this descriptor */
293
294 length = acpi_ut_get_descriptor_length(aml);
295
296 /* Invoke the user function */
297
298 if (user_function) {
299 status =
300 user_function(aml, length, offset, resource_index,
301 context);
302 if (ACPI_FAILURE(status)) {
303 return (status);
304 }
305 }
306
307 /* An end_tag descriptor terminates this resource template */
308
309 if (acpi_ut_get_resource_type(aml) ==
310 ACPI_RESOURCE_NAME_END_TAG) {
311 /*
312 * There must be at least one more byte in the buffer for
313 * the 2nd byte of the end_tag
314 */
315 if ((aml + 1) >= end_aml) {
316 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
317 }
318
319 /* Return the pointer to the end_tag if requested */
320
321 if (!user_function) {
322 *(void **)context = aml;
323 }
324
325 /* Normal exit */
326
327 return_ACPI_STATUS(AE_OK);
328 }
329
330 aml += length;
331 offset += length;
332 }
333
334 /* Did not find an end_tag descriptor */
335
336 return (AE_AML_NO_RESOURCE_END_TAG);
337}
338
339/*******************************************************************************
340 *
243 * FUNCTION: acpi_ut_validate_resource 341 * FUNCTION: acpi_ut_validate_resource
244 * 342 *
245 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 343 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
@@ -498,61 +596,21 @@ acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc,
498 u8 ** end_tag) 596 u8 ** end_tag)
499{ 597{
500 acpi_status status; 598 acpi_status status;
501 u8 *aml;
502 u8 *end_aml;
503 599
504 ACPI_FUNCTION_TRACE("ut_get_resource_end_tag"); 600 ACPI_FUNCTION_TRACE("ut_get_resource_end_tag");
505 601
506 /* Get start and end pointers */
507
508 aml = obj_desc->buffer.pointer;
509 end_aml = aml + obj_desc->buffer.length;
510
511 /* Allow a buffer length of zero */ 602 /* Allow a buffer length of zero */
512 603
513 if (!obj_desc->buffer.length) { 604 if (!obj_desc->buffer.length) {
514 *end_tag = aml; 605 *end_tag = obj_desc->buffer.pointer;
515 return_ACPI_STATUS(AE_OK); 606 return_ACPI_STATUS(AE_OK);
516 } 607 }
517 608
518 /* Walk the resource template, one descriptor per iteration */ 609 /* Validate the template and get a pointer to the end_tag */
519
520 while (aml < end_aml) {
521
522 /* Validate the Resource Type and Resource Length */
523
524 status = acpi_ut_validate_resource(aml, NULL);
525 if (ACPI_FAILURE(status)) {
526 return_ACPI_STATUS(status);
527 }
528
529 /* end_tag resource indicates the end of the resource template */
530
531 if (acpi_ut_get_resource_type(aml) ==
532 ACPI_RESOURCE_NAME_END_TAG) {
533 /*
534 * There must be at least one more byte in the buffer for
535 * the 2nd byte of the end_tag
536 */
537 if ((aml + 1) >= end_aml) {
538 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
539 }
540
541 /* Return the pointer to the end_tag */
542
543 *end_tag = aml;
544 return_ACPI_STATUS(AE_OK);
545 }
546
547 /*
548 * Point to the next resource descriptor in the AML buffer. The
549 * descriptor length is guaranteed to be non-zero by resource
550 * validation above.
551 */
552 aml += acpi_ut_get_descriptor_length(aml);
553 }
554 610
555 /* Did not find an end_tag resource descriptor */ 611 status = acpi_ut_walk_aml_resources(obj_desc->buffer.pointer,
612 obj_desc->buffer.length, NULL,
613 end_tag);
556 614
557 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); 615 return_ACPI_STATUS(status);
558} 616}
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c
index 69f2bfdc26ab..637c5f964879 100644
--- a/drivers/acpi/utilities/utstate.c
+++ b/drivers/acpi/utilities/utstate.c
@@ -162,7 +162,7 @@ union acpi_generic_state *acpi_ut_create_generic_state(void)
162 162
163 /* Initialize */ 163 /* Initialize */
164 memset(state, 0, sizeof(union acpi_generic_state)); 164 memset(state, 0, sizeof(union acpi_generic_state));
165 state->common.data_type = ACPI_DESC_TYPE_STATE; 165 state->common.descriptor_type = ACPI_DESC_TYPE_STATE;
166 } 166 }
167 167
168 return (state); 168 return (state);
@@ -196,7 +196,7 @@ struct acpi_thread_state *acpi_ut_create_thread_state(void)
196 196
197 /* Init fields specific to the update struct */ 197 /* Init fields specific to the update struct */
198 198
199 state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD; 199 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_THREAD;
200 state->thread.thread_id = acpi_os_get_thread_id(); 200 state->thread.thread_id = acpi_os_get_thread_id();
201 201
202 return_PTR((struct acpi_thread_state *)state); 202 return_PTR((struct acpi_thread_state *)state);
@@ -233,7 +233,7 @@ union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
233 233
234 /* Init fields specific to the update struct */ 234 /* Init fields specific to the update struct */
235 235
236 state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE; 236 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_UPDATE;
237 state->update.object = object; 237 state->update.object = object;
238 state->update.value = action; 238 state->update.value = action;
239 239
@@ -270,7 +270,7 @@ union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
270 270
271 /* Init fields specific to the update struct */ 271 /* Init fields specific to the update struct */
272 272
273 state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE; 273 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_PACKAGE;
274 state->pkg.source_object = (union acpi_operand_object *)internal_object; 274 state->pkg.source_object = (union acpi_operand_object *)internal_object;
275 state->pkg.dest_object = external_object; 275 state->pkg.dest_object = external_object;
276 state->pkg.index = index; 276 state->pkg.index = index;
@@ -307,7 +307,7 @@ union acpi_generic_state *acpi_ut_create_control_state(void)
307 307
308 /* Init fields specific to the control struct */ 308 /* Init fields specific to the control struct */
309 309
310 state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL; 310 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_CONTROL;
311 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; 311 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING;
312 312
313 return_PTR(state); 313 return_PTR(state);