aslparseop.c revision 1.1.1.7 1 /******************************************************************************
2 *
3 * Module Name: aslparseop - Parse op create/allocate/cache interfaces
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2020, 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 AslGbl_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 (AcpiGbl_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 (AcpiGbl_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", Op->Asl.Value.String);
299 break;
300
301 case PARSEOP_NAMESEG:
302
303 DbgPrint (ASL_PARSE_OUTPUT, "NAMESEG->%s", Op->Asl.Value.String);
304 break;
305
306 case PARSEOP_NAMESTRING:
307
308 DbgPrint (ASL_PARSE_OUTPUT, "NAMESTRING->%s", Op->Asl.Value.String);
309 break;
310
311 case PARSEOP_EISAID:
312
313 DbgPrint (ASL_PARSE_OUTPUT, "EISAID->%s", Op->Asl.Value.String);
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 = NULL;
589 ACPI_STATUS Status;
590
591
592 switch (ParseOpcode)
593 {
594 case PARSEOP___LINE__:
595
596 Op = TrAllocateOp (PARSEOP_INTEGER);
597 Op->Asl.Value.Integer = Op->Asl.LineNumber;
598 break;
599
600 case PARSEOP___METHOD__:
601
602 /* Will become a string literal later */
603
604 Op = TrAllocateOp (PARSEOP___METHOD__);
605 Op->Asl.Value.String = NULL;
606 break;
607
608 case PARSEOP___PATH__:
609
610 Op = TrAllocateOp (PARSEOP_STRING_LITERAL);
611
612 /* Op.Asl.Filename contains the full pathname to the file */
613
614 Op->Asl.Value.String = Op->Asl.Filename;
615 break;
616
617 case PARSEOP___FILE__:
618
619 Op = TrAllocateOp (PARSEOP_STRING_LITERAL);
620
621 /* Get the simple filename from the full path */
622
623 Status = FlSplitInputPathname (Op->Asl.Filename, NULL, &Filename);
624 if (ACPI_FAILURE (Status))
625 {
626 return (NULL);
627 }
628
629 Op->Asl.Value.String = Filename;
630 break;
631
632 case PARSEOP___DATE__:
633
634 Op = TrAllocateOp (PARSEOP_STRING_LITERAL);
635
636 /* Get a copy of the current time */
637
638 Op->Asl.Value.String = "";
639 CurrentTime = time (NULL);
640
641 StaticTimeString = ctime (&CurrentTime);
642 if (StaticTimeString)
643 {
644 TimeString = UtLocalCalloc (strlen (StaticTimeString) + 1);
645 strcpy (TimeString, StaticTimeString);
646
647 TimeString[strlen(TimeString) -1] = 0; /* Remove trailing newline */
648 Op->Asl.Value.String = TimeString;
649 }
650 break;
651
652 default: /* This would be an internal error */
653
654 return (NULL);
655 }
656
657 DbgPrint (ASL_PARSE_OUTPUT,
658 "\nCreateConstantLeafOp Ln/Col %u/%u NewOp %p "
659 "Op %s Value %8.8X%8.8X \n",
660 Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName (ParseOpcode),
661 ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer));
662
663 return (Op);
664 }
665
666
667 /*******************************************************************************
668 *
669 * FUNCTION: TrAllocateOp
670 *
671 * PARAMETERS: ParseOpcode - Opcode to be assigned to the op
672 *
673 * RETURN: New parse op. Aborts on allocation failure
674 *
675 * DESCRIPTION: Allocate and initialize a new parse op for the parse tree
676 *
677 ******************************************************************************/
678
679 ACPI_PARSE_OBJECT *
680 TrAllocateOp (
681 UINT32 ParseOpcode)
682 {
683 ACPI_PARSE_OBJECT *Op;
684 ACPI_PARSE_OBJECT *LatestOp;
685
686
687 Op = UtParseOpCacheCalloc ();
688
689 Op->Asl.ParseOpcode = (UINT16) ParseOpcode;
690 Op->Asl.Filename = AslGbl_Files[ASL_FILE_INPUT].Filename;
691 Op->Asl.LineNumber = AslGbl_CurrentLineNumber;
692 Op->Asl.LogicalLineNumber = AslGbl_LogicalLineNumber;
693 Op->Asl.LogicalByteOffset = AslGbl_CurrentLineOffset;
694 Op->Asl.Column = AslGbl_CurrentColumn;
695
696 UtSetParseOpName (Op);
697
698 /* The following is for capturing comments */
699
700 if (AcpiGbl_CaptureComments)
701 {
702 LatestOp = AslGbl_CommentState.LatestParseOp;
703 Op->Asl.InlineComment = NULL;
704 Op->Asl.EndNodeComment = NULL;
705 Op->Asl.CommentList = NULL;
706 Op->Asl.FileChanged = FALSE;
707
708 /*
709 * Check to see if the file name has changed before resetting the
710 * latest parse op.
711 */
712 if (LatestOp &&
713 (ParseOpcode != PARSEOP_INCLUDE) &&
714 (ParseOpcode != PARSEOP_INCLUDE_END) &&
715 strcmp (LatestOp->Asl.Filename, Op->Asl.Filename))
716 {
717 CvDbgPrint ("latest op: %s\n", LatestOp->Asl.ParseOpName);
718 Op->Asl.FileChanged = TRUE;
719 if (AslGbl_IncludeFileStack)
720 {
721 Op->Asl.ParentFilename = AslGbl_IncludeFileStack->Filename;
722 }
723 else
724 {
725 Op->Asl.ParentFilename = NULL;
726 }
727 }
728
729 AslGbl_CommentState.LatestParseOp = Op;
730 CvDbgPrint ("TrAllocateOp=Set latest parse op to this op.\n");
731 CvDbgPrint (" Op->Asl.ParseOpName = %s\n",
732 AslGbl_CommentState.LatestParseOp->Asl.ParseOpName);
733 CvDbgPrint (" Op->Asl.ParseOpcode = 0x%x\n", ParseOpcode);
734
735 if (Op->Asl.FileChanged)
736 {
737 CvDbgPrint(" file has been changed!\n");
738 }
739
740 /*
741 * if this parse op's syntax uses () and {} (i.e. Package(1){0x00}) then
742 * set a flag in the comment state. This facilitates paring comments for
743 * these types of opcodes.
744 */
745 if ((CvParseOpBlockType(Op) == (BLOCK_PAREN | BLOCK_BRACE)) &&
746 (ParseOpcode != PARSEOP_DEFINITION_BLOCK))
747 {
748 CvDbgPrint ("Parsing paren/Brace op now!\n");
749 AslGbl_CommentState.ParsingParenBraceNode = Op;
750 }
751
752 if (AslGbl_CommentListHead)
753 {
754 CvDbgPrint ("Transferring...\n");
755 Op->Asl.CommentList = AslGbl_CommentListHead;
756 AslGbl_CommentListHead = NULL;
757 AslGbl_CommentListTail = NULL;
758 CvDbgPrint (" Transferred current comment list to this op.\n");
759 CvDbgPrint (" %s\n", Op->Asl.CommentList->Comment);
760 }
761
762 if (AslGbl_InlineCommentBuffer)
763 {
764 Op->Asl.InlineComment = AslGbl_InlineCommentBuffer;
765 AslGbl_InlineCommentBuffer = NULL;
766 CvDbgPrint ("Transferred current inline comment list to this op.\n");
767 }
768 }
769
770 return (Op);
771 }
772
773
774 /*******************************************************************************
775 *
776 * FUNCTION: TrPrintOpFlags
777 *
778 * PARAMETERS: Flags - Flags word to be decoded
779 * OutputLevel - Debug output level: ASL_TREE_OUTPUT etc.
780 *
781 * RETURN: None
782 *
783 * DESCRIPTION: Decode a flags word to text. Displays all flags that are set.
784 *
785 ******************************************************************************/
786
787 void
788 TrPrintOpFlags (
789 UINT32 Flags,
790 UINT32 OutputLevel)
791 {
792 UINT32 FlagBit = 1;
793 UINT32 i;
794
795
796 for (i = 0; i < ACPI_NUM_OP_FLAGS; i++)
797 {
798 if (Flags & FlagBit)
799 {
800 DbgPrint (OutputLevel, " %s", AslGbl_OpFlagNames[i]);
801 }
802
803 FlagBit <<= 1;
804 }
805 }
806