Ticket #4459: acpi_reboot.diff

File acpi_reboot.diff, 2.6 KB (added by VinDuv, 10 years ago)
  • src/system/kernel/arch/x86/arch_cpu.cpp

     
    103103
    104104
    105105static status_t
    106 acpi_shutdown(void)
     106acpi_shutdown(bool rebootSystem)
    107107{
    108108    if (debug_debugger_running())
    109109        return B_ERROR;
     
    112112    if (get_module(B_ACPI_MODULE_NAME, (module_info**)&acpi) != B_OK)
    113113        return B_NOT_SUPPORTED;
    114114
     115    if (rebootSystem)
     116        return acpi->reboot();
     117
    115118    status_t status = acpi->prepare_sleep_state(ACPI_POWER_STATE_OFF, NULL, 0);
    116119    if (status == B_OK) {
    117120        //cpu_status state = disable_interrupts();
     
    822825status_t
    823826arch_cpu_shutdown(bool rebootSystem)
    824827{
    825     if (!rebootSystem) {
    826         status_t status = acpi_shutdown();
    827         if (status != B_OK)
    828             status = apm_shutdown();
    829 
    830         return status;
    831     }
    832 
     828    acpi_shutdown(rebootSystem);
     829   
     830    if (!rebootSystem)
     831        return apm_shutdown();
     832   
    833833    cpu_status state = disable_interrupts();
    834834
    835835    // try to reset the system using the keyboard controller
  • src/add-ons/kernel/bus_managers/acpi/acpi_busman.c

     
    11/*
     2 * Copyright 2009, Vincent Duvert, vincent.duvert@free.fr
    23 * Copyright 2009, Clemens Zeidler, haiku@clemens-zeidler.de
    34 * Copyright 2008, Axel Dörfler, axeld@pinc-software.de.
    45 * Copyright 2006, Bryan Varner. All rights reserved.
     
    533534}
    534535
    535536
     537static status_t
     538reboot(void)
     539{
     540    ACPI_STATUS status;
     541
     542    TRACE("reboot\n");
     543
     544    if (AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER == 0)
     545        return B_UNSUPPORTED;
     546
     547    status = AcpiHwLowLevelWrite(AcpiGbl_FADT.ResetRegister.BitWidth,
     548        AcpiGbl_FADT.ResetValue, &AcpiGbl_FADT.ResetRegister);
     549   
     550    if (status != AE_OK) {
     551        ERROR("Reset failed, status = %d\n", status);
     552        return B_ERROR;
     553    }
     554   
     555    snooze(1000000);
     556    ERROR("Reset failed, timeout\n");   
     557    return B_ERROR;
     558}
     559
    536560struct acpi_module_info gACPIModule = {
    537561    {
    538562        B_ACPI_MODULE_NAME,
     
    566590    evaluate_object,
    567591    evaluate_method,
    568592    prepare_sleep_state,
    569     enter_sleep_state
     593    enter_sleep_state,
     594    reboot
    570595};
  • headers/os/drivers/ACPI.h

     
    224224    status_t    (*prepare_sleep_state)(uint8 state, void (*wakeFunc)(void),
    225225                    size_t size);
    226226    status_t    (*enter_sleep_state)(uint8 state);
     227    status_t    (*reboot)(void);
    227228};
    228229
    229230