poweroff.c 911 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * poweroff.c - ACPI handler for powering off the system.
  3. *
  4. * AKA S5, but it is independent of whether or not the kernel supports
  5. * any other sleep support in the system.
  6. */
  7. #include <linux/pm.h>
  8. #include <linux/init.h>
  9. #include <acpi/acpi_bus.h>
  10. #include <linux/sched.h>
  11. #include "sleep.h"
  12. static void
  13. acpi_power_off (void)
  14. {
  15. printk("%s called\n",__FUNCTION__);
  16. /* Some SMP machines only can poweroff in boot CPU */
  17. set_cpus_allowed(current, cpumask_of_cpu(0));
  18. acpi_wakeup_gpe_poweroff_prepare();
  19. acpi_enter_sleep_state_prep(ACPI_STATE_S5);
  20. ACPI_DISABLE_IRQS();
  21. acpi_enter_sleep_state(ACPI_STATE_S5);
  22. }
  23. static int acpi_poweroff_init(void)
  24. {
  25. if (!acpi_disabled) {
  26. u8 type_a, type_b;
  27. acpi_status status;
  28. status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b);
  29. if (ACPI_SUCCESS(status))
  30. pm_power_off = acpi_power_off;
  31. }
  32. return 0;
  33. }
  34. late_initcall(acpi_poweroff_init);