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.

122 lines
3.1 KiB

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