ReactOS 0.4.16-dev-329-g9223134
dswscope.c
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Module Name: dswscope - Scope stack manipulation
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2022, Intel Corp.
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 MERCHANTABILITY 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#include "acpi.h"
45#include "accommon.h"
46#include "acdispat.h"
47
48
49#define _COMPONENT ACPI_DISPATCHER
50 ACPI_MODULE_NAME ("dswscope")
51
52
53/****************************************************************************
54 *
55 * FUNCTION: AcpiDsScopeStackClear
56 *
57 * PARAMETERS: WalkState - Current state
58 *
59 * RETURN: None
60 *
61 * DESCRIPTION: Pop (and free) everything on the scope stack except the
62 * root scope object (which remains at the stack top.)
63 *
64 ***************************************************************************/
65
66void
68 ACPI_WALK_STATE *WalkState)
69{
70 ACPI_GENERIC_STATE *ScopeInfo;
71
72 ACPI_FUNCTION_NAME (DsScopeStackClear);
73
74
75 while (WalkState->ScopeInfo)
76 {
77 /* Pop a scope off the stack */
78
79 ScopeInfo = WalkState->ScopeInfo;
80 WalkState->ScopeInfo = ScopeInfo->Scope.Next;
81
83 "Popped object type (%s)\n",
84 AcpiUtGetTypeName (ScopeInfo->Common.Value)));
85
86 AcpiUtDeleteGenericState (ScopeInfo);
87 }
88}
89
90
91/****************************************************************************
92 *
93 * FUNCTION: AcpiDsScopeStackPush
94 *
95 * PARAMETERS: Node - Name to be made current
96 * Type - Type of frame being pushed
97 * WalkState - Current state
98 *
99 * RETURN: Status
100 *
101 * DESCRIPTION: Push the current scope on the scope stack, and make the
102 * passed Node current.
103 *
104 ***************************************************************************/
105
110 ACPI_WALK_STATE *WalkState)
111{
112 ACPI_GENERIC_STATE *ScopeInfo;
113 ACPI_GENERIC_STATE *OldScopeInfo;
114
115
116 ACPI_FUNCTION_TRACE (DsScopeStackPush);
117
118
119 if (!Node)
120 {
121 /* Invalid scope */
122
123 ACPI_ERROR ((AE_INFO, "Null scope parameter"));
125 }
126
127 /* Make sure object type is valid */
128
130 {
132 "Invalid object type: 0x%X", Type));
133 }
134
135 /* Allocate a new scope object */
136
137 ScopeInfo = AcpiUtCreateGenericState ();
138 if (!ScopeInfo)
139 {
141 }
142
143 /* Init new scope object */
144
145 ScopeInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_WSCOPE;
146 ScopeInfo->Scope.Node = Node;
147 ScopeInfo->Common.Value = (UINT16) Type;
148
149 WalkState->ScopeDepth++;
150
152 "[%.2d] Pushed scope ", (UINT32) WalkState->ScopeDepth));
153
154 OldScopeInfo = WalkState->ScopeInfo;
155 if (OldScopeInfo)
156 {
158 "[%4.4s] (%s)",
159 AcpiUtGetNodeName (OldScopeInfo->Scope.Node),
160 AcpiUtGetTypeName (OldScopeInfo->Common.Value)));
161 }
162 else
163 {
165 }
166
168 ", New scope -> [%4.4s] (%s)\n",
169 AcpiUtGetNodeName (ScopeInfo->Scope.Node),
170 AcpiUtGetTypeName (ScopeInfo->Common.Value)));
171
172 /* Push new scope object onto stack */
173
174 AcpiUtPushGenericState (&WalkState->ScopeInfo, ScopeInfo);
176}
177
178
179/****************************************************************************
180 *
181 * FUNCTION: AcpiDsScopeStackPop
182 *
183 * PARAMETERS: WalkState - Current state
184 *
185 * RETURN: Status
186 *
187 * DESCRIPTION: Pop the scope stack once.
188 *
189 ***************************************************************************/
190
193 ACPI_WALK_STATE *WalkState)
194{
195 ACPI_GENERIC_STATE *ScopeInfo;
196 ACPI_GENERIC_STATE *NewScopeInfo;
197
198
199 ACPI_FUNCTION_TRACE (DsScopeStackPop);
200
201
202 /*
203 * Pop scope info object off the stack.
204 */
205 ScopeInfo = AcpiUtPopGenericState (&WalkState->ScopeInfo);
206 if (!ScopeInfo)
207 {
209 }
210
211 WalkState->ScopeDepth--;
212
214 "[%.2d] Popped scope [%4.4s] (%s), New scope -> ",
215 (UINT32) WalkState->ScopeDepth,
216 AcpiUtGetNodeName (ScopeInfo->Scope.Node),
217 AcpiUtGetTypeName (ScopeInfo->Common.Value)));
218
219 NewScopeInfo = WalkState->ScopeInfo;
220 if (NewScopeInfo)
221 {
222 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "[%4.4s] (%s)\n",
223 AcpiUtGetNodeName (NewScopeInfo->Scope.Node),
224 AcpiUtGetTypeName (NewScopeInfo->Common.Value)));
225 }
226 else
227 {
229 }
230
231 AcpiUtDeleteGenericState (ScopeInfo);
233}
unsigned short UINT16
unsigned int UINT32
Type
Definition: Type.h:7
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define AE_STACK_UNDERFLOW
Definition: acexcep.h:121
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_OK
Definition: acexcep.h:97
#define ACPI_NAMESPACE_ROOT
Definition: acnames.h:94
#define ACPI_DESC_TYPE_STATE_WSCOPE
Definition: acobject.h:570
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_MODULE_NAME(Name)
Definition: acoutput.h:216
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
#define ACPI_DB_EXEC
Definition: acoutput.h:165
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_DEBUG_PRINT_RAW(pl)
Definition: acoutput.h:476
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
UINT32 ACPI_OBJECT_TYPE
Definition: actypes.h:685
UINT32 ACPI_STATUS
Definition: actypes.h:460
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:250
ACPI_GENERIC_STATE * AcpiUtCreateGenericState(void)
Definition: utstate.c:130
const char * AcpiUtGetNodeName(void *Object)
Definition: utdecode.c:306
BOOLEAN AcpiUtValidObjectType(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:681
ACPI_GENERIC_STATE * AcpiUtPopGenericState(ACPI_GENERIC_STATE **ListHead)
Definition: utstate.c:93
void AcpiUtPushGenericState(ACPI_GENERIC_STATE **ListHead, ACPI_GENERIC_STATE *State)
Definition: utstate.c:65
void AcpiUtDeleteGenericState(ACPI_GENERIC_STATE *State)
Definition: utstate.c:340
union node Node
Definition: types.h:1255
ACPI_STATUS AcpiDsScopeStackPush(ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, ACPI_WALK_STATE *WalkState)
Definition: dswscope.c:107
ACPI_STATUS AcpiDsScopeStackPop(ACPI_WALK_STATE *WalkState)
Definition: dswscope.c:192
void AcpiDsScopeStackClear(ACPI_WALK_STATE *WalkState)
Definition: dswscope.c:67
ACPI_STATE_COMMON ACPI_NAMESPACE_NODE * Node
Definition: aclocal.h:740
UINT8 ScopeDepth
Definition: acstruct.h:86
ACPI_GENERIC_STATE * ScopeInfo
Definition: acstruct.h:124
ACPI_COMMON_STATE Common
Definition: aclocal.h:822
ACPI_SCOPE_STATE Scope
Definition: aclocal.h:825
Definition: dlist.c:348