- Make TIME_ZONE_ID_XXX constants available from kernel mode.
authorEric Kohl <eric.kohl@reactos.org>
Sat, 6 Nov 2004 16:05:49 +0000 (16:05 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 6 Nov 2004 16:05:49 +0000 (16:05 +0000)
- Fix definition of KSYSTEM_TIME.
- Set default time zone bias and id in the shared user page.

svn path=/trunk/; revision=11556

reactos/include/defines.h
reactos/include/napi/shared_data.h
reactos/ntoskrnl/ex/sysinfo.c
reactos/ntoskrnl/ex/time.c
reactos/ntoskrnl/include/internal/ex.h
reactos/ntoskrnl/ke/timer.c

index 37871d0..7036925 100644 (file)
@@ -1927,12 +1927,6 @@ extern "C" {
 #define TIME_NOTIMEMARKER      (4)
 #define TIME_FORCE24HOURFORMAT (8)
 
-/* GetTimeZoneInformation */
-#define TIME_ZONE_ID_INVALID   ((DWORD) -1)
-#define TIME_ZONE_ID_UNKNOWN   (0)
-#define TIME_ZONE_ID_STANDARD  (1)
-#define TIME_ZONE_ID_DAYLIGHT  (2)
-
 /* GetUserObjectInformation */
 #define UOI_FLAGS      (1)
 #define UOI_NAME       (2)
index 7a61b62..f8de59a 100644 (file)
@@ -25,8 +25,8 @@ typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
 typedef struct _KSYSTEM_TIME
 {
    ULONG LowPart;
-   LONG High1Part;
-   LONG High2Part;
+   LONG High1Time;
+   LONG High2Time;
 } KSYSTEM_TIME, *PKSYSTEM_TIME;
 
 typedef struct _KUSER_SHARED_DATA
@@ -71,6 +71,13 @@ typedef struct _KUSER_SHARED_DATA
 #define DOSDEVICE_DRIVE_CDROM          5
 #define DOSDEVICE_DRIVE_RAMDISK                6
 
+/* Values for TimeZoneId */
+#ifndef __USE_W32API
+#define TIME_ZONE_ID_INVALID           ((ULONG) -1)
+#define TIME_ZONE_ID_UNKNOWN           (0)
+#define TIME_ZONE_ID_STANDARD          (1)
+#define TIME_ZONE_ID_DAYLIGHT          (2)
+#endif
 
 #define KERNEL_SHARED_DATA     (0xFFDF0000)
 #define USER_SHARED_DATA       (0x7FFE0000)
index bc6364e..2efb261 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: sysinfo.c,v 1.57 2004/11/06 01:42:04 weiden Exp $
+/* $Id: sysinfo.c,v 1.58 2004/11/06 16:04:58 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -383,7 +383,7 @@ QSI_DEF(SystemProcessorInformation)
        if (Size < sizeof (SYSTEM_PROCESSOR_INFORMATION))
        {
                return (STATUS_INFO_LENGTH_MISMATCH);
-       }       
+       }
        Spi->ProcessorArchitecture = 0; /* Intel Processor */
        Spi->ProcessorLevel        = ((Ke386Cpuid >> 8) & 0xf);
        Spi->ProcessorRevision     = (Ke386Cpuid & 0xf) | ((Ke386Cpuid << 4) & 0xf00);
@@ -525,29 +525,27 @@ QSI_DEF(SystemPerformanceInformation)
 /* Class 3 - Time Of Day Information */
 QSI_DEF(SystemTimeOfDayInformation)
 {
-       LARGE_INTEGER CurrentTime;
+  PSYSTEM_TIMEOFDAY_INFORMATION Sti;
+  LARGE_INTEGER CurrentTime;
 
-       PSYSTEM_TIMEOFDAY_INFORMATION Sti
-               = (PSYSTEM_TIMEOFDAY_INFORMATION) Buffer;
+  Sti = (PSYSTEM_TIMEOFDAY_INFORMATION)Buffer;
+  *ReqSize = sizeof (SYSTEM_TIMEOFDAY_INFORMATION);
 
-       *ReqSize = sizeof (SYSTEM_TIMEOFDAY_INFORMATION);
-       /*
-        * Check user buffer's size 
-        */
-       if (Size < sizeof (SYSTEM_TIMEOFDAY_INFORMATION))
-       {
-               return (STATUS_INFO_LENGTH_MISMATCH);
-       }
+  /* Check user buffer's size */
+  if (Size < sizeof (SYSTEM_TIMEOFDAY_INFORMATION))
+    {
+      return STATUS_INFO_LENGTH_MISMATCH;
+    }
 
-       KeQuerySystemTime(&CurrentTime);
+  KeQuerySystemTime(&CurrentTime);
 
-       Sti->BootTime= SystemBootTime;
-       Sti->CurrentTime = CurrentTime;
-       Sti->TimeZoneBias.QuadPart = 0; /* FIXME */
-       Sti->TimeZoneId = 0;            /* FIXME */
-       Sti->Reserved = 0;              /* FIXME */
+  Sti->BootTime= SystemBootTime;
+  Sti->CurrentTime = CurrentTime;
+  Sti->TimeZoneBias.QuadPart = ExpTimeZoneBias.QuadPart;
+  Sti->TimeZoneId = ExpTimeZoneId;
+  Sti->Reserved = 0;
 
-       return (STATUS_SUCCESS);
+  return STATUS_SUCCESS;
 }
 
 /* Class 4 - Path Information */
index d65219c..3a08d9d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: time.c,v 1.23 2004/11/05 17:42:20 ekohl Exp $
+/* $Id: time.c,v 1.24 2004/11/06 16:04:58 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -21,6 +21,8 @@
 
 /* Note: Bias[minutes] = UTC - local time */
 TIME_ZONE_INFORMATION ExpTimeZoneInfo;
+LARGE_INTEGER ExpTimeZoneBias;
+ULONG ExpTimeZoneId;
 
 
 /* FUNCTIONS ****************************************************************/
@@ -36,7 +38,22 @@ ExpInitTimeZoneInfo(VOID)
     {
       memset(&ExpTimeZoneInfo, 0, sizeof(TIME_ZONE_INFORMATION));
 
+      ExpTimeZoneBias.QuadPart = (LONGLONG)0;
+      ExpTimeZoneId = TIME_ZONE_ID_UNKNOWN;
     }
+  else
+    {
+      /* FIXME: Calculate transition dates */
+
+      ExpTimeZoneBias.QuadPart =
+       ((LONGLONG)(ExpTimeZoneInfo.Bias + ExpTimeZoneInfo.StandardBias)) * TICKSPERMINUTE;
+      ExpTimeZoneId = TIME_ZONE_ID_STANDARD;
+    }
+
+  SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.u.HighPart;
+  SharedUserData->TimeZoneBias.High2Time = ExpTimeZoneBias.u.HighPart;
+  SharedUserData->TimeZoneBias.LowPart = ExpTimeZoneBias.u.LowPart;
+  SharedUserData->TimeZoneId = ExpTimeZoneId;
 }
 
 
@@ -56,6 +73,7 @@ NtSetSystemTime(IN PLARGE_INTEGER UnsafeNewSystemTime,
   NTSTATUS Status;
   LARGE_INTEGER OldSystemTime;
   LARGE_INTEGER NewSystemTime;
+  LARGE_INTEGER LocalTime;
   TIME_FIELDS TimeFields;
 
   /* FIXME: Check for SeSystemTimePrivilege */
@@ -78,8 +96,16 @@ NtSetSystemTime(IN PLARGE_INTEGER UnsafeNewSystemTime,
     {
       KeQuerySystemTime(&OldSystemTime);
     }
-  RtlTimeToTimeFields (&NewSystemTime, &TimeFields);
-  HalSetRealTimeClock (&TimeFields);
+  ExSystemTimeToLocalTime(&NewSystemTime,
+                         &LocalTime);
+  RtlTimeToTimeFields(&LocalTime,
+                     &TimeFields);
+  HalSetRealTimeClock(&TimeFields);
+
+  /* FIXME: set system time */
+#if 0
+  KeSetSystemTime();
+#endif
 
   if (UnsafeOldSystemTime != NULL)
     {
@@ -127,10 +153,10 @@ ExLocalTimeToSystemTime (
        PLARGE_INTEGER  SystemTime
        )
 {
-   SystemTime->QuadPart = LocalTime->QuadPart;
+  SystemTime->QuadPart =
+    LocalTime->QuadPart;
 #if 0
- +
-                          ExpTimeZoneInfo.Bias * TICKSPERMINUTE;
+    LocalTime->QuadPart + ExpTimeZoneBias.QuadPart;
 #endif
 }
 
@@ -159,10 +185,10 @@ ExSystemTimeToLocalTime (
        PLARGE_INTEGER  LocalTime
        )
 {
-   LocalTime->QuadPart = SystemTime->QuadPart;
+  LocalTime->QuadPart =
+    SystemTime->QuadPart;
 #if 0
- -
-                         ExpTimeZoneInfo.Bias * TICKSPERMINUTE;
+    SystemTime->QuadPart - ExpTimeZoneBias.QuadPart;
 #endif
 }
 
index 023b39d..901f10e 100644 (file)
@@ -75,7 +75,10 @@ typedef VOID (*PLOOKASIDE_MINMAX_ROUTINE)(
 
 /* GLOBAL VARIABLES *********************************************************/
 
-TIME_ZONE_INFORMATION ExpTimeZoneInfo;
+extern TIME_ZONE_INFORMATION ExpTimeZoneInfo;
+extern LARGE_INTEGER ExpTimeZoneBias;
+extern ULONG ExpTimeZoneId;
+
 extern POBJECT_TYPE ExEventPairObjectType;
 
 
index d80073b..628a22c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: timer.c,v 1.87 2004/10/31 21:22:06 navaraf Exp $
+/* $Id: timer.c,v 1.88 2004/11/06 16:05:49 ekohl Exp $
  *
  * COPYRIGHT:      See COPYING in the top level directory
  * PROJECT:        ReactOS kernel
@@ -18,6 +18,7 @@
 /* INCLUDES ***************************************************************/
 
 #include <ntoskrnl.h>
+
 #define NDEBUG
 #include <internal/debug.h>
 
@@ -203,25 +204,24 @@ KeQueryTimeIncrement(VOID)
 }
 
 
-/*
- * @implemented
- */
-VOID STDCALL
-KeQuerySystemTime(PLARGE_INTEGER CurrentTime)
 /*
  * FUNCTION: Gets the current system time
  * ARGUMENTS:
  *          CurrentTime (OUT) = The routine stores the current time here
  * NOTE: The time is the number of 100-nanosecond intervals since the
  * 1st of January, 1601.
+ *
+ * @implemented
  */
+VOID STDCALL
+KeQuerySystemTime(PLARGE_INTEGER CurrentTime)
 {
   do
     {
-      CurrentTime->u.HighPart = SharedUserData->SystemTime.High1Part;
+      CurrentTime->u.HighPart = SharedUserData->SystemTime.High1Time;
       CurrentTime->u.LowPart = SharedUserData->SystemTime.LowPart;
     }
-  while (CurrentTime->u.HighPart != SharedUserData->SystemTime.High2Part);
+  while (CurrentTime->u.HighPart != SharedUserData->SystemTime.High2Time);
 }
 
 ULONGLONG STDCALL
@@ -231,10 +231,10 @@ KeQueryInterruptTime(VOID)
 
   do
     {
-      CurrentTime.u.HighPart = SharedUserData->InterruptTime.High1Part;
+      CurrentTime.u.HighPart = SharedUserData->InterruptTime.High1Time;
       CurrentTime.u.LowPart = SharedUserData->InterruptTime.LowPart;
     }
-  while (CurrentTime.u.HighPart != SharedUserData->InterruptTime.High2Part);
+  while (CurrentTime.u.HighPart != SharedUserData->InterruptTime.High2Time);
 
   return CurrentTime.QuadPart;
 }
@@ -651,12 +651,12 @@ KeInitializeTimerImpl(VOID)
 
    SharedUserData->TickCountLow = 0;
    SharedUserData->TickCountMultiplier = 167783691; // 2^24 * 1193182 / 119310
-   SharedUserData->InterruptTime.High2Part = 0;
+   SharedUserData->InterruptTime.High2Time = 0;
    SharedUserData->InterruptTime.LowPart = 0;
-   SharedUserData->InterruptTime.High1Part = 0;
-   SharedUserData->SystemTime.High2Part = SystemBootTime.u.HighPart;
+   SharedUserData->InterruptTime.High1Time = 0;
+   SharedUserData->SystemTime.High2Time = SystemBootTime.u.HighPart;
    SharedUserData->SystemTime.LowPart = SystemBootTime.u.LowPart;
-   SharedUserData->SystemTime.High1Part = SystemBootTime.u.HighPart;
+   SharedUserData->SystemTime.High1Time = SystemBootTime.u.HighPart;
 
    TimerInitDone = TRUE;
    DPRINT("Finished KeInitializeTimerImpl()\n");
@@ -799,18 +799,18 @@ KeUpdateSystemTime(
    KiAcquireSpinLock(&TimerValueLock);
 
    Time.u.LowPart = SharedUserData->InterruptTime.LowPart;
-   Time.u.HighPart = SharedUserData->InterruptTime.High1Part;
+   Time.u.HighPart = SharedUserData->InterruptTime.High1Time;
    Time.QuadPart += CLOCK_INCREMENT;
-   SharedUserData->InterruptTime.High2Part = Time.u.HighPart;
+   SharedUserData->InterruptTime.High2Time = Time.u.HighPart;
    SharedUserData->InterruptTime.LowPart = Time.u.LowPart;
-   SharedUserData->InterruptTime.High1Part = Time.u.HighPart;
+   SharedUserData->InterruptTime.High1Time = Time.u.HighPart;
 
    Time.u.LowPart = SharedUserData->SystemTime.LowPart;
-   Time.u.HighPart = SharedUserData->SystemTime.High1Part;
+   Time.u.HighPart = SharedUserData->SystemTime.High1Time;
    Time.QuadPart += CLOCK_INCREMENT;
-   SharedUserData->SystemTime.High2Part = Time.u.HighPart;
+   SharedUserData->SystemTime.High2Time = Time.u.HighPart;
    SharedUserData->SystemTime.LowPart = Time.u.LowPart;
-   SharedUserData->SystemTime.High1Part = Time.u.HighPart;
+   SharedUserData->SystemTime.High1Time = Time.u.HighPart;
 
    /* FIXME: Here we should check for remote debugger break-ins */