[NTVDM]: For CreateHardwareTimer, use frequencies (in hertz) instead of using millise...
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Fri, 17 Apr 2015 23:58:01 +0000 (23:58 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Fri, 17 Apr 2015 23:58:01 +0000 (23:58 +0000)
svn path=/trunk/; revision=67234

reactos/subsystems/mvdm/ntvdm/clock.c
reactos/subsystems/mvdm/ntvdm/clock.h
reactos/subsystems/mvdm/ntvdm/hardware/cmos.c
reactos/subsystems/mvdm/ntvdm/hardware/mouse.c
reactos/subsystems/mvdm/ntvdm/hardware/pit.c
reactos/subsystems/mvdm/ntvdm/hardware/ps2.c
reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c

index bebb7cd..e1d43cf 100644 (file)
@@ -141,7 +141,7 @@ VOID ClockUpdate(VOID)
     }
 }
 
-PHARDWARE_TIMER CreateHardwareTimer(ULONG Flags, ULONG Delay, PHARDWARE_TIMER_PROC Callback)
+PHARDWARE_TIMER CreateHardwareTimer(ULONG Flags, ULONG Frequency, PHARDWARE_TIMER_PROC Callback)
 {
     PHARDWARE_TIMER Timer;
     
@@ -151,7 +151,7 @@ PHARDWARE_TIMER CreateHardwareTimer(ULONG Flags, ULONG Delay, PHARDWARE_TIMER_PR
     Timer->Flags = Flags & ~HARDWARE_TIMER_ENABLED;
     Timer->EnableCount = 0;
     Timer->Callback = Callback;
-    SetHardwareTimerDelay(Timer, (ULONGLONG)Delay);
+    SetHardwareTimerDelay(Timer, 1000000000ULL / (ULONGLONG)Frequency);
 
     if (Flags & HARDWARE_TIMER_ENABLED) EnableHardwareTimer(Timer);
     return Timer;
@@ -202,7 +202,7 @@ VOID SetHardwareTimerDelay(PHARDWARE_TIMER Timer, ULONGLONG NewDelay)
     }
     else
     {
-        Timer->Delay = NewDelay;
+        Timer->Delay = NewDelay / 1000000ULL;
     }
 }
 
@@ -234,7 +234,7 @@ BOOLEAN ClockInitialize(VOID)
 
 #ifdef IPS_DISPLAY
 
-    IpsTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 1000, IpsDisplayCallback);
+    IpsTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 1, IpsDisplayCallback);
     if (IpsTimer == NULL)
     {
         wprintf(L"FATAL: Cannot create IPS display timer.\n");
index 957a095..65111c5 100644 (file)
@@ -35,7 +35,7 @@ typedef struct _HARDWARE_TIMER
 PHARDWARE_TIMER CreateHardwareTimer
 (
     ULONG Flags,
-    ULONG Delay, /* milliseconds for normal timers, nanoseconds for precise timers */
+    ULONG Frequency, // in Hz
     PHARDWARE_TIMER_PROC Callback
 );
 VOID EnableHardwareTimer(PHARDWARE_TIMER Timer);
index 25632e1..470d837 100644 (file)
@@ -501,9 +501,9 @@ VOID CmosInitialize(VOID)
     RegisterIoPort(CMOS_ADDRESS_PORT, NULL        , CmosWritePort);
     RegisterIoPort(CMOS_DATA_PORT   , CmosReadPort, CmosWritePort);
 
-    ClockTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 1000, RtcTimeUpdate);
+    ClockTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 1, RtcTimeUpdate);
     PeriodicTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED | HARDWARE_TIMER_PRECISE,
-                                        1000000, /* 1,000,000 ns = 1 ms */
+                                        1000,
                                         RtcPeriodicTick);
 }
 
index 96ee4a2..1d722d0 100644 (file)
@@ -454,7 +454,7 @@ BOOLEAN MouseInit(BYTE PS2Connector)
     MouseMutex = CreateMutex(NULL, FALSE, NULL);
     if (MouseMutex == NULL) return FALSE;
 
-    StreamTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 10, MouseStreamingCallback);
+    StreamTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 100, MouseStreamingCallback);
 
     MouseReset();
     return TRUE;
index 07d6a75..0d1dfca 100644 (file)
@@ -511,7 +511,7 @@ VOID PitInitialize(VOID)
 
     /* Register the hardware timer */
     MasterClock = CreateHardwareTimer(HARDWARE_TIMER_ENABLED | HARDWARE_TIMER_PRECISE,
-                                      1000000000ULL / PIT_BASE_FREQUENCY,
+                                      PIT_BASE_FREQUENCY,
                                       PitClock);
 }
 
index c7f69f2..afade9a 100644 (file)
@@ -405,7 +405,7 @@ BOOLEAN PS2Initialize(VOID)
     RegisterIoPort(PS2_CONTROL_PORT, PS2ReadPort, PS2WritePort);
     RegisterIoPort(PS2_DATA_PORT   , PS2ReadPort, PS2WritePort);
 
-    IrqTimer = CreateHardwareTimer(HARDWARE_TIMER_ONESHOT, 10, GeneratePS2Irq);
+    IrqTimer = CreateHardwareTimer(HARDWARE_TIMER_ONESHOT, 100, GeneratePS2Irq);
 
     return TRUE;
 }
index e0226a7..a0dd0c5 100644 (file)
@@ -2127,8 +2127,8 @@ BOOLEAN VgaInitialize(HANDLE TextHandle)
     RegisterIoPort(0x3D8, VgaReadPort, VgaWritePort);   // CGA_MODE_CTRL_REG
     RegisterIoPort(0x3D9, VgaReadPort, VgaWritePort);   // CGA_PAL_CTRL_REG
 
-    HSyncTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 0, VgaHorizontalRetrace);
-    VSyncTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 16, VgaVerticalRetrace);
+    HSyncTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 31469, VgaHorizontalRetrace);
+    VSyncTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 60, VgaVerticalRetrace);
 
     /* Return success */
     return TRUE;