1 /******************************************************************************
3 * Module Name: dswscope - Scope stack manipulation
6 *****************************************************************************/
9 * Copyright (C) 2000, 2001 R. Byron Moore
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #define _COMPONENT ACPI_DISPATCHER
33 MODULE_NAME ("dswscope")
36 #define STACK_POP(head) head
39 /****************************************************************************
41 * FUNCTION: Acpi_ds_scope_stack_clear
45 * DESCRIPTION: Pop (and free) everything on the scope stack except the
46 * root scope object (which remains at the stack top.)
48 ***************************************************************************/
51 acpi_ds_scope_stack_clear (
52 ACPI_WALK_STATE *walk_state)
54 ACPI_GENERIC_STATE *scope_info;
57 while (walk_state->scope_info) {
58 /* Pop a scope off the stack */
60 scope_info = walk_state->scope_info;
61 walk_state->scope_info = scope_info->scope.next;
63 acpi_cm_delete_generic_state (scope_info);
68 /****************************************************************************
70 * FUNCTION: Acpi_ds_scope_stack_push
72 * PARAMETERS: *Node, - Name to be made current
73 * Type, - Type of frame being pushed
75 * DESCRIPTION: Push the current scope on the scope stack, and make the
76 * passed Node current.
78 ***************************************************************************/
81 acpi_ds_scope_stack_push (
82 ACPI_NAMESPACE_NODE *node,
83 OBJECT_TYPE_INTERNAL type,
84 ACPI_WALK_STATE *walk_state)
86 ACPI_GENERIC_STATE *scope_info;
92 REPORT_ERROR (("Ds_scope_stack_push: null scope passed\n"));
93 return (AE_BAD_PARAMETER);
96 /* Make sure object type is valid */
98 if (!acpi_aml_validate_object_type (type)) {
99 REPORT_WARNING (("Ds_scope_stack_push: type code out of range\n"));
103 /* Allocate a new scope object */
105 scope_info = acpi_cm_create_generic_state ();
107 return (AE_NO_MEMORY);
110 /* Init new scope object */
112 scope_info->scope.node = node;
113 scope_info->common.value = (u16) type;
115 /* Push new scope object onto stack */
117 acpi_cm_push_generic_state (&walk_state->scope_info, scope_info);
123 /****************************************************************************
125 * FUNCTION: Acpi_ds_scope_stack_pop
127 * PARAMETERS: Type - The type of frame to be found
129 * DESCRIPTION: Pop the scope stack until a frame of the requested type
132 * RETURN: Count of frames popped. If no frame of the requested type
133 * was found, the count is returned as a negative number and
134 * the scope stack is emptied (which sets the current scope
135 * to the root). If the scope stack was empty at entry, the
136 * function is a no-op and returns 0.
138 ***************************************************************************/
141 acpi_ds_scope_stack_pop (
142 ACPI_WALK_STATE *walk_state)
144 ACPI_GENERIC_STATE *scope_info;
148 * Pop scope info object off the stack.
151 scope_info = acpi_cm_pop_generic_state (&walk_state->scope_info);
153 return (AE_STACK_UNDERFLOW);
156 acpi_cm_delete_generic_state (scope_info);