[ros-diffs] [ion] 24741: - 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.

ion at svn.reactos.org ion at svn.reactos.org
Mon Nov 13 05:33:46 CET 2006


Author: ion
Date: Mon Nov 13 07:33:45 2006
New Revision: 24741

URL: http://svn.reactos.org/svn/reactos?rev=24741&view=rev
Log:
- 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.

Modified:
    trunk/reactos/hal/halx86/generic/reboot.c

Modified: trunk/reactos/hal/halx86/generic/reboot.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/reboot.c?rev=24741&r1=24740&r2=24741&view=diff
==============================================================================
--- trunk/reactos/hal/halx86/generic/reboot.c (original)
+++ trunk/reactos/hal/halx86/generic/reboot.c Mon Nov 13 07:33:45 2006
@@ -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 at abo.rhein-zeitung.de)
- * UPDATE HISTORY:
- *                  Created 11/10/99
+ * PURPOSE:         Reboot functions
+ * PROGRAMMERS:     Alex Ionescu (alex.ionescu at reactos.org)
+ *                  Eric Kohl (ekohl at 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();
     }
 }
 




More information about the Ros-diffs mailing list