⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exoparg1.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** * * Module Name: exoparg1 - AML execution - opcodes with 1 argument * *****************************************************************************//* * 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>#include <acpi/acparser.h>#include <acpi/acdispat.h>#include <acpi/acinterp.h>#include <acpi/amlcode.h>#include <acpi/acnamesp.h>#define _COMPONENT          ACPI_EXECUTERACPI_MODULE_NAME("exoparg1")/*! * Naming convention for AML interpreter execution routines. * * The routines that begin execution of AML opcodes are named with a common * convention based upon the number of arguments, the number of target operands, * and whether or not a value is returned: * *      AcpiExOpcode_xA_yT_zR * * Where: * * xA - ARGUMENTS:    The number of arguments (input operands) that are *                    required for this opcode type (0 through 6 args). * yT - TARGETS:      The number of targets (output operands) that are required *                    for this opcode type (0, 1, or 2 targets). * zR - RETURN VALUE: Indicates whether this opcode type returns a value *                    as the function return (0 or 1). * * The AcpiExOpcode* functions are called via the Dispatcher component with * fully resolved operands.!*//******************************************************************************* * * FUNCTION:    acpi_ex_opcode_0A_0T_1R * * PARAMETERS:  walk_state          - Current state (contains AML opcode) * * RETURN:      Status * * DESCRIPTION: Execute operator with no operands, one return value * ******************************************************************************/acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state){	acpi_status status = AE_OK;	union acpi_operand_object *return_desc = NULL;	ACPI_FUNCTION_TRACE_STR("ex_opcode_0A_0T_1R",				acpi_ps_get_opcode_name(walk_state->opcode));	/* Examine the AML opcode */	switch (walk_state->opcode) {	case AML_TIMER_OP:	/*  Timer () */		/* Create a return object of type Integer */		return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);		if (!return_desc) {			status = AE_NO_MEMORY;			goto cleanup;		}#if ACPI_MACHINE_WIDTH != 16		return_desc->integer.value = acpi_os_get_timer();#endif		break;	default:		/*  Unknown opcode  */		ACPI_REPORT_ERROR(("acpi_ex_opcode_0A_0T_1R: Unknown opcode %X\n", walk_state->opcode));		status = AE_AML_BAD_OPCODE;		break;	}      cleanup:	/* Delete return object on error */	if ((ACPI_FAILURE(status)) || walk_state->result_obj) {		acpi_ut_remove_reference(return_desc);	} else {		/* Save the return value */		walk_state->result_obj = return_desc;	}	return_ACPI_STATUS(status);}/******************************************************************************* * * FUNCTION:    acpi_ex_opcode_1A_0T_0R * * PARAMETERS:  walk_state          - Current state (contains AML opcode) * * RETURN:      Status * * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on *              object stack * ******************************************************************************/acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state){	union acpi_operand_object **operand = &walk_state->operands[0];	acpi_status status = AE_OK;	ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_0T_0R",				acpi_ps_get_opcode_name(walk_state->opcode));	/* Examine the AML opcode */	switch (walk_state->opcode) {	case AML_RELEASE_OP:	/*  Release (mutex_object) */		status = acpi_ex_release_mutex(operand[0], walk_state);		break;	case AML_RESET_OP:	/*  Reset (event_object) */		status = acpi_ex_system_reset_event(operand[0]);		break;	case AML_SIGNAL_OP:	/*  Signal (event_object) */		status = acpi_ex_system_signal_event(operand[0]);		break;	case AML_SLEEP_OP:	/*  Sleep (msec_time) */		status = acpi_ex_system_do_suspend(operand[0]->integer.value);		break;	case AML_STALL_OP:	/*  Stall (usec_time) */		status =		    acpi_ex_system_do_stall((u32) operand[0]->integer.value);		break;	case AML_UNLOAD_OP:	/*  Unload (Handle) */		status = acpi_ex_unload_table(operand[0]);		break;	default:		/*  Unknown opcode  */		ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n", walk_state->opcode));		status = AE_AML_BAD_OPCODE;		break;	}	return_ACPI_STATUS(status);}/******************************************************************************* * * FUNCTION:    acpi_ex_opcode_1A_1T_0R * * PARAMETERS:  walk_state          - Current state (contains AML opcode) * * RETURN:      Status * * DESCRIPTION: Execute opcode with one argument, one target, and no *              return value. * ******************************************************************************/acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state){	acpi_status status = AE_OK;	union acpi_operand_object **operand = &walk_state->operands[0];	ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_1T_0R",				acpi_ps_get_opcode_name(walk_state->opcode));	/* Examine the AML opcode */	switch (walk_state->opcode) {	case AML_LOAD_OP:		status = acpi_ex_load_op(operand[0], operand[1], walk_state);		break;	default:		/* Unknown opcode */		ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n", walk_state->opcode));		status = AE_AML_BAD_OPCODE;		goto cleanup;	}      cleanup:	return_ACPI_STATUS(status);}/******************************************************************************* * * FUNCTION:    acpi_ex_opcode_1A_1T_1R * * PARAMETERS:  walk_state          - Current state (contains AML opcode) * * RETURN:      Status * * DESCRIPTION: Execute opcode with one argument, one target, and a *              return value. * ******************************************************************************/acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state){	acpi_status status = AE_OK;	union acpi_operand_object **operand = &walk_state->operands[0];	union acpi_operand_object *return_desc = NULL;	union acpi_operand_object *return_desc2 = NULL;	u32 temp32;	u32 i;	acpi_integer power_of_ten;	acpi_integer digit;	ACPI_FUNCTION_TRACE_STR("ex_opcode_1A_1T_1R",				acpi_ps_get_opcode_name(walk_state->opcode));	/* Examine the AML opcode */	switch (walk_state->opcode) {	case AML_BIT_NOT_OP:	case AML_FIND_SET_LEFT_BIT_OP:	case AML_FIND_SET_RIGHT_BIT_OP:	case AML_FROM_BCD_OP:	case AML_TO_BCD_OP:	case AML_COND_REF_OF_OP:		/* Create a return object of type Integer for these opcodes */		return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);		if (!return_desc) {			status = AE_NO_MEMORY;			goto cleanup;		}		switch (walk_state->opcode) {		case AML_BIT_NOT_OP:	/* Not (Operand, Result)  */			return_desc->integer.value = ~operand[0]->integer.value;			break;		case AML_FIND_SET_LEFT_BIT_OP:	/* find_set_left_bit (Operand, Result) */			return_desc->integer.value = operand[0]->integer.value;			/*			 * Acpi specification describes Integer type as a little			 * endian unsigned value, so this boundary condition is valid.			 */			for (temp32 = 0; return_desc->integer.value &&			     temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {				return_desc->integer.value >>= 1;			}			return_desc->integer.value = temp32;			break;		case AML_FIND_SET_RIGHT_BIT_OP:	/* find_set_right_bit (Operand, Result) */			return_desc->integer.value = operand[0]->integer.value;			/*			 * The Acpi specification describes Integer type as a little			 * endian unsigned value, so this boundary condition is valid.			 */			for (temp32 = 0; return_desc->integer.value &&			     temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {				return_desc->integer.value <<= 1;			}			/* Since the bit position is one-based, subtract from 33 (65) */			return_desc->integer.value = temp32 == 0 ? 0 :			    (ACPI_INTEGER_BIT_SIZE + 1) - temp32;			break;		case AML_FROM_BCD_OP:	/* from_bcd (BCDValue, Result) */			/*			 * The 64-bit ACPI integer can hold 16 4-bit BCD characters			 * (if table is 32-bit, integer can hold 8 BCD characters)			 * Convert each 4-bit BCD value			 */			power_of_ten = 1;			return_desc->integer.value = 0;			digit = operand[0]->integer.value;			/* Convert each BCD digit (each is one nybble wide) */			for (i = 0;			     (i < acpi_gbl_integer_nybble_width) && (digit > 0);			     i++) {				/* Get the least significant 4-bit BCD digit */				temp32 = ((u32) digit) & 0xF;				/* Check the range of the digit */				if (temp32 > 9) {					ACPI_DEBUG_PRINT((ACPI_DB_ERROR,							  "BCD digit too large (not decimal): 0x%X\n",							  temp32));					status = AE_AML_NUMERIC_OVERFLOW;					goto cleanup;				}				/* Sum the digit into the result with the current power of 10 */				return_desc->integer.value +=				    (((acpi_integer) temp32) * power_of_ten);				/* Shift to next BCD digit */				digit >>= 4;				/* Next power of 10 */				power_of_ten *= 10;			}			break;		case AML_TO_BCD_OP:	/* to_bcd (Operand, Result) */			return_desc->integer.value = 0;			digit = operand[0]->integer.value;			/* Each BCD digit is one nybble wide */			for (i = 0;			     (i < acpi_gbl_integer_nybble_width) && (digit > 0);			     i++) {				(void)acpi_ut_short_divide(digit, 10, &digit,							   &temp32);				/*				 * Insert the BCD digit that resides in the				 * remainder from above				 */				return_desc->integer.value |=				    (((acpi_integer) temp32) << ACPI_MUL_4(i));			}			/* Overflow if there is any data left in Digit */			if (digit > 0) {				ACPI_DEBUG_PRINT((ACPI_DB_ERROR,						  "Integer too large to convert to BCD: %8.8X%8.8X\n",						  ACPI_FORMAT_UINT64(operand								     [0]->								     integer.								     value)));				status = AE_AML_NUMERIC_OVERFLOW;				goto cleanup;			}			break;		case AML_COND_REF_OF_OP:	/* cond_ref_of (source_object, Result) */			/*			 * This op is a little strange because the internal return value is			 * different than the return value stored in the result descriptor			 * (There are really two return values)			 */			if ((struct acpi_namespace_node *)operand[0] ==			    acpi_gbl_root_node) {				/*				 * This means that the object does not exist in the namespace,				 * return FALSE				 */				return_desc->integer.value = 0;				goto cleanup;			}			/* Get the object reference, store it, and remove our reference */			status = acpi_ex_get_object_reference(operand[0],							      &return_desc2,							      walk_state);			if (ACPI_FAILURE(status)) {				goto cleanup;			}			status =			    acpi_ex_store(return_desc2, operand[1], walk_state);			acpi_ut_remove_reference(return_desc2);			/* The object exists in the namespace, return TRUE */			return_desc->integer.value = ACPI_INTEGER_MAX;			goto cleanup;		default:			/* No other opcodes get here */			break;		}		break;	case AML_STORE_OP:	/* Store (Source, Target) */		/*		 * A store operand is typically a number, string, buffer or lvalue		 * Be careful about deleting the source object,		 * since the object itself may have been stored.		 */		status = acpi_ex_store(operand[0], operand[1], walk_state);		if (ACPI_FAILURE(status)) {			return_ACPI_STATUS(status);		}		/* It is possible that the Store already produced a return object */		if (!walk_state->result_obj) {			/*			 * Normally, we would remove a reference on the Operand[0]			 * parameter; But since it is being used as the internal return			 * object (meaning we would normally increment it), the two			 * cancel out, and we simply don't do anything.			 */			walk_state->result_obj = operand[0];			walk_state->operands[0] = NULL;	/* Prevent deletion */		}		return_ACPI_STATUS(status);		/*		 * ACPI 2.0 Opcodes		 */	case AML_COPY_OP:	/* Copy (Source, Target) */		status =		    acpi_ut_copy_iobject_to_iobject(operand[0], &return_desc,						    walk_state);		break;	case AML_TO_DECSTRING_OP:	/* to_decimal_string (Data, Result) */		status = acpi_ex_convert_to_string(operand[0], &return_desc,						   ACPI_EXPLICIT_CONVERT_DECIMAL);		if (return_desc == operand[0]) {			/* No conversion performed, add ref to handle return value */			acpi_ut_add_reference(return_desc);		}		break;	case AML_TO_HEXSTRING_OP:	/* to_hex_string (Data, Result) */		status = acpi_ex_convert_to_string(operand[0], &return_desc,						   ACPI_EXPLICIT_CONVERT_HEX);		if (return_desc == operand[0]) {			/* No conversion performed, add ref to handle return value */			acpi_ut_add_reference(return_desc);		}		break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -