haiku/src/system/kernel/shutdown.cpp
Fredrik Holmqvist 01f964efeb Introduce a gSystemShutdown flag to be able to check if system is shutting down. ACPI Embedded Controller now uses polling when it is set to true.
This might help with ACPI shutdown issues, if not this change can be reverted. Not verified as it works on all my machines even without this.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38585 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-09-08 19:19:49 +00:00

48 lines
848 B
C++

/*
* Copyright 2009, Olivier Coursière. All rights reserved.
* Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <kernel.h>
#include <syscalls.h>
status_t
system_shutdown(bool reboot)
{
int32 cookie = 0;
team_info info;
gKernelShutdown = true;
// Now shutdown all system services!
// TODO: Once we are sure we can shutdown the system on all hardware
// checking reboot may not be necessary anymore.
if (reboot) {
while (get_next_team_info(&cookie, &info) == B_OK) {
if (info.team == B_SYSTEM_TEAM)
continue;
kill_team(info.team);
}
}
sync();
return arch_cpu_shutdown(reboot);
}
// #pragma mark -
status_t
_user_shutdown(bool reboot)
{
if (geteuid() != 0)
return B_NOT_ALLOWED;
return system_shutdown(reboot);
}