Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
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);
}
Ejemplo n.º 3
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;
	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;
		AcpiGbl_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) {
			int i;
			/*
			 * 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) {
			(void)fclose(fpout);
			_exit(1);
		}

		/* ...and do the ACPICA disassambly... */
		AslDoOneFile((char *)tables[which]);
		UtFreeLineBuffers();
		AslParserCleanup();
		if (AcpiGbl_ExternalFileList)
			AcpiDmClearExternalFileList();

		(void)fclose(fperr);
		(void)fclose(fpout);
		_exit(0);
		break;
	default:
		/* Parent */
		(void)waitpid(pid, &status, WUNTRACED | WCONTINUED);
	}

	return 0;
}