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