OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [acpi/] [dispatcher/] [dswscope.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/******************************************************************************
2
 *
3
 * Module Name: dswscope - Scope stack manipulation
4
 *
5
 *****************************************************************************/
6
 
7
/*
8
 * Copyright (C) 2000 - 2004, R. Byron Moore
9
 * All rights reserved.
10
 *
11
 * Redistribution and use in source and binary forms, with or without
12
 * modification, are permitted provided that the following conditions
13
 * are met:
14
 * 1. Redistributions of source code must retain the above copyright
15
 *    notice, this list of conditions, and the following disclaimer,
16
 *    without modification.
17
 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18
 *    substantially similar to the "NO WARRANTY" disclaimer below
19
 *    ("Disclaimer") and any redistribution must be conditioned upon
20
 *    including a substantially similar Disclaimer requirement for further
21
 *    binary redistribution.
22
 * 3. Neither the names of the above-listed copyright holders nor the names
23
 *    of any contributors may be used to endorse or promote products derived
24
 *    from this software without specific prior written permission.
25
 *
26
 * Alternatively, this software may be distributed under the terms of the
27
 * GNU General Public License ("GPL") version 2 as published by the Free
28
 * Software Foundation.
29
 *
30
 * NO WARRANTY
31
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35
 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41
 * POSSIBILITY OF SUCH DAMAGES.
42
 */
43
 
44
 
45
#include <acpi/acpi.h>
46
#include <acpi/acdispat.h>
47
 
48
 
49
#define _COMPONENT          ACPI_DISPATCHER
50
         ACPI_MODULE_NAME    ("dswscope")
51
 
52
 
53
#define STACK_POP(head) head
54
 
55
 
56
/****************************************************************************
57
 *
58
 * FUNCTION:    acpi_ds_scope_stack_clear
59
 *
60
 * PARAMETERS:  None
61
 *
62
 * DESCRIPTION: Pop (and free) everything on the scope stack except the
63
 *              root scope object (which remains at the stack top.)
64
 *
65
 ***************************************************************************/
66
 
67
void
68
acpi_ds_scope_stack_clear (
69
        struct acpi_walk_state          *walk_state)
70
{
71
        union acpi_generic_state        *scope_info;
72
 
73
        ACPI_FUNCTION_NAME ("ds_scope_stack_clear");
74
 
75
 
76
        while (walk_state->scope_info) {
77
                /* Pop a scope off the stack */
78
 
79
                scope_info = walk_state->scope_info;
80
                walk_state->scope_info = scope_info->scope.next;
81
 
82
                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
83
                        "Popped object type (%s)\n", acpi_ut_get_type_name (scope_info->common.value)));
84
                acpi_ut_delete_generic_state (scope_info);
85
        }
86
}
87
 
88
 
89
/****************************************************************************
90
 *
91
 * FUNCTION:    acpi_ds_scope_stack_push
92
 *
93
 * PARAMETERS:  *Node,              - Name to be made current
94
 *              Type,               - Type of frame being pushed
95
 *
96
 * DESCRIPTION: Push the current scope on the scope stack, and make the
97
 *              passed Node current.
98
 *
99
 ***************************************************************************/
100
 
101
acpi_status
102
acpi_ds_scope_stack_push (
103
        struct acpi_namespace_node      *node,
104
        acpi_object_type                type,
105
        struct acpi_walk_state          *walk_state)
106
{
107
        union acpi_generic_state        *scope_info;
108
        union acpi_generic_state        *old_scope_info;
109
 
110
 
111
        ACPI_FUNCTION_TRACE ("ds_scope_stack_push");
112
 
113
 
114
        if (!node) {
115
                /* Invalid scope   */
116
 
117
                ACPI_REPORT_ERROR (("ds_scope_stack_push: null scope passed\n"));
118
                return_ACPI_STATUS (AE_BAD_PARAMETER);
119
        }
120
 
121
        /* Make sure object type is valid */
122
 
123
        if (!acpi_ut_valid_object_type (type)) {
124
                ACPI_REPORT_WARNING (("ds_scope_stack_push: Invalid object type: 0x%X\n", type));
125
        }
126
 
127
        /* Allocate a new scope object */
128
 
129
        scope_info = acpi_ut_create_generic_state ();
130
        if (!scope_info) {
131
                return_ACPI_STATUS (AE_NO_MEMORY);
132
        }
133
 
134
        /* Init new scope object */
135
 
136
        scope_info->common.data_type = ACPI_DESC_TYPE_STATE_WSCOPE;
137
        scope_info->scope.node      = node;
138
        scope_info->common.value    = (u16) type;
139
 
140
        walk_state->scope_depth++;
141
 
142
        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
143
                "[%.2d] Pushed scope ", (u32) walk_state->scope_depth));
144
 
145
        old_scope_info = walk_state->scope_info;
146
        if (old_scope_info) {
147
                ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
148
                        "[%4.4s] (%s)",
149
                        acpi_ut_get_node_name (old_scope_info->scope.node),
150
                        acpi_ut_get_type_name (old_scope_info->common.value)));
151
        }
152
        else {
153
                ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
154
                        "[\\___] (%s)", "ROOT"));
155
        }
156
 
157
        ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
158
                ", New scope -> [%4.4s] (%s)\n",
159
                acpi_ut_get_node_name (scope_info->scope.node),
160
                acpi_ut_get_type_name (scope_info->common.value)));
161
 
162
        /* Push new scope object onto stack */
163
 
164
        acpi_ut_push_generic_state (&walk_state->scope_info, scope_info);
165
        return_ACPI_STATUS (AE_OK);
166
}
167
 
168
 
169
/****************************************************************************
170
 *
171
 * FUNCTION:    acpi_ds_scope_stack_pop
172
 *
173
 * PARAMETERS:  Type                - The type of frame to be found
174
 *
175
 * DESCRIPTION: Pop the scope stack until a frame of the requested type
176
 *              is found.
177
 *
178
 * RETURN:      Count of frames popped.  If no frame of the requested type
179
 *              was found, the count is returned as a negative number and
180
 *              the scope stack is emptied (which sets the current scope
181
 *              to the root).  If the scope stack was empty at entry, the
182
 *              function is a no-op and returns 0.
183
 *
184
 ***************************************************************************/
185
 
186
acpi_status
187
acpi_ds_scope_stack_pop (
188
        struct acpi_walk_state          *walk_state)
189
{
190
        union acpi_generic_state        *scope_info;
191
        union acpi_generic_state        *new_scope_info;
192
 
193
 
194
        ACPI_FUNCTION_TRACE ("ds_scope_stack_pop");
195
 
196
 
197
        /*
198
         * Pop scope info object off the stack.
199
         */
200
        scope_info = acpi_ut_pop_generic_state (&walk_state->scope_info);
201
        if (!scope_info) {
202
                return_ACPI_STATUS (AE_STACK_UNDERFLOW);
203
        }
204
 
205
        walk_state->scope_depth--;
206
 
207
        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
208
                "[%.2d] Popped scope [%4.4s] (%s), New scope -> ",
209
                (u32) walk_state->scope_depth,
210
                acpi_ut_get_node_name (scope_info->scope.node),
211
                acpi_ut_get_type_name (scope_info->common.value)));
212
 
213
        new_scope_info = walk_state->scope_info;
214
        if (new_scope_info) {
215
                ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
216
                        "[%4.4s] (%s)\n",
217
                        acpi_ut_get_node_name (new_scope_info->scope.node),
218
                        acpi_ut_get_type_name (new_scope_info->common.value)));
219
        }
220
        else {
221
                ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
222
                        "[\\___] (ROOT)\n"));
223
        }
224
 
225
        acpi_ut_delete_generic_state (scope_info);
226
        return_ACPI_STATUS (AE_OK);
227
}
228
 
229
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.