Author: hbelusca
Date: Sat Apr 18 00:29:14 2015
New Revision: 67235
URL:
http://svn.reactos.org/svn/reactos?rev=67235&view=rev
Log:
[NTVDM]: Partial revert to r67234: delays were in fact better than frequencies, in case
one would like to define sub-frequency timers. Instead, always specify delays in
nanoseconds, and add a macro to convert from frequency in hertz to duration in
nanoseconds.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/clock.c
trunk/reactos/subsystems/mvdm/ntvdm/clock.h
trunk/reactos/subsystems/mvdm/ntvdm/hardware/cmos.c
trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c
trunk/reactos/subsystems/mvdm/ntvdm/hardware/pit.c
trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c
trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/clock.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/cloc…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/clock.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/clock.c [iso-8859-1] Sat Apr 18 00:29:14 2015
@@ -141,7 +141,7 @@
}
}
-PHARDWARE_TIMER CreateHardwareTimer(ULONG Flags, ULONG Frequency, PHARDWARE_TIMER_PROC
Callback)
+PHARDWARE_TIMER CreateHardwareTimer(ULONG Flags, ULONGLONG Delay, PHARDWARE_TIMER_PROC
Callback)
{
PHARDWARE_TIMER Timer;
@@ -151,7 +151,7 @@
Timer->Flags = Flags & ~HARDWARE_TIMER_ENABLED;
Timer->EnableCount = 0;
Timer->Callback = Callback;
- SetHardwareTimerDelay(Timer, 1000000000ULL / (ULONGLONG)Frequency);
+ SetHardwareTimerDelay(Timer, Delay);
if (Flags & HARDWARE_TIMER_ENABLED) EnableHardwareTimer(Timer);
return Timer;
@@ -234,7 +234,7 @@
#ifdef IPS_DISPLAY
- IpsTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 1, IpsDisplayCallback);
+ IpsTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, HZ_TO_NS(1),
IpsDisplayCallback);
if (IpsTimer == NULL)
{
wprintf(L"FATAL: Cannot create IPS display timer.\n");
Modified: trunk/reactos/subsystems/mvdm/ntvdm/clock.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/cloc…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/clock.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/clock.h [iso-8859-1] Sat Apr 18 00:29:14 2015
@@ -18,6 +18,9 @@
#define HARDWARE_TIMER_ONESHOT (1 << 1)
#define HARDWARE_TIMER_PRECISE (1 << 2)
+/* Converts a frequency in Hertz into a duration in nanoseconds */
+#define HZ_TO_NS(Freq) (ULONGLONG)(1000000000ULL / (ULONGLONG)(Freq))
+
typedef VOID (FASTCALL *PHARDWARE_TIMER_PROC)(ULONGLONG ElapsedTime);
typedef struct _HARDWARE_TIMER
@@ -35,7 +38,7 @@
PHARDWARE_TIMER CreateHardwareTimer
(
ULONG Flags,
- ULONG Frequency, // in Hz
+ ULONGLONG Delay, /* nanoseconds */
PHARDWARE_TIMER_PROC Callback
);
VOID EnableHardwareTimer(PHARDWARE_TIMER Timer);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/cmos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/hardware/cmos.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/cmos.c [iso-8859-1] Sat Apr 18 00:29:14
2015
@@ -44,7 +44,7 @@
/* 1 and 2 act like 8 and 9 */
if (RateSelect <= 2) RateSelect += 7;
- SetHardwareTimerDelay(PeriodicTimer, 1000000000ULL / (ULONGLONG)(1 << (16 -
RateSelect)));
+ SetHardwareTimerDelay(PeriodicTimer, HZ_TO_NS(1 << (16 - RateSelect)));
EnableHardwareTimer(PeriodicTimer);
}
@@ -501,9 +501,11 @@
RegisterIoPort(CMOS_ADDRESS_PORT, NULL , CmosWritePort);
RegisterIoPort(CMOS_DATA_PORT , CmosReadPort, CmosWritePort);
- ClockTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 1, RtcTimeUpdate);
+ ClockTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED,
+ HZ_TO_NS(1),
+ RtcTimeUpdate);
PeriodicTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED | HARDWARE_TIMER_PRECISE,
- 1000,
+ HZ_TO_NS(1000),
RtcPeriodicTick);
}
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c [iso-8859-1] Sat Apr 18 00:29:14
2015
@@ -454,7 +454,9 @@
MouseMutex = CreateMutex(NULL, FALSE, NULL);
if (MouseMutex == NULL) return FALSE;
- StreamTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 100,
MouseStreamingCallback);
+ StreamTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED,
+ HZ_TO_NS(100),
+ MouseStreamingCallback);
MouseReset();
return TRUE;
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/pit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/hardware/pit.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/pit.c [iso-8859-1] Sat Apr 18 00:29:14
2015
@@ -511,7 +511,7 @@
/* Register the hardware timer */
MasterClock = CreateHardwareTimer(HARDWARE_TIMER_ENABLED | HARDWARE_TIMER_PRECISE,
- PIT_BASE_FREQUENCY,
+ HZ_TO_NS(PIT_BASE_FREQUENCY),
PitClock);
}
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c [iso-8859-1] Sat Apr 18 00:29:14
2015
@@ -405,7 +405,9 @@
RegisterIoPort(PS2_CONTROL_PORT, PS2ReadPort, PS2WritePort);
RegisterIoPort(PS2_DATA_PORT , PS2ReadPort, PS2WritePort);
- IrqTimer = CreateHardwareTimer(HARDWARE_TIMER_ONESHOT, 100, GeneratePS2Irq);
+ IrqTimer = CreateHardwareTimer(HARDWARE_TIMER_ONESHOT,
+ HZ_TO_NS(100),
+ GeneratePS2Irq);
return TRUE;
}
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c [iso-8859-1] Sat Apr 18
00:29:14 2015
@@ -2127,8 +2127,8 @@
RegisterIoPort(0x3D8, VgaReadPort, VgaWritePort); // CGA_MODE_CTRL_REG
RegisterIoPort(0x3D9, VgaReadPort, VgaWritePort); // CGA_PAL_CTRL_REG
- HSyncTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 31469,
VgaHorizontalRetrace);
- VSyncTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, 60, VgaVerticalRetrace);
+ HSyncTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, HZ_TO_NS(31469),
VgaHorizontalRetrace);
+ VSyncTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, HZ_TO_NS(60),
VgaVerticalRetrace);
/* Return success */
return TRUE;