📄 utmisc.c
字号:
}/******************************************************************************* * * 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 * ******************************************************************************/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: Status * * 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: Status * * 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: Status * * 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: Status * * DESCRIPTION: Put a state object back into the global state cache. The object * is not actually freed at this time. * ******************************************************************************/voidacpi_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: Status * * DESCRIPTION: Purge the global state object cache. Used during subsystem * termination. * ******************************************************************************/voidacpi_ut_delete_generic_state_cache ( void){ ACPI_FUNCTION_TRACE ("ut_delete_generic_state_cache"); acpi_ut_delete_generic_cache (ACPI_MEM_LIST_STATE); return_VOID;}#endif/******************************************************************************* * * FUNCTION: acpi_ut_walk_package_tree * * PARAMETERS: obj_desc - The Package object on which to resolve refs * * RETURN: Status * * DESCRIPTION: Walk through a package * ******************************************************************************/acpi_statusacpi_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"); state = acpi_ut_create_pkg_state (source_object, target_object, 0); if (!state) { return_ACPI_STATUS (AE_NO_MEMORY); } while (state) { /* Get one element of the package */ this_index = state->pkg.index; this_source_obj = (union acpi_operand_object *) state->pkg.source_object->package.elements[this_index]; /* * Check for: * 1) An uninitialized package element. It is completely * legal to declare a package and leave it uninitialized * 2) Not an internal object - can be a namespace node instead * 3) Any type other than a package. Packages are handled in else * 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); } state->pkg.index++; 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 * have contained one or more packages itself. * * Delete this state and pop the previous state (package). */ acpi_ut_delete_generic_state (state); state = acpi_ut_pop_generic_state (&state_list); /* Finished when there are no more states */ if (!state) { /* * We have handled all of the objects in the top level * package just add the length of the package objects * and exit */ return_ACPI_STATUS (AE_OK); } /* * Go back up a level and move the index past the just * completed package object. */ state->pkg.index++; } } 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); } /* * 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); if (!state) { return_ACPI_STATUS (AE_NO_MEMORY); } } } /* We should never get here */ return_ACPI_STATUS (AE_AML_INTERNAL);}/******************************************************************************* * * FUNCTION: acpi_ut_generate_checksum * * PARAMETERS: Buffer - Buffer to be scanned * Length - number of bytes to examine * * RETURN: checksum * * DESCRIPTION: Generate a checksum on a raw buffer * ******************************************************************************/u8acpi_ut_generate_checksum ( u8 *buffer, u32 length){ u32 i; signed char sum = 0; for (i = 0; i < length; i++) { sum = (signed char) (sum + buffer[i]); } return ((u8) (0 - sum));}/******************************************************************************* * * FUNCTION: acpi_ut_get_resource_end_tag * * PARAMETERS: obj_desc - The resource template buffer object * * RETURN: Pointer to the end tag * * DESCRIPTION: Find the END_TAG resource descriptor in a resource template * ******************************************************************************/u8 *acpi_ut_get_resource_end_tag ( union acpi_operand_object *obj_desc){ u8 buffer_byte; u8 *buffer; u8 *end_buffer; buffer = obj_desc->buffer.pointer; end_buffer = buffer + obj_desc->buffer.length; while (buffer < end_buffer) { buffer_byte = *buffer; if (buffer_byte & ACPI_RDESC_TYPE_MASK) { /* Large Descriptor - Length is next 2 bytes */ 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) { /* Found the end tag descriptor, all done. */ return (buffer); } /* Length is in the header */ buffer += ((buffer_byte & 0x07) + 1); } } /* End tag not found */ return (NULL);}/******************************************************************************* * * FUNCTION: acpi_ut_report_error * * PARAMETERS: module_name - Caller's module name (for error output) * line_number - Caller's line number (for error output) * component_id - Caller's component ID (for error output) * Message - Error message to use on failure * * RETURN: None * * DESCRIPTION: Print error message * ******************************************************************************/voidacpi_ut_report_error ( char *module_name, u32 line_number, u32 component_id){ acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number);}/******************************************************************************* * * FUNCTION: acpi_ut_report_warning * * PARAMETERS: module_name - Caller's module name (for error output) * line_number - Caller's line number (for error output) * component_id - Caller's component ID (for error output) * Message - Error message to use on failure * * RETURN: None * * DESCRIPTION: Print warning message * ******************************************************************************/voidacpi_ut_report_warning ( char *module_name, u32 line_number, u32 component_id){ acpi_os_printf ("%8s-%04d: *** Warning: ", module_name, line_number);}/******************************************************************************* * * FUNCTION: acpi_ut_report_info * * PARAMETERS: module_name - Caller's module name (for error output) * line_number - Caller's line number (for error output) * component_id - Caller's component ID (for error output) * Message - Error message to use on failure * * RETURN: None * * DESCRIPTION: Print information message * ******************************************************************************/voidacpi_ut_report_info ( char *module_name, u32 line_number, u32 component_id){ acpi_os_printf ("%8s-%04d: *** Info: ", module_name, line_number);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -