Deleted Added
full compact
dsutils.c (99146) dsutils.c (99679)
1/*******************************************************************************
2 *
3 * Module Name: dsutils - Dispatcher utilities
1/*******************************************************************************
2 *
3 * Module Name: dsutils - Dispatcher utilities
4 * $Revision: 89 $
4 * $Revision: 93 $
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.

--- 149 unchanged lines hidden (view full) ---

162 }
163
164 /*
165 * If there is no parent, the result can't possibly be used!
166 * (An executing method typically has no parent, since each
167 * method is parsed separately) However, a method that is
168 * invoked from another method has a parent.
169 */
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.

--- 149 unchanged lines hidden (view full) ---

162 }
163
164 /*
165 * If there is no parent, the result can't possibly be used!
166 * (An executing method typically has no parent, since each
167 * method is parsed separately) However, a method that is
168 * invoked from another method has a parent.
169 */
170 if (!Op->Parent)
170 if (!Op->Common.Parent)
171 {
172 return_VALUE (FALSE);
173 }
174
175 /*
176 * Get info on the parent. The root Op is AML_SCOPE
177 */
171 {
172 return_VALUE (FALSE);
173 }
174
175 /*
176 * Get info on the parent. The root Op is AML_SCOPE
177 */
178 ParentInfo = AcpiPsGetOpcodeInfo (Op->Parent->Opcode);
178 ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
179 if (ParentInfo->Class == AML_CLASS_UNKNOWN)
180 {
181 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown parent opcode. Op=%p\n", Op));
182 return_VALUE (FALSE);
183 }
184
185 /*
186 * Decide what to do with the result based on the parent. If
187 * the parent opcode will not use the result, delete the object.
188 * Otherwise leave it as is, it will be deleted when it is used
189 * as an operand later.
190 */
191 switch (ParentInfo->Class)
192 {
193 case AML_CLASS_CONTROL:
194
179 if (ParentInfo->Class == AML_CLASS_UNKNOWN)
180 {
181 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown parent opcode. Op=%p\n", Op));
182 return_VALUE (FALSE);
183 }
184
185 /*
186 * Decide what to do with the result based on the parent. If
187 * the parent opcode will not use the result, delete the object.
188 * Otherwise leave it as is, it will be deleted when it is used
189 * as an operand later.
190 */
191 switch (ParentInfo->Class)
192 {
193 case AML_CLASS_CONTROL:
194
195 switch (Op->Parent->Opcode)
195 switch (Op->Common.Parent->Common.AmlOpcode)
196 {
197 case AML_RETURN_OP:
198
199 /* Never delete the return value associated with a return opcode */
200
201 goto ResultUsed;
202
203 case AML_IF_OP:
204 case AML_WHILE_OP:
205
206 /*
207 * If we are executing the predicate AND this is the predicate op,
208 * we will use the return value
209 */
210 if ((WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) &&
211 (WalkState->ControlState->Control.PredicateOp == Op))
212 {
213 goto ResultUsed;
214 }
196 {
197 case AML_RETURN_OP:
198
199 /* Never delete the return value associated with a return opcode */
200
201 goto ResultUsed;
202
203 case AML_IF_OP:
204 case AML_WHILE_OP:
205
206 /*
207 * If we are executing the predicate AND this is the predicate op,
208 * we will use the return value
209 */
210 if ((WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) &&
211 (WalkState->ControlState->Control.PredicateOp == Op))
212 {
213 goto ResultUsed;
214 }
215 break;
216
217 default:
218 /* Ignore other control opcodes */
219 break;
215 }
216
217 /* The general control opcode returns no result */
218
219 goto ResultNotUsed;
220
221
222 case AML_CLASS_CREATE:
223
224 /*
225 * These opcodes allow TermArg(s) as operands and therefore
226 * the operands can be method calls. The result is used.
227 */
228 goto ResultUsed;
229
230
231 case AML_CLASS_NAMED_OBJECT:
232
220 }
221
222 /* The general control opcode returns no result */
223
224 goto ResultNotUsed;
225
226
227 case AML_CLASS_CREATE:
228
229 /*
230 * These opcodes allow TermArg(s) as operands and therefore
231 * the operands can be method calls. The result is used.
232 */
233 goto ResultUsed;
234
235
236 case AML_CLASS_NAMED_OBJECT:
237
233 if ((Op->Parent->Opcode == AML_REGION_OP) ||
234 (Op->Parent->Opcode == AML_DATA_REGION_OP) ||
235 (Op->Parent->Opcode == AML_PACKAGE_OP) ||
236 (Op->Parent->Opcode == AML_VAR_PACKAGE_OP) ||
237 (Op->Parent->Opcode == AML_BUFFER_OP) ||
238 (Op->Parent->Opcode == AML_INT_EVAL_SUBTREE_OP))
238 if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) ||
239 (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) ||
240 (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
241 (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) ||
242 (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) ||
243 (Op->Common.Parent->Common.AmlOpcode == AML_INT_EVAL_SUBTREE_OP))
239 {
240 /*
241 * These opcodes allow TermArg(s) as operands and therefore
242 * the operands can be method calls. The result is used.
243 */
244 goto ResultUsed;
245 }
246

--- 7 unchanged lines hidden (view full) ---

254 * object, so keep it.
255 */
256 goto ResultUsed;
257 }
258
259
260ResultUsed:
261 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] used by Parent [%s] Op=%p\n",
244 {
245 /*
246 * These opcodes allow TermArg(s) as operands and therefore
247 * the operands can be method calls. The result is used.
248 */
249 goto ResultUsed;
250 }
251

--- 7 unchanged lines hidden (view full) ---

259 * object, so keep it.
260 */
261 goto ResultUsed;
262 }
263
264
265ResultUsed:
266 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] used by Parent [%s] Op=%p\n",
262 AcpiPsGetOpcodeName (Op->Opcode),
263 AcpiPsGetOpcodeName (Op->Parent->Opcode), Op));
267 AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
268 AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op));
264
265 return_VALUE (TRUE);
266
267
268ResultNotUsed:
269 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] not used by Parent [%s] Op=%p\n",
269
270 return_VALUE (TRUE);
271
272
273ResultNotUsed:
274 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] not used by Parent [%s] Op=%p\n",
270 AcpiPsGetOpcodeName (Op->Opcode),
271 AcpiPsGetOpcodeName (Op->Parent->Opcode), Op));
275 AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
276 AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op));
272
273 return_VALUE (FALSE);
274
275}
276
277
278/*******************************************************************************
279 *

--- 71 unchanged lines hidden (view full) ---

351
352ACPI_STATUS
353AcpiDsCreateOperand (
354 ACPI_WALK_STATE *WalkState,
355 ACPI_PARSE_OBJECT *Arg,
356 UINT32 ArgIndex)
357{
358 ACPI_STATUS Status = AE_OK;
277
278 return_VALUE (FALSE);
279
280}
281
282
283/*******************************************************************************
284 *

--- 71 unchanged lines hidden (view full) ---

356
357ACPI_STATUS
358AcpiDsCreateOperand (
359 ACPI_WALK_STATE *WalkState,
360 ACPI_PARSE_OBJECT *Arg,
361 UINT32 ArgIndex)
362{
363 ACPI_STATUS Status = AE_OK;
364 ACPI_STATUS Status2;
359 NATIVE_CHAR *NameString;
360 UINT32 NameLength;
361 ACPI_OPERAND_OBJECT *ObjDesc;
362 ACPI_PARSE_OBJECT *ParentOp;
363 UINT16 Opcode;
364 ACPI_INTERPRETER_MODE InterpreterMode;
365 const ACPI_OPCODE_INFO *OpInfo;
366 char *Name;
367
368
369 ACPI_FUNCTION_TRACE_PTR ("DsCreateOperand", Arg);
370
371
372 /* A valid name must be looked up in the namespace */
373
365 NATIVE_CHAR *NameString;
366 UINT32 NameLength;
367 ACPI_OPERAND_OBJECT *ObjDesc;
368 ACPI_PARSE_OBJECT *ParentOp;
369 UINT16 Opcode;
370 ACPI_INTERPRETER_MODE InterpreterMode;
371 const ACPI_OPCODE_INFO *OpInfo;
372 char *Name;
373
374
375 ACPI_FUNCTION_TRACE_PTR ("DsCreateOperand", Arg);
376
377
378 /* A valid name must be looked up in the namespace */
379
374 if ((Arg->Opcode == AML_INT_NAMEPATH_OP) &&
375 (Arg->Value.String))
380 if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
381 (Arg->Common.Value.String))
376 {
377 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", Arg));
378
379 /* Get the entire name string from the AML stream */
380
382 {
383 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", Arg));
384
385 /* Get the entire name string from the AML stream */
386
381 Status = AcpiExGetNameString (ACPI_TYPE_ANY, Arg->Value.Buffer,
387 Status = AcpiExGetNameString (ACPI_TYPE_ANY, Arg->Common.Value.Buffer,
382 &NameString, &NameLength);
383
384 if (ACPI_FAILURE (Status))
385 {
386 return_ACPI_STATUS (Status);
387 }
388
389 /*
390 * All prefixes have been handled, and the name is
391 * in NameString
392 */
393
394 /*
395 * Differentiate between a namespace "create" operation
396 * versus a "lookup" operation (IMODE_LOAD_PASS2 vs.
397 * IMODE_EXECUTE) in order to support the creation of
398 * namespace objects during the execution of control methods.
399 */
388 &NameString, &NameLength);
389
390 if (ACPI_FAILURE (Status))
391 {
392 return_ACPI_STATUS (Status);
393 }
394
395 /*
396 * All prefixes have been handled, and the name is
397 * in NameString
398 */
399
400 /*
401 * Differentiate between a namespace "create" operation
402 * versus a "lookup" operation (IMODE_LOAD_PASS2 vs.
403 * IMODE_EXECUTE) in order to support the creation of
404 * namespace objects during the execution of control methods.
405 */
400 ParentOp = Arg->Parent;
401 OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Opcode);
406 ParentOp = Arg->Common.Parent;
407 OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode);
402 if ((OpInfo->Flags & AML_NSNODE) &&
408 if ((OpInfo->Flags & AML_NSNODE) &&
403 (ParentOp->Opcode != AML_INT_METHODCALL_OP) &&
404 (ParentOp->Opcode != AML_REGION_OP) &&
405 (ParentOp->Opcode != AML_INT_NAMEPATH_OP))
409 (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) &&
410 (ParentOp->Common.AmlOpcode != AML_REGION_OP) &&
411 (ParentOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP))
406 {
407 /* Enter name into namespace if not found */
408
409 InterpreterMode = ACPI_IMODE_LOAD_PASS2;
410 }
411
412 else
413 {
414 /* Return a failure if name not found */
415
416 InterpreterMode = ACPI_IMODE_EXECUTE;
417 }
418
419 Status = AcpiNsLookup (WalkState->ScopeInfo, NameString,
420 ACPI_TYPE_ANY, InterpreterMode,
421 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
422 WalkState,
412 {
413 /* Enter name into namespace if not found */
414
415 InterpreterMode = ACPI_IMODE_LOAD_PASS2;
416 }
417
418 else
419 {
420 /* Return a failure if name not found */
421
422 InterpreterMode = ACPI_IMODE_EXECUTE;
423 }
424
425 Status = AcpiNsLookup (WalkState->ScopeInfo, NameString,
426 ACPI_TYPE_ANY, InterpreterMode,
427 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
428 WalkState,
423 (ACPI_NAMESPACE_NODE **) &ObjDesc);
429 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc));
424 /*
425 * The only case where we pass through (ignore) a NOT_FOUND
426 * error is for the CondRefOf opcode.
427 */
428 if (Status == AE_NOT_FOUND)
429 {
430 /*
431 * The only case where we pass through (ignore) a NOT_FOUND
432 * error is for the CondRefOf opcode.
433 */
434 if (Status == AE_NOT_FOUND)
435 {
430 if (ParentOp->Opcode == AML_COND_REF_OF_OP)
436 if (ParentOp->Common.AmlOpcode == AML_COND_REF_OF_OP)
431 {
432 /*
433 * For the Conditional Reference op, it's OK if
434 * the name is not found; We just need a way to
435 * indicate this to the interpreter, set the
436 * object to the root
437 */
437 {
438 /*
439 * For the Conditional Reference op, it's OK if
440 * the name is not found; We just need a way to
441 * indicate this to the interpreter, set the
442 * object to the root
443 */
438 ObjDesc = (ACPI_OPERAND_OBJECT *) AcpiGbl_RootNode;
444 ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, AcpiGbl_RootNode);
439 Status = AE_OK;
440 }
441
442 else
443 {
444 /*
445 * We just plain didn't find it -- which is a
446 * very serious error at this point
447 */
448 Status = AE_AML_NAME_NOT_FOUND;
449
450 Name = NULL;
445 Status = AE_OK;
446 }
447
448 else
449 {
450 /*
451 * We just plain didn't find it -- which is a
452 * very serious error at this point
453 */
454 Status = AE_AML_NAME_NOT_FOUND;
455
456 Name = NULL;
451 AcpiNsExternalizeName (ACPI_UINT32_MAX, NameString, NULL, &Name);
452 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
453 "Object name [%s] was not found in namespace\n", Name));
454 ACPI_MEM_FREE (Name);
457 Status2 = AcpiNsExternalizeName (ACPI_UINT32_MAX, NameString, NULL, &Name);
458 if (ACPI_SUCCESS (Status2))
459 {
460 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
461 "Object name [%s] was not found in namespace\n", Name));
462 ACPI_MEM_FREE (Name);
463 }
455 }
456 }
457
458 /* Free the namestring created above */
459
460 ACPI_MEM_FREE (NameString);
461
462 /* Check status from the lookup */

--- 13 unchanged lines hidden (view full) ---

476 ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState));
477 }
478
479
480 else
481 {
482 /* Check for null name case */
483
464 }
465 }
466
467 /* Free the namestring created above */
468
469 ACPI_MEM_FREE (NameString);
470
471 /* Check status from the lookup */

--- 13 unchanged lines hidden (view full) ---

485 ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState));
486 }
487
488
489 else
490 {
491 /* Check for null name case */
492
484 if (Arg->Opcode == AML_INT_NAMEPATH_OP)
493 if (Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
485 {
486 /*
487 * If the name is null, this means that this is an
488 * optional result parameter that was not specified
494 {
495 /*
496 * If the name is null, this means that this is an
497 * optional result parameter that was not specified
489 * in the original ASL. Create an Reference for a
490 * placeholder
498 * in the original ASL. Create a Zero Constant for a
499 * placeholder. (Store to a constant is a Noop.)
491 */
492 Opcode = AML_ZERO_OP; /* Has no arguments! */
493
494 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Null namepath: Arg=%p\n", Arg));
495 }
496
497 else
498 {
500 */
501 Opcode = AML_ZERO_OP; /* Has no arguments! */
502
503 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Null namepath: Arg=%p\n", Arg));
504 }
505
506 else
507 {
499 Opcode = Arg->Opcode;
508 Opcode = Arg->Common.AmlOpcode;
500 }
501
502 /* Get the object type of the argument */
503
504 OpInfo = AcpiPsGetOpcodeInfo (Opcode);
505 if (OpInfo->ObjectType == INTERNAL_TYPE_INVALID)
506 {
507 return_ACPI_STATUS (AE_NOT_IMPLEMENTED);

--- 18 unchanged lines hidden (view full) ---

526 * Only error is underflow, and this indicates
527 * a missing or null operand!
528 */
529 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Missing or null operand, %s\n",
530 AcpiFormatException (Status)));
531 return_ACPI_STATUS (Status);
532 }
533 }
509 }
510
511 /* Get the object type of the argument */
512
513 OpInfo = AcpiPsGetOpcodeInfo (Opcode);
514 if (OpInfo->ObjectType == INTERNAL_TYPE_INVALID)
515 {
516 return_ACPI_STATUS (AE_NOT_IMPLEMENTED);

--- 18 unchanged lines hidden (view full) ---

535 * Only error is underflow, and this indicates
536 * a missing or null operand!
537 */
538 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Missing or null operand, %s\n",
539 AcpiFormatException (Status)));
540 return_ACPI_STATUS (Status);
541 }
542 }
534
535 else
536 {
537 /* Create an ACPI_INTERNAL_OBJECT for the argument */
538
539 ObjDesc = AcpiUtCreateInternalObject (OpInfo->ObjectType);
540 if (!ObjDesc)
541 {
542 return_ACPI_STATUS (AE_NO_MEMORY);
543 }
544
545 /* Initialize the new object */
546
547 Status = AcpiDsInitObjectFromOp (WalkState, Arg,
548 Opcode, &ObjDesc);
549 if (ACPI_FAILURE (Status))
550 {
551 AcpiUtDeleteObjectDesc (ObjDesc);
552 return_ACPI_STATUS (Status);
553 }
543 else
544 {
545 /* Create an ACPI_INTERNAL_OBJECT for the argument */
546
547 ObjDesc = AcpiUtCreateInternalObject (OpInfo->ObjectType);
548 if (!ObjDesc)
549 {
550 return_ACPI_STATUS (AE_NO_MEMORY);
551 }
552
553 /* Initialize the new object */
554
555 Status = AcpiDsInitObjectFromOp (WalkState, Arg,
556 Opcode, &ObjDesc);
557 if (ACPI_FAILURE (Status))
558 {
559 AcpiUtDeleteObjectDesc (ObjDesc);
560 return_ACPI_STATUS (Status);
561 }
554 }
562 }
555
556 /* Put the operand object on the object stack */
557
558 Status = AcpiDsObjStackPush (ObjDesc, WalkState);
559 if (ACPI_FAILURE (Status))
560 {
561 return_ACPI_STATUS (Status);
562 }

--- 43 unchanged lines hidden (view full) ---

606 goto Cleanup;
607 }
608
609 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n",
610 ArgCount, Arg, FirstArg));
611
612 /* Move on to next argument, if any */
613
563
564 /* Put the operand object on the object stack */
565
566 Status = AcpiDsObjStackPush (ObjDesc, WalkState);
567 if (ACPI_FAILURE (Status))
568 {
569 return_ACPI_STATUS (Status);
570 }

--- 43 unchanged lines hidden (view full) ---

614 goto Cleanup;
615 }
616
617 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n",
618 ArgCount, Arg, FirstArg));
619
620 /* Move on to next argument, if any */
621
614 Arg = Arg->Next;
622 Arg = Arg->Common.Next;
615 ArgCount++;
616 }
617
618 return_ACPI_STATUS (Status);
619
620
621Cleanup:
622 /*
623 * We must undo everything done above; meaning that we must
624 * pop everything off of the operand stack and delete those
625 * objects
626 */
623 ArgCount++;
624 }
625
626 return_ACPI_STATUS (Status);
627
628
629Cleanup:
630 /*
631 * We must undo everything done above; meaning that we must
632 * pop everything off of the operand stack and delete those
633 * objects
634 */
627 AcpiDsObjStackPopAndDelete (ArgCount, WalkState);
635 (void) AcpiDsObjStackPopAndDelete (ArgCount, WalkState);
628
629 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While creating Arg %d - %s\n",
630 (ArgCount + 1), AcpiFormatException (Status)));
631 return_ACPI_STATUS (Status);
632}
633
634
635/*******************************************************************************

--- 40 unchanged lines hidden ---
636
637 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While creating Arg %d - %s\n",
638 (ArgCount + 1), AcpiFormatException (Status)));
639 return_ACPI_STATUS (Status);
640}
641
642
643/*******************************************************************************

--- 40 unchanged lines hidden ---