Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/executer/exresolv.c
+++ new/usr/src/common/acpica/components/executer/exresolv.c
1 -
2 1 /******************************************************************************
3 2 *
4 3 * Module Name: exresolv - AML Interpreter object resolution
5 4 *
6 5 *****************************************************************************/
7 6
8 7 /*
9 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2013, Intel Corp.
10 9 * All rights reserved.
11 10 *
12 11 * Redistribution and use in source and binary forms, with or without
13 12 * modification, are permitted provided that the following conditions
14 13 * are met:
15 14 * 1. Redistributions of source code must retain the above copyright
16 15 * notice, this list of conditions, and the following disclaimer,
17 16 * without modification.
18 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 18 * substantially similar to the "NO WARRANTY" disclaimer below
20 19 * ("Disclaimer") and any redistribution must be conditioned upon
21 20 * including a substantially similar Disclaimer requirement for further
22 21 * binary redistribution.
23 22 * 3. Neither the names of the above-listed copyright holders nor the names
24 23 * of any contributors may be used to endorse or promote products derived
25 24 * from this software without specific prior written permission.
26 25 *
27 26 * Alternatively, this software may be distributed under the terms of the
28 27 * GNU General Public License ("GPL") version 2 as published by the Free
29 28 * Software Foundation.
30 29 *
31 30 * NO WARRANTY
32 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 41 * POSSIBILITY OF SUCH DAMAGES.
43 42 */
44 43
45 44 #define __EXRESOLV_C__
46 45
47 46 #include "acpi.h"
48 47 #include "accommon.h"
49 48 #include "amlcode.h"
50 49 #include "acdispat.h"
51 50 #include "acinterp.h"
52 51 #include "acnamesp.h"
53 52
54 53
55 54 #define _COMPONENT ACPI_EXECUTER
56 55 ACPI_MODULE_NAME ("exresolv")
57 56
58 57 /* Local prototypes */
59 58
60 59 static ACPI_STATUS
61 60 AcpiExResolveObjectToValue (
62 61 ACPI_OPERAND_OBJECT **StackPtr,
63 62 ACPI_WALK_STATE *WalkState);
64 63
65 64
66 65 /*******************************************************************************
67 66 *
68 67 * FUNCTION: AcpiExResolveToValue
69 68 *
70 69 * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can
71 70 * be either an (ACPI_OPERAND_OBJECT *)
72 71 * or an ACPI_HANDLE.
73 72 * WalkState - Current method state
74 73 *
75 74 * RETURN: Status
76 75 *
77 76 * DESCRIPTION: Convert Reference objects to values
78 77 *
79 78 ******************************************************************************/
80 79
81 80 ACPI_STATUS
82 81 AcpiExResolveToValue (
83 82 ACPI_OPERAND_OBJECT **StackPtr,
84 83 ACPI_WALK_STATE *WalkState)
85 84 {
86 85 ACPI_STATUS Status;
87 86
88 87
89 88 ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr);
90 89
91 90
92 91 if (!StackPtr || !*StackPtr)
93 92 {
94 93 ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
95 94 return_ACPI_STATUS (AE_AML_NO_OPERAND);
96 95 }
97 96
98 97 /*
99 98 * The entity pointed to by the StackPtr can be either
100 99 * 1) A valid ACPI_OPERAND_OBJECT, or
101 100 * 2) A ACPI_NAMESPACE_NODE (NamedObj)
102 101 */
103 102 if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND)
104 103 {
105 104 Status = AcpiExResolveObjectToValue (StackPtr, WalkState);
106 105 if (ACPI_FAILURE (Status))
107 106 {
108 107 return_ACPI_STATUS (Status);
109 108 }
110 109
111 110 if (!*StackPtr)
112 111 {
113 112 ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
114 113 return_ACPI_STATUS (AE_AML_NO_OPERAND);
115 114 }
116 115 }
117 116
118 117 /*
119 118 * Object on the stack may have changed if AcpiExResolveObjectToValue()
120 119 * was called (i.e., we can't use an _else_ here.)
121 120 */
122 121 if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED)
123 122 {
124 123 Status = AcpiExResolveNodeToValue (
125 124 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr),
126 125 WalkState);
127 126 if (ACPI_FAILURE (Status))
128 127 {
129 128 return_ACPI_STATUS (Status);
130 129 }
131 130 }
132 131
133 132 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr));
134 133 return_ACPI_STATUS (AE_OK);
135 134 }
136 135
137 136
138 137 /*******************************************************************************
139 138 *
140 139 * FUNCTION: AcpiExResolveObjectToValue
141 140 *
142 141 * PARAMETERS: StackPtr - Pointer to an internal object
143 142 * WalkState - Current method state
144 143 *
145 144 * RETURN: Status
146 145 *
147 146 * DESCRIPTION: Retrieve the value from an internal object. The Reference type
148 147 * uses the associated AML opcode to determine the value.
149 148 *
150 149 ******************************************************************************/
151 150
152 151 static ACPI_STATUS
153 152 AcpiExResolveObjectToValue (
154 153 ACPI_OPERAND_OBJECT **StackPtr,
155 154 ACPI_WALK_STATE *WalkState)
156 155 {
157 156 ACPI_STATUS Status = AE_OK;
↓ open down ↓ |
138 lines elided |
↑ open up ↑ |
158 157 ACPI_OPERAND_OBJECT *StackDesc;
159 158 ACPI_OPERAND_OBJECT *ObjDesc = NULL;
160 159 UINT8 RefType;
161 160
162 161
163 162 ACPI_FUNCTION_TRACE (ExResolveObjectToValue);
164 163
165 164
166 165 StackDesc = *StackPtr;
167 166
168 - /* This is an ACPI_OPERAND_OBJECT */
167 + /* This is an object of type ACPI_OPERAND_OBJECT */
169 168
170 169 switch (StackDesc->Common.Type)
171 170 {
172 171 case ACPI_TYPE_LOCAL_REFERENCE:
173 172
174 173 RefType = StackDesc->Reference.Class;
175 174
176 175 switch (RefType)
177 176 {
178 177 case ACPI_REFCLASS_LOCAL:
179 178 case ACPI_REFCLASS_ARG:
180 -
181 179 /*
182 180 * Get the local from the method's state info
183 181 * Note: this increments the local's object reference count
184 182 */
185 183 Status = AcpiDsMethodDataGetValue (RefType,
186 184 StackDesc->Reference.Value, WalkState, &ObjDesc);
187 185 if (ACPI_FAILURE (Status))
188 186 {
189 187 return_ACPI_STATUS (Status);
190 188 }
191 189
192 190 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n",
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
193 191 StackDesc->Reference.Value, ObjDesc));
194 192
195 193 /*
196 194 * Now we can delete the original Reference Object and
197 195 * replace it with the resolved value
198 196 */
199 197 AcpiUtRemoveReference (StackDesc);
200 198 *StackPtr = ObjDesc;
201 199 break;
202 200
203 -
204 201 case ACPI_REFCLASS_INDEX:
205 202
206 203 switch (StackDesc->Reference.TargetType)
207 204 {
208 205 case ACPI_TYPE_BUFFER_FIELD:
209 206
210 207 /* Just return - do not dereference */
211 208 break;
212 209
213 -
214 210 case ACPI_TYPE_PACKAGE:
215 211
216 212 /* If method call or CopyObject - do not dereference */
217 213
218 214 if ((WalkState->Opcode == AML_INT_METHODCALL_OP) ||
219 215 (WalkState->Opcode == AML_COPY_OP))
220 216 {
221 217 break;
222 218 }
223 219
224 220 /* Otherwise, dereference the PackageIndex to a package element */
225 221
226 222 ObjDesc = *StackDesc->Reference.Where;
227 223 if (ObjDesc)
228 224 {
229 225 /*
230 226 * Valid object descriptor, copy pointer to return value
231 227 * (i.e., dereference the package index)
232 228 * Delete the ref object, increment the returned object
233 229 */
234 230 AcpiUtRemoveReference (StackDesc);
235 231 AcpiUtAddReference (ObjDesc);
236 232 *StackPtr = ObjDesc;
237 233 }
238 234 else
239 235 {
240 236 /*
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
241 237 * A NULL object descriptor means an uninitialized element of
242 238 * the package, can't dereference it
243 239 */
244 240 ACPI_ERROR ((AE_INFO,
245 241 "Attempt to dereference an Index to NULL package element Idx=%p",
246 242 StackDesc));
247 243 Status = AE_AML_UNINITIALIZED_ELEMENT;
248 244 }
249 245 break;
250 246
251 -
252 247 default:
253 248
254 249 /* Invalid reference object */
255 250
256 251 ACPI_ERROR ((AE_INFO,
257 252 "Unknown TargetType 0x%X in Index/Reference object %p",
258 253 StackDesc->Reference.TargetType, StackDesc));
259 254 Status = AE_AML_INTERNAL;
260 255 break;
261 256 }
262 257 break;
263 258
264 -
265 259 case ACPI_REFCLASS_REFOF:
266 260 case ACPI_REFCLASS_DEBUG:
267 261 case ACPI_REFCLASS_TABLE:
268 262
269 263 /* Just leave the object as-is, do not dereference */
270 264
271 265 break;
272 266
273 267 case ACPI_REFCLASS_NAME: /* Reference to a named object */
274 268
275 269 /* Dereference the name */
276 270
277 271 if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) ||
278 272 (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL))
279 273 {
280 274 /* These node types do not have 'real' subobjects */
281 275
282 276 *StackPtr = (void *) StackDesc->Reference.Node;
283 277 }
284 278 else
285 279 {
286 280 /* Get the object pointed to by the namespace node */
287 281
288 282 *StackPtr = (StackDesc->Reference.Node)->Object;
289 283 AcpiUtAddReference (*StackPtr);
290 284 }
291 285
292 286 AcpiUtRemoveReference (StackDesc);
293 287 break;
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
294 288
295 289 default:
296 290
297 291 ACPI_ERROR ((AE_INFO,
298 292 "Unknown Reference type 0x%X in %p", RefType, StackDesc));
299 293 Status = AE_AML_INTERNAL;
300 294 break;
301 295 }
302 296 break;
303 297
304 -
305 298 case ACPI_TYPE_BUFFER:
306 299
307 300 Status = AcpiDsGetBufferArguments (StackDesc);
308 301 break;
309 302
310 -
311 303 case ACPI_TYPE_PACKAGE:
312 304
313 305 Status = AcpiDsGetPackageArguments (StackDesc);
314 306 break;
315 307
316 -
317 308 case ACPI_TYPE_BUFFER_FIELD:
318 309 case ACPI_TYPE_LOCAL_REGION_FIELD:
319 310 case ACPI_TYPE_LOCAL_BANK_FIELD:
320 311 case ACPI_TYPE_LOCAL_INDEX_FIELD:
321 312
322 313 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n",
323 314 StackDesc, StackDesc->Common.Type));
324 315
325 316 Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc);
326 317
327 318 /* Remove a reference to the original operand, then override */
328 319
329 320 AcpiUtRemoveReference (*StackPtr);
330 321 *StackPtr = (void *) ObjDesc;
331 322 break;
332 323
333 324 default:
325 +
334 326 break;
335 327 }
336 328
337 329 return_ACPI_STATUS (Status);
338 330 }
339 331
340 332
341 333 /*******************************************************************************
342 334 *
343 335 * FUNCTION: AcpiExResolveMultiple
344 336 *
345 337 * PARAMETERS: WalkState - Current state (contains AML opcode)
346 338 * Operand - Starting point for resolution
347 339 * ReturnType - Where the object type is returned
348 340 * ReturnDesc - Where the resolved object is returned
349 341 *
350 342 * RETURN: Status
351 343 *
352 - * DESCRIPTION: Return the base object and type. Traverse a reference list if
344 + * DESCRIPTION: Return the base object and type. Traverse a reference list if
353 345 * necessary to get to the base object.
354 346 *
355 347 ******************************************************************************/
356 348
357 349 ACPI_STATUS
358 350 AcpiExResolveMultiple (
359 351 ACPI_WALK_STATE *WalkState,
360 352 ACPI_OPERAND_OBJECT *Operand,
361 353 ACPI_OBJECT_TYPE *ReturnType,
362 354 ACPI_OPERAND_OBJECT **ReturnDesc)
363 355 {
364 356 ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand;
365 357 ACPI_NAMESPACE_NODE *Node;
366 358 ACPI_OBJECT_TYPE Type;
367 359 ACPI_STATUS Status;
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
368 360
369 361
370 362 ACPI_FUNCTION_TRACE (AcpiExResolveMultiple);
371 363
372 364
373 365 /* Operand can be either a namespace node or an operand descriptor */
374 366
375 367 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
376 368 {
377 369 case ACPI_DESC_TYPE_OPERAND:
370 +
378 371 Type = ObjDesc->Common.Type;
379 372 break;
380 373
381 374 case ACPI_DESC_TYPE_NAMED:
375 +
382 376 Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
383 377 ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
384 378
385 379 /* If we had an Alias node, use the attached object for type info */
386 380
387 381 if (Type == ACPI_TYPE_LOCAL_ALIAS)
388 382 {
389 383 Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
390 384 ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
391 385 }
392 386 break;
393 387
394 388 default:
395 389 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
396 390 }
397 391
398 392 /* If type is anything other than a reference, we are done */
399 393
400 394 if (Type != ACPI_TYPE_LOCAL_REFERENCE)
401 395 {
402 396 goto Exit;
403 397 }
404 398
405 399 /*
406 400 * For reference objects created via the RefOf, Index, or Load/LoadTable
407 401 * operators, we need to get to the base object (as per the ACPI
408 402 * specification of the ObjectType and SizeOf operators). This means
409 403 * traversing the list of possibly many nested references.
410 404 */
411 405 while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
412 406 {
413 407 switch (ObjDesc->Reference.Class)
414 408 {
415 409 case ACPI_REFCLASS_REFOF:
416 410 case ACPI_REFCLASS_NAME:
417 411
418 412 /* Dereference the reference pointer */
419 413
420 414 if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF)
421 415 {
422 416 Node = ObjDesc->Reference.Object;
423 417 }
424 418 else /* AML_INT_NAMEPATH_OP */
425 419 {
426 420 Node = ObjDesc->Reference.Node;
427 421 }
428 422
429 423 /* All "References" point to a NS node */
430 424
431 425 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
432 426 {
433 427 ACPI_ERROR ((AE_INFO,
434 428 "Not a namespace node %p [%s]",
435 429 Node, AcpiUtGetDescriptorName (Node)));
436 430 return_ACPI_STATUS (AE_AML_INTERNAL);
437 431 }
438 432
439 433 /* Get the attached object */
440 434
441 435 ObjDesc = AcpiNsGetAttachedObject (Node);
442 436 if (!ObjDesc)
443 437 {
444 438 /* No object, use the NS node type */
445 439
446 440 Type = AcpiNsGetType (Node);
447 441 goto Exit;
↓ open down ↓ |
56 lines elided |
↑ open up ↑ |
448 442 }
449 443
450 444 /* Check for circular references */
451 445
452 446 if (ObjDesc == Operand)
453 447 {
454 448 return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE);
455 449 }
456 450 break;
457 451
458 -
459 452 case ACPI_REFCLASS_INDEX:
460 453
461 454 /* Get the type of this reference (index into another object) */
462 455
463 456 Type = ObjDesc->Reference.TargetType;
464 457 if (Type != ACPI_TYPE_PACKAGE)
465 458 {
466 459 goto Exit;
467 460 }
468 461
469 462 /*
470 463 * The main object is a package, we want to get the type
471 464 * of the individual package element that is referenced by
472 465 * the index.
473 466 *
474 467 * This could of course in turn be another reference object.
475 468 */
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
476 469 ObjDesc = *(ObjDesc->Reference.Where);
477 470 if (!ObjDesc)
478 471 {
479 472 /* NULL package elements are allowed */
480 473
481 474 Type = 0; /* Uninitialized */
482 475 goto Exit;
483 476 }
484 477 break;
485 478
486 -
487 479 case ACPI_REFCLASS_TABLE:
488 480
489 481 Type = ACPI_TYPE_DDB_HANDLE;
490 482 goto Exit;
491 483
492 -
493 484 case ACPI_REFCLASS_LOCAL:
494 485 case ACPI_REFCLASS_ARG:
495 486
496 487 if (ReturnDesc)
497 488 {
498 489 Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class,
499 490 ObjDesc->Reference.Value, WalkState, &ObjDesc);
500 491 if (ACPI_FAILURE (Status))
501 492 {
502 493 return_ACPI_STATUS (Status);
503 494 }
504 495 AcpiUtRemoveReference (ObjDesc);
505 496 }
506 497 else
507 498 {
508 499 Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class,
509 500 ObjDesc->Reference.Value, WalkState, &Node);
510 501 if (ACPI_FAILURE (Status))
511 502 {
512 503 return_ACPI_STATUS (Status);
513 504 }
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
514 505
515 506 ObjDesc = AcpiNsGetAttachedObject (Node);
516 507 if (!ObjDesc)
517 508 {
518 509 Type = ACPI_TYPE_ANY;
519 510 goto Exit;
520 511 }
521 512 }
522 513 break;
523 514
524 -
525 515 case ACPI_REFCLASS_DEBUG:
526 516
527 517 /* The Debug Object is of type "DebugObject" */
528 518
529 519 Type = ACPI_TYPE_DEBUG_OBJECT;
530 520 goto Exit;
531 521
532 -
533 522 default:
534 523
535 524 ACPI_ERROR ((AE_INFO,
536 525 "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class));
537 526 return_ACPI_STATUS (AE_AML_INTERNAL);
538 527 }
539 528 }
540 529
541 530 /*
542 531 * Now we are guaranteed to have an object that has not been created
543 532 * via the RefOf or Index operators.
544 533 */
545 534 Type = ObjDesc->Common.Type;
546 535
547 536
548 537 Exit:
549 538 /* Convert internal types to external types */
550 539
551 540 switch (Type)
552 541 {
553 542 case ACPI_TYPE_LOCAL_REGION_FIELD:
554 543 case ACPI_TYPE_LOCAL_BANK_FIELD:
555 544 case ACPI_TYPE_LOCAL_INDEX_FIELD:
556 545
557 546 Type = ACPI_TYPE_FIELD_UNIT;
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
558 547 break;
559 548
560 549 case ACPI_TYPE_LOCAL_SCOPE:
561 550
562 551 /* Per ACPI Specification, Scope is untyped */
563 552
564 553 Type = ACPI_TYPE_ANY;
565 554 break;
566 555
567 556 default:
557 +
568 558 /* No change to Type required */
559 +
569 560 break;
570 561 }
571 562
572 563 *ReturnType = Type;
573 564 if (ReturnDesc)
574 565 {
575 566 *ReturnDesc = ObjDesc;
576 567 }
577 568 return_ACPI_STATUS (AE_OK);
578 569 }
579 -
580 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX