1/****************************************************************************** 2 * 3 * Module Name: dtio.c - File I/O support for data table compiler 4 * 5 *****************************************************************************/ 6 7/* 8 * Copyright (C) 2000 - 2011, Intel Corp. --- 52 unchanged lines hidden (view full) --- 61 DT_FIELD *Field); 62 63static ACPI_STATUS 64DtParseLine ( 65 char *LineBuffer, 66 UINT32 Line, 67 UINT32 Offset); 68 |
69UINT32 |
70DtGetNextLine ( 71 FILE *Handle); 72 73static void 74DtWriteBinary ( 75 DT_SUBTABLE *Subtable, 76 void *Context, 77 void *ReturnValue); 78 79static void 80DtDumpBuffer ( 81 UINT32 FileId, 82 UINT8 *Buffer, |
83 UINT32 Offset, |
84 UINT32 Length); 85 |
86 |
87/* States for DtGetNextLine */ 88 89#define DT_NORMAL_TEXT 0 90#define DT_START_QUOTED_STRING 1 91#define DT_START_COMMENT 2 92#define DT_SLASH_ASTERISK_COMMENT 3 93#define DT_SLASH_SLASH_COMMENT 4 94#define DT_END_COMMENT 5 --- 226 unchanged lines hidden (view full) --- 321 322 while (*End) 323 { 324 /* Found left quotation, go to the right quotation and break */ 325 326 if (*End == '"') 327 { 328 End++; |
329 while (*End && (*End != '"')) |
330 { 331 End++; 332 } 333 334 End++; 335 break; 336 } 337 |
338 /* 339 * Special "comment" fields at line end, ignore them. 340 * Note: normal slash-slash and slash-asterisk comments are 341 * stripped already by the DtGetNextLine parser. 342 * 343 * TBD: Perhaps DtGetNextLine should parse the following type 344 * of comments also. 345 */ |
346 if (*End == '(' || |
347 *End == '<') |
348 { 349 break; 350 } 351 352 End++; 353 } 354 355 Length = ACPI_PTR_DIFF (End, Start); --- 33 unchanged lines hidden (view full) --- 389 * Handles both slash-asterisk and slash-slash comments. 390 * Also, quoted strings, but no escapes within. 391 * 392 * Line is returned in Gbl_CurrentLineBuffer. 393 * Line number in original file is returned in Gbl_CurrentLineNumber. 394 * 395 *****************************************************************************/ 396 |
397UINT32 |
398DtGetNextLine ( 399 FILE *Handle) 400{ 401 UINT32 State = DT_NORMAL_TEXT; 402 UINT32 CurrentLineOffset; 403 UINT32 i; 404 char c; 405 406 407 for (i = 0; i < ASL_LINE_BUFFER_SIZE;) 408 { 409 c = (char) getc (Handle); 410 if (c == EOF) 411 { |
412 switch (State) 413 { 414 case DT_START_QUOTED_STRING: 415 case DT_SLASH_ASTERISK_COMMENT: 416 case DT_SLASH_SLASH_COMMENT: 417 418 AcpiOsPrintf ("**** EOF within comment/string %u\n", State); 419 break; 420 421 default: 422 break; 423 } 424 |
425 return (0); 426 } 427 428 switch (State) 429 { 430 case DT_NORMAL_TEXT: 431 432 /* Normal text, insert char into line buffer */ --- 104 unchanged lines hidden (view full) --- 537 /* End comment if this char is a slash */ 538 539 switch (c) 540 { 541 case '/': 542 State = DT_NORMAL_TEXT; 543 break; 544 |
545 case '\n': 546 CurrentLineOffset = Gbl_NextLineOffset; 547 Gbl_NextLineOffset = (UINT32) ftell (Handle); 548 Gbl_CurrentLineNumber++; 549 break; 550 551 case '*': 552 /* Consume all adjacent asterisks */ 553 break; 554 |
555 default: 556 State = DT_SLASH_ASTERISK_COMMENT; 557 break; 558 } 559 break; 560 561 default: 562 DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, "Unknown input state"); --- 117 unchanged lines hidden (view full) --- 680 */ 681 682/****************************************************************************** 683 * 684 * FUNCTION: DtDumpBuffer 685 * 686 * PARAMETERS: FileID - Where to write buffer data 687 * Buffer - Buffer to dump |
688 * Offset - Offset in current table |
689 * Length - Buffer Length 690 * 691 * RETURN: None 692 * 693 * DESCRIPTION: Another copy of DumpBuffer routine (unfortunately). 694 * 695 * TBD: merge dump buffer routines 696 * 697 *****************************************************************************/ 698 699static void 700DtDumpBuffer ( 701 UINT32 FileId, 702 UINT8 *Buffer, |
703 UINT32 Offset, |
704 UINT32 Length) 705{ 706 UINT32 i; 707 UINT32 j; 708 UINT8 BufChar; 709 710 |
711 FlPrintFile (FileId, "Output: [%3.3Xh %4.4d% 3d] ", 712 Offset, Offset, Length); 713 |
714 i = 0; 715 while (i < Length) 716 { |
717 if (i >= 16) 718 { 719 FlPrintFile (FileId, "%23s", ""); 720 } 721 |
722 /* Print 16 hex chars */ 723 |
724 for (j = 0; j < 16;) 725 { 726 if (i + j >= Length) 727 { 728 /* Dump fill spaces */ 729 730 FlPrintFile (FileId, " "); 731 j++; --- 76 unchanged lines hidden (view full) --- 808 } 809 } 810 811 /* Dump the line as parsed and represented internally */ 812 813 FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Parsed: %*s : %s\n", 814 Field->Column-4, Field->Name, Field->Value); 815 |
816 /* Dump the hex data that will be output for this field */ 817 |
818 DtDumpBuffer (ASL_FILE_LISTING_OUTPUT, Buffer, Field->TableOffset, Length); |
819} 820 821 822/****************************************************************************** 823 * 824 * FUNCTION: DtWriteTableToListing 825 * 826 * PARAMETERS: None --- 36 unchanged lines hidden --- |