Source code of Windows XP (NT5)
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.

159 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. bdreboot.c
  5. Abstract:
  6. System reboot function. Currently part of the debugger because
  7. that's the only place it's used.
  8. Author:
  9. Bryan M. Willman (bryanwi) 4-Dec-90
  10. Revision History:
  11. --*/
  12. #include "bd.h"
  13. VOID
  14. FwStallExecution(
  15. IN ULONG Microseconds
  16. );
  17. #define CMOS_CTRL (PUCHAR )0x70
  18. #define CMOS_DATA (PUCHAR )0x71
  19. #define RESET 0xfe
  20. #define KEYBPORT (PUCHAR )0x64
  21. VOID
  22. HalpReboot (
  23. VOID
  24. )
  25. /*++
  26. Routine Description:
  27. This procedure resets the CMOS clock to the standard timer settings
  28. so the bios will work, and then issues a reset command to the keyboard
  29. to cause a warm boot.
  30. It is very machine dependent, this implementation is intended for
  31. PC-AT like machines.
  32. This code copied from the "old debugger" sources.
  33. N.B.
  34. Will NOT return.
  35. --*/
  36. {
  37. UCHAR Scratch;
  38. PUSHORT Magic;
  39. //
  40. // Turn off interrupts
  41. //
  42. _asm {
  43. cli
  44. }
  45. //
  46. // Reset the cmos clock to a standard value
  47. // (We are setting the periodic interrupt control on the MC147818)
  48. //
  49. //
  50. // Disable periodic interrupt
  51. //
  52. WRITE_PORT_UCHAR(CMOS_CTRL, 0x0b); // Set up for control reg B.
  53. FwStallExecution(1);
  54. Scratch = READ_PORT_UCHAR(CMOS_DATA);
  55. FwStallExecution(1);
  56. Scratch &= 0xbf; // Clear periodic interrupt enable
  57. WRITE_PORT_UCHAR(CMOS_DATA, Scratch);
  58. FwStallExecution(1);
  59. //
  60. // Set "standard" divider rate
  61. //
  62. WRITE_PORT_UCHAR(CMOS_CTRL, 0x0a); // Set up for control reg A.
  63. FwStallExecution(1);
  64. Scratch = READ_PORT_UCHAR(CMOS_DATA);
  65. FwStallExecution(1);
  66. Scratch &= 0xf0; // Clear rate setting
  67. Scratch |= 6; // Set default rate and divider
  68. WRITE_PORT_UCHAR(CMOS_DATA, Scratch);
  69. FwStallExecution(1);
  70. //
  71. // Set a "neutral" cmos address to prevent weirdness
  72. // (Why is this needed? Source this was copied from doesn't say)
  73. //
  74. WRITE_PORT_UCHAR(CMOS_CTRL, 0x15);
  75. FwStallExecution(1);
  76. //
  77. // If we return, send the reset command to the keyboard controller
  78. //
  79. WRITE_PORT_UCHAR(KEYBPORT, RESET);
  80. _asm {
  81. hlt
  82. }
  83. }
  84. VOID
  85. BdReboot (
  86. VOID
  87. )
  88. /*++
  89. Routine Description:
  90. Just calls the HalReturnToFirmware function.
  91. Arguments:
  92. None
  93. Return Value:
  94. Does not return
  95. --*/
  96. {
  97. //
  98. // Never returns from HAL
  99. //
  100. HalpReboot();
  101. while (TRUE) {
  102. }
  103. }