aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/dispatcher/dsmthdat.c15
-rw-r--r--drivers/acpi/dispatcher/dswload.c6
-rw-r--r--drivers/acpi/dispatcher/dswstate.c33
-rw-r--r--drivers/acpi/events/evgpe.c5
-rw-r--r--drivers/acpi/events/evgpeblk.c27
-rw-r--r--drivers/acpi/events/evmisc.c4
-rw-r--r--drivers/acpi/events/evxface.c10
-rw-r--r--drivers/acpi/executer/exconvrt.c2
-rw-r--r--drivers/acpi/executer/exdump.c174
-rw-r--r--drivers/acpi/executer/exmisc.c2
-rw-r--r--drivers/acpi/executer/exoparg1.c3
-rw-r--r--drivers/acpi/executer/exoparg3.c63
-rw-r--r--drivers/acpi/executer/exstore.c2
-rw-r--r--drivers/acpi/executer/exutils.c2
-rw-r--r--drivers/acpi/hardware/hwgpe.c20
-rw-r--r--drivers/acpi/hardware/hwregs.c2
-rw-r--r--drivers/acpi/hardware/hwsleep.c12
-rw-r--r--drivers/acpi/namespace/nsaccess.c2
-rw-r--r--drivers/acpi/namespace/nsalloc.c6
-rw-r--r--drivers/acpi/namespace/nsdump.c30
-rw-r--r--drivers/acpi/osl.c196
-rw-r--r--drivers/acpi/parser/Makefile2
-rw-r--r--drivers/acpi/parser/psloop.c775
-rw-r--r--drivers/acpi/parser/psopcode.c28
-rw-r--r--drivers/acpi/parser/psparse.c728
-rw-r--r--drivers/acpi/parser/psutils.c37
-rw-r--r--drivers/acpi/tables/tbconvrt.c8
-rw-r--r--drivers/acpi/tables/tbrsdt.c34
-rw-r--r--drivers/acpi/tables/tbxfroot.c8
-rw-r--r--drivers/acpi/utilities/Makefile2
-rw-r--r--drivers/acpi/utilities/utalloc.c304
-rw-r--r--drivers/acpi/utilities/utcache.c322
-rw-r--r--drivers/acpi/utilities/utdebug.c4
-rw-r--r--drivers/acpi/utilities/utglobal.c38
-rw-r--r--drivers/acpi/utilities/utinit.c2
-rw-r--r--drivers/acpi/utilities/utmisc.c689
-rw-r--r--drivers/acpi/utilities/utmutex.c380
-rw-r--r--drivers/acpi/utilities/utobject.c34
-rw-r--r--drivers/acpi/utilities/utstate.c376
-rw-r--r--drivers/acpi/utilities/utxface.c23
40 files changed, 2469 insertions, 1941 deletions
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c
index f7998306f756..c83d53fd6398 100644
--- a/drivers/acpi/dispatcher/dsmthdat.c
+++ b/drivers/acpi/dispatcher/dsmthdat.c
@@ -633,22 +633,11 @@ acpi_ds_store_object_to_local (
633 */ 633 */
634 if (opcode == AML_ARG_OP) { 634 if (opcode == AML_ARG_OP) {
635 /* 635 /*
636 * Make sure that the object is the correct type. This may be
637 * overkill, butit is here because references were NS nodes in
638 * the past. Now they are operand objects of type Reference.
639 */
640 if (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) != ACPI_DESC_TYPE_OPERAND) {
641 ACPI_REPORT_ERROR ((
642 "Invalid descriptor type while storing to method arg: [%s]\n",
643 acpi_ut_get_descriptor_name (current_obj_desc)));
644 return_ACPI_STATUS (AE_AML_INTERNAL);
645 }
646
647 /*
648 * If we have a valid reference object that came from ref_of(), 636 * If we have a valid reference object that came from ref_of(),
649 * do the indirect store 637 * do the indirect store
650 */ 638 */
651 if ((current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && 639 if ((ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) == ACPI_DESC_TYPE_OPERAND) &&
640 (current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) &&
652 (current_obj_desc->reference.opcode == AML_REF_OF_OP)) { 641 (current_obj_desc->reference.opcode == AML_REF_OF_OP)) {
653 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 642 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
654 "Arg (%p) is an obj_ref(Node), storing in node %p\n", 643 "Arg (%p) is an obj_ref(Node), storing in node %p\n",
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c
index e2e0a855be2c..d2c603f54fd6 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/dispatcher/dswload.c
@@ -50,7 +50,7 @@
50#include <acpi/acnamesp.h> 50#include <acpi/acnamesp.h>
51#include <acpi/acevents.h> 51#include <acpi/acevents.h>
52 52
53#ifdef _ACPI_ASL_COMPILER 53#ifdef ACPI_ASL_COMPILER
54#include <acpi/acdisasm.h> 54#include <acpi/acdisasm.h>
55#endif 55#endif
56 56
@@ -176,7 +176,7 @@ acpi_ds_load1_begin_op (
176 */ 176 */
177 status = acpi_ns_lookup (walk_state->scope_info, path, object_type, 177 status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
178 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node)); 178 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
179#ifdef _ACPI_ASL_COMPILER 179#ifdef ACPI_ASL_COMPILER
180 if (status == AE_NOT_FOUND) { 180 if (status == AE_NOT_FOUND) {
181 /* 181 /*
182 * Table disassembly: 182 * Table disassembly:
@@ -569,7 +569,7 @@ acpi_ds_load2_begin_op (
569 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 569 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
570 walk_state, &(node)); 570 walk_state, &(node));
571 if (ACPI_FAILURE (status)) { 571 if (ACPI_FAILURE (status)) {
572#ifdef _ACPI_ASL_COMPILER 572#ifdef ACPI_ASL_COMPILER
573 if (status == AE_NOT_FOUND) { 573 if (status == AE_NOT_FOUND) {
574 status = AE_OK; 574 status = AE_OK;
575 } 575 }
diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c
index cc45d52225d6..d360d8e89544 100644
--- a/drivers/acpi/dispatcher/dswstate.c
+++ b/drivers/acpi/dispatcher/dswstate.c
@@ -681,7 +681,7 @@ acpi_ds_create_walk_state (
681 ACPI_FUNCTION_TRACE ("ds_create_walk_state"); 681 ACPI_FUNCTION_TRACE ("ds_create_walk_state");
682 682
683 683
684 walk_state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_WALK); 684 walk_state = ACPI_MEM_CALLOCATE (sizeof (struct acpi_walk_state));
685 if (!walk_state) { 685 if (!walk_state) {
686 return_PTR (NULL); 686 return_PTR (NULL);
687 } 687 }
@@ -704,7 +704,7 @@ acpi_ds_create_walk_state (
704 704
705 status = acpi_ds_result_stack_push (walk_state); 705 status = acpi_ds_result_stack_push (walk_state);
706 if (ACPI_FAILURE (status)) { 706 if (ACPI_FAILURE (status)) {
707 acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state); 707 ACPI_MEM_FREE (walk_state);
708 return_PTR (NULL); 708 return_PTR (NULL);
709 } 709 }
710 710
@@ -900,38 +900,11 @@ acpi_ds_delete_walk_state (
900 acpi_ut_delete_generic_state (state); 900 acpi_ut_delete_generic_state (state);
901 } 901 }
902 902
903 acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state); 903 ACPI_MEM_FREE (walk_state);
904 return_VOID; 904 return_VOID;
905} 905}
906 906
907 907
908#ifdef ACPI_ENABLE_OBJECT_CACHE
909/******************************************************************************
910 *
911 * FUNCTION: acpi_ds_delete_walk_state_cache
912 *
913 * PARAMETERS: None
914 *
915 * RETURN: None
916 *
917 * DESCRIPTION: Purge the global state object cache. Used during subsystem
918 * termination.
919 *
920 ******************************************************************************/
921
922void
923acpi_ds_delete_walk_state_cache (
924 void)
925{
926 ACPI_FUNCTION_TRACE ("ds_delete_walk_state_cache");
927
928
929 acpi_ut_delete_generic_cache (ACPI_MEM_LIST_WALK);
930 return_VOID;
931}
932#endif
933
934
935#ifdef ACPI_OBSOLETE_FUNCTIONS 908#ifdef ACPI_OBSOLETE_FUNCTIONS
936/******************************************************************************* 909/*******************************************************************************
937 * 910 *
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index 081120b109ba..ede834df4f69 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -396,6 +396,7 @@ acpi_ev_gpe_detect (
396 struct acpi_gpe_register_info *gpe_register_info; 396 struct acpi_gpe_register_info *gpe_register_info;
397 u32 status_reg; 397 u32 status_reg;
398 u32 enable_reg; 398 u32 enable_reg;
399 u32 flags;
399 acpi_status status; 400 acpi_status status;
400 struct acpi_gpe_block_info *gpe_block; 401 struct acpi_gpe_block_info *gpe_block;
401 acpi_native_uint i; 402 acpi_native_uint i;
@@ -412,7 +413,7 @@ acpi_ev_gpe_detect (
412 413
413 /* Examine all GPE blocks attached to this interrupt level */ 414 /* Examine all GPE blocks attached to this interrupt level */
414 415
415 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_ISR); 416 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
416 gpe_block = gpe_xrupt_list->gpe_block_list_head; 417 gpe_block = gpe_xrupt_list->gpe_block_list_head;
417 while (gpe_block) { 418 while (gpe_block) {
418 /* 419 /*
@@ -476,7 +477,7 @@ acpi_ev_gpe_detect (
476 477
477unlock_and_exit: 478unlock_and_exit:
478 479
479 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_ISR); 480 acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
480 return (int_status); 481 return (int_status);
481} 482}
482 483
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
index ee5419b8f1b1..dfc54692b127 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/events/evgpeblk.c
@@ -138,7 +138,6 @@ acpi_ev_valid_gpe_event (
138 * FUNCTION: acpi_ev_walk_gpe_list 138 * FUNCTION: acpi_ev_walk_gpe_list
139 * 139 *
140 * PARAMETERS: gpe_walk_callback - Routine called for each GPE block 140 * PARAMETERS: gpe_walk_callback - Routine called for each GPE block
141 * Flags - ACPI_NOT_ISR or ACPI_ISR
142 * 141 *
143 * RETURN: Status 142 * RETURN: Status
144 * 143 *
@@ -148,18 +147,18 @@ acpi_ev_valid_gpe_event (
148 147
149acpi_status 148acpi_status
150acpi_ev_walk_gpe_list ( 149acpi_ev_walk_gpe_list (
151 ACPI_GPE_CALLBACK gpe_walk_callback, 150 ACPI_GPE_CALLBACK gpe_walk_callback)
152 u32 flags)
153{ 151{
154 struct acpi_gpe_block_info *gpe_block; 152 struct acpi_gpe_block_info *gpe_block;
155 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 153 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
156 acpi_status status = AE_OK; 154 acpi_status status = AE_OK;
155 u32 flags;
157 156
158 157
159 ACPI_FUNCTION_TRACE ("ev_walk_gpe_list"); 158 ACPI_FUNCTION_TRACE ("ev_walk_gpe_list");
160 159
161 160
162 acpi_os_acquire_lock (acpi_gbl_gpe_lock, flags); 161 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
163 162
164 /* Walk the interrupt level descriptor list */ 163 /* Walk the interrupt level descriptor list */
165 164
@@ -500,6 +499,7 @@ acpi_ev_get_gpe_xrupt_block (
500 struct acpi_gpe_xrupt_info *next_gpe_xrupt; 499 struct acpi_gpe_xrupt_info *next_gpe_xrupt;
501 struct acpi_gpe_xrupt_info *gpe_xrupt; 500 struct acpi_gpe_xrupt_info *gpe_xrupt;
502 acpi_status status; 501 acpi_status status;
502 u32 flags;
503 503
504 504
505 ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block"); 505 ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block");
@@ -527,7 +527,7 @@ acpi_ev_get_gpe_xrupt_block (
527 527
528 /* Install new interrupt descriptor with spin lock */ 528 /* Install new interrupt descriptor with spin lock */
529 529
530 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 530 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
531 if (acpi_gbl_gpe_xrupt_list_head) { 531 if (acpi_gbl_gpe_xrupt_list_head) {
532 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; 532 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
533 while (next_gpe_xrupt->next) { 533 while (next_gpe_xrupt->next) {
@@ -540,7 +540,7 @@ acpi_ev_get_gpe_xrupt_block (
540 else { 540 else {
541 acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; 541 acpi_gbl_gpe_xrupt_list_head = gpe_xrupt;
542 } 542 }
543 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 543 acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
544 544
545 /* Install new interrupt handler if not SCI_INT */ 545 /* Install new interrupt handler if not SCI_INT */
546 546
@@ -577,6 +577,7 @@ acpi_ev_delete_gpe_xrupt (
577 struct acpi_gpe_xrupt_info *gpe_xrupt) 577 struct acpi_gpe_xrupt_info *gpe_xrupt)
578{ 578{
579 acpi_status status; 579 acpi_status status;
580 u32 flags;
580 581
581 582
582 ACPI_FUNCTION_TRACE ("ev_delete_gpe_xrupt"); 583 ACPI_FUNCTION_TRACE ("ev_delete_gpe_xrupt");
@@ -599,7 +600,7 @@ acpi_ev_delete_gpe_xrupt (
599 600
600 /* Unlink the interrupt block with lock */ 601 /* Unlink the interrupt block with lock */
601 602
602 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 603 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
603 if (gpe_xrupt->previous) { 604 if (gpe_xrupt->previous) {
604 gpe_xrupt->previous->next = gpe_xrupt->next; 605 gpe_xrupt->previous->next = gpe_xrupt->next;
605 } 606 }
@@ -607,7 +608,7 @@ acpi_ev_delete_gpe_xrupt (
607 if (gpe_xrupt->next) { 608 if (gpe_xrupt->next) {
608 gpe_xrupt->next->previous = gpe_xrupt->previous; 609 gpe_xrupt->next->previous = gpe_xrupt->previous;
609 } 610 }
610 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 611 acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
611 612
612 /* Free the block */ 613 /* Free the block */
613 614
@@ -637,6 +638,7 @@ acpi_ev_install_gpe_block (
637 struct acpi_gpe_block_info *next_gpe_block; 638 struct acpi_gpe_block_info *next_gpe_block;
638 struct acpi_gpe_xrupt_info *gpe_xrupt_block; 639 struct acpi_gpe_xrupt_info *gpe_xrupt_block;
639 acpi_status status; 640 acpi_status status;
641 u32 flags;
640 642
641 643
642 ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); 644 ACPI_FUNCTION_TRACE ("ev_install_gpe_block");
@@ -655,7 +657,7 @@ acpi_ev_install_gpe_block (
655 657
656 /* Install the new block at the end of the list with lock */ 658 /* Install the new block at the end of the list with lock */
657 659
658 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 660 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
659 if (gpe_xrupt_block->gpe_block_list_head) { 661 if (gpe_xrupt_block->gpe_block_list_head) {
660 next_gpe_block = gpe_xrupt_block->gpe_block_list_head; 662 next_gpe_block = gpe_xrupt_block->gpe_block_list_head;
661 while (next_gpe_block->next) { 663 while (next_gpe_block->next) {
@@ -670,7 +672,7 @@ acpi_ev_install_gpe_block (
670 } 672 }
671 673
672 gpe_block->xrupt_block = gpe_xrupt_block; 674 gpe_block->xrupt_block = gpe_xrupt_block;
673 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 675 acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
674 676
675unlock_and_exit: 677unlock_and_exit:
676 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 678 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
@@ -695,6 +697,7 @@ acpi_ev_delete_gpe_block (
695 struct acpi_gpe_block_info *gpe_block) 697 struct acpi_gpe_block_info *gpe_block)
696{ 698{
697 acpi_status status; 699 acpi_status status;
700 u32 flags;
698 701
699 702
700 ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); 703 ACPI_FUNCTION_TRACE ("ev_install_gpe_block");
@@ -720,7 +723,7 @@ acpi_ev_delete_gpe_block (
720 else { 723 else {
721 /* Remove the block on this interrupt with lock */ 724 /* Remove the block on this interrupt with lock */
722 725
723 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 726 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
724 if (gpe_block->previous) { 727 if (gpe_block->previous) {
725 gpe_block->previous->next = gpe_block->next; 728 gpe_block->previous->next = gpe_block->next;
726 } 729 }
@@ -731,7 +734,7 @@ acpi_ev_delete_gpe_block (
731 if (gpe_block->next) { 734 if (gpe_block->next) {
732 gpe_block->next->previous = gpe_block->previous; 735 gpe_block->next->previous = gpe_block->previous;
733 } 736 }
734 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 737 acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
735 } 738 }
736 739
737 /* Free the gpe_block */ 740 /* Free the gpe_block */
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c
index 659e90956112..38d7ab8aef3a 100644
--- a/drivers/acpi/events/evmisc.c
+++ b/drivers/acpi/events/evmisc.c
@@ -589,7 +589,7 @@ acpi_ev_terminate (
589 589
590 /* Disable all GPEs in all GPE blocks */ 590 /* Disable all GPEs in all GPE blocks */
591 591
592 status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block, ACPI_NOT_ISR); 592 status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block);
593 593
594 /* Remove SCI handler */ 594 /* Remove SCI handler */
595 595
@@ -602,7 +602,7 @@ acpi_ev_terminate (
602 602
603 /* Deallocate all handler objects installed within GPE info structs */ 603 /* Deallocate all handler objects installed within GPE info structs */
604 604
605 status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers, ACPI_NOT_ISR); 605 status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers);
606 606
607 /* Return to original mode if necessary */ 607 /* Return to original mode if necessary */
608 608
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c
index 4092d47f6758..4c1c25e316a8 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/events/evxface.c
@@ -591,6 +591,7 @@ acpi_install_gpe_handler (
591 struct acpi_gpe_event_info *gpe_event_info; 591 struct acpi_gpe_event_info *gpe_event_info;
592 struct acpi_handler_info *handler; 592 struct acpi_handler_info *handler;
593 acpi_status status; 593 acpi_status status;
594 u32 flags;
594 595
595 596
596 ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler"); 597 ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler");
@@ -643,7 +644,7 @@ acpi_install_gpe_handler (
643 644
644 /* Install the handler */ 645 /* Install the handler */
645 646
646 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 647 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
647 gpe_event_info->dispatch.handler = handler; 648 gpe_event_info->dispatch.handler = handler;
648 649
649 /* Setup up dispatch flags to indicate handler (vs. method) */ 650 /* Setup up dispatch flags to indicate handler (vs. method) */
@@ -651,7 +652,7 @@ acpi_install_gpe_handler (
651 gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ 652 gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */
652 gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER); 653 gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER);
653 654
654 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 655 acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
655 656
656 657
657unlock_and_exit: 658unlock_and_exit:
@@ -685,6 +686,7 @@ acpi_remove_gpe_handler (
685 struct acpi_gpe_event_info *gpe_event_info; 686 struct acpi_gpe_event_info *gpe_event_info;
686 struct acpi_handler_info *handler; 687 struct acpi_handler_info *handler;
687 acpi_status status; 688 acpi_status status;
689 u32 flags;
688 690
689 691
690 ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler"); 692 ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler");
@@ -741,7 +743,7 @@ acpi_remove_gpe_handler (
741 743
742 /* Remove the handler */ 744 /* Remove the handler */
743 745
744 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 746 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
745 handler = gpe_event_info->dispatch.handler; 747 handler = gpe_event_info->dispatch.handler;
746 748
747 /* Restore Method node (if any), set dispatch flags */ 749 /* Restore Method node (if any), set dispatch flags */
@@ -751,7 +753,7 @@ acpi_remove_gpe_handler (
751 if (handler->method_node) { 753 if (handler->method_node) {
752 gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD; 754 gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD;
753 } 755 }
754 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 756 acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
755 757
756 /* Now we can free the handler object */ 758 /* Now we can free the handler object */
757 759
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
index 97856c48bd74..21331625e66e 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/executer/exconvrt.c
@@ -367,7 +367,7 @@ acpi_ex_convert_to_ascii (
367 367
368 /* hex_length: 2 ascii hex chars per data byte */ 368 /* hex_length: 2 ascii hex chars per data byte */
369 369
370 hex_length = ACPI_MUL_2 (data_width); 370 hex_length = (acpi_native_uint) ACPI_MUL_2 (data_width);
371 for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) { 371 for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) {
372 /* Get one hex digit, most significant digits first */ 372 /* Get one hex digit, most significant digits first */
373 373
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index ae6cad85e015..7007abb6051e 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -80,6 +80,16 @@ acpi_ex_out_address (
80 acpi_physical_address value); 80 acpi_physical_address value);
81#endif /* ACPI_FUTURE_USAGE */ 81#endif /* ACPI_FUTURE_USAGE */
82 82
83static void
84acpi_ex_dump_reference (
85 union acpi_operand_object *obj_desc);
86
87static void
88acpi_ex_dump_package (
89 union acpi_operand_object *obj_desc,
90 u32 level,
91 u32 index);
92
83 93
84/******************************************************************************* 94/*******************************************************************************
85 * 95 *
@@ -508,7 +518,7 @@ acpi_ex_out_integer (
508 char *title, 518 char *title,
509 u32 value) 519 u32 value)
510{ 520{
511 acpi_os_printf ("%20s : %X\n", title, value); 521 acpi_os_printf ("%20s : %.2X\n", title, value);
512} 522}
513 523
514static void 524static void
@@ -565,9 +575,144 @@ acpi_ex_dump_node (
565 575
566/******************************************************************************* 576/*******************************************************************************
567 * 577 *
578 * FUNCTION: acpi_ex_dump_reference
579 *
580 * PARAMETERS: Object - Descriptor to dump
581 *
582 * DESCRIPTION: Dumps a reference object
583 *
584 ******************************************************************************/
585
586static void
587acpi_ex_dump_reference (
588 union acpi_operand_object *obj_desc)
589{
590 struct acpi_buffer ret_buf;
591 acpi_status status;
592
593
594 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) {
595 acpi_os_printf ("Named Object %p ", obj_desc->reference.node);
596 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
597 status = acpi_ns_handle_to_pathname (obj_desc->reference.node, &ret_buf);
598 if (ACPI_FAILURE (status)) {
599 acpi_os_printf ("Could not convert name to pathname\n");
600 }
601 else {
602 acpi_os_printf ("%s\n", ret_buf.pointer);
603 ACPI_MEM_FREE (ret_buf.pointer);
604 }
605 }
606 else if (obj_desc->reference.object) {
607 acpi_os_printf ("\nReferenced Object: %p\n", obj_desc->reference.object);
608 }
609}
610
611
612/*******************************************************************************
613 *
614 * FUNCTION: acpi_ex_dump_package
615 *
616 * PARAMETERS: Object - Descriptor to dump
617 * Level - Indentation Level
618 * Index - Package index for this object
619 *
620 * DESCRIPTION: Dumps the elements of the package
621 *
622 ******************************************************************************/
623
624static void
625acpi_ex_dump_package (
626 union acpi_operand_object *obj_desc,
627 u32 level,
628 u32 index)
629{
630 u32 i;
631
632
633 /* Indentation and index output */
634
635 if (level > 0) {
636 for (i = 0; i < level; i++) {
637 acpi_os_printf (" ");
638 }
639
640 acpi_os_printf ("[%.2d] ", index);
641 }
642
643 acpi_os_printf ("%p ", obj_desc);
644
645 /* Null package elements are allowed */
646
647 if (!obj_desc) {
648 acpi_os_printf ("[Null Object]\n");
649 return;
650 }
651
652 /* Packages may only contain a few object types */
653
654 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
655 case ACPI_TYPE_INTEGER:
656
657 acpi_os_printf ("[Integer] = %8.8X%8.8X\n",
658 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
659 break;
660
661
662 case ACPI_TYPE_STRING:
663
664 acpi_os_printf ("[String] Value: ");
665 for (i = 0; i < obj_desc->string.length; i++) {
666 acpi_os_printf ("%c", obj_desc->string.pointer[i]);
667 }
668 acpi_os_printf ("\n");
669 break;
670
671
672 case ACPI_TYPE_BUFFER:
673
674 acpi_os_printf ("[Buffer] Length %.2X = ", obj_desc->buffer.length);
675 if (obj_desc->buffer.length) {
676 acpi_ut_dump_buffer ((u8 *) obj_desc->buffer.pointer,
677 obj_desc->buffer.length, DB_DWORD_DISPLAY, _COMPONENT);
678 }
679 else {
680 acpi_os_printf ("\n");
681 }
682 break;
683
684
685 case ACPI_TYPE_PACKAGE:
686
687 acpi_os_printf ("[Package] Contains %d Elements: \n",
688 obj_desc->package.count);
689
690 for (i = 0; i < obj_desc->package.count; i++) {
691 acpi_ex_dump_package (obj_desc->package.elements[i], level+1, i);
692 }
693 break;
694
695
696 case ACPI_TYPE_LOCAL_REFERENCE:
697
698 acpi_os_printf ("[Object Reference] ");
699 acpi_ex_dump_reference (obj_desc);
700 break;
701
702
703 default:
704
705 acpi_os_printf ("[Unknown Type] %X\n", ACPI_GET_OBJECT_TYPE (obj_desc));
706 break;
707 }
708}
709
710
711/*******************************************************************************
712 *
568 * FUNCTION: acpi_ex_dump_object_descriptor 713 * FUNCTION: acpi_ex_dump_object_descriptor
569 * 714 *
570 * PARAMETERS: *Object - Descriptor to dump 715 * PARAMETERS: Object - Descriptor to dump
571 * Flags - Force display if TRUE 716 * Flags - Force display if TRUE
572 * 717 *
573 * DESCRIPTION: Dumps the members of the object descriptor given. 718 * DESCRIPTION: Dumps the members of the object descriptor given.
@@ -579,9 +724,6 @@ acpi_ex_dump_object_descriptor (
579 union acpi_operand_object *obj_desc, 724 union acpi_operand_object *obj_desc,
580 u32 flags) 725 u32 flags)
581{ 726{
582 u32 i;
583
584
585 ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor"); 727 ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor");
586 728
587 729
@@ -648,22 +790,13 @@ acpi_ex_dump_object_descriptor (
648 case ACPI_TYPE_PACKAGE: 790 case ACPI_TYPE_PACKAGE:
649 791
650 acpi_ex_out_integer ("Flags", obj_desc->package.flags); 792 acpi_ex_out_integer ("Flags", obj_desc->package.flags);
651 acpi_ex_out_integer ("Count", obj_desc->package.count); 793 acpi_ex_out_integer ("Elements", obj_desc->package.count);
652 acpi_ex_out_pointer ("Elements", obj_desc->package.elements); 794 acpi_ex_out_pointer ("Element List", obj_desc->package.elements);
653 795
654 /* Dump the package contents */ 796 /* Dump the package contents */
655 797
656 if (obj_desc->package.count > 0) { 798 acpi_os_printf ("\nPackage Contents:\n");
657 acpi_os_printf ("\nPackage Contents:\n"); 799 acpi_ex_dump_package (obj_desc, 0, 0);
658 for (i = 0; i < obj_desc->package.count; i++) {
659 acpi_os_printf ("[%.3d] %p", i, obj_desc->package.elements[i]);
660 if (obj_desc->package.elements[i]) {
661 acpi_os_printf (" %s",
662 acpi_ut_get_object_type_name (obj_desc->package.elements[i]));
663 }
664 acpi_os_printf ("\n");
665 }
666 }
667 break; 800 break;
668 801
669 802
@@ -790,10 +923,7 @@ acpi_ex_dump_object_descriptor (
790 acpi_ex_out_pointer ("Node", obj_desc->reference.node); 923 acpi_ex_out_pointer ("Node", obj_desc->reference.node);
791 acpi_ex_out_pointer ("Where", obj_desc->reference.where); 924 acpi_ex_out_pointer ("Where", obj_desc->reference.where);
792 925
793 if (obj_desc->reference.object) { 926 acpi_ex_dump_reference (obj_desc);
794 acpi_os_printf ("\nReferenced Object:\n");
795 acpi_ex_dump_object_descriptor (obj_desc->reference.object, flags);
796 }
797 break; 927 break;
798 928
799 929
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
index 022f281345b8..237ef28c8132 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/executer/exmisc.c
@@ -302,7 +302,7 @@ acpi_ex_do_concatenate (
302 /* Result of two Integers is a Buffer */ 302 /* Result of two Integers is a Buffer */
303 /* Need enough buffer space for two integers */ 303 /* Need enough buffer space for two integers */
304 304
305 return_desc = acpi_ut_create_buffer_object ( 305 return_desc = acpi_ut_create_buffer_object ((acpi_size)
306 ACPI_MUL_2 (acpi_gbl_integer_byte_width)); 306 ACPI_MUL_2 (acpi_gbl_integer_byte_width));
307 if (!return_desc) { 307 if (!return_desc) {
308 status = AE_NO_MEMORY; 308 status = AE_NO_MEMORY;
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c
index ffc61ddeb659..131f49acb1df 100644
--- a/drivers/acpi/executer/exoparg1.c
+++ b/drivers/acpi/executer/exoparg1.c
@@ -113,8 +113,9 @@ acpi_ex_opcode_0A_0T_1R (
113 status = AE_NO_MEMORY; 113 status = AE_NO_MEMORY;
114 goto cleanup; 114 goto cleanup;
115 } 115 }
116 116#if ACPI_MACHINE_WIDTH != 16
117 return_desc->integer.value = acpi_os_get_timer (); 117 return_desc->integer.value = acpi_os_get_timer ();
118#endif
118 break; 119 break;
119 120
120 default: /* Unknown opcode */ 121 default: /* Unknown opcode */
diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c
index 23b068adbf58..197890f443b5 100644
--- a/drivers/acpi/executer/exoparg3.c
+++ b/drivers/acpi/executer/exoparg3.c
@@ -160,7 +160,7 @@ acpi_ex_opcode_3A_1T_1R (
160{ 160{
161 union acpi_operand_object **operand = &walk_state->operands[0]; 161 union acpi_operand_object **operand = &walk_state->operands[0];
162 union acpi_operand_object *return_desc = NULL; 162 union acpi_operand_object *return_desc = NULL;
163 char *buffer; 163 char *buffer = NULL;
164 acpi_status status = AE_OK; 164 acpi_status status = AE_OK;
165 acpi_integer index; 165 acpi_integer index;
166 acpi_size length; 166 acpi_size length;
@@ -193,34 +193,63 @@ acpi_ex_opcode_3A_1T_1R (
193 * If the index is beyond the length of the String/Buffer, or if the 193 * If the index is beyond the length of the String/Buffer, or if the
194 * requested length is zero, return a zero-length String/Buffer 194 * requested length is zero, return a zero-length String/Buffer
195 */ 195 */
196 if ((index < operand[0]->string.length) && 196 if (index >= operand[0]->string.length) {
197 (length > 0)) { 197 length = 0;
198 /* Truncate request if larger than the actual String/Buffer */ 198 }
199 199
200 if ((index + length) > 200 /* Truncate request if larger than the actual String/Buffer */
201 operand[0]->string.length) { 201
202 length = (acpi_size) operand[0]->string.length - 202 else if ((index + length) > operand[0]->string.length) {
203 (acpi_size) index; 203 length = (acpi_size) operand[0]->string.length -
204 } 204 (acpi_size) index;
205 }
205 206
206 /* Allocate a new buffer for the String/Buffer */ 207 /* Strings always have a sub-pointer, not so for buffers */
208
209 switch (ACPI_GET_OBJECT_TYPE (operand[0])) {
210 case ACPI_TYPE_STRING:
211
212 /* Always allocate a new buffer for the String */
207 213
208 buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1); 214 buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1);
209 if (!buffer) { 215 if (!buffer) {
210 status = AE_NO_MEMORY; 216 status = AE_NO_MEMORY;
211 goto cleanup; 217 goto cleanup;
212 } 218 }
219 break;
220
221 case ACPI_TYPE_BUFFER:
222
223 /* If the requested length is zero, don't allocate a buffer */
224
225 if (length > 0) {
226 /* Allocate a new buffer for the Buffer */
227
228 buffer = ACPI_MEM_CALLOCATE (length);
229 if (!buffer) {
230 status = AE_NO_MEMORY;
231 goto cleanup;
232 }
233 }
234 break;
213 235
236 default: /* Should not happen */
237
238 status = AE_AML_OPERAND_TYPE;
239 goto cleanup;
240 }
241
242 if (length > 0) {
214 /* Copy the portion requested */ 243 /* Copy the portion requested */
215 244
216 ACPI_MEMCPY (buffer, operand[0]->string.pointer + index, 245 ACPI_MEMCPY (buffer, operand[0]->string.pointer + index,
217 length); 246 length);
247 }
218 248
219 /* Set the length of the new String/Buffer */ 249 /* Set the length of the new String/Buffer */
220 250
221 return_desc->string.pointer = buffer; 251 return_desc->string.pointer = buffer;
222 return_desc->string.length = (u32) length; 252 return_desc->string.length = (u32) length;
223 }
224 253
225 /* Mark buffer initialized */ 254 /* Mark buffer initialized */
226 255
@@ -244,13 +273,13 @@ cleanup:
244 273
245 /* Delete return object on error */ 274 /* Delete return object on error */
246 275
247 if (ACPI_FAILURE (status)) { 276 if (ACPI_FAILURE (status) || walk_state->result_obj) {
248 acpi_ut_remove_reference (return_desc); 277 acpi_ut_remove_reference (return_desc);
249 } 278 }
250 279
251 /* Set the return object and exit */ 280 /* Set the return object and exit */
252 281
253 if (!walk_state->result_obj) { 282 else {
254 walk_state->result_obj = return_desc; 283 walk_state->result_obj = return_desc;
255 } 284 }
256 return_ACPI_STATUS (status); 285 return_ACPI_STATUS (status);
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c
index 763ffeea8503..59dbfeaa54c0 100644
--- a/drivers/acpi/executer/exstore.c
+++ b/drivers/acpi/executer/exstore.c
@@ -147,7 +147,7 @@ acpi_ex_do_debug_object (
147 147
148 case ACPI_TYPE_BUFFER: 148 case ACPI_TYPE_BUFFER:
149 149
150 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]", 150 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n",
151 (u32) source_desc->buffer.length)); 151 (u32) source_desc->buffer.length));
152 ACPI_DUMP_BUFFER (source_desc->buffer.pointer, 152 ACPI_DUMP_BUFFER (source_desc->buffer.pointer,
153 (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32); 153 (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32);
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c
index 5c7ec0c04177..d00b0dcba96a 100644
--- a/drivers/acpi/executer/exutils.c
+++ b/drivers/acpi/executer/exutils.c
@@ -369,7 +369,7 @@ acpi_ex_eisa_id_to_string (
369 * 369 *
370 * RETURN: None, string 370 * RETURN: None, string
371 * 371 *
372 * DESCRIPTOIN: Convert a number to string representation. Assumes string 372 * DESCRIPTION: Convert a number to string representation. Assumes string
373 * buffer is large enough to hold the string. 373 * buffer is large enough to hold the string.
374 * 374 *
375 ******************************************************************************/ 375 ******************************************************************************/
diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c
index 8daeabb2fc7a..3536bbb990c3 100644
--- a/drivers/acpi/hardware/hwgpe.c
+++ b/drivers/acpi/hardware/hwgpe.c
@@ -374,7 +374,7 @@ acpi_hw_enable_wakeup_gpe_block (
374 * 374 *
375 * FUNCTION: acpi_hw_disable_all_gpes 375 * FUNCTION: acpi_hw_disable_all_gpes
376 * 376 *
377 * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR 377 * PARAMETERS: None
378 * 378 *
379 * RETURN: Status 379 * RETURN: Status
380 * 380 *
@@ -384,7 +384,7 @@ acpi_hw_enable_wakeup_gpe_block (
384 384
385acpi_status 385acpi_status
386acpi_hw_disable_all_gpes ( 386acpi_hw_disable_all_gpes (
387 u32 flags) 387 void)
388{ 388{
389 acpi_status status; 389 acpi_status status;
390 390
@@ -392,8 +392,8 @@ acpi_hw_disable_all_gpes (
392 ACPI_FUNCTION_TRACE ("hw_disable_all_gpes"); 392 ACPI_FUNCTION_TRACE ("hw_disable_all_gpes");
393 393
394 394
395 status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block, flags); 395 status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block);
396 status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block, flags); 396 status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block);
397 return_ACPI_STATUS (status); 397 return_ACPI_STATUS (status);
398} 398}
399 399
@@ -402,7 +402,7 @@ acpi_hw_disable_all_gpes (
402 * 402 *
403 * FUNCTION: acpi_hw_enable_all_runtime_gpes 403 * FUNCTION: acpi_hw_enable_all_runtime_gpes
404 * 404 *
405 * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR 405 * PARAMETERS: None
406 * 406 *
407 * RETURN: Status 407 * RETURN: Status
408 * 408 *
@@ -412,7 +412,7 @@ acpi_hw_disable_all_gpes (
412 412
413acpi_status 413acpi_status
414acpi_hw_enable_all_runtime_gpes ( 414acpi_hw_enable_all_runtime_gpes (
415 u32 flags) 415 void)
416{ 416{
417 acpi_status status; 417 acpi_status status;
418 418
@@ -420,7 +420,7 @@ acpi_hw_enable_all_runtime_gpes (
420 ACPI_FUNCTION_TRACE ("hw_enable_all_runtime_gpes"); 420 ACPI_FUNCTION_TRACE ("hw_enable_all_runtime_gpes");
421 421
422 422
423 status = acpi_ev_walk_gpe_list (acpi_hw_enable_runtime_gpe_block, flags); 423 status = acpi_ev_walk_gpe_list (acpi_hw_enable_runtime_gpe_block);
424 return_ACPI_STATUS (status); 424 return_ACPI_STATUS (status);
425} 425}
426 426
@@ -429,7 +429,7 @@ acpi_hw_enable_all_runtime_gpes (
429 * 429 *
430 * FUNCTION: acpi_hw_enable_all_wakeup_gpes 430 * FUNCTION: acpi_hw_enable_all_wakeup_gpes
431 * 431 *
432 * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR 432 * PARAMETERS: None
433 * 433 *
434 * RETURN: Status 434 * RETURN: Status
435 * 435 *
@@ -439,7 +439,7 @@ acpi_hw_enable_all_runtime_gpes (
439 439
440acpi_status 440acpi_status
441acpi_hw_enable_all_wakeup_gpes ( 441acpi_hw_enable_all_wakeup_gpes (
442 u32 flags) 442 void)
443{ 443{
444 acpi_status status; 444 acpi_status status;
445 445
@@ -447,7 +447,7 @@ acpi_hw_enable_all_wakeup_gpes (
447 ACPI_FUNCTION_TRACE ("hw_enable_all_wakeup_gpes"); 447 ACPI_FUNCTION_TRACE ("hw_enable_all_wakeup_gpes");
448 448
449 449
450 status = acpi_ev_walk_gpe_list (acpi_hw_enable_wakeup_gpe_block, flags); 450 status = acpi_ev_walk_gpe_list (acpi_hw_enable_wakeup_gpe_block);
451 return_ACPI_STATUS (status); 451 return_ACPI_STATUS (status);
452} 452}
453 453
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c
index 6d9e4eb84836..04a058565d8d 100644
--- a/drivers/acpi/hardware/hwregs.c
+++ b/drivers/acpi/hardware/hwregs.c
@@ -106,7 +106,7 @@ acpi_hw_clear_acpi_status (
106 106
107 /* Clear the GPE Bits in all GPE registers in all GPE blocks */ 107 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
108 108
109 status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block, ACPI_ISR); 109 status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block);
110 110
111unlock_and_exit: 111unlock_and_exit:
112 if (flags & ACPI_MTX_LOCK) { 112 if (flags & ACPI_MTX_LOCK) {
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
index 415d342aeab5..cedee0c43b5f 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/hardware/hwsleep.c
@@ -274,13 +274,13 @@ acpi_enter_sleep_state (
274 * 1) Disable/Clear all GPEs 274 * 1) Disable/Clear all GPEs
275 * 2) Enable all wakeup GPEs 275 * 2) Enable all wakeup GPEs
276 */ 276 */
277 status = acpi_hw_disable_all_gpes (ACPI_ISR); 277 status = acpi_hw_disable_all_gpes ();
278 if (ACPI_FAILURE (status)) { 278 if (ACPI_FAILURE (status)) {
279 return_ACPI_STATUS (status); 279 return_ACPI_STATUS (status);
280 } 280 }
281 acpi_gbl_system_awake_and_running = FALSE; 281 acpi_gbl_system_awake_and_running = FALSE;
282 282
283 status = acpi_hw_enable_all_wakeup_gpes (ACPI_ISR); 283 status = acpi_hw_enable_all_wakeup_gpes ();
284 if (ACPI_FAILURE (status)) { 284 if (ACPI_FAILURE (status)) {
285 return_ACPI_STATUS (status); 285 return_ACPI_STATUS (status);
286 } 286 }
@@ -424,13 +424,13 @@ acpi_enter_sleep_state_s4bios (
424 * 1) Disable/Clear all GPEs 424 * 1) Disable/Clear all GPEs
425 * 2) Enable all wakeup GPEs 425 * 2) Enable all wakeup GPEs
426 */ 426 */
427 status = acpi_hw_disable_all_gpes (ACPI_ISR); 427 status = acpi_hw_disable_all_gpes ();
428 if (ACPI_FAILURE (status)) { 428 if (ACPI_FAILURE (status)) {
429 return_ACPI_STATUS (status); 429 return_ACPI_STATUS (status);
430 } 430 }
431 acpi_gbl_system_awake_and_running = FALSE; 431 acpi_gbl_system_awake_and_running = FALSE;
432 432
433 status = acpi_hw_enable_all_wakeup_gpes (ACPI_ISR); 433 status = acpi_hw_enable_all_wakeup_gpes ();
434 if (ACPI_FAILURE (status)) { 434 if (ACPI_FAILURE (status)) {
435 return_ACPI_STATUS (status); 435 return_ACPI_STATUS (status);
436 } 436 }
@@ -557,13 +557,13 @@ acpi_leave_sleep_state (
557 * 1) Disable/Clear all GPEs 557 * 1) Disable/Clear all GPEs
558 * 2) Enable all runtime GPEs 558 * 2) Enable all runtime GPEs
559 */ 559 */
560 status = acpi_hw_disable_all_gpes (ACPI_NOT_ISR); 560 status = acpi_hw_disable_all_gpes ();
561 if (ACPI_FAILURE (status)) { 561 if (ACPI_FAILURE (status)) {
562 return_ACPI_STATUS (status); 562 return_ACPI_STATUS (status);
563 } 563 }
564 acpi_gbl_system_awake_and_running = TRUE; 564 acpi_gbl_system_awake_and_running = TRUE;
565 565
566 status = acpi_hw_enable_all_runtime_gpes (ACPI_NOT_ISR); 566 status = acpi_hw_enable_all_runtime_gpes ();
567 if (ACPI_FAILURE (status)) { 567 if (ACPI_FAILURE (status)) {
568 return_ACPI_STATUS (status); 568 return_ACPI_STATUS (status);
569 } 569 }
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
index ece7a9dedd5c..9df0a64ba9e9 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/namespace/nsaccess.c
@@ -159,7 +159,7 @@ acpi_ns_root_initialize (
159 obj_desc->method.param_count = (u8) ACPI_TO_INTEGER (val); 159 obj_desc->method.param_count = (u8) ACPI_TO_INTEGER (val);
160 obj_desc->common.flags |= AOPOBJ_DATA_VALID; 160 obj_desc->common.flags |= AOPOBJ_DATA_VALID;
161 161
162#if defined (_ACPI_ASL_COMPILER) || defined (_ACPI_DUMP_App) 162#if defined (ACPI_ASL_COMPILER) || defined (ACPI_DUMP_App)
163 163
164 /* 164 /*
165 * i_aSL Compiler cheats by putting parameter count 165 * i_aSL Compiler cheats by putting parameter count
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
index 5653a19d7172..3f94b0806ecf 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/namespace/nsalloc.c
@@ -83,7 +83,7 @@ acpi_ns_create_node (
83 return_PTR (NULL); 83 return_PTR (NULL);
84 } 84 }
85 85
86 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_allocated++); 86 ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_allocated++);
87 87
88 node->name.integer = name; 88 node->name.integer = name;
89 node->reference_count = 1; 89 node->reference_count = 1;
@@ -151,7 +151,7 @@ acpi_ns_delete_node (
151 } 151 }
152 } 152 }
153 153
154 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); 154 ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_freed++);
155 155
156 /* 156 /*
157 * Detach an object if there is one then delete the node 157 * Detach an object if there is one then delete the node
@@ -362,7 +362,7 @@ acpi_ns_delete_children (
362 362
363 /* Now we can free this child object */ 363 /* Now we can free this child object */
364 364
365 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); 365 ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_freed++);
366 366
367 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", 367 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n",
368 child_node, acpi_gbl_current_node_count)); 368 child_node, acpi_gbl_current_node_count));
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
index 05af95322a62..c9f35dd7a431 100644
--- a/drivers/acpi/namespace/nsdump.c
+++ b/drivers/acpi/namespace/nsdump.c
@@ -208,33 +208,37 @@ acpi_ns_dump_one_object (
208 return (AE_OK); 208 return (AE_OK);
209 } 209 }
210 210
211 /* Indent the object according to the level */ 211 if (!(info->display_type & ACPI_DISPLAY_SHORT)) {
212 /* Indent the object according to the level */
212 213
213 acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " "); 214 acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " ");
214 215
215 /* Check the node type and name */ 216 /* Check the node type and name */
216 217
217 if (type > ACPI_TYPE_LOCAL_MAX) { 218 if (type > ACPI_TYPE_LOCAL_MAX) {
218 ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type)); 219 ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type));
219 } 220 }
221
222 if (!acpi_ut_valid_acpi_name (this_node->name.integer)) {
223 ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n",
224 this_node->name.integer));
225 }
220 226
221 if (!acpi_ut_valid_acpi_name (this_node->name.integer)) { 227 acpi_os_printf ("%4.4s", acpi_ut_get_node_name (this_node));
222 ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n",
223 this_node->name.integer));
224 } 228 }
225 229
226 /* 230 /*
227 * Now we can print out the pertinent information 231 * Now we can print out the pertinent information
228 */ 232 */
229 acpi_os_printf ("%4.4s %-12s %p ", 233 acpi_os_printf (" %-12s %p ",
230 acpi_ut_get_node_name (this_node), acpi_ut_get_type_name (type), this_node); 234 acpi_ut_get_type_name (type), this_node);
231 235
232 dbg_level = acpi_dbg_level; 236 dbg_level = acpi_dbg_level;
233 acpi_dbg_level = 0; 237 acpi_dbg_level = 0;
234 obj_desc = acpi_ns_get_attached_object (this_node); 238 obj_desc = acpi_ns_get_attached_object (this_node);
235 acpi_dbg_level = dbg_level; 239 acpi_dbg_level = dbg_level;
236 240
237 switch (info->display_type) { 241 switch (info->display_type & ACPI_DISPLAY_MASK) {
238 case ACPI_DISPLAY_SUMMARY: 242 case ACPI_DISPLAY_SUMMARY:
239 243
240 if (!obj_desc) { 244 if (!obj_desc) {
@@ -646,7 +650,7 @@ acpi_ns_dump_entry (
646} 650}
647 651
648 652
649#ifdef _ACPI_ASL_COMPILER 653#ifdef ACPI_ASL_COMPILER
650/******************************************************************************* 654/*******************************************************************************
651 * 655 *
652 * FUNCTION: acpi_ns_dump_tables 656 * FUNCTION: acpi_ns_dump_tables
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index bdd9f37f8101..56e7cedba919 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -778,54 +778,6 @@ acpi_os_delete_lock (
778 return_VOID; 778 return_VOID;
779} 779}
780 780
781/*
782 * Acquire a spinlock.
783 *
784 * handle is a pointer to the spinlock_t.
785 * flags is *not* the result of save_flags - it is an ACPI-specific flag variable
786 * that indicates whether we are at interrupt level.
787 */
788void
789acpi_os_acquire_lock (
790 acpi_handle handle,
791 u32 flags)
792{
793 ACPI_FUNCTION_TRACE ("os_acquire_lock");
794
795 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Acquiring spinlock[%p] from %s level\n", handle,
796 ((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt")));
797
798 if (flags & ACPI_NOT_ISR)
799 ACPI_DISABLE_IRQS();
800
801 spin_lock((spinlock_t *)handle);
802
803 return_VOID;
804}
805
806
807/*
808 * Release a spinlock. See above.
809 */
810void
811acpi_os_release_lock (
812 acpi_handle handle,
813 u32 flags)
814{
815 ACPI_FUNCTION_TRACE ("os_release_lock");
816
817 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Releasing spinlock[%p] from %s level\n", handle,
818 ((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt")));
819
820 spin_unlock((spinlock_t *)handle);
821
822 if (flags & ACPI_NOT_ISR)
823 ACPI_ENABLE_IRQS();
824
825 return_VOID;
826}
827
828
829acpi_status 781acpi_status
830acpi_os_create_semaphore( 782acpi_os_create_semaphore(
831 u32 max_units, 783 u32 max_units,
@@ -1172,3 +1124,151 @@ unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER;
1172 1124
1173 1125
1174EXPORT_SYMBOL(max_cstate); 1126EXPORT_SYMBOL(max_cstate);
1127
1128/*
1129 * Acquire a spinlock.
1130 *
1131 * handle is a pointer to the spinlock_t.
1132 * flags is *not* the result of save_flags - it is an ACPI-specific flag variable
1133 * that indicates whether we are at interrupt level.
1134 */
1135
1136unsigned long
1137acpi_os_acquire_lock (
1138 acpi_handle handle)
1139{
1140 unsigned long flags;
1141 spin_lock_irqsave((spinlock_t *)handle, flags);
1142 return flags;
1143}
1144
1145/*
1146 * Release a spinlock. See above.
1147 */
1148
1149void
1150acpi_os_release_lock (
1151 acpi_handle handle,
1152 unsigned long flags)
1153{
1154 spin_unlock_irqrestore((spinlock_t *)handle, flags);
1155}
1156
1157
1158#ifndef ACPI_USE_LOCAL_CACHE
1159
1160/*******************************************************************************
1161 *
1162 * FUNCTION: acpi_os_create_cache
1163 *
1164 * PARAMETERS: CacheName - Ascii name for the cache
1165 * ObjectSize - Size of each cached object
1166 * MaxDepth - Maximum depth of the cache (in objects)
1167 * ReturnCache - Where the new cache object is returned
1168 *
1169 * RETURN: Status
1170 *
1171 * DESCRIPTION: Create a cache object
1172 *
1173 ******************************************************************************/
1174
1175acpi_status
1176acpi_os_create_cache (
1177 char *name,
1178 u16 size,
1179 u16 depth,
1180 acpi_cache_t **cache)
1181{
1182 *cache = kmem_cache_create (name, size, 0, 0, NULL, NULL);
1183 return AE_OK;
1184}
1185
1186/*******************************************************************************
1187 *
1188 * FUNCTION: acpi_os_purge_cache
1189 *
1190 * PARAMETERS: Cache - Handle to cache object
1191 *
1192 * RETURN: Status
1193 *
1194 * DESCRIPTION: Free all objects within the requested cache.
1195 *
1196 ******************************************************************************/
1197
1198acpi_status
1199acpi_os_purge_cache (
1200 acpi_cache_t *cache)
1201{
1202 (void) kmem_cache_shrink(cache);
1203 return (AE_OK);
1204}
1205
1206/*******************************************************************************
1207 *
1208 * FUNCTION: acpi_os_delete_cache
1209 *
1210 * PARAMETERS: Cache - Handle to cache object
1211 *
1212 * RETURN: Status
1213 *
1214 * DESCRIPTION: Free all objects within the requested cache and delete the
1215 * cache object.
1216 *
1217 ******************************************************************************/
1218
1219acpi_status
1220acpi_os_delete_cache (
1221 acpi_cache_t *cache)
1222{
1223 (void)kmem_cache_destroy(cache);
1224 return (AE_OK);
1225}
1226
1227/*******************************************************************************
1228 *
1229 * FUNCTION: acpi_os_release_object
1230 *
1231 * PARAMETERS: Cache - Handle to cache object
1232 * Object - The object to be released
1233 *
1234 * RETURN: None
1235 *
1236 * DESCRIPTION: Release an object to the specified cache. If cache is full,
1237 * the object is deleted.
1238 *
1239 ******************************************************************************/
1240
1241acpi_status
1242acpi_os_release_object (
1243 acpi_cache_t *cache,
1244 void *object)
1245{
1246 kmem_cache_free(cache, object);
1247 return (AE_OK);
1248}
1249
1250/*******************************************************************************
1251 *
1252 * FUNCTION: acpi_os_acquire_object
1253 *
1254 * PARAMETERS: Cache - Handle to cache object
1255 * ReturnObject - Where the object is returned
1256 *
1257 * RETURN: Status
1258 *
1259 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
1260 * the object is allocated.
1261 *
1262 ******************************************************************************/
1263
1264void *
1265acpi_os_acquire_object (
1266 acpi_cache_t *cache)
1267{
1268 void *object = kmem_cache_alloc(cache, GFP_KERNEL);
1269 WARN_ON(!object);
1270 return object;
1271}
1272
1273#endif
1274
diff --git a/drivers/acpi/parser/Makefile b/drivers/acpi/parser/Makefile
index bbdd286c660d..db24ee09cf11 100644
--- a/drivers/acpi/parser/Makefile
+++ b/drivers/acpi/parser/Makefile
@@ -2,7 +2,7 @@
2# Makefile for all Linux ACPI interpreter subdirectories 2# Makefile for all Linux ACPI interpreter subdirectories
3# 3#
4 4
5obj-y := psargs.o psparse.o pstree.o pswalk.o \ 5obj-y := psargs.o psparse.o psloop.o pstree.o pswalk.o \
6 psopcode.o psscope.o psutils.o psxface.o 6 psopcode.o psscope.o psutils.o psxface.o
7 7
8EXTRA_CFLAGS += $(ACPI_CFLAGS) 8EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c
new file mode 100644
index 000000000000..decb2e9a049d
--- /dev/null
+++ b/drivers/acpi/parser/psloop.c
@@ -0,0 +1,775 @@
1/******************************************************************************
2 *
3 * Module Name: psloop - Main AML parse loop
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45/*
46 * Parse the AML and build an operation tree as most interpreters,
47 * like Perl, do. Parsing is done by hand rather than with a YACC
48 * generated parser to tightly constrain stack and dynamic memory
49 * usage. At the same time, parsing is kept flexible and the code
50 * fairly compact by parsing based on a list of AML opcode
51 * templates in aml_op_info[]
52 */
53
54#include <acpi/acpi.h>
55#include <acpi/acparser.h>
56#include <acpi/acdispat.h>
57#include <acpi/amlcode.h>
58#include <acpi/acnamesp.h>
59#include <acpi/acinterp.h>
60
61#define _COMPONENT ACPI_PARSER
62 ACPI_MODULE_NAME ("psloop")
63
64static u32 acpi_gbl_depth = 0;
65
66
67/*******************************************************************************
68 *
69 * FUNCTION: acpi_ps_parse_loop
70 *
71 * PARAMETERS: walk_state - Current state
72 *
73 * RETURN: Status
74 *
75 * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
76 * a tree of ops.
77 *
78 ******************************************************************************/
79
80acpi_status
81acpi_ps_parse_loop (
82 struct acpi_walk_state *walk_state)
83{
84 acpi_status status = AE_OK;
85 acpi_status status2;
86 union acpi_parse_object *op = NULL; /* current op */
87 union acpi_parse_object *arg = NULL;
88 union acpi_parse_object *pre_op = NULL;
89 struct acpi_parse_state *parser_state;
90 u8 *aml_op_start = NULL;
91
92
93 ACPI_FUNCTION_TRACE_PTR ("ps_parse_loop", walk_state);
94
95 if (walk_state->descending_callback == NULL) {
96 return_ACPI_STATUS (AE_BAD_PARAMETER);
97 }
98
99 parser_state = &walk_state->parser_state;
100 walk_state->arg_types = 0;
101
102#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
103
104 if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
105 /* We are restarting a preempted control method */
106
107 if (acpi_ps_has_completed_scope (parser_state)) {
108 /*
109 * We must check if a predicate to an IF or WHILE statement
110 * was just completed
111 */
112 if ((parser_state->scope->parse_scope.op) &&
113 ((parser_state->scope->parse_scope.op->common.aml_opcode == AML_IF_OP) ||
114 (parser_state->scope->parse_scope.op->common.aml_opcode == AML_WHILE_OP)) &&
115 (walk_state->control_state) &&
116 (walk_state->control_state->common.state ==
117 ACPI_CONTROL_PREDICATE_EXECUTING)) {
118 /*
119 * A predicate was just completed, get the value of the
120 * predicate and branch based on that value
121 */
122 walk_state->op = NULL;
123 status = acpi_ds_get_predicate_value (walk_state, ACPI_TO_POINTER (TRUE));
124 if (ACPI_FAILURE (status) &&
125 ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) {
126 if (status == AE_AML_NO_RETURN_VALUE) {
127 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
128 "Invoked method did not return a value, %s\n",
129 acpi_format_exception (status)));
130
131 }
132 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
133 "get_predicate Failed, %s\n",
134 acpi_format_exception (status)));
135 return_ACPI_STATUS (status);
136 }
137
138 status = acpi_ps_next_parse_state (walk_state, op, status);
139 }
140
141 acpi_ps_pop_scope (parser_state, &op,
142 &walk_state->arg_types, &walk_state->arg_count);
143 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op));
144 }
145 else if (walk_state->prev_op) {
146 /* We were in the middle of an op */
147
148 op = walk_state->prev_op;
149 walk_state->arg_types = walk_state->prev_arg_types;
150 }
151 }
152#endif
153
154 /* Iterative parsing loop, while there is more AML to process: */
155
156 while ((parser_state->aml < parser_state->aml_end) || (op)) {
157 aml_op_start = parser_state->aml;
158 if (!op) {
159 /* Get the next opcode from the AML stream */
160
161 walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml,
162 parser_state->aml_start);
163 walk_state->opcode = acpi_ps_peek_opcode (parser_state);
164
165 /*
166 * First cut to determine what we have found:
167 * 1) A valid AML opcode
168 * 2) A name string
169 * 3) An unknown/invalid opcode
170 */
171 walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode);
172 switch (walk_state->op_info->class) {
173 case AML_CLASS_ASCII:
174 case AML_CLASS_PREFIX:
175 /*
176 * Starts with a valid prefix or ASCII char, this is a name
177 * string. Convert the bare name string to a namepath.
178 */
179 walk_state->opcode = AML_INT_NAMEPATH_OP;
180 walk_state->arg_types = ARGP_NAMESTRING;
181 break;
182
183 case AML_CLASS_UNKNOWN:
184
185 /* The opcode is unrecognized. Just skip unknown opcodes */
186
187 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
188 "Found unknown opcode %X at AML address %p offset %X, ignoring\n",
189 walk_state->opcode, parser_state->aml, walk_state->aml_offset));
190
191 ACPI_DUMP_BUFFER (parser_state->aml, 128);
192
193 /* Assume one-byte bad opcode */
194
195 parser_state->aml++;
196 continue;
197
198 default:
199
200 /* Found opcode info, this is a normal opcode */
201
202 parser_state->aml += acpi_ps_get_opcode_size (walk_state->opcode);
203 walk_state->arg_types = walk_state->op_info->parse_args;
204 break;
205 }
206
207 /* Create Op structure and append to parent's argument list */
208
209 if (walk_state->op_info->flags & AML_NAMED) {
210 /* Allocate a new pre_op if necessary */
211
212 if (!pre_op) {
213 pre_op = acpi_ps_alloc_op (walk_state->opcode);
214 if (!pre_op) {
215 status = AE_NO_MEMORY;
216 goto close_this_op;
217 }
218 }
219
220 pre_op->common.value.arg = NULL;
221 pre_op->common.aml_opcode = walk_state->opcode;
222
223 /*
224 * Get and append arguments until we find the node that contains
225 * the name (the type ARGP_NAME).
226 */
227 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) &&
228 (GET_CURRENT_ARG_TYPE (walk_state->arg_types) != ARGP_NAME)) {
229 status = acpi_ps_get_next_arg (walk_state, parser_state,
230 GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg);
231 if (ACPI_FAILURE (status)) {
232 goto close_this_op;
233 }
234
235 acpi_ps_append_arg (pre_op, arg);
236 INCREMENT_ARG_LIST (walk_state->arg_types);
237 }
238
239 /*
240 * Make sure that we found a NAME and didn't run out of
241 * arguments
242 */
243 if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) {
244 status = AE_AML_NO_OPERAND;
245 goto close_this_op;
246 }
247
248 /* We know that this arg is a name, move to next arg */
249
250 INCREMENT_ARG_LIST (walk_state->arg_types);
251
252 /*
253 * Find the object. This will either insert the object into
254 * the namespace or simply look it up
255 */
256 walk_state->op = NULL;
257
258 status = walk_state->descending_callback (walk_state, &op);
259 if (ACPI_FAILURE (status)) {
260 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
261 "During name lookup/catalog, %s\n",
262 acpi_format_exception (status)));
263 goto close_this_op;
264 }
265
266 if (!op) {
267 continue;
268 }
269
270 status = acpi_ps_next_parse_state (walk_state, op, status);
271 if (status == AE_CTRL_PENDING) {
272 status = AE_OK;
273 goto close_this_op;
274 }
275
276 if (ACPI_FAILURE (status)) {
277 goto close_this_op;
278 }
279
280 acpi_ps_append_arg (op, pre_op->common.value.arg);
281 acpi_gbl_depth++;
282
283 if (op->common.aml_opcode == AML_REGION_OP) {
284 /*
285 * Defer final parsing of an operation_region body,
286 * because we don't have enough info in the first pass
287 * to parse it correctly (i.e., there may be method
288 * calls within the term_arg elements of the body.)
289 *
290 * However, we must continue parsing because
291 * the opregion is not a standalone package --
292 * we don't know where the end is at this point.
293 *
294 * (Length is unknown until parse of the body complete)
295 */
296 op->named.data = aml_op_start;
297 op->named.length = 0;
298 }
299 }
300 else {
301 /* Not a named opcode, just allocate Op and append to parent */
302
303 walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode);
304 op = acpi_ps_alloc_op (walk_state->opcode);
305 if (!op) {
306 status = AE_NO_MEMORY;
307 goto close_this_op;
308 }
309
310 if (walk_state->op_info->flags & AML_CREATE) {
311 /*
312 * Backup to beginning of create_xXXfield declaration
313 * body_length is unknown until we parse the body
314 */
315 op->named.data = aml_op_start;
316 op->named.length = 0;
317 }
318
319 acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op);
320
321 if ((walk_state->descending_callback != NULL)) {
322 /*
323 * Find the object. This will either insert the object into
324 * the namespace or simply look it up
325 */
326 walk_state->op = op;
327
328 status = walk_state->descending_callback (walk_state, &op);
329 status = acpi_ps_next_parse_state (walk_state, op, status);
330 if (status == AE_CTRL_PENDING) {
331 status = AE_OK;
332 goto close_this_op;
333 }
334
335 if (ACPI_FAILURE (status)) {
336 goto close_this_op;
337 }
338 }
339 }
340
341 op->common.aml_offset = walk_state->aml_offset;
342
343 if (walk_state->op_info) {
344 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
345 "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n",
346 (u32) op->common.aml_opcode, walk_state->op_info->name,
347 op, parser_state->aml, op->common.aml_offset));
348 }
349 }
350
351
352 /*
353 * Start arg_count at zero because we don't know if there are
354 * any args yet
355 */
356 walk_state->arg_count = 0;
357
358 /* Are there any arguments that must be processed? */
359
360 if (walk_state->arg_types) {
361 /* Get arguments */
362
363 switch (op->common.aml_opcode) {
364 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
365 case AML_WORD_OP: /* AML_WORDDATA_ARG */
366 case AML_DWORD_OP: /* AML_DWORDATA_ARG */
367 case AML_QWORD_OP: /* AML_QWORDATA_ARG */
368 case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
369
370 /* Fill in constant or string argument directly */
371
372 acpi_ps_get_next_simple_arg (parser_state,
373 GET_CURRENT_ARG_TYPE (walk_state->arg_types), op);
374 break;
375
376 case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
377
378 status = acpi_ps_get_next_namepath (walk_state, parser_state, op, 1);
379 if (ACPI_FAILURE (status)) {
380 goto close_this_op;
381 }
382
383 walk_state->arg_types = 0;
384 break;
385
386 default:
387 /*
388 * Op is not a constant or string, append each argument
389 * to the Op
390 */
391 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) &&
392 !walk_state->arg_count) {
393 walk_state->aml_offset = (u32)
394 ACPI_PTR_DIFF (parser_state->aml, parser_state->aml_start);
395
396 status = acpi_ps_get_next_arg (walk_state, parser_state,
397 GET_CURRENT_ARG_TYPE (walk_state->arg_types),
398 &arg);
399 if (ACPI_FAILURE (status)) {
400 goto close_this_op;
401 }
402
403 if (arg) {
404 arg->common.aml_offset = walk_state->aml_offset;
405 acpi_ps_append_arg (op, arg);
406 }
407 INCREMENT_ARG_LIST (walk_state->arg_types);
408 }
409
410 /* Special processing for certain opcodes */
411
412 if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) &&
413 ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) {
414 /*
415 * We want to skip If/Else/While constructs during Pass1
416 * because we want to actually conditionally execute the
417 * code during Pass2.
418 *
419 * Except for disassembly, where we always want to
420 * walk the If/Else/While packages
421 */
422 switch (op->common.aml_opcode) {
423 case AML_IF_OP:
424 case AML_ELSE_OP:
425 case AML_WHILE_OP:
426
427 /* Skip body of if/else/while in pass 1 */
428
429 parser_state->aml = parser_state->pkg_end;
430 walk_state->arg_count = 0;
431 break;
432
433 default:
434 break;
435 }
436 }
437
438 switch (op->common.aml_opcode) {
439 case AML_METHOD_OP:
440
441 /*
442 * Skip parsing of control method
443 * because we don't have enough info in the first pass
444 * to parse it correctly.
445 *
446 * Save the length and address of the body
447 */
448 op->named.data = parser_state->aml;
449 op->named.length = (u32) (parser_state->pkg_end -
450 parser_state->aml);
451
452 /* Skip body of method */
453
454 parser_state->aml = parser_state->pkg_end;
455 walk_state->arg_count = 0;
456 break;
457
458 case AML_BUFFER_OP:
459 case AML_PACKAGE_OP:
460 case AML_VAR_PACKAGE_OP:
461
462 if ((op->common.parent) &&
463 (op->common.parent->common.aml_opcode == AML_NAME_OP) &&
464 (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2)) {
465 /*
466 * Skip parsing of Buffers and Packages
467 * because we don't have enough info in the first pass
468 * to parse them correctly.
469 */
470 op->named.data = aml_op_start;
471 op->named.length = (u32) (parser_state->pkg_end -
472 aml_op_start);
473
474 /* Skip body */
475
476 parser_state->aml = parser_state->pkg_end;
477 walk_state->arg_count = 0;
478 }
479 break;
480
481 case AML_WHILE_OP:
482
483 if (walk_state->control_state) {
484 walk_state->control_state->control.package_end =
485 parser_state->pkg_end;
486 }
487 break;
488
489 default:
490
491 /* No action for all other opcodes */
492 break;
493 }
494 break;
495 }
496 }
497
498 /* Check for arguments that need to be processed */
499
500 if (walk_state->arg_count) {
501 /*
502 * There are arguments (complex ones), push Op and
503 * prepare for argument
504 */
505 status = acpi_ps_push_scope (parser_state, op,
506 walk_state->arg_types, walk_state->arg_count);
507 if (ACPI_FAILURE (status)) {
508 goto close_this_op;
509 }
510 op = NULL;
511 continue;
512 }
513
514 /*
515 * All arguments have been processed -- Op is complete,
516 * prepare for next
517 */
518 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
519 if (walk_state->op_info->flags & AML_NAMED) {
520 if (acpi_gbl_depth) {
521 acpi_gbl_depth--;
522 }
523
524 if (op->common.aml_opcode == AML_REGION_OP) {
525 /*
526 * Skip parsing of control method or opregion body,
527 * because we don't have enough info in the first pass
528 * to parse them correctly.
529 *
530 * Completed parsing an op_region declaration, we now
531 * know the length.
532 */
533 op->named.length = (u32) (parser_state->aml - op->named.data);
534 }
535 }
536
537 if (walk_state->op_info->flags & AML_CREATE) {
538 /*
539 * Backup to beginning of create_xXXfield declaration (1 for
540 * Opcode)
541 *
542 * body_length is unknown until we parse the body
543 */
544 op->named.length = (u32) (parser_state->aml - op->named.data);
545 }
546
547 /* This op complete, notify the dispatcher */
548
549 if (walk_state->ascending_callback != NULL) {
550 walk_state->op = op;
551 walk_state->opcode = op->common.aml_opcode;
552
553 status = walk_state->ascending_callback (walk_state);
554 status = acpi_ps_next_parse_state (walk_state, op, status);
555 if (status == AE_CTRL_PENDING) {
556 status = AE_OK;
557 goto close_this_op;
558 }
559 }
560
561
562close_this_op:
563 /*
564 * Finished one argument of the containing scope
565 */
566 parser_state->scope->parse_scope.arg_count--;
567
568 /* Finished with pre_op */
569
570 if (pre_op) {
571 acpi_ps_free_op (pre_op);
572 pre_op = NULL;
573 }
574
575 /* Close this Op (will result in parse subtree deletion) */
576
577 status2 = acpi_ps_complete_this_op (walk_state, op);
578 if (ACPI_FAILURE (status2)) {
579 return_ACPI_STATUS (status2);
580 }
581 op = NULL;
582
583 switch (status) {
584 case AE_OK:
585 break;
586
587
588 case AE_CTRL_TRANSFER:
589
590 /* We are about to transfer to a called method. */
591
592 walk_state->prev_op = op;
593 walk_state->prev_arg_types = walk_state->arg_types;
594 return_ACPI_STATUS (status);
595
596
597 case AE_CTRL_END:
598
599 acpi_ps_pop_scope (parser_state, &op,
600 &walk_state->arg_types, &walk_state->arg_count);
601
602 if (op) {
603 walk_state->op = op;
604 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
605 walk_state->opcode = op->common.aml_opcode;
606
607 status = walk_state->ascending_callback (walk_state);
608 status = acpi_ps_next_parse_state (walk_state, op, status);
609
610 status2 = acpi_ps_complete_this_op (walk_state, op);
611 if (ACPI_FAILURE (status2)) {
612 return_ACPI_STATUS (status2);
613 }
614 op = NULL;
615 }
616 status = AE_OK;
617 break;
618
619
620 case AE_CTRL_BREAK:
621 case AE_CTRL_CONTINUE:
622
623 /* Pop off scopes until we find the While */
624
625 while (!op || (op->common.aml_opcode != AML_WHILE_OP)) {
626 acpi_ps_pop_scope (parser_state, &op,
627 &walk_state->arg_types, &walk_state->arg_count);
628 }
629
630 /* Close this iteration of the While loop */
631
632 walk_state->op = op;
633 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
634 walk_state->opcode = op->common.aml_opcode;
635
636 status = walk_state->ascending_callback (walk_state);
637 status = acpi_ps_next_parse_state (walk_state, op, status);
638
639 status2 = acpi_ps_complete_this_op (walk_state, op);
640 if (ACPI_FAILURE (status2)) {
641 return_ACPI_STATUS (status2);
642 }
643 op = NULL;
644
645 status = AE_OK;
646 break;
647
648
649 case AE_CTRL_TERMINATE:
650
651 status = AE_OK;
652
653 /* Clean up */
654 do {
655 if (op) {
656 status2 = acpi_ps_complete_this_op (walk_state, op);
657 if (ACPI_FAILURE (status2)) {
658 return_ACPI_STATUS (status2);
659 }
660 }
661 acpi_ps_pop_scope (parser_state, &op,
662 &walk_state->arg_types, &walk_state->arg_count);
663
664 } while (op);
665
666 return_ACPI_STATUS (status);
667
668
669 default: /* All other non-AE_OK status */
670
671 do {
672 if (op) {
673 status2 = acpi_ps_complete_this_op (walk_state, op);
674 if (ACPI_FAILURE (status2)) {
675 return_ACPI_STATUS (status2);
676 }
677 }
678 acpi_ps_pop_scope (parser_state, &op,
679 &walk_state->arg_types, &walk_state->arg_count);
680
681 } while (op);
682
683
684 /*
685 * TBD: Cleanup parse ops on error
686 */
687#if 0
688 if (op == NULL) {
689 acpi_ps_pop_scope (parser_state, &op,
690 &walk_state->arg_types, &walk_state->arg_count);
691 }
692#endif
693 walk_state->prev_op = op;
694 walk_state->prev_arg_types = walk_state->arg_types;
695 return_ACPI_STATUS (status);
696 }
697
698 /* This scope complete? */
699
700 if (acpi_ps_has_completed_scope (parser_state)) {
701 acpi_ps_pop_scope (parser_state, &op,
702 &walk_state->arg_types, &walk_state->arg_count);
703 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op));
704 }
705 else {
706 op = NULL;
707 }
708
709 } /* while parser_state->Aml */
710
711
712 /*
713 * Complete the last Op (if not completed), and clear the scope stack.
714 * It is easily possible to end an AML "package" with an unbounded number
715 * of open scopes (such as when several ASL blocks are closed with
716 * sequential closing braces). We want to terminate each one cleanly.
717 */
718 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", op));
719 do {
720 if (op) {
721 if (walk_state->ascending_callback != NULL) {
722 walk_state->op = op;
723 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
724 walk_state->opcode = op->common.aml_opcode;
725
726 status = walk_state->ascending_callback (walk_state);
727 status = acpi_ps_next_parse_state (walk_state, op, status);
728 if (status == AE_CTRL_PENDING) {
729 status = AE_OK;
730 goto close_this_op;
731 }
732
733 if (status == AE_CTRL_TERMINATE) {
734 status = AE_OK;
735
736 /* Clean up */
737 do {
738 if (op) {
739 status2 = acpi_ps_complete_this_op (walk_state, op);
740 if (ACPI_FAILURE (status2)) {
741 return_ACPI_STATUS (status2);
742 }
743 }
744
745 acpi_ps_pop_scope (parser_state, &op,
746 &walk_state->arg_types, &walk_state->arg_count);
747
748 } while (op);
749
750 return_ACPI_STATUS (status);
751 }
752
753 else if (ACPI_FAILURE (status)) {
754 /* First error is most important */
755
756 (void) acpi_ps_complete_this_op (walk_state, op);
757 return_ACPI_STATUS (status);
758 }
759 }
760
761 status2 = acpi_ps_complete_this_op (walk_state, op);
762 if (ACPI_FAILURE (status2)) {
763 return_ACPI_STATUS (status2);
764 }
765 }
766
767 acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types,
768 &walk_state->arg_count);
769
770 } while (op);
771
772 return_ACPI_STATUS (status);
773}
774
775
diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c
index 95ef5e8947a8..6f7594a516d2 100644
--- a/drivers/acpi/parser/psopcode.c
+++ b/drivers/acpi/parser/psopcode.c
@@ -428,33 +428,23 @@ acpi_ps_get_opcode_info (
428 /* 428 /*
429 * Detect normal 8-bit opcode or extended 16-bit opcode 429 * Detect normal 8-bit opcode or extended 16-bit opcode
430 */ 430 */
431 switch ((u8) (opcode >> 8)) { 431 if (!(opcode & 0xFF00)) {
432 case 0:
433
434 /* Simple (8-bit) opcode: 0-255, can't index beyond table */ 432 /* Simple (8-bit) opcode: 0-255, can't index beyond table */
435 433
436 return (&acpi_gbl_aml_op_info [acpi_gbl_short_op_index [(u8) opcode]]); 434 return (&acpi_gbl_aml_op_info [acpi_gbl_short_op_index [(u8) opcode]]);
435 }
437 436
438 case AML_EXTOP: 437 if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) &&
439 438 (((u8) opcode) <= MAX_EXTENDED_OPCODE)) {
440 /* Extended (16-bit, prefix+opcode) opcode */ 439 /* Valid extended (16-bit) opcode */
441
442 if (((u8) opcode) <= MAX_EXTENDED_OPCODE) {
443 return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]);
444 }
445
446 /* Else fall through to error case below */
447 /*lint -fallthrough */
448
449 default:
450 440
451 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 441 return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]);
452 "Unknown AML opcode [%4.4X]\n", opcode));
453 break;
454 } 442 }
455 443
444 /* Unknown AML opcode */
456 445
457 /* Default is "unknown opcode" */ 446 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
447 "Unknown AML opcode [%4.4X]\n", opcode));
458 448
459 return (&acpi_gbl_aml_op_info [_UNK]); 449 return (&acpi_gbl_aml_op_info [_UNK]);
460} 450}
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
index bdbe0d99486f..16b84a3d0436 100644
--- a/drivers/acpi/parser/psparse.c
+++ b/drivers/acpi/parser/psparse.c
@@ -62,26 +62,6 @@
62 ACPI_MODULE_NAME ("psparse") 62 ACPI_MODULE_NAME ("psparse")
63 63
64 64
65static u32 acpi_gbl_depth = 0;
66
67/* Local prototypes */
68
69static acpi_status
70acpi_ps_complete_this_op (
71 struct acpi_walk_state *walk_state,
72 union acpi_parse_object *op);
73
74static acpi_status
75acpi_ps_next_parse_state (
76 struct acpi_walk_state *walk_state,
77 union acpi_parse_object *op,
78 acpi_status callback_status);
79
80static acpi_status
81acpi_ps_parse_loop (
82 struct acpi_walk_state *walk_state);
83
84
85/******************************************************************************* 65/*******************************************************************************
86 * 66 *
87 * FUNCTION: acpi_ps_get_opcode_size 67 * FUNCTION: acpi_ps_get_opcode_size
@@ -134,8 +114,8 @@ acpi_ps_peek_opcode (
134 aml = parser_state->aml; 114 aml = parser_state->aml;
135 opcode = (u16) ACPI_GET8 (aml); 115 opcode = (u16) ACPI_GET8 (aml);
136 116
137 if (opcode == AML_EXTOP) { 117 if (opcode == AML_EXTENDED_OP_PREFIX) {
138 /* Extended opcode */ 118 /* Extended opcode, get the second opcode byte */
139 119
140 aml++; 120 aml++;
141 opcode = (u16) ((opcode << 8) | ACPI_GET8 (aml)); 121 opcode = (u16) ((opcode << 8) | ACPI_GET8 (aml));
@@ -158,7 +138,7 @@ acpi_ps_peek_opcode (
158 * 138 *
159 ******************************************************************************/ 139 ******************************************************************************/
160 140
161static acpi_status 141acpi_status
162acpi_ps_complete_this_op ( 142acpi_ps_complete_this_op (
163 struct acpi_walk_state *walk_state, 143 struct acpi_walk_state *walk_state,
164 union acpi_parse_object *op) 144 union acpi_parse_object *op)
@@ -331,7 +311,7 @@ allocate_error:
331 * 311 *
332 ******************************************************************************/ 312 ******************************************************************************/
333 313
334static acpi_status 314acpi_status
335acpi_ps_next_parse_state ( 315acpi_ps_next_parse_state (
336 struct acpi_walk_state *walk_state, 316 struct acpi_walk_state *walk_state,
337 union acpi_parse_object *op, 317 union acpi_parse_object *op,
@@ -441,706 +421,6 @@ acpi_ps_next_parse_state (
441 421
442/******************************************************************************* 422/*******************************************************************************
443 * 423 *
444 * FUNCTION: acpi_ps_parse_loop
445 *
446 * PARAMETERS: walk_state - Current state
447 *
448 * RETURN: Status
449 *
450 * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
451 * a tree of ops.
452 *
453 ******************************************************************************/
454
455static acpi_status
456acpi_ps_parse_loop (
457 struct acpi_walk_state *walk_state)
458{
459 acpi_status status = AE_OK;
460 acpi_status status2;
461 union acpi_parse_object *op = NULL; /* current op */
462 union acpi_parse_object *arg = NULL;
463 union acpi_parse_object *pre_op = NULL;
464 struct acpi_parse_state *parser_state;
465 u8 *aml_op_start = NULL;
466
467
468 ACPI_FUNCTION_TRACE_PTR ("ps_parse_loop", walk_state);
469
470 if (walk_state->descending_callback == NULL) {
471 return_ACPI_STATUS (AE_BAD_PARAMETER);
472 }
473
474 parser_state = &walk_state->parser_state;
475 walk_state->arg_types = 0;
476
477#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
478
479 if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
480 /* We are restarting a preempted control method */
481
482 if (acpi_ps_has_completed_scope (parser_state)) {
483 /*
484 * We must check if a predicate to an IF or WHILE statement
485 * was just completed
486 */
487 if ((parser_state->scope->parse_scope.op) &&
488 ((parser_state->scope->parse_scope.op->common.aml_opcode == AML_IF_OP) ||
489 (parser_state->scope->parse_scope.op->common.aml_opcode == AML_WHILE_OP)) &&
490 (walk_state->control_state) &&
491 (walk_state->control_state->common.state ==
492 ACPI_CONTROL_PREDICATE_EXECUTING)) {
493 /*
494 * A predicate was just completed, get the value of the
495 * predicate and branch based on that value
496 */
497 walk_state->op = NULL;
498 status = acpi_ds_get_predicate_value (walk_state, ACPI_TO_POINTER (TRUE));
499 if (ACPI_FAILURE (status) &&
500 ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) {
501 if (status == AE_AML_NO_RETURN_VALUE) {
502 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
503 "Invoked method did not return a value, %s\n",
504 acpi_format_exception (status)));
505
506 }
507 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
508 "get_predicate Failed, %s\n",
509 acpi_format_exception (status)));
510 return_ACPI_STATUS (status);
511 }
512
513 status = acpi_ps_next_parse_state (walk_state, op, status);
514 }
515
516 acpi_ps_pop_scope (parser_state, &op,
517 &walk_state->arg_types, &walk_state->arg_count);
518 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op));
519 }
520 else if (walk_state->prev_op) {
521 /* We were in the middle of an op */
522
523 op = walk_state->prev_op;
524 walk_state->arg_types = walk_state->prev_arg_types;
525 }
526 }
527#endif
528
529 /* Iterative parsing loop, while there is more AML to process: */
530
531 while ((parser_state->aml < parser_state->aml_end) || (op)) {
532 aml_op_start = parser_state->aml;
533 if (!op) {
534 /* Get the next opcode from the AML stream */
535
536 walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml,
537 parser_state->aml_start);
538 walk_state->opcode = acpi_ps_peek_opcode (parser_state);
539
540 /*
541 * First cut to determine what we have found:
542 * 1) A valid AML opcode
543 * 2) A name string
544 * 3) An unknown/invalid opcode
545 */
546 walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode);
547 switch (walk_state->op_info->class) {
548 case AML_CLASS_ASCII:
549 case AML_CLASS_PREFIX:
550 /*
551 * Starts with a valid prefix or ASCII char, this is a name
552 * string. Convert the bare name string to a namepath.
553 */
554 walk_state->opcode = AML_INT_NAMEPATH_OP;
555 walk_state->arg_types = ARGP_NAMESTRING;
556 break;
557
558 case AML_CLASS_UNKNOWN:
559
560 /* The opcode is unrecognized. Just skip unknown opcodes */
561
562 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
563 "Found unknown opcode %X at AML address %p offset %X, ignoring\n",
564 walk_state->opcode, parser_state->aml, walk_state->aml_offset));
565
566 ACPI_DUMP_BUFFER (parser_state->aml, 128);
567
568 /* Assume one-byte bad opcode */
569
570 parser_state->aml++;
571 continue;
572
573 default:
574
575 /* Found opcode info, this is a normal opcode */
576
577 parser_state->aml += acpi_ps_get_opcode_size (walk_state->opcode);
578 walk_state->arg_types = walk_state->op_info->parse_args;
579 break;
580 }
581
582 /* Create Op structure and append to parent's argument list */
583
584 if (walk_state->op_info->flags & AML_NAMED) {
585 /* Allocate a new pre_op if necessary */
586
587 if (!pre_op) {
588 pre_op = acpi_ps_alloc_op (walk_state->opcode);
589 if (!pre_op) {
590 status = AE_NO_MEMORY;
591 goto close_this_op;
592 }
593 }
594
595 pre_op->common.value.arg = NULL;
596 pre_op->common.aml_opcode = walk_state->opcode;
597
598 /*
599 * Get and append arguments until we find the node that contains
600 * the name (the type ARGP_NAME).
601 */
602 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) &&
603 (GET_CURRENT_ARG_TYPE (walk_state->arg_types) != ARGP_NAME)) {
604 status = acpi_ps_get_next_arg (walk_state, parser_state,
605 GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg);
606 if (ACPI_FAILURE (status)) {
607 goto close_this_op;
608 }
609
610 acpi_ps_append_arg (pre_op, arg);
611 INCREMENT_ARG_LIST (walk_state->arg_types);
612 }
613
614 /*
615 * Make sure that we found a NAME and didn't run out of
616 * arguments
617 */
618 if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) {
619 status = AE_AML_NO_OPERAND;
620 goto close_this_op;
621 }
622
623 /* We know that this arg is a name, move to next arg */
624
625 INCREMENT_ARG_LIST (walk_state->arg_types);
626
627 /*
628 * Find the object. This will either insert the object into
629 * the namespace or simply look it up
630 */
631 walk_state->op = NULL;
632
633 status = walk_state->descending_callback (walk_state, &op);
634 if (ACPI_FAILURE (status)) {
635 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
636 "During name lookup/catalog, %s\n",
637 acpi_format_exception (status)));
638 goto close_this_op;
639 }
640
641 if (!op) {
642 continue;
643 }
644
645 status = acpi_ps_next_parse_state (walk_state, op, status);
646 if (status == AE_CTRL_PENDING) {
647 status = AE_OK;
648 goto close_this_op;
649 }
650
651 if (ACPI_FAILURE (status)) {
652 goto close_this_op;
653 }
654
655 acpi_ps_append_arg (op, pre_op->common.value.arg);
656 acpi_gbl_depth++;
657
658 if (op->common.aml_opcode == AML_REGION_OP) {
659 /*
660 * Defer final parsing of an operation_region body,
661 * because we don't have enough info in the first pass
662 * to parse it correctly (i.e., there may be method
663 * calls within the term_arg elements of the body.)
664 *
665 * However, we must continue parsing because
666 * the opregion is not a standalone package --
667 * we don't know where the end is at this point.
668 *
669 * (Length is unknown until parse of the body complete)
670 */
671 op->named.data = aml_op_start;
672 op->named.length = 0;
673 }
674 }
675 else {
676 /* Not a named opcode, just allocate Op and append to parent */
677
678 walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode);
679 op = acpi_ps_alloc_op (walk_state->opcode);
680 if (!op) {
681 status = AE_NO_MEMORY;
682 goto close_this_op;
683 }
684
685 if (walk_state->op_info->flags & AML_CREATE) {
686 /*
687 * Backup to beginning of create_xXXfield declaration
688 * body_length is unknown until we parse the body
689 */
690 op->named.data = aml_op_start;
691 op->named.length = 0;
692 }
693
694 acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op);
695
696 if ((walk_state->descending_callback != NULL)) {
697 /*
698 * Find the object. This will either insert the object into
699 * the namespace or simply look it up
700 */
701 walk_state->op = op;
702
703 status = walk_state->descending_callback (walk_state, &op);
704 status = acpi_ps_next_parse_state (walk_state, op, status);
705 if (status == AE_CTRL_PENDING) {
706 status = AE_OK;
707 goto close_this_op;
708 }
709
710 if (ACPI_FAILURE (status)) {
711 goto close_this_op;
712 }
713 }
714 }
715
716 op->common.aml_offset = walk_state->aml_offset;
717
718 if (walk_state->op_info) {
719 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
720 "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n",
721 (u32) op->common.aml_opcode, walk_state->op_info->name,
722 op, parser_state->aml, op->common.aml_offset));
723 }
724 }
725
726
727 /*
728 * Start arg_count at zero because we don't know if there are
729 * any args yet
730 */
731 walk_state->arg_count = 0;
732
733 /* Are there any arguments that must be processed? */
734
735 if (walk_state->arg_types) {
736 /* Get arguments */
737
738 switch (op->common.aml_opcode) {
739 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
740 case AML_WORD_OP: /* AML_WORDDATA_ARG */
741 case AML_DWORD_OP: /* AML_DWORDATA_ARG */
742 case AML_QWORD_OP: /* AML_QWORDATA_ARG */
743 case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
744
745 /* Fill in constant or string argument directly */
746
747 acpi_ps_get_next_simple_arg (parser_state,
748 GET_CURRENT_ARG_TYPE (walk_state->arg_types), op);
749 break;
750
751 case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
752
753 status = acpi_ps_get_next_namepath (walk_state, parser_state, op, 1);
754 if (ACPI_FAILURE (status)) {
755 goto close_this_op;
756 }
757
758 walk_state->arg_types = 0;
759 break;
760
761 default:
762 /*
763 * Op is not a constant or string, append each argument
764 * to the Op
765 */
766 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) &&
767 !walk_state->arg_count) {
768 walk_state->aml_offset = (u32)
769 ACPI_PTR_DIFF (parser_state->aml, parser_state->aml_start);
770
771 status = acpi_ps_get_next_arg (walk_state, parser_state,
772 GET_CURRENT_ARG_TYPE (walk_state->arg_types),
773 &arg);
774 if (ACPI_FAILURE (status)) {
775 goto close_this_op;
776 }
777
778 if (arg) {
779 arg->common.aml_offset = walk_state->aml_offset;
780 acpi_ps_append_arg (op, arg);
781 }
782 INCREMENT_ARG_LIST (walk_state->arg_types);
783 }
784
785 /* Special processing for certain opcodes */
786
787 if (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) {
788 switch (op->common.aml_opcode) {
789 case AML_IF_OP:
790 case AML_ELSE_OP:
791 case AML_WHILE_OP:
792
793 /* Skip body of if/else/while in pass 1 */
794
795 parser_state->aml = parser_state->pkg_end;
796 walk_state->arg_count = 0;
797 break;
798
799 default:
800 break;
801 }
802 }
803
804 switch (op->common.aml_opcode) {
805 case AML_METHOD_OP:
806
807 /*
808 * Skip parsing of control method
809 * because we don't have enough info in the first pass
810 * to parse it correctly.
811 *
812 * Save the length and address of the body
813 */
814 op->named.data = parser_state->aml;
815 op->named.length = (u32) (parser_state->pkg_end -
816 parser_state->aml);
817
818 /* Skip body of method */
819
820 parser_state->aml = parser_state->pkg_end;
821 walk_state->arg_count = 0;
822 break;
823
824 case AML_BUFFER_OP:
825 case AML_PACKAGE_OP:
826 case AML_VAR_PACKAGE_OP:
827
828 if ((op->common.parent) &&
829 (op->common.parent->common.aml_opcode == AML_NAME_OP) &&
830 (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2)) {
831 /*
832 * Skip parsing of Buffers and Packages
833 * because we don't have enough info in the first pass
834 * to parse them correctly.
835 */
836 op->named.data = aml_op_start;
837 op->named.length = (u32) (parser_state->pkg_end -
838 aml_op_start);
839
840 /* Skip body */
841
842 parser_state->aml = parser_state->pkg_end;
843 walk_state->arg_count = 0;
844 }
845 break;
846
847 case AML_WHILE_OP:
848
849 if (walk_state->control_state) {
850 walk_state->control_state->control.package_end =
851 parser_state->pkg_end;
852 }
853 break;
854
855 default:
856
857 /* No action for all other opcodes */
858 break;
859 }
860 break;
861 }
862 }
863
864 /* Check for arguments that need to be processed */
865
866 if (walk_state->arg_count) {
867 /*
868 * There are arguments (complex ones), push Op and
869 * prepare for argument
870 */
871 status = acpi_ps_push_scope (parser_state, op,
872 walk_state->arg_types, walk_state->arg_count);
873 if (ACPI_FAILURE (status)) {
874 goto close_this_op;
875 }
876 op = NULL;
877 continue;
878 }
879
880 /*
881 * All arguments have been processed -- Op is complete,
882 * prepare for next
883 */
884 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
885 if (walk_state->op_info->flags & AML_NAMED) {
886 if (acpi_gbl_depth) {
887 acpi_gbl_depth--;
888 }
889
890 if (op->common.aml_opcode == AML_REGION_OP) {
891 /*
892 * Skip parsing of control method or opregion body,
893 * because we don't have enough info in the first pass
894 * to parse them correctly.
895 *
896 * Completed parsing an op_region declaration, we now
897 * know the length.
898 */
899 op->named.length = (u32) (parser_state->aml - op->named.data);
900 }
901 }
902
903 if (walk_state->op_info->flags & AML_CREATE) {
904 /*
905 * Backup to beginning of create_xXXfield declaration (1 for
906 * Opcode)
907 *
908 * body_length is unknown until we parse the body
909 */
910 op->named.length = (u32) (parser_state->aml - op->named.data);
911 }
912
913 /* This op complete, notify the dispatcher */
914
915 if (walk_state->ascending_callback != NULL) {
916 walk_state->op = op;
917 walk_state->opcode = op->common.aml_opcode;
918
919 status = walk_state->ascending_callback (walk_state);
920 status = acpi_ps_next_parse_state (walk_state, op, status);
921 if (status == AE_CTRL_PENDING) {
922 status = AE_OK;
923 goto close_this_op;
924 }
925 }
926
927
928close_this_op:
929 /*
930 * Finished one argument of the containing scope
931 */
932 parser_state->scope->parse_scope.arg_count--;
933
934 /* Finished with pre_op */
935
936 if (pre_op) {
937 acpi_ps_free_op (pre_op);
938 pre_op = NULL;
939 }
940
941 /* Close this Op (will result in parse subtree deletion) */
942
943 status2 = acpi_ps_complete_this_op (walk_state, op);
944 if (ACPI_FAILURE (status2)) {
945 return_ACPI_STATUS (status2);
946 }
947 op = NULL;
948
949 switch (status) {
950 case AE_OK:
951 break;
952
953
954 case AE_CTRL_TRANSFER:
955
956 /* We are about to transfer to a called method. */
957
958 walk_state->prev_op = op;
959 walk_state->prev_arg_types = walk_state->arg_types;
960 return_ACPI_STATUS (status);
961
962
963 case AE_CTRL_END:
964
965 acpi_ps_pop_scope (parser_state, &op,
966 &walk_state->arg_types, &walk_state->arg_count);
967
968 if (op) {
969 walk_state->op = op;
970 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
971 walk_state->opcode = op->common.aml_opcode;
972
973 status = walk_state->ascending_callback (walk_state);
974 status = acpi_ps_next_parse_state (walk_state, op, status);
975
976 status2 = acpi_ps_complete_this_op (walk_state, op);
977 if (ACPI_FAILURE (status2)) {
978 return_ACPI_STATUS (status2);
979 }
980 op = NULL;
981 }
982 status = AE_OK;
983 break;
984
985
986 case AE_CTRL_BREAK:
987 case AE_CTRL_CONTINUE:
988
989 /* Pop off scopes until we find the While */
990
991 while (!op || (op->common.aml_opcode != AML_WHILE_OP)) {
992 acpi_ps_pop_scope (parser_state, &op,
993 &walk_state->arg_types, &walk_state->arg_count);
994 }
995
996 /* Close this iteration of the While loop */
997
998 walk_state->op = op;
999 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
1000 walk_state->opcode = op->common.aml_opcode;
1001
1002 status = walk_state->ascending_callback (walk_state);
1003 status = acpi_ps_next_parse_state (walk_state, op, status);
1004
1005 status2 = acpi_ps_complete_this_op (walk_state, op);
1006 if (ACPI_FAILURE (status2)) {
1007 return_ACPI_STATUS (status2);
1008 }
1009 op = NULL;
1010
1011 status = AE_OK;
1012 break;
1013
1014
1015 case AE_CTRL_TERMINATE:
1016
1017 status = AE_OK;
1018
1019 /* Clean up */
1020 do {
1021 if (op) {
1022 status2 = acpi_ps_complete_this_op (walk_state, op);
1023 if (ACPI_FAILURE (status2)) {
1024 return_ACPI_STATUS (status2);
1025 }
1026 }
1027 acpi_ps_pop_scope (parser_state, &op,
1028 &walk_state->arg_types, &walk_state->arg_count);
1029
1030 } while (op);
1031
1032 return_ACPI_STATUS (status);
1033
1034
1035 default: /* All other non-AE_OK status */
1036
1037 do {
1038 if (op) {
1039 status2 = acpi_ps_complete_this_op (walk_state, op);
1040 if (ACPI_FAILURE (status2)) {
1041 return_ACPI_STATUS (status2);
1042 }
1043 }
1044 acpi_ps_pop_scope (parser_state, &op,
1045 &walk_state->arg_types, &walk_state->arg_count);
1046
1047 } while (op);
1048
1049
1050 /*
1051 * TBD: Cleanup parse ops on error
1052 */
1053#if 0
1054 if (op == NULL) {
1055 acpi_ps_pop_scope (parser_state, &op,
1056 &walk_state->arg_types, &walk_state->arg_count);
1057 }
1058#endif
1059 walk_state->prev_op = op;
1060 walk_state->prev_arg_types = walk_state->arg_types;
1061 return_ACPI_STATUS (status);
1062 }
1063
1064 /* This scope complete? */
1065
1066 if (acpi_ps_has_completed_scope (parser_state)) {
1067 acpi_ps_pop_scope (parser_state, &op,
1068 &walk_state->arg_types, &walk_state->arg_count);
1069 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op));
1070 }
1071 else {
1072 op = NULL;
1073 }
1074
1075 } /* while parser_state->Aml */
1076
1077
1078 /*
1079 * Complete the last Op (if not completed), and clear the scope stack.
1080 * It is easily possible to end an AML "package" with an unbounded number
1081 * of open scopes (such as when several ASL blocks are closed with
1082 * sequential closing braces). We want to terminate each one cleanly.
1083 */
1084 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", op));
1085 do {
1086 if (op) {
1087 if (walk_state->ascending_callback != NULL) {
1088 walk_state->op = op;
1089 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
1090 walk_state->opcode = op->common.aml_opcode;
1091
1092 status = walk_state->ascending_callback (walk_state);
1093 status = acpi_ps_next_parse_state (walk_state, op, status);
1094 if (status == AE_CTRL_PENDING) {
1095 status = AE_OK;
1096 goto close_this_op;
1097 }
1098
1099 if (status == AE_CTRL_TERMINATE) {
1100 status = AE_OK;
1101
1102 /* Clean up */
1103 do {
1104 if (op) {
1105 status2 = acpi_ps_complete_this_op (walk_state, op);
1106 if (ACPI_FAILURE (status2)) {
1107 return_ACPI_STATUS (status2);
1108 }
1109 }
1110
1111 acpi_ps_pop_scope (parser_state, &op,
1112 &walk_state->arg_types, &walk_state->arg_count);
1113
1114 } while (op);
1115
1116 return_ACPI_STATUS (status);
1117 }
1118
1119 else if (ACPI_FAILURE (status)) {
1120 /* First error is most important */
1121
1122 (void) acpi_ps_complete_this_op (walk_state, op);
1123 return_ACPI_STATUS (status);
1124 }
1125 }
1126
1127 status2 = acpi_ps_complete_this_op (walk_state, op);
1128 if (ACPI_FAILURE (status2)) {
1129 return_ACPI_STATUS (status2);
1130 }
1131 }
1132
1133 acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types,
1134 &walk_state->arg_count);
1135
1136 } while (op);
1137
1138 return_ACPI_STATUS (status);
1139}
1140
1141
1142/*******************************************************************************
1143 *
1144 * FUNCTION: acpi_ps_parse_aml 424 * FUNCTION: acpi_ps_parse_aml
1145 * 425 *
1146 * PARAMETERS: walk_state - Current state 426 * PARAMETERS: walk_state - Current state
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c
index a10f88715d43..19a27020eeef 100644
--- a/drivers/acpi/parser/psutils.c
+++ b/drivers/acpi/parser/psutils.c
@@ -154,12 +154,14 @@ acpi_ps_alloc_op (
154 if (flags == ACPI_PARSEOP_GENERIC) { 154 if (flags == ACPI_PARSEOP_GENERIC) {
155 /* The generic op (default) is by far the most common (16 to 1) */ 155 /* The generic op (default) is by far the most common (16 to 1) */
156 156
157 op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE); 157 op = acpi_os_acquire_object (acpi_gbl_ps_node_cache);
158 memset(op, 0, sizeof(struct acpi_parse_obj_common));
158 } 159 }
159 else { 160 else {
160 /* Extended parseop */ 161 /* Extended parseop */
161 162
162 op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE_EXT); 163 op = acpi_os_acquire_object (acpi_gbl_ps_node_ext_cache);
164 memset(op, 0, sizeof(struct acpi_parse_obj_named));
163 } 165 }
164 166
165 /* Initialize the Op */ 167 /* Initialize the Op */
@@ -198,41 +200,14 @@ acpi_ps_free_op (
198 } 200 }
199 201
200 if (op->common.flags & ACPI_PARSEOP_GENERIC) { 202 if (op->common.flags & ACPI_PARSEOP_GENERIC) {
201 acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE, op); 203 acpi_os_release_object (acpi_gbl_ps_node_cache, op);
202 } 204 }
203 else { 205 else {
204 acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE_EXT, op); 206 acpi_os_release_object (acpi_gbl_ps_node_ext_cache, op);
205 } 207 }
206} 208}
207 209
208 210
209#ifdef ACPI_ENABLE_OBJECT_CACHE
210/*******************************************************************************
211 *
212 * FUNCTION: acpi_ps_delete_parse_cache
213 *
214 * PARAMETERS: None
215 *
216 * RETURN: None
217 *
218 * DESCRIPTION: Free all objects that are on the parse cache list.
219 *
220 ******************************************************************************/
221
222void
223acpi_ps_delete_parse_cache (
224 void)
225{
226 ACPI_FUNCTION_TRACE ("ps_delete_parse_cache");
227
228
229 acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE);
230 acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE_EXT);
231 return_VOID;
232}
233#endif
234
235
236/******************************************************************************* 211/*******************************************************************************
237 * 212 *
238 * FUNCTION: Utility functions 213 * FUNCTION: Utility functions
diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c
index 92e0c31539be..d4ff71f5fe5d 100644
--- a/drivers/acpi/tables/tbconvrt.c
+++ b/drivers/acpi/tables/tbconvrt.c
@@ -97,7 +97,9 @@ acpi_tb_get_table_count (
97 ACPI_FUNCTION_ENTRY (); 97 ACPI_FUNCTION_ENTRY ();
98 98
99 99
100 if (RSDP->revision < 2) { 100 /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
101
102 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
101 pointer_size = sizeof (u32); 103 pointer_size = sizeof (u32);
102 } 104 }
103 else { 105 else {
@@ -158,7 +160,9 @@ acpi_tb_convert_to_xsdt (
158 /* Copy the table pointers */ 160 /* Copy the table pointers */
159 161
160 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { 162 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
161 if (acpi_gbl_RSDP->revision < 2) { 163 /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
164
165 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
162 ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], 166 ACPI_STORE_ADDRESS (new_table->table_offset_entry[i],
163 (ACPI_CAST_PTR (struct rsdt_descriptor_rev1, 167 (ACPI_CAST_PTR (struct rsdt_descriptor_rev1,
164 table_info->pointer))->table_offset_entry[i]); 168 table_info->pointer))->table_offset_entry[i]);
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index b7ffe39c3626..13c6ddb2f546 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -159,8 +159,8 @@ cleanup:
159 * 159 *
160 * RETURN: None, Address 160 * RETURN: None, Address
161 * 161 *
162 * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the 162 * DESCRIPTION: Extract the address of either the RSDT or XSDT, depending on the
163 * version of the RSDP 163 * version of the RSDP and whether the XSDT pointer is valid
164 * 164 *
165 ******************************************************************************/ 165 ******************************************************************************/
166 166
@@ -174,16 +174,19 @@ acpi_tb_get_rsdt_address (
174 174
175 out_address->pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; 175 out_address->pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
176 176
177 /* 177 /* Use XSDT if it is present */
178 * For RSDP revision 0 or 1, we use the RSDT. 178
179 * For RSDP revision 2 (and above), we use the XSDT 179 if ((acpi_gbl_RSDP->revision >= 2) &&
180 */ 180 acpi_gbl_RSDP->xsdt_physical_address) {
181 if (acpi_gbl_RSDP->revision < 2) {
182 out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address;
183 }
184 else {
185 out_address->pointer.value = 181 out_address->pointer.value =
186 acpi_gbl_RSDP->xsdt_physical_address; 182 acpi_gbl_RSDP->xsdt_physical_address;
183 acpi_gbl_root_table_type = ACPI_TABLE_TYPE_XSDT;
184 }
185 else {
186 /* No XSDT, use the RSDT */
187
188 out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address;
189 acpi_gbl_root_table_type = ACPI_TABLE_TYPE_RSDT;
187 } 190 }
188} 191}
189 192
@@ -211,10 +214,9 @@ acpi_tb_validate_rsdt (
211 214
212 215
213 /* 216 /*
214 * For RSDP revision 0 or 1, we use the RSDT. 217 * Search for appropriate signature, RSDT or XSDT
215 * For RSDP revision 2 and above, we use the XSDT
216 */ 218 */
217 if (acpi_gbl_RSDP->revision < 2) { 219 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
218 no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG, 220 no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG,
219 sizeof (RSDT_SIG) -1); 221 sizeof (RSDT_SIG) -1);
220 } 222 }
@@ -236,11 +238,11 @@ acpi_tb_validate_rsdt (
236 acpi_gbl_RSDP->rsdt_physical_address, 238 acpi_gbl_RSDP->rsdt_physical_address,
237 (void *) (acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address)); 239 (void *) (acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address));
238 240
239 if (acpi_gbl_RSDP->revision < 2) { 241 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
240 ACPI_REPORT_ERROR (("Looking for RSDT (RSDP->Rev < 2)\n")) 242 ACPI_REPORT_ERROR (("Looking for RSDT\n"))
241 } 243 }
242 else { 244 else {
243 ACPI_REPORT_ERROR (("Looking for XSDT (RSDP->Rev >= 2)\n")) 245 ACPI_REPORT_ERROR (("Looking for XSDT\n"))
244 } 246 }
245 247
246 ACPI_DUMP_BUFFER ((char *) table_ptr, 48); 248 ACPI_DUMP_BUFFER ((char *) table_ptr, 48);
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c
index 198997aa7fbe..fe9c8317df46 100644
--- a/drivers/acpi/tables/tbxfroot.c
+++ b/drivers/acpi/tables/tbxfroot.c
@@ -287,9 +287,11 @@ acpi_get_firmware_table (
287 * requested table 287 * requested table
288 */ 288 */
289 for (i = 0, j = 0; i < table_count; i++) { 289 for (i = 0, j = 0; i < table_count; i++) {
290 /* Get the next table pointer, handle RSDT vs. XSDT */ 290 /*
291 291 * Get the next table pointer, handle RSDT vs. XSDT
292 if (acpi_gbl_RSDP->revision < 2) { 292 * RSDT pointers are 32 bits, XSDT pointers are 64 bits
293 */
294 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
293 address.pointer.value = (ACPI_CAST_PTR ( 295 address.pointer.value = (ACPI_CAST_PTR (
294 RSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i]; 296 RSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i];
295 } 297 }
diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile
index 939c447dd52a..e87108b7338a 100644
--- a/drivers/acpi/utilities/Makefile
+++ b/drivers/acpi/utilities/Makefile
@@ -3,6 +3,6 @@
3# 3#
4 4
5obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ 5obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
6 utcopy.o utdelete.o utglobal.o utmath.o utobject.o 6 utcopy.o utdelete.o utglobal.o utmath.o utobject.o utstate.o utmutex.o utobject.o utcache.o
7 7
8EXTRA_CFLAGS += $(ACPI_CFLAGS) 8EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index c4e7f989a2bd..5061c6f0ee66 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: utalloc - local cache and memory allocation routines 3 * Module Name: utalloc - local memory allocation routines
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
@@ -52,12 +52,10 @@
52#ifdef ACPI_DBG_TRACK_ALLOCATIONS 52#ifdef ACPI_DBG_TRACK_ALLOCATIONS
53static struct acpi_debug_mem_block * 53static struct acpi_debug_mem_block *
54acpi_ut_find_allocation ( 54acpi_ut_find_allocation (
55 u32 list_id,
56 void *allocation); 55 void *allocation);
57 56
58static acpi_status 57static acpi_status
59acpi_ut_track_allocation ( 58acpi_ut_track_allocation (
60 u32 list_id,
61 struct acpi_debug_mem_block *address, 59 struct acpi_debug_mem_block *address,
62 acpi_size size, 60 acpi_size size,
63 u8 alloc_type, 61 u8 alloc_type,
@@ -67,206 +65,118 @@ acpi_ut_track_allocation (
67 65
68static acpi_status 66static acpi_status
69acpi_ut_remove_allocation ( 67acpi_ut_remove_allocation (
70 u32 list_id,
71 struct acpi_debug_mem_block *address, 68 struct acpi_debug_mem_block *address,
72 u32 component, 69 u32 component,
73 char *module, 70 char *module,
74 u32 line); 71 u32 line);
75#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ 72#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
76 73
77 74#ifdef ACPI_DBG_TRACK_ALLOCATIONS
78/******************************************************************************* 75static acpi_status
79 * 76acpi_ut_create_list (
80 * FUNCTION: acpi_ut_release_to_cache 77 char *list_name,
81 * 78 u16 object_size,
82 * PARAMETERS: list_id - Memory list/cache ID 79 acpi_handle *return_cache);
83 * Object - The object to be released
84 *
85 * RETURN: None
86 *
87 * DESCRIPTION: Release an object to the specified cache. If cache is full,
88 * the object is deleted.
89 *
90 ******************************************************************************/
91
92void
93acpi_ut_release_to_cache (
94 u32 list_id,
95 void *object)
96{
97 struct acpi_memory_list *cache_info;
98
99
100 ACPI_FUNCTION_ENTRY ();
101
102
103 cache_info = &acpi_gbl_memory_lists[list_id];
104
105#ifdef ACPI_ENABLE_OBJECT_CACHE
106
107 /* If walk cache is full, just free this wallkstate object */
108
109 if (cache_info->cache_depth >= cache_info->max_cache_depth) {
110 ACPI_MEM_FREE (object);
111 ACPI_MEM_TRACKING (cache_info->total_freed++);
112 }
113
114 /* Otherwise put this object back into the cache */
115
116 else {
117 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) {
118 return;
119 }
120
121 /* Mark the object as cached */
122
123 ACPI_MEMSET (object, 0xCA, cache_info->object_size);
124 ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED);
125
126 /* Put the object at the head of the cache list */
127
128 * (ACPI_CAST_INDIRECT_PTR (char,
129 &(((char *) object)[cache_info->link_offset]))) = cache_info->list_head;
130 cache_info->list_head = object;
131 cache_info->cache_depth++;
132
133 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
134 }
135
136#else
137
138 /* Object cache is disabled; just free the object */
139
140 ACPI_MEM_FREE (object);
141 ACPI_MEM_TRACKING (cache_info->total_freed++);
142#endif 80#endif
143}
144 81
145 82
146/******************************************************************************* 83/*******************************************************************************
147 * 84 *
148 * FUNCTION: acpi_ut_acquire_from_cache 85 * FUNCTION: acpi_ut_create_caches
149 * 86 *
150 * PARAMETERS: list_id - Memory list ID 87 * PARAMETERS: None
151 * 88 *
152 * RETURN: A requested object. NULL if the object could not be 89 * RETURN: Status
153 * allocated.
154 * 90 *
155 * DESCRIPTION: Get an object from the specified cache. If cache is empty, 91 * DESCRIPTION: Create all local caches
156 * the object is allocated.
157 * 92 *
158 ******************************************************************************/ 93 ******************************************************************************/
159 94
160void * 95acpi_status
161acpi_ut_acquire_from_cache ( 96acpi_ut_create_caches (
162 u32 list_id) 97 void)
163{ 98{
164 struct acpi_memory_list *cache_info; 99 acpi_status status;
165 void *object;
166
167
168 ACPI_FUNCTION_NAME ("ut_acquire_from_cache");
169 100
170 101
171 cache_info = &acpi_gbl_memory_lists[list_id]; 102#ifdef ACPI_DBG_TRACK_ALLOCATIONS
172 103
173#ifdef ACPI_ENABLE_OBJECT_CACHE 104 /* Memory allocation lists */
174 105
175 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) { 106 status = acpi_ut_create_list ("Acpi-Global", 0,
176 return (NULL); 107 &acpi_gbl_global_list);
108 if (ACPI_FAILURE (status)) {
109 return (status);
177 } 110 }
178 111
179 ACPI_MEM_TRACKING (cache_info->cache_requests++); 112 status = acpi_ut_create_list ("Acpi-Namespace", sizeof (struct acpi_namespace_node),
180 113 &acpi_gbl_ns_node_list);
181 /* Check the cache first */ 114 if (ACPI_FAILURE (status)) {
182 115 return (status);
183 if (cache_info->list_head) { 116 }
184 /* There is an object available, use it */
185
186 object = cache_info->list_head;
187 cache_info->list_head = *(ACPI_CAST_INDIRECT_PTR (char,
188 &(((char *) object)[cache_info->link_offset])));
189
190 ACPI_MEM_TRACKING (cache_info->cache_hits++);
191 cache_info->cache_depth--;
192
193#ifdef ACPI_DBG_TRACK_ALLOCATIONS
194 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p from %s\n",
195 object, acpi_gbl_memory_lists[list_id].list_name));
196#endif 117#endif
197 118
198 if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) { 119 /* Object Caches, for frequently used objects */
199 return (NULL);
200 }
201
202 /* Clear (zero) the previously used Object */
203 120
204 ACPI_MEMSET (object, 0, cache_info->object_size); 121 status = acpi_os_create_cache ("acpi_state", sizeof (union acpi_generic_state),
122 ACPI_MAX_STATE_CACHE_DEPTH, &acpi_gbl_state_cache);
123 if (ACPI_FAILURE (status)) {
124 return (status);
205 } 125 }
206 126
207 else { 127 status = acpi_os_create_cache ("acpi_parse", sizeof (struct acpi_parse_obj_common),
208 /* The cache is empty, create a new object */ 128 ACPI_MAX_PARSE_CACHE_DEPTH, &acpi_gbl_ps_node_cache);
209 129 if (ACPI_FAILURE (status)) {
210 /* Avoid deadlock with ACPI_MEM_CALLOCATE */ 130 return (status);
211
212 if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) {
213 return (NULL);
214 }
215
216 object = ACPI_MEM_CALLOCATE (cache_info->object_size);
217 ACPI_MEM_TRACKING (cache_info->total_allocated++);
218 } 131 }
219 132
220#else 133 status = acpi_os_create_cache ("acpi_parse_ext", sizeof (struct acpi_parse_obj_named),
221 134 ACPI_MAX_EXTPARSE_CACHE_DEPTH, &acpi_gbl_ps_node_ext_cache);
222 /* Object cache is disabled; just allocate the object */ 135 if (ACPI_FAILURE (status)) {
136 return (status);
137 }
223 138
224 object = ACPI_MEM_CALLOCATE (cache_info->object_size); 139 status = acpi_os_create_cache ("acpi_operand", sizeof (union acpi_operand_object),
225 ACPI_MEM_TRACKING (cache_info->total_allocated++); 140 ACPI_MAX_OBJECT_CACHE_DEPTH, &acpi_gbl_operand_cache);
226#endif 141 if (ACPI_FAILURE (status)) {
142 return (status);
143 }
227 144
228 return (object); 145 return (AE_OK);
229} 146}
230 147
231 148
232#ifdef ACPI_ENABLE_OBJECT_CACHE
233/******************************************************************************* 149/*******************************************************************************
234 * 150 *
235 * FUNCTION: acpi_ut_delete_generic_cache 151 * FUNCTION: acpi_ut_delete_caches
236 * 152 *
237 * PARAMETERS: list_id - Memory list ID 153 * PARAMETERS: None
238 * 154 *
239 * RETURN: None 155 * RETURN: Status
240 * 156 *
241 * DESCRIPTION: Free all objects within the requested cache. 157 * DESCRIPTION: Purge and delete all local caches
242 * 158 *
243 ******************************************************************************/ 159 ******************************************************************************/
244 160
245void 161acpi_status
246acpi_ut_delete_generic_cache ( 162acpi_ut_delete_caches (
247 u32 list_id) 163 void)
248{ 164{
249 struct acpi_memory_list *cache_info;
250 char *next;
251 165
166 (void) acpi_os_delete_cache (acpi_gbl_state_cache);
167 acpi_gbl_state_cache = NULL;
252 168
253 ACPI_FUNCTION_ENTRY (); 169 (void) acpi_os_delete_cache (acpi_gbl_operand_cache);
254 170 acpi_gbl_operand_cache = NULL;
255 171
256 cache_info = &acpi_gbl_memory_lists[list_id]; 172 (void) acpi_os_delete_cache (acpi_gbl_ps_node_cache);
257 while (cache_info->list_head) { 173 acpi_gbl_ps_node_cache = NULL;
258 /* Delete one cached state object */
259 174
260 next = *(ACPI_CAST_INDIRECT_PTR (char, 175 (void) acpi_os_delete_cache (acpi_gbl_ps_node_ext_cache);
261 &(((char *) cache_info->list_head)[cache_info->link_offset]))); 176 acpi_gbl_ps_node_ext_cache = NULL;
262 ACPI_MEM_FREE (cache_info->list_head);
263 177
264 cache_info->list_head = next; 178 return (AE_OK);
265 cache_info->cache_depth--;
266 }
267} 179}
268#endif
269
270 180
271/******************************************************************************* 181/*******************************************************************************
272 * 182 *
@@ -500,6 +410,43 @@ acpi_ut_callocate (
500 * occurs in the body of acpi_ut_free. 410 * occurs in the body of acpi_ut_free.
501 */ 411 */
502 412
413/*******************************************************************************
414 *
415 * FUNCTION: acpi_ut_create_list
416 *
417 * PARAMETERS: cache_name - Ascii name for the cache
418 * object_size - Size of each cached object
419 * return_cache - Where the new cache object is returned
420 *
421 * RETURN: Status
422 *
423 * DESCRIPTION: Create a local memory list for tracking purposed
424 *
425 ******************************************************************************/
426
427static acpi_status
428acpi_ut_create_list (
429 char *list_name,
430 u16 object_size,
431 acpi_handle *return_cache)
432{
433 struct acpi_memory_list *cache;
434
435
436 cache = acpi_os_allocate (sizeof (struct acpi_memory_list));
437 if (!cache) {
438 return (AE_NO_MEMORY);
439 }
440
441 ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list));
442
443 cache->list_name = list_name;
444 cache->object_size = object_size;
445
446 *return_cache = cache;
447 return (AE_OK);
448}
449
503 450
504/******************************************************************************* 451/*******************************************************************************
505 * 452 *
@@ -533,15 +480,15 @@ acpi_ut_allocate_and_track (
533 return (NULL); 480 return (NULL);
534 } 481 }
535 482
536 status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, 483 status = acpi_ut_track_allocation (allocation, size,
537 ACPI_MEM_MALLOC, component, module, line); 484 ACPI_MEM_MALLOC, component, module, line);
538 if (ACPI_FAILURE (status)) { 485 if (ACPI_FAILURE (status)) {
539 acpi_os_free (allocation); 486 acpi_os_free (allocation);
540 return (NULL); 487 return (NULL);
541 } 488 }
542 489
543 acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++; 490 acpi_gbl_global_list->total_allocated++;
544 acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size; 491 acpi_gbl_global_list->current_total_size += (u32) size;
545 492
546 return ((void *) &allocation->user_space); 493 return ((void *) &allocation->user_space);
547} 494}
@@ -583,15 +530,15 @@ acpi_ut_callocate_and_track (
583 return (NULL); 530 return (NULL);
584 } 531 }
585 532
586 status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, 533 status = acpi_ut_track_allocation (allocation, size,
587 ACPI_MEM_CALLOC, component, module, line); 534 ACPI_MEM_CALLOC, component, module, line);
588 if (ACPI_FAILURE (status)) { 535 if (ACPI_FAILURE (status)) {
589 acpi_os_free (allocation); 536 acpi_os_free (allocation);
590 return (NULL); 537 return (NULL);
591 } 538 }
592 539
593 acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++; 540 acpi_gbl_global_list->total_allocated++;
594 acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size; 541 acpi_gbl_global_list->current_total_size += (u32) size;
595 542
596 return ((void *) &allocation->user_space); 543 return ((void *) &allocation->user_space);
597} 544}
@@ -636,10 +583,10 @@ acpi_ut_free_and_track (
636 debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block, 583 debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block,
637 (((char *) allocation) - sizeof (struct acpi_debug_mem_header))); 584 (((char *) allocation) - sizeof (struct acpi_debug_mem_header)));
638 585
639 acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_freed++; 586 acpi_gbl_global_list->total_freed++;
640 acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size -= debug_block->size; 587 acpi_gbl_global_list->current_total_size -= debug_block->size;
641 588
642 status = acpi_ut_remove_allocation (ACPI_MEM_LIST_GLOBAL, debug_block, 589 status = acpi_ut_remove_allocation (debug_block,
643 component, module, line); 590 component, module, line);
644 if (ACPI_FAILURE (status)) { 591 if (ACPI_FAILURE (status)) {
645 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n", 592 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n",
@@ -658,8 +605,7 @@ acpi_ut_free_and_track (
658 * 605 *
659 * FUNCTION: acpi_ut_find_allocation 606 * FUNCTION: acpi_ut_find_allocation
660 * 607 *
661 * PARAMETERS: list_id - Memory list to search 608 * PARAMETERS: Allocation - Address of allocated memory
662 * Allocation - Address of allocated memory
663 * 609 *
664 * RETURN: A list element if found; NULL otherwise. 610 * RETURN: A list element if found; NULL otherwise.
665 * 611 *
@@ -669,7 +615,6 @@ acpi_ut_free_and_track (
669 615
670static struct acpi_debug_mem_block * 616static struct acpi_debug_mem_block *
671acpi_ut_find_allocation ( 617acpi_ut_find_allocation (
672 u32 list_id,
673 void *allocation) 618 void *allocation)
674{ 619{
675 struct acpi_debug_mem_block *element; 620 struct acpi_debug_mem_block *element;
@@ -678,11 +623,7 @@ acpi_ut_find_allocation (
678 ACPI_FUNCTION_ENTRY (); 623 ACPI_FUNCTION_ENTRY ();
679 624
680 625
681 if (list_id > ACPI_MEM_LIST_MAX) { 626 element = acpi_gbl_global_list->list_head;
682 return (NULL);
683 }
684
685 element = acpi_gbl_memory_lists[list_id].list_head;
686 627
687 /* Search for the address. */ 628 /* Search for the address. */
688 629
@@ -702,8 +643,7 @@ acpi_ut_find_allocation (
702 * 643 *
703 * FUNCTION: acpi_ut_track_allocation 644 * FUNCTION: acpi_ut_track_allocation
704 * 645 *
705 * PARAMETERS: list_id - Memory list to search 646 * PARAMETERS: Allocation - Address of allocated memory
706 * Allocation - Address of allocated memory
707 * Size - Size of the allocation 647 * Size - Size of the allocation
708 * alloc_type - MEM_MALLOC or MEM_CALLOC 648 * alloc_type - MEM_MALLOC or MEM_CALLOC
709 * Component - Component type of caller 649 * Component - Component type of caller
@@ -718,7 +658,6 @@ acpi_ut_find_allocation (
718 658
719static acpi_status 659static acpi_status
720acpi_ut_track_allocation ( 660acpi_ut_track_allocation (
721 u32 list_id,
722 struct acpi_debug_mem_block *allocation, 661 struct acpi_debug_mem_block *allocation,
723 acpi_size size, 662 acpi_size size,
724 u8 alloc_type, 663 u8 alloc_type,
@@ -734,11 +673,7 @@ acpi_ut_track_allocation (
734 ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation); 673 ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation);
735 674
736 675
737 if (list_id > ACPI_MEM_LIST_MAX) { 676 mem_list = acpi_gbl_global_list;
738 return_ACPI_STATUS (AE_BAD_PARAMETER);
739 }
740
741 mem_list = &acpi_gbl_memory_lists[list_id];
742 status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); 677 status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);
743 if (ACPI_FAILURE (status)) { 678 if (ACPI_FAILURE (status)) {
744 return_ACPI_STATUS (status); 679 return_ACPI_STATUS (status);
@@ -748,8 +683,7 @@ acpi_ut_track_allocation (
748 * Search list for this address to make sure it is not already on the list. 683 * Search list for this address to make sure it is not already on the list.
749 * This will catch several kinds of problems. 684 * This will catch several kinds of problems.
750 */ 685 */
751 686 element = acpi_ut_find_allocation (allocation);
752 element = acpi_ut_find_allocation (list_id, allocation);
753 if (element) { 687 if (element) {
754 ACPI_REPORT_ERROR (( 688 ACPI_REPORT_ERROR ((
755 "ut_track_allocation: Allocation already present in list! (%p)\n", 689 "ut_track_allocation: Allocation already present in list! (%p)\n",
@@ -793,8 +727,7 @@ unlock_and_exit:
793 * 727 *
794 * FUNCTION: acpi_ut_remove_allocation 728 * FUNCTION: acpi_ut_remove_allocation
795 * 729 *
796 * PARAMETERS: list_id - Memory list to search 730 * PARAMETERS: Allocation - Address of allocated memory
797 * Allocation - Address of allocated memory
798 * Component - Component type of caller 731 * Component - Component type of caller
799 * Module - Source file name of caller 732 * Module - Source file name of caller
800 * Line - Line number of caller 733 * Line - Line number of caller
@@ -807,7 +740,6 @@ unlock_and_exit:
807 740
808static acpi_status 741static acpi_status
809acpi_ut_remove_allocation ( 742acpi_ut_remove_allocation (
810 u32 list_id,
811 struct acpi_debug_mem_block *allocation, 743 struct acpi_debug_mem_block *allocation,
812 u32 component, 744 u32 component,
813 char *module, 745 char *module,
@@ -820,11 +752,7 @@ acpi_ut_remove_allocation (
820 ACPI_FUNCTION_TRACE ("ut_remove_allocation"); 752 ACPI_FUNCTION_TRACE ("ut_remove_allocation");
821 753
822 754
823 if (list_id > ACPI_MEM_LIST_MAX) { 755 mem_list = acpi_gbl_global_list;
824 return_ACPI_STATUS (AE_BAD_PARAMETER);
825 }
826
827 mem_list = &acpi_gbl_memory_lists[list_id];
828 if (NULL == mem_list->list_head) { 756 if (NULL == mem_list->list_head) {
829 /* No allocations! */ 757 /* No allocations! */
830 758
@@ -959,7 +887,7 @@ acpi_ut_dump_allocations (
959 return; 887 return;
960 } 888 }
961 889
962 element = acpi_gbl_memory_lists[0].list_head; 890 element = acpi_gbl_global_list->list_head;
963 while (element) { 891 while (element) {
964 if ((element->component & component) && 892 if ((element->component & component) &&
965 ((module == NULL) || (0 == ACPI_STRCMP (module, element->module)))) { 893 ((module == NULL) || (0 == ACPI_STRCMP (module, element->module)))) {
diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c
new file mode 100644
index 000000000000..07588812e72d
--- /dev/null
+++ b/drivers/acpi/utilities/utcache.c
@@ -0,0 +1,322 @@
1/******************************************************************************
2 *
3 * Module Name: utcache - local cache allocation routines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45#include <acpi/acpi.h>
46
47#define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME ("utcache")
49
50
51#ifdef ACPI_USE_LOCAL_CACHE
52/*******************************************************************************
53 *
54 * FUNCTION: acpi_os_create_cache
55 *
56 * PARAMETERS: cache_name - Ascii name for the cache
57 * object_size - Size of each cached object
58 * max_depth - Maximum depth of the cache (in objects)
59 * return_cache - Where the new cache object is returned
60 *
61 * RETURN: Status
62 *
63 * DESCRIPTION: Create a cache object
64 *
65 ******************************************************************************/
66
67acpi_status
68acpi_os_create_cache (
69 char *cache_name,
70 u16 object_size,
71 u16 max_depth,
72 struct acpi_memory_list **return_cache)
73{
74 struct acpi_memory_list *cache;
75
76
77 if (!cache_name || !return_cache || (object_size < 16)) {
78 return (AE_BAD_PARAMETER);
79 }
80
81 /* Create the cache object */
82
83 cache = acpi_os_allocate (sizeof (struct acpi_memory_list));
84 if (!cache) {
85 return (AE_NO_MEMORY);
86 }
87
88 /* Populate the cache object and return it */
89
90 ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list));
91 cache->link_offset = 8;
92 cache->list_name = cache_name;
93 cache->object_size = object_size;
94 cache->max_depth = max_depth;
95
96 *return_cache = cache;
97 return (AE_OK);
98}
99
100
101/*******************************************************************************
102 *
103 * FUNCTION: acpi_os_purge_cache
104 *
105 * PARAMETERS: Cache - Handle to cache object
106 *
107 * RETURN: Status
108 *
109 * DESCRIPTION: Free all objects within the requested cache.
110 *
111 ******************************************************************************/
112
113acpi_status
114acpi_os_purge_cache (
115 struct acpi_memory_list *cache)
116{
117 char *next;
118
119
120 ACPI_FUNCTION_ENTRY ();
121
122
123 if (!cache) {
124 return (AE_BAD_PARAMETER);
125 }
126
127 /* Walk the list of objects in this cache */
128
129 while (cache->list_head) {
130 /* Delete and unlink one cached state object */
131
132 next = *(ACPI_CAST_INDIRECT_PTR (char,
133 &(((char *) cache->list_head)[cache->link_offset])));
134 ACPI_MEM_FREE (cache->list_head);
135
136 cache->list_head = next;
137 cache->current_depth--;
138 }
139
140 return (AE_OK);
141}
142
143
144/*******************************************************************************
145 *
146 * FUNCTION: acpi_os_delete_cache
147 *
148 * PARAMETERS: Cache - Handle to cache object
149 *
150 * RETURN: Status
151 *
152 * DESCRIPTION: Free all objects within the requested cache and delete the
153 * cache object.
154 *
155 ******************************************************************************/
156
157acpi_status
158acpi_os_delete_cache (
159 struct acpi_memory_list *cache)
160{
161 acpi_status status;
162
163
164 /* Purge all objects in the cache */
165
166 status = acpi_os_purge_cache (cache);
167 if (ACPI_FAILURE (status)) {
168 return (status);
169 }
170
171 /* Now we can delete the cache object */
172
173 acpi_os_free (cache);
174 return (AE_OK);
175}
176
177
178/*******************************************************************************
179 *
180 * FUNCTION: acpi_os_release_object
181 *
182 * PARAMETERS: Cache - Handle to cache object
183 * Object - The object to be released
184 *
185 * RETURN: None
186 *
187 * DESCRIPTION: Release an object to the specified cache. If cache is full,
188 * the object is deleted.
189 *
190 ******************************************************************************/
191
192acpi_status
193acpi_os_release_object (
194 struct acpi_memory_list *cache,
195 void *object)
196{
197 acpi_status status;
198
199
200 ACPI_FUNCTION_ENTRY ();
201
202
203 if (!cache || !object) {
204 return (AE_BAD_PARAMETER);
205 }
206
207 /* If cache is full, just free this object */
208
209 if (cache->current_depth >= cache->max_depth) {
210 ACPI_MEM_FREE (object);
211 ACPI_MEM_TRACKING (cache->total_freed++);
212 }
213
214 /* Otherwise put this object back into the cache */
215
216 else {
217 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
218 if (ACPI_FAILURE (status)) {
219 return (status);
220 }
221
222 /* Mark the object as cached */
223
224 ACPI_MEMSET (object, 0xCA, cache->object_size);
225 ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED);
226
227 /* Put the object at the head of the cache list */
228
229 * (ACPI_CAST_INDIRECT_PTR (char,
230 &(((char *) object)[cache->link_offset]))) = cache->list_head;
231 cache->list_head = object;
232 cache->current_depth++;
233
234 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
235 }
236
237 return (AE_OK);
238}
239
240
241/*******************************************************************************
242 *
243 * FUNCTION: acpi_os_acquire_object
244 *
245 * PARAMETERS: Cache - Handle to cache object
246 *
247 * RETURN: the acquired object. NULL on error
248 *
249 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
250 * the object is allocated.
251 *
252 ******************************************************************************/
253
254void *
255acpi_os_acquire_object (
256 struct acpi_memory_list *cache)
257{
258 acpi_status status;
259 void *object;
260
261
262 ACPI_FUNCTION_NAME ("ut_acquire_from_cache");
263
264
265 if (!cache) {
266 return (NULL);
267 }
268
269 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
270 if (ACPI_FAILURE (status)) {
271 return (NULL);
272 }
273
274 ACPI_MEM_TRACKING (cache->requests++);
275
276 /* Check the cache first */
277
278 if (cache->list_head) {
279 /* There is an object available, use it */
280
281 object = cache->list_head;
282 cache->list_head = *(ACPI_CAST_INDIRECT_PTR (char,
283 &(((char *) object)[cache->link_offset])));
284
285 cache->current_depth--;
286
287 ACPI_MEM_TRACKING (cache->hits++);
288 ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
289 "Object %p from %s\n", object, cache->list_name)));
290
291 status = acpi_ut_release_mutex (ACPI_MTX_CACHES);
292 if (ACPI_FAILURE (status)) {
293 return (NULL);
294 }
295
296 /* Clear (zero) the previously used Object */
297
298 ACPI_MEMSET (object, 0, cache->object_size);
299 }
300 else {
301 /* The cache is empty, create a new object */
302
303 ACPI_MEM_TRACKING (cache->total_allocated++);
304
305 /* Avoid deadlock with ACPI_MEM_CALLOCATE */
306
307 status = acpi_ut_release_mutex (ACPI_MTX_CACHES);
308 if (ACPI_FAILURE (status)) {
309 return (NULL);
310 }
311
312 object = ACPI_MEM_CALLOCATE (cache->object_size);
313 if (!object) {
314 return (NULL);
315 }
316 }
317
318 return (object);
319}
320#endif /* ACPI_USE_LOCAL_CACHE */
321
322
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
index 794c7df3f2ad..08362f686ec1 100644
--- a/drivers/acpi/utilities/utdebug.c
+++ b/drivers/acpi/utilities/utdebug.c
@@ -549,7 +549,7 @@ acpi_ut_dump_buffer (
549 /* Dump fill spaces */ 549 /* Dump fill spaces */
550 550
551 acpi_os_printf ("%*s", ((display * 2) + 1), " "); 551 acpi_os_printf ("%*s", ((display * 2) + 1), " ");
552 j += display; 552 j += (acpi_native_uint) display;
553 continue; 553 continue;
554 } 554 }
555 555
@@ -584,7 +584,7 @@ acpi_ut_dump_buffer (
584 break; 584 break;
585 } 585 }
586 586
587 j += display; 587 j += (acpi_native_uint) display;
588 } 588 }
589 589
590 /* 590 /*
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 4146019b543f..8653dda4f813 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -820,42 +820,20 @@ void
820acpi_ut_init_globals ( 820acpi_ut_init_globals (
821 void) 821 void)
822{ 822{
823 acpi_status status;
823 u32 i; 824 u32 i;
824 825
825 826
826 ACPI_FUNCTION_TRACE ("ut_init_globals"); 827 ACPI_FUNCTION_TRACE ("ut_init_globals");
827 828
828 829
829 /* Memory allocation and cache lists */ 830 /* Create all memory caches */
830 831
831 ACPI_MEMSET (acpi_gbl_memory_lists, 0, sizeof (struct acpi_memory_list) * ACPI_NUM_MEM_LISTS); 832 status = acpi_ut_create_caches ();
832 833 if (ACPI_FAILURE (status))
833 acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_generic_state *) NULL)->common.next), NULL); 834 {
834 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL); 835 return;
835 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL); 836 }
836 acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_operand_object *) NULL)->cache.next), NULL);
837 acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].link_offset = (u16) ACPI_PTR_DIFF (&(((struct acpi_walk_state *) NULL)->next), NULL);
838
839 acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].object_size = sizeof (struct acpi_namespace_node);
840 acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].object_size = sizeof (union acpi_generic_state);
841 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].object_size = sizeof (struct acpi_parse_obj_common);
842 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].object_size = sizeof (struct acpi_parse_obj_named);
843 acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].object_size = sizeof (union acpi_operand_object);
844 acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].object_size = sizeof (struct acpi_walk_state);
845
846 acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].max_cache_depth = ACPI_MAX_STATE_CACHE_DEPTH;
847 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].max_cache_depth = ACPI_MAX_PARSE_CACHE_DEPTH;
848 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].max_cache_depth = ACPI_MAX_EXTPARSE_CACHE_DEPTH;
849 acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].max_cache_depth = ACPI_MAX_OBJECT_CACHE_DEPTH;
850 acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].max_cache_depth = ACPI_MAX_WALK_CACHE_DEPTH;
851
852 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].list_name = "Global Memory Allocation");
853 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].list_name = "Namespace Nodes");
854 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].list_name = "State Object Cache");
855 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].list_name = "Parse Node Cache");
856 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].list_name = "Extended Parse Node Cache");
857 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].list_name = "Operand Object Cache");
858 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].list_name = "Tree Walk Node Cache");
859 837
860 /* ACPI table structure */ 838 /* ACPI table structure */
861 839
diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c
index 7f3713889ff0..fd7ceba83229 100644
--- a/drivers/acpi/utilities/utinit.c
+++ b/drivers/acpi/utilities/utinit.c
@@ -264,7 +264,7 @@ acpi_ut_subsystem_shutdown (
264 264
265 /* Purge the local caches */ 265 /* Purge the local caches */
266 266
267 (void) acpi_purge_cached_objects (); 267 (void) acpi_ut_delete_caches ();
268 268
269 /* Debug only - display leftover memory allocation, if any */ 269 /* Debug only - display leftover memory allocation, if any */
270 270
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index bb658777fa88..207c836aec64 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -49,16 +49,6 @@
49#define _COMPONENT ACPI_UTILITIES 49#define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utmisc") 50 ACPI_MODULE_NAME ("utmisc")
51 51
52/* Local prototypes */
53
54static acpi_status
55acpi_ut_create_mutex (
56 acpi_mutex_handle mutex_id);
57
58static acpi_status
59acpi_ut_delete_mutex (
60 acpi_mutex_handle mutex_id);
61
62 52
63/******************************************************************************* 53/*******************************************************************************
64 * 54 *
@@ -84,6 +74,10 @@ acpi_ut_strupr (
84 ACPI_FUNCTION_ENTRY (); 74 ACPI_FUNCTION_ENTRY ();
85 75
86 76
77 if (!src_string) {
78 return (NULL);
79 }
80
87 /* Walk entire string, uppercasing the letters */ 81 /* Walk entire string, uppercasing the letters */
88 82
89 for (string = src_string; *string; string++) { 83 for (string = src_string; *string; string++) {
@@ -543,326 +537,6 @@ error_exit:
543 537
544/******************************************************************************* 538/*******************************************************************************
545 * 539 *
546 * FUNCTION: acpi_ut_mutex_initialize
547 *
548 * PARAMETERS: None.
549 *
550 * RETURN: Status
551 *
552 * DESCRIPTION: Create the system mutex objects.
553 *
554 ******************************************************************************/
555
556acpi_status
557acpi_ut_mutex_initialize (
558 void)
559{
560 u32 i;
561 acpi_status status;
562
563
564 ACPI_FUNCTION_TRACE ("ut_mutex_initialize");
565
566
567 /*
568 * Create each of the predefined mutex objects
569 */
570 for (i = 0; i < NUM_MUTEX; i++) {
571 status = acpi_ut_create_mutex (i);
572 if (ACPI_FAILURE (status)) {
573 return_ACPI_STATUS (status);
574 }
575 }
576
577 status = acpi_os_create_lock (&acpi_gbl_gpe_lock);
578 return_ACPI_STATUS (status);
579}
580
581
582/*******************************************************************************
583 *
584 * FUNCTION: acpi_ut_mutex_terminate
585 *
586 * PARAMETERS: None.
587 *
588 * RETURN: None.
589 *
590 * DESCRIPTION: Delete all of the system mutex objects.
591 *
592 ******************************************************************************/
593
594void
595acpi_ut_mutex_terminate (
596 void)
597{
598 u32 i;
599
600
601 ACPI_FUNCTION_TRACE ("ut_mutex_terminate");
602
603
604 /*
605 * Delete each predefined mutex object
606 */
607 for (i = 0; i < NUM_MUTEX; i++) {
608 (void) acpi_ut_delete_mutex (i);
609 }
610
611 acpi_os_delete_lock (acpi_gbl_gpe_lock);
612 return_VOID;
613}
614
615
616/*******************************************************************************
617 *
618 * FUNCTION: acpi_ut_create_mutex
619 *
620 * PARAMETERS: mutex_iD - ID of the mutex to be created
621 *
622 * RETURN: Status
623 *
624 * DESCRIPTION: Create a mutex object.
625 *
626 ******************************************************************************/
627
628static acpi_status
629acpi_ut_create_mutex (
630 acpi_mutex_handle mutex_id)
631{
632 acpi_status status = AE_OK;
633
634
635 ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id);
636
637
638 if (mutex_id > MAX_MUTEX) {
639 return_ACPI_STATUS (AE_BAD_PARAMETER);
640 }
641
642 if (!acpi_gbl_mutex_info[mutex_id].mutex) {
643 status = acpi_os_create_semaphore (1, 1,
644 &acpi_gbl_mutex_info[mutex_id].mutex);
645 acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
646 acpi_gbl_mutex_info[mutex_id].use_count = 0;
647 }
648
649 return_ACPI_STATUS (status);
650}
651
652
653/*******************************************************************************
654 *
655 * FUNCTION: acpi_ut_delete_mutex
656 *
657 * PARAMETERS: mutex_iD - ID of the mutex to be deleted
658 *
659 * RETURN: Status
660 *
661 * DESCRIPTION: Delete a mutex object.
662 *
663 ******************************************************************************/
664
665static acpi_status
666acpi_ut_delete_mutex (
667 acpi_mutex_handle mutex_id)
668{
669 acpi_status status;
670
671
672 ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id);
673
674
675 if (mutex_id > MAX_MUTEX) {
676 return_ACPI_STATUS (AE_BAD_PARAMETER);
677 }
678
679 status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex);
680
681 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
682 acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
683
684 return_ACPI_STATUS (status);
685}
686
687
688/*******************************************************************************
689 *
690 * FUNCTION: acpi_ut_acquire_mutex
691 *
692 * PARAMETERS: mutex_iD - ID of the mutex to be acquired
693 *
694 * RETURN: Status
695 *
696 * DESCRIPTION: Acquire a mutex object.
697 *
698 ******************************************************************************/
699
700acpi_status
701acpi_ut_acquire_mutex (
702 acpi_mutex_handle mutex_id)
703{
704 acpi_status status;
705 u32 this_thread_id;
706
707
708 ACPI_FUNCTION_NAME ("ut_acquire_mutex");
709
710
711 if (mutex_id > MAX_MUTEX) {
712 return (AE_BAD_PARAMETER);
713 }
714
715 this_thread_id = acpi_os_get_thread_id ();
716
717#ifdef ACPI_MUTEX_DEBUG
718 {
719 u32 i;
720 /*
721 * Mutex debug code, for internal debugging only.
722 *
723 * Deadlock prevention. Check if this thread owns any mutexes of value
724 * greater than or equal to this one. If so, the thread has violated
725 * the mutex ordering rule. This indicates a coding error somewhere in
726 * the ACPI subsystem code.
727 */
728 for (i = mutex_id; i < MAX_MUTEX; i++) {
729 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
730 if (i == mutex_id) {
731 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
732 "Mutex [%s] already acquired by this thread [%X]\n",
733 acpi_ut_get_mutex_name (mutex_id), this_thread_id));
734
735 return (AE_ALREADY_ACQUIRED);
736 }
737
738 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
739 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
740 this_thread_id, acpi_ut_get_mutex_name (i),
741 acpi_ut_get_mutex_name (mutex_id)));
742
743 return (AE_ACQUIRE_DEADLOCK);
744 }
745 }
746 }
747#endif
748
749 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
750 "Thread %X attempting to acquire Mutex [%s]\n",
751 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
752
753 status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex,
754 1, ACPI_WAIT_FOREVER);
755 if (ACPI_SUCCESS (status)) {
756 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n",
757 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
758
759 acpi_gbl_mutex_info[mutex_id].use_count++;
760 acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id;
761 }
762 else {
763 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
764 "Thread %X could not acquire Mutex [%s] %s\n",
765 this_thread_id, acpi_ut_get_mutex_name (mutex_id),
766 acpi_format_exception (status)));
767 }
768
769 return (status);
770}
771
772
773/*******************************************************************************
774 *
775 * FUNCTION: acpi_ut_release_mutex
776 *
777 * PARAMETERS: mutex_iD - ID of the mutex to be released
778 *
779 * RETURN: Status
780 *
781 * DESCRIPTION: Release a mutex object.
782 *
783 ******************************************************************************/
784
785acpi_status
786acpi_ut_release_mutex (
787 acpi_mutex_handle mutex_id)
788{
789 acpi_status status;
790 u32 this_thread_id;
791
792
793 ACPI_FUNCTION_NAME ("ut_release_mutex");
794
795
796 this_thread_id = acpi_os_get_thread_id ();
797 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
798 "Thread %X releasing Mutex [%s]\n", this_thread_id,
799 acpi_ut_get_mutex_name (mutex_id)));
800
801 if (mutex_id > MAX_MUTEX) {
802 return (AE_BAD_PARAMETER);
803 }
804
805 /*
806 * Mutex must be acquired in order to release it!
807 */
808 if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) {
809 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
810 "Mutex [%s] is not acquired, cannot release\n",
811 acpi_ut_get_mutex_name (mutex_id)));
812
813 return (AE_NOT_ACQUIRED);
814 }
815
816#ifdef ACPI_MUTEX_DEBUG
817 {
818 u32 i;
819 /*
820 * Mutex debug code, for internal debugging only.
821 *
822 * Deadlock prevention. Check if this thread owns any mutexes of value
823 * greater than this one. If so, the thread has violated the mutex
824 * ordering rule. This indicates a coding error somewhere in
825 * the ACPI subsystem code.
826 */
827 for (i = mutex_id; i < MAX_MUTEX; i++) {
828 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
829 if (i == mutex_id) {
830 continue;
831 }
832
833 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
834 "Invalid release order: owns [%s], releasing [%s]\n",
835 acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id)));
836
837 return (AE_RELEASE_DEADLOCK);
838 }
839 }
840 }
841#endif
842
843 /* Mark unlocked FIRST */
844
845 acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
846
847 status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1);
848
849 if (ACPI_FAILURE (status)) {
850 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
851 "Thread %X could not release Mutex [%s] %s\n",
852 this_thread_id, acpi_ut_get_mutex_name (mutex_id),
853 acpi_format_exception (status)));
854 }
855 else {
856 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n",
857 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
858 }
859
860 return (status);
861}
862
863
864/*******************************************************************************
865 *
866 * FUNCTION: acpi_ut_create_update_state_and_push 540 * FUNCTION: acpi_ut_create_update_state_and_push
867 * 541 *
868 * PARAMETERS: Object - Object to be added to the new state 542 * PARAMETERS: Object - Object to be added to the new state
@@ -905,361 +579,6 @@ acpi_ut_create_update_state_and_push (
905 579
906/******************************************************************************* 580/*******************************************************************************
907 * 581 *
908 * FUNCTION: acpi_ut_create_pkg_state_and_push
909 *
910 * PARAMETERS: Object - Object to be added to the new state
911 * Action - Increment/Decrement
912 * state_list - List the state will be added to
913 *
914 * RETURN: Status
915 *
916 * DESCRIPTION: Create a new state and push it
917 *
918 ******************************************************************************/
919
920#ifdef ACPI_FUTURE_USAGE
921acpi_status
922acpi_ut_create_pkg_state_and_push (
923 void *internal_object,
924 void *external_object,
925 u16 index,
926 union acpi_generic_state **state_list)
927{
928 union acpi_generic_state *state;
929
930
931 ACPI_FUNCTION_ENTRY ();
932
933
934 state = acpi_ut_create_pkg_state (internal_object, external_object, index);
935 if (!state) {
936 return (AE_NO_MEMORY);
937 }
938
939 acpi_ut_push_generic_state (state_list, state);
940 return (AE_OK);
941}
942#endif /* ACPI_FUTURE_USAGE */
943
944/*******************************************************************************
945 *
946 * FUNCTION: acpi_ut_push_generic_state
947 *
948 * PARAMETERS: list_head - Head of the state stack
949 * State - State object to push
950 *
951 * RETURN: None
952 *
953 * DESCRIPTION: Push a state object onto a state stack
954 *
955 ******************************************************************************/
956
957void
958acpi_ut_push_generic_state (
959 union acpi_generic_state **list_head,
960 union acpi_generic_state *state)
961{
962 ACPI_FUNCTION_TRACE ("ut_push_generic_state");
963
964
965 /* Push the state object onto the front of the list (stack) */
966
967 state->common.next = *list_head;
968 *list_head = state;
969
970 return_VOID;
971}
972
973
974/*******************************************************************************
975 *
976 * FUNCTION: acpi_ut_pop_generic_state
977 *
978 * PARAMETERS: list_head - Head of the state stack
979 *
980 * RETURN: The popped state object
981 *
982 * DESCRIPTION: Pop a state object from a state stack
983 *
984 ******************************************************************************/
985
986union acpi_generic_state *
987acpi_ut_pop_generic_state (
988 union acpi_generic_state **list_head)
989{
990 union acpi_generic_state *state;
991
992
993 ACPI_FUNCTION_TRACE ("ut_pop_generic_state");
994
995
996 /* Remove the state object at the head of the list (stack) */
997
998 state = *list_head;
999 if (state) {
1000 /* Update the list head */
1001
1002 *list_head = state->common.next;
1003 }
1004
1005 return_PTR (state);
1006}
1007
1008
1009/*******************************************************************************
1010 *
1011 * FUNCTION: acpi_ut_create_generic_state
1012 *
1013 * PARAMETERS: None
1014 *
1015 * RETURN: The new state object. NULL on failure.
1016 *
1017 * DESCRIPTION: Create a generic state object. Attempt to obtain one from
1018 * the global state cache; If none available, create a new one.
1019 *
1020 ******************************************************************************/
1021
1022union acpi_generic_state *
1023acpi_ut_create_generic_state (
1024 void)
1025{
1026 union acpi_generic_state *state;
1027
1028
1029 ACPI_FUNCTION_ENTRY ();
1030
1031
1032 state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_STATE);
1033
1034 /* Initialize */
1035
1036 if (state) {
1037 state->common.data_type = ACPI_DESC_TYPE_STATE;
1038 }
1039
1040 return (state);
1041}
1042
1043
1044/*******************************************************************************
1045 *
1046 * FUNCTION: acpi_ut_create_thread_state
1047 *
1048 * PARAMETERS: None
1049 *
1050 * RETURN: New Thread State. NULL on failure
1051 *
1052 * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
1053 * to track per-thread info during method execution
1054 *
1055 ******************************************************************************/
1056
1057struct acpi_thread_state *
1058acpi_ut_create_thread_state (
1059 void)
1060{
1061 union acpi_generic_state *state;
1062
1063
1064 ACPI_FUNCTION_TRACE ("ut_create_thread_state");
1065
1066
1067 /* Create the generic state object */
1068
1069 state = acpi_ut_create_generic_state ();
1070 if (!state) {
1071 return_PTR (NULL);
1072 }
1073
1074 /* Init fields specific to the update struct */
1075
1076 state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD;
1077 state->thread.thread_id = acpi_os_get_thread_id ();
1078
1079 return_PTR ((struct acpi_thread_state *) state);
1080}
1081
1082
1083/*******************************************************************************
1084 *
1085 * FUNCTION: acpi_ut_create_update_state
1086 *
1087 * PARAMETERS: Object - Initial Object to be installed in the state
1088 * Action - Update action to be performed
1089 *
1090 * RETURN: New state object, null on failure
1091 *
1092 * DESCRIPTION: Create an "Update State" - a flavor of the generic state used
1093 * to update reference counts and delete complex objects such
1094 * as packages.
1095 *
1096 ******************************************************************************/
1097
1098union acpi_generic_state *
1099acpi_ut_create_update_state (
1100 union acpi_operand_object *object,
1101 u16 action)
1102{
1103 union acpi_generic_state *state;
1104
1105
1106 ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object);
1107
1108
1109 /* Create the generic state object */
1110
1111 state = acpi_ut_create_generic_state ();
1112 if (!state) {
1113 return_PTR (NULL);
1114 }
1115
1116 /* Init fields specific to the update struct */
1117
1118 state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE;
1119 state->update.object = object;
1120 state->update.value = action;
1121
1122 return_PTR (state);
1123}
1124
1125
1126/*******************************************************************************
1127 *
1128 * FUNCTION: acpi_ut_create_pkg_state
1129 *
1130 * PARAMETERS: Object - Initial Object to be installed in the state
1131 * Action - Update action to be performed
1132 *
1133 * RETURN: New state object, null on failure
1134 *
1135 * DESCRIPTION: Create a "Package State"
1136 *
1137 ******************************************************************************/
1138
1139union acpi_generic_state *
1140acpi_ut_create_pkg_state (
1141 void *internal_object,
1142 void *external_object,
1143 u16 index)
1144{
1145 union acpi_generic_state *state;
1146
1147
1148 ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object);
1149
1150
1151 /* Create the generic state object */
1152
1153 state = acpi_ut_create_generic_state ();
1154 if (!state) {
1155 return_PTR (NULL);
1156 }
1157
1158 /* Init fields specific to the update struct */
1159
1160 state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE;
1161 state->pkg.source_object = (union acpi_operand_object *) internal_object;
1162 state->pkg.dest_object = external_object;
1163 state->pkg.index = index;
1164 state->pkg.num_packages = 1;
1165
1166 return_PTR (state);
1167}
1168
1169
1170/*******************************************************************************
1171 *
1172 * FUNCTION: acpi_ut_create_control_state
1173 *
1174 * PARAMETERS: None
1175 *
1176 * RETURN: New state object, null on failure
1177 *
1178 * DESCRIPTION: Create a "Control State" - a flavor of the generic state used
1179 * to support nested IF/WHILE constructs in the AML.
1180 *
1181 ******************************************************************************/
1182
1183union acpi_generic_state *
1184acpi_ut_create_control_state (
1185 void)
1186{
1187 union acpi_generic_state *state;
1188
1189
1190 ACPI_FUNCTION_TRACE ("ut_create_control_state");
1191
1192
1193 /* Create the generic state object */
1194
1195 state = acpi_ut_create_generic_state ();
1196 if (!state) {
1197 return_PTR (NULL);
1198 }
1199
1200 /* Init fields specific to the control struct */
1201
1202 state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL;
1203 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING;
1204
1205 return_PTR (state);
1206}
1207
1208
1209/*******************************************************************************
1210 *
1211 * FUNCTION: acpi_ut_delete_generic_state
1212 *
1213 * PARAMETERS: State - The state object to be deleted
1214 *
1215 * RETURN: None
1216 *
1217 * DESCRIPTION: Put a state object back into the global state cache. The object
1218 * is not actually freed at this time.
1219 *
1220 ******************************************************************************/
1221
1222void
1223acpi_ut_delete_generic_state (
1224 union acpi_generic_state *state)
1225{
1226 ACPI_FUNCTION_TRACE ("ut_delete_generic_state");
1227
1228
1229 acpi_ut_release_to_cache (ACPI_MEM_LIST_STATE, state);
1230 return_VOID;
1231}
1232
1233
1234#ifdef ACPI_ENABLE_OBJECT_CACHE
1235/*******************************************************************************
1236 *
1237 * FUNCTION: acpi_ut_delete_generic_state_cache
1238 *
1239 * PARAMETERS: None
1240 *
1241 * RETURN: None
1242 *
1243 * DESCRIPTION: Purge the global state object cache. Used during subsystem
1244 * termination.
1245 *
1246 ******************************************************************************/
1247
1248void
1249acpi_ut_delete_generic_state_cache (
1250 void)
1251{
1252 ACPI_FUNCTION_TRACE ("ut_delete_generic_state_cache");
1253
1254
1255 acpi_ut_delete_generic_cache (ACPI_MEM_LIST_STATE);
1256 return_VOID;
1257}
1258#endif
1259
1260
1261/*******************************************************************************
1262 *
1263 * FUNCTION: acpi_ut_walk_package_tree 582 * FUNCTION: acpi_ut_walk_package_tree
1264 * 583 *
1265 * PARAMETERS: source_object - The package to walk 584 * PARAMETERS: source_object - The package to walk
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c
new file mode 100644
index 000000000000..a80b97cb2e56
--- /dev/null
+++ b/drivers/acpi/utilities/utmutex.c
@@ -0,0 +1,380 @@
1/*******************************************************************************
2 *
3 * Module Name: utmutex - local mutex support
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45#include <acpi/acpi.h>
46
47#define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME ("utmutex")
49
50/* Local prototypes */
51
52static acpi_status
53acpi_ut_create_mutex (
54 acpi_mutex_handle mutex_id);
55
56static acpi_status
57acpi_ut_delete_mutex (
58 acpi_mutex_handle mutex_id);
59
60
61/*******************************************************************************
62 *
63 * FUNCTION: acpi_ut_mutex_initialize
64 *
65 * PARAMETERS: None.
66 *
67 * RETURN: Status
68 *
69 * DESCRIPTION: Create the system mutex objects.
70 *
71 ******************************************************************************/
72
73acpi_status
74acpi_ut_mutex_initialize (
75 void)
76{
77 u32 i;
78 acpi_status status;
79
80
81 ACPI_FUNCTION_TRACE ("ut_mutex_initialize");
82
83
84 /*
85 * Create each of the predefined mutex objects
86 */
87 for (i = 0; i < NUM_MUTEX; i++) {
88 status = acpi_ut_create_mutex (i);
89 if (ACPI_FAILURE (status)) {
90 return_ACPI_STATUS (status);
91 }
92 }
93
94 status = acpi_os_create_lock (&acpi_gbl_gpe_lock);
95 return_ACPI_STATUS (status);
96}
97
98
99/*******************************************************************************
100 *
101 * FUNCTION: acpi_ut_mutex_terminate
102 *
103 * PARAMETERS: None.
104 *
105 * RETURN: None.
106 *
107 * DESCRIPTION: Delete all of the system mutex objects.
108 *
109 ******************************************************************************/
110
111void
112acpi_ut_mutex_terminate (
113 void)
114{
115 u32 i;
116
117
118 ACPI_FUNCTION_TRACE ("ut_mutex_terminate");
119
120
121 /*
122 * Delete each predefined mutex object
123 */
124 for (i = 0; i < NUM_MUTEX; i++) {
125 (void) acpi_ut_delete_mutex (i);
126 }
127
128 acpi_os_delete_lock (acpi_gbl_gpe_lock);
129 return_VOID;
130}
131
132
133/*******************************************************************************
134 *
135 * FUNCTION: acpi_ut_create_mutex
136 *
137 * PARAMETERS: mutex_iD - ID of the mutex to be created
138 *
139 * RETURN: Status
140 *
141 * DESCRIPTION: Create a mutex object.
142 *
143 ******************************************************************************/
144
145static acpi_status
146acpi_ut_create_mutex (
147 acpi_mutex_handle mutex_id)
148{
149 acpi_status status = AE_OK;
150
151
152 ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id);
153
154
155 if (mutex_id > MAX_MUTEX) {
156 return_ACPI_STATUS (AE_BAD_PARAMETER);
157 }
158
159 if (!acpi_gbl_mutex_info[mutex_id].mutex) {
160 status = acpi_os_create_semaphore (1, 1,
161 &acpi_gbl_mutex_info[mutex_id].mutex);
162 acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
163 acpi_gbl_mutex_info[mutex_id].use_count = 0;
164 }
165
166 return_ACPI_STATUS (status);
167}
168
169
170/*******************************************************************************
171 *
172 * FUNCTION: acpi_ut_delete_mutex
173 *
174 * PARAMETERS: mutex_iD - ID of the mutex to be deleted
175 *
176 * RETURN: Status
177 *
178 * DESCRIPTION: Delete a mutex object.
179 *
180 ******************************************************************************/
181
182static acpi_status
183acpi_ut_delete_mutex (
184 acpi_mutex_handle mutex_id)
185{
186 acpi_status status;
187
188
189 ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id);
190
191
192 if (mutex_id > MAX_MUTEX) {
193 return_ACPI_STATUS (AE_BAD_PARAMETER);
194 }
195
196 status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex);
197
198 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
199 acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
200
201 return_ACPI_STATUS (status);
202}
203
204
205/*******************************************************************************
206 *
207 * FUNCTION: acpi_ut_acquire_mutex
208 *
209 * PARAMETERS: mutex_iD - ID of the mutex to be acquired
210 *
211 * RETURN: Status
212 *
213 * DESCRIPTION: Acquire a mutex object.
214 *
215 ******************************************************************************/
216
217acpi_status
218acpi_ut_acquire_mutex (
219 acpi_mutex_handle mutex_id)
220{
221 acpi_status status;
222 u32 this_thread_id;
223
224
225 ACPI_FUNCTION_NAME ("ut_acquire_mutex");
226
227
228 if (mutex_id > MAX_MUTEX) {
229 return (AE_BAD_PARAMETER);
230 }
231
232 this_thread_id = acpi_os_get_thread_id ();
233
234#ifdef ACPI_MUTEX_DEBUG
235 {
236 u32 i;
237 /*
238 * Mutex debug code, for internal debugging only.
239 *
240 * Deadlock prevention. Check if this thread owns any mutexes of value
241 * greater than or equal to this one. If so, the thread has violated
242 * the mutex ordering rule. This indicates a coding error somewhere in
243 * the ACPI subsystem code.
244 */
245 for (i = mutex_id; i < MAX_MUTEX; i++) {
246 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
247 if (i == mutex_id) {
248 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
249 "Mutex [%s] already acquired by this thread [%X]\n",
250 acpi_ut_get_mutex_name (mutex_id), this_thread_id));
251
252 return (AE_ALREADY_ACQUIRED);
253 }
254
255 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
256 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
257 this_thread_id, acpi_ut_get_mutex_name (i),
258 acpi_ut_get_mutex_name (mutex_id)));
259
260 return (AE_ACQUIRE_DEADLOCK);
261 }
262 }
263 }
264#endif
265
266 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
267 "Thread %X attempting to acquire Mutex [%s]\n",
268 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
269
270 status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex,
271 1, ACPI_WAIT_FOREVER);
272 if (ACPI_SUCCESS (status)) {
273 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n",
274 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
275
276 acpi_gbl_mutex_info[mutex_id].use_count++;
277 acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id;
278 }
279 else {
280 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
281 "Thread %X could not acquire Mutex [%s] %s\n",
282 this_thread_id, acpi_ut_get_mutex_name (mutex_id),
283 acpi_format_exception (status)));
284 }
285
286 return (status);
287}
288
289
290/*******************************************************************************
291 *
292 * FUNCTION: acpi_ut_release_mutex
293 *
294 * PARAMETERS: mutex_iD - ID of the mutex to be released
295 *
296 * RETURN: Status
297 *
298 * DESCRIPTION: Release a mutex object.
299 *
300 ******************************************************************************/
301
302acpi_status
303acpi_ut_release_mutex (
304 acpi_mutex_handle mutex_id)
305{
306 acpi_status status;
307 u32 this_thread_id;
308
309
310 ACPI_FUNCTION_NAME ("ut_release_mutex");
311
312
313 this_thread_id = acpi_os_get_thread_id ();
314 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
315 "Thread %X releasing Mutex [%s]\n", this_thread_id,
316 acpi_ut_get_mutex_name (mutex_id)));
317
318 if (mutex_id > MAX_MUTEX) {
319 return (AE_BAD_PARAMETER);
320 }
321
322 /*
323 * Mutex must be acquired in order to release it!
324 */
325 if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) {
326 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
327 "Mutex [%s] is not acquired, cannot release\n",
328 acpi_ut_get_mutex_name (mutex_id)));
329
330 return (AE_NOT_ACQUIRED);
331 }
332
333#ifdef ACPI_MUTEX_DEBUG
334 {
335 u32 i;
336 /*
337 * Mutex debug code, for internal debugging only.
338 *
339 * Deadlock prevention. Check if this thread owns any mutexes of value
340 * greater than this one. If so, the thread has violated the mutex
341 * ordering rule. This indicates a coding error somewhere in
342 * the ACPI subsystem code.
343 */
344 for (i = mutex_id; i < MAX_MUTEX; i++) {
345 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
346 if (i == mutex_id) {
347 continue;
348 }
349
350 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
351 "Invalid release order: owns [%s], releasing [%s]\n",
352 acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id)));
353
354 return (AE_RELEASE_DEADLOCK);
355 }
356 }
357 }
358#endif
359
360 /* Mark unlocked FIRST */
361
362 acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
363
364 status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1);
365
366 if (ACPI_FAILURE (status)) {
367 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
368 "Thread %X could not release Mutex [%s] %s\n",
369 this_thread_id, acpi_ut_get_mutex_name (mutex_id),
370 acpi_format_exception (status)));
371 }
372 else {
373 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n",
374 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
375 }
376
377 return (status);
378}
379
380
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c
index cd3899b9cc5a..19178e142951 100644
--- a/drivers/acpi/utilities/utobject.c
+++ b/drivers/acpi/utilities/utobject.c
@@ -338,7 +338,7 @@ acpi_ut_allocate_object_desc_dbg (
338 ACPI_FUNCTION_TRACE ("ut_allocate_object_desc_dbg"); 338 ACPI_FUNCTION_TRACE ("ut_allocate_object_desc_dbg");
339 339
340 340
341 object = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_OPERAND); 341 object = acpi_os_acquire_object (acpi_gbl_operand_cache);
342 if (!object) { 342 if (!object) {
343 _ACPI_REPORT_ERROR (module_name, line_number, component_id, 343 _ACPI_REPORT_ERROR (module_name, line_number, component_id,
344 ("Could not allocate an object descriptor\n")); 344 ("Could not allocate an object descriptor\n"));
@@ -347,7 +347,7 @@ acpi_ut_allocate_object_desc_dbg (
347 } 347 }
348 348
349 /* Mark the descriptor type */ 349 /* Mark the descriptor type */
350 350 memset(object, 0, sizeof(union acpi_operand_object));
351 ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND); 351 ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND);
352 352
353 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", 353 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
@@ -385,37 +385,9 @@ acpi_ut_delete_object_desc (
385 return_VOID; 385 return_VOID;
386 } 386 }
387 387
388 acpi_ut_release_to_cache (ACPI_MEM_LIST_OPERAND, object); 388 (void) acpi_os_release_object (acpi_gbl_operand_cache, object);
389
390 return_VOID;
391}
392
393
394#ifdef ACPI_ENABLE_OBJECT_CACHE
395/*******************************************************************************
396 *
397 * FUNCTION: acpi_ut_delete_object_cache
398 *
399 * PARAMETERS: None
400 *
401 * RETURN: None
402 *
403 * DESCRIPTION: Purge the global state object cache. Used during subsystem
404 * termination.
405 *
406 ******************************************************************************/
407
408void
409acpi_ut_delete_object_cache (
410 void)
411{
412 ACPI_FUNCTION_TRACE ("ut_delete_object_cache");
413
414
415 acpi_ut_delete_generic_cache (ACPI_MEM_LIST_OPERAND);
416 return_VOID; 389 return_VOID;
417} 390}
418#endif
419 391
420 392
421/******************************************************************************* 393/*******************************************************************************
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c
new file mode 100644
index 000000000000..192e7ac95690
--- /dev/null
+++ b/drivers/acpi/utilities/utstate.c
@@ -0,0 +1,376 @@
1/*******************************************************************************
2 *
3 * Module Name: utstate - state object support procedures
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45#include <acpi/acpi.h>
46
47#define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME ("utstate")
49
50
51/*******************************************************************************
52 *
53 * FUNCTION: acpi_ut_create_pkg_state_and_push
54 *
55 * PARAMETERS: Object - Object to be added to the new state
56 * Action - Increment/Decrement
57 * state_list - List the state will be added to
58 *
59 * RETURN: Status
60 *
61 * DESCRIPTION: Create a new state and push it
62 *
63 ******************************************************************************/
64
65acpi_status
66acpi_ut_create_pkg_state_and_push (
67 void *internal_object,
68 void *external_object,
69 u16 index,
70 union acpi_generic_state **state_list)
71{
72 union acpi_generic_state *state;
73
74
75 ACPI_FUNCTION_ENTRY ();
76
77
78 state = acpi_ut_create_pkg_state (internal_object, external_object, index);
79 if (!state) {
80 return (AE_NO_MEMORY);
81 }
82
83 acpi_ut_push_generic_state (state_list, state);
84 return (AE_OK);
85}
86
87
88/*******************************************************************************
89 *
90 * FUNCTION: acpi_ut_push_generic_state
91 *
92 * PARAMETERS: list_head - Head of the state stack
93 * State - State object to push
94 *
95 * RETURN: None
96 *
97 * DESCRIPTION: Push a state object onto a state stack
98 *
99 ******************************************************************************/
100
101void
102acpi_ut_push_generic_state (
103 union acpi_generic_state **list_head,
104 union acpi_generic_state *state)
105{
106 ACPI_FUNCTION_TRACE ("ut_push_generic_state");
107
108
109 /* Push the state object onto the front of the list (stack) */
110
111 state->common.next = *list_head;
112 *list_head = state;
113
114 return_VOID;
115}
116
117
118/*******************************************************************************
119 *
120 * FUNCTION: acpi_ut_pop_generic_state
121 *
122 * PARAMETERS: list_head - Head of the state stack
123 *
124 * RETURN: The popped state object
125 *
126 * DESCRIPTION: Pop a state object from a state stack
127 *
128 ******************************************************************************/
129
130union acpi_generic_state *
131acpi_ut_pop_generic_state (
132 union acpi_generic_state **list_head)
133{
134 union acpi_generic_state *state;
135
136
137 ACPI_FUNCTION_TRACE ("ut_pop_generic_state");
138
139
140 /* Remove the state object at the head of the list (stack) */
141
142 state = *list_head;
143 if (state) {
144 /* Update the list head */
145
146 *list_head = state->common.next;
147 }
148
149 return_PTR (state);
150}
151
152
153/*******************************************************************************
154 *
155 * FUNCTION: acpi_ut_create_generic_state
156 *
157 * PARAMETERS: None
158 *
159 * RETURN: The new state object. NULL on failure.
160 *
161 * DESCRIPTION: Create a generic state object. Attempt to obtain one from
162 * the global state cache; If none available, create a new one.
163 *
164 ******************************************************************************/
165
166union acpi_generic_state *
167acpi_ut_create_generic_state (
168 void)
169{
170 union acpi_generic_state *state;
171
172
173 ACPI_FUNCTION_ENTRY ();
174
175
176 state = acpi_os_acquire_object (acpi_gbl_state_cache);
177 if (state) {
178 /* Initialize */
179 memset(state, 0, sizeof(union acpi_generic_state));
180 state->common.data_type = ACPI_DESC_TYPE_STATE;
181 }
182
183 return (state);
184}
185
186
187/*******************************************************************************
188 *
189 * FUNCTION: acpi_ut_create_thread_state
190 *
191 * PARAMETERS: None
192 *
193 * RETURN: New Thread State. NULL on failure
194 *
195 * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
196 * to track per-thread info during method execution
197 *
198 ******************************************************************************/
199
200struct acpi_thread_state *
201acpi_ut_create_thread_state (
202 void)
203{
204 union acpi_generic_state *state;
205
206
207 ACPI_FUNCTION_TRACE ("ut_create_thread_state");
208
209
210 /* Create the generic state object */
211
212 state = acpi_ut_create_generic_state ();
213 if (!state) {
214 return_PTR (NULL);
215 }
216
217 /* Init fields specific to the update struct */
218
219 state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD;
220 state->thread.thread_id = acpi_os_get_thread_id ();
221
222 return_PTR ((struct acpi_thread_state *) state);
223}
224
225
226/*******************************************************************************
227 *
228 * FUNCTION: acpi_ut_create_update_state
229 *
230 * PARAMETERS: Object - Initial Object to be installed in the state
231 * Action - Update action to be performed
232 *
233 * RETURN: New state object, null on failure
234 *
235 * DESCRIPTION: Create an "Update State" - a flavor of the generic state used
236 * to update reference counts and delete complex objects such
237 * as packages.
238 *
239 ******************************************************************************/
240
241union acpi_generic_state *
242acpi_ut_create_update_state (
243 union acpi_operand_object *object,
244 u16 action)
245{
246 union acpi_generic_state *state;
247
248
249 ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object);
250
251
252 /* Create the generic state object */
253
254 state = acpi_ut_create_generic_state ();
255 if (!state) {
256 return_PTR (NULL);
257 }
258
259 /* Init fields specific to the update struct */
260
261 state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE;
262 state->update.object = object;
263 state->update.value = action;
264
265 return_PTR (state);
266}
267
268
269/*******************************************************************************
270 *
271 * FUNCTION: acpi_ut_create_pkg_state
272 *
273 * PARAMETERS: Object - Initial Object to be installed in the state
274 * Action - Update action to be performed
275 *
276 * RETURN: New state object, null on failure
277 *
278 * DESCRIPTION: Create a "Package State"
279 *
280 ******************************************************************************/
281
282union acpi_generic_state *
283acpi_ut_create_pkg_state (
284 void *internal_object,
285 void *external_object,
286 u16 index)
287{
288 union acpi_generic_state *state;
289
290
291 ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object);
292
293
294 /* Create the generic state object */
295
296 state = acpi_ut_create_generic_state ();
297 if (!state) {
298 return_PTR (NULL);
299 }
300
301 /* Init fields specific to the update struct */
302
303 state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE;
304 state->pkg.source_object = (union acpi_operand_object *) internal_object;
305 state->pkg.dest_object = external_object;
306 state->pkg.index = index;
307 state->pkg.num_packages = 1;
308
309 return_PTR (state);
310}
311
312
313/*******************************************************************************
314 *
315 * FUNCTION: acpi_ut_create_control_state
316 *
317 * PARAMETERS: None
318 *
319 * RETURN: New state object, null on failure
320 *
321 * DESCRIPTION: Create a "Control State" - a flavor of the generic state used
322 * to support nested IF/WHILE constructs in the AML.
323 *
324 ******************************************************************************/
325
326union acpi_generic_state *
327acpi_ut_create_control_state (
328 void)
329{
330 union acpi_generic_state *state;
331
332
333 ACPI_FUNCTION_TRACE ("ut_create_control_state");
334
335
336 /* Create the generic state object */
337
338 state = acpi_ut_create_generic_state ();
339 if (!state) {
340 return_PTR (NULL);
341 }
342
343 /* Init fields specific to the control struct */
344
345 state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL;
346 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING;
347
348 return_PTR (state);
349}
350
351
352/*******************************************************************************
353 *
354 * FUNCTION: acpi_ut_delete_generic_state
355 *
356 * PARAMETERS: State - The state object to be deleted
357 *
358 * RETURN: None
359 *
360 * DESCRIPTION: Put a state object back into the global state cache. The object
361 * is not actually freed at this time.
362 *
363 ******************************************************************************/
364
365void
366acpi_ut_delete_generic_state (
367 union acpi_generic_state *state)
368{
369 ACPI_FUNCTION_TRACE ("ut_delete_generic_state");
370
371
372 (void) acpi_os_release_object (acpi_gbl_state_cache, state);
373 return_VOID;
374}
375
376
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c
index e8803d810656..850da6817423 100644
--- a/drivers/acpi/utilities/utxface.c
+++ b/drivers/acpi/utilities/utxface.c
@@ -46,8 +46,6 @@
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47#include <acpi/acevents.h> 47#include <acpi/acevents.h>
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49#include <acpi/acparser.h>
50#include <acpi/acdispat.h>
51#include <acpi/acdebug.h> 49#include <acpi/acdebug.h>
52 50
53#define _COMPONENT ACPI_UTILITIES 51#define _COMPONENT ACPI_UTILITIES
@@ -79,11 +77,6 @@ acpi_initialize_subsystem (
79 77
80 ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ()); 78 ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ());
81 79
82
83 /* Initialize all globals used by the subsystem */
84
85 acpi_ut_init_globals ();
86
87 /* Initialize the OS-Dependent layer */ 80 /* Initialize the OS-Dependent layer */
88 81
89 status = acpi_os_initialize (); 82 status = acpi_os_initialize ();
@@ -93,6 +86,10 @@ acpi_initialize_subsystem (
93 return_ACPI_STATUS (status); 86 return_ACPI_STATUS (status);
94 } 87 }
95 88
89 /* Initialize all globals used by the subsystem */
90
91 acpi_ut_init_globals ();
92
96 /* Create the default mutex objects */ 93 /* Create the default mutex objects */
97 94
98 status = acpi_ut_mutex_initialize (); 95 status = acpi_ut_mutex_initialize ();
@@ -522,13 +519,9 @@ acpi_purge_cached_objects (
522{ 519{
523 ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects"); 520 ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects");
524 521
525 522 (void) acpi_os_purge_cache (acpi_gbl_state_cache);
526#ifdef ACPI_ENABLE_OBJECT_CACHE 523 (void) acpi_os_purge_cache (acpi_gbl_operand_cache);
527 acpi_ut_delete_generic_state_cache (); 524 (void) acpi_os_purge_cache (acpi_gbl_ps_node_cache);
528 acpi_ut_delete_object_cache (); 525 (void) acpi_os_purge_cache (acpi_gbl_ps_node_ext_cache);
529 acpi_ds_delete_walk_state_cache ();
530 acpi_ps_delete_parse_cache ();
531#endif
532
533 return_ACPI_STATUS (AE_OK); 526 return_ACPI_STATUS (AE_OK);
534} 527}