diff --git a/reactos/hal/halx86/generic/reboot.c b/reactos/hal/halx86/generic/reboot.c index 667443f0de5..b47e26217fe 100644 --- a/reactos/hal/halx86/generic/reboot.c +++ b/reactos/hal/halx86/generic/reboot.c @@ -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 #define NDEBUG #include +/* 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(); } }