cvcompiler.c (4224465e820a1a7232255d980e692720169776af) | cvcompiler.c (5f9b24fa4327c851ddb733b73904401afe3f0123) |
---|---|
1/****************************************************************************** 2 * 3 * Module Name: cvcompiler - ASL-/ASL+ converter functions 4 * 5 *****************************************************************************/ 6 7/****************************************************************************** 8 * --- 150 unchanged lines hidden (view full) --- 159/******************************************************************************* 160 * 161 * FUNCTION: CvProcessComment 162 * 163 * PARAMETERS: CurrentState Current comment parse state 164 * StringBuffer Buffer containing the comment being processed 165 * c1 Current input 166 * | 1/****************************************************************************** 2 * 3 * Module Name: cvcompiler - ASL-/ASL+ converter functions 4 * 5 *****************************************************************************/ 6 7/****************************************************************************** 8 * --- 150 unchanged lines hidden (view full) --- 159/******************************************************************************* 160 * 161 * FUNCTION: CvProcessComment 162 * 163 * PARAMETERS: CurrentState Current comment parse state 164 * StringBuffer Buffer containing the comment being processed 165 * c1 Current input 166 * |
167 * RETURN: none | 167 * RETURN: None |
168 * 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. 172 * 173 ******************************************************************************/ 174 175void --- 36 unchanged lines hidden (view full) --- 212 strcpy (FinalLineToken, LineToken); 213 214 /* Get rid of any carriage returns */ 215 216 if (FinalLineToken[strlen (FinalLineToken) - 1] == 0x0D) 217 { 218 FinalLineToken[strlen(FinalLineToken)-1] = 0; 219 } | 168 * 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. 172 * 173 ******************************************************************************/ 174 175void --- 36 unchanged lines hidden (view full) --- 212 strcpy (FinalLineToken, LineToken); 213 214 /* Get rid of any carriage returns */ 215 216 if (FinalLineToken[strlen (FinalLineToken) - 1] == 0x0D) 217 { 218 FinalLineToken[strlen(FinalLineToken)-1] = 0; 219 } |
220 |
|
220 CvAddToCommentList (FinalLineToken); 221 LineToken = strtok (NULL, "\n"); 222 while (LineToken != NULL) 223 { 224 /* 225 * It is assumed that each line has some sort of indentation. | 221 CvAddToCommentList (FinalLineToken); 222 LineToken = strtok (NULL, "\n"); 223 while (LineToken != NULL) 224 { 225 /* 226 * 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. | 227 * This means that we need to find the first character that 228 * is not a white space within each line. |
228 */ 229 CharStart = FALSE; 230 for (i = 0; (i < (strlen (LineToken) + 1)) && !CharStart; i++) 231 { 232 if (LineToken[i] != ' ' && LineToken[i] != '\t') 233 { 234 CharStart = TRUE; 235 LineToken += i-1; 236 LineToken [0] = ' '; /* Pad for Formatting */ 237 } 238 } | 229 */ 230 CharStart = FALSE; 231 for (i = 0; (i < (strlen (LineToken) + 1)) && !CharStart; i++) 232 { 233 if (LineToken[i] != ' ' && LineToken[i] != '\t') 234 { 235 CharStart = TRUE; 236 LineToken += i-1; 237 LineToken [0] = ' '; /* Pad for Formatting */ 238 } 239 } |
240 |
|
239 FinalLineToken = UtStringCacheCalloc (strlen (LineToken) + 1); 240 strcat (FinalLineToken, LineToken); 241 242 /* Get rid of any carriage returns */ 243 244 if (FinalLineToken[strlen (FinalLineToken) - 1] == 0x0D) 245 { 246 FinalLineToken[strlen(FinalLineToken) - 1] = 0; 247 } | 241 FinalLineToken = UtStringCacheCalloc (strlen (LineToken) + 1); 242 strcat (FinalLineToken, LineToken); 243 244 /* Get rid of any carriage returns */ 245 246 if (FinalLineToken[strlen (FinalLineToken) - 1] == 0x0D) 247 { 248 FinalLineToken[strlen(FinalLineToken) - 1] = 0; 249 } |
250 |
|
248 CvAddToCommentList (FinalLineToken); 249 LineToken = strtok (NULL,"\n"); 250 } 251 } 252 253 /* | 251 CvAddToCommentList (FinalLineToken); 252 LineToken = strtok (NULL,"\n"); 253 } 254 } 255 256 /* |
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. | 257 * If this only spans a single line, check to see whether if this 258 * comment appears on the same line as a line of code. If does, 259 * retain it's position for stylistic reasons. If it doesn't, 260 * add it to the comment list so that it can be associated with 261 * the next node that's created. |
258 */ 259 else 260 { 261 /* | 262 */ 263 else 264 { 265 /* |
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 * If this is not a regular comment, pad with extra spaces that 267 * appeared in the original source input to retain the original 268 * spacing. |
264 */ 265 FinalCommentString = 266 UtStringCacheCalloc (strlen (CommentString) + 267 CurrentState.SpacesBefore + 1); 268 | 269 */ 270 FinalCommentString = 271 UtStringCacheCalloc (strlen (CommentString) + 272 CurrentState.SpacesBefore + 1); 273 |
269 for (i=0; (CurrentState.CommentType != ASL_COMMENT_STANDARD) && 270 (i < CurrentState.SpacesBefore); ++i) | 274 for (i = 0; (CurrentState.CommentType != ASL_COMMENT_STANDARD) && 275 (i < CurrentState.SpacesBefore); i++) |
271 { 272 FinalCommentString[i] = ' '; 273 } | 276 { 277 FinalCommentString[i] = ' '; 278 } |
279 |
|
274 strcat (FinalCommentString, CommentString); 275 CvPlaceComment (CurrentState.CommentType, FinalCommentString); 276 } 277 } 278} 279 280 281/******************************************************************************* --- 23 unchanged lines hidden (view full) --- 305 306 if (Gbl_CaptureComments && CurrentState.CaptureComments) 307 { 308 *StringBuffer = 0; /* null terminate */ 309 CvDbgPrint ("Single-line comment\n"); 310 CommentString = UtStringCacheCalloc (strlen (MsgBuffer) + 1); 311 strcpy (CommentString, MsgBuffer); 312 | 280 strcat (FinalCommentString, CommentString); 281 CvPlaceComment (CurrentState.CommentType, FinalCommentString); 282 } 283 } 284} 285 286 287/******************************************************************************* --- 23 unchanged lines hidden (view full) --- 311 312 if (Gbl_CaptureComments && CurrentState.CaptureComments) 313 { 314 *StringBuffer = 0; /* null terminate */ 315 CvDbgPrint ("Single-line comment\n"); 316 CommentString = UtStringCacheCalloc (strlen (MsgBuffer) + 1); 317 strcpy (CommentString, MsgBuffer); 318 |
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, | 319 /* If this comment lies on the same line as the latest parse op, 320 * assign it to that op's CommentAfter field. Saving in this field 321 * will allow us to support comments that come after code on the 322 * same line as the code itself. For example, |
317 * Name(A,"") //comment 318 * 319 * will be retained rather than transformed into 320 * 321 * Name(A,"") 322 * //comment 323 * 324 * For this case, we only need to add one comment since 325 * 326 * Name(A,"") //comment1 //comment2 ... more comments here. 327 * 328 * would be lexically analyzed as a single comment. 329 * 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 "/ *" | 323 * Name(A,"") //comment 324 * 325 * will be retained rather than transformed into 326 * 327 * Name(A,"") 328 * //comment 329 * 330 * For this case, we only need to add one comment since 331 * 332 * Name(A,"") //comment1 //comment2 ... more comments here. 333 * 334 * would be lexically analyzed as a single comment. 335 * 336 * Create a new string with the approperiate spaces. Since we need 337 * to account for the proper spacing, the actual comment, 338 * extra 2 spaces so that this comment can be converted to the "/ *" |
333 * style and the null terminator, the string would look something like | 339 * style and the null terminator, the string would look something 340 * like: |
334 * 335 * [ (spaces) (comment) ( * /) ('\0') ] 336 * 337 */ 338 FinalCommentString = UtStringCacheCalloc (CurrentState.SpacesBefore + 339 strlen (CommentString) + 3 + 1); 340 | 341 * 342 * [ (spaces) (comment) ( * /) ('\0') ] 343 * 344 */ 345 FinalCommentString = UtStringCacheCalloc (CurrentState.SpacesBefore + 346 strlen (CommentString) + 3 + 1); 347 |
341 for (i=0; (CurrentState.CommentType!=1) && (i<CurrentState.SpacesBefore); ++i) | 348 for (i = 0; (CurrentState.CommentType != 1) && 349 (i < CurrentState.SpacesBefore); i++) |
342 { 343 FinalCommentString[i] = ' '; 344 } | 350 { 351 FinalCommentString[i] = ' '; 352 } |
353 |
|
345 strcat (FinalCommentString, CommentString); 346 347 /* convert to a "/ *" style comment */ 348 349 strcat (FinalCommentString, " */"); | 354 strcat (FinalCommentString, CommentString); 355 356 /* convert to a "/ *" style comment */ 357 358 strcat (FinalCommentString, " */"); |
350 FinalCommentString [CurrentState.SpacesBefore + strlen (CommentString) + 3] = 0; | 359 FinalCommentString [CurrentState.SpacesBefore + 360 strlen (CommentString) + 3] = 0; |
351 352 /* get rid of the carriage return */ 353 354 if (FinalCommentString[strlen (FinalCommentString) - 1] == 0x0D) 355 { | 361 362 /* get rid of the carriage return */ 363 364 if (FinalCommentString[strlen (FinalCommentString) - 1] == 0x0D) 365 { |
356 FinalCommentString[strlen(FinalCommentString)-1] = 0; | 366 FinalCommentString[strlen(FinalCommentString) - 1] = 0; |
357 } | 367 } |
368 |
|
358 CvPlaceComment (CurrentState.CommentType, FinalCommentString); 359 } 360} 361 362 363/******************************************************************************* 364 * 365 * FUNCTION: CgCalculateCommentLengths 366 * 367 * PARAMETERS: Op - Calculate all comments of this Op 368 * | 369 CvPlaceComment (CurrentState.CommentType, FinalCommentString); 370 } 371} 372 373 374/******************************************************************************* 375 * 376 * FUNCTION: CgCalculateCommentLengths 377 * 378 * PARAMETERS: Op - Calculate all comments of this Op 379 * |
369 * RETURN: TotalCommentLength - Length of all comments within this node. | 380 * RETURN: TotalCommentLength - Length of all comments within this op. |
370 * | 381 * |
371 * DESCRIPTION: calculate the length that the each comment takes up within Op. | 382 * 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. 375 * 376 ******************************************************************************/ 377 378UINT32 379CvCalculateCommentLengths( --- 4 unchanged lines hidden (view full) --- 384 ACPI_COMMENT_NODE *Current = NULL; 385 386 387 if (!Gbl_CaptureComments) 388 { 389 return (0); 390 } 391 | 383 * Comments look like the follwoing: [0xA9 OptionBtye comment 0x00] 384 * therefore, we add 1 + 1 + strlen (comment) + 1 to get the actual 385 * length of this comment. 386 * 387 ******************************************************************************/ 388 389UINT32 390CvCalculateCommentLengths( --- 4 unchanged lines hidden (view full) --- 395 ACPI_COMMENT_NODE *Current = NULL; 396 397 398 if (!Gbl_CaptureComments) 399 { 400 return (0); 401 } 402 |
392 CvDbgPrint ("==Calculating comment lengths for %s\n", Op->Asl.ParseOpName); | 403 CvDbgPrint ("==Calculating comment lengths for %s\n", 404 Op->Asl.ParseOpName); 405 |
393 if (Op->Asl.FileChanged) 394 { 395 TotalCommentLength += strlen (Op->Asl.Filename) + 3; 396 397 if (Op->Asl.ParentFilename && 398 AcpiUtStricmp (Op->Asl.Filename, Op->Asl.ParentFilename)) 399 { 400 TotalCommentLength += strlen (Op->Asl.ParentFilename) + 3; 401 } 402 } | 406 if (Op->Asl.FileChanged) 407 { 408 TotalCommentLength += strlen (Op->Asl.Filename) + 3; 409 410 if (Op->Asl.ParentFilename && 411 AcpiUtStricmp (Op->Asl.Filename, Op->Asl.ParentFilename)) 412 { 413 TotalCommentLength += strlen (Op->Asl.ParentFilename) + 3; 414 } 415 } |
416 |
|
403 if (Op->Asl.CommentList) 404 { 405 Current = Op->Asl.CommentList; 406 while (Current) 407 { 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; 413 } 414 } | 417 if (Op->Asl.CommentList) 418 { 419 Current = Op->Asl.CommentList; 420 while (Current) 421 { 422 CommentLength = strlen (Current->Comment)+3; 423 CvDbgPrint ("Length of standard comment: %d\n", CommentLength); 424 CvDbgPrint (" Comment string: %s\n\n", Current->Comment); 425 TotalCommentLength += CommentLength; 426 Current = Current->Next; 427 } 428 } |
429 |
|
415 if (Op->Asl.EndBlkComment) 416 { 417 Current = Op->Asl.EndBlkComment; 418 while (Current) 419 { 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; 425 } 426 } | 430 if (Op->Asl.EndBlkComment) 431 { 432 Current = Op->Asl.EndBlkComment; 433 while (Current) 434 { 435 CommentLength = strlen (Current->Comment)+3; 436 CvDbgPrint ("Length of endblkcomment: %d\n", CommentLength); 437 CvDbgPrint (" Comment string: %s\n\n", Current->Comment); 438 TotalCommentLength += CommentLength; 439 Current = Current->Next; 440 } 441 } |
442 |
|
427 if (Op->Asl.InlineComment) 428 { 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; 433 } | 443 if (Op->Asl.InlineComment) 444 { 445 CommentLength = strlen (Op->Asl.InlineComment)+3; 446 CvDbgPrint ("Length of inline comment: %d\n", CommentLength); 447 CvDbgPrint (" Comment string: %s\n\n", Op->Asl.InlineComment); 448 TotalCommentLength += CommentLength; 449 } |
450 |
|
434 if (Op->Asl.EndNodeComment) 435 { 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; 440 } 441 442 if (Op->Asl.CloseBraceComment) 443 { 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; 448 } 449 450 CvDbgPrint("\n\n"); | 451 if (Op->Asl.EndNodeComment) 452 { 453 CommentLength = strlen(Op->Asl.EndNodeComment)+3; 454 CvDbgPrint ("Length of end node comment +3: %d\n", CommentLength); 455 CvDbgPrint (" Comment string: %s\n\n", Op->Asl.EndNodeComment); 456 TotalCommentLength += CommentLength; 457 } 458 459 if (Op->Asl.CloseBraceComment) 460 { 461 CommentLength = strlen (Op->Asl.CloseBraceComment)+3; 462 CvDbgPrint ("Length of close brace comment: %d\n", CommentLength); 463 CvDbgPrint (" Comment string: %s\n\n", Op->Asl.CloseBraceComment); 464 TotalCommentLength += CommentLength; 465 } 466 467 CvDbgPrint("\n\n"); |
451 452 return TotalCommentLength; 453 | 468 return (TotalCommentLength); |
454} 455 456 457/******************************************************************************* 458 * 459 * FUNCTION: CgWriteAmlDefBlockComment 460 * 461 * PARAMETERS: Op - Current parse op --- 23 unchanged lines hidden (view full) --- 485 if (!Gbl_CaptureComments || 486 (Op->Asl.ParseOpcode != PARSEOP_DEFINITION_BLOCK)) 487 { 488 return; 489 } 490 491 CvDbgPrint ("Printing comments for a definition block..\n"); 492 | 469} 470 471 472/******************************************************************************* 473 * 474 * FUNCTION: CgWriteAmlDefBlockComment 475 * 476 * PARAMETERS: Op - Current parse op --- 23 unchanged lines hidden (view full) --- 500 if (!Gbl_CaptureComments || 501 (Op->Asl.ParseOpcode != PARSEOP_DEFINITION_BLOCK)) 502 { 503 return; 504 } 505 506 CvDbgPrint ("Printing comments for a definition block..\n"); 507 |
493 /* first, print the file name comment after changing .asl to .dsl */ | 508 /* First, print the file name comment after changing .asl to .dsl */ |
494 495 NewFilename = UtStringCacheCalloc (strlen (Op->Asl.Filename)); 496 strcpy (NewFilename, Op->Asl.Filename); 497 DirectoryPosition = strrchr (NewFilename, '/'); 498 Position = strrchr (NewFilename, '.'); 499 500 if (Position && (Position > DirectoryPosition)) 501 { --- 11 unchanged lines hidden (view full) --- 513 strcat (NewFilename, FILE_SUFFIX_DISASSEMBLY); 514 } 515 516 CommentOption = FILENAME_COMMENT; 517 CgWriteOneAmlComment(Op, NewFilename, CommentOption); 518 519 Current = Op->Asl.CommentList; 520 CommentOption = STD_DEFBLK_COMMENT; | 509 510 NewFilename = UtStringCacheCalloc (strlen (Op->Asl.Filename)); 511 strcpy (NewFilename, Op->Asl.Filename); 512 DirectoryPosition = strrchr (NewFilename, '/'); 513 Position = strrchr (NewFilename, '.'); 514 515 if (Position && (Position > DirectoryPosition)) 516 { --- 11 unchanged lines hidden (view full) --- 528 strcat (NewFilename, FILE_SUFFIX_DISASSEMBLY); 529 } 530 531 CommentOption = FILENAME_COMMENT; 532 CgWriteOneAmlComment(Op, NewFilename, CommentOption); 533 534 Current = Op->Asl.CommentList; 535 CommentOption = STD_DEFBLK_COMMENT; |
536 |
|
521 while (Current) 522 { 523 CgWriteOneAmlComment(Op, Current->Comment, CommentOption); 524 CvDbgPrint ("Printing comment: %s\n", Current->Comment); 525 Current = Current->Next; 526 } | 537 while (Current) 538 { 539 CgWriteOneAmlComment(Op, Current->Comment, CommentOption); 540 CvDbgPrint ("Printing comment: %s\n", Current->Comment); 541 Current = Current->Next; 542 } |
543 |
|
527 Op->Asl.CommentList = NULL; 528 | 544 Op->Asl.CommentList = NULL; 545 |
529 /* print any Inline comments associated with this node */ | 546 /* Print any Inline comments associated with this node */ |
530 531 if (Op->Asl.CloseBraceComment) 532 { 533 CommentOption = END_DEFBLK_COMMENT; 534 CgWriteOneAmlComment(Op, Op->Asl.CloseBraceComment, CommentOption); 535 Op->Asl.CloseBraceComment = NULL; 536 } 537} --- 14 unchanged lines hidden (view full) --- 552 ******************************************************************************/ 553 554void 555CgWriteOneAmlComment( 556 ACPI_PARSE_OBJECT *Op, 557 char* CommentToPrint, 558 UINT8 InputOption) 559{ | 547 548 if (Op->Asl.CloseBraceComment) 549 { 550 CommentOption = END_DEFBLK_COMMENT; 551 CgWriteOneAmlComment(Op, Op->Asl.CloseBraceComment, CommentOption); 552 Op->Asl.CloseBraceComment = NULL; 553 } 554} --- 14 unchanged lines hidden (view full) --- 569 ******************************************************************************/ 570 571void 572CgWriteOneAmlComment( 573 ACPI_PARSE_OBJECT *Op, 574 char* CommentToPrint, 575 UINT8 InputOption) 576{ |
560 UINT8 CommentOption = InputOption; 561 UINT8 CommentOpcode = (UINT8)AML_COMMENT_OP; | 577 UINT8 CommentOption = InputOption; 578 UINT8 CommentOpcode = (UINT8) AML_COMMENT_OP; |
562 563 564 if (!CommentToPrint) 565 { 566 return; 567 } 568 569 CgLocalWriteAmlData (Op, &CommentOpcode, 1); --- 8 unchanged lines hidden (view full) --- 578/******************************************************************************* 579 * 580 * FUNCTION: CgWriteAmlComment 581 * 582 * PARAMETERS: Op - Current parse op 583 * 584 * RETURN: None 585 * | 579 580 581 if (!CommentToPrint) 582 { 583 return; 584 } 585 586 CgLocalWriteAmlData (Op, &CommentOpcode, 1); --- 8 unchanged lines hidden (view full) --- 595/******************************************************************************* 596 * 597 * FUNCTION: CgWriteAmlComment 598 * 599 * PARAMETERS: Op - Current parse op 600 * 601 * RETURN: None 602 * |
586 * DESCRIPTION: write all comments pertaining to the 587 * current parse op | 603 * DESCRIPTION: Write all comments pertaining to the current parse op |
588 * 589 ******************************************************************************/ 590 591void 592CgWriteAmlComment( 593 ACPI_PARSE_OBJECT *Op) 594{ 595 ACPI_COMMENT_NODE *Current; --- 8 unchanged lines hidden (view full) --- 604 return; 605 } 606 607 /* Print out the filename comment if needed */ 608 609 if (Op->Asl.FileChanged) 610 { 611 | 604 * 605 ******************************************************************************/ 606 607void 608CgWriteAmlComment( 609 ACPI_PARSE_OBJECT *Op) 610{ 611 ACPI_COMMENT_NODE *Current; --- 8 unchanged lines hidden (view full) --- 620 return; 621 } 622 623 /* Print out the filename comment if needed */ 624 625 if (Op->Asl.FileChanged) 626 { 627 |
612 /* first, print the file name comment after changing .asl to .dsl */ | 628 /* First, print the file name comment after changing .asl to .dsl */ |
613 614 NewFilename = 615 FlGenerateFilename (Op->Asl.Filename, FILE_SUFFIX_DISASSEMBLY); 616 if (NewFilename) 617 { 618 CvDbgPrint ("Writing file comment, \"%s\" for %s\n", 619 NewFilename, Op->Asl.ParseOpName); 620 } 621 622 CgWriteOneAmlComment(Op, NewFilename, FILENAME_COMMENT); 623 624 if (Op->Asl.ParentFilename && 625 AcpiUtStricmp (Op->Asl.ParentFilename, Op->Asl.Filename)) 626 { 627 ParentFilename = FlGenerateFilename (Op->Asl.ParentFilename, 628 FILE_SUFFIX_DISASSEMBLY); 629 CgWriteOneAmlComment(Op, ParentFilename, PARENTFILENAME_COMMENT); 630 } 631 | 629 630 NewFilename = 631 FlGenerateFilename (Op->Asl.Filename, FILE_SUFFIX_DISASSEMBLY); 632 if (NewFilename) 633 { 634 CvDbgPrint ("Writing file comment, \"%s\" for %s\n", 635 NewFilename, Op->Asl.ParseOpName); 636 } 637 638 CgWriteOneAmlComment(Op, NewFilename, FILENAME_COMMENT); 639 640 if (Op->Asl.ParentFilename && 641 AcpiUtStricmp (Op->Asl.ParentFilename, Op->Asl.Filename)) 642 { 643 ParentFilename = FlGenerateFilename (Op->Asl.ParentFilename, 644 FILE_SUFFIX_DISASSEMBLY); 645 CgWriteOneAmlComment(Op, ParentFilename, PARENTFILENAME_COMMENT); 646 } 647 |
632 /* prevent multiple writes of the same comment */ | 648 /* Prevent multiple writes of the same comment */ |
633 634 Op->Asl.FileChanged = FALSE; 635 } 636 637 /* 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 640 * as byte code. --- 8 unchanged lines hidden (view full) --- 649 CommentOption = STANDARD_COMMENT; 650 } 651 652 while (Current) 653 { 654 CgWriteOneAmlComment(Op, Current->Comment, CommentOption); 655 Current = Current->Next; 656 } | 649 650 Op->Asl.FileChanged = FALSE; 651 } 652 653 /* 654 * Regular comments are stored in a list of comments within an Op. 655 * If there is a such list in this node, print out the comment 656 * as byte code. --- 8 unchanged lines hidden (view full) --- 665 CommentOption = STANDARD_COMMENT; 666 } 667 668 while (Current) 669 { 670 CgWriteOneAmlComment(Op, Current->Comment, CommentOption); 671 Current = Current->Next; 672 } |
673 |
|
657 Op->Asl.CommentList = NULL; 658 659 Current = Op->Asl.EndBlkComment; 660 CommentOption = ENDBLK_COMMENT; 661 while (Current) 662 { 663 CgWriteOneAmlComment(Op, Current->Comment, CommentOption); 664 Current = Current->Next; 665 } | 674 Op->Asl.CommentList = NULL; 675 676 Current = Op->Asl.EndBlkComment; 677 CommentOption = ENDBLK_COMMENT; 678 while (Current) 679 { 680 CgWriteOneAmlComment(Op, Current->Comment, CommentOption); 681 Current = Current->Next; 682 } |
683 |
|
666 Op->Asl.EndBlkComment = NULL; 667 | 684 Op->Asl.EndBlkComment = NULL; 685 |
668 /* print any Inline comments associated with this node */ | 686 /* Print any Inline comments associated with this node */ |
669 670 if (Op->Asl.InlineComment) 671 { 672 CommentOption = INLINE_COMMENT; 673 CgWriteOneAmlComment(Op, Op->Asl.InlineComment, CommentOption); 674 Op->Asl.InlineComment = NULL; 675 } 676 --- 12 unchanged lines hidden (view full) --- 689 } 690} 691 692 693/******************************************************************************* 694 * 695 * FUNCTION: CvCommentNodeCalloc 696 * | 687 688 if (Op->Asl.InlineComment) 689 { 690 CommentOption = INLINE_COMMENT; 691 CgWriteOneAmlComment(Op, Op->Asl.InlineComment, CommentOption); 692 Op->Asl.InlineComment = NULL; 693 } 694 --- 12 unchanged lines hidden (view full) --- 707 } 708} 709 710 711/******************************************************************************* 712 * 713 * FUNCTION: CvCommentNodeCalloc 714 * |
697 * PARAMETERS: none | 715 * PARAMETERS: None |
698 * 699 * RETURN: Pointer to the comment node. Aborts on allocation failure 700 * 701 * DESCRIPTION: Allocate a string node buffer. 702 * 703 ******************************************************************************/ 704 705ACPI_COMMENT_NODE * --- 22 unchanged lines hidden (view full) --- 728 * aslrules.y 729 * 730 ******************************************************************************/ 731 732UINT32 733CvParseOpBlockType ( 734 ACPI_PARSE_OBJECT *Op) 735{ | 716 * 717 * RETURN: Pointer to the comment node. Aborts on allocation failure 718 * 719 * DESCRIPTION: Allocate a string node buffer. 720 * 721 ******************************************************************************/ 722 723ACPI_COMMENT_NODE * --- 22 unchanged lines hidden (view full) --- 746 * aslrules.y 747 * 748 ******************************************************************************/ 749 750UINT32 751CvParseOpBlockType ( 752 ACPI_PARSE_OBJECT *Op) 753{ |
754 |
|
736 if (!Op) 737 { 738 return (BLOCK_NONE); 739 } 740 741 switch (Op->Asl.ParseOpcode) 742 { | 755 if (!Op) 756 { 757 return (BLOCK_NONE); 758 } 759 760 switch (Op->Asl.ParseOpcode) 761 { |
762 /* From aslprimaries.y */ |
|
743 | 763 |
744 /* from aslprimaries.y */ 745 | |
746 case PARSEOP_VAR_PACKAGE: 747 case PARSEOP_BANKFIELD: 748 case PARSEOP_BUFFER: 749 case PARSEOP_CASE: 750 case PARSEOP_DEVICE: 751 case PARSEOP_FIELD: 752 case PARSEOP_FOR: 753 case PARSEOP_FUNCTION: --- 4 unchanged lines hidden (view full) --- 758 case PARSEOP_POWERRESOURCE: 759 case PARSEOP_PROCESSOR: 760 case PARSEOP_DATABUFFER: 761 case PARSEOP_SCOPE: 762 case PARSEOP_SWITCH: 763 case PARSEOP_THERMALZONE: 764 case PARSEOP_WHILE: 765 | 764 case PARSEOP_VAR_PACKAGE: 765 case PARSEOP_BANKFIELD: 766 case PARSEOP_BUFFER: 767 case PARSEOP_CASE: 768 case PARSEOP_DEVICE: 769 case PARSEOP_FIELD: 770 case PARSEOP_FOR: 771 case PARSEOP_FUNCTION: --- 4 unchanged lines hidden (view full) --- 776 case PARSEOP_POWERRESOURCE: 777 case PARSEOP_PROCESSOR: 778 case PARSEOP_DATABUFFER: 779 case PARSEOP_SCOPE: 780 case PARSEOP_SWITCH: 781 case PARSEOP_THERMALZONE: 782 case PARSEOP_WHILE: 783 |
766 /* from aslresources.y */ | 784 /* From aslresources.y */ |
767 768 case PARSEOP_RESOURCETEMPLATE: /* optional parens */ 769 case PARSEOP_VENDORLONG: 770 case PARSEOP_VENDORSHORT: 771 case PARSEOP_INTERRUPT: 772 case PARSEOP_IRQNOFLAGS: 773 case PARSEOP_IRQ: 774 case PARSEOP_GPIO_INT: 775 case PARSEOP_GPIO_IO: 776 case PARSEOP_DMA: 777 | 785 786 case PARSEOP_RESOURCETEMPLATE: /* optional parens */ 787 case PARSEOP_VENDORLONG: 788 case PARSEOP_VENDORSHORT: 789 case PARSEOP_INTERRUPT: 790 case PARSEOP_IRQNOFLAGS: 791 case PARSEOP_IRQ: 792 case PARSEOP_GPIO_INT: 793 case PARSEOP_GPIO_IO: 794 case PARSEOP_DMA: 795 |
778 /*from aslrules.y */ | 796 /* From aslrules.y */ |
779 780 case PARSEOP_DEFINITION_BLOCK: 781 return (BLOCK_PAREN | BLOCK_BRACE); 782 783 default: | 797 798 case PARSEOP_DEFINITION_BLOCK: 799 return (BLOCK_PAREN | BLOCK_BRACE); 800 801 default: |
784 | |
785 return (BLOCK_NONE); 786 } 787} 788 789 790/******************************************************************************* 791 * 792 * FUNCTION: CvProcessCommentState 793 * | 802 return (BLOCK_NONE); 803 } 804} 805 806 807/******************************************************************************* 808 * 809 * FUNCTION: CvProcessCommentState 810 * |
794 * PARAMETERS: char | 811 * PARAMETERS: Input - Input character |
795 * 796 * RETURN: None 797 * 798 * DESCRIPTION: Take the given input. If this character is 799 * defined as a comment table entry, then update the state 800 * accordingly. 801 * 802 ******************************************************************************/ 803 804void 805CvProcessCommentState ( | 812 * 813 * RETURN: None 814 * 815 * DESCRIPTION: Take the given input. If this character is 816 * defined as a comment table entry, then update the state 817 * accordingly. 818 * 819 ******************************************************************************/ 820 821void 822CvProcessCommentState ( |
806 char input) | 823 char Input) |
807{ 808 | 824{ 825 |
809 if (input != ' ') | 826 if (Input != ' ') |
810 { 811 Gbl_CommentState.SpacesBefore = 0; 812 } 813 | 827 { 828 Gbl_CommentState.SpacesBefore = 0; 829 } 830 |
814 switch (input) | 831 switch (Input) |
815 { 816 case '\n': 817 818 Gbl_CommentState.CommentType = ASL_COMMENT_STANDARD; 819 break; 820 821 case ' ': 822 --- 28 unchanged lines hidden (view full) --- 851 852 Gbl_CommentState.CommentType = ASLCOMMENT_INLINE; 853 break; 854 855 default: 856 857 Gbl_CommentState.CommentType = ASLCOMMENT_INLINE; 858 break; | 832 { 833 case '\n': 834 835 Gbl_CommentState.CommentType = ASL_COMMENT_STANDARD; 836 break; 837 838 case ' ': 839 --- 28 unchanged lines hidden (view full) --- 868 869 Gbl_CommentState.CommentType = ASLCOMMENT_INLINE; 870 break; 871 872 default: 873 874 Gbl_CommentState.CommentType = ASLCOMMENT_INLINE; 875 break; |
859 | |
860 } 861} 862 863 864/******************************************************************************* 865 * 866 * FUNCTION: CvAddToCommentList 867 * | 876 } 877} 878 879 880/******************************************************************************* 881 * 882 * FUNCTION: CvAddToCommentList 883 * |
868 * PARAMETERS: toAdd - Contains the comment to be inserted | 884 * PARAMETERS: ToAdd - Contains the comment to be inserted |
869 * 870 * RETURN: None 871 * 872 * DESCRIPTION: Add the given char* to a list of comments in the global list 873 * of comments. 874 * 875 ******************************************************************************/ 876 877void 878CvAddToCommentList ( | 885 * 886 * RETURN: None 887 * 888 * DESCRIPTION: Add the given char* to a list of comments in the global list 889 * of comments. 890 * 891 ******************************************************************************/ 892 893void 894CvAddToCommentList ( |
879 char* ToAdd) | 895 char *ToAdd) |
880{ | 896{ |
881 if (Gbl_Comment_List_Head) | 897 898 if (Gbl_CommentListHead) |
882 { | 899 { |
883 Gbl_Comment_List_Tail->Next = CvCommentNodeCalloc (); 884 Gbl_Comment_List_Tail = Gbl_Comment_List_Tail->Next; | 900 Gbl_CommentListTail->Next = CvCommentNodeCalloc (); 901 Gbl_CommentListTail = Gbl_CommentListTail->Next; |
885 } 886 else 887 { | 902 } 903 else 904 { |
888 Gbl_Comment_List_Head = CvCommentNodeCalloc (); 889 Gbl_Comment_List_Tail = Gbl_Comment_List_Head; | 905 Gbl_CommentListHead = CvCommentNodeCalloc (); 906 Gbl_CommentListTail = Gbl_CommentListHead; |
890 } 891 | 907 } 908 |
892 Gbl_Comment_List_Tail->Comment = ToAdd; 893 894 return; | 909 Gbl_CommentListTail->Comment = ToAdd; |
895} 896 | 910} 911 |
912 |
|
897/******************************************************************************* 898 * 899 * FUNCTION: CvAppendInlineComment 900 * 901 * PARAMETERS: InlineComment - Append to the end of this string. 902 * toAdd - Contains the comment to be inserted 903 * 904 * RETURN: Str - toAdd appended to InlineComment 905 * 906 * DESCRIPTION: Concatenate ToAdd to InlineComment 907 * 908 ******************************************************************************/ 909 | 913/******************************************************************************* 914 * 915 * FUNCTION: CvAppendInlineComment 916 * 917 * PARAMETERS: InlineComment - Append to the end of this string. 918 * toAdd - Contains the comment to be inserted 919 * 920 * RETURN: Str - toAdd appended to InlineComment 921 * 922 * DESCRIPTION: Concatenate ToAdd to InlineComment 923 * 924 ******************************************************************************/ 925 |
910char* | 926char * |
911CvAppendInlineComment ( 912 char *InlineComment, 913 char *ToAdd) 914{ 915 char* Str; 916 UINT32 Size = 0; 917 918 919 if (!InlineComment) 920 { | 927CvAppendInlineComment ( 928 char *InlineComment, 929 char *ToAdd) 930{ 931 char* Str; 932 UINT32 Size = 0; 933 934 935 if (!InlineComment) 936 { |
921 return ToAdd; | 937 return (ToAdd); |
922 } | 938 } |
939 |
|
923 if (!ToAdd) 924 { | 940 if (!ToAdd) 941 { |
925 return InlineComment; | 942 return (InlineComment); |
926 } 927 928 Size = strlen (ToAdd); 929 Size += strlen (InlineComment); | 943 } 944 945 Size = strlen (ToAdd); 946 Size += strlen (InlineComment); |
930 Str = UtStringCacheCalloc (Size+1); | 947 Str = UtStringCacheCalloc (Size + 1); 948 |
931 strcpy (Str, InlineComment); 932 strcat (Str, ToAdd); | 949 strcpy (Str, InlineComment); 950 strcat (Str, ToAdd); |
933 Str[Size+1] = 0; 934 935 return Str; | 951 Str[Size +1] = 0; 952 return (Str); |
936} 937 938 939/******************************************************************************* 940 * 941 * FUNCTION: CvPlaceComment 942 * | 953} 954 955 956/******************************************************************************* 957 * 958 * FUNCTION: CvPlaceComment 959 * |
943 * PARAMETERS: Int - Type 944 * char* - CommentString | 960 * PARAMETERS: UINT8 - Type 961 * char * - CommentString |
945 * 946 * RETURN: None 947 * 948 * DESCRIPTION: Given type and CommentString, this function places the 949 * CommentString in the approperiate global comment list or char* 950 * 951 ******************************************************************************/ 952 953void 954CvPlaceComment( 955 UINT8 Type, 956 char *CommentString) 957{ 958 ACPI_PARSE_OBJECT *LatestParseNode; 959 ACPI_PARSE_OBJECT *ParenBraceNode; 960 961 | 962 * 963 * RETURN: None 964 * 965 * DESCRIPTION: Given type and CommentString, this function places the 966 * CommentString in the approperiate global comment list or char* 967 * 968 ******************************************************************************/ 969 970void 971CvPlaceComment( 972 UINT8 Type, 973 char *CommentString) 974{ 975 ACPI_PARSE_OBJECT *LatestParseNode; 976 ACPI_PARSE_OBJECT *ParenBraceNode; 977 978 |
962 LatestParseNode = Gbl_CommentState.Latest_Parse_Node; | 979 LatestParseNode = Gbl_CommentState.LatestParseOp; |
963 ParenBraceNode = Gbl_CommentState.ParsingParenBraceNode; 964 CvDbgPrint ("Placing comment %s for type %d\n", CommentString, Type); 965 966 switch (Type) 967 { 968 case ASL_COMMENT_STANDARD: 969 970 CvAddToCommentList (CommentString); 971 break; 972 973 case ASLCOMMENT_INLINE: 974 975 LatestParseNode->Asl.InlineComment = 976 CvAppendInlineComment (LatestParseNode->Asl.InlineComment, 977 CommentString); 978 break; 979 980 case ASL_COMMENT_OPEN_PAREN: 981 | 980 ParenBraceNode = Gbl_CommentState.ParsingParenBraceNode; 981 CvDbgPrint ("Placing comment %s for type %d\n", CommentString, Type); 982 983 switch (Type) 984 { 985 case ASL_COMMENT_STANDARD: 986 987 CvAddToCommentList (CommentString); 988 break; 989 990 case ASLCOMMENT_INLINE: 991 992 LatestParseNode->Asl.InlineComment = 993 CvAppendInlineComment (LatestParseNode->Asl.InlineComment, 994 CommentString); 995 break; 996 997 case ASL_COMMENT_OPEN_PAREN: 998 |
982 Gbl_Inline_Comment_Buffer = 983 CvAppendInlineComment(Gbl_Inline_Comment_Buffer, | 999 Gbl_InlineCommentBuffer = 1000 CvAppendInlineComment(Gbl_InlineCommentBuffer, |
984 CommentString); 985 break; 986 987 case ASL_COMMENT_CLOSE_PAREN: 988 989 if (ParenBraceNode) 990 { 991 ParenBraceNode->Asl.EndNodeComment = --- 11 unchanged lines hidden (view full) --- 1003 case ASL_COMMENT_CLOSE_BRACE: 1004 1005 LatestParseNode->Asl.CloseBraceComment = CommentString; 1006 break; 1007 1008 default: 1009 1010 break; | 1001 CommentString); 1002 break; 1003 1004 case ASL_COMMENT_CLOSE_PAREN: 1005 1006 if (ParenBraceNode) 1007 { 1008 ParenBraceNode->Asl.EndNodeComment = --- 11 unchanged lines hidden (view full) --- 1020 case ASL_COMMENT_CLOSE_BRACE: 1021 1022 LatestParseNode->Asl.CloseBraceComment = CommentString; 1023 break; 1024 1025 default: 1026 1027 break; |
1011 | |
1012 } 1013} | 1028 } 1029} |