Simplified access to the shared user page.
authorEric Kohl <eric.kohl@reactos.org>
Fri, 26 Apr 2002 13:12:34 +0000 (13:12 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Fri, 26 Apr 2002 13:12:34 +0000 (13:12 +0000)
Update TickCountLow on timer ticks.

svn path=/trunk/; revision=2870

14 files changed:
reactos/apps/tests/dump_shared_data/dump_shared_data.c
reactos/include/ddk/ntddk.h
reactos/include/napi/shared_data.h
reactos/lib/kernel32/file/volume.c
reactos/lib/kernel32/misc/dllmain.c
reactos/lib/kernel32/misc/time.c
reactos/lib/ntdll/ldr/startup.c
reactos/lib/ntdll/ldr/utils.c
reactos/lib/ntdll/rtl/misc.c
reactos/ntoskrnl/ke/main.c
reactos/ntoskrnl/ke/timer.c
reactos/ntoskrnl/mm/mminit.c
reactos/ntoskrnl/ps/process.c
reactos/subsys/smss/init.c

index 189b53b..fd12996 100644 (file)
@@ -1,9 +1,8 @@
 #include <stdio.h>
 #include <ntddk.h>
-#include <napi/shared_data.h>
 
 int main()
 {
-   printf("TickCountLow: %x\n", 
-         ((PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE)->TickCountLow);
+  printf("TickCountLow: %x\n", 
+        SharedUserData->TickCountLow);
 }
index 48afd72..a2b24e7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: ntddk.h,v 1.27 2002/04/10 17:01:10 ekohl Exp $
+/* $Id: ntddk.h,v 1.28 2002/04/26 13:05:09 ekohl Exp $
  *
  * COPYRIGHT:      See COPYING in the top level directory
  * PROJECT:        ReactOS kernel
@@ -54,6 +54,7 @@ extern "C"
 #include <ddk/ioctrl.h>
 #include <ddk/rtltypes.h>
 #include <ddk/haltypes.h>
+#include <napi/shared_data.h>
 
 #include <ddk/zw.h>
 #include <ddk/rtl.h>
index e1f1a03..8b601d2 100644 (file)
@@ -44,7 +44,15 @@ typedef struct _KUSER_SHARED_DATA
    BOOLEAN KdDebuggerEnabled;
 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
 
-#define KERNEL_SHARED_DATA_BASE    (0xFFDF0000)
-#define USER_SHARED_DATA_BASE      (0x7FFE0000)
+#define KERNEL_SHARED_DATA     (0xFFDF0000)
+#define USER_SHARED_DATA       (0x7FFE0000)
+
+#if defined(__NTOSKRNL__) || defined(__NTDRIVER__) || defined(__NTHAL__)
+#define KI_USER_SHARED_DATA    (0xFFDF0000)
+#define SharedUserData         ((KUSER_SHARED_DATA * const)KI_USER_SHARED_DATA)
+#else
+#define SharedUserData         ((KUSER_SHARED_DATA * const)USER_SHARED_DATA)
+#endif
+
 
 #endif /* __INCLUDE_NAPI_SHARED_DATA_H */
index a4ce9d7..5b73de3 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: volume.c,v 1.21 2001/11/02 22:08:28 hbirr Exp $
+/* $Id: volume.c,v 1.22 2002/04/26 13:07:33 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -20,7 +20,6 @@
  */
 
 #include <ddk/ntddk.h>
-#include <napi/shared_data.h>
 #include <windows.h>
 #include <ntos/minmax.h>
 
@@ -39,7 +38,7 @@ GetLogicalDriveStringsA(DWORD nBufferLength,
    DWORD drive, count;
    DWORD dwDriveMap;
 
-   dwDriveMap = ((PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE)->DosDeviceMap;
+   dwDriveMap = SharedUserData->DosDeviceMap;
 
    for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++)
      {
@@ -73,7 +72,7 @@ GetLogicalDriveStringsW(DWORD nBufferLength,
    DWORD drive, count;
    DWORD dwDriveMap;
 
-   dwDriveMap = ((PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE)->DosDeviceMap;
+   dwDriveMap = SharedUserData->DosDeviceMap;
 
    for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++)
      {
@@ -101,7 +100,7 @@ GetLogicalDriveStringsW(DWORD nBufferLength,
 DWORD STDCALL
 GetLogicalDrives(VOID)
 {
-   return (((PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE)->DosDeviceMap);
+  return(SharedUserData->DosDeviceMap);
 }
 
 
index fe0dd2d..7b7aa15 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: dllmain.c,v 1.19 2001/11/25 15:21:09 dwelch Exp $
+/* $Id: dllmain.c,v 1.20 2002/04/26 13:07:03 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -14,7 +14,6 @@
 #include <ddk/ntddk.h>
 #include <ntdll/csr.h>
 #include <ntdll/ldr.h>
-#include <napi/shared_data.h>
 #include <windows.h>
 #include <wchar.h>
 
@@ -76,13 +75,13 @@ OpenBaseDirectory(PHANDLE DirHandle)
 }
 
 
-BOOL WINAPI 
+BOOL WINAPI
 DllMainCRTStartup(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
 {
    return(DllMain(hDll,dwReason,lpReserved));
 }
 
-WINBOOL STDCALL 
+WINBOOL STDCALL
 DllMain(HANDLE hInst,
        ULONG ul_reason_for_call,
        LPVOID lpReserved)
@@ -95,8 +94,6 @@ DllMain(HANDLE hInst,
       case DLL_PROCESS_ATTACH:
          {
             NTSTATUS Status;
-            PKUSER_SHARED_DATA SharedUserData = 
-               (PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE;
 
             DPRINT("DLL_PROCESS_ATTACH\n");
 
index 9efe405..f613ae5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: time.c,v 1.13 2001/05/30 20:03:28 ekohl Exp $
+/* $Id: time.c,v 1.14 2002/04/26 13:07:03 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -14,7 +14,6 @@
 
 #include <ddk/ntddk.h>
 #include <windows.h>
-#include <napi/shared_data.h>
 #include <kernel32/error.h>
 //#include <string.h>
 
@@ -430,7 +429,7 @@ GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
          &TimeZoneInformation,
          sizeof(TIME_ZONE_INFORMATION));
 
-   return ((PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE)->TimeZoneId;
+   return(SharedUserData->TimeZoneId);
 }
 
 
index 5f1a6b9..db4f775 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: startup.c,v 1.36 2002/02/08 02:57:06 chorns Exp $
+/* $Id: startup.c,v 1.37 2002/04/26 13:08:18 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -17,7 +17,6 @@
 #include <ntdll/rtl.h>
 #include <csrss/csrss.h>
 #include <ntdll/csr.h>
-#include <napi/shared_data.h>
 #include <user32/callback.h>
 
 #define NDEBUG
@@ -54,8 +53,6 @@ LdrInitializeThunk (ULONG Unknown1,
    PPEB Peb;
    PLDR_MODULE NtModule;  // ntdll
    PLDR_MODULE ExeModule; // executable
-   PKUSER_SHARED_DATA SharedUserData = 
-       (PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE;
    WCHAR FullNtDllPath[MAX_PATH];
 
    DPRINT("LdrInitializeThunk()\n");
index c2662e1..969794d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: utils.c,v 1.49 2001/10/31 01:03:04 dwelch Exp $
+/* $Id: utils.c,v 1.50 2002/04/26 13:08:18 ekohl Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -24,7 +24,6 @@
 #include <wchar.h>
 #include <ntdll/ldr.h>
 #include <ntos/minmax.h>
-#include <napi/shared_data.h>
 
 
 #ifdef DBG_NTDLL_LDR_UTILS
@@ -217,9 +216,6 @@ LdrLoadDll (IN PWSTR SearchPath OPTIONAL,
   
   if (SearchPath == NULL)
     {
-      PKUSER_SHARED_DATA SharedUserData = 
-       (PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE;
-      
       SearchPath = SearchPathBuffer;
       wcscpy (SearchPathBuffer, SharedUserData->NtSystemRoot);
       wcscat (SearchPathBuffer, L"\\system32;");
index a76a1aa..cb28b1d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.2 2000/08/15 12:41:13 ekohl Exp $
+/* $Id: misc.c,v 1.3 2002/04/26 13:08:42 ekohl Exp $
  *
  * COPYRIGHT:         See COPYING in the top level directory
  * PROJECT:           ReactOS kernel
@@ -13,7 +13,6 @@
 
 #include <ddk/ntddk.h>
 #include <ntdll/rtl.h>
-#include <napi/shared_data.h>
 
 /* GLOBALS ******************************************************************/
 
@@ -41,7 +40,7 @@ extern ULONG NtGlobalFlag;
 ULONG STDCALL
 RtlGetNtGlobalFlags(VOID)
 {
-   return (NtGlobalFlag);
+  return(NtGlobalFlag);
 }
 
 
@@ -71,8 +70,8 @@ RtlGetNtGlobalFlags(VOID)
 BOOLEAN STDCALL
 RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType)
 {
-   *ProductType = ((PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE)->NtProductType;
-   return TRUE;
+  *ProductType = SharedUserData->NtProductType;
+  return(TRUE);
 }
 
 /* EOF */
index e884d4a..d983be8 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: main.c,v 1.117 2002/04/17 11:56:33 ekohl Exp $
+/* $Id: main.c,v 1.118 2002/04/26 13:11:28 ekohl Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ke/main.c
@@ -41,7 +41,6 @@
 #include <internal/po.h>
 #include <internal/cc.h>
 #include <internal/se.h>
-#include <napi/shared_data.h>
 #include <internal/v86m.h>
 #include <internal/kd.h>
 #include <internal/trap.h>
@@ -402,8 +401,6 @@ RtlpCheckFileNameExtension(PCHAR FileName,
 static VOID
 InitSystemSharedUserPage (PCSZ ParameterLine)
 {
-   PKUSER_SHARED_DATA SharedPage;
-
    UNICODE_STRING ArcDeviceName;
    UNICODE_STRING ArcName;
    UNICODE_STRING BootPath;
@@ -420,13 +417,13 @@ InitSystemSharedUserPage (PCSZ ParameterLine)
    ULONG i;
    BOOLEAN BootDriveFound;
 
-   SharedPage = (PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE;
-   SharedPage->DosDeviceMap = 0;
-   SharedPage->NtProductType = NtProductWinNt;
-   for (i = 0; i < 32; i++)
-     {
-       SharedPage->DosDeviceDriveType[i] = 0;
-     }
+   /*
+    * NOTE:
+    *   The shared user page has been zeroed-out right after creation.
+    *   There is NO need to do this again.
+    */
+
+   SharedUserData->NtProductType = NtProductWinNt;
 
    BootDriveFound = FALSE;
 
@@ -557,8 +554,8 @@ InitSystemSharedUserPage (PCSZ ParameterLine)
        if (!RtlCompareUnicodeString (&ArcDeviceName, &DriveDeviceName, FALSE))
          {
             DPRINT("DOS Boot path: %c:%wZ\n", 'A' + i, &BootPath);
-            swprintf (SharedPage->NtSystemRoot,
-                      L"%C:%wZ", 'A' + i, &BootPath);
+            swprintf(SharedUserData->NtSystemRoot,
+                     L"%C:%wZ", 'A' + i, &BootPath);
 
                BootDriveFound = TRUE;
          }
@@ -566,7 +563,7 @@ InitSystemSharedUserPage (PCSZ ParameterLine)
        NtClose (Handle);
 
        /* set bit in dos drives bitmap (drive available) */
-       SharedPage->DosDeviceMap |= (1<<i);
+       SharedUserData->DosDeviceMap |= (1<<i);
      }
 
    RtlFreeUnicodeString (&BootPath);
index 466e895..40aefca 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: timer.c,v 1.47 2001/08/27 01:21:50 ekohl Exp $
+/* $Id: timer.c,v 1.48 2002/04/26 13:11:28 ekohl Exp $
  *
  * COPYRIGHT:      See COPYING in the top level directory
  * PROJECT:        ReactOS kernel
 
 /* GLOBALS ****************************************************************/
 
-#define IDMAP_BASE         (0xd0000000)
-
-/*
- * Return a linear address which can be used to access the physical memory
- * starting at x 
- */
-unsigned int physical_to_linear(unsigned int x)
-{
-        return(x+IDMAP_BASE);
-}
-
-unsigned int linear_to_physical(unsigned int x)
-{
-        return(x-IDMAP_BASE);
-}
-
 /*
  * Current time
  */
@@ -57,7 +41,7 @@ static unsigned long long system_time = 0;
 /*
  * Number of timer interrupts since initialisation
  */
-volatile ULONGLONG KeTickCount;
+volatile ULONGLONG KeTickCount = 0;
 volatile ULONG KiRawTicks = 0;
 
 /*
@@ -90,32 +74,35 @@ static BOOLEAN TimerInitDone = FALSE;
 /* FUNCTIONS **************************************************************/
 
 
-NTSTATUS STDCALL NtQueryTimerResolution(OUT    PULONG  MinimumResolution,
-                                       OUT     PULONG  MaximumResolution, 
-                                       OUT     PULONG  ActualResolution)
+NTSTATUS STDCALL
+NtQueryTimerResolution(OUT PULONG MinimumResolution,
+                      OUT PULONG MaximumResolution,
+                      OUT PULONG ActualResolution)
 {
-       UNIMPLEMENTED;
+  UNIMPLEMENTED;
 }
 
 
-NTSTATUS STDCALL NtSetTimerResolution(IN       ULONG   RequestedResolution,
-                                     IN        BOOL    SetOrUnset,
-                                     OUT       PULONG  ActualResolution)
+NTSTATUS STDCALL
+NtSetTimerResolution(IN ULONG RequestedResolution,
+                    IN BOOL SetOrUnset,
+                    OUT PULONG ActualResolution)
 {
-       UNIMPLEMENTED;
+  UNIMPLEMENTED;
 }
 
 
-NTSTATUS STDCALL NtQueryPerformanceCounter (IN PLARGE_INTEGER  Counter,
-                                           IN  PLARGE_INTEGER  Frequency)
+NTSTATUS STDCALL
+NtQueryPerformanceCounter(IN PLARGE_INTEGER Counter,
+                         IN PLARGE_INTEGER Frequency)
 {
-       UNIMPLEMENTED;
+  UNIMPLEMENTED;
 }
 
 
-
-NTSTATUS STDCALL NtDelayExecution(IN ULONG Alertable,
-                                 IN TIME* Interval)
+NTSTATUS STDCALL
+NtDelayExecution(IN ULONG Alertable,
+                IN TIME* Interval)
 {
    NTSTATUS Status;
    LARGE_INTEGER Timeout;
@@ -156,19 +143,21 @@ KeDelayExecutionThread (KPROCESSOR_MODE   WaitMode,
                                 NULL));
 }
 
+
 ULONG STDCALL
-KeQueryTimeIncrement (VOID)
+KeQueryTimeIncrement(VOID)
 /*
  * FUNCTION: Gets the increment (in 100-nanosecond units) that is added to 
  * the system clock every time the clock interrupts
  * RETURNS: The increment
  */
 {
-   return(CLOCK_INCREMENT);
+  return(CLOCK_INCREMENT);
 }
 
+
 VOID STDCALL
-KeQuerySystemTime (PLARGE_INTEGER      CurrentTime)
+KeQuerySystemTime(PLARGE_INTEGER CurrentTime)
 /*
  * FUNCTION: Gets the current system time
  * ARGUMENTS:
@@ -343,7 +332,7 @@ KeInitializeTimerEx (PKTIMER                Timer,
 }
 
 VOID STDCALL
-KeQueryTickCount (PLARGE_INTEGER       TickCount)
+KeQueryTickCount(PLARGE_INTEGER TickCount)
 /*
  * FUNCTION: Returns the number of ticks since the system was booted
  * ARGUMENTS:
@@ -407,7 +396,7 @@ KeExpireTimers(PKDPC Dpc,
        if (system_time >= current->DueTime.QuadPart)
         {
           HandleExpiredTimer(current);
-        }      
+        }
      }
 
    KiAddProfileEvent(ProfileTime, Eip);
@@ -416,8 +405,9 @@ KeExpireTimers(PKDPC Dpc,
 }
 
 
-VOID 
-KiUpdateSystemTime (KIRQL oldIrql, ULONG Eip)
+VOID
+KiUpdateSystemTime(KIRQL oldIrql,
+                  ULONG Eip)
 /*
  * FUNCTION: Handles a timer interrupt
  */
@@ -432,6 +422,7 @@ KiUpdateSystemTime (KIRQL oldIrql, ULONG Eip)
     * Increment the number of timers ticks 
     */
    KeTickCount++;
+   SharedUserData->TickCountLow++;
    system_time = system_time + CLOCK_INCREMENT;
    
    /*
@@ -441,7 +432,7 @@ KiUpdateSystemTime (KIRQL oldIrql, ULONG Eip)
 }
 
 
-VOID 
+VOID
 KeInitializeTimerImpl(VOID)
 /*
  * FUNCTION: Initializes timer irq handling
index 385f064..6f47b68 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: mminit.c,v 1.30 2002/01/01 00:21:56 dwelch Exp $
+/* $Id: mminit.c,v 1.31 2002/04/26 13:11:55 ekohl Exp $
  *
  * COPYRIGHT:   See COPYING in the top directory
  * PROJECT:     ReactOS kernel 
@@ -18,7 +18,6 @@
 #include <internal/ntoskrnl.h>
 #include <internal/io.h>
 #include <internal/ps.h>
-#include <napi/shared_data.h>
 #include <internal/pool.h>
 
 #define NDEBUG
@@ -170,7 +169,7 @@ VOID MmInitVirtualMemory(ULONG LastKernelAddress,
    /*
     * Create the kernel mapping of the user/kernel shared memory.
     */
-   BaseAddress = (PVOID)KERNEL_SHARED_DATA_BASE;
+   BaseAddress = (PVOID)KI_USER_SHARED_DATA;
    Length = PAGESIZE;
    MmCreateMemoryArea(NULL,
                      MmGetKernelAddressSpace(),
@@ -182,7 +181,7 @@ VOID MmInitVirtualMemory(ULONG LastKernelAddress,
                      FALSE);
    Status = MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE, &MmSharedDataPagePhysicalAddress);
    Status = MmCreateVirtualMapping(NULL,
-                                  (PVOID)KERNEL_SHARED_DATA_BASE,
+                                  (PVOID)KI_USER_SHARED_DATA,
                                   PAGE_READWRITE,
                                   (ULONG)MmSharedDataPagePhysicalAddress,
                                   TRUE);
@@ -191,7 +190,7 @@ VOID MmInitVirtualMemory(ULONG LastKernelAddress,
        DbgPrint("Unable to create virtual mapping\n");
        KeBugCheck(0);
      }
-   ((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->TickCountLow = 0xdeadbeef;
+   RtlZeroMemory(BaseAddress, Length);
 
    /*
     *
index 9952f85..79930c8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: process.c,v 1.78 2002/02/20 20:15:07 ekohl Exp $
+/* $Id: process.c,v 1.79 2002/04/26 13:12:34 ekohl Exp $
  *
  * COPYRIGHT:         See COPYING in the top level directory
  * PROJECT:           ReactOS kernel
@@ -24,7 +24,6 @@
 #include <internal/port.h>
 #include <napi/dbg.h>
 #include <internal/dbg.h>
-#include <napi/shared_data.h>
 #include <internal/pool.h>
 #include <roscfg.h>
 
@@ -581,7 +580,7 @@ NtCreateProcess(OUT PHANDLE ProcessHandle,
     * Create the shared data page
     */
    MmLockAddressSpace(&Process->AddressSpace);
-   BaseAddress = (PVOID)USER_SHARED_DATA_BASE;
+   BaseAddress = (PVOID)USER_SHARED_DATA;
    Status = MmCreateMemoryArea(Process,
                               &Process->AddressSpace,
                               MEMORY_AREA_SHARED_DATA,
index 929b9aa..43653d1 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: init.c,v 1.32 2002/03/18 22:44:42 hbirr Exp $
+/* $Id: init.c,v 1.33 2002/04/26 13:09:21 ekohl Exp $
  *
  * init.c - Session Manager initialization
  * 
@@ -29,7 +29,6 @@
 #include <ntos.h>
 #include <ntdll/rtl.h>
 #include <napi/lpc.h>
-#include <napi/shared_data.h>
 
 #include "smss.h"
 
@@ -174,8 +173,6 @@ SmSetEnvironmentVariables (VOID)
        ULONG ExpandedLength;
        WCHAR ExpandBuffer[512];
        WCHAR ValueBuffer[MAX_PATH];
-       PKUSER_SHARED_DATA SharedUserData = 
-               (PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE;
 
        /*
         * The following environment variables are read from the registry.
@@ -273,8 +270,6 @@ BOOL InitSessionManager (HANDLE     Children[])
   HANDLE CsrssInitEvent;
   HANDLE WindowsDirectory;
   WCHAR UnicodeBuffer[MAX_PATH];
-  PKUSER_SHARED_DATA SharedUserData = 
-    (PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE;
 
   /*
    * FIXME: The '\Windows' directory is created by csrss.exe but