aslparseop.c revision 1.1.1.2 1 /******************************************************************************
2 *
3 * Module Name: aslparseop - Parse op create/allocate/cache interfaces
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2017, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44 #include "aslcompiler.h"
45 #include "aslcompiler.y.h"
46 #include "acapps.h"
47 #include "acconvert.h"
48
49 #define _COMPONENT ACPI_COMPILER
50 ACPI_MODULE_NAME ("aslparseop")
51
52
53 /*******************************************************************************
54 *
55 * FUNCTION: TrCreateOp
56 *
57 * PARAMETERS: ParseOpcode - Opcode to be assigned to the op
58 * NumChildren - Number of children to follow
59 * ... - A list of child ops to link to the new
60 * op. NumChildren long.
61 *
62 * RETURN: Pointer to the new op. Aborts on allocation failure
63 *
64 * DESCRIPTION: Create a new parse op and link together a list of child
65 * ops underneath the new op.
66 *
67 ******************************************************************************/
68
69 ACPI_PARSE_OBJECT *
70 TrCreateOp (
71 UINT32 ParseOpcode,
72 UINT32 NumChildren,
73 ...)
74 {
75 ACPI_PARSE_OBJECT *Op;
76 ACPI_PARSE_OBJECT *Child;
77 ACPI_PARSE_OBJECT *PrevChild;
78 va_list ap;
79 UINT32 i;
80 BOOLEAN FirstChild;
81
82
83 va_start (ap, NumChildren);
84
85 /* Allocate one new op */
86
87 Op = TrAllocateOp (ParseOpcode);
88
89 DbgPrint (ASL_PARSE_OUTPUT,
90 "\nCreateOp Ln/Col %u/%u NewParent %p Child %u Op %s ",
91 Op->Asl.LineNumber, Op->Asl.Column, Op,
92 NumChildren, UtGetOpName(ParseOpcode));
93
94 /* Some extra debug output based on the parse opcode */
95
96 switch (ParseOpcode)
97 {
98 case PARSEOP_ASL_CODE:
99
100 Gbl_ParseTreeRoot = Op;
101 Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
102 DbgPrint (ASL_PARSE_OUTPUT, "ASLCODE (Tree Completed)->");
103 break;
104
105 case PARSEOP_DEFINITION_BLOCK:
106
107 DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->");
108 break;
109
110 case PARSEOP_OPERATIONREGION:
111
112 DbgPrint (ASL_PARSE_OUTPUT, "OPREGION->");
113 break;
114
115 case PARSEOP_OR:
116
117 DbgPrint (ASL_PARSE_OUTPUT, "OR->");
118 break;
119
120 default:
121
122 /* Nothing to do for other opcodes */
123
124 break;
125 }
126
127 /* Link the new op to its children */
128
129 PrevChild = NULL;
130 FirstChild = TRUE;
131 for (i = 0; i < NumChildren; i++)
132 {
133 /* Get the next child */
134
135 Child = va_arg (ap, ACPI_PARSE_OBJECT *);
136 DbgPrint (ASL_PARSE_OUTPUT, "%p, ", Child);
137
138 /*
139 * If child is NULL, this means that an optional argument
140 * was omitted. We must create a placeholder with a special
141 * opcode (DEFAULT_ARG) so that the code generator will know
142 * that it must emit the correct default for this argument
143 */
144 if (!Child)
145 {
146 Child = TrAllocateOp (PARSEOP_DEFAULT_ARG);
147 }
148
149 /* Link first child to parent */
150
151 if (FirstChild)
152 {
153 FirstChild = FALSE;
154 Op->Asl.Child = Child;
155
156 /*
157 * For the ASL-/ASL+ converter: if the ParseOp is a Connection,
158 * External, Offset or AccessAs, it means that the comments in the
159 * FirstChild belongs to their parent due to the parsing order in
160 * the .y files. To correct this, take the comments in the
161 * FirstChild place it in the parent. This also means that
162 * legitimate comments for the child gets put to the parent.
163 */
164 if (Gbl_CaptureComments &&
165 ((ParseOpcode == PARSEOP_CONNECTION) ||
166 (ParseOpcode == PARSEOP_EXTERNAL) ||
167 (ParseOpcode == PARSEOP_OFFSET) ||
168 (ParseOpcode == PARSEOP_ACCESSAS)))
169 {
170 Op->Asl.CommentList = Child->Asl.CommentList;
171 Op->Asl.EndBlkComment = Child->Asl.EndBlkComment;
172 Op->Asl.InlineComment = Child->Asl.InlineComment;
173 Op->Asl.FileChanged = Child->Asl.FileChanged;
174
175 Child->Asl.CommentList = NULL;
176 Child->Asl.EndBlkComment = NULL;
177 Child->Asl.InlineComment = NULL;
178 Child->Asl.FileChanged = FALSE;
179
180 /*
181 * These do not need to be "passed off". They can be copied
182 * because the code for these opcodes should be printed in the
183 * same file.
184 */
185 Op->Asl.Filename = Child->Asl.Filename;
186 Op->Asl.ParentFilename = Child->Asl.ParentFilename;
187 }
188 }
189
190 /* Point all children to parent */
191
192 Child->Asl.Parent = Op;
193
194 /* Link children in a peer list */
195
196 if (PrevChild)
197 {
198 PrevChild->Asl.Next = Child;
199 };
200
201 /* Get the comment from last child in the resource template call */
202
203 if (Gbl_CaptureComments &&
204 (Op->Asl.ParseOpcode == PARSEOP_RESOURCETEMPLATE))
205 {
206 CvDbgPrint ("Transferred current comment list to this op.\n");
207 Op->Asl.CommentList = Child->Asl.CommentList;
208 Child->Asl.CommentList = NULL;
209
210 Op->Asl.InlineComment = Child->Asl.InlineComment;
211 Child->Asl.InlineComment = NULL;
212 }
213
214 /*
215 * This child might be a list, point all ops in the list
216 * to the same parent
217 */
218 while (Child->Asl.Next)
219 {
220 Child = Child->Asl.Next;
221 Child->Asl.Parent = Op;
222 }
223
224 PrevChild = Child;
225 }
226
227 va_end(ap);
228 DbgPrint (ASL_PARSE_OUTPUT, "\n");
229 return (Op);
230 }
231
232
233 /*******************************************************************************
234 *
235 * FUNCTION: TrCreateLeafOp
236 *
237 * PARAMETERS: ParseOpcode - New opcode to be assigned to the op
238 *
239 * RETURN: Pointer to the new op. Aborts on allocation failure
240 *
241 * DESCRIPTION: Create a simple leaf op (no children or peers, and no value
242 * assigned to the op)
243 *
244 ******************************************************************************/
245
246 ACPI_PARSE_OBJECT *
247 TrCreateLeafOp (
248 UINT32 ParseOpcode)
249 {
250 ACPI_PARSE_OBJECT *Op;
251
252
253 Op = TrAllocateOp (ParseOpcode);
254
255 DbgPrint (ASL_PARSE_OUTPUT,
256 "\nCreateLeafOp Ln/Col %u/%u NewOp %p Op %s\n\n",
257 Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName (ParseOpcode));
258
259 return (Op);
260 }
261
262
263 /*******************************************************************************
264 *
265 * FUNCTION: TrCreateValuedLeafOp
266 *
267 * PARAMETERS: ParseOpcode - New opcode to be assigned to the op
268 * Value - Value to be assigned to the op
269 *
270 * RETURN: Pointer to the new op. Aborts on allocation failure
271 *
272 * DESCRIPTION: Create a leaf op (no children or peers) with a value
273 * assigned to it
274 *
275 ******************************************************************************/
276
277 ACPI_PARSE_OBJECT *
278 TrCreateValuedLeafOp (
279 UINT32 ParseOpcode,
280 UINT64 Value)
281 {
282 ACPI_PARSE_OBJECT *Op;
283
284
285 Op = TrAllocateOp (ParseOpcode);
286 Op->Asl.Value.Integer = Value;
287
288 DbgPrint (ASL_PARSE_OUTPUT,
289 "\nCreateValuedLeafOp Ln/Col %u/%u NewOp %p "
290 "Op %s Value %8.8X%8.8X ",
291 Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName(ParseOpcode),
292 ACPI_FORMAT_UINT64 (Value));
293
294 switch (ParseOpcode)
295 {
296 case PARSEOP_STRING_LITERAL:
297
298 DbgPrint (ASL_PARSE_OUTPUT, "STRING->%s", Value);
299 break;
300
301 case PARSEOP_NAMESEG:
302
303 DbgPrint (ASL_PARSE_OUTPUT, "NAMESEG->%s", Value);
304 break;
305
306 case PARSEOP_NAMESTRING:
307
308 DbgPrint (ASL_PARSE_OUTPUT, "NAMESTRING->%s", Value);
309 break;
310
311 case PARSEOP_EISAID:
312
313 DbgPrint (ASL_PARSE_OUTPUT, "EISAID->%s", Value);
314 break;
315
316 case PARSEOP_METHOD:
317
318 DbgPrint (ASL_PARSE_OUTPUT, "METHOD");
319 break;
320
321 case PARSEOP_INTEGER:
322
323 DbgPrint (ASL_PARSE_OUTPUT, "INTEGER->%8.8X%8.8X",
324 ACPI_FORMAT_UINT64 (Value));
325 break;
326
327 default:
328 break;
329 }
330
331 DbgPrint (ASL_PARSE_OUTPUT, "\n\n");
332 return (Op);
333 }
334
335
336 /*******************************************************************************
337 *
338 * FUNCTION: TrCreateTargetOp
339 *
340 * PARAMETERS: OriginalOp - Op to be copied
341 *
342 * RETURN: Pointer to the new op. Aborts on allocation failure
343 *
344 * DESCRIPTION: Copy an existing op (and subtree). Used in ASL+ (C-style)
345 * expressions where the target is the same as one of the
346 * operands. A new op and subtree must be created from the
347 * original so that the parse tree can be linked properly.
348 *
349 * NOTE: This code is specific to target operands that are the last
350 * operand in an ASL/AML operator. Meaning that the top-level
351 * parse Op in a possible subtree has a NULL Next pointer.
352 * This simplifies the recursion.
353 *
354 * Subtree example:
355 * DeRefOf (Local1) += 32
356 *
357 * This gets converted to:
358 * Add (DeRefOf (Local1), 32, DeRefOf (Local1))
359 *
360 * Each DeRefOf has a single child, Local1. Even more complex
361 * subtrees can be created via the Index and DeRefOf operators.
362 *
363 ******************************************************************************/
364
365 ACPI_PARSE_OBJECT *
366 TrCreateTargetOp (
367 ACPI_PARSE_OBJECT *OriginalOp,
368 ACPI_PARSE_OBJECT *ParentOp)
369 {
370 ACPI_PARSE_OBJECT *Op;
371
372
373 if (!OriginalOp)
374 {
375 return (NULL);
376 }
377
378 Op = UtParseOpCacheCalloc ();
379
380 /* Copy the pertinent values (omit link pointer fields) */
381
382 Op->Asl.Value = OriginalOp->Asl.Value;
383 Op->Asl.Filename = OriginalOp->Asl.Filename;
384 Op->Asl.LineNumber = OriginalOp->Asl.LineNumber;
385 Op->Asl.LogicalLineNumber = OriginalOp->Asl.LogicalLineNumber;
386 Op->Asl.LogicalByteOffset = OriginalOp->Asl.LogicalByteOffset;
387 Op->Asl.Column = OriginalOp->Asl.Column;
388 Op->Asl.Flags = OriginalOp->Asl.Flags;
389 Op->Asl.CompileFlags = OriginalOp->Asl.CompileFlags;
390 Op->Asl.AmlOpcode = OriginalOp->Asl.AmlOpcode;
391 Op->Asl.ParseOpcode = OriginalOp->Asl.ParseOpcode;
392 Op->Asl.Parent = ParentOp;
393
394 UtSetParseOpName (Op);
395
396 /* Copy a possible subtree below this op */
397
398 if (OriginalOp->Asl.Child)
399 {
400 Op->Asl.Child = TrCreateTargetOp (OriginalOp->Asl.Child, Op);
401 }
402
403 if (OriginalOp->Asl.Next) /* Null for top-level op */
404 {
405 Op->Asl.Next = TrCreateTargetOp (OriginalOp->Asl.Next, ParentOp);
406 }
407
408 return (Op);
409 }
410
411
412 /*******************************************************************************
413 *
414 * FUNCTION: TrCreateAssignmentOp
415 *
416 * PARAMETERS: Target - Assignment target
417 * Source - Assignment source
418 *
419 * RETURN: Pointer to the new op. Aborts on allocation failure
420 *
421 * DESCRIPTION: Implements the C-style '=' operator. It changes the parse
422 * tree if possible to utilize the last argument of the math
423 * operators which is a target operand -- thus saving invocation
424 * of and additional Store() operator. An optimization.
425 *
426 ******************************************************************************/
427
428 ACPI_PARSE_OBJECT *
429 TrCreateAssignmentOp (
430 ACPI_PARSE_OBJECT *Target,
431 ACPI_PARSE_OBJECT *Source)
432 {
433 ACPI_PARSE_OBJECT *TargetOp;
434 ACPI_PARSE_OBJECT *SourceOp1;
435 ACPI_PARSE_OBJECT *SourceOp2;
436 ACPI_PARSE_OBJECT *Operator;
437
438
439 DbgPrint (ASL_PARSE_OUTPUT,
440 "\nTrCreateAssignmentOp Line [%u to %u] Source %s Target %s\n",
441 Source->Asl.LineNumber, Source->Asl.EndLine,
442 UtGetOpName (Source->Asl.ParseOpcode),
443 UtGetOpName (Target->Asl.ParseOpcode));
444
445 TrSetOpFlags (Target, OP_IS_TARGET);
446
447 switch (Source->Asl.ParseOpcode)
448 {
449 /*
450 * Only these operators can be optimized because they have
451 * a target operand
452 */
453 case PARSEOP_ADD:
454 case PARSEOP_AND:
455 case PARSEOP_DIVIDE:
456 case PARSEOP_INDEX:
457 case PARSEOP_MOD:
458 case PARSEOP_MULTIPLY:
459 case PARSEOP_NOT:
460 case PARSEOP_OR:
461 case PARSEOP_SHIFTLEFT:
462 case PARSEOP_SHIFTRIGHT:
463 case PARSEOP_SUBTRACT:
464 case PARSEOP_XOR:
465
466 break;
467
468 /* Otherwise, just create a normal Store operator */
469
470 default:
471 goto CannotOptimize;
472 }
473
474 /*
475 * Transform the parse tree such that the target is moved to the
476 * last operand of the operator
477 */
478 SourceOp1 = Source->Asl.Child;
479 SourceOp2 = SourceOp1->Asl.Next;
480
481 /* NOT only has one operand, but has a target */
482
483 if (Source->Asl.ParseOpcode == PARSEOP_NOT)
484 {
485 SourceOp2 = SourceOp1;
486 }
487
488 /* DIVIDE has an extra target operand (remainder) */
489
490 if (Source->Asl.ParseOpcode == PARSEOP_DIVIDE)
491 {
492 SourceOp2 = SourceOp2->Asl.Next;
493 }
494
495 TargetOp = SourceOp2->Asl.Next;
496
497 /*
498 * Can't perform this optimization if there already is a target
499 * for the operator (ZERO is a "no target" placeholder).
500 */
501 if (TargetOp->Asl.ParseOpcode != PARSEOP_ZERO)
502 {
503 goto CannotOptimize;
504 }
505
506 /* Link in the target as the final operand */
507
508 SourceOp2->Asl.Next = Target;
509 Target->Asl.Parent = Source;
510 return (Source);
511
512
513 CannotOptimize:
514
515 Operator = TrAllocateOp (PARSEOP_STORE);
516 TrLinkOpChildren (Operator, 2, Source, Target);
517
518 /* Set the appropriate line numbers for the new op */
519
520 Operator->Asl.LineNumber = Target->Asl.LineNumber;
521 Operator->Asl.LogicalLineNumber = Target->Asl.LogicalLineNumber;
522 Operator->Asl.LogicalByteOffset = Target->Asl.LogicalByteOffset;
523 Operator->Asl.Column = Target->Asl.Column;
524
525 return (Operator);
526 }
527
528
529 /*******************************************************************************
530 *
531 * FUNCTION: TrCreateNullTargetOp
532 *
533 * PARAMETERS: None
534 *
535 * RETURN: Pointer to the new op. Aborts on allocation failure
536 *
537 * DESCRIPTION: Create a "null" target op. This is defined by the ACPI
538 * specification to be a zero AML opcode, and indicates that
539 * no target has been specified for the parent operation
540 *
541 ******************************************************************************/
542
543 ACPI_PARSE_OBJECT *
544 TrCreateNullTargetOp (
545 void)
546 {
547 ACPI_PARSE_OBJECT *Op;
548
549
550 Op = TrAllocateOp (PARSEOP_ZERO);
551 Op->Asl.CompileFlags |= (OP_IS_TARGET | OP_COMPILE_TIME_CONST);
552
553 DbgPrint (ASL_PARSE_OUTPUT,
554 "\nCreateNullTargetOp Ln/Col %u/%u NewOp %p Op %s\n",
555 Op->Asl.LineNumber, Op->Asl.Column, Op,
556 UtGetOpName (Op->Asl.ParseOpcode));
557
558 return (Op);
559 }
560
561
562 /*******************************************************************************
563 *
564 * FUNCTION: TrCreateConstantLeafOp
565 *
566 * PARAMETERS: ParseOpcode - The constant opcode
567 *
568 * RETURN: Pointer to the new op. Aborts on allocation failure
569 *
570 * DESCRIPTION: Create a leaf op (no children or peers) for one of the
571 * special constants - __LINE__, __FILE__, and __DATE__.
572 *
573 * Note: The fullimplemenation of __METHOD__ cannot happen here because we
574 * don't have a full parse tree at this time and cannot find the parent
575 * control method. __METHOD__ must be implemented later, after the parse
576 * tree has been fully constructed.
577 *
578 ******************************************************************************/
579
580 ACPI_PARSE_OBJECT *
581 TrCreateConstantLeafOp (
582 UINT32 ParseOpcode)
583 {
584 ACPI_PARSE_OBJECT *Op = NULL;
585 time_t CurrentTime;
586 char *StaticTimeString;
587 char *TimeString;
588 char *Filename;
589
590
591 switch (ParseOpcode)
592 {
593 case PARSEOP___LINE__:
594
595 Op = TrAllocateOp (PARSEOP_INTEGER);
596 Op->Asl.Value.Integer = Op->Asl.LineNumber;
597 break;
598
599 case PARSEOP___METHOD__:
600
601 /* Will become a string literal later */
602
603 Op = TrAllocateOp (PARSEOP___METHOD__);
604 Op->Asl.Value.String = NULL;
605 break;
606
607 case PARSEOP___PATH__:
608
609 Op = TrAllocateOp (PARSEOP_STRING_LITERAL);
610
611 /* Op.Asl.Filename contains the full pathname to the file */
612
613 Op->Asl.Value.String = Op->Asl.Filename;
614 break;
615
616 case PARSEOP___FILE__:
617
618 Op = TrAllocateOp (PARSEOP_STRING_LITERAL);
619
620 /* Get the simple filename from the full path */
621
622 FlSplitInputPathname (Op->Asl.Filename, NULL, &Filename);
623 Op->Asl.Value.String = Filename;
624 break;
625
626 case PARSEOP___DATE__:
627
628 Op = TrAllocateOp (PARSEOP_STRING_LITERAL);
629
630 /* Get a copy of the current time */
631
632 CurrentTime = time (NULL);
633 StaticTimeString = ctime (&CurrentTime);
634 TimeString = UtLocalCalloc (strlen (StaticTimeString) + 1);
635 strcpy (TimeString, StaticTimeString);
636
637 TimeString[strlen(TimeString) -1] = 0; /* Remove trailing newline */
638 Op->Asl.Value.String = TimeString;
639 break;
640
641 default: /* This would be an internal error */
642
643 return (NULL);
644 }
645
646 DbgPrint (ASL_PARSE_OUTPUT,
647 "\nCreateConstantLeafOp Ln/Col %u/%u NewOp %p "
648 "Op %s Value %8.8X%8.8X \n",
649 Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName (ParseOpcode),
650 ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer));
651
652 return (Op);
653 }
654
655
656 /*******************************************************************************
657 *
658 * FUNCTION: TrAllocateOp
659 *
660 * PARAMETERS: ParseOpcode - Opcode to be assigned to the op
661 *
662 * RETURN: New parse op. Aborts on allocation failure
663 *
664 * DESCRIPTION: Allocate and initialize a new parse op for the parse tree
665 *
666 ******************************************************************************/
667
668 ACPI_PARSE_OBJECT *
669 TrAllocateOp (
670 UINT32 ParseOpcode)
671 {
672 ACPI_PARSE_OBJECT *Op;
673 ACPI_PARSE_OBJECT *LatestOp;
674
675
676 Op = UtParseOpCacheCalloc ();
677
678 Op->Asl.ParseOpcode = (UINT16) ParseOpcode;
679 Op->Asl.Filename = Gbl_Files[ASL_FILE_INPUT].Filename;
680 Op->Asl.LineNumber = Gbl_CurrentLineNumber;
681 Op->Asl.LogicalLineNumber = Gbl_LogicalLineNumber;
682 Op->Asl.LogicalByteOffset = Gbl_CurrentLineOffset;
683 Op->Asl.Column = Gbl_CurrentColumn;
684
685 UtSetParseOpName (Op);
686
687 /* The following is for capturing comments */
688
689 if(Gbl_CaptureComments)
690 {
691 LatestOp = Gbl_CommentState.LatestParseOp;
692 Op->Asl.InlineComment = NULL;
693 Op->Asl.EndNodeComment = NULL;
694 Op->Asl.CommentList = NULL;
695 Op->Asl.FileChanged = FALSE;
696
697 /*
698 * Check to see if the file name has changed before resetting the
699 * latest parse op.
700 */
701 if (LatestOp &&
702 (ParseOpcode != PARSEOP_INCLUDE) &&
703 (ParseOpcode != PARSEOP_INCLUDE_END) &&
704 strcmp (LatestOp->Asl.Filename, Op->Asl.Filename))
705 {
706 CvDbgPrint ("latest op: %s\n", LatestOp->Asl.ParseOpName);
707 Op->Asl.FileChanged = TRUE;
708 if (Gbl_IncludeFileStack)
709 {
710 Op->Asl.ParentFilename = Gbl_IncludeFileStack->Filename;
711 }
712 else
713 {
714 Op->Asl.ParentFilename = NULL;
715 }
716 }
717
718 Gbl_CommentState.LatestParseOp = Op;
719 CvDbgPrint ("TrAllocateOp=Set latest parse op to this op.\n");
720 CvDbgPrint (" Op->Asl.ParseOpName = %s\n",
721 Gbl_CommentState.LatestParseOp->Asl.ParseOpName);
722 CvDbgPrint (" Op->Asl.ParseOpcode = 0x%x\n", ParseOpcode);
723
724 if (Op->Asl.FileChanged)
725 {
726 CvDbgPrint(" file has been changed!\n");
727 }
728
729 /*
730 * if this parse op's syntax uses () and {} (i.e. Package(1){0x00}) then
731 * set a flag in the comment state. This facilitates paring comments for
732 * these types of opcodes.
733 */
734 if ((CvParseOpBlockType(Op) == (BLOCK_PAREN | BLOCK_BRACE)) &&
735 (ParseOpcode != PARSEOP_DEFINITION_BLOCK))
736 {
737 CvDbgPrint ("Parsing paren/Brace op now!\n");
738 Gbl_CommentState.ParsingParenBraceNode = Op;
739 }
740
741 if (Gbl_CommentListHead)
742 {
743 CvDbgPrint ("Transferring...\n");
744 Op->Asl.CommentList = Gbl_CommentListHead;
745 Gbl_CommentListHead = NULL;
746 Gbl_CommentListTail = NULL;
747 CvDbgPrint (" Transferred current comment list to this op.\n");
748 CvDbgPrint (" %s\n", Op->Asl.CommentList->Comment);
749 }
750
751 if (Gbl_InlineCommentBuffer)
752 {
753 Op->Asl.InlineComment = Gbl_InlineCommentBuffer;
754 Gbl_InlineCommentBuffer = NULL;
755 CvDbgPrint ("Transferred current inline comment list to this op.\n");
756 }
757 }
758
759 return (Op);
760 }
761
762
763 /*******************************************************************************
764 *
765 * FUNCTION: TrPrintOpFlags
766 *
767 * PARAMETERS: Flags - Flags word to be decoded
768 * OutputLevel - Debug output level: ASL_TREE_OUTPUT etc.
769 *
770 * RETURN: None
771 *
772 * DESCRIPTION: Decode a flags word to text. Displays all flags that are set.
773 *
774 ******************************************************************************/
775
776 void
777 TrPrintOpFlags (
778 UINT32 Flags,
779 UINT32 OutputLevel)
780 {
781 UINT32 FlagBit = 1;
782 UINT32 i;
783
784
785 for (i = 0; i < ACPI_NUM_OP_FLAGS; i++)
786 {
787 if (Flags & FlagBit)
788 {
789 DbgPrint (OutputLevel, " %s", Gbl_OpFlagNames[i]);
790 }
791
792 FlagBit <<= 1;
793 }
794 }
795