Patch from Vincent Duvert (edited by myself): Implement reboot via ACPI (#4459)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33135 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -224,6 +224,7 @@ struct acpi_module_info {
|
|||||||
status_t (*prepare_sleep_state)(uint8 state, void (*wakeFunc)(void),
|
status_t (*prepare_sleep_state)(uint8 state, void (*wakeFunc)(void),
|
||||||
size_t size);
|
size_t size);
|
||||||
status_t (*enter_sleep_state)(uint8 state);
|
status_t (*enter_sleep_state)(uint8 state);
|
||||||
|
status_t (*reboot)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2009, Vincent Duvert, [email protected]
|
||||||
* Copyright 2009, Clemens Zeidler, [email protected]
|
* Copyright 2009, Clemens Zeidler, [email protected]
|
||||||
* Copyright 2008, Axel Dörfler, [email protected].
|
* Copyright 2008, Axel Dörfler, [email protected].
|
||||||
* Copyright 2006, Bryan Varner. All rights reserved.
|
* Copyright 2006, Bryan Varner. All rights reserved.
|
||||||
@@ -533,6 +534,29 @@ enter_sleep_state(uint8 state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static status_t
|
||||||
|
reboot(void)
|
||||||
|
{
|
||||||
|
ACPI_STATUS status;
|
||||||
|
|
||||||
|
TRACE("reboot\n");
|
||||||
|
|
||||||
|
if (AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER == 0)
|
||||||
|
return B_UNSUPPORTED;
|
||||||
|
|
||||||
|
status = AcpiHwLowLevelWrite(AcpiGbl_FADT.ResetRegister.BitWidth,
|
||||||
|
AcpiGbl_FADT.ResetValue, &AcpiGbl_FADT.ResetRegister);
|
||||||
|
|
||||||
|
if (status != AE_OK) {
|
||||||
|
ERROR("Reset failed, status = %d\n", status);
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
snooze(1000000);
|
||||||
|
ERROR("Reset failed, timeout\n");
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
struct acpi_module_info gACPIModule = {
|
struct acpi_module_info gACPIModule = {
|
||||||
{
|
{
|
||||||
B_ACPI_MODULE_NAME,
|
B_ACPI_MODULE_NAME,
|
||||||
@@ -566,5 +590,6 @@ struct acpi_module_info gACPIModule = {
|
|||||||
evaluate_object,
|
evaluate_object,
|
||||||
evaluate_method,
|
evaluate_method,
|
||||||
prepare_sleep_state,
|
prepare_sleep_state,
|
||||||
enter_sleep_state
|
enter_sleep_state,
|
||||||
|
reboot
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ x86_optimized_functions gOptimizedFunctions = {
|
|||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
acpi_shutdown(void)
|
acpi_shutdown(bool rebootSystem)
|
||||||
{
|
{
|
||||||
if (debug_debugger_running())
|
if (debug_debugger_running())
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -112,11 +112,16 @@ acpi_shutdown(void)
|
|||||||
if (get_module(B_ACPI_MODULE_NAME, (module_info**)&acpi) != B_OK)
|
if (get_module(B_ACPI_MODULE_NAME, (module_info**)&acpi) != B_OK)
|
||||||
return B_NOT_SUPPORTED;
|
return B_NOT_SUPPORTED;
|
||||||
|
|
||||||
status_t status = acpi->prepare_sleep_state(ACPI_POWER_STATE_OFF, NULL, 0);
|
status_t status;
|
||||||
if (status == B_OK) {
|
if (rebootSystem) {
|
||||||
//cpu_status state = disable_interrupts();
|
status = acpi->reboot();
|
||||||
status = acpi->enter_sleep_state(ACPI_POWER_STATE_OFF);
|
} else {
|
||||||
//restore_interrupts(state);
|
status = acpi->prepare_sleep_state(ACPI_POWER_STATE_OFF, NULL, 0);
|
||||||
|
if (status == B_OK) {
|
||||||
|
//cpu_status state = disable_interrupts();
|
||||||
|
status = acpi->enter_sleep_state(ACPI_POWER_STATE_OFF);
|
||||||
|
//restore_interrupts(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
put_module(B_ACPI_MODULE_NAME);
|
put_module(B_ACPI_MODULE_NAME);
|
||||||
@@ -822,14 +827,12 @@ error:
|
|||||||
status_t
|
status_t
|
||||||
arch_cpu_shutdown(bool rebootSystem)
|
arch_cpu_shutdown(bool rebootSystem)
|
||||||
{
|
{
|
||||||
if (!rebootSystem) {
|
if (acpi_shutdown(rebootSystem) == B_OK)
|
||||||
status_t status = acpi_shutdown();
|
return B_OK;
|
||||||
if (status != B_OK)
|
|
||||||
status = apm_shutdown();
|
if (!rebootSystem)
|
||||||
|
return apm_shutdown();
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
cpu_status state = disable_interrupts();
|
cpu_status state = disable_interrupts();
|
||||||
|
|
||||||
// try to reset the system using the keyboard controller
|
// try to reset the system using the keyboard controller
|
||||||
|
|||||||
Reference in New Issue
Block a user