Deleted Added
sdiff udiff text old ( 99146 ) new ( 99679 )
full compact
1/*******************************************************************************
2 *
3 * Module Name: dsutils - Dispatcher utilities
4 * $Revision: 89 $
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)
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);
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)
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 }
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
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))
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",
262 AcpiPsGetOpcodeName (Op->Opcode),
263 AcpiPsGetOpcodeName (Op->Parent->Opcode), 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",
270 AcpiPsGetOpcodeName (Op->Opcode),
271 AcpiPsGetOpcodeName (Op->Parent->Opcode), 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;
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
374 if ((Arg->Opcode == AML_INT_NAMEPATH_OP) &&
375 (Arg->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
381 Status = AcpiExGetNameString (ACPI_TYPE_ANY, Arg->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 */
400 ParentOp = Arg->Parent;
401 OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Opcode);
402 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))
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,
423 (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 if (ParentOp->Opcode == 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 */
438 ObjDesc = (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;
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);
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
484 if (Arg->Opcode == 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
489 * in the original ASL. Create an Reference for a
490 * placeholder
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 {
499 Opcode = Arg->Opcode;
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 }
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 }
554 }
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
614 Arg = Arg->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 */
627 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 ---