Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. ixhalt.c
  5. Abstract:
  6. Implements various ACPI utility functions.
  7. Author:
  8. Todd Kjos (HP) (v-tkjos) 15-Jun-1998
  9. Based on i386 version by Jake Oshins (jakeo) 12-Feb-1997
  10. Environment:
  11. Kernel mode only.
  12. Revision History:
  13. --*/
  14. #include "halp.h"
  15. #include "acpitabl.h"
  16. #include "xxacpi.h"
  17. #include <inbv.h>
  18. extern ULONG_PTR KiBugCheckData[];
  19. SLEEP_STATE_CONTEXT HalpShutdownContext;
  20. VOID
  21. HaliHaltSystem (
  22. VOID
  23. )
  24. /*++
  25. Routine Description:
  26. This procedure is called when the machine has crashed and is to be
  27. halted
  28. N.B.
  29. Will NOT return.
  30. --*/
  31. {
  32. #ifndef IA64
  33. for (; ;) {
  34. HalpCheckPowerButton();
  35. HalpYieldProcessor();
  36. }
  37. #else
  38. HalDebugPrint(( HAL_ERROR, "HAL: HaliHaltSystem called -- in tight loop\n" ));
  39. for (;;) {}
  40. #endif
  41. }
  42. VOID
  43. HalpCheckPowerButton (
  44. VOID
  45. )
  46. /*++
  47. Routine Description:
  48. This procedure is called when the machine is spinning in the debugger,
  49. or has crashed and halted.
  50. --*/
  51. {
  52. USHORT Pm1Status, Pm1Control;
  53. SLEEP_STATE_CONTEXT ShutdownContext;
  54. //
  55. // If there's been a bugcheck, or if the hal owns the display check
  56. // the fixed power button for an unconditional power off
  57. //
  58. if ((KiBugCheckData[0] || InbvCheckDisplayOwnership()) && HalpShutdownContext.AsULONG) {
  59. Pm1Status = (USHORT)HalpReadGenAddr(&HalpFixedAcpiDescTable.x_pm1a_evt_blk);
  60. if (HalpFixedAcpiDescTable.x_pm1b_evt_blk.Address.QuadPart) {
  61. Pm1Status |= (USHORT)HalpReadGenAddr(&HalpFixedAcpiDescTable.x_pm1b_evt_blk);
  62. }
  63. //
  64. // If the fixed button has been pushed, power off the system
  65. //
  66. if (Pm1Status & PM1_PWRBTN_STS) {
  67. //
  68. // Only do this once
  69. //
  70. ShutdownContext = HalpShutdownContext;
  71. HalpShutdownContext.AsULONG = 0;
  72. //
  73. // Disable & eoi all wake events
  74. //
  75. AcpiEnableDisableGPEvents(FALSE);
  76. HalpWriteGenAddr(&HalpFixedAcpiDescTable.x_pm1a_evt_blk, Pm1Status);
  77. if (HalpFixedAcpiDescTable.x_pm1b_evt_blk.Address.QuadPart) {
  78. HalpWriteGenAddr(&HalpFixedAcpiDescTable.x_pm1b_evt_blk, Pm1Status);
  79. }
  80. //
  81. // Power off
  82. //
  83. Pm1Control = (USHORT)HalpReadGenAddr(&HalpFixedAcpiDescTable.x_pm1a_ctrl_blk);
  84. Pm1Control = (USHORT) ((Pm1Control & CTL_PRESERVE) | (ShutdownContext.bits.Pm1aVal << SLP_TYP_SHIFT) | SLP_EN);
  85. HalpWriteGenAddr (&HalpFixedAcpiDescTable.x_pm1a_ctrl_blk, Pm1Control);
  86. if (HalpFixedAcpiDescTable.x_pm1b_ctrl_blk.Address.QuadPart) {
  87. Pm1Control = (USHORT)HalpReadGenAddr(&HalpFixedAcpiDescTable.x_pm1b_ctrl_blk);
  88. Pm1Control = (USHORT) ((Pm1Control & CTL_PRESERVE) | (ShutdownContext.bits.Pm1bVal << SLP_TYP_SHIFT) | SLP_EN);
  89. HalpWriteGenAddr(&HalpFixedAcpiDescTable.x_pm1b_ctrl_blk, Pm1Control);
  90. }
  91. }
  92. }
  93. }