diff options
author | Robert Moore <robert.moore@intel.com> | 2005-06-24 00:00:00 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2005-07-13 23:45:36 -0400 |
commit | 73459f73e5d1602c59ebec114fc45185521353c1 (patch) | |
tree | 56c2183e345784d2be09c2f5d2530cf36221c55e /drivers/acpi/utilities/utmisc.c | |
parent | 88ac00f5a841dcfc5c682000f4a6add0add8caac (diff) |
ACPICA 20050617-0624 from Bob Moore <robert.moore@intel.com>
ACPICA 20050617:
Moved the object cache operations into the OS interface
layer (OSL) to allow the host OS to handle these operations
if desired (for example, the Linux OSL will invoke the
slab allocator). This support is optional; the compile
time define ACPI_USE_LOCAL_CACHE may be used to utilize
the original cache code in the ACPI CA core. The new OSL
interfaces are shown below. See utalloc.c for an example
implementation, and acpiosxf.h for the exact interface
definitions. Thanks to Alexey Starikovskiy.
acpi_os_create_cache
acpi_os_delete_cache
acpi_os_purge_cache
acpi_os_acquire_object
acpi_os_release_object
Modified the interfaces to acpi_os_acquire_lock and
acpi_os_release_lock to return and restore a flags
parameter. This fits better with many OS lock models.
Note: the current execution state (interrupt handler
or not) is no longer passed to these interfaces. If
necessary, the OSL must determine this state by itself, a
simple and fast operation. Thanks to Alexey Starikovskiy.
Fixed a problem in the ACPI table handling where a valid
XSDT was assumed present if the revision of the RSDP
was 2 or greater. According to the ACPI specification,
the XSDT is optional in all cases, and the table manager
therefore now checks for both an RSDP >=2 and a valid
XSDT pointer. Otherwise, the RSDT pointer is used.
Some ACPI 2.0 compliant BIOSs contain only the RSDT.
Fixed an interpreter problem with the Mid() operator in the
case of an input string where the resulting output string
is of zero length. It now correctly returns a valid,
null terminated string object instead of a string object
with a null pointer.
Fixed a problem with the control method argument handling
to allow a store to an Arg object that already contains an
object of type Device. The Device object is now correctly
overwritten. Previously, an error was returned.
ACPICA 20050624:
Modified the new OSL cache interfaces to use ACPI_CACHE_T
as the type for the host-defined cache object. This allows
the OSL implementation to define and type this object in
any manner desired, simplifying the OSL implementation.
For example, ACPI_CACHE_T is defined as kmem_cache_t for
Linux, and should be defined in the OS-specific header
file for other operating systems as required.
Changed the interface to AcpiOsAcquireObject to directly
return the requested object as the function return (instead
of ACPI_STATUS.) This change was made for performance
reasons, since this is the purpose of the interface in the
first place. acpi_os_acquire_object is now similar to the
acpi_os_allocate interface. Thanks to Alexey Starikovskiy.
Modified the initialization sequence in
acpi_initialize_subsystem to call the OSL interface
acpi_osl_initialize first, before any local initialization.
This change was required because the global initialization
now calls OSL interfaces.
Restructured the code base to split some files because
of size and/or because the code logically belonged in a
separate file. New files are listed below.
utilities/utcache.c /* Local cache interfaces */
utilities/utmutex.c /* Local mutex support */
utilities/utstate.c /* State object support */
parser/psloop.c /* Main AML parse loop */
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/utilities/utmisc.c')
-rw-r--r-- | drivers/acpi/utilities/utmisc.c | 689 |
1 files changed, 4 insertions, 685 deletions
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 | |||
54 | static acpi_status | ||
55 | acpi_ut_create_mutex ( | ||
56 | acpi_mutex_handle mutex_id); | ||
57 | |||
58 | static acpi_status | ||
59 | acpi_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 | |||
556 | acpi_status | ||
557 | acpi_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 | |||
594 | void | ||
595 | acpi_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 | |||
628 | static acpi_status | ||
629 | acpi_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 | |||
665 | static acpi_status | ||
666 | acpi_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 | |||
700 | acpi_status | ||
701 | acpi_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 | |||
785 | acpi_status | ||
786 | acpi_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 | ||
921 | acpi_status | ||
922 | acpi_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 | |||
957 | void | ||
958 | acpi_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 | |||
986 | union acpi_generic_state * | ||
987 | acpi_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 | |||
1022 | union acpi_generic_state * | ||
1023 | acpi_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 | |||
1057 | struct acpi_thread_state * | ||
1058 | acpi_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 | |||
1098 | union acpi_generic_state * | ||
1099 | acpi_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 | |||
1139 | union acpi_generic_state * | ||
1140 | acpi_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 | |||
1183 | union acpi_generic_state * | ||
1184 | acpi_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 | |||
1222 | void | ||
1223 | acpi_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 | |||
1248 | void | ||
1249 | acpi_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 |