diff options
Diffstat (limited to 'drivers/acpi/utilities')
-rw-r--r-- | drivers/acpi/utilities/Makefile | 2 | ||||
-rw-r--r-- | drivers/acpi/utilities/utalloc.c | 713 | ||||
-rw-r--r-- | drivers/acpi/utilities/utcache.c | 305 | ||||
-rw-r--r-- | drivers/acpi/utilities/utcopy.c | 592 | ||||
-rw-r--r-- | drivers/acpi/utilities/utdebug.c | 400 | ||||
-rw-r--r-- | drivers/acpi/utilities/utdelete.c | 431 | ||||
-rw-r--r-- | drivers/acpi/utilities/uteval.c | 396 | ||||
-rw-r--r-- | drivers/acpi/utilities/utglobal.c | 653 | ||||
-rw-r--r-- | drivers/acpi/utilities/utinit.c | 135 | ||||
-rw-r--r-- | drivers/acpi/utilities/utmath.c | 144 | ||||
-rw-r--r-- | drivers/acpi/utilities/utmisc.c | 1175 | ||||
-rw-r--r-- | drivers/acpi/utilities/utmutex.c | 354 | ||||
-rw-r--r-- | drivers/acpi/utilities/utobject.c | 354 | ||||
-rw-r--r-- | drivers/acpi/utilities/utstate.c | 333 | ||||
-rw-r--r-- | drivers/acpi/utilities/utxface.c | 278 |
15 files changed, 3018 insertions, 3247 deletions
diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile index 939c447dd52..e87108b7338 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 c4e7f989a2b..068450b3647 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 * *****************************************************************************/ @@ -41,232 +41,134 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <acpi/acpi.h> #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utalloc") +ACPI_MODULE_NAME("utalloc") /* Local prototypes */ - #ifdef ACPI_DBG_TRACK_ALLOCATIONS -static struct acpi_debug_mem_block * -acpi_ut_find_allocation ( - u32 list_id, - void *allocation); +static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation); static acpi_status -acpi_ut_track_allocation ( - u32 list_id, - struct acpi_debug_mem_block *address, - acpi_size size, - u8 alloc_type, - u32 component, - char *module, - u32 line); +acpi_ut_track_allocation(struct acpi_debug_mem_block *address, + acpi_size size, + u8 alloc_type, u32 component, char *module, u32 line); 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 */ +acpi_ut_remove_allocation(struct acpi_debug_mem_block *address, + u32 component, char *module, u32 line); +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +static acpi_status +acpi_ut_create_list(char *list_name, + u16 object_size, struct acpi_memory_list **return_cache); +#endif /******************************************************************************* * - * FUNCTION: acpi_ut_release_to_cache + * FUNCTION: acpi_ut_create_caches * - * PARAMETERS: list_id - Memory list/cache ID - * Object - The object to be released + * PARAMETERS: None * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Release an object to the specified cache. If cache is full, - * the object is deleted. + * DESCRIPTION: Create all local caches * ******************************************************************************/ -void -acpi_ut_release_to_cache ( - u32 list_id, - void *object) +acpi_status acpi_ut_create_caches(void) { - struct acpi_memory_list *cache_info; - + acpi_status status; - ACPI_FUNCTION_ENTRY (); - - - cache_info = &acpi_gbl_memory_lists[list_id]; - -#ifdef ACPI_ENABLE_OBJECT_CACHE +#ifdef ACPI_DBG_TRACK_ALLOCATIONS - /* If walk cache is full, just free this wallkstate object */ + /* Memory allocation lists */ - if (cache_info->cache_depth >= cache_info->max_cache_depth) { - ACPI_MEM_FREE (object); - ACPI_MEM_TRACKING (cache_info->total_freed++); + status = acpi_ut_create_list("Acpi-Global", 0, &acpi_gbl_global_list); + if (ACPI_FAILURE(status)) { + return (status); } - /* 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); + status = + acpi_ut_create_list("Acpi-Namespace", + sizeof(struct acpi_namespace_node), + &acpi_gbl_ns_node_list); + if (ACPI_FAILURE(status)) { + return (status); } - -#else - - /* Object cache is disabled; just free the object */ - - ACPI_MEM_FREE (object); - ACPI_MEM_TRACKING (cache_info->total_freed++); #endif -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ut_acquire_from_cache - * - * PARAMETERS: list_id - Memory list ID - * - * RETURN: A requested object. NULL if the object could not be - * allocated. - * - * DESCRIPTION: Get an object from the specified cache. If cache is empty, - * the object is allocated. - * - ******************************************************************************/ - -void * -acpi_ut_acquire_from_cache ( - u32 list_id) -{ - struct acpi_memory_list *cache_info; - void *object; + /* Object Caches, for frequently used objects */ - ACPI_FUNCTION_NAME ("ut_acquire_from_cache"); - - - cache_info = &acpi_gbl_memory_lists[list_id]; - -#ifdef ACPI_ENABLE_OBJECT_CACHE - - if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) { - return (NULL); + 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); } - 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)); -#endif - - if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) { - return (NULL); - } - - /* Clear (zero) the previously used Object */ - - ACPI_MEMSET (object, 0, cache_info->object_size); + 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 { - /* 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_ext", + sizeof(struct acpi_parse_obj_named), + ACPI_MAX_EXTPARSE_CACHE_DEPTH, + &acpi_gbl_ps_node_ext_cache); + if (ACPI_FAILURE(status)) { + return (status); } -#else - - /* Object cache is disabled; just allocate the object */ - - 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; - - ACPI_FUNCTION_ENTRY (); + (void)acpi_os_delete_cache(acpi_gbl_state_cache); + acpi_gbl_state_cache = NULL; + (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 - /******************************************************************************* * @@ -280,9 +182,7 @@ acpi_ut_delete_generic_cache ( * ******************************************************************************/ -acpi_status -acpi_ut_validate_buffer ( - struct acpi_buffer *buffer) +acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer) { /* Obviously, the structure pointer must be valid */ @@ -293,9 +193,9 @@ acpi_ut_validate_buffer ( /* Special semantics for the length */ - if ((buffer->length == ACPI_NO_BUFFER) || - (buffer->length == ACPI_ALLOCATE_BUFFER) || - (buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) { + if ((buffer->length == ACPI_NO_BUFFER) || + (buffer->length == ACPI_ALLOCATE_BUFFER) || + (buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) { return (AE_OK); } @@ -308,7 +208,6 @@ acpi_ut_validate_buffer ( return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ut_initialize_buffer @@ -324,12 +223,10 @@ acpi_ut_validate_buffer ( ******************************************************************************/ acpi_status -acpi_ut_initialize_buffer ( - struct acpi_buffer *buffer, - acpi_size required_length) +acpi_ut_initialize_buffer(struct acpi_buffer * buffer, + acpi_size required_length) { - acpi_status status = AE_OK; - + acpi_status status = AE_OK; switch (buffer->length) { case ACPI_NO_BUFFER: @@ -339,33 +236,30 @@ acpi_ut_initialize_buffer ( status = AE_BUFFER_OVERFLOW; break; - case ACPI_ALLOCATE_BUFFER: /* Allocate a new buffer */ - buffer->pointer = acpi_os_allocate (required_length); + buffer->pointer = acpi_os_allocate(required_length); if (!buffer->pointer) { return (AE_NO_MEMORY); } /* Clear the buffer */ - ACPI_MEMSET (buffer->pointer, 0, required_length); + ACPI_MEMSET(buffer->pointer, 0, required_length); break; - case ACPI_ALLOCATE_LOCAL_BUFFER: /* Allocate a new buffer with local interface to allow tracking */ - buffer->pointer = ACPI_MEM_CALLOCATE (required_length); + buffer->pointer = ACPI_MEM_CALLOCATE(required_length); if (!buffer->pointer) { return (AE_NO_MEMORY); } break; - default: /* Existing buffer: Validate the size of the buffer */ @@ -377,7 +271,7 @@ acpi_ut_initialize_buffer ( /* Clear the buffer */ - ACPI_MEMSET (buffer->pointer, 0, required_length); + ACPI_MEMSET(buffer->pointer, 0, required_length); break; } @@ -385,7 +279,6 @@ acpi_ut_initialize_buffer ( return (status); } - /******************************************************************************* * * FUNCTION: acpi_ut_allocate @@ -401,41 +294,34 @@ acpi_ut_initialize_buffer ( * ******************************************************************************/ -void * -acpi_ut_allocate ( - acpi_size size, - u32 component, - char *module, - u32 line) +void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line) { - void *allocation; - - - ACPI_FUNCTION_TRACE_U32 ("ut_allocate", size); + void *allocation; + ACPI_FUNCTION_TRACE_U32("ut_allocate", size); /* Check for an inadvertent size of zero bytes */ if (!size) { - _ACPI_REPORT_ERROR (module, line, component, - ("ut_allocate: Attempt to allocate zero bytes\n")); + _ACPI_REPORT_ERROR(module, line, component, + ("ut_allocate: Attempt to allocate zero bytes\n")); size = 1; } - allocation = acpi_os_allocate (size); + allocation = acpi_os_allocate(size); if (!allocation) { /* Report allocation error */ - _ACPI_REPORT_ERROR (module, line, component, - ("ut_allocate: Could not allocate size %X\n", (u32) size)); + _ACPI_REPORT_ERROR(module, line, component, + ("ut_allocate: Could not allocate size %X\n", + (u32) size)); - return_PTR (NULL); + return_PTR(NULL); } - return_PTR (allocation); + return_PTR(allocation); } - /******************************************************************************* * * FUNCTION: acpi_ut_callocate @@ -451,43 +337,36 @@ acpi_ut_allocate ( * ******************************************************************************/ -void * -acpi_ut_callocate ( - acpi_size size, - u32 component, - char *module, - u32 line) +void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line) { - void *allocation; - - - ACPI_FUNCTION_TRACE_U32 ("ut_callocate", size); + void *allocation; + ACPI_FUNCTION_TRACE_U32("ut_callocate", size); /* Check for an inadvertent size of zero bytes */ if (!size) { - _ACPI_REPORT_ERROR (module, line, component, - ("ut_callocate: Attempt to allocate zero bytes\n")); - return_PTR (NULL); + _ACPI_REPORT_ERROR(module, line, component, + ("ut_callocate: Attempt to allocate zero bytes\n")); + return_PTR(NULL); } - allocation = acpi_os_allocate (size); + allocation = acpi_os_allocate(size); if (!allocation) { /* Report allocation error */ - _ACPI_REPORT_ERROR (module, line, component, - ("ut_callocate: Could not allocate size %X\n", (u32) size)); - return_PTR (NULL); + _ACPI_REPORT_ERROR(module, line, component, + ("ut_callocate: Could not allocate size %X\n", + (u32) size)); + return_PTR(NULL); } /* Clear the memory block */ - ACPI_MEMSET (allocation, 0, size); - return_PTR (allocation); + ACPI_MEMSET(allocation, 0, size); + return_PTR(allocation); } - #ifdef ACPI_DBG_TRACK_ALLOCATIONS /* * These procedures are used for tracking memory leaks in the subsystem, and @@ -500,6 +379,39 @@ 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, struct acpi_memory_list **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); +} /******************************************************************************* * @@ -516,37 +428,33 @@ acpi_ut_callocate ( * ******************************************************************************/ -void * -acpi_ut_allocate_and_track ( - acpi_size size, - u32 component, - char *module, - u32 line) +void *acpi_ut_allocate_and_track(acpi_size size, + u32 component, char *module, u32 line) { - struct acpi_debug_mem_block *allocation; - acpi_status status; - + struct acpi_debug_mem_block *allocation; + acpi_status status; - allocation = acpi_ut_allocate (size + sizeof (struct acpi_debug_mem_header), - component, module, line); + allocation = + acpi_ut_allocate(size + sizeof(struct acpi_debug_mem_header), + component, module, line); if (!allocation) { return (NULL); } - status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, - ACPI_MEM_MALLOC, component, module, line); - if (ACPI_FAILURE (status)) { - acpi_os_free (allocation); + 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); + return ((void *)&allocation->user_space); } - /******************************************************************************* * * FUNCTION: acpi_ut_callocate_and_track @@ -562,41 +470,38 @@ acpi_ut_allocate_and_track ( * ******************************************************************************/ -void * -acpi_ut_callocate_and_track ( - acpi_size size, - u32 component, - char *module, - u32 line) +void *acpi_ut_callocate_and_track(acpi_size size, + u32 component, char *module, u32 line) { - struct acpi_debug_mem_block *allocation; - acpi_status status; - + struct acpi_debug_mem_block *allocation; + acpi_status status; - allocation = acpi_ut_callocate (size + sizeof (struct acpi_debug_mem_header), - component, module, line); + allocation = + acpi_ut_callocate(size + sizeof(struct acpi_debug_mem_header), + component, module, line); if (!allocation) { /* Report allocation error */ - _ACPI_REPORT_ERROR (module, line, component, - ("ut_callocate: Could not allocate size %X\n", (u32) size)); + _ACPI_REPORT_ERROR(module, line, component, + ("ut_callocate: Could not allocate size %X\n", + (u32) size)); return (NULL); } - status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, - ACPI_MEM_CALLOC, component, module, line); - if (ACPI_FAILURE (status)) { - acpi_os_free (allocation); + 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); + return ((void *)&allocation->user_space); } - /******************************************************************************* * * FUNCTION: acpi_ut_free_and_track @@ -613,53 +518,46 @@ acpi_ut_callocate_and_track ( ******************************************************************************/ void -acpi_ut_free_and_track ( - void *allocation, - u32 component, - char *module, - u32 line) +acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line) { - struct acpi_debug_mem_block *debug_block; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ut_free", allocation); + struct acpi_debug_mem_block *debug_block; + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ut_free", allocation); if (NULL == allocation) { - _ACPI_REPORT_ERROR (module, line, component, - ("acpi_ut_free: Attempt to delete a NULL address\n")); + _ACPI_REPORT_ERROR(module, line, component, + ("acpi_ut_free: Attempt to delete a NULL address\n")); return_VOID; } - debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block, - (((char *) allocation) - sizeof (struct acpi_debug_mem_header))); + 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, - component, module, line); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n", - acpi_format_exception (status))); + 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", + acpi_format_exception(status))); } - acpi_os_free (debug_block); + acpi_os_free(debug_block); - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation)); return_VOID; } - /******************************************************************************* * * 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. * @@ -667,22 +565,13 @@ acpi_ut_free_and_track ( * ******************************************************************************/ -static struct acpi_debug_mem_block * -acpi_ut_find_allocation ( - u32 list_id, - void *allocation) +static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation) { - struct acpi_debug_mem_block *element; - + struct acpi_debug_mem_block *element; - ACPI_FUNCTION_ENTRY (); - - - if (list_id > ACPI_MEM_LIST_MAX) { - return (NULL); - } + ACPI_FUNCTION_ENTRY(); - element = acpi_gbl_memory_lists[list_id].list_head; + element = acpi_gbl_global_list->list_head; /* Search for the address. */ @@ -697,13 +586,11 @@ acpi_ut_find_allocation ( return (NULL); } - /******************************************************************************* * * 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 @@ -717,64 +604,51 @@ 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, - u32 component, - char *module, - u32 line) +acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation, + acpi_size size, + u8 alloc_type, u32 component, char *module, u32 line) { - struct acpi_memory_list *mem_list; - struct acpi_debug_mem_block *element; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation); + struct acpi_memory_list *mem_list; + struct acpi_debug_mem_block *element; + acpi_status status = AE_OK; + 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]; - status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + mem_list = acpi_gbl_global_list; + status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* * 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", - allocation)); + ACPI_REPORT_ERROR(("ut_track_allocation: Allocation already present in list! (%p)\n", allocation)); - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", - element, allocation)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Element %p Address %p\n", + element, allocation)); goto unlock_and_exit; } /* Fill in the instance data. */ - allocation->size = (u32) size; + allocation->size = (u32) size; allocation->alloc_type = alloc_type; allocation->component = component; - allocation->line = line; + allocation->line = line; - ACPI_STRNCPY (allocation->module, module, ACPI_MAX_MODULE_NAME); - allocation->module[ACPI_MAX_MODULE_NAME-1] = 0; + ACPI_STRNCPY(allocation->module, module, ACPI_MAX_MODULE_NAME); + allocation->module[ACPI_MAX_MODULE_NAME - 1] = 0; /* Insert at list head */ if (mem_list->list_head) { - ((struct acpi_debug_mem_block *)(mem_list->list_head))->previous = allocation; + ((struct acpi_debug_mem_block *)(mem_list->list_head))-> + previous = allocation; } allocation->next = mem_list->list_head; @@ -782,19 +656,16 @@ acpi_ut_track_allocation ( mem_list->list_head = allocation; - -unlock_and_exit: - status = acpi_ut_release_mutex (ACPI_MTX_MEMORY); - return_ACPI_STATUS (status); + unlock_and_exit: + status = acpi_ut_release_mutex(ACPI_MTX_MEMORY); + return_ACPI_STATUS(status); } - /******************************************************************************* * * 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 @@ -806,45 +677,34 @@ unlock_and_exit: ******************************************************************************/ static acpi_status -acpi_ut_remove_allocation ( - u32 list_id, - struct acpi_debug_mem_block *allocation, - u32 component, - char *module, - u32 line) +acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation, + u32 component, char *module, u32 line) { - struct acpi_memory_list *mem_list; - acpi_status status; - + struct acpi_memory_list *mem_list; + acpi_status status; - ACPI_FUNCTION_TRACE ("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! */ - _ACPI_REPORT_ERROR (module, line, component, - ("ut_remove_allocation: Empty allocation list, nothing to free!\n")); + _ACPI_REPORT_ERROR(module, line, component, + ("ut_remove_allocation: Empty allocation list, nothing to free!\n")); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Unlink */ if (allocation->previous) { (allocation->previous)->next = allocation->next; - } - else { + } else { mem_list->list_head = allocation->next; } @@ -854,16 +714,15 @@ acpi_ut_remove_allocation ( /* Mark the segment as deleted */ - ACPI_MEMSET (&allocation->user_space, 0xEA, allocation->size); + ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size); - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", - allocation->size)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", + allocation->size)); - status = acpi_ut_release_mutex (ACPI_MTX_MEMORY); - return_ACPI_STATUS (status); + status = acpi_ut_release_mutex(ACPI_MTX_MEMORY); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_dump_allocation_info @@ -877,15 +736,13 @@ acpi_ut_remove_allocation ( ******************************************************************************/ #ifdef ACPI_FUTURE_USAGE -void -acpi_ut_dump_allocation_info ( - void) +void acpi_ut_dump_allocation_info(void) { /* struct acpi_memory_list *mem_list; */ - ACPI_FUNCTION_TRACE ("ut_dump_allocation_info"); + ACPI_FUNCTION_TRACE("ut_dump_allocation_info"); /* ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, @@ -898,7 +755,6 @@ acpi_ut_dump_allocation_info ( mem_list->max_concurrent_count, ROUND_UP_TO_1K (mem_list->max_concurrent_size))); - ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", running_object_count, @@ -909,7 +765,6 @@ acpi_ut_dump_allocation_info ( running_alloc_count, ROUND_UP_TO_1K (running_alloc_size))); - ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, ("%30s: %4d (%3d Kb)\n", "Current Nodes", acpi_gbl_current_node_count, @@ -923,8 +778,7 @@ acpi_ut_dump_allocation_info ( */ return_VOID; } -#endif /* ACPI_FUTURE_USAGE */ - +#endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* * @@ -939,84 +793,87 @@ acpi_ut_dump_allocation_info ( * ******************************************************************************/ -void -acpi_ut_dump_allocations ( - u32 component, - char *module) +void acpi_ut_dump_allocations(u32 component, char *module) { - struct acpi_debug_mem_block *element; - union acpi_descriptor *descriptor; - u32 num_outstanding = 0; - - - ACPI_FUNCTION_TRACE ("ut_dump_allocations"); + struct acpi_debug_mem_block *element; + union acpi_descriptor *descriptor; + u32 num_outstanding = 0; + ACPI_FUNCTION_TRACE("ut_dump_allocations"); /* * Walk the allocation list. */ - if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_MEMORY))) { + if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_MEMORY))) { 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)))) { + ((module == NULL) + || (0 == ACPI_STRCMP(module, element->module)))) { /* Ignore allocated objects that are in a cache */ - descriptor = ACPI_CAST_PTR (union acpi_descriptor, &element->user_space); + descriptor = + ACPI_CAST_PTR(union acpi_descriptor, + &element->user_space); if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) { - acpi_os_printf ("%p Len %04X %9.9s-%d [%s] ", - descriptor, element->size, element->module, - element->line, acpi_ut_get_descriptor_name (descriptor)); + acpi_os_printf("%p Len %04X %9.9s-%d [%s] ", + descriptor, element->size, + element->module, element->line, + acpi_ut_get_descriptor_name + (descriptor)); /* Most of the elements will be Operand objects. */ - switch (ACPI_GET_DESCRIPTOR_TYPE (descriptor)) { + switch (ACPI_GET_DESCRIPTOR_TYPE(descriptor)) { case ACPI_DESC_TYPE_OPERAND: - acpi_os_printf ("%12.12s R%hd", - acpi_ut_get_type_name (descriptor->object.common.type), - descriptor->object.common.reference_count); + acpi_os_printf("%12.12s R%hd", + acpi_ut_get_type_name + (descriptor->object. + common.type), + descriptor->object. + common.reference_count); break; case ACPI_DESC_TYPE_PARSER: - acpi_os_printf ("aml_opcode %04hX", - descriptor->op.asl.aml_opcode); + acpi_os_printf("aml_opcode %04hX", + descriptor->op.asl. + aml_opcode); break; case ACPI_DESC_TYPE_NAMED: - acpi_os_printf ("%4.4s", - acpi_ut_get_node_name (&descriptor->node)); + acpi_os_printf("%4.4s", + acpi_ut_get_node_name + (&descriptor->node)); break; default: break; } - acpi_os_printf ( "\n"); + acpi_os_printf("\n"); num_outstanding++; } } element = element->next; } - (void) acpi_ut_release_mutex (ACPI_MTX_MEMORY); + (void)acpi_ut_release_mutex(ACPI_MTX_MEMORY); /* Print summary */ if (!num_outstanding) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "No outstanding allocations.\n")); - } - else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "%d(%X) Outstanding allocations\n", - num_outstanding, num_outstanding)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No outstanding allocations.\n")); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "%d(%X) Outstanding allocations\n", + num_outstanding, num_outstanding)); } return_VOID; } -#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */ - +#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */ diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c new file mode 100644 index 00000000000..93d48681d27 --- /dev/null +++ b/drivers/acpi/utilities/utcache.c @@ -0,0 +1,305 @@ +/****************************************************************************** + * + * 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; + + ACPI_FUNCTION_ENTRY(); + + 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; + + ACPI_FUNCTION_ENTRY(); + + /* 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("os_acquire_object"); + + 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 cache\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/utcopy.c b/drivers/acpi/utilities/utcopy.c index 11e88495716..5442b32de61 100644 --- a/drivers/acpi/utilities/utcopy.c +++ b/drivers/acpi/utilities/utcopy.c @@ -41,59 +41,46 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <acpi/acpi.h> #include <acpi/amlcode.h> - #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utcopy") +ACPI_MODULE_NAME("utcopy") /* Local prototypes */ - static acpi_status -acpi_ut_copy_isimple_to_esimple ( - union acpi_operand_object *internal_object, - union acpi_object *external_object, - u8 *data_space, - acpi_size *buffer_space_used); +acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object, + union acpi_object *external_object, + u8 * data_space, acpi_size * buffer_space_used); static acpi_status -acpi_ut_copy_ielement_to_ielement ( - u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state *state, - void *context); +acpi_ut_copy_ielement_to_ielement(u8 object_type, + union acpi_operand_object *source_object, + union acpi_generic_state *state, + void *context); static acpi_status -acpi_ut_copy_ipackage_to_epackage ( - union acpi_operand_object *internal_object, - u8 *buffer, - acpi_size *space_used); +acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object, + u8 * buffer, acpi_size * space_used); static acpi_status -acpi_ut_copy_esimple_to_isimple( - union acpi_object *user_obj, - union acpi_operand_object **return_obj); +acpi_ut_copy_esimple_to_isimple(union acpi_object *user_obj, + union acpi_operand_object **return_obj); static acpi_status -acpi_ut_copy_simple_object ( - union acpi_operand_object *source_desc, - union acpi_operand_object *dest_desc); +acpi_ut_copy_simple_object(union acpi_operand_object *source_desc, + union acpi_operand_object *dest_desc); static acpi_status -acpi_ut_copy_ielement_to_eelement ( - u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state *state, - void *context); +acpi_ut_copy_ielement_to_eelement(u8 object_type, + union acpi_operand_object *source_object, + union acpi_generic_state *state, + void *context); static acpi_status -acpi_ut_copy_ipackage_to_ipackage ( - union acpi_operand_object *source_obj, - union acpi_operand_object *dest_obj, - struct acpi_walk_state *walk_state); - +acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj, + union acpi_operand_object *dest_obj, + struct acpi_walk_state *walk_state); /******************************************************************************* * @@ -116,17 +103,13 @@ acpi_ut_copy_ipackage_to_ipackage ( ******************************************************************************/ static acpi_status -acpi_ut_copy_isimple_to_esimple ( - union acpi_operand_object *internal_object, - union acpi_object *external_object, - u8 *data_space, - acpi_size *buffer_space_used) +acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object, + union acpi_object *external_object, + u8 * data_space, acpi_size * buffer_space_used) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ut_copy_isimple_to_esimple"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("ut_copy_isimple_to_esimple"); *buffer_space_used = 0; @@ -135,54 +118,54 @@ acpi_ut_copy_isimple_to_esimple ( * package element) */ if (!internal_object) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Always clear the external object */ - ACPI_MEMSET (external_object, 0, sizeof (union acpi_object)); + ACPI_MEMSET(external_object, 0, sizeof(union acpi_object)); /* * In general, the external object will be the same type as * the internal object */ - external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); + external_object->type = ACPI_GET_OBJECT_TYPE(internal_object); /* However, only a limited number of external types are supported */ - switch (ACPI_GET_OBJECT_TYPE (internal_object)) { + switch (ACPI_GET_OBJECT_TYPE(internal_object)) { case ACPI_TYPE_STRING: - external_object->string.pointer = (char *) data_space; + external_object->string.pointer = (char *)data_space; external_object->string.length = internal_object->string.length; - *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD ( - (acpi_size) internal_object->string.length + 1); - - ACPI_MEMCPY ((void *) data_space, - (void *) internal_object->string.pointer, - (acpi_size) internal_object->string.length + 1); + *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size) + internal_object-> + string. + length + 1); + + ACPI_MEMCPY((void *)data_space, + (void *)internal_object->string.pointer, + (acpi_size) internal_object->string.length + 1); break; - case ACPI_TYPE_BUFFER: external_object->buffer.pointer = data_space; external_object->buffer.length = internal_object->buffer.length; - *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD ( - internal_object->string.length); + *buffer_space_used = + ACPI_ROUND_UP_TO_NATIVE_WORD(internal_object->string. + length); - ACPI_MEMCPY ((void *) data_space, - (void *) internal_object->buffer.pointer, - internal_object->buffer.length); + ACPI_MEMCPY((void *)data_space, + (void *)internal_object->buffer.pointer, + internal_object->buffer.length); break; - case ACPI_TYPE_INTEGER: external_object->integer.value = internal_object->integer.value; break; - case ACPI_TYPE_LOCAL_REFERENCE: /* @@ -199,41 +182,41 @@ acpi_ut_copy_isimple_to_esimple ( * to object containing a handle to an ACPI named object. */ external_object->type = ACPI_TYPE_ANY; - external_object->reference.handle = internal_object->reference.node; + external_object->reference.handle = + internal_object->reference.node; break; } break; - case ACPI_TYPE_PROCESSOR: - external_object->processor.proc_id = internal_object->processor.proc_id; - external_object->processor.pblk_address = internal_object->processor.address; - external_object->processor.pblk_length = internal_object->processor.length; + external_object->processor.proc_id = + internal_object->processor.proc_id; + external_object->processor.pblk_address = + internal_object->processor.address; + external_object->processor.pblk_length = + internal_object->processor.length; break; - case ACPI_TYPE_POWER: external_object->power_resource.system_level = - internal_object->power_resource.system_level; + internal_object->power_resource.system_level; external_object->power_resource.resource_order = - internal_object->power_resource.resource_order; + internal_object->power_resource.resource_order; break; - default: /* * There is no corresponding external object type */ - return_ACPI_STATUS (AE_SUPPORT); + return_ACPI_STATUS(AE_SUPPORT); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_ielement_to_eelement @@ -247,25 +230,23 @@ acpi_ut_copy_isimple_to_esimple ( ******************************************************************************/ static acpi_status -acpi_ut_copy_ielement_to_eelement ( - u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state *state, - void *context) +acpi_ut_copy_ielement_to_eelement(u8 object_type, + union acpi_operand_object *source_object, + union acpi_generic_state *state, + void *context) { - acpi_status status = AE_OK; - struct acpi_pkg_info *info = (struct acpi_pkg_info *) context; - acpi_size object_space; - u32 this_index; - union acpi_object *target_object; + acpi_status status = AE_OK; + struct acpi_pkg_info *info = (struct acpi_pkg_info *)context; + acpi_size object_space; + u32 this_index; + union acpi_object *target_object; + ACPI_FUNCTION_ENTRY(); - ACPI_FUNCTION_ENTRY (); - - - this_index = state->pkg.index; + this_index = state->pkg.index; target_object = (union acpi_object *) - &((union acpi_object *)(state->pkg.dest_object))->package.elements[this_index]; + &((union acpi_object *)(state->pkg.dest_object))->package. + elements[this_index]; switch (object_type) { case ACPI_COPY_TYPE_SIMPLE: @@ -273,23 +254,24 @@ acpi_ut_copy_ielement_to_eelement ( /* * This is a simple or null object */ - status = acpi_ut_copy_isimple_to_esimple (source_object, - target_object, info->free_space, &object_space); - if (ACPI_FAILURE (status)) { + status = acpi_ut_copy_isimple_to_esimple(source_object, + target_object, + info->free_space, + &object_space); + if (ACPI_FAILURE(status)) { return (status); } break; - case ACPI_COPY_TYPE_PACKAGE: /* * Build the package object */ - target_object->type = ACPI_TYPE_PACKAGE; - target_object->package.count = source_object->package.count; + target_object->type = ACPI_TYPE_PACKAGE; + target_object->package.count = source_object->package.count; target_object->package.elements = - ACPI_CAST_PTR (union acpi_object, info->free_space); + ACPI_CAST_PTR(union acpi_object, info->free_space); /* * Pass the new package object back to the package walk routine @@ -300,22 +282,22 @@ acpi_ut_copy_ielement_to_eelement ( * Save space for the array of objects (Package elements) * update the buffer length counter */ - object_space = ACPI_ROUND_UP_TO_NATIVE_WORD ( - (acpi_size) target_object->package.count * - sizeof (union acpi_object)); + object_space = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size) + target_object-> + package.count * + sizeof(union + acpi_object)); break; - default: return (AE_BAD_PARAMETER); } - info->free_space += object_space; - info->length += object_space; + info->free_space += object_space; + info->length += object_space; return (status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_ipackage_to_epackage @@ -336,55 +318,51 @@ acpi_ut_copy_ielement_to_eelement ( ******************************************************************************/ static acpi_status -acpi_ut_copy_ipackage_to_epackage ( - union acpi_operand_object *internal_object, - u8 *buffer, - acpi_size *space_used) +acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object, + u8 * buffer, acpi_size * space_used) { - union acpi_object *external_object; - acpi_status status; - struct acpi_pkg_info info; - - - ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_epackage"); + union acpi_object *external_object; + acpi_status status; + struct acpi_pkg_info info; + ACPI_FUNCTION_TRACE("ut_copy_ipackage_to_epackage"); /* * First package at head of the buffer */ - external_object = ACPI_CAST_PTR (union acpi_object, buffer); + external_object = ACPI_CAST_PTR(union acpi_object, buffer); /* * Free space begins right after the first package */ - info.length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); - info.free_space = buffer + ACPI_ROUND_UP_TO_NATIVE_WORD ( - sizeof (union acpi_object)); + info.length = ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)); + info.free_space = + buffer + ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)); info.object_space = 0; info.num_packages = 1; - external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); - external_object->package.count = internal_object->package.count; - external_object->package.elements = ACPI_CAST_PTR (union acpi_object, - info.free_space); + external_object->type = ACPI_GET_OBJECT_TYPE(internal_object); + external_object->package.count = internal_object->package.count; + external_object->package.elements = ACPI_CAST_PTR(union acpi_object, + info.free_space); /* * Leave room for an array of ACPI_OBJECTS in the buffer * and move the free space past it */ - info.length += (acpi_size) external_object->package.count * - ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); + info.length += (acpi_size) external_object->package.count * + ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)); info.free_space += external_object->package.count * - ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); + ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)); - status = acpi_ut_walk_package_tree (internal_object, external_object, - acpi_ut_copy_ielement_to_eelement, &info); + status = acpi_ut_walk_package_tree(internal_object, external_object, + acpi_ut_copy_ielement_to_eelement, + &info); *space_used = info.length; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_iobject_to_eobject @@ -400,44 +378,45 @@ acpi_ut_copy_ipackage_to_epackage ( ******************************************************************************/ acpi_status -acpi_ut_copy_iobject_to_eobject ( - union acpi_operand_object *internal_object, - struct acpi_buffer *ret_buffer) +acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object, + struct acpi_buffer *ret_buffer) { - acpi_status status; + acpi_status status; + ACPI_FUNCTION_TRACE("ut_copy_iobject_to_eobject"); - ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_eobject"); - - - if (ACPI_GET_OBJECT_TYPE (internal_object) == ACPI_TYPE_PACKAGE) { + if (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE) { /* * Package object: Copy all subobjects (including * nested packages) */ - status = acpi_ut_copy_ipackage_to_epackage (internal_object, - ret_buffer->pointer, &ret_buffer->length); - } - else { + status = acpi_ut_copy_ipackage_to_epackage(internal_object, + ret_buffer->pointer, + &ret_buffer->length); + } else { /* * Build a simple object (no nested objects) */ - status = acpi_ut_copy_isimple_to_esimple (internal_object, - (union acpi_object *) ret_buffer->pointer, - ((u8 *) ret_buffer->pointer + - ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object))), - &ret_buffer->length); + status = acpi_ut_copy_isimple_to_esimple(internal_object, + (union acpi_object *) + ret_buffer->pointer, + ((u8 *) ret_buffer-> + pointer + + ACPI_ROUND_UP_TO_NATIVE_WORD + (sizeof + (union + acpi_object))), + &ret_buffer->length); /* * build simple does not include the object size in the length * so we add it in here */ - ret_buffer->length += sizeof (union acpi_object); + ret_buffer->length += sizeof(union acpi_object); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_esimple_to_isimple @@ -455,15 +434,12 @@ acpi_ut_copy_iobject_to_eobject ( ******************************************************************************/ static acpi_status -acpi_ut_copy_esimple_to_isimple ( - union acpi_object *external_object, - union acpi_operand_object **ret_internal_object) +acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object, + union acpi_operand_object **ret_internal_object) { - union acpi_operand_object *internal_object; - - - ACPI_FUNCTION_TRACE ("ut_copy_esimple_to_isimple"); + union acpi_operand_object *internal_object; + ACPI_FUNCTION_TRACE("ut_copy_esimple_to_isimple"); /* * Simple types supported are: String, Buffer, Integer @@ -473,58 +449,57 @@ acpi_ut_copy_esimple_to_isimple ( case ACPI_TYPE_BUFFER: case ACPI_TYPE_INTEGER: - internal_object = acpi_ut_create_internal_object ( - (u8) external_object->type); + internal_object = acpi_ut_create_internal_object((u8) + external_object-> + type); if (!internal_object) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } break; default: /* All other types are not supported */ - return_ACPI_STATUS (AE_SUPPORT); + return_ACPI_STATUS(AE_SUPPORT); } - /* Must COPY string and buffer contents */ switch (external_object->type) { case ACPI_TYPE_STRING: internal_object->string.pointer = - ACPI_MEM_CALLOCATE ((acpi_size) external_object->string.length + 1); + ACPI_MEM_CALLOCATE((acpi_size) external_object->string. + length + 1); if (!internal_object->string.pointer) { goto error_exit; } - ACPI_MEMCPY (internal_object->string.pointer, - external_object->string.pointer, - external_object->string.length); + ACPI_MEMCPY(internal_object->string.pointer, + external_object->string.pointer, + external_object->string.length); internal_object->string.length = external_object->string.length; break; - case ACPI_TYPE_BUFFER: internal_object->buffer.pointer = - ACPI_MEM_CALLOCATE (external_object->buffer.length); + ACPI_MEM_CALLOCATE(external_object->buffer.length); if (!internal_object->buffer.pointer) { goto error_exit; } - ACPI_MEMCPY (internal_object->buffer.pointer, - external_object->buffer.pointer, - external_object->buffer.length); + ACPI_MEMCPY(internal_object->buffer.pointer, + external_object->buffer.pointer, + external_object->buffer.length); internal_object->buffer.length = external_object->buffer.length; break; - case ACPI_TYPE_INTEGER: - internal_object->integer.value = external_object->integer.value; + internal_object->integer.value = external_object->integer.value; break; default: @@ -533,15 +508,13 @@ acpi_ut_copy_esimple_to_isimple ( } *ret_internal_object = internal_object; - return_ACPI_STATUS (AE_OK); - + return_ACPI_STATUS(AE_OK); -error_exit: - acpi_ut_remove_reference (internal_object); - return_ACPI_STATUS (AE_NO_MEMORY); + error_exit: + acpi_ut_remove_reference(internal_object); + return_ACPI_STATUS(AE_NO_MEMORY); } - #ifdef ACPI_FUTURE_IMPLEMENTATION /* Code to convert packages that are parameters to control methods */ @@ -565,22 +538,18 @@ error_exit: ******************************************************************************/ static acpi_status -acpi_ut_copy_epackage_to_ipackage ( - union acpi_operand_object *internal_object, - u8 *buffer, - u32 *space_used) +acpi_ut_copy_epackage_to_ipackage(union acpi_operand_object *internal_object, + u8 * buffer, u32 * space_used) { - u8 *free_space; - union acpi_object *external_object; - u32 length = 0; - u32 this_index; - u32 object_space = 0; - union acpi_operand_object *this_internal_obj; - union acpi_object *this_external_obj; - - - ACPI_FUNCTION_TRACE ("ut_copy_epackage_to_ipackage"); + u8 *free_space; + union acpi_object *external_object; + u32 length = 0; + u32 this_index; + u32 object_space = 0; + union acpi_operand_object *this_internal_obj; + union acpi_object *this_external_obj; + ACPI_FUNCTION_TRACE("ut_copy_epackage_to_ipackage"); /* * First package at head of the buffer @@ -592,24 +561,22 @@ acpi_ut_copy_epackage_to_ipackage ( */ free_space = buffer + sizeof(union acpi_object); - - external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); - external_object->package.count = internal_object->package.count; - external_object->package.elements = (union acpi_object *)free_space; + external_object->type = ACPI_GET_OBJECT_TYPE(internal_object); + external_object->package.count = internal_object->package.count; + external_object->package.elements = (union acpi_object *)free_space; /* * Build an array of ACPI_OBJECTS in the buffer * and move the free space past it */ - free_space += external_object->package.count * sizeof(union acpi_object); - + free_space += + external_object->package.count * sizeof(union acpi_object); /* Call walk_package */ } -#endif /* Future implementation */ - +#endif /* Future implementation */ /******************************************************************************* * @@ -625,37 +592,35 @@ acpi_ut_copy_epackage_to_ipackage ( ******************************************************************************/ acpi_status -acpi_ut_copy_eobject_to_iobject ( - union acpi_object *external_object, - union acpi_operand_object **internal_object) +acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object, + union acpi_operand_object **internal_object) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ut_copy_eobject_to_iobject"); + acpi_status status; + ACPI_FUNCTION_TRACE("ut_copy_eobject_to_iobject"); if (external_object->type == ACPI_TYPE_PACKAGE) { /* * Packages as external input to control methods are not supported, */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Packages as parameters not implemented!\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Packages as parameters not implemented!\n")); - return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + return_ACPI_STATUS(AE_NOT_IMPLEMENTED); } else { /* * Build a simple object (no nested objects) */ - status = acpi_ut_copy_esimple_to_isimple (external_object, internal_object); + status = + acpi_ut_copy_esimple_to_isimple(external_object, + internal_object); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_simple_object @@ -671,83 +636,75 @@ acpi_ut_copy_eobject_to_iobject ( ******************************************************************************/ static acpi_status -acpi_ut_copy_simple_object ( - union acpi_operand_object *source_desc, - union acpi_operand_object *dest_desc) +acpi_ut_copy_simple_object(union acpi_operand_object *source_desc, + union acpi_operand_object *dest_desc) { - u16 reference_count; - union acpi_operand_object *next_object; - + u16 reference_count; + union acpi_operand_object *next_object; /* Save fields from destination that we don't want to overwrite */ reference_count = dest_desc->common.reference_count; next_object = dest_desc->common.next_object; - /* Copy the entire source object over the destination object*/ + /* Copy the entire source object over the destination object */ - ACPI_MEMCPY ((char *) dest_desc, (char *) source_desc, - sizeof (union acpi_operand_object)); + ACPI_MEMCPY((char *)dest_desc, (char *)source_desc, + sizeof(union acpi_operand_object)); /* Restore the saved fields */ dest_desc->common.reference_count = reference_count; dest_desc->common.next_object = next_object; - /* Handle the objects with extra data */ + /* New object is not static, regardless of source */ - switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { - case ACPI_TYPE_BUFFER: + dest_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; - dest_desc->buffer.node = NULL; - dest_desc->common.flags = source_desc->common.flags; + /* Handle the objects with extra data */ + switch (ACPI_GET_OBJECT_TYPE(dest_desc)) { + case ACPI_TYPE_BUFFER: /* * Allocate and copy the actual buffer if and only if: * 1) There is a valid buffer pointer - * 2) The buffer is not static (not in an ACPI table) (in this case, - * the actual pointer was already copied above) + * 2) The buffer has a length > 0 */ if ((source_desc->buffer.pointer) && - (!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) { - dest_desc->buffer.pointer = NULL; - - /* Create an actual buffer only if length > 0 */ - - if (source_desc->buffer.length) { - dest_desc->buffer.pointer = - ACPI_MEM_ALLOCATE (source_desc->buffer.length); - if (!dest_desc->buffer.pointer) { - return (AE_NO_MEMORY); - } + (source_desc->buffer.length)) { + dest_desc->buffer.pointer = + ACPI_MEM_ALLOCATE(source_desc->buffer.length); + if (!dest_desc->buffer.pointer) { + return (AE_NO_MEMORY); + } - /* Copy the actual buffer data */ + /* Copy the actual buffer data */ - ACPI_MEMCPY (dest_desc->buffer.pointer, - source_desc->buffer.pointer, - source_desc->buffer.length); - } + ACPI_MEMCPY(dest_desc->buffer.pointer, + source_desc->buffer.pointer, + source_desc->buffer.length); } break; case ACPI_TYPE_STRING: - /* * Allocate and copy the actual string if and only if: * 1) There is a valid string pointer - * 2) The string is not static (not in an ACPI table) (in this case, - * the actual pointer was already copied above) + * (Pointer to a NULL string is allowed) */ - if ((source_desc->string.pointer) && - (!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) { + if (source_desc->string.pointer) { dest_desc->string.pointer = - ACPI_MEM_ALLOCATE ((acpi_size) source_desc->string.length + 1); + ACPI_MEM_ALLOCATE((acpi_size) source_desc->string. + length + 1); if (!dest_desc->string.pointer) { return (AE_NO_MEMORY); } - ACPI_MEMCPY (dest_desc->string.pointer, source_desc->string.pointer, - (acpi_size) source_desc->string.length + 1); + /* Copy the actual string data */ + + ACPI_MEMCPY(dest_desc->string.pointer, + source_desc->string.pointer, + (acpi_size) source_desc->string.length + 1); } break; @@ -756,7 +713,7 @@ acpi_ut_copy_simple_object ( * We copied the reference object, so we now must add a reference * to the object pointed to by the reference */ - acpi_ut_add_reference (source_desc->reference.object); + acpi_ut_add_reference(source_desc->reference.object); break; default: @@ -767,7 +724,6 @@ acpi_ut_copy_simple_object ( return (AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_ielement_to_ielement @@ -781,24 +737,21 @@ acpi_ut_copy_simple_object ( ******************************************************************************/ static acpi_status -acpi_ut_copy_ielement_to_ielement ( - u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state *state, - void *context) +acpi_ut_copy_ielement_to_ielement(u8 object_type, + union acpi_operand_object *source_object, + union acpi_generic_state *state, + void *context) { - acpi_status status = AE_OK; - u32 this_index; - union acpi_operand_object **this_target_ptr; - union acpi_operand_object *target_object; - + acpi_status status = AE_OK; + u32 this_index; + union acpi_operand_object **this_target_ptr; + union acpi_operand_object *target_object; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); - - this_index = state->pkg.index; + this_index = state->pkg.index; this_target_ptr = (union acpi_operand_object **) - &state->pkg.dest_object->package.elements[this_index]; + &state->pkg.dest_object->package.elements[this_index]; switch (object_type) { case ACPI_COPY_TYPE_SIMPLE: @@ -809,34 +762,36 @@ acpi_ut_copy_ielement_to_ielement ( /* * This is a simple object, just copy it */ - target_object = acpi_ut_create_internal_object ( - ACPI_GET_OBJECT_TYPE (source_object)); + target_object = + acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE + (source_object)); if (!target_object) { return (AE_NO_MEMORY); } - status = acpi_ut_copy_simple_object (source_object, target_object); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_copy_simple_object(source_object, + target_object); + if (ACPI_FAILURE(status)) { goto error_exit; } *this_target_ptr = target_object; - } - else { + } else { /* Pass through a null element */ *this_target_ptr = NULL; } break; - case ACPI_COPY_TYPE_PACKAGE: /* * This object is a package - go down another nesting level * Create and build the package object */ - target_object = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE); + target_object = + acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE); if (!target_object) { return (AE_NO_MEMORY); } @@ -848,8 +803,8 @@ acpi_ut_copy_ielement_to_ielement ( * Create the object array */ target_object->package.elements = - ACPI_MEM_CALLOCATE (((acpi_size) source_object->package.count + 1) * - sizeof (void *)); + ACPI_MEM_CALLOCATE(((acpi_size) source_object->package. + count + 1) * sizeof(void *)); if (!target_object->package.elements) { status = AE_NO_MEMORY; goto error_exit; @@ -866,19 +821,17 @@ acpi_ut_copy_ielement_to_ielement ( *this_target_ptr = target_object; break; - default: return (AE_BAD_PARAMETER); } return (status); -error_exit: - acpi_ut_remove_reference (target_object); + error_exit: + acpi_ut_remove_reference(target_object); return (status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_ipackage_to_ipackage @@ -894,49 +847,46 @@ error_exit: ******************************************************************************/ static acpi_status -acpi_ut_copy_ipackage_to_ipackage ( - union acpi_operand_object *source_obj, - union acpi_operand_object *dest_obj, - struct acpi_walk_state *walk_state) +acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj, + union acpi_operand_object *dest_obj, + struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - + acpi_status status = AE_OK; - ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_ipackage"); + ACPI_FUNCTION_TRACE("ut_copy_ipackage_to_ipackage"); - - dest_obj->common.type = ACPI_GET_OBJECT_TYPE (source_obj); - dest_obj->common.flags = source_obj->common.flags; + dest_obj->common.type = ACPI_GET_OBJECT_TYPE(source_obj); + dest_obj->common.flags = source_obj->common.flags; dest_obj->package.count = source_obj->package.count; /* * Create the object array and walk the source package tree */ - dest_obj->package.elements = ACPI_MEM_CALLOCATE ( - ((acpi_size) source_obj->package.count + 1) * - sizeof (void *)); + dest_obj->package.elements = ACPI_MEM_CALLOCATE(((acpi_size) + source_obj->package. + count + + 1) * sizeof(void *)); if (!dest_obj->package.elements) { - ACPI_REPORT_ERROR ( - ("aml_build_copy_internal_package_object: Package allocation failure\n")); - return_ACPI_STATUS (AE_NO_MEMORY); + ACPI_REPORT_ERROR(("aml_build_copy_internal_package_object: Package allocation failure\n")); + return_ACPI_STATUS(AE_NO_MEMORY); } /* * Copy the package element-by-element by walking the package "tree". * This handles nested packages of arbitrary depth. */ - status = acpi_ut_walk_package_tree (source_obj, dest_obj, - acpi_ut_copy_ielement_to_ielement, walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ut_walk_package_tree(source_obj, dest_obj, + acpi_ut_copy_ielement_to_ielement, + walk_state); + if (ACPI_FAILURE(status)) { /* On failure, delete the destination package object */ - acpi_ut_remove_reference (dest_obj); + acpi_ut_remove_reference(dest_obj); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_iobject_to_iobject @@ -952,35 +902,31 @@ acpi_ut_copy_ipackage_to_ipackage ( ******************************************************************************/ acpi_status -acpi_ut_copy_iobject_to_iobject ( - union acpi_operand_object *source_desc, - union acpi_operand_object **dest_desc, - struct acpi_walk_state *walk_state) +acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc, + union acpi_operand_object **dest_desc, + struct acpi_walk_state *walk_state) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_iobject"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("ut_copy_iobject_to_iobject"); /* Create the top level object */ - *dest_desc = acpi_ut_create_internal_object (ACPI_GET_OBJECT_TYPE (source_desc)); + *dest_desc = + acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE(source_desc)); if (!*dest_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Copy the object and possible subobjects */ - if (ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_PACKAGE) { - status = acpi_ut_copy_ipackage_to_ipackage (source_desc, *dest_desc, - walk_state); - } - else { - status = acpi_ut_copy_simple_object (source_desc, *dest_desc); + if (ACPI_GET_OBJECT_TYPE(source_desc) == ACPI_TYPE_PACKAGE) { + status = + acpi_ut_copy_ipackage_to_ipackage(source_desc, *dest_desc, + walk_state); + } else { + status = acpi_ut_copy_simple_object(source_desc, *dest_desc); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - - diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c index 794c7df3f2a..d80e9263993 100644 --- a/drivers/acpi/utilities/utdebug.c +++ b/drivers/acpi/utilities/utdebug.c @@ -46,15 +46,16 @@ #include <acpi/acpi.h> #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utdebug") - +ACPI_MODULE_NAME("utdebug") #ifdef ACPI_DEBUG_OUTPUT +static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF; +static char *acpi_gbl_fn_entry_str = "----Entry"; +static char *acpi_gbl_fn_exit_str = "----Exit-"; -static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF; -static char *acpi_gbl_fn_entry_str = "----Entry"; -static char *acpi_gbl_fn_exit_str = "----Exit-"; +/* Local prototypes */ +static const char *acpi_ut_trim_function_name(const char *function_name); /******************************************************************************* * @@ -68,17 +69,13 @@ static char *acpi_gbl_fn_exit_str = "----Exit-"; * ******************************************************************************/ -void -acpi_ut_init_stack_ptr_trace ( - void) +void acpi_ut_init_stack_ptr_trace(void) { - u32 current_sp; - + u32 current_sp; - acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF (¤t_sp, NULL); + acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF(¤t_sp, NULL); } - /******************************************************************************* * * FUNCTION: acpi_ut_track_stack_ptr @@ -91,14 +88,11 @@ acpi_ut_init_stack_ptr_trace ( * ******************************************************************************/ -void -acpi_ut_track_stack_ptr ( - void) +void acpi_ut_track_stack_ptr(void) { - acpi_size current_sp; - + acpi_size current_sp; - current_sp = ACPI_PTR_DIFF (¤t_sp, NULL); + current_sp = ACPI_PTR_DIFF(¤t_sp, NULL); if (current_sp < acpi_gbl_lowest_stack_pointer) { acpi_gbl_lowest_stack_pointer = current_sp; @@ -109,6 +103,39 @@ acpi_ut_track_stack_ptr ( } } +/******************************************************************************* + * + * FUNCTION: acpi_ut_trim_function_name + * + * PARAMETERS: function_name - Ascii string containing a procedure name + * + * RETURN: Updated pointer to the function name + * + * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present. + * This allows compiler macros such as __FUNCTION__ to be used + * with no change to the debug output. + * + ******************************************************************************/ + +static const char *acpi_ut_trim_function_name(const char *function_name) +{ + + /* All Function names are longer than 4 chars, check is safe */ + + if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) { + /* This is the case where the original source has not been modified */ + + return (function_name + 4); + } + + if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) { + /* This is the case where the source has been 'linuxized' */ + + return (function_name + 5); + } + + return (function_name); +} /******************************************************************************* * @@ -116,10 +143,9 @@ acpi_ut_track_stack_ptr ( * * PARAMETERS: requested_debug_level - Requested debug print level * line_number - Caller's line number (for error output) - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Format - Printf format field * ... - Optional printf arguments * @@ -130,36 +156,33 @@ acpi_ut_track_stack_ptr ( * ******************************************************************************/ -void ACPI_INTERNAL_VAR_XFACE -acpi_ut_debug_print ( - u32 requested_debug_level, - u32 line_number, - struct acpi_debug_print_info *dbg_info, - char *format, - ...) +void ACPI_INTERNAL_VAR_XFACE +acpi_ut_debug_print(u32 requested_debug_level, + u32 line_number, + const char *function_name, + char *module_name, u32 component_id, char *format, ...) { - u32 thread_id; - va_list args; - + u32 thread_id; + va_list args; /* * Stay silent if the debug level or component ID is disabled */ if (!(requested_debug_level & acpi_dbg_level) || - !(dbg_info->component_id & acpi_dbg_layer)) { + !(component_id & acpi_dbg_layer)) { return; } /* * Thread tracking and context switch notification */ - thread_id = acpi_os_get_thread_id (); + thread_id = acpi_os_get_thread_id(); if (thread_id != acpi_gbl_prev_thread_id) { if (ACPI_LV_THREADS & acpi_dbg_level) { - acpi_os_printf ( - "\n**** Context Switch from TID %X to TID %X ****\n\n", - acpi_gbl_prev_thread_id, thread_id); + acpi_os_printf + ("\n**** Context Switch from TID %X to TID %X ****\n\n", + acpi_gbl_prev_thread_id, thread_id); } acpi_gbl_prev_thread_id = thread_id; @@ -169,17 +192,18 @@ acpi_ut_debug_print ( * Display the module name, current line number, thread ID (if requested), * current procedure nesting level, and the current procedure name */ - acpi_os_printf ("%8s-%04ld ", dbg_info->module_name, line_number); + acpi_os_printf("%8s-%04ld ", module_name, line_number); if (ACPI_LV_THREADS & acpi_dbg_level) { - acpi_os_printf ("[%04lX] ", thread_id); + acpi_os_printf("[%04lX] ", thread_id); } - acpi_os_printf ("[%02ld] %-22.22s: ", - acpi_gbl_nesting_level, dbg_info->proc_name); + acpi_os_printf("[%02ld] %-22.22s: ", + acpi_gbl_nesting_level, + acpi_ut_trim_function_name(function_name)); - va_start (args, format); - acpi_os_vprintf (format, args); + va_start(args, format); + acpi_os_vprintf(format, args); } EXPORT_SYMBOL(acpi_ut_debug_print); @@ -190,10 +214,9 @@ EXPORT_SYMBOL(acpi_ut_debug_print); * * PARAMETERS: requested_debug_level - Requested debug print level * line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Format - Printf format field * ... - Optional printf arguments * @@ -204,37 +227,33 @@ EXPORT_SYMBOL(acpi_ut_debug_print); * ******************************************************************************/ -void ACPI_INTERNAL_VAR_XFACE -acpi_ut_debug_print_raw ( - u32 requested_debug_level, - u32 line_number, - struct acpi_debug_print_info *dbg_info, - char *format, - ...) +void ACPI_INTERNAL_VAR_XFACE +acpi_ut_debug_print_raw(u32 requested_debug_level, + u32 line_number, + const char *function_name, + char *module_name, u32 component_id, char *format, ...) { - va_list args; - + va_list args; if (!(requested_debug_level & acpi_dbg_level) || - !(dbg_info->component_id & acpi_dbg_layer)) { + !(component_id & acpi_dbg_layer)) { return; } - va_start (args, format); - acpi_os_vprintf (format, args); + va_start(args, format); + acpi_os_vprintf(format, args); } -EXPORT_SYMBOL(acpi_ut_debug_print_raw); +EXPORT_SYMBOL(acpi_ut_debug_print_raw); /******************************************************************************* * * FUNCTION: acpi_ut_trace * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * * RETURN: None * @@ -244,29 +263,28 @@ EXPORT_SYMBOL(acpi_ut_debug_print_raw); ******************************************************************************/ void -acpi_ut_trace ( - u32 line_number, - struct acpi_debug_print_info *dbg_info) +acpi_ut_trace(u32 line_number, + const char *function_name, char *module_name, u32 component_id) { acpi_gbl_nesting_level++; - acpi_ut_track_stack_ptr (); + acpi_ut_track_stack_ptr(); - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s\n", acpi_gbl_fn_entry_str); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s\n", acpi_gbl_fn_entry_str); } -EXPORT_SYMBOL(acpi_ut_trace); +EXPORT_SYMBOL(acpi_ut_trace); /******************************************************************************* * * FUNCTION: acpi_ut_trace_ptr * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Pointer - Pointer to display * * RETURN: None @@ -277,28 +295,27 @@ EXPORT_SYMBOL(acpi_ut_trace); ******************************************************************************/ void -acpi_ut_trace_ptr ( - u32 line_number, - struct acpi_debug_print_info *dbg_info, - void *pointer) +acpi_ut_trace_ptr(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, void *pointer) { acpi_gbl_nesting_level++; - acpi_ut_track_stack_ptr (); + acpi_ut_track_stack_ptr(); - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s %p\n", acpi_gbl_fn_entry_str, pointer); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s %p\n", acpi_gbl_fn_entry_str, + pointer); } - /******************************************************************************* * * FUNCTION: acpi_ut_trace_str * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * String - Additional string to display * * RETURN: None @@ -309,29 +326,28 @@ acpi_ut_trace_ptr ( ******************************************************************************/ void -acpi_ut_trace_str ( - u32 line_number, - struct acpi_debug_print_info *dbg_info, - char *string) +acpi_ut_trace_str(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, char *string) { acpi_gbl_nesting_level++; - acpi_ut_track_stack_ptr (); + acpi_ut_track_stack_ptr(); - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s %s\n", acpi_gbl_fn_entry_str, string); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s %s\n", acpi_gbl_fn_entry_str, + string); } - /******************************************************************************* * * FUNCTION: acpi_ut_trace_u32 * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Integer - Integer to display * * RETURN: None @@ -342,29 +358,28 @@ acpi_ut_trace_str ( ******************************************************************************/ void -acpi_ut_trace_u32 ( - u32 line_number, - struct acpi_debug_print_info *dbg_info, - u32 integer) +acpi_ut_trace_u32(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, u32 integer) { acpi_gbl_nesting_level++; - acpi_ut_track_stack_ptr (); + acpi_ut_track_stack_ptr(); - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s %08X\n", acpi_gbl_fn_entry_str, integer); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s %08X\n", acpi_gbl_fn_entry_str, + integer); } - /******************************************************************************* * * FUNCTION: acpi_ut_exit * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * * RETURN: None * @@ -374,28 +389,27 @@ acpi_ut_trace_u32 ( ******************************************************************************/ void -acpi_ut_exit ( - u32 line_number, - struct acpi_debug_print_info *dbg_info) +acpi_ut_exit(u32 line_number, + const char *function_name, char *module_name, u32 component_id) { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s\n", acpi_gbl_fn_exit_str); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s\n", acpi_gbl_fn_exit_str); acpi_gbl_nesting_level--; } -EXPORT_SYMBOL(acpi_ut_exit); +EXPORT_SYMBOL(acpi_ut_exit); /******************************************************************************* * * FUNCTION: acpi_ut_status_exit * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Status - Exit status code * * RETURN: None @@ -406,37 +420,38 @@ EXPORT_SYMBOL(acpi_ut_exit); ******************************************************************************/ void -acpi_ut_status_exit ( - u32 line_number, - struct acpi_debug_print_info *dbg_info, - acpi_status status) +acpi_ut_status_exit(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, acpi_status status) { - if (ACPI_SUCCESS (status)) { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s %s\n", acpi_gbl_fn_exit_str, - acpi_format_exception (status)); - } - else { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s ****Exception****: %s\n", acpi_gbl_fn_exit_str, - acpi_format_exception (status)); + if (ACPI_SUCCESS(status)) { + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s %s\n", + acpi_gbl_fn_exit_str, + acpi_format_exception(status)); + } else { + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s ****Exception****: %s\n", + acpi_gbl_fn_exit_str, + acpi_format_exception(status)); } acpi_gbl_nesting_level--; } -EXPORT_SYMBOL(acpi_ut_status_exit); +EXPORT_SYMBOL(acpi_ut_status_exit); /******************************************************************************* * * FUNCTION: acpi_ut_value_exit * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Value - Value to be printed with exit msg * * RETURN: None @@ -447,30 +462,29 @@ EXPORT_SYMBOL(acpi_ut_status_exit); ******************************************************************************/ void -acpi_ut_value_exit ( - u32 line_number, - struct acpi_debug_print_info *dbg_info, - acpi_integer value) +acpi_ut_value_exit(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, acpi_integer value) { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, - ACPI_FORMAT_UINT64 (value)); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s %8.8X%8.8X\n", + acpi_gbl_fn_exit_str, ACPI_FORMAT_UINT64(value)); acpi_gbl_nesting_level--; } -EXPORT_SYMBOL(acpi_ut_value_exit); +EXPORT_SYMBOL(acpi_ut_value_exit); /******************************************************************************* * * FUNCTION: acpi_ut_ptr_exit * * PARAMETERS: line_number - Caller's line number - * dbg_info - Contains: - * proc_name - Caller's procedure name - * module_name - Caller's module name - * component_id - Caller's component ID + * function_name - Caller's procedure name + * module_name - Caller's module name + * component_id - Caller's component ID * Ptr - Pointer to display * * RETURN: None @@ -481,21 +495,20 @@ EXPORT_SYMBOL(acpi_ut_value_exit); ******************************************************************************/ void -acpi_ut_ptr_exit ( - u32 line_number, - struct acpi_debug_print_info *dbg_info, - u8 *ptr) +acpi_ut_ptr_exit(u32 line_number, + const char *function_name, + char *module_name, u32 component_id, u8 * ptr) { - acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, - "%s %p\n", acpi_gbl_fn_exit_str, ptr); + acpi_ut_debug_print(ACPI_LV_FUNCTIONS, + line_number, function_name, module_name, + component_id, "%s %p\n", acpi_gbl_fn_exit_str, ptr); acpi_gbl_nesting_level--; } #endif - /******************************************************************************* * * FUNCTION: acpi_ut_dump_buffer @@ -511,23 +524,17 @@ acpi_ut_ptr_exit ( * ******************************************************************************/ -void -acpi_ut_dump_buffer ( - u8 *buffer, - u32 count, - u32 display, - u32 component_id) +void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id) { - acpi_native_uint i = 0; - acpi_native_uint j; - u32 temp32; - u8 buf_char; - + acpi_native_uint i = 0; + acpi_native_uint j; + u32 temp32; + u8 buf_char; /* Only dump the buffer if tracing is enabled */ if (!((ACPI_LV_TABLES & acpi_dbg_level) && - (component_id & acpi_dbg_layer))) { + (component_id & acpi_dbg_layer))) { return; } @@ -540,7 +547,7 @@ acpi_ut_dump_buffer ( while (i < count) { /* Print current offset */ - acpi_os_printf ("%6.4X: ", (u32) i); + acpi_os_printf("%6.4X: ", (u32) i); /* Print 16 hex chars */ @@ -548,73 +555,66 @@ acpi_ut_dump_buffer ( if (i + j >= count) { /* Dump fill spaces */ - acpi_os_printf ("%*s", ((display * 2) + 1), " "); - j += display; + acpi_os_printf("%*s", ((display * 2) + 1), " "); + j += (acpi_native_uint) display; continue; } switch (display) { - default: /* Default is BYTE display */ + default: /* Default is BYTE display */ - acpi_os_printf ("%02X ", buffer[i + j]); + acpi_os_printf("%02X ", buffer[i + j]); break; - case DB_WORD_DISPLAY: - ACPI_MOVE_16_TO_32 (&temp32, &buffer[i + j]); - acpi_os_printf ("%04X ", temp32); + ACPI_MOVE_16_TO_32(&temp32, &buffer[i + j]); + acpi_os_printf("%04X ", temp32); break; - case DB_DWORD_DISPLAY: - ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]); - acpi_os_printf ("%08X ", temp32); + ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]); + acpi_os_printf("%08X ", temp32); break; - case DB_QWORD_DISPLAY: - ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]); - acpi_os_printf ("%08X", temp32); + ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]); + acpi_os_printf("%08X", temp32); - ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j + 4]); - acpi_os_printf ("%08X ", temp32); + ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j + 4]); + acpi_os_printf("%08X ", temp32); break; } - j += display; + j += (acpi_native_uint) display; } /* - * Print the ASCII equivalent characters - * But watch out for the bad unprintable ones... + * Print the ASCII equivalent characters but watch out for the bad + * unprintable ones (printable chars are 0x20 through 0x7E) */ - acpi_os_printf (" "); + acpi_os_printf(" "); for (j = 0; j < 16; j++) { if (i + j >= count) { - acpi_os_printf ("\n"); + acpi_os_printf("\n"); return; } buf_char = buffer[i + j]; - if ((buf_char > 0x1F && buf_char < 0x2E) || - (buf_char > 0x2F && buf_char < 0x61) || - (buf_char > 0x60 && buf_char < 0x7F)) { - acpi_os_printf ("%c", buf_char); - } - else { - acpi_os_printf ("."); + if (ACPI_IS_PRINT(buf_char)) { + acpi_os_printf("%c", buf_char); + } else { + acpi_os_printf("."); } } /* Done with that line. */ - acpi_os_printf ("\n"); + acpi_os_printf("\n"); i += 16; } return; } - diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c index bc540302268..2bc878f7a12 100644 --- a/drivers/acpi/utilities/utdelete.c +++ b/drivers/acpi/utilities/utdelete.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <acpi/acpi.h> #include <acpi/acinterp.h> #include <acpi/acnamesp.h> @@ -49,19 +48,13 @@ #include <acpi/amlcode.h> #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utdelete") +ACPI_MODULE_NAME("utdelete") /* Local prototypes */ +static void acpi_ut_delete_internal_obj(union acpi_operand_object *object); static void -acpi_ut_delete_internal_obj ( - union acpi_operand_object *object); - -static void -acpi_ut_update_ref_count ( - union acpi_operand_object *object, - u32 action); - +acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action); /******************************************************************************* * @@ -76,18 +69,14 @@ acpi_ut_update_ref_count ( * ******************************************************************************/ -static void -acpi_ut_delete_internal_obj ( - union acpi_operand_object *object) +static void acpi_ut_delete_internal_obj(union acpi_operand_object *object) { - void *obj_pointer = NULL; - union acpi_operand_object *handler_desc; - union acpi_operand_object *second_desc; - union acpi_operand_object *next_desc; - - - ACPI_FUNCTION_TRACE_PTR ("ut_delete_internal_obj", object); + void *obj_pointer = NULL; + union acpi_operand_object *handler_desc; + union acpi_operand_object *second_desc; + union acpi_operand_object *next_desc; + ACPI_FUNCTION_TRACE_PTR("ut_delete_internal_obj", object); if (!object) { return_VOID; @@ -97,11 +86,12 @@ acpi_ut_delete_internal_obj ( * Must delete or free any pointers within the object that are not * actual ACPI objects (for example, a raw buffer pointer). */ - switch (ACPI_GET_OBJECT_TYPE (object)) { + switch (ACPI_GET_OBJECT_TYPE(object)) { case ACPI_TYPE_STRING: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n", - object, object->string.pointer)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "**** String %p, ptr %p\n", object, + object->string.pointer)); /* Free the actual string buffer */ @@ -112,11 +102,11 @@ acpi_ut_delete_internal_obj ( } break; - case ACPI_TYPE_BUFFER: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n", - object, object->buffer.pointer)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "**** Buffer %p, ptr %p\n", object, + object->buffer.pointer)); /* Free the actual buffer */ @@ -127,11 +117,11 @@ acpi_ut_delete_internal_obj ( } break; - case ACPI_TYPE_PACKAGE: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n", - object->package.count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + " **** Package of count %X\n", + object->package.count)); /* * Elements of the package are not handled here, they are deleted @@ -143,11 +133,11 @@ acpi_ut_delete_internal_obj ( obj_pointer = object->package.elements; break; - case ACPI_TYPE_DEVICE: if (object->device.gpe_block) { - (void) acpi_ev_delete_gpe_block (object->device.gpe_block); + (void)acpi_ev_delete_gpe_block(object->device. + gpe_block); } /* Walk the handler list for this device */ @@ -155,54 +145,51 @@ acpi_ut_delete_internal_obj ( handler_desc = object->device.handler; while (handler_desc) { next_desc = handler_desc->address_space.next; - acpi_ut_remove_reference (handler_desc); + acpi_ut_remove_reference(handler_desc); handler_desc = next_desc; } break; - case ACPI_TYPE_MUTEX: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "***** Mutex %p, Semaphore %p\n", - object, object->mutex.semaphore)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "***** Mutex %p, Semaphore %p\n", + object, object->mutex.semaphore)); - acpi_ex_unlink_mutex (object); - (void) acpi_os_delete_semaphore (object->mutex.semaphore); + acpi_ex_unlink_mutex(object); + (void)acpi_os_delete_semaphore(object->mutex.semaphore); break; - case ACPI_TYPE_EVENT: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "***** Event %p, Semaphore %p\n", - object, object->event.semaphore)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "***** Event %p, Semaphore %p\n", + object, object->event.semaphore)); - (void) acpi_os_delete_semaphore (object->event.semaphore); + (void)acpi_os_delete_semaphore(object->event.semaphore); object->event.semaphore = NULL; break; - case ACPI_TYPE_METHOD: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "***** Method %p\n", object)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "***** Method %p\n", object)); /* Delete the method semaphore if it exists */ if (object->method.semaphore) { - (void) acpi_os_delete_semaphore (object->method.semaphore); + (void)acpi_os_delete_semaphore(object->method. + semaphore); object->method.semaphore = NULL; } break; - case ACPI_TYPE_REGION: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "***** Region %p\n", object)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "***** Region %p\n", object)); - second_desc = acpi_ns_get_secondary_object (object); + second_desc = acpi_ns_get_secondary_object(object); if (second_desc) { /* * Free the region_context if and only if the handler is one of the @@ -211,32 +198,33 @@ acpi_ut_delete_internal_obj ( */ handler_desc = object->region.handler; if (handler_desc) { - if (handler_desc->address_space.hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { - obj_pointer = second_desc->extra.region_context; + if (handler_desc->address_space. + hflags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { + obj_pointer = + second_desc->extra.region_context; } - acpi_ut_remove_reference (handler_desc); + acpi_ut_remove_reference(handler_desc); } /* Now we can free the Extra object */ - acpi_ut_delete_object_desc (second_desc); + acpi_ut_delete_object_desc(second_desc); } break; - case ACPI_TYPE_BUFFER_FIELD: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "***** Buffer Field %p\n", object)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "***** Buffer Field %p\n", object)); - second_desc = acpi_ns_get_secondary_object (object); + second_desc = acpi_ns_get_secondary_object(object); if (second_desc) { - acpi_ut_delete_object_desc (second_desc); + acpi_ut_delete_object_desc(second_desc); } break; - default: break; } @@ -244,21 +232,20 @@ acpi_ut_delete_internal_obj ( /* Free any allocated memory (pointer within the object) found above */ if (obj_pointer) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n", - obj_pointer)); - ACPI_MEM_FREE (obj_pointer); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Deleting Object Subptr %p\n", obj_pointer)); + ACPI_MEM_FREE(obj_pointer); } /* Now the object can be safely deleted */ - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n", - object, acpi_ut_get_object_type_name (object))); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n", + object, acpi_ut_get_object_type_name(object))); - acpi_ut_delete_object_desc (object); + acpi_ut_delete_object_desc(object); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ut_delete_internal_object_list @@ -272,29 +259,24 @@ acpi_ut_delete_internal_obj ( * ******************************************************************************/ -void -acpi_ut_delete_internal_object_list ( - union acpi_operand_object **obj_list) +void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list) { - union acpi_operand_object **internal_obj; - - - ACPI_FUNCTION_TRACE ("ut_delete_internal_object_list"); + union acpi_operand_object **internal_obj; + ACPI_FUNCTION_TRACE("ut_delete_internal_object_list"); /* Walk the null-terminated internal list */ for (internal_obj = obj_list; *internal_obj; internal_obj++) { - acpi_ut_remove_reference (*internal_obj); + acpi_ut_remove_reference(*internal_obj); } /* Free the combined parameter pointer list and object array */ - ACPI_MEM_FREE (obj_list); + ACPI_MEM_FREE(obj_list); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ut_update_ref_count @@ -309,16 +291,12 @@ acpi_ut_delete_internal_object_list ( ******************************************************************************/ static void -acpi_ut_update_ref_count ( - union acpi_operand_object *object, - u32 action) +acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action) { - u16 count; - u16 new_count; - - - ACPI_FUNCTION_NAME ("ut_update_ref_count"); + u16 count; + u16 new_count; + ACPI_FUNCTION_NAME("ut_update_ref_count"); if (!object) { return; @@ -338,58 +316,55 @@ acpi_ut_update_ref_count ( new_count++; object->common.reference_count = new_count; - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Refs=%X, [Incremented]\n", - object, new_count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Incremented]\n", + object, new_count)); break; - case REF_DECREMENT: if (count < 1) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Refs=%X, can't decrement! (Set to 0)\n", - object, new_count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, can't decrement! (Set to 0)\n", + object, new_count)); new_count = 0; - } - else { + } else { new_count--; - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Refs=%X, [Decremented]\n", - object, new_count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Decremented]\n", + object, new_count)); } - if (ACPI_GET_OBJECT_TYPE (object) == ACPI_TYPE_METHOD) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Method Obj %p Refs=%X, [Decremented]\n", - object, new_count)); + if (ACPI_GET_OBJECT_TYPE(object) == ACPI_TYPE_METHOD) { + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Method Obj %p Refs=%X, [Decremented]\n", + object, new_count)); } object->common.reference_count = new_count; if (new_count == 0) { - acpi_ut_delete_internal_obj (object); + acpi_ut_delete_internal_obj(object); } break; - case REF_FORCE_DELETE: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Refs=%X, Force delete! (Set to 0)\n", - object, count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, Force delete! (Set to 0)\n", + object, count)); new_count = 0; object->common.reference_count = new_count; - acpi_ut_delete_internal_obj (object); + acpi_ut_delete_internal_obj(object); break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown action (%X)\n", action)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown action (%X)\n", + action)); break; } @@ -399,15 +374,14 @@ acpi_ut_update_ref_count ( */ if (count > ACPI_MAX_REFERENCE_COUNT) { - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, - "**** Warning **** Large Reference Count (%X) in object %p\n\n", - count, object)); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "**** Warning **** Large Reference Count (%X) in object %p\n\n", + count, object)); } return; } - /******************************************************************************* * * FUNCTION: acpi_ut_update_object_reference @@ -431,65 +405,42 @@ acpi_ut_update_ref_count ( ******************************************************************************/ acpi_status -acpi_ut_update_object_reference ( - union acpi_operand_object *object, - u16 action) +acpi_ut_update_object_reference(union acpi_operand_object * object, u16 action) { - acpi_status status; - u32 i; - union acpi_generic_state *state_list = NULL; - union acpi_generic_state *state; - union acpi_operand_object *tmp; - - ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object); + acpi_status status = AE_OK; + union acpi_generic_state *state_list = NULL; + union acpi_operand_object *next_object = NULL; + union acpi_generic_state *state; + acpi_native_uint i; + ACPI_FUNCTION_TRACE_PTR("ut_update_object_reference", object); - /* Ignore a null object ptr */ + while (object) { + /* Make sure that this isn't a namespace handle */ - if (!object) { - return_ACPI_STATUS (AE_OK); - } - - /* Make sure that this isn't a namespace handle */ - - if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Object %p is NS handle\n", object)); - return_ACPI_STATUS (AE_OK); - } - - state = acpi_ut_create_update_state (object, action); - - while (state) { - object = state->update.object; - action = state->update.value; - acpi_ut_delete_generic_state (state); + if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) { + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Object %p is NS handle\n", object)); + return_ACPI_STATUS(AE_OK); + } /* * All sub-objects must have their reference count incremented also. * Different object types have different subobjects. */ - switch (ACPI_GET_OBJECT_TYPE (object)) { + switch (ACPI_GET_OBJECT_TYPE(object)) { case ACPI_TYPE_DEVICE: - tmp = object->device.system_notify; - if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->device.system_notify = NULL; - acpi_ut_update_ref_count (tmp, action); - - tmp = object->device.device_notify; - if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->device.device_notify = NULL; - acpi_ut_update_ref_count (tmp, action); - + acpi_ut_update_ref_count(object->device.system_notify, + action); + acpi_ut_update_ref_count(object->device.device_notify, + action); break; - case ACPI_TYPE_PACKAGE: - /* - * We must update all the sub-objects of the package - * (Each of whom may have their own sub-objects, etc. + * We must update all the sub-objects of the package, + * each of whom may have their own sub-objects. */ for (i = 0; i < object->package.count; i++) { /* @@ -497,116 +448,67 @@ acpi_ut_update_object_reference ( * Note: There can be null elements within the package, * these are simply ignored */ - status = acpi_ut_create_update_state_and_push ( - object->package.elements[i], action, &state_list); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_create_update_state_and_push + (object->package.elements[i], action, + &state_list); + if (ACPI_FAILURE(status)) { goto error_exit; } - - tmp = object->package.elements[i]; - if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->package.elements[i] = NULL; } break; - case ACPI_TYPE_BUFFER_FIELD: - status = acpi_ut_create_update_state_and_push ( - object->buffer_field.buffer_obj, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } - - tmp = object->buffer_field.buffer_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->buffer_field.buffer_obj = NULL; + next_object = object->buffer_field.buffer_obj; break; - case ACPI_TYPE_LOCAL_REGION_FIELD: - status = acpi_ut_create_update_state_and_push ( - object->field.region_obj, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } - - tmp = object->field.region_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->field.region_obj = NULL; - break; - + next_object = object->field.region_obj; + break; case ACPI_TYPE_LOCAL_BANK_FIELD: - status = acpi_ut_create_update_state_and_push ( - object->bank_field.bank_obj, action, &state_list); - if (ACPI_FAILURE (status)) { + next_object = object->bank_field.bank_obj; + status = + acpi_ut_create_update_state_and_push(object-> + bank_field. + region_obj, + action, + &state_list); + if (ACPI_FAILURE(status)) { goto error_exit; } - - tmp = object->bank_field.bank_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->bank_field.bank_obj = NULL; - - status = acpi_ut_create_update_state_and_push ( - object->bank_field.region_obj, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } - - tmp = object->bank_field.region_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->bank_field.region_obj = NULL; break; - case ACPI_TYPE_LOCAL_INDEX_FIELD: - status = acpi_ut_create_update_state_and_push ( - object->index_field.index_obj, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } - - tmp = object->index_field.index_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->index_field.index_obj = NULL; - - status = acpi_ut_create_update_state_and_push ( - object->index_field.data_obj, action, &state_list); - if (ACPI_FAILURE (status)) { + next_object = object->index_field.index_obj; + status = + acpi_ut_create_update_state_and_push(object-> + index_field. + data_obj, + action, + &state_list); + if (ACPI_FAILURE(status)) { goto error_exit; } - - tmp = object->index_field.data_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->index_field.data_obj = NULL; break; - case ACPI_TYPE_LOCAL_REFERENCE: - /* * The target of an Index (a package, string, or buffer) must track * changes to the ref count of the index. */ if (object->reference.opcode == AML_INDEX_OP) { - status = acpi_ut_create_update_state_and_push ( - object->reference.object, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } + next_object = object->reference.object; } break; - case ACPI_TYPE_REGION: default: - - /* No subobjects */ - break; + break; /* No subobjects */ } /* @@ -614,25 +516,31 @@ acpi_ut_update_object_reference ( * happen after we update the sub-objects in case this causes the * main object to be deleted. */ - acpi_ut_update_ref_count (object, action); + acpi_ut_update_ref_count(object, action); + object = NULL; /* Move on to the next object to be updated */ - state = acpi_ut_pop_generic_state (&state_list); + if (next_object) { + object = next_object; + next_object = NULL; + } else if (state_list) { + state = acpi_ut_pop_generic_state(&state_list); + object = state->update.object; + acpi_ut_delete_generic_state(state); + } } - return_ACPI_STATUS (AE_OK); - + return_ACPI_STATUS(AE_OK); -error_exit: + error_exit: - ACPI_REPORT_ERROR (("Could not update object reference count, %s\n", - acpi_format_exception (status))); + ACPI_REPORT_ERROR(("Could not update object reference count, %s\n", + acpi_format_exception(status))); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_add_reference @@ -646,31 +554,27 @@ error_exit: * ******************************************************************************/ -void -acpi_ut_add_reference ( - union acpi_operand_object *object) +void acpi_ut_add_reference(union acpi_operand_object *object) { - ACPI_FUNCTION_TRACE_PTR ("ut_add_reference", object); - + ACPI_FUNCTION_TRACE_PTR("ut_add_reference", object); /* Ensure that we have a valid object */ - if (!acpi_ut_valid_internal_object (object)) { + if (!acpi_ut_valid_internal_object(object)) { return_VOID; } - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Current Refs=%X [To Be Incremented]\n", - object, object->common.reference_count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Incremented]\n", + object, object->common.reference_count)); /* Increment the reference count */ - (void) acpi_ut_update_object_reference (object, REF_INCREMENT); + (void)acpi_ut_update_object_reference(object, REF_INCREMENT); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ut_remove_reference @@ -683,13 +587,10 @@ acpi_ut_add_reference ( * ******************************************************************************/ -void -acpi_ut_remove_reference ( - union acpi_operand_object *object) +void acpi_ut_remove_reference(union acpi_operand_object *object) { - ACPI_FUNCTION_TRACE_PTR ("ut_remove_reference", object); - + ACPI_FUNCTION_TRACE_PTR("ut_remove_reference", object); /* * Allow a NULL pointer to be passed in, just ignore it. This saves @@ -697,27 +598,25 @@ acpi_ut_remove_reference ( * */ if (!object || - (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED)) { + (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) { return_VOID; } /* Ensure that we have a valid object */ - if (!acpi_ut_valid_internal_object (object)) { + if (!acpi_ut_valid_internal_object(object)) { return_VOID; } - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Current Refs=%X [To Be Decremented]\n", - object, object->common.reference_count)); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Decremented]\n", + object, object->common.reference_count)); /* * Decrement the reference count, and only actually delete the object * if the reference count becomes 0. (Must also decrement the ref count * of all subobjects!) */ - (void) acpi_ut_update_object_reference (object, REF_DECREMENT); + (void)acpi_ut_update_object_reference(object, REF_DECREMENT); return_VOID; } - - diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c index 00046dd5d92..7b81d5ef3c3 100644 --- a/drivers/acpi/utilities/uteval.c +++ b/drivers/acpi/utilities/uteval.c @@ -41,28 +41,20 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <acpi/acpi.h> #include <acpi/acnamesp.h> #include <acpi/acinterp.h> - #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("uteval") +ACPI_MODULE_NAME("uteval") /* Local prototypes */ - static void -acpi_ut_copy_id_string ( - char *destination, - char *source, - acpi_size max_length); +acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length); static acpi_status -acpi_ut_translate_one_cid ( - union acpi_operand_object *obj_desc, - struct acpi_compatible_id *one_cid); - +acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc, + struct acpi_compatible_id *one_cid); /******************************************************************************* * @@ -77,37 +69,33 @@ acpi_ut_translate_one_cid ( * ******************************************************************************/ -acpi_status -acpi_ut_osi_implementation ( - struct acpi_walk_state *walk_state) +acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) { - union acpi_operand_object *string_desc; - union acpi_operand_object *return_desc; - acpi_native_uint i; - - - ACPI_FUNCTION_TRACE ("ut_osi_implementation"); + union acpi_operand_object *string_desc; + union acpi_operand_object *return_desc; + acpi_native_uint i; + ACPI_FUNCTION_TRACE("ut_osi_implementation"); /* Validate the string input argument */ string_desc = walk_state->arguments[0].object; if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) { - return_ACPI_STATUS (AE_TYPE); + return_ACPI_STATUS(AE_TYPE); } /* Create a return object (Default value = 0) */ - return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); + return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!return_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Compare input string to table of supported strings */ for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) { - if (!ACPI_STRCMP (string_desc->string.pointer, - (char *) acpi_gbl_valid_osi_strings[i])) { + if (!ACPI_STRCMP(string_desc->string.pointer, + (char *)acpi_gbl_valid_osi_strings[i])) { /* This string is supported */ return_desc->integer.value = 0xFFFFFFFF; @@ -116,10 +104,9 @@ acpi_ut_osi_implementation ( } walk_state->return_desc = return_desc; - return_ACPI_STATUS (AE_CTRL_TERMINATE); + return_ACPI_STATUS(AE_CTRL_TERMINATE); } - /******************************************************************************* * * FUNCTION: acpi_ut_evaluate_object @@ -140,19 +127,16 @@ acpi_ut_osi_implementation ( ******************************************************************************/ acpi_status -acpi_ut_evaluate_object ( - struct acpi_namespace_node *prefix_node, - char *path, - u32 expected_return_btypes, - union acpi_operand_object **return_desc) +acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, + char *path, + u32 expected_return_btypes, + union acpi_operand_object **return_desc) { - struct acpi_parameter_info info; - acpi_status status; - u32 return_btype; - - - ACPI_FUNCTION_TRACE ("ut_evaluate_object"); + struct acpi_parameter_info info; + acpi_status status; + u32 return_btype; + ACPI_FUNCTION_TRACE("ut_evaluate_object"); info.node = prefix_node; info.parameters = NULL; @@ -160,36 +144,38 @@ acpi_ut_evaluate_object ( /* Evaluate the object/method */ - status = acpi_ns_evaluate_relative (path, &info); - if (ACPI_FAILURE (status)) { + status = acpi_ns_evaluate_relative(path, &info); + if (ACPI_FAILURE(status)) { if (status == AE_NOT_FOUND) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n", - acpi_ut_get_node_name (prefix_node), path)); - } - else { - ACPI_REPORT_METHOD_ERROR ("Method execution failed", - prefix_node, path, status); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[%4.4s.%s] was not found\n", + acpi_ut_get_node_name(prefix_node), + path)); + } else { + ACPI_REPORT_METHOD_ERROR("Method execution failed", + prefix_node, path, status); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Did we get a return object? */ if (!info.return_object) { if (expected_return_btypes) { - ACPI_REPORT_METHOD_ERROR ("No object was returned from", - prefix_node, path, AE_NOT_EXIST); + ACPI_REPORT_METHOD_ERROR("No object was returned from", + prefix_node, path, + AE_NOT_EXIST); - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Map the return object type to the bitmapped type */ - switch (ACPI_GET_OBJECT_TYPE (info.return_object)) { + switch (ACPI_GET_OBJECT_TYPE(info.return_object)) { case ACPI_TYPE_INTEGER: return_btype = ACPI_BTYPE_INTEGER; break; @@ -211,41 +197,41 @@ acpi_ut_evaluate_object ( break; } - if ((acpi_gbl_enable_interpreter_slack) && - (!expected_return_btypes)) { + if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) { /* * We received a return object, but one was not expected. This can * happen frequently if the "implicit return" feature is enabled. * Just delete the return object and return AE_OK. */ - acpi_ut_remove_reference (info.return_object); - return_ACPI_STATUS (AE_OK); + acpi_ut_remove_reference(info.return_object); + return_ACPI_STATUS(AE_OK); } /* Is the return object one of the expected types? */ if (!(expected_return_btypes & return_btype)) { - ACPI_REPORT_METHOD_ERROR ("Return object type is incorrect", - prefix_node, path, AE_TYPE); + ACPI_REPORT_METHOD_ERROR("Return object type is incorrect", + prefix_node, path, AE_TYPE); - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Type returned from %s was incorrect: %s, expected Btypes: %X\n", - path, acpi_ut_get_object_type_name (info.return_object), - expected_return_btypes)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Type returned from %s was incorrect: %s, expected Btypes: %X\n", + path, + acpi_ut_get_object_type_name(info. + return_object), + expected_return_btypes)); /* On error exit, we must delete the return object */ - acpi_ut_remove_reference (info.return_object); - return_ACPI_STATUS (AE_TYPE); + acpi_ut_remove_reference(info.return_object); + return_ACPI_STATUS(AE_TYPE); } /* Object type is OK, return it */ *return_desc = info.return_object; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ut_evaluate_numeric_object @@ -264,22 +250,19 @@ acpi_ut_evaluate_object ( ******************************************************************************/ acpi_status -acpi_ut_evaluate_numeric_object ( - char *object_name, - struct acpi_namespace_node *device_node, - acpi_integer *address) +acpi_ut_evaluate_numeric_object(char *object_name, + struct acpi_namespace_node *device_node, + acpi_integer * address) { - union acpi_operand_object *obj_desc; - acpi_status status; - + union acpi_operand_object *obj_desc; + acpi_status status; - ACPI_FUNCTION_TRACE ("ut_evaluate_numeric_object"); + ACPI_FUNCTION_TRACE("ut_evaluate_numeric_object"); - - status = acpi_ut_evaluate_object (device_node, object_name, - ACPI_BTYPE_INTEGER, &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_evaluate_object(device_node, object_name, + ACPI_BTYPE_INTEGER, &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Get the returned Integer */ @@ -288,11 +271,10 @@ acpi_ut_evaluate_numeric_object ( /* On exit, we must delete the return object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_copy_id_string @@ -310,10 +292,7 @@ acpi_ut_evaluate_numeric_object ( ******************************************************************************/ static void -acpi_ut_copy_id_string ( - char *destination, - char *source, - acpi_size max_length) +acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length) { /* @@ -328,10 +307,9 @@ acpi_ut_copy_id_string ( /* Do the actual copy */ - ACPI_STRNCPY (destination, source, max_length); + ACPI_STRNCPY(destination, source, max_length); } - /******************************************************************************* * * FUNCTION: acpi_ut_execute_HID @@ -349,42 +327,39 @@ acpi_ut_copy_id_string ( ******************************************************************************/ acpi_status -acpi_ut_execute_HID ( - struct acpi_namespace_node *device_node, - struct acpi_device_id *hid) +acpi_ut_execute_HID(struct acpi_namespace_node *device_node, + struct acpi_device_id *hid) { - union acpi_operand_object *obj_desc; - acpi_status status; - + union acpi_operand_object *obj_desc; + acpi_status status; - ACPI_FUNCTION_TRACE ("ut_execute_HID"); + ACPI_FUNCTION_TRACE("ut_execute_HID"); - - status = acpi_ut_evaluate_object (device_node, METHOD_NAME__HID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, + &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { /* Convert the Numeric HID to string */ - acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, hid->value); - } - else { + acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value, + hid->value); + } else { /* Copy the String HID from the returned object */ - acpi_ut_copy_id_string (hid->value, obj_desc->string.pointer, - sizeof (hid->value)); + acpi_ut_copy_id_string(hid->value, obj_desc->string.pointer, + sizeof(hid->value)); } /* On exit, we must delete the return object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_translate_one_cid @@ -403,18 +378,17 @@ acpi_ut_execute_HID ( ******************************************************************************/ static acpi_status -acpi_ut_translate_one_cid ( - union acpi_operand_object *obj_desc, - struct acpi_compatible_id *one_cid) +acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc, + struct acpi_compatible_id *one_cid) { - - switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { case ACPI_TYPE_INTEGER: /* Convert the Numeric CID to string */ - acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, one_cid->value); + acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value, + one_cid->value); return (AE_OK); case ACPI_TYPE_STRING: @@ -425,8 +399,8 @@ acpi_ut_translate_one_cid ( /* Copy the String CID from the returned object */ - acpi_ut_copy_id_string (one_cid->value, obj_desc->string.pointer, - ACPI_MAX_CID_LENGTH); + acpi_ut_copy_id_string(one_cid->value, obj_desc->string.pointer, + ACPI_MAX_CID_LENGTH); return (AE_OK); default: @@ -435,7 +409,6 @@ acpi_ut_translate_one_cid ( } } - /******************************************************************************* * * FUNCTION: acpi_ut_execute_CID @@ -453,45 +426,42 @@ acpi_ut_translate_one_cid ( ******************************************************************************/ acpi_status -acpi_ut_execute_CID ( - struct acpi_namespace_node *device_node, - struct acpi_compatible_id_list **return_cid_list) +acpi_ut_execute_CID(struct acpi_namespace_node * device_node, + struct acpi_compatible_id_list ** return_cid_list) { - union acpi_operand_object *obj_desc; - acpi_status status; - u32 count; - u32 size; + union acpi_operand_object *obj_desc; + acpi_status status; + u32 count; + u32 size; struct acpi_compatible_id_list *cid_list; - acpi_native_uint i; - - - ACPI_FUNCTION_TRACE ("ut_execute_CID"); + acpi_native_uint i; + ACPI_FUNCTION_TRACE("ut_execute_CID"); /* Evaluate the _CID method for this device */ - status = acpi_ut_evaluate_object (device_node, METHOD_NAME__CID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, - &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING + | ACPI_BTYPE_PACKAGE, &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Get the number of _CIDs returned */ count = 1; - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { count = obj_desc->package.count; } /* Allocate a worst-case buffer for the _CIDs */ - size = (((count - 1) * sizeof (struct acpi_compatible_id)) + - sizeof (struct acpi_compatible_id_list)); + size = (((count - 1) * sizeof(struct acpi_compatible_id)) + + sizeof(struct acpi_compatible_id_list)); - cid_list = ACPI_MEM_CALLOCATE ((acpi_size) size); + cid_list = ACPI_MEM_CALLOCATE((acpi_size) size); if (!cid_list) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Init CID list */ @@ -508,39 +478,38 @@ acpi_ut_execute_CID ( /* The _CID object can be either a single CID or a package (list) of CIDs */ - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { /* Translate each package element */ for (i = 0; i < count; i++) { - status = acpi_ut_translate_one_cid (obj_desc->package.elements[i], - &cid_list->id[i]); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_translate_one_cid(obj_desc->package. + elements[i], + &cid_list->id[i]); + if (ACPI_FAILURE(status)) { break; } } - } - else { + } else { /* Only one CID, translate to a string */ - status = acpi_ut_translate_one_cid (obj_desc, cid_list->id); + status = acpi_ut_translate_one_cid(obj_desc, cid_list->id); } /* Cleanup on error */ - if (ACPI_FAILURE (status)) { - ACPI_MEM_FREE (cid_list); - } - else { + if (ACPI_FAILURE(status)) { + ACPI_MEM_FREE(cid_list); + } else { *return_cid_list = cid_list; } /* On exit, we must delete the _CID return object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_execute_UID @@ -558,42 +527,39 @@ acpi_ut_execute_CID ( ******************************************************************************/ acpi_status -acpi_ut_execute_UID ( - struct acpi_namespace_node *device_node, - struct acpi_device_id *uid) +acpi_ut_execute_UID(struct acpi_namespace_node *device_node, + struct acpi_device_id *uid) { - union acpi_operand_object *obj_desc; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("ut_execute_UID"); + union acpi_operand_object *obj_desc; + acpi_status status; + ACPI_FUNCTION_TRACE("ut_execute_UID"); - status = acpi_ut_evaluate_object (device_node, METHOD_NAME__UID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &obj_desc); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, + &obj_desc); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { + if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { /* Convert the Numeric UID to string */ - acpi_ex_unsigned_integer_to_string (obj_desc->integer.value, uid->value); - } - else { + acpi_ex_unsigned_integer_to_string(obj_desc->integer.value, + uid->value); + } else { /* Copy the String UID from the returned object */ - acpi_ut_copy_id_string (uid->value, obj_desc->string.pointer, - sizeof (uid->value)); + acpi_ut_copy_id_string(uid->value, obj_desc->string.pointer, + sizeof(uid->value)); } /* On exit, we must delete the return object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_execute_STA @@ -611,30 +577,26 @@ acpi_ut_execute_UID ( ******************************************************************************/ acpi_status -acpi_ut_execute_STA ( - struct acpi_namespace_node *device_node, - u32 *flags) +acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags) { - union acpi_operand_object *obj_desc; - acpi_status status; - + union acpi_operand_object *obj_desc; + acpi_status status; - ACPI_FUNCTION_TRACE ("ut_execute_STA"); + ACPI_FUNCTION_TRACE("ut_execute_STA"); - - status = acpi_ut_evaluate_object (device_node, METHOD_NAME__STA, - ACPI_BTYPE_INTEGER, &obj_desc); - if (ACPI_FAILURE (status)) { + status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA, + ACPI_BTYPE_INTEGER, &obj_desc); + if (ACPI_FAILURE(status)) { if (AE_NOT_FOUND == status) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "_STA on %4.4s was not found, assuming device is present\n", - acpi_ut_get_node_name (device_node))); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "_STA on %4.4s was not found, assuming device is present\n", + acpi_ut_get_node_name(device_node))); *flags = 0x0F; status = AE_OK; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Extract the status flags */ @@ -643,11 +605,10 @@ acpi_ut_execute_STA ( /* On exit, we must delete the return object */ - acpi_ut_remove_reference (obj_desc); - return_ACPI_STATUS (status); + acpi_ut_remove_reference(obj_desc); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_execute_Sxds @@ -665,44 +626,45 @@ acpi_ut_execute_STA ( ******************************************************************************/ acpi_status -acpi_ut_execute_sxds ( - struct acpi_namespace_node *device_node, - u8 *highest) +acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest) { - union acpi_operand_object *obj_desc; - acpi_status status; - u32 i; - - - ACPI_FUNCTION_TRACE ("ut_execute_Sxds"); + union acpi_operand_object *obj_desc; + acpi_status status; + u32 i; + ACPI_FUNCTION_TRACE("ut_execute_Sxds"); for (i = 0; i < 4; i++) { highest[i] = 0xFF; - status = acpi_ut_evaluate_object (device_node, - (char *) acpi_gbl_highest_dstate_names[i], - ACPI_BTYPE_INTEGER, &obj_desc); - if (ACPI_FAILURE (status)) { + status = acpi_ut_evaluate_object(device_node, + (char *) + acpi_gbl_highest_dstate_names + [i], ACPI_BTYPE_INTEGER, + &obj_desc); + if (ACPI_FAILURE(status)) { if (status != AE_NOT_FOUND) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "%s on Device %4.4s, %s\n", - (char *) acpi_gbl_highest_dstate_names[i], - acpi_ut_get_node_name (device_node), - acpi_format_exception (status))); - - return_ACPI_STATUS (status); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "%s on Device %4.4s, %s\n", + (char *) + acpi_gbl_highest_dstate_names + [i], + acpi_ut_get_node_name + (device_node), + acpi_format_exception + (status))); + + return_ACPI_STATUS(status); } - } - else { + } else { /* Extract the Dstate value */ highest[i] = (u8) obj_desc->integer.value; /* Delete the return object */ - acpi_ut_remove_reference (obj_desc); + acpi_ut_remove_reference(obj_desc); } } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index 4146019b543..399e64b5188 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -48,8 +48,7 @@ #include <acpi/acnamesp.h> #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utglobal") - +ACPI_MODULE_NAME("utglobal") /******************************************************************************* * @@ -63,17 +62,12 @@ * DESCRIPTION: This function translates an ACPI exception into an ASCII string. * ******************************************************************************/ - -const char * -acpi_format_exception ( - acpi_status status) +const char *acpi_format_exception(acpi_status status) { - acpi_status sub_status; - const char *exception = NULL; - - - ACPI_FUNCTION_NAME ("format_exception"); + acpi_status sub_status; + const char *exception = NULL; + ACPI_FUNCTION_NAME("format_exception"); sub_status = (status & ~AE_CODE_MASK); @@ -81,35 +75,39 @@ acpi_format_exception ( case AE_CODE_ENVIRONMENTAL: if (sub_status <= AE_CODE_ENV_MAX) { - exception = acpi_gbl_exception_names_env [sub_status]; + exception = acpi_gbl_exception_names_env[sub_status]; } break; case AE_CODE_PROGRAMMER: if (sub_status <= AE_CODE_PGM_MAX) { - exception = acpi_gbl_exception_names_pgm [sub_status -1]; + exception = + acpi_gbl_exception_names_pgm[sub_status - 1]; } break; case AE_CODE_ACPI_TABLES: if (sub_status <= AE_CODE_TBL_MAX) { - exception = acpi_gbl_exception_names_tbl [sub_status -1]; + exception = + acpi_gbl_exception_names_tbl[sub_status - 1]; } break; case AE_CODE_AML: if (sub_status <= AE_CODE_AML_MAX) { - exception = acpi_gbl_exception_names_aml [sub_status -1]; + exception = + acpi_gbl_exception_names_aml[sub_status - 1]; } break; case AE_CODE_CONTROL: if (sub_status <= AE_CODE_CTRL_MAX) { - exception = acpi_gbl_exception_names_ctrl [sub_status -1]; + exception = + acpi_gbl_exception_names_ctrl[sub_status - 1]; } break; @@ -120,16 +118,15 @@ acpi_format_exception ( if (!exception) { /* Exception code was not recognized */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown exception code: 0x%8.8X\n", status)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown exception code: 0x%8.8X\n", status)); - return ((const char *) "UNKNOWN_STATUS_CODE"); + return ((const char *)"UNKNOWN_STATUS_CODE"); } - return ((const char *) exception); + return ((const char *)exception); } - /******************************************************************************* * * Static global variable initialization. @@ -142,34 +139,32 @@ acpi_format_exception ( */ /* Debug switch - level and trace mask */ -u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT; +u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT; EXPORT_SYMBOL(acpi_dbg_level); /* Debug switch - layer (component) mask */ -u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; +u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; EXPORT_SYMBOL(acpi_dbg_layer); -u32 acpi_gbl_nesting_level = 0; - +u32 acpi_gbl_nesting_level = 0; /* Debugger globals */ -u8 acpi_gbl_db_terminate_threads = FALSE; -u8 acpi_gbl_abort_method = FALSE; -u8 acpi_gbl_method_executing = FALSE; +u8 acpi_gbl_db_terminate_threads = FALSE; +u8 acpi_gbl_abort_method = FALSE; +u8 acpi_gbl_method_executing = FALSE; /* System flags */ -u32 acpi_gbl_startup_flags = 0; +u32 acpi_gbl_startup_flags = 0; /* System starts uninitialized */ -u8 acpi_gbl_shutdown = TRUE; +u8 acpi_gbl_shutdown = TRUE; -const u8 acpi_gbl_decode_to8bit [8] = {1,2,4,8,16,32,64,128}; +const u8 acpi_gbl_decode_to8bit[8] = { 1, 2, 4, 8, 16, 32, 64, 128 }; -const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = -{ +const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = { "\\_S0_", "\\_S1_", "\\_S2_", @@ -178,8 +173,7 @@ const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COU "\\_S5_" }; -const char *acpi_gbl_highest_dstate_names[4] = -{ +const char *acpi_gbl_highest_dstate_names[4] = { "_S1D", "_S2D", "_S3D", @@ -190,8 +184,7 @@ const char *acpi_gbl_highest_dstate_names[4] = * Strings supported by the _OSI predefined (internal) method. * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS. */ -const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = -{ +const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = { /* Operating System Vendor Strings */ "Linux", @@ -209,7 +202,6 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STR "Extended Address Space Descriptor" }; - /******************************************************************************* * * Namespace globals @@ -225,74 +217,70 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STR * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to * perform a Notify() operation on it. */ -const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = -{ {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, - {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, - {"_SB_", ACPI_TYPE_DEVICE, NULL}, - {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, - {"_TZ_", ACPI_TYPE_THERMAL, NULL}, - {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, - {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, - {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, +const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = + { {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, +{"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, +{"_SB_", ACPI_TYPE_DEVICE, NULL}, +{"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, +{"_TZ_", ACPI_TYPE_THERMAL, NULL}, +{"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL}, +{"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, +{"_GL_", ACPI_TYPE_MUTEX, (char *)1}, #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) - {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, +{"_OSI", ACPI_TYPE_METHOD, (char *)1}, #endif /* Table terminator */ - {NULL, ACPI_TYPE_ANY, NULL} +{NULL, ACPI_TYPE_ANY, NULL} }; /* * Properties of the ACPI Object Types, both internal and external. * The table is indexed by values of acpi_object_type */ -const u8 acpi_gbl_ns_properties[] = -{ - ACPI_NS_NORMAL, /* 00 Any */ - ACPI_NS_NORMAL, /* 01 Number */ - ACPI_NS_NORMAL, /* 02 String */ - ACPI_NS_NORMAL, /* 03 Buffer */ - ACPI_NS_NORMAL, /* 04 Package */ - ACPI_NS_NORMAL, /* 05 field_unit */ - ACPI_NS_NEWSCOPE, /* 06 Device */ - ACPI_NS_NORMAL, /* 07 Event */ - ACPI_NS_NEWSCOPE, /* 08 Method */ - ACPI_NS_NORMAL, /* 09 Mutex */ - ACPI_NS_NORMAL, /* 10 Region */ - ACPI_NS_NEWSCOPE, /* 11 Power */ - ACPI_NS_NEWSCOPE, /* 12 Processor */ - ACPI_NS_NEWSCOPE, /* 13 Thermal */ - ACPI_NS_NORMAL, /* 14 buffer_field */ - ACPI_NS_NORMAL, /* 15 ddb_handle */ - ACPI_NS_NORMAL, /* 16 Debug Object */ - ACPI_NS_NORMAL, /* 17 def_field */ - ACPI_NS_NORMAL, /* 18 bank_field */ - ACPI_NS_NORMAL, /* 19 index_field */ - ACPI_NS_NORMAL, /* 20 Reference */ - ACPI_NS_NORMAL, /* 21 Alias */ - ACPI_NS_NORMAL, /* 22 method_alias */ - ACPI_NS_NORMAL, /* 23 Notify */ - ACPI_NS_NORMAL, /* 24 Address Handler */ - ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ - ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ - ACPI_NS_NEWSCOPE, /* 27 Scope */ - ACPI_NS_NORMAL, /* 28 Extra */ - ACPI_NS_NORMAL, /* 29 Data */ - ACPI_NS_NORMAL /* 30 Invalid */ +const u8 acpi_gbl_ns_properties[] = { + ACPI_NS_NORMAL, /* 00 Any */ + ACPI_NS_NORMAL, /* 01 Number */ + ACPI_NS_NORMAL, /* 02 String */ + ACPI_NS_NORMAL, /* 03 Buffer */ + ACPI_NS_NORMAL, /* 04 Package */ + ACPI_NS_NORMAL, /* 05 field_unit */ + ACPI_NS_NEWSCOPE, /* 06 Device */ + ACPI_NS_NORMAL, /* 07 Event */ + ACPI_NS_NEWSCOPE, /* 08 Method */ + ACPI_NS_NORMAL, /* 09 Mutex */ + ACPI_NS_NORMAL, /* 10 Region */ + ACPI_NS_NEWSCOPE, /* 11 Power */ + ACPI_NS_NEWSCOPE, /* 12 Processor */ + ACPI_NS_NEWSCOPE, /* 13 Thermal */ + ACPI_NS_NORMAL, /* 14 buffer_field */ + ACPI_NS_NORMAL, /* 15 ddb_handle */ + ACPI_NS_NORMAL, /* 16 Debug Object */ + ACPI_NS_NORMAL, /* 17 def_field */ + ACPI_NS_NORMAL, /* 18 bank_field */ + ACPI_NS_NORMAL, /* 19 index_field */ + ACPI_NS_NORMAL, /* 20 Reference */ + ACPI_NS_NORMAL, /* 21 Alias */ + ACPI_NS_NORMAL, /* 22 method_alias */ + ACPI_NS_NORMAL, /* 23 Notify */ + ACPI_NS_NORMAL, /* 24 Address Handler */ + ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ + ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ + ACPI_NS_NEWSCOPE, /* 27 Scope */ + ACPI_NS_NORMAL, /* 28 Extra */ + ACPI_NS_NORMAL, /* 29 Data */ + ACPI_NS_NORMAL /* 30 Invalid */ }; - /* Hex to ASCII conversion table */ -static const char acpi_gbl_hex_to_ascii[] = -{ - '0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F' +static const char acpi_gbl_hex_to_ascii[] = { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - /******************************************************************************* * * FUNCTION: acpi_ut_hex_to_ascii_char @@ -307,16 +295,12 @@ static const char acpi_gbl_hex_to_ascii[] = * ******************************************************************************/ -char -acpi_ut_hex_to_ascii_char ( - acpi_integer integer, - u32 position) +char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position) { return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]); } - /******************************************************************************* * * Table name globals @@ -330,67 +314,139 @@ acpi_ut_hex_to_ascii_char ( * ******************************************************************************/ -struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES]; +struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES]; -struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] = -{ +struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] = { /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */ - /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, - /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *) &acpi_gbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE | ACPI_TABLE_EXECUTABLE}, - /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *) &acpi_gbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE}, - /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *) &acpi_gbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE}, - /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, - /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, - /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, + /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof(RSDP_SIG) - 1, + ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE} + , + /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *)&acpi_gbl_DSDT, + sizeof(DSDT_SIG) - 1, + ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE | + ACPI_TABLE_EXECUTABLE} + , + /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *)&acpi_gbl_FADT, + sizeof(FADT_SIG) - 1, + ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE} + , + /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *)&acpi_gbl_FACS, + sizeof(FACS_SIG) - 1, + ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE} + , + /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof(PSDT_SIG) - 1, + ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | + ACPI_TABLE_EXECUTABLE} + , + /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof(SSDT_SIG) - 1, + ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | + ACPI_TABLE_EXECUTABLE} + , + /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof(RSDT_SIG) - 1, + ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE} + , }; - /****************************************************************************** * * Event and Hardware globals * ******************************************************************************/ -struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = -{ +struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = { /* Name Parent Register Register Bit Position Register Bit Mask */ - /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, - /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, - /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, - /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, - /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, - /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, - /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, - /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, - - /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, - /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, - /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, - /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, - /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, - /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, - /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, - - /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, - /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, - /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, - /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, - /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, - /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, - - /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} + /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_TIMER_STATUS, + ACPI_BITMASK_TIMER_STATUS}, + /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_BUS_MASTER_STATUS, + ACPI_BITMASK_BUS_MASTER_STATUS}, + /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, + ACPI_BITMASK_GLOBAL_LOCK_STATUS}, + /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_POWER_BUTTON_STATUS, + ACPI_BITMASK_POWER_BUTTON_STATUS}, + /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, + ACPI_BITMASK_SLEEP_BUTTON_STATUS}, + /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_RT_CLOCK_STATUS, + ACPI_BITMASK_RT_CLOCK_STATUS}, + /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_WAKE_STATUS, + ACPI_BITMASK_WAKE_STATUS}, + /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, + ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, + ACPI_BITMASK_PCIEXP_WAKE_STATUS}, + + /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, + ACPI_BITPOSITION_TIMER_ENABLE, + ACPI_BITMASK_TIMER_ENABLE}, + /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, + ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, + ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, + /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, + ACPI_BITPOSITION_POWER_BUTTON_ENABLE, + ACPI_BITMASK_POWER_BUTTON_ENABLE}, + /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, + ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, + ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, + /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, + ACPI_BITPOSITION_RT_CLOCK_ENABLE, + ACPI_BITMASK_RT_CLOCK_ENABLE}, + /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, + /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, + ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, + ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, + + /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, + ACPI_BITPOSITION_SCI_ENABLE, + ACPI_BITMASK_SCI_ENABLE}, + /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, + ACPI_BITPOSITION_BUS_MASTER_RLD, + ACPI_BITMASK_BUS_MASTER_RLD}, + /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, + ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, + ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, + /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, + ACPI_BITPOSITION_SLEEP_TYPE_X, + ACPI_BITMASK_SLEEP_TYPE_X}, + /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, + ACPI_BITPOSITION_SLEEP_TYPE_X, + ACPI_BITMASK_SLEEP_TYPE_X}, + /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, + ACPI_BITPOSITION_SLEEP_ENABLE, + ACPI_BITMASK_SLEEP_ENABLE}, + + /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, + ACPI_BITPOSITION_ARB_DISABLE, + ACPI_BITMASK_ARB_DISABLE} }; - -struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = -{ - /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, - /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, - /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, - /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, - /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, +struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = { + /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, + ACPI_BITREG_TIMER_ENABLE, + ACPI_BITMASK_TIMER_STATUS, + ACPI_BITMASK_TIMER_ENABLE}, + /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, + ACPI_BITREG_GLOBAL_LOCK_ENABLE, + ACPI_BITMASK_GLOBAL_LOCK_STATUS, + ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, + /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, + ACPI_BITREG_POWER_BUTTON_ENABLE, + ACPI_BITMASK_POWER_BUTTON_STATUS, + ACPI_BITMASK_POWER_BUTTON_ENABLE}, + /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, + ACPI_BITREG_SLEEP_BUTTON_ENABLE, + ACPI_BITMASK_SLEEP_BUTTON_STATUS, + ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, + /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, + ACPI_BITREG_RT_CLOCK_ENABLE, + ACPI_BITMASK_RT_CLOCK_STATUS, + ACPI_BITMASK_RT_CLOCK_ENABLE}, }; /******************************************************************************* @@ -407,8 +463,7 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVE /* Region type decoding */ -const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = -{ +const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = { /*! [Begin] no source code translation (keep these ASL Keywords as-is) */ "SystemMemory", "SystemIO", @@ -421,25 +476,18 @@ const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = /*! [End] no source code translation !*/ }; - -char * -acpi_ut_get_region_name ( - u8 space_id) +char *acpi_ut_get_region_name(u8 space_id) { - if (space_id >= ACPI_USER_REGION_BEGIN) - { + if (space_id >= ACPI_USER_REGION_BEGIN) { return ("user_defined_region"); - } - else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) - { + } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) { return ("invalid_space_id"); } - return ((char *) acpi_gbl_region_types[space_id]); + return ((char *)acpi_gbl_region_types[space_id]); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_event_name @@ -454,8 +502,7 @@ acpi_ut_get_region_name ( /* Event type decoding */ -static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = -{ +static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = { "PM_Timer", "global_lock", "power_button", @@ -463,21 +510,16 @@ static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = "real_time_clock", }; - -char * -acpi_ut_get_event_name ( - u32 event_id) +char *acpi_ut_get_event_name(u32 event_id) { - if (event_id > ACPI_EVENT_MAX) - { + if (event_id > ACPI_EVENT_MAX) { return ("invalid_event_iD"); } - return ((char *) acpi_gbl_event_types[event_id]); + return ((char *)acpi_gbl_event_types[event_id]); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_type_name @@ -498,12 +540,11 @@ acpi_ut_get_event_name ( * when stored in a table it really means that we have thus far seen no * evidence to indicate what type is actually going to be stored for this entry. */ -static const char acpi_gbl_bad_type[] = "UNDEFINED"; +static const char acpi_gbl_bad_type[] = "UNDEFINED"; /* Printable names of the ACPI object types */ -static const char *acpi_gbl_ns_type_names[] = -{ +static const char *acpi_gbl_ns_type_names[] = { /* 00 */ "Untyped", /* 01 */ "Integer", /* 02 */ "String", @@ -537,35 +578,26 @@ static const char *acpi_gbl_ns_type_names[] = /* 30 */ "Invalid" }; - -char * -acpi_ut_get_type_name ( - acpi_object_type type) +char *acpi_ut_get_type_name(acpi_object_type type) { - if (type > ACPI_TYPE_INVALID) - { - return ((char *) acpi_gbl_bad_type); + if (type > ACPI_TYPE_INVALID) { + return ((char *)acpi_gbl_bad_type); } - return ((char *) acpi_gbl_ns_type_names[type]); + return ((char *)acpi_gbl_ns_type_names[type]); } - -char * -acpi_ut_get_object_type_name ( - union acpi_operand_object *obj_desc) +char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc) { - if (!obj_desc) - { + if (!obj_desc) { return ("[NULL Object Descriptor]"); } - return (acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc))); + return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc))); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_node_name @@ -578,39 +610,31 @@ acpi_ut_get_object_type_name ( * ******************************************************************************/ -char * -acpi_ut_get_node_name ( - void *object) +char *acpi_ut_get_node_name(void *object) { - struct acpi_namespace_node *node = (struct acpi_namespace_node *) object; - + struct acpi_namespace_node *node = (struct acpi_namespace_node *)object; /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ - if (!object) - { + if (!object) { return ("NULL"); } /* Check for Root node */ - if ((object == ACPI_ROOT_OBJECT) || - (object == acpi_gbl_root_node)) - { + if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) { return ("\"\\\" "); } /* Descriptor must be a namespace node */ - if (node->descriptor != ACPI_DESC_TYPE_NAMED) - { + if (node->descriptor != ACPI_DESC_TYPE_NAMED) { return ("####"); } /* Name must be a valid ACPI name */ - if (!acpi_ut_valid_acpi_name (* (u32 *) node->name.ascii)) - { + if (!acpi_ut_valid_acpi_name(*(u32 *) node->name.ascii)) { return ("????"); } @@ -619,7 +643,6 @@ acpi_ut_get_node_name ( return (node->name.ascii); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_descriptor_name @@ -634,8 +657,7 @@ acpi_ut_get_node_name ( /* Printable names of object descriptor types */ -static const char *acpi_gbl_desc_type_names[] = -{ +static const char *acpi_gbl_desc_type_names[] = { /* 00 */ "Invalid", /* 01 */ "Cached", /* 02 */ "State-Generic", @@ -654,27 +676,22 @@ static const char *acpi_gbl_desc_type_names[] = /* 15 */ "Node" }; - -char * -acpi_ut_get_descriptor_name ( - void *object) +char *acpi_ut_get_descriptor_name(void *object) { - if (!object) - { + if (!object) { return ("NULL OBJECT"); } - if (ACPI_GET_DESCRIPTOR_TYPE (object) > ACPI_DESC_TYPE_MAX) - { - return ((char *) acpi_gbl_bad_type); + if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) { + return ((char *)acpi_gbl_bad_type); } - return ((char *) acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE (object)]); + return ((char *) + acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE(object)]); } - #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /* * Strings and procedures used for debug only @@ -693,13 +710,10 @@ acpi_ut_get_descriptor_name ( * ******************************************************************************/ -char * -acpi_ut_get_mutex_name ( - u32 mutex_id) +char *acpi_ut_get_mutex_name(u32 mutex_id) { - if (mutex_id > MAX_MUTEX) - { + if (mutex_id > MAX_MUTEX) { return ("Invalid Mutex ID"); } @@ -707,7 +721,6 @@ acpi_ut_get_mutex_name ( } #endif - /******************************************************************************* * * FUNCTION: acpi_ut_valid_object_type @@ -720,13 +733,10 @@ acpi_ut_get_mutex_name ( * ******************************************************************************/ -u8 -acpi_ut_valid_object_type ( - acpi_object_type type) +u8 acpi_ut_valid_object_type(acpi_object_type type) { - if (type > ACPI_TYPE_LOCAL_MAX) - { + if (type > ACPI_TYPE_LOCAL_MAX) { /* Note: Assumes all TYPEs are contiguous (external/local) */ return (FALSE); @@ -735,74 +745,6 @@ acpi_ut_valid_object_type ( return (TRUE); } - -/******************************************************************************* - * - * FUNCTION: acpi_ut_allocate_owner_id - * - * PARAMETERS: id_type - Type of ID (method or table) - * - * DESCRIPTION: Allocate a table or method owner id - * - * NOTE: this algorithm has a wraparound problem at 64_k method invocations, and - * should be revisited (TBD) - * - ******************************************************************************/ - -acpi_owner_id -acpi_ut_allocate_owner_id ( - u32 id_type) -{ - acpi_owner_id owner_id = 0xFFFF; - - - ACPI_FUNCTION_TRACE ("ut_allocate_owner_id"); - - - if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) - { - return (0); - } - - switch (id_type) - { - case ACPI_OWNER_TYPE_TABLE: - - owner_id = acpi_gbl_next_table_owner_id; - acpi_gbl_next_table_owner_id++; - - /* Check for wraparound */ - - if (acpi_gbl_next_table_owner_id == ACPI_FIRST_METHOD_ID) - { - acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID; - ACPI_REPORT_WARNING (("Table owner ID wraparound\n")); - } - break; - - - case ACPI_OWNER_TYPE_METHOD: - - owner_id = acpi_gbl_next_method_owner_id; - acpi_gbl_next_method_owner_id++; - - if (acpi_gbl_next_method_owner_id == ACPI_FIRST_TABLE_ID) - { - /* Check for wraparound */ - - acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID; - } - break; - - default: - break; - } - - (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); - return_VALUE (owner_id); -} - - /******************************************************************************* * * FUNCTION: acpi_ut_init_globals @@ -816,129 +758,96 @@ acpi_ut_allocate_owner_id ( * ******************************************************************************/ -void -acpi_ut_init_globals ( - void) +void acpi_ut_init_globals(void) { - u32 i; + acpi_status status; + u32 i; + ACPI_FUNCTION_TRACE("ut_init_globals"); - ACPI_FUNCTION_TRACE ("ut_init_globals"); + /* Create all memory caches */ - - /* 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"); + status = acpi_ut_create_caches(); + if (ACPI_FAILURE(status)) { + return; + } /* ACPI table structure */ - for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) - { - acpi_gbl_table_lists[i].next = NULL; - acpi_gbl_table_lists[i].count = 0; + for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) { + acpi_gbl_table_lists[i].next = NULL; + acpi_gbl_table_lists[i].count = 0; } /* Mutex locked flags */ - for (i = 0; i < NUM_MUTEX; i++) - { - acpi_gbl_mutex_info[i].mutex = NULL; - acpi_gbl_mutex_info[i].owner_id = ACPI_MUTEX_NOT_ACQUIRED; - acpi_gbl_mutex_info[i].use_count = 0; + for (i = 0; i < NUM_MUTEX; i++) { + acpi_gbl_mutex_info[i].mutex = NULL; + acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED; + acpi_gbl_mutex_info[i].use_count = 0; } /* GPE support */ - acpi_gbl_gpe_xrupt_list_head = NULL; - acpi_gbl_gpe_fadt_blocks[0] = NULL; - acpi_gbl_gpe_fadt_blocks[1] = NULL; + acpi_gbl_gpe_xrupt_list_head = NULL; + acpi_gbl_gpe_fadt_blocks[0] = NULL; + acpi_gbl_gpe_fadt_blocks[1] = NULL; /* Global notify handlers */ - acpi_gbl_system_notify.handler = NULL; - acpi_gbl_device_notify.handler = NULL; - acpi_gbl_exception_handler = NULL; - acpi_gbl_init_handler = NULL; + acpi_gbl_system_notify.handler = NULL; + acpi_gbl_device_notify.handler = NULL; + acpi_gbl_exception_handler = NULL; + acpi_gbl_init_handler = NULL; /* Global "typed" ACPI table pointers */ - acpi_gbl_RSDP = NULL; - acpi_gbl_XSDT = NULL; - acpi_gbl_FACS = NULL; - acpi_gbl_FADT = NULL; - acpi_gbl_DSDT = NULL; + acpi_gbl_RSDP = NULL; + acpi_gbl_XSDT = NULL; + acpi_gbl_FACS = NULL; + acpi_gbl_FADT = NULL; + acpi_gbl_DSDT = NULL; /* Global Lock support */ - acpi_gbl_global_lock_acquired = FALSE; - acpi_gbl_global_lock_thread_count = 0; - acpi_gbl_global_lock_handle = 0; + acpi_gbl_global_lock_acquired = FALSE; + acpi_gbl_global_lock_thread_count = 0; + acpi_gbl_global_lock_handle = 0; /* Miscellaneous variables */ - acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER; - acpi_gbl_rsdp_original_location = 0; - acpi_gbl_cm_single_step = FALSE; - acpi_gbl_db_terminate_threads = FALSE; - acpi_gbl_shutdown = FALSE; - acpi_gbl_ns_lookup_count = 0; - acpi_gbl_ps_find_count = 0; - acpi_gbl_acpi_hardware_present = TRUE; - acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID; - acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID; - acpi_gbl_debugger_configuration = DEBUGGER_THREADING; - acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; + acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER; + acpi_gbl_rsdp_original_location = 0; + acpi_gbl_cm_single_step = FALSE; + acpi_gbl_db_terminate_threads = FALSE; + acpi_gbl_shutdown = FALSE; + acpi_gbl_ns_lookup_count = 0; + acpi_gbl_ps_find_count = 0; + acpi_gbl_acpi_hardware_present = TRUE; + acpi_gbl_owner_id_mask = 0; + acpi_gbl_debugger_configuration = DEBUGGER_THREADING; + acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; /* Hardware oriented */ - acpi_gbl_events_initialized = FALSE; - acpi_gbl_system_awake_and_running = TRUE; + acpi_gbl_events_initialized = FALSE; + acpi_gbl_system_awake_and_running = TRUE; /* Namespace */ - acpi_gbl_root_node = NULL; + acpi_gbl_root_node = NULL; acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED; - acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; - acpi_gbl_root_node_struct.child = NULL; - acpi_gbl_root_node_struct.peer = NULL; - acpi_gbl_root_node_struct.object = NULL; - acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST; - + acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; + acpi_gbl_root_node_struct.child = NULL; + acpi_gbl_root_node_struct.peer = NULL; + acpi_gbl_root_node_struct.object = NULL; + acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST; #ifdef ACPI_DEBUG_OUTPUT - acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX; + acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX; #endif return_VOID; } - - diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c index 7f3713889ff..9dde82b0bea 100644 --- a/drivers/acpi/utilities/utinit.c +++ b/drivers/acpi/utilities/utinit.c @@ -41,25 +41,18 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <acpi/acpi.h> #include <acpi/acnamesp.h> #include <acpi/acevents.h> #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utinit") +ACPI_MODULE_NAME("utinit") /* Local prototypes */ - static void -acpi_ut_fadt_register_error ( - char *register_name, - u32 value, - acpi_size offset); - -static void acpi_ut_terminate ( - void); +acpi_ut_fadt_register_error(char *register_name, u32 value, acpi_size offset); +static void acpi_ut_terminate(void); /******************************************************************************* * @@ -76,18 +69,14 @@ static void acpi_ut_terminate ( ******************************************************************************/ static void -acpi_ut_fadt_register_error ( - char *register_name, - u32 value, - acpi_size offset) +acpi_ut_fadt_register_error(char *register_name, u32 value, acpi_size offset) { - ACPI_REPORT_WARNING ( - ("Invalid FADT value %s=%X at offset %X FADT=%p\n", - register_name, value, (u32) offset, acpi_gbl_FADT)); + ACPI_REPORT_WARNING(("Invalid FADT value %s=%X at offset %X FADT=%p\n", + register_name, value, (u32) offset, + acpi_gbl_FADT)); } - /****************************************************************************** * * FUNCTION: acpi_ut_validate_fadt @@ -100,9 +89,7 @@ acpi_ut_fadt_register_error ( * ******************************************************************************/ -acpi_status -acpi_ut_validate_fadt ( - void) +acpi_status acpi_ut_validate_fadt(void) { /* @@ -110,64 +97,66 @@ acpi_ut_validate_fadt ( * but don't abort on any problems, just display error */ if (acpi_gbl_FADT->pm1_evt_len < 4) { - acpi_ut_fadt_register_error ("PM1_EVT_LEN", - (u32) acpi_gbl_FADT->pm1_evt_len, - ACPI_FADT_OFFSET (pm1_evt_len)); + acpi_ut_fadt_register_error("PM1_EVT_LEN", + (u32) acpi_gbl_FADT->pm1_evt_len, + ACPI_FADT_OFFSET(pm1_evt_len)); } if (!acpi_gbl_FADT->pm1_cnt_len) { - acpi_ut_fadt_register_error ("PM1_CNT_LEN", 0, - ACPI_FADT_OFFSET (pm1_cnt_len)); + acpi_ut_fadt_register_error("PM1_CNT_LEN", 0, + ACPI_FADT_OFFSET(pm1_cnt_len)); } if (!acpi_gbl_FADT->xpm1a_evt_blk.address) { - acpi_ut_fadt_register_error ("X_PM1a_EVT_BLK", 0, - ACPI_FADT_OFFSET (xpm1a_evt_blk.address)); + acpi_ut_fadt_register_error("X_PM1a_EVT_BLK", 0, + ACPI_FADT_OFFSET(xpm1a_evt_blk. + address)); } if (!acpi_gbl_FADT->xpm1a_cnt_blk.address) { - acpi_ut_fadt_register_error ("X_PM1a_CNT_BLK", 0, - ACPI_FADT_OFFSET (xpm1a_cnt_blk.address)); + acpi_ut_fadt_register_error("X_PM1a_CNT_BLK", 0, + ACPI_FADT_OFFSET(xpm1a_cnt_blk. + address)); } if (!acpi_gbl_FADT->xpm_tmr_blk.address) { - acpi_ut_fadt_register_error ("X_PM_TMR_BLK", 0, - ACPI_FADT_OFFSET (xpm_tmr_blk.address)); + acpi_ut_fadt_register_error("X_PM_TMR_BLK", 0, + ACPI_FADT_OFFSET(xpm_tmr_blk. + address)); } if ((acpi_gbl_FADT->xpm2_cnt_blk.address && - !acpi_gbl_FADT->pm2_cnt_len)) { - acpi_ut_fadt_register_error ("PM2_CNT_LEN", - (u32) acpi_gbl_FADT->pm2_cnt_len, - ACPI_FADT_OFFSET (pm2_cnt_len)); + !acpi_gbl_FADT->pm2_cnt_len)) { + acpi_ut_fadt_register_error("PM2_CNT_LEN", + (u32) acpi_gbl_FADT->pm2_cnt_len, + ACPI_FADT_OFFSET(pm2_cnt_len)); } if (acpi_gbl_FADT->pm_tm_len < 4) { - acpi_ut_fadt_register_error ("PM_TM_LEN", - (u32) acpi_gbl_FADT->pm_tm_len, - ACPI_FADT_OFFSET (pm_tm_len)); + acpi_ut_fadt_register_error("PM_TM_LEN", + (u32) acpi_gbl_FADT->pm_tm_len, + ACPI_FADT_OFFSET(pm_tm_len)); } /* Length of GPE blocks must be a multiple of 2 */ if (acpi_gbl_FADT->xgpe0_blk.address && - (acpi_gbl_FADT->gpe0_blk_len & 1)) { - acpi_ut_fadt_register_error ("(x)GPE0_BLK_LEN", - (u32) acpi_gbl_FADT->gpe0_blk_len, - ACPI_FADT_OFFSET (gpe0_blk_len)); + (acpi_gbl_FADT->gpe0_blk_len & 1)) { + acpi_ut_fadt_register_error("(x)GPE0_BLK_LEN", + (u32) acpi_gbl_FADT->gpe0_blk_len, + ACPI_FADT_OFFSET(gpe0_blk_len)); } if (acpi_gbl_FADT->xgpe1_blk.address && - (acpi_gbl_FADT->gpe1_blk_len & 1)) { - acpi_ut_fadt_register_error ("(x)GPE1_BLK_LEN", - (u32) acpi_gbl_FADT->gpe1_blk_len, - ACPI_FADT_OFFSET (gpe1_blk_len)); + (acpi_gbl_FADT->gpe1_blk_len & 1)) { + acpi_ut_fadt_register_error("(x)GPE1_BLK_LEN", + (u32) acpi_gbl_FADT->gpe1_blk_len, + ACPI_FADT_OFFSET(gpe1_blk_len)); } return (AE_OK); } - /****************************************************************************** * * FUNCTION: acpi_ut_terminate @@ -180,18 +169,14 @@ acpi_ut_validate_fadt ( * ******************************************************************************/ -static void -acpi_ut_terminate ( - void) +static void acpi_ut_terminate(void) { - struct acpi_gpe_block_info *gpe_block; - struct acpi_gpe_block_info *next_gpe_block; - struct acpi_gpe_xrupt_info *gpe_xrupt_info; - struct acpi_gpe_xrupt_info *next_gpe_xrupt_info; - - - ACPI_FUNCTION_TRACE ("ut_terminate"); + struct acpi_gpe_block_info *gpe_block; + struct acpi_gpe_block_info *next_gpe_block; + struct acpi_gpe_xrupt_info *gpe_xrupt_info; + struct acpi_gpe_xrupt_info *next_gpe_xrupt_info; + ACPI_FUNCTION_TRACE("ut_terminate"); /* Free global tables, etc. */ /* Free global GPE blocks and related info structures */ @@ -201,21 +186,20 @@ acpi_ut_terminate ( gpe_block = gpe_xrupt_info->gpe_block_list_head; while (gpe_block) { next_gpe_block = gpe_block->next; - ACPI_MEM_FREE (gpe_block->event_info); - ACPI_MEM_FREE (gpe_block->register_info); - ACPI_MEM_FREE (gpe_block); + ACPI_MEM_FREE(gpe_block->event_info); + ACPI_MEM_FREE(gpe_block->register_info); + ACPI_MEM_FREE(gpe_block); gpe_block = next_gpe_block; } next_gpe_xrupt_info = gpe_xrupt_info->next; - ACPI_MEM_FREE (gpe_xrupt_info); + ACPI_MEM_FREE(gpe_xrupt_info); gpe_xrupt_info = next_gpe_xrupt_info; } return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_ut_subsystem_shutdown @@ -229,50 +213,45 @@ acpi_ut_terminate ( * ******************************************************************************/ -void -acpi_ut_subsystem_shutdown ( - void) +void acpi_ut_subsystem_shutdown(void) { - ACPI_FUNCTION_TRACE ("ut_subsystem_shutdown"); + ACPI_FUNCTION_TRACE("ut_subsystem_shutdown"); /* Just exit if subsystem is already shutdown */ if (acpi_gbl_shutdown) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "ACPI Subsystem is already terminated\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "ACPI Subsystem is already terminated\n")); return_VOID; } /* Subsystem appears active, go ahead and shut it down */ acpi_gbl_shutdown = TRUE; - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Shutting down ACPI Subsystem...\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n")); /* Close the acpi_event Handling */ - acpi_ev_terminate (); + acpi_ev_terminate(); /* Close the Namespace */ - acpi_ns_terminate (); + acpi_ns_terminate(); /* Close the globals */ - acpi_ut_terminate (); + acpi_ut_terminate(); /* Purge the local caches */ - (void) acpi_purge_cached_objects (); + (void)acpi_ut_delete_caches(); /* Debug only - display leftover memory allocation, if any */ #ifdef ACPI_DBG_TRACK_ALLOCATIONS - acpi_ut_dump_allocations (ACPI_UINT32_MAX, NULL); + acpi_ut_dump_allocations(ACPI_UINT32_MAX, NULL); #endif return_VOID; } - - diff --git a/drivers/acpi/utilities/utmath.c b/drivers/acpi/utilities/utmath.c index 0d527c91543..68a0a6f9412 100644 --- a/drivers/acpi/utilities/utmath.c +++ b/drivers/acpi/utilities/utmath.c @@ -41,19 +41,16 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <acpi/acpi.h> - #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utmath") +ACPI_MODULE_NAME("utmath") /* * Support for double-precision integer divide. This code is included here * in order to support kernel environments where the double-precision math * library is not available. */ - #ifndef ACPI_USE_NATIVE_DIVIDE /******************************************************************************* * @@ -71,27 +68,22 @@ * 32-bit remainder. * ******************************************************************************/ - acpi_status -acpi_ut_short_divide ( - acpi_integer dividend, - u32 divisor, - acpi_integer *out_quotient, - u32 *out_remainder) +acpi_ut_short_divide(acpi_integer dividend, + u32 divisor, + acpi_integer * out_quotient, u32 * out_remainder) { - union uint64_overlay dividend_ovl; - union uint64_overlay quotient; - u32 remainder32; - - - ACPI_FUNCTION_TRACE ("ut_short_divide"); + union uint64_overlay dividend_ovl; + union uint64_overlay quotient; + u32 remainder32; + ACPI_FUNCTION_TRACE("ut_short_divide"); /* Always check for a zero divisor */ if (divisor == 0) { - ACPI_REPORT_ERROR (("acpi_ut_short_divide: Divide by zero\n")); - return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n")); + return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } dividend_ovl.full = dividend; @@ -100,9 +92,9 @@ acpi_ut_short_divide ( * The quotient is 64 bits, the remainder is always 32 bits, * and is generated by the second divide. */ - ACPI_DIV_64_BY_32 (0, dividend_ovl.part.hi, divisor, + ACPI_DIV_64_BY_32(0, dividend_ovl.part.hi, divisor, quotient.part.hi, remainder32); - ACPI_DIV_64_BY_32 (remainder32, dividend_ovl.part.lo, divisor, + ACPI_DIV_64_BY_32(remainder32, dividend_ovl.part.lo, divisor, quotient.part.lo, remainder32); /* Return only what was requested */ @@ -114,10 +106,9 @@ acpi_ut_short_divide ( *out_remainder = remainder32; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - /******************************************************************************* * * FUNCTION: acpi_ut_divide @@ -134,34 +125,30 @@ acpi_ut_short_divide ( ******************************************************************************/ acpi_status -acpi_ut_divide ( - acpi_integer in_dividend, - acpi_integer in_divisor, - acpi_integer *out_quotient, - acpi_integer *out_remainder) +acpi_ut_divide(acpi_integer in_dividend, + acpi_integer in_divisor, + acpi_integer * out_quotient, acpi_integer * out_remainder) { - union uint64_overlay dividend; - union uint64_overlay divisor; - union uint64_overlay quotient; - union uint64_overlay remainder; - union uint64_overlay normalized_dividend; - union uint64_overlay normalized_divisor; - u32 partial1; - union uint64_overlay partial2; - union uint64_overlay partial3; - - - ACPI_FUNCTION_TRACE ("ut_divide"); - + union uint64_overlay dividend; + union uint64_overlay divisor; + union uint64_overlay quotient; + union uint64_overlay remainder; + union uint64_overlay normalized_dividend; + union uint64_overlay normalized_divisor; + u32 partial1; + union uint64_overlay partial2; + union uint64_overlay partial3; + + ACPI_FUNCTION_TRACE("ut_divide"); /* Always check for a zero divisor */ if (in_divisor == 0) { - ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n")); - return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n")); + return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } - divisor.full = in_divisor; + divisor.full = in_divisor; dividend.full = in_dividend; if (divisor.part.hi == 0) { /* @@ -174,9 +161,9 @@ acpi_ut_divide ( * The quotient is 64 bits, the remainder is always 32 bits, * and is generated by the second divide. */ - ACPI_DIV_64_BY_32 (0, dividend.part.hi, divisor.part.lo, + ACPI_DIV_64_BY_32(0, dividend.part.hi, divisor.part.lo, quotient.part.hi, partial1); - ACPI_DIV_64_BY_32 (partial1, dividend.part.lo, divisor.part.lo, + ACPI_DIV_64_BY_32(partial1, dividend.part.lo, divisor.part.lo, quotient.part.lo, remainder.part.lo); } @@ -185,23 +172,23 @@ acpi_ut_divide ( * 2) The general case where the divisor is a full 64 bits * is more difficult */ - quotient.part.hi = 0; + quotient.part.hi = 0; normalized_dividend = dividend; normalized_divisor = divisor; /* Normalize the operands (shift until the divisor is < 32 bits) */ do { - ACPI_SHIFT_RIGHT_64 (normalized_divisor.part.hi, - normalized_divisor.part.lo); - ACPI_SHIFT_RIGHT_64 (normalized_dividend.part.hi, - normalized_dividend.part.lo); + ACPI_SHIFT_RIGHT_64(normalized_divisor.part.hi, + normalized_divisor.part.lo); + ACPI_SHIFT_RIGHT_64(normalized_dividend.part.hi, + normalized_dividend.part.lo); } while (normalized_divisor.part.hi != 0); /* Partial divide */ - ACPI_DIV_64_BY_32 (normalized_dividend.part.hi, + ACPI_DIV_64_BY_32(normalized_dividend.part.hi, normalized_dividend.part.lo, normalized_divisor.part.lo, quotient.part.lo, partial1); @@ -210,8 +197,9 @@ acpi_ut_divide ( * The quotient is always 32 bits, and simply requires adjustment. * The 64-bit remainder must be generated. */ - partial1 = quotient.part.lo * divisor.part.hi; - partial2.full = (acpi_integer) quotient.part.lo * divisor.part.lo; + partial1 = quotient.part.lo * divisor.part.hi; + partial2.full = + (acpi_integer) quotient.part.lo * divisor.part.lo; partial3.full = (acpi_integer) partial2.part.hi + partial1; remainder.part.hi = partial3.part.lo; @@ -224,16 +212,15 @@ acpi_ut_divide ( quotient.part.lo--; remainder.full -= divisor.full; } - } - else { + } else { quotient.part.lo--; remainder.full -= divisor.full; } } - remainder.full = remainder.full - dividend.full; - remainder.part.hi = (u32) -((s32) remainder.part.hi); - remainder.part.lo = (u32) -((s32) remainder.part.lo); + remainder.full = remainder.full - dividend.full; + remainder.part.hi = (u32) - ((s32) remainder.part.hi); + remainder.part.lo = (u32) - ((s32) remainder.part.lo); if (remainder.part.lo) { remainder.part.hi--; @@ -250,11 +237,10 @@ acpi_ut_divide ( *out_remainder = remainder.full; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } #else - /******************************************************************************* * * FUNCTION: acpi_ut_short_divide, acpi_ut_divide @@ -269,23 +255,19 @@ acpi_ut_divide ( * perform the divide. * ******************************************************************************/ - acpi_status -acpi_ut_short_divide ( - acpi_integer in_dividend, - u32 divisor, - acpi_integer *out_quotient, - u32 *out_remainder) +acpi_ut_short_divide(acpi_integer in_dividend, + u32 divisor, + acpi_integer * out_quotient, u32 * out_remainder) { - ACPI_FUNCTION_TRACE ("ut_short_divide"); - + ACPI_FUNCTION_TRACE("ut_short_divide"); /* Always check for a zero divisor */ if (divisor == 0) { - ACPI_REPORT_ERROR (("acpi_ut_short_divide: Divide by zero\n")); - return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n")); + return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } /* Return only what was requested */ @@ -297,27 +279,23 @@ acpi_ut_short_divide ( *out_remainder = (u32) in_dividend % divisor; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } acpi_status -acpi_ut_divide ( - acpi_integer in_dividend, - acpi_integer in_divisor, - acpi_integer *out_quotient, - acpi_integer *out_remainder) +acpi_ut_divide(acpi_integer in_dividend, + acpi_integer in_divisor, + acpi_integer * out_quotient, acpi_integer * out_remainder) { - ACPI_FUNCTION_TRACE ("ut_divide"); - + ACPI_FUNCTION_TRACE("ut_divide"); /* Always check for a zero divisor */ if (in_divisor == 0) { - ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n")); - return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n")); + return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } - /* Return only what was requested */ if (out_quotient) { @@ -327,9 +305,7 @@ acpi_ut_divide ( *out_remainder = in_dividend % in_divisor; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } #endif - - diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index f6de4ed3d52..0c5abc536c7 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -41,24 +41,130 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <acpi/acpi.h> #include <acpi/acnamesp.h> - #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utmisc") +ACPI_MODULE_NAME("utmisc") + +/******************************************************************************* + * + * FUNCTION: acpi_ut_allocate_owner_id + * + * PARAMETERS: owner_id - Where the new owner ID is returned + * + * RETURN: Status + * + * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to + * track objects created by the table or method, to be deleted + * when the method exits or the table is unloaded. + * + ******************************************************************************/ +acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) +{ + acpi_native_uint i; + acpi_status status; + + ACPI_FUNCTION_TRACE("ut_allocate_owner_id"); + + /* Guard against multiple allocations of ID to the same location */ + + if (*owner_id) { + ACPI_REPORT_ERROR(("Owner ID [%2.2X] already exists\n", + *owner_id)); + return_ACPI_STATUS(AE_ALREADY_EXISTS); + } + + /* Mutex for the global ID mask */ + + status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } -/* Local prototypes */ + /* Find a free owner ID */ -static acpi_status -acpi_ut_create_mutex ( - acpi_mutex_handle mutex_id); + for (i = 0; i < 32; i++) { + if (!(acpi_gbl_owner_id_mask & (1 << i))) { + ACPI_DEBUG_PRINT((ACPI_DB_VALUES, + "Current owner_id mask: %8.8X New ID: %2.2X\n", + acpi_gbl_owner_id_mask, + (unsigned int)(i + 1))); -static acpi_status -acpi_ut_delete_mutex ( - acpi_mutex_handle mutex_id); + acpi_gbl_owner_id_mask |= (1 << i); + *owner_id = (acpi_owner_id) (i + 1); + goto exit; + } + } + /* + * If we are here, all owner_ids have been allocated. This probably should + * not happen since the IDs are reused after deallocation. The IDs are + * allocated upon table load (one per table) and method execution, and + * they are released when a table is unloaded or a method completes + * execution. + */ + *owner_id = 0; + status = AE_OWNER_ID_LIMIT; + ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); + + exit: + (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); + return_ACPI_STATUS(status); +} + +/******************************************************************************* + * + * FUNCTION: acpi_ut_release_owner_id + * + * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_iD + * + * RETURN: None. No error is returned because we are either exiting a + * control method or unloading a table. Either way, we would + * ignore any error anyway. + * + * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 32 + * + ******************************************************************************/ + +void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) +{ + acpi_owner_id owner_id = *owner_id_ptr; + acpi_status status; + + ACPI_FUNCTION_TRACE_U32("ut_release_owner_id", owner_id); + + /* Always clear the input owner_id (zero is an invalid ID) */ + + *owner_id_ptr = 0; + + /* Zero is not a valid owner_iD */ + + if ((owner_id == 0) || (owner_id > 32)) { + ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id)); + return_VOID; + } + + /* Mutex for the global ID mask */ + + status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); + if (ACPI_FAILURE(status)) { + return_VOID; + } + + /* Normalize the ID to zero */ + + owner_id--; + + /* Free the owner ID only if it is valid */ + + if (acpi_gbl_owner_id_mask & (1 << owner_id)) { + acpi_gbl_owner_id_mask ^= (1 << owner_id); + } + + (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); + return_VOID; +} /******************************************************************************* * @@ -66,7 +172,7 @@ acpi_ut_delete_mutex ( * * PARAMETERS: src_string - The source string to convert * - * RETURN: Converted src_string (same as input pointer) + * RETURN: None * * DESCRIPTION: Convert string to uppercase * @@ -74,26 +180,25 @@ acpi_ut_delete_mutex ( * ******************************************************************************/ -char * -acpi_ut_strupr ( - char *src_string) +void acpi_ut_strupr(char *src_string) { - char *string; - + char *string; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); + if (!src_string) { + return; + } /* Walk entire string, uppercasing the letters */ for (string = src_string; *string; string++) { - *string = (char) ACPI_TOUPPER (*string); + *string = (char)ACPI_TOUPPER(*string); } - return (src_string); + return; } - /******************************************************************************* * * FUNCTION: acpi_ut_print_string @@ -108,85 +213,77 @@ acpi_ut_strupr ( * ******************************************************************************/ -void -acpi_ut_print_string ( - char *string, - u8 max_length) +void acpi_ut_print_string(char *string, u8 max_length) { - u32 i; - + u32 i; if (!string) { - acpi_os_printf ("<\"NULL STRING PTR\">"); + acpi_os_printf("<\"NULL STRING PTR\">"); return; } - acpi_os_printf ("\""); + acpi_os_printf("\""); for (i = 0; string[i] && (i < max_length); i++) { /* Escape sequences */ switch (string[i]) { case 0x07: - acpi_os_printf ("\\a"); /* BELL */ + acpi_os_printf("\\a"); /* BELL */ break; case 0x08: - acpi_os_printf ("\\b"); /* BACKSPACE */ + acpi_os_printf("\\b"); /* BACKSPACE */ break; case 0x0C: - acpi_os_printf ("\\f"); /* FORMFEED */ + acpi_os_printf("\\f"); /* FORMFEED */ break; case 0x0A: - acpi_os_printf ("\\n"); /* LINEFEED */ + acpi_os_printf("\\n"); /* LINEFEED */ break; case 0x0D: - acpi_os_printf ("\\r"); /* CARRIAGE RETURN*/ + acpi_os_printf("\\r"); /* CARRIAGE RETURN */ break; case 0x09: - acpi_os_printf ("\\t"); /* HORIZONTAL TAB */ + acpi_os_printf("\\t"); /* HORIZONTAL TAB */ break; case 0x0B: - acpi_os_printf ("\\v"); /* VERTICAL TAB */ + acpi_os_printf("\\v"); /* VERTICAL TAB */ break; - case '\'': /* Single Quote */ - case '\"': /* Double Quote */ - case '\\': /* Backslash */ - acpi_os_printf ("\\%c", (int) string[i]); + case '\'': /* Single Quote */ + case '\"': /* Double Quote */ + case '\\': /* Backslash */ + acpi_os_printf("\\%c", (int)string[i]); break; default: /* Check for printable character or hex escape */ - if (ACPI_IS_PRINT (string[i])) - { + if (ACPI_IS_PRINT(string[i])) { /* This is a normal character */ - acpi_os_printf ("%c", (int) string[i]); - } - else - { + acpi_os_printf("%c", (int)string[i]); + } else { /* All others will be Hex escapes */ - acpi_os_printf ("\\x%2.2X", (s32) string[i]); + acpi_os_printf("\\x%2.2X", (s32) string[i]); } break; } } - acpi_os_printf ("\""); + acpi_os_printf("\""); if (i == max_length && string[i]) { - acpi_os_printf ("..."); + acpi_os_printf("..."); } } - /******************************************************************************* * * FUNCTION: acpi_ut_dword_byte_swap @@ -199,22 +296,18 @@ acpi_ut_print_string ( * ******************************************************************************/ -u32 -acpi_ut_dword_byte_swap ( - u32 value) +u32 acpi_ut_dword_byte_swap(u32 value) { union { - u32 value; - u8 bytes[4]; + u32 value; + u8 bytes[4]; } out; union { - u32 value; - u8 bytes[4]; + u32 value; + u8 bytes[4]; } in; - - ACPI_FUNCTION_ENTRY (); - + ACPI_FUNCTION_ENTRY(); in.value = value; @@ -226,7 +319,6 @@ acpi_ut_dword_byte_swap ( return (out.value); } - /******************************************************************************* * * FUNCTION: acpi_ut_set_integer_width @@ -242,24 +334,20 @@ acpi_ut_dword_byte_swap ( * ******************************************************************************/ -void -acpi_ut_set_integer_width ( - u8 revision) +void acpi_ut_set_integer_width(u8 revision) { if (revision <= 1) { acpi_gbl_integer_bit_width = 32; acpi_gbl_integer_nybble_width = 8; acpi_gbl_integer_byte_width = 4; - } - else { + } else { acpi_gbl_integer_bit_width = 64; acpi_gbl_integer_nybble_width = 16; acpi_gbl_integer_byte_width = 8; } } - #ifdef ACPI_DEBUG_OUTPUT /******************************************************************************* * @@ -277,17 +365,14 @@ acpi_ut_set_integer_width ( ******************************************************************************/ void -acpi_ut_display_init_pathname ( - u8 type, - struct acpi_namespace_node *obj_handle, - char *path) +acpi_ut_display_init_pathname(u8 type, + struct acpi_namespace_node *obj_handle, + char *path) { - acpi_status status; - struct acpi_buffer buffer; - - - ACPI_FUNCTION_ENTRY (); + acpi_status status; + struct acpi_buffer buffer; + ACPI_FUNCTION_ENTRY(); /* Only print the path if the appropriate debug level is enabled */ @@ -298,8 +383,8 @@ acpi_ut_display_init_pathname ( /* Get the full pathname to the node */ buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; - status = acpi_ns_handle_to_pathname (obj_handle, &buffer); - if (ACPI_FAILURE (status)) { + status = acpi_ns_handle_to_pathname(obj_handle, &buffer); + if (ACPI_FAILURE(status)) { return; } @@ -307,31 +392,30 @@ acpi_ut_display_init_pathname ( switch (type) { case ACPI_TYPE_METHOD: - acpi_os_printf ("Executing "); + acpi_os_printf("Executing "); break; default: - acpi_os_printf ("Initializing "); + acpi_os_printf("Initializing "); break; } /* Print the object type and pathname */ - acpi_os_printf ("%-12s %s", - acpi_ut_get_type_name (type), (char *) buffer.pointer); + acpi_os_printf("%-12s %s", + acpi_ut_get_type_name(type), (char *)buffer.pointer); /* Extra path is used to append names like _STA, _INI, etc. */ if (path) { - acpi_os_printf (".%s", path); + acpi_os_printf(".%s", path); } - acpi_os_printf ("\n"); + acpi_os_printf("\n"); - ACPI_MEM_FREE (buffer.pointer); + ACPI_MEM_FREE(buffer.pointer); } #endif - /******************************************************************************* * * FUNCTION: acpi_ut_valid_acpi_name @@ -347,25 +431,21 @@ acpi_ut_display_init_pathname ( * ******************************************************************************/ -u8 -acpi_ut_valid_acpi_name ( - u32 name) +u8 acpi_ut_valid_acpi_name(u32 name) { - char *name_ptr = (char *) &name; - char character; - acpi_native_uint i; - - - ACPI_FUNCTION_ENTRY (); + char *name_ptr = (char *)&name; + char character; + acpi_native_uint i; + ACPI_FUNCTION_ENTRY(); for (i = 0; i < ACPI_NAME_SIZE; i++) { character = *name_ptr; name_ptr++; if (!((character == '_') || - (character >= 'A' && character <= 'Z') || - (character >= '0' && character <= '9'))) { + (character >= 'A' && character <= 'Z') || + (character >= '0' && character <= '9'))) { return (FALSE); } } @@ -373,7 +453,6 @@ acpi_ut_valid_acpi_name ( return (TRUE); } - /******************************************************************************* * * FUNCTION: acpi_ut_valid_acpi_character @@ -386,19 +465,16 @@ acpi_ut_valid_acpi_name ( * ******************************************************************************/ -u8 -acpi_ut_valid_acpi_character ( - char character) +u8 acpi_ut_valid_acpi_character(char character) { - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY(); - return ((u8) ((character == '_') || - (character >= 'A' && character <= 'Z') || - (character >= '0' && character <= '9'))); + return ((u8) ((character == '_') || + (character >= 'A' && character <= 'Z') || + (character >= '0' && character <= '9'))); } - /******************************************************************************* * * FUNCTION: acpi_ut_strtoul64 @@ -415,18 +491,13 @@ acpi_ut_valid_acpi_character ( ******************************************************************************/ acpi_status -acpi_ut_strtoul64 ( - char *string, - u32 base, - acpi_integer *ret_integer) +acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer) { - u32 this_digit = 0; - acpi_integer return_value = 0; - acpi_integer quotient; - - - ACPI_FUNCTION_TRACE ("ut_stroul64"); + u32 this_digit = 0; + acpi_integer return_value = 0; + acpi_integer quotient; + ACPI_FUNCTION_TRACE("ut_stroul64"); if ((!string) || !(*string)) { goto error_exit; @@ -440,12 +511,12 @@ acpi_ut_strtoul64 ( default: /* Invalid Base */ - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Skip over any white space in the buffer */ - while (ACPI_IS_SPACE (*string) || *string == '\t') { + while (ACPI_IS_SPACE(*string) || *string == '\t') { string++; } @@ -454,12 +525,10 @@ acpi_ut_strtoul64 ( * determine if it is decimal or hexadecimal: */ if (base == 0) { - if ((*string == '0') && - (ACPI_TOLOWER (*(string + 1)) == 'x')) { + if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) { base = 16; string += 2; - } - else { + } else { base = 10; } } @@ -469,8 +538,7 @@ acpi_ut_strtoul64 ( * 0 or 0x, if they are present. */ if ((base == 16) && - (*string == '0') && - (ACPI_TOLOWER (*(string + 1)) == 'x')) { + (*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) { string += 2; } @@ -483,25 +551,23 @@ acpi_ut_strtoul64 ( /* Main loop: convert the string to a 64-bit integer */ while (*string) { - if (ACPI_IS_DIGIT (*string)) { + if (ACPI_IS_DIGIT(*string)) { /* Convert ASCII 0-9 to Decimal value */ - this_digit = ((u8) *string) - '0'; - } - else { + this_digit = ((u8) * string) - '0'; + } else { if (base == 10) { /* Digit is out of range */ goto error_exit; } - this_digit = (u8) ACPI_TOUPPER (*string); - if (ACPI_IS_XDIGIT ((char) this_digit)) { + this_digit = (u8) ACPI_TOUPPER(*string); + if (ACPI_IS_XDIGIT((char)this_digit)) { /* Convert ASCII Hex char to value */ this_digit = this_digit - 'A' + 10; - } - else { + } else { /* * We allow non-hex chars, just stop now, same as end-of-string. * See ACPI spec, string-to-integer conversion. @@ -512,8 +578,10 @@ acpi_ut_strtoul64 ( /* Divide the digit into the correct position */ - (void) acpi_ut_short_divide ((ACPI_INTEGER_MAX - (acpi_integer) this_digit), - base, "ient, NULL); + (void) + acpi_ut_short_divide((ACPI_INTEGER_MAX - + (acpi_integer) this_digit), base, + "ient, NULL); if (return_value > quotient) { goto error_exit; } @@ -526,335 +594,18 @@ acpi_ut_strtoul64 ( /* All done, normal exit */ *ret_integer = return_value; - return_ACPI_STATUS (AE_OK); - + return_ACPI_STATUS(AE_OK); -error_exit: + error_exit: /* Base was set/validated above */ if (base == 10) { - return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); - } - else { - return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); - } -} - - -/******************************************************************************* - * - * 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 i; - 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); - } - - /* - * 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); - } - } - - /* 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))); + return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT); + } else { + return_ACPI_STATUS(AE_BAD_HEX_CONSTANT); } - 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 @@ -870,16 +621,13 @@ acpi_ut_release_mutex ( ******************************************************************************/ acpi_status -acpi_ut_create_update_state_and_push ( - union acpi_operand_object *object, - u16 action, - union acpi_generic_state **state_list) +acpi_ut_create_update_state_and_push(union acpi_operand_object *object, + u16 action, + union acpi_generic_state **state_list) { - union acpi_generic_state *state; - - - ACPI_FUNCTION_ENTRY (); + union acpi_generic_state *state; + ACPI_FUNCTION_ENTRY(); /* Ignore null objects; these are expected */ @@ -887,371 +635,15 @@ acpi_ut_create_update_state_and_push ( return (AE_OK); } - state = acpi_ut_create_update_state (object, action); + state = acpi_ut_create_update_state(object, action); if (!state) { return (AE_NO_MEMORY); } - acpi_ut_push_generic_state (state_list, state); + acpi_ut_push_generic_state(state_list, state); return (AE_OK); } - -/******************************************************************************* - * - * 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 @@ -1268,33 +660,29 @@ acpi_ut_delete_generic_state_cache ( ******************************************************************************/ acpi_status -acpi_ut_walk_package_tree ( - union acpi_operand_object *source_object, - void *target_object, - acpi_pkg_callback walk_callback, - void *context) +acpi_ut_walk_package_tree(union acpi_operand_object * source_object, + void *target_object, + acpi_pkg_callback walk_callback, void *context) { - acpi_status status = AE_OK; - union acpi_generic_state *state_list = NULL; - union acpi_generic_state *state; - u32 this_index; - union acpi_operand_object *this_source_obj; - - - ACPI_FUNCTION_TRACE ("ut_walk_package_tree"); + acpi_status status = AE_OK; + union acpi_generic_state *state_list = NULL; + union acpi_generic_state *state; + u32 this_index; + union acpi_operand_object *this_source_obj; + ACPI_FUNCTION_TRACE("ut_walk_package_tree"); - state = acpi_ut_create_pkg_state (source_object, target_object, 0); + state = acpi_ut_create_pkg_state(source_object, target_object, 0); if (!state) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } while (state) { /* Get one element of the package */ - this_index = state->pkg.index; + this_index = state->pkg.index; this_source_obj = (union acpi_operand_object *) - state->pkg.source_object->package.elements[this_index]; + state->pkg.source_object->package.elements[this_index]; /* * Check for: @@ -1305,16 +693,20 @@ acpi_ut_walk_package_tree ( * case below. */ if ((!this_source_obj) || - (ACPI_GET_DESCRIPTOR_TYPE (this_source_obj) != ACPI_DESC_TYPE_OPERAND) || - (ACPI_GET_OBJECT_TYPE (this_source_obj) != ACPI_TYPE_PACKAGE)) { - status = walk_callback (ACPI_COPY_TYPE_SIMPLE, this_source_obj, - state, context); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) != + ACPI_DESC_TYPE_OPERAND) + || (ACPI_GET_OBJECT_TYPE(this_source_obj) != + ACPI_TYPE_PACKAGE)) { + status = + walk_callback(ACPI_COPY_TYPE_SIMPLE, + this_source_obj, state, context); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } state->pkg.index++; - while (state->pkg.index >= state->pkg.source_object->package.count) { + while (state->pkg.index >= + state->pkg.source_object->package.count) { /* * We've handled all of the objects at this level, This means * that we have just completed a package. That package may @@ -1322,8 +714,8 @@ acpi_ut_walk_package_tree ( * * Delete this state and pop the previous state (package). */ - acpi_ut_delete_generic_state (state); - state = acpi_ut_pop_generic_state (&state_list); + acpi_ut_delete_generic_state(state); + state = acpi_ut_pop_generic_state(&state_list); /* Finished when there are no more states */ @@ -1333,7 +725,7 @@ acpi_ut_walk_package_tree ( * package just add the length of the package objects * and exit */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* @@ -1342,35 +734,35 @@ acpi_ut_walk_package_tree ( */ state->pkg.index++; } - } - else { + } else { /* This is a subobject of type package */ - status = walk_callback (ACPI_COPY_TYPE_PACKAGE, this_source_obj, - state, context); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + walk_callback(ACPI_COPY_TYPE_PACKAGE, + this_source_obj, state, context); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* * Push the current state and create a new one * The callback above returned a new target package object. */ - acpi_ut_push_generic_state (&state_list, state); - state = acpi_ut_create_pkg_state (this_source_obj, - state->pkg.this_target_obj, 0); + acpi_ut_push_generic_state(&state_list, state); + state = acpi_ut_create_pkg_state(this_source_obj, + state->pkg. + this_target_obj, 0); if (!state) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } } } /* We should never get here */ - return_ACPI_STATUS (AE_AML_INTERNAL); + return_ACPI_STATUS(AE_AML_INTERNAL); } - /******************************************************************************* * * FUNCTION: acpi_ut_generate_checksum @@ -1384,23 +776,18 @@ acpi_ut_walk_package_tree ( * ******************************************************************************/ -u8 -acpi_ut_generate_checksum ( - u8 *buffer, - u32 length) +u8 acpi_ut_generate_checksum(u8 * buffer, u32 length) { - u32 i; - signed char sum = 0; - + u32 i; + signed char sum = 0; for (i = 0; i < length; i++) { - sum = (signed char) (sum + buffer[i]); + sum = (signed char)(sum + buffer[i]); } return ((u8) (0 - sum)); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_resource_end_tag @@ -1413,17 +800,13 @@ acpi_ut_generate_checksum ( * ******************************************************************************/ - -u8 * -acpi_ut_get_resource_end_tag ( - union acpi_operand_object *obj_desc) +u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc) { - u8 buffer_byte; - u8 *buffer; - u8 *end_buffer; - + u8 buffer_byte; + u8 *buffer; + u8 *end_buffer; - buffer = obj_desc->buffer.pointer; + buffer = obj_desc->buffer.pointer; end_buffer = buffer + obj_desc->buffer.length; while (buffer < end_buffer) { @@ -1431,12 +814,12 @@ acpi_ut_get_resource_end_tag ( if (buffer_byte & ACPI_RDESC_TYPE_MASK) { /* Large Descriptor - Length is next 2 bytes */ - buffer += ((*(buffer+1) | (*(buffer+2) << 8)) + 3); - } - else { + buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3); + } else { /* Small Descriptor. End Tag will be found here */ - if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == ACPI_RDESC_TYPE_END_TAG) { + if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == + ACPI_RDESC_TYPE_END_TAG) { /* Found the end tag descriptor, all done. */ return (buffer); @@ -1453,7 +836,6 @@ acpi_ut_get_resource_end_tag ( return (NULL); } - /******************************************************************************* * * FUNCTION: acpi_ut_report_error @@ -1468,17 +850,12 @@ acpi_ut_get_resource_end_tag ( * ******************************************************************************/ -void -acpi_ut_report_error ( - char *module_name, - u32 line_number, - u32 component_id) +void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id) { - acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number); + acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number); } - /******************************************************************************* * * FUNCTION: acpi_ut_report_warning @@ -1494,16 +871,12 @@ acpi_ut_report_error ( ******************************************************************************/ void -acpi_ut_report_warning ( - char *module_name, - u32 line_number, - u32 component_id) +acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id) { - acpi_os_printf ("%8s-%04d: *** Warning: ", module_name, line_number); + acpi_os_printf("%8s-%04d: *** Warning: ", module_name, line_number); } - /******************************************************************************* * * FUNCTION: acpi_ut_report_info @@ -1518,14 +891,8 @@ acpi_ut_report_warning ( * ******************************************************************************/ -void -acpi_ut_report_info ( - char *module_name, - u32 line_number, - u32 component_id) +void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id) { - acpi_os_printf ("%8s-%04d: *** Info: ", module_name, line_number); + acpi_os_printf("%8s-%04d: *** Info: ", module_name, line_number); } - - diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c new file mode 100644 index 00000000000..90134c56ece --- /dev/null +++ b/drivers/acpi/utilities/utmutex.c @@ -0,0 +1,354 @@ +/******************************************************************************* + * + * 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].thread_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].thread_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].thread_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].thread_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].thread_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 cd3899b9cc5..3015e154005 100644 --- a/drivers/acpi/utilities/utobject.c +++ b/drivers/acpi/utilities/utobject.c @@ -41,34 +41,26 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <acpi/acpi.h> #include <acpi/acnamesp.h> #include <acpi/amlcode.h> - #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utobject") +ACPI_MODULE_NAME("utobject") /* Local prototypes */ - static acpi_status -acpi_ut_get_simple_object_size ( - union acpi_operand_object *obj, - acpi_size *obj_length); +acpi_ut_get_simple_object_size(union acpi_operand_object *obj, + acpi_size * obj_length); static acpi_status -acpi_ut_get_package_object_size ( - union acpi_operand_object *obj, - acpi_size *obj_length); +acpi_ut_get_package_object_size(union acpi_operand_object *obj, + acpi_size * obj_length); static acpi_status -acpi_ut_get_element_length ( - u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state *state, - void *context); - +acpi_ut_get_element_length(u8 object_type, + union acpi_operand_object *source_object, + union acpi_generic_state *state, void *context); /******************************************************************************* * @@ -91,26 +83,25 @@ acpi_ut_get_element_length ( * ******************************************************************************/ -union acpi_operand_object * -acpi_ut_create_internal_object_dbg ( - char *module_name, - u32 line_number, - u32 component_id, - acpi_object_type type) +union acpi_operand_object *acpi_ut_create_internal_object_dbg(char *module_name, + u32 line_number, + u32 component_id, + acpi_object_type + type) { - union acpi_operand_object *object; - union acpi_operand_object *second_object; - - - ACPI_FUNCTION_TRACE_STR ("ut_create_internal_object_dbg", - acpi_ut_get_type_name (type)); + union acpi_operand_object *object; + union acpi_operand_object *second_object; + ACPI_FUNCTION_TRACE_STR("ut_create_internal_object_dbg", + acpi_ut_get_type_name(type)); /* Allocate the raw object descriptor */ - object = acpi_ut_allocate_object_desc_dbg (module_name, line_number, component_id); + object = + acpi_ut_allocate_object_desc_dbg(module_name, line_number, + component_id); if (!object) { - return_PTR (NULL); + return_PTR(NULL); } switch (type) { @@ -119,11 +110,12 @@ acpi_ut_create_internal_object_dbg ( /* These types require a secondary object */ - second_object = acpi_ut_allocate_object_desc_dbg (module_name, - line_number, component_id); + second_object = acpi_ut_allocate_object_desc_dbg(module_name, + line_number, + component_id); if (!second_object) { - acpi_ut_delete_object_desc (object); - return_PTR (NULL); + acpi_ut_delete_object_desc(object); + return_PTR(NULL); } second_object->common.type = ACPI_TYPE_LOCAL_EXTRA; @@ -149,10 +141,9 @@ acpi_ut_create_internal_object_dbg ( /* Any per-type initialization should go here */ - return_PTR (object); + return_PTR(object); } - /******************************************************************************* * * FUNCTION: acpi_ut_create_buffer_object @@ -165,22 +156,18 @@ acpi_ut_create_internal_object_dbg ( * ******************************************************************************/ -union acpi_operand_object * -acpi_ut_create_buffer_object ( - acpi_size buffer_size) +union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size) { - union acpi_operand_object *buffer_desc; - u8 *buffer = NULL; - - - ACPI_FUNCTION_TRACE_U32 ("ut_create_buffer_object", buffer_size); + union acpi_operand_object *buffer_desc; + u8 *buffer = NULL; + ACPI_FUNCTION_TRACE_U32("ut_create_buffer_object", buffer_size); /* Create a new Buffer object */ - buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); + buffer_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); if (!buffer_desc) { - return_PTR (NULL); + return_PTR(NULL); } /* Create an actual buffer only if size > 0 */ @@ -188,12 +175,11 @@ acpi_ut_create_buffer_object ( if (buffer_size > 0) { /* Allocate the actual buffer */ - buffer = ACPI_MEM_CALLOCATE (buffer_size); + buffer = ACPI_MEM_CALLOCATE(buffer_size); if (!buffer) { - ACPI_REPORT_ERROR (("create_buffer: could not allocate size %X\n", - (u32) buffer_size)); - acpi_ut_remove_reference (buffer_desc); - return_PTR (NULL); + ACPI_REPORT_ERROR(("create_buffer: could not allocate size %X\n", (u32) buffer_size)); + acpi_ut_remove_reference(buffer_desc); + return_PTR(NULL); } } @@ -205,10 +191,9 @@ acpi_ut_create_buffer_object ( /* Return the new buffer descriptor */ - return_PTR (buffer_desc); + return_PTR(buffer_desc); } - /******************************************************************************* * * FUNCTION: acpi_ut_create_string_object @@ -223,34 +208,29 @@ acpi_ut_create_buffer_object ( * ******************************************************************************/ -union acpi_operand_object * -acpi_ut_create_string_object ( - acpi_size string_size) +union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size) { - union acpi_operand_object *string_desc; - char *string; - - - ACPI_FUNCTION_TRACE_U32 ("ut_create_string_object", string_size); + union acpi_operand_object *string_desc; + char *string; + ACPI_FUNCTION_TRACE_U32("ut_create_string_object", string_size); /* Create a new String object */ - string_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING); + string_desc = acpi_ut_create_internal_object(ACPI_TYPE_STRING); if (!string_desc) { - return_PTR (NULL); + return_PTR(NULL); } /* * Allocate the actual string buffer -- (Size + 1) for NULL terminator. * NOTE: Zero-length strings are NULL terminated */ - string = ACPI_MEM_CALLOCATE (string_size + 1); + string = ACPI_MEM_CALLOCATE(string_size + 1); if (!string) { - ACPI_REPORT_ERROR (("create_string: could not allocate size %X\n", - (u32) string_size)); - acpi_ut_remove_reference (string_desc); - return_PTR (NULL); + ACPI_REPORT_ERROR(("create_string: could not allocate size %X\n", (u32) string_size)); + acpi_ut_remove_reference(string_desc); + return_PTR(NULL); } /* Complete string object initialization */ @@ -260,10 +240,9 @@ acpi_ut_create_string_object ( /* Return the new string descriptor */ - return_PTR (string_desc); + return_PTR(string_desc); } - /******************************************************************************* * * FUNCTION: acpi_ut_valid_internal_object @@ -276,24 +255,21 @@ acpi_ut_create_string_object ( * ******************************************************************************/ -u8 -acpi_ut_valid_internal_object ( - void *object) +u8 acpi_ut_valid_internal_object(void *object) { - ACPI_FUNCTION_NAME ("ut_valid_internal_object"); - + ACPI_FUNCTION_NAME("ut_valid_internal_object"); /* Check for a null pointer */ if (!object) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Null Object Ptr\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "**** Null Object Ptr\n")); return (FALSE); } /* Check the descriptor type field */ - switch (ACPI_GET_DESCRIPTOR_TYPE (object)) { + switch (ACPI_GET_DESCRIPTOR_TYPE(object)) { case ACPI_DESC_TYPE_OPERAND: /* The object appears to be a valid union acpi_operand_object */ @@ -301,16 +277,15 @@ acpi_ut_valid_internal_object ( return (TRUE); default: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "%p is not not an ACPI operand obj [%s]\n", - object, acpi_ut_get_descriptor_name (object))); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "%p is not not an ACPI operand obj [%s]\n", + object, acpi_ut_get_descriptor_name(object))); break; } return (FALSE); } - /******************************************************************************* * * FUNCTION: acpi_ut_allocate_object_desc_dbg @@ -326,37 +301,31 @@ acpi_ut_valid_internal_object ( * ******************************************************************************/ -void * -acpi_ut_allocate_object_desc_dbg ( - char *module_name, - u32 line_number, - u32 component_id) +void *acpi_ut_allocate_object_desc_dbg(char *module_name, + u32 line_number, u32 component_id) { - union acpi_operand_object *object; + union acpi_operand_object *object; + ACPI_FUNCTION_TRACE("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")); + _ACPI_REPORT_ERROR(module_name, line_number, component_id, + ("Could not allocate an object descriptor\n")); - return_PTR (NULL); + return_PTR(NULL); } /* Mark the descriptor type */ + memset(object, 0, sizeof(union acpi_operand_object)); + ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_OPERAND); - ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND); + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p Size %X\n", + object, (u32) sizeof(union acpi_operand_object))); - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", - object, (u32) sizeof (union acpi_operand_object))); - - return_PTR (object); + return_PTR(object); } - /******************************************************************************* * * FUNCTION: acpi_ut_delete_object_desc @@ -369,54 +338,22 @@ acpi_ut_allocate_object_desc_dbg ( * ******************************************************************************/ -void -acpi_ut_delete_object_desc ( - union acpi_operand_object *object) +void acpi_ut_delete_object_desc(union acpi_operand_object *object) { - ACPI_FUNCTION_TRACE_PTR ("ut_delete_object_desc", object); - + ACPI_FUNCTION_TRACE_PTR("ut_delete_object_desc", object); /* Object must be an union acpi_operand_object */ - if (ACPI_GET_DESCRIPTOR_TYPE (object) != ACPI_DESC_TYPE_OPERAND) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "%p is not an ACPI Operand object [%s]\n", object, - acpi_ut_get_descriptor_name (object))); + if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "%p is not an ACPI Operand object [%s]\n", + object, acpi_ut_get_descriptor_name(object))); 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 - /******************************************************************************* * @@ -436,16 +373,13 @@ acpi_ut_delete_object_cache ( ******************************************************************************/ static acpi_status -acpi_ut_get_simple_object_size ( - union acpi_operand_object *internal_object, - acpi_size *obj_length) +acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, + acpi_size * obj_length) { - acpi_size length; - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE_PTR ("ut_get_simple_object_size", internal_object); + acpi_size length; + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE_PTR("ut_get_simple_object_size", internal_object); /* * Handle a null object (Could be a uninitialized package @@ -453,18 +387,18 @@ acpi_ut_get_simple_object_size ( */ if (!internal_object) { *obj_length = 0; - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Start with the length of the Acpi object */ - length = sizeof (union acpi_object); + length = sizeof(union acpi_object); - if (ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_NAMED) { + if (ACPI_GET_DESCRIPTOR_TYPE(internal_object) == ACPI_DESC_TYPE_NAMED) { /* Object is a named object (reference), just return the length */ - *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length); - return_ACPI_STATUS (status); + *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length); + return_ACPI_STATUS(status); } /* @@ -473,19 +407,17 @@ acpi_ut_get_simple_object_size ( * must be accessed bytewise or there may be alignment problems on * certain processors */ - switch (ACPI_GET_OBJECT_TYPE (internal_object)) { + switch (ACPI_GET_OBJECT_TYPE(internal_object)) { case ACPI_TYPE_STRING: length += (acpi_size) internal_object->string.length + 1; break; - case ACPI_TYPE_BUFFER: length += (acpi_size) internal_object->buffer.length; break; - case ACPI_TYPE_INTEGER: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: @@ -495,7 +427,6 @@ acpi_ut_get_simple_object_size ( */ break; - case ACPI_TYPE_LOCAL_REFERENCE: switch (internal_object->reference.opcode) { @@ -505,8 +436,10 @@ acpi_ut_get_simple_object_size ( * Get the actual length of the full pathname to this object. * The reference will be converted to the pathname to the object */ - length += ACPI_ROUND_UP_TO_NATIVE_WORD ( - acpi_ns_get_pathname_length (internal_object->reference.node)); + length += + ACPI_ROUND_UP_TO_NATIVE_WORD + (acpi_ns_get_pathname_length + (internal_object->reference.node)); break; default: @@ -516,19 +449,21 @@ acpi_ut_get_simple_object_size ( * Notably, Locals and Args are not supported, but this may be * required eventually. */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unsupported Reference opcode=%X in object %p\n", - internal_object->reference.opcode, internal_object)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unsupported Reference opcode=%X in object %p\n", + internal_object->reference.opcode, + internal_object)); status = AE_TYPE; break; } break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported type=%X in object %p\n", - ACPI_GET_OBJECT_TYPE (internal_object), internal_object)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unsupported type=%X in object %p\n", + ACPI_GET_OBJECT_TYPE(internal_object), + internal_object)); status = AE_TYPE; break; } @@ -539,11 +474,10 @@ acpi_ut_get_simple_object_size ( * on a machine word boundary. (preventing alignment faults on some * machines.) */ - *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length); - return_ACPI_STATUS (status); + *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_element_length @@ -557,16 +491,13 @@ acpi_ut_get_simple_object_size ( ******************************************************************************/ static acpi_status -acpi_ut_get_element_length ( - u8 object_type, - union acpi_operand_object *source_object, - union acpi_generic_state *state, - void *context) +acpi_ut_get_element_length(u8 object_type, + union acpi_operand_object *source_object, + union acpi_generic_state *state, void *context) { - acpi_status status = AE_OK; - struct acpi_pkg_info *info = (struct acpi_pkg_info *) context; - acpi_size object_space; - + acpi_status status = AE_OK; + struct acpi_pkg_info *info = (struct acpi_pkg_info *)context; + acpi_size object_space; switch (object_type) { case ACPI_COPY_TYPE_SIMPLE: @@ -575,15 +506,16 @@ acpi_ut_get_element_length ( * Simple object - just get the size (Null object/entry is handled * here also) and sum it into the running package length */ - status = acpi_ut_get_simple_object_size (source_object, &object_space); - if (ACPI_FAILURE (status)) { + status = + acpi_ut_get_simple_object_size(source_object, + &object_space); + if (ACPI_FAILURE(status)) { return (status); } info->length += object_space; break; - case ACPI_COPY_TYPE_PACKAGE: /* Package object - nothing much to do here, let the walk handle it */ @@ -592,7 +524,6 @@ acpi_ut_get_element_length ( state->pkg.this_target_obj = NULL; break; - default: /* No other types allowed */ @@ -603,7 +534,6 @@ acpi_ut_get_element_length ( return (status); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_package_object_size @@ -622,25 +552,22 @@ acpi_ut_get_element_length ( ******************************************************************************/ static acpi_status -acpi_ut_get_package_object_size ( - union acpi_operand_object *internal_object, - acpi_size *obj_length) +acpi_ut_get_package_object_size(union acpi_operand_object *internal_object, + acpi_size * obj_length) { - acpi_status status; - struct acpi_pkg_info info; + acpi_status status; + struct acpi_pkg_info info; + ACPI_FUNCTION_TRACE_PTR("ut_get_package_object_size", internal_object); - ACPI_FUNCTION_TRACE_PTR ("ut_get_package_object_size", internal_object); - - - info.length = 0; + info.length = 0; info.object_space = 0; info.num_packages = 1; - status = acpi_ut_walk_package_tree (internal_object, NULL, - acpi_ut_get_element_length, &info); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_walk_package_tree(internal_object, NULL, + acpi_ut_get_element_length, &info); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* @@ -648,16 +575,15 @@ acpi_ut_get_package_object_size ( * just add the length of the package objects themselves. * Round up to the next machine word. */ - info.length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)) * - (acpi_size) info.num_packages; + info.length += ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)) * + (acpi_size) info.num_packages; /* Return the total package length */ *obj_length = info.length; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ut_get_object_size @@ -673,25 +599,23 @@ acpi_ut_get_package_object_size ( ******************************************************************************/ acpi_status -acpi_ut_get_object_size ( - union acpi_operand_object *internal_object, - acpi_size *obj_length) +acpi_ut_get_object_size(union acpi_operand_object *internal_object, + acpi_size * obj_length) { - acpi_status status; - - - ACPI_FUNCTION_ENTRY (); - - - if ((ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_OPERAND) && - (ACPI_GET_OBJECT_TYPE (internal_object) == ACPI_TYPE_PACKAGE)) { - status = acpi_ut_get_package_object_size (internal_object, obj_length); - } - else { - status = acpi_ut_get_simple_object_size (internal_object, obj_length); + acpi_status status; + + ACPI_FUNCTION_ENTRY(); + + if ((ACPI_GET_DESCRIPTOR_TYPE(internal_object) == + ACPI_DESC_TYPE_OPERAND) + && (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE)) { + status = + acpi_ut_get_package_object_size(internal_object, + obj_length); + } else { + status = + acpi_ut_get_simple_object_size(internal_object, obj_length); } return (status); } - - diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c new file mode 100644 index 00000000000..c1cb27583be --- /dev/null +++ b/drivers/acpi/utilities/utstate.c @@ -0,0 +1,333 @@ +/******************************************************************************* + * + * 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 e8803d81065..f06bd5e5e9d 100644 --- a/drivers/acpi/utilities/utxface.c +++ b/drivers/acpi/utilities/utxface.c @@ -46,13 +46,10 @@ #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 - ACPI_MODULE_NAME ("utxface") - +ACPI_MODULE_NAME("utxface") /******************************************************************************* * @@ -66,61 +63,54 @@ * called, so any early initialization belongs here. * ******************************************************************************/ - -acpi_status -acpi_initialize_subsystem ( - void) +acpi_status acpi_initialize_subsystem(void) { - acpi_status status; + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_initialize_subsystem"); - ACPI_FUNCTION_TRACE ("acpi_initialize_subsystem"); + ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace()); + /* Initialize the OS-Dependent layer */ - ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ()); - + status = acpi_os_initialize(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("OSD failed to initialize, %s\n", + acpi_format_exception(status))); + return_ACPI_STATUS(status); + } /* Initialize all globals used by the subsystem */ - acpi_ut_init_globals (); - - /* Initialize the OS-Dependent layer */ - - status = acpi_os_initialize (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("OSD failed to initialize, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); - } + acpi_ut_init_globals(); /* Create the default mutex objects */ - status = acpi_ut_mutex_initialize (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Global mutex creation failure, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_ut_mutex_initialize(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Global mutex creation failure, %s\n", + acpi_format_exception(status))); + return_ACPI_STATUS(status); } /* * Initialize the namespace manager and * the root of the namespace tree */ - status = acpi_ns_root_initialize (); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Namespace initialization failure, %s\n", - acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_ns_root_initialize(); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Namespace initialization failure, %s\n", + acpi_format_exception(status))); + return_ACPI_STATUS(status); } /* If configured, initialize the AML debugger */ - ACPI_DEBUGGER_EXEC (status = acpi_db_initialize ()); + ACPI_DEBUGGER_EXEC(status = acpi_db_initialize()); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_enable_subsystem @@ -134,41 +124,39 @@ acpi_initialize_subsystem ( * ******************************************************************************/ -acpi_status -acpi_enable_subsystem ( - u32 flags) +acpi_status acpi_enable_subsystem(u32 flags) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("acpi_enable_subsystem"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_enable_subsystem"); /* * We must initialize the hardware before we can enable ACPI. * The values from the FADT are validated here. */ if (!(flags & ACPI_NO_HARDWARE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Initializing ACPI hardware\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Initializing ACPI hardware\n")); - status = acpi_hw_initialize (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_hw_initialize(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Enable ACPI mode */ if (!(flags & ACPI_NO_ACPI_ENABLE)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Going into ACPI mode\n")); acpi_gbl_original_mode = acpi_hw_get_mode(); - status = acpi_enable (); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "acpi_enable failed.\n")); - return_ACPI_STATUS (status); + status = acpi_enable(); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "acpi_enable failed.\n")); + return_ACPI_STATUS(status); } } @@ -178,12 +166,12 @@ acpi_enable_subsystem ( * install_address_space_handler interface. */ if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Installing default address space handlers\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Installing default address space handlers\n")); - status = acpi_ev_install_region_handlers (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ev_install_region_handlers(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } @@ -196,28 +184,28 @@ acpi_enable_subsystem ( * execution! */ if (!(flags & ACPI_NO_EVENT_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Initializing ACPI events\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Initializing ACPI events\n")); - status = acpi_ev_initialize_events (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ev_initialize_events(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } /* Install the SCI handler and Global Lock handler */ if (!(flags & ACPI_NO_HANDLER_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Installing SCI/GL handlers\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Installing SCI/GL handlers\n")); - status = acpi_ev_install_xrupt_handlers (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ev_install_xrupt_handlers(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /******************************************************************************* @@ -233,15 +221,11 @@ acpi_enable_subsystem ( * ******************************************************************************/ -acpi_status -acpi_initialize_objects ( - u32 flags) +acpi_status acpi_initialize_objects(u32 flags) { - acpi_status status = AE_OK; - - - ACPI_FUNCTION_TRACE ("acpi_initialize_objects"); + acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_initialize_objects"); /* * Run all _REG methods @@ -251,12 +235,12 @@ acpi_initialize_objects ( * contain executable AML (see call to acpi_ns_initialize_objects below). */ if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Executing _REG op_region methods\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Executing _REG op_region methods\n")); - status = acpi_ev_initialize_op_regions (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ev_initialize_op_regions(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } @@ -266,12 +250,12 @@ acpi_initialize_objects ( * objects: operation_regions, buffer_fields, Buffers, and Packages. */ if (!(flags & ACPI_NO_OBJECT_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Completing Initialization of ACPI Objects\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Completing Initialization of ACPI Objects\n")); - status = acpi_ns_initialize_objects (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ns_initialize_objects(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } @@ -280,12 +264,12 @@ acpi_initialize_objects ( * This runs the _STA and _INI methods. */ if (!(flags & ACPI_NO_DEVICE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Initializing ACPI Devices\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[Init] Initializing ACPI Devices\n")); - status = acpi_ns_initialize_devices (); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ns_initialize_devices(); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } } @@ -294,13 +278,12 @@ acpi_initialize_objects ( * the table load filled them up more than they will be at runtime -- * thus wasting non-paged memory. */ - status = acpi_purge_cached_objects (); + status = acpi_purge_cached_objects(); acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_terminate @@ -313,15 +296,11 @@ acpi_initialize_objects ( * ******************************************************************************/ -acpi_status -acpi_terminate ( - void) +acpi_status acpi_terminate(void) { - acpi_status status; - - - ACPI_FUNCTION_TRACE ("acpi_terminate"); + acpi_status status; + ACPI_FUNCTION_TRACE("acpi_terminate"); /* Terminate the AML Debugger if present */ @@ -329,28 +308,25 @@ acpi_terminate ( /* Shutdown and free all resources */ - acpi_ut_subsystem_shutdown (); - + acpi_ut_subsystem_shutdown(); /* Free the mutex objects */ - acpi_ut_mutex_terminate (); - + acpi_ut_mutex_terminate(); #ifdef ACPI_DEBUGGER /* Shut down the debugger */ - acpi_db_terminate (); + acpi_db_terminate(); #endif /* Now we can shutdown the OS-dependent layer */ - status = acpi_os_terminate (); - return_ACPI_STATUS (status); + status = acpi_os_terminate(); + return_ACPI_STATUS(status); } - #ifdef ACPI_FUTURE_USAGE /******************************************************************************* * @@ -366,20 +342,16 @@ acpi_terminate ( * ******************************************************************************/ -acpi_status -acpi_subsystem_status ( - void) +acpi_status acpi_subsystem_status(void) { if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) { return (AE_OK); - } - else { + } else { return (AE_ERROR); } } - /******************************************************************************* * * FUNCTION: acpi_get_system_info @@ -398,64 +370,60 @@ acpi_subsystem_status ( * ******************************************************************************/ -acpi_status -acpi_get_system_info ( - struct acpi_buffer *out_buffer) +acpi_status acpi_get_system_info(struct acpi_buffer * out_buffer) { - struct acpi_system_info *info_ptr; - acpi_status status; - u32 i; - - - ACPI_FUNCTION_TRACE ("acpi_get_system_info"); + struct acpi_system_info *info_ptr; + acpi_status status; + u32 i; + ACPI_FUNCTION_TRACE("acpi_get_system_info"); /* Parameter validation */ - status = acpi_ut_validate_buffer (out_buffer); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ut_validate_buffer(out_buffer); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Validate/Allocate/Clear caller buffer */ - status = acpi_ut_initialize_buffer (out_buffer, sizeof (struct acpi_system_info)); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = + acpi_ut_initialize_buffer(out_buffer, + sizeof(struct acpi_system_info)); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* * Populate the return buffer */ - info_ptr = (struct acpi_system_info *) out_buffer->pointer; + info_ptr = (struct acpi_system_info *)out_buffer->pointer; - info_ptr->acpi_ca_version = ACPI_CA_VERSION; + info_ptr->acpi_ca_version = ACPI_CA_VERSION; /* System flags (ACPI capabilities) */ - info_ptr->flags = ACPI_SYS_MODE_ACPI; + info_ptr->flags = ACPI_SYS_MODE_ACPI; /* Timer resolution - 24 or 32 bits */ if (!acpi_gbl_FADT) { info_ptr->timer_resolution = 0; - } - else if (acpi_gbl_FADT->tmr_val_ext == 0) { + } else if (acpi_gbl_FADT->tmr_val_ext == 0) { info_ptr->timer_resolution = 24; - } - else { + } else { info_ptr->timer_resolution = 32; } /* Clear the reserved fields */ - info_ptr->reserved1 = 0; - info_ptr->reserved2 = 0; + info_ptr->reserved1 = 0; + info_ptr->reserved2 = 0; /* Current debug levels */ - info_ptr->debug_layer = acpi_dbg_layer; - info_ptr->debug_level = acpi_dbg_level; + info_ptr->debug_layer = acpi_dbg_layer; + info_ptr->debug_level = acpi_dbg_level; /* Current status of the ACPI tables, per table type */ @@ -464,10 +432,10 @@ acpi_get_system_info ( info_ptr->table_info[i].count = acpi_gbl_table_lists[i].count; } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } -EXPORT_SYMBOL(acpi_get_system_info); +EXPORT_SYMBOL(acpi_get_system_info); /***************************************************************************** * @@ -485,9 +453,7 @@ EXPORT_SYMBOL(acpi_get_system_info); ****************************************************************************/ acpi_status -acpi_install_initialization_handler ( - acpi_init_handler handler, - u32 function) +acpi_install_initialization_handler(acpi_init_handler handler, u32 function) { if (!handler) { @@ -502,7 +468,7 @@ acpi_install_initialization_handler ( return AE_OK; } -#endif /* ACPI_FUTURE_USAGE */ +#endif /* ACPI_FUTURE_USAGE */ /***************************************************************************** * @@ -516,19 +482,13 @@ acpi_install_initialization_handler ( * ****************************************************************************/ -acpi_status -acpi_purge_cached_objects ( - void) +acpi_status acpi_purge_cached_objects(void) { - 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 + ACPI_FUNCTION_TRACE("acpi_purge_cached_objects"); - return_ACPI_STATUS (AE_OK); + (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); } |