utmisc.c

来自「是关于linux2.5.1的完全源码」· C语言 代码 · 共 1,270 行 · 第 1/3 页

C
1,270
字号
 * ******************************************************************************/voidacpi_ut_delete_generic_state (	acpi_generic_state      *state){	ACPI_FUNCTION_TRACE ("Ut_delete_generic_state");	acpi_ut_release_to_cache (ACPI_MEM_LIST_STATE, state);	return_VOID;}/******************************************************************************* * * 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;}/******************************************************************************* * * FUNCTION:    Acpi_ut_resolve_reference * * PARAMETERS:  ACPI_PKG_CALLBACK * * RETURN:      Status          - the status of the call * * DESCRIPTION: Resolve a reference object to an actual value * ******************************************************************************/acpi_statusacpi_ut_resolve_reference (	u8                      object_type,	acpi_operand_object     *source_object,	acpi_generic_state      *state,	void                    *context){	acpi_pkg_info           *info = (acpi_pkg_info *) context;	switch (object_type) {	case ACPI_COPY_TYPE_SIMPLE:		/*		 * Simple object - check for a reference		 */		if (source_object->common.type == INTERNAL_TYPE_REFERENCE) {			switch (source_object->reference.opcode) {			case AML_ZERO_OP:				source_object->common.type = ACPI_TYPE_INTEGER;				source_object->integer.value = 0;				break;			case AML_ONE_OP:				source_object->common.type = ACPI_TYPE_INTEGER;				source_object->integer.value = 1;				break;			case AML_ONES_OP:				source_object->common.type = ACPI_TYPE_INTEGER;				source_object->integer.value = ACPI_INTEGER_MAX;				break;			}		}		break;	case ACPI_COPY_TYPE_PACKAGE:		/* Package object - nothing much to do here, let the walk handle it */		info->num_packages++;		state->pkg.this_target_obj = NULL;		break;	}	return (AE_OK);}/******************************************************************************* * * FUNCTION:    Acpi_ut_resolve_package_references * * PARAMETERS:  Obj_desc        - The Package object on which to resolve refs * * RETURN:      Status * * DESCRIPTION: Walk through a package and turn internal references into values * ******************************************************************************/acpi_statusacpi_ut_resolve_package_references (	acpi_operand_object     *obj_desc){	acpi_pkg_info           info;	acpi_status             status;	ACPI_FUNCTION_TRACE ("Ut_resolve_package_references");	if (obj_desc->common.type != ACPI_TYPE_PACKAGE) {		/* The object must be a package */		ACPI_REPORT_ERROR (("Expecting a Package object\n"));		return_ACPI_STATUS (AE_TYPE);	}	info.length      = 0;	info.object_space = 0;	info.num_packages = 1;	status = acpi_ut_walk_package_tree (obj_desc, NULL,			 acpi_ut_resolve_reference, &info);	return_ACPI_STATUS (status);}/******************************************************************************* * * 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 (	acpi_operand_object     *source_object,	void                    *target_object,	ACPI_PKG_CALLBACK       walk_callback,	void                    *context){	acpi_status             status = AE_OK;	acpi_generic_state      *state_list = NULL;	acpi_generic_state      *state;	u32                     this_index;	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) {		this_index    = state->pkg.index;		this_source_obj = (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_INTERNAL) ||			(this_source_obj->common.type != 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 (	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 (	NATIVE_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 (	NATIVE_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 (	NATIVE_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 + =
减小字号Ctrl + -
显示快捷键?