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

📄 exoparg1.c

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** * * Module Name: exoparg1 - AML execution - opcodes with 1 argument *              $Revision: 120 $ * *****************************************************************************//* *  Copyright (C) 2000, 2001 R. Byron Moore * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#include "acpi.h"#include "acparser.h"#include "acdispat.h"#include "acinterp.h"#include "amlcode.h"#include "acnamesp.h"#define _COMPONENT          ACPI_EXECUTER	 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 (1 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_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_statusacpi_ex_opcode_1A_0T_0R (	acpi_walk_state         *walk_state){	acpi_operand_object     **operand = &walk_state->operands[0];	acpi_status             status = AE_OK;	FUNCTION_TRACE_STR ("Ex_opcode_1A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));	/* Examine the 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) */		acpi_ex_system_do_suspend ((u32) operand[0]->integer.value);		break;	case AML_STALL_OP:      /*  Stall (Usec_time) */		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  */		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_statusacpi_ex_opcode_1A_1T_0R (	acpi_walk_state         *walk_state){	acpi_status             status = AE_OK;	acpi_operand_object     **operand = &walk_state->operands[0];	FUNCTION_TRACE_STR ("Ex_opcode_1A_1T_0R", acpi_ps_get_opcode_name (walk_state->opcode));	switch (walk_state->opcode) {	case AML_LOAD_OP:		status = acpi_ex_load_op (operand[0], operand[1]);		break;	default:                        /* Unknown opcode */		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_statusacpi_ex_opcode_1A_1T_1R (	acpi_walk_state         *walk_state){	acpi_status             status = AE_OK;	acpi_operand_object     **operand = &walk_state->operands[0];	acpi_operand_object     *return_desc = NULL;	acpi_operand_object     *return_desc2 = NULL;	u32                     temp32;	u32                     i;	u32                     j;	acpi_integer            digit;	FUNCTION_TRACE_STR ("Ex_opcode_1A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));	/* Create a return object of type Integer for most opcodes */	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:		return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);		if (!return_desc) {			status = AE_NO_MEMORY;			goto cleanup;		}		break;	}	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 integers		 */		return_desc->integer.value = 0;		for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++) {			/* Get one BCD digit */			digit = (acpi_integer) ((operand[0]->integer.value >> (i * 4)) & 0xF);			/* Check the range of the digit */			if (digit > 9) {				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD digit too large: %d\n",					(u32) digit));				status = AE_AML_NUMERIC_OVERFLOW;				goto cleanup;			}			if (digit > 0) {				/* Sum into the result with the appropriate power of 10 */				for (j = 0; j < i; j++) {					digit *= 10;				}				return_desc->integer.value += digit;			}		}		break;	case AML_TO_BCD_OP:             /* To_bcd (Operand, Result) */		if (operand[0]->integer.value > ACPI_MAX_BCD_VALUE) {			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD overflow: %8.8X%8.8X\n",				HIDWORD(operand[0]->integer.value), LODWORD(operand[0]->integer.value)));			status = AE_AML_NUMERIC_OVERFLOW;			goto cleanup;		}		return_desc->integer.value = 0;		for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++) {			/* Divide by nth factor of 10 */			temp32 = 0;			digit = operand[0]->integer.value;			for (j = 0; j < i; j++) {				acpi_ut_short_divide (&digit, 10, &digit, &temp32);			}			/* Create the BCD digit from the remainder above */			if (digit > 0) {				return_desc->integer.value += (temp32 << (i * 4));			}		}		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 ((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;			/*			 * Must delete the result descriptor since there is no reference			 * being returned			 */			acpi_ut_remove_reference (operand[1]);			goto cleanup;		}		/* Get the object reference and store it */		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);		/* The object exists in the namespace, return TRUE */		return_desc->integer.value = ACPI_INTEGER_MAX;		goto cleanup;		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);		}		/*		 * 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);		break;	/*	 * ACPI 2.0 Opcodes	 */	case AML_COPY_OP:               /* Copy (Source, Target) */		status = AE_NOT_IMPLEMENTED;		goto cleanup;		break;	case AML_TO_DECSTRING_OP:       /* To_decimal_string (Data, Result) */		status = acpi_ex_convert_to_string (operand[0], &return_desc, 10, ACPI_UINT32_MAX, walk_state);		break;	case AML_TO_HEXSTRING_OP:       /* To_hex_string (Data, Result) */		status = acpi_ex_convert_to_string (operand[0], &return_desc, 16, ACPI_UINT32_MAX, walk_state);		break;	case AML_TO_BUFFER_OP:          /* To_buffer (Data, Result) */		status = acpi_ex_convert_to_buffer (operand[0], &return_desc, walk_state);		break;	case AML_TO_INTEGER_OP:         /* To_integer (Data, Result) */		status = acpi_ex_convert_to_integer (operand[0], &return_desc, walk_state);		break;	/*	 * These are two obsolete opcodes	 */	case AML_SHIFT_LEFT_BIT_OP:     /*  Shift_left_bit (Source, Bit_num) */	case AML_SHIFT_RIGHT_BIT_OP:    /*  Shift_right_bit (Source, Bit_num) */

⌨️ 快捷键说明

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