dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / uts / intel / io / acpica / dispatcher / dswscope.c
bloba2497cfa33c3feb338bfb5e79e341ae441c62d5d
1 /******************************************************************************
3 * Module Name: dswscope - Scope stack manipulation
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2016, Intel Corp.
9 * All rights reserved.
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.
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.
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.
44 #include "acpi.h"
45 #include "accommon.h"
46 #include "acdispat.h"
49 #define _COMPONENT ACPI_DISPATCHER
50 ACPI_MODULE_NAME ("dswscope")
53 /****************************************************************************
55 * FUNCTION: AcpiDsScopeStackClear
57 * PARAMETERS: WalkState - Current state
59 * RETURN: None
61 * DESCRIPTION: Pop (and free) everything on the scope stack except the
62 * root scope object (which remains at the stack top.)
64 ***************************************************************************/
66 void
67 AcpiDsScopeStackClear (
68 ACPI_WALK_STATE *WalkState)
70 ACPI_GENERIC_STATE *ScopeInfo;
72 ACPI_FUNCTION_NAME (DsScopeStackClear);
75 while (WalkState->ScopeInfo)
77 /* Pop a scope off the stack */
79 ScopeInfo = WalkState->ScopeInfo;
80 WalkState->ScopeInfo = ScopeInfo->Scope.Next;
82 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
83 "Popped object type (%s)\n",
84 AcpiUtGetTypeName (ScopeInfo->Common.Value)));
86 AcpiUtDeleteGenericState (ScopeInfo);
91 /****************************************************************************
93 * FUNCTION: AcpiDsScopeStackPush
95 * PARAMETERS: Node - Name to be made current
96 * Type - Type of frame being pushed
97 * WalkState - Current state
99 * RETURN: Status
101 * DESCRIPTION: Push the current scope on the scope stack, and make the
102 * passed Node current.
104 ***************************************************************************/
106 ACPI_STATUS
107 AcpiDsScopeStackPush (
108 ACPI_NAMESPACE_NODE *Node,
109 ACPI_OBJECT_TYPE Type,
110 ACPI_WALK_STATE *WalkState)
112 ACPI_GENERIC_STATE *ScopeInfo;
113 ACPI_GENERIC_STATE *OldScopeInfo;
116 ACPI_FUNCTION_TRACE (DsScopeStackPush);
119 if (!Node)
121 /* Invalid scope */
123 ACPI_ERROR ((AE_INFO, "Null scope parameter"));
124 return_ACPI_STATUS (AE_BAD_PARAMETER);
127 /* Make sure object type is valid */
129 if (!AcpiUtValidObjectType (Type))
131 ACPI_WARNING ((AE_INFO,
132 "Invalid object type: 0x%X", Type));
135 /* Allocate a new scope object */
137 ScopeInfo = AcpiUtCreateGenericState ();
138 if (!ScopeInfo)
140 return_ACPI_STATUS (AE_NO_MEMORY);
143 /* Init new scope object */
145 ScopeInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_WSCOPE;
146 ScopeInfo->Scope.Node = Node;
147 ScopeInfo->Common.Value = (UINT16) Type;
149 WalkState->ScopeDepth++;
151 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
152 "[%.2d] Pushed scope ", (UINT32) WalkState->ScopeDepth));
154 OldScopeInfo = WalkState->ScopeInfo;
155 if (OldScopeInfo)
157 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
158 "[%4.4s] (%s)",
159 AcpiUtGetNodeName (OldScopeInfo->Scope.Node),
160 AcpiUtGetTypeName (OldScopeInfo->Common.Value)));
162 else
164 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
165 "[\\___] (%s)", "ROOT"));
168 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
169 ", New scope -> [%4.4s] (%s)\n",
170 AcpiUtGetNodeName (ScopeInfo->Scope.Node),
171 AcpiUtGetTypeName (ScopeInfo->Common.Value)));
173 /* Push new scope object onto stack */
175 AcpiUtPushGenericState (&WalkState->ScopeInfo, ScopeInfo);
176 return_ACPI_STATUS (AE_OK);
180 /****************************************************************************
182 * FUNCTION: AcpiDsScopeStackPop
184 * PARAMETERS: WalkState - Current state
186 * RETURN: Status
188 * DESCRIPTION: Pop the scope stack once.
190 ***************************************************************************/
192 ACPI_STATUS
193 AcpiDsScopeStackPop (
194 ACPI_WALK_STATE *WalkState)
196 ACPI_GENERIC_STATE *ScopeInfo;
197 ACPI_GENERIC_STATE *NewScopeInfo;
200 ACPI_FUNCTION_TRACE (DsScopeStackPop);
204 * Pop scope info object off the stack.
206 ScopeInfo = AcpiUtPopGenericState (&WalkState->ScopeInfo);
207 if (!ScopeInfo)
209 return_ACPI_STATUS (AE_STACK_UNDERFLOW);
212 WalkState->ScopeDepth--;
214 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
215 "[%.2d] Popped scope [%4.4s] (%s), New scope -> ",
216 (UINT32) WalkState->ScopeDepth,
217 AcpiUtGetNodeName (ScopeInfo->Scope.Node),
218 AcpiUtGetTypeName (ScopeInfo->Common.Value)));
220 NewScopeInfo = WalkState->ScopeInfo;
221 if (NewScopeInfo)
223 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
224 "[%4.4s] (%s)\n",
225 AcpiUtGetNodeName (NewScopeInfo->Scope.Node),
226 AcpiUtGetTypeName (NewScopeInfo->Common.Value)));
228 else
230 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
231 "[\\___] (ROOT)\n"));
234 AcpiUtDeleteGenericState (ScopeInfo);
235 return_ACPI_STATUS (AE_OK);