ACPI_STATUS AcpiDbGetTableFromFile ( char *Filename, ACPI_TABLE_HEADER **ReturnTable) { #ifdef ACPI_APPLICATION ACPI_STATUS Status; ACPI_TABLE_HEADER *Table; BOOLEAN IsAmlTable = TRUE; Status = AcpiDbReadTableFromFile (Filename, &Table); if (ACPI_FAILURE (Status)) { return (Status); } #ifdef ACPI_DATA_TABLE_DISASSEMBLY IsAmlTable = AcpiUtIsAmlTable (Table); #endif if (IsAmlTable) { /* Attempt to recognize and install the table */ Status = AeLocalLoadTable (Table); if (ACPI_FAILURE (Status)) { if (Status == AE_ALREADY_EXISTS) { AcpiOsPrintf ("Table %4.4s is already installed\n", Table->Signature); } else { AcpiOsPrintf ("Could not install table, %s\n", AcpiFormatException (Status)); } return (Status); } AcpiTbPrintTableHeader (0, Table); fprintf (stderr, "Acpi table [%4.4s] successfully installed and loaded\n", Table->Signature); } AcpiGbl_AcpiHardwarePresent = FALSE; if (ReturnTable) { *ReturnTable = Table; } #endif /* ACPI_APPLICATION */ return (AE_OK); }
ACPI_STATUS AcpiDbGetTableFromFile ( char *Filename, ACPI_TABLE_HEADER **ReturnTable, BOOLEAN MustBeAmlFile) { #ifdef ACPI_APPLICATION ACPI_STATUS Status; ACPI_TABLE_HEADER *Table; BOOLEAN IsAmlTable = TRUE; Status = AcpiUtReadTableFromFile (Filename, &Table); if (ACPI_FAILURE (Status)) { return (Status); } if (MustBeAmlFile) { IsAmlTable = AcpiUtIsAmlTable (Table); if (!IsAmlTable) { ACPI_EXCEPTION ((AE_INFO, AE_OK, "Input for -e is not an AML table: " "\"%4.4s\" (must be DSDT/SSDT)", Table->Signature)); return (AE_TYPE); } } if (IsAmlTable) { /* Attempt to recognize and install the table */ Status = AeLocalLoadTable (Table); if (ACPI_FAILURE (Status)) { if (Status == AE_ALREADY_EXISTS) { AcpiOsPrintf ("Table %4.4s is already installed\n", Table->Signature); } else { AcpiOsPrintf ("Could not install table, %s\n", AcpiFormatException (Status)); } return (Status); } AcpiTbPrintTableHeader (0, Table); fprintf (stderr, "Acpi table [%4.4s] successfully installed and loaded\n", Table->Signature); } AcpiGbl_AcpiHardwarePresent = FALSE; if (ReturnTable) { *ReturnTable = Table; } #endif /* ACPI_APPLICATION */ return (AE_OK); }
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\n", Table->Signature); fprintf (stderr, "Formatted output: %s - %u bytes\n", DisasmFilename, AdGetFileSize (File)); } 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"); NsSetupNamespaceListing (File); NsDisplayNamespace (); 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); /* * 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 the table again. No need to reload it, however */ 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"); NsSetupNamespaceListing (File); NsDisplayNamespace (); AcpiOsPrintf ("*****/\n"); AcpiDmDumpTree (AcpiGbl_ParseOpRoot); } } /* * Now that the namespace is finalized, we can perform namespace * transforms. * * 1) Convert fixed-offset references to resource descriptors * to symbolic references (Note: modifies namespace) */ AcpiDmConvertResourceIndexes (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode); /* Optional displays */ if (AcpiGbl_DbOpt_disasm) { /* This is the real disassembly */ AdDisplayTables (Filename, Table); /* Dump hex table if requested (-vt) */ AcpiDmDumpDataTable (Table); fprintf (stderr, "Disassembly completed\n"); fprintf (stderr, "ASL Output: %s - %u bytes\n", DisasmFilename, AdGetFileSize (File)); } } Cleanup: if (Table && !AcpiUtIsAmlTable (Table)) { ACPI_FREE (Table); } if (OutToFile && File) { if (AslCompilerdebug) /* Display final namespace, with transforms */ { NsSetupNamespaceListing (File); NsDisplayNamespace (); } fclose (File); AcpiOsRedirectOutput (stdout); } AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); AcpiGbl_ParseOpRoot = NULL; return (Status); }
static ACPI_STATUS AcGetOneTableFromFile ( char *Filename, FILE *File, UINT8 GetOnlyAmlTables, ACPI_TABLE_HEADER **ReturnTable) { ACPI_STATUS Status = AE_OK; ACPI_TABLE_HEADER TableHeader; ACPI_TABLE_HEADER *Table; INT32 Count; long TableOffset; *ReturnTable = NULL; /* Get the table header to examine signature and length */ TableOffset = ftell (File); Count = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), File); if (Count != sizeof (ACPI_TABLE_HEADER)) { return (AE_CTRL_TERMINATE); } /* Validate the table signature/header (limited ASCII chars) */ Status = AcValidateTableHeader (File, TableOffset); if (ACPI_FAILURE (Status)) { return (Status); } if (GetOnlyAmlTables) { /* * Table must be an AML table (DSDT/SSDT). * Used for iASL -e option only. */ if (!AcpiUtIsAmlTable (&TableHeader)) { fprintf (stderr, " %s: Table [%4.4s] is not an AML table - ignoring\n", Filename, TableHeader.Signature); return (AE_TYPE); } } /* Allocate a buffer for the entire table */ Table = AcpiOsAllocate ((ACPI_SIZE) TableHeader.Length); if (!Table) { return (AE_NO_MEMORY); } /* Read the entire ACPI table, including header */ fseek (File, TableOffset, SEEK_SET); Count = fread (Table, 1, TableHeader.Length, File); if (Count != (INT32) TableHeader.Length) { Status = AE_ERROR; goto ErrorExit; } /* Validate the checksum (just issue a warning) */ Status = AcpiTbVerifyChecksum (Table, TableHeader.Length); if (ACPI_FAILURE (Status)) { Status = AcCheckTextModeCorruption (Table); if (ACPI_FAILURE (Status)) { goto ErrorExit; } } *ReturnTable = Table; return (AE_OK); ErrorExit: AcpiOsFree (Table); return (Status); }
static ACPI_STATUS AdDisassembleOneTable ( ACPI_TABLE_HEADER *Table, FILE *File, char *Filename, char *DisasmFilename) { ACPI_STATUS Status; ACPI_OWNER_ID OwnerId; /* ForceAmlDisassembly means to assume the table contains valid AML */ if (!AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table)) { AdDisassemblerHeader (Filename, ACPI_IS_DATA_TABLE); /* This is a "Data Table" (non-AML table) */ 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\n", Table->Signature); if (File) { fprintf (stderr, "Formatted output: %s - %u bytes\n", DisasmFilename, CmGetFileSize (File)); } return (AE_OK); } /* * This is an AML table (DSDT or SSDT). * 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)); return (Status); } /* Debug output, namespace and parse tree */ if (AslCompilerdebug && File) { AcpiOsPrintf ("/**** Before second load\n"); NsSetupNamespaceListing (File); NsDisplayNamespace (); 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); /* * 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 ()) { Status = AdReparseOneTable (Table, File, OwnerId); if (ACPI_FAILURE (Status)) { return (Status); } } /* * Now that the namespace is finalized, we can perform namespace * transforms. * * 1) Convert fixed-offset references to resource descriptors * to symbolic references (Note: modifies namespace) */ AcpiDmConvertResourceIndexes (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode); /* Optional displays */ if (AcpiGbl_DmOpt_Disasm) { /* This is the real disassembly */ AdDisplayTables (Filename, Table); /* Dump hex table if requested (-vt) */ AcpiDmDumpDataTable (Table); fprintf (stderr, "Disassembly completed\n"); if (File) { fprintf (stderr, "ASL Output: %s - %u bytes\n", DisasmFilename, CmGetFileSize (File)); } if (Gbl_MapfileFlag) { fprintf (stderr, "%14s %s - %u bytes\n", Gbl_Files[ASL_FILE_MAP_OUTPUT].ShortDescription, Gbl_Files[ASL_FILE_MAP_OUTPUT].Filename, FlGetFileSize (ASL_FILE_MAP_OUTPUT)); } } return (AE_OK); }
ACPI_STATUS AdAmlDisassemble ( BOOLEAN OutToFile, char *Filename, char *Prefix, char **OutFilename) { ACPI_STATUS Status; char *DisasmFilename = NULL; FILE *File = NULL; ACPI_TABLE_HEADER *Table = NULL; ACPI_NEW_TABLE_DESC *ListHead = NULL; /* * Input: AML code from either a file or via GetTables (memory or * registry) */ if (Filename) { /* Get the list of all AML tables in the file */ Status = AcGetAllTablesFromFile (Filename, ACPI_GET_ALL_TABLES, &ListHead); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get ACPI tables from %s, %s\n", Filename, AcpiFormatException (Status)); return (Status); } /* Process any user-specified files for external objects */ Status = AdDoExternalFileList (Filename); if (ACPI_FAILURE (Status)) { return (Status); } } else { Status = AdGetLocalTables (); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get ACPI tables, %s\n", AcpiFormatException (Status)); return (Status); } if (!AcpiGbl_DmOpt_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 (!DisasmFilename) { 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; /* Disassemble all AML tables within the file */ while (ListHead) { Status = AdDisassembleOneTable (ListHead->Table, File, Filename, DisasmFilename); if (ACPI_FAILURE (Status)) { break; } ListHead = ListHead->Next; } Cleanup: if (Table && !AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table)) { ACPI_FREE (Table); } if (File) { fclose (File); AcpiOsRedirectOutput (stdout); } AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); AcpiGbl_ParseOpRoot = NULL; return (Status); }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_STATUS Status; UINT32 InitFlags; ACPI_TABLE_HEADER *Table = NULL; UINT32 TableCount; AE_TABLE_DESC *TableDesc; ACPI_DEBUG_INITIALIZE (); /* For debug version only */ signal (SIGINT, AeCtrlCHandler); /* Init debug globals */ AcpiDbgLevel = ACPI_NORMAL_DEFAULT; AcpiDbgLayer = 0xFFFFFFFF; /* Init ACPICA and start debugger thread */ Status = AcpiInitializeSubsystem (); AE_CHECK_OK (AcpiInitializeSubsystem, Status); if (ACPI_FAILURE (Status)) { goto ErrorExit; } printf (ACPI_COMMON_SIGNON (ACPIEXEC_NAME)); if (argc < 2) { usage (); (void) AcpiOsTerminate (); return (0); } /* Get the command line options */ if (AeDoOptions (argc, argv)) { goto ErrorExit; } /* The remaining arguments are filenames for ACPI tables */ if (!argv[AcpiGbl_Optind]) { goto EnterDebugger; } AcpiGbl_DbOpt_tables = TRUE; AcpiGbl_CstyleDisassembly = FALSE; /* Not supported for AcpiExec */ TableCount = 0; /* Get each of the ACPI table files on the command line */ while (argv[AcpiGbl_Optind]) { /* Get one entire table */ Status = AcpiUtReadTableFromFile (argv[AcpiGbl_Optind], &Table); if (ACPI_FAILURE (Status)) { printf ("**** Could not get table from file %s, %s\n", argv[AcpiGbl_Optind], AcpiFormatException (Status)); goto ErrorExit; } /* Ignore non-AML tables, we can't use them. Except for an FADT */ if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FADT) && !AcpiUtIsAmlTable (Table)) { ACPI_INFO ((AE_INFO, "Table [%4.4s] is not an AML table, ignoring", Table->Signature)); AcpiOsFree (Table); } else { /* Allocate and link a table descriptor */ TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC)); TableDesc->Table = Table; TableDesc->Next = AeTableListHead; AeTableListHead = TableDesc; TableCount++; } AcpiGbl_Optind++; } printf ("\n"); /* Build a local RSDT with all tables and let ACPICA process the RSDT */ Status = AeBuildLocalTables (TableCount, AeTableListHead); if (ACPI_FAILURE (Status)) { goto ErrorExit; } Status = AeInstallTables (); if (ACPI_FAILURE (Status)) { printf ("**** Could not load ACPI tables, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } /* * Install most of the handlers. * Override some default region handlers, especially SystemMemory */ Status = AeInstallEarlyHandlers (); if (ACPI_FAILURE (Status)) { goto EnterDebugger; } /* Setup initialization flags for ACPICA */ InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE); if (!AcpiGbl_DbOpt_ini_methods) { InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); } /* * Main initialization for ACPICA subsystem * TBD: Need a way to call this after the ACPI table "LOAD" command */ Status = AcpiEnableSubsystem (InitFlags); if (ACPI_FAILURE (Status)) { printf ("**** Could not EnableSubsystem, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } /* * Install handlers for "device driver" space IDs (EC,SMBus, etc.) * and fixed event handlers */ AeInstallLateHandlers (); /* Finish the ACPICA initialization */ Status = AcpiInitializeObjects (InitFlags); if (ACPI_FAILURE (Status)) { printf ("**** Could not InitializeObjects, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } AeMiscellaneousTests (); EnterDebugger: /* Exit if error above and we are in one of the batch modes */ if (ACPI_FAILURE (Status) && (AcpiGbl_ExecutionMode > 0)) { goto ErrorExit; } /* Run a batch command or enter the command loop */ switch (AcpiGbl_ExecutionMode) { default: case AE_MODE_COMMAND_LOOP: AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL); break; case AE_MODE_BATCH_MULTIPLE: AcpiDbRunBatchMode (); break; case AE_MODE_BATCH_SINGLE: AcpiDbExecute (BatchBuffer, NULL, NULL, EX_NO_SINGLE_STEP); Status = AcpiTerminate (); break; } return (0); ErrorExit: (void) AcpiOsTerminate (); return (-1); }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_STATUS Status; UINT32 InitFlags; ACPI_TABLE_HEADER *Table = NULL; UINT32 TableCount; AE_TABLE_DESC *TableDesc; char **WildcardList; char *Filename; char *Directory; char *FullPathname; #ifdef _DEBUG _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); #endif printf (ACPI_COMMON_SIGNON ("AML Execution/Debug Utility")); if (argc < 2) { usage (); return (0); } signal (SIGINT, AeCtrlCHandler); /* Init globals */ AcpiDbgLevel = ACPI_NORMAL_DEFAULT; AcpiDbgLayer = 0xFFFFFFFF; /* Init ACPI and start debugger thread */ Status = AcpiInitializeSubsystem (); AE_CHECK_OK (AcpiInitializeSubsystem, Status); if (ACPI_FAILURE (Status)) { return (-1); } /* Get the command line options */ if (AeDoOptions (argc, argv)) { return (-1); } /* The remaining arguments are filenames for ACPI tables */ if (argv[AcpiGbl_Optind]) { AcpiGbl_DbOpt_tables = TRUE; TableCount = 0; /* Get each of the ACPI table files on the command line */ while (argv[AcpiGbl_Optind]) { /* Split incoming path into a directory/filename combo */ Status = FlSplitInputPathname (argv[AcpiGbl_Optind], &Directory, &Filename); if (ACPI_FAILURE (Status)) { return (-1); } /* Expand wildcards (Windows only) */ WildcardList = AsDoWildcard (Directory, Filename); if (!WildcardList) { return (-1); } while (*WildcardList) { FullPathname = AcpiOsAllocate ( strlen (Directory) + strlen (*WildcardList) + 1); /* Construct a full path to the file */ strcpy (FullPathname, Directory); strcat (FullPathname, *WildcardList); /* Get one table */ Status = AcpiDbReadTableFromFile (FullPathname, &Table); if (ACPI_FAILURE (Status)) { printf ("**** Could not get input table %s, %s\n", FullPathname, AcpiFormatException (Status)); goto EnterDebugger; } AcpiOsFree (FullPathname); AcpiOsFree (*WildcardList); *WildcardList = NULL; WildcardList++; /* Ignore non-AML tables, we can't use them. Except for an FADT */ if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FADT) && !AcpiUtIsAmlTable (Table)) { ACPI_WARNING ((AE_INFO, "Table %4.4s is not an AML table, ignoring", Table->Signature)); AcpiOsFree (Table); continue; } /* Allocate and link a table descriptor */ TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC)); TableDesc->Table = Table; TableDesc->Next = AeTableListHead; AeTableListHead = TableDesc; TableCount++; } AcpiGbl_Optind++; } /* Build a local RSDT with all tables and let ACPICA process the RSDT */ Status = AeBuildLocalTables (TableCount, AeTableListHead); if (ACPI_FAILURE (Status)) { return (-1); } Status = AeInstallTables (); if (ACPI_FAILURE (Status)) { printf ("**** Could not load ACPI tables, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } /* * Install most of the handlers. * Override some default region handlers, especially SystemMemory */ Status = AeInstallEarlyHandlers (); if (ACPI_FAILURE (Status)) { goto EnterDebugger; } /* Setup initialization flags for ACPICA */ InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE); if (!AcpiGbl_DbOpt_ini_methods) { InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); } /* * Main initialization for ACPICA subsystem * TBD: Need a way to call this after the ACPI table "LOAD" command */ Status = AcpiEnableSubsystem (InitFlags); if (ACPI_FAILURE (Status)) { printf ("**** Could not EnableSubsystem, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } Status = AcpiInitializeObjects (InitFlags); if (ACPI_FAILURE (Status)) { printf ("**** Could not InitializeObjects, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } /* * Install handlers for "device driver" space IDs (EC,SMBus, etc.) * and fixed event handlers */ AeInstallLateHandlers (); AeMiscellaneousTests (); } EnterDebugger: /* Exit if error above and we are in one of the batch modes */ if (ACPI_FAILURE (Status) && (AcpiGbl_ExecutionMode > 0)) { return (-1); } /* Run a batch command or enter the command loop */ switch (AcpiGbl_ExecutionMode) { default: case AE_MODE_COMMAND_LOOP: AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL); break; case AE_MODE_BATCH_MULTIPLE: AcpiDbRunBatchMode (); break; case AE_MODE_BATCH_SINGLE: AcpiDbExecute (BatchBuffer, NULL, NULL, EX_NO_SINGLE_STEP); break; } return (0); }