ACPI_STATUS AslDoOnePathname ( char *Pathname) { ACPI_STATUS Status; char **FileList; char *Filename; char *FullPathname; /* Split incoming path into a directory/filename combo */ Status = FlSplitInputPathname (Pathname, &Gbl_DirectoryPath, &Filename); if (ACPI_FAILURE (Status)) { return (Status); } /* Expand possible wildcard into a file list (Windows/DOS only) */ FileList = AsDoWildcard (Gbl_DirectoryPath, Filename); while (*FileList) { FullPathname = ACPI_ALLOCATE ( strlen (Gbl_DirectoryPath) + strlen (*FileList) + 1); /* Construct a full path to the file */ strcpy (FullPathname, Gbl_DirectoryPath); strcat (FullPathname, *FileList); /* * If -p not specified, we will use the input filename as the * output filename prefix */ if (Gbl_UseDefaultAmlFilename) { Gbl_OutputFilenamePrefix = FullPathname; } Status = AslDoOneFile (FullPathname); if (ACPI_FAILURE (Status)) { return (Status); } ACPI_FREE (FullPathname); ACPI_FREE (*FileList); *FileList = NULL; FileList++; } ACPI_FREE (Gbl_DirectoryPath); ACPI_FREE (Filename); return (AE_OK); }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_STATUS Status; int Index; #ifdef _DEBUG _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); #endif /* Init and command line */ AslInitialize (); Index = AslCommandLine (argc, argv); /* Options that have no additional parameters or pathnames */ if (Gbl_GetAllTables) { Status = AslDoOneFile (NULL); if (ACPI_FAILURE (Status)) { return (-1); } return (0); } /* Process each pathname/filename in the list, with possible wildcards */ while (argv[Index]) { Status = AslDoOnePathname (argv[Index]); if (ACPI_FAILURE (Status)) { return (-1); } Index++; } return (0); }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_STATUS Status; int Index1; int Index2; int ReturnStatus = 0; /* * Big-endian machines are not currently supported. ACPI tables must * be little-endian, and support for big-endian machines needs to * be implemented. */ if (AcpiIsBigEndianMachine ()) { fprintf (stderr, "iASL is not currently supported on big-endian machines.\n"); return (-1); } AcpiOsInitialize (); ACPI_DEBUG_INITIALIZE (); /* For debug version only */ /* Initialize preprocessor and compiler before command line processing */ signal (SIGINT, AslSignalHandler); AcpiGbl_ExternalFileList = NULL; AcpiDbgLevel = 0; PrInitializePreprocessor (); AslInitialize (); Index1 = Index2 = AslCommandLine (argc, argv); /* Allocate the line buffer(s), must be after command line */ Gbl_LineBufferSize /= 2; UtExpandLineBuffers (); /* Perform global actions first/only */ if (Gbl_DisassembleAll) { while (argv[Index1]) { Status = AcpiDmAddToExternalFileList (argv[Index1]); if (ACPI_FAILURE (Status)) { return (-1); } Index1++; } } /* Process each pathname/filename in the list, with possible wildcards */ while (argv[Index2]) { /* * If -p not specified, we will use the input filename as the * output filename prefix */ if (Gbl_UseDefaultAmlFilename) { Gbl_OutputFilenamePrefix = argv[Index2]; UtConvertBackslashes (Gbl_OutputFilenamePrefix); } Status = AslDoOneFile (argv[Index2]); if (ACPI_FAILURE (Status)) { ReturnStatus = -1; goto CleanupAndExit; } Index2++; } CleanupAndExit: UtFreeLineBuffers (); AslParserCleanup (); if (AcpiGbl_ExternalFileList) { AcpiDmClearExternalFileList(); } return (ReturnStatus); }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_STATUS Status; int Index1; int Index2; AcpiGbl_ExternalFileList = NULL; #ifdef _DEBUG _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); #endif /* Init and command line */ AslInitialize (); PrInitializePreprocessor (); Index1 = Index2 = AslCommandLine (argc, argv); /* Options that have no additional parameters or pathnames */ if (Gbl_GetAllTables) { Status = AslDoOneFile (NULL); if (ACPI_FAILURE (Status)) { return (-1); } return (0); } if (Gbl_DisassembleAll) { while (argv[Index1]) { Status = AslDoOnePathname (argv[Index1], AcpiDmAddToExternalFileList); if (ACPI_FAILURE (Status)) { return (-1); } Index1++; } } /* Process each pathname/filename in the list, with possible wildcards */ while (argv[Index2]) { Status = AslDoOnePathname (argv[Index2], AslDoOneFile); if (ACPI_FAILURE (Status)) { return (-1); } Index2++; } if (AcpiGbl_ExternalFileList) { AcpiDmClearExternalFileList(); } return (0); }
/* * fwts_iasl_disassemble_aml() * invoke iasl to disassemble AML */ int fwts_iasl_disassemble_aml( char *tables[], char *names[], const int table_entries, const int which, const bool use_externals, const char *outputfile) { pid_t pid; int status, i; FILE *fpout, *fperr; fflush(stdout); fflush(stderr); pid = fork(); switch (pid) { case -1: return -1; case 0: /* Child */ init_asl_core(); /* Setup ACPICA disassembler globals */ Gbl_WarningLevel = ASL_WARNING3; Gbl_IgnoreErrors = TRUE; Gbl_DisasmFlag = TRUE; Gbl_DoCompile = FALSE; Gbl_OutputFilenamePrefix = (char*)outputfile; Gbl_UseDefaultAmlFilename = FALSE; AcpiGbl_CstyleDisassembly = FALSE; AcpiGbl_DmOpt_Verbose = FALSE; UtConvertBackslashes (Gbl_OutputFilenamePrefix); /* Do we need to include external tables in? */ if (use_externals) { /* * Add in external SSDT files and NOT the one we want * disassemble */ for (i = 0; i < table_entries; i++) { if ((i != which) && (names[i] != NULL) && (tables[i] != NULL) && (!strcmp(names[i], "SSDT") || !strcmp(names[i], "DSDT"))) { ACPI_STATUS acpi_status; /* * Add in external tables that are NOT the table * we intent to disassemble */ acpi_status = AcpiDmAddToExternalFileList(tables[i]); if (ACPI_FAILURE(acpi_status)) { (void)unlink(outputfile); _exit(1); } } } } /* Throw away noisy errors */ if ((fpout = freopen("/dev/null", "w", stdout)) == NULL) { _exit(1); } if ((fperr = freopen("/dev/null", "w", stderr)) == NULL) { fclose(fpout); _exit(1); } /* ...and do the ACPICA disassambly... */ AslDoOneFile((char *)tables[which]); fclose(fperr); fclose(fpout); _exit(0); break; default: /* Parent */ (void)waitpid(pid, &status, WUNTRACED | WCONTINUED); } return 0; }
/* * fwts_iasl_assemble_aml() * invoke iasl and assemble some source, stdout into * stdout_output, stderr into stderr_output */ int fwts_iasl_assemble_aml(const char *source, char **stdout_output, char **stderr_output) { int stdout_fds[2], stderr_fds[2]; int status, ret = 0; size_t stdout_len = 0, stderr_len = 0; pid_t pid; bool stdout_eof = false, stderr_eof = false; fflush(stdout); fflush(stderr); if (pipe(stdout_fds) < 0) return -1; if (pipe(stderr_fds) < 0) return -1; pid = fork(); switch (pid) { case -1: (void)close(stdout_fds[0]); (void)close(stdout_fds[1]); (void)close(stderr_fds[0]); (void)close(stderr_fds[1]); return -1; case 0: /* Child */ init_asl_core(); /* stdout to be redirected down the writer end of pipe */ if (stdout_fds[1] != STDOUT_FILENO) if (dup2(stdout_fds[1], STDOUT_FILENO) < 0) _exit(EXIT_FAILURE); if (stderr_fds[1] != STDERR_FILENO) if (dup2(stderr_fds[1], STDERR_FILENO) < 0) _exit(EXIT_FAILURE); /* Close reader end */ (void)close(stdout_fds[0]); (void)close(stderr_fds[0]); /* Setup ACPICA compiler globals */ Gbl_DisasmFlag = FALSE; Gbl_DoCompile = TRUE; Gbl_PreprocessFlag = TRUE; Gbl_UseDefaultAmlFilename = FALSE; Gbl_OutputFilenamePrefix = (char*)source; UtConvertBackslashes (Gbl_OutputFilenamePrefix); (void)AslDoOneFile((char *)source); /* * We need to flush buffered I/O on IASL stdout * before we exit */ (void)fflush(stdout); (void)fflush(stderr); _exit(0); break; default: /* Parent */ /* Close writer end */ (void)close(stdout_fds[1]); (void)close(stderr_fds[1]); while (!stdout_eof && !stderr_eof) { if (fwts_iasl_read_output(stdout_fds[0], stdout_output, &stdout_len, &stdout_eof) < 0) break; if (fwts_iasl_read_output(stderr_fds[0], stderr_output, &stderr_len, &stderr_eof) < 0) break; } (void)waitpid(pid, &status, WUNTRACED | WCONTINUED); (void)close(stdout_fds[0]); (void)close(stderr_fds[0]); break; } return ret; }