ACPI_STATUS AcpiTerminate ( void) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE (AcpiTerminate); /* Just exit if subsystem is already shutdown */ if (AcpiGbl_Shutdown) { ACPI_ERROR ((AE_INFO, "ACPI Subsystem is already terminated")); return_ACPI_STATUS (AE_OK); } /* Subsystem appears active, go ahead and shut it down */ AcpiGbl_Shutdown = TRUE; AcpiGbl_StartupFlags = 0; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n")); /* Terminate the AML Debugger if present */ ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = TRUE); /* Shutdown and free all resources */ AcpiUtSubsystemShutdown (); /* Free the mutex objects */ AcpiUtMutexTerminate (); #ifdef ACPI_DEBUGGER /* Shut down the debugger */ AcpiDbTerminate (); #endif /* Now we can shutdown the OS-dependent layer */ Status = AcpiOsTerminate (); return_ACPI_STATUS (Status); }
ACPI_STATUS ACPI_INIT_FUNCTION AcpiTerminate ( void) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE (AcpiTerminate); /* Shutdown and free all resources */ AcpiUtSubsystemShutdown (); /* Free the mutex objects */ AcpiUtMutexTerminate (); /* Now we can shutdown the OS-dependent layer */ Status = AcpiOsTerminate (); return_ACPI_STATUS (Status); }
void ACPI_SYSTEM_XFACE AeCtrlCHandler ( int Sig) { signal (SIGINT, SIG_IGN); SigintCount++; AcpiOsPrintf ("Caught a ctrl-c (#%u)\n\n", SigintCount); if (AcpiGbl_MethodExecuting) { AcpiGbl_AbortMethod = TRUE; signal (SIGINT, AeCtrlCHandler); if (SigintCount < 10) { return; } } (void) AcpiOsTerminate (); exit (0); }
ACPI_STATUS AcpiTerminate ( void) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE (AcpiTerminate); /* Terminate the AML Debugger if present */ ACPI_DEBUGGER_EXEC(AcpiGbl_DbTerminateThreads = TRUE); /* Shutdown and free all resources */ AcpiUtSubsystemShutdown (); /* Free the mutex objects */ AcpiUtMutexTerminate (); #ifdef ACPI_DEBUGGER /* Shut down the debugger */ AcpiDbTerminate (); #endif /* Now we can shutdown the OS-dependent layer */ Status = AcpiOsTerminate (); return_ACPI_STATUS (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); }
static int AeDoOptions ( int argc, char **argv) { int j; while ((j = AcpiGetopt (argc, argv, AE_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) { case 'b': if (strlen (AcpiGbl_Optarg) > (AE_BUFFER_SIZE -1)) { printf ("**** The length of command line (%u) exceeded maximum (%u)\n", (UINT32) strlen (AcpiGbl_Optarg), (AE_BUFFER_SIZE -1)); return (-1); } AcpiGbl_ExecutionMode = AE_MODE_BATCH_MULTIPLE; strcpy (BatchBuffer, AcpiGbl_Optarg); break; case 'd': switch (AcpiGbl_Optarg[0]) { case 'a': AcpiGbl_IgnoreErrors = TRUE; break; case 'i': AcpiGbl_DbOpt_ini_methods = FALSE; break; case 'o': AcpiGbl_DbOpt_NoRegionSupport = TRUE; break; case 'r': AcpiGbl_DisableAutoRepair = TRUE; break; case 's': AcpiGbl_AutoSerializeMethods = FALSE; break; case 't': #ifdef ACPI_DBG_TRACK_ALLOCATIONS AcpiGbl_DisableMemTracking = TRUE; #endif break; default: printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); return (-1); } break; case 'e': switch (AcpiGbl_Optarg[0]) { case 'f': #ifdef ACPI_DBG_TRACK_ALLOCATIONS AcpiGbl_DisplayFinalMemStats = TRUE; #endif break; case 'i': AcpiGbl_DoInterfaceTests = TRUE; break; case 'l': AcpiGbl_LoadTestTables = TRUE; break; case 's': AcpiGbl_EnableInterpreterSlack = TRUE; printf ("Enabling AML Interpreter slack mode\n"); break; case 't': AcpiGbl_DebugTimeout = TRUE; break; default: printf ("Unknown option: -e%s\n", AcpiGbl_Optarg); return (-1); } break; case 'f': switch (AcpiGbl_Optarg[0]) { case 'v': /* -fv: region fill value */ if (AcpiGetoptArgument (argc, argv)) { return (-1); } AcpiGbl_RegionFillValue = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); break; case 'i': /* -fi: specify initialization file */ if (AcpiGetoptArgument (argc, argv)) { return (-1); } if (AeOpenInitializationFile (AcpiGbl_Optarg)) { return (-1); } break; default: printf ("Unknown option: -f%s\n", AcpiGbl_Optarg); return (-1); } break; case 'g': AcpiGbl_DbOpt_tables = TRUE; AcpiGbl_DbFilename = NULL; break; case 'h': case '?': usage(); return (0); case 'm': AcpiGbl_ExecutionMode = AE_MODE_BATCH_SINGLE; switch (AcpiGbl_Optarg[0]) { case '^': strcpy (BatchBuffer, "MAIN"); break; default: strcpy (BatchBuffer, AcpiGbl_Optarg); break; } break; case 'o': AcpiGbl_DbOpt_disasm = TRUE; AcpiGbl_DbOpt_stats = TRUE; break; case 'r': AcpiGbl_UseHwReducedFadt = TRUE; printf ("Using ACPI 5.0 Hardware Reduced Mode via version 5 FADT\n"); break; case 'v': switch (AcpiGbl_Optarg[0]) { case '^': /* -v: (Version): signon already emitted, just exit */ (void) AcpiOsTerminate (); exit (0); case 'i': AcpiDbgLevel |= ACPI_LV_INIT_NAMES; break; case 'r': AcpiGbl_DisplayRegionAccess = TRUE; break; default: printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); return (-1); } break; case 'x': AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 0); AcpiGbl_DbConsoleDebugLevel = AcpiDbgLevel; printf ("Debug Level: 0x%8.8X\n", AcpiDbgLevel); break; default: usage(); return (-1); } 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); }