📄 adisasm.c
字号:
{ Status = AcpiDbGetTableFromFile (Gbl_ExternalFilename, &ExternalTable); if (ACPI_FAILURE (Status)) { return Status; } } } 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, TRUE); 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); /* * Cross reference the namespace here, in order to generate External() statements */ AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode); 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 (AslCompilerdebug) { AcpiOsPrintf ("/**** After second load and resource conversion\n"); LsSetupNsList (File); LsDisplayNamespace (); AcpiOsPrintf ("*****/\n"); } /* * 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 (AdMethodExternalCount ()) { fprintf (stderr, "\nFound %d external control methods, reparsing with new information\n", AdMethodExternalCount()); /* * 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.Child = NULL; AcpiGbl_RootNodeStruct.Peer = NULL; AcpiGbl_RootNodeStruct.Object = NULL; AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST; Status = AcpiNsRootInitialize (); AdAddExternalsToNamespace (); /* Parse table. No need to reload it, however (FALSE) */ Status = AdParseTable (Table, FALSE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not parse ACPI tables, %s\n", AcpiFormatException (Status)); goto Cleanup; } if (AslCompilerdebug) { 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);}/****************************************************************************** * * FUNCTION: AdDisassemblerHeader * * PARAMETERS: Filename - Input file for the table * * RETURN: None * * DESCRIPTION: Create the disassembler header, including ACPI CA signon with * current time and date. * *****************************************************************************/voidAdDisassemblerHeader ( char *Filename){ time_t Timer; time (&Timer); /* Header and input table info */ AcpiOsPrintf ("/*\n * Intel ACPI Component Architecture\n"); AcpiOsPrintf (" * AML Disassembler version %8.8X\n", ACPI_CA_VERSION); AcpiOsPrintf (" *\n * Disassembly of %s, %s", Filename, ctime (&Timer)); AcpiOsPrintf (" *\n");}/****************************************************************************** * * FUNCTION: AdCreateTableHeader * * PARAMETERS: Filename - Input file for the table * Table - Pointer to the raw table * * RETURN: None * * DESCRIPTION: Create the ASL table header, including ACPI CA signon with * current time and date. * *****************************************************************************/voidAdCreateTableHeader ( char *Filename, ACPI_TABLE_HEADER *Table){ char *NewFilename; UINT8 Checksum; /* * Print file header and dump original table header */ AdDisassemblerHeader (Filename); AcpiOsPrintf (" *\n * Original Table Header:\n"); AcpiOsPrintf (" * Signature \"%4.4s\"\n", Table->Signature); AcpiOsPrintf (" * Length 0x%8.8X (%u)\n", Table->Length, Table->Length); AcpiOsPrintf (" * Revision 0x%2.2X\n", Table->Revision); /* Print and validate the table checksum */ AcpiOsPrintf (" * Checksum 0x%2.2X", Table->Checksum); Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length); if (Checksum) { AcpiOsPrintf (" **** Incorrect checksum, should be 0x%2.2X", (UINT8) (Table->Checksum - Checksum)); } AcpiOsPrintf ("\n"); AcpiOsPrintf (" * OEM ID \"%.6s\"\n", Table->OemId); AcpiOsPrintf (" * OEM Table ID \"%.8s\"\n", Table->OemTableId); AcpiOsPrintf (" * OEM Revision 0x%8.8X (%u)\n", Table->OemRevision, Table->OemRevision); AcpiOsPrintf (" * Compiler ID \"%.4s\"\n", Table->AslCompilerId); AcpiOsPrintf (" * Compiler Version 0x%8.8X (%u)\n", Table->AslCompilerRevision, Table->AslCompilerRevision); AcpiOsPrintf (" */\n"); /* Create AML output filename based on input filename */ if (Filename) { NewFilename = FlGenerateFilename (Filename, "aml"); } else { NewFilename = ACPI_ALLOCATE_ZEROED (9); strncat (NewFilename, Table->Signature, 4); strcat (NewFilename, ".aml"); } /* Open the ASL definition block */ AcpiOsPrintf ( "DefinitionBlock (\"%s\", \"%4.4s\", %hd, \"%.6s\", \"%.8s\", 0x%8.8X)\n", NewFilename, Table->Signature, Table->Revision, Table->OemId, Table->OemTableId, Table->OemRevision); ACPI_FREE (NewFilename);}/****************************************************************************** * * FUNCTION: AdDisplayTables * * PARAMETERS: Filename - Input file for the table * Table - Pointer to the raw table * * RETURN: Status * * DESCRIPTION: Display (disassemble) loaded tables and dump raw tables * *****************************************************************************/ACPI_STATUSAdDisplayTables ( char *Filename, ACPI_TABLE_HEADER *Table){ if (!AcpiGbl_ParseOpRoot) { return AE_NOT_EXIST; } if (!AcpiGbl_DbOpt_verbose) { AdCreateTableHeader (Filename, Table); } AcpiDmDisassemble (NULL, AcpiGbl_ParseOpRoot, ACPI_UINT32_MAX); if (AcpiGbl_DbOpt_verbose) { AcpiOsPrintf ("\n\nTable Header:\n"); AcpiUtDumpBuffer ((UINT8 *) Table, sizeof (ACPI_TABLE_HEADER), DB_BYTE_DISPLAY, ACPI_UINT32_MAX); AcpiOsPrintf ("Table Body (Length 0x%X)\n", Table->Length); AcpiUtDumpBuffer (((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)), Table->Length, DB_BYTE_DISPLAY, ACPI_UINT32_MAX); } return AE_OK;}/****************************************************************************** * * FUNCTION: AdDeferredParse * * PARAMETERS: Op - Root Op of the deferred opcode * Aml - Pointer to the raw AML * AmlLength - Length of the AML * * RETURN: Status * * DESCRIPTION: Parse one deferred opcode * (Methods, operation regions, etc.) * *****************************************************************************/ACPI_STATUSAdDeferredParse ( ACPI_PARSE_OBJECT *Op, UINT8 *Aml, UINT32 AmlLength){ ACPI_WALK_STATE *WalkState; ACPI_STATUS Status;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -