Author: hbelusca
Date: Wed Aug 21 16:54:19 2013
New Revision: 59790
URL:
http://svn.reactos.org/svn/reactos?rev=59790&view=rev
Log:
[NTOSKRNL]
- Move NtQueryTimerResolution and NtSetTimerResolution from ke/clock.c to their proper
place in ex/time.c
- Simplify NtQueryTimerResolution and implement NtSetTimerResolution based on the patch of
Aleksandar Andrejevic.
CORE-7387 #resolve #comment NtSetTimerResolution function committed in revision 59790,
thanks :D
Modified:
trunk/reactos/ntoskrnl/ex/time.c
trunk/reactos/ntoskrnl/ke/clock.c
Modified: trunk/reactos/ntoskrnl/ex/time.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/time.c?rev=597…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/time.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/time.c [iso-8859-1] Wed Aug 21 16:54:19 2013
@@ -48,9 +48,7 @@
*--*/
BOOLEAN
NTAPI
-ExAcquireTimeRefreshLock(
- IN BOOLEAN Wait
- )
+ExAcquireTimeRefreshLock(IN BOOLEAN Wait)
{
/* Block APCs */
KeEnterCriticalRegion();
@@ -82,9 +80,7 @@
*--*/
VOID
NTAPI
-ExReleaseTimeRefreshLock(
- VOID
- )
+ExReleaseTimeRefreshLock(VOID)
{
/* Release the lock and re-enable APCs */
ExReleaseResourceLite(&ExpTimeRefreshLock);
@@ -478,4 +474,92 @@
LocalTime->QuadPart = SystemTime->QuadPart - ExpTimeZoneBias.QuadPart;
}
+/*
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+NtQueryTimerResolution(OUT PULONG MinimumResolution,
+ OUT PULONG MaximumResolution,
+ OUT PULONG ActualResolution)
+{
+ KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
+
+ /* Check if the call came from user mode */
+ if (PreviousMode != KernelMode)
+ {
+ _SEH2_TRY
+ {
+ /* Probe the parameters */
+ ProbeForWriteUlong(MinimumResolution);
+ ProbeForWriteUlong(MaximumResolution);
+ ProbeForWriteUlong(ActualResolution);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ /* Return the exception code */
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
+ }
+
+ /*
+ * Set the parameters to the actual values.
+ *
+ * NOTE:
+ * MinimumResolution corresponds to the biggest time increment and
+ * MaximumResolution corresponds to the smallest time increment.
+ */
+ *MinimumResolution = KeMaximumIncrement;
+ *MaximumResolution = KeMinimumIncrement;
+ *ActualResolution = KeTimeIncrement;
+
+ /* Return success */
+ return STATUS_SUCCESS;
+}
+
+/*
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+NtSetTimerResolution(IN ULONG DesiredResolution,
+ IN BOOLEAN SetResolution,
+ OUT PULONG CurrentResolution)
+{
+ KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
+ PEPROCESS Process = PsGetCurrentProcess();
+ ULONG NewResolution;
+
+ /* Check if the call came from user mode */
+ if (PreviousMode != KernelMode)
+ {
+ _SEH2_TRY
+ {
+ /* Probe the parameter */
+ ProbeForWriteUlong(CurrentResolution);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ /* Return the exception code */
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
+ }
+
+ /* Set and return the new resolution */
+ NewResolution = ExSetTimerResolution(DesiredResolution, SetResolution);
+ *CurrentResolution = NewResolution;
+
+ if (SetResolution)
+ {
+ /* Set the flag that the resolution has been changed */
+ Process->SetTimerResolution = TRUE;
+ }
+
+ /* Return success if the process changed its timer resolution */
+ if (Process->SetTimerResolution) return STATUS_SUCCESS;
+ else return STATUS_TIMER_RESOLUTION_NOT_SET;
+}
+
/* EOF */
Modified: trunk/reactos/ntoskrnl/ke/clock.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/clock.c?rev=59…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/clock.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/clock.c [iso-8859-1] Wed Aug 21 16:54:19 2013
@@ -236,56 +236,4 @@
KiTickOffset = MaxIncrement;
}
-NTSTATUS
-NTAPI
-NtQueryTimerResolution(OUT PULONG MinimumResolution,
- OUT PULONG MaximumResolution,
- OUT PULONG ActualResolution)
-{
- KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
-
- /* Check if the call came from user mode */
- if (PreviousMode != KernelMode)
- {
- _SEH2_TRY
- {
- /* Probe the parameters */
- ProbeForWriteUlong(MinimumResolution);
- ProbeForWriteUlong(MaximumResolution);
- ProbeForWriteUlong(ActualResolution);
-
- /* Try to set the parameters to the actual values */
- *MinimumResolution = KeMinimumIncrement;
- *MaximumResolution = KeMaximumIncrement;
- *ActualResolution = KeTimeIncrement;
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
- }
- _SEH2_END;
- }
- else
- {
- /* The call came from kernel mode. Use the pointers directly */
- *MinimumResolution = KeMinimumIncrement;
- *MaximumResolution = KeMaximumIncrement;
- *ActualResolution = KeTimeIncrement;
- }
-
- /* Return success */
- return STATUS_SUCCESS;
-}
-
-NTSTATUS
-NTAPI
-NtSetTimerResolution(IN ULONG DesiredResolution,
- IN BOOLEAN SetResolution,
- OUT PULONG CurrentResolution)
-{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
-}
-
/* EOF */