Deleted Added
sdiff udiff text old ( 80062 ) new ( 82367 )
full compact
1/*******************************************************************************
2 *
3 * Module Name: dsutils - Dispatcher utilities
4 * $Revision: 62 $
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#define __DSUTILS_C__
118
119#include "acpi.h"
120#include "acparser.h"
121#include "amlcode.h"
122#include "acdispat.h"
123#include "acinterp.h"
124#include "acnamesp.h"
125#include "acdebug.h"
126
127#define _COMPONENT ACPI_DISPATCHER
128 MODULE_NAME ("dsutils")
129
130
131/*******************************************************************************
132 *
133 * FUNCTION: AcpiDsIsResultUsed
134 *
135 * PARAMETERS: Op
136 * ResultObj
137 * WalkState
138 *
139 * RETURN: Status
140 *
141 * DESCRIPTION: Check if a result object will be used by the parent
142 *
143 ******************************************************************************/
144
145BOOLEAN
146AcpiDsIsResultUsed (
147 ACPI_PARSE_OBJECT *Op,
148 ACPI_WALK_STATE *WalkState)
149{
150 ACPI_OPCODE_INFO *ParentInfo;
151
152
153 FUNCTION_TRACE_PTR ("DsIsResultUsed", Op);
154
155
156 /* Must have both an Op and a Result Object */
157
158 if (!Op)
159 {
160 DEBUG_PRINTP (ACPI_ERROR, ("Null Op\n"));
161 return_VALUE (TRUE);
162 }
163
164
165 /*
166 * If there is no parent, the result can't possibly be used!
167 * (An executing method typically has no parent, since each
168 * method is parsed separately) However, a method that is
169 * invoked from another method has a parent.
170 */
171 if (!Op->Parent)
172 {
173 return_VALUE (FALSE);
174 }
175
176
177 /*
178 * Get info on the parent. The root Op is AML_SCOPE
179 */
180
181 ParentInfo = AcpiPsGetOpcodeInfo (Op->Parent->Opcode);
182 if (ACPI_GET_OP_TYPE (ParentInfo) != ACPI_OP_TYPE_OPCODE)
183 {
184 DEBUG_PRINTP (ACPI_ERROR, ("Unknown parent opcode. Op=%X\n", Op));
185 return_VALUE (FALSE);
186 }
187
188
189 /*
190 * Decide what to do with the result based on the parent. If
191 * the parent opcode will not use the result, delete the object.
192 * Otherwise leave it as is, it will be deleted when it is used
193 * as an operand later.
194 */
195
196 switch (ACPI_GET_OP_CLASS (ParentInfo))
197 {
198 /*
199 * In these cases, the parent will never use the return object
200 */
201 case OPTYPE_CONTROL: /* IF, ELSE, WHILE only */
202
203 switch (Op->Parent->Opcode)
204 {
205 case AML_RETURN_OP:
206
207 /* Never delete the return value associated with a return opcode */
208
209 DEBUG_PRINTP (TRACE_DISPATCH,
210 ("Result used, [RETURN] opcode=%X Op=%X\n", Op->Opcode, Op));
211 return_VALUE (TRUE);
212 break;
213
214 case AML_IF_OP:
215 case AML_WHILE_OP:
216
217 /*
218 * If we are executing the predicate AND this is the predicate op,
219 * we will use the return value!
220 */
221
222 if ((WalkState->ControlState->Common.State == CONTROL_PREDICATE_EXECUTING) &&
223 (WalkState->ControlState->Control.PredicateOp == Op))
224 {
225 DEBUG_PRINTP (TRACE_DISPATCH,
226 ("Result used as a predicate, [IF/WHILE] opcode=%X Op=%X\n",
227 Op->Opcode, Op));
228 return_VALUE (TRUE);
229 }
230
231 break;
232 }
233
234
235 /* Fall through to not used case below */
236
237
238 case OPTYPE_NAMED_OBJECT: /* Scope, method, etc. */
239
240 /*
241 * These opcodes allow TermArg(s) as operands and therefore
242 * method calls. The result is used.
243 */
244 if ((Op->Parent->Opcode == AML_REGION_OP) ||
245 (Op->Parent->Opcode == AML_CREATE_FIELD_OP) ||
246 (Op->Parent->Opcode == AML_CREATE_BIT_FIELD_OP) ||
247 (Op->Parent->Opcode == AML_CREATE_BYTE_FIELD_OP) ||
248 (Op->Parent->Opcode == AML_CREATE_WORD_FIELD_OP) ||
249 (Op->Parent->Opcode == AML_CREATE_DWORD_FIELD_OP) ||
250 (Op->Parent->Opcode == AML_CREATE_QWORD_FIELD_OP))
251 {
252 DEBUG_PRINTP (TRACE_DISPATCH,
253 ("Result used, [Region or CreateField] opcode=%X Op=%X\n",
254 Op->Opcode, Op));
255 return_VALUE (TRUE);
256 }
257
258 DEBUG_PRINTP (TRACE_DISPATCH,
259 ("Result not used, Parent opcode=%X Op=%X\n", Op->Opcode, Op));
260
261 return_VALUE (FALSE);
262 break;
263
264 /*
265 * In all other cases. the parent will actually use the return
266 * object, so keep it.
267 */
268 default:
269 break;
270 }
271
272 return_VALUE (TRUE);
273}
274
275
276/*******************************************************************************
277 *
278 * FUNCTION: AcpiDsDeleteResultIfNotUsed
279 *
280 * PARAMETERS: Op
281 * ResultObj
282 * WalkState
283 *
284 * RETURN: Status
285 *
286 * DESCRIPTION: Used after interpretation of an opcode. If there is an internal
287 * result descriptor, check if the parent opcode will actually use
288 * this result. If not, delete the result now so that it will
289 * not become orphaned.
290 *
291 ******************************************************************************/
292
293void
294AcpiDsDeleteResultIfNotUsed (
295 ACPI_PARSE_OBJECT *Op,
296 ACPI_OPERAND_OBJECT *ResultObj,
297 ACPI_WALK_STATE *WalkState)
298{
299 ACPI_OPERAND_OBJECT *ObjDesc;
300 ACPI_STATUS Status;
301
302
303 FUNCTION_TRACE_PTR ("DsDeleteResultIfNotUsed", ResultObj);
304
305
306 if (!Op)
307 {
308 DEBUG_PRINTP (ACPI_ERROR, ("Null Op\n"));
309 return_VOID;
310 }
311
312 if (!ResultObj)
313 {
314 return_VOID;
315 }
316
317
318 if (!AcpiDsIsResultUsed (Op, WalkState))
319 {
320 /*
321 * Must pop the result stack (ObjDesc should be equal
322 * to ResultObj)
323 */
324
325 Status = AcpiDsResultPop (&ObjDesc, WalkState);
326 if (ACPI_SUCCESS (Status))
327 {
328 AcpiUtRemoveReference (ResultObj);
329 }
330 }
331
332 return_VOID;
333}
334
335
336/*******************************************************************************
337 *
338 * FUNCTION: AcpiDsCreateOperand
339 *
340 * PARAMETERS: WalkState
341 * Arg
342 *
343 * RETURN: Status
344 *
345 * DESCRIPTION: Translate a parse tree object that is an argument to an AML
346 * opcode to the equivalent interpreter object. This may include
347 * looking up a name or entering a new name into the internal
348 * namespace.
349 *
350 ******************************************************************************/
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_OBJECT_TYPE8 DataType;
362 ACPI_OPERAND_OBJECT *ObjDesc;
363 ACPI_PARSE_OBJECT *ParentOp;
364 UINT16 Opcode;
365 UINT32 Flags;
366 OPERATING_MODE InterpreterMode;
367
368
369 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 DEBUG_PRINTP (TRACE_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
401 ParentOp = Arg->Parent;
402 if ((AcpiPsIsNodeOp (ParentOp->Opcode)) &&
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 = IMODE_LOAD_PASS2;
410 }
411
412 else
413 {
414 /* Return a failure if name not found */
415
416 InterpreterMode = IMODE_EXECUTE;
417 }
418
419 Status = AcpiNsLookup (WalkState->ScopeInfo, NameString,
420 ACPI_TYPE_ANY, InterpreterMode,
421 NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE,
422 WalkState,
423 (ACPI_NAMESPACE_NODE **) &ObjDesc);
424
425 /* Free the namestring created above */
426
427 ACPI_MEM_FREE (NameString);
428
429 /*
430 * The only case where we pass through (ignore) a NOT_FOUND
431 * error is for the CondRefOf opcode.
432 */
433
434 if (Status == AE_NOT_FOUND)
435 {
436 if (ParentOp->Opcode == AML_COND_REF_OF_OP)
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 */
444 ObjDesc = (ACPI_OPERAND_OBJECT *) AcpiGbl_RootNode;
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 }
457
458 /* Check status from the lookup */
459
460 if (ACPI_FAILURE (Status))
461 {
462 return_ACPI_STATUS (Status);
463 }
464
465 /* Put the resulting object onto the current object stack */
466
467 Status = AcpiDsObjStackPush (ObjDesc, WalkState);
468 if (ACPI_FAILURE (Status))
469 {
470 return_ACPI_STATUS (Status);
471 }
472 DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState));
473 }
474
475
476 else
477 {
478 /* Check for null name case */
479
480 if (Arg->Opcode == AML_INT_NAMEPATH_OP)
481 {
482 /*
483 * If the name is null, this means that this is an
484 * optional result parameter that was not specified
485 * in the original ASL. Create an Reference for a
486 * placeholder
487 */
488 Opcode = AML_ZERO_OP; /* Has no arguments! */
489
490 DEBUG_PRINTP (TRACE_DISPATCH, ("Null namepath: Arg=%p\n", Arg));
491
492 /*
493 * TBD: [Investigate] anything else needed for the
494 * zero op lvalue?
495 */
496 }
497
498 else
499 {
500 Opcode = Arg->Opcode;
501 }
502
503
504 /* Get the data type of the argument */
505
506 DataType = AcpiDsMapOpcodeToDataType (Opcode, &Flags);
507 if (DataType == INTERNAL_TYPE_INVALID)
508 {
509 return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
510 }
511
512 if (Flags & OP_HAS_RETURN_VALUE)
513 {
514 DEBUG_PRINTP (TRACE_DISPATCH,
515 ("Argument previously created, already stacked \n"));
516
517 DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (WalkState->Operands [WalkState->NumOperands - 1], WalkState));
518
519 /*
520 * Use value that was already previously returned
521 * by the evaluation of this argument
522 */
523 Status = AcpiDsResultPopFromBottom (&ObjDesc, WalkState);
524 if (ACPI_FAILURE (Status))
525 {
526 /*
527 * Only error is underflow, and this indicates
528 * a missing or null operand!
529 */
530 DEBUG_PRINTP (ACPI_ERROR, ("Missing or null operand, %s\n",
531 AcpiFormatException (Status)));
532 return_ACPI_STATUS (Status);
533 }
534
535 }
536
537 else
538 {
539 /* Create an ACPI_INTERNAL_OBJECT for the argument */
540
541 ObjDesc = AcpiUtCreateInternalObject (DataType);
542 if (!ObjDesc)
543 {
544 return_ACPI_STATUS (AE_NO_MEMORY);
545 }
546
547 /* Initialize the new object */
548
549 Status = AcpiDsInitObjectFromOp (WalkState, Arg,
550 Opcode, &ObjDesc);
551 if (ACPI_FAILURE (Status))
552 {
553 AcpiUtDeleteObjectDesc (ObjDesc);
554 return_ACPI_STATUS (Status);
555 }
556 }
557
558 /* Put the operand object on the object stack */
559
560 Status = AcpiDsObjStackPush (ObjDesc, WalkState);
561 if (ACPI_FAILURE (Status))
562 {
563 return_ACPI_STATUS (Status);
564 }
565
566 DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState));
567 }
568
569 return_ACPI_STATUS (AE_OK);
570}
571
572
573/*******************************************************************************
574 *
575 * FUNCTION: AcpiDsCreateOperands
576 *
577 * PARAMETERS: FirstArg - First argument of a parser argument tree
578 *
579 * RETURN: Status
580 *
581 * DESCRIPTION: Convert an operator's arguments from a parse tree format to
582 * namespace objects and place those argument object on the object
583 * stack in preparation for evaluation by the interpreter.
584 *
585 ******************************************************************************/
586
587ACPI_STATUS
588AcpiDsCreateOperands (
589 ACPI_WALK_STATE *WalkState,
590 ACPI_PARSE_OBJECT *FirstArg)
591{
592 ACPI_STATUS Status = AE_OK;
593 ACPI_PARSE_OBJECT *Arg;
594 UINT32 ArgCount = 0;
595
596
597 FUNCTION_TRACE_PTR ("DsCreateOperands", FirstArg);
598
599 /* For all arguments in the list... */
600
601 Arg = FirstArg;
602 while (Arg)
603 {
604 Status = AcpiDsCreateOperand (WalkState, Arg, ArgCount);
605 if (ACPI_FAILURE (Status))
606 {
607 goto Cleanup;
608 }
609
610 DEBUG_PRINTP (TRACE_DISPATCH, ("Arg #%d (%p) done, Arg1=%p\n",
611 ArgCount, Arg, FirstArg));
612
613 /* Move on to next argument, if any */
614
615 Arg = Arg->Next;
616 ArgCount++;
617 }
618
619 return_ACPI_STATUS (Status);
620
621
622Cleanup:
623 /*
624 * We must undo everything done above; meaning that we must
625 * pop everything off of the operand stack and delete those
626 * objects
627 */
628
629 AcpiDsObjStackPopAndDelete (ArgCount, WalkState);
630
631 DEBUG_PRINTP (ACPI_ERROR, ("While creating Arg %d - %s\n",
632 (ArgCount + 1), AcpiFormatException (Status)));
633 return_ACPI_STATUS (Status);
634}
635
636
637/*******************************************************************************
638 *
639 * FUNCTION: AcpiDsResolveOperands
640 *
641 * PARAMETERS: WalkState - Current walk state with operands on stack
642 *
643 * RETURN: Status
644 *
645 * DESCRIPTION: Resolve all operands to their values. Used to prepare
646 * arguments to a control method invocation (a call from one
647 * method to another.)
648 *
649 ******************************************************************************/
650
651ACPI_STATUS
652AcpiDsResolveOperands (
653 ACPI_WALK_STATE *WalkState)
654{
655 UINT32 i;
656 ACPI_STATUS Status = AE_OK;
657
658
659 FUNCTION_TRACE_PTR ("DsResolveOperands", WalkState);
660
661
662 /*
663 * Attempt to resolve each of the valid operands
664 * Method arguments are passed by value, not by reference
665 */
666
667 /*
668 * TBD: [Investigate] Note from previous parser:
669 * RefOf problem with AcpiExResolveToValue() conversion.
670 */
671
672 for (i = 0; i < WalkState->NumOperands; i++)
673 {
674 Status = AcpiExResolveToValue (&WalkState->Operands[i], WalkState);
675 if (ACPI_FAILURE (Status))
676 {
677 break;
678 }
679 }
680
681 return_ACPI_STATUS (Status);
682}
683
684
685/*******************************************************************************
686 *
687 * FUNCTION: AcpiDsMapOpcodeToDataType
688 *
689 * PARAMETERS: Opcode - AML opcode to map
690 * OutFlags - Additional info about the opcode
691 *
692 * RETURN: The ACPI type associated with the opcode
693 *
694 * DESCRIPTION: Convert a raw AML opcode to the associated ACPI data type,
695 * if any. If the opcode returns a value as part of the
696 * intepreter execution, a flag is returned in OutFlags.
697 *
698 ******************************************************************************/
699
700ACPI_OBJECT_TYPE8
701AcpiDsMapOpcodeToDataType (
702 UINT16 Opcode,
703 UINT32 *OutFlags)
704{
705 ACPI_OBJECT_TYPE8 DataType = INTERNAL_TYPE_INVALID;
706 ACPI_OPCODE_INFO *OpInfo;
707 UINT32 Flags = 0;
708
709
710 PROC_NAME ("DsMapOpcodeToDataType");
711
712
713 OpInfo = AcpiPsGetOpcodeInfo (Opcode);
714 if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE)
715 {
716 /* Unknown opcode */
717
718 DEBUG_PRINTP (ACPI_ERROR, ("Unknown AML opcode: %x\n", Opcode));
719 return (DataType);
720 }
721
722 switch (ACPI_GET_OP_CLASS (OpInfo))
723 {
724
725 case OPTYPE_LITERAL:
726
727 switch (Opcode)
728 {
729 case AML_BYTE_OP:
730 case AML_WORD_OP:
731 case AML_DWORD_OP:
732
733 DataType = ACPI_TYPE_INTEGER;
734 break;
735
736
737 case AML_STRING_OP:
738
739 DataType = ACPI_TYPE_STRING;
740 break;
741
742 case AML_INT_NAMEPATH_OP:
743 DataType = INTERNAL_TYPE_REFERENCE;
744 break;
745
746 default:
747 DEBUG_PRINTP (ACPI_ERROR,
748 ("Unknown (type LITERAL) AML opcode: %x\n", Opcode));
749 break;
750 }
751 break;
752
753
754 case OPTYPE_DATA_TERM:
755
756 switch (Opcode)
757 {
758 case AML_BUFFER_OP:
759
760 DataType = ACPI_TYPE_BUFFER;
761 break;
762
763 case AML_PACKAGE_OP:
764 case AML_VAR_PACKAGE_OP:
765
766 DataType = ACPI_TYPE_PACKAGE;
767 break;
768
769 default:
770 DEBUG_PRINTP (ACPI_ERROR,
771 ("Unknown (type DATA_TERM) AML opcode: %x\n", Opcode));
772 break;
773 }
774 break;
775
776
777 case OPTYPE_CONSTANT:
778 case OPTYPE_METHOD_ARGUMENT:
779 case OPTYPE_LOCAL_VARIABLE:
780
781 DataType = INTERNAL_TYPE_REFERENCE;
782 break;
783
784
785 case OPTYPE_MONADIC2:
786 case OPTYPE_MONADIC2R:
787 case OPTYPE_DYADIC2:
788 case OPTYPE_DYADIC2R:
789 case OPTYPE_DYADIC2S:
790 case OPTYPE_TRIADIC:
791 case OPTYPE_QUADRADIC:
792 case OPTYPE_HEXADIC:
793 case OPTYPE_RETURN:
794
795 Flags = OP_HAS_RETURN_VALUE;
796 DataType = ACPI_TYPE_ANY;
797 break;
798
799
800 case OPTYPE_METHOD_CALL:
801
802 Flags = OP_HAS_RETURN_VALUE;
803 DataType = ACPI_TYPE_METHOD;
804 break;
805
806
807 case OPTYPE_NAMED_OBJECT:
808
809 DataType = AcpiDsMapNamedOpcodeToDataType (Opcode);
810 break;
811
812
813 case OPTYPE_DYADIC1:
814 case OPTYPE_CONTROL:
815
816 /* No mapping needed at this time */
817
818 break;
819
820
821 default:
822
823 DEBUG_PRINTP (ACPI_ERROR,
824 ("Unimplemented data type opcode: %x\n", Opcode));
825 break;
826 }
827
828 /* Return flags to caller if requested */
829
830 if (OutFlags)
831 {
832 *OutFlags = Flags;
833 }
834
835 return (DataType);
836}
837
838
839/*******************************************************************************
840 *
841 * FUNCTION: AcpiDsMapNamedOpcodeToDataType
842 *
843 * PARAMETERS: Opcode - The Named AML opcode to map
844 *
845 * RETURN: The ACPI type associated with the named opcode
846 *
847 * DESCRIPTION: Convert a raw Named AML opcode to the associated data type.
848 * Named opcodes are a subsystem of the AML opcodes.
849 *
850 ******************************************************************************/
851
852ACPI_OBJECT_TYPE8
853AcpiDsMapNamedOpcodeToDataType (
854 UINT16 Opcode)
855{
856 ACPI_OBJECT_TYPE8 DataType;
857
858
859 /* Decode Opcode */
860
861 switch (Opcode)
862 {
863 case AML_SCOPE_OP:
864 DataType = INTERNAL_TYPE_SCOPE;
865 break;
866
867 case AML_DEVICE_OP:
868 DataType = ACPI_TYPE_DEVICE;
869 break;
870
871 case AML_THERMAL_ZONE_OP:
872 DataType = ACPI_TYPE_THERMAL;
873 break;
874
875 case AML_METHOD_OP:
876 DataType = ACPI_TYPE_METHOD;
877 break;
878
879 case AML_POWER_RES_OP:
880 DataType = ACPI_TYPE_POWER;
881 break;
882
883 case AML_PROCESSOR_OP:
884 DataType = ACPI_TYPE_PROCESSOR;
885 break;
886
887 case AML_FIELD_OP: /* FieldOp */
888 DataType = INTERNAL_TYPE_FIELD_DEFN;
889 break;
890
891 case AML_INDEX_FIELD_OP: /* IndexFieldOp */
892 DataType = INTERNAL_TYPE_INDEX_FIELD_DEFN;
893 break;
894
895 case AML_BANK_FIELD_OP: /* BankFieldOp */
896 DataType = INTERNAL_TYPE_BANK_FIELD_DEFN;
897 break;
898
899 case AML_INT_NAMEDFIELD_OP: /* NO CASE IN ORIGINAL */
900 DataType = ACPI_TYPE_ANY;
901 break;
902
903 case AML_NAME_OP: /* NameOp - special code in original */
904 case AML_INT_NAMEPATH_OP:
905 DataType = ACPI_TYPE_ANY;
906 break;
907
908 case AML_ALIAS_OP:
909 DataType = INTERNAL_TYPE_ALIAS;
910 break;
911
912 case AML_MUTEX_OP:
913 DataType = ACPI_TYPE_MUTEX;
914 break;
915
916 case AML_EVENT_OP:
917 DataType = ACPI_TYPE_EVENT;
918 break;
919
920 case AML_REGION_OP:
921 DataType = ACPI_TYPE_REGION;
922 break;
923
924
925 default:
926 DataType = ACPI_TYPE_ANY;
927 break;
928
929 }
930
931 return (DataType);
932}
933
934