1 /****************************************************************************** 2 * 3 * Module Name: aslfiles - File support functions 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2013, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44 #include "aslcompiler.h" 45 #include "acapps.h" 46 47 #define _COMPONENT ACPI_COMPILER 48 ACPI_MODULE_NAME ("aslfiles") 49 50 /* Local prototypes */ 51 52 FILE * 53 FlOpenIncludeWithPrefix ( 54 char *PrefixDir, 55 char *Filename); 56 57 58 #ifdef ACPI_OBSOLETE_FUNCTIONS 59 ACPI_STATUS 60 FlParseInputPathname ( 61 char *InputFilename); 62 #endif 63 64 65 /******************************************************************************* 66 * 67 * FUNCTION: FlSetLineNumber 68 * 69 * PARAMETERS: Op - Parse node for the LINE asl statement 70 * 71 * RETURN: None. 72 * 73 * DESCRIPTION: Set the current line number 74 * 75 ******************************************************************************/ 76 77 void 78 FlSetLineNumber ( 79 UINT32 LineNumber) 80 { 81 82 DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New line number %u (old %u)\n", 83 LineNumber, Gbl_LogicalLineNumber); 84 85 Gbl_CurrentLineNumber = LineNumber; 86 Gbl_LogicalLineNumber = LineNumber; 87 } 88 89 90 /******************************************************************************* 91 * 92 * FUNCTION: FlSetFilename 93 * 94 * PARAMETERS: Op - Parse node for the LINE asl statement 95 * 96 * RETURN: None. 97 * 98 * DESCRIPTION: Set the current filename 99 * 100 ******************************************************************************/ 101 102 void 103 FlSetFilename ( 104 char *Filename) 105 { 106 107 DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New filename %s (old %s)\n", 108 Filename, Gbl_Files[ASL_FILE_INPUT].Filename); 109 110 Gbl_Files[ASL_FILE_INPUT].Filename = Filename; 111 } 112 113 114 /******************************************************************************* 115 * 116 * FUNCTION: FlAddIncludeDirectory 117 * 118 * PARAMETERS: Dir - Directory pathname string 119 * 120 * RETURN: None 121 * 122 * DESCRIPTION: Add a directory the list of include prefix directories. 123 * 124 ******************************************************************************/ 125 126 void 127 FlAddIncludeDirectory ( 128 char *Dir) 129 { 130 ASL_INCLUDE_DIR *NewDir; 131 ASL_INCLUDE_DIR *NextDir; 132 ASL_INCLUDE_DIR *PrevDir = NULL; 133 UINT32 NeedsSeparator = 0; 134 size_t DirLength; 135 136 137 DirLength = strlen (Dir); 138 if (!DirLength) 139 { 140 return; 141 } 142 143 /* Make sure that the pathname ends with a path separator */ 144 145 if ((Dir[DirLength-1] != '/') && 146 (Dir[DirLength-1] != '\\')) 147 { 148 NeedsSeparator = 1; 149 } 150 151 NewDir = ACPI_ALLOCATE_ZEROED (sizeof (ASL_INCLUDE_DIR)); 152 NewDir->Dir = ACPI_ALLOCATE (DirLength + 1 + NeedsSeparator); 153 strcpy (NewDir->Dir, Dir); 154 if (NeedsSeparator) 155 { 156 strcat (NewDir->Dir, "/"); 157 } 158 159 /* 160 * Preserve command line ordering of -I options by adding new elements 161 * at the end of the list 162 */ 163 NextDir = Gbl_IncludeDirList; 164 while (NextDir) 165 { 166 PrevDir = NextDir; 167 NextDir = NextDir->Next; 168 } 169 170 if (PrevDir) 171 { 172 PrevDir->Next = NewDir; 173 } 174 else 175 { 176 Gbl_IncludeDirList = NewDir; 177 } 178 } 179 180 181 /******************************************************************************* 182 * 183 * FUNCTION: FlMergePathnames 184 * 185 * PARAMETERS: PrefixDir - Prefix directory pathname. Can be NULL or 186 * a zero length string. 187 * FilePathname - The include filename from the source ASL. 188 * 189 * RETURN: Merged pathname string 190 * 191 * DESCRIPTION: Merge two pathnames that (probably) have common elements, to 192 * arrive at a minimal length string. Merge can occur if the 193 * FilePathname is relative to the PrefixDir. 194 * 195 ******************************************************************************/ 196 197 char * 198 FlMergePathnames ( 199 char *PrefixDir, 200 char *FilePathname) 201 { 202 char *CommonPath; 203 char *Pathname; 204 char *LastElement; 205 206 207 DbgPrint (ASL_PARSE_OUTPUT, "Include: Prefix path - \"%s\"\n" 208 "Include: FilePathname - \"%s\"\n", 209 PrefixDir, FilePathname); 210 211 /* 212 * If there is no prefix directory or if the file pathname is absolute, 213 * just return the original file pathname 214 */ 215 if (!PrefixDir || (!*PrefixDir) || 216 (*FilePathname == '/') || 217 (FilePathname[1] == ':')) 218 { 219 Pathname = ACPI_ALLOCATE (strlen (FilePathname) + 1); 220 strcpy (Pathname, FilePathname); 221 goto ConvertBackslashes; 222 } 223 224 /* Need a local copy of the prefix directory path */ 225 226 CommonPath = ACPI_ALLOCATE (strlen (PrefixDir) + 1); 227 strcpy (CommonPath, PrefixDir); 228 229 /* 230 * Walk forward through the file path, and simultaneously backward 231 * through the prefix directory path until there are no more 232 * relative references at the start of the file path. 233 */ 234 while (*FilePathname && (!strncmp (FilePathname, "../", 3))) 235 { 236 /* Remove last element of the prefix directory path */ 237 238 LastElement = strrchr (CommonPath, '/'); 239 if (!LastElement) 240 { 241 goto ConcatenatePaths; 242 } 243 244 *LastElement = 0; /* Terminate CommonPath string */ 245 FilePathname += 3; /* Point to next path element */ 246 } 247 248 /* 249 * Remove the last element of the prefix directory path (it is the same as 250 * the first element of the file pathname), and build the final merged 251 * pathname. 252 */ 253 LastElement = strrchr (CommonPath, '/'); 254 if (LastElement) 255 { 256 *LastElement = 0; 257 } 258 259 /* Build the final merged pathname */ 260 261 ConcatenatePaths: 262 Pathname = ACPI_ALLOCATE_ZEROED (strlen (CommonPath) + strlen (FilePathname) + 2); 263 if (LastElement && *CommonPath) 264 { 265 strcpy (Pathname, CommonPath); 266 strcat (Pathname, "/"); 267 } 268 strcat (Pathname, FilePathname); 269 ACPI_FREE (CommonPath); 270 271 /* Convert all backslashes to normal slashes */ 272 273 ConvertBackslashes: 274 UtConvertBackslashes (Pathname); 275 276 DbgPrint (ASL_PARSE_OUTPUT, "Include: Merged Pathname - \"%s\"\n", 277 Pathname); 278 return (Pathname); 279 } 280 281 282 /******************************************************************************* 283 * 284 * FUNCTION: FlOpenIncludeWithPrefix 285 * 286 * PARAMETERS: PrefixDir - Prefix directory pathname. Can be a zero 287 * length string. 288 * Filename - The include filename from the source ASL. 289 * 290 * RETURN: Valid file descriptor if successful. Null otherwise. 291 * 292 * DESCRIPTION: Open an include file and push it on the input file stack. 293 * 294 ******************************************************************************/ 295 296 FILE * 297 FlOpenIncludeWithPrefix ( 298 char *PrefixDir, 299 char *Filename) 300 { 301 FILE *IncludeFile; 302 char *Pathname; 303 304 305 /* Build the full pathname to the file */ 306 307 Pathname = FlMergePathnames (PrefixDir, Filename); 308 309 DbgPrint (ASL_PARSE_OUTPUT, "Include: Opening file - \"%s\"\n\n", 310 Pathname); 311 312 /* Attempt to open the file, push if successful */ 313 314 IncludeFile = fopen (Pathname, "r"); 315 if (!IncludeFile) 316 { 317 fprintf (stderr, "Could not open include file %s\n", Pathname); 318 ACPI_FREE (Pathname); 319 return (NULL); 320 } 321 322 /* Push the include file on the open input file stack */ 323 324 AslPushInputFileStack (IncludeFile, Pathname); 325 return (IncludeFile); 326 } 327 328 329 /******************************************************************************* 330 * 331 * FUNCTION: FlOpenIncludeFile 332 * 333 * PARAMETERS: Op - Parse node for the INCLUDE ASL statement 334 * 335 * RETURN: None. 336 * 337 * DESCRIPTION: Open an include file and push it on the input file stack. 338 * 339 ******************************************************************************/ 340 341 void 342 FlOpenIncludeFile ( 343 ACPI_PARSE_OBJECT *Op) 344 { 345 FILE *IncludeFile; 346 ASL_INCLUDE_DIR *NextDir; 347 348 349 /* Op must be valid */ 350 351 if (!Op) 352 { 353 AslCommonError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, 354 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 355 Gbl_InputByteCount, Gbl_CurrentColumn, 356 Gbl_Files[ASL_FILE_INPUT].Filename, " - Null parse node"); 357 358 return; 359 } 360 361 /* 362 * Flush out the "include ()" statement on this line, start 363 * the actual include file on the next line 364 */ 365 AslResetCurrentLineBuffer (); 366 FlPrintFile (ASL_FILE_SOURCE_OUTPUT, "\n"); 367 Gbl_CurrentLineOffset++; 368 369 370 /* Attempt to open the include file */ 371 372 /* If the file specifies an absolute path, just open it */ 373 374 if ((Op->Asl.Value.String[0] == '/') || 375 (Op->Asl.Value.String[0] == '\\') || 376 (Op->Asl.Value.String[1] == ':')) 377 { 378 IncludeFile = FlOpenIncludeWithPrefix ("", Op->Asl.Value.String); 379 if (!IncludeFile) 380 { 381 goto ErrorExit; 382 } 383 return; 384 } 385 386 /* 387 * The include filename is not an absolute path. 388 * 389 * First, search for the file within the "local" directory -- meaning 390 * the same directory that contains the source file. 391 * 392 * Construct the file pathname from the global directory name. 393 */ 394 IncludeFile = FlOpenIncludeWithPrefix (Gbl_DirectoryPath, Op->Asl.Value.String); 395 if (IncludeFile) 396 { 397 return; 398 } 399 400 /* 401 * Second, search for the file within the (possibly multiple) directories 402 * specified by the -I option on the command line. 403 */ 404 NextDir = Gbl_IncludeDirList; 405 while (NextDir) 406 { 407 IncludeFile = FlOpenIncludeWithPrefix (NextDir->Dir, Op->Asl.Value.String); 408 if (IncludeFile) 409 { 410 return; 411 } 412 413 NextDir = NextDir->Next; 414 } 415 416 /* We could not open the include file after trying very hard */ 417 418 ErrorExit: 419 sprintf (MsgBuffer, "%s, %s", Op->Asl.Value.String, strerror (errno)); 420 AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, MsgBuffer); 421 } 422 423 424 /******************************************************************************* 425 * 426 * FUNCTION: FlOpenInputFile 427 * 428 * PARAMETERS: InputFilename - The user-specified ASL source file to be 429 * compiled 430 * 431 * RETURN: Status 432 * 433 * DESCRIPTION: Open the specified input file, and save the directory path to 434 * the file so that include files can be opened in 435 * the same directory. 436 * 437 ******************************************************************************/ 438 439 ACPI_STATUS 440 FlOpenInputFile ( 441 char *InputFilename) 442 { 443 444 /* Open the input ASL file, text mode */ 445 446 FlOpenFile (ASL_FILE_INPUT, InputFilename, "rt"); 447 AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle; 448 449 return (AE_OK); 450 } 451 452 453 /******************************************************************************* 454 * 455 * FUNCTION: FlOpenAmlOutputFile 456 * 457 * PARAMETERS: FilenamePrefix - The user-specified ASL source file 458 * 459 * RETURN: Status 460 * 461 * DESCRIPTION: Create the output filename (*.AML) and open the file. The file 462 * is created in the same directory as the parent input file. 463 * 464 ******************************************************************************/ 465 466 ACPI_STATUS 467 FlOpenAmlOutputFile ( 468 char *FilenamePrefix) 469 { 470 char *Filename; 471 472 473 /* Output filename usually comes from the ASL itself */ 474 475 Filename = Gbl_Files[ASL_FILE_AML_OUTPUT].Filename; 476 if (!Filename) 477 { 478 /* Create the output AML filename */ 479 480 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE); 481 if (!Filename) 482 { 483 AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME, 484 0, 0, 0, 0, NULL, NULL); 485 return (AE_ERROR); 486 } 487 } 488 489 /* Open the output AML file in binary mode */ 490 491 FlOpenFile (ASL_FILE_AML_OUTPUT, Filename, "w+b"); 492 return (AE_OK); 493 } 494 495 496 /******************************************************************************* 497 * 498 * FUNCTION: FlOpenMiscOutputFiles 499 * 500 * PARAMETERS: FilenamePrefix - The user-specified ASL source file 501 * 502 * RETURN: Status 503 * 504 * DESCRIPTION: Create and open the various output files needed, depending on 505 * the command line options 506 * 507 ******************************************************************************/ 508 509 ACPI_STATUS 510 FlOpenMiscOutputFiles ( 511 char *FilenamePrefix) 512 { 513 char *Filename; 514 515 516 /* All done for disassembler */ 517 518 if (Gbl_FileType == ASL_INPUT_TYPE_ACPI_TABLE) 519 { 520 return (AE_OK); 521 } 522 523 /* Create/Open a hex output file if asked */ 524 525 if (Gbl_HexOutputFlag) 526 { 527 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP); 528 if (!Filename) 529 { 530 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 531 0, 0, 0, 0, NULL, NULL); 532 return (AE_ERROR); 533 } 534 535 /* Open the hex file, text mode */ 536 537 FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+t"); 538 539 AslCompilerSignon (ASL_FILE_HEX_OUTPUT); 540 AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT); 541 } 542 543 /* Create/Open a debug output file if asked */ 544 545 if (Gbl_DebugFlag) 546 { 547 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG); 548 if (!Filename) 549 { 550 AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME, 551 0, 0, 0, 0, NULL, NULL); 552 return (AE_ERROR); 553 } 554 555 /* Open the debug file as STDERR, text mode */ 556 557 /* TBD: hide this behind a FlReopenFile function */ 558 559 Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename; 560 Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle = 561 freopen (Filename, "w+t", stderr); 562 563 if (!Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle) 564 { 565 AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME, 566 0, 0, 0, 0, NULL, NULL); 567 return (AE_ERROR); 568 } 569 570 AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT); 571 AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT); 572 } 573 574 /* Create/Open a listing output file if asked */ 575 576 if (Gbl_ListingFlag) 577 { 578 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_LISTING); 579 if (!Filename) 580 { 581 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 582 0, 0, 0, 0, NULL, NULL); 583 return (AE_ERROR); 584 } 585 586 /* Open the listing file, text mode */ 587 588 FlOpenFile (ASL_FILE_LISTING_OUTPUT, Filename, "w+t"); 589 590 AslCompilerSignon (ASL_FILE_LISTING_OUTPUT); 591 AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT); 592 } 593 594 /* Create the preprocessor output file if preprocessor enabled */ 595 596 if (Gbl_PreprocessFlag) 597 { 598 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROCESSOR); 599 if (!Filename) 600 { 601 AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME, 602 0, 0, 0, 0, NULL, NULL); 603 return (AE_ERROR); 604 } 605 606 FlOpenFile (ASL_FILE_PREPROCESSOR, Filename, "w+t"); 607 } 608 609 /* All done for data table compiler */ 610 611 if (Gbl_FileType == ASL_INPUT_TYPE_ASCII_DATA) 612 { 613 return (AE_OK); 614 } 615 616 /* Create/Open a combined source output file */ 617 618 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE); 619 if (!Filename) 620 { 621 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 622 0, 0, 0, 0, NULL, NULL); 623 return (AE_ERROR); 624 } 625 626 /* 627 * Open the source output file, binary mode (so that LF does not get 628 * expanded to CR/LF on some systems, messing up our seek 629 * calculations.) 630 */ 631 FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+b"); 632 633 /* 634 // TBD: TEMP 635 // AslCompilerin = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle; 636 */ 637 /* Create/Open a assembly code source output file if asked */ 638 639 if (Gbl_AsmOutputFlag) 640 { 641 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_SOURCE); 642 if (!Filename) 643 { 644 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 645 0, 0, 0, 0, NULL, NULL); 646 return (AE_ERROR); 647 } 648 649 /* Open the assembly code source file, text mode */ 650 651 FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT, Filename, "w+t"); 652 653 AslCompilerSignon (ASL_FILE_ASM_SOURCE_OUTPUT); 654 AslCompilerFileHeader (ASL_FILE_ASM_SOURCE_OUTPUT); 655 } 656 657 /* Create/Open a C code source output file if asked */ 658 659 if (Gbl_C_OutputFlag) 660 { 661 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_SOURCE); 662 if (!Filename) 663 { 664 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 665 0, 0, 0, 0, NULL, NULL); 666 return (AE_ERROR); 667 } 668 669 /* Open the C code source file, text mode */ 670 671 FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT, Filename, "w+t"); 672 673 FlPrintFile (ASL_FILE_C_SOURCE_OUTPUT, "/*\n"); 674 AslCompilerSignon (ASL_FILE_C_SOURCE_OUTPUT); 675 AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT); 676 } 677 678 /* Create/Open a C code source output file for the offset table if asked */ 679 680 if (Gbl_C_OffsetTableFlag) 681 { 682 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_OFFSET); 683 if (!Filename) 684 { 685 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 686 0, 0, 0, 0, NULL, NULL); 687 return (AE_ERROR); 688 } 689 690 /* Open the C code source file, text mode */ 691 692 FlOpenFile (ASL_FILE_C_OFFSET_OUTPUT, Filename, "w+t"); 693 694 FlPrintFile (ASL_FILE_C_OFFSET_OUTPUT, "/*\n"); 695 AslCompilerSignon (ASL_FILE_C_OFFSET_OUTPUT); 696 AslCompilerFileHeader (ASL_FILE_C_OFFSET_OUTPUT); 697 } 698 699 /* Create/Open a assembly include output file if asked */ 700 701 if (Gbl_AsmIncludeOutputFlag) 702 { 703 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_INCLUDE); 704 if (!Filename) 705 { 706 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 707 0, 0, 0, 0, NULL, NULL); 708 return (AE_ERROR); 709 } 710 711 /* Open the assembly include file, text mode */ 712 713 FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT, Filename, "w+t"); 714 715 AslCompilerSignon (ASL_FILE_ASM_INCLUDE_OUTPUT); 716 AslCompilerFileHeader (ASL_FILE_ASM_INCLUDE_OUTPUT); 717 } 718 719 /* Create/Open a C include output file if asked */ 720 721 if (Gbl_C_IncludeOutputFlag) 722 { 723 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_INCLUDE); 724 if (!Filename) 725 { 726 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 727 0, 0, 0, 0, NULL, NULL); 728 return (AE_ERROR); 729 } 730 731 /* Open the C include file, text mode */ 732 733 FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT, Filename, "w+t"); 734 735 FlPrintFile (ASL_FILE_C_INCLUDE_OUTPUT, "/*\n"); 736 AslCompilerSignon (ASL_FILE_C_INCLUDE_OUTPUT); 737 AslCompilerFileHeader (ASL_FILE_C_INCLUDE_OUTPUT); 738 } 739 740 /* Create a namespace output file if asked */ 741 742 if (Gbl_NsOutputFlag) 743 { 744 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_NAMESPACE); 745 if (!Filename) 746 { 747 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 748 0, 0, 0, 0, NULL, NULL); 749 return (AE_ERROR); 750 } 751 752 /* Open the namespace file, text mode */ 753 754 FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT, Filename, "w+t"); 755 756 AslCompilerSignon (ASL_FILE_NAMESPACE_OUTPUT); 757 AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT); 758 } 759 760 return (AE_OK); 761 } 762 763 764 #ifdef ACPI_OBSOLETE_FUNCTIONS 765 /******************************************************************************* 766 * 767 * FUNCTION: FlParseInputPathname 768 * 769 * PARAMETERS: InputFilename - The user-specified ASL source file to be 770 * compiled 771 * 772 * RETURN: Status 773 * 774 * DESCRIPTION: Split the input path into a directory and filename part 775 * 1) Directory part used to open include files 776 * 2) Filename part used to generate output filenames 777 * 778 ******************************************************************************/ 779 780 ACPI_STATUS 781 FlParseInputPathname ( 782 char *InputFilename) 783 { 784 char *Substring; 785 786 787 if (!InputFilename) 788 { 789 return (AE_OK); 790 } 791 792 /* Get the path to the input filename's directory */ 793 794 Gbl_DirectoryPath = strdup (InputFilename); 795 if (!Gbl_DirectoryPath) 796 { 797 return (AE_NO_MEMORY); 798 } 799 800 Substring = strrchr (Gbl_DirectoryPath, '\\'); 801 if (!Substring) 802 { 803 Substring = strrchr (Gbl_DirectoryPath, '/'); 804 if (!Substring) 805 { 806 Substring = strrchr (Gbl_DirectoryPath, ':'); 807 } 808 } 809 810 if (!Substring) 811 { 812 Gbl_DirectoryPath[0] = 0; 813 if (Gbl_UseDefaultAmlFilename) 814 { 815 Gbl_OutputFilenamePrefix = strdup (InputFilename); 816 } 817 } 818 else 819 { 820 if (Gbl_UseDefaultAmlFilename) 821 { 822 Gbl_OutputFilenamePrefix = strdup (Substring + 1); 823 } 824 *(Substring+1) = 0; 825 } 826 827 UtConvertBackslashes (Gbl_OutputFilenamePrefix); 828 return (AE_OK); 829 } 830 #endif