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;
195 CvDbgPrint ("Multi-line comment\n");
196 CommentString = UtStringCacheCalloc (strlen (MsgBuffer) + 1);
197 strcpy (CommentString, MsgBuffer);
199 CvDbgPrint ("CommentString: %s\n", CommentString);
202 * Determine whether if this comment spans multiple lines. If so,
203 * break apart the comment by storing each line in a different node
204 * within the comment list. This allows the disassembler to
205 * properly indent a multi-line comment.
207 LineToken = strtok (CommentString, "\n");
211 FinalLineToken = UtStringCacheCalloc (strlen (LineToken) + 1);
212 strcpy (FinalLineToken, LineToken);
214 /* Get rid of any carriage returns */
216 if (FinalLineToken[strlen (FinalLineToken) - 1] == 0x0D)
218 FinalLineToken[strlen(FinalLineToken)-1] = 0;
220 CvAddToCommentList (FinalLineToken);
221 LineToken = strtok (NULL, "\n");
222 while (LineToken != NULL)
225 * It is assumed that each line has some sort of indentation.
226 * This means that we need to find the first character that is not
227 * a white space within each line.
230 for (i = 0; (i < (strlen (LineToken) + 1)) && !CharStart; i++)
232 if (LineToken[i] != ' ' && LineToken[i] != '\t')
236 LineToken [0] = ' '; /* Pad for Formatting */
239 FinalLineToken = UtStringCacheCalloc (strlen (LineToken) + 1);
240 strcat (FinalLineToken, LineToken);
242 /* Get rid of any carriage returns */
244 if (FinalLineToken[strlen (FinalLineToken) - 1] == 0x0D)
246 FinalLineToken[strlen(FinalLineToken) - 1] = 0;
248 CvAddToCommentList (FinalLineToken);
249 LineToken = strtok (NULL,"\n");
254 * If this only spans a single line, check to see whether if this comment
255 * appears on the same line as a line of code. If does, retain it's
256 * position for stylistic reasons. If it doesn't, add it to the comment
257 * List so that it can be associated with the next node that's created.
262 * if this is not a regular comment, pad with extra spaces that appeared
263 * in the original source input to retain the original spacing.
266 UtStringCacheCalloc (strlen (CommentString) +
267 CurrentState.SpacesBefore + 1);
269 for (i=0; (CurrentState.CommentType != ASL_COMMENT_STANDARD) &&
270 (i < CurrentState.SpacesBefore); ++i)
272 FinalCommentString[i] = ' ';
274 strcat (FinalCommentString, CommentString);
275 CvPlaceComment (CurrentState.CommentType, FinalCommentString);
281 /*******************************************************************************
283 * FUNCTION: CvProcessCommentType2
285 * PARAMETERS: CurrentState Current comment parse state
286 * StringBuffer Buffer containing the comment being processed
290 * DESCRIPTION: Process a single line comment. This function captures a comment
291 * in a char* and places the comment in the approperiate global
292 * buffer through CvPlaceComment
294 ******************************************************************************/
297 CvProcessCommentType2 (
298 ASL_COMMENT_STATE CurrentState,
303 char *FinalCommentString;
306 if (Gbl_CaptureComments && CurrentState.CaptureComments)
308 *StringBuffer = 0; /* null terminate */
309 CvDbgPrint ("Single-line comment\n");
310 CommentString = UtStringCacheCalloc (strlen (MsgBuffer) + 1);
311 strcpy (CommentString, MsgBuffer);
313 /* If this comment lies on the same line as the latest parse node,
314 * assign it to that node's CommentAfter field. Saving in this field
315 * will allow us to support comments that come after code on the same
316 * line as the code itself. For example,
317 * Name(A,"") //comment
319 * will be retained rather than transformed into
324 * For this case, we only need to add one comment since
326 * Name(A,"") //comment1 //comment2 ... more comments here.
328 * would be lexically analyzed as a single comment.
330 * Create a new string with the approperiate spaces. Since we need
331 * to account for the proper spacing, the actual comment,
332 * extra 2 spaces so that this comment can be converted to the "/ *"
333 * style and the null terminator, the string would look something like
335 * [ (spaces) (comment) ( * /) ('\0') ]
338 FinalCommentString = UtStringCacheCalloc (CurrentState.SpacesBefore +
339 strlen (CommentString) + 3 + 1);
341 for (i=0; (CurrentState.CommentType!=1) && (i<CurrentState.SpacesBefore); ++i)
343 FinalCommentString[i] = ' ';
345 strcat (FinalCommentString, CommentString);
347 /* convert to a "/ *" style comment */
349 strcat (FinalCommentString, " */");
350 FinalCommentString [CurrentState.SpacesBefore + strlen (CommentString) + 3] = 0;
352 /* get rid of the carriage return */
354 if (FinalCommentString[strlen (FinalCommentString) - 1] == 0x0D)
356 FinalCommentString[strlen(FinalCommentString)-1] = 0;
358 CvPlaceComment (CurrentState.CommentType, FinalCommentString);
363 /*******************************************************************************
365 * FUNCTION: CgCalculateCommentLengths
367 * PARAMETERS: Op - Calculate all comments of this Op
369 * RETURN: TotalCommentLength - Length of all comments within this node.
371 * DESCRIPTION: calculate the length that the each comment takes up within Op.
372 * Comments look like the follwoing: [0xA9 OptionBtye comment 0x00]
373 * therefore, we add 1 + 1 + strlen (comment) + 1 to get the actual
374 * length of this comment.
376 ******************************************************************************/
379 CvCalculateCommentLengths(
380 ACPI_PARSE_OBJECT *Op)
382 UINT32 CommentLength = 0;
383 UINT32 TotalCommentLength = 0;
384 ACPI_COMMENT_NODE *Current = NULL;
387 if (!Gbl_CaptureComments)
392 CvDbgPrint ("==Calculating comment lengths for %s\n", Op->Asl.ParseOpName);
393 if (Op->Asl.FileChanged)
395 TotalCommentLength += strlen (Op->Asl.Filename) + 3;
397 if (Op->Asl.ParentFilename &&
398 AcpiUtStricmp (Op->Asl.Filename, Op->Asl.ParentFilename))
400 TotalCommentLength += strlen (Op->Asl.ParentFilename) + 3;
403 if (Op->Asl.CommentList)
405 Current = Op->Asl.CommentList;
408 CommentLength = strlen (Current->Comment)+3;
409 CvDbgPrint ("Length of standard comment: %d\n", CommentLength);
410 CvDbgPrint (" Comment string: %s\n\n", Current->Comment);
411 TotalCommentLength += CommentLength;
412 Current = Current->Next;
415 if (Op->Asl.EndBlkComment)
417 Current = Op->Asl.EndBlkComment;
420 CommentLength = strlen (Current->Comment)+3;
421 CvDbgPrint ("Length of endblkcomment: %d\n", CommentLength);
422 CvDbgPrint (" Comment string: %s\n\n", Current->Comment);
423 TotalCommentLength += CommentLength;
424 Current = Current->Next;
427 if (Op->Asl.InlineComment)
429 CommentLength = strlen (Op->Asl.InlineComment)+3;
430 CvDbgPrint ("Length of inline comment: %d\n", CommentLength);
431 CvDbgPrint (" Comment string: %s\n\n", Op->Asl.InlineComment);
432 TotalCommentLength += CommentLength;
434 if (Op->Asl.EndNodeComment)
436 CommentLength = strlen(Op->Asl.EndNodeComment)+3;
437 CvDbgPrint ("Length of end node comment +3: %d\n", CommentLength);
438 CvDbgPrint (" Comment string: %s\n\n", Op->Asl.EndNodeComment);
439 TotalCommentLength += CommentLength;
442 if (Op->Asl.CloseBraceComment)
444 CommentLength = strlen (Op->Asl.CloseBraceComment)+3;
445 CvDbgPrint ("Length of close brace comment: %d\n", CommentLength);
446 CvDbgPrint (" Comment string: %s\n\n", Op->Asl.CloseBraceComment);
447 TotalCommentLength += CommentLength;
452 return TotalCommentLength;
457 /*******************************************************************************
459 * FUNCTION: CgWriteAmlDefBlockComment
461 * PARAMETERS: Op - Current parse op
465 * DESCRIPTION: Write all comments for a particular definition block.
466 * For definition blocks, the comments need to come after the
467 * definition block header. The regular comments above the
468 * definition block would be categorized as
469 * STD_DEFBLK_COMMENT and comments after the closing brace
470 * is categorized as END_DEFBLK_COMMENT.
472 ******************************************************************************/
475 CgWriteAmlDefBlockComment(
476 ACPI_PARSE_OBJECT *Op)
479 ACPI_COMMENT_NODE *Current;
482 char *DirectoryPosition;
485 if (!Gbl_CaptureComments ||
486 (Op->Asl.ParseOpcode != PARSEOP_DEFINITION_BLOCK))
491 CvDbgPrint ("Printing comments for a definition block..\n");
493 /* first, print the file name comment after changing .asl to .dsl */
495 NewFilename = UtStringCacheCalloc (strlen (Op->Asl.Filename));
496 strcpy (NewFilename, Op->Asl.Filename);
497 DirectoryPosition = strrchr (NewFilename, '/');
498 Position = strrchr (NewFilename, '.');
500 if (Position && (Position > DirectoryPosition))
502 /* Tack on the new suffix */
506 strcat (Position, FILE_SUFFIX_DISASSEMBLY);
510 /* No dot, add one and then the suffix */
512 strcat (NewFilename, ".");
513 strcat (NewFilename, FILE_SUFFIX_DISASSEMBLY);
516 CommentOption = FILENAME_COMMENT;
517 CgWriteOneAmlComment(Op, NewFilename, CommentOption);
519 Current = Op->Asl.CommentList;
520 CommentOption = STD_DEFBLK_COMMENT;
523 CgWriteOneAmlComment(Op, Current->Comment, CommentOption);
524 CvDbgPrint ("Printing comment: %s\n", Current->Comment);
525 Current = Current->Next;
527 Op->Asl.CommentList = NULL;
529 /* print any Inline comments associated with this node */
531 if (Op->Asl.CloseBraceComment)
533 CommentOption = END_DEFBLK_COMMENT;
534 CgWriteOneAmlComment(Op, Op->Asl.CloseBraceComment, CommentOption);
535 Op->Asl.CloseBraceComment = NULL;
540 /*******************************************************************************
542 * FUNCTION: CgWriteOneAmlComment
544 * PARAMETERS: Op - Current parse op
545 * CommentToPrint - Comment that's printed
546 * InputOption - Denotes the comment option.
550 * DESCRIPTION: write a single comment.
552 ******************************************************************************/
555 CgWriteOneAmlComment(
556 ACPI_PARSE_OBJECT *Op,
557 char* CommentToPrint,
560 UINT8 CommentOption = InputOption;
561 UINT8 CommentOpcode = (UINT8)AML_COMMENT_OP;
569 CgLocalWriteAmlData (Op, &CommentOpcode, 1);
570 CgLocalWriteAmlData (Op, &CommentOption, 1);
572 /* The strlen (..) + 1 is to include the null terminator */
574 CgLocalWriteAmlData (Op, CommentToPrint, strlen (CommentToPrint) + 1);
578 /*******************************************************************************
580 * FUNCTION: CgWriteAmlComment
582 * PARAMETERS: Op - Current parse op
586 * DESCRIPTION: write all comments pertaining to the
589 ******************************************************************************/
593 ACPI_PARSE_OBJECT *Op)
595 ACPI_COMMENT_NODE *Current;
598 char *ParentFilename;
601 if ((Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK) ||
602 !Gbl_CaptureComments)
607 /* Print out the filename comment if needed */
609 if (Op->Asl.FileChanged)
612 /* first, print the file name comment after changing .asl to .dsl */
615 FlGenerateFilename (Op->Asl.Filename, FILE_SUFFIX_DISASSEMBLY);
618 CvDbgPrint ("Writing file comment, \"%s\" for %s\n",
619 NewFilename, Op->Asl.ParseOpName);
622 CgWriteOneAmlComment(Op, NewFilename, FILENAME_COMMENT);
624 if (Op->Asl.ParentFilename &&
625 AcpiUtStricmp (Op->Asl.ParentFilename, Op->Asl.Filename))
627 ParentFilename = FlGenerateFilename (Op->Asl.ParentFilename,
628 FILE_SUFFIX_DISASSEMBLY);
629 CgWriteOneAmlComment(Op, ParentFilename, PARENTFILENAME_COMMENT);
632 /* prevent multiple writes of the same comment */
634 Op->Asl.FileChanged = FALSE;
638 * Regular comments are stored in a list of comments within an Op.
639 * If there is a such list in this node, print out the comment
642 Current = Op->Asl.CommentList;
643 if (Op->Asl.ParseOpcode == PARSEOP_INCLUDE)
645 CommentOption = INCLUDE_COMMENT;
649 CommentOption = STANDARD_COMMENT;
654 CgWriteOneAmlComment(Op, Current->Comment, CommentOption);
655 Current = Current->Next;
657 Op->Asl.CommentList = NULL;
659 Current = Op->Asl.EndBlkComment;
660 CommentOption = ENDBLK_COMMENT;
663 CgWriteOneAmlComment(Op, Current->Comment, CommentOption);
664 Current = Current->Next;
666 Op->Asl.EndBlkComment = NULL;
668 /* print any Inline comments associated with this node */
670 if (Op->Asl.InlineComment)
672 CommentOption = INLINE_COMMENT;
673 CgWriteOneAmlComment(Op, Op->Asl.InlineComment, CommentOption);
674 Op->Asl.InlineComment = NULL;
677 if (Op->Asl.EndNodeComment)
679 CommentOption = ENDNODE_COMMENT;
680 CgWriteOneAmlComment(Op, Op->Asl.EndNodeComment, CommentOption);
681 Op->Asl.EndNodeComment = NULL;
684 if (Op->Asl.CloseBraceComment)
686 CommentOption = CLOSE_BRACE_COMMENT;
687 CgWriteOneAmlComment(Op, Op->Asl.CloseBraceComment, CommentOption);
688 Op->Asl.CloseBraceComment = NULL;
693 /*******************************************************************************
695 * FUNCTION: CvCommentNodeCalloc
699 * RETURN: Pointer to the comment node. Aborts on allocation failure
701 * DESCRIPTION: Allocate a string node buffer.
703 ******************************************************************************/
706 CvCommentNodeCalloc (
709 ACPI_COMMENT_NODE *NewCommentNode;
712 NewCommentNode = UtLocalCalloc (sizeof (ACPI_COMMENT_NODE));
713 NewCommentNode->Next = NULL;
714 return (NewCommentNode);
718 /*******************************************************************************
720 * FUNCTION: CvParseOpBlockType
722 * PARAMETERS: Op - Object to be examined
724 * RETURN: BlockType - not a block, parens, braces, or even both.
726 * DESCRIPTION: Type of block for this ASL parseop (parens or braces)
727 * keep this in sync with aslprimaries.y, aslresources.y and
730 ******************************************************************************/
734 ACPI_PARSE_OBJECT *Op)
741 switch (Op->Asl.ParseOpcode)
744 /* from aslprimaries.y */
746 case PARSEOP_VAR_PACKAGE:
747 case PARSEOP_BANKFIELD:
753 case PARSEOP_FUNCTION:
756 case PARSEOP_INDEXFIELD:
758 case PARSEOP_POWERRESOURCE:
759 case PARSEOP_PROCESSOR:
760 case PARSEOP_DATABUFFER:
763 case PARSEOP_THERMALZONE:
766 /* from aslresources.y */
768 case PARSEOP_RESOURCETEMPLATE: /* optional parens */
769 case PARSEOP_VENDORLONG:
770 case PARSEOP_VENDORSHORT:
771 case PARSEOP_INTERRUPT:
772 case PARSEOP_IRQNOFLAGS:
774 case PARSEOP_GPIO_INT:
775 case PARSEOP_GPIO_IO:
780 case PARSEOP_DEFINITION_BLOCK:
781 return (BLOCK_PAREN | BLOCK_BRACE);
790 /*******************************************************************************
792 * FUNCTION: CvProcessCommentState
798 * DESCRIPTION: Take the given input. If this character is
799 * defined as a comment table entry, then update the state
802 ******************************************************************************/
805 CvProcessCommentState (
811 Gbl_CommentState.SpacesBefore = 0;
818 Gbl_CommentState.CommentType = ASL_COMMENT_STANDARD;
823 /* Keep the CommentType the same */
825 Gbl_CommentState.SpacesBefore++;
830 Gbl_CommentState.CommentType = ASL_COMMENT_OPEN_PAREN;
835 Gbl_CommentState.CommentType = ASL_COMMENT_CLOSE_PAREN;
840 Gbl_CommentState.CommentType = ASL_COMMENT_STANDARD;
841 Gbl_CommentState.ParsingParenBraceNode = NULL;
842 CvDbgPrint ("End Parsing paren/Brace node!\n");
847 Gbl_CommentState.CommentType = ASL_COMMENT_CLOSE_BRACE;
852 Gbl_CommentState.CommentType = ASLCOMMENT_INLINE;
857 Gbl_CommentState.CommentType = ASLCOMMENT_INLINE;
864 /*******************************************************************************
866 * FUNCTION: CvAddToCommentList
868 * PARAMETERS: toAdd - Contains the comment to be inserted
872 * DESCRIPTION: Add the given char* to a list of comments in the global list
875 ******************************************************************************/
881 if (Gbl_Comment_List_Head)
883 Gbl_Comment_List_Tail->Next = CvCommentNodeCalloc ();
884 Gbl_Comment_List_Tail = Gbl_Comment_List_Tail->Next;
888 Gbl_Comment_List_Head = CvCommentNodeCalloc ();
889 Gbl_Comment_List_Tail = Gbl_Comment_List_Head;
892 Gbl_Comment_List_Tail->Comment = ToAdd;
897 /*******************************************************************************
899 * FUNCTION: CvAppendInlineComment
901 * PARAMETERS: InlineComment - Append to the end of this string.
902 * toAdd - Contains the comment to be inserted
904 * RETURN: Str - toAdd appended to InlineComment
906 * DESCRIPTION: Concatenate ToAdd to InlineComment
908 ******************************************************************************/
911 CvAppendInlineComment (
925 return InlineComment;
928 Size = strlen (ToAdd);
929 Size += strlen (InlineComment);
930 Str = UtStringCacheCalloc (Size+1);
931 strcpy (Str, InlineComment);
939 /*******************************************************************************
941 * FUNCTION: CvPlaceComment
943 * PARAMETERS: Int - Type
944 * char* - CommentString
948 * DESCRIPTION: Given type and CommentString, this function places the
949 * CommentString in the approperiate global comment list or char*
951 ******************************************************************************/
958 ACPI_PARSE_OBJECT *LatestParseNode;
959 ACPI_PARSE_OBJECT *ParenBraceNode;
962 LatestParseNode = Gbl_CommentState.Latest_Parse_Node;
963 ParenBraceNode = Gbl_CommentState.ParsingParenBraceNode;
964 CvDbgPrint ("Placing comment %s for type %d\n", CommentString, Type);
968 case ASL_COMMENT_STANDARD:
970 CvAddToCommentList (CommentString);
973 case ASLCOMMENT_INLINE:
975 LatestParseNode->Asl.InlineComment =
976 CvAppendInlineComment (LatestParseNode->Asl.InlineComment,
980 case ASL_COMMENT_OPEN_PAREN:
982 Gbl_Inline_Comment_Buffer =
983 CvAppendInlineComment(Gbl_Inline_Comment_Buffer,
987 case ASL_COMMENT_CLOSE_PAREN:
991 ParenBraceNode->Asl.EndNodeComment =
992 CvAppendInlineComment (ParenBraceNode->Asl.EndNodeComment,
997 LatestParseNode->Asl.EndNodeComment =
998 CvAppendInlineComment (LatestParseNode->Asl.EndNodeComment,
1003 case ASL_COMMENT_CLOSE_BRACE:
1005 LatestParseNode->Asl.CloseBraceComment = CommentString;