1 1.1 christos /****************************************************************************** 2 1.1 christos * 3 1.1 christos * Module Name: cvcompiler - ASL-/ASL+ converter functions 4 1.1 christos * 5 1.1 christos *****************************************************************************/ 6 1.1 christos 7 1.1.1.11 christos /****************************************************************************** 8 1.1.1.11 christos * 9 1.1.1.11 christos * 1. Copyright Notice 10 1.1.1.11 christos * 11 1.1.1.12 christos * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. 12 1.1 christos * All rights reserved. 13 1.1 christos * 14 1.1.1.11 christos * 2. License 15 1.1.1.11 christos * 16 1.1.1.11 christos * 2.1. This is your license from Intel Corp. under its intellectual property 17 1.1.1.11 christos * rights. You may have additional license terms from the party that provided 18 1.1.1.11 christos * you this software, covering your right to use that party's intellectual 19 1.1.1.11 christos * property rights. 20 1.1.1.11 christos * 21 1.1.1.11 christos * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 1.1.1.11 christos * copy of the source code appearing in this file ("Covered Code") an 23 1.1.1.11 christos * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 1.1.1.11 christos * base code distributed originally by Intel ("Original Intel Code") to copy, 25 1.1.1.11 christos * make derivatives, distribute, use and display any portion of the Covered 26 1.1.1.11 christos * Code in any form, with the right to sublicense such rights; and 27 1.1.1.11 christos * 28 1.1.1.11 christos * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 1.1.1.11 christos * license (with the right to sublicense), under only those claims of Intel 30 1.1.1.11 christos * patents that are infringed by the Original Intel Code, to make, use, sell, 31 1.1.1.11 christos * offer to sell, and import the Covered Code and derivative works thereof 32 1.1.1.11 christos * solely to the minimum extent necessary to exercise the above copyright 33 1.1.1.11 christos * license, and in no event shall the patent license extend to any additions 34 1.1.1.11 christos * to or modifications of the Original Intel Code. No other license or right 35 1.1.1.11 christos * is granted directly or by implication, estoppel or otherwise; 36 1.1.1.11 christos * 37 1.1.1.11 christos * The above copyright and patent license is granted only if the following 38 1.1.1.11 christos * conditions are met: 39 1.1.1.11 christos * 40 1.1.1.11 christos * 3. Conditions 41 1.1.1.11 christos * 42 1.1.1.11 christos * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 1.1.1.11 christos * Redistribution of source code of any substantial portion of the Covered 44 1.1.1.11 christos * Code or modification with rights to further distribute source must include 45 1.1.1.11 christos * the above Copyright Notice, the above License, this list of Conditions, 46 1.1.1.11 christos * and the following Disclaimer and Export Compliance provision. In addition, 47 1.1.1.11 christos * Licensee must cause all Covered Code to which Licensee contributes to 48 1.1.1.11 christos * contain a file documenting the changes Licensee made to create that Covered 49 1.1.1.11 christos * Code and the date of any change. Licensee must include in that file the 50 1.1.1.11 christos * documentation of any changes made by any predecessor Licensee. Licensee 51 1.1.1.11 christos * must include a prominent statement that the modification is derived, 52 1.1.1.11 christos * directly or indirectly, from Original Intel Code. 53 1.1.1.11 christos * 54 1.1.1.11 christos * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 1.1.1.11 christos * Redistribution of source code of any substantial portion of the Covered 56 1.1.1.11 christos * Code or modification without rights to further distribute source must 57 1.1.1.11 christos * include the following Disclaimer and Export Compliance provision in the 58 1.1.1.11 christos * documentation and/or other materials provided with distribution. In 59 1.1.1.11 christos * addition, Licensee may not authorize further sublicense of source of any 60 1.1.1.11 christos * portion of the Covered Code, and must include terms to the effect that the 61 1.1.1.11 christos * license from Licensee to its licensee is limited to the intellectual 62 1.1.1.11 christos * property embodied in the software Licensee provides to its licensee, and 63 1.1.1.11 christos * not to intellectual property embodied in modifications its licensee may 64 1.1.1.11 christos * make. 65 1.1.1.11 christos * 66 1.1.1.11 christos * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 1.1.1.11 christos * substantial portion of the Covered Code or modification must reproduce the 68 1.1.1.11 christos * above Copyright Notice, and the following Disclaimer and Export Compliance 69 1.1.1.11 christos * provision in the documentation and/or other materials provided with the 70 1.1.1.11 christos * distribution. 71 1.1.1.11 christos * 72 1.1.1.11 christos * 3.4. Intel retains all right, title, and interest in and to the Original 73 1.1.1.11 christos * Intel Code. 74 1.1.1.11 christos * 75 1.1.1.11 christos * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 1.1.1.11 christos * Intel shall be used in advertising or otherwise to promote the sale, use or 77 1.1.1.11 christos * other dealings in products derived from or relating to the Covered Code 78 1.1.1.11 christos * without prior written authorization from Intel. 79 1.1.1.11 christos * 80 1.1.1.11 christos * 4. Disclaimer and Export Compliance 81 1.1.1.11 christos * 82 1.1.1.11 christos * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 1.1.1.11 christos * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 1.1.1.11 christos * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 1.1.1.11 christos * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 1.1.1.11 christos * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 1.1.1.11 christos * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 1.1.1.11 christos * PARTICULAR PURPOSE. 89 1.1.1.11 christos * 90 1.1.1.11 christos * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 1.1.1.11 christos * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 1.1.1.11 christos * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 1.1.1.11 christos * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 1.1.1.11 christos * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 1.1.1.11 christos * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 1.1.1.11 christos * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 1.1.1.11 christos * LIMITED REMEDY. 98 1.1.1.11 christos * 99 1.1.1.11 christos * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 1.1.1.11 christos * software or system incorporating such software without first obtaining any 101 1.1.1.11 christos * required license or other approval from the U. S. Department of Commerce or 102 1.1.1.11 christos * any other agency or department of the United States Government. In the 103 1.1.1.11 christos * event Licensee exports any such software from the United States or 104 1.1.1.11 christos * re-exports any such software from a foreign destination, Licensee shall 105 1.1.1.11 christos * ensure that the distribution and export/re-export of the software is in 106 1.1.1.11 christos * compliance with all laws, regulations, orders, or other restrictions of the 107 1.1.1.11 christos * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 1.1.1.11 christos * any of its subsidiaries will export/re-export any technical data, process, 109 1.1.1.11 christos * software, or service, directly or indirectly, to any country for which the 110 1.1.1.11 christos * United States government or any agency thereof requires an export license, 111 1.1.1.11 christos * other governmental approval, or letter of assurance, without first obtaining 112 1.1.1.11 christos * such license, approval or letter. 113 1.1.1.11 christos * 114 1.1.1.11 christos ***************************************************************************** 115 1.1.1.11 christos * 116 1.1.1.11 christos * Alternatively, you may choose to be licensed under the terms of the 117 1.1.1.11 christos * following license: 118 1.1.1.11 christos * 119 1.1 christos * Redistribution and use in source and binary forms, with or without 120 1.1 christos * modification, are permitted provided that the following conditions 121 1.1 christos * are met: 122 1.1 christos * 1. Redistributions of source code must retain the above copyright 123 1.1 christos * notice, this list of conditions, and the following disclaimer, 124 1.1 christos * without modification. 125 1.1 christos * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 1.1 christos * substantially similar to the "NO WARRANTY" disclaimer below 127 1.1 christos * ("Disclaimer") and any redistribution must be conditioned upon 128 1.1 christos * including a substantially similar Disclaimer requirement for further 129 1.1 christos * binary redistribution. 130 1.1 christos * 3. Neither the names of the above-listed copyright holders nor the names 131 1.1 christos * of any contributors may be used to endorse or promote products derived 132 1.1 christos * from this software without specific prior written permission. 133 1.1 christos * 134 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 1.1 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 1.1.1.8 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 1.1 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 1.1.1.11 christos * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 1.1.1.11 christos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 1.1.1.11 christos * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 1.1.1.11 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 1.1.1.11 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 1.1.1.11 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 1.1.1.11 christos * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 1.1.1.11 christos * 146 1.1.1.11 christos * Alternatively, you may choose to be licensed under the terms of the 147 1.1.1.11 christos * GNU General Public License ("GPL") version 2 as published by the Free 148 1.1.1.11 christos * Software Foundation. 149 1.1.1.11 christos * 150 1.1.1.11 christos *****************************************************************************/ 151 1.1 christos 152 1.1 christos #include "aslcompiler.h" 153 1.1 christos #include "aslcompiler.y.h" 154 1.1 christos #include "amlcode.h" 155 1.1 christos #include "acapps.h" 156 1.1 christos #include "acconvert.h" 157 1.1 christos 158 1.1 christos 159 1.1 christos /******************************************************************************* 160 1.1 christos * 161 1.1 christos * FUNCTION: CvProcessComment 162 1.1 christos * 163 1.1 christos * PARAMETERS: CurrentState Current comment parse state 164 1.1 christos * StringBuffer Buffer containing the comment being processed 165 1.1 christos * c1 Current input 166 1.1 christos * 167 1.1.1.2 christos * RETURN: None 168 1.1 christos * 169 1.1 christos * DESCRIPTION: Process a single line comment of a c Style comment. This 170 1.1 christos * function captures a line of a c style comment in a char* and 171 1.1.1.6 christos * places the comment in the appropriate global buffer. 172 1.1 christos * 173 1.1 christos ******************************************************************************/ 174 1.1 christos 175 1.1 christos void 176 1.1 christos CvProcessComment ( 177 1.1 christos ASL_COMMENT_STATE CurrentState, 178 1.1 christos char *StringBuffer, 179 1.1 christos int c1) 180 1.1 christos { 181 1.1 christos UINT64 i; 182 1.1 christos char *LineToken; 183 1.1 christos char *FinalLineToken; 184 1.1 christos BOOLEAN CharStart; 185 1.1 christos char *CommentString; 186 1.1 christos char *FinalCommentString; 187 1.1 christos 188 1.1 christos 189 1.1.1.4 christos if (AcpiGbl_CaptureComments && CurrentState.CaptureComments) 190 1.1 christos { 191 1.1 christos *StringBuffer = (char) c1; 192 1.1 christos ++StringBuffer; 193 1.1 christos *StringBuffer = 0; 194 1.1.1.2 christos 195 1.1 christos CvDbgPrint ("Multi-line comment\n"); 196 1.1.1.5 christos CommentString = UtLocalCacheCalloc (strlen (AslGbl_MsgBuffer) + 1); 197 1.1.1.5 christos strcpy (CommentString, AslGbl_MsgBuffer); 198 1.1 christos 199 1.1 christos CvDbgPrint ("CommentString: %s\n", CommentString); 200 1.1 christos 201 1.1 christos /* 202 1.1.1.2 christos * Determine whether if this comment spans multiple lines. If so, 203 1.1.1.2 christos * break apart the comment by storing each line in a different node 204 1.1.1.2 christos * within the comment list. This allows the disassembler to 205 1.1.1.2 christos * properly indent a multi-line comment. 206 1.1 christos */ 207 1.1.1.2 christos LineToken = strtok (CommentString, "\n"); 208 1.1.1.2 christos 209 1.1.1.2 christos if (LineToken) 210 1.1 christos { 211 1.1.1.3 christos FinalLineToken = UtLocalCacheCalloc (strlen (LineToken) + 1); 212 1.1 christos strcpy (FinalLineToken, LineToken); 213 1.1 christos 214 1.1 christos /* Get rid of any carriage returns */ 215 1.1 christos 216 1.1 christos if (FinalLineToken[strlen (FinalLineToken) - 1] == 0x0D) 217 1.1 christos { 218 1.1 christos FinalLineToken[strlen(FinalLineToken)-1] = 0; 219 1.1 christos } 220 1.1.1.2 christos 221 1.1 christos CvAddToCommentList (FinalLineToken); 222 1.1 christos LineToken = strtok (NULL, "\n"); 223 1.1 christos while (LineToken != NULL) 224 1.1 christos { 225 1.1 christos /* 226 1.1 christos * It is assumed that each line has some sort of indentation. 227 1.1.1.2 christos * This means that we need to find the first character that 228 1.1.1.2 christos * is not a white space within each line. 229 1.1 christos */ 230 1.1 christos CharStart = FALSE; 231 1.1 christos for (i = 0; (i < (strlen (LineToken) + 1)) && !CharStart; i++) 232 1.1 christos { 233 1.1 christos if (LineToken[i] != ' ' && LineToken[i] != '\t') 234 1.1 christos { 235 1.1 christos CharStart = TRUE; 236 1.1 christos LineToken += i-1; 237 1.1 christos LineToken [0] = ' '; /* Pad for Formatting */ 238 1.1 christos } 239 1.1 christos } 240 1.1.1.2 christos 241 1.1.1.3 christos FinalLineToken = UtLocalCacheCalloc (strlen (LineToken) + 1); 242 1.1 christos strcat (FinalLineToken, LineToken); 243 1.1 christos 244 1.1 christos /* Get rid of any carriage returns */ 245 1.1 christos 246 1.1 christos if (FinalLineToken[strlen (FinalLineToken) - 1] == 0x0D) 247 1.1 christos { 248 1.1 christos FinalLineToken[strlen(FinalLineToken) - 1] = 0; 249 1.1 christos } 250 1.1.1.2 christos 251 1.1 christos CvAddToCommentList (FinalLineToken); 252 1.1 christos LineToken = strtok (NULL,"\n"); 253 1.1 christos } 254 1.1 christos } 255 1.1 christos 256 1.1 christos /* 257 1.1.1.2 christos * If this only spans a single line, check to see whether if this 258 1.1.1.2 christos * comment appears on the same line as a line of code. If does, 259 1.1.1.2 christos * retain it's position for stylistic reasons. If it doesn't, 260 1.1.1.2 christos * add it to the comment list so that it can be associated with 261 1.1.1.2 christos * the next node that's created. 262 1.1 christos */ 263 1.1 christos else 264 1.1 christos { 265 1.1 christos /* 266 1.1.1.2 christos * If this is not a regular comment, pad with extra spaces that 267 1.1.1.2 christos * appeared in the original source input to retain the original 268 1.1.1.2 christos * spacing. 269 1.1 christos */ 270 1.1.1.2 christos FinalCommentString = 271 1.1.1.3 christos UtLocalCacheCalloc (strlen (CommentString) + 272 1.1.1.2 christos CurrentState.SpacesBefore + 1); 273 1.1.1.2 christos 274 1.1.1.2 christos for (i = 0; (CurrentState.CommentType != ASL_COMMENT_STANDARD) && 275 1.1.1.2 christos (i < CurrentState.SpacesBefore); i++) 276 1.1 christos { 277 1.1 christos FinalCommentString[i] = ' '; 278 1.1 christos } 279 1.1.1.2 christos 280 1.1 christos strcat (FinalCommentString, CommentString); 281 1.1 christos CvPlaceComment (CurrentState.CommentType, FinalCommentString); 282 1.1 christos } 283 1.1 christos } 284 1.1 christos } 285 1.1 christos 286 1.1 christos 287 1.1 christos /******************************************************************************* 288 1.1 christos * 289 1.1 christos * FUNCTION: CvProcessCommentType2 290 1.1 christos * 291 1.1 christos * PARAMETERS: CurrentState Current comment parse state 292 1.1 christos * StringBuffer Buffer containing the comment being processed 293 1.1 christos * 294 1.1 christos * RETURN: none 295 1.1 christos * 296 1.1 christos * DESCRIPTION: Process a single line comment. This function captures a comment 297 1.1.1.6 christos * in a char* and places the comment in the appropriate global 298 1.1 christos * buffer through CvPlaceComment 299 1.1 christos * 300 1.1 christos ******************************************************************************/ 301 1.1 christos 302 1.1 christos void 303 1.1 christos CvProcessCommentType2 ( 304 1.1 christos ASL_COMMENT_STATE CurrentState, 305 1.1 christos char *StringBuffer) 306 1.1 christos { 307 1.1 christos UINT32 i; 308 1.1 christos char *CommentString; 309 1.1 christos char *FinalCommentString; 310 1.1 christos 311 1.1 christos 312 1.1.1.4 christos if (AcpiGbl_CaptureComments && CurrentState.CaptureComments) 313 1.1 christos { 314 1.1 christos *StringBuffer = 0; /* null terminate */ 315 1.1 christos CvDbgPrint ("Single-line comment\n"); 316 1.1.1.5 christos CommentString = UtLocalCacheCalloc (strlen (AslGbl_MsgBuffer) + 1); 317 1.1.1.5 christos strcpy (CommentString, AslGbl_MsgBuffer); 318 1.1 christos 319 1.1.1.2 christos /* If this comment lies on the same line as the latest parse op, 320 1.1.1.2 christos * assign it to that op's CommentAfter field. Saving in this field 321 1.1.1.2 christos * will allow us to support comments that come after code on the 322 1.1.1.2 christos * same line as the code itself. For example, 323 1.1 christos * Name(A,"") //comment 324 1.1 christos * 325 1.1 christos * will be retained rather than transformed into 326 1.1 christos * 327 1.1 christos * Name(A,"") 328 1.1 christos * //comment 329 1.1 christos * 330 1.1 christos * For this case, we only need to add one comment since 331 1.1 christos * 332 1.1 christos * Name(A,"") //comment1 //comment2 ... more comments here. 333 1.1 christos * 334 1.1 christos * would be lexically analyzed as a single comment. 335 1.1 christos * 336 1.1.1.6 christos * Create a new string with the appropriate spaces. Since we need 337 1.1 christos * to account for the proper spacing, the actual comment, 338 1.1 christos * extra 2 spaces so that this comment can be converted to the "/ *" 339 1.1.1.2 christos * style and the null terminator, the string would look something 340 1.1.1.2 christos * like: 341 1.1 christos * 342 1.1 christos * [ (spaces) (comment) ( * /) ('\0') ] 343 1.1 christos * 344 1.1 christos */ 345 1.1.1.3 christos FinalCommentString = UtLocalCacheCalloc (CurrentState.SpacesBefore + 346 1.1.1.2 christos strlen (CommentString) + 3 + 1); 347 1.1.1.2 christos 348 1.1.1.2 christos for (i = 0; (CurrentState.CommentType != 1) && 349 1.1.1.2 christos (i < CurrentState.SpacesBefore); i++) 350 1.1 christos { 351 1.1 christos FinalCommentString[i] = ' '; 352 1.1 christos } 353 1.1.1.2 christos 354 1.1 christos strcat (FinalCommentString, CommentString); 355 1.1 christos 356 1.1 christos /* convert to a "/ *" style comment */ 357 1.1 christos 358 1.1 christos strcat (FinalCommentString, " */"); 359 1.1.1.2 christos FinalCommentString [CurrentState.SpacesBefore + 360 1.1.1.2 christos strlen (CommentString) + 3] = 0; 361 1.1 christos 362 1.1 christos /* get rid of the carriage return */ 363 1.1 christos 364 1.1 christos if (FinalCommentString[strlen (FinalCommentString) - 1] == 0x0D) 365 1.1 christos { 366 1.1.1.2 christos FinalCommentString[strlen(FinalCommentString) - 1] = 0; 367 1.1 christos } 368 1.1.1.2 christos 369 1.1 christos CvPlaceComment (CurrentState.CommentType, FinalCommentString); 370 1.1 christos } 371 1.1 christos } 372 1.1 christos 373 1.1 christos 374 1.1 christos /******************************************************************************* 375 1.1 christos * 376 1.1 christos * FUNCTION: CgCalculateCommentLengths 377 1.1 christos * 378 1.1 christos * PARAMETERS: Op - Calculate all comments of this Op 379 1.1 christos * 380 1.1.1.2 christos * RETURN: TotalCommentLength - Length of all comments within this op. 381 1.1 christos * 382 1.1.1.2 christos * DESCRIPTION: Calculate the length that the each comment takes up within Op. 383 1.1.1.6 christos * Comments look like the following: [0xA9 OptionBtye comment 0x00] 384 1.1 christos * therefore, we add 1 + 1 + strlen (comment) + 1 to get the actual 385 1.1 christos * length of this comment. 386 1.1 christos * 387 1.1 christos ******************************************************************************/ 388 1.1 christos 389 1.1 christos UINT32 390 1.1 christos CvCalculateCommentLengths( 391 1.1 christos ACPI_PARSE_OBJECT *Op) 392 1.1 christos { 393 1.1 christos UINT32 CommentLength = 0; 394 1.1 christos UINT32 TotalCommentLength = 0; 395 1.1 christos ACPI_COMMENT_NODE *Current = NULL; 396 1.1 christos 397 1.1 christos 398 1.1.1.4 christos if (!AcpiGbl_CaptureComments) 399 1.1 christos { 400 1.1 christos return (0); 401 1.1 christos } 402 1.1 christos 403 1.1.1.2 christos CvDbgPrint ("==Calculating comment lengths for %s\n", 404 1.1.1.2 christos Op->Asl.ParseOpName); 405 1.1.1.2 christos 406 1.1 christos if (Op->Asl.FileChanged) 407 1.1 christos { 408 1.1 christos TotalCommentLength += strlen (Op->Asl.Filename) + 3; 409 1.1 christos 410 1.1 christos if (Op->Asl.ParentFilename && 411 1.1 christos AcpiUtStricmp (Op->Asl.Filename, Op->Asl.ParentFilename)) 412 1.1 christos { 413 1.1 christos TotalCommentLength += strlen (Op->Asl.ParentFilename) + 3; 414 1.1 christos } 415 1.1 christos } 416 1.1.1.2 christos 417 1.1 christos if (Op->Asl.CommentList) 418 1.1 christos { 419 1.1 christos Current = Op->Asl.CommentList; 420 1.1 christos while (Current) 421 1.1 christos { 422 1.1 christos CommentLength = strlen (Current->Comment)+3; 423 1.1 christos CvDbgPrint ("Length of standard comment: %d\n", CommentLength); 424 1.1 christos CvDbgPrint (" Comment string: %s\n\n", Current->Comment); 425 1.1 christos TotalCommentLength += CommentLength; 426 1.1 christos Current = Current->Next; 427 1.1 christos } 428 1.1 christos } 429 1.1.1.2 christos 430 1.1 christos if (Op->Asl.EndBlkComment) 431 1.1 christos { 432 1.1 christos Current = Op->Asl.EndBlkComment; 433 1.1 christos while (Current) 434 1.1 christos { 435 1.1 christos CommentLength = strlen (Current->Comment)+3; 436 1.1 christos CvDbgPrint ("Length of endblkcomment: %d\n", CommentLength); 437 1.1 christos CvDbgPrint (" Comment string: %s\n\n", Current->Comment); 438 1.1 christos TotalCommentLength += CommentLength; 439 1.1 christos Current = Current->Next; 440 1.1 christos } 441 1.1 christos } 442 1.1.1.2 christos 443 1.1 christos if (Op->Asl.InlineComment) 444 1.1 christos { 445 1.1 christos CommentLength = strlen (Op->Asl.InlineComment)+3; 446 1.1 christos CvDbgPrint ("Length of inline comment: %d\n", CommentLength); 447 1.1 christos CvDbgPrint (" Comment string: %s\n\n", Op->Asl.InlineComment); 448 1.1 christos TotalCommentLength += CommentLength; 449 1.1 christos } 450 1.1.1.2 christos 451 1.1 christos if (Op->Asl.EndNodeComment) 452 1.1 christos { 453 1.1 christos CommentLength = strlen(Op->Asl.EndNodeComment)+3; 454 1.1 christos CvDbgPrint ("Length of end node comment +3: %d\n", CommentLength); 455 1.1 christos CvDbgPrint (" Comment string: %s\n\n", Op->Asl.EndNodeComment); 456 1.1 christos TotalCommentLength += CommentLength; 457 1.1 christos } 458 1.1 christos 459 1.1 christos if (Op->Asl.CloseBraceComment) 460 1.1 christos { 461 1.1 christos CommentLength = strlen (Op->Asl.CloseBraceComment)+3; 462 1.1 christos CvDbgPrint ("Length of close brace comment: %d\n", CommentLength); 463 1.1 christos CvDbgPrint (" Comment string: %s\n\n", Op->Asl.CloseBraceComment); 464 1.1 christos TotalCommentLength += CommentLength; 465 1.1 christos } 466 1.1 christos 467 1.1 christos CvDbgPrint("\n\n"); 468 1.1.1.2 christos return (TotalCommentLength); 469 1.1 christos } 470 1.1 christos 471 1.1 christos 472 1.1 christos /******************************************************************************* 473 1.1 christos * 474 1.1 christos * FUNCTION: CgWriteAmlDefBlockComment 475 1.1 christos * 476 1.1 christos * PARAMETERS: Op - Current parse op 477 1.1 christos * 478 1.1 christos * RETURN: None 479 1.1 christos * 480 1.1 christos * DESCRIPTION: Write all comments for a particular definition block. 481 1.1 christos * For definition blocks, the comments need to come after the 482 1.1 christos * definition block header. The regular comments above the 483 1.1 christos * definition block would be categorized as 484 1.1 christos * STD_DEFBLK_COMMENT and comments after the closing brace 485 1.1 christos * is categorized as END_DEFBLK_COMMENT. 486 1.1 christos * 487 1.1 christos ******************************************************************************/ 488 1.1 christos 489 1.1 christos void 490 1.1 christos CgWriteAmlDefBlockComment( 491 1.1 christos ACPI_PARSE_OBJECT *Op) 492 1.1 christos { 493 1.1 christos UINT8 CommentOption; 494 1.1 christos ACPI_COMMENT_NODE *Current; 495 1.1 christos char *NewFilename; 496 1.1 christos char *Position; 497 1.1 christos char *DirectoryPosition; 498 1.1 christos 499 1.1 christos 500 1.1.1.4 christos if (!AcpiGbl_CaptureComments || 501 1.1 christos (Op->Asl.ParseOpcode != PARSEOP_DEFINITION_BLOCK)) 502 1.1 christos { 503 1.1 christos return; 504 1.1 christos } 505 1.1 christos 506 1.1 christos CvDbgPrint ("Printing comments for a definition block..\n"); 507 1.1 christos 508 1.1.1.2 christos /* First, print the file name comment after changing .asl to .dsl */ 509 1.1 christos 510 1.1.1.3 christos NewFilename = UtLocalCacheCalloc (strlen (Op->Asl.Filename)); 511 1.1 christos strcpy (NewFilename, Op->Asl.Filename); 512 1.1 christos DirectoryPosition = strrchr (NewFilename, '/'); 513 1.1 christos Position = strrchr (NewFilename, '.'); 514 1.1 christos 515 1.1 christos if (Position && (Position > DirectoryPosition)) 516 1.1 christos { 517 1.1 christos /* Tack on the new suffix */ 518 1.1 christos 519 1.1 christos Position++; 520 1.1 christos *Position = 0; 521 1.1 christos strcat (Position, FILE_SUFFIX_DISASSEMBLY); 522 1.1 christos } 523 1.1 christos else 524 1.1 christos { 525 1.1 christos /* No dot, add one and then the suffix */ 526 1.1 christos 527 1.1 christos strcat (NewFilename, "."); 528 1.1 christos strcat (NewFilename, FILE_SUFFIX_DISASSEMBLY); 529 1.1 christos } 530 1.1 christos 531 1.1 christos CommentOption = FILENAME_COMMENT; 532 1.1 christos CgWriteOneAmlComment(Op, NewFilename, CommentOption); 533 1.1 christos 534 1.1 christos Current = Op->Asl.CommentList; 535 1.1 christos CommentOption = STD_DEFBLK_COMMENT; 536 1.1.1.2 christos 537 1.1 christos while (Current) 538 1.1 christos { 539 1.1 christos CgWriteOneAmlComment(Op, Current->Comment, CommentOption); 540 1.1 christos CvDbgPrint ("Printing comment: %s\n", Current->Comment); 541 1.1 christos Current = Current->Next; 542 1.1 christos } 543 1.1.1.2 christos 544 1.1 christos Op->Asl.CommentList = NULL; 545 1.1 christos 546 1.1.1.2 christos /* Print any Inline comments associated with this node */ 547 1.1 christos 548 1.1 christos if (Op->Asl.CloseBraceComment) 549 1.1 christos { 550 1.1 christos CommentOption = END_DEFBLK_COMMENT; 551 1.1 christos CgWriteOneAmlComment(Op, Op->Asl.CloseBraceComment, CommentOption); 552 1.1 christos Op->Asl.CloseBraceComment = NULL; 553 1.1 christos } 554 1.1 christos } 555 1.1 christos 556 1.1 christos 557 1.1 christos /******************************************************************************* 558 1.1 christos * 559 1.1 christos * FUNCTION: CgWriteOneAmlComment 560 1.1 christos * 561 1.1 christos * PARAMETERS: Op - Current parse op 562 1.1 christos * CommentToPrint - Comment that's printed 563 1.1 christos * InputOption - Denotes the comment option. 564 1.1 christos * 565 1.1 christos * RETURN: None 566 1.1 christos * 567 1.1 christos * DESCRIPTION: write a single comment. 568 1.1 christos * 569 1.1 christos ******************************************************************************/ 570 1.1 christos 571 1.1 christos void 572 1.1 christos CgWriteOneAmlComment( 573 1.1 christos ACPI_PARSE_OBJECT *Op, 574 1.1 christos char* CommentToPrint, 575 1.1 christos UINT8 InputOption) 576 1.1 christos { 577 1.1.1.2 christos UINT8 CommentOption = InputOption; 578 1.1.1.2 christos UINT8 CommentOpcode = (UINT8) AML_COMMENT_OP; 579 1.1.1.2 christos 580 1.1.1.2 christos 581 1.1.1.2 christos if (!CommentToPrint) 582 1.1.1.2 christos { 583 1.1.1.2 christos return; 584 1.1.1.2 christos } 585 1.1 christos 586 1.1 christos CgLocalWriteAmlData (Op, &CommentOpcode, 1); 587 1.1 christos CgLocalWriteAmlData (Op, &CommentOption, 1); 588 1.1 christos 589 1.1 christos /* The strlen (..) + 1 is to include the null terminator */ 590 1.1 christos 591 1.1 christos CgLocalWriteAmlData (Op, CommentToPrint, strlen (CommentToPrint) + 1); 592 1.1 christos } 593 1.1 christos 594 1.1 christos 595 1.1 christos /******************************************************************************* 596 1.1 christos * 597 1.1 christos * FUNCTION: CgWriteAmlComment 598 1.1 christos * 599 1.1 christos * PARAMETERS: Op - Current parse op 600 1.1 christos * 601 1.1 christos * RETURN: None 602 1.1 christos * 603 1.1.1.2 christos * DESCRIPTION: Write all comments pertaining to the current parse op 604 1.1 christos * 605 1.1 christos ******************************************************************************/ 606 1.1 christos 607 1.1 christos void 608 1.1 christos CgWriteAmlComment( 609 1.1 christos ACPI_PARSE_OBJECT *Op) 610 1.1 christos { 611 1.1 christos ACPI_COMMENT_NODE *Current; 612 1.1 christos UINT8 CommentOption; 613 1.1 christos char *NewFilename; 614 1.1 christos char *ParentFilename; 615 1.1 christos 616 1.1 christos 617 1.1 christos if ((Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK) || 618 1.1.1.4 christos !AcpiGbl_CaptureComments) 619 1.1 christos { 620 1.1 christos return; 621 1.1 christos } 622 1.1 christos 623 1.1 christos /* Print out the filename comment if needed */ 624 1.1 christos 625 1.1 christos if (Op->Asl.FileChanged) 626 1.1 christos { 627 1.1 christos 628 1.1.1.2 christos /* First, print the file name comment after changing .asl to .dsl */ 629 1.1 christos 630 1.1 christos NewFilename = 631 1.1 christos FlGenerateFilename (Op->Asl.Filename, FILE_SUFFIX_DISASSEMBLY); 632 1.1.1.2 christos if (NewFilename) 633 1.1.1.2 christos { 634 1.1.1.2 christos CvDbgPrint ("Writing file comment, \"%s\" for %s\n", 635 1.1.1.2 christos NewFilename, Op->Asl.ParseOpName); 636 1.1.1.2 christos } 637 1.1.1.2 christos 638 1.1 christos CgWriteOneAmlComment(Op, NewFilename, FILENAME_COMMENT); 639 1.1 christos 640 1.1 christos if (Op->Asl.ParentFilename && 641 1.1 christos AcpiUtStricmp (Op->Asl.ParentFilename, Op->Asl.Filename)) 642 1.1 christos { 643 1.1 christos ParentFilename = FlGenerateFilename (Op->Asl.ParentFilename, 644 1.1 christos FILE_SUFFIX_DISASSEMBLY); 645 1.1 christos CgWriteOneAmlComment(Op, ParentFilename, PARENTFILENAME_COMMENT); 646 1.1 christos } 647 1.1 christos 648 1.1.1.2 christos /* Prevent multiple writes of the same comment */ 649 1.1 christos 650 1.1 christos Op->Asl.FileChanged = FALSE; 651 1.1 christos } 652 1.1 christos 653 1.1 christos /* 654 1.1 christos * Regular comments are stored in a list of comments within an Op. 655 1.1 christos * If there is a such list in this node, print out the comment 656 1.1 christos * as byte code. 657 1.1 christos */ 658 1.1 christos Current = Op->Asl.CommentList; 659 1.1 christos if (Op->Asl.ParseOpcode == PARSEOP_INCLUDE) 660 1.1 christos { 661 1.1 christos CommentOption = INCLUDE_COMMENT; 662 1.1 christos } 663 1.1 christos else 664 1.1 christos { 665 1.1 christos CommentOption = STANDARD_COMMENT; 666 1.1 christos } 667 1.1 christos 668 1.1 christos while (Current) 669 1.1 christos { 670 1.1 christos CgWriteOneAmlComment(Op, Current->Comment, CommentOption); 671 1.1 christos Current = Current->Next; 672 1.1 christos } 673 1.1.1.2 christos 674 1.1 christos Op->Asl.CommentList = NULL; 675 1.1 christos 676 1.1 christos Current = Op->Asl.EndBlkComment; 677 1.1 christos CommentOption = ENDBLK_COMMENT; 678 1.1 christos while (Current) 679 1.1 christos { 680 1.1 christos CgWriteOneAmlComment(Op, Current->Comment, CommentOption); 681 1.1 christos Current = Current->Next; 682 1.1 christos } 683 1.1.1.2 christos 684 1.1 christos Op->Asl.EndBlkComment = NULL; 685 1.1 christos 686 1.1.1.2 christos /* Print any Inline comments associated with this node */ 687 1.1 christos 688 1.1 christos if (Op->Asl.InlineComment) 689 1.1 christos { 690 1.1 christos CommentOption = INLINE_COMMENT; 691 1.1 christos CgWriteOneAmlComment(Op, Op->Asl.InlineComment, CommentOption); 692 1.1 christos Op->Asl.InlineComment = NULL; 693 1.1 christos } 694 1.1 christos 695 1.1 christos if (Op->Asl.EndNodeComment) 696 1.1 christos { 697 1.1 christos CommentOption = ENDNODE_COMMENT; 698 1.1 christos CgWriteOneAmlComment(Op, Op->Asl.EndNodeComment, CommentOption); 699 1.1 christos Op->Asl.EndNodeComment = NULL; 700 1.1 christos } 701 1.1 christos 702 1.1 christos if (Op->Asl.CloseBraceComment) 703 1.1 christos { 704 1.1 christos CommentOption = CLOSE_BRACE_COMMENT; 705 1.1 christos CgWriteOneAmlComment(Op, Op->Asl.CloseBraceComment, CommentOption); 706 1.1 christos Op->Asl.CloseBraceComment = NULL; 707 1.1 christos } 708 1.1 christos } 709 1.1 christos 710 1.1 christos 711 1.1 christos /******************************************************************************* 712 1.1 christos * 713 1.1 christos * FUNCTION: CvCommentNodeCalloc 714 1.1 christos * 715 1.1.1.2 christos * PARAMETERS: None 716 1.1 christos * 717 1.1 christos * RETURN: Pointer to the comment node. Aborts on allocation failure 718 1.1 christos * 719 1.1 christos * DESCRIPTION: Allocate a string node buffer. 720 1.1 christos * 721 1.1 christos ******************************************************************************/ 722 1.1 christos 723 1.1.1.2 christos ACPI_COMMENT_NODE * 724 1.1 christos CvCommentNodeCalloc ( 725 1.1 christos void) 726 1.1 christos { 727 1.1 christos ACPI_COMMENT_NODE *NewCommentNode; 728 1.1 christos 729 1.1 christos 730 1.1.1.2 christos NewCommentNode = UtLocalCalloc (sizeof (ACPI_COMMENT_NODE)); 731 1.1 christos NewCommentNode->Next = NULL; 732 1.1.1.2 christos return (NewCommentNode); 733 1.1 christos } 734 1.1 christos 735 1.1 christos 736 1.1 christos /******************************************************************************* 737 1.1 christos * 738 1.1 christos * FUNCTION: CvParseOpBlockType 739 1.1 christos * 740 1.1 christos * PARAMETERS: Op - Object to be examined 741 1.1 christos * 742 1.1 christos * RETURN: BlockType - not a block, parens, braces, or even both. 743 1.1 christos * 744 1.1 christos * DESCRIPTION: Type of block for this ASL parseop (parens or braces) 745 1.1 christos * keep this in sync with aslprimaries.y, aslresources.y and 746 1.1 christos * aslrules.y 747 1.1 christos * 748 1.1 christos ******************************************************************************/ 749 1.1 christos 750 1.1 christos UINT32 751 1.1 christos CvParseOpBlockType ( 752 1.1 christos ACPI_PARSE_OBJECT *Op) 753 1.1 christos { 754 1.1.1.2 christos 755 1.1 christos if (!Op) 756 1.1 christos { 757 1.1 christos return (BLOCK_NONE); 758 1.1 christos } 759 1.1 christos 760 1.1 christos switch (Op->Asl.ParseOpcode) 761 1.1 christos { 762 1.1.1.2 christos /* From aslprimaries.y */ 763 1.1 christos 764 1.1 christos case PARSEOP_VAR_PACKAGE: 765 1.1 christos case PARSEOP_BANKFIELD: 766 1.1 christos case PARSEOP_BUFFER: 767 1.1 christos case PARSEOP_CASE: 768 1.1 christos case PARSEOP_DEVICE: 769 1.1 christos case PARSEOP_FIELD: 770 1.1 christos case PARSEOP_FOR: 771 1.1 christos case PARSEOP_FUNCTION: 772 1.1 christos case PARSEOP_IF: 773 1.1 christos case PARSEOP_ELSEIF: 774 1.1 christos case PARSEOP_INDEXFIELD: 775 1.1 christos case PARSEOP_METHOD: 776 1.1 christos case PARSEOP_POWERRESOURCE: 777 1.1 christos case PARSEOP_PROCESSOR: 778 1.1 christos case PARSEOP_DATABUFFER: 779 1.1 christos case PARSEOP_SCOPE: 780 1.1 christos case PARSEOP_SWITCH: 781 1.1 christos case PARSEOP_THERMALZONE: 782 1.1 christos case PARSEOP_WHILE: 783 1.1 christos 784 1.1.1.2 christos /* From aslresources.y */ 785 1.1 christos 786 1.1 christos case PARSEOP_RESOURCETEMPLATE: /* optional parens */ 787 1.1 christos case PARSEOP_VENDORLONG: 788 1.1 christos case PARSEOP_VENDORSHORT: 789 1.1 christos case PARSEOP_INTERRUPT: 790 1.1 christos case PARSEOP_IRQNOFLAGS: 791 1.1 christos case PARSEOP_IRQ: 792 1.1 christos case PARSEOP_GPIO_INT: 793 1.1 christos case PARSEOP_GPIO_IO: 794 1.1 christos case PARSEOP_DMA: 795 1.1 christos 796 1.1.1.2 christos /* From aslrules.y */ 797 1.1 christos 798 1.1 christos case PARSEOP_DEFINITION_BLOCK: 799 1.1 christos return (BLOCK_PAREN | BLOCK_BRACE); 800 1.1 christos 801 1.1 christos default: 802 1.1 christos return (BLOCK_NONE); 803 1.1 christos } 804 1.1 christos } 805 1.1 christos 806 1.1 christos 807 1.1 christos /******************************************************************************* 808 1.1 christos * 809 1.1 christos * FUNCTION: CvProcessCommentState 810 1.1 christos * 811 1.1.1.2 christos * PARAMETERS: Input - Input character 812 1.1 christos * 813 1.1 christos * RETURN: None 814 1.1 christos * 815 1.1 christos * DESCRIPTION: Take the given input. If this character is 816 1.1 christos * defined as a comment table entry, then update the state 817 1.1 christos * accordingly. 818 1.1 christos * 819 1.1 christos ******************************************************************************/ 820 1.1 christos 821 1.1 christos void 822 1.1 christos CvProcessCommentState ( 823 1.1.1.2 christos char Input) 824 1.1 christos { 825 1.1 christos 826 1.1.1.2 christos if (Input != ' ') 827 1.1 christos { 828 1.1.1.5 christos AslGbl_CommentState.SpacesBefore = 0; 829 1.1 christos } 830 1.1 christos 831 1.1.1.2 christos switch (Input) 832 1.1 christos { 833 1.1 christos case '\n': 834 1.1 christos 835 1.1.1.5 christos AslGbl_CommentState.CommentType = ASL_COMMENT_STANDARD; 836 1.1 christos break; 837 1.1 christos 838 1.1 christos case ' ': 839 1.1 christos 840 1.1 christos /* Keep the CommentType the same */ 841 1.1 christos 842 1.1.1.5 christos AslGbl_CommentState.SpacesBefore++; 843 1.1 christos break; 844 1.1 christos 845 1.1 christos case '(': 846 1.1 christos 847 1.1.1.5 christos AslGbl_CommentState.CommentType = ASL_COMMENT_OPEN_PAREN; 848 1.1 christos break; 849 1.1 christos 850 1.1 christos case ')': 851 1.1 christos 852 1.1.1.5 christos AslGbl_CommentState.CommentType = ASL_COMMENT_CLOSE_PAREN; 853 1.1 christos break; 854 1.1 christos 855 1.1 christos case '{': 856 1.1 christos 857 1.1.1.5 christos AslGbl_CommentState.CommentType = ASL_COMMENT_STANDARD; 858 1.1.1.5 christos AslGbl_CommentState.ParsingParenBraceNode = NULL; 859 1.1 christos CvDbgPrint ("End Parsing paren/Brace node!\n"); 860 1.1 christos break; 861 1.1 christos 862 1.1 christos case '}': 863 1.1 christos 864 1.1.1.5 christos AslGbl_CommentState.CommentType = ASL_COMMENT_CLOSE_BRACE; 865 1.1 christos break; 866 1.1 christos 867 1.1 christos case ',': 868 1.1 christos 869 1.1.1.5 christos AslGbl_CommentState.CommentType = ASLCOMMENT_INLINE; 870 1.1 christos break; 871 1.1 christos 872 1.1 christos default: 873 1.1 christos 874 1.1.1.5 christos AslGbl_CommentState.CommentType = ASLCOMMENT_INLINE; 875 1.1 christos break; 876 1.1 christos } 877 1.1 christos } 878 1.1 christos 879 1.1 christos 880 1.1 christos /******************************************************************************* 881 1.1 christos * 882 1.1 christos * FUNCTION: CvAddToCommentList 883 1.1 christos * 884 1.1.1.2 christos * PARAMETERS: ToAdd - Contains the comment to be inserted 885 1.1 christos * 886 1.1 christos * RETURN: None 887 1.1 christos * 888 1.1 christos * DESCRIPTION: Add the given char* to a list of comments in the global list 889 1.1 christos * of comments. 890 1.1 christos * 891 1.1 christos ******************************************************************************/ 892 1.1 christos 893 1.1 christos void 894 1.1 christos CvAddToCommentList ( 895 1.1.1.2 christos char *ToAdd) 896 1.1 christos { 897 1.1.1.2 christos 898 1.1.1.5 christos if (AslGbl_CommentListHead) 899 1.1 christos { 900 1.1.1.5 christos AslGbl_CommentListTail->Next = CvCommentNodeCalloc (); 901 1.1.1.5 christos AslGbl_CommentListTail = AslGbl_CommentListTail->Next; 902 1.1 christos } 903 1.1 christos else 904 1.1 christos { 905 1.1.1.5 christos AslGbl_CommentListHead = CvCommentNodeCalloc (); 906 1.1.1.5 christos AslGbl_CommentListTail = AslGbl_CommentListHead; 907 1.1 christos } 908 1.1 christos 909 1.1.1.5 christos AslGbl_CommentListTail->Comment = ToAdd; 910 1.1 christos } 911 1.1 christos 912 1.1.1.2 christos 913 1.1 christos /******************************************************************************* 914 1.1 christos * 915 1.1 christos * FUNCTION: CvAppendInlineComment 916 1.1 christos * 917 1.1 christos * PARAMETERS: InlineComment - Append to the end of this string. 918 1.1 christos * toAdd - Contains the comment to be inserted 919 1.1 christos * 920 1.1 christos * RETURN: Str - toAdd appended to InlineComment 921 1.1 christos * 922 1.1 christos * DESCRIPTION: Concatenate ToAdd to InlineComment 923 1.1 christos * 924 1.1 christos ******************************************************************************/ 925 1.1 christos 926 1.1.1.2 christos char * 927 1.1 christos CvAppendInlineComment ( 928 1.1 christos char *InlineComment, 929 1.1 christos char *ToAdd) 930 1.1 christos { 931 1.1 christos char* Str; 932 1.1 christos UINT32 Size = 0; 933 1.1 christos 934 1.1 christos 935 1.1 christos if (!InlineComment) 936 1.1 christos { 937 1.1.1.2 christos return (ToAdd); 938 1.1 christos } 939 1.1.1.2 christos 940 1.1.1.2 christos if (!ToAdd) 941 1.1 christos { 942 1.1.1.2 christos return (InlineComment); 943 1.1 christos } 944 1.1.1.2 christos 945 1.1.1.2 christos Size = strlen (ToAdd); 946 1.1 christos Size += strlen (InlineComment); 947 1.1.1.3 christos Str = UtLocalCacheCalloc (Size + 1); 948 1.1.1.2 christos 949 1.1 christos strcpy (Str, InlineComment); 950 1.1 christos strcat (Str, ToAdd); 951 1.1.1.2 christos Str[Size +1] = 0; 952 1.1.1.2 christos return (Str); 953 1.1 christos } 954 1.1 christos 955 1.1 christos 956 1.1 christos /******************************************************************************* 957 1.1 christos * 958 1.1 christos * FUNCTION: CvPlaceComment 959 1.1 christos * 960 1.1.1.2 christos * PARAMETERS: UINT8 - Type 961 1.1.1.2 christos * char * - CommentString 962 1.1 christos * 963 1.1 christos * RETURN: None 964 1.1 christos * 965 1.1 christos * DESCRIPTION: Given type and CommentString, this function places the 966 1.1.1.6 christos * CommentString in the appropriate global comment list or char* 967 1.1 christos * 968 1.1 christos ******************************************************************************/ 969 1.1 christos 970 1.1 christos void 971 1.1 christos CvPlaceComment( 972 1.1 christos UINT8 Type, 973 1.1 christos char *CommentString) 974 1.1 christos { 975 1.1 christos ACPI_PARSE_OBJECT *LatestParseNode; 976 1.1 christos ACPI_PARSE_OBJECT *ParenBraceNode; 977 1.1 christos 978 1.1 christos 979 1.1.1.5 christos LatestParseNode = AslGbl_CommentState.LatestParseOp; 980 1.1.1.5 christos ParenBraceNode = AslGbl_CommentState.ParsingParenBraceNode; 981 1.1 christos CvDbgPrint ("Placing comment %s for type %d\n", CommentString, Type); 982 1.1 christos 983 1.1 christos switch (Type) 984 1.1 christos { 985 1.1 christos case ASL_COMMENT_STANDARD: 986 1.1 christos 987 1.1 christos CvAddToCommentList (CommentString); 988 1.1 christos break; 989 1.1 christos 990 1.1 christos case ASLCOMMENT_INLINE: 991 1.1 christos 992 1.1 christos LatestParseNode->Asl.InlineComment = 993 1.1 christos CvAppendInlineComment (LatestParseNode->Asl.InlineComment, 994 1.1 christos CommentString); 995 1.1 christos break; 996 1.1 christos 997 1.1 christos case ASL_COMMENT_OPEN_PAREN: 998 1.1 christos 999 1.1.1.5 christos AslGbl_InlineCommentBuffer = 1000 1.1.1.5 christos CvAppendInlineComment(AslGbl_InlineCommentBuffer, 1001 1.1 christos CommentString); 1002 1.1 christos break; 1003 1.1 christos 1004 1.1 christos case ASL_COMMENT_CLOSE_PAREN: 1005 1.1 christos 1006 1.1 christos if (ParenBraceNode) 1007 1.1 christos { 1008 1.1 christos ParenBraceNode->Asl.EndNodeComment = 1009 1.1 christos CvAppendInlineComment (ParenBraceNode->Asl.EndNodeComment, 1010 1.1 christos CommentString); 1011 1.1 christos } 1012 1.1 christos else 1013 1.1 christos { 1014 1.1 christos LatestParseNode->Asl.EndNodeComment = 1015 1.1 christos CvAppendInlineComment (LatestParseNode->Asl.EndNodeComment, 1016 1.1 christos CommentString); 1017 1.1 christos } 1018 1.1 christos break; 1019 1.1 christos 1020 1.1 christos case ASL_COMMENT_CLOSE_BRACE: 1021 1.1 christos 1022 1.1 christos LatestParseNode->Asl.CloseBraceComment = CommentString; 1023 1.1 christos break; 1024 1.1 christos 1025 1.1 christos default: 1026 1.1 christos 1027 1.1 christos break; 1028 1.1 christos } 1029 1.1 christos } 1030