Author: ion
Date: Thu Aug 24 10:27:29 2006
New Revision: 23679
URL:
http://svn.reactos.org/svn/reactos?rev=23679&view=rev
Log:
- Update KeUpdateSystemTime to use variable increments.
- Update KeTickCount properly instead of an ugly timecast hack.
- Also update UserSharedData->TickCount.
- Get rid of KiRawTicks.
- Properly update KiTickOffset at the end.
Modified:
trunk/reactos/include/ndk/asm.h
trunk/reactos/include/ndk/kefuncs.h
trunk/reactos/ntoskrnl/include/internal/ke.h
trunk/reactos/ntoskrnl/ke/clock.c
trunk/reactos/ntoskrnl/ke/i386/irq.c
trunk/reactos/ntoskrnl/ke/i386/trap.s
trunk/reactos/ntoskrnl/ntoskrnl.def
Modified: trunk/reactos/include/ndk/asm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/asm.h?rev=2367…
==============================================================================
--- trunk/reactos/include/ndk/asm.h (original)
+++ trunk/reactos/include/ndk/asm.h Thu Aug 24 10:27:29 2006
@@ -246,6 +246,16 @@
//
// KUSER_SHARED_DATA Offsets
//
+#ifdef __ASM__
+#define USER_SHARED_DATA 0xFFDF0000
+#endif
+#define USER_SHARED_DATA_INTERRUPT_TIME 0x8
+#define USER_SHARED_DATA_SYSTEM_TIME 0x14
+#define USER_SHARED_DATA_TICK_COUNT 0x320
+
+//
+// KUSER_SHARED_DATA Offsets (this stuff is trash)
+//
#define KERNEL_USER_SHARED_DATA 0x7FFE0000
#define KUSER_SHARED_PROCESSOR_FEATURES KERNEL_USER_SHARED_DATA + 0x274
#define KUSER_SHARED_SYSCALL KERNEL_USER_SHARED_DATA + 0x300
Modified: trunk/reactos/include/ndk/kefuncs.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/kefuncs.h?rev=…
==============================================================================
--- trunk/reactos/include/ndk/kefuncs.h (original)
+++ trunk/reactos/include/ndk/kefuncs.h Thu Aug 24 10:27:29 2006
@@ -231,7 +231,8 @@
NTAPI
KeUpdateSystemTime(
PKTRAP_FRAME TrapFrame,
- KIRQL Irql
+ KIRQL Irql,
+ ULONG Increment
);
VOID
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ke.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ke.h Thu Aug 24 10:27:29 2006
@@ -260,13 +260,6 @@
VOID
STDCALL
-KeUpdateSystemTime(
- PKTRAP_FRAME TrapFrame,
- KIRQL Irql
-);
-
-VOID
-STDCALL
KeUpdateRunTime(
PKTRAP_FRAME TrapFrame,
KIRQL Irql
Modified: trunk/reactos/ntoskrnl/ke/clock.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/clock.c?rev=23…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/clock.c (original)
+++ trunk/reactos/ntoskrnl/ke/clock.c Thu Aug 24 10:27:29 2006
@@ -63,6 +63,7 @@
ULONG KeMaximumIncrement = 100000;
ULONG KeMinimumIncrement = 100000;
+ULONG KeTimeAdjustment = 100000;
#define MICROSECONDS_PER_TICK (10000)
#define TICKS_TO_CALIBRATE (1)
@@ -353,23 +354,23 @@
VOID
STDCALL
KeUpdateSystemTime(IN PKTRAP_FRAME TrapFrame,
- IN KIRQL Irql)
+ IN KIRQL Irql,
+ IN ULONG Increment)
{
LONG OldOffset;
LARGE_INTEGER Time;
ASSERT(KeGetCurrentIrql() == PROFILE_LEVEL);
- if (!KiClockSetupComplete) return;
/* Update interrupt time */
Time.LowPart = SharedUserData->InterruptTime.LowPart;
Time.HighPart = SharedUserData->InterruptTime.High1Time;
- Time.QuadPart += CLOCK_INCREMENT;
+ Time.QuadPart += Increment;
SharedUserData->InterruptTime.High2Time = Time.u.HighPart;
SharedUserData->InterruptTime.LowPart = Time.u.LowPart;
SharedUserData->InterruptTime.High1Time = Time.u.HighPart;
/* Increase the tick offset */
- KiTickOffset -= CLOCK_INCREMENT;
+ KiTickOffset -= Increment;
OldOffset = KiTickOffset;
/* Check if this isn't a tick yet */
@@ -380,28 +381,39 @@
}
else
{
- /* This was a tick, calculate the next one */
- KiTickOffset += CLOCK_INCREMENT;
-
/* Setup time structure for system time */
Time.LowPart = SharedUserData->SystemTime.LowPart;
Time.HighPart = SharedUserData->SystemTime.High1Time;
- Time.QuadPart += CLOCK_INCREMENT;
+ Time.QuadPart += KeTimeAdjustment;
SharedUserData->SystemTime.High2Time = Time.HighPart;
SharedUserData->SystemTime.LowPart = Time.LowPart;
SharedUserData->SystemTime.High1Time = Time.HighPart;
- /* Update tick count */
- (*(PULONGLONG)&KeTickCount)++;
+ /* Setup time structure for tick time */
+ Time.LowPart = KeTickCount.LowPart;
+ Time.HighPart = KeTickCount.High1Time;
+ Time.QuadPart += 1;
+ KeTickCount.High2Time = Time.HighPart;
+ KeTickCount.LowPart = Time.LowPart;
+ KeTickCount.High1Time = Time.HighPart;
+ SharedUserData->TickCount.High2Time = Time.HighPart;
+ SharedUserData->TickCount.LowPart = Time.LowPart;
+ SharedUserData->TickCount.High1Time = Time.HighPart;
+
+ /* Update tick count in shared user data as well */
SharedUserData->TickCountLowDeprecated++;
- KiRawTicks++;
/* Queue a DPC that will expire timers */
KeInsertQueueDpc(&KiExpireTimerDpc, (PVOID)TrapFrame->Eip, 0);
}
/* Update process and thread times */
- if (OldOffset <= 0) KeUpdateRunTime(TrapFrame, Irql);
+ if (OldOffset <= 0)
+ {
+ /* This was a tick, calculate the next one */
+ KiTickOffset += KeMaximumIncrement;
+ KeUpdateRunTime(TrapFrame, Irql);
+ }
}
/*
Modified: trunk/reactos/ntoskrnl/ke/i386/irq.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/irq.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/irq.c (original)
+++ trunk/reactos/ntoskrnl/ke/i386/irq.c Thu Aug 24 10:27:29 2006
@@ -153,8 +153,11 @@
Ke386EnableInterrupts();
//DPRINT1("Tick\n");
+ if (KiClockSetupComplete)
+ {
KeIRQTrapFrameToTrapFrame(Trapframe, &KernelTrapFrame);
- KeUpdateSystemTime(&KernelTrapFrame, old_level);
+ KeUpdateSystemTime(&KernelTrapFrame, old_level, 100000);
+ }
/*
* End the system interrupt.
Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/trap.s?re…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/trap.s (original)
+++ trunk/reactos/ntoskrnl/ke/i386/trap.s Thu Aug 24 10:27:29 2006
@@ -12,7 +12,7 @@
#include <internal/i386/asmmacro.S>
.intel_syntax noprefix
-/* GLOBALS ******************************************************************/
+/* GLOBALS *******************************************************************/
.globl _KiIdt
_KiIdt:
Modified: trunk/reactos/ntoskrnl/ntoskrnl.def
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.def?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ntoskrnl.def (original)
+++ trunk/reactos/ntoskrnl/ntoskrnl.def Thu Aug 24 10:27:29 2006
@@ -648,7 +648,7 @@
KeTickCount DATA
@KeTryToAcquireGuardedMutex@4
KeUpdateRunTime@8
-KeUpdateSystemTime@8
+KeUpdateSystemTime@12
KeUnstackDetachProcess@4
KeUserModeCallback@20
KeWaitForMultipleObjects@32