int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_DEBUG_INITIALIZE (); /* For debug version only */ printf (ACPI_COMMON_SIGNON ("ACPI Example Code")); /* Initialize the local ACPI tables (RSDP/RSDT/XSDT/FADT/DSDT/FACS) */ ExInitializeAcpiTables (); /* Initialize the ACPICA subsystem */ InitializeFullAcpica (); /* Example warning and error output */ ACPI_INFO ((AE_INFO, "Example ACPICA info message")); ACPI_WARNING ((AE_INFO, "Example ACPICA warning message")); ACPI_ERROR ((AE_INFO, "Example ACPICA error message")); ACPI_EXCEPTION ((AE_INFO, AE_AML_OPERAND_TYPE, "Example ACPICA exception message")); ExecuteOSI (); ExecuteMAIN (); return (0); }
/* * init_asl_core() * initialize iasl */ static void init_asl_core(void) { int i; AcpiOsInitialize(); ACPI_DEBUG_INITIALIZE(); AcpiGbl_ExternalFileList = NULL; AcpiDbgLevel = 0; PrInitializePreprocessor(); AcpiGbl_DmOpt_Verbose = FALSE; AcpiGbl_IntegerBitWidth = 64; AcpiGbl_IntegerNybbleWidth = 16; AcpiGbl_IntegerByteWidth = 8; for (i = 0; i < ASL_NUM_FILES; i++) { Gbl_Files[i].Handle = NULL; Gbl_Files[i].Filename = NULL; } Gbl_Files[ASL_FILE_STDOUT].Handle = stdout; Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT"; Gbl_Files[ASL_FILE_STDERR].Handle = stdout; Gbl_Files[ASL_FILE_STDERR].Filename = "STDOUT"; Gbl_LineBufferSize = 1024; Gbl_CurrentLineBuffer = NULL; Gbl_MainTokenBuffer = NULL; UtExpandLineBuffers(); }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_STATUS Status; int j; ACPI_DEBUG_INITIALIZE (); /* For debug version only */ /* Init debug globals and ACPICA */ AcpiDbgLevel = ACPI_LV_TABLES; AcpiDbgLayer = 0xFFFFFFFF; Status = AcpiInitializeSubsystem (); AE_CHECK_OK (AcpiInitializeSubsystem, Status); if (ACPI_FAILURE (Status)) { return (-1); } printf (ACPI_COMMON_SIGNON (AN_UTILITY_NAME)); if (argc < 2) { usage (); return (0); } /* Get the command line options */ while ((j = AcpiGetopt (argc, argv, AN_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j) { case 'v': /* -v: (Version): signon already emitted, just exit */ return (0); case '?': case 'h': default: usage(); return (0); } /* * The next argument is the filename for the DSDT or SSDT. * Open the file, build namespace and dump it. */ return (NsDumpEntireNamespace (argv[AcpiGbl_Optind])); }
int ACPI_SYSTEM_XFACE main ( int argc, char *argv[]) { int j; ACPI_CONVERSION_TABLE *ConversionTable = NULL; char *SourcePath; char *TargetPath; UINT32 FileType; ACPI_DEBUG_INITIALIZE (); /* For debug version only */ AcpiOsInitialize (); printf (ACPI_COMMON_SIGNON (AS_UTILITY_NAME)); if (argc < 2) { AsDisplayUsage (); return (0); } /* Command line options */ while ((j = AcpiGetopt (argc, argv, AS_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j) { case 'l': /* Linux code generation */ printf ("Creating Linux source code\n"); ConversionTable = &LinuxConversionTable; Gbl_WidenDeclarations = TRUE; Gbl_IgnoreLoneLineFeeds = TRUE; break; case 'c': /* Cleanup code */ printf ("Code cleanup\n"); ConversionTable = &CleanupConversionTable; Gbl_Cleanup = TRUE; break; case 'h': /* Inject Dual-license header */ printf ("Inserting Dual-license header to all modules\n"); ConversionTable = &LicenseConversionTable; break; case 'i': /* Cleanup wrong indent result */ printf ("Cleaning up macro indentation\n"); ConversionTable = &IndentConversionTable; Gbl_IgnoreLoneLineFeeds = TRUE; Gbl_IgnoreTranslationEscapes = TRUE; break; case 's': /* Statistics only */ break; case 'u': /* custom conversion */ printf ("Custom source translation\n"); ConversionTable = &CustomConversionTable; break; case 'v': switch (AcpiGbl_Optarg[0]) { case '^': /* -v: (Version): signon already emitted, just exit */ exit (0); case 'b': /* Verbose mode */ Gbl_VerboseMode = TRUE; break; default: printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); return (-1); } break; case 'y': /* Batch mode */ Gbl_BatchMode = TRUE; break; case 'd': /* Leave debug statements in */ Gbl_DebugStatementsMode = TRUE; break; case 'q': /* Quiet mode */ Gbl_QuietMode = TRUE; break; default: AsDisplayUsage (); return (-1); } SourcePath = argv[AcpiGbl_Optind]; if (!SourcePath) { printf ("Missing source path\n"); AsDisplayUsage (); return (-1); } TargetPath = argv[AcpiGbl_Optind+1]; if (!ConversionTable) { /* Just generate statistics. Ignore target path */ TargetPath = SourcePath; printf ("Source code statistics only\n"); ConversionTable = &StatsConversionTable; } else if (!TargetPath) { TargetPath = SourcePath; } if (Gbl_DebugStatementsMode) { ConversionTable->SourceFunctions &= ~CVT_REMOVE_DEBUG_MACROS; } /* Check source and target paths and files */ if (AsExaminePaths (ConversionTable, SourcePath, TargetPath, &FileType)) { return (-1); } /* Source/target can be either directories or a files */ if (FileType == S_IFDIR) { /* Process the directory tree */ AsProcessTree (ConversionTable, SourcePath, TargetPath); } else { /* Process a single file */ /* Differentiate between source and header files */ if (strstr (SourcePath, ".h")) { AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, SourcePath, FILE_TYPE_HEADER); } else if (strstr (SourcePath, ".c")) { AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, SourcePath, FILE_TYPE_SOURCE); } else if (strstr (SourcePath, ".patch")) { AsProcessOneFile (ConversionTable, NULL, TargetPath, 0, SourcePath, FILE_TYPE_PATCH); } else { printf ("Unknown file type - %s\n", SourcePath); } } /* Always display final summary and stats */ AsDisplayStats (); return (0); }
int main ( int argc, char *argv[]) { char *Filename; int AxAction; int Status; int j; Gbl_TableCount = 0; Gbl_TableListHead = NULL; AxAction = AX_EXTRACT_AML_TABLES; /* Default: DSDT & SSDTs */ ACPI_DEBUG_INITIALIZE (); /* For debug version only */ AcpiOsInitialize (); printf (ACPI_COMMON_SIGNON (AX_UTILITY_NAME)); if (argc < 2) { DisplayUsage (); return (0); } /* Command line options */ while ((j = AcpiGetopt (argc, argv, AX_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) { case 'a': AxAction = AX_EXTRACT_ALL; /* Extract all tables found */ break; case 'l': AxAction = AX_LIST_ALL; /* List tables only, do not extract */ break; case 'm': AxAction = AX_EXTRACT_MULTI_TABLE; /* Make single file for all DSDT/SSDTs */ break; case 's': AxAction = AX_EXTRACT_SIGNATURE; /* Extract only tables with this sig */ break; case 'v': /* -v: (Version): signon already emitted, just exit */ return (0); case 'h': default: DisplayUsage (); return (0); } /* Input filename is always required */ Filename = argv[AcpiGbl_Optind]; if (!Filename) { printf ("Missing required input filename\n"); return (-1); } /* Perform requested action */ switch (AxAction) { case AX_EXTRACT_ALL: Status = AxExtractTables (Filename, NULL, AX_OPTIONAL_TABLES); break; case AX_EXTRACT_MULTI_TABLE: Status = AxExtractToMultiAmlFile (Filename); break; case AX_LIST_ALL: Status = AxListTables (Filename); break; case AX_EXTRACT_SIGNATURE: Status = AxExtractTables (Filename, AcpiGbl_Optarg, AX_REQUIRED_TABLE); break; default: /* * Default output is the DSDT and all SSDTs. One DSDT is required, * any SSDTs are optional. */ Status = AxExtractTables (Filename, "DSDT", AX_REQUIRED_TABLE); if (Status) { return (Status); } Status = AxExtractTables (Filename, "SSDT", AX_OPTIONAL_TABLES); break; } return (Status); }
int ACPI_SYSTEM_XFACE main ( int argc, char *argv[]) { char *Name; UINT32 DecodeType; int j; AcpiOsInitialize (); ACPI_DEBUG_INITIALIZE (); /* For debug version only */ printf (ACPI_COMMON_SIGNON (AH_UTILITY_NAME)); DecodeType = AH_DECODE_DEFAULT; if (argc < 2) { AhDisplayUsage (); return (0); } /* Command line options */ while ((j = AcpiGetopt (argc, argv, AH_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) { case 'a': DecodeType = AH_DECODE_ASL_AML; break; case 'e': DecodeType = AH_DECODE_EXCEPTION; break; case 'i': DecodeType = AH_DISPLAY_DEVICE_IDS; break; case 'k': DecodeType = AH_DECODE_ASL_KEYWORD; break; case 'm': DecodeType = AH_DECODE_AML; break; case 'o': DecodeType = AH_DECODE_AML_OPCODE; break; case 'p': DecodeType = AH_DECODE_PREDEFINED_NAME; break; case 's': DecodeType = AH_DECODE_ASL; break; case 'u': DecodeType = AH_DISPLAY_UUIDS; break; case 'v': /* -v: (Version): signon already emitted, just exit */ return (0); case 'h': default: AhDisplayUsage (); return (-1); } /* Missing (null) name means "display all" */ Name = argv[AcpiGbl_Optind]; switch (DecodeType) { case AH_DECODE_ASL_AML: AhFindAslAndAmlOperators (Name); break; case AH_DECODE_AML: AhFindAmlOpcode (Name); break; case AH_DECODE_AML_OPCODE: AhDecodeAmlOpcode (Name); break; case AH_DECODE_PREDEFINED_NAME: AhFindPredefinedNames (Name); break; case AH_DECODE_ASL: AhFindAslOperators (Name); break; case AH_DECODE_ASL_KEYWORD: AhFindAslKeywords (Name); break; case AH_DISPLAY_DEVICE_IDS: AhDisplayDeviceIds (Name); break; case AH_DECODE_EXCEPTION: AhDecodeException (Name); break; case AH_DISPLAY_UUIDS: AhDisplayUuids (); break; default: if (!Name) { AhFindAslOperators (Name); break; } if (*Name == '_') { AhFindPredefinedNames (Name); } else { AhFindAslAndAmlOperators (Name); } break; } return (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); }
int ACPI_SYSTEM_XFACE main ( int argc, char *argv[]) { int j; int Status = AE_OK; ACPI_DEBUG_INITIALIZE (); /* For debug version only */ AcpiGbl_DebugFile = NULL; AcpiGbl_DbOutputFlags = DB_CONSOLE_OUTPUT; AcpiOsInitialize (); printf (ACPI_COMMON_SIGNON (AB_UTILITY_NAME)); if (argc < 2) { AbDisplayUsage (0); return (0); } /* Command line options */ while ((j = AcpiGetopt (argc, argv, AB_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j) { case 'c': /* Compare Files */ if (argc < 4) { AbDisplayUsage (2); return (-1); } Status = AbCompareAmlFiles (AcpiGbl_Optarg, argv[AcpiGbl_Optind]); break; case 'd': /* Dump AML file */ if (argc < 4) { AbDisplayUsage (2); return (-1); } Status = AbDumpAmlFile (AcpiGbl_Optarg, argv[AcpiGbl_Optind]); break; case 'h': /* Display ACPI table header */ if (argc < 3) { AbDisplayUsage (1); return (-1); } AbDisplayHeader (AcpiGbl_Optarg); return (0); case 's': /* Compute/update checksum */ if (argc < 3) { AbDisplayUsage (1); return (-1); } AbComputeChecksum (AcpiGbl_Optarg); return (0); case 't': /* Enable terse mode */ Gbl_TerseMode = TRUE; break; case 'v': /* -v: (Version): signon already emitted, just exit */ return (0); default: AbDisplayUsage (0); return (-1); } 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 acpi_main(int argc, char *argv[]) #endif { int status = 0; struct ap_dump_action *action; u32 file_size; u32 i; ACPI_DEBUG_INITIALIZE(); /* For debug version only */ acpi_os_initialize(); gbl_output_file = ACPI_FILE_OUT; acpi_gbl_integer_byte_width = 8; /* Process command line options */ status = ap_do_options(argc, argv); if (status > 0) { return (0); } if (status < 0) { return (status); } /* Get/dump ACPI table(s) as requested */ for (i = 0; i < current_action; i++) { action = &action_table[i]; switch (action->to_be_done) { case AP_DUMP_ALL_TABLES: status = ap_dump_all_tables(); break; case AP_DUMP_TABLE_BY_ADDRESS: status = ap_dump_table_by_address(action->argument); break; case AP_DUMP_TABLE_BY_NAME: status = ap_dump_table_by_name(action->argument); break; case AP_DUMP_TABLE_BY_FILE: status = ap_dump_table_from_file(action->argument); break; default: fprintf(stderr, "Internal error, invalid action: 0x%X\n", action->to_be_done); return (-1); } if (status) { return (status); } } if (gbl_output_filename) { if (gbl_verbose_mode) { /* Summary for the output file */ file_size = cm_get_file_size(gbl_output_file); fprintf(stderr, "Output file %s contains 0x%X (%u) bytes\n\n", gbl_output_filename, file_size, file_size); } fclose(gbl_output_file); } return (status); }
int ACPI_SYSTEM_XFACE main ( int argc, char *argv[]) { int Status = 0; AP_DUMP_ACTION *Action; UINT32 FileSize; UINT32 i; ACPI_DEBUG_INITIALIZE (); /* For debug version only */ /* Process command line options */ if (ApDoOptions (argc, argv)) { return (-1); } /* Get/dump ACPI table(s) as requested */ for (i = 0; i < CurrentAction; i++) { Action = &ActionTable[i]; switch (Action->ToBeDone) { case AP_DUMP_ALL_TABLES: Status = ApDumpAllTables (); break; case AP_DUMP_TABLE_BY_ADDRESS: Status = ApDumpTableByAddress (Action->Argument); break; case AP_DUMP_TABLE_BY_NAME: Status = ApDumpTableByName (Action->Argument); break; case AP_DUMP_TABLE_BY_FILE: Status = ApDumpTableFromFile (Action->Argument); break; default: fprintf (stderr, "Internal error, invalid action: 0x%X\n", Action->ToBeDone); return (-1); } if (Status) { return (Status); } } if (Gbl_OutputFile) { if (Gbl_VerboseMode) { /* Summary for the output file */ FileSize = CmGetFileSize (Gbl_OutputFile); fprintf (stderr, "Output file %s contains 0x%X (%u) bytes\n\n", Gbl_OutputFilename, FileSize, FileSize); } fclose (Gbl_OutputFile); } return (Status); }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_NEW_TABLE_DESC *ListHead = NULL; ACPI_STATUS Status; int j; ACPI_DEBUG_INITIALIZE (); /* For debug version only */ /* Init debug globals and ACPICA */ AcpiDbgLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES; AcpiDbgLayer = 0xFFFFFFFF; /* Set flags so that the interpreter is not used */ Status = AcpiInitializeSubsystem (); ACPI_CHECK_OK (AcpiInitializeSubsystem, Status); if (ACPI_FAILURE (Status)) { return (-1); } printf (ACPI_COMMON_SIGNON (AN_UTILITY_NAME)); if (argc < 2) { usage (); return (0); } /* Get the command line options */ while ((j = AcpiGetopt (argc, argv, AN_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j) { case 'l': AcpiGbl_NsLoadOnly = TRUE; break; case 'v': switch (AcpiGbl_Optarg[0]) { case '^': /* -v: (Version): signon already emitted, just exit */ exit (0); case 'd': printf (ACPI_COMMON_BUILD_TIME); return (0); default: printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); return (-1); } break; case 'x': AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 0); printf ("Debug Level: 0x%8.8X\n", AcpiDbgLevel); break; case '?': case 'h': default: usage(); return (0); } /* Get each of the ACPI table files on the command line */ while (argv[AcpiGbl_Optind]) { /* Get all ACPI AML tables in this file */ Status = AcGetAllTablesFromFile (argv[AcpiGbl_Optind], ACPI_GET_ALL_TABLES, &ListHead); if (ACPI_FAILURE (Status)) { return (-1); } AcpiGbl_Optind++; } printf ("\n"); /* * The next argument is the filename for the DSDT or SSDT. * Open the file, build namespace and dump it. */ return (AnDumpEntireNamespace (ListHead)); }
int ACPI_SYSTEM_XFACE main ( int argc, char *argv[]) { char *Name; UINT32 DecodeType; int j; ACPI_DEBUG_INITIALIZE (); /* For debug version only */ printf (ACPI_COMMON_SIGNON ("ACPI Help Utility")); DecodeType = AH_DECODE_DEFAULT; if (argc < 2) { AhDisplayUsage (); return (0); } /* Command line options */ while ((j = AcpiGetopt (argc, argv, "ehikmops")) != EOF) switch (j) { case 'e': DecodeType = AH_DECODE_EXCEPTION; break; case 'i': DecodeType = AH_DISPLAY_DEVICE_IDS; break; case 'k': DecodeType = AH_DECODE_ASL_KEYWORD; break; case 'm': DecodeType = AH_DECODE_AML; break; case 'o': DecodeType = AH_DECODE_AML_OPCODE; break; case 'p': DecodeType = AH_DECODE_PREDEFINED_NAME; break; case 's': DecodeType = AH_DECODE_ASL; break; case 'h': default: AhDisplayUsage (); return (-1); } /* Missing (null) name means "display all" */ Name = argv[AcpiGbl_Optind]; switch (DecodeType) { case AH_DECODE_AML: AhFindAmlOpcode (Name); break; case AH_DECODE_AML_OPCODE: AhDecodeAmlOpcode (Name); break; case AH_DECODE_PREDEFINED_NAME: AhFindPredefinedNames (Name); break; case AH_DECODE_ASL: AhFindAslOperators (Name); break; case AH_DECODE_ASL_KEYWORD: AhFindAslKeywords (Name); break; case AH_DISPLAY_DEVICE_IDS: AhDisplayDeviceIds (); break; case AH_DECODE_EXCEPTION: AhDecodeException (Name); break; default: if (!Name) { AhFindAslOperators (Name); break; } if (*Name == '_') { AhFindPredefinedNames (Name); } else { AhFindAslOperators (Name); } break; } return (0); }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_NEW_TABLE_DESC *ListHead = NULL; ACPI_STATUS Status; UINT32 InitFlags; int ExitCode = 0; ACPI_DEBUG_INITIALIZE (); /* For debug version only */ signal (SIGINT, AeCtrlCHandler); /* Init debug globals */ AcpiDbgLevel = ACPI_NORMAL_DEFAULT; AcpiDbgLayer = 0xFFFFFFFF; /* * Initialize ACPICA and start debugger thread. * * NOTE: After ACPICA initialization, AcpiTerminate MUST be called * before this procedure exits -- otherwise, the console may be * left in an incorrect state. */ Status = AcpiInitializeSubsystem (); ACPI_CHECK_OK (AcpiInitializeSubsystem, Status); if (ACPI_FAILURE (Status)) { goto ErrorExit; } /* ACPICA runtime configuration */ AcpiGbl_MaxLoopIterations = 400; /* Initialize the AML debugger */ Status = AcpiInitializeDebugger (); ACPI_CHECK_OK (AcpiInitializeDebugger, Status); if (ACPI_FAILURE (Status)) { goto ErrorExit; } printf (ACPI_COMMON_SIGNON (ACPIEXEC_NAME)); if (argc < 2) { usage (); goto NormalExit; } /* Get the command line options */ ExitCode = AeDoOptions (argc, argv); if (ExitCode) { if (ExitCode > 0) { ExitCode = 0; } goto ErrorExit; } /* The remaining arguments are filenames for ACPI tables */ if (!argv[AcpiGbl_Optind]) { goto EnterDebugger; } AcpiGbl_CstyleDisassembly = FALSE; /* Not supported for AcpiExec */ /* Get each of the ACPI table files on the command line */ while (argv[AcpiGbl_Optind]) { /* Get all ACPI AML tables in this file */ Status = AcGetAllTablesFromFile (argv[AcpiGbl_Optind], ACPI_GET_ALL_TABLES, &ListHead); if (ACPI_FAILURE (Status)) { ExitCode = -1; goto ErrorExit; } AcpiGbl_Optind++; } printf ("\n"); /* Build a local RSDT with all tables and let ACPICA process the RSDT */ Status = AeBuildLocalTables (ListHead); if (ACPI_FAILURE (Status)) { goto ErrorExit; } /* Install all of the ACPI tables */ Status = AeInstallTables (); if (ACPI_FAILURE (Status)) { printf ("**** Could not install ACPI tables, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } /* * Install most of the handlers (Regions, Notify, Table, etc.) * Override the default region handlers, especially SystemMemory, * which is simulated in this utility. */ 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_NoIniMethods) { 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? * * NOTE: This initialization does not match the _Lxx and _Exx methods * to individual GPEs, as there are no real GPEs when the hardware * is simulated - because there is no namespace until AeLoadTables is * executed. This may have to change if AcpiExec is ever run natively * on actual hardware (such as under UEFI). */ Status = AcpiEnableSubsystem (InitFlags); if (ACPI_FAILURE (Status)) { printf ("**** Could not EnableSubsystem, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } Status = AeLoadTables (); /* * Exit namespace initialization for the "load namespace only" option. * No control methods will be executed. However, still enter the * the debugger. */ if (AcpiGbl_AeLoadOnly) { goto EnterDebugger; } if (ACPI_FAILURE (Status)) { printf ("**** Could not load ACPI tables, %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: AcpiRunDebugger (NULL); break; case AE_MODE_BATCH_MULTIPLE: AcpiRunDebugger (BatchBuffer); break; case AE_MODE_BATCH_SINGLE: AcpiDbExecute (BatchBuffer, NULL, NULL, EX_NO_SINGLE_STEP); break; } /* Shut down the debugger and ACPICA */ AcpiTerminateDebugger (); NormalExit: ExitCode = 0; ErrorExit: (void) AcpiOsTerminate (); return (ExitCode); }
int ACPI_SYSTEM_XFACE main ( int argc, char *argv[]) { int j; int Status = AE_OK; ACPI_DEBUG_INITIALIZE (); /* For debug version only */ AcpiGbl_DebugFile = NULL; AcpiGbl_DbOutputFlags = DB_CONSOLE_OUTPUT; AcpiOsInitialize (); printf (ACPI_COMMON_SIGNON ("ACPI Binary AML File Utility")); if (argc < 2) { AbDisplayUsage (0); return (0); } /* Command line options */ while ((j = AcpiGetopt (argc, argv, "c:d:e:h:s:t")) != EOF) switch(j) { case 'c': /* Compare Files */ if (argc < 4) { AbDisplayUsage (2); return (-1); } Status = AbCompareAmlFiles (AcpiGbl_Optarg, argv[AcpiGbl_Optind]); break; case 'd': /* Dump AML file */ if (argc < 4) { AbDisplayUsage (2); return (-1); } Status = AbDumpAmlFile (AcpiGbl_Optarg, argv[AcpiGbl_Optind]); break; case 'e': /* Extract AML text file */ if (argc < 5) { AbDisplayUsage (3); return (-1); } Status = AbExtractAmlFile (AcpiGbl_Optarg, argv[AcpiGbl_Optind], argv[AcpiGbl_Optind+1]); break; case 'h': /* Display ACPI table header */ if (argc < 3) { AbDisplayUsage (1); return (-1); } AbDisplayHeader (AcpiGbl_Optarg); return (0); case 's': /* Compute/update checksum */ if (argc < 3) { AbDisplayUsage (1); return (-1); } AbComputeChecksum (AcpiGbl_Optarg); return (0); case 't': /* Enable terse mode */ Gbl_TerseMode = TRUE; break; default: AbDisplayUsage (0); return (-1); } return (Status); }