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

📄 dsopcode.c

📁 这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自测试~但就算用来做参考资料也是非常好的
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** * * Module Name: dsopcode - Dispatcher Op Region support and handling of *                         "control" opcodes *              $Revision: 56 $ * *****************************************************************************//* *  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 "amlcode.h"#include "acdispat.h"#include "acinterp.h"#include "acnamesp.h"#include "acevents.h"#include "actables.h"#define _COMPONENT          ACPI_DISPATCHER	 MODULE_NAME         ("dsopcode")/***************************************************************************** * * FUNCTION:    Acpi_ds_get_buffer_field_arguments * * PARAMETERS:  Obj_desc        - A valid Buffer_field object * * RETURN:      Status. * * DESCRIPTION: Get Buffer_field Buffer and Index. This implements the late *              evaluation of these field attributes. * ****************************************************************************/acpi_statusacpi_ds_get_buffer_field_arguments (	acpi_operand_object     *obj_desc){	acpi_operand_object     *extra_desc;	acpi_namespace_node     *node;	acpi_parse_object       *op;	acpi_parse_object       *field_op;	acpi_status             status;	acpi_table_desc         *table_desc;	acpi_walk_state         *walk_state;	FUNCTION_TRACE_PTR ("Ds_get_buffer_field_arguments", obj_desc);	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {		return_ACPI_STATUS (AE_OK);	}	/* Get the AML pointer (method object) and Buffer_field node */	extra_desc = obj_desc->buffer_field.extra;	node = obj_desc->buffer_field.node;	DEBUG_EXEC(acpi_ut_display_init_pathname (node, " [Field]"));	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] Buffer_field JIT Init\n",		(char*)&node->name));	/*	 * Allocate a new parser op to be the root of the parsed	 * Op_region tree	 */	op = acpi_ps_alloc_op (AML_SCOPE_OP);	if (!op) {		return (AE_NO_MEMORY);	}	/* Save the Node for use in Acpi_ps_parse_aml */	op->node = acpi_ns_get_parent_object (node);	/* Get a handle to the parent ACPI table */	status = acpi_tb_handle_to_object (node->owner_id, &table_desc);	if (ACPI_FAILURE (status)) {		return_ACPI_STATUS (status);	}	/* Create and initialize a new parser state */	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,			   NULL, NULL, NULL);	if (!walk_state) {		return_ACPI_STATUS (AE_NO_MEMORY);	}	status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,			  extra_desc->extra.aml_length, NULL, NULL, 1);	if (ACPI_FAILURE (status)) {		/* TBD: delete walk state */		return_ACPI_STATUS (status);	}	/* TBD: No Walk flags?? */	walk_state->parse_flags = 0;	/* Pass1: Parse the entire Buffer_field declaration */	status = acpi_ps_parse_aml (walk_state);	if (ACPI_FAILURE (status)) {		acpi_ps_delete_parse_tree (op);		return_ACPI_STATUS (status);	}	/* Get and init the actual Field_unit Op created above */	field_op = op->value.arg;	op->node = node;	field_op = op->value.arg;	field_op->node = node;	acpi_ps_delete_parse_tree (op);	/* Evaluate the address and length arguments for the Op_region */	op = acpi_ps_alloc_op (AML_SCOPE_OP);	if (!op) {		return (AE_NO_MEMORY);	}	op->node = acpi_ns_get_parent_object (node);	/* Create and initialize a new parser state */	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,			   NULL, NULL, NULL);	if (!walk_state) {		return_ACPI_STATUS (AE_NO_MEMORY);	}	status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,			  extra_desc->extra.aml_length, NULL, NULL, 3);	if (ACPI_FAILURE (status)) {		/* TBD: delete walk state */		return_ACPI_STATUS (status);	}	status = acpi_ps_parse_aml (walk_state);	acpi_ps_delete_parse_tree (op);	/*	 * The pseudo-method object is no longer needed since the region is	 * now initialized	 */	acpi_ut_remove_reference (obj_desc->buffer_field.extra);	obj_desc->buffer_field.extra = NULL;	return_ACPI_STATUS (status);}/***************************************************************************** * * FUNCTION:    Acpi_ds_get_region_arguments * * PARAMETERS:  Obj_desc        - A valid region object * * RETURN:      Status. * * DESCRIPTION: Get region address and length.  This implements the late *              evaluation of these region attributes. * ****************************************************************************/acpi_statusacpi_ds_get_region_arguments (	acpi_operand_object     *obj_desc){	acpi_operand_object     *extra_desc = NULL;	acpi_namespace_node     *node;	acpi_parse_object       *op;	acpi_parse_object       *region_op;	acpi_status             status;	acpi_table_desc         *table_desc;	acpi_walk_state         *walk_state;	FUNCTION_TRACE_PTR ("Ds_get_region_arguments", obj_desc);	if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {		return_ACPI_STATUS (AE_OK);	}	/* Get the AML pointer (method object) and region node */	extra_desc = obj_desc->region.extra;	node = obj_desc->region.node;	DEBUG_EXEC(acpi_ut_display_init_pathname (node, " [Operation Region]"));	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] Op_region Init at AML %p\n",		(char*)&node->name, extra_desc->extra.aml_start));	/*	 * Allocate a new parser op to be the root of the parsed	 * Op_region tree	 */	op = acpi_ps_alloc_op (AML_SCOPE_OP);	if (!op) {		return (AE_NO_MEMORY);	}	/* Save the Node for use in Acpi_ps_parse_aml */	op->node = acpi_ns_get_parent_object (node);	/* Get a handle to the parent ACPI table */	status = acpi_tb_handle_to_object (node->owner_id, &table_desc);	if (ACPI_FAILURE (status)) {		return_ACPI_STATUS (status);	}	/* Create and initialize a new parser state */	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,			   op, NULL, NULL);	if (!walk_state) {		return_ACPI_STATUS (AE_NO_MEMORY);	}	status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,			  extra_desc->extra.aml_length, NULL, NULL, 1);	if (ACPI_FAILURE (status)) {		/* TBD: delete walk state */		return_ACPI_STATUS (status);	}	/* TBD: No Walk flags?? */	walk_state->parse_flags = 0;	/* Parse the entire Op_region declaration, creating a parse tree */	status = acpi_ps_parse_aml (walk_state);	if (ACPI_FAILURE (status)) {		acpi_ps_delete_parse_tree (op);		return_ACPI_STATUS (status);	}	/* Get and init the actual Region_op created above */	region_op = op->value.arg;	op->node = node;	region_op = op->value.arg;	region_op->node = node;	acpi_ps_delete_parse_tree (op);	/* Evaluate the address and length arguments for the Op_region */	op = acpi_ps_alloc_op (AML_SCOPE_OP);	if (!op) {		return (AE_NO_MEMORY);	}	op->node = acpi_ns_get_parent_object (node);	/* Create and initialize a new parser state */	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,			   op, NULL, NULL);	if (!walk_state) {		return_ACPI_STATUS (AE_NO_MEMORY);	}	status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,			  extra_desc->extra.aml_length, NULL, NULL, 3);	if (ACPI_FAILURE (status)) {		/* TBD: delete walk state */		return_ACPI_STATUS (status);	}	status = acpi_ps_parse_aml (walk_state);	acpi_ps_delete_parse_tree (op);	return_ACPI_STATUS (status);}/***************************************************************************** * * FUNCTION:    Acpi_ds_initialize_region * * PARAMETERS:  Op              - A valid region Op object * * RETURN:      Status * * DESCRIPTION: * ****************************************************************************/acpi_statusacpi_ds_initialize_region (	acpi_handle             obj_handle){	acpi_operand_object     *obj_desc;	acpi_status             status;	obj_desc = acpi_ns_get_attached_object (obj_handle);	/* Namespace is NOT locked */	status = acpi_ev_initialize_region (obj_desc, FALSE);	return (status);}/***************************************************************************** * * FUNCTION:    Acpi_ds_eval_buffer_field_operands * * PARAMETERS:  Op              - A valid Buffer_field Op object * * RETURN:      Status * * DESCRIPTION: Get Buffer_field Buffer and Index *              Called from Acpi_ds_exec_end_op during Buffer_field parse tree walk * * ACPI SPECIFICATION REFERENCES: *  Each of the Buffer Field opcodes is defined as specified in in-line *  comments below. For each one, use the following definitions. * *  Def_bit_field   :=  Bit_field_op    Src_buf Bit_idx Destination *  Def_byte_field  :=  Byte_field_op   Src_buf Byte_idx Destination *  Def_create_field := Create_field_op Src_buf Bit_idx Num_bits Name_string *  Def_dWord_field :=  DWord_field_op  Src_buf Byte_idx Destination *  Def_word_field  :=  Word_field_op   Src_buf Byte_idx Destination *  Bit_index       :=  Term_arg=>Integer *  Byte_index      :=  Term_arg=>Integer *  Destination     :=  Name_string *  Num_bits        :=  Term_arg=>Integer *  Source_buf      :=  Term_arg=>Buffer * ****************************************************************************/acpi_statusacpi_ds_eval_buffer_field_operands (	acpi_walk_state         *walk_state,	acpi_parse_object       *op){	acpi_status             status;	acpi_operand_object     *obj_desc;	acpi_namespace_node     *node;	acpi_parse_object       *next_op;	u32                     offset;	u32                     bit_offset;	u32                     bit_count;	u8                      field_flags;	acpi_operand_object     *res_desc = NULL;	acpi_operand_object     *cnt_desc = NULL;	acpi_operand_object     *off_desc = NULL;	acpi_operand_object     *src_desc = NULL;	FUNCTION_TRACE_PTR ("Ds_eval_buffer_field_operands", op);	/*	 * This is where we evaluate the address and length fields of the	 * Create_xxx_field declaration	 */	node =  op->node;	/* Next_op points to the op that holds the Buffer */	next_op = op->value.arg;	/* Acpi_evaluate/create the address and length operands */	status = acpi_ds_create_operands (walk_state, next_op);	if (ACPI_FAILURE (status)) {		return_ACPI_STATUS (status);	}	obj_desc = acpi_ns_get_attached_object (node);	if (!obj_desc) {		return_ACPI_STATUS (AE_NOT_EXIST);	}	/* Resolve the operands */	status = acpi_ex_resolve_operands (op->opcode, WALK_OPERANDS, walk_state);	DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, acpi_ps_get_opcode_name (op->opcode),			  walk_state->num_operands, "after Acpi_ex_resolve_operands");	if (ACPI_FAILURE (status)) {		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n",			acpi_ps_get_opcode_name (op->opcode), status));		goto cleanup;	}	/* Get the operands */	if (AML_CREATE_FIELD_OP == op->opcode) {		res_desc = walk_state->operands[3];		cnt_desc = walk_state->operands[2];	}	else {		res_desc = walk_state->operands[2];	}	off_desc = walk_state->operands[1];	src_desc = walk_state->operands[0];	offset = (u32) off_desc->integer.value;	/*	 * If Res_desc is a Name, it will be a direct name pointer after	 * Acpi_ex_resolve_operands()	 */	if (!VALID_DESCRIPTOR_TYPE (res_desc, ACPI_DESC_TYPE_NAMED)) {		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a Node\n",			acpi_ps_get_opcode_name (op->opcode)));		status = AE_AML_OPERAND_TYPE;		goto cleanup;	}	/*	 * Setup the Bit offsets and counts, according to the opcode	 */	switch (op->opcode) {	/* Def_create_field */	case AML_CREATE_FIELD_OP:		/* Offset is in bits, count is in bits */		bit_offset  = offset;		bit_count   = (u32) cnt_desc->integer.value;		field_flags = ACCESS_BYTE_ACC;		break;	/* Def_create_bit_field */	case AML_CREATE_BIT_FIELD_OP:		/* Offset is in bits, Field is one bit */		bit_offset  = offset;		bit_count   = 1;		field_flags = ACCESS_BYTE_ACC;		break;	/* Def_create_byte_field */	case AML_CREATE_BYTE_FIELD_OP:		/* Offset is in bytes, field is one byte */		bit_offset  = 8 * offset;		bit_count   = 8;		field_flags = ACCESS_BYTE_ACC;		break;	/* Def_create_word_field */	case AML_CREATE_WORD_FIELD_OP:		/* Offset is in bytes, field is one word */		bit_offset  = 8 * offset;		bit_count   = 16;		field_flags = ACCESS_WORD_ACC;		break;	/* Def_create_dWord_field */	case AML_CREATE_DWORD_FIELD_OP:		/* Offset is in bytes, field is one dword */		bit_offset  = 8 * offset;

⌨️ 快捷键说明

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