mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
- Add some more descriptive comments to HalpReboot (and rename it from HalReboot) since some of the operations lacked comments.
- Stall the CPU after each I/O command to simulate I/O delay. - Flush write buffers before rebooting. - Refactor sending the reset command since it's not always a matter of using the keyboard port. - HalReturnToFirmware does a HalpReboot no matter what parameter is sent. svn path=/trunk/; revision=24741
This commit is contained in:
parent
0e8c70ba22
commit
30c16d9652
1 changed files with 70 additions and 42 deletions
|
@ -1,70 +1,98 @@
|
|||
/* $Id$
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
/*
|
||||
* PROJECT: ReactOS HAL
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: ntoskrnl/hal/x86/reboot.c
|
||||
* PURPOSE: Reboot functions.
|
||||
* PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
||||
* UPDATE HISTORY:
|
||||
* Created 11/10/99
|
||||
* PURPOSE: Reboot functions
|
||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
* Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <hal.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* PRIVATE FUNCTIONS *********************************************************/
|
||||
|
||||
static VOID
|
||||
HalReboot (VOID)
|
||||
VOID
|
||||
NTAPI
|
||||
HalpWriteResetCommand(VOID)
|
||||
{
|
||||
char data;
|
||||
/* Generate RESET signal via keyboard controller */
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x64, 0xFE);
|
||||
};
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
HalpReboot(VOID)
|
||||
{
|
||||
UCHAR Data;
|
||||
extern PVOID HalpZeroPageMapping;
|
||||
|
||||
/* enable warm reboot */
|
||||
((PUCHAR)HalpZeroPageMapping)[0x472] = 0x34;
|
||||
((PUCHAR)HalpZeroPageMapping)[0x473] = 0x12;
|
||||
/* Enable warm reboot */
|
||||
((PUSHORT)HalpZeroPageMapping)[0x472] = 0x1234;
|
||||
|
||||
/* disable interrupts */
|
||||
Ki386DisableInterrupts();
|
||||
/* FIXME: Lock CMOS Access */
|
||||
|
||||
/* Disable interrupts */
|
||||
_disable();
|
||||
|
||||
/* disable periodic interrupt (RTC) */
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0b);
|
||||
data = READ_PORT_UCHAR((PUCHAR)0x71);
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x71, (UCHAR)(data & 0xbf));
|
||||
/* Setup control register B */
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0B);
|
||||
KeStallExecutionProcessor(1);
|
||||
|
||||
/* */
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0a);
|
||||
data = READ_PORT_UCHAR((PUCHAR)0x71);
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x71, (UCHAR)((data & 0xf0) | 0x06));
|
||||
/* Read periodic register and clear the interrupt enable */
|
||||
Data = READ_PORT_UCHAR((PUCHAR)0x71);
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x71, Data & 0xBF);
|
||||
KeStallExecutionProcessor(1);
|
||||
|
||||
/* */
|
||||
/* Setup control register A */
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0A);
|
||||
KeStallExecutionProcessor(1);
|
||||
|
||||
/* Read divider rate and reset it */
|
||||
Data = READ_PORT_UCHAR((PUCHAR)0x71);
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x71, (Data & 0xF0) | 0x06);
|
||||
KeStallExecutionProcessor(1);
|
||||
|
||||
/* Reset neutral CMOS address */
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x70, 0x15);
|
||||
KeStallExecutionProcessor(1);
|
||||
|
||||
/* generate RESET signal via keyboard controller */
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x64, 0xfe);
|
||||
/* Flush write buffers and send the reset command */
|
||||
KeFlushWriteBuffer();
|
||||
HalpWriteResetCommand();
|
||||
|
||||
/* stop the processor */
|
||||
#if 1
|
||||
/* Halt the CPU */
|
||||
Ki386HaltProcessor();
|
||||
for(;;);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* PUBLIC FUNCTIONS **********************************************************/
|
||||
|
||||
VOID STDCALL
|
||||
HalReturnToFirmware (
|
||||
FIRMWARE_REENTRY Action
|
||||
)
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
NTAPI
|
||||
HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
|
||||
{
|
||||
if (Action == HalHaltRoutine)
|
||||
/* Check the kind of action this is */
|
||||
switch (Action)
|
||||
{
|
||||
DbgPrint ("HalReturnToFirmware called!\n");
|
||||
DbgBreakPoint ();
|
||||
}
|
||||
else if (Action == HalRebootRoutine)
|
||||
{
|
||||
HalReboot ();
|
||||
/* All recognized actions */
|
||||
case HalHaltRoutine:
|
||||
case HalRebootRoutine:
|
||||
|
||||
/* Call the internal reboot function */
|
||||
HalpReboot();
|
||||
|
||||
/* Anything else */
|
||||
default:
|
||||
|
||||
/* Print message and break */
|
||||
DbgPrint("HalReturnToFirmware called!\n");
|
||||
DbgBreakPoint();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue