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
29 #define _COMPONENT ACPI_DISPATCHER
30 MODULE_NAME ("dswscope")
33 #define STACK_POP(head) head
36 /****************************************************************************
38 * FUNCTION: Acpi_ds_scope_stack_clear
42 * DESCRIPTION: Pop (and free) everything on the scope stack except the
43 * root scope object (which remains at the stack top.)
45 ***************************************************************************/
48 acpi_ds_scope_stack_clear (
49 ACPI_WALK_STATE
*walk_state
)
51 ACPI_GENERIC_STATE
*scope_info
;
54 while (walk_state
->scope_info
) {
55 /* Pop a scope off the stack */
57 scope_info
= walk_state
->scope_info
;
58 walk_state
->scope_info
= scope_info
->scope
.next
;
60 acpi_cm_delete_generic_state (scope_info
);
65 /****************************************************************************
67 * FUNCTION: Acpi_ds_scope_stack_push
69 * PARAMETERS: *Node, - Name to be made current
70 * Type, - Type of frame being pushed
72 * DESCRIPTION: Push the current scope on the scope stack, and make the
73 * passed Node current.
75 ***************************************************************************/
78 acpi_ds_scope_stack_push (
79 ACPI_NAMESPACE_NODE
*node
,
80 OBJECT_TYPE_INTERNAL type
,
81 ACPI_WALK_STATE
*walk_state
)
83 ACPI_GENERIC_STATE
*scope_info
;
89 REPORT_ERROR (("Ds_scope_stack_push: null scope passed\n"));
90 return (AE_BAD_PARAMETER
);
93 /* Make sure object type is valid */
95 if (!acpi_aml_validate_object_type (type
)) {
96 REPORT_WARNING (("Ds_scope_stack_push: type code out of range\n"));
100 /* Allocate a new scope object */
102 scope_info
= acpi_cm_create_generic_state ();
104 return (AE_NO_MEMORY
);
107 /* Init new scope object */
109 scope_info
->scope
.node
= node
;
110 scope_info
->common
.value
= (u16
) type
;
112 /* Push new scope object onto stack */
114 acpi_cm_push_generic_state (&walk_state
->scope_info
, scope_info
);
120 /****************************************************************************
122 * FUNCTION: Acpi_ds_scope_stack_pop
124 * PARAMETERS: Type - The type of frame to be found
126 * DESCRIPTION: Pop the scope stack until a frame of the requested type
129 * RETURN: Count of frames popped. If no frame of the requested type
130 * was found, the count is returned as a negative number and
131 * the scope stack is emptied (which sets the current scope
132 * to the root). If the scope stack was empty at entry, the
133 * function is a no-op and returns 0.
135 ***************************************************************************/
138 acpi_ds_scope_stack_pop (
139 ACPI_WALK_STATE
*walk_state
)
141 ACPI_GENERIC_STATE
*scope_info
;
145 * Pop scope info object off the stack.
148 scope_info
= acpi_cm_pop_generic_state (&walk_state
->scope_info
);
150 return (AE_STACK_UNDERFLOW
);
153 acpi_cm_delete_generic_state (scope_info
);