ACPI_STATUS AcpiDisable ( void) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE (AcpiDisable); if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY) { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in legacy (non-ACPI) mode\n")); } else { /* Transition to LEGACY mode */ Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY); if (ACPI_FAILURE (Status)) { ACPI_ERROR ((AE_INFO, "Could not exit ACPI mode to legacy mode")); return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n")); } return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiDisable (void) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("AcpiDisable"); if (!AcpiGbl_FADT) { ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n")); return_ACPI_STATUS (AE_NO_ACPI_TABLES); } if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY) { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in legacy (non-ACPI) mode\n")); } else { /* Transition to LEGACY mode */ Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not exit ACPI mode to legacy mode")); return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n")); } return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiEnable ( void) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE (AcpiEnable); /* ACPI tables must be present */ if (AcpiGbl_FadtIndex == ACPI_INVALID_TABLE_INDEX) { return_ACPI_STATUS (AE_NO_ACPI_TABLES); } /* If the Hardware Reduced flag is set, machine is always in acpi mode */ if (AcpiGbl_ReducedHardware) { return_ACPI_STATUS (AE_OK); } /* Check current mode */ if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI) { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n")); } else { /* Transition to ACPI mode */ Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI); if (ACPI_FAILURE (Status)) { ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode")); return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Transition to ACPI mode successful\n")); } return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiDisable ( void) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE (AcpiDisable); /* If the Hardware Reduced flag is set, machine is always in acpi mode */ if (AcpiGbl_ReducedHardware) { return_ACPI_STATUS (AE_OK); } if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY) { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in legacy (non-ACPI) mode\n")); } else { /* Transition to LEGACY mode */ Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY); if (ACPI_FAILURE (Status)) { ACPI_ERROR ((AE_INFO, "Could not exit ACPI mode to legacy mode")); return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n")); } return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiEnable ( void) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE (AcpiEnable); /* ACPI tables must be present */ if (!AcpiTbTablesLoaded ()) { return_ACPI_STATUS (AE_NO_ACPI_TABLES); } /* Check current mode */ if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI) { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n")); } else { /* Transition to ACPI mode */ Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI); if (ACPI_FAILURE (Status)) { ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode")); return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Transition to ACPI mode successful\n")); } return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiEnable (void) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("AcpiEnable"); /* Make sure we have the FADT*/ if (!AcpiGbl_FADT) { ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n")); return_ACPI_STATUS (AE_NO_ACPI_TABLES); } if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI) { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n")); } else { /* Transition to ACPI mode */ Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("Could not transition to ACPI mode.\n")); return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Transition to ACPI mode successful\n")); } return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiHwSetMode ( UINT32 Mode) { ACPI_STATUS Status; UINT32 Retry; ACPI_FUNCTION_TRACE (HwSetMode); /* If the Hardware Reduced flag is set, machine is always in acpi mode */ if (AcpiGbl_ReducedHardware) { return_ACPI_STATUS (AE_OK); } /* * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, * system does not support mode transition. */ if (!AcpiGbl_FADT.SmiCommand) { ACPI_ERROR ((AE_INFO, "No SMI_CMD in FADT, mode transition failed")); return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); } /* * ACPI 2.0 clarified the meaning of ACPI_ENABLE and ACPI_DISABLE * in FADT: If it is zero, enabling or disabling is not supported. * As old systems may have used zero for mode transition, * we make sure both the numbers are zero to determine these * transitions are not supported. */ if (!AcpiGbl_FADT.AcpiEnable && !AcpiGbl_FADT.AcpiDisable) { ACPI_ERROR ((AE_INFO, "No ACPI mode transition supported in this system " "(enable/disable both zero)")); return_ACPI_STATUS (AE_OK); } switch (Mode) { case ACPI_SYS_MODE_ACPI: /* BIOS should have disabled ALL fixed and GP events */ Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, (UINT32) AcpiGbl_FADT.AcpiEnable, 8); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n")); break; case ACPI_SYS_MODE_LEGACY: /* * BIOS should clear all fixed status bits and restore fixed event * enable bits to default */ Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, (UINT32) AcpiGbl_FADT.AcpiDisable, 8); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable Legacy (non-ACPI) mode\n")); break; default: return_ACPI_STATUS (AE_BAD_PARAMETER); } if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "Could not write ACPI mode change")); return_ACPI_STATUS (Status); } /* * Some hardware takes a LONG time to switch modes. Give them 3 sec to * do so, but allow faster systems to proceed more quickly. */ Retry = 3000; while (Retry) { if (AcpiHwGetMode () == Mode) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", Mode)); return_ACPI_STATUS (AE_OK); } AcpiOsStall (ACPI_USEC_PER_MSEC); Retry--; } ACPI_ERROR ((AE_INFO, "Hardware did not change modes")); return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); }
ACPI_STATUS AcpiEnableSubsystem ( UINT32 Flags) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE (AcpiEnableSubsystem); #if (!ACPI_REDUCED_HARDWARE) /* Enable ACPI mode */ if (!(Flags & ACPI_NO_ACPI_ENABLE)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n")); AcpiGbl_OriginalMode = AcpiHwGetMode(); Status = AcpiEnable (); if (ACPI_FAILURE (Status)) { ACPI_WARNING ((AE_INFO, "AcpiEnable failed")); return_ACPI_STATUS (Status); } } /* * Obtain a permanent mapping for the FACS. This is required for the * Global Lock and the Firmware Waking Vector */ Status = AcpiTbInitializeFacs (); if (ACPI_FAILURE (Status)) { ACPI_WARNING ((AE_INFO, "Could not map the FACS table")); return_ACPI_STATUS (Status); } #endif /* !ACPI_REDUCED_HARDWARE */ /* * Install the default OpRegion handlers. These are installed unless * other handlers have already been installed via the * InstallAddressSpaceHandler interface. */ if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n")); Status = AcpiEvInstallRegionHandlers (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } #if (!ACPI_REDUCED_HARDWARE) /* * Initialize ACPI Event handling (Fixed and General Purpose) * * Note1: We must have the hardware and events initialized before we can * execute any control methods safely. Any control method can require * ACPI hardware support, so the hardware must be fully initialized before * any method execution! * * Note2: Fixed events are initialized and enabled here. GPEs are * initialized, but cannot be enabled until after the hardware is * completely initialized (SCI and GlobalLock activated) and the various * initialization control methods are run (_REG, _STA, _INI) on the * entire namespace. */ if (!(Flags & ACPI_NO_EVENT_INIT)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI events\n")); Status = AcpiEvInitializeEvents (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* * Install the SCI handler and Global Lock handler. This completes the * hardware initialization. */ if (!(Flags & ACPI_NO_HANDLER_INIT)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL handlers\n")); Status = AcpiEvInstallXruptHandlers (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } #endif /* !ACPI_REDUCED_HARDWARE */ return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiEnableSubsystem ( UINT32 Flags) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE (AcpiEnableSubsystem); /* * The early initialization phase is complete. The namespace is loaded, * and we can now support address spaces other than Memory, I/O, and * PCI_Config. */ AcpiGbl_EarlyInitialization = FALSE; /* * Install the default operation region handlers. These are the * handlers that are defined by the ACPI specification to be * "always accessible" -- namely, SystemMemory, SystemIO, and * PCI_Config. This also means that no _REG methods need to be * run for these address spaces. We need to have these handlers * installed before any AML code can be executed, especially any * module-level code (11/2015). */ if (!AcpiGbl_GroupModuleLevelCode) { Status = AcpiEvInstallRegionHandlers (); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization")); return_ACPI_STATUS (Status); } } #if (!ACPI_REDUCED_HARDWARE) /* Enable ACPI mode */ if (!(Flags & ACPI_NO_ACPI_ENABLE)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n")); AcpiGbl_OriginalMode = AcpiHwGetMode(); Status = AcpiEnable (); if (ACPI_FAILURE (Status)) { ACPI_WARNING ((AE_INFO, "AcpiEnable failed")); return_ACPI_STATUS (Status); } } /* * Obtain a permanent mapping for the FACS. This is required for the * Global Lock and the Firmware Waking Vector */ if (!(Flags & ACPI_NO_FACS_INIT)) { Status = AcpiTbInitializeFacs (); if (ACPI_FAILURE (Status)) { ACPI_WARNING ((AE_INFO, "Could not map the FACS table")); return_ACPI_STATUS (Status); } } /* * Initialize ACPI Event handling (Fixed and General Purpose) * * Note1: We must have the hardware and events initialized before we can * execute any control methods safely. Any control method can require * ACPI hardware support, so the hardware must be fully initialized before * any method execution! * * Note2: Fixed events are initialized and enabled here. GPEs are * initialized, but cannot be enabled until after the hardware is * completely initialized (SCI and GlobalLock activated) and the various * initialization control methods are run (_REG, _STA, _INI) on the * entire namespace. */ if (!(Flags & ACPI_NO_EVENT_INIT)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI events\n")); Status = AcpiEvInitializeEvents (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* * Install the SCI handler and Global Lock handler. This completes the * hardware initialization. */ if (!(Flags & ACPI_NO_HANDLER_INIT)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL handlers\n")); Status = AcpiEvInstallXruptHandlers (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } #endif /* !ACPI_REDUCED_HARDWARE */ return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiEnableSubsystem ( UINT32 Flags) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE (AcpiEnableSubsystem); /* Enable ACPI mode */ if (!(Flags & ACPI_NO_ACPI_ENABLE)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n")); AcpiGbl_OriginalMode = AcpiHwGetMode(); Status = AcpiEnable (); if (ACPI_FAILURE (Status)) { ACPI_WARNING ((AE_INFO, "AcpiEnable failed")); return_ACPI_STATUS (Status); } } /* * Install the default OpRegion handlers. These are installed unless * other handlers have already been installed via the * InstallAddressSpaceHandler interface. */ if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n")); Status = AcpiEvInstallRegionHandlers (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* * Initialize ACPI Event handling (Fixed and General Purpose) * * Note1: We must have the hardware and events initialized before we can * execute any control methods safely. Any control method can require * ACPI hardware support, so the hardware must be fully initialized before * any method execution! * * Note2: Fixed events are initialized and enabled here. GPEs are * initialized, but cannot be enabled until after the hardware is * completely initialized (SCI and GlobalLock activated) */ if (!(Flags & ACPI_NO_EVENT_INIT)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI events\n")); Status = AcpiEvInitializeEvents (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* * Install the SCI handler and Global Lock handler. This completes the * hardware initialization. */ if (!(Flags & ACPI_NO_HANDLER_INIT)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL handlers\n")); Status = AcpiEvInstallXruptHandlers (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* * Complete the GPE initialization for the GPE blocks defined in the FADT * (GPE block 0 and 1). * * Note1: This is where the _PRW methods are executed for the GPEs. These * methods can only be executed after the SCI and Global Lock handlers are * installed and initialized. * * Note2: Currently, there seems to be no need to run the _REG methods * before execution of the _PRW methods and enabling of the GPEs. */ if (!(Flags & ACPI_NO_EVENT_INIT)) { Status = AcpiEvInstallFadtGpes (); if (ACPI_FAILURE (Status)) { return (Status); } } return_ACPI_STATUS (Status); }