mirror of
https://github.com/reactos/reactos.git
synced 2024-07-07 13:15:07 +00:00
[NTVDM]: Make static some variables, fix IRQ1/12 timing, use NT QueryPerformanceCounter API instead of its Win32 part and move the "while (VdmRunning && CpuRunning)" loop into ClockUpdate.
svn path=/trunk/; revision=65377
This commit is contained in:
parent
2f840d26f8
commit
77ee067aa5
|
@ -21,6 +21,9 @@
|
||||||
#include "hardware/timer.h"
|
#include "hardware/timer.h"
|
||||||
#include "hardware/vga.h"
|
#include "hardware/vga.h"
|
||||||
|
|
||||||
|
/* Extra PSDK/NDK Headers */
|
||||||
|
#include <ndk/kefuncs.h>
|
||||||
|
|
||||||
/* DEFINES ********************************************************************/
|
/* DEFINES ********************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,20 +46,19 @@
|
||||||
|
|
||||||
/* VARIABLES ******************************************************************/
|
/* VARIABLES ******************************************************************/
|
||||||
|
|
||||||
LARGE_INTEGER StartPerfCount, Frequency;
|
static LARGE_INTEGER StartPerfCount, Frequency;
|
||||||
|
|
||||||
LARGE_INTEGER LastTimerTick, LastRtcTick, Counter;
|
static LARGE_INTEGER LastTimerTick, LastRtcTick, Counter;
|
||||||
LONGLONG TimerTicks;
|
static LONGLONG TimerTicks;
|
||||||
DWORD StartTickCount, CurrentTickCount;
|
static DWORD StartTickCount, CurrentTickCount;
|
||||||
DWORD LastClockUpdate;
|
static DWORD LastClockUpdate;
|
||||||
DWORD LastVerticalRefresh;
|
static DWORD LastVerticalRefresh;
|
||||||
|
|
||||||
UINT Irq1Counter = 0;
|
static DWORD LastIrq1Tick = 0, LastIrq12Tick = 0;
|
||||||
UINT Irq12Counter = 0;
|
|
||||||
|
|
||||||
#ifdef IPS_DISPLAY
|
#ifdef IPS_DISPLAY
|
||||||
DWORD LastCyclePrintout;
|
static DWORD LastCyclePrintout;
|
||||||
ULONGLONG Cycles = 0;
|
static ULONGLONG Cycles = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS ***********************************************************/
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
||||||
|
@ -65,11 +67,20 @@ VOID ClockUpdate(VOID)
|
||||||
{
|
{
|
||||||
extern BOOLEAN CpuRunning;
|
extern BOOLEAN CpuRunning;
|
||||||
UINT i;
|
UINT i;
|
||||||
|
// LARGE_INTEGER Counter;
|
||||||
|
|
||||||
#ifdef WORKING_TIMER
|
#ifdef WORKING_TIMER
|
||||||
DWORD PitResolution = PitGetResolution();
|
DWORD PitResolution;
|
||||||
#endif
|
#endif
|
||||||
DWORD RtcFrequency = RtcGetTicksPerSecond();
|
DWORD RtcFrequency;
|
||||||
|
|
||||||
|
while (VdmRunning && CpuRunning)
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef WORKING_TIMER
|
||||||
|
PitResolution = PitGetResolution();
|
||||||
|
#endif
|
||||||
|
RtcFrequency = RtcGetTicksPerSecond();
|
||||||
|
|
||||||
/* Get the current number of ticks */
|
/* Get the current number of ticks */
|
||||||
CurrentTickCount = GetTickCount();
|
CurrentTickCount = GetTickCount();
|
||||||
|
@ -86,7 +97,9 @@ VOID ClockUpdate(VOID)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Get the current performance counter value */
|
/* Get the current performance counter value */
|
||||||
QueryPerformanceCounter(&Counter);
|
/// DWORD_PTR oldmask = SetThreadAffinityMask(GetCurrentThread(), 0);
|
||||||
|
NtQueryPerformanceCounter(&Counter, NULL);
|
||||||
|
/// SetThreadAffinityMask(GetCurrentThread(), oldmask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the number of PIT ticks that have passed */
|
/* Get the number of PIT ticks that have passed */
|
||||||
|
@ -122,16 +135,16 @@ VOID ClockUpdate(VOID)
|
||||||
LastVerticalRefresh = CurrentTickCount;
|
LastVerticalRefresh = CurrentTickCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++Irq1Counter == IRQ1_CYCLES)
|
if ((CurrentTickCount - LastIrq1Tick) >= IRQ1_CYCLES)
|
||||||
{
|
{
|
||||||
GenerateIrq1();
|
GenerateIrq1();
|
||||||
Irq1Counter = 0;
|
LastIrq1Tick = CurrentTickCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++Irq12Counter == IRQ12_CYCLES)
|
if ((CurrentTickCount - LastIrq12Tick) >= IRQ12_CYCLES)
|
||||||
{
|
{
|
||||||
GenerateIrq12();
|
GenerateIrq12();
|
||||||
Irq12Counter = 0;
|
LastIrq12Tick = CurrentTickCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Horizontal retrace occurs as fast as possible */
|
/* Horizontal retrace occurs as fast as possible */
|
||||||
|
@ -154,20 +167,23 @@ VOID ClockUpdate(VOID)
|
||||||
Cycles = 0;
|
Cycles = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN ClockInitialize(VOID)
|
BOOLEAN ClockInitialize(VOID)
|
||||||
{
|
{
|
||||||
/* Initialize the performance counter (needed for hardware timers) */
|
/* Initialize the performance counter (needed for hardware timers) */
|
||||||
if (!QueryPerformanceFrequency(&Frequency))
|
/* Find the starting performance */
|
||||||
|
NtQueryPerformanceCounter(&StartPerfCount, &Frequency);
|
||||||
|
if (Frequency.QuadPart == 0)
|
||||||
{
|
{
|
||||||
wprintf(L"FATAL: Performance counter not available\n");
|
wprintf(L"FATAL: Performance counter not available\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the starting performance and tick count */
|
/* Find the starting tick count */
|
||||||
StartTickCount = GetTickCount();
|
StartTickCount = GetTickCount();
|
||||||
QueryPerformanceCounter(&StartPerfCount);
|
|
||||||
|
|
||||||
/* Set the different last counts to the starting count */
|
/* Set the different last counts to the starting count */
|
||||||
LastClockUpdate = LastVerticalRefresh =
|
LastClockUpdate = LastVerticalRefresh =
|
||||||
|
|
Loading…
Reference in a new issue