utmisc.c (114237) | utmisc.c (117521) |
---|---|
1/******************************************************************************* 2 * 3 * Module Name: utmisc - common utility procedures | 1/******************************************************************************* 2 * 3 * Module Name: utmisc - common utility procedures |
4 * $Revision: 93 $ | 4 * $Revision: 97 $ |
5 * 6 ******************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. --- 266 unchanged lines hidden (view full) --- 279 280void 281AcpiUtSetIntegerWidth ( 282 UINT8 Revision) 283{ 284 285 if (Revision <= 1) 286 { | 5 * 6 ******************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. --- 266 unchanged lines hidden (view full) --- 279 280void 281AcpiUtSetIntegerWidth ( 282 UINT8 Revision) 283{ 284 285 if (Revision <= 1) 286 { |
287 AcpiGbl_IntegerBitWidth = 32; 288 AcpiGbl_IntegerByteWidth = 4; | 287 AcpiGbl_IntegerBitWidth = 32; 288 AcpiGbl_IntegerNybbleWidth = 8; 289 AcpiGbl_IntegerByteWidth = 4; |
289 } 290 else 291 { | 290 } 291 else 292 { |
292 AcpiGbl_IntegerBitWidth = 64; 293 AcpiGbl_IntegerByteWidth = 8; | 293 AcpiGbl_IntegerBitWidth = 64; 294 AcpiGbl_IntegerNybbleWidth = 16; 295 AcpiGbl_IntegerByteWidth = 8; |
294 } 295} 296 297 298#ifdef ACPI_DEBUG_OUTPUT 299/******************************************************************************* 300 * 301 * FUNCTION: AcpiUtDisplayInitPathname --- 349 unchanged lines hidden (view full) --- 651 652 653 ACPI_FUNCTION_TRACE ("UtMutexInitialize"); 654 655 656 /* 657 * Create each of the predefined mutex objects 658 */ | 296 } 297} 298 299 300#ifdef ACPI_DEBUG_OUTPUT 301/******************************************************************************* 302 * 303 * FUNCTION: AcpiUtDisplayInitPathname --- 349 unchanged lines hidden (view full) --- 653 654 655 ACPI_FUNCTION_TRACE ("UtMutexInitialize"); 656 657 658 /* 659 * Create each of the predefined mutex objects 660 */ |
659 for (i = 0; i < NUM_MTX; i++) | 661 for (i = 0; i < NUM_MUTEX; i++) |
660 { 661 Status = AcpiUtCreateMutex (i); 662 if (ACPI_FAILURE (Status)) 663 { 664 return_ACPI_STATUS (Status); 665 } 666 } 667 | 662 { 663 Status = AcpiUtCreateMutex (i); 664 if (ACPI_FAILURE (Status)) 665 { 666 return_ACPI_STATUS (Status); 667 } 668 } 669 |
670 671 Status = AcpiOsCreateLock (&AcpiGbl_GpeLock); 672 |
|
668 return_ACPI_STATUS (AE_OK); 669} 670 671 672/******************************************************************************* 673 * 674 * FUNCTION: AcpiUtMutexTerminate 675 * --- 13 unchanged lines hidden (view full) --- 689 690 691 ACPI_FUNCTION_TRACE ("UtMutexTerminate"); 692 693 694 /* 695 * Delete each predefined mutex object 696 */ | 673 return_ACPI_STATUS (AE_OK); 674} 675 676 677/******************************************************************************* 678 * 679 * FUNCTION: AcpiUtMutexTerminate 680 * --- 13 unchanged lines hidden (view full) --- 694 695 696 ACPI_FUNCTION_TRACE ("UtMutexTerminate"); 697 698 699 /* 700 * Delete each predefined mutex object 701 */ |
697 for (i = 0; i < NUM_MTX; i++) | 702 for (i = 0; i < NUM_MUTEX; i++) |
698 { 699 (void) AcpiUtDeleteMutex (i); 700 } 701 | 703 { 704 (void) AcpiUtDeleteMutex (i); 705 } 706 |
707 AcpiOsDeleteLock (AcpiGbl_GpeLock); |
|
702 return_VOID; 703} 704 705 706/******************************************************************************* 707 * 708 * FUNCTION: AcpiUtCreateMutex 709 * --- 10 unchanged lines hidden (view full) --- 720 ACPI_MUTEX_HANDLE MutexId) 721{ 722 ACPI_STATUS Status = AE_OK; 723 724 725 ACPI_FUNCTION_TRACE_U32 ("UtCreateMutex", MutexId); 726 727 | 708 return_VOID; 709} 710 711 712/******************************************************************************* 713 * 714 * FUNCTION: AcpiUtCreateMutex 715 * --- 10 unchanged lines hidden (view full) --- 726 ACPI_MUTEX_HANDLE MutexId) 727{ 728 ACPI_STATUS Status = AE_OK; 729 730 731 ACPI_FUNCTION_TRACE_U32 ("UtCreateMutex", MutexId); 732 733 |
728 if (MutexId > MAX_MTX) | 734 if (MutexId > MAX_MUTEX) |
729 { 730 return_ACPI_STATUS (AE_BAD_PARAMETER); 731 } 732 | 735 { 736 return_ACPI_STATUS (AE_BAD_PARAMETER); 737 } 738 |
733 if (!AcpiGbl_AcpiMutexInfo[MutexId].Mutex) | 739 if (!AcpiGbl_MutexInfo[MutexId].Mutex) |
734 { 735 Status = AcpiOsCreateSemaphore (1, 1, | 740 { 741 Status = AcpiOsCreateSemaphore (1, 1, |
736 &AcpiGbl_AcpiMutexInfo[MutexId].Mutex); 737 AcpiGbl_AcpiMutexInfo[MutexId].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; 738 AcpiGbl_AcpiMutexInfo[MutexId].UseCount = 0; | 742 &AcpiGbl_MutexInfo[MutexId].Mutex); 743 AcpiGbl_MutexInfo[MutexId].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; 744 AcpiGbl_MutexInfo[MutexId].UseCount = 0; |
739 } 740 741 return_ACPI_STATUS (Status); 742} 743 744 745/******************************************************************************* 746 * --- 12 unchanged lines hidden (view full) --- 759 ACPI_MUTEX_HANDLE MutexId) 760{ 761 ACPI_STATUS Status; 762 763 764 ACPI_FUNCTION_TRACE_U32 ("UtDeleteMutex", MutexId); 765 766 | 745 } 746 747 return_ACPI_STATUS (Status); 748} 749 750 751/******************************************************************************* 752 * --- 12 unchanged lines hidden (view full) --- 765 ACPI_MUTEX_HANDLE MutexId) 766{ 767 ACPI_STATUS Status; 768 769 770 ACPI_FUNCTION_TRACE_U32 ("UtDeleteMutex", MutexId); 771 772 |
767 if (MutexId > MAX_MTX) | 773 if (MutexId > MAX_MUTEX) |
768 { 769 return_ACPI_STATUS (AE_BAD_PARAMETER); 770 } 771 | 774 { 775 return_ACPI_STATUS (AE_BAD_PARAMETER); 776 } 777 |
772 Status = AcpiOsDeleteSemaphore (AcpiGbl_AcpiMutexInfo[MutexId].Mutex); | 778 Status = AcpiOsDeleteSemaphore (AcpiGbl_MutexInfo[MutexId].Mutex); |
773 | 779 |
774 AcpiGbl_AcpiMutexInfo[MutexId].Mutex = NULL; 775 AcpiGbl_AcpiMutexInfo[MutexId].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; | 780 AcpiGbl_MutexInfo[MutexId].Mutex = NULL; 781 AcpiGbl_MutexInfo[MutexId].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; |
776 777 return_ACPI_STATUS (Status); 778} 779 780 781/******************************************************************************* 782 * 783 * FUNCTION: AcpiUtAcquireMutex --- 13 unchanged lines hidden (view full) --- 797 ACPI_STATUS Status; 798 UINT32 i; 799 UINT32 ThisThreadId; 800 801 802 ACPI_FUNCTION_NAME ("UtAcquireMutex"); 803 804 | 782 783 return_ACPI_STATUS (Status); 784} 785 786 787/******************************************************************************* 788 * 789 * FUNCTION: AcpiUtAcquireMutex --- 13 unchanged lines hidden (view full) --- 803 ACPI_STATUS Status; 804 UINT32 i; 805 UINT32 ThisThreadId; 806 807 808 ACPI_FUNCTION_NAME ("UtAcquireMutex"); 809 810 |
805 if (MutexId > MAX_MTX) | 811 if (MutexId > MAX_MUTEX) |
806 { 807 return (AE_BAD_PARAMETER); 808 } 809 810 ThisThreadId = AcpiOsGetThreadId (); 811 812 /* 813 * Deadlock prevention. Check if this thread owns any mutexes of value 814 * greater than or equal to this one. If so, the thread has violated 815 * the mutex ordering rule. This indicates a coding error somewhere in 816 * the ACPI subsystem code. 817 */ | 812 { 813 return (AE_BAD_PARAMETER); 814 } 815 816 ThisThreadId = AcpiOsGetThreadId (); 817 818 /* 819 * Deadlock prevention. Check if this thread owns any mutexes of value 820 * greater than or equal to this one. If so, the thread has violated 821 * the mutex ordering rule. This indicates a coding error somewhere in 822 * the ACPI subsystem code. 823 */ |
818 for (i = MutexId; i < MAX_MTX; i++) | 824 for (i = MutexId; i < MAX_MUTEX; i++) |
819 { | 825 { |
820 if (AcpiGbl_AcpiMutexInfo[i].OwnerId == ThisThreadId) | 826 if (AcpiGbl_MutexInfo[i].OwnerId == ThisThreadId) |
821 { 822 if (i == MutexId) 823 { 824 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 825 "Mutex [%s] already acquired by this thread [%X]\n", 826 AcpiUtGetMutexName (MutexId), ThisThreadId)); 827 828 return (AE_ALREADY_ACQUIRED); --- 7 unchanged lines hidden (view full) --- 836 return (AE_ACQUIRE_DEADLOCK); 837 } 838 } 839 840 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, 841 "Thread %X attempting to acquire Mutex [%s]\n", 842 ThisThreadId, AcpiUtGetMutexName (MutexId))); 843 | 827 { 828 if (i == MutexId) 829 { 830 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 831 "Mutex [%s] already acquired by this thread [%X]\n", 832 AcpiUtGetMutexName (MutexId), ThisThreadId)); 833 834 return (AE_ALREADY_ACQUIRED); --- 7 unchanged lines hidden (view full) --- 842 return (AE_ACQUIRE_DEADLOCK); 843 } 844 } 845 846 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, 847 "Thread %X attempting to acquire Mutex [%s]\n", 848 ThisThreadId, AcpiUtGetMutexName (MutexId))); 849 |
844 Status = AcpiOsWaitSemaphore (AcpiGbl_AcpiMutexInfo[MutexId].Mutex, | 850 Status = AcpiOsWaitSemaphore (AcpiGbl_MutexInfo[MutexId].Mutex, |
845 1, ACPI_WAIT_FOREVER); 846 if (ACPI_SUCCESS (Status)) 847 { 848 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", 849 ThisThreadId, AcpiUtGetMutexName (MutexId))); 850 | 851 1, ACPI_WAIT_FOREVER); 852 if (ACPI_SUCCESS (Status)) 853 { 854 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", 855 ThisThreadId, AcpiUtGetMutexName (MutexId))); 856 |
851 AcpiGbl_AcpiMutexInfo[MutexId].UseCount++; 852 AcpiGbl_AcpiMutexInfo[MutexId].OwnerId = ThisThreadId; | 857 AcpiGbl_MutexInfo[MutexId].UseCount++; 858 AcpiGbl_MutexInfo[MutexId].OwnerId = ThisThreadId; |
853 } 854 else 855 { 856 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not acquire Mutex [%s] %s\n", 857 ThisThreadId, AcpiUtGetMutexName (MutexId), 858 AcpiFormatException (Status))); 859 } 860 --- 25 unchanged lines hidden (view full) --- 886 ACPI_FUNCTION_NAME ("UtReleaseMutex"); 887 888 889 ThisThreadId = AcpiOsGetThreadId (); 890 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, 891 "Thread %X releasing Mutex [%s]\n", ThisThreadId, 892 AcpiUtGetMutexName (MutexId))); 893 | 859 } 860 else 861 { 862 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not acquire Mutex [%s] %s\n", 863 ThisThreadId, AcpiUtGetMutexName (MutexId), 864 AcpiFormatException (Status))); 865 } 866 --- 25 unchanged lines hidden (view full) --- 892 ACPI_FUNCTION_NAME ("UtReleaseMutex"); 893 894 895 ThisThreadId = AcpiOsGetThreadId (); 896 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, 897 "Thread %X releasing Mutex [%s]\n", ThisThreadId, 898 AcpiUtGetMutexName (MutexId))); 899 |
894 if (MutexId > MAX_MTX) | 900 if (MutexId > MAX_MUTEX) |
895 { 896 return (AE_BAD_PARAMETER); 897 } 898 899 /* 900 * Mutex must be acquired in order to release it! 901 */ | 901 { 902 return (AE_BAD_PARAMETER); 903 } 904 905 /* 906 * Mutex must be acquired in order to release it! 907 */ |
902 if (AcpiGbl_AcpiMutexInfo[MutexId].OwnerId == ACPI_MUTEX_NOT_ACQUIRED) | 908 if (AcpiGbl_MutexInfo[MutexId].OwnerId == ACPI_MUTEX_NOT_ACQUIRED) |
903 { 904 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 905 "Mutex [%s] is not acquired, cannot release\n", 906 AcpiUtGetMutexName (MutexId))); 907 908 return (AE_NOT_ACQUIRED); 909 } 910 911 /* 912 * Deadlock prevention. Check if this thread owns any mutexes of value 913 * greater than this one. If so, the thread has violated the mutex 914 * ordering rule. This indicates a coding error somewhere in 915 * the ACPI subsystem code. 916 */ | 909 { 910 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 911 "Mutex [%s] is not acquired, cannot release\n", 912 AcpiUtGetMutexName (MutexId))); 913 914 return (AE_NOT_ACQUIRED); 915 } 916 917 /* 918 * Deadlock prevention. Check if this thread owns any mutexes of value 919 * greater than this one. If so, the thread has violated the mutex 920 * ordering rule. This indicates a coding error somewhere in 921 * the ACPI subsystem code. 922 */ |
917 for (i = MutexId; i < MAX_MTX; i++) | 923 for (i = MutexId; i < MAX_MUTEX; i++) |
918 { | 924 { |
919 if (AcpiGbl_AcpiMutexInfo[i].OwnerId == ThisThreadId) | 925 if (AcpiGbl_MutexInfo[i].OwnerId == ThisThreadId) |
920 { 921 if (i == MutexId) 922 { 923 continue; 924 } 925 926 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 927 "Invalid release order: owns [%s], releasing [%s]\n", 928 AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId))); 929 930 return (AE_RELEASE_DEADLOCK); 931 } 932 } 933 934 /* Mark unlocked FIRST */ 935 | 926 { 927 if (i == MutexId) 928 { 929 continue; 930 } 931 932 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 933 "Invalid release order: owns [%s], releasing [%s]\n", 934 AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId))); 935 936 return (AE_RELEASE_DEADLOCK); 937 } 938 } 939 940 /* Mark unlocked FIRST */ 941 |
936 AcpiGbl_AcpiMutexInfo[MutexId].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; | 942 AcpiGbl_MutexInfo[MutexId].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; |
937 | 943 |
938 Status = AcpiOsSignalSemaphore (AcpiGbl_AcpiMutexInfo[MutexId].Mutex, 1); | 944 Status = AcpiOsSignalSemaphore (AcpiGbl_MutexInfo[MutexId].Mutex, 1); |
939 940 if (ACPI_FAILURE (Status)) 941 { 942 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not release Mutex [%s] %s\n", 943 ThisThreadId, AcpiUtGetMutexName (MutexId), 944 AcpiFormatException (Status))); 945 } 946 else --- 705 unchanged lines hidden --- | 945 946 if (ACPI_FAILURE (Status)) 947 { 948 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not release Mutex [%s] %s\n", 949 ThisThreadId, AcpiUtGetMutexName (MutexId), 950 AcpiFormatException (Status))); 951 } 952 else --- 705 unchanged lines hidden --- |