📄 dswstate.c
字号:
/****************************************************************************** * * Module Name: dswstate - Dispatcher parse tree walk management routines * $Revision: 36 $ * *****************************************************************************//* * Copyright (C) 2000 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 "acparser.h"#include "acdispat.h"#include "acnamesp.h"#include "acinterp.h"#define _COMPONENT DISPATCHER MODULE_NAME ("dswstate")/******************************************************************************* * * FUNCTION: Acpi_ds_result_stack_clear * * PARAMETERS: Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Reset this walk's result stack pointers to zero, thus setting * the stack to zero. * ******************************************************************************/ACPI_STATUSxxx_acpi_ds_result_stack_clear ( ACPI_WALK_STATE *walk_state){/* Walk_state->Num_results = 0; Walk_state->Current_result = 0;*/ return (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_ds_result_insert * * PARAMETERS: Object - Object to push * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Push an object onto this walk's result stack * ******************************************************************************/ACPI_STATUSacpi_ds_result_insert ( void *object, u32 index, ACPI_WALK_STATE *walk_state){ ACPI_GENERIC_STATE *state; state = walk_state->results; if (!state) { return (AE_NOT_EXIST); } if (index >= OBJ_NUM_OPERANDS) { return (AE_BAD_PARAMETER); } if (!object) { return (AE_BAD_PARAMETER); } state->results.obj_desc [index] = object; state->results.num_results++; return (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_ds_result_remove * * PARAMETERS: Object - Where to return the popped object * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In * other words, this is a FIFO. * ******************************************************************************/ACPI_STATUSacpi_ds_result_remove ( ACPI_OPERAND_OBJECT **object, u32 index, ACPI_WALK_STATE *walk_state){ ACPI_GENERIC_STATE *state; state = walk_state->results; if (!state) { return (AE_NOT_EXIST); } /* Check for a valid result object */ if (!state->results.obj_desc [index]) { return (AE_AML_NO_OPERAND); } /* Remove the object */ state->results.num_results--; *object = state->results.obj_desc [index]; state->results.obj_desc [index] = NULL; return (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_ds_result_pop * * PARAMETERS: Object - Where to return the popped object * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In * other words, this is a FIFO. * ******************************************************************************/ACPI_STATUSacpi_ds_result_pop ( ACPI_OPERAND_OBJECT **object, ACPI_WALK_STATE *walk_state){ u32 index; ACPI_GENERIC_STATE *state; state = walk_state->results; if (!state) { return (AE_OK); } if (!state->results.num_results) { return (AE_STACK_UNDERFLOW); } /* Remove top element */ state->results.num_results--; for (index = OBJ_NUM_OPERANDS; index; index--) { /* Check for a valid result object */ if (state->results.obj_desc [index -1]) { *object = state->results.obj_desc [index -1]; state->results.obj_desc [index -1] = NULL; return (AE_OK); } } return (AE_STACK_UNDERFLOW);}/******************************************************************************* * * FUNCTION: Acpi_ds_result_pop * * PARAMETERS: Object - Where to return the popped object * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In * other words, this is a FIFO. * ******************************************************************************/ACPI_STATUSacpi_ds_result_pop_from_bottom ( ACPI_OPERAND_OBJECT **object, ACPI_WALK_STATE *walk_state){ u32 index; ACPI_GENERIC_STATE *state; state = walk_state->results; if (!state) { return (AE_NOT_EXIST); } if (!state->results.num_results) { return (AE_STACK_UNDERFLOW); } /* Remove Bottom element */ *object = state->results.obj_desc [0]; /* Push entire stack down one element */ for (index = 0; index < state->results.num_results; index++) { state->results.obj_desc [index] = state->results.obj_desc [index + 1]; } state->results.num_results--; /* Check for a valid result object */ if (!*object) { return (AE_AML_NO_OPERAND); } return (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_ds_result_pop * * PARAMETERS: Object - Where to return the popped object * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In * other words, this is a FIFO. * ******************************************************************************/ACPI_STATUSacpi_ds_result_push ( ACPI_OPERAND_OBJECT *object, ACPI_WALK_STATE *walk_state){ ACPI_GENERIC_STATE *state; state = walk_state->results; if (!state) { return (AE_OK); } if (state->results.num_results == OBJ_NUM_OPERANDS) { return (AE_STACK_OVERFLOW); } if (!object) { return (AE_BAD_PARAMETER); } state->results.obj_desc [state->results.num_results] = object; state->results.num_results++; return (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_ds_result_stack_push * * PARAMETERS: Object - Object to push * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: * ******************************************************************************/ACPI_STATUSacpi_ds_result_stack_push ( ACPI_WALK_STATE *walk_state){ ACPI_GENERIC_STATE *state; state = acpi_cm_create_generic_state (); if (!state) { return (AE_NO_MEMORY); } acpi_cm_push_generic_state (&walk_state->results, state); return (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_ds_result_stack_pop * * PARAMETERS: Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: * ******************************************************************************/ACPI_STATUSacpi_ds_result_stack_pop ( ACPI_WALK_STATE *walk_state){ ACPI_GENERIC_STATE *state; /* Check for stack underflow */ if (walk_state->results == NULL) { return (AE_AML_NO_OPERAND); } state = acpi_cm_pop_generic_state (&walk_state->results); acpi_cm_delete_generic_state (state); return (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_ds_obj_stack_delete_all * * PARAMETERS: Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Clear the object stack by deleting all objects that are on it. * Should be used with great care, if at all! * ******************************************************************************/ACPI_STATUSacpi_ds_obj_stack_delete_all ( ACPI_WALK_STATE *walk_state){ u32 i; /* The stack size is configurable, but fixed */ for (i = 0; i < OBJ_NUM_OPERANDS; i++) { if (walk_state->operands[i]) { acpi_cm_remove_reference (walk_state->operands[i]); walk_state->operands[i] = NULL; } } return (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_ds_obj_stack_push * * PARAMETERS: Object - Object to push * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Push an object onto this walk's object/operand stack * ******************************************************************************/ACPI_STATUSacpi_ds_obj_stack_push ( void *object, ACPI_WALK_STATE *walk_state){ /* Check for stack overflow */ if (walk_state->num_operands >= OBJ_NUM_OPERANDS) { return (AE_STACK_OVERFLOW); } /* Put the object onto the stack */ walk_state->operands [walk_state->num_operands] = object; walk_state->num_operands++; return (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_ds_obj_stack_pop_object * * PARAMETERS: Pop_count - Number of objects/entries to pop * Walk_state - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT * deleted by this routine.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -