void CmDoOutputFiles ( void) { /* Create listings and hex files */ LsDoListings (); LsDoHexOutput (); /* Dump the namespace to the .nsp file if requested */ (void) LsDisplayNamespace (); }
ACPI_STATUS AdAmlDisassemble ( BOOLEAN OutToFile, char *Filename, char *Prefix, char **OutFilename, BOOLEAN GetAllTables) { ACPI_STATUS Status; char *DisasmFilename = NULL; char *ExternalFilename; ACPI_EXTERNAL_FILE *ExternalFileList = AcpiGbl_ExternalFileList; FILE *File = NULL; ACPI_TABLE_HEADER *Table = NULL; ACPI_TABLE_HEADER *ExternalTable; ACPI_OWNER_ID OwnerId; /* * Input: AML code from either a file or via GetTables (memory or * registry) */ if (Filename) { Status = AcpiDbGetTableFromFile (Filename, &Table); if (ACPI_FAILURE (Status)) { return Status; } /* * External filenames separated by commas * Example: iasl -e file1,file2,file3 -d xxx.aml */ while (ExternalFileList) { ExternalFilename = ExternalFileList->Path; if (!ACPI_STRCMP (ExternalFilename, Filename)) { /* Next external file */ ExternalFileList = ExternalFileList->Next; continue; } Status = AcpiDbGetTableFromFile (ExternalFilename, &ExternalTable); if (ACPI_FAILURE (Status)) { return Status; } /* Load external table for symbol resolution */ if (ExternalTable) { Status = AdParseTable (ExternalTable, &OwnerId, TRUE, TRUE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not parse external ACPI tables, %s\n", AcpiFormatException (Status)); return Status; } /* * Load namespace from names created within control methods * Set owner id of nodes in external table */ AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode, OwnerId); AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); } /* Next external file */ ExternalFileList = ExternalFileList->Next; } /* Clear external list generated by Scope in external tables */ if (AcpiGbl_ExternalFileList) { AcpiDmClearExternalList (); } } else { Status = AdGetLocalTables (Filename, GetAllTables); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get ACPI tables, %s\n", AcpiFormatException (Status)); return Status; } if (!AcpiGbl_DbOpt_disasm) { return AE_OK; } /* Obtained the local tables, just disassemble the DSDT */ Status = AcpiGetTable (ACPI_SIG_DSDT, 0, &Table); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get DSDT, %s\n", AcpiFormatException (Status)); return Status; } AcpiOsPrintf ("\nDisassembly of DSDT\n"); Prefix = AdGenerateFilename ("dsdt", Table->OemTableId); } /* * Output: ASL code. Redirect to a file if requested */ if (OutToFile) { /* Create/Open a disassembly output file */ DisasmFilename = FlGenerateFilename (Prefix, FILE_SUFFIX_DISASSEMBLY); if (!OutFilename) { fprintf (stderr, "Could not generate output filename\n"); Status = AE_ERROR; goto Cleanup; } File = fopen (DisasmFilename, "w+"); if (!File) { fprintf (stderr, "Could not open output file %s\n", DisasmFilename); Status = AE_ERROR; goto Cleanup; } AcpiOsRedirectOutput (File); } *OutFilename = DisasmFilename; if (!AcpiUtIsAmlTable (Table)) { AdDisassemblerHeader (Filename); AcpiOsPrintf (" * ACPI Data Table [%4.4s]\n *\n", Table->Signature); AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue\n */\n\n"); AcpiDmDumpDataTable (Table); fprintf (stderr, "Acpi Data Table [%4.4s] decoded, written to \"%s\"\n", Table->Signature, DisasmFilename); } else { /* Always parse the tables, only option is what to display */ Status = AdParseTable (Table, &OwnerId, TRUE, FALSE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not parse ACPI tables, %s\n", AcpiFormatException (Status)); goto Cleanup; } if (AslCompilerdebug) { AcpiOsPrintf ("/**** Before second load\n"); LsSetupNsList (File); LsDisplayNamespace (); AcpiOsPrintf ("*****/\n"); } /* * Load namespace from names created within control methods */ AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode, OwnerId); /* * Cross reference the namespace here, in order to generate External() statements */ AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode, OwnerId); if (AslCompilerdebug) { AcpiDmDumpTree (AcpiGbl_ParseOpRoot); } /* Find possible calls to external control methods */ AcpiDmFindOrphanMethods (AcpiGbl_ParseOpRoot); /* Convert fixed-offset references to resource descriptors to symbolic references */ AcpiDmConvertResourceIndexes (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode); /* * If we found any external control methods, we must reparse the entire * tree with the new information (namely, the number of arguments per * method) */ if (AcpiDmGetExternalMethodCount ()) { fprintf (stderr, "\nFound %u external control methods, reparsing with new information\n", AcpiDmGetExternalMethodCount ()); /* * Reparse, rebuild namespace. no need to xref namespace */ AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode); AcpiGbl_RootNode = NULL; AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; AcpiGbl_RootNodeStruct.Parent = NULL; AcpiGbl_RootNodeStruct.Child = NULL; AcpiGbl_RootNodeStruct.Peer = NULL; AcpiGbl_RootNodeStruct.Object = NULL; AcpiGbl_RootNodeStruct.Flags = 0; Status = AcpiNsRootInitialize (); AcpiDmAddExternalsToNamespace (); /* Parse table. No need to reload it, however (FALSE) */ Status = AdParseTable (Table, NULL, FALSE, FALSE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not parse ACPI tables, %s\n", AcpiFormatException (Status)); goto Cleanup; } if (AslCompilerdebug) { AcpiOsPrintf ("/**** After second load and resource conversion\n"); LsSetupNsList (File); LsDisplayNamespace (); AcpiOsPrintf ("*****/\n"); AcpiDmDumpTree (AcpiGbl_ParseOpRoot); } } /* Optional displays */ if (AcpiGbl_DbOpt_disasm) { AdDisplayTables (Filename, Table); fprintf (stderr, "Disassembly completed, written to \"%s\"\n", DisasmFilename); } } Cleanup: if (Table && !AcpiUtIsAmlTable (Table)) { ACPI_FREE (Table); } if (DisasmFilename) { ACPI_FREE (DisasmFilename); } if (OutToFile && File) { #ifdef ASL_DISASM_DEBUG LsSetupNsList (File); LsDisplayNamespace (); #endif fclose (File); AcpiOsRedirectOutput (stdout); } AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); AcpiGbl_ParseOpRoot = NULL; return (Status); }