1 /******************************************************************************
3 * Module Name: cvcompiler - ASL-/ASL+ converter functions
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include <contrib/dev/acpica/compiler/aslcompiler.h>
153 #include "aslcompiler.y.h"
154 #include <contrib/dev/acpica/include/amlcode.h>
155 #include <contrib/dev/acpica/include/acapps.h>
156 #include <contrib/dev/acpica/include/acconvert.h>
159 /*******************************************************************************
161 * FUNCTION: CvProcessComment
163 * PARAMETERS: CurrentState Current comment parse state
164 * StringBuffer Buffer containing the comment being processed
169 * DESCRIPTION: Process a single line comment of a c Style comment. This
170 * function captures a line of a c style comment in a char* and
171 * places the comment in the approperiate global buffer.
173 ******************************************************************************/
177 ASL_COMMENT_STATE CurrentState,
183 char *FinalLineToken;
186 char *FinalCommentString;
189 if (Gbl_CaptureComments && CurrentState.CaptureComments)
191 *StringBuffer = (char) c1;
194 CvDbgPrint ("Multi-line comment\n");
195 CommentString = UtStringCacheCalloc (strlen (MsgBuffer) + 1);
196 strcpy (CommentString, MsgBuffer);
198 CvDbgPrint ("CommentString: %s\n", CommentString);
201 * Determine whether if this comment spans multiple lines.
202 * If so, break apart the comment by line so that it can be
205 if (strchr (CommentString, '\n') != NULL)
208 * Get the first token. The for loop pads subsequent lines
209 * for comments similar to the style of this comment.
211 LineToken = strtok (CommentString, "\n");
212 FinalLineToken = UtStringCacheCalloc (strlen (LineToken) + 1);
213 strcpy (FinalLineToken, LineToken);
215 /* Get rid of any carriage returns */
217 if (FinalLineToken[strlen (FinalLineToken) - 1] == 0x0D)
219 FinalLineToken[strlen(FinalLineToken)-1] = 0;
221 CvAddToCommentList (FinalLineToken);
222 LineToken = strtok (NULL, "\n");
223 while (LineToken != NULL)
226 * It is assumed that each line has some sort of indentation.
227 * This means that we need to find the first character that is not
228 * a white space within each line.
231 for (i = 0; (i < (strlen (LineToken) + 1)) && !CharStart; i++)
233 if (LineToken[i] != ' ' && LineToken[i] != '\t')
237 LineToken [0] = ' '; /* Pad for Formatting */
240 FinalLineToken = UtStringCacheCalloc (strlen (LineToken) + 1);
241 strcat (FinalLineToken, LineToken);
243 /* Get rid of any carriage returns */
245 if (FinalLineToken[strlen (FinalLineToken) - 1] == 0x0D)
247 FinalLineToken[strlen(FinalLineToken) - 1] = 0;
249 CvAddToCommentList (FinalLineToken);
250 LineToken = strtok (NULL,"\n");
255 * If this only spans a single line, check to see whether if this comment
256 * appears on the same line as a line of code. If does, retain it's
257 * position for stylistic reasons. If it doesn't, add it to the comment
258 * List so that it can be associated with the next node that's created.
263 * if this is not a regular comment, pad with extra spaces that appeared
264 * in the original source input to retain the original spacing.
266 FinalCommentString = UtStringCacheCalloc (strlen (CommentString) + CurrentState.SpacesBefore + 1);
267 for (i=0; (CurrentState.CommentType != ASL_COMMENT_STANDARD) &&
268 (i < CurrentState.SpacesBefore); ++i)
270 FinalCommentString[i] = ' ';
272 strcat (FinalCommentString, CommentString);
273 CvPlaceComment (CurrentState.CommentType, FinalCommentString);
279 /*******************************************************************************
281 * FUNCTION: CvProcessCommentType2
283 * PARAMETERS: CurrentState Current comment parse state
284 * StringBuffer Buffer containing the comment being processed
288 * DESCRIPTION: Process a single line comment. This function captures a comment
289 * in a char* and places the comment in the approperiate global
290 * buffer through CvPlaceComment
292 ******************************************************************************/
295 CvProcessCommentType2 (
296 ASL_COMMENT_STATE CurrentState,
301 char *FinalCommentString;
304 if (Gbl_CaptureComments && CurrentState.CaptureComments)
306 *StringBuffer = 0; /* null terminate */
307 CvDbgPrint ("Single-line comment\n");
308 CommentString = UtStringCacheCalloc (strlen (MsgBuffer) + 1);
309 strcpy (CommentString, MsgBuffer);
311 /* If this comment lies on the same line as the latest parse node,
312 * assign it to that node's CommentAfter field. Saving in this field
313 * will allow us to support comments that come after code on the same
314 * line as the code itself. For example,
315 * Name(A,"") //comment
317 * will be retained rather than transformed into
322 * For this case, we only need to add one comment since
324 * Name(A,"") //comment1 //comment2 ... more comments here.
326 * would be lexically analyzed as a single comment.
328 * Create a new string with the approperiate spaces. Since we need
329 * to account for the proper spacing, the actual comment,
330 * extra 2 spaces so that this comment can be converted to the "/ *"
331 * style and the null terminator, the string would look something like
333 * [ (spaces) (comment) ( * /) ('\0') ]
336 FinalCommentString = UtStringCacheCalloc (CurrentState.SpacesBefore + strlen (CommentString) + 3 + 1);
337 for (i=0; (CurrentState.CommentType!=1) && (i<CurrentState.SpacesBefore); ++i)
339 FinalCommentString[i] = ' ';
341 strcat (FinalCommentString, CommentString);
343 /* convert to a "/ *" style comment */
345 strcat (FinalCommentString, " */");
346 FinalCommentString [CurrentState.SpacesBefore + strlen (CommentString) + 3] = 0;
348 /* get rid of the carriage return */
350 if (FinalCommentString[strlen (FinalCommentString) - 1] == 0x0D)
352 FinalCommentString[strlen(FinalCommentString)-1] = 0;
354 CvPlaceComment (CurrentState.CommentType, FinalCommentString);
359 /*******************************************************************************
361 * FUNCTION: CgCalculateCommentLengths
363 * PARAMETERS: Op - Calculate all comments of this Op
365 * RETURN: TotalCommentLength - Length of all comments within this node.
367 * DESCRIPTION: calculate the length that the each comment takes up within Op.
368 * Comments look like the follwoing: [0xA9 OptionBtye comment 0x00]
369 * therefore, we add 1 + 1 + strlen (comment) + 1 to get the actual
370 * length of this comment.
372 ******************************************************************************/
375 CvCalculateCommentLengths(
376 ACPI_PARSE_OBJECT *Op)
378 UINT32 CommentLength = 0;
379 UINT32 TotalCommentLength = 0;
380 ACPI_COMMENT_NODE *Current = NULL;
383 if (!Gbl_CaptureComments)
388 CvDbgPrint ("==Calculating comment lengths for %s\n", Op->Asl.ParseOpName);
389 if (Op->Asl.FileChanged)
391 TotalCommentLength += strlen (Op->Asl.Filename) + 3;
393 if (Op->Asl.ParentFilename &&
394 AcpiUtStricmp (Op->Asl.Filename, Op->Asl.ParentFilename))
396 TotalCommentLength += strlen (Op->Asl.ParentFilename) + 3;
399 if (Op->Asl.CommentList)
401 Current = Op->Asl.CommentList;
404 CommentLength = strlen (Current->Comment)+3;
405 CvDbgPrint ("Length of standard comment: %d\n", CommentLength);
406 CvDbgPrint (" Comment string: %s\n\n", Current->Comment);
407 TotalCommentLength += CommentLength;
408 Current = Current->Next;
411 if (Op->Asl.EndBlkComment)
413 Current = Op->Asl.EndBlkComment;
416 CommentLength = strlen (Current->Comment)+3;
417 CvDbgPrint ("Length of endblkcomment: %d\n", CommentLength);
418 CvDbgPrint (" Comment string: %s\n\n", Current->Comment);
419 TotalCommentLength += CommentLength;
420 Current = Current->Next;
423 if (Op->Asl.InlineComment)
425 CommentLength = strlen (Op->Asl.InlineComment)+3;
426 CvDbgPrint ("Length of inline comment: %d\n", CommentLength);
427 CvDbgPrint (" Comment string: %s\n\n", Op->Asl.InlineComment);
428 TotalCommentLength += CommentLength;
430 if (Op->Asl.EndNodeComment)
432 CommentLength = strlen(Op->Asl.EndNodeComment)+3;
433 CvDbgPrint ("Length of end node comment +3: %d\n", CommentLength);
434 CvDbgPrint (" Comment string: %s\n\n", Op->Asl.EndNodeComment);
435 TotalCommentLength += CommentLength;
438 if (Op->Asl.CloseBraceComment)
440 CommentLength = strlen (Op->Asl.CloseBraceComment)+3;
441 CvDbgPrint ("Length of close brace comment: %d\n", CommentLength);
442 CvDbgPrint (" Comment string: %s\n\n", Op->Asl.CloseBraceComment);
443 TotalCommentLength += CommentLength;
448 return TotalCommentLength;
453 /*******************************************************************************
455 * FUNCTION: CgWriteAmlDefBlockComment
457 * PARAMETERS: Op - Current parse op
461 * DESCRIPTION: Write all comments for a particular definition block.
462 * For definition blocks, the comments need to come after the
463 * definition block header. The regular comments above the
464 * definition block would be categorized as
465 * STD_DEFBLK_COMMENT and comments after the closing brace
466 * is categorized as END_DEFBLK_COMMENT.
468 ******************************************************************************/
471 CgWriteAmlDefBlockComment(
472 ACPI_PARSE_OBJECT *Op)
475 ACPI_COMMENT_NODE *Current;
478 char *DirectoryPosition;
481 if (!Gbl_CaptureComments ||
482 (Op->Asl.ParseOpcode != PARSEOP_DEFINITION_BLOCK))
487 CvDbgPrint ("Printing comments for a definition block..\n");
489 /* first, print the file name comment after changing .asl to .dsl */
491 NewFilename = UtStringCacheCalloc (strlen (Op->Asl.Filename));
492 strcpy (NewFilename, Op->Asl.Filename);
493 DirectoryPosition = strrchr (NewFilename, '/');
494 Position = strrchr (NewFilename, '.');
496 if (Position && (Position > DirectoryPosition))
498 /* Tack on the new suffix */
502 strcat (Position, FILE_SUFFIX_DISASSEMBLY);
506 /* No dot, add one and then the suffix */
508 strcat (NewFilename, ".");
509 strcat (NewFilename, FILE_SUFFIX_DISASSEMBLY);
512 CommentOption = FILENAME_COMMENT;
513 CgWriteOneAmlComment(Op, NewFilename, CommentOption);
515 Current = Op->Asl.CommentList;
516 CommentOption = STD_DEFBLK_COMMENT;
519 CgWriteOneAmlComment(Op, Current->Comment, CommentOption);
520 CvDbgPrint ("Printing comment: %s\n", Current->Comment);
521 Current = Current->Next;
523 Op->Asl.CommentList = NULL;
525 /* print any Inline comments associated with this node */
527 if (Op->Asl.CloseBraceComment)
529 CommentOption = END_DEFBLK_COMMENT;
530 CgWriteOneAmlComment(Op, Op->Asl.CloseBraceComment, CommentOption);
531 Op->Asl.CloseBraceComment = NULL;
536 /*******************************************************************************
538 * FUNCTION: CgWriteOneAmlComment
540 * PARAMETERS: Op - Current parse op
541 * CommentToPrint - Comment that's printed
542 * InputOption - Denotes the comment option.
546 * DESCRIPTION: write a single comment.
548 ******************************************************************************/
551 CgWriteOneAmlComment(
552 ACPI_PARSE_OBJECT *Op,
553 char* CommentToPrint,
556 UINT8 CommentOption = InputOption;
557 UINT8 CommentOpcode = (UINT8)AML_COMMENT_OP;
559 CgLocalWriteAmlData (Op, &CommentOpcode, 1);
560 CgLocalWriteAmlData (Op, &CommentOption, 1);
562 /* The strlen (..) + 1 is to include the null terminator */
564 CgLocalWriteAmlData (Op, CommentToPrint, strlen (CommentToPrint) + 1);
568 /*******************************************************************************
570 * FUNCTION: CgWriteAmlComment
572 * PARAMETERS: Op - Current parse op
576 * DESCRIPTION: write all comments pertaining to the
579 ******************************************************************************/
583 ACPI_PARSE_OBJECT *Op)
585 ACPI_COMMENT_NODE *Current;
588 char *ParentFilename;
591 if ((Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK) ||
592 !Gbl_CaptureComments)
597 /* Print out the filename comment if needed */
599 if (Op->Asl.FileChanged)
602 /* first, print the file name comment after changing .asl to .dsl */
605 FlGenerateFilename (Op->Asl.Filename, FILE_SUFFIX_DISASSEMBLY);
606 CvDbgPrint ("Writing file comment, \"%s\" for %s\n",
607 NewFilename, Op->Asl.ParseOpName);
608 CgWriteOneAmlComment(Op, NewFilename, FILENAME_COMMENT);
610 if (Op->Asl.ParentFilename &&
611 AcpiUtStricmp (Op->Asl.ParentFilename, Op->Asl.Filename))
613 ParentFilename = FlGenerateFilename (Op->Asl.ParentFilename,
614 FILE_SUFFIX_DISASSEMBLY);
615 CgWriteOneAmlComment(Op, ParentFilename, PARENTFILENAME_COMMENT);
618 /* prevent multiple writes of the same comment */
620 Op->Asl.FileChanged = FALSE;
624 * Regular comments are stored in a list of comments within an Op.
625 * If there is a such list in this node, print out the comment
628 Current = Op->Asl.CommentList;
629 if (Op->Asl.ParseOpcode == PARSEOP_INCLUDE)
631 CommentOption = INCLUDE_COMMENT;
635 CommentOption = STANDARD_COMMENT;
640 CgWriteOneAmlComment(Op, Current->Comment, CommentOption);
641 Current = Current->Next;
643 Op->Asl.CommentList = NULL;
645 Current = Op->Asl.EndBlkComment;
646 CommentOption = ENDBLK_COMMENT;
649 CgWriteOneAmlComment(Op, Current->Comment, CommentOption);
650 Current = Current->Next;
652 Op->Asl.EndBlkComment = NULL;
654 /* print any Inline comments associated with this node */
656 if (Op->Asl.InlineComment)
658 CommentOption = INLINE_COMMENT;
659 CgWriteOneAmlComment(Op, Op->Asl.InlineComment, CommentOption);
660 Op->Asl.InlineComment = NULL;
663 if (Op->Asl.EndNodeComment)
665 CommentOption = ENDNODE_COMMENT;
666 CgWriteOneAmlComment(Op, Op->Asl.EndNodeComment, CommentOption);
667 Op->Asl.EndNodeComment = NULL;
670 if (Op->Asl.CloseBraceComment)
672 CommentOption = CLOSE_BRACE_COMMENT;
673 CgWriteOneAmlComment(Op, Op->Asl.CloseBraceComment, CommentOption);
674 Op->Asl.CloseBraceComment = NULL;
679 /*******************************************************************************
681 * FUNCTION: CvCommentNodeCalloc
685 * RETURN: Pointer to the comment node. Aborts on allocation failure
687 * DESCRIPTION: Allocate a string node buffer.
689 ******************************************************************************/
692 CvCommentNodeCalloc (
695 ACPI_COMMENT_NODE *NewCommentNode;
699 (ACPI_COMMENT_NODE*) UtLocalCalloc (sizeof(ACPI_COMMENT_NODE));
700 NewCommentNode->Next = NULL;
701 return NewCommentNode;
705 /*******************************************************************************
707 * FUNCTION: CvParseOpBlockType
709 * PARAMETERS: Op - Object to be examined
711 * RETURN: BlockType - not a block, parens, braces, or even both.
713 * DESCRIPTION: Type of block for this ASL parseop (parens or braces)
714 * keep this in sync with aslprimaries.y, aslresources.y and
717 ******************************************************************************/
721 ACPI_PARSE_OBJECT *Op)
728 switch (Op->Asl.ParseOpcode)
731 /* from aslprimaries.y */
733 case PARSEOP_VAR_PACKAGE:
734 case PARSEOP_BANKFIELD:
740 case PARSEOP_FUNCTION:
743 case PARSEOP_INDEXFIELD:
745 case PARSEOP_POWERRESOURCE:
746 case PARSEOP_PROCESSOR:
747 case PARSEOP_DATABUFFER:
750 case PARSEOP_THERMALZONE:
753 /* from aslresources.y */
755 case PARSEOP_RESOURCETEMPLATE: /* optional parens */
756 case PARSEOP_VENDORLONG:
757 case PARSEOP_VENDORSHORT:
758 case PARSEOP_INTERRUPT:
759 case PARSEOP_IRQNOFLAGS:
761 case PARSEOP_GPIO_INT:
762 case PARSEOP_GPIO_IO:
767 case PARSEOP_DEFINITION_BLOCK:
768 return (BLOCK_PAREN | BLOCK_BRACE);
777 /*******************************************************************************
779 * FUNCTION: CvProcessCommentState
785 * DESCRIPTION: Take the given input. If this character is
786 * defined as a comment table entry, then update the state
789 ******************************************************************************/
792 CvProcessCommentState (
798 Gbl_CommentState.SpacesBefore = 0;
805 Gbl_CommentState.CommentType = ASL_COMMENT_STANDARD;
810 /* Keep the CommentType the same */
812 Gbl_CommentState.SpacesBefore++;
817 Gbl_CommentState.CommentType = ASL_COMMENT_OPEN_PAREN;
822 Gbl_CommentState.CommentType = ASL_COMMENT_CLOSE_PAREN;
827 Gbl_CommentState.CommentType = ASL_COMMENT_STANDARD;
828 Gbl_CommentState.ParsingParenBraceNode = NULL;
829 CvDbgPrint ("End Parsing paren/Brace node!\n");
834 Gbl_CommentState.CommentType = ASL_COMMENT_CLOSE_BRACE;
839 Gbl_CommentState.CommentType = ASLCOMMENT_INLINE;
844 Gbl_CommentState.CommentType = ASLCOMMENT_INLINE;
851 /*******************************************************************************
853 * FUNCTION: CvAddToCommentList
855 * PARAMETERS: toAdd - Contains the comment to be inserted
859 * DESCRIPTION: Add the given char* to a list of comments in the global list
862 ******************************************************************************/
868 if (Gbl_Comment_List_Head)
870 Gbl_Comment_List_Tail->Next = CvCommentNodeCalloc ();
871 Gbl_Comment_List_Tail = Gbl_Comment_List_Tail->Next;
875 Gbl_Comment_List_Head = CvCommentNodeCalloc ();
876 Gbl_Comment_List_Tail = Gbl_Comment_List_Head;
879 Gbl_Comment_List_Tail->Comment = ToAdd;
884 /*******************************************************************************
886 * FUNCTION: CvAppendInlineComment
888 * PARAMETERS: InlineComment - Append to the end of this string.
889 * toAdd - Contains the comment to be inserted
891 * RETURN: Str - toAdd appended to InlineComment
893 * DESCRIPTION: Concatenate ToAdd to InlineComment
895 ******************************************************************************/
898 CvAppendInlineComment (
912 Size = strlen (ToAdd);
914 Size += strlen (InlineComment);
915 Str = UtStringCacheCalloc (Size+1);
916 strcpy (Str, InlineComment);
924 /*******************************************************************************
926 * FUNCTION: CvPlaceComment
928 * PARAMETERS: Int - Type
929 * char* - CommentString
933 * DESCRIPTION: Given type and CommentString, this function places the
934 * CommentString in the approperiate global comment list or char*
936 ******************************************************************************/
943 ACPI_PARSE_OBJECT *LatestParseNode;
944 ACPI_PARSE_OBJECT *ParenBraceNode;
947 LatestParseNode = Gbl_CommentState.Latest_Parse_Node;
948 ParenBraceNode = Gbl_CommentState.ParsingParenBraceNode;
949 CvDbgPrint ("Placing comment %s for type %d\n", CommentString, Type);
953 case ASL_COMMENT_STANDARD:
955 CvAddToCommentList (CommentString);
958 case ASLCOMMENT_INLINE:
960 LatestParseNode->Asl.InlineComment =
961 CvAppendInlineComment (LatestParseNode->Asl.InlineComment,
965 case ASL_COMMENT_OPEN_PAREN:
967 Gbl_Inline_Comment_Buffer =
968 CvAppendInlineComment(Gbl_Inline_Comment_Buffer,
972 case ASL_COMMENT_CLOSE_PAREN:
976 ParenBraceNode->Asl.EndNodeComment =
977 CvAppendInlineComment (ParenBraceNode->Asl.EndNodeComment,
982 LatestParseNode->Asl.EndNodeComment =
983 CvAppendInlineComment (LatestParseNode->Asl.EndNodeComment,
988 case ASL_COMMENT_CLOSE_BRACE:
990 LatestParseNode->Asl.CloseBraceComment = CommentString;