Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/parser/psxface.c
+++ new/usr/src/common/acpica/components/parser/psxface.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: psxface - Parser external interfaces
4 4 *
5 5 *****************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2014, 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 #define __PSXFACE_C__
45 45
46 46 #include "acpi.h"
47 47 #include "accommon.h"
48 48 #include "acparser.h"
49 49 #include "acdispat.h"
50 50 #include "acinterp.h"
51 51 #include "actables.h"
52 52
53 53
54 54 #define _COMPONENT ACPI_PARSER
55 55 ACPI_MODULE_NAME ("psxface")
56 56
57 57 /* Local Prototypes */
58 58
59 59 static void
60 60 AcpiPsStartTrace (
61 61 ACPI_EVALUATE_INFO *Info);
62 62
63 63 static void
64 64 AcpiPsStopTrace (
65 65 ACPI_EVALUATE_INFO *Info);
66 66
67 67 static void
68 68 AcpiPsUpdateParameterList (
69 69 ACPI_EVALUATE_INFO *Info,
70 70 UINT16 Action);
71 71
72 72
73 73 /*******************************************************************************
74 74 *
75 75 * FUNCTION: AcpiDebugTrace
76 76 *
77 77 * PARAMETERS: MethodName - Valid ACPI name string
78 78 * DebugLevel - Optional level mask. 0 to use default
79 79 * DebugLayer - Optional layer mask. 0 to use default
80 80 * Flags - bit 1: one shot(1) or persistent(0)
81 81 *
82 82 * RETURN: Status
83 83 *
84 84 * DESCRIPTION: External interface to enable debug tracing during control
85 85 * method execution
86 86 *
87 87 ******************************************************************************/
88 88
89 89 ACPI_STATUS
90 90 AcpiDebugTrace (
91 91 char *Name,
92 92 UINT32 DebugLevel,
93 93 UINT32 DebugLayer,
94 94 UINT32 Flags)
95 95 {
96 96 ACPI_STATUS Status;
97 97
98 98
99 99 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
100 100 if (ACPI_FAILURE (Status))
101 101 {
102 102 return (Status);
103 103 }
104 104
105 105 /* TBDs: Validate name, allow full path or just nameseg */
106 106
107 107 AcpiGbl_TraceMethodName = *ACPI_CAST_PTR (UINT32, Name);
108 108 AcpiGbl_TraceFlags = Flags;
109 109
110 110 if (DebugLevel)
111 111 {
112 112 AcpiGbl_TraceDbgLevel = DebugLevel;
113 113 }
114 114 if (DebugLayer)
115 115 {
116 116 AcpiGbl_TraceDbgLayer = DebugLayer;
117 117 }
118 118
119 119 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
120 120 return (AE_OK);
121 121 }
122 122
123 123
124 124 /*******************************************************************************
125 125 *
126 126 * FUNCTION: AcpiPsStartTrace
127 127 *
128 128 * PARAMETERS: Info - Method info struct
129 129 *
130 130 * RETURN: None
131 131 *
132 132 * DESCRIPTION: Start control method execution trace
133 133 *
134 134 ******************************************************************************/
135 135
136 136 static void
137 137 AcpiPsStartTrace (
138 138 ACPI_EVALUATE_INFO *Info)
139 139 {
140 140 ACPI_STATUS Status;
141 141
142 142
↓ open down ↓ |
124 lines elided |
↑ open up ↑ |
143 143 ACPI_FUNCTION_ENTRY ();
144 144
145 145
146 146 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
147 147 if (ACPI_FAILURE (Status))
148 148 {
149 149 return;
150 150 }
151 151
152 152 if ((!AcpiGbl_TraceMethodName) ||
153 - (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer))
153 + (AcpiGbl_TraceMethodName != Info->Node->Name.Integer))
154 154 {
155 155 goto Exit;
156 156 }
157 157
158 158 AcpiGbl_OriginalDbgLevel = AcpiDbgLevel;
159 159 AcpiGbl_OriginalDbgLayer = AcpiDbgLayer;
160 160
161 161 AcpiDbgLevel = 0x00FFFFFF;
162 162 AcpiDbgLayer = ACPI_UINT32_MAX;
163 163
164 164 if (AcpiGbl_TraceDbgLevel)
165 165 {
166 166 AcpiDbgLevel = AcpiGbl_TraceDbgLevel;
167 167 }
168 168 if (AcpiGbl_TraceDbgLayer)
169 169 {
170 170 AcpiDbgLayer = AcpiGbl_TraceDbgLayer;
171 171 }
172 172
173 173
174 174 Exit:
175 175 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
176 176 }
177 177
178 178
179 179 /*******************************************************************************
180 180 *
181 181 * FUNCTION: AcpiPsStopTrace
182 182 *
183 183 * PARAMETERS: Info - Method info struct
184 184 *
185 185 * RETURN: None
186 186 *
187 187 * DESCRIPTION: Stop control method execution trace
188 188 *
189 189 ******************************************************************************/
190 190
191 191 static void
192 192 AcpiPsStopTrace (
193 193 ACPI_EVALUATE_INFO *Info)
194 194 {
195 195 ACPI_STATUS Status;
196 196
197 197
↓ open down ↓ |
34 lines elided |
↑ open up ↑ |
198 198 ACPI_FUNCTION_ENTRY ();
199 199
200 200
201 201 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
202 202 if (ACPI_FAILURE (Status))
203 203 {
204 204 return;
205 205 }
206 206
207 207 if ((!AcpiGbl_TraceMethodName) ||
208 - (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer))
208 + (AcpiGbl_TraceMethodName != Info->Node->Name.Integer))
209 209 {
210 210 goto Exit;
211 211 }
212 212
213 213 /* Disable further tracing if type is one-shot */
214 214
215 215 if (AcpiGbl_TraceFlags & 1)
216 216 {
217 217 AcpiGbl_TraceMethodName = 0;
218 218 AcpiGbl_TraceDbgLevel = 0;
219 219 AcpiGbl_TraceDbgLayer = 0;
220 220 }
221 221
222 222 AcpiDbgLevel = AcpiGbl_OriginalDbgLevel;
223 223 AcpiDbgLayer = AcpiGbl_OriginalDbgLayer;
224 224
225 225 Exit:
226 226 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
227 227 }
228 228
229 229
230 230 /*******************************************************************************
231 231 *
232 232 * FUNCTION: AcpiPsExecuteMethod
233 233 *
234 234 * PARAMETERS: Info - Method info block, contains:
235 235 * Node - Method Node to execute
236 236 * ObjDesc - Method object
237 237 * Parameters - List of parameters to pass to the method,
238 238 * terminated by NULL. Params itself may be
239 239 * NULL if no parameters are being passed.
240 240 * ReturnObject - Where to put method's return value (if
241 241 * any). If NULL, no value is returned.
242 242 * ParameterType - Type of Parameter list
243 243 * ReturnObject - Where to put method's return value (if
244 244 * any). If NULL, no value is returned.
245 245 * PassNumber - Parse or execute pass
246 246 *
247 247 * RETURN: Status
248 248 *
249 249 * DESCRIPTION: Execute a control method
250 250 *
251 251 ******************************************************************************/
252 252
253 253 ACPI_STATUS
254 254 AcpiPsExecuteMethod (
255 255 ACPI_EVALUATE_INFO *Info)
256 256 {
257 257 ACPI_STATUS Status;
258 258 ACPI_PARSE_OBJECT *Op;
259 259 ACPI_WALK_STATE *WalkState;
260 260
↓ open down ↓ |
42 lines elided |
↑ open up ↑ |
261 261
262 262 ACPI_FUNCTION_TRACE (PsExecuteMethod);
263 263
264 264
265 265 /* Quick validation of DSDT header */
266 266
267 267 AcpiTbCheckDsdtHeader ();
268 268
269 269 /* Validate the Info and method Node */
270 270
271 - if (!Info || !Info->ResolvedNode)
271 + if (!Info || !Info->Node)
272 272 {
273 273 return_ACPI_STATUS (AE_NULL_ENTRY);
274 274 }
275 275
276 276 /* Init for new method, wait on concurrency semaphore */
277 277
278 - Status = AcpiDsBeginMethodExecution (Info->ResolvedNode, Info->ObjDesc, NULL);
278 + Status = AcpiDsBeginMethodExecution (Info->Node, Info->ObjDesc, NULL);
279 279 if (ACPI_FAILURE (Status))
280 280 {
281 281 return_ACPI_STATUS (Status);
282 282 }
283 283
284 284 /*
285 285 * The caller "owns" the parameters, so give each one an extra reference
286 286 */
287 287 AcpiPsUpdateParameterList (Info, REF_INCREMENT);
288 288
289 289 /* Begin tracing if requested */
290 290
291 291 AcpiPsStartTrace (Info);
292 292
293 293 /*
294 294 * Execute the method. Performs parse simultaneously
295 295 */
296 296 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
297 297 "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n",
298 - Info->ResolvedNode->Name.Ascii, Info->ResolvedNode, Info->ObjDesc));
298 + Info->Node->Name.Ascii, Info->Node, Info->ObjDesc));
299 299
300 300 /* Create and init a Root Node */
301 301
302 302 Op = AcpiPsCreateScopeOp ();
303 303 if (!Op)
304 304 {
305 305 Status = AE_NO_MEMORY;
306 306 goto Cleanup;
307 307 }
308 308
309 309 /* Create and initialize a new walk state */
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
310 310
311 311 Info->PassNumber = ACPI_IMODE_EXECUTE;
312 312 WalkState = AcpiDsCreateWalkState (
313 313 Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL);
314 314 if (!WalkState)
315 315 {
316 316 Status = AE_NO_MEMORY;
317 317 goto Cleanup;
318 318 }
319 319
320 - Status = AcpiDsInitAmlWalk (WalkState, Op, Info->ResolvedNode,
320 + Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node,
321 321 Info->ObjDesc->Method.AmlStart,
322 322 Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber);
323 323 if (ACPI_FAILURE (Status))
324 324 {
325 325 AcpiDsDeleteWalkState (WalkState);
326 326 goto Cleanup;
327 327 }
328 328
329 329 if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)
330 330 {
331 331 WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL;
332 332 }
333 333
334 334 /* Invoke an internal method if necessary */
335 335
336 336 if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_INTERNAL_ONLY)
337 337 {
338 338 Status = Info->ObjDesc->Method.Dispatch.Implementation (WalkState);
339 339 Info->ReturnObject = WalkState->ReturnDesc;
340 340
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
341 341 /* Cleanup states */
342 342
343 343 AcpiDsScopeStackClear (WalkState);
344 344 AcpiPsCleanupScope (&WalkState->ParserState);
345 345 AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
346 346 AcpiDsDeleteWalkState (WalkState);
347 347 goto Cleanup;
348 348 }
349 349
350 350 /*
351 - * Start method evaluation with an implicit return of zero. This is done
352 - * for Windows compatibility.
351 + * Start method evaluation with an implicit return of zero.
352 + * This is done for Windows compatibility.
353 353 */
354 354 if (AcpiGbl_EnableInterpreterSlack)
355 355 {
356 356 WalkState->ImplicitReturnObj =
357 357 AcpiUtCreateIntegerObject ((UINT64) 0);
358 358 if (!WalkState->ImplicitReturnObj)
359 359 {
360 360 Status = AE_NO_MEMORY;
361 361 AcpiDsDeleteWalkState (WalkState);
362 362 goto Cleanup;
363 363 }
364 364 }
365 365
366 366 /* Parse the AML */
367 367
368 368 Status = AcpiPsParseAml (WalkState);
369 369
370 370 /* WalkState was deleted by ParseAml */
371 371
372 372 Cleanup:
373 373 AcpiPsDeleteParseTree (Op);
374 374
375 375 /* End optional tracing */
376 376
377 377 AcpiPsStopTrace (Info);
378 378
379 379 /* Take away the extra reference that we gave the parameters above */
380 380
381 381 AcpiPsUpdateParameterList (Info, REF_DECREMENT);
382 382
383 383 /* Exit now if error above */
384 384
385 385 if (ACPI_FAILURE (Status))
386 386 {
387 387 return_ACPI_STATUS (Status);
388 388 }
389 389
390 390 /*
391 391 * If the method has returned an object, signal this to the caller with
392 392 * a control exception code
393 393 */
394 394 if (Info->ReturnObject)
395 395 {
396 396 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n",
397 397 Info->ReturnObject));
398 398 ACPI_DUMP_STACK_ENTRY (Info->ReturnObject);
399 399
400 400 Status = AE_CTRL_RETURN_VALUE;
401 401 }
402 402
403 403 return_ACPI_STATUS (Status);
404 404 }
405 405
406 406
407 407 /*******************************************************************************
408 408 *
409 409 * FUNCTION: AcpiPsUpdateParameterList
410 410 *
411 411 * PARAMETERS: Info - See ACPI_EVALUATE_INFO
412 412 * (Used: ParameterType and Parameters)
413 413 * Action - Add or Remove reference
414 414 *
415 415 * RETURN: Status
416 416 *
417 417 * DESCRIPTION: Update reference count on all method parameter objects
418 418 *
419 419 ******************************************************************************/
420 420
421 421 static void
422 422 AcpiPsUpdateParameterList (
423 423 ACPI_EVALUATE_INFO *Info,
424 424 UINT16 Action)
425 425 {
426 426 UINT32 i;
427 427
428 428
429 429 if (Info->Parameters)
430 430 {
↓ open down ↓ |
68 lines elided |
↑ open up ↑ |
431 431 /* Update reference count for each parameter */
432 432
433 433 for (i = 0; Info->Parameters[i]; i++)
434 434 {
435 435 /* Ignore errors, just do them all */
436 436
437 437 (void) AcpiUtUpdateObjectReference (Info->Parameters[i], Action);
438 438 }
439 439 }
440 440 }
441 -
442 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX