Rev 1498 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1498 | Rev 2216 | ||
---|---|---|---|
Line 6... | Line 6... | ||
6 | 6 | ||
7 | /****************************************************************************** |
7 | /****************************************************************************** |
8 | * |
8 | * |
9 | * 1. Copyright Notice |
9 | * 1. Copyright Notice |
10 | * |
10 | * |
11 | * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
12 | * All rights reserved. |
12 | * All rights reserved. |
13 | * |
13 | * |
14 | * 2. License |
14 | * 2. License |
15 | * |
15 | * |
Line 120... | Line 120... | ||
120 | 120 | ||
121 | #define _COMPONENT DT_COMPILER |
121 | #define _COMPONENT DT_COMPILER |
Line 122... | Line -... | ||
122 | ACPI_MODULE_NAME ("dtio") |
- | |
123 | - | ||
124 | 122 | ACPI_MODULE_NAME ("dtio") |
|
125 | /****************************************************************************** |
- | |
126 | * |
- | |
127 | * FUNCTION: DtIsComment |
- | |
128 | * |
- | |
129 | * PARAMETERS: Line - Current source code line |
- | |
130 | * |
- | |
131 | * RETURN: TRUE if comment, FALSE otherwise |
- | |
132 | * |
- | |
Line -... | Line 123... | ||
- | 123 | ||
- | 124 | ||
133 | * DESCRIPTION: Detect a comment in the source module |
125 | /* Local prototypes */ |
Line 134... | Line 126... | ||
134 | * |
126 | |
135 | *****************************************************************************/ |
127 | static char * |
136 | 128 | DtTrim ( |
|
137 | /* TBD: Temporary: very simple code to detect comments */ |
- | |
Line 138... | Line 129... | ||
138 | 129 | char *String); |
|
- | 130 | ||
139 | static int |
131 | static void |
140 | DtIsComment( |
132 | DtLinkField ( |
141 | char *Line) |
133 | DT_FIELD *Field); |
142 | { |
- | |
Line -... | Line 134... | ||
- | 134 | ||
143 | 135 | static ACPI_STATUS |
|
- | 136 | DtParseLine ( |
|
- | 137 | char *LineBuffer, |
|
- | 138 | UINT32 Line, |
|
- | 139 | UINT32 Offset); |
|
- | 140 | ||
- | 141 | UINT32 |
|
- | 142 | DtGetNextLine ( |
|
- | 143 | FILE *Handle); |
|
- | 144 | ||
- | 145 | static void |
|
- | 146 | DtWriteBinary ( |
|
- | 147 | DT_SUBTABLE *Subtable, |
|
- | 148 | void *Context, |
|
- | 149 | void *ReturnValue); |
|
- | 150 | ||
- | 151 | static void |
|
- | 152 | DtDumpBuffer ( |
|
- | 153 | UINT32 FileId, |
|
- | 154 | UINT8 *Buffer, |
|
- | 155 | UINT32 Offset, |
|
- | 156 | UINT32 Length); |
|
- | 157 | ||
- | 158 | ||
- | 159 | /* States for DtGetNextLine */ |
|
- | 160 | ||
144 | if (!ACPI_STRNCMP (Line, "/*", 2) || |
161 | #define DT_NORMAL_TEXT 0 |
- | 162 | #define DT_START_QUOTED_STRING 1 |
|
Line 145... | Line 163... | ||
145 | !ACPI_STRNCMP (Line, " *", 2)) |
163 | #define DT_START_COMMENT 2 |
146 | { |
164 | #define DT_SLASH_ASTERISK_COMMENT 3 |
147 | return 1; |
165 | #define DT_SLASH_SLASH_COMMENT 4 |
Line 281... | Line 299... | ||
281 | * |
299 | * |
282 | * PARAMETERS: LineBuffer - Current source code line |
300 | * PARAMETERS: LineBuffer - Current source code line |
283 | * Line - Current line number in the source |
301 | * Line - Current line number in the source |
284 | * Offset - Current byte offset of the line |
302 | * Offset - Current byte offset of the line |
285 | * |
303 | * |
286 | * RETURN: None |
304 | * RETURN: Status |
287 | * |
305 | * |
288 | * DESCRIPTION: Parse one source line |
306 | * DESCRIPTION: Parse one source line |
289 | * |
307 | * |
290 | *****************************************************************************/ |
308 | *****************************************************************************/ |
Line 291... | Line 309... | ||
291 | 309 | ||
292 | static void |
310 | static ACPI_STATUS |
293 | DtParseLine ( |
311 | DtParseLine ( |
294 | char *LineBuffer, |
312 | char *LineBuffer, |
295 | UINT32 Line, |
313 | UINT32 Line, |
296 | UINT32 Offset) |
314 | UINT32 Offset) |
Line 304... | Line 322... | ||
304 | char *Colon; |
322 | char *Colon; |
305 | UINT32 Length; |
323 | UINT32 Length; |
306 | DT_FIELD *Field; |
324 | DT_FIELD *Field; |
307 | UINT32 Column; |
325 | UINT32 Column; |
308 | UINT32 NameColumn; |
326 | UINT32 NameColumn; |
- | 327 | BOOLEAN IsNullString = FALSE; |
|
Line 309... | Line 328... | ||
309 | 328 | ||
310 | 329 | ||
311 | if (!LineBuffer || DtIsComment (LineBuffer)) |
330 | if (!LineBuffer) |
- | 331 | { |
|
- | 332 | return (AE_OK); |
|
- | 333 | } |
|
- | 334 | ||
- | 335 | /* All lines after "Raw Table Data" are ingored */ |
|
- | 336 | ||
- | 337 | if (strstr (LineBuffer, ACPI_RAW_TABLE_DATA_HEADER)) |
|
312 | { |
338 | { |
Line 313... | Line 339... | ||
313 | return; |
339 | return (AE_NOT_FOUND); |
314 | } |
340 | } |
315 | 341 | ||
316 | Colon = strchr (LineBuffer, ':'); |
342 | Colon = strchr (LineBuffer, ':'); |
317 | if (!Colon || *(Colon - 1) != ' ') |
343 | if (!Colon) |
Line 318... | Line 344... | ||
318 | { |
344 | { |
319 | return; |
345 | return (AE_OK); |
Line 339... | Line 365... | ||
339 | Start++; |
365 | Start++; |
340 | } |
366 | } |
Line 341... | Line 367... | ||
341 | 367 | ||
342 | if (Start == Colon) |
368 | if (Start == Colon) |
343 | { |
- | |
344 | MYDEBUG ("ERROR: right bracket reaches colon position\n"); |
369 | { |
345 | break; |
370 | break; |
Line 346... | Line 371... | ||
346 | } |
371 | } |
347 | 372 | ||
Line 365... | Line 390... | ||
365 | ACPI_STRNCPY (TmpName, Start, Length); |
390 | ACPI_STRNCPY (TmpName, Start, Length); |
366 | Name = DtTrim (TmpName); |
391 | Name = DtTrim (TmpName); |
367 | ACPI_FREE (TmpName); |
392 | ACPI_FREE (TmpName); |
Line 368... | Line 393... | ||
368 | 393 | ||
369 | Start = End = (Colon + 1); |
- | |
370 | 394 | Start = End = (Colon + 1); |
|
371 | while (*End) |
395 | while (*End) |
372 | { |
396 | { |
Line 373... | Line 397... | ||
373 | /* Found left quotation, go to the right quotation and break */ |
397 | /* Found left quotation, go to the right quotation and break */ |
374 | 398 | ||
375 | if (*End == '"') |
399 | if (*End == '"') |
- | 400 | { |
|
- | 401 | End++; |
|
- | 402 | ||
- | 403 | /* Check for an explicit null string */ |
|
- | 404 | ||
- | 405 | if (*End == '"') |
|
- | 406 | { |
|
376 | { |
407 | IsNullString = TRUE; |
377 | End++; |
408 | } |
378 | while (*End && *End != '"') |
409 | while (*End && (*End != '"')) |
379 | { |
410 | { |
Line 380... | Line 411... | ||
380 | End++; |
411 | End++; |
381 | } |
412 | } |
382 | 413 | ||
Line -... | Line 414... | ||
- | 414 | End++; |
|
- | 415 | break; |
|
- | 416 | } |
|
- | 417 | ||
383 | End++; |
418 | /* |
- | 419 | * Special "comment" fields at line end, ignore them. |
|
384 | break; |
420 | * Note: normal slash-slash and slash-asterisk comments are |
- | 421 | * stripped already by the DtGetNextLine parser. |
|
385 | } |
422 | * |
386 | 423 | * TBD: Perhaps DtGetNextLine should parse the following type |
|
- | 424 | * of comments also. |
|
387 | if (*End == '(' || |
425 | */ |
388 | *End == '<' || |
426 | if (*End == '[') |
389 | *End == '/') |
- | |
390 | { |
427 | { |
391 | break; |
428 | End--; |
Line 392... | Line 429... | ||
392 | } |
429 | break; |
393 | 430 | } |
|
- | 431 | End++; |
|
394 | End++; |
432 | } |
395 | } |
433 | |
396 | 434 | Length = ACPI_PTR_DIFF (End, Start); |
|
Line -... | Line 435... | ||
- | 435 | TmpValue = UtLocalCalloc (Length + 1); |
|
- | 436 | ||
397 | Length = ACPI_PTR_DIFF (End, Start); |
437 | ACPI_STRNCPY (TmpValue, Start, Length); |
398 | TmpValue = UtLocalCalloc (Length + 1); |
438 | Value = DtTrim (TmpValue); |
399 | ACPI_STRNCPY (TmpValue, Start, Length); |
439 | ACPI_FREE (TmpValue); |
400 | Value = DtTrim (TmpValue); |
440 | |
401 | ACPI_FREE (TmpValue); |
441 | /* Create a new field object only if we have a valid value field */ |
402 | 442 | ||
Line 410... | Line 450... | ||
410 | Field->NameColumn = NameColumn; |
450 | Field->NameColumn = NameColumn; |
411 | Field->Column = Column; |
451 | Field->Column = Column; |
Line 412... | Line 452... | ||
412 | 452 | ||
413 | DtLinkField (Field); |
453 | DtLinkField (Field); |
- | 454 | } |
|
- | 455 | else /* Ignore this field, it has no valid data */ |
|
- | 456 | { |
|
- | 457 | ACPI_FREE (Name); |
|
- | 458 | ACPI_FREE (Value); |
|
- | 459 | } |
|
- | 460 | ||
- | 461 | return (AE_OK); |
|
- | 462 | } |
|
- | 463 | ||
- | 464 | ||
- | 465 | /****************************************************************************** |
|
- | 466 | * |
|
- | 467 | * FUNCTION: DtGetNextLine |
|
- | 468 | * |
|
- | 469 | * PARAMETERS: Handle - Open file handle for the source file |
|
- | 470 | * |
|
- | 471 | * RETURN: Filled line buffer and offset of start-of-line (ASL_EOF on EOF) |
|
- | 472 | * |
|
- | 473 | * DESCRIPTION: Get the next valid source line. Removes all comments. |
|
- | 474 | * Ignores empty lines. |
|
- | 475 | * |
|
- | 476 | * Handles both slash-asterisk and slash-slash comments. |
|
- | 477 | * Also, quoted strings, but no escapes within. |
|
- | 478 | * |
|
- | 479 | * Line is returned in Gbl_CurrentLineBuffer. |
|
- | 480 | * Line number in original file is returned in Gbl_CurrentLineNumber. |
|
- | 481 | * |
|
- | 482 | *****************************************************************************/ |
|
- | 483 | ||
- | 484 | UINT32 |
|
- | 485 | DtGetNextLine ( |
|
- | 486 | FILE *Handle) |
|
- | 487 | { |
|
- | 488 | BOOLEAN LineNotAllBlanks = FALSE; |
|
- | 489 | UINT32 State = DT_NORMAL_TEXT; |
|
- | 490 | UINT32 CurrentLineOffset; |
|
- | 491 | UINT32 i; |
|
- | 492 | char c; |
|
- | 493 | ||
- | 494 | ||
- | 495 | for (i = 0; i < ASL_LINE_BUFFER_SIZE;) |
|
- | 496 | { |
|
- | 497 | c = (char) getc (Handle); |
|
- | 498 | if (c == EOF) |
|
- | 499 | { |
|
- | 500 | switch (State) |
|
- | 501 | { |
|
- | 502 | case DT_START_QUOTED_STRING: |
|
- | 503 | case DT_SLASH_ASTERISK_COMMENT: |
|
- | 504 | case DT_SLASH_SLASH_COMMENT: |
|
- | 505 | ||
- | 506 | AcpiOsPrintf ("**** EOF within comment/string %u\n", State); |
|
- | 507 | break; |
|
- | 508 | ||
- | 509 | default: |
|
- | 510 | break; |
|
- | 511 | } |
|
- | 512 | ||
- | 513 | return (ASL_EOF); |
|
- | 514 | } |
|
- | 515 | ||
- | 516 | switch (State) |
|
- | 517 | { |
|
- | 518 | case DT_NORMAL_TEXT: |
|
- | 519 | ||
- | 520 | /* Normal text, insert char into line buffer */ |
|
- | 521 | ||
- | 522 | Gbl_CurrentLineBuffer[i] = c; |
|
- | 523 | switch (c) |
|
- | 524 | { |
|
- | 525 | case '/': |
|
- | 526 | State = DT_START_COMMENT; |
|
- | 527 | break; |
|
- | 528 | ||
- | 529 | case '"': |
|
- | 530 | State = DT_START_QUOTED_STRING; |
|
- | 531 | LineNotAllBlanks = TRUE; |
|
- | 532 | i++; |
|
- | 533 | break; |
|
- | 534 | ||
- | 535 | case '\\': |
|
- | 536 | /* |
|
- | 537 | * The continuation char MUST be last char on this line. |
|
- | 538 | * Otherwise, it will be assumed to be a valid ASL char. |
|
- | 539 | */ |
|
- | 540 | State = DT_MERGE_LINES; |
|
- | 541 | break; |
|
- | 542 | ||
- | 543 | case '\n': |
|
- | 544 | CurrentLineOffset = Gbl_NextLineOffset; |
|
- | 545 | Gbl_NextLineOffset = (UINT32) ftell (Handle); |
|
- | 546 | Gbl_CurrentLineNumber++; |
|
- | 547 | ||
- | 548 | /* |
|
- | 549 | * Exit if line is complete. Ignore empty lines (only \n) |
|
- | 550 | * or lines that contain nothing but blanks. |
|
- | 551 | */ |
|
- | 552 | if ((i != 0) && LineNotAllBlanks) |
|
- | 553 | { |
|
- | 554 | Gbl_CurrentLineBuffer[i+1] = 0; /* Terminate string */ |
|
- | 555 | return (CurrentLineOffset); |
|
- | 556 | } |
|
- | 557 | ||
- | 558 | /* Toss this line and start a new one */ |
|
- | 559 | ||
- | 560 | i = 0; |
|
- | 561 | LineNotAllBlanks = FALSE; |
|
- | 562 | break; |
|
- | 563 | ||
- | 564 | default: |
|
- | 565 | if (c != ' ') |
|
- | 566 | { |
|
- | 567 | LineNotAllBlanks = TRUE; |
|
- | 568 | } |
|
- | 569 | ||
- | 570 | i++; |
|
- | 571 | break; |
|
- | 572 | } |
|
- | 573 | break; |
|
- | 574 | ||
- | 575 | case DT_START_QUOTED_STRING: |
|
- | 576 | ||
- | 577 | /* Insert raw chars until end of quoted string */ |
|
- | 578 | ||
- | 579 | Gbl_CurrentLineBuffer[i] = c; |
|
- | 580 | i++; |
|
- | 581 | ||
- | 582 | if (c == '"') |
|
- | 583 | { |
|
- | 584 | State = DT_NORMAL_TEXT; |
|
- | 585 | } |
|
- | 586 | break; |
|
- | 587 | ||
- | 588 | case DT_START_COMMENT: |
|
- | 589 | ||
- | 590 | /* Open comment if this character is an asterisk or slash */ |
|
- | 591 | ||
- | 592 | switch (c) |
|
- | 593 | { |
|
- | 594 | case '*': |
|
- | 595 | State = DT_SLASH_ASTERISK_COMMENT; |
|
- | 596 | break; |
|
- | 597 | ||
- | 598 | case '/': |
|
- | 599 | State = DT_SLASH_SLASH_COMMENT; |
|
- | 600 | break; |
|
- | 601 | ||
- | 602 | default: /* Not a comment */ |
|
- | 603 | i++; /* Save the preceeding slash */ |
|
- | 604 | Gbl_CurrentLineBuffer[i] = c; |
|
- | 605 | i++; |
|
- | 606 | State = DT_NORMAL_TEXT; |
|
- | 607 | break; |
|
- | 608 | } |
|
- | 609 | break; |
|
- | 610 | ||
- | 611 | case DT_SLASH_ASTERISK_COMMENT: |
|
- | 612 | ||
- | 613 | /* Ignore chars until an asterisk-slash is found */ |
|
- | 614 | ||
- | 615 | switch (c) |
|
- | 616 | { |
|
- | 617 | case '\n': |
|
- | 618 | Gbl_NextLineOffset = (UINT32) ftell (Handle); |
|
- | 619 | Gbl_CurrentLineNumber++; |
|
- | 620 | break; |
|
- | 621 | ||
- | 622 | case '*': |
|
- | 623 | State = DT_END_COMMENT; |
|
- | 624 | break; |
|
- | 625 | ||
- | 626 | default: |
|
- | 627 | break; |
|
- | 628 | } |
|
- | 629 | break; |
|
- | 630 | ||
- | 631 | case DT_SLASH_SLASH_COMMENT: |
|
- | 632 | ||
- | 633 | /* Ignore chars until end-of-line */ |
|
- | 634 | ||
- | 635 | if (c == '\n') |
|
- | 636 | { |
|
- | 637 | /* We will exit via the NORMAL_TEXT path */ |
|
- | 638 | ||
- | 639 | ungetc (c, Handle); |
|
- | 640 | State = DT_NORMAL_TEXT; |
|
- | 641 | } |
|
- | 642 | break; |
|
- | 643 | ||
- | 644 | case DT_END_COMMENT: |
|
- | 645 | ||
- | 646 | /* End comment if this char is a slash */ |
|
- | 647 | ||
- | 648 | switch (c) |
|
- | 649 | { |
|
- | 650 | case '/': |
|
- | 651 | State = DT_NORMAL_TEXT; |
|
- | 652 | break; |
|
- | 653 | ||
- | 654 | case '\n': |
|
- | 655 | CurrentLineOffset = Gbl_NextLineOffset; |
|
- | 656 | Gbl_NextLineOffset = (UINT32) ftell (Handle); |
|
- | 657 | Gbl_CurrentLineNumber++; |
|
- | 658 | break; |
|
- | 659 | ||
- | 660 | case '*': |
|
- | 661 | /* Consume all adjacent asterisks */ |
|
- | 662 | break; |
|
- | 663 | ||
- | 664 | default: |
|
- | 665 | State = DT_SLASH_ASTERISK_COMMENT; |
|
- | 666 | break; |
|
- | 667 | } |
|
- | 668 | break; |
|
- | 669 | ||
- | 670 | case DT_MERGE_LINES: |
|
- | 671 | ||
- | 672 | if (c != '\n') |
|
- | 673 | { |
|
- | 674 | /* |
|
- | 675 | * This is not a continuation backslash, it is a normal |
|
- | 676 | * normal ASL backslash - for example: Scope(\_SB_) |
|
- | 677 | */ |
|
- | 678 | i++; /* Keep the backslash that is already in the buffer */ |
|
- | 679 | ||
- | 680 | ungetc (c, Handle); |
|
- | 681 | State = DT_NORMAL_TEXT; |
|
- | 682 | } |
|
- | 683 | else |
|
- | 684 | { |
|
- | 685 | /* |
|
- | 686 | * This is a continuation line -- a backlash followed |
|
- | 687 | * immediately by a newline. Insert a space between the |
|
- | 688 | * lines (overwrite the backslash) |
|
- | 689 | */ |
|
- | 690 | Gbl_CurrentLineBuffer[i] = ' '; |
|
- | 691 | i++; |
|
- | 692 | ||
- | 693 | /* Ignore newline, this will merge the lines */ |
|
- | 694 | ||
- | 695 | CurrentLineOffset = Gbl_NextLineOffset; |
|
- | 696 | Gbl_NextLineOffset = (UINT32) ftell (Handle); |
|
- | 697 | Gbl_CurrentLineNumber++; |
|
- | 698 | State = DT_NORMAL_TEXT; |
|
- | 699 | } |
|
- | 700 | break; |
|
- | 701 | ||
- | 702 | default: |
|
- | 703 | DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, "Unknown input state"); |
|
- | 704 | return (ASL_EOF); |
|
- | 705 | } |
|
- | 706 | } |
|
- | 707 | ||
- | 708 | printf ("ERROR - Input line is too long (max %u)\n", ASL_LINE_BUFFER_SIZE); |
|
414 | } |
709 | return (ASL_EOF); |
Line 415... | Line 710... | ||
415 | } |
710 | } |
416 | 711 | ||
Line 421... | Line 716... | ||
421 | * |
716 | * |
422 | * PARAMETERS: Handle - Open file handle for the source file |
717 | * PARAMETERS: Handle - Open file handle for the source file |
423 | * |
718 | * |
424 | * RETURN: Pointer to start of the constructed parse tree. |
719 | * RETURN: Pointer to start of the constructed parse tree. |
425 | * |
720 | * |
426 | * DESCRIPTION: Scan source file, link all field name and value |
721 | * DESCRIPTION: Scan source file, link all field names and values |
427 | * to the global parse tree: Gbl_FieldList |
722 | * to the global parse tree: Gbl_FieldList |
428 | * |
723 | * |
429 | *****************************************************************************/ |
724 | *****************************************************************************/ |
Line 430... | Line 725... | ||
430 | 725 | ||
431 | DT_FIELD * |
726 | DT_FIELD * |
432 | DtScanFile ( |
727 | DtScanFile ( |
433 | FILE *Handle) |
728 | FILE *Handle) |
434 | { |
729 | { |
435 | UINT32 Line = 0; |
730 | ACPI_STATUS Status; |
- | 731 | UINT32 Offset; |
|
- | 732 | DT_FIELD *Next; |
|
- | 733 | ||
- | 734 | ||
Line 436... | Line 735... | ||
436 | UINT32 Offset = 0; |
735 | ACPI_FUNCTION_NAME (DtScanFile); |
Line 437... | Line 736... | ||
437 | 736 | ||
Line -... | Line 737... | ||
- | 737 | ||
- | 738 | /* Get the file size */ |
|
- | 739 | ||
- | 740 | Gbl_InputByteCount = DtGetFileSize (Handle); |
|
438 | 741 | ||
Line 439... | Line 742... | ||
439 | /* Get the file size */ |
742 | Gbl_CurrentLineNumber = 0; |
440 | 743 | Gbl_CurrentLineOffset = 0; |
|
441 | Gbl_InputByteCount = DtGetFileSize (Handle); |
- | |
442 | 744 | Gbl_NextLineOffset = 0; |
|
443 | /* Scan line-by-line */ |
745 | |
Line -... | Line 746... | ||
- | 746 | /* Scan line-by-line */ |
|
- | 747 | ||
- | 748 | while ((Offset = DtGetNextLine (Handle)) != ASL_EOF) |
|
- | 749 | { |
|
- | 750 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Line %2.2u/%4.4X - %s", |
|
- | 751 | Gbl_CurrentLineNumber, Offset, Gbl_CurrentLineBuffer)); |
|
- | 752 | ||
- | 753 | Status = DtParseLine (Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber, Offset); |
|
- | 754 | if (Status == AE_NOT_FOUND) |
|
- | 755 | { |
|
- | 756 | break; |
|
444 | 757 | } |
|
- | 758 | } |
|
- | 759 | ||
- | 760 | /* Dump the parse tree if debug enabled */ |
|
- | 761 | ||
- | 762 | if (Gbl_DebugFlag) |
|
- | 763 | { |
|
- | 764 | Next = Gbl_FieldList; |
|
- | 765 | DbgPrint (ASL_DEBUG_OUTPUT, "Tree: %32s %32s %8s %8s %8s %8s %8s %8s\n\n", |
|
- | 766 | "Name", "Value", "Line", "ByteOff", "NameCol", "Column", "TableOff", "Flags"); |
|
- | 767 | ||
- | 768 | while (Next) |
|
- | 769 | { |
|
- | 770 | DbgPrint (ASL_DEBUG_OUTPUT, "Field: %32.32s %32.32s %.8X %.8X %.8X %.8X %.8X %.8X\n", |
|
- | 771 | Next->Name, |
|
- | 772 | Next->Value, |
|
- | 773 | Next->Line, |
|
- | 774 | Next->ByteOffset, |
|
445 | while (fgets (Gbl_CurrentLineBuffer, ASL_LINE_BUFFER_SIZE, Handle)) |
775 | Next->NameColumn, |
Line 446... | Line 776... | ||
446 | { |
776 | Next->Column, |
447 | Line++; |
777 | Next->TableOffset, |
Line 448... | Line 778... | ||
448 | Gbl_CurrentLineNumber++; |
778 | Next->Flags); |
449 | DtParseLine (Gbl_CurrentLineBuffer, Line, Offset); |
779 | |
450 | 780 | Next = Next->Next; |
|
Line 451... | Line -... | ||
451 | Offset = (UINT32) ftell (Handle); |
- | |
452 | } |
781 | } |
453 | 782 | } |
|
454 | return (Gbl_FieldList); |
783 | |
455 | } |
784 | return (Gbl_FieldList); |
456 | 785 | } |
|
Line 508... | Line 837... | ||
508 | /* Walk the entire parse tree, emitting the binary data */ |
837 | /* Walk the entire parse tree, emitting the binary data */ |
Line 509... | Line 838... | ||
509 | 838 | ||
510 | DtWalkTableTree (RootTable, DtWriteBinary, NULL, NULL); |
839 | DtWalkTableTree (RootTable, DtWriteBinary, NULL, NULL); |
511 | Gbl_TableLength = DtGetFileSize (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); |
840 | Gbl_TableLength = DtGetFileSize (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); |
- | 841 | } |
|
- | 842 | ||
- | 843 | ||
- | 844 | /* |
|
- | 845 | * Listing support |
|
- | 846 | */ |
|
- | 847 | ||
- | 848 | /****************************************************************************** |
|
- | 849 | * |
|
- | 850 | * FUNCTION: DtDumpBuffer |
|
- | 851 | * |
|
- | 852 | * PARAMETERS: FileID - Where to write buffer data |
|
- | 853 | * Buffer - Buffer to dump |
|
- | 854 | * Offset - Offset in current table |
|
- | 855 | * Length - Buffer Length |
|
- | 856 | * |
|
- | 857 | * RETURN: None |
|
- | 858 | * |
|
- | 859 | * DESCRIPTION: Another copy of DumpBuffer routine (unfortunately). |
|
- | 860 | * |
|
- | 861 | * TBD: merge dump buffer routines |
|
- | 862 | * |
|
- | 863 | *****************************************************************************/ |
|
- | 864 | ||
- | 865 | static void |
|
- | 866 | DtDumpBuffer ( |
|
- | 867 | UINT32 FileId, |
|
- | 868 | UINT8 *Buffer, |
|
- | 869 | UINT32 Offset, |
|
- | 870 | UINT32 Length) |
|
- | 871 | { |
|
- | 872 | UINT32 i; |
|
- | 873 | UINT32 j; |
|
- | 874 | UINT8 BufChar; |
|
- | 875 | ||
- | 876 | ||
- | 877 | FlPrintFile (FileId, "Output: [%3.3Xh %4.4d %3d] ", |
|
- | 878 | Offset, Offset, Length); |
|
- | 879 | ||
- | 880 | i = 0; |
|
- | 881 | while (i < Length) |
|
- | 882 | { |
|
- | 883 | if (i >= 16) |
|
- | 884 | { |
|
- | 885 | FlPrintFile (FileId, "%24s", ""); |
|
- | 886 | } |
|
- | 887 | ||
- | 888 | /* Print 16 hex chars */ |
|
- | 889 | ||
- | 890 | for (j = 0; j < 16;) |
|
- | 891 | { |
|
- | 892 | if (i + j >= Length) |
|
- | 893 | { |
|
- | 894 | /* Dump fill spaces */ |
|
- | 895 | ||
- | 896 | FlPrintFile (FileId, " "); |
|
- | 897 | j++; |
|
- | 898 | continue; |
|
- | 899 | } |
|
- | 900 | ||
- | 901 | FlPrintFile (FileId, "%02X ", Buffer[i+j]); |
|
- | 902 | j++; |
|
- | 903 | } |
|
- | 904 | ||
- | 905 | FlPrintFile (FileId, " "); |
|
- | 906 | for (j = 0; j < 16; j++) |
|
- | 907 | { |
|
- | 908 | if (i + j >= Length) |
|
- | 909 | { |
|
- | 910 | FlPrintFile (FileId, "\n\n"); |
|
- | 911 | return; |
|
- | 912 | } |
|
- | 913 | ||
- | 914 | BufChar = Buffer[(ACPI_SIZE) i + j]; |
|
- | 915 | if (ACPI_IS_PRINT (BufChar)) |
|
- | 916 | { |
|
- | 917 | FlPrintFile (FileId, "%c", BufChar); |
|
- | 918 | } |
|
- | 919 | else |
|
- | 920 | { |
|
- | 921 | FlPrintFile (FileId, "."); |
|
- | 922 | } |
|
- | 923 | } |
|
- | 924 | ||
- | 925 | /* Done with that line. */ |
|
- | 926 | ||
- | 927 | FlPrintFile (FileId, "\n"); |
|
- | 928 | i += 16; |
|
- | 929 | } |
|
- | 930 | ||
- | 931 | FlPrintFile (FileId, "\n\n"); |
|
- | 932 | } |
|
- | 933 | ||
- | 934 | ||
- | 935 | /****************************************************************************** |
|
- | 936 | * |
|
- | 937 | * FUNCTION: DtWriteFieldToListing |
|
- | 938 | * |
|
- | 939 | * PARAMETERS: Buffer - Contains the compiled data |
|
- | 940 | * Field - Field node for the input line |
|
- | 941 | * Length - Length of the output data |
|
- | 942 | * |
|
- | 943 | * RETURN: None |
|
- | 944 | * |
|
- | 945 | * DESCRIPTION: Write one field to the listing file (if listing is enabled). |
|
- | 946 | * |
|
- | 947 | *****************************************************************************/ |
|
- | 948 | ||
- | 949 | void |
|
- | 950 | DtWriteFieldToListing ( |
|
- | 951 | UINT8 *Buffer, |
|
- | 952 | DT_FIELD *Field, |
|
- | 953 | UINT32 Length) |
|
- | 954 | { |
|
- | 955 | UINT8 FileByte; |
|
- | 956 | ||
- | 957 | ||
- | 958 | if (!Gbl_ListingFlag || !Field) |
|
- | 959 | { |
|
- | 960 | return; |
|
- | 961 | } |
|
- | 962 | ||
- | 963 | /* Dump the original source line */ |
|
- | 964 | ||
- | 965 | FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Input: "); |
|
- | 966 | FlSeekFile (ASL_FILE_INPUT, Field->ByteOffset); |
|
- | 967 | ||
- | 968 | while (FlReadFile (ASL_FILE_INPUT, &FileByte, 1) == AE_OK) |
|
- | 969 | { |
|
- | 970 | FlWriteFile (ASL_FILE_LISTING_OUTPUT, &FileByte, 1); |
|
- | 971 | if (FileByte == '\n') |
|
- | 972 | { |
|
- | 973 | break; |
|
- | 974 | } |
|
- | 975 | } |
|
- | 976 | ||
- | 977 | /* Dump the line as parsed and represented internally */ |
|
- | 978 | ||
- | 979 | FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Parsed: %*s : %.64s", |
|
- | 980 | Field->Column-4, Field->Name, Field->Value); |
|
- | 981 | ||
- | 982 | if (strlen (Field->Value) > 64) |
|
- | 983 | { |
|
- | 984 | FlPrintFile (ASL_FILE_LISTING_OUTPUT, "...Additional data, length 0x%X\n", |
|
- | 985 | strlen (Field->Value)); |
|
- | 986 | } |
|
- | 987 | FlPrintFile (ASL_FILE_LISTING_OUTPUT, "\n"); |
|
- | 988 | ||
- | 989 | /* Dump the hex data that will be output for this field */ |
|
- | 990 | ||
- | 991 | DtDumpBuffer (ASL_FILE_LISTING_OUTPUT, Buffer, Field->TableOffset, Length); |
|
- | 992 | } |
|
- | 993 | ||
- | 994 | ||
- | 995 | /****************************************************************************** |
|
- | 996 | * |
|
- | 997 | * FUNCTION: DtWriteTableToListing |
|
- | 998 | * |
|
- | 999 | * PARAMETERS: None |
|
- | 1000 | * |
|
- | 1001 | * RETURN: None |
|
- | 1002 | * |
|
- | 1003 | * DESCRIPTION: Write the entire compiled table to the listing file |
|
- | 1004 | * in hex format |
|
- | 1005 | * |
|
- | 1006 | *****************************************************************************/ |
|
- | 1007 | ||
- | 1008 | void |
|
- | 1009 | DtWriteTableToListing ( |
|
- | 1010 | void) |
|
- | 1011 | { |
|
- | 1012 | UINT8 *Buffer; |
|
- | 1013 | ||
- | 1014 | ||
- | 1015 | if (!Gbl_ListingFlag) |
|
- | 1016 | { |
|
- | 1017 | return; |
|
- | 1018 | } |
|
- | 1019 | ||
- | 1020 | /* Read the entire table from the output file */ |
|
- | 1021 | ||
- | 1022 | Buffer = UtLocalCalloc (Gbl_TableLength); |
|
- | 1023 | FlSeekFile (ASL_FILE_AML_OUTPUT, 0); |
|
- | 1024 | FlReadFile (ASL_FILE_AML_OUTPUT, Buffer, Gbl_TableLength); |
|
- | 1025 | ||
- | 1026 | /* Dump the raw table data */ |
|
- | 1027 | ||
- | 1028 | AcpiOsRedirectOutput (Gbl_Files[ASL_FILE_LISTING_OUTPUT].Handle); |
|
- | 1029 | ||
- | 1030 | AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n", |
|
- | 1031 | ACPI_RAW_TABLE_DATA_HEADER, Gbl_TableLength, Gbl_TableLength); |
|
- | 1032 | AcpiUtDumpBuffer2 (Buffer, Gbl_TableLength, DB_BYTE_DISPLAY); |
|
- | 1033 | ||
- | 1034 | AcpiOsRedirectOutput (stdout); |