dsmthdat.c
来自「是关于linux2.5.1的完全源码」· C语言 代码 · 共 626 行 · 第 1/2 页
C
626 行
/******************************************************************************* * * Module Name: dsmthdat - control method arguments and local variables * $Revision: 59 $ * ******************************************************************************//* * 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 "acparser.h"#include "acdispat.h"#include "acinterp.h"#include "amlcode.h"#include "acnamesp.h"#define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsmthdat")/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_init * * PARAMETERS: Walk_state - Current walk state object * * RETURN: Status * * DESCRIPTION: Initialize the data structures that hold the method's arguments * and locals. The data struct is an array of NTEs for each. * This allows Ref_of and De_ref_of to work properly for these * special data types. * * NOTES: Walk_state fields are initialized to zero by the * ACPI_MEM_CALLOCATE(). * * A pseudo-Namespace Node is assigned to each argument and local * so that Ref_of() can return a pointer to the Node. * ******************************************************************************/acpi_statusacpi_ds_method_data_init ( acpi_walk_state *walk_state){ u32 i; ACPI_FUNCTION_TRACE ("Ds_method_data_init"); /* Init the method arguments */ for (i = 0; i < MTH_NUM_ARGS; i++) { ACPI_MOVE_UNALIGNED32_TO_32 (&walk_state->arguments[i].name, NAMEOF_ARG_NTE); walk_state->arguments[i].name.integer |= (i << 24); walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED; walk_state->arguments[i].type = ACPI_TYPE_ANY; walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; } /* Init the method locals */ for (i = 0; i < MTH_NUM_LOCALS; i++) { ACPI_MOVE_UNALIGNED32_TO_32 (&walk_state->local_variables[i].name, NAMEOF_LOCAL_NTE); walk_state->local_variables[i].name.integer |= (i << 24); walk_state->local_variables[i].descriptor = ACPI_DESC_TYPE_NAMED; walk_state->local_variables[i].type = ACPI_TYPE_ANY; walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; } return_ACPI_STATUS (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_delete_all * * PARAMETERS: Walk_state - Current walk state object * * RETURN: Status * * DESCRIPTION: Delete method locals and arguments. Arguments are only * deleted if this method was called from another method. * ******************************************************************************/acpi_statusacpi_ds_method_data_delete_all ( acpi_walk_state *walk_state){ u32 index; ACPI_FUNCTION_TRACE ("Ds_method_data_delete_all"); /* Detach the locals */ for (index = 0; index < MTH_NUM_LOCALS; index++) { if (walk_state->local_variables[index].object) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", index, walk_state->local_variables[index].object)); /* Detach object (if present) and remove a reference */ acpi_ns_detach_object (&walk_state->local_variables[index]); } } /* Detach the arguments */ for (index = 0; index < MTH_NUM_ARGS; index++) { if (walk_state->arguments[index].object) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", index, walk_state->arguments[index].object)); /* Detach object (if present) and remove a reference */ acpi_ns_detach_object (&walk_state->arguments[index]); } } return_ACPI_STATUS (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_init_args * * PARAMETERS: *Params - Pointer to a parameter list for the method * Max_param_count - The arg count for this method * Walk_state - Current walk state object * * RETURN: Status * * DESCRIPTION: Initialize arguments for a method. The parameter list is a list * of ACPI operand objects, either null terminated or whose length * is defined by Max_param_count. * ******************************************************************************/acpi_statusacpi_ds_method_data_init_args ( acpi_operand_object **params, u32 max_param_count, acpi_walk_state *walk_state){ acpi_status status; u32 index = 0; ACPI_FUNCTION_TRACE_PTR ("Ds_method_data_init_args", params); if (!params) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); return_ACPI_STATUS (AE_OK); } /* Copy passed parameters into the new method stack frame */ while ((index < MTH_NUM_ARGS) && (index < max_param_count) && params[index]) { /* * A valid parameter. * Store the argument in the method/walk descriptor */ status = acpi_ds_store_object_to_local (AML_ARG_OP, index, params[index], walk_state); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } index++; } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", index)); return_ACPI_STATUS (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_get_node * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which local_var or argument whose type * to get * Walk_state - Current walk state object * * RETURN: Get the Node associated with a local or arg. * ******************************************************************************/acpi_statusacpi_ds_method_data_get_node ( u16 opcode, u32 index, acpi_walk_state *walk_state, acpi_namespace_node **node){ ACPI_FUNCTION_TRACE ("Ds_method_data_get_node"); /* * Method Locals and Arguments are supported */ switch (opcode) { case AML_LOCAL_OP: if (index > MTH_MAX_LOCAL) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n", index, MTH_MAX_LOCAL)); return_ACPI_STATUS (AE_AML_INVALID_INDEX); } /* Return a pointer to the pseudo-node */ *node = &walk_state->local_variables[index]; break; case AML_ARG_OP: if (index > MTH_MAX_ARG) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", index, MTH_MAX_ARG)); return_ACPI_STATUS (AE_AML_INVALID_INDEX); } /* Return a pointer to the pseudo-node */ *node = &walk_state->arguments[index]; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", opcode)); return_ACPI_STATUS (AE_AML_BAD_OPCODE); } return_ACPI_STATUS (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_set_value * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which local_var or argument to get * Object - Object to be inserted into the stack entry * Walk_state - Current walk state object * * RETURN: Status * * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. * ******************************************************************************/acpi_statusacpi_ds_method_data_set_value ( u16 opcode, u32 index, acpi_operand_object *object, acpi_walk_state *walk_state){ acpi_status status; acpi_namespace_node *node; ACPI_FUNCTION_TRACE ("Ds_method_data_set_value"); /* Get the namespace node for the arg/local */ status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* Increment ref count so object can't be deleted while installed */ acpi_ut_add_reference (object); /* Install the object into the stack entry */ node->object = object; return_ACPI_STATUS (AE_OK);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?