dsfield.c

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

C
563
字号
/****************************************************************************** * * Module Name: dsfield - Dispatcher field routines *              $Revision: 62 $ * *****************************************************************************//* *  Copyright (C) 2000 - 2002, 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 "amlcode.h"#include "acdispat.h"#include "acinterp.h"#include "acnamesp.h"#include "acparser.h"#define _COMPONENT          ACPI_DISPATCHER	 ACPI_MODULE_NAME    ("dsfield")/******************************************************************************* * * FUNCTION:    Acpi_ds_create_buffer_field * * PARAMETERS:  Opcode              - The opcode to be executed *              Operands            - List of operands for the opcode *              Walk_state          - Current state * * RETURN:      Status * * DESCRIPTION: Execute the Create_field operators: *              Create_bit_field_op, *              Create_byte_field_op, *              Create_word_field_op, *              Create_dWord_field_op, *              Create_qWord_field_op, *              Create_field_op     (all of which define fields in buffers) * ******************************************************************************/acpi_statusacpi_ds_create_buffer_field (	acpi_parse_object       *op,	acpi_walk_state         *walk_state){	acpi_parse_object       *arg;	acpi_namespace_node     *node;	acpi_status             status;	acpi_operand_object     *obj_desc;	acpi_operand_object     *second_desc = NULL;	u32                     flags;	ACPI_FUNCTION_TRACE ("Ds_create_buffer_field");	/* Get the Name_string argument */	if (op->opcode == AML_CREATE_FIELD_OP) {		arg = acpi_ps_get_arg (op, 3);	}	else {		/* Create Bit/Byte/Word/Dword field */		arg = acpi_ps_get_arg (op, 2);	}	if (!arg) {		return_ACPI_STATUS (AE_AML_NO_OPERAND);	}	/*	 * During the load phase, we want to enter the name of the field into	 * the namespace.  During the execute phase (when we evaluate the size	 * operand), we want to lookup the name	 */	if (walk_state->parse_flags & ACPI_PARSE_EXECUTE) {		flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE;	}	else {		flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND;	}	/*	 * Enter the Name_string into the namespace	 */	status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,			 INTERNAL_TYPE_DEF_ANY, ACPI_IMODE_LOAD_PASS1,			 flags, walk_state, &(node));	if (ACPI_FAILURE (status)) {		return_ACPI_STATUS (status);	}	/* We could put the returned object (Node) on the object stack for later, but	 * for now, we will put it in the "op" object that the parser uses, so we	 * can get it again at the end of this scope	 */	op->node = node;	/*	 * If there is no object attached to the node, this node was just created and	 * we need to create the field object.  Otherwise, this was a lookup of an	 * existing node and we don't want to create the field object again.	 */	obj_desc = acpi_ns_get_attached_object (node);	if (obj_desc) {		return_ACPI_STATUS (AE_OK);	}	/*	 * The Field definition is not fully parsed at this time.	 * (We must save the address of the AML for the buffer and index operands)	 */	/* Create the buffer field object */	obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER_FIELD);	if (!obj_desc) {		status = AE_NO_MEMORY;		goto cleanup;	}	/*	 * Remember location in AML stream of the field unit	 * opcode and operands -- since the buffer and index	 * operands must be evaluated.	 */	second_desc                 = obj_desc->common.next_object;	second_desc->extra.aml_start = ((acpi_parse2_object *) op)->data;	second_desc->extra.aml_length = ((acpi_parse2_object *) op)->length;	obj_desc->buffer_field.node = node;	/* Attach constructed field descriptors to parent node */	status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_BUFFER_FIELD);	if (ACPI_FAILURE (status)) {		goto cleanup;	}cleanup:	/* Remove local reference to the object */	acpi_ut_remove_reference (obj_desc);	return_ACPI_STATUS (status);}/******************************************************************************* * * FUNCTION:    Acpi_ds_get_field_names * * PARAMETERS:  Info            - Create_field info structure *  `           Walk_state      - Current method state *              Arg             - First parser arg for the field name list * * RETURN:      Status * * DESCRIPTION: Process all named fields in a field declaration.  Names are *              entered into the namespace. * ******************************************************************************/acpi_statusacpi_ds_get_field_names (	ACPI_CREATE_FIELD_INFO  *info,	acpi_walk_state         *walk_state,	acpi_parse_object       *arg){	acpi_status             status;	ACPI_FUNCTION_TRACE_PTR ("Ds_get_field_names", info);	/* First field starts at bit zero */	info->field_bit_position = 0;	/* Process all elements in the field list (of parse nodes) */	while (arg) {		/*		 * Three types of field elements are handled:		 * 1) Offset - specifies a bit offset		 * 2) Access_as - changes the access mode		 * 3) Name - Enters a new named field into the namespace		 */		switch (arg->opcode) {		case AML_INT_RESERVEDFIELD_OP:			if (((acpi_integer) info->field_bit_position + arg->value.size) >				ACPI_UINT32_MAX) {				ACPI_REPORT_ERROR (("Bit offset within field too large (> 0xFFFFFFFF)\n"));				return_ACPI_STATUS (AE_SUPPORT);			}			info->field_bit_position += arg->value.size;			break;		case AML_INT_ACCESSFIELD_OP:			/*			 * Get a new Access_type and Access_attribute -- to be used for all			 * field units that follow, until field end or another Access_as keyword.			 *			 * In Field_flags, preserve the flag bits other than the ACCESS_TYPE bits			 */			info->field_flags = (u8) ((info->field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |					  ((u8) (arg->value.integer32 >> 8)));			info->attribute = (u8) (arg->value.integer32);			break;		case AML_INT_NAMEDFIELD_OP:			/* Lookup the name */			status = acpi_ns_lookup (walk_state->scope_info,					  (NATIVE_CHAR *) &((acpi_parse2_object *)arg)->name,					  info->field_type, ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,					  walk_state, &info->field_node);			if (ACPI_FAILURE (status)) {				if (status != AE_ALREADY_EXISTS) {					return_ACPI_STATUS (status);				}				ACPI_REPORT_ERROR (("Field name [%4.4s] already exists in current scope\n",						  &((acpi_parse2_object *)arg)->name));			}			else {				arg->node = info->field_node;				info->field_bit_length = arg->value.size;				/* Create and initialize an object for the new Field Node */				status = acpi_ex_prep_field_value (info);				if (ACPI_FAILURE (status)) {					return_ACPI_STATUS (status);				}			}			/* Keep track of bit position for the next field */			if (((acpi_integer) info->field_bit_position + arg->value.size) >				ACPI_UINT32_MAX) {				ACPI_REPORT_ERROR (("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n",					&info->field_node->name));				return_ACPI_STATUS (AE_SUPPORT);			}			info->field_bit_position += info->field_bit_length;			break;		default:			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid opcode in field list: %X\n",				arg->opcode));			return_ACPI_STATUS (AE_AML_ERROR);		}

⌨️ 快捷键说明

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