summaryrefslogtreecommitdiffstats
path: root/source/compiler/aslstartup.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/compiler/aslstartup.c')
-rw-r--r--source/compiler/aslstartup.c163
1 files changed, 111 insertions, 52 deletions
diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c
index c8c6449..ad9a2bb 100644
--- a/source/compiler/aslstartup.c
+++ b/source/compiler/aslstartup.c
@@ -44,6 +44,7 @@
#include "aslcompiler.h"
#include "actables.h"
+#include "acdisasm.h"
#include "acapps.h"
#define _COMPONENT ACPI_COMPILER
@@ -66,6 +67,10 @@ static UINT8
AslDetectSourceFileType (
ASL_FILE_INFO *Info);
+static ACPI_STATUS
+AslDoDisassembly (
+ void);
+
/*******************************************************************************
*
@@ -224,6 +229,15 @@ AslDetectSourceFileType (
ACPI_STATUS Status;
+ /* Check for a valid binary ACPI table */
+
+ Status = FlCheckForAcpiTable (Info->Handle);
+ if (ACPI_SUCCESS (Status))
+ {
+ Type = ASL_INPUT_TYPE_ACPI_TABLE;
+ goto Cleanup;
+ }
+
/* Check for 100% ASCII source file (comments are ignored) */
Status = FlCheckForAscii (Info->Handle, Info->Filename, TRUE);
@@ -279,6 +293,86 @@ Cleanup:
/*******************************************************************************
*
+ * FUNCTION: AslDoDisassembly
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Initiate AML file disassembly. Uses ACPICA subsystem to build
+ * namespace.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AslDoDisassembly (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ /* ACPICA subsystem initialization */
+
+ Status = AdInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Status = AcpiAllocateRootTable (4);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could not initialize ACPI Table Manager, %s\n",
+ AcpiFormatException (Status));
+ return (Status);
+ }
+
+ /* This is where the disassembly happens */
+
+ AcpiGbl_DbOpt_disasm = TRUE;
+ Status = AdAmlDisassemble (AslToFile,
+ Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_OutputFilenamePrefix,
+ &Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_GetAllTables);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Check if any control methods were unresolved */
+
+ AcpiDmUnresolvedWarning (0);
+
+#if 0
+ /* TBD: Handle additional output files for disassembler */
+
+ Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix);
+ NsDisplayNamespace ();
+#endif
+
+ /* Shutdown compiler and ACPICA subsystem */
+
+ AeClearErrorLog ();
+ (void) AcpiTerminate ();
+
+ /*
+ * Gbl_Files[ASL_FILE_INPUT].Filename was replaced with the
+ * .DSL disassembly file, which can now be compiled if requested
+ */
+ if (Gbl_DoCompile)
+ {
+ AcpiOsPrintf ("\nCompiling \"%s\"\n",
+ Gbl_Files[ASL_FILE_INPUT].Filename);
+ return (AE_CTRL_CONTINUE);
+ }
+
+ ACPI_FREE (Gbl_Files[ASL_FILE_INPUT].Filename);
+ Gbl_Files[ASL_FILE_INPUT].Filename = NULL;
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: AslDoOneFile
*
* PARAMETERS: Filename - Name of the file
@@ -308,61 +402,11 @@ AslDoOneFile (
*/
if (Gbl_DisasmFlag || Gbl_GetAllTables)
{
- /* ACPICA subsystem initialization */
-
- Status = AdInitialize ();
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- Status = AcpiAllocateRootTable (4);
- if (ACPI_FAILURE (Status))
- {
- AcpiOsPrintf ("Could not initialize ACPI Table Manager, %s\n",
- AcpiFormatException (Status));
- return (Status);
- }
-
- /* This is where the disassembly happens */
-
- AcpiGbl_DbOpt_disasm = TRUE;
- Status = AdAmlDisassemble (AslToFile,
- Gbl_Files[ASL_FILE_INPUT].Filename,
- Gbl_OutputFilenamePrefix,
- &Gbl_Files[ASL_FILE_INPUT].Filename,
- Gbl_GetAllTables);
- if (ACPI_FAILURE (Status))
+ Status = AslDoDisassembly ();
+ if (Status != AE_CTRL_CONTINUE)
{
return (Status);
}
-
-#if 0
- /* TBD: Handle additional output files for disassembler */
-
- Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix);
- NsDisplayNamespace ();
-#endif
-
- /* Shutdown compiler and ACPICA subsystem */
-
- AeClearErrorLog ();
- (void) AcpiTerminate ();
-
- /*
- * Gbl_Files[ASL_FILE_INPUT].Filename was replaced with the
- * .DSL disassembly file, which can now be compiled if requested
- */
- if (Gbl_DoCompile)
- {
- AcpiOsPrintf ("\nCompiling \"%s\"\n",
- Gbl_Files[ASL_FILE_INPUT].Filename);
- }
- else
- {
- Gbl_Files[ASL_FILE_INPUT].Filename = NULL;
- return (AE_OK);
- }
}
/*
@@ -469,6 +513,21 @@ AslDoOneFile (
PrTerminatePreprocessor ();
return (AE_OK);
+ /*
+ * Binary ACPI table was auto-detected, disassemble it
+ */
+ case ASL_INPUT_TYPE_ACPI_TABLE:
+
+ /* We have what appears to be an ACPI table, disassemble it */
+
+ FlCloseFile (ASL_FILE_INPUT);
+ Gbl_DoCompile = FALSE;
+ Gbl_DisasmFlag = TRUE;
+ Status = AslDoDisassembly ();
+ return (Status);
+
+ /* Unknown binary table */
+
case ASL_INPUT_TYPE_BINARY:
AePrintErrorLog (ASL_FILE_STDERR);
OpenPOWER on IntegriCloud