Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/parser/psscope.c
+++ new/usr/src/common/acpica/components/parser/psscope.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: psscope - Parser scope stack management routines
4 4 *
5 5 *****************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2013, Intel Corp.
9 9 * All rights reserved.
10 10 *
11 11 * Redistribution and use in source and binary forms, with or without
12 12 * modification, are permitted provided that the following conditions
13 13 * are met:
14 14 * 1. Redistributions of source code must retain the above copyright
15 15 * notice, this list of conditions, and the following disclaimer,
16 16 * without modification.
17 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 18 * substantially similar to the "NO WARRANTY" disclaimer below
19 19 * ("Disclaimer") and any redistribution must be conditioned upon
20 20 * including a substantially similar Disclaimer requirement for further
21 21 * binary redistribution.
22 22 * 3. Neither the names of the above-listed copyright holders nor the names
23 23 * of any contributors may be used to endorse or promote products derived
24 24 * from this software without specific prior written permission.
25 25 *
26 26 * Alternatively, this software may be distributed under the terms of the
27 27 * GNU General Public License ("GPL") version 2 as published by the Free
28 28 * Software Foundation.
29 29 *
30 30 * NO WARRANTY
31 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 41 * POSSIBILITY OF SUCH DAMAGES.
42 42 */
43 43
44 44
45 45 #include "acpi.h"
46 46 #include "accommon.h"
47 47 #include "acparser.h"
48 48
49 49 #define _COMPONENT ACPI_PARSER
50 50 ACPI_MODULE_NAME ("psscope")
51 51
52 52
53 53 /*******************************************************************************
54 54 *
55 55 * FUNCTION: AcpiPsGetParentScope
56 56 *
57 57 * PARAMETERS: ParserState - Current parser state object
58 58 *
59 59 * RETURN: Pointer to an Op object
60 60 *
61 61 * DESCRIPTION: Get parent of current op being parsed
62 62 *
63 63 ******************************************************************************/
64 64
65 65 ACPI_PARSE_OBJECT *
66 66 AcpiPsGetParentScope (
67 67 ACPI_PARSE_STATE *ParserState)
68 68 {
69 69
70 70 return (ParserState->Scope->ParseScope.Op);
71 71 }
72 72
73 73
74 74 /*******************************************************************************
75 75 *
76 76 * FUNCTION: AcpiPsHasCompletedScope
77 77 *
78 78 * PARAMETERS: ParserState - Current parser state object
79 79 *
80 80 * RETURN: Boolean, TRUE = scope completed.
81 81 *
82 82 * DESCRIPTION: Is parsing of current argument complete? Determined by
83 83 * 1) AML pointer is at or beyond the end of the scope
84 84 * 2) The scope argument count has reached zero.
85 85 *
86 86 ******************************************************************************/
87 87
88 88 BOOLEAN
89 89 AcpiPsHasCompletedScope (
90 90 ACPI_PARSE_STATE *ParserState)
91 91 {
92 92
93 93 return ((BOOLEAN)
94 94 ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd ||
95 95 !ParserState->Scope->ParseScope.ArgCount)));
96 96 }
97 97
98 98
99 99 /*******************************************************************************
100 100 *
101 101 * FUNCTION: AcpiPsInitScope
102 102 *
103 103 * PARAMETERS: ParserState - Current parser state object
104 104 * Root - the Root Node of this new scope
105 105 *
106 106 * RETURN: Status
107 107 *
108 108 * DESCRIPTION: Allocate and init a new scope object
109 109 *
110 110 ******************************************************************************/
111 111
112 112 ACPI_STATUS
113 113 AcpiPsInitScope (
114 114 ACPI_PARSE_STATE *ParserState,
115 115 ACPI_PARSE_OBJECT *RootOp)
116 116 {
117 117 ACPI_GENERIC_STATE *Scope;
118 118
119 119
120 120 ACPI_FUNCTION_TRACE_PTR (PsInitScope, RootOp);
121 121
122 122
123 123 Scope = AcpiUtCreateGenericState ();
124 124 if (!Scope)
125 125 {
126 126 return_ACPI_STATUS (AE_NO_MEMORY);
127 127 }
128 128
129 129 Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RPSCOPE;
130 130 Scope->ParseScope.Op = RootOp;
131 131 Scope->ParseScope.ArgCount = ACPI_VAR_ARGS;
132 132 Scope->ParseScope.ArgEnd = ParserState->AmlEnd;
133 133 Scope->ParseScope.PkgEnd = ParserState->AmlEnd;
134 134
135 135 ParserState->Scope = Scope;
136 136 ParserState->StartOp = RootOp;
137 137
138 138 return_ACPI_STATUS (AE_OK);
139 139 }
140 140
141 141
142 142 /*******************************************************************************
143 143 *
144 144 * FUNCTION: AcpiPsPushScope
145 145 *
146 146 * PARAMETERS: ParserState - Current parser state object
147 147 * Op - Current op to be pushed
148 148 * RemainingArgs - List of args remaining
149 149 * ArgCount - Fixed or variable number of args
150 150 *
151 151 * RETURN: Status
152 152 *
153 153 * DESCRIPTION: Push current op to begin parsing its argument
154 154 *
155 155 ******************************************************************************/
156 156
157 157 ACPI_STATUS
158 158 AcpiPsPushScope (
159 159 ACPI_PARSE_STATE *ParserState,
160 160 ACPI_PARSE_OBJECT *Op,
161 161 UINT32 RemainingArgs,
162 162 UINT32 ArgCount)
163 163 {
164 164 ACPI_GENERIC_STATE *Scope;
165 165
166 166
167 167 ACPI_FUNCTION_TRACE_PTR (PsPushScope, Op);
168 168
169 169
170 170 Scope = AcpiUtCreateGenericState ();
171 171 if (!Scope)
172 172 {
173 173 return_ACPI_STATUS (AE_NO_MEMORY);
174 174 }
175 175
176 176 Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PSCOPE;
177 177 Scope->ParseScope.Op = Op;
178 178 Scope->ParseScope.ArgList = RemainingArgs;
179 179 Scope->ParseScope.ArgCount = ArgCount;
180 180 Scope->ParseScope.PkgEnd = ParserState->PkgEnd;
181 181
182 182 /* Push onto scope stack */
183 183
184 184 AcpiUtPushGenericState (&ParserState->Scope, Scope);
185 185
186 186 if (ArgCount == ACPI_VAR_ARGS)
187 187 {
188 188 /* Multiple arguments */
189 189
190 190 Scope->ParseScope.ArgEnd = ParserState->PkgEnd;
191 191 }
192 192 else
193 193 {
194 194 /* Single argument */
195 195
196 196 Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR);
197 197 }
198 198
199 199 return_ACPI_STATUS (AE_OK);
200 200 }
201 201
202 202
203 203 /*******************************************************************************
204 204 *
205 205 * FUNCTION: AcpiPsPopScope
206 206 *
207 207 * PARAMETERS: ParserState - Current parser state object
208 208 * Op - Where the popped op is returned
209 209 * ArgList - Where the popped "next argument" is
210 210 * returned
211 211 * ArgCount - Count of objects in ArgList
212 212 *
213 213 * RETURN: Status
214 214 *
215 215 * DESCRIPTION: Return to parsing a previous op
216 216 *
217 217 ******************************************************************************/
218 218
219 219 void
220 220 AcpiPsPopScope (
221 221 ACPI_PARSE_STATE *ParserState,
222 222 ACPI_PARSE_OBJECT **Op,
223 223 UINT32 *ArgList,
224 224 UINT32 *ArgCount)
225 225 {
226 226 ACPI_GENERIC_STATE *Scope = ParserState->Scope;
227 227
228 228
229 229 ACPI_FUNCTION_TRACE (PsPopScope);
230 230
231 231
232 232 /* Only pop the scope if there is in fact a next scope */
233 233
234 234 if (Scope->Common.Next)
235 235 {
236 236 Scope = AcpiUtPopGenericState (&ParserState->Scope);
237 237
238 238 /* Return to parsing previous op */
239 239
240 240 *Op = Scope->ParseScope.Op;
241 241 *ArgList = Scope->ParseScope.ArgList;
242 242 *ArgCount = Scope->ParseScope.ArgCount;
243 243 ParserState->PkgEnd = Scope->ParseScope.PkgEnd;
244 244
245 245 /* All done with this scope state structure */
246 246
247 247 AcpiUtDeleteGenericState (Scope);
248 248 }
249 249 else
250 250 {
251 251 /* Empty parse stack, prepare to fetch next opcode */
252 252
253 253 *Op = NULL;
254 254 *ArgList = 0;
255 255 *ArgCount = 0;
256 256 }
257 257
258 258 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
259 259 "Popped Op %p Args %X\n", *Op, *ArgCount));
260 260 return_VOID;
261 261 }
262 262
263 263
264 264 /*******************************************************************************
265 265 *
266 266 * FUNCTION: AcpiPsCleanupScope
267 267 *
268 268 * PARAMETERS: ParserState - Current parser state object
269 269 *
270 270 * RETURN: None
271 271 *
272 272 * DESCRIPTION: Destroy available list, remaining stack levels, and return
273 273 * root scope
274 274 *
275 275 ******************************************************************************/
276 276
277 277 void
278 278 AcpiPsCleanupScope (
279 279 ACPI_PARSE_STATE *ParserState)
280 280 {
281 281 ACPI_GENERIC_STATE *Scope;
282 282
283 283
284 284 ACPI_FUNCTION_TRACE_PTR (PsCleanupScope, ParserState);
285 285
286 286
287 287 if (!ParserState)
288 288 {
289 289 return_VOID;
290 290 }
291 291
↓ open down ↓ |
273 lines elided |
↑ open up ↑ |
292 292 /* Delete anything on the scope stack */
293 293
294 294 while (ParserState->Scope)
295 295 {
296 296 Scope = AcpiUtPopGenericState (&ParserState->Scope);
297 297 AcpiUtDeleteGenericState (Scope);
298 298 }
299 299
300 300 return_VOID;
301 301 }
302 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX