1 /******************************************************************************
3 * Module Name: cvparser - Converter functions that are called from the AML
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
13 * All rights reserved.
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
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
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;
38 * The above copyright and patent license is granted only if the following
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.
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
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
73 * 3.4. Intel retains all right, title, and interest in and to the Original
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.
81 * 4. Disclaimer and Export Compliance
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
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
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.
115 *****************************************************************************
117 * Alternatively, you may choose to be licensed under the terms of the
120 * Redistribution and use in source and binary forms, with or without
121 * modification, are permitted provided that the following conditions
123 * 1. Redistributions of source code must retain the above copyright
124 * notice, this list of conditions, and the following disclaimer,
125 * without modification.
126 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
127 * substantially similar to the "NO WARRANTY" disclaimer below
128 * ("Disclaimer") and any redistribution must be conditioned upon
129 * including a substantially similar Disclaimer requirement for further
130 * binary redistribution.
131 * 3. Neither the names of the above-listed copyright holders nor the names
132 * of any contributors may be used to endorse or promote products derived
133 * from this software without specific prior written permission.
135 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
136 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
137 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
138 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
139 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
140 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
141 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
142 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
143 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
144 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
145 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
147 * Alternatively, you may choose to be licensed under the terms of the
148 * GNU General Public License ("GPL") version 2 as published by the Free
149 * Software Foundation.
151 *****************************************************************************/
153 #include "aslcompiler.h"
154 #include "acparser.h"
155 #include "acdispat.h"
157 #include "acinterp.h"
158 #include "acdisasm.h"
159 #include "acconvert.h"
162 /* local prototypes */
172 static ACPI_FILE_NODE
*
175 ACPI_FILE_NODE
*Head
);
180 char *PreviousFilename
);
188 /*******************************************************************************
190 * FUNCTION: CvIsFilename
192 * PARAMETERS: filename - input filename
194 * RETURN: BOOLEAN - TRUE if all characters are between 0x20 and 0x7f
196 * DESCRIPTION: Take a given char * and see if it contains all printable
197 * characters. If all characters have hexvalues 20-7f and ends with
198 * .dsl, we will assume that it is a proper filename.
200 ******************************************************************************/
206 UINT64 Length
= strlen(Filename
);
207 char *FileExt
= Filename
+ Length
- 4;
211 if ((Length
> 4) && AcpiUtStricmp (FileExt
, ".dsl"))
216 for(i
= 0; i
<Length
; ++i
)
218 if (!isprint ((int) Filename
[i
]))
228 /*******************************************************************************
230 * FUNCTION: CvInitFileTree
232 * PARAMETERS: Table - input table
233 * AmlStart - Address of the starting point of the AML.
234 * AmlLength - Length of the AML file.
238 * DESCRIPTION: Initialize the file dependency tree by scanning the AML.
239 * This is referred as ASL_CV_INIT_FILETREE.
241 ******************************************************************************/
245 ACPI_TABLE_HEADER
*Table
,
251 char *Filename
= NULL
;
252 char *PreviousFilename
= NULL
;
253 char *ParentFilename
= NULL
;
254 char *ChildFilename
= NULL
;
257 if (!AcpiGbl_CaptureComments
)
262 CvDbgPrint ("AmlLength: %x\n", AmlLength
);
263 CvDbgPrint ("AmlStart: %p\n", AmlStart
);
264 CvDbgPrint ("AmlEnd?: %p\n", AmlStart
+AmlLength
);
266 AcpiGbl_FileTreeRoot
= AcpiOsAcquireObject (AcpiGbl_FileCache
);
268 AcpiGbl_FileTreeRoot
->FileStart
= (char *)(AmlStart
);
269 AcpiGbl_FileTreeRoot
->FileEnd
= (char *)(AmlStart
+ Table
->Length
);
270 AcpiGbl_FileTreeRoot
->Next
= NULL
;
271 AcpiGbl_FileTreeRoot
->Parent
= NULL
;
272 AcpiGbl_FileTreeRoot
->Filename
= (char *)(AmlStart
+2);
274 /* Set the root file to the current open file */
276 AcpiGbl_FileTreeRoot
->File
= AcpiGbl_OutputFile
;
279 * Set this to true because we dont need to output
280 * an include statement for the topmost file
282 AcpiGbl_FileTreeRoot
->IncludeWritten
= TRUE
;
284 AcpiGbl_CurrentFilename
= (char *)(AmlStart
+2);
285 AcpiGbl_RootFilename
= (char *)(AmlStart
+2);
288 FileEnd
= AmlStart
+ AmlLength
;
290 while (TreeAml
<= FileEnd
)
293 * Make sure that this filename contains all printable characters
294 * and a .dsl extension at the end. If not, then it must be some
295 * raw data that doesn't outline a filename.
297 if ((*TreeAml
== AML_COMMENT_OP
) &&
298 (*(TreeAml
+1) == FILENAME_COMMENT
) &&
299 (CvIsFilename ((char *)(TreeAml
+2))))
301 CvDbgPrint ("A9 and a 08 file\n");
302 PreviousFilename
= Filename
;
303 Filename
= (char *) (TreeAml
+2);
305 CvAddToFileTree (Filename
, PreviousFilename
);
306 ChildFilename
= Filename
;
307 CvDbgPrint ("%s\n", Filename
);
309 else if ((*TreeAml
== AML_COMMENT_OP
) &&
310 (*(TreeAml
+1) == PARENTFILENAME_COMMENT
) &&
311 (CvIsFilename ((char *)(TreeAml
+2))))
313 CvDbgPrint ("A9 and a 09 file\n");
314 ParentFilename
= (char *)(TreeAml
+2);
315 CvSetFileParent (ChildFilename
, ParentFilename
);
316 CvDbgPrint ("%s\n", ParentFilename
);
324 /*******************************************************************************
326 * FUNCTION: CvClearOpComments
328 * PARAMETERS: Op -- clear all comments within this Op
332 * DESCRIPTION: Clear all converter-related fields of the given Op.
333 * This is referred as ASL_CV_CLEAR_OP_COMMENTS.
335 ******************************************************************************/
339 ACPI_PARSE_OBJECT
*Op
)
342 Op
->Common
.InlineComment
= NULL
;
343 Op
->Common
.EndNodeComment
= NULL
;
344 Op
->Common
.NameComment
= NULL
;
345 Op
->Common
.CommentList
= NULL
;
346 Op
->Common
.EndBlkComment
= NULL
;
347 Op
->Common
.CloseBraceComment
= NULL
;
348 Op
->Common
.CvFilename
= NULL
;
349 Op
->Common
.CvParentFilename
= NULL
;
353 /*******************************************************************************
355 * FUNCTION: CvCommentExists
357 * PARAMETERS: Address - check if this address appears in the list
359 * RETURN: BOOLEAN - TRUE if the address exists.
361 * DESCRIPTION: Look at the pointer address and check if this appears in the
362 * list of all addresses. If it exists in the list, return TRUE
363 * if it exists. Otherwise add to the list and return FALSE.
365 ******************************************************************************/
371 ACPI_COMMENT_ADDR_NODE
*Current
= AcpiGbl_CommentAddrListHead
;
380 Option
= *(Address
+ 1);
383 * FILENAME_COMMENT and PARENTFILENAME_COMMENT are not treated as
384 * comments. They serve as markers for where the file starts and ends.
386 if ((Option
== FILENAME_COMMENT
) ||
387 (Option
== PARENTFILENAME_COMMENT
))
394 AcpiGbl_CommentAddrListHead
=
395 AcpiOsAcquireObject (AcpiGbl_RegCommentCache
);
396 AcpiGbl_CommentAddrListHead
->Addr
= Address
;
397 AcpiGbl_CommentAddrListHead
->Next
= NULL
;
404 if (Current
->Addr
!= Address
)
406 Current
= Current
->Next
;
415 * If the execution gets to this point, it means that this
416 * address does not exists in the list. Add this address to the
417 * beginning of the list.
419 Current
= AcpiGbl_CommentAddrListHead
;
420 AcpiGbl_CommentAddrListHead
=
421 AcpiOsAcquireObject (AcpiGbl_RegCommentCache
);
423 AcpiGbl_CommentAddrListHead
->Addr
= Address
;
424 AcpiGbl_CommentAddrListHead
->Next
= Current
;
430 /*******************************************************************************
432 * FUNCTION: CvFilenameExists
434 * PARAMETERS: Filename - filename to search
436 * RETURN: ACPI_FILE_NODE - a pointer to a file node
438 * DESCRIPTION: Look for the given filename in the file dependency tree.
439 * Returns the file node if it exists, returns NULL if it does not.
441 ******************************************************************************/
446 ACPI_FILE_NODE
*Head
)
448 ACPI_FILE_NODE
*Current
= Head
;
458 if (!AcpiUtStricmp (Current
->Filename
, Filename
))
463 Current
= Current
->Next
;
469 /*******************************************************************************
471 * FUNCTION: CvFileAddressLookup
473 * PARAMETERS: Address - address to look up
474 * Head - file dependency tree
476 * RETURN: ACPI_FILE_NODE - pointer to a file node containing the address
478 * DESCRIPTION: Look for the given address in the file dependency tree.
479 * Returns the first file node where the given address is within
480 * the file node's starting and ending address.
482 ******************************************************************************/
484 static ACPI_FILE_NODE
*
487 ACPI_FILE_NODE
*Head
)
489 ACPI_FILE_NODE
*Current
= Head
;
494 if ((Address
>= Current
->FileStart
) &&
495 (Address
< Current
->FileEnd
||
501 Current
= Current
->Next
;
508 /*******************************************************************************
510 * FUNCTION: CvLabelFileNode
516 * DESCRIPTION: Takes a given parse op, looks up its Op->Common.Aml field
517 * within the file tree and fills in approperiate file information
518 * from a matching node within the tree.
519 * This is referred as ASL_CV_LABEL_FILENODE.
521 ******************************************************************************/
525 ACPI_PARSE_OBJECT
*Op
)
527 ACPI_FILE_NODE
*Node
;
535 Node
= CvFileAddressLookup ((char *)
536 Op
->Common
.Aml
, AcpiGbl_FileTreeRoot
);
542 Op
->Common
.CvFilename
= Node
->Filename
;
545 Op
->Common
.CvParentFilename
= Node
->Parent
->Filename
;
549 Op
->Common
.CvParentFilename
= Node
->Filename
;
554 /*******************************************************************************
556 * FUNCTION: CvAddToFileTree
558 * PARAMETERS: Filename - Address containing the name of the current
560 * PreviousFilename - Address containing the name of the previous
565 * DESCRIPTION: Add this filename to the AcpiGbl_FileTree if it does not exist.
567 ******************************************************************************/
572 char *PreviousFilename
)
574 ACPI_FILE_NODE
*Node
;
577 if (!AcpiUtStricmp(Filename
, AcpiGbl_RootFilename
) &&
580 Node
= CvFilenameExists (PreviousFilename
, AcpiGbl_FileTreeRoot
);
584 * Set the end point of the PreviousFilename to the address
587 Node
->FileEnd
= Filename
;
590 else if (!AcpiUtStricmp(Filename
, AcpiGbl_RootFilename
) &&
596 Node
= CvFilenameExists (Filename
, AcpiGbl_FileTreeRoot
);
597 if (Node
&& PreviousFilename
)
600 * Update the end of the previous file and all of their parents'
601 * ending addresses. This is done to ensure that parent file
602 * ranges extend to the end of their childrens' files.
604 Node
= CvFilenameExists (PreviousFilename
, AcpiGbl_FileTreeRoot
);
605 if (Node
&& (Node
->FileEnd
< Filename
))
607 Node
->FileEnd
= Filename
;
611 if (Node
->FileEnd
< Filename
)
613 Node
->FileEnd
= Filename
;
622 Node
= AcpiGbl_FileTreeRoot
;
623 AcpiGbl_FileTreeRoot
= AcpiOsAcquireObject (AcpiGbl_FileCache
);
625 AcpiGbl_FileTreeRoot
->Next
= Node
;
626 AcpiGbl_FileTreeRoot
->Parent
= NULL
;
627 AcpiGbl_FileTreeRoot
->Filename
= Filename
;
628 AcpiGbl_FileTreeRoot
->FileStart
= Filename
;
629 AcpiGbl_FileTreeRoot
->IncludeWritten
= FALSE
;
630 AcpiGbl_FileTreeRoot
->File
= fopen(Filename
, "w+");
633 * If we can't open the file, we need to abort here before we
634 * accidentally write to a NULL file.
636 if (!AcpiGbl_FileTreeRoot
->File
)
638 /* delete the .xxx file */
640 FlDeleteFile (ASL_FILE_AML_OUTPUT
);
641 sprintf (MsgBuffer
, "\"%s\" - %s", Filename
, strerror (errno
));
642 AslCommonError (ASL_ERROR
, ASL_MSG_OPEN
, 0, 0, 0, 0,
650 /*******************************************************************************
652 * FUNCTION: CvSetFileParent
654 * PARAMETERS: ChildFile - contains the filename of the child file
655 * ParentFile - contains the filename of the parent file.
659 * DESCRIPTION: Point the parent pointer of the Child to the node that
660 * corresponds with the parent file node.
662 ******************************************************************************/
669 ACPI_FILE_NODE
*Child
;
670 ACPI_FILE_NODE
*Parent
;
673 Child
= CvFilenameExists (ChildFile
, AcpiGbl_FileTreeRoot
);
674 Parent
= CvFilenameExists (ParentFile
, AcpiGbl_FileTreeRoot
);
678 Child
->Parent
= Parent
;
680 while (Child
->Parent
)
682 if (Child
->Parent
->FileEnd
< Child
->FileStart
)
684 Child
->Parent
->FileEnd
= Child
->FileStart
;
687 Child
= Child
->Parent
;
693 /*******************************************************************************
695 * FUNCTION: CvCaptureCommentsOnly
697 * PARAMETERS: ParserState - A parser state object
701 * DESCRIPTION: Look at the aml that the parser state is pointing to,
702 * capture any AML_COMMENT_OP and it's arguments and increment the
703 * aml pointer past the comment. Comments are transferred to parse
704 * nodes through CvTransferComments() as well as
705 * AcpiPsBuildNamedOp().
706 * This is referred as ASL_CV_CAPTURE_COMMENTS_ONLY.
708 ******************************************************************************/
711 CvCaptureCommentsOnly (
712 ACPI_PARSE_STATE
*ParserState
)
714 UINT8
*Aml
= ParserState
->Aml
;
715 UINT16 Opcode
= (UINT16
) ACPI_GET8 (Aml
);
718 BOOLEAN StdDefBlockFlag
= FALSE
;
719 ACPI_COMMENT_NODE
*CommentNode
;
720 ACPI_FILE_NODE
*FileNode
;
723 if (!AcpiGbl_CaptureComments
||
724 Opcode
!= AML_COMMENT_OP
)
729 while (Opcode
== AML_COMMENT_OP
)
731 CvDbgPrint ("comment aml address: %p\n", Aml
);
733 if (CvCommentExists(ParserState
->Aml
))
735 CvDbgPrint ("Avoiding capturing an existing comment.\n");
739 CommentOption
= *(Aml
+1);
742 * Increment past the comment option and point the
743 * appropriate char pointers
747 /* Found a comment. Now, set pointers to these comments. */
749 switch (CommentOption
)
751 case STD_DEFBLK_COMMENT
:
753 StdDefBlockFlag
= TRUE
;
756 * Add to a linked list of nodes. This list will be
757 * taken by the parse node created next.
759 CommentNode
= AcpiOsAcquireObject (
760 AcpiGbl_RegCommentCache
);
761 CommentNode
->Comment
= ACPI_CAST_PTR (char, Aml
);
762 CommentNode
->Next
= NULL
;
764 if (!AcpiGbl_DefBlkCommentListHead
)
766 AcpiGbl_DefBlkCommentListHead
= CommentNode
;
767 AcpiGbl_DefBlkCommentListTail
= CommentNode
;
771 AcpiGbl_DefBlkCommentListTail
->Next
= CommentNode
;
772 AcpiGbl_DefBlkCommentListTail
=
773 AcpiGbl_DefBlkCommentListTail
->Next
;
777 case STANDARD_COMMENT
:
779 CvDbgPrint ("found regular comment.\n");
782 * Add to a linked list of nodes. This list will be
783 * taken by the parse node created next.
785 CommentNode
= AcpiOsAcquireObject (
786 AcpiGbl_RegCommentCache
);
787 CommentNode
->Comment
= ACPI_CAST_PTR (char, Aml
);
788 CommentNode
->Next
= NULL
;
790 if (!AcpiGbl_RegCommentListHead
)
792 AcpiGbl_RegCommentListHead
= CommentNode
;
793 AcpiGbl_RegCommentListTail
= CommentNode
;
797 AcpiGbl_RegCommentListTail
->Next
= CommentNode
;
798 AcpiGbl_RegCommentListTail
=
799 AcpiGbl_RegCommentListTail
->Next
;
805 CvDbgPrint ("found endblk comment.\n");
807 /* Add to a linked list of nodes. This will be
808 * taken by the next created parse node.
810 CommentNode
= AcpiOsAcquireObject (
811 AcpiGbl_RegCommentCache
);
812 CommentNode
->Comment
= ACPI_CAST_PTR (char, Aml
);
813 CommentNode
->Next
= NULL
;
815 if (!AcpiGbl_EndBlkCommentListHead
)
817 AcpiGbl_EndBlkCommentListHead
= CommentNode
;
818 AcpiGbl_EndBlkCommentListTail
= CommentNode
;
822 AcpiGbl_EndBlkCommentListTail
->Next
= CommentNode
;
823 AcpiGbl_EndBlkCommentListTail
=
824 AcpiGbl_EndBlkCommentListTail
->Next
;
830 CvDbgPrint ("found inline comment.\n");
831 AcpiGbl_CurrentInlineComment
=
832 ACPI_CAST_PTR (char, Aml
);
835 case ENDNODE_COMMENT
:
837 CvDbgPrint ("found EndNode comment.\n");
838 AcpiGbl_CurrentEndNodeComment
=
839 ACPI_CAST_PTR (char, Aml
);
842 case CLOSE_BRACE_COMMENT
:
844 CvDbgPrint ("found close brace comment.\n");
845 AcpiGbl_CurrentCloseBraceComment
=
846 ACPI_CAST_PTR (char, Aml
);
849 case END_DEFBLK_COMMENT
:
851 CvDbgPrint ("Found comment that belongs after"
852 " the } for a definition block.\n");
853 AcpiGbl_CurrentScope
->Common
.CloseBraceComment
=
854 ACPI_CAST_PTR (char, Aml
);
857 case FILENAME_COMMENT
:
859 CvDbgPrint ("Found a filename: %s\n",
860 ACPI_CAST_PTR (char, Aml
));
861 FileNode
= CvFilenameExists (
862 ACPI_CAST_PTR (char, Aml
), AcpiGbl_FileTreeRoot
);
865 * If there is an INCLUDE_COMMENT followed by a
866 * FILENAME_COMMENT, then the INCLUDE_COMMENT is a comment
867 * that is emitted before the #include for the file.
868 * We will save the IncludeComment within the FileNode
869 * associated with this FILENAME_COMMENT.
871 if (FileNode
&& AcpiGbl_IncCommentListHead
)
873 FileNode
->IncludeComment
= AcpiGbl_IncCommentListHead
;
874 AcpiGbl_IncCommentListHead
= NULL
;
875 AcpiGbl_IncCommentListTail
= NULL
;
879 case PARENTFILENAME_COMMENT
:
880 CvDbgPrint (" Found a parent filename.\n");
883 case INCLUDE_COMMENT
:
886 * Add to a linked list. This list will be taken by the
887 * parse node created next. See the FILENAME_COMMENT case
890 CommentNode
= AcpiOsAcquireObject (
891 AcpiGbl_RegCommentCache
);
892 CommentNode
->Comment
= ACPI_CAST_PTR (char, Aml
);
893 CommentNode
->Next
= NULL
;
895 if (!AcpiGbl_IncCommentListHead
)
897 AcpiGbl_IncCommentListHead
= CommentNode
;
898 AcpiGbl_IncCommentListTail
= CommentNode
;
902 AcpiGbl_IncCommentListTail
->Next
= CommentNode
;
903 AcpiGbl_IncCommentListTail
=
904 AcpiGbl_IncCommentListTail
->Next
;
907 CvDbgPrint ("Found a include comment: %s\n",
908 CommentNode
->Comment
);
913 /* Not a valid comment option. Revert the AML */
918 } /* End switch statement */
922 /* Determine the length and move forward that amount */
925 while (ParserState
->Aml
[Length
])
930 ParserState
->Aml
+= Length
+ 1;
932 /* Peek at the next Opcode. */
934 Aml
= ParserState
->Aml
;
935 Opcode
= (UINT16
) ACPI_GET8 (Aml
);
942 * Give all of its comments to the current scope, which is known as
943 * the definition block, since STD_DEFBLK_COMMENT only appears after
944 * definition block headers.
946 AcpiGbl_CurrentScope
->Common
.CommentList
947 = AcpiGbl_DefBlkCommentListHead
;
948 AcpiGbl_DefBlkCommentListHead
= NULL
;
949 AcpiGbl_DefBlkCommentListTail
= NULL
;
954 /*******************************************************************************
956 * FUNCTION: CvCaptureComments
958 * PARAMETERS: ParserState - A parser state object
962 * DESCRIPTION: Wrapper function for CvCaptureCommentsOnly
963 * This is referred as ASL_CV_CAPTURE_COMMENTS.
965 ******************************************************************************/
969 ACPI_WALK_STATE
*WalkState
)
973 const ACPI_OPCODE_INFO
*OpInfo
;
976 if (!AcpiGbl_CaptureComments
)
982 * Before parsing, check to see that comments that come directly
983 * after deferred opcodes aren't being processed.
985 Aml
= WalkState
->ParserState
.Aml
;
986 Opcode
= (UINT16
) ACPI_GET8 (Aml
);
987 OpInfo
= AcpiPsGetOpcodeInfo (Opcode
);
989 if (!(OpInfo
->Flags
& AML_DEFER
) ||
990 ((OpInfo
->Flags
& AML_DEFER
) &&
991 (WalkState
->PassNumber
!= ACPI_IMODE_LOAD_PASS1
)))
993 CvCaptureCommentsOnly (&WalkState
->ParserState
);
994 WalkState
->Aml
= WalkState
->ParserState
.Aml
;
1000 /*******************************************************************************
1002 * FUNCTION: CvTransferComments
1004 * PARAMETERS: Op - Transfer comments to this Op
1008 * DESCRIPTION: Transfer all of the commments stored in global containers to the
1009 * given Op. This will be invoked shortly after the parser creates
1011 * This is referred as ASL_CV_TRANSFER_COMMENTS.
1013 ******************************************************************************/
1016 CvTransferComments (
1017 ACPI_PARSE_OBJECT
*Op
)
1020 Op
->Common
.InlineComment
= AcpiGbl_CurrentInlineComment
;
1021 AcpiGbl_CurrentInlineComment
= NULL
;
1023 Op
->Common
.EndNodeComment
= AcpiGbl_CurrentEndNodeComment
;
1024 AcpiGbl_CurrentEndNodeComment
= NULL
;
1026 Op
->Common
.CloseBraceComment
= AcpiGbl_CurrentCloseBraceComment
;
1027 AcpiGbl_CurrentCloseBraceComment
= NULL
;
1029 Op
->Common
.CommentList
= AcpiGbl_RegCommentListHead
;
1030 AcpiGbl_RegCommentListHead
= NULL
;
1031 AcpiGbl_RegCommentListTail
= NULL
;
1033 Op
->Common
.EndBlkComment
= AcpiGbl_EndBlkCommentListHead
;
1034 AcpiGbl_EndBlkCommentListHead
= NULL
;
1035 AcpiGbl_EndBlkCommentListTail
= NULL
;