mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[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.
svn path=/trunk/; revision=67235
This commit is contained in:
parent
6dc704ff48
commit
b673932d12
7 changed files with 21 additions and 12 deletions
|
@ -141,7 +141,7 @@ VOID ClockUpdate(VOID)
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ PHARDWARE_TIMER CreateHardwareTimer(ULONG Flags, ULONG Frequency, PHARDWARE_TIME
|
|||
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 @@ BOOLEAN ClockInitialize(VOID)
|
|||
|
||||
#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");
|
||||
|
|
|
@ -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 @@ typedef struct _HARDWARE_TIMER
|
|||
PHARDWARE_TIMER CreateHardwareTimer
|
||||
(
|
||||
ULONG Flags,
|
||||
ULONG Frequency, // in Hz
|
||||
ULONGLONG Delay, /* nanoseconds */
|
||||
PHARDWARE_TIMER_PROC Callback
|
||||
);
|
||||
VOID EnableHardwareTimer(PHARDWARE_TIMER Timer);
|
||||
|
|
|
@ -44,7 +44,7 @@ static VOID RtcUpdatePeriodicTimer(VOID)
|
|||
/* 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 @@ VOID CmosInitialize(VOID)
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -454,7 +454,9 @@ BOOLEAN MouseInit(BYTE PS2Connector)
|
|||
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;
|
||||
|
|
|
@ -511,7 +511,7 @@ VOID PitInitialize(VOID)
|
|||
|
||||
/* Register the hardware timer */
|
||||
MasterClock = CreateHardwareTimer(HARDWARE_TIMER_ENABLED | HARDWARE_TIMER_PRECISE,
|
||||
PIT_BASE_FREQUENCY,
|
||||
HZ_TO_NS(PIT_BASE_FREQUENCY),
|
||||
PitClock);
|
||||
}
|
||||
|
||||
|
|
|
@ -405,7 +405,9 @@ BOOLEAN PS2Initialize(VOID)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -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, 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;
|
||||
|
|
Loading…
Reference in a new issue