Continue of MSVC-compiling changes....
authorAleksey Bragin <aleksey@reactos.org>
Tue, 30 Dec 2003 18:52:06 +0000 (18:52 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Tue, 30 Dec 2003 18:52:06 +0000 (18:52 +0000)
I double checked, but in case someone's recent commit is somehow overwritten -- please, don't be very frustrated :) -- I will fix it, just drop me a note.

svn path=/trunk/; revision=7338

101 files changed:
reactos/ntoskrnl/cc/copy.c
reactos/ntoskrnl/cc/pin.c
reactos/ntoskrnl/cc/view.c
reactos/ntoskrnl/cm/regfile.c
reactos/ntoskrnl/cm/registry.c
reactos/ntoskrnl/cm/rtlfunc.c
reactos/ntoskrnl/dbg/kdb_stabs.c
reactos/ntoskrnl/ex/i386/interlck.c
reactos/ntoskrnl/ex/lookas.c
reactos/ntoskrnl/ex/resource.c
reactos/ntoskrnl/ex/zone.c
reactos/ntoskrnl/fs/mcb.c
reactos/ntoskrnl/fs/notify.c
reactos/ntoskrnl/inbv/inbv.c
reactos/ntoskrnl/include/internal/ctype.h
reactos/ntoskrnl/include/internal/debug.h
reactos/ntoskrnl/include/internal/i386/mm.h
reactos/ntoskrnl/include/internal/i386/ps.h
reactos/ntoskrnl/io/buildirp.c
reactos/ntoskrnl/io/create.c
reactos/ntoskrnl/io/driver.c
reactos/ntoskrnl/io/errlog.c
reactos/ntoskrnl/io/iowork.c
reactos/ntoskrnl/io/irp.c
reactos/ntoskrnl/io/mdl.c
reactos/ntoskrnl/io/pnproot.c
reactos/ntoskrnl/io/process.c
reactos/ntoskrnl/io/rawfs.c
reactos/ntoskrnl/io/timer.c
reactos/ntoskrnl/io/xhaldrv.c
reactos/ntoskrnl/kd/gdbstub.c
reactos/ntoskrnl/kd/service.c
reactos/ntoskrnl/ke/apc.c
reactos/ntoskrnl/ke/bug.c
reactos/ntoskrnl/ke/catch.c
reactos/ntoskrnl/ke/dpc.c
reactos/ntoskrnl/ke/i386/brkpoint.c
reactos/ntoskrnl/ke/i386/exp.c
reactos/ntoskrnl/ke/i386/fpu.c
reactos/ntoskrnl/ke/i386/gdt.c
reactos/ntoskrnl/ke/i386/idt.c
reactos/ntoskrnl/ke/i386/irq.c
reactos/ntoskrnl/ke/i386/kernel.c
reactos/ntoskrnl/ke/i386/ldt.c
reactos/ntoskrnl/ke/i386/thread.c
reactos/ntoskrnl/ke/i386/tss.c
reactos/ntoskrnl/ke/i386/usertrap.c
reactos/ntoskrnl/ke/i386/v86m.c
reactos/ntoskrnl/ke/kthread.c
reactos/ntoskrnl/ke/main.c
reactos/ntoskrnl/ke/process.c
reactos/ntoskrnl/ke/timer.c
reactos/ntoskrnl/ke/wait.c
reactos/ntoskrnl/ldr/init.c
reactos/ntoskrnl/ldr/loader.c
reactos/ntoskrnl/ldr/rtl.c
reactos/ntoskrnl/lpc/complete.c
reactos/ntoskrnl/lpc/connect.c
reactos/ntoskrnl/lpc/create.c
reactos/ntoskrnl/lpc/listen.c
reactos/ntoskrnl/lpc/query.c
reactos/ntoskrnl/mm/anonmem.c
reactos/ntoskrnl/mm/balance.c
reactos/ntoskrnl/mm/cont.c
reactos/ntoskrnl/mm/freelist.c
reactos/ntoskrnl/mm/i386/page.c
reactos/ntoskrnl/mm/iospace.c
reactos/ntoskrnl/mm/kmap.c
reactos/ntoskrnl/mm/marea.c
reactos/ntoskrnl/mm/mdl.c
reactos/ntoskrnl/mm/mm.c
reactos/ntoskrnl/mm/mminit.c
reactos/ntoskrnl/mm/mpw.c
reactos/ntoskrnl/mm/ncache.c
reactos/ntoskrnl/mm/npool.c
reactos/ntoskrnl/mm/pagefile.c
reactos/ntoskrnl/mm/pool.c
reactos/ntoskrnl/mm/ppool.c
reactos/ntoskrnl/mm/region.c
reactos/ntoskrnl/mm/rmap.c
reactos/ntoskrnl/mm/section.c
reactos/ntoskrnl/mm/slab.c
reactos/ntoskrnl/nt/evtpair.c
reactos/ntoskrnl/nt/nttimer.c
reactos/ntoskrnl/nt/profile.c
reactos/ntoskrnl/ob/ntobj.c
reactos/ntoskrnl/ob/object.c
reactos/ntoskrnl/ob/symlink.c
reactos/ntoskrnl/ps/tinfo.c
reactos/ntoskrnl/ps/w32call.c
reactos/ntoskrnl/rtl/handle.c
reactos/ntoskrnl/rtl/i386/exception.c
reactos/ntoskrnl/rtl/sprintf.c
reactos/ntoskrnl/rtl/stdlib.c
reactos/ntoskrnl/rtl/swprintf.c
reactos/ntoskrnl/rtl/time.c
reactos/ntoskrnl/rtl/unicode.c
reactos/ntoskrnl/se/acl.c
reactos/ntoskrnl/se/sd.c
reactos/ntoskrnl/se/sid.c
reactos/ntoskrnl/se/token.c

index fe4a7a3..2ce0702 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: copy.c,v 1.19 2003/07/21 21:53:51 royce Exp $
+/* $Id: copy.c,v 1.20 2003/12/30 18:52:03 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
 
 #define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
 
+#if defined(__GNUC__)
 static PHYSICAL_ADDRESS CcZeroPage = (PHYSICAL_ADDRESS)0LL;
+#else
+static PHYSICAL_ADDRESS CcZeroPage = { 0 };
+#endif
 
 /* FUNCTIONS *****************************************************************/
 
@@ -78,7 +82,15 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
        {
          TempLength = min(Bcb->CacheSegmentSize, Length);
          memcpy(Buffer, current->BaseAddress, TempLength);
+#if defined(__GNUC__)
          Buffer += TempLength;
+#else
+         {
+           char* pTemp = Buffer;
+               pTemp += TempLength;
+               Buffer = pTemp;
+         }
+#endif
          Length = Length - TempLength; 
          previous = current;
          current = current->NextInChain;
@@ -120,7 +132,7 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
                {
                  PVOID address;
                  PHYSICAL_ADDRESS page;
-                 address = current2->BaseAddress + (i * PAGE_SIZE);
+                 address = (char*)current2->BaseAddress + (i * PAGE_SIZE);
                  page = MmGetPhysicalAddressForProcess(NULL, address);
                  ((PULONG)(Mdl + 1))[offset] = page.u.LowPart;
                  offset++;
@@ -159,7 +171,15 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
              current = current->NextInChain;
              TempLength = min(Bcb->CacheSegmentSize, Length);
              memcpy(Buffer, previous->BaseAddress, TempLength);
+#if defined(__GNUC__)
              Buffer += TempLength;
+#else
+                 {
+                       char* pTemp = Buffer;
+                       pTemp += TempLength;
+                       Buffer = pTemp;
+                 }
+#endif
              Length = Length - TempLength; 
              CcRosReleaseCacheSegment(Bcb, previous, TRUE, FALSE, FALSE);
            }
@@ -179,7 +199,7 @@ ReadCacheSegment(PCACHE_SEGMENT CacheSeg)
   KEVENT Event;
 
   SegOffset.QuadPart = CacheSeg->FileOffset;
-  Size = CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset;
+  Size = (ULONG)(CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset);
   if (Size > CacheSeg->Bcb->CacheSegmentSize)
     {
       Size = CacheSeg->Bcb->CacheSegmentSize;
@@ -201,7 +221,7 @@ ReadCacheSegment(PCACHE_SEGMENT CacheSeg)
     }
   if (CacheSeg->Bcb->CacheSegmentSize > Size)
     {
-      memset (CacheSeg->BaseAddress + Size, 0, 
+      memset ((char*)CacheSeg->BaseAddress + Size, 0, 
              CacheSeg->Bcb->CacheSegmentSize - Size);
     }
   return STATUS_SUCCESS;
@@ -219,7 +239,7 @@ WriteCacheSegment(PCACHE_SEGMENT CacheSeg)
 
   CacheSeg->Dirty = FALSE;
   SegOffset.QuadPart = CacheSeg->FileOffset;
-  Size = CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset;
+  Size = (ULONG)(CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset);
   if (Size > CacheSeg->Bcb->CacheSegmentSize)
     {
       Size = CacheSeg->Bcb->CacheSegmentSize;
@@ -271,7 +291,7 @@ CcCopyRead (IN PFILE_OBJECT FileObject,
         Buffer, IoStatus);
 
   Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
-  ReadOffset = FileOffset->QuadPart;
+  ReadOffset = (ULONG)FileOffset->QuadPart;
   
   DPRINT("AllocationSize %d, FileSize %d\n",
          (ULONG)Bcb->AllocationSize.QuadPart,
@@ -328,13 +348,21 @@ CcCopyRead (IN PFILE_OBJECT FileObject,
              return FALSE;
            }
        }
-      memcpy (Buffer, BaseAddress + ReadOffset % Bcb->CacheSegmentSize, 
+      memcpy (Buffer, (char*)BaseAddress + ReadOffset % Bcb->CacheSegmentSize, 
              TempLength);
       CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
       ReadLength += TempLength;
       Length -= TempLength;
       ReadOffset += TempLength;
+#if defined(__GNUC__)
       Buffer += TempLength;
+#else
+         {
+               char* pTemp = Buffer;
+               pTemp += TempLength;
+               Buffer = pTemp;
+         }
+#endif
     }  
   while (Length > 0)
     {
@@ -343,7 +371,15 @@ CcCopyRead (IN PFILE_OBJECT FileObject,
       ReadLength += TempLength;
       Length -= TempLength;
       ReadOffset += TempLength;
+#if defined(__GNUC__)
       Buffer += TempLength;
+#else
+         {
+               char* pTemp = Buffer;
+               pTemp += TempLength;
+               Buffer = pTemp;
+         }
+#endif
     }
   IoStatus->Status = STATUS_SUCCESS;
   IoStatus->Information = ReadLength;
@@ -424,13 +460,21 @@ CcCopyWrite (IN PFILE_OBJECT FileObject,
               return(FALSE);
             }
         }
-       memcpy (BaseAddress + WriteOffset % Bcb->CacheSegmentSize, 
+       memcpy ((char*)BaseAddress + WriteOffset % Bcb->CacheSegmentSize, 
               Buffer, TempLength);
        CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, TRUE, FALSE);
        
        Length -= TempLength;
        WriteOffset += TempLength;
+#if defined(__GNUC__)
        Buffer += TempLength;
+#else
+         {
+               char* pTemp = Buffer;
+               pTemp += TempLength;
+               Buffer = pTemp;
+         }
+#endif
      }
    
    while (Length > 0)
@@ -454,7 +498,15 @@ CcCopyWrite (IN PFILE_OBJECT FileObject,
        CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, TRUE, FALSE);
        Length -= TempLength;
        WriteOffset += TempLength;
+#if defined(__GNUC__)
        Buffer += TempLength;
+#else
+         {
+               char* pTemp = Buffer;
+               pTemp += TempLength;
+               Buffer = pTemp;
+         }
+#endif
      }
    return(TRUE);
 }
@@ -628,7 +680,7 @@ CcZeroData (IN PFILE_OBJECT     FileObject,
                    }
                  TempLength = min (Length, Bcb->CacheSegmentSize - 
                                    Start % Bcb->CacheSegmentSize);
-                 memset (current->BaseAddress + Start % Bcb->CacheSegmentSize,
+                 memset ((char*)current->BaseAddress + Start % Bcb->CacheSegmentSize,
                          0, TempLength);
                }
              else
@@ -644,7 +696,7 @@ CcZeroData (IN PFILE_OBJECT     FileObject,
                     count < size; i++)
                {
                  PVOID Address;
-                 Address = current->BaseAddress + (i * PAGE_SIZE);
+                 Address = (char*)current->BaseAddress + (i * PAGE_SIZE);
                  page = 
                    MmGetPhysicalAddressForProcess(NULL, Address);
                  ((PULONG)(Mdl + 1))[count++] = page.u.LowPart;
index b40d5a1..7fc0446 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: pin.c,v 1.13 2003/07/10 06:27:13 royce Exp $
+/* $Id: pin.c,v 1.14 2003/12/30 18:52:03 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -53,7 +53,7 @@ CcMapData (IN PFILE_OBJECT FileObject,
         " pBcb %x, pBuffer %x)\n", FileObject, (ULONG)FileOffset->QuadPart,
         Length, Wait, pBcb, pBuffer);
   
-  ReadOffset = FileOffset->QuadPart;
+  ReadOffset = (ULONG)FileOffset->QuadPart;
   Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
   assert(Bcb);
 
@@ -88,7 +88,15 @@ CcMapData (IN PFILE_OBJECT FileObject,
          return(FALSE);
        }
     }
+#if defined(__GNUC__)
   *pBuffer += ReadOffset % Bcb->CacheSegmentSize;
+#else
+  {
+    char* pTemp = *pBuffer;
+    pTemp += ReadOffset % Bcb->CacheSegmentSize;
+    *pBuffer = pTemp;
+  }
+#endif
   iBcb = ExAllocateFromNPagedLookasideList(&iBcbLookasideList);
   if (iBcb == NULL)
     {
index 60c714a..512c205 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: view.c,v 1.69 2003/10/12 17:05:44 hbirr Exp $
+/* $Id: view.c,v 1.70 2003/12/30 18:52:03 fireball Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/cc/view.c
@@ -105,7 +105,14 @@ static HANDLE LazyCloseThreadHandle;
 static CLIENT_ID LazyCloseThreadId;
 static volatile BOOLEAN LazyCloseThreadShouldTerminate;
 
+#if defined(__GNUC__)
 void * alloca(size_t size);
+#elif defined(_MSC_VER)
+void* _alloca(size_t size);
+#else
+#error Unknown compiler for alloca intrinsic stack allocation "function"
+#endif
+
 
 NTSTATUS
 CcRosInternalFreeCacheSegment(PCACHE_SEGMENT CacheSeg);
@@ -275,7 +282,7 @@ CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed)
             for (i = 0; i < current->Bcb->CacheSegmentSize / PAGE_SIZE; i++)
               {
                 PHYSICAL_ADDRESS Page;
-                Page = MmGetPhysicalAddress(current->BaseAddress + i * PAGE_SIZE);
+                Page = MmGetPhysicalAddress((char*)current->BaseAddress + i * PAGE_SIZE);
                  Status = MmPageOutPhysicalAddress(Page);
                 if (!NT_SUCCESS(Status))
                   {
@@ -609,7 +616,7 @@ CcRosCreateCacheSegment(PBCB Bcb,
      }
       
      Status = MmCreateVirtualMapping(NULL,
-                                    current->BaseAddress + (i * PAGE_SIZE),
+                                    (char*)current->BaseAddress + (i * PAGE_SIZE),
                                     PAGE_READWRITE,
                                     Page,
                                     TRUE);
@@ -638,8 +645,15 @@ CcRosGetCacheSegmentChain(PBCB Bcb,
 
   Length = ROUND_UP(Length, Bcb->CacheSegmentSize);
 
+#if defined(__GNUC__)
   CacheSegList = alloca(sizeof(PCACHE_SEGMENT) * 
                        (Length / Bcb->CacheSegmentSize));
+#elif defined(_MSC_VER)
+  CacheSegList = _alloca(sizeof(PCACHE_SEGMENT) * 
+                       (Length / Bcb->CacheSegmentSize));
+#else
+#error Unknown compiler for alloca intrinsic stack allocation "function"
+#endif
 
   /*
    * Look for a cache segment already mapping the same data.
@@ -866,7 +880,11 @@ CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointers,
       }
       else 
       {
+#if defined(__GNUC__)
         Offset.QuadPart = 0LL;
+#else
+        Offset.QuadPart = 0;
+#endif
         Length = Bcb->FileSize.u.LowPart;
       }
    
@@ -1204,7 +1222,11 @@ CmLazyCloseThreadMain(PVOID Ignored)
 
    while (1)
    {
+#if defined(__GNUC__)
       Timeout.QuadPart += 100000000LL; // 10sec
+#else
+      Timeout.QuadPart += 100000000; // 10sec
+#endif
       Status = KeWaitForSingleObject(&LazyCloseThreadEvent,
                                     0,
                                     KernelMode,
index 8e6ceff..f93b395 100644 (file)
@@ -1446,7 +1446,11 @@ CmiStartLogUpdate(PREGISTRY_HIVE RegistryHive)
                BitmapSize);
 
   /* Write hive block and block bitmap */
+#if defined(__GNUC__)
   FileOffset.QuadPart = 0ULL;
+#else
+  FileOffset.QuadPart = 0;
+#endif
   Status = NtWriteFile(FileHandle,
                       NULL,
                       NULL,
@@ -1505,7 +1509,11 @@ CmiStartLogUpdate(PREGISTRY_HIVE RegistryHive)
        }
 
       BlockIndex++;
+#if defined(__GNUC__)
       FileOffset.QuadPart += 4096ULL;
+#else
+      FileOffset.QuadPart += 4096;
+#endif
     }
 
   /* Truncate log file */
@@ -1624,7 +1632,11 @@ CmiFinishLogUpdate(PREGISTRY_HIVE RegistryHive)
                BitmapSize);
 
   /* Write hive block and block bitmap */
+#if defined(__GNUC__)
   FileOffset.QuadPart = 0ULL;
+#else
+  FileOffset.QuadPart = 0;
+#endif
   Status = NtWriteFile(FileHandle,
                       NULL,
                       NULL,
@@ -1787,7 +1799,11 @@ CmiStartHiveUpdate(PREGISTRY_HIVE RegistryHive)
   RegistryHive->HiveHeader->Checksum = CmiCalcChecksum((PULONG)RegistryHive->HiveHeader);
 
   /* Write hive block */
+#if defined(__GNUC__)
   FileOffset.QuadPart = 0ULL;
+#else
+  FileOffset.QuadPart = 0;
+#endif
   Status = NtWriteFile(FileHandle,
                       NULL,
                       NULL,
@@ -1823,7 +1839,11 @@ CmiStartHiveUpdate(PREGISTRY_HIVE RegistryHive)
       BlockPtr = RegistryHive->BlockList[BlockIndex];
       DPRINT("BlockPtr %p\n", BlockPtr);
 
+#if defined(__GNUC__)
       FileOffset.QuadPart = (ULONGLONG)(BlockIndex + 1) * 4096ULL;
+#else
+      FileOffset.QuadPart = (ULONGLONG)(BlockIndex + 1) * 4096;
+#endif
       DPRINT("File offset %I64x\n", FileOffset.QuadPart);
 
       /* Write hive block */
@@ -1899,7 +1919,11 @@ CmiFinishHiveUpdate(PREGISTRY_HIVE RegistryHive)
   RegistryHive->HiveHeader->Checksum = CmiCalcChecksum((PULONG)RegistryHive->HiveHeader);
 
   /* Write hive block */
+#if defined(__GNUC__)
   FileOffset.QuadPart = 0ULL;
+#else
+  FileOffset.QuadPart = 0;
+#endif
   Status = NtWriteFile(FileHandle,
                       NULL,
                       NULL,
@@ -2599,7 +2623,7 @@ CmiRemoveSubKey(PREGISTRY_HIVE RegistryHive,
   /* Remove the key from the parent key's hash block */
   if (ParentKey->KeyCell->HashTableOffset != (BLOCK_OFFSET) -1)
     {
-      DPRINT("ParentKey HashTableOffset %lx\n", ParentKey->KeyCell->HashTableOffset)
+      DPRINT("ParentKey HashTableOffset %lx\n", ParentKey->KeyCell->HashTableOffset);
       HashBlock = CmiGetCell (ParentKey->RegistryHive,
                              ParentKey->KeyCell->HashTableOffset,
                              NULL);
@@ -2608,7 +2632,7 @@ CmiRemoveSubKey(PREGISTRY_HIVE RegistryHive,
          DPRINT("CmiGetCell() failed\n");
          return STATUS_UNSUCCESSFUL;
        }
-      DPRINT("ParentKey HashBlock %p\n", HashBlock)
+      DPRINT("ParentKey HashBlock %p\n", HashBlock);
       if (HashBlock != NULL)
        {
          CmiRemoveKeyFromHashTable(ParentKey->RegistryHive,
@@ -2622,7 +2646,7 @@ CmiRemoveSubKey(PREGISTRY_HIVE RegistryHive,
   /* Remove the key's hash block */
   if (SubKey->KeyCell->HashTableOffset != (BLOCK_OFFSET) -1)
     {
-      DPRINT("SubKey HashTableOffset %lx\n", SubKey->KeyCell->HashTableOffset)
+      DPRINT("SubKey HashTableOffset %lx\n", SubKey->KeyCell->HashTableOffset);
       HashBlock = CmiGetCell (RegistryHive,
                              SubKey->KeyCell->HashTableOffset,
                              NULL);
@@ -2631,7 +2655,7 @@ CmiRemoveSubKey(PREGISTRY_HIVE RegistryHive,
          DPRINT("CmiGetCell() failed\n");
          return STATUS_UNSUCCESSFUL;
        }
-      DPRINT("SubKey HashBlock %p\n", HashBlock)
+      DPRINT("SubKey HashBlock %p\n", HashBlock);
       if (HashBlock != NULL)
        {
          CmiDestroyCell (RegistryHive,
@@ -2644,13 +2668,13 @@ CmiRemoveSubKey(PREGISTRY_HIVE RegistryHive,
   /* Decrement the number of the parent key's sub keys */
   if (ParentKey != NULL)
     {
-      DPRINT("ParentKey %p\n", ParentKey)
+      DPRINT("ParentKey %p\n", ParentKey);
       ParentKey->KeyCell->NumberOfSubKeys--;
 
       /* Remove the parent key's hash table */
       if (ParentKey->KeyCell->NumberOfSubKeys == 0)
        {
-         DPRINT("ParentKey HashTableOffset %lx\n", ParentKey->KeyCell->HashTableOffset)
+         DPRINT("ParentKey HashTableOffset %lx\n", ParentKey->KeyCell->HashTableOffset);
          HashBlock = CmiGetCell (ParentKey->RegistryHive,
                                  ParentKey->KeyCell->HashTableOffset,
                                  NULL);
@@ -2659,7 +2683,7 @@ CmiRemoveSubKey(PREGISTRY_HIVE RegistryHive,
              DPRINT("CmiGetCell() failed\n");
              return STATUS_UNSUCCESSFUL;
            }
-         DPRINT("ParentKey HashBlock %p\n", HashBlock)
+         DPRINT("ParentKey HashBlock %p\n", HashBlock);
          if (HashBlock != NULL)
            {
              CmiDestroyCell (ParentKey->RegistryHive,
@@ -3381,7 +3405,7 @@ CmiDestroyCell (PREGISTRY_HIVE RegistryHive,
         pFree->CellSize = -pFree->CellSize;
 
       /* Clear block (except the block size) */
-      RtlZeroMemory(((PVOID)pFree) + sizeof(ULONG),
+      RtlZeroMemory(((char*)pFree) + sizeof(ULONG),
                    pFree->CellSize - sizeof(ULONG));
 
       /* Add block to the list of free blocks */
@@ -4163,7 +4187,11 @@ CmiSaveTempHive (PREGISTRY_HIVE Hive,
   Hive->HiveHeader->Checksum = CmiCalcChecksum ((PULONG)Hive->HiveHeader);
 
   /* Write hive block */
+#if defined(__GNUC__)
   FileOffset.QuadPart = 0ULL;
+#else
+  FileOffset.QuadPart = 0;
+#endif
   Status = NtWriteFile (FileHandle,
                        NULL,
                        NULL,
@@ -4185,7 +4213,11 @@ CmiSaveTempHive (PREGISTRY_HIVE Hive,
       BlockPtr = Hive->BlockList[BlockIndex];
       DPRINT ("BlockPtr %p\n", BlockPtr);
 
+#if defined(__GNUC__)
       FileOffset.QuadPart = (ULONGLONG)(BlockIndex + 1) * 4096ULL;
+#else
+      FileOffset.QuadPart = (ULONGLONG)(BlockIndex + 1) * 4096;
+#endif
       DPRINT ("File offset %I64x\n", FileOffset.QuadPart);
 
       /* Write hive block */
index e2c1c98..1170d08 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: registry.c,v 1.115 2003/11/27 00:48:11 gdalsnes Exp $
+/* $Id: registry.c,v 1.116 2003/12/30 18:52:03 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -1106,7 +1106,11 @@ CmiSyncHives(VOID)
   CmiHiveSyncPending = TRUE;
 
 
+#if defined(__GNUC__)
   Timeout.QuadPart = -50000000LL;
+#else
+  Timeout.QuadPart = -50000000;
+#endif
   KeSetTimer(&CmiHiveSyncTimer,
             Timeout,
             &CmiHiveSyncDpc);
index 1713536..6b2aded 100644 (file)
@@ -590,7 +590,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
                    {
                      DPRINT("Expand REG_MULTI_SZ type\n");
 
-                     StringPtr = (PWSTR)((PVOID)FullValueInfo + FullValueInfo->DataOffset);
+                     StringPtr = (PWSTR)((char*)FullValueInfo + FullValueInfo->DataOffset);
                      while (*StringPtr != 0)
                        {
                          StringLen = (wcslen(StringPtr) + 1) * sizeof(WCHAR);
@@ -609,7 +609,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
                    {
                      Status = QueryEntry->QueryRoutine(ValueName,
                                                        FullValueInfo->Type,
-                                                       (PVOID)FullValueInfo + FullValueInfo->DataOffset,
+                                                       (char*)FullValueInfo + FullValueInfo->DataOffset,
                                                        FullValueInfo->DataLength,
                                                        Context,
                                                        QueryEntry->EntryContext);
index d4f9e84..78cdf3f 100644 (file)
@@ -140,7 +140,7 @@ KdbPrintUserAddress(PVOID address)
          CONTAINING_RECORD(current_entry, LDR_MODULE, InLoadOrderModuleList);
        
        if (address >= (PVOID)current->BaseAddress &&
-           address < (PVOID)(current->BaseAddress + current->SizeOfImage))
+           address < (PVOID)((char*)current->BaseAddress + current->SizeOfImage))
          {
             RelativeAddress = (ULONG_PTR) address - (ULONG_PTR)current->BaseAddress;
             Status = LdrGetAddressInformation(&current->SymbolInfo,
index 7fc2c8b..2a83bb5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: interlck.c,v 1.5 2002/12/16 22:56:30 hbirr Exp $
+/* $Id: interlck.c,v 1.6 2003/12/30 18:52:03 fireball Exp $
  *
  * reactos/ntoskrnl/ex/i386/interlck.c
  *
@@ -6,6 +6,8 @@
 #include <ddk/ntddk.h>
 
 
+#if defined(__GNUC__)
+
 INTERLOCKED_RESULT FASTCALL
 Exfi386InterlockedIncrementLong(IN PLONG Addend);
 
@@ -16,6 +18,24 @@ __asm__("\n\t.global @Exfi386InterlockedIncrementLong@4\n\t"
        "andl $0xC000, %eax\n\t"
        "ret\n\t");
 
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+INTERLOCKED_RESULT FASTCALL
+Exfi386InterlockedIncrementLong(IN PLONG Addend)
+{
+       __asm add ecx, 1
+       __asm lahf
+       __asm and eax, 0xC000
+       __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+
+#if defined(__GNUC__)
 
 INTERLOCKED_RESULT FASTCALL
 Exfi386InterlockedDecrementLong(IN PLONG Addend);
@@ -27,6 +47,24 @@ __asm__("\n\t.global @Exfi386InterlockedDecrementLong@4\n\t"
        "andl $0xC000, %eax\n\t"
        "ret\n\t");
 
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+INTERLOCKED_RESULT FASTCALL
+Exfi386InterlockedDecrementLong(IN PLONG Addend)
+{
+       __asm sub ecx, 1
+       __asm lahf
+       __asm and eax, 0xC000
+       __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+
+#if defined(__GNUC__)
 
 ULONG FASTCALL
 Exfi386InterlockedExchangeUlong(IN PULONG Target,
@@ -38,7 +76,24 @@ __asm__("\n\t.global @Exfi386InterlockedExchangeUlong@8\n\t"
        "movl  %edx,%eax\n\t"
        "ret\n\t");
 
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+ULONG FASTCALL
+Exfi386InterlockedExchangeUlong(IN PULONG Target,
+                               IN ULONG Value)
+{
+       __asm xchg [ecx], edx
+       __asm mov  eax, edx
+       __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
 
+#if defined(__GNUC__)
 
 INTERLOCKED_RESULT STDCALL
 Exi386InterlockedIncrementLong(IN PLONG Addend);
@@ -51,6 +106,25 @@ __asm__("\n\t.global _Exi386InterlockedIncrementLong@4\n\t"
        "andl $0xC000, %eax\n\t"
        "ret $4\n\t");
 
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+INTERLOCKED_RESULT STDCALL
+Exi386InterlockedIncrementLong(IN PLONG Addend)
+{
+       __asm mov eax, Addend
+       __asm add [eax], 1
+       __asm lahf
+       __asm and eax, 0xC000
+       __asm ret 4
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+
+#if defined(__GNUC__)
 
 INTERLOCKED_RESULT STDCALL
 Exi386InterlockedDecrementLong(IN PLONG Addend);
@@ -63,6 +137,25 @@ __asm__("\n\t.global _Exi386InterlockedDecrementLong@4\n\t"
        "andl $0xC000, %eax\n\t"
        "ret $4\n\t");
 
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+INTERLOCKED_RESULT STDCALL
+Exi386InterlockedDecrementLong(IN PLONG Addend)
+{
+       __asm mov eax, Addend
+       __asm sub [eax], 1
+       __asm lahf
+       __asm and eax, 0xC000
+       __asm ret 4
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+
+#if defined(__GNUC__)
 
 ULONG STDCALL
 Exi386InterlockedExchangeUlong(IN PULONG Target,
@@ -75,11 +168,30 @@ __asm__("\n\t.global _Exi386InterlockedExchangeUlong@8\n\t"
        "xchgl %eax,(%edx)\n\t"
        "ret $8\n\t");
 
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+ULONG STDCALL
+Exi386InterlockedExchangeUlong(IN PULONG Target,
+                              IN ULONG Value)
+{
+       __asm mov edx, Value
+       __asm mov eax, Target
+       __asm xchg [edx], eax
+       __asm ret 8
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+
 
 /**********************************************************************
  * FASTCALL: @InterlockedIncrement@4
  * STDCALL : _InterlockedIncrement@4
  */
+#if defined(__GNUC__)
 LONG FASTCALL
 InterlockedIncrement(PLONG Addend);
 /*
@@ -97,11 +209,28 @@ __asm__("\n\t.global @InterlockedIncrement@4\n\t"
        "incl %eax\n\t"
        "ret\n\t");
 
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+LONG FASTCALL
+InterlockedIncrement(PLONG Addend)
+{
+       __asm mov eax, 1
+       __asm xadd [ecx], eax
+       __asm inc eax
+       __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
 
 /**********************************************************************
  * FASTCALL: @InterlockedDecrement@4
  * STDCALL : _InterlockedDecrement@4
  */
+#if defined(__GNUC__)
 LONG FASTCALL
 InterlockedDecrement(PLONG Addend);
 
@@ -112,12 +241,29 @@ __asm__("\n\t.global @InterlockedDecrement@4\n\t"
        "decl %eax\n\t"
        "ret\n\t");
 
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+LONG FASTCALL
+InterlockedDecrement(PLONG Addend)
+{
+       __asm mov eax, -1
+       __asm xadd [ecx], eax
+       __asm dec eax
+       __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
 
 /**********************************************************************
  * FASTCALL: @InterlockedExchange@8
  * STDCALL : _InterlockedExchange@8
  */
 
+#if defined(__GNUC__)
 LONG FASTCALL
 InterlockedExchange(PLONG Target,
                    LONG Value);
@@ -128,11 +274,28 @@ __asm__("\n\t.global @InterlockedExchange@8\n\t"
        "movl  %edx,%eax\n\t"
        "ret\n\t");
 
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+LONG FASTCALL
+InterlockedExchange(PLONG Target,
+                   LONG Value)
+{
+       __asm xchg [ecx], edx
+       __asm mov eax, edx
+       __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
 
 /**********************************************************************
  * FASTCALL: @InterlockedExchangeAdd@8
  * STDCALL: _InterlockedExchangeAdd@8
  */
+#if defined(__GNUC__)
+
 LONG FASTCALL
 InterlockedExchangeAdd(PLONG Addend,
                       LONG Value);
@@ -143,11 +306,29 @@ __asm__("\n\t.global @InterlockedExchangeAdd@8\n\t"
        "movl %edx,%eax\n\t"
        "ret\n\t");
 
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+LONG FASTCALL
+InterlockedExchangeAdd(PLONG Addend,
+                      LONG Value)
+{
+       __asm xadd [ecx], edx
+       __asm mov eax, edx
+       __asm ret
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
 
 /**********************************************************************
  * FASTCALL: @InterlockedCompareExchange@12
  * STDCALL: _InterlockedCompareExchange@12
  */
+#if defined(__GNUC__)
+
 LONG FASTCALL
 InterlockedCompareExchange(PLONG Destination,
                           LONG Exchange,
@@ -159,4 +340,21 @@ __asm__("\n\t.global @InterlockedCompareExchange@12\n\t"
        "cmpxchg %edx,(%ecx)\n\t"
        "ret $4\n\t");
 
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+LONG FASTCALL
+InterlockedCompareExchange(PLONG Destination,
+                          LONG Exchange,
+                          LONG Comperand)
+{
+       __asm mov eax, Comperand
+       __asm cmpxchg [ecx], edx
+       __asm ret 4
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
 /* EOF */
index e5b2a75..8de7d11 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: lookas.c,v 1.12 2003/10/12 17:05:44 hbirr Exp $
+/* $Id: lookas.c,v 1.13 2003/12/30 18:52:03 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -126,7 +126,7 @@ ExpDefaultFree(PVOID Buffer)
  *   Buffer = Pointer to memory to free
  */
 {
-  return ExFreePool(Buffer);
+  ExFreePool(Buffer);
 }
 
 
index 86b1efa..22a2ed7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: resource.c,v 1.26 2003/08/14 18:30:28 silverblade Exp $
+/* $Id: resource.c,v 1.27 2003/12/30 18:52:03 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -712,11 +712,11 @@ ExIsResourceAcquiredSharedLite(
    ULONG i;
    if (Resource->OwnerThreads[0].OwnerThread == ExGetCurrentResourceThread())
      {
-    return(Resource->OwnerThreads[0].OwnerCount);
+    return (USHORT)(Resource->OwnerThreads[0].OwnerCount);
      }
    if (Resource->OwnerThreads[1].OwnerThread == ExGetCurrentResourceThread())
      {
-    return(Resource->OwnerThreads[1].OwnerCount);
+    return (USHORT)(Resource->OwnerThreads[1].OwnerCount);
      }
    if (!Resource->OwnerThreads[1].TableSize) 
      {
@@ -726,7 +726,7 @@ ExIsResourceAcquiredSharedLite(
      {
        if (Resource->OwnerTable[i].OwnerThread==ExGetCurrentResourceThread())
          {
-         return Resource->OwnerTable[i].OwnerCount;
+         return (USHORT)Resource->OwnerTable[i].OwnerCount;
          }
      }
    return(0);
@@ -768,8 +768,8 @@ ExReleaseResourceLite (
        PERESOURCE      Resource
        )
 {
-  return(ExReleaseResourceForThreadLite(Resource,
-                                       ExGetCurrentResourceThread()));
+  ExReleaseResourceForThreadLite(Resource,
+                                       ExGetCurrentResourceThread());
 }
 
 
@@ -789,7 +789,7 @@ ExReleaseResourceForThread (
        ERESOURCE_THREAD        ResourceThreadId
        )
 {
-  return(ExReleaseResourceForThreadLite(Resource,ResourceThreadId));
+  ExReleaseResourceForThreadLite(Resource,ResourceThreadId);
 }
 
 
index 79daf19..42bc838 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zone.c,v 1.6 2003/07/17 16:57:38 silverblade Exp $
+/* $Id: zone.c,v 1.7 2003/12/30 18:52:03 fireball Exp $
  *
  * COPYRIGHT:     See COPYING in the top level directory
  * PROJECT:       ReactOS kernel
@@ -42,12 +42,12 @@ ExExtendZone (
    
    PushEntryList(&Zone->SegmentList,&seg->SegmentList);
    
-   entry = (PZONE_SEGMENT_HEADER)( ((PVOID)seg) + sizeof(ZONE_SEGMENT_HEADER) );
+   entry = (PZONE_SEGMENT_HEADER)( ((char*)seg) + sizeof(ZONE_SEGMENT_HEADER) );
    
    for (i=0;i<(SegmentSize / Zone->BlockSize);i++)
      {
        PushEntryList(&Zone->FreeList,&entry->SegmentList);
-       entry = (PZONE_SEGMENT_HEADER)(((PVOID)entry) + sizeof(PZONE_SEGMENT_HEADER) + 
+       entry = (PZONE_SEGMENT_HEADER)(((char*)entry) + sizeof(PZONE_SEGMENT_HEADER) + 
                              Zone->BlockSize);
      }
    return(STATUS_SUCCESS);
@@ -111,12 +111,12 @@ ExInitializeZone (
    
    PushEntryList(&Zone->SegmentList,&seg->SegmentList);
    
-   entry = (PZONE_SEGMENT_HEADER)( ((PVOID)seg) + sizeof(ZONE_SEGMENT_HEADER) );
+   entry = (PZONE_SEGMENT_HEADER)( ((char*)seg) + sizeof(ZONE_SEGMENT_HEADER) );
    
    for (i=0;i<(InitialSegmentSize / BlockSize);i++)
      {
        PushEntryList(&Zone->FreeList,&entry->SegmentList);
-       entry = (PZONE_SEGMENT_HEADER)(((PVOID)entry) + sizeof(PZONE_SEGMENT_HEADER) + BlockSize);
+       entry = (PZONE_SEGMENT_HEADER)(((char*)entry) + sizeof(PZONE_SEGMENT_HEADER) + BlockSize);
      }
 
    return(STATUS_SUCCESS);
index 94e3cf2..9eba357 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: mcb.c,v 1.10 2003/07/10 06:27:13 royce Exp $
+/* $Id: mcb.c,v 1.11 2003/12/30 18:52:03 fireball Exp $
  *
  * reactos/ntoskrnl/fs/mcb.c
  *
@@ -27,7 +27,7 @@ FsRtlAddLargeMcbEntry(IN PLARGE_MCB Mcb,
                      IN LONGLONG Lbn,
                      IN LONGLONG SectorCount)
 {
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return(FALSE);
 }
 
@@ -58,7 +58,7 @@ FsRtlGetNextLargeMcbEntry(IN PLARGE_MCB Mcb,
                          OUT PLONGLONG Lbn,
                          OUT PLONGLONG SectorCount)
 {
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return(FALSE);
 }
 
@@ -96,7 +96,7 @@ VOID STDCALL
 FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb,
                        IN POOL_TYPE PoolType)
 {
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   Mcb->PoolType = PoolType;
 }
 
@@ -124,7 +124,7 @@ FsRtlLookupLargeMcbEntry(IN PLARGE_MCB Mcb,
                         OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL,
                         OUT PULONG Index OPTIONAL)
 {
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return(FALSE);
 }
 
@@ -137,7 +137,7 @@ FsRtlLookupLastLargeMcbEntry(IN PLARGE_MCB Mcb,
                             OUT PLONGLONG Vbn,
                             OUT PLONGLONG Lbn)
 {
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return(FALSE);
 }
 
@@ -150,7 +150,7 @@ FsRtlLookupLastMcbEntry (IN PMCB     Mcb,
                         OUT PVBN    Vbn,
                         OUT PLBN    Lbn)
 {
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return(FALSE);
 }
 
@@ -165,7 +165,7 @@ FsRtlLookupMcbEntry (IN PMCB     Mcb,
                     OUT PULONG  SectorCount OPTIONAL,
                     OUT PULONG  Index)
 {
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return(FALSE);
 }
 
@@ -204,7 +204,7 @@ FsRtlRemoveLargeMcbEntry(IN PLARGE_MCB Mcb,
                         IN LONGLONG Vbn,
                         IN LONGLONG SectorCount)
 {
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
 }
 
 
@@ -216,7 +216,7 @@ FsRtlRemoveMcbEntry (IN PMCB     Mcb,
                     IN VBN      Vbn,
                     IN ULONG    SectorCount)
 {
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
 }
 
 
@@ -228,7 +228,7 @@ FsRtlSplitLargeMcb(IN PLARGE_MCB Mcb,
                   IN LONGLONG Vbn,
                   IN LONGLONG Amount)
 {
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return(FALSE);
 }
 
@@ -240,7 +240,7 @@ VOID STDCALL
 FsRtlTruncateLargeMcb(IN PLARGE_MCB Mcb,
                      IN LONGLONG Vbn)
 {
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
 }
 
 
index 1b2a8a2..8188961 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: notify.c,v 1.8 2003/10/11 20:40:21 navaraf Exp $
+/* $Id: notify.c,v 1.9 2003/12/30 18:52:03 fireball Exp $
  *
  * reactos/ntoskrnl/fs/notify.c
  *
@@ -96,7 +96,11 @@ FsRtlNotifyFullChangeDirectory (
        IN      PSECURITY_SUBJECT_CONTEXT       SubjectContext          OPTIONAL
        )
 {
+#if defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1300)
        DbgPrint("%s()\n", __FUNCTION__);
+#else
+       DbgPrint("FsRtlNotifyFullChangeDirectory()\n");
+#endif
 }
 
 
index 70c841c..5298d61 100755 (executable)
@@ -1,4 +1,4 @@
-/* $Id: inbv.c,v 1.4 2003/11/17 02:12:50 hyperion Exp $
+/* $Id: inbv.c,v 1.5 2003/12/30 18:52:03 fireball Exp $
  *
  * COPYRIGHT:      See COPYING in the top level directory
  * PROJECT:        ReactOS kernel
@@ -85,7 +85,7 @@ InbvDisplayString(IN PCHAR String)
 }
 
 BOOLEAN
-STDCALL_FUNC
+STDCALL
 InbvResetDisplayParameters(ULONG SizeX, ULONG SizeY)
 {
   return(InbvResetDisplay());
index 3b4571a..4efb3fa 100644 (file)
@@ -9,6 +9,7 @@
  * The following flags are used to tell iswctype and _isctype what character
  * types you are looking for.
  */
+
 #define _UPPER      0x0001
 #define _LOWER      0x0002
 #define _DIGIT      0x0004
 typedef wchar_t wctype_t;
 
 
+#if defined(_MSC_VER)
+#define inline __inline
+typedef wchar_t wint_t;
+#endif
 
 extern inline int isspace(int c);
 extern inline int toupper(int c);
index 6cd638d..73abb01 100644 (file)
 #include <internal/dbg.h>
 #include <roscfg.h>
 
-#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;);  } while(0);
+#if defined(_MSC_VER) && (_MSC_VER < 1300)
+/* TODO: Verify which version the MS compiler learned the __FUNCTION__ macro */
+#define __FUNCTION__ "<unknown>"
+#endif
+#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;);  } while(0)
 
 
 #ifdef DBG
 #endif
 
 /* Print if using a "checked" version */
-#define CPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
+#ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
+#define CPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
+#else
+#define CPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
+#endif
 
 #else /* DBG */
 
 
 #endif /* DBG */
 
-#define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
-#define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
+#ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
+#define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
+#else
+#define DPRINT1 DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
+#endif
+
+#define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0)
 
 #if defined(KDBG) && defined(NDEBUG) && defined(__NTOSKRNL__)
 
     DbgPrint("(%s:%d) ",__FILE__,__LINE__); \
     DbgPrint(args); \
   } \
-} while(0);
+} while(0)
 
 #define CHECKPOINT
 
 #else /* KDBG && NDEBUG && __NTOSKRNL__ */
 
 #ifndef NDEBUG
-#define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
-#define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool,0); } while(0);
+#ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
+#define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
+#else
+#define DPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
+#endif
+#define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool,0); } while(0)
 #else /* NDEBUG */
+#ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
 #define DPRINT(args...)
+#else
+#define DPRINT
+#endif
 #define CHECKPOINT
 #endif /* NDEBUG */
 
index 1cc0693..1367a8d 100644 (file)
@@ -30,6 +30,8 @@ PULONG MmGetPageEntry(PVOID Address);
 
 #define KERNEL_BASE        (0xc0000000)
 
+#if defined(__GNUC__)
+
 #define FLUSH_TLB   {                          \
                        unsigned int tmp;       \
                        __asm__ __volatile__(   \
@@ -39,6 +41,15 @@ PULONG MmGetPageEntry(PVOID Address);
                            :: "memory");       \
                    }
 
+#elif defined(_MSC_VER)
+/* TODO: Verify that this really WORKS. Perhaps it, as the GCC thing */
+/* above, needs to actually touch some memory too ? */
+#define FLUSH_TLB __asm mov eax, cr3  __asm mov cr3, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+
 PULONG MmGetPageDirectory(VOID);
 
 #if 0
index a37b625..69e501e 100644 (file)
@@ -130,10 +130,17 @@ static inline PKPCR KeGetCurrentKPCR(VOID)
 {
   ULONG value;
 
+#if defined(__GNUC__)
   __asm__ __volatile__ ("movl %%fs:0x18, %0\n\t"
          : "=r" (value)
     : /* no inputs */
     );
+#elif defined(_MSC_VER)
+  __asm mov eax, fs:0x18;
+  __asm mov value, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
   return((PKPCR)value);
 }
 
index f68ffe8..7aecbb8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: buildirp.c,v 1.37 2003/11/19 21:11:47 gdalsnes Exp $
+/* $Id: buildirp.c,v 1.38 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -114,7 +114,7 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
    Irp->Tail.Overlay.Thread = PsGetCurrentThread();
 
    StackPtr = IoGetNextIrpStackLocation(Irp);
-   StackPtr->MajorFunction = MajorFunction;
+   StackPtr->MajorFunction = (UCHAR)MajorFunction;
    StackPtr->MinorFunction = 0;
    StackPtr->Flags = 0;
    StackPtr->Control = 0;
@@ -447,7 +447,7 @@ IoBuildSynchronousFsdRequestWithMdl(ULONG MajorFunction,
      }
    
    StackPtr = IoGetNextIrpStackLocation(Irp);
-   StackPtr->MajorFunction = MajorFunction;
+   StackPtr->MajorFunction = (UCHAR)MajorFunction;
    StackPtr->MinorFunction = 0;
    StackPtr->Flags = 0;
    StackPtr->Control = 0;
index 542519e..eb9c1fa 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: create.c,v 1.71 2003/12/14 17:44:02 hbirr Exp $
+/* $Id: create.c,v 1.72 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -457,15 +457,15 @@ IoCreateFile(OUT  PHANDLE                 FileHandle,
          break;
      }
    StackLoc->MinorFunction = 0;
-   StackLoc->Flags = Options;
+   StackLoc->Flags = (UCHAR)Options;
    StackLoc->Control = 0;
    StackLoc->DeviceObject = FileObject->DeviceObject;
    StackLoc->FileObject = FileObject;
    StackLoc->Parameters.Create.SecurityContext = &SecurityContext;
    StackLoc->Parameters.Create.Options = (CreateOptions & FILE_VALID_OPTION_FLAGS);
    StackLoc->Parameters.Create.Options |= (CreateDisposition << 24);
-   StackLoc->Parameters.Create.FileAttributes = FileAttributes;
-   StackLoc->Parameters.Create.ShareAccess = ShareAccess;
+   StackLoc->Parameters.Create.FileAttributes = (USHORT)FileAttributes;
+   StackLoc->Parameters.Create.ShareAccess = (USHORT)ShareAccess;
    StackLoc->Parameters.Create.EaLength = EaLength;
    
    /*
index d1b2255..8a8df4f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: driver.c,v 1.32 2003/12/15 17:50:23 ekohl Exp $
+/* $Id: driver.c,v 1.33 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:      See COPYING in the top level directory
  * PROJECT:        ReactOS kernel
@@ -420,7 +420,7 @@ MiFreeBootDriverMemory(PVOID StartAddress, ULONG Length)
 
   for (i = 0; i < PAGE_ROUND_UP(Length)/PAGE_SIZE; i++)
   {
-     MmDeleteVirtualMapping(NULL, StartAddress + i * PAGE_SIZE, TRUE, NULL, NULL);
+     MmDeleteVirtualMapping(NULL, (char*)StartAddress + i * PAGE_SIZE, TRUE, NULL, NULL);
   }
 }
 
index d460325..09c424b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errlog.c,v 1.15 2003/11/21 22:28:50 ekohl Exp $
+/* $Id: errlog.c,v 1.16 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -121,7 +121,11 @@ IopRestartLogWorker (VOID)
   KeInitializeTimer (&WorkerDpc->Timer);
 
   /* Restart after 30 seconds */
+#if defined(__GNUC__)
   Timeout.QuadPart = -300000000LL;
+#else
+  Timeout.QuadPart = -300000000;
+#endif
   KeSetTimer (&WorkerDpc->Timer,
              Timeout,
              &WorkerDpc->Dpc);
@@ -274,7 +278,7 @@ IopLogWorker (PVOID Parameter)
       Message->Size =
        sizeof(IO_ERROR_LOG_MESSAGE) - sizeof(IO_ERROR_LOG_PACKET) +
        LogEntry->PacketSize + DriverNameLength;
-      Message->DriverNameLength = DriverNameLength;
+      Message->DriverNameLength = (USHORT)DriverNameLength;
       Message->TimeStamp.QuadPart = LogEntry->TimeStamp.QuadPart;
       Message->DriverNameOffset = (DriverName != NULL) ? LogEntry->PacketSize : 0;
 
index 71e4987..449d2fd 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: iowork.c,v 1.5 2003/07/11 01:23:14 royce Exp $
+/* $Id: iowork.c,v 1.6 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:          See COPYING in the top level directory
  * PROJECT:            ReactOS kernel
@@ -34,7 +34,7 @@ typedef struct _IO_WORKITEM
 
 /* FUNCTIONS ****************************************************************/
 
-VOID STDCALL STATIC
+VOID STATIC STDCALL
 IoWorkItemCallback(PVOID Parameter)
 {
   PIO_WORKITEM IoWorkItem = (PIO_WORKITEM)Parameter;
index b0e91d1..45350a9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: irp.c,v 1.55 2003/11/30 20:01:05 gdalsnes Exp $
+/* $Id: irp.c,v 1.56 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -386,7 +386,7 @@ IoIsOperationSynchronous(IN PIRP Irp)
 VOID STDCALL
 IoEnqueueIrp(IN PIRP Irp)
 {
-  return IoQueueThreadIrp(Irp);
+  IoQueueThreadIrp(Irp);
 }
 
 
index 9dbf5c7..f476511 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: mdl.c,v 1.12 2003/07/10 15:47:00 royce Exp $
+/* $Id: mdl.c,v 1.13 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -49,7 +49,7 @@ IoAllocateMdl(PVOID VirtualAddress,
                                    MmSizeOfMdl(VirtualAddress,Length),
                                    TAG_MDL);
      }
-   MmInitializeMdl(Mdl,VirtualAddress,Length);
+   MmInitializeMdl(Mdl, (char*)VirtualAddress, Length);
    if (Irp!=NULL && !SecondaryBuffer)
      {
        Irp->MdlAddress = Mdl;
index 8f05b7e..a934c2e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: pnproot.c,v 1.18 2003/11/17 02:12:51 hyperion Exp $
+/* $Id: pnproot.c,v 1.19 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:      See COPYING in the top level directory
  * PROJECT:        ReactOS kernel
@@ -49,6 +49,8 @@ typedef enum {
 } PNPROOT_DEVICE_STATE;
 
 
+#if defined(__GNUC__)
+
 typedef struct _PNPROOT_COMMON_DEVICE_EXTENSION
 {
   // Pointer to device object, this device extension is associated with
@@ -61,6 +63,29 @@ typedef struct _PNPROOT_COMMON_DEVICE_EXTENSION
   DEVICE_POWER_STATE DevicePowerState;
 } __attribute((packed)) PNPROOT_COMMON_DEVICE_EXTENSION, *PPNPROOT_COMMON_DEVICE_EXTENSION;
 
+#elif defined(_MSC_VER)
+
+#include <pshpack1.h>
+typedef struct _PNPROOT_COMMON_DEVICE_EXTENSION
+{
+  // Pointer to device object, this device extension is associated with
+  PDEVICE_OBJECT DeviceObject;
+  // Wether this device extension is for an FDO or PDO
+  BOOLEAN IsFDO;
+  // Wether the device is removed
+  BOOLEAN Removed;
+  // Current device power state for the device
+  DEVICE_POWER_STATE DevicePowerState;
+} PNPROOT_COMMON_DEVICE_EXTENSION, *PPNPROOT_COMMON_DEVICE_EXTENSION;
+#include <poppack.h>
+
+#else
+#error Unknown compiler for structure packing
+#endif
+
+
+#if defined(__GNUC__)
+
 /* Physical Device Object device extension for a child device */
 typedef struct _PNPROOT_PDO_DEVICE_EXTENSION
 {
@@ -72,6 +97,27 @@ typedef struct _PNPROOT_PDO_DEVICE_EXTENSION
   UNICODE_STRING InstanceID;
 } __attribute((packed)) PNPROOT_PDO_DEVICE_EXTENSION, *PPNPROOT_PDO_DEVICE_EXTENSION;
 
+#elif defined(_MSC_VER)
+
+#include <pshpack1.h>
+typedef struct _PNPROOT_PDO_DEVICE_EXTENSION
+{
+  // Common device data
+  PNPROOT_COMMON_DEVICE_EXTENSION Common;
+  // Device ID
+  UNICODE_STRING DeviceID;
+  // Instance ID
+  UNICODE_STRING InstanceID;
+} PNPROOT_PDO_DEVICE_EXTENSION, *PPNPROOT_PDO_DEVICE_EXTENSION;
+#include <poppack.h>
+
+#else
+#error Unknown compiler for structure packing
+#endif
+
+
+#if defined(__GNUC__)
+
 /* Functional Device Object device extension for the PCI driver device object */
 typedef struct _PNPROOT_FDO_DEVICE_EXTENSION
 {
@@ -92,6 +138,34 @@ typedef struct _PNPROOT_FDO_DEVICE_EXTENSION
   KSPIN_LOCK DeviceListLock;
 } __attribute((packed)) PNPROOT_FDO_DEVICE_EXTENSION, *PPNPROOT_FDO_DEVICE_EXTENSION;
 
+#elif defined(_MSC_VER)
+
+#include <pshpack1.h>
+typedef struct _PNPROOT_FDO_DEVICE_EXTENSION
+{
+  // Common device data
+  PNPROOT_COMMON_DEVICE_EXTENSION Common;
+  // Physical Device Object
+  PDEVICE_OBJECT Pdo;
+  // Lower device object
+  PDEVICE_OBJECT Ldo;
+  // Current state of the driver
+  PNPROOT_DEVICE_STATE State;
+  // Namespace device list
+  LIST_ENTRY DeviceListHead;
+  // Number of (not removed) devices in device list
+  ULONG DeviceListCount;
+  // Lock for namespace device list
+  // FIXME: Use fast mutex instead?
+  KSPIN_LOCK DeviceListLock;
+} PNPROOT_FDO_DEVICE_EXTENSION, *PPNPROOT_FDO_DEVICE_EXTENSION;
+#include <poppack.h>
+
+#else
+#error Unknown compiler for structure packing
+#endif
+
+
 
 PDEVICE_OBJECT PnpRootDeviceObject;
 
index c362004..2c783fa 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: process.c,v 1.15 2003/07/10 15:47:00 royce Exp $
+/* $Id: process.c,v 1.16 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -93,10 +93,10 @@ IoGetRequestorProcess(IN PIRP Irp)
  *
  * @implemented
  */
-BOOLEAN STDCALL EXPORTED
+BOOLEAN STDCALL
 IoSetThreadHardErrorMode(IN BOOLEAN HardErrorEnabled)
 {
-  BOOLEAN PreviousHEM = NtCurrentTeb()->HardErrorDisabled;
+  BOOLEAN PreviousHEM = (BOOLEAN)(NtCurrentTeb()->HardErrorDisabled);
 
   NtCurrentTeb()->HardErrorDisabled = ((TRUE == HardErrorEnabled) ? FALSE : TRUE);
 
index a5b54ce..9074478 100755 (executable)
@@ -1,4 +1,4 @@
-/* $Id: rawfs.c,v 1.8 2003/12/14 17:56:22 hbirr Exp $
+/* $Id: rawfs.c,v 1.9 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -412,7 +412,7 @@ static NTSTATUS
 RawFsClose(IN PRAWFS_IRP_CONTEXT IrpContext)
 {
   DPRINT("RawFsClose(IrpContext %x)\n", IrpContext);
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -501,7 +501,7 @@ RawFsCreate(IN PRAWFS_IRP_CONTEXT IrpContext)
 
   IrpContext->Irp->IoStatus.Status = Status;
   IoCompleteRequest(IrpContext->Irp, 
-    NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT);
+    (CCHAR)(NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT));
   RawFsFreeIrpContext(IrpContext);
 
   return Status;
@@ -511,7 +511,7 @@ static NTSTATUS
 RawFsRead(IN PRAWFS_IRP_CONTEXT IrpContext)
 {
   DPRINT("RawFsRead(IrpContext %x)\n", IrpContext);
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -519,7 +519,7 @@ static NTSTATUS
 RawFsWrite(IN PRAWFS_IRP_CONTEXT IrpContext)
 {
   DPRINT("RawFsWrite(IrpContext %x)\n", IrpContext);
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -714,7 +714,7 @@ static NTSTATUS
 RawFsQueryInformation(IN PRAWFS_IRP_CONTEXT IrpContext)
 {
   DPRINT("RawFsQueryInformation(IrpContext %x)\n", IrpContext);
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -722,7 +722,7 @@ static NTSTATUS
 RawFsSetInformation(IN PRAWFS_IRP_CONTEXT IrpContext)
 {
   DPRINT("RawFsSetInformation(IrpContext %x)\n", IrpContext);
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -730,7 +730,7 @@ static NTSTATUS
 RawFsDirectoryControl(IN PRAWFS_IRP_CONTEXT IrpContext)
 {
   DPRINT("RawFsDirectoryControl(IrpContext %x)\n", IrpContext);
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -738,7 +738,7 @@ static NTSTATUS
 RawFsQueryVolumeInformation(IN PRAWFS_IRP_CONTEXT IrpContext)
 {
   DPRINT("RawFsQueryVolumeInformation(IrpContext %x)\n", IrpContext);
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -746,7 +746,7 @@ static NTSTATUS
 RawFsSetVolumeInformation(IN PRAWFS_IRP_CONTEXT IrpContext)
 {
   DPRINT("RawFsSetVolumeInformation(IrpContext %x)\n", IrpContext);
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -754,7 +754,7 @@ static NTSTATUS
 RawFsLockControl(IN PRAWFS_IRP_CONTEXT IrpContext)
 {
   DPRINT("RawFsLockControl(IrpContext %x)\n", IrpContext);
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -762,7 +762,7 @@ static NTSTATUS
 RawFsCleanup(IN PRAWFS_IRP_CONTEXT IrpContext)
 {
   DPRINT("RawFsCleanup(IrpContext %x)\n", IrpContext);
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -770,7 +770,7 @@ static NTSTATUS
 RawFsFlush(IN PRAWFS_IRP_CONTEXT IrpContext)
 {
   DPRINT("RawFsFlush(IrpContext %x)\n", IrpContext);
-  UNIMPLEMENTED
+  UNIMPLEMENTED;
   return STATUS_NOT_IMPLEMENTED;
 }
 
index 6ce81eb..67d04c2 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: timer.c,v 1.10 2003/11/05 22:49:06 gvg Exp $
+/* $Id: timer.c,v 1.11 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -78,7 +78,7 @@ IoStartTimer(PDEVICE_OBJECT DeviceObject)
  *       DeviceObject = Device whose timer is to be started
  */
 {
-   long long int lli;
+   LONGLONG lli;
    LARGE_INTEGER li;
    
    lli = -1000000;
index 75c6013..e203cab 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: xhaldrv.c,v 1.41 2003/12/14 17:56:22 hbirr Exp $
+/* $Id: xhaldrv.c,v 1.42 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -298,7 +298,11 @@ xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
       return;
     }
 
+#if defined(__GNUC__)
   SectorOffset.QuadPart = 0LL;
+#else
+  SectorOffset.QuadPart = 0;
+#endif
   Status = xHalpReadSector (DeviceObject,
                            SectorSize,
                            &SectorOffset,
@@ -686,7 +690,11 @@ xHalIoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
 {
   LARGE_INTEGER RealPartitionOffset;
   ULONGLONG PartitionOffset;
+#if defined(__GNUC__)
   ULONGLONG nextPartitionOffset = 0LL;
+#else
+  ULONGLONG nextPartitionOffset = 0;
+#endif
   ULONGLONG containerOffset;
   NTSTATUS Status;
   PPARTITION_SECTOR PartitionSector;
@@ -754,8 +762,13 @@ xHalIoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
   RtlZeroMemory(LayoutBuffer,
                0x1000);
 
+#if defined(__GNUC__)
   PartitionOffset = 0ULL;
   containerOffset = 0ULL;
+#else
+  PartitionOffset = 0;
+  containerOffset = 0;
+#endif
 
   do
     {
@@ -767,7 +780,11 @@ xHalIoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
          /* Shift offset by 63 sectors */
          RealPartitionOffset.QuadPart = PartitionOffset + (ULONGLONG)(63 * SectorSize);
        }
+#if defined(__GNUC__)
       else if (DiskManager == EZ_Drive && PartitionOffset == 0ULL)
+#else
+      else if (DiskManager == EZ_Drive && PartitionOffset == 0)
+#endif
        {
          /* Use sector 1 instead of sector 0 */
          RealPartitionOffset.QuadPart = (ULONGLONG)SectorSize;
@@ -823,7 +840,11 @@ xHalIoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
        }
 #endif
 
+#if defined(__GNUC__)
       if (PartitionOffset == 0ULL)
+#else
+      if (PartitionOffset == 0)
+#endif
        {
          LayoutBuffer->Signature = PartitionSector->Signature;
          DPRINT("Disk signature: %lx\n", LayoutBuffer->Signature);
@@ -926,7 +947,11 @@ xHalIoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject,
   PPARTITION_SECTOR PartitionSector;
   LARGE_INTEGER RealPartitionOffset;
   ULONGLONG PartitionOffset;
+#if defined(__GNUC__)
   ULONGLONG nextPartitionOffset = 0LL;
+#else
+  ULONGLONG nextPartitionOffset = 0;
+#endif
   ULONGLONG containerOffset;
   NTSTATUS Status;
   ULONG i;
@@ -978,8 +1003,13 @@ xHalIoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject,
       return STATUS_INSUFFICIENT_RESOURCES;
     }
 
+#if defined(__GNUC__)
   PartitionOffset = 0ULL;
   containerOffset = 0ULL;
+#else
+  PartitionOffset = 0;
+  containerOffset = 0;
+#endif
 
   do
     {
@@ -991,7 +1021,11 @@ xHalIoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject,
          /* Shift offset by 63 sectors */
          RealPartitionOffset.QuadPart = PartitionOffset + (ULONGLONG)(63 * SectorSize);
        }
+#if defined(__GNUC__)
       else if (DiskManager == EZ_Drive && PartitionOffset == 0ULL)
+#else
+      else if (DiskManager == EZ_Drive && PartitionOffset == 0)
+#endif
        {
          /* Use sector 1 instead of sector 0 */
          RealPartitionOffset.QuadPart = (ULONGLONG)SectorSize;
@@ -1051,7 +1085,11 @@ xHalIoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject,
          if (IsContainerPartition (PartitionSector->Partition[i].PartitionType))
            {
              ExtendedFound = TRUE;
+#if defined(__GNUC__)
              if (containerOffset == 0ULL)
+#else
+             if (containerOffset == 0)
+#endif
                {
                  containerOffset = PartitionOffset;
                }
@@ -1105,7 +1143,11 @@ xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
   PPARTITION_SECTOR PartitionSector;
   LARGE_INTEGER RealPartitionOffset;
   ULONGLONG PartitionOffset;
+#if defined(__GNUC__)
   ULONGLONG NextPartitionOffset = 0LL;
+#else
+  ULONGLONG NextPartitionOffset = 0;
+#endif
   ULONGLONG ContainerOffset;
   BOOLEAN ContainerEntry;
   DISK_MANAGER DiskManager;
@@ -1174,8 +1216,13 @@ xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
     }
 
   Status = STATUS_SUCCESS;
+#if defined(__GNUC__)
   PartitionOffset = 0ULL;
   ContainerOffset = 0ULL;
+#else
+  PartitionOffset = 0;
+  ContainerOffset = 0;
+#endif
   for (i = 0; i < PartitionBuffer->PartitionCount; i += 4)
     {
       DPRINT ("PartitionOffset: %I64u\n", PartitionOffset);
@@ -1187,7 +1234,11 @@ xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
          /* Shift offset by 63 sectors */
          RealPartitionOffset.QuadPart = PartitionOffset + (ULONGLONG)(63 * SectorSize);
        }
+#if defined(__GNUC__)
       else if (DiskManager == EZ_Drive && PartitionOffset == 0ULL)
+#else
+      else if (DiskManager == EZ_Drive && PartitionOffset == 0)
+#endif
        {
          /* Use sector 1 instead of sector 0 */
          RealPartitionOffset.QuadPart = (ULONGLONG)SectorSize;
@@ -1243,8 +1294,13 @@ xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
                    PartitionBuffer->PartitionEntry[i + j].PartitionType;
 
                  /* Set partition data */
+#if defined(__GNUC__)
                  if (PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart == 0ULL &&
                      PartitionBuffer->PartitionEntry[i + j].PartitionLength.QuadPart == 0ULL)
+#else
+                 if (PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart == 0 &&
+                     PartitionBuffer->PartitionEntry[i + j].PartitionLength.QuadPart == 0)
+#endif
                    {
                      PartitionSector->Partition[j].StartingBlock = 0;
                      PartitionSector->Partition[j].SectorCount = 0;
@@ -1266,7 +1322,7 @@ xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
                       */
 
                      /* Compute starting CHS values */
-                     lba = (PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart) / SectorSize;
+                     lba = (ULONG)((PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart) / SectorSize);
                      x = lba / SectorsPerTrack;
                      StartCylinder = (x / NumberOfHeads) %1024;
                      StartHead = x % NumberOfHeads;
@@ -1275,8 +1331,8 @@ xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
                              lba, StartCylinder, StartHead, StartSector);
 
                      /* Compute ending CHS values */
-                     lba = (PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart +
-                            (PartitionBuffer->PartitionEntry[i + j].PartitionLength.QuadPart - 1)) / SectorSize;
+                     lba = (ULONG)((PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart +
+                            (PartitionBuffer->PartitionEntry[i + j].PartitionLength.QuadPart - 1)) / SectorSize);
                      x = lba / SectorsPerTrack;
                      EndCylinder = (x / NumberOfHeads) % 1024;
                      EndHead = x % NumberOfHeads;
@@ -1332,7 +1388,11 @@ xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
              NextPartitionOffset = 
                PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart;
 
+#if defined(__GNUC__)
              if (ContainerOffset == 0ULL)
+#else
+             if (ContainerOffset == 0)
+#endif
                {
                  ContainerOffset = NextPartitionOffset;
                }
index 78f988b..e5998d0 100644 (file)
@@ -269,9 +269,9 @@ GspGetPacket()
       if (ch == '#')
        {
          ch = KdGetChar ();
-         XmitChecksum = HexValue (ch) << 4;
+         XmitChecksum = (CHAR)(HexValue (ch) << 4);
          ch = KdGetChar ();
-         XmitChecksum += HexValue (ch);
+         XmitChecksum += (CHAR)(HexValue (ch));
 
          if (Checksum != XmitChecksum)
            {
@@ -430,8 +430,8 @@ GspHex2Mem (PCHAR Buffer,
 
       for (i = 0; i < countinpage && ! GspMemoryError; i++)
         {
-          ch = HexValue (*Buffer++) << 4;
-          ch = ch + HexValue (*Buffer++);
+          ch = (CHAR)(HexValue (*Buffer++) << 4);
+          ch = (CHAR)(ch + HexValue (*Buffer++));
 
           GspAccessLocation = Address;
           *current = ch;
@@ -874,6 +874,7 @@ typedef struct _GsHwBreakPoint
   ULONG Address;
 } GsHwBreakPoint;
 
+#if defined(__GNUC__)
 GsHwBreakPoint GspBreakpoints[4] =
 {
   { Enabled : FALSE },
@@ -881,6 +882,15 @@ GsHwBreakPoint GspBreakpoints[4] =
   { Enabled : FALSE },
   { Enabled : FALSE }
 };
+#else
+GsHwBreakPoint GspBreakpoints[4] =
+{
+  { FALSE },
+  { FALSE },
+  { FALSE },
+  { FALSE }
+};
+#endif
 
 VOID
 GspCorrectHwBreakpoint()
@@ -888,10 +898,11 @@ GspCorrectHwBreakpoint()
   ULONG BreakpointNumber;
   BOOLEAN CorrectIt;
   BOOLEAN Bit;
-  ULONG dr7;
+  ULONG dr7_;
 
+#if defined(__GNUC__)
   asm volatile (
-    "movl %%db7, %0\n" : "=r" (dr7) : );
+    "movl %%db7, %0\n" : "=r" (dr7_) : );
   do
     {
       ULONG addr0, addr1, addr2, addr3;
@@ -904,17 +915,30 @@ GspCorrectHwBreakpoint()
           : "=r" (addr0), "=r" (addr1),
             "=r" (addr2), "=r" (addr3) : );
     } while (FALSE);
+#elif defined(_MSC_VER)
+    __asm
+    {
+       mov eax, dr7; mov dr7_, eax;
+       mov eax, dr0; mov addr0, eax;
+       mov eax, dr1; mov addr1, eax;
+       mov eax, dr2; mov addr2, eax;
+       mov eax, dr3; mov addr3, eax;
+    }
+#else
+#error Unknown compiler for inline assembler
+#endif
     CorrectIt = FALSE;
     for (BreakpointNumber = 0; BreakpointNumber < 3; BreakpointNumber++)
     {
                        Bit = 2 << (BreakpointNumber << 1);
-                       if (!(dr7 & Bit) && GspBreakpoints[BreakpointNumber].Enabled) {
+                       if (!(dr7_ & Bit) && GspBreakpoints[BreakpointNumber].Enabled) {
                  CorrectIt = TRUE;
-                       dr7 |= Bit;
-                       dr7 &= ~(0xf0000 << (BreakpointNumber << 2));
-                       dr7 |= (((GspBreakpoints[BreakpointNumber].Length << 2) |
+                       dr7_ |= Bit;
+                       dr7_ &= ~(0xf0000 << (BreakpointNumber << 2));
+                       dr7_ |= (((GspBreakpoints[BreakpointNumber].Length << 2) |
         GspBreakpoints[BreakpointNumber].Type) << 16) << (BreakpointNumber << 2);
     switch (BreakpointNumber) {
+#if defined(__GNUC__)
                        case 0:
                          asm volatile ("movl %0, %%dr0\n"
                            : : "r" (GspBreakpoints[BreakpointNumber].Address) );
@@ -934,18 +958,57 @@ GspCorrectHwBreakpoint()
         asm volatile ("movl %0, %%dr3\n"
           : : "r" (GspBreakpoints[BreakpointNumber].Address) );
         break;
+#elif defined(_MSC_VER)
+       case 0:
+           {
+             ULONG addr = GspBreakpoints[BreakpointNumber].Address;
+             __asm mov eax, addr;
+             __asm mov dr0, eax;
+           }
+         break;
+       case 1:
+           {
+             ULONG addr = GspBreakpoints[BreakpointNumber].Address;
+             __asm mov eax, addr;
+             __asm mov dr1, eax;
+           }
+         break;
+       case 2:
+           {
+             ULONG addr = GspBreakpoints[BreakpointNumber].Address;
+             __asm mov eax, addr;
+             __asm mov dr2, eax;
+           }
+         break;
+       case 3:
+           {
+             ULONG addr = GspBreakpoints[BreakpointNumber].Address;
+             __asm mov eax, addr;
+             __asm mov dr3, eax;
+           }
+         break;
+#else
+#error Unknown compiler for inline assembler
+#endif
       }
     }
-    else if ((dr7 & Bit) && !GspBreakpoints[BreakpointNumber].Enabled)
+    else if ((dr7_ & Bit) && !GspBreakpoints[BreakpointNumber].Enabled)
       {
         CorrectIt = TRUE;
-        dr7 &= ~Bit;
-        dr7 &= ~(0xf0000 << (BreakpointNumber << 2));
+        dr7_ &= ~Bit;
+        dr7_ &= ~(0xf0000 << (BreakpointNumber << 2));
       }
   }
   if (CorrectIt)
     {
-           asm volatile ( "movl %0, %%db7\n" : : "r" (dr7));
+#if defined(__GNUC__)
+           asm volatile ( "movl %0, %%db7\n" : : "r" (dr7_));
+#elif defined(_MSC_VER)
+           __asm mov eax, dr7_;
+           __asm mov dr7, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
     }
 }
 
@@ -997,7 +1060,13 @@ KdEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
 
   /* FIXME: Stop on other CPUs too */
   /* Disable hardware debugging while we are inside the stub */
+#if defined(__GNUC__)
   __asm__("movl %0,%%db7" : /* no output */ : "r" (0));
+#elif defined(_MSC_VER)
+  __asm mov eax, 0  __asm mov dr7, eax
+#else
+#error Unknown compiler for inline assembler
+#endif
 
   if (STATUS_ACCESS_VIOLATION == (NTSTATUS) ExceptionRecord->ExceptionCode &&
       NULL != GspAccessLocation &&
@@ -1149,7 +1218,7 @@ GspSetSingleRegisterInTrapFrame (ptr, Register, Context, TrapFrame);
             case 'c':
               {
                 ULONG BreakpointNumber;
-                ULONG dr6;
+                ULONG dr6_;
 
                 /* try to read optional parameter, pc unchanged if no parm */
                 if (GspHex2Long (&ptr, &Address))
@@ -1164,12 +1233,18 @@ GspSetSingleRegisterInTrapFrame (ptr, Register, Context, TrapFrame);
                 if (Stepping)
                   Context->EFlags |= 0x100;
 
-                asm volatile ("movl %%db6, %0\n" : "=r" (dr6) : );
-                if (!(dr6 & 0x4000))
+#if defined(__GNUC__)
+                asm volatile ("movl %%db6, %0\n" : "=r" (dr6_) : );
+#elif defined(_MSC_VER)
+                __asm mov eax, dr6  __asm mov dr6_, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
+                if (!(dr6_ & 0x4000))
                   {
                     for (BreakpointNumber = 0; BreakpointNumber < 4; ++BreakpointNumber)
                       {
-                        if (dr6 & (1 << BreakpointNumber))
+                        if (dr6_ & (1 << BreakpointNumber))
                           {
                             if (GspBreakpoints[BreakpointNumber].Type == 0)
                               {
@@ -1181,7 +1256,13 @@ GspSetSingleRegisterInTrapFrame (ptr, Register, Context, TrapFrame);
                       }
                   }
                 GspCorrectHwBreakpoint();
+#if defined(__GNUC__)
                 asm volatile ("movl %0, %%db6\n" : : "r" (0));
+#elif defined(_MSC_VER)
+                __asm mov eax, 0  __asm mov dr6, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
 
                 return kdHandleException;
                 break;
index c2f9c3e..6626e00 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: service.c,v 1.5 2002/09/08 10:23:27 chorns Exp $
+/* $Id: service.c,v 1.6 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -47,6 +47,8 @@ KdpServiceDispatcher (
 #define _STR(x) #x
 #define STR(x) _STR(x)
 
+#if defined(__GNUC__)
+
 void interrupt_handler2d(void);
    __asm__("\n\t.global _interrupt_handler2d\n\t"
           "_interrupt_handler2d:\n\t"
@@ -113,4 +115,82 @@ void interrupt_handler2d(void);
           
           "iret\n\t");
 
+#elif defined(_MSC_VER)
+
+__declspec(naked)
+void interrupt_handler2d()
+{
+       __asm
+       {
+               /* Save the user context */
+               push ebp
+               push eax
+               push ecx
+               push edx
+               push ebx
+               push esi
+               push edi
+
+               push ds
+               push es
+               push fs
+               push gs
+
+               sub esp, 112  /* FloatSave */
+
+               mov eax, dr7; push eax;
+               mov eax, dr6; push eax;
+               mov eax, dr3; push eax;
+               mov eax, dr2; push eax;
+               mov eax, dr1; push eax;
+               mov eax, dr0; push eax;
+
+               push 0          /* ContextFlags */
+
+               /*  Set ES to kernel segment  */
+               mov bx, KERNEL_DS
+               mov es, bx
+
+               /* FIXME: check to see if SS is valid/inrange */
+
+               mov ds, bx      /*  DS is now also kernel segment */
+
+                       /* Call debug service dispatcher */
+               push edx
+               push ecx
+               push eax
+               call KdpServiceDispatcher
+               add esp, 12             /* restore stack pointer */
+
+               /*  Restore the user context  */
+               add esp, 4                      /* UserContext */
+               pop eax; mov dr0, eax;
+               pop eax; mov dr1, eax;
+               pop eax; mov dr2, eax;
+               pop eax; mov dr3, eax;
+               pop eax; mov dr6, eax;
+               pop eax; mov dr7, eax;
+               add esp, 112            /* FloatingSave */
+               pop gs
+               pop fs
+               pop es
+               pop ds
+
+               pop edi
+               pop esi
+               pop ebx
+               pop edx
+               pop ecx
+               add esp, 4              /* Eax Not restored */
+
+               pop ebp
+
+               iret
+       }
+}
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
 /* EOF */
index f98404c..de7e89d 100644 (file)
@@ -297,7 +297,7 @@ BOOLEAN STDCALL
 KeInsertQueueApc (PKAPC        Apc,
                  PVOID SystemArgument1,
                  PVOID SystemArgument2,
-        KPRIORITY PriorityBoost)
+                 KPRIORITY PriorityBoost)
 /*
  * FUNCTION: Queues an APC for execution
  * ARGUMENTS:
@@ -313,18 +313,23 @@ KeInsertQueueApc (PKAPC   Apc,
    DPRINT("KeInsertQueueApc(Apc %x, SystemArgument1 %x, "
          "SystemArgument2 %x)\n",Apc,SystemArgument1,
          SystemArgument2);
-   
-   KeAcquireSpinLock(&PiApcLock, &oldlvl);
-   
+
    Apc->SystemArgument1 = SystemArgument1;
    Apc->SystemArgument2 = SystemArgument2;
-   
+
    if (Apc->Inserted)
      {
+#if 0
+       /* TMN: This code is in error */
        DbgPrint("KeInsertQueueApc(): multiple APC insertations\n");
        KEBUGCHECK(0);
+#else
+       return FALSE;
+#endif
      }
-   
+
+   KeAcquireSpinLock(&PiApcLock, &oldlvl);
+
    TargetThread = Apc->Thread;
 
    if (TargetThread->State == THREAD_STATE_TERMINATED_1 ||
index 73961df..c0cf574 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: bug.c,v 1.40 2003/10/12 17:05:45 hbirr Exp $
+/* $Id: bug.c,v 1.41 2003/12/30 18:52:04 fireball Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ke/bug.c
@@ -103,7 +103,14 @@ KeBugCheckWithTf(ULONG BugCheckCode,
       KdDebugState |= KD_DEBUG_SCREEN;
     }
 
+#if defined(__GNUC__)
   __asm__("cli\n\t");
+#elif defined(_MSC_VER)
+  __asm cli
+#else
+#error Unknown compiler for inline assembler
+#endif
+
   if (KeGetCurrentIrql() < DISPATCH_LEVEL)
     {
       KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
@@ -137,7 +144,13 @@ KeBugCheckWithTf(ULONG BugCheckCode,
       DbgPrint("Recursive bug check halting now\n");
       for (;;)
        {
-         __asm__ ("hlt\n\t");
+#if defined(__GNUC__)
+         __asm__("hlt\n\t");
+#elif defined(_MSC_VER)
+         __asm hlt
+#else
+#error Unknown compiler for inline assembler
+#endif
        }
     }
   InBugCheck = 1;
@@ -148,14 +161,28 @@ KeBugCheckWithTf(ULONG BugCheckCode,
 
   if (KdDebuggerEnabled)
     {
+#if defined(__GNUC__)
       __asm__("sti\n\t");
       DbgBreakPoint();
       __asm__("cli\n\t");
+#elif defined(_MSC_VER)
+      __asm sti
+      DbgBreakPoint();
+      __asm cli
+#else
+#error Unknown compiler for inline assembler
+#endif
     }
 
   for (;;)
     {
+#if defined(__GNUC__)
       __asm__("hlt\n\t");
+#elif defined(_MSC_VER)
+      __asm hlt
+#else
+#error Unknown compiler for inline assembler
+#endif
     }
 }
 
@@ -188,7 +215,13 @@ KeBugCheckEx(ULONG BugCheckCode,
       KdDebugState |= KD_DEBUG_SCREEN;
     }
 
+#if defined(__GNUC__)
   __asm__("cli\n\t");
+#elif defined(_MSC_VER)
+  __asm cli
+#else
+#error Unknown compiler for inline assembler
+#endif
   if (KeGetCurrentIrql() < DISPATCH_LEVEL)
     {
       KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
@@ -222,7 +255,13 @@ KeBugCheckEx(ULONG BugCheckCode,
       DbgPrint("Recursive bug check halting now\n");
       for (;;)
        {
+#if defined(__GNUC__)
          __asm__("hlt\n\t");
+#elif defined(_MSC_VER)
+         __asm hlt
+#else
+#error Unknown compiler for inline assembler
+#endif
        }
     }
   InBugCheck = 1;
@@ -237,21 +276,43 @@ KeBugCheckEx(ULONG BugCheckCode,
               PsGetCurrentThread(),
               PsGetCurrentThread()->Cid.UniqueThread);
     }
+#if defined(__GNUC__)
   KeDumpStackFrames((PULONG)__builtin_frame_address(0));
+#elif defined(_MSC_VER)
+  __asm push ebp
+  __asm call KeDumpStackFrames
+  __asm add esp, 4
+#else
+#error Unknown compiler for inline assembler
+#endif
   MmDumpToPagingFile(BugCheckCode, BugCheckParameter1, 
                     BugCheckParameter2, BugCheckParameter3,
                     BugCheckParameter4, NULL);
 
   if (KdDebuggerEnabled)
     {
+#if defined(__GNUC__)
       __asm__("sti\n\t");
       DbgBreakPoint();
       __asm__("cli\n\t");
+#elif defined(_MSC_VER)
+      __asm sti
+      DbgBreakPoint();
+      __asm cli
+#else
+#error Unknown compiler for inline assembler
+#endif
     }
 
   for (;;)
     {
+#if defined(__GNUC__)
       __asm__("hlt\n\t");
+#elif defined(_MSC_VER)
+      __asm hlt
+#else
+#error Unknown compiler for inline assembler
+#endif
     }
 }
 
index efa873e..f6c35a2 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: catch.c,v 1.38 2003/12/14 19:43:09 navaraf Exp $
+/* $Id: catch.c,v 1.39 2003/12/30 18:52:04 fireball Exp $
  *
  * PROJECT:              ReactOS kernel
  * FILE:                 ntoskrnl/ke/catch.c
@@ -220,7 +220,7 @@ NtRaiseException (IN PEXCEPTION_RECORD ExceptionRecord,
   KiDispatchException(ExceptionRecord,
                      Context,
                      PsGetCurrentThread()->Tcb.TrapFrame,
-                     ExGetPreviousMode(),
+                     (KPROCESSOR_MODE)ExGetPreviousMode(),
                      SearchFrames);
   return(STATUS_SUCCESS);
 }
index c0b0f8e..09f27a7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ReactOS kernel
- *  Copyright (C) 2000, 1999, 1998 David Welch <welch@cwcom.net>, 
+ *  Copyright (C) 2000, 1999, 1998 David Welch <welch@cwcom.net>,
  *                                 Philip Susi <phreak@iag.net>,
  *                                 Eric Kohl <ekohl@abo.rhein-zeitung.de>
  *
@@ -18,7 +18,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dpc.c,v 1.28 2003/10/12 17:05:45 hbirr Exp $
+/* $Id: dpc.c,v 1.29 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
 
 static LIST_ENTRY DpcQueueHead; /* Head of the list of pending DPCs */
 static KSPIN_LOCK DpcQueueLock; /* Lock for the above list */
-/* 
+/*
  * Number of pending DPCs. This is inspected by
  * the idle thread to determine if the queue needs to
  * be run down
  */
-ULONG DpcQueueSize = 0; 
+ULONG DpcQueueSize = 0;
 
 /* FUNCTIONS ****************************************************************/
 
 /*
  * @implemented
  */
-VOID STDCALL 
+VOID STDCALL
 KeInitializeDpc (PKDPC                 Dpc,
                 PKDEFERRED_ROUTINE     DeferredRoutine,
                 PVOID                  DeferredContext)
@@ -82,7 +82,7 @@ KeInitializeDpc (PKDPC                        Dpc,
 /*
  * @implemented
  */
-VOID STDCALL 
+VOID STDCALL
 KiDispatchInterrupt(VOID)
 /*
  * FUNCTION: Called to execute queued dpcs
@@ -91,14 +91,14 @@ KiDispatchInterrupt(VOID)
    PLIST_ENTRY current_entry;
    PKDPC current;
    KIRQL oldlvl;
-   
+
    assert_irql(DISPATCH_LEVEL);
-   
+
    if (DpcQueueSize == 0)
      {
        return;
      }
-   
+
    KeRaiseIrql(HIGH_LEVEL, &oldlvl);
    KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
 
@@ -106,9 +106,13 @@ KiDispatchInterrupt(VOID)
    {
       current_entry = RemoveHeadList(&DpcQueueHead);
       DpcQueueSize--;
+
+      assert(DpcQueueSize || IsListEmpty(&DpcQueueHead));
+
       current = CONTAINING_RECORD(current_entry,KDPC,DpcListEntry);
       current->Lock=FALSE;
-      KeReleaseSpinLock(&DpcQueueLock, oldlvl);
+      KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
+      KeLowerIrql(oldlvl);
       current->DeferredRoutine(current,current->DeferredContext,
                               current->SystemArgument1,
                               current->SystemArgument2);
@@ -116,13 +120,14 @@ KiDispatchInterrupt(VOID)
       KeRaiseIrql(HIGH_LEVEL, &oldlvl);
       KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
    }
-   KeReleaseSpinLock(&DpcQueueLock, oldlvl);
+   KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
+   KeLowerIrql(oldlvl);
 }
 
 /*
  * @implemented
  */
-BOOLEAN STDCALL 
+BOOLEAN STDCALL
 KeRemoveQueueDpc (PKDPC        Dpc)
 /*
  * FUNCTION: Removes DPC object from the system dpc queue
@@ -133,25 +138,30 @@ KeRemoveQueueDpc (PKDPC   Dpc)
  */
 {
    KIRQL oldIrql;
-   
+   BOOLEAN WasInQueue;
+
    KeRaiseIrql(HIGH_LEVEL, &oldIrql);
    KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
-   if (!Dpc->Lock)
+   WasInQueue = Dpc->Lock ? TRUE : FALSE;
+   if (WasInQueue)
      {
-       KeReleaseSpinLock(&DpcQueueLock, oldIrql);
-       return(FALSE);
+       RemoveEntryList(&Dpc->DpcListEntry);
+       DpcQueueSize--;
+       Dpc->Lock=0;
      }
-   RemoveEntryList(&Dpc->DpcListEntry);
-   DpcQueueSize--;
-   Dpc->Lock=0;
-   KeReleaseSpinLock(&DpcQueueLock, oldIrql);
-   return(TRUE);
+
+   assert(DpcQueueSize || IsListEmpty(&DpcQueueHead));
+
+   KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
+   KeLowerIrql(oldIrql);
+
+   return WasInQueue;
 }
 
 /*
  * @implemented
  */
-BOOLEAN STDCALL 
+BOOLEAN STDCALL
 KeInsertQueueDpc (PKDPC        Dpc,
                  PVOID SystemArgument1,
                  PVOID SystemArgument2)
@@ -181,11 +191,13 @@ KeInsertQueueDpc (PKDPC   Dpc,
      }
    KeRaiseIrql(HIGH_LEVEL, &oldlvl);
    KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
+   assert(DpcQueueSize || IsListEmpty(&DpcQueueHead));
    InsertHeadList(&DpcQueueHead,&Dpc->DpcListEntry);
    DPRINT("Dpc->DpcListEntry.Flink %x\n", Dpc->DpcListEntry.Flink);
    DpcQueueSize++;
    Dpc->Lock=(PULONG)1;
-   KeReleaseSpinLock( &DpcQueueLock, oldlvl );
+   KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
+   KeLowerIrql(oldlvl);
    DPRINT("DpcQueueHead.Flink %x\n",DpcQueueHead.Flink);
    DPRINT("Leaving KeInsertQueueDpc()\n",0);
    return(TRUE);
index 9fbcfd1..eea7b63 100644 (file)
 VOID STDCALL 
 DbgBreakPoint(VOID)
 {
+#if defined(__GNUC__)
    __asm__("int $3\n\t");
+#elif defined(_MSC_VER)
+   __asm int 3;
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 
 /*
@@ -46,7 +52,14 @@ DbgBreakPoint(VOID)
 VOID STDCALL 
 DbgBreakPointWithStatus(ULONG Status)
 {
+#if defined(__GNUC__)
    __asm__("mov %0, %%eax\n\t"
            "int $3\n\t"
            ::"m"(Status));
+#elif defined(_MSC_VER)
+   __asm mov eax, Status
+   __asm int 3;
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
index aad25c7..466d9a5 100644 (file)
@@ -194,7 +194,7 @@ KiKernelTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr, PVOID Cr2)
 ULONG
 KiDoubleFaultHandler(VOID)
 {
-  unsigned int cr2;
+  unsigned int cr2_;
   ULONG StackLimit;
   ULONG StackBase;
   ULONG Esp0;
@@ -215,12 +215,19 @@ KiDoubleFaultHandler(VOID)
   Esp0 = OldTss->Esp;
 
   /* Get CR2 */
-  __asm__("movl %%cr2,%0\n\t" : "=d" (cr2));
+#if defined(__GNUC__)
+  __asm__("movl %%cr2,%0\n\t" : "=d" (cr2_));
+#elif defined(_MSC_VER)
+  __asm mov eax, cr2;
+  __asm mov cr2_, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
 
   if (PsGetCurrentThread() != NULL &&
       PsGetCurrentThread()->ThreadsProcess != NULL)
     {
-      OldCr3 = 
+      OldCr3 = (ULONG)
        PsGetCurrentThread()->ThreadsProcess->Pcb.DirectoryTableBase.QuadPart;
     }
   else
@@ -254,7 +261,7 @@ KiDoubleFaultHandler(VOID)
    DbgPrint("CS:EIP %x:%x ", OldTss->Cs, OldTss->Eip);
    print_address((PVOID)OldTss->Eip);
    DbgPrint("\n");
-   DbgPrint("cr2 %x cr3 %x ", cr2, OldCr3);
+   DbgPrint("cr2 %x cr3 %x ", cr2_, OldCr3);
    DbgPrint("Proc: %x ",PsGetCurrentProcess());
    if (PsGetCurrentProcess() != NULL)
      {
@@ -401,7 +408,7 @@ KiDoubleFaultHandler(VOID)
 VOID
 KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG Parameter1, ULONG Parameter2)
 {
-  ULONG cr3;
+  ULONG cr3_;
   ULONG i;
   ULONG StackLimit;
   PULONG Frame;
@@ -427,8 +434,15 @@ KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG Parameter1, ULONG Parameter2)
            Tf->Cs&0xffff, Tf->Eip);
    print_address((PVOID)Tf->Eip);
    DbgPrint("\n");
-   __asm__("movl %%cr3,%0\n\t" : "=d" (cr3));
-   DbgPrint("cr2 %x cr3 %x ", cr2, cr3);
+#if defined(__GNUC__)
+   __asm__("movl %%cr3,%0\n\t" : "=d" (cr3_));
+#elif defined(_MSC_VER)
+  __asm mov eax, cr3;
+  __asm mov cr3_, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
+   DbgPrint("cr2 %x cr3 %x ", cr2, cr3_);
    DbgPrint("Proc: %x ",PsGetCurrentProcess());
    if (PsGetCurrentProcess() != NULL)
      {
@@ -493,7 +507,7 @@ KiTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr)
  *        Complete CPU context
  */
 {
-   unsigned int cr2;
+   unsigned int cr2_;
    NTSTATUS Status;
    ULONG Esp0;
 
@@ -504,15 +518,22 @@ KiTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr)
    Esp0 = (ULONG)&Tf->Eip;
   
    /* Get CR2 */
-   __asm__("movl %%cr2,%0\n\t" : "=d" (cr2));
-   Tf->DebugPointer = (PVOID)cr2;
+#if defined(__GNUC__)
+   __asm__("movl %%cr2,%0\n\t" : "=d" (cr2_));
+#elif defined(_MSC_VER)
+  __asm mov eax, cr2;
+  __asm mov cr2_, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
+   Tf->DebugPointer = (PVOID)cr2_;
    
    /*
     * If this was a V86 mode exception then handle it specially
     */
    if (Tf->Eflags & (1 << 17))
      {
-       return(KeV86Exception(ExceptionNr, Tf, cr2));
+       return(KeV86Exception(ExceptionNr, Tf, cr2_));
      }
 
    /*
@@ -538,7 +559,7 @@ KiTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr)
        Status = MmPageFault(Tf->Cs&0xffff,
                             &Tf->Eip,
                             &Tf->Eax,
-                            cr2,
+                            cr2_,
                             Tf->ErrorCode);
        if (NT_SUCCESS(Status))
          {
@@ -551,11 +572,11 @@ KiTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr)
     */
    if ((Tf->Cs & 0xFFFF) == USER_CS)
      {
-       return(KiUserTrapHandler(Tf, ExceptionNr, (PVOID)cr2));
+       return(KiUserTrapHandler(Tf, ExceptionNr, (PVOID)cr2_));
      }
    else
     {
-      return(KiKernelTrapHandler(Tf, ExceptionNr, (PVOID)cr2));
+      return(KiKernelTrapHandler(Tf, ExceptionNr, (PVOID)cr2_));
     }
 }
 
index 405e235..770ec99 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: fpu.c,v 1.11 2003/11/06 20:40:25 gvg Exp $
+/* $Id: fpu.c,v 1.12 2003/12/30 18:52:04 fireball Exp $
  *
  *  ReactOS kernel
  *  Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
@@ -46,31 +46,60 @@ VOID INIT_FUNCTION
 KiCheckFPU(VOID)
 {
    unsigned short int status;
-   int cr0;
+   int cr0_;
    
    HardwareMathSupport = 0;
    
-   __asm__("movl %%cr0, %0\n\t" : "=a" (cr0));
+#if defined(__GNUC__)
+   __asm__("movl %%cr0, %0\n\t" : "=a" (cr0_));
    /* Set NE and MP. */
-   cr0 = cr0 | 0x22;
+   cr0_ = cr0_ | 0x22;
    /* Clear EM */
-   cr0 = cr0 & (~0x4);
-   __asm__("movl %0, %%cr0\n\t" : : "a" (cr0));
+   cr0_ = cr0_ & (~0x4);
+   __asm__("movl %0, %%cr0\n\t" : : "a" (cr0_));
 
    __asm__("clts\n\t");
    __asm__("fninit\n\t");
    __asm__("fstsw %0\n\t" : "=a" (status));
    if (status != 0)
      {
-       __asm__("movl %%cr0, %0\n\t" : "=a" (cr0));
+       __asm__("movl %%cr0, %0\n\t" : "=a" (cr0_));
        /* Set the EM flag in CR0 so any FPU instructions cause a trap. */
-       cr0 = cr0 | 0x4;
+       cr0_ = cr0_ | 0x4;
        __asm__("movl %0, %%cr0\n\t" :
-               : "a" (cr0));
+               : "a" (cr0_));
        return;
      }
    /* fsetpm for i287, ignored by i387 */
    __asm__(".byte 0xDB, 0xE4\n\t");
+#elif defined(_MSC_VER)
+   __asm mov eax, cr0;
+   __asm mov cr0_, eax;
+   cr0_ |= 0x22;       /* Set NE and MP. */
+   cr0_ &= ~0x4;       /* Clear EM */
+   __asm
+   {
+          mov eax, cr0_;
+          mov cr0, eax;
+          clts;
+          fninit;
+          fstsw status
+   }
+   if (status != 0)
+     {
+       __asm mov eax, cr0_;
+       __asm or eax, 4; /* Set the EM flag in CR0 so any FPU instructions cause a trap. */
+       __asm mov cr0, eax;
+       return;
+     }
+   /* fsetpm for i287, ignored by i387 */
+   __asm _emit 0xDB __asm _emit 0xe4
+//   __asm fsetpm;
+//   __asm__(".byte 0xDB, 0xE4\n\t");
+#else
+#error Unknown compiler for inline assembler
+#endif
+
    HardwareMathSupport = 1;
 }
 
@@ -91,7 +120,14 @@ KeSaveFloatingPointState(OUT PKFLOATING_SAVE Save)
     }
   *((PVOID *) Save) = FpState;
 
+#if defined(__GNUC__)
   __asm__("fsave %0\n\t" : "=m" (*FpState));
+#elif defined(_MSC_VER)
+  __asm mov eax, FpState;
+  __asm fsave [eax];
+#else
+#error Unknown compiler for inline assembler
+#endif
 
   return STATUS_SUCCESS;
 }
@@ -101,7 +137,15 @@ KeRestoreFloatingPointState(IN PKFLOATING_SAVE Save)
 {
   char *FpState = *((PVOID *) Save);
 
+#if defined(__GNUC__)
   __asm__("frstor %0\n\t" : "=m" (*FpState));
+#elif defined(_MSC_VER)
+  __asm mov eax, FpState;
+  __asm frstor [eax];
+#else
+#error Unknown compiler for inline assembler
+#endif
+
   ExFreePool(FpState);
 
   return STATUS_SUCCESS;
index 5a1ede9..a1c2dd5 100644 (file)
@@ -112,19 +112,20 @@ KiInitializeGdt(PKPCR Pcr)
    */
   Base = (ULONG)Pcr;
   Entry = PCR_SELECTOR / 2;
-  Gdt[Entry + 1] = ((ULONG)Base) & 0xffff;
+  Gdt[Entry + 1] = (USHORT)(((ULONG)Base) & 0xffff);
   
   Gdt[Entry + 2] = Gdt[Entry + 2] & ~(0xff);
-  Gdt[Entry + 2] = Gdt[Entry + 2] | ((((ULONG)Base) & 0xff0000) >> 16);
+  Gdt[Entry + 2] = (USHORT)(Gdt[Entry + 2] | ((((ULONG)Base) & 0xff0000) >> 16));
    
   Gdt[Entry + 3] = Gdt[Entry + 3] & ~(0xff00);
-  Gdt[Entry + 3] = Gdt[Entry + 3] | ((((ULONG)Base) & 0xff000000) >> 16);
+  Gdt[Entry + 3] = (USHORT)(Gdt[Entry + 3] | ((((ULONG)Base) & 0xff000000) >> 16));
 
   /*
    * Load the GDT
    */
   Descriptor.Length = 8 * 11;
   Descriptor.Base = (ULONG)Gdt;
+#if defined(__GNUC__)
   __asm__ ("lgdt %0\n\t" : /* no output */ : "m" (Descriptor));
   
   /*
@@ -142,6 +143,24 @@ KiInitializeGdt(PKPCR Pcr)
           ".l4:\n\t"
           : /* no output */
           : "a" (KERNEL_CS));
+#elif defined(_MSC_VER)
+  __asm
+  {
+         lgdt Descriptor;
+               mov ax, KERNEL_DS;
+               mov bx, PCR_SELECTOR;
+               mov ds, ax;
+               mov es, ax;
+               mov fs, bx;
+               mov gs, ax;
+               push KERNEL_CS;
+               push offset l4 ; // what the heck...
+               ret
+               l4:
+       }
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 
 VOID 
@@ -158,15 +177,15 @@ KeSetBaseGdtSelector(ULONG Entry,
    
    Entry = (Entry & (~0x3)) / 2;
    
-   Gdt[Entry + 1] = ((ULONG)Base) & 0xffff;
+   Gdt[Entry + 1] = (USHORT)(((ULONG)Base) & 0xffff);
    
    Gdt[Entry + 2] = Gdt[Entry + 2] & ~(0xff);
-   Gdt[Entry + 2] = Gdt[Entry + 2] |
-     ((((ULONG)Base) & 0xff0000) >> 16);
+   Gdt[Entry + 2] = (USHORT)(Gdt[Entry + 2] |
+     ((((ULONG)Base) & 0xff0000) >> 16));
    
    Gdt[Entry + 3] = Gdt[Entry + 3] & ~(0xff00);
-   Gdt[Entry + 3] = Gdt[Entry + 3] |
-     ((((ULONG)Base) & 0xff000000) >> 16);
+   Gdt[Entry + 3] = (USHORT)(Gdt[Entry + 3] |
+     ((((ULONG)Base) & 0xff000000) >> 16));
    
    DPRINT("%x %x %x %x\n", 
           Gdt[Entry + 0],
index 1e2e291..b036c2c 100644 (file)
 
 IDT_DESCRIPTOR KiIdt[256];
 
+#if defined(__GNUC__)
 struct
 {
   USHORT Length;
   ULONG Base;
 } __attribute__((packed)) KiIdtDescriptor = {256 * 8, (ULONG)KiIdt};
+#else
+#include <pshpack1.h>
+struct dummyname_for_this_one
+{
+  USHORT Length;
+  ULONG Base;
+};
+#include <poppack.h>
+struct dummyname_for_this_one KiIdtDescriptor = {256 * 8, (ULONG)KiIdt};
+#endif
 
 
 /* FUNCTIONS *****************************************************************/
index b21ca4d..914334c 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: irq.c,v 1.36 2003/10/12 17:05:45 hbirr Exp $
+/* $Id: irq.c,v 1.37 2003/12/30 18:52:05 fireball Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ke/i386/irq.c
@@ -275,9 +275,9 @@ VOID
 KeIRQTrapFrameToTrapFrame(PKIRQ_TRAPFRAME IrqTrapFrame,
   PKTRAP_FRAME TrapFrame)
 {
-   TrapFrame->Fs     = IrqTrapFrame->Fs;
-   TrapFrame->Es     = IrqTrapFrame->Es;
-   TrapFrame->Ds     = IrqTrapFrame->Ds;
+   TrapFrame->Fs     = (USHORT)IrqTrapFrame->Fs;
+   TrapFrame->Es     = (USHORT)IrqTrapFrame->Es;
+   TrapFrame->Ds     = (USHORT)IrqTrapFrame->Ds;
    TrapFrame->Eax    = IrqTrapFrame->Eax;
    TrapFrame->Ecx    = IrqTrapFrame->Ecx;
    TrapFrame->Edx    = IrqTrapFrame->Edx;
@@ -480,7 +480,7 @@ KiInterruptDispatch (ULONG irq, PKIRQ_TRAPFRAME Trapframe)
     * default HAL this will send an EOI to the PIC and alter the IRQL.
     */
    if (!HalBeginSystemInterrupt (irq + IRQ_BASE,
-                                PROFILE_LEVEL - irq,
+                                (KIRQL)(PROFILE_LEVEL - irq),
                                 &old_level))
      {
        return;
index a99a5b2..238bb39 100644 (file)
@@ -66,7 +66,7 @@ KeApplicationProcessorInit(VOID)
                                  PAGE_READWRITE,
                                  PcrPages[Offset]);
   memset(KPCR, 0, PAGE_SIZE);
-  KPCR->ProcessorNumber = Offset;
+  KPCR->ProcessorNumber = (UCHAR)Offset;
   KPCR->Self = KPCR;
   KPCR->Irql = HIGH_LEVEL;
 
index 4422a59..6782782 100644 (file)
@@ -131,19 +131,26 @@ NtSetLdtEntries (ULONG Selector1,
       memcpy((PVOID) NewLdtBase, (PVOID) LdtBase, LdtLimit+1);
     }
 
-    LdtDescriptor[0] = (--NewLdtSize) & 0xffff;
-    LdtDescriptor[1] = NewLdtBase & 0xffff;
-    LdtDescriptor[2] = ((NewLdtBase & 0xff0000) >> 16) | 0x8200;
-    LdtDescriptor[3] = ((NewLdtSize & 0xf0000) >> 16) |
-                       ((NewLdtBase & 0xff000000) >> 16);
+    LdtDescriptor[0] = (USHORT)((--NewLdtSize) & 0xffff);
+    LdtDescriptor[1] = (USHORT)(NewLdtBase & 0xffff);
+    LdtDescriptor[2] = (USHORT)(((NewLdtBase & 0xff0000) >> 16) | 0x8200);
+    LdtDescriptor[3] = (USHORT)(((NewLdtSize & 0xf0000) >> 16) |
+                                ((NewLdtBase & 0xff000000) >> 16));
 
     KeSetGdtSelector(LDT_SELECTOR,
                      ((PULONG) LdtDescriptor)[0],
                      ((PULONG) LdtDescriptor)[1]);
 
+#if defined(__GNUC__)
     __asm__("lldtw %%ax" 
             : /* no output */
             : "a" (LDT_SELECTOR));
+#elif defined(_MSC_VER)
+    __asm mov ax, LDT_SELECTOR
+    __asm lldt ax 
+#else
+#error Unknown compiler for inline assembler
+#endif
 
     if(LdtBase)
     {
@@ -155,14 +162,14 @@ NtSetLdtEntries (ULONG Selector1,
 
   if(Selector1)
   {
-    memcpy((PVOID) LdtBase + Selector1,
+    memcpy((char*)LdtBase + Selector1,
            &LdtEntry1,
            sizeof(LDT_ENTRY));
   }
 
   if(Selector2)
   {
-    memcpy((PVOID) LdtBase + Selector2,
+    memcpy((char*)LdtBase + Selector2,
            &LdtEntry2,
            sizeof(LDT_ENTRY));
   }
index 33a3792..655f238 100644 (file)
@@ -106,7 +106,7 @@ Ke386InitThreadWithContext(PKTHREAD Thread, PCONTEXT Context)
   
   InitSize = 5 * sizeof(DWORD) + sizeof(DWORD) + 6 * sizeof(DWORD) + 
     sizeof(FLOATING_SAVE_AREA) + sizeof(KTRAP_FRAME);
-  KernelStack = (PULONG)(Thread->KernelStack - InitSize);
+  KernelStack = (PULONG)((char*)Thread->KernelStack - InitSize);
 
   /* Set up the initial frame for the return from the dispatcher. */
   KernelStack[0] = 0;      /* EDI */
@@ -132,16 +132,16 @@ Ke386InitThreadWithContext(PKTHREAD Thread, PCONTEXT Context)
 
   /* Set up a trap frame from the context. */
   TrapFrame = (PKTRAP_FRAME)
-    ((PVOID)KernelStack + 12 * sizeof(DWORD) + sizeof(FLOATING_SAVE_AREA));
+    ((char*)KernelStack + 12 * sizeof(DWORD) + sizeof(FLOATING_SAVE_AREA));
   TrapFrame->DebugEbp = (PVOID)Context->Ebp;
   TrapFrame->DebugEip = (PVOID)Context->Eip;
   TrapFrame->DebugArgMark = 0;
   TrapFrame->DebugPointer = 0;
   TrapFrame->TempCs = 0;
   TrapFrame->TempEip = 0;
-  TrapFrame->Gs = Context->SegGs;
-  TrapFrame->Es = Context->SegEs;
-  TrapFrame->Ds = Context->SegDs;
+  TrapFrame->Gs = (USHORT)Context->SegGs;
+  TrapFrame->Es = (USHORT)Context->SegEs;
+  TrapFrame->Ds = (USHORT)Context->SegDs;
   TrapFrame->Edx = Context->Edx;
   TrapFrame->Ecx = Context->Ecx;
   TrapFrame->Eax = Context->Eax;
@@ -158,7 +158,7 @@ Ke386InitThreadWithContext(PKTHREAD Thread, PCONTEXT Context)
   TrapFrame->Eflags = Context->EFlags | FLAG_IF;
   TrapFrame->Eflags &= ~(FLAG_VM | FLAG_NT | FLAG_IOPL);
   TrapFrame->Esp = Context->Esp;
-  TrapFrame->Ss = Context->SegSs;
+  TrapFrame->Ss = (USHORT)Context->SegSs;
   /* FIXME: Should check for a v86 mode context here. */
 
   /* Save back the new value of the kernel stack. */
@@ -181,7 +181,7 @@ Ke386InitThread(PKTHREAD Thread,
    * Setup a stack frame for exit from the task switching routine
    */
   
-  KernelStack = (PULONG)(Thread->KernelStack - (8*4));
+  KernelStack = (PULONG)((char*)Thread->KernelStack - (8*4));
   KernelStack[0] = 0;      /* EDI */
   KernelStack[1] = 0;      /* ESI */
   KernelStack[2] = 0;      /* EBX */
index 04bf701..e81a09f 100644 (file)
@@ -115,7 +115,7 @@ Ke386QueryIoAccessMap(DWORD MapNumber, PULONG IOMapStart)
 VOID
 Ki386ApplicationProcessorInitializeTSS(VOID)
 {
-  ULONG cr3;
+  ULONG cr3_;
   KTSS* Tss;
   KTSSNOIOPM* TrapTss;
   PVOID TrapStack;
@@ -126,7 +126,14 @@ Ki386ApplicationProcessorInitializeTSS(VOID)
   Id = KeGetCurrentProcessorNumber();
   Gdt = KeGetCurrentKPCR()->GDT;
 
-  __asm__("movl %%cr3,%0\n\t" : "=d" (cr3));
+#if defined(__GNUC__)
+  __asm__("movl %%cr3,%0\n\t" : "=d" (cr3_));
+#elif defined(_MSC_VER)
+  __asm mov eax, cr3;
+  __asm mov cr3_, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
 
   Tss = ExAllocatePool(NonPagedPool, sizeof(KTSS));
   TrapTss = ExAllocatePool(NonPagedPool, sizeof(KTSSNOIOPM));
@@ -150,11 +157,11 @@ Ki386ApplicationProcessorInitializeTSS(VOID)
   base = (ULONG)Tss;
   length = sizeof(KTSS) - 1;
   
-  Gdt[(TSS_SELECTOR / 2) + 0] = (length & 0xFFFF);
-  Gdt[(TSS_SELECTOR / 2) + 1] = (base & 0xFFFF);
-  Gdt[(TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8900;
-  Gdt[(TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
-    ((base & 0xFF000000) >> 16);
+  Gdt[(TSS_SELECTOR / 2) + 0] = (USHORT)(length & 0xFFFF);
+  Gdt[(TSS_SELECTOR / 2) + 1] = (USHORT)(base & 0xFFFF);
+  Gdt[(TSS_SELECTOR / 2) + 2] = (USHORT)(((base & 0xFF0000) >> 16) | 0x8900);
+  Gdt[(TSS_SELECTOR / 2) + 3] = (USHORT)(((length & 0xF0000) >> 16) |
+    ((base & 0xFF000000) >> 16));
 
   /* Initialize the TSS used for handling double faults. */
   TrapTss->Eflags = 0;
@@ -170,7 +177,7 @@ Ki386ApplicationProcessorInitializeTSS(VOID)
   TrapTss->IoMapBase = 0xFFFF; /* No i/o bitmap */
   TrapTss->IoBitmap[0] = 0xFF;   
   TrapTss->Ldt = 0;
-  TrapTss->Cr3 = cr3;  
+  TrapTss->Cr3 = cr3_;  
 
   /*
    * Initialize a descriptor for the trap TSS.
@@ -178,29 +185,43 @@ Ki386ApplicationProcessorInitializeTSS(VOID)
   base = (ULONG)TrapTss;
   length = sizeof(KTSSNOIOPM) - 1;
 
-  Gdt[(TRAP_TSS_SELECTOR / 2) + 0] = (length & 0xFFFF);
-  Gdt[(TRAP_TSS_SELECTOR / 2) + 1] = (base & 0xFFFF);
-  Gdt[(TRAP_TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8900;
-  Gdt[(TRAP_TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
-    ((base & 0xFF000000) >> 16);
+  Gdt[(TRAP_TSS_SELECTOR / 2) + 0] = (USHORT)(length & 0xFFFF);
+  Gdt[(TRAP_TSS_SELECTOR / 2) + 1] = (USHORT)(base & 0xFFFF);
+  Gdt[(TRAP_TSS_SELECTOR / 2) + 2] = (USHORT)(((base & 0xFF0000) >> 16) | 0x8900);
+  Gdt[(TRAP_TSS_SELECTOR / 2) + 3] = (USHORT)(((length & 0xF0000) >> 16) |
+    ((base & 0xFF000000) >> 16));
 
   /*
    * Load the task register
    */
+#if defined(__GNUC__)
   __asm__("ltr %%ax" 
          : /* no output */
          : "a" (TSS_SELECTOR));
+#elif defined(_MSC_VER)
+  __asm mov ax, TSS_SELECTOR
+  __asm ltr ax
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 
 VOID INIT_FUNCTION
 Ki386BootInitializeTSS(VOID)
 {
-  ULONG cr3;
+  ULONG cr3_;
   extern unsigned int init_stack, init_stack_top;
   extern unsigned int trap_stack, trap_stack_top;
   unsigned int base, length;
 
-  __asm__("movl %%cr3,%0\n\t" : "=d" (cr3));
+#if defined(__GNUC__)
+  __asm__("movl %%cr3,%0\n\t" : "=d" (cr3_));
+#elif defined(_MSC_VER)
+  __asm mov eax, cr3;
+  __asm mov cr3_, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
 
   Ki386TssArray[0] = &KiBootTss;
   Ki386TrapTssArray[0] = &KiBootTrapTss;
@@ -241,7 +262,7 @@ Ki386BootInitializeTSS(VOID)
   KiBootTrapTss.IoMapBase = 0xFFFF; /* No i/o bitmap */
   KiBootTrapTss.IoBitmap[0] = 0xFF;   
   KiBootTrapTss.Ldt = 0x0;
-  KiBootTrapTss.Cr3 = cr3;
+  KiBootTrapTss.Cr3 = cr3_;
   
   /*
    * Initialize a descriptor for the trap TSS.
@@ -258,9 +279,16 @@ Ki386BootInitializeTSS(VOID)
   /*
    * Load the task register
    */
+#if defined(__GNUC__)
   __asm__("ltr %%ax" 
          : /* no output */
          : "a" (TSS_SELECTOR));
+#elif defined(_MSC_VER)
+  __asm mov ax, TSS_SELECTOR
+  __asm ltr ax
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 
 
index 9253e76..2da16fb 100644 (file)
@@ -83,7 +83,7 @@ print_user_address(PVOID address)
          CONTAINING_RECORD(current_entry, LDR_MODULE, InLoadOrderModuleList);
        
        if (address >= (PVOID)current->BaseAddress &&
-           address < (PVOID)(current->BaseAddress + current->SizeOfImage))
+           address < (PVOID)((char*)current->BaseAddress + current->SizeOfImage))
          {
             RelativeAddress = 
              (ULONG_PTR) address - (ULONG_PTR)current->BaseAddress;
index be7e9a5..7cf8535 100644 (file)
@@ -137,14 +137,14 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf)
                {
                  Tf->Esp = Tf->Esp - 2;
                  sp = sp - 1;
-                 sp[0] = Tf->Eflags & 0xFFFF;
+                 sp[0] = (USHORT)(Tf->Eflags & 0xFFFF);
                  if (VTf->regs->Vif == 1)
                    {
-                     sp[0] = sp[0] | INTERRUPT_FLAG;
+                     sp[0] = (USHORT)(sp[0] | INTERRUPT_FLAG);
                    }
                  else
                    {
-                     sp[0] = sp[0] & (~INTERRUPT_FLAG);
+                     sp[0] = (USHORT)(sp[0] & (~INTERRUPT_FLAG));
                    }
                }
              else
@@ -250,7 +250,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf)
            {
              DPRINT("outb %d, %x\n", (ULONG)ip[i + 1], Tf->Eax & 0xFF);
              WRITE_PORT_UCHAR((PUCHAR)(ULONG)ip[i + 1], 
-                              Tf->Eax & 0xFF);
+                              (UCHAR)(Tf->Eax & 0xFF));
              Tf->Eip = Tf->Eip + 2;
              return(0);
            }
@@ -269,7 +269,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf)
              if (!BigDataPrefix)
                {
                  DPRINT("outw %d, %x\n", (ULONG)ip[i + 1], Tf->Eax & 0xFFFF);
-                 WRITE_PORT_USHORT((PUSHORT)(ULONG)ip[1], Tf->Eax & 0xFFFF);
+                 WRITE_PORT_USHORT((PUSHORT)(ULONG)ip[1], (USHORT)(Tf->Eax & 0xFFFF));
                }
              else
                {
@@ -292,7 +292,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf)
          if (VTf->regs->Flags & KV86M_ALLOW_IO_PORT_ACCESS)
            {
              DPRINT("outb %d, %x\n", Tf->Edx & 0xFFFF, Tf->Eax & 0xFF);
-             WRITE_PORT_UCHAR((PUCHAR)(Tf->Edx & 0xFFFF), Tf->Eax & 0xFF);
+             WRITE_PORT_UCHAR((PUCHAR)(Tf->Edx & 0xFFFF), (UCHAR)(Tf->Eax & 0xFF));
              Tf->Eip = Tf->Eip + 1;
              return(0);
            }
@@ -312,7 +312,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf)
                {
                  DPRINT("outw %d, %x\n", Tf->Edx & 0xFFFF, Tf->Eax & 0xFFFF);
                  WRITE_PORT_USHORT((PUSHORT)(Tf->Edx & 0xFFFF), 
-                                   Tf->Eax & 0xFFFF);
+                                   (USHORT)(Tf->Eax & 0xFFFF));
                }
              else
                {
@@ -676,12 +676,12 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf)
            Tf->Esp = Tf->Esp - 6;
            sp = sp - 3;
            
-           sp[0] = (Tf->Eip & 0xFFFF) + 2;
-           sp[1] = Tf->Cs & 0xFFFF;
-           sp[2] = Tf->Eflags & 0xFFFF;
+           sp[0] = (USHORT)((Tf->Eip & 0xFFFF) + 2);
+           sp[1] = (USHORT)(Tf->Cs & 0xFFFF);
+           sp[2] = (USHORT)(Tf->Eflags & 0xFFFF);
            if (VTf->regs->Vif == 1)
              {
-               sp[2] = sp[2] | INTERRUPT_FLAG;
+               sp[2] = (USHORT)(sp[2] | INTERRUPT_FLAG);
              }
            DPRINT("sp[0] %x sp[1] %x sp[2] %x\n", sp[0], sp[1], sp[2]);
            Tf->Eip = entry & 0xFFFF;
index 53b8498..c718417 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: kthread.c,v 1.44 2003/11/30 19:00:02 gdalsnes Exp $
+/* $Id: kthread.c,v 1.45 2003/12/30 18:52:04 fireball Exp $
  *
  * FILE:            ntoskrnl/ke/kthread.c
  * PURPOSE:         Microkernel thread support
@@ -124,15 +124,15 @@ KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First)
              KEBUGCHECK(0);
            }
          Status = MmCreateVirtualMapping(NULL,
-                                         KernelStack + (i * PAGE_SIZE),
+                                         (char*)KernelStack + (i * PAGE_SIZE),
                                          PAGE_EXECUTE_READWRITE,
                                          Page,
                                          TRUE);
        }
-      Thread->InitialStack = KernelStack + MM_STACK_SIZE;
-      Thread->StackBase KernelStack + MM_STACK_SIZE;
-      Thread->StackLimit = (ULONG)KernelStack;
-      Thread->KernelStack KernelStack + MM_STACK_SIZE;
+      Thread->InitialStack = (char*)KernelStack + MM_STACK_SIZE;
+      Thread->StackBase    = (char*)KernelStack + MM_STACK_SIZE;
+      Thread->StackLimit   = (ULONG)KernelStack;
+      Thread->KernelStack  = (char*)KernelStack + MM_STACK_SIZE;
     }
   else
     {
@@ -208,6 +208,7 @@ crashes. I'm disabling it again, until we fix the APC implementation...
   Thread->Queue = NULL;
   KeInitializeSpinLock(&Thread->ApcQueueLock);
   memset(&Thread->Timer, 0, sizeof(KTIMER));
+  KeInitializeTimer(&Thread->Timer);
   Thread->QueueListEntry.Flink = NULL;
   Thread->QueueListEntry.Blink = NULL;
   Thread->Affinity = Process->Affinity;
index 466415b..df5d166 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.179 2003/12/14 18:16:18 hbirr Exp $
+/* $Id: main.c,v 1.180 2003/12/30 18:52:04 fireball Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ke/main.c
 #ifdef HALDBG
 #include <internal/ntosdbg.h>
 #else
+#if defined(_MSC_VER) && (_MSC_VER <= 1200)
+#define ps
+#else
 #define ps(args...)
+#endif /* HALDBG */
+
 #endif
 
 #define NDEBUG
 
 /* GLOBALS *******************************************************************/
 
+#ifdef  __GNUC__
 ULONG EXPORTED NtBuildNumber = KERNEL_VERSION_BUILD;
 ULONG EXPORTED NtGlobalFlag = 0;
 CHAR  EXPORTED KeNumberProcessors;
 LOADER_PARAMETER_BLOCK EXPORTED KeLoaderBlock;
 ULONG EXPORTED KeDcacheFlushCount = 0;
 ULONG EXPORTED KeIcacheFlushCount = 0;
+#else
+/* Microsoft-style declarations */
+EXPORTED ULONG NtBuildNumber = KERNEL_VERSION_BUILD;
+EXPORTED ULONG NtGlobalFlag = 0;
+EXPORTED CHAR  KeNumberProcessors;
+EXPORTED LOADER_PARAMETER_BLOCK KeLoaderBlock;
+EXPORTED ULONG KeDcacheFlushCount = 0;
+EXPORTED ULONG KeIcacheFlushCount = 0;
+#endif /* __GNUC__ */
+
 static LOADER_MODULE KeLoaderModules[64];
 static UCHAR KeLoaderModuleStrings[64][256];
 static UCHAR KeLoaderCommandLine[256];
@@ -481,9 +497,9 @@ ExpInitializeExecutive(VOID)
       /* Allocate a stack for use when booting the processor */
       /* FIXME: The nonpaged memory for the stack is not released after use */
       ProcessorStack = 
-       ExAllocatePool(NonPagedPool, MM_STACK_SIZE) + MM_STACK_SIZE;
+       (char*)ExAllocatePool(NonPagedPool, MM_STACK_SIZE) + MM_STACK_SIZE;
       Ki386InitialStackArray[((int)KeNumberProcessors)] = 
-       (PVOID)(ProcessorStack - MM_STACK_SIZE);
+       (PVOID)((char*)ProcessorStack - MM_STACK_SIZE);
       HalInitializeProcessor(KeNumberProcessors, ProcessorStack);
       KeNumberProcessors++;
     }
@@ -714,7 +730,11 @@ ExpInitializeExecutive(VOID)
       Handles[1] = ProcessHandle;
 
       /* Wait for the system to be initialized */
+#ifdef __GNUC__
       Timeout.QuadPart = -1200000000LL;  /* 120 second timeout */
+#else
+      Timeout.QuadPart = -1200000000;  /* 120 second timeout */
+#endif
       Status = NtWaitForMultipleObjects(((LONG) sizeof(Handles) / sizeof(HANDLE)),
         Handles,
         WaitAny,
@@ -756,7 +776,11 @@ ExpInitializeExecutive(VOID)
       /*
        * Crash the system if the initial process terminates within 5 seconds.
        */
+#ifdef __GNUC__
       Timeout.QuadPart = -50000000LL;
+#else
+      Timeout.QuadPart = -50000000;
+#endif
       Status = NtWaitForSingleObject(ProcessHandle,
                                 FALSE,
                                 &Timeout);
index 5f3bb42..3094e07 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: process.c,v 1.17 2003/11/27 01:09:10 gdalsnes Exp $
+/* $Id: process.c,v 1.18 2003/12/30 18:52:04 fireball Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ke/process.c
@@ -80,11 +80,17 @@ KeAttachProcess (PEPROCESS Process)
    CurrentThread->OldProcess = PsGetCurrentProcess();
    CurrentThread->ThreadsProcess = Process;
    PageDir = Process->Pcb.DirectoryTableBase.u.LowPart;
-   DPRINT("Switching process context to %x\n",PageDir)
+   DPRINT("Switching process context to %x\n",PageDir);
+#if defined(__GNUC__)
    __asm__("movl %0,%%cr3\n\t"
           : /* no outputs */
           : "r" (PageDir));
-   
+#elif defined(_MSC_VER)
+         __asm mov eax, PageDir;
+         __asm mov cr3, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
    KeLowerIrql(oldlvl);
 }
 
@@ -115,10 +121,17 @@ KeDetachProcess (VOID)
    CurrentThread->ThreadsProcess = CurrentThread->OldProcess;
    CurrentThread->OldProcess = NULL;
    PageDir = CurrentThread->ThreadsProcess->Pcb.DirectoryTableBase.u.LowPart;
+#if defined(__GNUC__)
    __asm__("movl %0,%%cr3\n\t"
           : /* no inputs */
           : "r" (PageDir));
-   
+#elif defined(_MSC_VER)
+         __asm mov eax, PageDir;
+         __asm mov cr3, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
+
    KeLowerIrql(oldlvl);
 }
 
index d14cf07..29f6aba 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: timer.c,v 1.63 2003/11/02 01:15:15 ekohl Exp $
+/* $Id: timer.c,v 1.64 2003/12/30 18:52:04 fireball Exp $
  *
  * COPYRIGHT:      See COPYING in the top level directory
  * PROJECT:        ReactOS kernel
@@ -22,6 +22,7 @@
 #include <internal/ke.h>
 #include <internal/id.h>
 #include <internal/ps.h>
+#include <internal/safe.h>
 
 #define NDEBUG
 #include <internal/debug.h>
@@ -35,8 +36,8 @@
 /*
  * Current time
  */
-static LARGE_INTEGER boot_time = (LARGE_INTEGER)0LL;
-static LARGE_INTEGER system_time = (LARGE_INTEGER)0LL;
+static LONGLONG boot_time   = 0;
+static LONGLONG system_time = 0;
 
 /*
  * Number of timer interrupts since initialisation
@@ -99,14 +100,27 @@ NtQueryPerformanceCounter(IN PLARGE_INTEGER Counter,
 {
   LARGE_INTEGER PerfCounter;
   LARGE_INTEGER PerfFrequency;
+  NTSTATUS      Status;
 
   PerfCounter = KeQueryPerformanceCounter(&PerfFrequency);
 
   if (Counter != NULL)
-    Counter->QuadPart = PerfCounter.QuadPart;
+    {
+      Status = MmCopyToCaller(&Counter->QuadPart, &PerfCounter.QuadPart, sizeof(PerfCounter.QuadPart));
+      if (!NT_SUCCESS(Status))
+        {
+         return(Status);
+        }
+    }
 
   if (Frequency != NULL)
-    Frequency->QuadPart = PerfFrequency.QuadPart;
+  {
+      Status = MmCopyToCaller(&Frequency->QuadPart, &PerfFrequency.QuadPart, sizeof(PerfFrequency.QuadPart));
+      if (!NT_SUCCESS(Status))
+        {
+         return(Status);
+        }
+  }
 
   return(STATUS_SUCCESS);
 }
@@ -118,14 +132,20 @@ NtDelayExecution(IN ULONG Alertable,
 {
    NTSTATUS Status;
    LARGE_INTEGER Timeout;
-   
+
+   Status = MmCopyFromCaller(&Timeout, Interval, sizeof(Timeout));
+   if (!NT_SUCCESS(Status))
+     {
+       return(Status);
+     }
+
    Timeout = *((PLARGE_INTEGER)Interval);
    DPRINT("NtDelayExecution(Alertable %d, Internal %x) IntervalP %x\n",
          Alertable, Internal, Timeout);
    
    DPRINT("Execution delay is %d/%d\n", 
          Timeout.u.HighPart, Timeout.u.LowPart);
-   Status = KeDelayExecutionThread(UserMode, Alertable, &Timeout);
+   Status = KeDelayExecutionThread(UserMode, (BOOLEAN)Alertable, &Timeout);
    return(Status);
 }
 
@@ -149,11 +169,10 @@ KeDelayExecutionThread (KPROCESSOR_MODE   WaitMode,
 {
    PKTHREAD Thread = KeGetCurrentThread();
 
-   KeInitializeTimer(&Thread->Timer);
    KeSetTimer(&Thread->Timer, *Interval, NULL);
    return (KeWaitForSingleObject(&Thread->Timer,
-                                Executive,
-                                UserMode,
+                                (WaitMode == KernelMode) ? Executive : UserRequest, /* TMN: Was unconditionally Executive */
+                                WaitMode, /* TMN: Was UserMode */
                                 Alertable,
                                 NULL));
 }
@@ -191,8 +210,9 @@ KeQuerySystemTime(PLARGE_INTEGER CurrentTime)
 
   KeRaiseIrql(PROFILE_LEVEL, &oldIrql);
   KeAcquireSpinLockAtDpcLevel(&TimerValueLock);
-  *CurrentTime = system_time;
-  KeReleaseSpinLock(&TimerValueLock, oldIrql);
+  CurrentTime->QuadPart = system_time;
+  KeReleaseSpinLockFromDpcLevel(&TimerValueLock);
+  KeLowerIrql(oldIrql);
 }
 
 
@@ -201,10 +221,12 @@ NtGetTickCount (PULONG    UpTime)
 {
   LARGE_INTEGER TickCount;
   if (UpTime == NULL)
+  {
     return(STATUS_INVALID_PARAMETER);
+  }
+
   KeQueryTickCount(&TickCount);
-  *UpTime = TickCount.u.LowPart;
-  return (STATUS_SUCCESS);
+  return(MmCopyToCaller(UpTime, &TickCount.u.LowPart, sizeof(*UpTime)));
 }
 
 
@@ -254,21 +276,19 @@ KeSetTimerEx (PKTIMER             Timer,
 {
    KIRQL oldlvl;
    LARGE_INTEGER SystemTime;
-   
-   DPRINT("KeSetTimerEx(Timer %x), DueTime: \n",Timer);
+   BOOLEAN AlreadyInList;
 
-   KeRaiseIrql(PROFILE_LEVEL, &oldlvl);
-   KeAcquireSpinLockAtDpcLevel(&TimerValueLock);
+   DPRINT("KeSetTimerEx(Timer %x), DueTime: \n",Timer);
 
-   SystemTime = system_time;
+   assert(KeGetCurrentIrql() <= DISPATCH_LEVEL);
 
-   KeReleaseSpinLock(&TimerValueLock, DISPATCH_LEVEL);
+   KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
+   KeQuerySystemTime(&SystemTime);
    KeAcquireSpinLockAtDpcLevel(&TimerListLock);
 
    Timer->Dpc = Dpc;
    if (DueTime.QuadPart < 0)
      {
-        
        Timer->DueTime.QuadPart = SystemTime.QuadPart - DueTime.QuadPart;
      }
    else
@@ -277,15 +297,24 @@ KeSetTimerEx (PKTIMER             Timer,
      }
    Timer->Period = Period;
    Timer->Header.SignalState = FALSE;
-   if (Timer->TimerListEntry.Flink != NULL)
+   AlreadyInList = (Timer->TimerListEntry.Flink == NULL) ? FALSE : TRUE;
+   assert((Timer->TimerListEntry.Flink == NULL && Timer->TimerListEntry.Blink == NULL) ||
+          (Timer->TimerListEntry.Flink != NULL && Timer->TimerListEntry.Blink != NULL));
+   if (!AlreadyInList)
      {
-       KeReleaseSpinLock(&TimerListLock, oldlvl);
-       return(TRUE);
+       assert(&TimerListHead != &Timer->TimerListEntry);
+       InsertTailList(&TimerListHead, &Timer->TimerListEntry);
+       assert(TimerListHead.Flink != &TimerListHead);
+       assert(Timer->TimerListEntry.Flink != &Timer->TimerListEntry);
      }
-   InsertTailList(&TimerListHead,&Timer->TimerListEntry);
-   KeReleaseSpinLock(&TimerListLock, oldlvl);
-   
-   return(FALSE);
+   /*
+    * TODO: Perhaps verify that the timer really is in
+    * the TimerListHead list if AlreadyInList is TRUE?
+    */
+   KeReleaseSpinLockFromDpcLevel(&TimerListLock);
+   KeLowerIrql(oldlvl);
+
+   return AlreadyInList;
 }
 
 /*
@@ -304,14 +333,16 @@ KeCancelTimer (PKTIMER    Timer)
    KIRQL oldlvl;
    
    DPRINT("KeCancelTimer(Timer %x)\n",Timer);
-   
+
    KeAcquireSpinLock(&TimerListLock, &oldlvl);
-                    
+
    if (Timer->TimerListEntry.Flink == NULL)
      {
        KeReleaseSpinLock(&TimerListLock, oldlvl);
        return(FALSE);
      }
+   assert(&Timer->TimerListEntry != &TimerListHead);
+   assert(Timer->TimerListEntry.Flink != &Timer->TimerListEntry);
    RemoveEntryList(&Timer->TimerListEntry);
    Timer->TimerListEntry.Flink = Timer->TimerListEntry.Blink = NULL;
    KeReleaseSpinLock(&TimerListLock, oldlvl);
@@ -325,7 +356,7 @@ KeCancelTimer (PKTIMER      Timer)
 BOOLEAN STDCALL
 KeReadStateTimer (PKTIMER      Timer)
 {
-   return(Timer->Header.SignalState);
+   return (BOOLEAN)(Timer->Header.SignalState);
 }
 
 /*
@@ -361,7 +392,7 @@ KeInitializeTimerEx (PKTIMER                Timer,
  */
 {
    ULONG IType;
-   
+
    if (Type == NotificationTimer)
      {
        IType = InternalNotificationTimer;
@@ -375,7 +406,7 @@ KeInitializeTimerEx (PKTIMER                Timer,
        assert(FALSE);
        return;
      }
-   
+
    KeInitializeDispatcherHeader(&Timer->Header,
                                IType,
                                sizeof(KTIMER) / sizeof(ULONG),
@@ -397,34 +428,40 @@ KeQueryTickCount(PLARGE_INTEGER TickCount)
   TickCount->QuadPart = KeTickCount;
 }
 
+/*
+ * We enter this function at IRQL DISPATCH_LEVEL, and with the
+ * TimerListLock held.
+ */
 STATIC VOID 
-HandleExpiredTimer(PKTIMER current)
+HandleExpiredTimer(PKTIMER Timer)
 {
-  KIRQL OldIrql;
-
-   DPRINT("HandleExpiredTime(current %x)\n",current);
-   if (current->Dpc != NULL)
+   DPRINT("HandleExpiredTime(Timer %x) at IRQL: %d\n", Timer, KeGetCurrentIrql());
+   if (Timer->Dpc != NULL)
      {
-       DPRINT("current->Dpc %x current->Dpc->DeferredRoutine %x\n",
-              current->Dpc, current->Dpc->DeferredRoutine);
-       KeInsertQueueDpc(current->Dpc,
+       DPRINT("Timer->Dpc %x Timer->Dpc->DeferredRoutine %x\n",
+              Timer->Dpc, Timer->Dpc->DeferredRoutine);
+       KeInsertQueueDpc(Timer->Dpc,
                         NULL,
                         NULL);
        DPRINT("Finished dpc routine\n");
      }
-   OldIrql = KeAcquireDispatcherDatabaseLock ();
-   current->Header.SignalState = TRUE;
-   KeDispatcherObjectWake(&current->Header);
-   KeReleaseDispatcherDatabaseLock (OldIrql);
-   if (current->Period != 0)
+
+   assert(KeGetCurrentIrql() == DISPATCH_LEVEL);
+
+   KeAcquireDispatcherDatabaseLockAtDpcLevel();
+   Timer->Header.SignalState = TRUE;
+   KeDispatcherObjectWake(&Timer->Header);
+   KeReleaseDispatcherDatabaseLockFromDpcLevel();
+   if (Timer->Period != 0)
      {
-       current->DueTime.QuadPart += 
-         current->Period * SYSTEM_TIME_UNITS_PER_MSEC;
+       Timer->DueTime.QuadPart += 
+         Timer->Period * SYSTEM_TIME_UNITS_PER_MSEC;
      }
    else
      {
-       RemoveEntryList(&current->TimerListEntry);
-       current->TimerListEntry.Flink = current->TimerListEntry.Blink = NULL;
+       assert(&Timer->TimerListEntry != &TimerListHead);
+       RemoveEntryList(&Timer->TimerListEntry);
+       Timer->TimerListEntry.Flink = Timer->TimerListEntry.Blink = NULL;
      }
 }
 
@@ -437,18 +474,13 @@ KeExpireTimers(PKDPC Dpc,
    PLIST_ENTRY current_entry = NULL;
    PKTIMER current = NULL;
    ULONG Eip = (ULONG)Arg1;
-   KIRQL oldIrql;
    LARGE_INTEGER SystemTime;
 
    DPRINT("KeExpireTimers()\n");
 
-   KeRaiseIrql(PROFILE_LEVEL, &oldIrql);
-   KeAcquireSpinLockAtDpcLevel(&TimerValueLock);
+   assert(KeGetCurrentIrql() == DISPATCH_LEVEL);
 
-   SystemTime = system_time;
-
-   KeReleaseSpinLock(&TimerValueLock, oldIrql);
-   KeAcquireSpinLockAtDpcLevel(&TimerListLock);
+   KeQuerySystemTime(&SystemTime);
 
    if (KeGetCurrentIrql() > DISPATCH_LEVEL)
    {
@@ -456,13 +488,19 @@ KeExpireTimers(PKDPC Dpc,
        KEBUGCHECK(0);
    }
 
+   KeAcquireSpinLockAtDpcLevel(&TimerListLock);
 
    current_entry = TimerListHead.Flink;
 
+   assert(current_entry);
+
    while (current_entry != &TimerListHead)
      {
        current = CONTAINING_RECORD(current_entry, KTIMER, TimerListEntry);
-       
+       assert(current);
+       assert(current_entry != &TimerListHead);
+       assert(current_entry->Flink != current_entry);
+
        current_entry = current_entry->Flink;
        if ((ULONGLONG) SystemTime.QuadPart >= current->DueTime.QuadPart)
         {
@@ -471,7 +509,7 @@ KeExpireTimers(PKDPC Dpc,
      }
 
    KiAddProfileEvent(ProfileTime, Eip);
-   
+
    KeReleaseSpinLockFromDpcLevel(&TimerListLock);
 }
 
@@ -499,9 +537,9 @@ KiUpdateSystemTime(KIRQL oldIrql,
    SharedUserData->TickCountLow++;
 
    KeAcquireSpinLockAtDpcLevel(&TimerValueLock);
-   system_time.QuadPart += CLOCK_INCREMENT;
+   system_time += CLOCK_INCREMENT;
    KeReleaseSpinLockFromDpcLevel(&TimerValueLock);
-   
+
    /*
     * Queue a DPC that will expire timers
     */
@@ -530,7 +568,7 @@ KeInitializeTimerImpl(VOID)
     */
    HalQueryRealTimeClock(&TimeFields);
    RtlTimeFieldsToTime(&TimeFields, &SystemBootTime);
-   boot_time=SystemBootTime;
+   boot_time=SystemBootTime.QuadPart;
    system_time=boot_time;
 
    SharedUserData->TickCountLow = 0;
index a6fa042..df95ff2 100644 (file)
@@ -40,10 +40,10 @@ VOID KeInitializeDispatcherHeader(DISPATCHER_HEADER* Header,
                                  ULONG Size,
                                  ULONG SignalState)
 {
-   Header->Type = Type;
+   Header->Type = (UCHAR)Type;
    Header->Absolute = 0;
    Header->Inserted = 0;
-   Header->Size = Size;
+   Header->Size = (UCHAR)Size;
    Header->SignalState = SignalState;
    InitializeListHead(&(Header->WaitListHead));
 }
@@ -503,7 +503,6 @@ KeWaitForMultipleObjects(ULONG Count,
     */
    if (Timeout != NULL && Timeout->QuadPart != 0)
    {
-      KeInitializeTimer(&CurrentThread->Timer);
       KeSetTimer(&CurrentThread->Timer, *Timeout, NULL);
    }
 
@@ -622,8 +621,8 @@ KeWaitForMultipleObjects(ULONG Count,
 
          blk->Object = KiGetWaitableObjectFromObject(Object[i]);
          blk->Thread = CurrentThread;
-         blk->WaitKey = STATUS_WAIT_0 + i;
-         blk->WaitType = WaitType;
+         blk->WaitKey = (USHORT)(STATUS_WAIT_0 + i);
+         blk->WaitType = (USHORT)WaitType;
 
          if (i == (Count - 1))
          {
@@ -680,7 +679,7 @@ KeWaitForMultipleObjects(ULONG Count,
          }
       }
 
-      PsBlockThread(&Status, Alertable, WaitMode, TRUE, WaitIrql, WaitReason);
+      PsBlockThread(&Status, Alertable, WaitMode, TRUE, WaitIrql, (UCHAR)WaitReason);
 
       //io completion
       if (CurrentThread->Queue)
index 2366071..acdb339 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: init.c,v 1.44 2003/11/17 02:12:51 hyperion Exp $
+/* $Id: init.c,v 1.45 2003/12/30 18:52:05 fireball Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ldr/init.c
@@ -513,7 +513,7 @@ LdrLoadInitialProcess(PHANDLE ProcessHandle,
   Context.FloatSave.StatusWord = 0xffff0000;
   Context.FloatSave.TagWord = 0xffffffff;
   Context.FloatSave.DataSelector = 0xffff0000;
-  Context.Eip = (ULONG_PTR)(ImageBaseAddress + (ULONG_PTR)Sii.EntryPoint);
+  Context.Eip = (ULONG_PTR)((char*)ImageBaseAddress + (ULONG_PTR)Sii.EntryPoint);
   Context.SegCs = USER_CS;
   Context.SegDs = USER_DS;
   Context.SegEs = USER_DS;
index d3331d3..f3405d1 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: loader.c,v 1.137 2003/10/15 17:04:39 navaraf Exp $
+/* $Id: loader.c,v 1.138 2003/12/30 18:52:05 fireball Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
 #ifdef HALDBG
 #include <internal/ntosdbg.h>
 #else
+#ifdef __GNUC__
 #define ps(args...)
+#else
+#define ps
+#endif /* __GNUC__ */
 #endif
 
 #define NDEBUG
@@ -638,7 +642,7 @@ LdrpQueryModuleInformation(PVOID Buffer,
       Smi->Module[ModuleCount].Base = current->Base;
       Smi->Module[ModuleCount].Size = current->Length;
       Smi->Module[ModuleCount].Flags = 0;              /* Flags ??? (GN) */
-      Smi->Module[ModuleCount].Index = ModuleCount;
+      Smi->Module[ModuleCount].Index = (USHORT)ModuleCount;
       Smi->Module[ModuleCount].NameLength = 0;
       Smi->Module[ModuleCount].LoadCount = 0; /* FIXME */
 
@@ -842,8 +846,8 @@ PageNeedsWriteAccess(PVOID PageStart,
          Length = 
              max(PESectionHeaders[Idx].Misc.VirtualSize,
                  PESectionHeaders[Idx].SizeOfRawData);
-         BaseAddress = PESectionHeaders[Idx].VirtualAddress + DriverBase;
-         NeedsWriteAccess = BaseAddress < PageStart + PAGE_SIZE &&
+         BaseAddress = PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase;
+         NeedsWriteAccess = (char*)BaseAddress < (char*)PageStart + PAGE_SIZE &&
                             PageStart < (PVOID)((PCHAR) BaseAddress + Length);
        }
     }
@@ -958,17 +962,17 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
           (IMAGE_SECTION_CHAR_CODE | IMAGE_SECTION_CHAR_DATA))
         {
           DPRINT("PESectionHeaders[Idx].VirtualAddress + DriverBase %x\n",
-                 PESectionHeaders[Idx].VirtualAddress + DriverBase);
-           memcpy(PESectionHeaders[Idx].VirtualAddress + DriverBase,
-                  (PVOID)(ModuleLoadBase + PESectionHeaders[Idx].PointerToRawData),
+                 PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase);
+           memcpy(PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase,
+                  (PVOID)((char*)ModuleLoadBase + PESectionHeaders[Idx].PointerToRawData),
                   PESectionHeaders[Idx].Misc.VirtualSize > PESectionHeaders[Idx].SizeOfRawData
                   ? PESectionHeaders[Idx].SizeOfRawData : PESectionHeaders[Idx].Misc.VirtualSize );
         }
       else
         {
           DPRINT("PESectionHeaders[Idx].VirtualAddress + DriverBase %x\n",
-                 PESectionHeaders[Idx].VirtualAddress + DriverBase);
-          memset(PESectionHeaders[Idx].VirtualAddress + DriverBase, 
+                 PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase);
+          memset(PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase, 
                  '\0', PESectionHeaders[Idx].Misc.VirtualSize);
 
         }
@@ -998,8 +1002,8 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
            DPRINT("Name %.8s PESectionHeader[Idx].PointerToRawData %x\n",
                   PESectionHeaders[Idx].Name,
                   PESectionHeaders[Idx].PointerToRawData);
-           RelocDir = PESectionHeaders[Idx].PointerToRawData +
-             ModuleLoadBase;
+           RelocDir = (PRELOCATION_DIRECTORY)(PESectionHeaders[Idx].PointerToRawData +
+             (char*)ModuleLoadBase);
             CurrentSize = PESectionHeaders[Idx].Misc.VirtualSize;
            break;
         }
@@ -1029,7 +1033,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
           
           Offset = RelocEntry[Idx].TypeOffset & 0xfff;
           Type = (RelocEntry[Idx].TypeOffset >> 12) & 0xf;
-          RelocItem = (PDWORD)(DriverBase + RelocDir->VirtualAddress + 
+          RelocItem = (PDWORD)((char*)DriverBase + RelocDir->VirtualAddress + 
                                Offset);
 /*        DPRINT("  reloc at %08lx %x %s old:%08lx new:%08lx\n", 
                  RelocItem,
@@ -1119,7 +1123,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
                   pName = NULL;
 
 
-                  Hint = (*FunctionNameList) & 0xffff;
+                  Hint = (WORD)((*FunctionNameList) & 0xffff);
                 }
               else // hint-name
                 {
@@ -1166,7 +1170,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
          Length = 
              max(PESectionHeaders[Idx].Misc.VirtualSize,
                  PESectionHeaders[Idx].SizeOfRawData);
-         BaseAddress = PESectionHeaders[Idx].VirtualAddress + DriverBase;
+         BaseAddress = PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase;
          PageAddress = (PVOID)PAGE_ROUND_DOWN(BaseAddress);
          if (! PageNeedsWriteAccess(PageAddress, DriverBase, PEFileHeader, PESectionHeaders))
            {
@@ -1349,16 +1353,16 @@ LdrSafePEProcessModule(PVOID ModuleLoadBase,
        {
          //ps("PESectionHeaders[Idx].VirtualAddress (%X) + DriverBase %x\n",
          //PESectionHeaders[Idx].VirtualAddress, PESectionHeaders[Idx].VirtualAddress + DriverBase);
-         memcpy(PESectionHeaders[Idx].VirtualAddress + DriverBase,
-                (PVOID)(ModuleLoadBase + PESectionHeaders[Idx].PointerToRawData),
+         memcpy(PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase,
+                (PVOID)((char*)ModuleLoadBase + PESectionHeaders[Idx].PointerToRawData),
                 PESectionHeaders[Idx].Misc.VirtualSize > PESectionHeaders[Idx].SizeOfRawData ?
                   PESectionHeaders[Idx].SizeOfRawData : PESectionHeaders[Idx].Misc.VirtualSize );
        }
       else
        {
          ps("PESectionHeaders[Idx].VirtualAddress (%X) + DriverBase %x\n",
-            PESectionHeaders[Idx].VirtualAddress, PESectionHeaders[Idx].VirtualAddress + DriverBase);
-         memset(PESectionHeaders[Idx].VirtualAddress + DriverBase, 
+            PESectionHeaders[Idx].VirtualAddress, PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase);
+         memset(PESectionHeaders[Idx].VirtualAddress + (char*)DriverBase, 
                 '\0',
                 PESectionHeaders[Idx].Misc.VirtualSize);
        }
@@ -1383,7 +1387,7 @@ LdrSafePEProcessModule(PVOID ModuleLoadBase,
          DPRINT("Name %.8s PESectionHeader[Idx].PointerToRawData %x\n",
                 PESectionHeaders[Idx].Name,
                 PESectionHeaders[Idx].PointerToRawData);
-         RelocDir = PESectionHeaders[Idx].PointerToRawData + ModuleLoadBase;
+         RelocDir = (PRELOCATION_DIRECTORY)(PESectionHeaders[Idx].PointerToRawData + (char*)ModuleLoadBase);
          CurrentSize = PESectionHeaders[Idx].Misc.VirtualSize;
          break;
        }
@@ -1406,7 +1410,7 @@ LdrSafePEProcessModule(PVOID ModuleLoadBase,
 
          Offset = RelocEntry[Idx].TypeOffset & 0xfff;
          Type = (RelocEntry[Idx].TypeOffset >> 12) & 0xf;
-         RelocItem = (PULONG)(DriverBase + RelocDir->VirtualAddress + Offset);
+         RelocItem = (PULONG)((char*)DriverBase + RelocDir->VirtualAddress + Offset);
          if (Type == 3)
            {
              (*RelocItem) += RelocDelta;
@@ -1475,7 +1479,7 @@ LdrSafePEProcessModule(PVOID ModuleLoadBase,
            {
               /* Hint */
              pName = NULL;
-             Hint = (*FunctionNameList) & 0xffff;
+             Hint = (USHORT)((*FunctionNameList) & 0xffff);
            }
          else
            {
@@ -1523,9 +1527,9 @@ LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject,
        return NULL;
      }
 
-   FunctionList = (PDWORD)((DWORD)ExportDir->AddressOfFunctions + ModuleObject->Base);
-   NameList = (PDWORD)((DWORD)ExportDir->AddressOfNames + ModuleObject->Base);
-   OrdinalList = (PWORD)((DWORD)ExportDir->AddressOfNameOrdinals + ModuleObject->Base);
+   FunctionList = (PDWORD)((DWORD)ExportDir->AddressOfFunctions + (char*)ModuleObject->Base);
+   NameList = (PDWORD)((DWORD)ExportDir->AddressOfNames + (char*)ModuleObject->Base);
+   OrdinalList = (PWORD)((DWORD)ExportDir->AddressOfNameOrdinals + (char*)ModuleObject->Base);
 
   ExportAddress = 0;
 
@@ -1599,9 +1603,9 @@ LdrSafePEGetExportAddress(PVOID ImportModuleBase,
     ps("ExportDir %x\n", ExportDir);
   }
 
-  FunctionList = (PDWORD)((DWORD)ExportDir->AddressOfFunctions + ImportModuleBase);
-  NameList = (PDWORD)((DWORD)ExportDir->AddressOfNames + ImportModuleBase);
-  OrdinalList = (PWORD)((DWORD)ExportDir->AddressOfNameOrdinals + ImportModuleBase);
+  FunctionList = (PDWORD)((DWORD)ExportDir->AddressOfFunctions + (char*)ImportModuleBase);
+  NameList = (PDWORD)((DWORD)ExportDir->AddressOfNames + (char*)ImportModuleBase);
+  OrdinalList = (PWORD)((DWORD)ExportDir->AddressOfNameOrdinals + (char*)ImportModuleBase);
 
   ExportAddress = 0;
 
index c1c33af..0a165ea 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rtl.c,v 1.17 2003/07/11 01:23:15 royce Exp $
+/* $Id: rtl.c,v 1.18 2003/12/30 18:52:05 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -33,7 +33,7 @@ RtlImageNtHeader (IN PVOID BaseAddress)
    PIMAGE_NT_HEADERS NTHeaders;
    
    DosHeader = (PIMAGE_DOS_HEADER)BaseAddress;
-   NTHeaders = (PIMAGE_NT_HEADERS)(BaseAddress + DosHeader->e_lfanew);
+   NTHeaders = (PIMAGE_NT_HEADERS)((char*)BaseAddress + DosHeader->e_lfanew);
    if ((DosHeader->e_magic != IMAGE_DOS_MAGIC)
        || (DosHeader->e_lfanew == 0L)
        || (*(PULONG) NTHeaders != IMAGE_PE_MAGIC))
@@ -73,7 +73,7 @@ RtlImageDirectoryEntryToData (IN PVOID        BaseAddress,
                *Size = NtHeader->OptionalHeader.DataDirectory[Directory].Size;
 
        if (ImageLoaded)
-               return (PVOID)(BaseAddress + Va);
+               return (PVOID)((char*)BaseAddress + Va);
 
        /* image mapped as ordinary file, we must find raw pointer */
        SectionHeader = (PIMAGE_SECTION_HEADER)(NtHeader + 1);
@@ -81,7 +81,7 @@ RtlImageDirectoryEntryToData (IN PVOID        BaseAddress,
        while (Count--)
        {
                if (SectionHeader->VirtualAddress == Va)
-                       return (PVOID)(BaseAddress + SectionHeader->PointerToRawData);
+                       return (PVOID)((char*)BaseAddress + SectionHeader->PointerToRawData);
                SectionHeader++;
        }
 
@@ -142,7 +142,7 @@ RtlImageRvaToVa (
                        *SectionHeader = Section;
        }
 
-       return (ULONG)(BaseAddress +
+       return (ULONG)((char*)BaseAddress +
                       Rva +
                       Section->PointerToRawData -
                       Section->VirtualAddress);
@@ -172,15 +172,15 @@ LdrGetProcedureAddress (IN PVOID BaseAddress,
        return(STATUS_INVALID_PARAMETER);
      }
    
-   AddressPtr = (PULONG)RVA(BaseAddress, ExportDir->AddressOfFunctions);
+   AddressPtr = (PULONG)RVA((char*)BaseAddress, ExportDir->AddressOfFunctions);
    if (Name && Name->Length)
      {
        ULONG minn, maxn;
 
        /* by name */
        OrdinalPtr = 
-        (PUSHORT)RVA(BaseAddress, ExportDir->AddressOfNameOrdinals);
-       NamePtr = (PULONG)RVA(BaseAddress, ExportDir->AddressOfNames);
+        (PUSHORT)RVA((char*)BaseAddress, ExportDir->AddressOfNameOrdinals);
+       NamePtr = (PULONG)RVA((char*)BaseAddress, ExportDir->AddressOfNames);
 
        minn = 0; maxn = ExportDir->NumberOfNames;
        while (minn <= maxn)
@@ -189,12 +189,12 @@ LdrGetProcedureAddress (IN PVOID BaseAddress,
            LONG res;
 
            mid = (minn + maxn) / 2;
-           res = _strnicmp(Name->Buffer, (PCH)RVA(BaseAddress, NamePtr[mid]),
+           res = _strnicmp(Name->Buffer, (PCH)RVA((char*)BaseAddress, NamePtr[mid]),
                            Name->Length);
            if (res == 0)
              {
                *ProcedureAddress = 
-                 (PVOID)RVA(BaseAddress, AddressPtr[OrdinalPtr[mid]]);
+                 (PVOID)RVA((char*)BaseAddress, AddressPtr[OrdinalPtr[mid]]);
                return(STATUS_SUCCESS);
              }
            else if (res > 0)
@@ -210,7 +210,7 @@ LdrGetProcedureAddress (IN PVOID BaseAddress,
        for (i = 0; i < ExportDir->NumberOfNames; i++, NamePtr++, OrdinalPtr++)
          {
             if (!_strnicmp(Name->Buffer, 
-                           (char*)(BaseAddress + *NamePtr), Name->Length))
+                           (char*)((char*)BaseAddress + *NamePtr), Name->Length))
               {
                  *ProcedureAddress = 
                    (PVOID)((ULONG)BaseAddress + 
index 97c2d82..f1427ca 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: complete.c,v 1.9 2003/07/11 01:23:15 royce Exp $
+/* $Id: complete.c,v 1.10 2003/12/30 18:52:05 fireball Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -26,7 +26,7 @@
  *     NtCompleteConnectPort@4
  *
  */
-EXPORTED NTSTATUS STDCALL
+/*EXPORTED*/ NTSTATUS STDCALL
 NtCompleteConnectPort (HANDLE PortHandle)
 {
   NTSTATUS     Status;
index d8b99a9..a82e9c5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: connect.c,v 1.21 2003/11/20 11:06:35 ekohl Exp $
+/* $Id: connect.c,v 1.22 2003/12/30 18:52:05 fireball Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -514,7 +514,7 @@ NtConnectPort (PHANDLE                              UnsafeConnectedPortHandle,
  *
  * RETURN VALUE
  */
-EXPORTED NTSTATUS STDCALL
+/*EXPORTED*/ NTSTATUS STDCALL
 NtAcceptConnectPort (PHANDLE                   ServerPortHandle,
                     HANDLE                     NamedPortHandle,
                     PLPC_MESSAGE               LpcMessage,
index 727455b..040716a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: create.c,v 1.13 2003/09/25 20:04:59 ekohl Exp $
+/* $Id: create.c,v 1.14 2003/12/30 18:52:05 fireball Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -90,7 +90,7 @@ NiCreatePort (PVOID                   ObjectBody,
  * 
  * RETURN VALUE
  */
-EXPORTED NTSTATUS STDCALL 
+/*EXPORTED*/ NTSTATUS STDCALL 
 NtCreatePort (PHANDLE                PortHandle,
              POBJECT_ATTRIBUTES    ObjectAttributes,
              ULONG            MaxConnectInfoLength,
@@ -168,7 +168,7 @@ NtCreatePort (PHANDLE                     PortHandle,
  * 
  * RETURN VALUE
  */
-EXPORTED NTSTATUS STDCALL
+/*EXPORTED*/ NTSTATUS STDCALL
 NtCreateWaitablePort (OUT      PHANDLE                 PortHandle,
                      IN        POBJECT_ATTRIBUTES      ObjectAttributes,
                      IN        ULONG                   MaxConnectInfoLength,
index 4010837..374b8e6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: listen.c,v 1.7 2003/07/11 01:23:15 royce Exp $
+/* $Id: listen.c,v 1.8 2003/12/30 18:52:05 fireball Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -43,7 +43,7 @@
  *
  * NOTE
  */
-EXPORTED NTSTATUS STDCALL
+/*EXPORTED*/ NTSTATUS STDCALL
 NtListenPort (IN       HANDLE          PortHandle,
              IN        PLPC_MESSAGE    ConnectMsg)
 {
index 43caccd..440c98d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: query.c,v 1.7 2003/07/11 01:23:15 royce Exp $
+/* $Id: query.c,v 1.8 2003/12/30 18:52:05 fireball Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -42,7 +42,7 @@
  *     P. Dabak reports that this system service seems to return
  *     no information.
  */
-EXPORTED NTSTATUS STDCALL
+/*EXPORTED*/ NTSTATUS STDCALL
 NtQueryInformationPort (IN     HANDLE  PortHandle,
                        IN      CINT    PortInformationClass,   
                        OUT     PVOID   PortInformation,    
index 832eab8..526ea6c 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: anonmem.c,v 1.22 2003/11/30 17:24:22 hbirr Exp $
+/* $Id: anonmem.c,v 1.23 2003/12/30 18:52:05 fireball Exp $
  *
  * PROJECT:     ReactOS kernel
  * FILE:        ntoskrnl/mm/anonmem.c
@@ -454,19 +454,19 @@ MmModifyAttributes(PMADDRESS_SPACE AddressSpace,
          LARGE_INTEGER PhysicalAddr;
 
          if (MmIsPageSwapEntry(AddressSpace->Process,
-                               BaseAddress + (i * PAGE_SIZE)))
+                               (char*)BaseAddress + (i * PAGE_SIZE)))
            {
              SWAPENTRY SwapEntry;
              
              MmDeletePageFileMapping(AddressSpace->Process,
-                                     BaseAddress + (i * PAGE_SIZE),
+                                     (char*)BaseAddress + (i * PAGE_SIZE),
                                      &SwapEntry);
              MmFreeSwapPage(SwapEntry);
            }
          else
            {
              MmDeleteVirtualMapping(AddressSpace->Process,
-                                    BaseAddress + (i*PAGE_SIZE),
+                                    (char*)BaseAddress + (i*PAGE_SIZE),
                                     FALSE, NULL, &PhysicalAddr);
              if (PhysicalAddr.QuadPart != 0)
                {
@@ -478,7 +478,7 @@ MmModifyAttributes(PMADDRESS_SPACE AddressSpace,
                      MmSetSavedSwapEntryPage(PhysicalAddr, 0);
                    }
                  MmDeleteRmap(PhysicalAddr, AddressSpace->Process,
-                              BaseAddress + (i * PAGE_SIZE));
+                              (char*)BaseAddress + (i * PAGE_SIZE));
                  MmReleasePageMemoryConsumer(MC_USER, PhysicalAddr);
                }
            }
@@ -497,10 +497,10 @@ MmModifyAttributes(PMADDRESS_SPACE AddressSpace,
       for (i=0; i < PAGE_ROUND_UP(RegionSize)/PAGE_SIZE; i++)
        {
          if (MmIsPagePresent(AddressSpace->Process, 
-                             BaseAddress + (i*PAGE_SIZE)))
+                             (char*)BaseAddress + (i*PAGE_SIZE)))
            {
              MmSetPageProtect(AddressSpace->Process,
-                              BaseAddress + (i*PAGE_SIZE), 
+                              (char*)BaseAddress + (i*PAGE_SIZE), 
                               NewProtect);
            }
        }
@@ -712,7 +712,7 @@ MmFreeVirtualMemory(PEPROCESS Process,
            }
          
          PageOp = MmCheckForPageOp(MemoryArea, Process->UniqueProcessId,
-                                   MemoryArea->BaseAddress + (i * PAGE_SIZE),
+                                   (char*)MemoryArea->BaseAddress + (i * PAGE_SIZE),
                                    NULL, 0);
          if (PageOp != NULL)
            {
@@ -882,7 +882,7 @@ MmQueryAnonMem(PMEMORY_AREA MemoryArea,
                        Address, &RegionBase);
   Info->AllocationBase = RegionBase;
   Info->AllocationProtect = Region->Protect;  /* FIXME */
-  Info->RegionSize = RegionBase + Region->Length - Info->BaseAddress;
+  Info->RegionSize = (char*)RegionBase + Region->Length - (char*)Info->BaseAddress;
   Info->State = Region->Type;
   Info->Protect = Region->Protect;
   Info->Type = MEM_PRIVATE;
index 18b90a5..b5582e7 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: balance.c,v 1.24 2003/11/24 16:15:00 gvg Exp $
+/* $Id: balance.c,v 1.25 2003/12/30 18:52:05 fireball Exp $
  *
  * PROJECT:     ReactOS kernel 
  * FILE:        ntoskrnl/mm/balance.c
@@ -112,7 +112,11 @@ MmReleasePageMemoryConsumer(ULONG Consumer, PHYSICAL_ADDRESS Page)
   PLIST_ENTRY Entry;
   KIRQL oldIrql;
 
+#if defined(__GNUC__)
   if (Page.QuadPart == 0LL)
+#else
+  if (Page.QuadPart == 0)
+#endif
     {
       DPRINT1("Tried to release page zero.\n");
       KEBUGCHECK(0);
@@ -228,7 +232,11 @@ MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait,
   if (Consumer == MC_NPPOOL || MiIsBalancerThread())
     {
       Page = MmAllocPage(Consumer, 0);
+#if defined(__GNUC__)
       if (Page.QuadPart == 0LL)
+#else
+      if (Page.QuadPart == 0)
+#endif
         {
          KEBUGCHECK(0);
        }
@@ -256,7 +264,11 @@ MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait,
        }
 
       /* Insert an allocation request. */
+#if defined(__GNUC__)
       Request.Page.QuadPart = 0LL;
+#else
+      Request.Page.QuadPart = 0;
+#endif
       KeInitializeEvent(&Request.Event, NotificationEvent, FALSE);
       InterlockedIncrement((LONG *)&MiPagesRequired);
 
@@ -276,7 +288,11 @@ MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait,
                            NULL);
       
       Page = Request.Page;
+#if defined(__GNUC__)
       if (Page.QuadPart == 0LL)
+#else
+      if (Page.QuadPart == 0)
+#endif
        {
          KEBUGCHECK(0);
        }
@@ -290,7 +306,11 @@ MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait,
    * Actually allocate the page.
    */
   Page = MmAllocPage(Consumer, 0);
+#if defined(__GNUC__)
   if (Page.QuadPart == 0LL)
+#else
+  if (Page.QuadPart == 0)
+#endif
     {
       KEBUGCHECK(0);
     }
@@ -390,13 +410,21 @@ MiInitBalancerThread(VOID)
 {
   KPRIORITY Priority;
   NTSTATUS Status;
+#if !defined(__GNUC__)
+  LARGE_INTEGER dummyJunkNeeded;
+  dummyJunkNeeded.QuadPart = -20000000;        /* 2 sec */;
+#endif
 
   CHECKPOINT;
 
   KeInitializeEvent(&MiBalancerEvent, SynchronizationEvent, FALSE);
   KeInitializeTimerEx(&MiBalancerTimer, SynchronizationTimer);
   KeSetTimerEx(&MiBalancerTimer, 
+#if defined(__GNUC__)
                (LARGE_INTEGER)(LONGLONG)-20000000LL,       /* 2 sec */
+#else
+               dummyJunkNeeded,
+#endif
                2000,                                       /* 2 sec */
                NULL);
 
index 756db18..a0b804b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: cont.c,v 1.28 2003/07/11 01:23:15 royce Exp $
+/* $Id: cont.c,v 1.29 2003/12/30 18:52:05 fireball Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -62,7 +62,11 @@ MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes,
    PBase = MmGetContinuousPages(NumberOfBytes,
                                HighestAcceptableAddress,
                                Alignment);
+#if defined(__GNUC__)
    if (PBase.QuadPart == 0LL)
+#else
+   if (PBase.QuadPart == 0)
+#endif
      {
        MmLockAddressSpace(MmGetKernelAddressSpace());
        MmFreeMemoryArea(MmGetKernelAddressSpace(),
@@ -75,10 +79,18 @@ MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes,
      }
    for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / 4096); i++)
      {
+#if !defined(__GNUC__)
+       LARGE_INTEGER dummyJunkNeeded;
+       dummyJunkNeeded.QuadPart = PBase.QuadPart + (i * 4096);
+#endif
        MmCreateVirtualMapping(NULL,
-                              BaseAddress + (i * 4096),
+                              (char*)BaseAddress + (i * 4096),
                               PAGE_EXECUTE_READWRITE | PAGE_SYSTEM,
+#if defined(__GNUC__)
                               (LARGE_INTEGER)(PBase.QuadPart + (i * 4096)),
+#else
+                              dummyJunkNeeded,
+#endif
                               TRUE);
      }
    return(BaseAddress);
index e992996..3abc716 100644 (file)
@@ -96,7 +96,14 @@ MmGetLRUFirstUserPage(VOID)
   if (NextListEntry == &UsedPageListHeads[MC_USER])
     {
       KeReleaseSpinLock(&PageListLock, oldIrql);
-      return((LARGE_INTEGER)0LL);
+#if defined(__GNUC__)
+      return((PHYSICAL_ADDRESS)0LL);
+#else
+      {
+        const PHYSICAL_ADDRESS dummyJunkNeeded = { 0 };
+        return dummyJunkNeeded;
+      }
+#endif
     }
   PageDescriptor = CONTAINING_RECORD(NextListEntry, PHYSICAL_PAGE, ListEntry);
   Next.QuadPart = (ULONG)((ULONG)PageDescriptor - (ULONG)MmPageArray);
@@ -144,7 +151,14 @@ MmGetLRUNextUserPage(PHYSICAL_ADDRESS PreviousPhysicalAddress)
   if (NextListEntry == &UsedPageListHeads[MC_USER])
     {
       KeReleaseSpinLock(&PageListLock, oldIrql);
-      return((LARGE_INTEGER)0LL);
+#if defined(__GNUC__)
+      return((PHYSICAL_ADDRESS)0LL);
+#else
+      {
+        const PHYSICAL_ADDRESS dummyJunkNeeded = { 0 };
+        return dummyJunkNeeded;
+      }
+#endif
     }
   PageDescriptor = CONTAINING_RECORD(NextListEntry, PHYSICAL_PAGE, ListEntry);
   Next.QuadPart = (ULONG)((ULONG)PageDescriptor - (ULONG)MmPageArray);
@@ -201,7 +215,14 @@ MmGetContinuousPages(ULONG NumberOfBytes,
    if (start == -1 || length != NrPages)
      {
        KeReleaseSpinLock(&PageListLock, oldIrql);
-       return((LARGE_INTEGER)(LONGLONG)0);
+#if defined(__GNUC__)
+       return((PHYSICAL_ADDRESS)(LONGLONG)0);
+#else
+       {
+         const PHYSICAL_ADDRESS dummyJunkNeeded = { 0 };
+         return dummyJunkNeeded;
+      }
+#endif
      }  
    for (i = start; i < (start + length); i++)
      {
@@ -216,7 +237,14 @@ MmGetContinuousPages(ULONG NumberOfBytes,
                       &MmPageArray[i].ListEntry);
      }
    KeReleaseSpinLock(&PageListLock, oldIrql);
-   return((LARGE_INTEGER)((LONGLONG)start * PAGE_SIZE));
+#if defined(__GNUC__)
+   return((PHYSICAL_ADDRESS)((LONGLONG)start * PAGE_SIZE));
+#else
+   {
+     const PHYSICAL_ADDRESS dummyJunkNeeded = { start * PAGE_SIZE };
+     return dummyJunkNeeded;
+   }
+#endif
 }
 
 VOID INIT_FUNCTION
@@ -349,7 +377,7 @@ MmInitializePageList(PVOID FirstPhysKernelAddress,
    LastKernelAddress = PAGE_ROUND_UP(LastKernelAddress);
    LastKernelAddress = ((ULONG)LastKernelAddress + (Reserved * PAGE_SIZE));
    LastPhysKernelAddress = (PVOID)PAGE_ROUND_UP(LastPhysKernelAddress);
-   LastPhysKernelAddress = LastPhysKernelAddress + (Reserved * PAGE_SIZE);
+   LastPhysKernelAddress = (char*)LastPhysKernelAddress + (Reserved * PAGE_SIZE);
      
    MmStats.NrTotalPages = 0;
    MmStats.NrSystemPages = 0;
@@ -360,17 +388,26 @@ MmInitializePageList(PVOID FirstPhysKernelAddress,
    
    for (i = 0; i < Reserved; i++)
      {
-       PVOID Address = (PVOID)(ULONG)MmPageArray + (i * PAGE_SIZE);
+       PVOID Address = (char*)(ULONG)MmPageArray + (i * PAGE_SIZE);
        if (!MmIsPagePresent(NULL, Address))
         {
-          ULONG PhysicalAddress;
-          PhysicalAddress = (ULONG)LastPhysKernelAddress - 
+#if !defined(__GNUC__)
+          const PHYSICAL_ADDRESS dummyJunkNeeded = {
+              (ULONG)LastPhysKernelAddress - 
+              (Reserved * PAGE_SIZE) + (i * PAGE_SIZE)
+            };
+#endif
+          ULONG PhysicalAddress = (ULONG)LastPhysKernelAddress - 
             (Reserved * PAGE_SIZE) + (i * PAGE_SIZE);
           Status = 
             MmCreateVirtualMappingUnsafe(NULL,
                                          Address,
                                          PAGE_READWRITE,
+#if defined(__GNUC__)
                                          (PHYSICAL_ADDRESS)(LONGLONG)PhysicalAddress,
+#else
+                                         dummyJunkNeeded,
+#endif
                                          FALSE);
           if (!NT_SUCCESS(Status))
             {
@@ -378,7 +415,7 @@ MmInitializePageList(PVOID FirstPhysKernelAddress,
               KEBUGCHECK(0);
             }
         }
-       memset((PVOID)MmPageArray + (i * PAGE_SIZE), 0, PAGE_SIZE);
+       memset((char*)MmPageArray + (i * PAGE_SIZE), 0, PAGE_SIZE);
      }
    
 
@@ -859,7 +896,14 @@ MmAllocPage(ULONG Consumer, SWAPENTRY SavedSwapEntry)
        {
          DPRINT1("MmAllocPage(): Out of memory\n");
          KeReleaseSpinLock(&PageListLock, oldIrql);
+#if defined(__GNUC__)
          return((PHYSICAL_ADDRESS)0LL);
+#else
+         {
+           const PHYSICAL_ADDRESS dummyJunkNeeded = { 0 };
+           return dummyJunkNeeded;
+         }
+#endif
        }
       ListEntry = RemoveTailList(&FreeUnzeroedPageListHead);
       UnzeroedPageCount--;
index 1f7d85d..1057e03 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: page.c,v 1.60 2003/10/12 17:05:48 hbirr Exp $
+/* $Id: page.c,v 1.61 2003/12/30 18:52:05 fireball Exp $
  *
  * PROJECT:     ReactOS kernel
  * FILE:        ntoskrnl/mm/i386/page.c
 
 ULONG MmGlobalKernelPageDirectory[1024] = {0, };
 
+#if defined(__GNUC__)
 #define PTE_TO_PAGE(X) ((LARGE_INTEGER)(LONGLONG)(PAGE_MASK(X)))
+#else
+__inline LARGE_INTEGER PTE_TO_PAGE(ULONG npage)
+{
+    LARGE_INTEGER dummy;
+    dummy.QuadPart = (LONGLONG)(PAGE_MASK(npage));
+    return dummy;
+}
+#endif
 
 /* FUNCTIONS ***************************************************************/
 
@@ -69,8 +78,15 @@ PULONG
 MmGetPageDirectory(VOID)
 {
    unsigned int page_dir=0;
+#if defined(__GNUC__)
    __asm__("movl %%cr3,%0\n\t"
                 : "=r" (page_dir));
+#elif defined(_MSC_VER)
+   __asm mov eax, cr3;
+   __asm mov page_dir, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
    return((PULONG)page_dir);
 }
 
@@ -140,7 +156,11 @@ NTSTATUS Mmi386ReleaseMmInfo(PEPROCESS Process)
      }
    
    MmReleasePageMemoryConsumer(MC_NPPOOL, Process->Pcb.DirectoryTableBase);
+#if defined(__GNUC__)
    Process->Pcb.DirectoryTableBase.QuadPart = 0LL;
+#else
+   Process->Pcb.DirectoryTableBase.QuadPart = 0;
+#endif
    
    DPRINT("Finished Mmi386ReleaseMmInfo()\n");
    return(STATUS_SUCCESS);
@@ -382,7 +402,14 @@ MmGetPhysicalAddressForProcess(PEPROCESS Process,
    
    if (!(PageEntry & PA_PRESENT))
      {
+#if defined(__GNUC__)
        return((LARGE_INTEGER)0LL);
+#else
+       {
+         PHYSICAL_ADDRESS dummy = { 0 };
+         return dummy;
+       }
+#endif
      }
    return(PTE_TO_PAGE(PageEntry));
 }
@@ -537,7 +564,11 @@ MmDeleteVirtualMapping(PEPROCESS Process, PVOID Address, BOOL FreePage,
          }
        if (PhysicalAddr != NULL)
          {
+#if defined(__GNUC__)
            *PhysicalAddr = (LARGE_INTEGER)0LL;
+#else
+           PhysicalAddr->QuadPart = 0;
+#endif
          }
        return;
      }
@@ -838,7 +869,7 @@ PULONG MmGetPageEntry(PVOID PAddress)
 
 BOOLEAN MmIsDirtyPage(PEPROCESS Process, PVOID Address)
 {
-   return((MmGetPageEntryForProcess(Process, Address)) & PA_DIRTY);
+   return (BOOLEAN)((MmGetPageEntryForProcess(Process, Address)) & PA_DIRTY);
 }
 
 BOOLEAN 
@@ -867,7 +898,7 @@ MmIsAccessedAndResetAccessPage(PEPROCESS Process, PVOID Address)
      }
 
    PageEntry = MmGetPageEntry(Address);
-   Accessed = (*PageEntry) & PA_ACCESSED;
+   Accessed = (BOOLEAN)((*PageEntry) & PA_ACCESSED);
    if (Accessed)
      {
        (*PageEntry) = (*PageEntry) & (~PA_ACCESSED);
@@ -963,7 +994,7 @@ VOID MmEnableVirtualMapping(PEPROCESS Process, PVOID Address)
 
 BOOLEAN MmIsPagePresent(PEPROCESS Process, PVOID Address)
 {
-   return((MmGetPageEntryForProcess1(Process, Address)) & PA_PRESENT);
+   return (BOOLEAN)((MmGetPageEntryForProcess1(Process, Address)) & PA_PRESENT);
 }
 
 BOOLEAN MmIsPageSwapEntry(PEPROCESS Process, PVOID Address)
@@ -1006,7 +1037,7 @@ MmCreateVirtualMappingDump(PVOID Address,
      {
        KEBUGCHECK(0);
      }
-   *Pte = PhysicalAddress.QuadPart | Attributes;
+   *Pte = (ULONG)(PhysicalAddress.QuadPart | Attributes);
    FLUSH_TLB;
    return(STATUS_SUCCESS);
 }
@@ -1066,7 +1097,7 @@ MmCreateVirtualMappingForKernel(PVOID Address,
      {
        MmMarkPageUnmapped(PTE_TO_PAGE((*Pte)));
      }
-   *Pte = PhysicalAddress.QuadPart | Attributes;
+   *Pte = (ULONG)(PhysicalAddress.QuadPart | Attributes);
    if (Process != NULL && 
        Process->AddressSpace.PageTableRefCountTable != NULL &&
        Address < (PVOID)KERNEL_BASE &&
@@ -1222,7 +1253,7 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
      {
        MmMarkPageUnmapped(PTE_TO_PAGE((*Pte)));
      }
-   *Pte = PhysicalAddress.QuadPart | Attributes;
+   *Pte = (ULONG)(PhysicalAddress.QuadPart | Attributes);
    if (Process != NULL && 
        Process->AddressSpace.PageTableRefCountTable != NULL &&
        Address < (PVOID)KERNEL_BASE &&
@@ -1341,7 +1372,7 @@ VOID
 MmUpdateStackPageDir(PULONG LocalPageDir, PKTHREAD PThread)
 {
   unsigned EntryBase = ADDR_TO_PDE_OFFSET(PThread->StackLimit);
-  unsigned EntryTop = ADDR_TO_PDE_OFFSET(PThread->InitialStack - PAGE_SIZE);
+  unsigned EntryTop  = ADDR_TO_PDE_OFFSET((char*)PThread->InitialStack - PAGE_SIZE);
 
   if (0 == LocalPageDir[EntryBase])
     {
index 95e4e24..3009877 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: iospace.c,v 1.22 2003/12/20 21:43:21 navaraf Exp $
+/* $Id: iospace.c,v 1.23 2003/12/30 18:52:05 fireball Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/mm/iospace.c
@@ -103,21 +103,34 @@ MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress,
      }
    for (i = 0; (i < (PAGE_ROUND_UP(NumberOfBytes) / PAGE_SIZE)); i++)
      {
+#if !defined(__GNUC__)
+        PHYSICAL_ADDRESS dummyJunkNeeded;
+       dummyJunkNeeded.QuadPart = PhysicalAddress.QuadPart + (i * PAGE_SIZE);
+#endif
        Status = 
-         MmCreateVirtualMappingForKernel(Result + (i * PAGE_SIZE),
+         MmCreateVirtualMappingForKernel((char*)Result + (i * PAGE_SIZE),
                                          Attributes,
+#if defined(__GNUC__)
                                          (PHYSICAL_ADDRESS)
                                          (PhysicalAddress.QuadPart + 
-                                          (i * PAGE_SIZE)));
+                                          (i * PAGE_SIZE))
+#else
+                                         dummyJunkNeeded
+#endif
+                                         );
        if (!NT_SUCCESS(Status))
          {
             DbgPrint("Unable to create virtual mapping\n");
             KEBUGCHECK(0);
          }
+#if defined(__GNUC__)
        MmMarkPageMapped((PHYSICAL_ADDRESS) (PhysicalAddress.QuadPart + 
                                             (i * PAGE_SIZE)));
+#else
+       MmMarkPageMapped(dummyJunkNeeded);
+#endif
      }
-   return ((PVOID)(Result + PhysicalAddress.QuadPart % PAGE_SIZE));
+   return ((PVOID)((char*)Result + PhysicalAddress.QuadPart % PAGE_SIZE));
 }
  
 
@@ -170,7 +183,7 @@ MmMapVideoDisplay (IN       PHYSICAL_ADDRESS        PhysicalAddress,
                   IN   ULONG                   NumberOfBytes,
                   IN   MEMORY_CACHING_TYPE     CacheType)
 {
-  return MmMapIoSpace (PhysicalAddress, NumberOfBytes, CacheType);
+  return MmMapIoSpace (PhysicalAddress, NumberOfBytes, (BOOLEAN)CacheType);
 }
 
 
index 3953868..09f9792 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: kmap.c,v 1.29 2003/10/12 17:05:48 hbirr Exp $
+/* $Id: kmap.c,v 1.30 2003/12/30 18:52:05 fireball Exp $
  *
  * COPYRIGHT:    See COPYING in the top level directory
  * PROJECT:      ReactOS kernel
@@ -40,7 +40,7 @@ VOID
 ExUnmapPage(PVOID Addr)
 {
    KIRQL oldIrql;
-   ULONG Base = (Addr - MiKernelMapStart) / PAGE_SIZE;
+   ULONG Base = ((char*)Addr - (char*)MiKernelMapStart) / PAGE_SIZE;
    
    DPRINT("ExUnmapPage(Addr %x)\n",Addr);
    
@@ -110,7 +110,7 @@ ExAllocatePageWithPhysPage(PHYSICAL_ADDRESS PhysPage)
    {
       AllocMapHint = Base + 1;
       KeReleaseSpinLock(&AllocMapLock, oldlvl);
-      Addr = MiKernelMapStart + Base * PAGE_SIZE;
+      Addr = (char*)MiKernelMapStart + Base * PAGE_SIZE;
       Status = MmCreateVirtualMapping(NULL, 
                                      Addr, 
                                      PAGE_READWRITE | PAGE_SYSTEM, 
@@ -139,13 +139,13 @@ VOID
 MiFreeNonPagedPoolRegion(PVOID Addr, ULONG Count, BOOLEAN Free)
 {
   ULONG i;
-  ULONG Base = (Addr - MiKernelMapStart) / PAGE_SIZE;
+  ULONG Base = ((char*)Addr - (char*)MiKernelMapStart) / PAGE_SIZE;
   KIRQL oldlvl;
   
   for (i = 0; i < Count; i++)
   {
       MmDeleteVirtualMapping(NULL, 
-                            Addr + (i * PAGE_SIZE), 
+                            (char*)Addr + (i * PAGE_SIZE), 
                             Free, 
                             NULL, 
                             NULL);
@@ -178,7 +178,7 @@ MiAllocNonPagedPoolRegion(ULONG nr_pages)
    }
    KeReleaseSpinLock(&AllocMapLock, oldlvl);
    //DPRINT("returning %x\n",NonPagedPoolBase + Base * PAGE_SIZE);
-   return MiKernelMapStart + Base * PAGE_SIZE;
+   return (char*)MiKernelMapStart + Base * PAGE_SIZE;
 }
 
 
index 3571265..e42af29 100644 (file)
@@ -54,7 +54,7 @@ VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
        current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
        DbgPrint("Base %x Length %x End %x Attributes %x Flink %x\n",
               current->BaseAddress,current->Length,
-              current->BaseAddress+current->Length,current->Attributes,
+              (char*)current->BaseAddress+current->Length,current->Attributes,
               current->Entry.Flink);
        current_entry = current_entry->Flink;
      }
@@ -82,7 +82,7 @@ MEMORY_AREA* MmOpenMemoryAreaByAddress(PMADDRESS_SPACE AddressSpace,
        assert(current_entry->Flink->Blink == current_entry);
        assert(previous_entry->Flink == current_entry);
        if (current->BaseAddress <= Address &&
-           (current->BaseAddress + current->Length) > Address)
+           (PVOID)((char*)current->BaseAddress + current->Length) > Address)
          {
             DPRINT("%s() = %x\n",__FUNCTION__,current);
             return(current);
@@ -119,7 +119,7 @@ MEMORY_AREA* MmOpenMemoryAreaByRegion(PMADDRESS_SPACE AddressSpace,
        DPRINT("current->BaseAddress %x current->Length %x\n",
               current->BaseAddress,current->Length);
        if (current->BaseAddress >= Address &&
-           current->BaseAddress < (Address+Length))
+           current->BaseAddress < (PVOID)((char*)Address+Length))
          {
             DPRINT("Finished MmOpenMemoryAreaByRegion() = %x\n",
                    current);
@@ -127,20 +127,20 @@ MEMORY_AREA* MmOpenMemoryAreaByRegion(PMADDRESS_SPACE AddressSpace,
          }
        Extent = (ULONG)current->BaseAddress + current->Length;
        if (Extent > (ULONG)Address &&
-           Extent < (ULONG)(Address+Length))
+           Extent < (ULONG)((char*)Address+Length))
          {
             DPRINT("Finished MmOpenMemoryAreaByRegion() = %x\n",
                    current);
             return(current);
          }
        if (current->BaseAddress <= Address &&
-           Extent >= (ULONG)(Address+Length))
+           Extent >= (ULONG)((char*)Address+Length))
          {
             DPRINT("Finished MmOpenMemoryAreaByRegion() = %x\n",
                    current);
             return(current);
          }
-       if (current->BaseAddress >= (Address+Length))
+       if (current->BaseAddress >= (PVOID)((char*)Address+Length))
          {
             DPRINT("Finished MmOpenMemoryAreaByRegion()= NULL\n",0);
             return(NULL);
@@ -224,10 +224,10 @@ PVOID MmFindGapBottomUp(PMADDRESS_SPACE AddressSpace, ULONG Length)
      {
        current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
        next = CONTAINING_RECORD(current_entry->Flink,MEMORY_AREA,Entry);
-       Gap = next->BaseAddress - (current->BaseAddress + PAGE_ROUND_UP(current->Length));
+       Gap = (char*)next->BaseAddress - ((char*)current->BaseAddress + PAGE_ROUND_UP(current->Length));
        if (Gap >= Length)
          {
-            return(current->BaseAddress + PAGE_ROUND_UP(current->Length));
+            return((char*)current->BaseAddress + PAGE_ROUND_UP(current->Length));
          }
        current_entry = current_entry->Flink;
      }
@@ -239,7 +239,7 @@ PVOID MmFindGapBottomUp(PMADDRESS_SPACE AddressSpace, ULONG Length)
    else
      {
         current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
-        Address = current->BaseAddress + PAGE_ROUND_UP(current->Length);
+        Address = (char*)current->BaseAddress + PAGE_ROUND_UP(current->Length);
      }
    /* Check if enough space for the block */
    if (AddressSpace->LowestAddress < KERNEL_BASE)
@@ -289,30 +289,30 @@ PVOID MmFindGapTopDown(PMADDRESS_SPACE AddressSpace, ULONG Length)
   while (current_entry->Blink != ListHead)
     {
       current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
-      BottomAddress = current->BaseAddress + PAGE_ROUND_UP(current->Length);
+      BottomAddress = (char*)current->BaseAddress + PAGE_ROUND_UP(current->Length);
       DPRINT("Base %p  Length %lx\n", current->BaseAddress, PAGE_ROUND_UP(current->Length));
 
       if (BottomAddress < HighestAddress)
        {
-         Gap = TopAddress - BottomAddress + 1;
+         Gap = (char*)TopAddress - (char*)BottomAddress + 1;
          DPRINT("Bottom %p  Top %p  Gap %lx\n", BottomAddress, TopAddress, Gap);
          if (Gap >= Length)
            {
-             DPRINT("Found gap at %p\n", TopAddress - Length);
-             return(TopAddress - Length + 1);
+             DPRINT("Found gap at %p\n", (char*)TopAddress - Length);
+             return((char*)TopAddress - Length + 1);
            }
-         TopAddress = current->BaseAddress - 1;
+         TopAddress = (char*)current->BaseAddress - 1;
        }
       current_entry = current_entry->Blink;
     }
 
   if (current_entry == ListHead)
     {
-      Address = (PVOID)HighestAddress - Length + 1;
+      Address = (char*)HighestAddress - Length + 1;
     }
   else
     {
-      Address = TopAddress - Length + 1;
+      Address = (char*)TopAddress - Length + 1;
     }
 
   /* Check if enough space for the block */
@@ -388,29 +388,33 @@ MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
      }
    for (i=0; i<(PAGE_ROUND_UP(MemoryArea->Length)/PAGE_SIZE); i++)
      {
+#if defined(__GNUC__)
        PHYSICAL_ADDRESS PhysAddr = (PHYSICAL_ADDRESS)0LL;
+#else
+       PHYSICAL_ADDRESS PhysAddr = { 0 };
+#endif
        BOOL Dirty = FALSE;
        SWAPENTRY SwapEntry = 0;
 
        if (MmIsPageSwapEntry(AddressSpace->Process,
-                            MemoryArea->BaseAddress + (i * PAGE_SIZE)))
+                            (char*)MemoryArea->BaseAddress + (i * PAGE_SIZE)))
         {
           MmDeletePageFileMapping(AddressSpace->Process,
-                                  MemoryArea->BaseAddress + (i * PAGE_SIZE),
+                                  (char*)MemoryArea->BaseAddress + (i * PAGE_SIZE),
                                   &SwapEntry);
         }
        else
         {
           MmDeleteVirtualMapping(AddressSpace->Process, 
-                                 MemoryArea->BaseAddress + (i*PAGE_SIZE),
+                                 (char*)MemoryArea->BaseAddress + (i*PAGE_SIZE),
                                  FALSE, &Dirty, &PhysAddr);
 
         }
        if (FreePage != NULL)
         {
           FreePage(FreePageContext, MemoryArea,
-                   MemoryArea->BaseAddress + (i * PAGE_SIZE), PhysAddr, 
-                   SwapEntry, Dirty);
+                   (char*)MemoryArea->BaseAddress + (i * PAGE_SIZE), PhysAddr, 
+                   SwapEntry, (BOOLEAN)Dirty);
         }
      }
    if (AddressSpace->Process != NULL &&
@@ -449,13 +453,13 @@ PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
    
    if (BaseAddress == OriginalMemoryArea->BaseAddress)
      {
-       OriginalMemoryArea->BaseAddress = BaseAddress + Length;
+       OriginalMemoryArea->BaseAddress = (char*)BaseAddress + Length;
        OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length;
        MmInsertMemoryArea(AddressSpace, Result);
        return(Result);
      }
-   if ((BaseAddress + Length) == 
-       (OriginalMemoryArea->BaseAddress + OriginalMemoryArea->Length))
+   if (((char*)BaseAddress + Length) == 
+       ((char*)OriginalMemoryArea->BaseAddress + OriginalMemoryArea->Length))
      {
        OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length; 
        MmInsertMemoryArea(AddressSpace, Result);
@@ -466,11 +470,11 @@ PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
    Split = ExAllocatePoolWithTag(NonPagedPool, sizeof(MEMORY_AREA),
                                 TAG_MAREA);
    RtlCopyMemory(Split,OriginalMemoryArea,sizeof(MEMORY_AREA));
-   Split->BaseAddress = BaseAddress + Length;
+   Split->BaseAddress = (char*)BaseAddress + Length;
    Split->Length = OriginalMemoryArea->Length - (((ULONG)BaseAddress) 
                                                 + Length);
    
-   OriginalMemoryArea->Length = BaseAddress - OriginalMemoryArea->BaseAddress;
+   OriginalMemoryArea->Length = (char*)BaseAddress - (char*)OriginalMemoryArea->BaseAddress;
       
    return(Split);
 }
@@ -513,7 +517,15 @@ NTSTATUS MmCreateMemoryArea(PEPROCESS Process,
             DPRINT("No suitable gap\n");
             return(STATUS_NO_MEMORY);
          }
+#if defined(__GNUC__)
        (*BaseAddress)=(*BaseAddress)+PAGE_SIZE;
+#else
+       {
+         char* pTemp = *BaseAddress;
+         pTemp += PAGE_SIZE;
+         *BaseAddress = pTemp;
+       }
+#endif
      }
    else
      {
@@ -527,7 +539,7 @@ NTSTATUS MmCreateMemoryArea(PEPROCESS Process,
          }
 
         if (AddressSpace->LowestAddress < KERNEL_BASE && 
-           (*BaseAddress) + tmpLength > (PVOID)KERNEL_BASE)
+           (PVOID)((char*)(*BaseAddress) + tmpLength) > (PVOID)KERNEL_BASE)
          {
            return STATUS_ACCESS_VIOLATION;
          }
index e615f23..6db8c53 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: mdl.c,v 1.54 2003/10/12 17:05:48 hbirr Exp $
+/* $Id: mdl.c,v 1.55 2003/12/30 18:52:05 fireball Exp $
  *
  * COPYRIGHT:    See COPYING in the top level directory
  * PROJECT:      ReactOS kernel
@@ -115,8 +115,15 @@ MmUnlockPages(PMDL Mdl)
    MdlPages = (PULONG)(Mdl + 1);
    for (i=0; i<(PAGE_ROUND_UP(Mdl->ByteCount+Mdl->ByteOffset)/PAGE_SIZE); i++)
      {
+#if defined(__GNUC__)
        MmUnlockPage((LARGE_INTEGER)(LONGLONG)MdlPages[i]);
        MmDereferencePage((LARGE_INTEGER)(LONGLONG)MdlPages[i]);
+#else
+       PHYSICAL_ADDRESS dummyJunkNeeded;
+       dummyJunkNeeded.QuadPart = MdlPages[i];
+       MmUnlockPage(dummyJunkNeeded);
+       MmDereferencePage(dummyJunkNeeded);
+#endif
      }   
    Mdl->MdlFlags = Mdl->MdlFlags & (~MDL_PAGES_LOCKED);
 }
@@ -170,7 +177,7 @@ MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
       KEBUGCHECK(0);
    }
 
-   Base = MiMdlMappingRegionBase + StartingOffset * PAGE_SIZE;
+   Base = (char*)MiMdlMappingRegionBase + StartingOffset * PAGE_SIZE;
 
    if (MiMdlMappingRegionHint == StartingOffset)
    {
@@ -184,10 +191,18 @@ MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
    for (i = 0; i < RegionSize; i++)
      {
        NTSTATUS Status;
+#if !defined(__GNUC__)
+       PHYSICAL_ADDRESS dummyJunkNeeded;
+       dummyJunkNeeded.QuadPart = MdlPages[i];
+#endif
        Status = MmCreateVirtualMapping(NULL,
                                       (PVOID)((ULONG)Base+(i*PAGE_SIZE)),
                                       PAGE_READWRITE,
+#if defined(__GNUC__)
                                       (LARGE_INTEGER)(LONGLONG)MdlPages[i],
+#else
+                                      dummyJunkNeeded,
+#endif
                                       FALSE);
        if (!NT_SUCCESS(Status))
         {
@@ -198,8 +213,8 @@ MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
 
    /* Mark the MDL has having being mapped. */
    Mdl->MdlFlags = Mdl->MdlFlags | MDL_MAPPED_TO_SYSTEM_VA;
-   Mdl->MappedSystemVa = Base + Mdl->ByteOffset;
-   return(Base + Mdl->ByteOffset);
+   Mdl->MappedSystemVa = (char*)Base + Mdl->ByteOffset;
+   return((char*)Base + Mdl->ByteOffset);
 }
 
 /*
@@ -232,13 +247,21 @@ MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl)
 
   /* Calculate the number of pages we mapped. */
   RegionSize = PAGE_ROUND_UP(Mdl->ByteCount + Mdl->ByteOffset) / PAGE_SIZE;
+#if defined(__GNUC__)
   BaseAddress -= Mdl->ByteOffset;
+#else
+  {
+    char* pTemp = BaseAddress;
+    pTemp -= Mdl->ByteOffset;
+    BaseAddress = pTemp;
+  }
+#endif
 
   /* Unmap all the pages. */
   for (i = 0; i < RegionSize; i++)
     {
       MmDeleteVirtualMapping(NULL, 
-                            BaseAddress + (i * PAGE_SIZE),
+                            (char*)BaseAddress + (i * PAGE_SIZE),
                             FALSE,
                             NULL,
                             NULL);
@@ -246,7 +269,7 @@ MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl)
 
   KeAcquireSpinLock(&MiMdlMappingRegionLock, &oldIrql);
   /* Deallocate all the pages used. */
-  Base = (ULONG)(BaseAddress - MiMdlMappingRegionBase) / PAGE_SIZE;
+  Base = (ULONG)((char*)BaseAddress - (char*)MiMdlMappingRegionBase) / PAGE_SIZE;
   
   RtlClearBits(&MiMdlMappingRegionAllocMap, Base, RegionSize);
 
@@ -335,7 +358,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
      {
        PVOID Address;
        
-       Address = Mdl->StartVa + (i*PAGE_SIZE);       
+       Address = (char*)Mdl->StartVa + (i*PAGE_SIZE);
        
        if (!MmIsPagePresent(NULL, Address))
          {
@@ -344,8 +367,15 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
              {
                for (j = 0; j < i; j++)
                  {
+#if defined(__GNUC__)
                    MmUnlockPage((LARGE_INTEGER)(LONGLONG)MdlPages[j]);
                    MmDereferencePage((LARGE_INTEGER)(LONGLONG)MdlPages[j]);
+#else
+                   PHYSICAL_ADDRESS dummyJunkNeeded;
+                   dummyJunkNeeded.QuadPart = MdlPages[j];
+                   MmUnlockPage(dummyJunkNeeded);
+                   MmDereferencePage(dummyJunkNeeded);
+#endif
                  }
                ExRaiseStatus(Status);
              }
@@ -362,15 +392,30 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
              {
                for (j = 0; j < i; j++)
                  {
+#if defined(__GNUC__)
                        MmUnlockPage((LARGE_INTEGER)(LONGLONG)MdlPages[j]);
                        MmDereferencePage(
                                         (LARGE_INTEGER)(LONGLONG)MdlPages[j]);
+#else
+                       PHYSICAL_ADDRESS dummyJunkNeeded;
+                       dummyJunkNeeded.QuadPart = MdlPages[j];
+                       MmUnlockPage(dummyJunkNeeded);
+                       MmDereferencePage(dummyJunkNeeded);
+#endif
                  }
                ExRaiseStatus(Status);
              }
          }
        MdlPages[i] = MmGetPhysicalAddressForProcess(NULL, Address).u.LowPart;
+#if defined(__GNUC__)
        MmReferencePage((LARGE_INTEGER)(LONGLONG)MdlPages[i]);
+#else
+       {
+         PHYSICAL_ADDRESS dummyJunkNeeded;
+         dummyJunkNeeded.QuadPart = MdlPages[i];
+         MmReferencePage(dummyJunkNeeded);
+       }
+#endif
      }
    MmUnlockAddressSpace(&Mdl->Process->AddressSpace);
    if (Mode == UserMode && Mdl->Process != CurrentProcess)
@@ -421,9 +466,9 @@ MmBuildMdlForNonPagedPool (PMDL     Mdl)
    for (va=0; va < ((Mdl->Size - sizeof(MDL)) / sizeof(ULONG)); va++)
      {
         ((PULONG)(Mdl + 1))[va] =
-            (MmGetPhysicalAddress(Mdl->StartVa + (va * PAGE_SIZE))).u.LowPart;
+            (MmGetPhysicalAddress((char*)Mdl->StartVa + (va * PAGE_SIZE))).u.LowPart;
      }
-   Mdl->MappedSystemVa = Mdl->StartVa + Mdl->ByteOffset;
+   Mdl->MappedSystemVa = (char*)Mdl->StartVa + Mdl->ByteOffset;
 }
 
 
@@ -456,9 +501,9 @@ MmCreateMdl (PMDL   MemoryDescriptorList,
             return(NULL);
          }
      }
-   
-   MmInitializeMdl(MemoryDescriptorList,Base,Length);
-   
+
+   MmInitializeMdl(MemoryDescriptorList, (char*)Base, Length);
+
    return(MemoryDescriptorList);
 }
 
index 8aa9641..e6ac184 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: mm.c,v 1.66 2003/07/26 12:45:37 hbirr Exp $
+/* $Id: mm.c,v 1.67 2003/12/30 18:52:05 fireball Exp $
  *
  * COPYRIGHT:   See COPYING in the top directory
  * PROJECT:     ReactOS kernel 
@@ -56,7 +56,7 @@ NTSTATUS MmReleaseMemoryArea(PEPROCESS Process, PMEMORY_AREA Marea)
    DPRINT("MmReleaseMemoryArea(Process %x, Marea %x)\n",Process,Marea);
    
    DPRINT("Releasing %x between %x %x (type %d)\n",
-          Marea, Marea->BaseAddress, Marea->BaseAddress + Marea->Length,
+          Marea, Marea->BaseAddress, (char*)Marea->BaseAddress + Marea->Length,
           Marea->Type);
    
    switch (Marea->Type)
index aac9d0c..1fb3b7d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: mminit.c,v 1.57 2003/11/30 17:17:02 hbirr Exp $
+/* $Id: mminit.c,v 1.58 2003/12/30 18:52:05 fireball Exp $
  *
  * COPYRIGHT:   See COPYING in the top directory
  * PROJECT:     ReactOS kernel 
@@ -39,11 +39,17 @@ extern unsigned int _text_end__;
 extern unsigned int _init_start__;
 extern unsigned int _init_end__;
 
+extern unsigned int _bss_end__;
+
+#if defined(_MSC_VER)
+
+#pragma message("This will never work until we somehow fix these!")
+
+#endif
+
 static BOOLEAN IsThisAnNtAsSystem = FALSE;
 static MM_SYSTEM_SIZE MmSystemSize = MmSmallSystem;
 
-extern unsigned int _bss_end__;
-
 static MEMORY_AREA* kernel_text_desc = NULL;
 static MEMORY_AREA* kernel_init_desc = NULL;
 static MEMORY_AREA* kernel_map_desc = NULL;
@@ -108,13 +114,13 @@ MmInitVirtualMemory(ULONG LastKernelAddress,
    MmInitMemoryAreas();
 
    /* Don't change the start of kernel map. Pte's must always exist for this region. */
-   MiKernelMapStart = (PVOID)LastKernelAddress + PAGE_SIZE;
+   MiKernelMapStart = (char*)LastKernelAddress + PAGE_SIZE;
    MiKernelMapLength = MM_KERNEL_MAP_SIZE;
 
-   MiNonPagedPoolStart = MiKernelMapStart + MiKernelMapLength + PAGE_SIZE;
+   MiNonPagedPoolStart = (char*)MiKernelMapStart + MiKernelMapLength + PAGE_SIZE;
    MiNonPagedPoolLength = MM_NONPAGED_POOL_SIZE;
 
-   MmPagedPoolBase = MiNonPagedPoolStart + MiNonPagedPoolLength + PAGE_SIZE;
+   MmPagedPoolBase = (char*)MiNonPagedPoolStart + MiNonPagedPoolLength + PAGE_SIZE;
    MmPagedPoolSize = MM_PAGED_POOL_SIZE;
 
 
index c43ba2e..9176384 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: mpw.c,v 1.16 2003/07/21 21:53:53 royce Exp $
+/* $Id: mpw.c,v 1.17 2003/12/30 18:52:05 fireball Exp $
  *
  * PROJECT:      ReactOS kernel
  * FILE:         ntoskrnl/mm/mpw.c
@@ -54,7 +54,11 @@ MmWriteDirtyPages(ULONG Target, PULONG Actual)
   NTSTATUS Status;
 
   Page = MmGetLRUFirstUserPage();
+#if defined(__GNUC__)
   while (Page.QuadPart != 0LL && Target > 0)
+#else
+  while (Page.QuadPart && Target > 0)
+#endif
     {
       /*
        * FIXME: While the current page is write back it is possible
index 643ff3d..b448337 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: ncache.c,v 1.25 2003/07/10 21:05:03 royce Exp $
+/* $Id: ncache.c,v 1.26 2003/12/30 18:52:05 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -79,7 +79,7 @@ MmAllocateNonCachedMemory(IN ULONG NumberOfBytes)
 
        Status = MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE, &NPage);
        MmCreateVirtualMapping (NULL,
-                              Result + (i * PAGE_SIZE),
+                              (char*)Result + (i * PAGE_SIZE),
                               Attributes,
                               NPage,
                               TRUE);
index b96b020..3bb84c7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: npool.c,v 1.79 2003/12/14 17:56:23 hbirr Exp $
+/* $Id: npool.c,v 1.80 2003/12/30 18:52:05 fireball Exp $
  *
  * COPYRIGHT:    See COPYING in the top level directory
  * PROJECT:      ReactOS kernel
 #if 0
 #define POOL_TRACE(args...) do { DbgPrint(args); } while(0);
 #else
+#if defined(__GNUC__)
 #define POOL_TRACE(args...)
+#else
+#define POOL_TRACE
+#endif /* __GNUC__ */
 #endif
 
 /* avl types ****************************************************************/
@@ -778,10 +782,10 @@ MiDumpTagStats(ULONG CurrentTag, ULONG CurrentNrBlocks, ULONG CurrentSize)
 {
   CHAR c1, c2, c3, c4;
   
-  c1 = (CurrentTag >> 24) & 0xFF;
-  c2 = (CurrentTag >> 16) & 0xFF;
-  c3 = (CurrentTag >> 8) & 0xFF;
-  c4 = CurrentTag & 0xFF;
+  c1 = (CHAR)((CurrentTag >> 24) & 0xFF);
+  c2 = (CHAR)((CurrentTag >> 16) & 0xFF);
+  c3 = (CHAR)((CurrentTag >> 8) & 0xFF);
+  c4 = (CHAR)(CurrentTag & 0xFF);
   
   if (isprint(c1) && isprint(c2) && isprint(c3) && isprint(c4))
     {
@@ -897,12 +901,12 @@ MiDebugDumpNonPagedPool(BOOLEAN NewOnly)
        if (!NewOnly || !current->Used.Dumped)
         {
           CHAR c1, c2, c3, c4;
-          
-          c1 = (current->Used.Tag >> 24) & 0xFF;
-          c2 = (current->Used.Tag >> 16) & 0xFF;
-          c3 = (current->Used.Tag >> 8) & 0xFF;
-          c4 = current->Used.Tag & 0xFF;
-          
+
+          c1 = (CHAR)((current->Used.Tag >> 24) & 0xFF);
+          c2 = (CHAR)((current->Used.Tag >> 16) & 0xFF);
+          c3 = (CHAR)((current->Used.Tag >> 8) & 0xFF);
+          c4 = (CHAR)(current->Used.Tag & 0xFF);
+
           if (isprint(c1) && isprint(c2) && isprint(c3) && isprint(c4))
             {
               DbgPrint("Size 0x%x Tag 0x%x (%c%c%c%c) Allocator 0x%x\n",
@@ -1182,14 +1186,14 @@ add_to_free_list(BLOCK_HDR* blk)
     }
 
   current = (BLOCK_HDR*)((char*)blk + BLOCK_HDR_SIZE + blk->Size);
-  if ((PVOID)current < MiNonPagedPoolStart + MiNonPagedPoolLength &&
+  if ((char*)current < (char*)MiNonPagedPoolStart + MiNonPagedPoolLength &&
       current->Magic == BLOCK_HDR_FREE_MAGIC)
     {
       remove_from_free_list(current);
       blk->Size += BLOCK_HDR_SIZE + current->Size;
       memset(current, 0xcc, BLOCK_HDR_SIZE);
       current = (BLOCK_HDR*)((char*)blk + BLOCK_HDR_SIZE + blk->Size);
-      if ((PVOID)current < MiNonPagedPoolStart + MiNonPagedPoolLength)
+      if ((char*)current < (char*)MiNonPagedPoolStart + MiNonPagedPoolLength)
         {
          current->previous = blk;
        }
@@ -1241,7 +1245,7 @@ grow_block(BLOCK_HDR* blk, PVOID end)
 
    PVOID start = (PVOID)PAGE_ROUND_UP((ULONG)((char*)blk + BLOCK_HDR_SIZE));
    end = (PVOID)PAGE_ROUND_UP(end);
-   index = (ULONG)(start - MiNonPagedPoolStart) / PAGE_SIZE;
+   index = (ULONG)((char*)start - (char*)MiNonPagedPoolStart) / PAGE_SIZE;
    while (start < end)
      {
        if (!(MiNonPagedPoolAllocMap[index / 32] & (1 << (index % 32))))
@@ -1269,7 +1273,15 @@ grow_block(BLOCK_HDR* blk, PVOID end)
           MiNonPagedPoolNrOfPages++;
         }
        index++;
+#if defined(__GNUC__)
        start += PAGE_SIZE;
+#else
+       {
+        char* pTemp = start;
+        pTemp += PAGE_SIZE;
+        start = pTemp;
+       }
+#endif
      }
    return result;
 }
@@ -1373,15 +1385,15 @@ static BLOCK_HDR* get_block(unsigned int size, unsigned long alignment)
         }
      }
 
-   end = (PVOID)current + BLOCK_HDR_SIZE + size;
-   
+   end = (char*)current + BLOCK_HDR_SIZE + size;
+
    if (current_size >= size + BLOCK_HDR_SIZE + MM_POOL_ALIGNMENT)
      {
        /* create a new free block after our block, if the memory size is >= 4 byte for this block */
        next = (BLOCK_HDR*)((ULONG)current + size + BLOCK_HDR_SIZE);
        next_size = current_size - size - BLOCK_HDR_SIZE;
        current_size = size;
-       end = (PVOID)next + BLOCK_HDR_SIZE;
+       end = (char*)next + BLOCK_HDR_SIZE;
      }
 
    if (previous)
@@ -1400,7 +1412,7 @@ static BLOCK_HDR* get_block(unsigned int size, unsigned long alignment)
        if (next == NULL)
          {
           blk = (BLOCK_HDR*)((char*)current + BLOCK_HDR_SIZE + current->Size);
-          if ((PVOID)blk < MiNonPagedPoolStart + MiNonPagedPoolLength)
+          if ((char*)blk < (char*)MiNonPagedPoolStart + MiNonPagedPoolLength)
             {
               blk->previous = current;
             }
@@ -1433,7 +1445,7 @@ static BLOCK_HDR* get_block(unsigned int size, unsigned long alignment)
        next->Magic = BLOCK_HDR_FREE_MAGIC;
        next->previous = current;
        blk = (BLOCK_HDR*)((char*)next + BLOCK_HDR_SIZE + next->Size);
-       if ((PVOID)blk < MiNonPagedPoolStart + MiNonPagedPoolLength)
+       if ((char*)blk < (char*)MiNonPagedPoolStart + MiNonPagedPoolLength)
          {
           blk->previous = next;
         }
@@ -1484,7 +1496,7 @@ VOID STDCALL ExFreeNonPagedPool (PVOID block)
 
    DPRINT("freeing block %x\n",blk);
    
-   POOL_TRACE("ExFreePool(block %x), size %d, caller %x\n",block,blk->size,
+   POOL_TRACE("ExFreePool(block %x), size %d, caller %x\n",block,blk->Size,
             ((PULONG)&block)[-1]);
    
    KeAcquireSpinLock(&MmNpoolLock, &oldIrql);
@@ -1766,7 +1778,15 @@ MiInitializeNonPagedPool(VOID)
            KEBUGCHECK(0);
          }
        MiNonPagedPoolAllocMap[i / 32] |= (1 << (i % 32));
+#if defined(__GNUC__)
        Address += PAGE_SIZE;
+#else
+       {
+        char* pTemp = Address;
+        pTemp += PAGE_SIZE;
+        Address = pTemp;
+       }
+#endif
      }
    /* the first block contains the non paged pool bitmap */
    blk = (BLOCK_HDR*)MiNonPagedPoolStart;
@@ -1784,7 +1804,7 @@ MiInitializeNonPagedPool(VOID)
    /* the second block is the first free block */
    blk = (BLOCK_HDR*)((char*)blk + BLOCK_HDR_SIZE + blk->Size);
    memset(blk, 0, BLOCK_HDR_SIZE);
-   memset((PVOID)blk + BLOCK_HDR_SIZE, 0x0cc, MiNonPagedPoolNrOfPages * PAGE_SIZE - ((ULONG)blk + BLOCK_HDR_SIZE - (ULONG)MiNonPagedPoolStart));
+   memset((char*)blk + BLOCK_HDR_SIZE, 0x0cc, MiNonPagedPoolNrOfPages * PAGE_SIZE - ((ULONG)blk + BLOCK_HDR_SIZE - (ULONG)MiNonPagedPoolStart));
    blk->Magic = BLOCK_HDR_FREE_MAGIC;
    blk->Size = MiNonPagedPoolLength - ((ULONG)blk + BLOCK_HDR_SIZE - (ULONG)MiNonPagedPoolStart);
    blk->previous = (BLOCK_HDR*)MiNonPagedPoolStart;
index e2b738b..3200ec7 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: pagefile.c,v 1.40 2003/12/14 17:54:22 hbirr Exp $
+/* $Id: pagefile.c,v 1.41 2003/12/30 18:52:05 fireball Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/mm/pagefile.c
@@ -175,7 +175,14 @@ MmGetOffsetPageFile(PGET_RETRIEVAL_DESCRIPTOR RetrievalPointers, LARGE_INTEGER O
         }
      }
    KEBUGCHECK(0);
+#if defined(__GNUC__)
    return (LARGE_INTEGER)0LL;
+#else
+   {
+        const LARGE_INTEGER dummy = { 0 };
+        return dummy;
+   }
+#endif
 }
 
 NTSTATUS MmWriteToSwapPage(SWAPENTRY SwapEntry, PMDL Mdl)
@@ -497,7 +504,7 @@ MmDumpToPagingFile(ULONG BugCode,
   Headers->BugCheckParameters[3] = BugCodeParameter4;
   Headers->FaultingStackBase = (PVOID)Thread->Tcb.StackLimit;
   Headers->FaultingStackSize = StackSize =
-    (ULONG)(Thread->Tcb.StackBase - Thread->Tcb.StackLimit);
+    (ULONG)((char*)Thread->Tcb.StackBase - Thread->Tcb.StackLimit);
   Headers->PhysicalMemorySize = MmStats.NrTotalPages * PAGE_SIZE;
 
   /* Initialize the dump device. */
@@ -525,7 +532,14 @@ MmDumpToPagingFile(ULONG BugCode,
 
   /* Dump the header. */
   MdlMap[0] = MmGetPhysicalAddress(MmCoreDumpPageFrame).u.LowPart;
+#if defined(__GNUC__)
   DiskOffset = MmGetOffsetPageFile(RetrievalPointers, (LARGE_INTEGER)0LL);
+#else
+  {
+    const LARGE_INTEGER dummy = { 0 };
+    DiskOffset = MmGetOffsetPageFile(RetrievalPointers, dummy);
+  }
+#endif
   DiskOffset.QuadPart += MmCoreDumpLcnMapping.LcnDiskOffset.QuadPart;
   Status = MmCoreDumpFunctions->DumpWrite(DiskOffset, Mdl);
   if (!NT_SUCCESS(Status))
@@ -548,8 +562,16 @@ MmDumpToPagingFile(ULONG BugCode,
          MmCreateVirtualMappingDump(MmCoreDumpPageFrame,
                                     PAGE_READWRITE,
                                     PhysicalAddress);
+#if defined(__GNUC__)
          DiskOffset = MmGetOffsetPageFile(RetrievalPointers, 
                                           (LARGE_INTEGER)NextOffset);
+#else
+         {
+           LARGE_INTEGER dummy;
+           dummy.QuadPart = NextOffset;
+           DiskOffset = MmGetOffsetPageFile(RetrievalPointers, dummy);
+         }
+#endif
          DiskOffset.QuadPart += MmCoreDumpLcnMapping.LcnDiskOffset.QuadPart;
          Status = MmCoreDumpFunctions->DumpWrite(DiskOffset, Mdl);
          if (!NT_SUCCESS(Status))
@@ -789,9 +811,13 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
        return(STATUS_NO_MEMORY);
      }
 
+#if defined(__GNUC__)
    Vcn.QuadPart = 0LL;
+#else
+   Vcn.QuadPart = 0;
+#endif
    ExtentCount = 0;
-   MaxVcn = (InitialSize->QuadPart + BytesPerAllocationUnit - 1) / BytesPerAllocationUnit;
+   MaxVcn = (ULONG)((InitialSize->QuadPart + BytesPerAllocationUnit - 1) / BytesPerAllocationUnit);
    while(1)
      {
        Status = NtFsControlFile(FileHandle,
@@ -858,7 +884,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
    PagingFile->FileObject = FileObject;
    PagingFile->MaximumSize.QuadPart = MaximumSize->QuadPart;
    PagingFile->CurrentSize.QuadPart = InitialSize->QuadPart;
-   PagingFile->FreePages = InitialSize->QuadPart / PAGE_SIZE;
+   PagingFile->FreePages = (ULONG)(InitialSize->QuadPart / PAGE_SIZE);
    PagingFile->UsedPages = 0;
    KeInitializeSpinLock(&PagingFile->AllocMapLock);
    
index 8b0497c..5f0442a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: pool.c,v 1.25 2003/12/14 17:44:02 hbirr Exp $
+/* $Id: pool.c,v 1.26 2003/12/30 18:52:05 fireball Exp $
  * 
  * COPYRIGHT:    See COPYING in the top level directory
  * PROJECT:      ReactOS kernel
 
 /* FUNCTIONS ***************************************************************/
 
+#if defined(__GNUC__)
 PVOID STDCALL STATIC
+#else
+STATIC PVOID STDCALL
+#endif
 EiAllocatePool(POOL_TYPE PoolType,
               ULONG NumberOfBytes,
               ULONG Tag,
@@ -90,10 +94,19 @@ ExAllocatePool (POOL_TYPE PoolType, ULONG NumberOfBytes)
  */
 {
    PVOID Block;
+#if defined(__GNUC__)
    Block = EiAllocatePool(PoolType,
                          NumberOfBytes,
                          TAG_NONE,
                          (PVOID)__builtin_return_address(0));
+#elif defined(_MSC_VER)
+   Block = EiAllocatePool(PoolType,
+                         NumberOfBytes,
+                         TAG_NONE,
+                         &ExAllocatePool);
+#else
+#error Unknown compiler
+#endif
    return(Block);
 }
 
@@ -105,10 +118,19 @@ PVOID STDCALL
 ExAllocatePoolWithTag (ULONG PoolType, ULONG NumberOfBytes, ULONG Tag)
 {
    PVOID Block;
+#if defined(__GNUC__)
    Block = EiAllocatePool(PoolType,
                          NumberOfBytes,
                          Tag,
                          (PVOID)__builtin_return_address(0));
+#elif defined(_MSC_VER)
+   Block = EiAllocatePool(PoolType,
+                         NumberOfBytes,
+                         Tag,
+                         &ExAllocatePoolWithTag);
+#else
+#error Unknown compiler
+#endif
    return(Block);
 }
 
@@ -150,7 +172,7 @@ ExAllocatePoolWithQuotaTag (IN      POOL_TYPE       PoolType,
 VOID STDCALL
 ExFreePool(IN PVOID Block)
 {
-  if (Block >= MmPagedPoolBase && Block < (MmPagedPoolBase + MmPagedPoolSize))
+  if (Block >= MmPagedPoolBase && (char*)Block < ((char*)MmPagedPoolBase + MmPagedPoolSize))
     {
       ExFreePagedPool(Block);
     }
index d9c8faa..f316a65 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: ppool.c,v 1.23 2003/12/14 18:36:15 navaraf Exp $
+/* $Id: ppool.c,v 1.24 2003/12/30 18:52:05 fireball Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -26,7 +26,7 @@
 #undef assert
 #define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); KeBugCheck(0); }
 #define ASSERT_SIZE(n) assert ( (n) <= MmPagedPoolSize && (n) >= 0 )
-#define ASSERT_PTR(p) assert ( ((size_t)(p)) >= ((size_t)MmPagedPoolBase) && ((size_t)(p)) < ((size_t)(MmPagedPoolBase+MmPagedPoolSize)) )
+#define ASSERT_PTR(p) assert ( ((size_t)(p)) >= ((size_t)MmPagedPoolBase) && ((size_t)(p)) < ((size_t)((size_t)MmPagedPoolBase+MmPagedPoolSize)) )
 
 // to disable buffer over/under-run detection, set the following macro to 0
 #define MM_PPOOL_REDZONE_BYTES 4
@@ -221,10 +221,10 @@ ExAllocatePagedPoolWithTag (IN    POOL_TYPE       PoolType,
       while ( CurrentBlock != NULL )
        {
          PVOID Addr = block_to_address(CurrentBlock);
-         PVOID CurrentBlockEnd = (PVOID)CurrentBlock + CurrentBlock->Size;
+         PVOID CurrentBlockEnd = (char*)CurrentBlock + CurrentBlock->Size;
          /* calculate last size-aligned address available within this block */
-         PVOID AlignedAddr = MM_ROUND_DOWN(CurrentBlockEnd-NumberOfBytes-MM_PPOOL_REDZONE_BYTES, Alignment);
-         assert ( AlignedAddr+NumberOfBytes+MM_PPOOL_REDZONE_BYTES <= CurrentBlockEnd );
+         PVOID AlignedAddr = MM_ROUND_DOWN((char*)CurrentBlockEnd-NumberOfBytes-MM_PPOOL_REDZONE_BYTES, Alignment);
+         assert ( (char*)AlignedAddr+NumberOfBytes+MM_PPOOL_REDZONE_BYTES <= (char*)CurrentBlockEnd );
 
          /* special case, this address is already size-aligned, and the right size */
          if ( Addr == AlignedAddr )
@@ -265,7 +265,7 @@ ExAllocatePagedPoolWithTag (IN      POOL_TYPE       PoolType,
              PMM_PPOOL_FREE_BLOCK_HEADER NewFreeBlock =
                (PMM_PPOOL_FREE_BLOCK_HEADER)address_to_block(BestAlignedAddr);
              assert ( BestAlignedAddr > Addr );
-             NewFreeBlock->Size = Addr + BestBlock->Size - BestAlignedAddr;
+             NewFreeBlock->Size = (char*)Addr + BestBlock->Size - (char*)BestAlignedAddr;
              ASSERT_SIZE(NewFreeBlock->Size);
              BestBlock->Size = (size_t)NewFreeBlock - (size_t)Addr;
              ASSERT_SIZE(BestBlock->Size);
index ee57ca9..697158c 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: region.c,v 1.5 2003/01/02 16:41:56 hbirr Exp $
+/* $Id: region.c,v 1.6 2003/12/30 18:52:05 fireball Exp $
  *
  * PROJECT:     ReactOS kernel
  * FILE:        ntoskrnl/mm/region.c
@@ -86,7 +86,7 @@ MmSplitRegion(PMM_REGION InitialRegion, PVOID InitialBaseAddress,
     }
   NewRegion1->Type = NewType;
   NewRegion1->Protect = NewProtect;
-  InternalLength = (InitialBaseAddress + InitialRegion->Length) - StartAddress;
+  InternalLength = ((char*)InitialBaseAddress + InitialRegion->Length) - (char*)StartAddress;
   InternalLength = min(InternalLength, Length);
   NewRegion1->Length = InternalLength;
   InsertAfterEntry(&InitialRegion->RegionListEntry,
@@ -103,12 +103,12 @@ MmSplitRegion(PMM_REGION InitialRegion, PVOID InitialBaseAddress,
    * If necessary create a new region for the portion of the initial region
    * beyond the range of addresses to alter.
    */
-  if ((InitialBaseAddress + InitialRegion->Length) > (StartAddress + Length))
+  if (((char*)InitialBaseAddress + InitialRegion->Length) > ((char*)StartAddress + Length))
     {
       NewRegion2->Type = InitialRegion->Type;
       NewRegion2->Protect = InitialRegion->Protect;
-      NewRegion2->Length = (InitialBaseAddress + InitialRegion->Length) - 
-       (StartAddress + Length);
+      NewRegion2->Length = ((char*)InitialBaseAddress + InitialRegion->Length) - 
+       ((char*)StartAddress + Length);
       InsertAfterEntry(&NewRegion1->RegionListEntry, 
                       &NewRegion2->RegionListEntry);           
     }
@@ -125,7 +125,7 @@ MmSplitRegion(PMM_REGION InitialRegion, PVOID InitialBaseAddress,
     }
   else
     {
-      InitialRegion->Length = StartAddress - InitialBaseAddress;
+      InitialRegion->Length = (char*)StartAddress - (char*)InitialBaseAddress;
     }
   
   return(NewRegion1);
@@ -150,11 +150,11 @@ MmAlterRegion(PMADDRESS_SPACE AddressSpace, PVOID BaseAddress,
    */
   InitialRegion = MmFindRegion(BaseAddress, RegionListHead, StartAddress,
                               &InitialBaseAddress);
-  if ((StartAddress + Length) >
-      (InitialBaseAddress + InitialRegion->Length))
+  if (((char*)StartAddress + Length) >
+      ((char*)InitialBaseAddress + InitialRegion->Length))
     {
-      RemainingLength = (StartAddress + Length) - 
-       (InitialBaseAddress + InitialRegion->Length);
+      RemainingLength = ((char*)StartAddress + Length) - 
+       ((char*)InitialBaseAddress + InitialRegion->Length);
     }
   else
     {
@@ -185,7 +185,7 @@ MmAlterRegion(PMADDRESS_SPACE AddressSpace, PVOID BaseAddress,
   CurrentEntry = NewRegion->RegionListEntry.Flink;
   CurrentRegion = CONTAINING_RECORD(CurrentEntry, MM_REGION, 
                                    RegionListEntry);
-  CurrentBaseAddress = StartAddress + NewRegion->Length;
+  CurrentBaseAddress = (char*)StartAddress + NewRegion->Length;
   while (RemainingLength > 0 && CurrentRegion->Length <= RemainingLength)
     {
       if (CurrentRegion->Type != NewType &&
@@ -195,7 +195,15 @@ MmAlterRegion(PMADDRESS_SPACE AddressSpace, PVOID BaseAddress,
                    CurrentRegion->Type, CurrentRegion->Protect,
                    NewType, NewProtect);
        }
+#if defined(__GNUC__)
       CurrentBaseAddress += CurrentRegion->Length;
+#else
+      {
+       char* pTemp = CurrentBaseAddress;
+       pTemp += CurrentRegion->Length;
+       CurrentBaseAddress = pTemp;
+      }
+#endif
       NewRegion->Length += CurrentRegion->Length;
       RemainingLength -= CurrentRegion->Length;
       CurrentEntry = CurrentEntry->Flink;      
@@ -289,7 +297,7 @@ MmFindRegion(PVOID BaseAddress, PLIST_ENTRY RegionListHead, PVOID Address,
       current = CONTAINING_RECORD(current_entry, MM_REGION, RegionListEntry);
 
       if (StartAddress <= Address && 
-         (StartAddress + current->Length) > Address)
+         ((char*)StartAddress + current->Length) > (char*)Address)
        {
          if (RegionBaseAddress != NULL)
            {
@@ -299,7 +307,15 @@ MmFindRegion(PVOID BaseAddress, PLIST_ENTRY RegionListHead, PVOID Address,
        }
 
       current_entry = current_entry->Flink;
+#if defined(__GNUC__)
       StartAddress += current->Length;
+#else
+      {
+       char* pTemp = StartAddress;
+       pTemp += current->Length;
+       StartAddress = pTemp;
+      }
+#endif
     }
   return(NULL);
 }
index 28df758..f8f1ff7 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: rmap.c,v 1.25 2003/10/22 18:26:34 hbirr Exp $
+/* $Id: rmap.c,v 1.26 2003/12/30 18:52:05 fireball Exp $
  *
  * COPYRIGHT:   See COPYING in the top directory
  * PROJECT:     ReactOS kernel 
@@ -133,7 +133,7 @@ MmWritePagePhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress)
   Type = MemoryArea->Type;
   if (Type == MEMORY_AREA_SECTION_VIEW)
     {
-      Offset = (ULONG)(Address - (ULONG)MemoryArea->BaseAddress);
+      Offset = (ULONG)((char*)Address - (ULONG)MemoryArea->BaseAddress);
 
       /*
        * Get or create a pageop
@@ -271,7 +271,7 @@ MmPageOutPhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress)
   Type = MemoryArea->Type;
   if (Type == MEMORY_AREA_SECTION_VIEW)
     {
-      Offset = (ULONG)(Address - (ULONG)MemoryArea->BaseAddress);
+      Offset = (ULONG)((char*)Address - (ULONG)MemoryArea->BaseAddress);
 
       /*
        * Get or create a pageop
@@ -438,7 +438,7 @@ MmInsertRmap(PHYSICAL_ADDRESS PhysicalAddress, PEPROCESS Process,
       DPRINT1("Insert rmap (%d, 0x%.8X) 0x%.8X which doesn't match physical "
              "address 0x%.8X\n", Process->UniqueProcessId, Address, 
              MmGetPhysicalAddressForProcess(Process, Address).u.LowPart, 
-             PhysicalAddress.u.LowPart)
+             PhysicalAddress.u.LowPart);
       KEBUGCHECK(0);
     }
 
index 1ca8cd5..9c7e0c7 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: section.c,v 1.137 2003/12/21 19:12:19 navaraf Exp $
+/* $Id: section.c,v 1.138 2003/12/30 18:52:05 fireball Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/mm/section.c
@@ -40,6 +40,7 @@
 #include <ddk/ntifs.h>
 #include <ntos/minmax.h>
 #include <rosrtl/string.h>
+#include <reactos/bugcodes.h>
 
 #define NDEBUG
 #include <internal/debug.h>
@@ -78,6 +79,52 @@ static GENERIC_MAPPING MmpSectionMapping = {
 
 /* FUNCTIONS *****************************************************************/
 
+/* Note: Mmsp prefix denotes "Memory Manager Section Private". */
+
+/*
+ * FUNCTION:  Waits in kernel mode up to ten seconds for an MM_PAGEOP event.
+ * ARGUMENTS: PMM_PAGEOP which event we should wait for.
+ * RETURNS:   Status of the wait.
+ */
+static NTSTATUS
+MmspWaitForPageOpCompletionEvent(PMM_PAGEOP PageOp)
+{
+  LARGE_INTEGER Timeout;
+#ifdef __GNUC__ /* TODO: Use other macro to check for suffix to use? */
+  Timeout.QuadPart = -100000000LL;     // 10 sec
+#else
+  Timeout.QuadPart = -100000000;       // 10 sec
+#endif
+  return KeWaitForSingleObject(&PageOp->CompletionEvent, 0, KernelMode, FALSE, &Timeout);
+}
+
+
+/*
+ * FUNCTION:  Sets the page op completion event and releases the page op.
+ * ARGUMENTS: PMM_PAGEOP.
+ * RETURNS:   In shorter time than it takes you to even read this
+ *            description, so don't even think about geting a mug of coffee.
+ */
+static void
+MmspCompleteAndReleasePageOp(PMM_PAGEOP PageOp)
+{
+  KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
+  MmReleasePageOp(PageOp);
+}
+
+
+/*
+ * FUNCTION:  Waits in kernel mode indefinitely for a file object lock.
+ * ARGUMENTS: PFILE_OBJECT to wait for.
+ * RETURNS:   Status of the wait.
+ */
+static NTSTATUS
+MmspWaitForFileLock(PFILE_OBJECT File)
+{
+  return KeWaitForSingleObject(&File->Lock, 0, KernelMode, FALSE, NULL);
+}
+
+
 VOID
 MmFreePageTablesSectionSegment(PMM_SECTION_SEGMENT Segment)
 {
@@ -138,7 +185,7 @@ MmFreeSectionSegments(PFILE_OBJECT FileObject)
     }
 }
 
-VOID 
+VOID
 MmLockSectionSegment(PMM_SECTION_SEGMENT Segment)
 {
    ExAcquireFastMutex(&Segment->Lock);
@@ -150,7 +197,7 @@ MmUnlockSectionSegment(PMM_SECTION_SEGMENT Segment)
    ExReleaseFastMutex(&Segment->Lock);
 }
 
-VOID 
+VOID
 MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
                             ULONG Offset,
                             ULONG Entry)
@@ -169,7 +216,7 @@ MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
        Table = Segment->PageDirectory.PageTables[DirectoryOffset];
        if (Table == NULL)
          {
-          Table = 
+          Table =
            Segment->PageDirectory.PageTables[DirectoryOffset] =
             ExAllocatePoolWithTag(NonPagedPool, sizeof(SECTION_PAGE_TABLE),
                                   TAG_SECTION_PAGE_TABLE);
@@ -186,7 +233,7 @@ MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
 }
 
 
-ULONG 
+ULONG
 MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
                             ULONG Offset)
 {
@@ -194,9 +241,9 @@ MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
    ULONG Entry;
    ULONG DirectoryOffset;
    ULONG TableOffset;
-   
+
    DPRINT("MmGetPageEntrySection(Offset %x)\n", Offset);
-   
+
    if (Segment->Length <= NR_SECTION_PAGE_TABLES * PAGE_SIZE)
      {
        Table = (PSECTION_PAGE_TABLE)&Segment->PageDirectory;
@@ -266,7 +313,7 @@ MmUnsharePageEntrySectionSegment(PSECTION_OBJECT Section,
     }
   Entry = MAKE_SSE(PAGE_FROM_SSE(Entry), SHARE_COUNT_FROM_SSE(Entry) - 1);
   /*
-   * If we reducing the share count of this entry to zero then set the entry 
+   * If we reducing the share count of this entry to zero then set the entry
    * to zero and tell the cache the page is no longer mapped.
    */
   if (SHARE_COUNT_FROM_SSE(Entry) == 0)
@@ -279,10 +326,10 @@ MmUnsharePageEntrySectionSegment(PSECTION_OBJECT Section,
       ULONG FileOffset;
 
       FileOffset = Offset + Segment->FileOffset;
-   
+
       IsImageSection = Section->AllocationAttributes & SEC_IMAGE ? TRUE : FALSE;
-    
-      Page = (PHYSICAL_ADDRESS)(LONGLONG)PAGE_FROM_SSE(Entry);
+
+      Page.QuadPart = (LONGLONG)PAGE_FROM_SSE(Entry);
       FileObject = Section->FileObject;
       if (FileObject != NULL)
        {
@@ -307,11 +354,11 @@ MmUnsharePageEntrySectionSegment(PSECTION_OBJECT Section,
         {
          if (Segment->Flags & MM_PAGEFILE_SEGMENT)
             {
-             /* 
+             /*
               * FIXME:
-              *   Try to page out this page and set the swap entry 
+              *   Try to page out this page and set the swap entry
               *   within the section segment. There exist no rmap entry
-              *   for this page. The pager thread can't page out a 
+              *   for this page. The pager thread can't page out a
               *   page without a rmap entry.
               */
              MmSetPageEntrySectionSegment(Segment, Offset, Entry);
@@ -382,13 +429,13 @@ MiReadPage(PMEMORY_AREA MemoryArea,
   PBCB Bcb;
   BOOLEAN IsImageSection;
   ULONG Length;
+
   FileObject = MemoryArea->Data.SectionData.Section->FileObject;
   Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
   RawLength = MemoryArea->Data.SectionData.Segment->RawLength;
   FileOffset = SegOffset + MemoryArea->Data.SectionData.Segment->FileOffset;
   IsImageSection = MemoryArea->Data.SectionData.Section->AllocationAttributes & SEC_IMAGE ? TRUE : FALSE;
-  
+
   assert(Bcb);
 
   DPRINT("%S %x\n", FileObject->FileName.Buffer, FileOffset);
@@ -435,7 +482,7 @@ MiReadPage(PMEMORY_AREA MemoryArea,
       /*
        * Retrieve the page from the cache segment that we actually want.
        */
-      Addr = MmGetPhysicalAddress(BaseAddress +
+      Addr = MmGetPhysicalAddress((char*)BaseAddress +
                                  FileOffset - BaseOffset);
       (*Page) = Addr;
       MmReferencePage((*Page));
@@ -483,15 +530,15 @@ MiReadPage(PMEMORY_AREA MemoryArea,
       Length = RawLength - SegOffset;
       if (Length <= CacheSegOffset && Length <= PAGE_SIZE)
       {
-         memcpy(PageAddr, BaseAddress + FileOffset - BaseOffset, Length);
+         memcpy(PageAddr, (char*)BaseAddress + FileOffset - BaseOffset, Length);
       }
       else if (CacheSegOffset >= PAGE_SIZE)
       {
-         memcpy(PageAddr, BaseAddress + FileOffset - BaseOffset, PAGE_SIZE);
+         memcpy(PageAddr, (char*)BaseAddress + FileOffset - BaseOffset, PAGE_SIZE);
       }
       else
       {
-        memcpy(PageAddr, BaseAddress + FileOffset - BaseOffset, CacheSegOffset);
+        memcpy(PageAddr, (char*)BaseAddress + FileOffset - BaseOffset, CacheSegOffset);
          CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
         Status = CcRosGetCacheSegment(Bcb,
                                       FileOffset + CacheSegOffset,
@@ -520,11 +567,11 @@ MiReadPage(PMEMORY_AREA MemoryArea,
           }
          if (Length < PAGE_SIZE)
         {
-           memcpy(PageAddr + CacheSegOffset, BaseAddress, Length - CacheSegOffset);
+           memcpy((char*)PageAddr + CacheSegOffset, BaseAddress, Length - CacheSegOffset);
         }
         else
         {
-            memcpy(PageAddr + CacheSegOffset, BaseAddress, PAGE_SIZE - CacheSegOffset);
+            memcpy((char*)PageAddr + CacheSegOffset, BaseAddress, PAGE_SIZE - CacheSegOffset);
         }
       }
       CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
@@ -550,7 +597,6 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
    ULONG Attributes;
    PMM_PAGEOP PageOp;
    PMM_REGION Region;
-   LARGE_INTEGER Timeout;
 
    /*
     * There is a window between taking the page fault and locking the
@@ -562,17 +608,17 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
        if (Locked)
          {
            MmLockPage(MmGetPhysicalAddressForProcess(AddressSpace->Process, Address));
-         }  
+         }
        return(STATUS_SUCCESS);
      }
-   
+
    PAddress = (ULONG)PAGE_ROUND_DOWN(((ULONG)Address));
    Offset = PAddress - (ULONG)MemoryArea->BaseAddress;
-   
+
    Segment = MemoryArea->Data.SectionData.Segment;
    Section = MemoryArea->Data.SectionData.Section;
    Region = MmFindRegion(MemoryArea->BaseAddress,
-                        &MemoryArea->Data.SectionData.RegionListHead, 
+                        &MemoryArea->Data.SectionData.RegionListHead,
                         Address, NULL);
    /*
     * Lock the segment
@@ -592,7 +638,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
      {
        Attributes = Region->Protect;
      }
-   
+
    /*
     * Get or create a page operation descriptor
     */
@@ -611,13 +657,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
      {
        MmUnlockSectionSegment(Segment);
        MmUnlockAddressSpace(AddressSpace);
-       Timeout.QuadPart = -100000000LL;        // 10 sec
-       Status = KeWaitForSingleObject(&PageOp->CompletionEvent,
-                                     0,
-                                     KernelMode,
-                                     FALSE,
-                                     &Timeout);
-
+       Status = MmspWaitForPageOpCompletionEvent(PageOp);
        /*
        * Check for various strange conditions
        */
@@ -637,26 +677,24 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
        */
        if (PageOp->OpType != MM_PAGEOP_PAGEIN)
         {
-           KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-          MmReleasePageOp(PageOp);
+           MmspCompleteAndReleasePageOp(PageOp);
           DPRINT("Address 0x%.8X\n", Address);
           return(STATUS_MM_RESTART_OPERATION);
         }
-       
+
        /*
        * If the thread handling this fault has failed then we don't retry
        */
        if (!NT_SUCCESS(PageOp->Status))
         {
           Status = PageOp->Status;
-          KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-          MmReleasePageOp(PageOp);
+          MmspCompleteAndReleasePageOp(PageOp);
           DPRINT("Address 0x%.8X\n", Address);
           return(Status);
         }
        MmLockSectionSegment(Segment);
        /*
-       * If the completed fault was for another address space then set the 
+       * If the completed fault was for another address space then set the
        * page in this one.
        */
        if (!MmIsPagePresent(AddressSpace->Process, Address))
@@ -665,13 +703,12 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
           if (Entry == 0)
           {
                MmUnlockSectionSegment(Segment);
-                KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-               MmReleasePageOp(PageOp);
+                MmspCompleteAndReleasePageOp(PageOp);
                return(STATUS_MM_RESTART_OPERATION);
-          } 
+          }
 
-          Page = (LARGE_INTEGER)(LONGLONG)(PAGE_FROM_SSE(Entry));
-          MmReferencePage(Page);       
+          Page.QuadPart = (LONGLONG)(PAGE_FROM_SSE(Entry));
+          MmReferencePage(Page);
           MmSharePageEntrySectionSegment(Segment, Offset);
 
           Status = MmCreateVirtualMapping(MemoryArea->Process,
@@ -703,8 +740,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
         }
        MmUnlockSectionSegment(Segment);
        PageOp->Status = STATUS_SUCCESS;
-       KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-       MmReleasePageOp(PageOp);
+       MmspCompleteAndReleasePageOp(PageOp);
        DPRINT("Address 0x%.8X\n", Address);
        return(STATUS_SUCCESS);
      }
@@ -745,21 +781,21 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
           KEBUGCHECK(0);
         }
        MmLockAddressSpace(AddressSpace);
-       Status = MmCreateVirtualMapping(AddressSpace->Process,                
+       Status = MmCreateVirtualMapping(AddressSpace->Process,
                                       Address,
                                       Region->Protect,
                                       Page,
                                       FALSE);
        if (Status == STATUS_NO_MEMORY)
         {
-          MmUnlockAddressSpace(AddressSpace);     
+          MmUnlockAddressSpace(AddressSpace);
           Status = MmCreateVirtualMapping(AddressSpace->Process,
                                           Address,
                                           Region->Protect,
                                           Page,
                                           TRUE);
           MmLockAddressSpace(AddressSpace);
-        }  
+        }
        if (!NT_SUCCESS(Status))
         {
           DPRINT("MmCreateVirtualMapping failed, not out of memory\n");
@@ -771,22 +807,21 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
        * Store the swap entry for later use.
        */
        MmSetSavedSwapEntryPage(Page, SwapEntry);
-       
+
        /*
        * Add the page to the process's working set
        */
        MmInsertRmap(Page, AddressSpace->Process, (PVOID)PAddress);
-       
+
        /*
        * Finish the operation
        */
        if (Locked)
         {
           MmLockPage(MmGetPhysicalAddressForProcess(NULL, Address));
-        }  
+        }
        PageOp->Status = STATUS_SUCCESS;
-       KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-       MmReleasePageOp(PageOp);
+       MmspCompleteAndReleasePageOp(PageOp);
        DPRINT("Address 0x%.8X\n", Address);
        return(STATUS_SUCCESS);
      }
@@ -798,7 +833,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
      {
        MmUnlockSectionSegment(Segment);
        /*
-       * Just map the desired physical page 
+       * Just map the desired physical page
        */
        Page.QuadPart = Offset + MemoryArea->Data.SectionData.ViewOffset;
        Status = MmCreateVirtualMapping(AddressSpace->Process,
@@ -808,39 +843,38 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
                                       FALSE);
        if (Status == STATUS_NO_MEMORY)
         {
-          MmUnlockAddressSpace(AddressSpace);     
+          MmUnlockAddressSpace(AddressSpace);
           Status = MmCreateVirtualMapping(AddressSpace->Process,
                                           Address,
                                           Region->Protect,
                                           Page,
                                           TRUE);
           MmLockAddressSpace(AddressSpace);
-        }  
+        }
        if (!NT_SUCCESS(Status))
         {
           DPRINT("MmCreateVirtualMapping failed, not out of memory\n");
           KEBUGCHECK(0);
           return(Status);
         }
-       /* 
-        * Don't add an rmap entry since the page mapped could be for 
-       * anything. 
+       /*
+        * Don't add an rmap entry since the page mapped could be for
+       * anything.
        */
        if (Locked)
         {
           MmLockPage(Page);
-        }  
+        }
 
        /*
        * Cleanup and release locks
        */
        PageOp->Status = STATUS_SUCCESS;
-       KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-       MmReleasePageOp(PageOp);
+       MmspCompleteAndReleasePageOp(PageOp);
        DPRINT("Address 0x%.8X\n", Address);
        return(STATUS_SUCCESS);
      }
-   
+
    /*
     * Map anonymous memory for BSS sections
     */
@@ -850,7 +884,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
        Status = MmRequestPageMemoryConsumer(MC_USER, FALSE, &Page);
        if (!NT_SUCCESS(Status))
         {
-          MmUnlockAddressSpace(AddressSpace);     
+          MmUnlockAddressSpace(AddressSpace);
           Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
           MmLockAddressSpace(AddressSpace);
         }
@@ -865,14 +899,14 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
                                       FALSE);
        if (Status == STATUS_NO_MEMORY)
         {
-          MmUnlockAddressSpace(AddressSpace);     
+          MmUnlockAddressSpace(AddressSpace);
           Status = MmCreateVirtualMapping(AddressSpace->Process,
                                           Address,
                                           Region->Protect,
                                           Page,
                                           TRUE);
           MmLockAddressSpace(AddressSpace);
-        }  
+        }
 
        if (!NT_SUCCESS(Status))
         {
@@ -884,14 +918,13 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
        if (Locked)
         {
           MmLockPage(Page);
-        }  
+        }
 
        /*
        * Cleanup and release locks
        */
        PageOp->Status = STATUS_SUCCESS;
-       KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-       MmReleasePageOp(PageOp);
+       MmspCompleteAndReleasePageOp(PageOp);
        DPRINT("Address 0x%.8X\n", Address);
        return(STATUS_SUCCESS);
      }
@@ -900,9 +933,9 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
     * Get the entry corresponding to the offset within the section
     */
    Entry = MmGetPageEntrySectionSegment(Segment, Offset);
-   
+
    if (Entry == 0)
-     {   
+     {
        /*
        * If the entry is zero (and it can't change because we have
        * locked the segment) then we need to load the page.
@@ -914,7 +947,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
        MmUnlockSectionSegment(Segment);
        MmUnlockAddressSpace(AddressSpace);
 
-       if ((Segment->Flags & MM_PAGEFILE_SEGMENT) || 
+       if ((Segment->Flags & MM_PAGEFILE_SEGMENT) ||
           (Offset >= PAGE_ROUND_UP(Segment->RawLength) && Section->AllocationAttributes & SEC_IMAGE))
         {
           Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
@@ -941,8 +974,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
            */
           MmLockAddressSpace(AddressSpace);
           PageOp->Status = Status;
-          KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-          MmReleasePageOp(PageOp);
+          MmspCompleteAndReleasePageOp(PageOp);
            DPRINT("Address 0x%.8X\n", Address);
           return(Status);
         }
@@ -951,7 +983,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
        */
        MmLockAddressSpace(AddressSpace);
        MmLockSectionSegment(Segment);
-       
+
        /*
        * Check the entry. No one should change the status of a page
        * that has a pending page-in.
@@ -962,7 +994,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
           DbgPrint("Someone changed ppte entry while we slept\n");
           KEBUGCHECK(0);
         }
-       
+
        /*
        * Mark the offset within the section as having valid, in-memory
        * data
@@ -996,10 +1028,9 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
        if (Locked)
         {
           MmLockPage(Page);
-        }  
+        }
        PageOp->Status = STATUS_SUCCESS;
-       KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-       MmReleasePageOp(PageOp);
+       MmspCompleteAndReleasePageOp(PageOp);
        DPRINT("Address 0x%.8X\n", Address);
        return(STATUS_SUCCESS);
      }
@@ -1016,7 +1047,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
        MmUnlockSectionSegment(Segment);
 
        MmUnlockAddressSpace(AddressSpace);
-       
+
        Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
        if (!NT_SUCCESS(Status))
         {
@@ -1036,7 +1067,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
        */
        MmLockAddressSpace(AddressSpace);
        MmLockSectionSegment(Segment);
-       
+
        /*
        * Check the entry. No one should change the status of a page
        * that has a pending page-in.
@@ -1047,7 +1078,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
           DbgPrint("Someone changed ppte entry while we slept\n");
           KEBUGCHECK(0);
         }
-       
+
        /*
        * Mark the offset within the section as having valid, in-memory
        * data
@@ -1084,10 +1115,9 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
        if (Locked)
         {
           MmLockPage(Page);
-        }  
+        }
        PageOp->Status = STATUS_SUCCESS;
-       KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-       MmReleasePageOp(PageOp);
+       MmspCompleteAndReleasePageOp(PageOp);
        DPRINT("Address 0x%.8X\n", Address);
        return(STATUS_SUCCESS);
      }
@@ -1095,11 +1125,11 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
      {
        /*
         * If the section offset is already in-memory and valid then just
-       * take another reference to the page 
+       * take another reference to the page
        */
-       
-       Page = (LARGE_INTEGER)(LONGLONG)PAGE_FROM_SSE(Entry);
-       MmReferencePage(Page);  
+
+       Page.QuadPart = (LONGLONG)PAGE_FROM_SSE(Entry);
+       MmReferencePage(Page);
        MmSharePageEntrySectionSegment(Segment, Offset);
        MmUnlockSectionSegment(Segment);
 
@@ -1127,18 +1157,17 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
        if (Locked)
          {
            MmLockPage(Page);
-         }  
+         }
        PageOp->Status = STATUS_SUCCESS;
-       KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-       MmReleasePageOp(PageOp);
+       MmspCompleteAndReleasePageOp(PageOp);
        DPRINT("Address 0x%.8X\n", Address);
        return(STATUS_SUCCESS);
      }
 }
 
-NTSTATUS 
+NTSTATUS
 MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
-                        MEMORY_AREA* MemoryArea, 
+                        MEMORY_AREA* MemoryArea,
                         PVOID Address,
                         BOOLEAN Locked)
 {
@@ -1152,7 +1181,6 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
   ULONG Offset;
   PMM_PAGEOP PageOp;
   PMM_REGION Region;
-  LARGE_INTEGER Timeout;
 
   /*
    * Check if the page has been paged out or has already been set readwrite
@@ -1162,7 +1190,7 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
      {
        DPRINT("Address 0x%.8X\n", Address);
        return(STATUS_SUCCESS);
-     }  
+     }
 
    /*
     * Find the offset of the page
@@ -1217,12 +1245,7 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
    if (PageOp->Thread != PsGetCurrentThread())
      {
        MmUnlockAddressSpace(AddressSpace);
-       Timeout.QuadPart = -100000000LL;        // 10 sec
-       Status = KeWaitForSingleObject(&PageOp->CompletionEvent,
-                                     0,
-                                     KernelMode,
-                                     FALSE,
-                                     &Timeout);
+       Status = MmspWaitForPageOpCompletionEvent(PageOp);
        /*
        * Check for various strange conditions
        */
@@ -1240,8 +1263,7 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
        * Restart the operation
        */
        MmLockAddressSpace(AddressSpace);
-       KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-       MmReleasePageOp(PageOp);
+       MmspCompleteAndReleasePageOp(PageOp);
        DPRINT("Address 0x%.8X\n", Address);
        return(STATUS_MM_RESTART_OPERATION);
      }
@@ -1264,7 +1286,7 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
     * Copy the old page
     */
    OldPage = MmGetPhysicalAddressForProcess(NULL, Address);
+
    NewAddress = ExAllocatePageWithPhysPage(NewPage);
    memcpy(NewAddress, (PVOID)PAddress, PAGE_SIZE);
    ExUnmapPage(NewAddress);
@@ -1282,17 +1304,17 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
                                   Address,
                                   Region->Protect,
                                   NewPage,
-                                  FALSE);   
+                                  FALSE);
    if (Status == STATUS_NO_MEMORY)
      {
-       MmUnlockAddressSpace(AddressSpace);        
+       MmUnlockAddressSpace(AddressSpace);
        Status = MmCreateVirtualMapping(AddressSpace->Process,
                                       Address,
                                       Region->Protect,
                                       NewPage,
                                       TRUE);
        MmLockAddressSpace(AddressSpace);
-     }  
+     }
    if (!NT_SUCCESS(Status))
      {
        DPRINT("MmCreateVirtualMapping failed, not out of memory\n");
@@ -1307,8 +1329,9 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
      }
    if (Locked)
      {
+/*       MmUnlockPage(OldPage); */
        MmLockPage(NewPage);
-     }  
+     }
 
    /*
     * Unshare the old page.
@@ -1320,8 +1343,7 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
    MmReleasePageMemoryConsumer(MC_USER, OldPage);
 
    PageOp->Status = STATUS_SUCCESS;
-   KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-   MmReleasePageOp(PageOp);
+   MmspCompleteAndReleasePageOp(PageOp);
    DPRINT("Address 0x%.8X\n", Address);
    return(STATUS_SUCCESS);
 }
@@ -1356,7 +1378,7 @@ MmPageOutDeleteMapping(PVOID Context, PEPROCESS Process, PVOID Address)
 
 NTSTATUS
 MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
-                    MEMORY_AREA* MemoryArea, 
+                    MEMORY_AREA* MemoryArea,
                     PVOID Address,
                     PMM_PAGEOP PageOp)
 {
@@ -1380,7 +1402,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
   Context.Segment = MemoryArea->Data.SectionData.Segment;
   Context.Section = MemoryArea->Data.SectionData.Section;
 
-  Context.Offset = (ULONG)(Address - (ULONG)MemoryArea->BaseAddress);
+  Context.Offset = (ULONG)((char*)Address - (ULONG)MemoryArea->BaseAddress);
   FileOffset = Context.Offset + Context.Segment->FileOffset;
 
   IsImageSection = Context.Section->AllocationAttributes & SEC_IMAGE ? TRUE : FALSE;
@@ -1390,7 +1412,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
   if (FileObject != NULL)
     {
       Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
-  
+
       /*
        * If the file system is letting us go directly to the cache and the
        * memory area was mapped at an offset in the file which is page aligned
@@ -1403,7 +1425,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
          DirectMapped = TRUE;
        }
     }
-   
+
 
   /*
    * This should never happen since mappings of physical memory are never
@@ -1412,7 +1434,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
   if (Context.Section->AllocationAttributes & SEC_PHYSICALMEMORY)
     {
       DPRINT1("Trying to page out from physical memory section address 0x%X "
-             "process %d\n", Address, 
+             "process %d\n", Address,
              AddressSpace->Process ? AddressSpace->Process->UniqueProcessId : 0);
       KEBUGCHECK(0);
     }
@@ -1427,7 +1449,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
          AddressSpace->Process ? AddressSpace->Process->UniqueProcessId : 0, Address);
       KEBUGCHECK(0);
     }
-  PhysicalAddress = 
+  PhysicalAddress =
     MmGetPhysicalAddressForProcess(AddressSpace->Process, Address);
   SwapEntry = MmGetSavedSwapEntryPage(PhysicalAddress);
 
@@ -1436,7 +1458,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
    */
   Context.WasDirty = FALSE;
   if (Context.Segment->Characteristics & IMAGE_SECTION_CHAR_BSS ||
-      IS_SWAP_FROM_SSE(Entry) || 
+      IS_SWAP_FROM_SSE(Entry) ||
       (LONGLONG)PAGE_FROM_SSE(Entry) != PhysicalAddress.QuadPart)
     {
       Context.Private = TRUE;
@@ -1457,7 +1479,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
       if (SwapEntry != 0)
        {
          DPRINT1("SwapEntry != 0 was 0x%.8X at address 0x%.8X, "
-                 "paddress 0x%.8X\n", SwapEntry, Address, 
+                 "paddress 0x%.8X\n", SwapEntry, Address,
                  PhysicalAddress);
          KEBUGCHECK(0);
        }
@@ -1470,11 +1492,11 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
          DPRINT1("Had private copy of read-only page.\n");
          KEBUGCHECK(0);
        }
-      
+
       /*
        * Delete all mappings of this page.
        */
-      MmDeleteAllRmaps(PhysicalAddress, (PVOID)&Context, 
+      MmDeleteAllRmaps(PhysicalAddress, (PVOID)&Context,
                       MmPageOutDeleteMapping);
       if (Context.WasDirty)
        {
@@ -1483,8 +1505,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
        }
 
       PageOp->Status = STATUS_SUCCESS;
-      KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-      MmReleasePageOp(PageOp);
+      MmspCompleteAndReleasePageOp(PageOp);
       return(STATUS_SUCCESS);
     }
 
@@ -1499,7 +1520,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
     {
       if(!MiIsPageFromCache(MemoryArea, Context.Offset))
         {
-         DPRINT1("Direct mapped non private page is not associated with the cache.\n")
+         DPRINT1("Direct mapped non private page is not associated with the cache.\n");;
           KEBUGCHECK(0);
         }
     }
@@ -1509,7 +1530,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
     }
 
   MmDeleteAllRmaps(PhysicalAddress, (PVOID)&Context, MmPageOutDeleteMapping);
-  
+
   /*
    * If this wasn't a private page then we should have reduced the entry to
    * zero by deleting all the rmaps.
@@ -1526,14 +1547,14 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
   /*
    * If the page wasn't dirty then we can just free it as for a readonly page.
    * Since we unmapped all the mappings above we know it will not suddenly
-   * become dirty. 
-   * If the page is from a pagefile section and has no swap entry, 
+   * become dirty.
+   * If the page is from a pagefile section and has no swap entry,
    * we can't free the page at this point.
    */
   SwapEntry = MmGetSavedSwapEntryPage(PhysicalAddress);
-  if (!Context.WasDirty && 
+  if (!Context.WasDirty &&
       !(SwapEntry == 0 && Context.Segment->Flags & MM_PAGEFILE_SEGMENT))
-      
+
     {
       if (Context.Private)
        {
@@ -1543,7 +1564,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
              DPRINT1("Private page, non-dirty but not swapped out "
                      "process %d address 0x%.8X\n",
                      AddressSpace->Process ? AddressSpace->Process->UniqueProcessId : 0,
-                     Address);       
+                     Address);
              KEBUGCHECK(0);
            }
          else
@@ -1574,10 +1595,9 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
         {
           MmReleasePageMemoryConsumer(MC_USER, PhysicalAddress);
        }
-      
+
       PageOp->Status = STATUS_SUCCESS;
-      KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-      MmReleasePageOp(PageOp);
+      MmspCompleteAndReleasePageOp(PageOp);
       return(STATUS_SUCCESS);
     }
 
@@ -1595,8 +1615,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
           KEBUGCHECK(0);
        }
       PageOp->Status = STATUS_SUCCESS;
-      KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-      MmReleasePageOp(PageOp);
+      MmspCompleteAndReleasePageOp(PageOp);
       return(STATUS_SUCCESS);
     }
 
@@ -1615,13 +1634,13 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
           */
          if (Context.Private)
            {
-             Status = MmCreateVirtualMapping(MemoryArea->Process,   
+             Status = MmCreateVirtualMapping(MemoryArea->Process,
                                              Address,
                                              MemoryArea->Attributes,
                                              PhysicalAddress,
                                              FALSE);
              MmSetDirtyPage(MemoryArea->Process, Address);
-             MmInsertRmap(PhysicalAddress, 
+             MmInsertRmap(PhysicalAddress,
                           MemoryArea->Process,
                           Address);
            }
@@ -1629,24 +1648,23 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
            {
              /*
               * For non-private pages if the page wasn't direct mapped then
-              * set it back into the section segment entry so we don't loose 
+              * set it back into the section segment entry so we don't loose
               * our copy. Otherwise it will be handled by the cache manager.
               */
-             Status = MmCreateVirtua