utmisc.c
来自「是关于linux2.5.1的完全源码」· C语言 代码 · 共 1,270 行 · 第 1/3 页
C
1,270 行
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_MTX) { return (AE_BAD_PARAMETER); } /* * Mutex must be acquired in order to release it! */ if (acpi_gbl_acpi_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_MTX; i++) { if (acpi_gbl_acpi_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_acpi_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; status = acpi_os_signal_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex, 1); if (ACPI_FAILURE (status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not release Mutex [%s] %s\n", this_thread_id, acpi_ut_get_mutex_name (mutex_id), acpi_format_exception (status))); } else { ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", this_thread_id, acpi_ut_get_mutex_name (mutex_id))); } return (status);}/******************************************************************************* * * FUNCTION: Acpi_ut_create_update_state_and_push * * PARAMETERS: *Object - Object to be added to the new state * Action - Increment/Decrement * State_list - List the state will be added to * * RETURN: None * * DESCRIPTION: Create a new state and push it * ******************************************************************************/acpi_statusacpi_ut_create_update_state_and_push ( acpi_operand_object *object, u16 action, acpi_generic_state **state_list){ acpi_generic_state *state; ACPI_FUNCTION_ENTRY (); /* Ignore null objects; these are expected */ if (!object) { return (AE_OK); } state = acpi_ut_create_update_state (object, action); if (!state) { return (AE_NO_MEMORY); } 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: None * * DESCRIPTION: Create a new state and push it * ******************************************************************************/acpi_statusacpi_ut_create_pkg_state_and_push ( void *internal_object, void *external_object, u16 index, acpi_generic_state **state_list){ 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: Status * * DESCRIPTION: Push a state object onto a state stack * ******************************************************************************/voidacpi_ut_push_generic_state ( acpi_generic_state **list_head, 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: Status * * DESCRIPTION: Pop a state object from a state stack * ******************************************************************************/acpi_generic_state *acpi_ut_pop_generic_state ( acpi_generic_state **list_head){ 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: Status * * DESCRIPTION: Create a generic state object. Attempt to obtain one from * the global state cache; If none available, create a new one. * ******************************************************************************/acpi_generic_state *acpi_ut_create_generic_state (void){ 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: Thread State * * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used * to track per-thread info during method execution * ******************************************************************************/ACPI_THREAD_STATE *acpi_ut_create_thread_state ( void){ 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 ((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: Status * * DESCRIPTION: Create an "Update State" - a flavor of the generic state used * to update reference counts and delete complex objects such * as packages. * ******************************************************************************/acpi_generic_state *acpi_ut_create_update_state ( acpi_operand_object *object, u16 action){ 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: Status * * DESCRIPTION: Create a "Package State" * ******************************************************************************/acpi_generic_state *acpi_ut_create_pkg_state ( void *internal_object, void *external_object, u16 index){ 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 = (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: Status * * DESCRIPTION: Create a "Control State" - a flavor of the generic state used * to support nested IF/WHILE constructs in the AML. * ******************************************************************************/acpi_generic_state *acpi_ut_create_control_state ( void){ 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: Status * * DESCRIPTION: Put a state object back into the global state cache. The object * is not actually freed at this time.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?