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.

151 lines
3.7 KiB

  1. title "SystemPro reboot"
  2. ;++
  3. ;
  4. ;Copyright (c) 1991 Microsoft Corporation
  5. ;
  6. ;Module Name:
  7. ;
  8. ; spreboot.asm
  9. ;
  10. ;Abstract:
  11. ;
  12. ; SystemPro reboot code.
  13. ;
  14. ;Author:
  15. ;
  16. ; Ken Reneris (kenr) 13-Jan-1992
  17. ;
  18. ;Revision History:
  19. ;
  20. ;--
  21. .386p
  22. .xlist
  23. include hal386.inc
  24. include i386\kimacro.inc
  25. include i386\ix8259.inc
  26. include callconv.inc ; calling convention macros
  27. include i386\spmp.inc
  28. EXTRNP _HalRequestIpi,1
  29. EXTRNP _KeStallExecutionProcessor,1
  30. extrn _SpProcessorControlPort:WORD
  31. extrn _SpCpuCount:BYTE
  32. extrn _SpType:BYTE
  33. extrn _HalpProcessorPCR:DWORD
  34. ;
  35. ; Defines to let us diddle the CMOS clock and the keyboard
  36. ;
  37. CMOS_CTRL equ 70h
  38. CMOS_DATA equ 71h
  39. KEYB_RESET equ 0feh
  40. KEYB_PORT equ 64h
  41. _TEXT SEGMENT DWORD PUBLIC 'CODE' ; Start 32 bit code
  42. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  43. ;++
  44. ;
  45. ; VOID
  46. ; HalpResetAllProcessors (
  47. ; VOID
  48. ; );
  49. ;
  50. ;Routine Description:
  51. ;
  52. ; Called at last phase of reboot code.
  53. ;
  54. ; Some SystemPro clones do not reboot properly by having the keyboard
  55. ; issue a reset. (The bootup roms do not reset the other processors
  56. ; properly).
  57. ;
  58. ; To work around this, we attempt to use P0 to halt all the other
  59. ; processors before reseting the computer.
  60. ;
  61. ; Note: P0 may not respond to an IPI if it's stuck or in the debugger.
  62. ; In this case we will just use the current processor to reset the
  63. ; computer. This will not work on every machine, but the machine
  64. ; was in some sort of crashed state to begin with. (it does work
  65. ; on all compaq SystemPros).
  66. ;
  67. ; N.B.
  68. ;
  69. ; will not return
  70. ;
  71. ;--
  72. cPublicProc _HalpResetAllProcessors, 0
  73. ;
  74. ; Belize SystemPros can not halt processors in the same manner; however
  75. ; simply resetting the machine via the keyboard controller works - so
  76. ; skip this code on a belize.
  77. ;
  78. cmp _SpType, SMP_SYSPRO2
  79. je rb20 ; Belize, just reset
  80. cmp byte ptr fs:PcHal.PcrNumber, 0 ; boot processor?
  81. je HalpRebootNow ; Yes, reset everyone
  82. ;
  83. ; Try signal the boot processor to perform the reboot
  84. ;
  85. mov ecx, offset FLAT:HalpRebootNow ; Zap P0's IPI handler
  86. mov eax, _HalpProcessorPCR[0] ; be reboot function
  87. xchg [eax].PcHal.PcrIpiType, ecx
  88. stdCall _HalRequestIpi,<1> ; Send P0 an IPI
  89. stdCall _KeStallExecutionProcessor,<50000> ; Let P0 reboot us
  90. ;
  91. ; P0 didn't reboot the machine - just do it with the current processor
  92. ;
  93. HalpRebootNow:
  94. xor ecx, ecx
  95. rb10: cmp cl, _SpCpuCount ; halt each processor
  96. jae short rb20
  97. mov dx, _SpProcessorControlPort[ecx*2]
  98. in al, dx ; (al) = original content of PCP
  99. or al, INTDIS ; Disable IPI interrupt
  100. cmp cl, fs:PcHal.PcrNumber ; cl == currentprocessor?
  101. je short @f ; don't halt ourselves
  102. or al, SLEEP
  103. cmp _SpType, SMP_ACER ; On acer MP machines
  104. jne short @f ; reset other processors
  105. or al, RESET ; (not tested to work on other
  106. ; other machines)
  107. @@: out dx, al
  108. inc ecx
  109. jmp short rb10
  110. rb20:
  111. xor eax, eax
  112. ;
  113. ; Send the reset command to the keyboard controller
  114. ;
  115. mov edx, KEYB_PORT
  116. mov al, KEYB_RESET
  117. out dx, al
  118. @@: hlt
  119. jmp @b
  120. stdENDP _HalpResetAllProcessors
  121. _TEXT ENDS
  122. END