1a9f12690SJung-uk Kim 2a9f12690SJung-uk Kim /****************************************************************************** 3a9f12690SJung-uk Kim * 4a9f12690SJung-uk Kim * Module Name: aslstartup - Compiler startup routines, called from main 5a9f12690SJung-uk Kim * 6a9f12690SJung-uk Kim *****************************************************************************/ 7a9f12690SJung-uk Kim 8*d244b227SJung-uk Kim /* 9*d244b227SJung-uk Kim * Copyright (C) 2000 - 2011, Intel Corp. 10a9f12690SJung-uk Kim * All rights reserved. 11a9f12690SJung-uk Kim * 12*d244b227SJung-uk Kim * Redistribution and use in source and binary forms, with or without 13*d244b227SJung-uk Kim * modification, are permitted provided that the following conditions 14*d244b227SJung-uk Kim * are met: 15*d244b227SJung-uk Kim * 1. Redistributions of source code must retain the above copyright 16*d244b227SJung-uk Kim * notice, this list of conditions, and the following disclaimer, 17*d244b227SJung-uk Kim * without modification. 18*d244b227SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 19*d244b227SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 20*d244b227SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 21*d244b227SJung-uk Kim * including a substantially similar Disclaimer requirement for further 22*d244b227SJung-uk Kim * binary redistribution. 23*d244b227SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 24*d244b227SJung-uk Kim * of any contributors may be used to endorse or promote products derived 25*d244b227SJung-uk Kim * from this software without specific prior written permission. 26a9f12690SJung-uk Kim * 27*d244b227SJung-uk Kim * Alternatively, this software may be distributed under the terms of the 28*d244b227SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 29*d244b227SJung-uk Kim * Software Foundation. 30a9f12690SJung-uk Kim * 31*d244b227SJung-uk Kim * NO WARRANTY 32*d244b227SJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33*d244b227SJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34*d244b227SJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 35*d244b227SJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36*d244b227SJung-uk Kim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37*d244b227SJung-uk Kim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38*d244b227SJung-uk Kim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39*d244b227SJung-uk Kim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40*d244b227SJung-uk Kim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 41*d244b227SJung-uk Kim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42*d244b227SJung-uk Kim * POSSIBILITY OF SUCH DAMAGES. 43*d244b227SJung-uk Kim */ 44a9f12690SJung-uk Kim 45a9f12690SJung-uk Kim 46ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 47ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/actables.h> 48ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acapps.h> 49a9f12690SJung-uk Kim 50a9f12690SJung-uk Kim #define _COMPONENT ACPI_COMPILER 51a9f12690SJung-uk Kim ACPI_MODULE_NAME ("aslstartup") 52a9f12690SJung-uk Kim 53a9f12690SJung-uk Kim 54a9f12690SJung-uk Kim #define ASL_MAX_FILES 256 5542fecd12SJung-uk Kim static char *FileList[ASL_MAX_FILES]; 5642fecd12SJung-uk Kim static BOOLEAN AslToFile = TRUE; 57a9f12690SJung-uk Kim 58a9f12690SJung-uk Kim 59a9f12690SJung-uk Kim /* Local prototypes */ 60a9f12690SJung-uk Kim 61a9f12690SJung-uk Kim static char ** 62a9f12690SJung-uk Kim AsDoWildcard ( 63a9f12690SJung-uk Kim char *DirectoryPathname, 64a9f12690SJung-uk Kim char *FileSpecifier); 65a9f12690SJung-uk Kim 6642fecd12SJung-uk Kim static UINT8 67a88e22b7SJung-uk Kim AslDetectSourceFileType ( 68a88e22b7SJung-uk Kim ASL_FILE_INFO *Info); 69a88e22b7SJung-uk Kim 70a9f12690SJung-uk Kim 71a9f12690SJung-uk Kim /******************************************************************************* 72a9f12690SJung-uk Kim * 73a9f12690SJung-uk Kim * FUNCTION: AslInitializeGlobals 74a9f12690SJung-uk Kim * 75a9f12690SJung-uk Kim * PARAMETERS: None 76a9f12690SJung-uk Kim * 77a9f12690SJung-uk Kim * RETURN: None 78a9f12690SJung-uk Kim * 79a9f12690SJung-uk Kim * DESCRIPTION: Re-initialize globals needed to restart the compiler. This 80a9f12690SJung-uk Kim * allows multiple files to be disassembled and/or compiled. 81a9f12690SJung-uk Kim * 82a9f12690SJung-uk Kim ******************************************************************************/ 83a9f12690SJung-uk Kim 84a88e22b7SJung-uk Kim void 85a9f12690SJung-uk Kim AslInitializeGlobals ( 86a9f12690SJung-uk Kim void) 87a9f12690SJung-uk Kim { 88a9f12690SJung-uk Kim UINT32 i; 89a9f12690SJung-uk Kim 90a9f12690SJung-uk Kim 91a9f12690SJung-uk Kim /* Init compiler globals */ 92a9f12690SJung-uk Kim 93a9f12690SJung-uk Kim Gbl_CurrentColumn = 0; 94a9f12690SJung-uk Kim Gbl_CurrentLineNumber = 1; 95a9f12690SJung-uk Kim Gbl_LogicalLineNumber = 1; 96a9f12690SJung-uk Kim Gbl_CurrentLineOffset = 0; 97a88e22b7SJung-uk Kim Gbl_InputFieldCount = 0; 98a9f12690SJung-uk Kim Gbl_LineBufPtr = Gbl_CurrentLineBuffer; 99a9f12690SJung-uk Kim 100a9f12690SJung-uk Kim Gbl_ErrorLog = NULL; 101a9f12690SJung-uk Kim Gbl_NextError = NULL; 102a88e22b7SJung-uk Kim Gbl_Signature = NULL; 103a88e22b7SJung-uk Kim Gbl_FileType = 0; 104a9f12690SJung-uk Kim 105a9f12690SJung-uk Kim AslGbl_NextEvent = 0; 106a9f12690SJung-uk Kim for (i = 0; i < ASL_NUM_REPORT_LEVELS; i++) 107a9f12690SJung-uk Kim { 108a9f12690SJung-uk Kim Gbl_ExceptionCount[i] = 0; 109a9f12690SJung-uk Kim } 110a9f12690SJung-uk Kim 111a9f12690SJung-uk Kim Gbl_Files[ASL_FILE_AML_OUTPUT].Filename = NULL; 112a88e22b7SJung-uk Kim Gbl_Files[ASL_FILE_AML_OUTPUT].Handle = NULL; 113a88e22b7SJung-uk Kim 114a88e22b7SJung-uk Kim Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename = NULL; 115a88e22b7SJung-uk Kim Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle = NULL; 116a9f12690SJung-uk Kim } 117a9f12690SJung-uk Kim 118a9f12690SJung-uk Kim 119a9f12690SJung-uk Kim /****************************************************************************** 120a9f12690SJung-uk Kim * 121a9f12690SJung-uk Kim * FUNCTION: AsDoWildcard 122a9f12690SJung-uk Kim * 123a9f12690SJung-uk Kim * PARAMETERS: None 124a9f12690SJung-uk Kim * 125a9f12690SJung-uk Kim * RETURN: None 126a9f12690SJung-uk Kim * 127a9f12690SJung-uk Kim * DESCRIPTION: Process files via wildcards. This function is for the Windows 128a9f12690SJung-uk Kim * case only. 129a9f12690SJung-uk Kim * 130a9f12690SJung-uk Kim ******************************************************************************/ 131a9f12690SJung-uk Kim 132a9f12690SJung-uk Kim static char ** 133a9f12690SJung-uk Kim AsDoWildcard ( 134a9f12690SJung-uk Kim char *DirectoryPathname, 135a9f12690SJung-uk Kim char *FileSpecifier) 136a9f12690SJung-uk Kim { 137a9f12690SJung-uk Kim #ifdef WIN32 138a9f12690SJung-uk Kim void *DirInfo; 139a9f12690SJung-uk Kim char *Filename; 14042fecd12SJung-uk Kim int FileCount; 141a9f12690SJung-uk Kim 142a9f12690SJung-uk Kim 143a9f12690SJung-uk Kim FileCount = 0; 144a9f12690SJung-uk Kim 145a9f12690SJung-uk Kim /* Open parent directory */ 146a9f12690SJung-uk Kim 147a9f12690SJung-uk Kim DirInfo = AcpiOsOpenDirectory (DirectoryPathname, FileSpecifier, REQUEST_FILE_ONLY); 148a9f12690SJung-uk Kim if (!DirInfo) 149a9f12690SJung-uk Kim { 150a9f12690SJung-uk Kim /* Either the directory of file does not exist */ 151a9f12690SJung-uk Kim 152a9f12690SJung-uk Kim Gbl_Files[ASL_FILE_INPUT].Filename = FileSpecifier; 153a9f12690SJung-uk Kim FlFileError (ASL_FILE_INPUT, ASL_MSG_OPEN); 154a9f12690SJung-uk Kim AslAbort (); 155a9f12690SJung-uk Kim } 156a9f12690SJung-uk Kim 157a9f12690SJung-uk Kim /* Process each file that matches the wildcard specification */ 158a9f12690SJung-uk Kim 159a9f12690SJung-uk Kim while ((Filename = AcpiOsGetNextFilename (DirInfo))) 160a9f12690SJung-uk Kim { 161a9f12690SJung-uk Kim /* Add the filename to the file list */ 162a9f12690SJung-uk Kim 163a9f12690SJung-uk Kim FileList[FileCount] = AcpiOsAllocate (strlen (Filename) + 1); 164a9f12690SJung-uk Kim strcpy (FileList[FileCount], Filename); 165a9f12690SJung-uk Kim FileCount++; 166a9f12690SJung-uk Kim 167a9f12690SJung-uk Kim if (FileCount >= ASL_MAX_FILES) 168a9f12690SJung-uk Kim { 169a9f12690SJung-uk Kim printf ("Max files reached\n"); 170a9f12690SJung-uk Kim FileList[0] = NULL; 171a9f12690SJung-uk Kim return (FileList); 172a9f12690SJung-uk Kim } 173a9f12690SJung-uk Kim } 174a9f12690SJung-uk Kim 175a9f12690SJung-uk Kim /* Cleanup */ 176a9f12690SJung-uk Kim 177a9f12690SJung-uk Kim AcpiOsCloseDirectory (DirInfo); 178a9f12690SJung-uk Kim FileList[FileCount] = NULL; 179a9f12690SJung-uk Kim return (FileList); 180a9f12690SJung-uk Kim 181a9f12690SJung-uk Kim #else 182a9f12690SJung-uk Kim /* 183a9f12690SJung-uk Kim * Linux/Unix cases - Wildcards are expanded by the shell automatically. 184a9f12690SJung-uk Kim * Just return the filename in a null terminated list 185a9f12690SJung-uk Kim */ 186a9f12690SJung-uk Kim FileList[0] = AcpiOsAllocate (strlen (FileSpecifier) + 1); 187a9f12690SJung-uk Kim strcpy (FileList[0], FileSpecifier); 188a9f12690SJung-uk Kim FileList[1] = NULL; 189a9f12690SJung-uk Kim 190a9f12690SJung-uk Kim return (FileList); 191a9f12690SJung-uk Kim #endif 192a9f12690SJung-uk Kim } 193a9f12690SJung-uk Kim 194a9f12690SJung-uk Kim 195a9f12690SJung-uk Kim /******************************************************************************* 196a9f12690SJung-uk Kim * 197a88e22b7SJung-uk Kim * FUNCTION: AslDetectSourceFileType 198a88e22b7SJung-uk Kim * 199a88e22b7SJung-uk Kim * PARAMETERS: Info - Name/Handle for the file (must be open) 200a88e22b7SJung-uk Kim * 201a88e22b7SJung-uk Kim * RETURN: File Type 202a88e22b7SJung-uk Kim * 203a88e22b7SJung-uk Kim * DESCRIPTION: Determine the type of the input file. Either binary (contains 204a88e22b7SJung-uk Kim * non-ASCII characters), ASL file, or an ACPI Data Table file. 205a88e22b7SJung-uk Kim * 206a88e22b7SJung-uk Kim ******************************************************************************/ 207a88e22b7SJung-uk Kim 20842fecd12SJung-uk Kim static UINT8 209a88e22b7SJung-uk Kim AslDetectSourceFileType ( 210a88e22b7SJung-uk Kim ASL_FILE_INFO *Info) 211a88e22b7SJung-uk Kim { 212a88e22b7SJung-uk Kim char *FileChar; 213a88e22b7SJung-uk Kim UINT8 Type; 214a88e22b7SJung-uk Kim ACPI_STATUS Status; 215a88e22b7SJung-uk Kim 216a88e22b7SJung-uk Kim 217a88e22b7SJung-uk Kim /* Check for 100% ASCII source file (comments are ignored) */ 218a88e22b7SJung-uk Kim 219a88e22b7SJung-uk Kim Status = FlCheckForAscii (Info); 220a88e22b7SJung-uk Kim if (ACPI_FAILURE (Status)) 221a88e22b7SJung-uk Kim { 222a88e22b7SJung-uk Kim printf ("Non-ascii input file - %s\n", Info->Filename); 223a88e22b7SJung-uk Kim Type = ASL_INPUT_TYPE_BINARY; 224a88e22b7SJung-uk Kim goto Cleanup; 225a88e22b7SJung-uk Kim } 226a88e22b7SJung-uk Kim 227a88e22b7SJung-uk Kim /* 228a88e22b7SJung-uk Kim * File is ASCII. Determine if this is an ASL file or an ACPI data 229a88e22b7SJung-uk Kim * table file. 230a88e22b7SJung-uk Kim */ 231a88e22b7SJung-uk Kim while (fgets (Gbl_CurrentLineBuffer, ASL_LINE_BUFFER_SIZE, Info->Handle)) 232a88e22b7SJung-uk Kim { 233a88e22b7SJung-uk Kim /* Uppercase the buffer for caseless compare */ 234a88e22b7SJung-uk Kim 235a88e22b7SJung-uk Kim FileChar = Gbl_CurrentLineBuffer; 236a88e22b7SJung-uk Kim while (*FileChar) 237a88e22b7SJung-uk Kim { 238a88e22b7SJung-uk Kim *FileChar = (char) toupper ((int) *FileChar); 239a88e22b7SJung-uk Kim FileChar++; 240a88e22b7SJung-uk Kim } 241a88e22b7SJung-uk Kim 242a88e22b7SJung-uk Kim /* Presence of "DefinitionBlock" indicates actual ASL code */ 243a88e22b7SJung-uk Kim 244a88e22b7SJung-uk Kim if (strstr (Gbl_CurrentLineBuffer, "DEFINITIONBLOCK")) 245a88e22b7SJung-uk Kim { 246a88e22b7SJung-uk Kim /* Appears to be an ASL file */ 247a88e22b7SJung-uk Kim 248a88e22b7SJung-uk Kim Type = ASL_INPUT_TYPE_ASCII_ASL; 249a88e22b7SJung-uk Kim goto Cleanup; 250a88e22b7SJung-uk Kim } 251a88e22b7SJung-uk Kim } 252a88e22b7SJung-uk Kim 253a88e22b7SJung-uk Kim /* Not an ASL source file, default to a data table source file */ 254a88e22b7SJung-uk Kim 255a88e22b7SJung-uk Kim Type = ASL_INPUT_TYPE_ASCII_DATA; 256a88e22b7SJung-uk Kim 257a88e22b7SJung-uk Kim Cleanup: 258a88e22b7SJung-uk Kim 259a88e22b7SJung-uk Kim /* Must seek back to the start of the file */ 260a88e22b7SJung-uk Kim 261a88e22b7SJung-uk Kim fseek (Info->Handle, 0, SEEK_SET); 262a88e22b7SJung-uk Kim return (Type); 263a88e22b7SJung-uk Kim } 264a88e22b7SJung-uk Kim 265a88e22b7SJung-uk Kim 266a88e22b7SJung-uk Kim /******************************************************************************* 267a88e22b7SJung-uk Kim * 268a9f12690SJung-uk Kim * FUNCTION: AslDoOneFile 269a9f12690SJung-uk Kim * 270a9f12690SJung-uk Kim * PARAMETERS: Filename - Name of the file 271a9f12690SJung-uk Kim * 272a9f12690SJung-uk Kim * RETURN: Status 273a9f12690SJung-uk Kim * 274a9f12690SJung-uk Kim * DESCRIPTION: Process a single file - either disassemble, compile, or both 275a9f12690SJung-uk Kim * 276a9f12690SJung-uk Kim ******************************************************************************/ 277a9f12690SJung-uk Kim 278a9f12690SJung-uk Kim ACPI_STATUS 279a9f12690SJung-uk Kim AslDoOneFile ( 280a9f12690SJung-uk Kim char *Filename) 281a9f12690SJung-uk Kim { 282a9f12690SJung-uk Kim ACPI_STATUS Status; 283a9f12690SJung-uk Kim 284a9f12690SJung-uk Kim 285a9f12690SJung-uk Kim Gbl_Files[ASL_FILE_INPUT].Filename = Filename; 286a9f12690SJung-uk Kim 287a9f12690SJung-uk Kim /* Re-initialize "some" compiler globals */ 288a9f12690SJung-uk Kim 289a9f12690SJung-uk Kim AslInitializeGlobals (); 290a9f12690SJung-uk Kim 291a9f12690SJung-uk Kim /* 292a9f12690SJung-uk Kim * AML Disassembly (Optional) 293a9f12690SJung-uk Kim */ 294a9f12690SJung-uk Kim if (Gbl_DisasmFlag || Gbl_GetAllTables) 295a9f12690SJung-uk Kim { 296a9f12690SJung-uk Kim /* ACPICA subsystem initialization */ 297a9f12690SJung-uk Kim 298a9f12690SJung-uk Kim Status = AdInitialize (); 299a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 300a9f12690SJung-uk Kim { 301a9f12690SJung-uk Kim return (Status); 302a9f12690SJung-uk Kim } 303a9f12690SJung-uk Kim 304a9f12690SJung-uk Kim Status = AcpiAllocateRootTable (4); 305a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 306a9f12690SJung-uk Kim { 307a9f12690SJung-uk Kim AcpiOsPrintf ("Could not initialize ACPI Table Manager, %s\n", 308a9f12690SJung-uk Kim AcpiFormatException (Status)); 309a9f12690SJung-uk Kim return (Status); 310a9f12690SJung-uk Kim } 311a9f12690SJung-uk Kim 312a9f12690SJung-uk Kim /* This is where the disassembly happens */ 313a9f12690SJung-uk Kim 314a9f12690SJung-uk Kim AcpiGbl_DbOpt_disasm = TRUE; 315a9f12690SJung-uk Kim Status = AdAmlDisassemble (AslToFile, 316a9f12690SJung-uk Kim Gbl_Files[ASL_FILE_INPUT].Filename, 317a9f12690SJung-uk Kim Gbl_OutputFilenamePrefix, 318a9f12690SJung-uk Kim &Gbl_Files[ASL_FILE_INPUT].Filename, 319a9f12690SJung-uk Kim Gbl_GetAllTables); 320a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 321a9f12690SJung-uk Kim { 322a9f12690SJung-uk Kim return (Status); 323a9f12690SJung-uk Kim } 324a9f12690SJung-uk Kim 325a9f12690SJung-uk Kim /* Shutdown compiler and ACPICA subsystem */ 326a9f12690SJung-uk Kim 327a9f12690SJung-uk Kim AeClearErrorLog (); 32842fecd12SJung-uk Kim (void) AcpiTerminate (); 329a9f12690SJung-uk Kim 330a9f12690SJung-uk Kim /* 331a9f12690SJung-uk Kim * Gbl_Files[ASL_FILE_INPUT].Filename was replaced with the 332a9f12690SJung-uk Kim * .DSL disassembly file, which can now be compiled if requested 333a9f12690SJung-uk Kim */ 334a9f12690SJung-uk Kim if (Gbl_DoCompile) 335a9f12690SJung-uk Kim { 336a9f12690SJung-uk Kim AcpiOsPrintf ("\nCompiling \"%s\"\n", 337a9f12690SJung-uk Kim Gbl_Files[ASL_FILE_INPUT].Filename); 338a9f12690SJung-uk Kim } 339a88e22b7SJung-uk Kim else 340a88e22b7SJung-uk Kim { 341a88e22b7SJung-uk Kim Gbl_Files[ASL_FILE_INPUT].Filename = NULL; 342a88e22b7SJung-uk Kim return (AE_OK); 343a88e22b7SJung-uk Kim } 344a9f12690SJung-uk Kim } 345a9f12690SJung-uk Kim 346a9f12690SJung-uk Kim /* 347a88e22b7SJung-uk Kim * Open the input file. Here, this should be an ASCII source file, 348a88e22b7SJung-uk Kim * either an ASL file or a Data Table file 349a9f12690SJung-uk Kim */ 350a88e22b7SJung-uk Kim Status = FlOpenInputFile (Gbl_Files[ASL_FILE_INPUT].Filename); 351a88e22b7SJung-uk Kim if (ACPI_FAILURE (Status)) 352a9f12690SJung-uk Kim { 353a88e22b7SJung-uk Kim AePrintErrorLog (ASL_FILE_STDERR); 354a88e22b7SJung-uk Kim return (AE_ERROR); 355a88e22b7SJung-uk Kim } 356a88e22b7SJung-uk Kim 357a88e22b7SJung-uk Kim /* Determine input file type */ 358a88e22b7SJung-uk Kim 359a88e22b7SJung-uk Kim Gbl_FileType = AslDetectSourceFileType (&Gbl_Files[ASL_FILE_INPUT]); 360a88e22b7SJung-uk Kim if (Gbl_FileType == ASL_INPUT_TYPE_BINARY) 361a88e22b7SJung-uk Kim { 362a88e22b7SJung-uk Kim return (AE_ERROR); 363a88e22b7SJung-uk Kim } 364a88e22b7SJung-uk Kim 365a9f12690SJung-uk Kim /* 366a9f12690SJung-uk Kim * If -p not specified, we will use the input filename as the 367a9f12690SJung-uk Kim * output filename prefix 368a9f12690SJung-uk Kim */ 369a9f12690SJung-uk Kim if (Gbl_UseDefaultAmlFilename) 370a9f12690SJung-uk Kim { 371a9f12690SJung-uk Kim Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename; 372a9f12690SJung-uk Kim } 373a9f12690SJung-uk Kim 374a88e22b7SJung-uk Kim /* Open the optional output files (listings, etc.) */ 375a88e22b7SJung-uk Kim 376a88e22b7SJung-uk Kim Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix); 377a88e22b7SJung-uk Kim if (ACPI_FAILURE (Status)) 378a88e22b7SJung-uk Kim { 379a88e22b7SJung-uk Kim AePrintErrorLog (ASL_FILE_STDERR); 380a88e22b7SJung-uk Kim return (AE_ERROR); 381a88e22b7SJung-uk Kim } 382a88e22b7SJung-uk Kim 383a88e22b7SJung-uk Kim /* 384a88e22b7SJung-uk Kim * Compilation of ASL source versus DataTable source uses different 385a88e22b7SJung-uk Kim * compiler subsystems 386a88e22b7SJung-uk Kim */ 387a88e22b7SJung-uk Kim switch (Gbl_FileType) 388a88e22b7SJung-uk Kim { 389a88e22b7SJung-uk Kim /* 390a88e22b7SJung-uk Kim * Data Table Compilation 391a88e22b7SJung-uk Kim */ 392a88e22b7SJung-uk Kim case ASL_INPUT_TYPE_ASCII_DATA: 393a88e22b7SJung-uk Kim 394a88e22b7SJung-uk Kim Status = DtDoCompile (); 395a88e22b7SJung-uk Kim 396a88e22b7SJung-uk Kim if (Gbl_Signature) 397a88e22b7SJung-uk Kim { 398a88e22b7SJung-uk Kim ACPI_FREE (Gbl_Signature); 399a88e22b7SJung-uk Kim Gbl_Signature = NULL; 400a88e22b7SJung-uk Kim } 401a88e22b7SJung-uk Kim AeClearErrorLog (); 402a88e22b7SJung-uk Kim return (Status); 403a88e22b7SJung-uk Kim 404a88e22b7SJung-uk Kim /* 405a88e22b7SJung-uk Kim * ASL Compilation (Optional) 406a88e22b7SJung-uk Kim */ 407a88e22b7SJung-uk Kim case ASL_INPUT_TYPE_ASCII_ASL: 408a88e22b7SJung-uk Kim 409a88e22b7SJung-uk Kim /* ACPICA subsystem initialization */ 410a9f12690SJung-uk Kim 411a9f12690SJung-uk Kim Status = AdInitialize (); 412a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 413a9f12690SJung-uk Kim { 414a9f12690SJung-uk Kim return (Status); 415a9f12690SJung-uk Kim } 416a9f12690SJung-uk Kim 417a9f12690SJung-uk Kim Status = CmDoCompile (); 41842fecd12SJung-uk Kim (void) AcpiTerminate (); 419a9f12690SJung-uk Kim 420a9f12690SJung-uk Kim /* 421a9f12690SJung-uk Kim * Return non-zero exit code if there have been errors, unless the 422a9f12690SJung-uk Kim * global ignore error flag has been set 423a9f12690SJung-uk Kim */ 424a9f12690SJung-uk Kim if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors)) 425a9f12690SJung-uk Kim { 426a9f12690SJung-uk Kim return (AE_ERROR); 427a9f12690SJung-uk Kim } 428a9f12690SJung-uk Kim 429a9f12690SJung-uk Kim AeClearErrorLog (); 430a9f12690SJung-uk Kim return (AE_OK); 431a88e22b7SJung-uk Kim 432a88e22b7SJung-uk Kim case ASL_INPUT_TYPE_BINARY: 433a88e22b7SJung-uk Kim 434a88e22b7SJung-uk Kim AePrintErrorLog (ASL_FILE_STDERR); 435a88e22b7SJung-uk Kim return (AE_ERROR); 436a88e22b7SJung-uk Kim 437a88e22b7SJung-uk Kim default: 438a88e22b7SJung-uk Kim printf ("Unknown file type %X\n", Gbl_FileType); 439a88e22b7SJung-uk Kim return (AE_ERROR); 440a88e22b7SJung-uk Kim } 441a9f12690SJung-uk Kim } 442a9f12690SJung-uk Kim 443a9f12690SJung-uk Kim 444a9f12690SJung-uk Kim /******************************************************************************* 445a9f12690SJung-uk Kim * 446a9f12690SJung-uk Kim * FUNCTION: AslDoOnePathname 447a9f12690SJung-uk Kim * 448a9f12690SJung-uk Kim * PARAMETERS: Pathname - Full pathname, possibly with wildcards 449a9f12690SJung-uk Kim * 450a9f12690SJung-uk Kim * RETURN: Status 451a9f12690SJung-uk Kim * 452a9f12690SJung-uk Kim * DESCRIPTION: Process one pathname, possible terminated with a wildcard 453a9f12690SJung-uk Kim * specification. If a wildcard, it is expanded and the multiple 454a9f12690SJung-uk Kim * files are processed. 455a9f12690SJung-uk Kim * 456a9f12690SJung-uk Kim ******************************************************************************/ 457a9f12690SJung-uk Kim 458a9f12690SJung-uk Kim ACPI_STATUS 459a9f12690SJung-uk Kim AslDoOnePathname ( 460709fac06SJung-uk Kim char *Pathname, 461709fac06SJung-uk Kim ASL_PATHNAME_CALLBACK PathCallback) 462a9f12690SJung-uk Kim { 463a88e22b7SJung-uk Kim ACPI_STATUS Status = AE_OK; 46442fecd12SJung-uk Kim char **WildcardList; 465a9f12690SJung-uk Kim char *Filename; 466a9f12690SJung-uk Kim char *FullPathname; 467a9f12690SJung-uk Kim 468a9f12690SJung-uk Kim 469a9f12690SJung-uk Kim /* Split incoming path into a directory/filename combo */ 470a9f12690SJung-uk Kim 471a9f12690SJung-uk Kim Status = FlSplitInputPathname (Pathname, &Gbl_DirectoryPath, &Filename); 472a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 473a9f12690SJung-uk Kim { 474a9f12690SJung-uk Kim return (Status); 475a9f12690SJung-uk Kim } 476a9f12690SJung-uk Kim 477a9f12690SJung-uk Kim /* Expand possible wildcard into a file list (Windows/DOS only) */ 478a9f12690SJung-uk Kim 47942fecd12SJung-uk Kim WildcardList = AsDoWildcard (Gbl_DirectoryPath, Filename); 48042fecd12SJung-uk Kim while (*WildcardList) 481a9f12690SJung-uk Kim { 482a9f12690SJung-uk Kim FullPathname = ACPI_ALLOCATE ( 48342fecd12SJung-uk Kim strlen (Gbl_DirectoryPath) + strlen (*WildcardList) + 1); 484a9f12690SJung-uk Kim 485a9f12690SJung-uk Kim /* Construct a full path to the file */ 486a9f12690SJung-uk Kim 487a9f12690SJung-uk Kim strcpy (FullPathname, Gbl_DirectoryPath); 48842fecd12SJung-uk Kim strcat (FullPathname, *WildcardList); 489a9f12690SJung-uk Kim 490a9f12690SJung-uk Kim /* 491a9f12690SJung-uk Kim * If -p not specified, we will use the input filename as the 492a9f12690SJung-uk Kim * output filename prefix 493a9f12690SJung-uk Kim */ 494a9f12690SJung-uk Kim if (Gbl_UseDefaultAmlFilename) 495a9f12690SJung-uk Kim { 496a9f12690SJung-uk Kim Gbl_OutputFilenamePrefix = FullPathname; 497a9f12690SJung-uk Kim } 498a9f12690SJung-uk Kim 499a88e22b7SJung-uk Kim /* Save status from all compiles */ 500a88e22b7SJung-uk Kim 501709fac06SJung-uk Kim Status |= (*PathCallback) (FullPathname); 502a9f12690SJung-uk Kim 503a9f12690SJung-uk Kim ACPI_FREE (FullPathname); 50442fecd12SJung-uk Kim ACPI_FREE (*WildcardList); 50542fecd12SJung-uk Kim *WildcardList = NULL; 50642fecd12SJung-uk Kim WildcardList++; 507a9f12690SJung-uk Kim } 508a9f12690SJung-uk Kim 509a9f12690SJung-uk Kim ACPI_FREE (Gbl_DirectoryPath); 510a9f12690SJung-uk Kim ACPI_FREE (Filename); 511a88e22b7SJung-uk Kim return (Status); 512a9f12690SJung-uk Kim } 513a9f12690SJung-uk Kim 514