diff options
Diffstat (limited to 'drivers/acpi/utilities')
-rw-r--r-- | drivers/acpi/utilities/Makefile | 2 | ||||
-rw-r--r-- | drivers/acpi/utilities/utalloc.c | 304 | ||||
-rw-r--r-- | drivers/acpi/utilities/utcache.c | 322 | ||||
-rw-r--r-- | drivers/acpi/utilities/utdebug.c | 4 | ||||
-rw-r--r-- | drivers/acpi/utilities/utglobal.c | 38 | ||||
-rw-r--r-- | drivers/acpi/utilities/utinit.c | 2 | ||||
-rw-r--r-- | drivers/acpi/utilities/utmisc.c | 689 | ||||
-rw-r--r-- | drivers/acpi/utilities/utmutex.c | 380 | ||||
-rw-r--r-- | drivers/acpi/utilities/utobject.c | 34 | ||||
-rw-r--r-- | drivers/acpi/utilities/utstate.c | 376 | ||||
-rw-r--r-- | drivers/acpi/utilities/utxface.c | 23 |
11 files changed, 1221 insertions, 953 deletions
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 @@ # obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ - utcopy.o utdelete.o utglobal.o utmath.o utobject.o + utcopy.o utdelete.o utglobal.o utmath.o utobject.o utstate.o utmutex.o utobject.o utcache.o EXTRA_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 @@ /****************************************************************************** * - * Module Name: utalloc - local cache and memory allocation routines + * Module Name: utalloc - local memory allocation routines * *****************************************************************************/ @@ -52,12 +52,10 @@ #ifdef ACPI_DBG_TRACK_ALLOCATIONS static struct acpi_debug_mem_block * acpi_ut_find_allocation ( - u32 list_id, void *allocation); static acpi_status acpi_ut_track_allocation ( - u32 list_id, struct acpi_debug_mem_block *address, acpi_size size, u8 alloc_type, @@ -67,206 +65,118 @@ acpi_ut_track_allocation ( static acpi_status acpi_ut_remove_allocation ( - u32 list_id, struct acpi_debug_mem_block *address, u32 component, char *module, u32 line); #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ - -/******************************************************************************* - * - * FUNCTION: acpi_ut_release_to_cache - * - * PARAMETERS: list_id - Memory list/cache ID - * Object - The object to be released - * - * RETURN: None - * - * DESCRIPTION: Release an object to the specified cache. If cache is full, - * the object is deleted. - * - ******************************************************************************/ - -void -acpi_ut_release_to_cache ( - u32 list_id, - void *object) -{ - struct acpi_memory_list *cache_info; - - - ACPI_FUNCTION_ENTRY (); - - - cache_info = &acpi_gbl_memory_lists[list_id]; - -#ifdef ACPI_ENABLE_OBJECT_CACHE - - /* If walk cache is full, just free this wallkstate object */ - - if (cache_info->cache_depth >= cache_info->max_cache_depth) { - ACPI_MEM_FREE (object); - ACPI_MEM_TRACKING (cache_info->total_freed++); - } - - /* Otherwise put this object back into the cache */ - - else { - if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) { - return; - } - - /* Mark the object as cached */ - - ACPI_MEMSET (object, 0xCA, cache_info->object_size); - ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED); - - /* Put the object at the head of the cache list */ - - * (ACPI_CAST_INDIRECT_PTR (char, - &(((char *) object)[cache_info->link_offset]))) = cache_info->list_head; - cache_info->list_head = object; - cache_info->cache_depth++; - - (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); - } - -#else - - /* Object cache is disabled; just free the object */ - - ACPI_MEM_FREE (object); - ACPI_MEM_TRACKING (cache_info->total_freed++); +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +static acpi_status +acpi_ut_create_list ( + char *list_name, + u16 object_size, + acpi_handle *return_cache); #endif -} /******************************************************************************* * - * FUNCTION: acpi_ut_acquire_from_cache + * FUNCTION: acpi_ut_create_caches * - * PARAMETERS: list_id - Memory list ID + * PARAMETERS: None * - * RETURN: A requested object. NULL if the object could not be - * allocated. + * RETURN: Status * - * DESCRIPTION: Get an object from the specified cache. If cache is empty, - * the object is allocated. + * DESCRIPTION: Create all local caches * ******************************************************************************/ -void * -acpi_ut_acquire_from_cache ( - u32 list_id) +acpi_status +acpi_ut_create_caches ( + void) { - struct acpi_memory_list *cache_info; - void *object; - - - ACPI_FUNCTION_NAME ("ut_acquire_from_cache"); + acpi_status status; - cache_info = &acpi_gbl_memory_lists[list_id]; +#ifdef ACPI_DBG_TRACK_ALLOCATIONS -#ifdef ACPI_ENABLE_OBJECT_CACHE + /* Memory allocation lists */ - if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) { - return (NULL); + status = acpi_ut_create_list ("Acpi-Global", 0, + &acpi_gbl_global_list); + if (ACPI_FAILURE (status)) { + return (status); } - ACPI_MEM_TRACKING (cache_info->cache_requests++); - - /* Check the cache first */ - - if (cache_info->list_head) { - /* There is an object available, use it */ - - object = cache_info->list_head; - cache_info->list_head = *(ACPI_CAST_INDIRECT_PTR (char, - &(((char *) object)[cache_info->link_offset]))); - - ACPI_MEM_TRACKING (cache_info->cache_hits++); - cache_info->cache_depth--; - -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p from %s\n", - object, acpi_gbl_memory_lists[list_id].list_name)); + status = acpi_ut_create_list ("Acpi-Namespace", sizeof (struct acpi_namespace_node), + &acpi_gbl_ns_node_list); + if (ACPI_FAILURE (status)) { + return (status); + } #endif - if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) { - return (NULL); - } - - /* Clear (zero) the previously used Object */ + /* Object Caches, for frequently used objects */ - ACPI_MEMSET (object, 0, cache_info->object_size); + status = acpi_os_create_cache ("acpi_state", sizeof (union acpi_generic_state), + ACPI_MAX_STATE_CACHE_DEPTH, &acpi_gbl_state_cache); + if (ACPI_FAILURE (status)) { + return (status); } - else { - /* The cache is empty, create a new object */ - - /* Avoid deadlock with ACPI_MEM_CALLOCATE */ - - if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) { - return (NULL); - } - - object = ACPI_MEM_CALLOCATE (cache_info->object_size); - ACPI_MEM_TRACKING (cache_info->total_allocated++); + status = acpi_os_create_cache ("acpi_parse", sizeof (struct acpi_parse_obj_common), + ACPI_MAX_PARSE_CACHE_DEPTH, &acpi_gbl_ps_node_cache); + if (ACPI_FAILURE (status)) { + return (status); } -#else - - /* Object cache is disabled; just allocate the object */ + status = acpi_os_create_cache ("acpi_parse_ext", sizeof (struct acpi_parse_obj_named), + ACPI_MAX_EXTPARSE_CACHE_DEPTH, &acpi_gbl_ps_node_ext_cache); + if (ACPI_FAILURE (status)) { + return (status); + } - object = ACPI_MEM_CALLOCATE (cache_info->object_size); - ACPI_MEM_TRACKING (cache_info->total_allocated++); -#endif + status = acpi_os_create_cache ("acpi_operand", sizeof (union acpi_operand_object), + ACPI_MAX_OBJECT_CACHE_DEPTH, &acpi_gbl_operand_cache); + if (ACPI_FAILURE (status)) { + return (status); + } - return (object); + return (AE_OK); } -#ifdef ACPI_ENABLE_OBJECT_CACHE /******************************************************************************* * - * FUNCTION: acpi_ut_delete_generic_cache + * FUNCTION: acpi_ut_delete_caches * - * PARAMETERS: list_id - Memory list ID + * PARAMETERS: None * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Free all objects within the requested cache. + * DESCRIPTION: Purge and delete all local caches * ******************************************************************************/ -void -acpi_ut_delete_generic_cache ( - u32 list_id) +acpi_status +acpi_ut_delete_caches ( + void) { - struct acpi_memory_list *cache_info; - char *next; + (void) acpi_os_delete_cache (acpi_gbl_state_cache); + acpi_gbl_state_cache = NULL; - ACPI_FUNCTION_ENTRY (); - + (void) acpi_os_delete_cache (acpi_gbl_operand_cache); + acpi_gbl_operand_cache = NULL; - cache_info = &acpi_gbl_memory_lists[list_id]; - while (cache_info->list_head) { - /* Delete one cached state object */ + (void) acpi_os_delete_cache (acpi_gbl_ps_node_cache); + acpi_gbl_ps_node_cache = NULL; - next = *(ACPI_CAST_INDIRECT_PTR (char, - &(((char *) cache_info->list_head)[cache_info->link_offset]))); - ACPI_MEM_FREE (cache_info->list_head); + (void) acpi_os_delete_cache (acpi_gbl_ps_node_ext_cache); + acpi_gbl_ps_node_ext_cache = NULL; - cache_info->list_head = next; - cache_info->cache_depth--; - } + return (AE_OK); } -#endif - /******************************************************************************* * @@ -500,6 +410,43 @@ acpi_ut_callocate ( * occurs in the body of acpi_ut_free. */ +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_list + * + * PARAMETERS: cache_name - Ascii name for the cache + * object_size - Size of each cached object + * return_cache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a local memory list for tracking purposed + * + ******************************************************************************/ + +static acpi_status +acpi_ut_create_list ( + char *list_name, + u16 object_size, + acpi_handle *return_cache) +{ + struct acpi_memory_list *cache; + + + cache = acpi_os_allocate (sizeof (struct acpi_memory_list)); + if (!cache) { + return (AE_NO_MEMORY); + } + + ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list)); + + cache->list_name = list_name; + cache->object_size = object_size; + + *return_cache = cache; + return (AE_OK); +} + /******************************************************************************* * @@ -533,15 +480,15 @@ acpi_ut_allocate_and_track ( return (NULL); } - status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, + status = acpi_ut_track_allocation (allocation, size, ACPI_MEM_MALLOC, component, module, line); if (ACPI_FAILURE (status)) { acpi_os_free (allocation); return (NULL); } - acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++; - acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size; + acpi_gbl_global_list->total_allocated++; + acpi_gbl_global_list->current_total_size += (u32) size; return ((void *) &allocation->user_space); } @@ -583,15 +530,15 @@ acpi_ut_callocate_and_track ( return (NULL); } - status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, + status = acpi_ut_track_allocation (allocation, size, ACPI_MEM_CALLOC, component, module, line); if (ACPI_FAILURE (status)) { acpi_os_free (allocation); return (NULL); } - acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++; - acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size; + acpi_gbl_global_list->total_allocated++; + acpi_gbl_global_list->current_total_size += (u32) size; return ((void *) &allocation->user_space); } @@ -636,10 +583,10 @@ acpi_ut_free_and_track ( debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block, (((char *) allocation) - sizeof (struct acpi_debug_mem_header))); - acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_freed++; - acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size -= debug_block->size; + acpi_gbl_global_list->total_freed++; + acpi_gbl_global_list->current_total_size -= debug_block->size; - status = acpi_ut_remove_allocation (ACPI_MEM_LIST_GLOBAL, debug_block, + status = acpi_ut_remove_allocation (debug_block, component, module, line); if (ACPI_FAILURE (status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n", @@ -658,8 +605,7 @@ acpi_ut_free_and_track ( * * FUNCTION: acpi_ut_find_allocation * - * PARAMETERS: list_id - Memory list to search - * Allocation - Address of allocated memory + * PARAMETERS: Allocation - Address of allocated memory * * RETURN: A list element if found; NULL otherwise. * @@ -669,7 +615,6 @@ acpi_ut_free_and_track ( static struct acpi_debug_mem_block * acpi_ut_find_allocation ( - u32 list_id, void *allocation) { struct acpi_debug_mem_block *element; @@ -678,11 +623,7 @@ acpi_ut_find_allocation ( ACPI_FUNCTION_ENTRY (); - if (list_id > ACPI_MEM_LIST_MAX) { - return (NULL); - } - - element = acpi_gbl_memory_lists[list_id].list_head; + element = acpi_gbl_global_list->list_head; /* Search for the address. */ @@ -702,8 +643,7 @@ acpi_ut_find_allocation ( * * FUNCTION: acpi_ut_track_allocation * - * PARAMETERS: list_id - Memory list to search - * Allocation - Address of allocated memory + * PARAMETERS: Allocation - Address of allocated memory * Size - Size of the allocation * alloc_type - MEM_MALLOC or MEM_CALLOC * Component - Component type of caller @@ -718,7 +658,6 @@ acpi_ut_find_allocation ( static acpi_status acpi_ut_track_allocation ( - u32 list_id, struct acpi_debug_mem_block *allocation, acpi_size size, u8 alloc_type, @@ -734,11 +673,7 @@ acpi_ut_track_allocation ( ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation); - if (list_id > ACPI_MEM_LIST_MAX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - mem_list = &acpi_gbl_memory_lists[list_id]; + mem_list = acpi_gbl_global_list; status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); @@ -748,8 +683,7 @@ acpi_ut_track_allocation ( * Search list for this address to make sure it is not already on the list. * This will catch several kinds of problems. */ - - element = acpi_ut_find_allocation (list_id, allocation); + element = acpi_ut_find_allocation (allocation); if (element) { ACPI_REPORT_ERROR (( "ut_track_allocation: Allocation already present in list! (%p)\n", @@ -793,8 +727,7 @@ unlock_and_exit: * * FUNCTION: acpi_ut_remove_allocation * - * PARAMETERS: list_id - Memory list to search - * Allocation - Address of allocated memory + * PARAMETERS: Allocation - Address of allocated memory * Component - Component type of caller * Module - Source file name of caller * Line - Line number of caller @@ -807,7 +740,6 @@ unlock_and_exit: static acpi_status acpi_ut_remove_allocation ( - u32 list_id, struct acpi_debug_mem_block *allocation, u32 component, char *module, @@ -820,11 +752,7 @@ acpi_ut_remove_allocation ( ACPI_FUNCTION_TRACE ("ut_remove_allocation"); - if (list_id > ACPI_MEM_LIST_MAX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - mem_list = &acpi_gbl_memory_lists[list_id]; + mem_list = acpi_gbl_global_list; if (NULL == mem_list->list_head) { /* No allocations! */ @@ -959,7 +887,7 @@ acpi_ut_dump_allocations ( return; } - element = acpi_gbl_memory_lists[0].list_head; + element = acpi_gbl_global_list->list_head; while (element) { if ((element->component & component) && ((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 @@ +/****************************************************************************** + * + * Module Name: utcache - local cache allocation routines + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2005, R. Byron Moore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + +#include <acpi/acpi.h> + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utcache") + + +#ifdef ACPI_USE_LOCAL_CACHE +/******************************************************************************* + * + * FUNCTION: acpi_os_create_cache + * + * PARAMETERS: cache_name - Ascii name for the cache + * object_size - Size of each cached object + * max_depth - Maximum depth of the cache (in objects) + * return_cache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a cache object + * + ******************************************************************************/ + +acpi_status +acpi_os_create_cache ( + char *cache_name, + u16 object_size, + u16 max_depth, + struct acpi_memory_list **return_cache) +{ + struct acpi_memory_list *cache; + + + if (!cache_name || !return_cache || (object_size < 16)) { + return (AE_BAD_PARAMETER); + } + + /* Create the cache object */ + + cache = acpi_os_allocate (sizeof (struct acpi_memory_list)); + if (!cache) { + return (AE_NO_MEMORY); + } + + /* Populate the cache object and return it */ + + ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list)); + cache->link_offset = 8; + cache->list_name = cache_name; + cache->object_size = object_size; + cache->max_depth = max_depth; + + *return_cache = cache; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_os_purge_cache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache. + * + ******************************************************************************/ + +acpi_status +acpi_os_purge_cache ( + struct acpi_memory_list *cache) +{ + char *next; + + + ACPI_FUNCTION_ENTRY (); + + + if (!cache) { + return (AE_BAD_PARAMETER); + } + + /* Walk the list of objects in this cache */ + + while (cache->list_head) { + /* Delete and unlink one cached state object */ + + next = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) cache->list_head)[cache->link_offset]))); + ACPI_MEM_FREE (cache->list_head); + + cache->list_head = next; + cache->current_depth--; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_os_delete_cache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache and delete the + * cache object. + * + ******************************************************************************/ + +acpi_status +acpi_os_delete_cache ( + struct acpi_memory_list *cache) +{ + acpi_status status; + + + /* Purge all objects in the cache */ + + status = acpi_os_purge_cache (cache); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Now we can delete the cache object */ + + acpi_os_free (cache); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_os_release_object + * + * PARAMETERS: Cache - Handle to cache object + * Object - The object to be released + * + * RETURN: None + * + * DESCRIPTION: Release an object to the specified cache. If cache is full, + * the object is deleted. + * + ******************************************************************************/ + +acpi_status +acpi_os_release_object ( + struct acpi_memory_list *cache, + void *object) +{ + acpi_status status; + + + ACPI_FUNCTION_ENTRY (); + + + if (!cache || !object) { + return (AE_BAD_PARAMETER); + } + + /* If cache is full, just free this object */ + + if (cache->current_depth >= cache->max_depth) { + ACPI_MEM_FREE (object); + ACPI_MEM_TRACKING (cache->total_freed++); + } + + /* Otherwise put this object back into the cache */ + + else { + status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Mark the object as cached */ + + ACPI_MEMSET (object, 0xCA, cache->object_size); + ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED); + + /* Put the object at the head of the cache list */ + + * (ACPI_CAST_INDIRECT_PTR (char, + &(((char *) object)[cache->link_offset]))) = cache->list_head; + cache->list_head = object; + cache->current_depth++; + + (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_os_acquire_object + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: the acquired object. NULL on error + * + * DESCRIPTION: Get an object from the specified cache. If cache is empty, + * the object is allocated. + * + ******************************************************************************/ + +void * +acpi_os_acquire_object ( + struct acpi_memory_list *cache) +{ + acpi_status status; + void *object; + + + ACPI_FUNCTION_NAME ("ut_acquire_from_cache"); + + + if (!cache) { + return (NULL); + } + + status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (status)) { + return (NULL); + } + + ACPI_MEM_TRACKING (cache->requests++); + + /* Check the cache first */ + + if (cache->list_head) { + /* There is an object available, use it */ + + object = cache->list_head; + cache->list_head = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) object)[cache->link_offset]))); + + cache->current_depth--; + + ACPI_MEM_TRACKING (cache->hits++); + ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Object %p from %s\n", object, cache->list_name))); + + status = acpi_ut_release_mutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (status)) { + return (NULL); + } + + /* Clear (zero) the previously used Object */ + + ACPI_MEMSET (object, 0, cache->object_size); + } + else { + /* The cache is empty, create a new object */ + + ACPI_MEM_TRACKING (cache->total_allocated++); + + /* Avoid deadlock with ACPI_MEM_CALLOCATE */ + + status = acpi_ut_release_mutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (status)) { + return (NULL); + } + + object = ACPI_MEM_CALLOCATE (cache->object_size); + if (!object) { + return (NULL); + } + } + + return (object); +} +#endif /* ACPI_USE_LOCAL_CACHE */ + + 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 ( /* Dump fill spaces */ acpi_os_printf ("%*s", ((display * 2) + 1), " "); - j += display; + j += (acpi_native_uint) display; continue; } @@ -584,7 +584,7 @@ acpi_ut_dump_buffer ( break; } - j += display; + j += (acpi_native_uint) display; } /* 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 acpi_ut_init_globals ( void) { + acpi_status status; u32 i; ACPI_FUNCTION_TRACE ("ut_init_globals"); - /* Memory allocation and cache lists */ - - ACPI_MEMSET (acpi_gbl_memory_lists, 0, sizeof (struct acpi_memory_list) * ACPI_NUM_MEM_LISTS); - - acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_generic_state *) NULL)->common.next), NULL); - acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL); - acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL); - acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_operand_object *) NULL)->cache.next), NULL); - acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].link_offset = (u16) ACPI_PTR_DIFF (&(((struct acpi_walk_state *) NULL)->next), NULL); - - acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].object_size = sizeof (struct acpi_namespace_node); - acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].object_size = sizeof (union acpi_generic_state); - acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].object_size = sizeof (struct acpi_parse_obj_common); - acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].object_size = sizeof (struct acpi_parse_obj_named); - acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].object_size = sizeof (union acpi_operand_object); - acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].object_size = sizeof (struct acpi_walk_state); - - acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].max_cache_depth = ACPI_MAX_STATE_CACHE_DEPTH; - acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].max_cache_depth = ACPI_MAX_PARSE_CACHE_DEPTH; - acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].max_cache_depth = ACPI_MAX_EXTPARSE_CACHE_DEPTH; - acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].max_cache_depth = ACPI_MAX_OBJECT_CACHE_DEPTH; - acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].max_cache_depth = ACPI_MAX_WALK_CACHE_DEPTH; - - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].list_name = "Global Memory Allocation"); - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].list_name = "Namespace Nodes"); - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].list_name = "State Object Cache"); - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].list_name = "Parse Node Cache"); - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].list_name = "Extended Parse Node Cache"); - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].list_name = "Operand Object Cache"); - ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].list_name = "Tree Walk Node Cache"); + /* Create all memory caches */ + + status = acpi_ut_create_caches (); + if (ACPI_FAILURE (status)) + { + return; + } /* ACPI table structure */ 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 ( /* Purge the local caches */ - (void) acpi_purge_cached_objects (); + (void) acpi_ut_delete_caches (); /* Debug only - display leftover memory allocation, if any */ 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 @@ #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utmisc") -/* Local prototypes */ - -static acpi_status -acpi_ut_create_mutex ( - acpi_mutex_handle mutex_id); - -static acpi_status -acpi_ut_delete_mutex ( - acpi_mutex_handle mutex_id); - /******************************************************************************* * @@ -84,6 +74,10 @@ acpi_ut_strupr ( ACPI_FUNCTION_ENTRY (); + if (!src_string) { + return (NULL); + } + /* Walk entire string, uppercasing the letters */ for (string = src_string; *string; string++) { @@ -543,326 +537,6 @@ error_exit: /******************************************************************************* * - * FUNCTION: acpi_ut_mutex_initialize - * - * PARAMETERS: None. - * - * RETURN: Status - * - * DESCRIPTION: Create the system mutex objects. - * - ******************************************************************************/ - -acpi_status -acpi_ut_mutex_initialize ( - void) -{ - u32 i; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ut_mutex_initialize"); - - - /* - * Create each of the predefined mutex objects - */ - for (i = 0; i < NUM_MUTEX; i++) { - status = acpi_ut_create_mutex (i); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); - } - } - - status = acpi_os_create_lock (&acpi_gbl_gpe_lock); - return_ACPI_STATUS (status); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_mutex_terminate - * - * PARAMETERS: None. - * - * RETURN: None. - * - * DESCRIPTION: Delete all of the system mutex objects. - * - ******************************************************************************/ - -void -acpi_ut_mutex_terminate ( - void) -{ - u32 i; - - - ACPI_FUNCTION_TRACE ("ut_mutex_terminate"); - - - /* - * Delete each predefined mutex object - */ - for (i = 0; i < NUM_MUTEX; i++) { - (void) acpi_ut_delete_mutex (i); - } - - acpi_os_delete_lock (acpi_gbl_gpe_lock); - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_create_mutex - * - * PARAMETERS: mutex_iD - ID of the mutex to be created - * - * RETURN: Status - * - * DESCRIPTION: Create a mutex object. - * - ******************************************************************************/ - -static acpi_status -acpi_ut_create_mutex ( - acpi_mutex_handle mutex_id) -{ - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id); - - - if (mutex_id > MAX_MUTEX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (!acpi_gbl_mutex_info[mutex_id].mutex) { - status = acpi_os_create_semaphore (1, 1, - &acpi_gbl_mutex_info[mutex_id].mutex); - acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; - acpi_gbl_mutex_info[mutex_id].use_count = 0; - } - - return_ACPI_STATUS (status); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_delete_mutex - * - * PARAMETERS: mutex_iD - ID of the mutex to be deleted - * - * RETURN: Status - * - * DESCRIPTION: Delete a mutex object. - * - ******************************************************************************/ - -static acpi_status -acpi_ut_delete_mutex ( - acpi_mutex_handle mutex_id) -{ - acpi_status status; - - - ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id); - - - if (mutex_id > MAX_MUTEX) { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex); - - acpi_gbl_mutex_info[mutex_id].mutex = NULL; - acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; - - return_ACPI_STATUS (status); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_acquire_mutex - * - * PARAMETERS: mutex_iD - ID of the mutex to be acquired - * - * RETURN: Status - * - * DESCRIPTION: Acquire a mutex object. - * - ******************************************************************************/ - -acpi_status -acpi_ut_acquire_mutex ( - acpi_mutex_handle mutex_id) -{ - acpi_status status; - u32 this_thread_id; - - - ACPI_FUNCTION_NAME ("ut_acquire_mutex"); - - - if (mutex_id > MAX_MUTEX) { - return (AE_BAD_PARAMETER); - } - - this_thread_id = acpi_os_get_thread_id (); - -#ifdef ACPI_MUTEX_DEBUG - { - u32 i; - /* - * Mutex debug code, for internal debugging only. - * - * Deadlock prevention. Check if this thread owns any mutexes of value - * greater than or equal to this one. If so, the thread has violated - * the mutex ordering rule. This indicates a coding error somewhere in - * the ACPI subsystem code. - */ - for (i = mutex_id; i < MAX_MUTEX; i++) { - if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { - if (i == mutex_id) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Mutex [%s] already acquired by this thread [%X]\n", - acpi_ut_get_mutex_name (mutex_id), this_thread_id)); - - return (AE_ALREADY_ACQUIRED); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", - this_thread_id, acpi_ut_get_mutex_name (i), - acpi_ut_get_mutex_name (mutex_id))); - - return (AE_ACQUIRE_DEADLOCK); - } - } - } -#endif - - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %X attempting to acquire Mutex [%s]\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id))); - - status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, - 1, ACPI_WAIT_FOREVER); - if (ACPI_SUCCESS (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id))); - - acpi_gbl_mutex_info[mutex_id].use_count++; - acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id; - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Thread %X could not acquire Mutex [%s] %s\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id), - acpi_format_exception (status))); - } - - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_release_mutex - * - * PARAMETERS: mutex_iD - ID of the mutex to be released - * - * RETURN: Status - * - * DESCRIPTION: Release a mutex object. - * - ******************************************************************************/ - -acpi_status -acpi_ut_release_mutex ( - acpi_mutex_handle mutex_id) -{ - acpi_status status; - u32 this_thread_id; - - - ACPI_FUNCTION_NAME ("ut_release_mutex"); - - - this_thread_id = acpi_os_get_thread_id (); - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %X releasing Mutex [%s]\n", this_thread_id, - acpi_ut_get_mutex_name (mutex_id))); - - if (mutex_id > MAX_MUTEX) { - return (AE_BAD_PARAMETER); - } - - /* - * Mutex must be acquired in order to release it! - */ - if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Mutex [%s] is not acquired, cannot release\n", - acpi_ut_get_mutex_name (mutex_id))); - - return (AE_NOT_ACQUIRED); - } - -#ifdef ACPI_MUTEX_DEBUG - { - u32 i; - /* - * Mutex debug code, for internal debugging only. - * - * Deadlock prevention. Check if this thread owns any mutexes of value - * greater than this one. If so, the thread has violated the mutex - * ordering rule. This indicates a coding error somewhere in - * the ACPI subsystem code. - */ - for (i = mutex_id; i < MAX_MUTEX; i++) { - if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { - if (i == mutex_id) { - continue; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid release order: owns [%s], releasing [%s]\n", - acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); - - return (AE_RELEASE_DEADLOCK); - } - } - } -#endif - - /* Mark unlocked FIRST */ - - acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; - - status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1); - - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Thread %X could not release Mutex [%s] %s\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id), - acpi_format_exception (status))); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", - this_thread_id, acpi_ut_get_mutex_name (mutex_id))); - } - - return (status); -} - - -/******************************************************************************* - * * FUNCTION: acpi_ut_create_update_state_and_push * * PARAMETERS: Object - Object to be added to the new state @@ -905,361 +579,6 @@ acpi_ut_create_update_state_and_push ( /******************************************************************************* * - * FUNCTION: acpi_ut_create_pkg_state_and_push - * - * PARAMETERS: Object - Object to be added to the new state - * Action - Increment/Decrement - * state_list - List the state will be added to - * - * RETURN: Status - * - * DESCRIPTION: Create a new state and push it - * - ******************************************************************************/ - -#ifdef ACPI_FUTURE_USAGE -acpi_status -acpi_ut_create_pkg_state_and_push ( - void *internal_object, - void *external_object, - u16 index, - union acpi_generic_state **state_list) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_ENTRY (); - - - state = acpi_ut_create_pkg_state (internal_object, external_object, index); - if (!state) { - return (AE_NO_MEMORY); - } - - acpi_ut_push_generic_state (state_list, state); - return (AE_OK); -} -#endif /* ACPI_FUTURE_USAGE */ - -/******************************************************************************* - * - * FUNCTION: acpi_ut_push_generic_state - * - * PARAMETERS: list_head - Head of the state stack - * State - State object to push - * - * RETURN: None - * - * DESCRIPTION: Push a state object onto a state stack - * - ******************************************************************************/ - -void -acpi_ut_push_generic_state ( - union acpi_generic_state **list_head, - union acpi_generic_state *state) -{ - ACPI_FUNCTION_TRACE ("ut_push_generic_state"); - - - /* Push the state object onto the front of the list (stack) */ - - state->common.next = *list_head; - *list_head = state; - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_pop_generic_state - * - * PARAMETERS: list_head - Head of the state stack - * - * RETURN: The popped state object - * - * DESCRIPTION: Pop a state object from a state stack - * - ******************************************************************************/ - -union acpi_generic_state * -acpi_ut_pop_generic_state ( - union acpi_generic_state **list_head) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE ("ut_pop_generic_state"); - - - /* Remove the state object at the head of the list (stack) */ - - state = *list_head; - if (state) { - /* Update the list head */ - - *list_head = state->common.next; - } - - return_PTR (state); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_create_generic_state - * - * PARAMETERS: None - * - * RETURN: The new state object. NULL on failure. - * - * DESCRIPTION: Create a generic state object. Attempt to obtain one from - * the global state cache; If none available, create a new one. - * - ******************************************************************************/ - -union acpi_generic_state * -acpi_ut_create_generic_state ( - void) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_ENTRY (); - - - state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_STATE); - - /* Initialize */ - - if (state) { - state->common.data_type = ACPI_DESC_TYPE_STATE; - } - - return (state); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_create_thread_state - * - * PARAMETERS: None - * - * RETURN: New Thread State. NULL on failure - * - * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used - * to track per-thread info during method execution - * - ******************************************************************************/ - -struct acpi_thread_state * -acpi_ut_create_thread_state ( - void) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE ("ut_create_thread_state"); - - - /* Create the generic state object */ - - state = acpi_ut_create_generic_state (); - if (!state) { - return_PTR (NULL); - } - - /* Init fields specific to the update struct */ - - state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD; - state->thread.thread_id = acpi_os_get_thread_id (); - - return_PTR ((struct acpi_thread_state *) state); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_create_update_state - * - * PARAMETERS: Object - Initial Object to be installed in the state - * Action - Update action to be performed - * - * RETURN: New state object, null on failure - * - * DESCRIPTION: Create an "Update State" - a flavor of the generic state used - * to update reference counts and delete complex objects such - * as packages. - * - ******************************************************************************/ - -union acpi_generic_state * -acpi_ut_create_update_state ( - union acpi_operand_object *object, - u16 action) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object); - - - /* Create the generic state object */ - - state = acpi_ut_create_generic_state (); - if (!state) { - return_PTR (NULL); - } - - /* Init fields specific to the update struct */ - - state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE; - state->update.object = object; - state->update.value = action; - - return_PTR (state); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_create_pkg_state - * - * PARAMETERS: Object - Initial Object to be installed in the state - * Action - Update action to be performed - * - * RETURN: New state object, null on failure - * - * DESCRIPTION: Create a "Package State" - * - ******************************************************************************/ - -union acpi_generic_state * -acpi_ut_create_pkg_state ( - void *internal_object, - void *external_object, - u16 index) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object); - - - /* Create the generic state object */ - - state = acpi_ut_create_generic_state (); - if (!state) { - return_PTR (NULL); - } - - /* Init fields specific to the update struct */ - - state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE; - state->pkg.source_object = (union acpi_operand_object *) internal_object; - state->pkg.dest_object = external_object; - state->pkg.index = index; - state->pkg.num_packages = 1; - - return_PTR (state); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_create_control_state - * - * PARAMETERS: None - * - * RETURN: New state object, null on failure - * - * DESCRIPTION: Create a "Control State" - a flavor of the generic state used - * to support nested IF/WHILE constructs in the AML. - * - ******************************************************************************/ - -union acpi_generic_state * -acpi_ut_create_control_state ( - void) -{ - union acpi_generic_state *state; - - - ACPI_FUNCTION_TRACE ("ut_create_control_state"); - - - /* Create the generic state object */ - - state = acpi_ut_create_generic_state (); - if (!state) { - return_PTR (NULL); - } - - /* Init fields specific to the control struct */ - - state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL; - state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; - - return_PTR (state); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_delete_generic_state - * - * PARAMETERS: State - The state object to be deleted - * - * RETURN: None - * - * DESCRIPTION: Put a state object back into the global state cache. The object - * is not actually freed at this time. - * - ******************************************************************************/ - -void -acpi_ut_delete_generic_state ( - union acpi_generic_state *state) -{ - ACPI_FUNCTION_TRACE ("ut_delete_generic_state"); - - - acpi_ut_release_to_cache (ACPI_MEM_LIST_STATE, state); - return_VOID; -} - - -#ifdef ACPI_ENABLE_OBJECT_CACHE -/******************************************************************************* - * - * FUNCTION: acpi_ut_delete_generic_state_cache - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Purge the global state object cache. Used during subsystem - * termination. - * - ******************************************************************************/ - -void -acpi_ut_delete_generic_state_cache ( - void) -{ - ACPI_FUNCTION_TRACE ("ut_delete_generic_state_cache"); - - - acpi_ut_delete_generic_cache (ACPI_MEM_LIST_STATE); - return_VOID; -} -#endif - - -/******************************************************************************* - * * FUNCTION: acpi_ut_walk_package_tree * * 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 @@ +/******************************************************************************* + * + * Module Name: utmutex - local mutex support + * + ******************************************************************************/ + +/* + * Copyright (C) 2000 - 2005, R. Byron Moore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + +#include <acpi/acpi.h> + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utmutex") + +/* Local prototypes */ + +static acpi_status +acpi_ut_create_mutex ( + acpi_mutex_handle mutex_id); + +static acpi_status +acpi_ut_delete_mutex ( + acpi_mutex_handle mutex_id); + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_mutex_initialize + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Create the system mutex objects. + * + ******************************************************************************/ + +acpi_status +acpi_ut_mutex_initialize ( + void) +{ + u32 i; + acpi_status status; + + + ACPI_FUNCTION_TRACE ("ut_mutex_initialize"); + + + /* + * Create each of the predefined mutex objects + */ + for (i = 0; i < NUM_MUTEX; i++) { + status = acpi_ut_create_mutex (i); + if (ACPI_FAILURE (status)) { + return_ACPI_STATUS (status); + } + } + + status = acpi_os_create_lock (&acpi_gbl_gpe_lock); + return_ACPI_STATUS (status); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_mutex_terminate + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete all of the system mutex objects. + * + ******************************************************************************/ + +void +acpi_ut_mutex_terminate ( + void) +{ + u32 i; + + + ACPI_FUNCTION_TRACE ("ut_mutex_terminate"); + + + /* + * Delete each predefined mutex object + */ + for (i = 0; i < NUM_MUTEX; i++) { + (void) acpi_ut_delete_mutex (i); + } + + acpi_os_delete_lock (acpi_gbl_gpe_lock); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_mutex + * + * PARAMETERS: mutex_iD - ID of the mutex to be created + * + * RETURN: Status + * + * DESCRIPTION: Create a mutex object. + * + ******************************************************************************/ + +static acpi_status +acpi_ut_create_mutex ( + acpi_mutex_handle mutex_id) +{ + acpi_status status = AE_OK; + + + ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id); + + + if (mutex_id > MAX_MUTEX) { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!acpi_gbl_mutex_info[mutex_id].mutex) { + status = acpi_os_create_semaphore (1, 1, + &acpi_gbl_mutex_info[mutex_id].mutex); + acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; + acpi_gbl_mutex_info[mutex_id].use_count = 0; + } + + return_ACPI_STATUS (status); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_delete_mutex + * + * PARAMETERS: mutex_iD - ID of the mutex to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Delete a mutex object. + * + ******************************************************************************/ + +static acpi_status +acpi_ut_delete_mutex ( + acpi_mutex_handle mutex_id) +{ + acpi_status status; + + + ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id); + + + if (mutex_id > MAX_MUTEX) { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex); + + acpi_gbl_mutex_info[mutex_id].mutex = NULL; + acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; + + return_ACPI_STATUS (status); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_acquire_mutex + * + * PARAMETERS: mutex_iD - ID of the mutex to be acquired + * + * RETURN: Status + * + * DESCRIPTION: Acquire a mutex object. + * + ******************************************************************************/ + +acpi_status +acpi_ut_acquire_mutex ( + acpi_mutex_handle mutex_id) +{ + acpi_status status; + u32 this_thread_id; + + + ACPI_FUNCTION_NAME ("ut_acquire_mutex"); + + + if (mutex_id > MAX_MUTEX) { + return (AE_BAD_PARAMETER); + } + + this_thread_id = acpi_os_get_thread_id (); + +#ifdef ACPI_MUTEX_DEBUG + { + u32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than or equal to this one. If so, the thread has violated + * the mutex ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = mutex_id; i < MAX_MUTEX; i++) { + if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { + if (i == mutex_id) { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Mutex [%s] already acquired by this thread [%X]\n", + acpi_ut_get_mutex_name (mutex_id), this_thread_id)); + + return (AE_ALREADY_ACQUIRED); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", + this_thread_id, acpi_ut_get_mutex_name (i), + acpi_ut_get_mutex_name (mutex_id))); + + return (AE_ACQUIRE_DEADLOCK); + } + } + } +#endif + + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, + "Thread %X attempting to acquire Mutex [%s]\n", + this_thread_id, acpi_ut_get_mutex_name (mutex_id))); + + status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, + 1, ACPI_WAIT_FOREVER); + if (ACPI_SUCCESS (status)) { + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", + this_thread_id, acpi_ut_get_mutex_name (mutex_id))); + + acpi_gbl_mutex_info[mutex_id].use_count++; + acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id; + } + else { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Thread %X could not acquire Mutex [%s] %s\n", + this_thread_id, acpi_ut_get_mutex_name (mutex_id), + acpi_format_exception (status))); + } + + return (status); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_release_mutex + * + * PARAMETERS: mutex_iD - ID of the mutex to be released + * + * RETURN: Status + * + * DESCRIPTION: Release a mutex object. + * + ******************************************************************************/ + +acpi_status +acpi_ut_release_mutex ( + acpi_mutex_handle mutex_id) +{ + acpi_status status; + u32 this_thread_id; + + + ACPI_FUNCTION_NAME ("ut_release_mutex"); + + + this_thread_id = acpi_os_get_thread_id (); + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, + "Thread %X releasing Mutex [%s]\n", this_thread_id, + acpi_ut_get_mutex_name (mutex_id))); + + if (mutex_id > MAX_MUTEX) { + return (AE_BAD_PARAMETER); + } + + /* + * Mutex must be acquired in order to release it! + */ + if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Mutex [%s] is not acquired, cannot release\n", + acpi_ut_get_mutex_name (mutex_id))); + + return (AE_NOT_ACQUIRED); + } + +#ifdef ACPI_MUTEX_DEBUG + { + u32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than this one. If so, the thread has violated the mutex + * ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = mutex_id; i < MAX_MUTEX; i++) { + if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { + if (i == mutex_id) { + continue; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid release order: owns [%s], releasing [%s]\n", + acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); + + return (AE_RELEASE_DEADLOCK); + } + } + } +#endif + + /* Mark unlocked FIRST */ + + acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; + + status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1); + + if (ACPI_FAILURE (status)) { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Thread %X could not release Mutex [%s] %s\n", + this_thread_id, acpi_ut_get_mutex_name (mutex_id), + acpi_format_exception (status))); + } + else { + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", + this_thread_id, acpi_ut_get_mutex_name (mutex_id))); + } + + return (status); +} + + 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 ( ACPI_FUNCTION_TRACE ("ut_allocate_object_desc_dbg"); - object = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_OPERAND); + object = acpi_os_acquire_object (acpi_gbl_operand_cache); if (!object) { _ACPI_REPORT_ERROR (module_name, line_number, component_id, ("Could not allocate an object descriptor\n")); @@ -347,7 +347,7 @@ acpi_ut_allocate_object_desc_dbg ( } /* Mark the descriptor type */ - + memset(object, 0, sizeof(union acpi_operand_object)); ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND); ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", @@ -385,37 +385,9 @@ acpi_ut_delete_object_desc ( return_VOID; } - acpi_ut_release_to_cache (ACPI_MEM_LIST_OPERAND, object); - - return_VOID; -} - - -#ifdef ACPI_ENABLE_OBJECT_CACHE -/******************************************************************************* - * - * FUNCTION: acpi_ut_delete_object_cache - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Purge the global state object cache. Used during subsystem - * termination. - * - ******************************************************************************/ - -void -acpi_ut_delete_object_cache ( - void) -{ - ACPI_FUNCTION_TRACE ("ut_delete_object_cache"); - - - acpi_ut_delete_generic_cache (ACPI_MEM_LIST_OPERAND); + (void) acpi_os_release_object (acpi_gbl_operand_cache, object); return_VOID; } -#endif /******************************************************************************* 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 @@ +/******************************************************************************* + * + * Module Name: utstate - state object support procedures + * + ******************************************************************************/ + +/* + * Copyright (C) 2000 - 2005, R. Byron Moore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + +#include <acpi/acpi.h> + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utstate") + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_pkg_state_and_push + * + * PARAMETERS: Object - Object to be added to the new state + * Action - Increment/Decrement + * state_list - List the state will be added to + * + * RETURN: Status + * + * DESCRIPTION: Create a new state and push it + * + ******************************************************************************/ + +acpi_status +acpi_ut_create_pkg_state_and_push ( + void *internal_object, + void *external_object, + u16 index, + union acpi_generic_state **state_list) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_ENTRY (); + + + state = acpi_ut_create_pkg_state (internal_object, external_object, index); + if (!state) { + return (AE_NO_MEMORY); + } + + acpi_ut_push_generic_state (state_list, state); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_push_generic_state + * + * PARAMETERS: list_head - Head of the state stack + * State - State object to push + * + * RETURN: None + * + * DESCRIPTION: Push a state object onto a state stack + * + ******************************************************************************/ + +void +acpi_ut_push_generic_state ( + union acpi_generic_state **list_head, + union acpi_generic_state *state) +{ + ACPI_FUNCTION_TRACE ("ut_push_generic_state"); + + + /* Push the state object onto the front of the list (stack) */ + + state->common.next = *list_head; + *list_head = state; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_pop_generic_state + * + * PARAMETERS: list_head - Head of the state stack + * + * RETURN: The popped state object + * + * DESCRIPTION: Pop a state object from a state stack + * + ******************************************************************************/ + +union acpi_generic_state * +acpi_ut_pop_generic_state ( + union acpi_generic_state **list_head) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_TRACE ("ut_pop_generic_state"); + + + /* Remove the state object at the head of the list (stack) */ + + state = *list_head; + if (state) { + /* Update the list head */ + + *list_head = state->common.next; + } + + return_PTR (state); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_generic_state + * + * PARAMETERS: None + * + * RETURN: The new state object. NULL on failure. + * + * DESCRIPTION: Create a generic state object. Attempt to obtain one from + * the global state cache; If none available, create a new one. + * + ******************************************************************************/ + +union acpi_generic_state * +acpi_ut_create_generic_state ( + void) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_ENTRY (); + + + state = acpi_os_acquire_object (acpi_gbl_state_cache); + if (state) { + /* Initialize */ + memset(state, 0, sizeof(union acpi_generic_state)); + state->common.data_type = ACPI_DESC_TYPE_STATE; + } + + return (state); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_thread_state + * + * PARAMETERS: None + * + * RETURN: New Thread State. NULL on failure + * + * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used + * to track per-thread info during method execution + * + ******************************************************************************/ + +struct acpi_thread_state * +acpi_ut_create_thread_state ( + void) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_TRACE ("ut_create_thread_state"); + + + /* Create the generic state object */ + + state = acpi_ut_create_generic_state (); + if (!state) { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD; + state->thread.thread_id = acpi_os_get_thread_id (); + + return_PTR ((struct acpi_thread_state *) state); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_update_state + * + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create an "Update State" - a flavor of the generic state used + * to update reference counts and delete complex objects such + * as packages. + * + ******************************************************************************/ + +union acpi_generic_state * +acpi_ut_create_update_state ( + union acpi_operand_object *object, + u16 action) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object); + + + /* Create the generic state object */ + + state = acpi_ut_create_generic_state (); + if (!state) { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE; + state->update.object = object; + state->update.value = action; + + return_PTR (state); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_pkg_state + * + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create a "Package State" + * + ******************************************************************************/ + +union acpi_generic_state * +acpi_ut_create_pkg_state ( + void *internal_object, + void *external_object, + u16 index) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object); + + + /* Create the generic state object */ + + state = acpi_ut_create_generic_state (); + if (!state) { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE; + state->pkg.source_object = (union acpi_operand_object *) internal_object; + state->pkg.dest_object = external_object; + state->pkg.index = index; + state->pkg.num_packages = 1; + + return_PTR (state); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_control_state + * + * PARAMETERS: None + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create a "Control State" - a flavor of the generic state used + * to support nested IF/WHILE constructs in the AML. + * + ******************************************************************************/ + +union acpi_generic_state * +acpi_ut_create_control_state ( + void) +{ + union acpi_generic_state *state; + + + ACPI_FUNCTION_TRACE ("ut_create_control_state"); + + + /* Create the generic state object */ + + state = acpi_ut_create_generic_state (); + if (!state) { + return_PTR (NULL); + } + + /* Init fields specific to the control struct */ + + state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL; + state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; + + return_PTR (state); +} + + +/******************************************************************************* + * + * FUNCTION: acpi_ut_delete_generic_state + * + * PARAMETERS: State - The state object to be deleted + * + * RETURN: None + * + * DESCRIPTION: Put a state object back into the global state cache. The object + * is not actually freed at this time. + * + ******************************************************************************/ + +void +acpi_ut_delete_generic_state ( + union acpi_generic_state *state) +{ + ACPI_FUNCTION_TRACE ("ut_delete_generic_state"); + + + (void) acpi_os_release_object (acpi_gbl_state_cache, state); + return_VOID; +} + + 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 @@ #include <acpi/acpi.h> #include <acpi/acevents.h> #include <acpi/acnamesp.h> -#include <acpi/acparser.h> -#include <acpi/acdispat.h> #include <acpi/acdebug.h> #define _COMPONENT ACPI_UTILITIES @@ -79,11 +77,6 @@ acpi_initialize_subsystem ( ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ()); - - /* Initialize all globals used by the subsystem */ - - acpi_ut_init_globals (); - /* Initialize the OS-Dependent layer */ status = acpi_os_initialize (); @@ -93,6 +86,10 @@ acpi_initialize_subsystem ( return_ACPI_STATUS (status); } + /* Initialize all globals used by the subsystem */ + + acpi_ut_init_globals (); + /* Create the default mutex objects */ status = acpi_ut_mutex_initialize (); @@ -522,13 +519,9 @@ acpi_purge_cached_objects ( { ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects"); - -#ifdef ACPI_ENABLE_OBJECT_CACHE - acpi_ut_delete_generic_state_cache (); - acpi_ut_delete_object_cache (); - acpi_ds_delete_walk_state_cache (); - acpi_ps_delete_parse_cache (); -#endif - + (void) acpi_os_purge_cache (acpi_gbl_state_cache); + (void) acpi_os_purge_cache (acpi_gbl_operand_cache); + (void) acpi_os_purge_cache (acpi_gbl_ps_node_cache); + (void) acpi_os_purge_cache (acpi_gbl_ps_node_ext_cache); return_ACPI_STATUS (AE_OK); } |