[CMAKE]
authorSylvain Petreolle <spetreolle@yahoo.fr>
Fri, 26 Nov 2010 23:33:34 +0000 (23:33 +0000)
committerSylvain Petreolle <spetreolle@yahoo.fr>
Fri, 26 Nov 2010 23:33:34 +0000 (23:33 +0000)
Sync with trunk. (r49792)

svn path=/branches/cmake-bringup/; revision=49803

111 files changed:
base/applications/rapps/rapps/7zip.txt
base/applications/rapps/rapps/libreoffice.txt
base/applications/rapps/rapps/mirandaim.txt
base/applications/rapps/rapps/mono2.txt
base/applications/rapps/rapps/openttd.txt
base/system/services/rpcserver.c
boot/CMakeLists.txt
boot/armllb/boot.s
boot/armllb/crtsupp.c
boot/armllb/envir.c
boot/armllb/fw.c
boot/armllb/hw/matrix.c [new file with mode: 0755]
boot/armllb/hw/omap3-beagle/hwinfo.c [new file with mode: 0755]
boot/armllb/hw/omap3-beagle/hwinit.c [moved from boot/armllb/hw/omap3/hwinit.c with 78% similarity]
boot/armllb/hw/omap3-beagle/hwuart.c [new file with mode: 0755]
boot/armllb/hw/omap3-zoom2/hwinfo.c [new file with mode: 0755]
boot/armllb/hw/omap3-zoom2/hwinit.c [new file with mode: 0755]
boot/armllb/hw/omap3-zoom2/hwlcd.c [new file with mode: 0755]
boot/armllb/hw/omap3-zoom2/hwsynkp.c [new file with mode: 0755]
boot/armllb/hw/omap3-zoom2/hwtwl40x.c [new file with mode: 0755]
boot/armllb/hw/omap3-zoom2/hwuart.c [new file with mode: 0755]
boot/armllb/hw/omap3/hwinfo.c [deleted file]
boot/armllb/hw/time.c
boot/armllb/hw/video.c
boot/armllb/inc/envir.h
boot/armllb/inc/keyboard.h
boot/armllb/inc/machtype.h
boot/armllb/inc/omap3.h [new file with mode: 0755]
boot/armllb/inc/precomp.h
boot/armllb/main.c
boot/armllb/os/loader.c
boot/freeldr/freeldr/arch/arm/boot.s
boot/freeldr/freeldr/arch/arm/macharm.c
boot/freeldr/freeldr/freeldr_arm.lnk [new file with mode: 0644]
boot/freeldr/freeldr/include/keycodes.h
boot/freeldr/freeldr/mm/mm.c
boot/freeldr/freeldr/rtl/bget.c
boot/freeldr/freeldr/windows/arm/wlmemory.c
boot/freeldr/freeldr/windows/conversion.c
boot/freeldr/freeldr/windows/winldr.c
boot/freeldr/freeldr/windows/wlregistry.c
dll/ntdll/ldr/utils.c
dll/win32/gdi32/objects/coord.c
dll/win32/gdi32/objects/dc.c
dll/win32/kernel32/file/npipe.c
drivers/filesystems/npfs/create.c
drivers/filesystems/npfs/fsctrl.c
drivers/filesystems/npfs/npfs.c
drivers/filesystems/npfs/npfs.h
hal/halarm/omap3/halinit_up.c [new file with mode: 0644]
hal/halarm/omap3/halup.rbuild [new file with mode: 0644]
hal/halarm/omap3/halup.rc [new file with mode: 0644]
include/crt/mingw32/intrin_arm.h
include/crt/setjmp.h
include/crt/stddef.h
include/ddk/wdm.h
include/ndk/arm/ketypes.h
include/ndk/arm/mmtypes.h
include/ndk/umfuncs.h
include/psdk/specstrings.h [new file with mode: 0644]
include/psdk/windef.h
include/psdk/winnt.h
include/reactos/arm/armddk.h
include/reactos/wine/exception.h
lib/sdk/crt/misc/assert.c
ntoskrnl/fsrtl/dbcsname.c
ntoskrnl/fsrtl/filtrctx.c
ntoskrnl/fsrtl/name.c
ntoskrnl/include/internal/arm/kxarm.h
ntoskrnl/include/internal/arm/mm.h
ntoskrnl/include/internal/fsrtl.h
ntoskrnl/include/internal/i386/mm.h
ntoskrnl/include/internal/io.h
ntoskrnl/include/internal/mm.h
ntoskrnl/include/internal/ntoskrnl.h
ntoskrnl/io/iomgr/controller.c
ntoskrnl/io/iomgr/file.c
ntoskrnl/ke/arm/boot.s
ntoskrnl/ke/arm/cpu.c
ntoskrnl/ke/arm/ctxswtch.s
ntoskrnl/ke/arm/thrdini.c
ntoskrnl/ke/arm/trapc.c
ntoskrnl/mm/ARM3/arm/init.c
ntoskrnl/mm/ARM3/mdlsup.c
ntoskrnl/mm/ARM3/miarm.h
ntoskrnl/mm/ARM3/mminit.c
ntoskrnl/mm/ARM3/pagfault.c
ntoskrnl/mm/ARM3/pool.c
ntoskrnl/mm/ARM3/procsup.c
ntoskrnl/mm/ARM3/section.c
ntoskrnl/mm/ARM3/virtual.c
ntoskrnl/mm/amd64/init.c
ntoskrnl/mm/arm/page.c
ntoskrnl/mm/arm/stubs.c
ntoskrnl/mm/pagefile.c
ntoskrnl/ntoskrnl.spec
ntoskrnl/po/power.c
subsystems/win32/win32k/include/msgqueue.h
subsystems/win32/win32k/include/winpos.h
subsystems/win32/win32k/ntuser/clipboard.c
subsystems/win32/win32k/ntuser/cursoricon.c
subsystems/win32/win32k/ntuser/desktop.c
subsystems/win32/win32k/ntuser/input.c
subsystems/win32/win32k/ntuser/menu.c
subsystems/win32/win32k/ntuser/message.c
subsystems/win32/win32k/ntuser/msgqueue.c
subsystems/win32/win32k/ntuser/ntstubs.c
subsystems/win32/win32k/ntuser/window.c
subsystems/win32/win32k/ntuser/winpos.c
subsystems/win32/win32k/ntuser/winsta.c
subsystems/win32/win32k/pch.h

index fb070f7..e5e8df8 100644 (file)
@@ -2,13 +2,13 @@
 
 [Section]
 Name = 7-Zip
-Version = 4.65
+Version = 9.20
 Licence = LGPL
 Description = Utility to create and open 7zip, zip, tar, rar and other archive files.
-Size = 0.9M
+Size = 1.0M
 Category = 12
 URLSite = http://www.7-zip.org/
-URLDownload = http://ovh.dl.sourceforge.net/project/sevenzip/7-Zip/4.65/7z465.exe
+URLDownload = http://ovh.dl.sourceforge.net/project/sevenzip/7-Zip/9.20/7z920.exe
 CDPath = none
 
 [Section.0407]
index f9d6959..65ae3c3 100644 (file)
@@ -2,13 +2,13 @@
 
 [Section]
 Name = LibreOffice
-Version = 3.3.0 Beta 2
+Version = 3.3.0 Beta 3
 Licence = LGPL
 Description = Former called OpenOffice. Open Source Office Suite.
-Size = 318.0MB
+Size = 300.0MB
 Category = 6
 URLSite = http://www.documentfoundation.org/
-URLDownload = http://download.documentfoundation.org/libreoffice/testing/3.3.0-beta2/win/x86/LibO_3.3.0_beta2_Win_x86_install_multi.exe
+URLDownload = http://download.documentfoundation.org/libreoffice/testing/3.3.0-beta3/win/x86/LibO_3.3.0_Win_x86_install_multi.exe
 CDPath = none
 
 [Section.0407]
index 0073737..d7a4180 100644 (file)
@@ -2,13 +2,13 @@
 
 [Section]
 Name = Miranda IM
-Version = 0.9.10
+Version = 0.9.11
 Licence = GPL
 Description = Open source multiprotocol instant messaging application - May not work completely.
 Size = 3.0MB
 Category = 5
 URLSite = http://www.miranda-im.org/
-URLDownload = http://miranda.googlecode.com/files/miranda-im-v0.9.10-unicode.exe
+URLDownload = http://miranda.googlecode.com/files/miranda-im-v0.9.11-unicode.exe
 CDPath = none
 
 [Section.0407]
index c766941..5911b62 100644 (file)
@@ -2,13 +2,13 @@
 
 [Section]
 Name = Mono .net Development Framework
-Version = 2.8
+Version = 2.8.1
 Licence = Unknown
 Description = Open Source .net Framework.
-Size = 78MB
+Size = 77MB
 Category = 14
 URLSite = http://www.mono-project.com/Main_Page
-URLDownload = http://ftp.novell.com/pub/mono/archive/2.8/windows-installer/9/mono-2.8-gtksharp-2.12.10-win32-9.exe
+URLDownload = http://ftp.novell.com/pub/mono/archive/2.8.1/windows-installer/3/mono-2.8.1-gtksharp-2.12.10-win32-3.exe
 CDPath = none
 
 [Section.0415]
index 9f038ff..43d5738 100644 (file)
@@ -2,13 +2,13 @@
 
 [Section]
 Name = OpenTTD
-Version = 1.0.4
+Version = 1.0.5
 Licence = GPL v2
 Description = Open Source clone of the "Transport Tycoon Deluxe" game engine. You need a copy of Transport Tycoon.
 Size = 3.4MB
 Category = 4
 URLSite = http://www.openttd.org/
-URLDownload = http://cz.binaries.openttd.org/openttd/binaries/releases/1.0.4/openttd-1.0.4-windows-win32.exe
+URLDownload = http://cz.binaries.openttd.org/openttd/binaries/releases/1.0.5/openttd-1.0.5-windows-win32.exe
 CDPath = none
 
 [Section.0407]
index 28bce05..ad3e460 100644 (file)
@@ -834,8 +834,8 @@ DWORD RQueryServiceObjectSecurity(
         return ERROR_INVALID_HANDLE;
     }
 
-    if (dwSecurityInformation & (DACL_SECURITY_INFORMATION ||
-                                 GROUP_SECURITY_INFORMATION ||
+    if (dwSecurityInformation & (DACL_SECURITY_INFORMATION |
+                                 GROUP_SECURITY_INFORMATION |
                                  OWNER_SECURITY_INFORMATION))
         DesiredAccess |= READ_CONTROL;
 
index 78bc3d7..29dc28e 100644 (file)
@@ -9,6 +9,12 @@ CreateBootSectorTarget(isobtrt ${CMAKE_CURRENT_SOURCE_DIR}/freeldr/bootsect/isob
 include_directories(BEFORE freeldr/freeldr/include)
 include_directories(${REACTOS_SOURCE_DIR}/ntoskrnl/include)
 
+if(ARCH MATCHES arm)
+    if(SARCH MATCHES omap-zoom2)
+        add_definitions(-D_ZOOM2_)
+    endif()    
+endif()
+
 if(ARCH MATCHES i386)
 if(MSVC)
 list(APPEND FREELDR_BASE64K_SOURCE
@@ -90,7 +96,6 @@ list(APPEND FREELDR_BASE_SOURCE
     freeldr/freeldr/video/palette.c
     freeldr/freeldr/video/video.c
     freeldr/freeldr/windows/conversion.c
-    freeldr/freeldr/windows/headless.c
     freeldr/freeldr/windows/peloader.c
     freeldr/freeldr/windows/winldr.c
     freeldr/freeldr/windows/wlmemory.c
@@ -105,7 +110,9 @@ list(APPEND FREELDR_BASE_SOURCE
     freeldr/freeldr/oslist.c)
 
 if(ARCH MATCHES i386)
-list(APPEND FREELDR_BASE_SOURCE freeldr/freeldr/disk/scsiport.c)
+list(APPEND FREELDR_BASE_SOURCE
+    freeldr/freeldr/windows/headless.c
+    freeldr/freeldr/disk/scsiport.c)
 endif(ARCH MATCHES i386)
 
 set_source_files_properties(${FREELDR_BASE_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_;_BLDR_;_NTSYSTEM_")
index 505ae84..899013f 100644 (file)
     NESTED_ENTRY _start
     PROLOG_END _start
     
-#ifdef _OMAP3_
+#ifdef _BEAGLE_ // This is only used for TI BootROM on Beagle/Emulator for now
     /*
-     * On OMAP3, the boot is directly from TI BootROM that reads NAND flash.
+     * On Beagle, the boot is directly from TI BootROM that reads NAND flash.
      * First word is size of program to load.
      * Second word is load address of program. Since DDR is not initialized,
      * we load to SDRAM at 40200000h. Max 64K.
      */
     .word 0x8000
     .word 0x40200000
+#elif _ZOOM2_
+       /*
+        * On ZOOM2, we currently load from u-boot to make bring-up easier.
+        *
+        * In order to get ATAG and all that goodness, we have to fool u-boot into
+        * thinking we are a Linux ARM kernel.
+        *
+        * So this is a 'fake' uImage-format header, which will make u-boot grok our
+        * image and correctly execute it.
+        *
+        * Note that a data checksum is in the header, but thankfully we can disable
+        * the check.
+        *
+        * There's also a header checksum, but as long as there's no need to modify
+        * this header, we can leave it static.
+        *
+        * Finally, note that the "Image String" is sized as a 32-byte array in the
+        * uImage header format. The string chosen below is not only accurate, but
+        * also happens to fit exactly in 32 bytes, meaning we don't need to pad.
+        */
+       .word 0x56190527 // Header Magic
+       .word 0x5E4B8444 // Checksum
+       .word 0x483BE54C // Timestamp
+       .word 0x0CA10000 // Image size (64K)
+       .word 0x00000081 // Load address
+       .word 0x40000081 // Entrypoint
+       .word 0x90873DD8 // Data Checksum ('setenv verify n' must be set!)
+       .byte 5                  // Linux OS
+       .byte 2                  // ARM
+       .byte 2                  // Kernel
+       .byte 0                  // No compression
+       .ascii "ReactOS ARM Low-Level Bootloader" 
 #endif
 
     /* Load C entrypoint and setup LLB stack */
     ENTRY_END _start
 
 L_BootStackEnd:
+#ifdef _BEAGLE_ // This is only used for TI BootROM on Beagle/Emulator for now
     .long 0x00010000
-        
+#elif _ZOOM2_ // On ZOOM2 RAM starts at 0x80000000, not 0
+       .long 0x81014000
+#else
+#error Stack Address Not Defined
+#endif
+
 L_LlbStartup:
     .long LlbStartup
 
index ba2dde3..f535a17 100644 (file)
@@ -40,7 +40,7 @@ int printf(const char *fmt, ...)
     return puts(printbuffer);
 }
 
-VOID
+ULONG
 DbgPrint(const char *fmt, ...)
 {
     va_list args;
@@ -52,6 +52,7 @@ DbgPrint(const char *fmt, ...)
     va_end(args);
     
     for (j = 0; j < i; j++) LlbSerialPutChar(Buffer[j]);
+    return 0;
 }
 
 /* EOF */
index 31ec2a5..0b1c451 100644 (file)
@@ -9,10 +9,11 @@
 #include "precomp.h"
 
 ULONG LlbEnvHwPageSize;
-ULONG LlbEnvHwMemStart;
-ULONG LlbEnvHwMemSize;
-ULONG LlbEnvRamDiskStart;
-ULONG LlbEnvRamDiskSize;
+ULONG LlbEnvHwMemStart = 0;
+ULONG LlbEnvHwMemSize = 0;
+ULONG LlbEnvRamDiskStart = 0;
+ULONG LlbEnvRamDiskSize = 0;
+ULONG LlbEnvHwRevision;
 CHAR LlbEnvCmdLine[256];
 CHAR LlbValueData[32];
     
@@ -35,11 +36,17 @@ LlbEnvParseArguments(IN PATAG Arguments)
                 LlbEnvHwPageSize = Atag->u.Core.PageSize;
                 break;
                 
+            case ATAG_REVISION:
+
+                /* Save page size */
+                LlbEnvHwRevision = Atag->u.Revision.Rev;
+                break;
+                
             case ATAG_MEM:
             
                 /* Save RAM start and size */
-                LlbEnvHwMemStart = Atag->u.Mem.Start;
-                LlbEnvHwMemSize = Atag->u.Mem.Size;
+                if (!LlbEnvHwMemStart) LlbEnvHwMemStart = Atag->u.Mem.Start;
+                LlbEnvHwMemSize += Atag->u.Mem.Size;
                 break;
                 
             case ATAG_INITRD2:
@@ -48,6 +55,7 @@ LlbEnvParseArguments(IN PATAG Arguments)
                 LlbEnvRamDiskStart = Atag->u.InitRd2.Start;
                 LlbEnvRamDiskSize = Atag->u.InitRd2.Size;
                 
+#ifdef _BEAGLE_
                 /* Make sure it's 16MB-aligned */
                 LlbEnvRamDiskSize = (LlbEnvRamDiskSize + (16 * 1024 * 1024) - 1) 
                                     &~ ((16 * 1024 * 1024) - 1);
@@ -55,6 +63,7 @@ LlbEnvParseArguments(IN PATAG Arguments)
                 /* The RAMDISK actually starts 16MB later */
                 LlbEnvRamDiskStart += 16 * 1024 * 1024;
                 LlbEnvRamDiskSize  -= 16 * 1024 * 1024;
+#endif
                 break;
                 
             case ATAG_CMDLINE:
@@ -68,7 +77,7 @@ LlbEnvParseArguments(IN PATAG Arguments)
             /* Nothing left to handle */
             case ATAG_NONE:
             default:
-                return;
+                break;
         }
         
         /* Next tag */
@@ -76,8 +85,11 @@ LlbEnvParseArguments(IN PATAG Arguments)
     }
     
     /* For debugging */
-    DbgPrint("[BOOTROM] PageSize: %dKB RAM: %dMB CMDLINE: %s\n",
-             LlbEnvHwPageSize / 1024, LlbEnvHwMemSize / 1024 / 1024, LlbEnvCmdLine);
+    DbgPrint("[BOOTROM] Board Revision: %lx PageSize: %dKB RAM: %dMB CMDLINE: %s\n"
+             "[RAMDISK] Base: %lx Size: %dMB\n",
+             LlbEnvHwRevision,
+             LlbEnvHwPageSize / 1024, LlbEnvHwMemSize / 1024 / 1024, LlbEnvCmdLine,
+             LlbEnvRamDiskStart, LlbEnvRamDiskSize / 1024 / 1024);
 }
 
 VOID
index 4286b4a..8831d95 100644 (file)
@@ -49,7 +49,11 @@ INT
 LlbFwGetCh(VOID)
 {
     /* Return the key pressed */
+#ifdef _ZOOM2_
+    return LlbKeypadGetChar();
+#else
     return LlbKeyboardGetChar();
+#endif
 }
 
 ULONG
diff --git a/boot/armllb/hw/matrix.c b/boot/armllb/hw/matrix.c
new file mode 100755 (executable)
index 0000000..c1275c2
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/armllb/hw/matrix.c
+ * PURPOSE:         LLB Matrix Keypad Routines
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+#include "precomp.h"
+
+/* SYNPATICS KEYPAD MATRIX ****************************************************/
+
+UCHAR KeyMatrix[8][8] =
+{
+    {'e', 'r', 't', KEY_HOME, 0, 0, 'i', KEY_LEFTSHIFT},
+    {'d', 'f', 'g', KEY_SEND, 0, 0, 'k', KEY_ENTER},
+    {'x', 'c', 'v', KEY_END, 0, 0, '.', KEY_CAPS_LOCK},
+    {'z', '+', 'b', KEY_F1, 0, 0, 'o', KEY_SPACE},
+    {'w', 'y', 'u', KEY_F2, 0, 0, 'l', KEY_LEFT},
+    {'s', 'h', 'j', KEY_F3, 0, 0, 'm', KEY_RIGHT},
+    {'q', 'a', 'n', KEY_BACKSPACE, 0, 0, 'p', KEY_UP},
+    {0, 0, 0, 0, 0, 0, KEY_ENTER, KEY_DOWN}
+};
+
+/* FUNCTIONS ******************************************************************/
+CHAR
+NTAPI
+LlbKeypadGetChar(VOID)
+{
+    UCHAR ScanCode;
+    UCHAR Col, Row;
+    
+    ScanCode = LlbHwKbdRead();
+    Col = ScanCode >> 4;
+    Row = ScanCode & 0xF;
+    
+    /* Return the ASCII character */
+    return KeyMatrix[Col][Row];
+}
+
+/* EOF */
diff --git a/boot/armllb/hw/omap3-beagle/hwinfo.c b/boot/armllb/hw/omap3-beagle/hwinfo.c
new file mode 100755 (executable)
index 0000000..8a7d5b5
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/armllb/hw/omap3-beagle/hwinfo.c
+ * PURPOSE:         LLB Hardware Info Routines for OMAP3 Beagle
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+#include "precomp.h"
+
+ULONG
+NTAPI
+LlbHwGetBoardType(VOID)
+{
+    return MACH_TYPE_OMAP3_BEAGLE;
+}
+
+ULONG
+NTAPI
+LlbHwGetPClk(VOID)
+{
+    return 48000000;
+}
+
+ULONG
+NTAPI
+LlbHwGetTmr0Base(VOID)
+{
+    return 0x48318000;
+}
+
+ULONG
+NTAPI
+LlbHwGetSerialUart(VOID)
+{
+    return 3;
+} 
+
+VOID
+NTAPI
+LlbHwKbdSend(IN ULONG Value)
+{
+
+}
+
+BOOLEAN
+NTAPI
+LlbHwKbdReady(VOID)
+{
+    return FALSE;
+}
+
+INT
+NTAPI
+LlbHwKbdRead(VOID)
+{
+    return 0;
+}
+
+ULONG
+NTAPI
+LlbHwGetScreenWidth(VOID)
+{
+    return 1280;
+}
+
+ULONG
+NTAPI
+LlbHwGetScreenHeight(VOID)
+{
+     return 720;
+}
+PVOID
+NTAPI
+LlbHwGetFrameBuffer(VOID)
+{
+    return (PVOID)0x80500000;
+}
+
+ULONG
+NTAPI
+LlbHwVideoCreateColor(IN ULONG Red,
+                      IN ULONG Green,
+                      IN ULONG Blue)
+{
+    return 0;
+}
+
+
+//
+// OMAP3 Memory Map
+//
+BIOS_MEMORY_MAP LlbHwOmap3MemoryMap[] =
+{
+    {0, 0, 0, 0}
+};
+
+VOID
+NTAPI
+LlbHwBuildMemoryMap(IN PBIOS_MEMORY_MAP MemoryMap)
+{
+    PBIOS_MEMORY_MAP MapEntry;
+    ULONG Base, Size, FsBase, FsSize;
+    
+    /* Parse hardware memory map */
+    MapEntry = LlbHwOmap3MemoryMap;
+    while (MapEntry->Length)
+    {
+        /* Add this entry */
+        LlbAllocateMemoryEntry(MapEntry->Type, MapEntry->BaseAddress, MapEntry->Length);
+        
+        /* Move to the next one */
+        MapEntry++;
+    }
+    
+    /* Query memory and RAMDISK information */
+    LlbEnvGetMemoryInformation(&Base, &Size);
+    LlbEnvGetRamDiskInformation(&FsBase, &FsSize);
+    
+    /* Add-in the size of the ramdisk */
+    Base = FsBase + FsSize;
+    
+    /* Subtract size of ramdisk and anything else before it */
+    Size -= Base;
+    
+    /* Allocate an entry for it */
+    LlbAllocateMemoryEntry(BiosMemoryUsable, Base, Size);
+}
+
+ULONG
+LlbHwRtcRead(VOID)
+{
+    return 0;
+}
+
+/* EOF */
similarity index 78%
rename from boot/armllb/hw/omap3/hwinit.c
rename to boot/armllb/hw/omap3-beagle/hwinit.c
index 85ee055..4c7c0c9 100755 (executable)
@@ -1,8 +1,8 @@
 /*
  * PROJECT:         ReactOS Boot Loader
  * LICENSE:         BSD - See COPYING.ARM in the top level directory
- * FILE:            boot/armllb/hw/omap3/hwinit.c
- * PURPOSE:         LLB Hardware Initialization Routines for OMAP3
+ * FILE:            boot/armllb/hw/omap3-beagle/hwinit.c
+ * PURPOSE:         LLB Hardware Initialization Routines for OMAP3 Beagle
  * PROGRAMMERS:     ReactOS Portable Systems Group
  */
 
@@ -12,7 +12,7 @@ VOID
 NTAPI
 LlbHwInitialize(VOID)
 {
-    
+    while (TRUE);
 }
 
 /* EOF */
diff --git a/boot/armllb/hw/omap3-beagle/hwuart.c b/boot/armllb/hw/omap3-beagle/hwuart.c
new file mode 100755 (executable)
index 0000000..7f8669c
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/armllb/hw/omap3-beagle/hwuart.c
+ * PURPOSE:         LLB UART Initialization Routines for OMAP3 Beagle
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+#include "precomp.h"
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+NTAPI
+LlbHwOmap3UartInitialize(VOID)
+{
+
+}
+
+VOID
+NTAPI
+LlbHwUartSendChar(IN CHAR Char)
+{
+
+}
+
+BOOLEAN
+NTAPI
+LlbHwUartTxReady(VOID)
+{
+    return FALSE;
+}
+
+ULONG
+NTAPI
+LlbHwGetUartBase(IN ULONG Port)
+{
+    if (Port == 1)
+    {
+        return 0x4806A000;
+    }
+    else if (Port == 2)
+    {
+        return 0x4806C000;        
+    }
+    else if (Port == 3)
+    {
+        return 0x49020000;        
+    }
+    
+    return 0;
+}
+
+/* EOF */
diff --git a/boot/armllb/hw/omap3-zoom2/hwinfo.c b/boot/armllb/hw/omap3-zoom2/hwinfo.c
new file mode 100755 (executable)
index 0000000..3fd7edc
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/armllb/hw/omap3-zoom2/hwuart.c
+ * PURPOSE:         LLB Hardware Info Routines for OMAP3 ZOOM2
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+#include "precomp.h"
+
+TIMEINFO LlbTime;
+
+#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))
+
+ULONG
+NTAPI
+LlbHwGetBoardType(VOID)
+{
+    return MACH_TYPE_OMAP_ZOOM2;
+}
+
+ULONG
+NTAPI
+LlbHwGetPClk(VOID)
+{
+    return 48000000;
+}
+
+ULONG
+NTAPI
+LlbHwGetTmr0Base(VOID)
+{
+    return 0x48318000;
+}
+
+ULONG
+NTAPI
+LlbHwGetSerialUart(VOID)
+{
+    return 0;
+} 
+
+ULONG
+LlbHwRtcRead(VOID)
+{
+    /* Issue the GET_TIME request on the RTC control register */
+    LlbHwOmap3TwlWrite1(0x4B, 0x29, 0x41);
+    
+    /* Read the BCD registers and convert them */
+    LlbTime.Second = BCD_INT(LlbHwOmap3TwlRead1(0x4B, 0x1C));
+    LlbTime.Minute = BCD_INT(LlbHwOmap3TwlRead1(0x4B, 0x1D));
+    LlbTime.Hour = BCD_INT(LlbHwOmap3TwlRead1(0x4B, 0x1E));
+    LlbTime.Day = BCD_INT(LlbHwOmap3TwlRead1(0x4B, 0x1F));
+    LlbTime.Month = BCD_INT(LlbHwOmap3TwlRead1(0x4B, 0x20));
+    LlbTime.Year = BCD_INT(LlbHwOmap3TwlRead1(0x4B, 0x21));
+    LlbTime.Year += (LlbTime.Year > 80) ? 1900 : 2000;
+    return 0;
+}
+
+/* EOF */
diff --git a/boot/armllb/hw/omap3-zoom2/hwinit.c b/boot/armllb/hw/omap3-zoom2/hwinit.c
new file mode 100755 (executable)
index 0000000..37749a6
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/armllb/hw/omap3-zoom2/hwinit.c
+ * PURPOSE:         LLB UART Initialization Routines for OMAP3 ZOOM2
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+#include "precomp.h"
+
+//
+// OMAP3 Memory Map
+//
+// 0x00000000 - 0x3FFFFFFF GPMC                                     [  1 GB]
+// 0x40000000 - 0x47FFFFFF On-Chip Memory (ROM/SRAM Address Space)  [128 MB]
+// 0x48000000 - 0x4FFFFFFF L4 Interconnects (All system peripherals)[128 MB]
+// 0x50000000 - 0x53FFFFFF SGX Graphics Accelerator Slave Port      [ 64 MB]
+// 0x54000000 - 0x57FFFFFF L4 Emulation                             [128 MB]
+// 0x58000000 - 0x58FFFFFF Reserved                                 [ 64 MB]
+// 0x5C000000 - 0x5FFFFFFF IVA2.2 Subsystem                         [ 64 MB]
+// 0x60000000 - 0x67FFFFFF Reserved                                 [128 MB]
+// 0x68000000 - 0x6FFFFFFF L3 Interconnect (Control Registers)      [128 MB]
+// 0x70000000 - 0x7FFFFFFF SDRC/SMS Virtual Address Space 0         [256 MB]
+// 0x80000000 - 0x9FFFFFFF SDRC/SMS CS0 SDRAM                       [512 MB]
+    // 0x80000000 - 0x80FFFFFF KERNEL, HAL, BOOT DRIVERS            [ 16 MB]
+// THIS IS THE x86-STYLE "LOW 1MB" THAT IS IDENTITY MAPPED
+    // 0x81000000 - 0x8100FFFF ARM LLB                              [ 64 KB]
+    // 0x81010000 - 0x81013FFF ARM BOOT STACK                       [ 16 KB]
+    // 0x81014000 - 0x81073FFF ARM FRAMEBUFFER                      [384 KB]
+    // 0x81070000 - 0x81093FFF ARM OS LOADER                        [128 KB]
+    // 0x81094000 - 0x810FFFFF RESERVED FOR BOOT LOADER EXPANSION   [432 KB]
+// END OF THE x86-STYLE "LOW 1MB" THAT IS IDENTITY MAPPED
+    // 0x81100000 - 0x8FFFFFFF FREE RAM                             [ 15 MB]
+    // 0x82000000 - 0x83FFFFFF ARM RAMDISK                          [ 32 MB]
+    // 0x84000000 - 0x8FFFFFFF FREE RAM                             [192 MB]
+    // 0x90000000 - 0x9FFFFFFF FREE RAM IF > 256MB INSTALLED        [256 MB]
+// 0xA0000000 - 0xBFFFFFFF SDRC/SMS CS1 SDRAM                       [512 MB]
+    // 0xA0000000 - 0xAFFFFFFF FREE RAM IF > 512MB INSTALLED        [256 MB]
+    // 0xB0000000 - 0xBFFFFFFF FREE RAM IF > 768MB INSTALLED        [256 MB]
+// 0xC0000000 - 0xDFFFFFFF Reserved                                 [512 MB]
+// 0xE0000000 - 0xFFFFFFFF SDRC/SMS Virtual Address Space 1         [512 MB]
+BIOS_MEMORY_MAP LlbHwOmap3MemoryMap[] =
+{
+    {0x00000000, 0x80000000, BiosMemoryReserved,   0}, /* Device Registers */
+    {0x80000000, 0x01000000, BiosMemoryUsable,     0}, /* 16 MB RAM for Kernel map */
+    {0x81000000, 0x00010000, BiosMemoryBootLoader, 0}, /* Arm LLB */
+    {0x81010000, 0x00004000, BiosMemoryBootStrap,  0}, // LLB Stack
+    {0x81014000, 0x00060000, BiosMemoryBootLoader, 0}, /* Kernel Framebuffer */
+    {0x81070000, 0x00020000, BiosMemoryBootStrap,  0}, /* ARM OS Loader */
+    {0x81094000, 0x0006C000, BiosMemoryBootStrap,  0}, /* ARM OS Loader Expansion */
+    {0x81100000, 0x00F00000, BiosMemoryUsable,     0}, /* 15 MB Free RAM */
+    {0x82000000, 0x02000000, BiosMemoryBootStrap,  0}, /* 32MB RAMDISK */
+    {0x84000000, 0x0C000000, BiosMemoryUsable,     0}, /* 192 MB Free RAM */
+    {0x90000000, 0x70000000, BiosMemoryReserved,   0},
+    {0, 0, 0, 0}
+};
+
+VOID
+NTAPI
+LlbHwBuildMemoryMap(IN PBIOS_MEMORY_MAP MemoryMap)
+{
+    PBIOS_MEMORY_MAP MapEntry;
+    ULONG Base, Size, FsBase, FsSize;
+    
+    /* Parse hardware memory map */
+    MapEntry = LlbHwOmap3MemoryMap;
+    while (MapEntry->Length)
+    {
+        /* Add this entry */
+        LlbAllocateMemoryEntry(MapEntry->Type, MapEntry->BaseAddress, MapEntry->Length);
+        
+        /* Move to the next one */
+        MapEntry++;
+    }
+    
+    /* Query memory and RAMDISK information */
+    LlbEnvGetMemoryInformation(&Base, &Size);
+    LlbEnvGetRamDiskInformation(&FsBase, &FsSize);
+    if (!FsSize) return;
+#ifdef _BEAGLE_
+    /* Add-in the size of the ramdisk */
+    Base = FsBase + FsSize;
+    
+    /* Subtract size of ramdisk and anything else before it */
+    Size -= Base;
+    
+    /* Allocate an entry for it */
+    LlbAllocateMemoryEntry(BiosMemoryUsable, Base, Size);
+#endif
+}
+
+VOID
+NTAPI
+LlbHwInitialize(VOID)
+{
+    /* Setup the UART (NS16550) */
+    LlbHwOmap3UartInitialize();
+    
+    /* Setup the NEC WVGA LCD Panel and the Display Controller */
+    LlbHwOmap3LcdInitialize();
+    
+    /* Setup the keyboard */
+    LlbHwOmap3SynKpdInitialize();
+}
+
+/* EOF */
diff --git a/boot/armllb/hw/omap3-zoom2/hwlcd.c b/boot/armllb/hw/omap3-zoom2/hwlcd.c
new file mode 100755 (executable)
index 0000000..4b7dae2
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/armllb/hw/omap3-zoom2/hwlcd.c
+ * PURPOSE:         LLB LCD Routines for OMAP3 ZOOM2
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+#include "precomp.h"
+
+PUSHORT LlbHwVideoBuffer;
+
+VOID
+NTAPI
+LlbHwOmap3LcdInitialize(VOID)
+{
+    /*
+     * N.B. The following initialization sequence took about 12 months to figure
+     *      out.
+     *      This means if you are glancing at it and have no idea what on Earth
+     *      could possibly be going on, this is *normal*.
+     *      Just trust that this turns on the LCD.
+     *      And be thankful all you ever have to worry about is Java and HTML.
+     */
+
+    /* Turn on the functional and interface clocks in the entire PER domain */
+    WRITE_REGISTER_ULONG(0x48005000, 0x3ffff);  /* Functional clocks */
+    WRITE_REGISTER_ULONG(0x48005010, 0x3ffff);  /* Interface clocks */
+
+    /* Now that GPIO Module 3 is on, send a reset to the LCD panel on GPIO 96 */
+    WRITE_REGISTER_ULONG(0x49054034, 0);             /* FIXME: Enable all as output */
+    WRITE_REGISTER_ULONG(0x49054094, 0xffffffff);    /* FIXME: Output on all gpios */
+
+    /* Now turn on the functional and interface clocks in the CORE domain */
+    WRITE_REGISTER_ULONG(0x48004a00, 0x03fffe29); /* Functional clocks */
+    WRITE_REGISTER_ULONG(0x48004a10, 0x3ffffffb); /* Interface clocks */
+    
+    /* The HS I2C interface is now on, configure it */
+    WRITE_REGISTER_USHORT(0x48070024, 0x0);    /* Disable I2c */
+    WRITE_REGISTER_USHORT(0x48070030, 0x17);   /* Configure clock divider */
+    WRITE_REGISTER_USHORT(0x48070034, 0xd);    /* Configure clock scaler */
+    WRITE_REGISTER_USHORT(0x48070038, 0xf);    /* Configure clock scaler */
+    WRITE_REGISTER_USHORT(0x48070020, 0x215);  /* Configure clocks and idle */
+    WRITE_REGISTER_USHORT(0x4807000c, 0x636f); /* Select wakeup bits */
+    WRITE_REGISTER_USHORT(0x48070014, 0x4343); /* Disable DMA */
+    WRITE_REGISTER_USHORT(0x48070024, 0x8000); /* Enable I2C */
+    
+    /*
+     * Set the VPLL2 to cover all device groups instead of just P3.
+     * This essentially enables the VRRTC to power up the LCD panel.
+     */
+    LlbHwOmap3TwlWrite1(0x4B, 0x8E, 0xE0);
+
+    /* VPLL2 runs at 1.2V by default, so we need to reprogram to 1.8V for DVI */
+    LlbHwOmap3TwlWrite1(0x4B, 0x91, 0x05);
+
+    /* Set GPIO pin 7 on the TWL4030 as an output pin */
+    LlbHwOmap3TwlWrite1(0x49, 0x9B, 0x80);
+
+    /* Set GPIO pin 7 signal on the TWL4030 ON. This powers the LCD backlight */
+    LlbHwOmap3TwlWrite1(0x49, 0xA4, 0x80);
+   
+    /* Now go on the McSPI interface and program it on for the channel */
+    WRITE_REGISTER_ULONG(0x48098010, 0x15);
+    WRITE_REGISTER_ULONG(0x48098020, 0x1);
+    WRITE_REGISTER_ULONG(0x48098028, 0x1);
+    WRITE_REGISTER_ULONG(0x4809802c, 0x112fdc);
+
+    /* Send the reset signal (R2 = 00h) to the NEC WVGA LCD Panel */
+    WRITE_REGISTER_ULONG(0x48098034, 0x1);
+    WRITE_REGISTER_ULONG(0x48098038, 0x20100);
+    WRITE_REGISTER_ULONG(0x48098034, 0x0);
+
+    /* Turn on the functional and interface clocks in the DSS domain */
+    WRITE_REGISTER_ULONG(0x48004e00, 0x5);
+    WRITE_REGISTER_ULONG(0x48004e10, 0x1);
+
+    /* Reset the Display Controller (DISPC) */
+    WRITE_REGISTER_ULONG(0x48050410, 0x00000005); // DISPC_SYSCONFIG
+    
+    /* Set the frame buffer address */
+       WRITE_REGISTER_ULONG(0x48050480, 0x800A0000); // DISPC_GFX_BA0
+
+       /* Set resolution and RGB16 color mode */
+       WRITE_REGISTER_ULONG(0x4805048c, 0x01df031f); // DISPC_GFX_SIZE
+       WRITE_REGISTER_ULONG(0x480504a0, 0x0000000d); // DISPC_GFX_ATTRIBUTES
+
+    /* Set LCD timings (VSync and HSync), pixel clock, and LCD size */
+       WRITE_REGISTER_ULONG(0x4805046c, 0x00003000); // DISPC_POL_FREQ
+       WRITE_REGISTER_ULONG(0x48050470, 0x00010004); // DISPC_DIVISOR
+       WRITE_REGISTER_ULONG(0x48050464, 0x00300500); // DISPC_TIMING_H
+       WRITE_REGISTER_ULONG(0x48050468, 0x00400300); // DISPC_TIMING_V
+       WRITE_REGISTER_ULONG(0x4805047c, 0x01df031f); // DISPC_SIZE_LCD
+
+    /* Turn the LCD on */
+       WRITE_REGISTER_ULONG(0x48050440, 0x00018309); // DISPC_CONTROL
+}
+
+ULONG
+NTAPI
+LlbHwGetScreenWidth(VOID)
+{
+    return 800;
+}
+ULONG
+NTAPI
+LlbHwGetScreenHeight(VOID)
+{
+    return 480;
+}
+
+PVOID
+NTAPI
+LlbHwGetFrameBuffer(VOID)
+{
+    return (PVOID)0x800A0000;
+}
+
+ULONG
+NTAPI
+LlbHwVideoCreateColor(IN ULONG Red,
+                      IN ULONG Green,
+                      IN ULONG Blue)
+{
+    return (((Red >> 3) << 11)| ((Green >> 2) << 5)| ((Blue >> 3) << 0));
+}
+
+/* EOF */
diff --git a/boot/armllb/hw/omap3-zoom2/hwsynkp.c b/boot/armllb/hw/omap3-zoom2/hwsynkp.c
new file mode 100755 (executable)
index 0000000..39ccdcd
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/armllb/hw/omap3-zoom2/hwsynkpd.c
+ * PURPOSE:         LLB Synpatics Keypad Support for OMAP3 ZOOM 2
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+#include "precomp.h"
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+NTAPI
+LlbHwOmap3SynKpdInitialize(VOID)
+{
+    /* Set GPIO pin 8 on the TWL4030 as an output pin */
+    LlbHwOmap3TwlWrite1(0x49, 0x9B, 0xC0);
+
+    /* Set GPIO pin 8 signal on the TWL4030 ON. This powers the keypad backlight */
+    LlbHwOmap3TwlWrite1(0x49, 0xA4, 0xC0);
+    
+    /* Set PENDDIS and COR on the the keypad interrupt controller */
+    LlbHwOmap3TwlWrite1(0x4A, 0xE9, 0x06);
+
+    /* Only falling edge detection for key pressed */
+    LlbHwOmap3TwlWrite1(0x4A, 0xE8, 0x01);
+    
+    /* Unmask key-pressed events */
+    LlbHwOmap3TwlWrite1(0x4A, 0xE4, 0x0E);
+
+    /* Set the keypad control register to turn hardware sequencing and turn it on */
+    LlbHwOmap3TwlWrite1(0x4A, 0xD2, 0x0);
+    LlbHwOmap3TwlRead1(0x4A, 0xE3);
+    LlbHwOmap3TwlWrite1(0x4A, 0xD2, 0x43);
+}
+
+UCHAR KeyboardMatrixStatus[8];
+BOOLEAN LastState = FALSE;
+
+BOOLEAN
+NTAPI
+LlbHwKbdReady(VOID)
+{
+    UCHAR Value;
+
+    Value = LlbHwOmap3TwlRead1(0x4A, 0xE3);
+    if (!Value) return FALSE;
+    
+    LastState ^= 1;
+    if (!LastState) return FALSE;
+    
+    /* Return whether or not an interrupt is pending */
+    return TRUE;
+}
+
+INT
+NTAPI
+LlbHwKbdRead(VOID)
+{
+    UCHAR ActiveCol = 0, ActiveRow = 0, col, coldata, row;
+    
+    for (col = 0; col < 8; col++)
+    {
+        coldata = LlbHwOmap3TwlRead1(0x4A, 0xDB + col);
+        if (coldata)
+        {
+            for (row = 0; row < 8; row++)
+            {
+                if (coldata == (1 << row))
+                {
+                    ActiveRow = row;
+                    ActiveCol = col;
+                    break;
+                }
+            }
+        }
+    }
+    
+    return ((ActiveCol << 4) | ActiveRow);
+}
+
+/* EOF */
diff --git a/boot/armllb/hw/omap3-zoom2/hwtwl40x.c b/boot/armllb/hw/omap3-zoom2/hwtwl40x.c
new file mode 100755 (executable)
index 0000000..faca517
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/armllb/hw/omap3-zoom2/hwsynkpd.c
+ * PURPOSE:         LLB Synpatics Keypad Support for OMAP3 ZOOM 2
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+#include "precomp.h"
+
+/* FUNCTIONS ******************************************************************/
+
+UCHAR
+NTAPI
+LlbHwOmap3TwlRead1(IN UCHAR ChipAddress,
+                   IN UCHAR RegisterAddress)
+{
+    volatile int i = 1000;
+        
+    /* Select the register */
+    LlbHwOmap3TwlWrite(ChipAddress, RegisterAddress, 0, NULL);
+
+    /* Now read it */
+    WRITE_REGISTER_USHORT(0x48070024, 0x8401);
+    for (i = 1000; i > 0; i--);
+    return READ_REGISTER_USHORT(0x4807001c);
+}
+
+VOID
+NTAPI
+LlbHwOmap3TwlWrite(IN UCHAR ChipAddress,
+                   IN UCHAR RegisterAddress,
+                   IN UCHAR Length,
+                   IN PUCHAR Values)
+{
+    volatile int i = 1000;
+    ULONG j;
+
+    /* Select chip address */
+    WRITE_REGISTER_USHORT(0x4807002c, ChipAddress);
+    WRITE_REGISTER_USHORT(0x48070018, Length + 1);
+
+    /* Enable master transmit mode */
+    WRITE_REGISTER_USHORT(0x48070024, 0x8601);
+    WRITE_REGISTER_USHORT(0x4807001c, RegisterAddress);
+    
+    /* Loop each byte */
+    for (j = 0; j < Length; j++)
+    {
+        /* Write the data */
+        WRITE_REGISTER_USHORT(0x4807001c, Values[j]);
+    }
+
+    /* Issue stop command */
+    WRITE_REGISTER_USHORT(0x48070024, 0x8602);
+    for (i = 1000; i > 0; i--);
+}
+
+VOID
+NTAPI
+LlbHwOmap3TwlWrite1(IN UCHAR ChipAddress,
+                    IN UCHAR RegisterAddress,
+                    IN UCHAR Value)
+{
+    /* Do the actual write */
+    LlbHwOmap3TwlWrite(ChipAddress, RegisterAddress, 1, &Value);
+}
+
+/* EOF */
diff --git a/boot/armllb/hw/omap3-zoom2/hwuart.c b/boot/armllb/hw/omap3-zoom2/hwuart.c
new file mode 100755 (executable)
index 0000000..52143dd
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/armllb/hw/omap3-zoom2/hwuart.c
+ * PURPOSE:         LLB UART Initialization Routines for OMAP3 ZOOM2
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+#include "precomp.h"
+#define SERIAL_REGISTER_STRIDE 2
+#include "lib/cportlib/cport.c"
+
+/* GLOBALS ********************************************************************/
+
+#define SERIAL_TL16CP754C_QUAD0_BASE (PVOID)0x10000000
+
+CPPORT LlbHwOmap3UartPorts[4] =
+{
+    {NULL, 0, 0},
+    {NULL, 0, 0},
+    {NULL, 0, 0},
+    {NULL, 0, 0}
+};
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+NTAPI
+LlbHwOmap3UartInitialize(VOID)
+{
+    CpInitialize(&LlbHwOmap3UartPorts[0], SERIAL_TL16CP754C_QUAD0_BASE, 115200);
+}
+
+VOID
+NTAPI
+LlbHwUartSendChar(IN CHAR Char)
+{
+    /* Send the character */
+    CpPutByte(&LlbHwOmap3UartPorts[0], Char);
+}
+
+BOOLEAN
+NTAPI
+LlbHwUartTxReady(VOID)
+{
+    /* TX output buffer is ready? */
+    return TRUE;
+}
+
+ULONG
+NTAPI
+LlbHwGetUartBase(IN ULONG Port)
+{
+    if (Port == 0)
+    {
+        return 0x10000000;
+    }
+    
+    return 0;
+}
+
+/* EOF */
diff --git a/boot/armllb/hw/omap3/hwinfo.c b/boot/armllb/hw/omap3/hwinfo.c
deleted file mode 100755 (executable)
index a1bd1cd..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * PROJECT:         ReactOS Boot Loader
- * LICENSE:         BSD - See COPYING.ARM in the top level directory
- * FILE:            boot/armllb/hw/omap3/hwinfo.c
- * PURPOSE:         LLB Hardware Info Routines for OMAP3
- * PROGRAMMERS:     ReactOS Portable Systems Group
- */
-
-#include "precomp.h"
-
-ULONG
-NTAPI
-LlbHwGetScreenWidth(VOID)
-{
-    return 1280;
-}
-
-ULONG
-NTAPI
-LlbHwGetScreenHeight(VOID)
-{
-     return 720;
-}
-PVOID
-NTAPI
-LlbHwGetFrameBuffer(VOID)
-{
-    return (PVOID)0x80500000;
-}
-
-ULONG
-NTAPI
-LlbHwGetBoardType(VOID)
-{
-    return MACH_TYPE_OMAP3_BEAGLE;
-}
-
-ULONG
-NTAPI
-LlbHwGetPClk(VOID)
-{
-    return 48000000;
-}
-
-ULONG
-NTAPI
-LlbHwGetTmr0Base(VOID)
-{
-    return 0x48318000;
-}
-
-ULONG
-NTAPI
-LlbHwGetUartBase(IN ULONG Port)
-{
-    if (Port == 1)
-    {
-        return 0x4806A000;
-    }
-    else if (Port == 2)
-    {
-        return 0x4806C000;        
-    }
-    else if (Port == 3)
-    {
-        return 0x49020000;        
-    }
-}
-
-ULONG
-NTAPI
-LlbHwGetSerialUart(VOID)
-{
-    return 3;
-} 
-
-/* EOF */
index f37be24..ed78ea4 100755 (executable)
 #define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400)
 
 UCHAR LlbDaysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+
+#ifndef _ZOOM2_
 TIMEINFO LlbTime;
+#else
+extern TIMEINFO LlbTime;
+#endif
 
 BOOLEAN
 NTAPI
@@ -82,9 +87,10 @@ LlbGetTime(VOID)
 
     /* Read RTC time */
     RtcTime = LlbHwRtcRead();
-
+#ifndef _ZOOM2_
     /* Convert it */
     LlbConvertRtcTime(RtcTime, &LlbTime);
+#endif
     return &LlbTime;
 }
 
index 3e3179a..2ee37eb 100644 (file)
@@ -326,7 +326,11 @@ LlbVideoClearScreen(IN BOOLEAN OsLoader)
     else
     {
         /* Deep blue */
+#ifdef BLUE_SCREEN
         BackColor = LlbHwVideoCreateColor(14, 0, 82);
+#else
+        BackColor = LlbHwVideoCreateColor(0, 0, 0);
+#endif
         BackColor = (BackColor << 16) | BackColor;
     }
     
@@ -346,8 +350,12 @@ LlbVideoPutChar(IN UCHAR c)
 {
     ULONG cx, cy, CharsPerLine, BackColor, ScreenWidth;
     
-    /* Forecolor on this machine */
-    BackColor = LlbHwVideoCreateColor(14, 0, 82);
+    /* Backcolor on this machine */
+#ifdef BLUE_SCREEN
+      BackColor = LlbHwVideoCreateColor(14, 0, 82);
+#else
+      BackColor = LlbHwVideoCreateColor(0, 0, 0);
+#endif
     
     /* Amount of characters in a line */
     ScreenWidth = LlbHwGetScreenWidth();
index 590f32f..f3b52fb 100755 (executable)
@@ -25,6 +25,11 @@ typedef struct _ATAG_MEM
     ULONG Start;
 } ATAG_MEM, *PATAG_MEM;
 
+typedef struct _ATAG_REVISION
+{
+    ULONG Rev;
+} ATAG_REVISION, *PATAG_REVISION;
+
 typedef struct _ATAG_INITRD2
 {
     ULONG Start;
@@ -43,6 +48,7 @@ typedef struct _ATAG
     {
         ATAG_CORE Core;
         ATAG_MEM Mem;
+        ATAG_REVISION Revision;
         ATAG_INITRD2 InitRd2;
         ATAG_CMDLINE CmdLine;
     } u;
index 034f76d..29d6151 100755 (executable)
@@ -12,4 +12,10 @@ LlbKeyboardGetChar(
     VOID
 );
 
+CHAR
+NTAPI
+LlbKeypadGetChar(
+    VOID
+);
+
 /* EOF */
index 10ecfaf..9c76f4c 100644 (file)
@@ -24,4 +24,9 @@
 //
 #define MACH_TYPE_OMAP3_BEAGLE 1546
 
+//
+// LogicPD ZOOM-II MDK Board, OMAP3530 SoC
+//
+#define MACH_TYPE_OMAP_ZOOM2   1967
+
 /* EOF */
\ No newline at end of file
diff --git a/boot/armllb/inc/omap3.h b/boot/armllb/inc/omap3.h
new file mode 100755 (executable)
index 0000000..f557fff
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/armllb/inc/omap3.h
+ * PURPOSE:         LLB Board-Specific Hardware Functions for OMAP3
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+VOID
+NTAPI
+LlbHwOmap3UartInitialize(
+    VOID
+);
+
+VOID
+NTAPI
+LlbHwOmap3LcdInitialize(
+    VOID
+);
+
+UCHAR
+NTAPI
+LlbHwOmap3TwlRead1(
+    IN UCHAR ChipAddress,
+    IN UCHAR RegisterAddress
+);
+
+VOID
+NTAPI
+LlbHwOmap3TwlWrite(
+    IN UCHAR ChipAddress,
+    IN UCHAR RegisterAddress,
+    IN UCHAR Length,
+    IN PUCHAR Values
+);
+
+VOID
+NTAPI
+LlbHwOmap3TwlWrite1(
+    IN UCHAR ChipAddress,
+    IN UCHAR RegisterAddress,
+    IN UCHAR Value
+);
+
+VOID
+NTAPI
+LlbHwOmap3SynKpdInitialize(
+    VOID
+);
+
+/* EOF */
index 8bd44b7..a3f65e8 100755 (executable)
 #include "video.h"
 #include "keyboard.h"
 #include "envir.h"
-
-VOID
-DbgPrint(
-    const char *fmt,
-    ...
-);
+#include "../../freeldr/freeldr/include/keycodes.h"
+#include "debug.h"
 
 /* EOF */
index e18ae4c..83c5622 100755 (executable)
@@ -16,17 +16,17 @@ LlbStartup(IN ULONG Reserved,
     /* Make sure we are booting on the correct kind of machine */
     if (BoardInfo != LlbHwGetBoardType()) while (TRUE);
 
-    /* Either QEMU or U-Boot itself should send this information */
-    LlbEnvParseArguments(Arguments);
-    
     /* Initialize hardware components */
     LlbHwInitialize();
 
+    /* Either QEMU or U-Boot itself should send this information */
+    LlbEnvParseArguments(Arguments);
+    
     /* Clean up the screen */
     LlbVideoClearScreen(FALSE);
 
     /* Print header */
-    printf("ReactOS ARM Low-Level Boot Loader [" __DATE__ " "__TIME__ "]\n");
+    printf("\nReactOS ARM Low-Level Boot Loader [" __DATE__ " "__TIME__ "]\n");
     
     /* Boot the OS Loader */
     LlbBoot();
index 5b7caa6..05689d9 100755 (executable)
@@ -91,6 +91,38 @@ LlbBuildMemoryMap(VOID)
     LlbHwBuildMemoryMap(MemoryMap);
 }
 
+//
+// Should go to hwdev.c
+//
+POSLOADER_INIT
+NTAPI
+LlbHwLoadOsLoaderFromRam(VOID)
+{
+    ULONG Base, RootFs, Size;
+    PCHAR Offset;
+    CHAR CommandLine[64];
+    
+    /* On versatile we load the RAMDISK with initrd */
+    LlbEnvGetRamDiskInformation(&RootFs, &Size);
+    DbgPrint("Root fs: %lx, size: %lx\n", RootFs, Size);
+    
+    /* The OS Loader is at 0x20000, always */
+    Base = 0x20000;
+    
+    /* Read image offset */
+    Offset = LlbEnvRead("rdoffset");
+    
+    /* Set parameters for the OS loader */
+    snprintf(CommandLine,
+             sizeof(CommandLine),
+             "rdbase=0x%x rdsize=0x%x rdoffset=%s",
+             RootFs, Size, Offset);
+    LlbSetCommandLine(CommandLine);
+    
+    /* Return the OS loader base address */
+    return (POSLOADER_INIT)Base;
+}
+
 VOID
 NTAPI
 LlbLoadOsLoader(VOID)
@@ -118,6 +150,11 @@ LlbLoadOsLoader(VOID)
     {
         //todo
     }
+    
+    LoaderInit = (PVOID)0x80000000;
+#ifdef _ZOOM2_ // need something better than this...
+    LoaderInit = (PVOID)0x81070000;
+#endif
     printf("OS Loader loaded at 0x%p...JUMP!\n\n\n\n\n", LoaderInit);
 }
 
@@ -133,7 +170,7 @@ LlbBoot(VOID)
     
     /* Load the OS loader */
     LlbLoadOsLoader();
-    
+
     /* Jump to the OS Loader (FreeLDR in this case) */
     LoaderInit(&ArmBlock);
 }
index cbe9e9b..0114bb7 100644 (file)
@@ -9,6 +9,7 @@
     .title "ARM FreeLDR Entry Point"
     .include "ntoskrnl/include/internal/arm/kxarm.h"
     .include "ntoskrnl/include/internal/arm/ksarm.h"
+    .section .init
 
     NESTED_ENTRY _start
     PROLOG_END _start
index ae5e96e..5688406 100644 (file)
@@ -74,7 +74,8 @@ ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext)
     /* This should probably go away once we support more boards */
     ASSERT((ArmBoardBlock->BoardType == MACH_TYPE_FEROCEON) ||
            (ArmBoardBlock->BoardType == MACH_TYPE_VERSATILE_PB) ||
-           (ArmBoardBlock->BoardType == MACH_TYPE_OMAP3_BEAGLE));
+           (ArmBoardBlock->BoardType == MACH_TYPE_OMAP3_BEAGLE) ||
+           (ArmBoardBlock->BoardType == MACH_TYPE_OMAP_ZOOM2));
 
     /* Call FreeLDR's portable entrypoint with our command-line */
     BootMain(ArmBoardBlock->CommandLine);
@@ -156,6 +157,16 @@ ArmMemGetMemoryMap(OUT PBIOS_MEMORY_MAP BiosMemoryMap,
 VOID
 MachInit(IN PCCH CommandLine)
 {
+    /* Copy Machine Routines from Firmware Table */
+    MachVtbl.ConsPutChar = ArmBoardBlock->ConsPutChar;
+    MachVtbl.ConsKbHit = ArmBoardBlock->ConsKbHit;
+    MachVtbl.ConsGetCh = ArmBoardBlock->ConsGetCh;
+    MachVtbl.VideoClearScreen = ArmBoardBlock->VideoClearScreen;
+    MachVtbl.VideoSetDisplayMode = ArmBoardBlock->VideoSetDisplayMode;
+    MachVtbl.VideoGetDisplaySize = ArmBoardBlock->VideoGetDisplaySize;
+    MachVtbl.VideoPutChar = ArmBoardBlock->VideoPutChar;
+    MachVtbl.GetTime = ArmBoardBlock->GetTime;
+    
     /* Setup board-specific ARM routines */
     switch (ArmBoardBlock->BoardType)
     {
@@ -164,29 +175,24 @@ MachInit(IN PCCH CommandLine)
             TuiPrintf("Not implemented\n");
             while (TRUE);
             break;
+
+        /* Check for TI OMAP3 ZOOM-II MDK */
+        case MACH_TYPE_OMAP_ZOOM2:
+            
+            /* Setup the disk and file system buffers */
+            gDiskReadBuffer = 0x81094000;
+            gFileSysBuffer = 0x81094000;
+            break;
             
         /* Check for ARM Versatile PB boards */
         case MACH_TYPE_VERSATILE_PB:
             
-            /* Copy Machine Routines from Firmware Table */
-            MachVtbl.ConsPutChar = ArmBoardBlock->ConsPutChar;
-            MachVtbl.ConsKbHit = ArmBoardBlock->ConsKbHit;
-            MachVtbl.ConsGetCh = ArmBoardBlock->ConsGetCh;
-            MachVtbl.VideoClearScreen = ArmBoardBlock->VideoClearScreen;
-            MachVtbl.VideoSetDisplayMode = ArmBoardBlock->VideoSetDisplayMode;
-            MachVtbl.VideoGetDisplaySize = ArmBoardBlock->VideoGetDisplaySize;
-            MachVtbl.VideoPutChar = ArmBoardBlock->VideoPutChar;
-            MachVtbl.GetTime = ArmBoardBlock->GetTime;
-                        
             /* Setup the disk and file system buffers */
             gDiskReadBuffer = 0x00090000;
             gFileSysBuffer = 0x00090000;
             break;
             
-        /* 
-         * Check for TI OMAP3 boards
-         * For now that means only Beagle, but ZOOM and others should be ok too
-         */
+        /* Check for TI OMAP3 Beagleboard */
         case MACH_TYPE_OMAP3_BEAGLE:
             TuiPrintf("Not implemented\n");
             while (TRUE);
@@ -195,7 +201,7 @@ MachInit(IN PCCH CommandLine)
         default:
             ASSERT(FALSE);
     }
-        
+    
     /* Setup generic ARM routines for all boards */
     MachVtbl.PrepareForReactOS = ArmPrepareForReactOS;
     MachVtbl.GetMemoryMap = ArmMemGetMemoryMap;
diff --git a/boot/freeldr/freeldr/freeldr_arm.lnk b/boot/freeldr/freeldr/freeldr_arm.lnk
new file mode 100644 (file)
index 0000000..82feba1
--- /dev/null
@@ -0,0 +1,54 @@
+OUTPUT_FORMAT(pei-arm-wince-little)
+SECTIONS
+{
+  .text  __image_base__ + __section_alignment__  : 
+  {
+    __text_start__ = .;
+    *(.init)
+    *(.text)
+    *(SORT(.text$*))
+    *(.glue_7t)
+    *(.glue_7)
+     ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; 
+                       LONG (-1); *(.ctors); *(.ctor); LONG (0); 
+     ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; 
+                       LONG (-1); *(.dtors); *(.dtor);  LONG (0); 
+     *(.fini)
+    /* ??? Why is .gcc_exc here?  */
+     *(.gcc_exc)
+     __text_end__ = .;
+    *(.gcc_except_table)
+  }
+  init BLOCK(__section_alignment__) :
+  {
+    __init_start__ = . ;
+    *(init)
+    __init_end__ = . ;
+  }
+  .data BLOCK(__section_alignment__) : 
+  {
+    __data_start__ = . ;
+    *(.data)
+    *(.data2)
+    *(SORT(.data$*))
+    __data_end__ = . ;
+    __bss_start__ = . ;
+    *(.bss)
+    *(COMMON)
+    __bss_end__ = . ;
+  }
+  .rdata BLOCK(__section_alignment__) :
+  {
+    *(.rdata)
+    *(SORT(.rdata$*))
+    *(.eh_frame)
+  }
+  /DISCARD/ :
+  {
+    [ .stab ]
+    [ .stabstr ]
+       *(.reloc)
+  }
+
+}
+
index 5d781f9..5435233 100644 (file)
 #define        KEY_ENTER               0x0D
 #define KEY_BACKSPACE  0x08
 #define KEY_SPACE              0x20
+#define KEY_LEFTSHIFT   0x2A
+#define KEY_HOME        0x47
 #define KEY_UP                 0x48
 #define KEY_DOWN               0x50
 #define KEY_LEFT               0x4B
 #define KEY_RIGHT              0x4D
 #define KEY_ESC                        0x1B
+#define KEY_CAPS_LOCK  0x3A
 #define KEY_F1                 0x3B
 #define KEY_F2                 0x3C
 #define KEY_F3                 0x3D
@@ -38,4 +41,7 @@
 #define KEY_F7                 0x41
 #define KEY_F8                 0x42
 #define KEY_F9                 0x43
-#define KEY_F10                        0x44
+#define KEY_F10         0x44
+#define KEY_KEYPAD_PLUS        0x4e
+#define KEY_END         0x4f
+#define KEY_SEND        0xE7
index f4a4c69..0066cb9 100644 (file)
@@ -85,7 +85,6 @@ PVOID MmAllocateMemoryWithType(ULONG MemorySize, TYPE_OF_MEMORY MemoryType)
 PVOID MmHeapAlloc(ULONG MemorySize)
 {
        PVOID Result;
-       LONG CurAlloc, TotalFree, MaxFree, NumberOfGets, NumberOfRels;
 
        if (MemorySize > MM_PAGE_SIZE)
        {
@@ -99,13 +98,17 @@ PVOID MmHeapAlloc(ULONG MemorySize)
        {
                DPRINTM(DPRINT_MEMORY, "Heap allocation for %d bytes failed\n", MemorySize);
        }
+#if MM_DBG
+    {
+       LONG CurAlloc, TotalFree, MaxFree, NumberOfGets, NumberOfRels;
 
-       // Gather some stats
-       bstats(&CurAlloc, &TotalFree, &MaxFree, &NumberOfGets, &NumberOfRels);
-
-       DPRINTM(DPRINT_MEMORY, "Current alloced %d bytes, free %d bytes, allocs %d, frees %d\n",
-               CurAlloc, TotalFree, NumberOfGets, NumberOfRels);
+           // Gather some stats
+           bstats(&CurAlloc, &TotalFree, &MaxFree, &NumberOfGets, &NumberOfRels);
 
+           DPRINTM(DPRINT_MEMORY, "Current alloced %d bytes, free %d bytes, allocs %d, frees %d\n",
+                   CurAlloc, TotalFree, NumberOfGets, NumberOfRels);
+       }
+#endif
        return Result;
 }
 
index cff04fa..fb6c2d4 100644 (file)
                                         all buffers allocated are a
                                         multiple of this size.  This
                                         MUST be a power of two. */
+#ifdef MM_DBG
 
 #define BufDump     1                /* Define this symbol to enable the
                                         bpoold() function which dumps the
 #define BECtl      1                 /* Define this symbol to enable the
                                         bectl() function for automatic
                                         pool space control.  */
+#else
+#endif
 
 #include <stdio.h>
 
index 660656a..37356a4 100644 (file)
 #define PTE_BASE                    0xC0000000
 #define PDE_BASE                    0xC0400000
 #define PDR_BASE                    0xFFD00000
-#define MMIO_BASE                   0x10000000
 #define VECTOR_BASE                 0xFFFF0000
 
-#define LowMemPageTableIndex        0
+#ifdef _ZOOM2_
+#define IDMAP_BASE                  0x81000000
+#define MMIO_BASE                   0x10000000
+#else
+#define IDMAP_BASE                  0x00000000
+#define MMIO_BASE                   0x10000000
+#endif
+
+#define LowMemPageTableIndex        (IDMAP_BASE >> PDE_SHIFT)
+#define MmioPageTableIndex          (MMIO_BASE >> PDE_SHIFT)
 #define KernelPageTableIndex        (KSEG0_BASE >> PDE_SHIFT)
 #define StartupPtePageTableIndex    (PTE_BASE >> PDE_SHIFT)
 #define StartupPdePageTableIndex    (PDE_BASE >> PDE_SHIFT)
-#define MmioPageTableIndex          (MMIO_BASE >> PDE_SHIFT)
 #define PdrPageTableIndex           (PDR_BASE >> PDE_SHIFT)
 #define VectorPageTableIndex        (VECTOR_BASE >> PDE_SHIFT)
 
+#ifndef _ZOOM2_
+PVOID MempPdrBaseAddress = (PVOID)0x70000;
+PVOID MempKernelBaseAddress = (PVOID)0;
+#else
+PVOID MempPdrBaseAddress = (PVOID)0x81100000;
+PVOID MempKernelBaseAddress = (PVOID)0x80000000;
+#endif
+
 /* Converts a Physical Address into a Page Frame Number */
 #define PaToPfn(p)                  ((p) >> PFN_SHIFT)
 #define PaToLargePfn(p)             ((p) >> LARGE_PFN_SHIFT)
@@ -185,18 +200,21 @@ MempAllocatePageTables(VOID)
     PFN_NUMBER Pfn;
 
     /* Setup templates */
-    TempPte.Accessed = TempPte.Valid = TempLargePte.LargePage = TempLargePte.Accessed = TempPde.Valid = 1;
+    TempPte.Sbo = TempPte.Valid = TempLargePte.LargePage = TempLargePte.Sbo = TempPde.Valid = 1;
 
     /* Allocate the 1MB "PDR" (Processor Data Region). Must be 1MB aligned */
-    PdrPage = MmAllocateMemoryAtAddress(sizeof(KPDR_PAGE), (PVOID)0x700000, LoaderMemoryData);
+    PdrPage = MmAllocateMemoryAtAddress(sizeof(KPDR_PAGE),
+                                        MempPdrBaseAddress,
+                                        LoaderMemoryData);
 
     /* Setup the Low Memory PDE as an identity-mapped Large Page (1MB) */
     LargePte = &PdrPage->PageDir.Pte[LowMemPageTableIndex];
+    TempLargePte.PageFrameNumber = PaToLargePfn(IDMAP_BASE);
     *LargePte = TempLargePte;
 
     /* Setup the MMIO PDE as two identity mapped large pages -- the kernel will blow these away later */
     LargePte = &PdrPage->PageDir.Pte[MmioPageTableIndex];
-    Pfn = PaToLargePfn(0x10000000);
+    Pfn = PaToLargePfn(MMIO_BASE);
     for (i = 0; i < 2; i++)
     {
         TempLargePte.PageFrameNumber = Pfn++;
@@ -215,13 +233,13 @@ MempAllocatePageTables(VOID)
 
     /* Setup the Kernel PTEs */
     PointerPte = PdrPage->KernelPageTable[0].Pte;
-    Pfn = 0;
+    Pfn = PaPtrToPfn(MempKernelBaseAddress);
     for (i = 0; i < 3072; i++)
     {
         TempPte.PageFrameNumber = Pfn++;
         *PointerPte++ = TempPte;
     }
-    
+
     /* Done */
     return TRUE;
 }
index 95c5bde..2f58a5f 100644 (file)
@@ -15,6 +15,7 @@
 
 /* FUNCTIONS **************************************************************/
 
+#ifndef _ZOOM2_
 /* Arch-specific addresses translation implementation */
 PVOID
 VaToPa(PVOID Va)
@@ -27,6 +28,19 @@ PaToVa(PVOID Pa)
 {
        return (PVOID)((ULONG_PTR)Pa | KSEG0_BASE);
 }
+#else
+PVOID
+VaToPa(PVOID Va)
+{
+    return Va;
+}
+
+PVOID
+PaToVa(PVOID Pa)
+{
+    return Pa;
+}
+#endif
 
 VOID
 List_PaToVa(LIST_ENTRY *ListEntry)
index 29c4eab..251c188 100644 (file)
@@ -209,6 +209,7 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
                Extension->AcpiTable = (PVOID)1;
        }
     
+#ifndef _M_ARM
     /* Set headless block pointer */
     if (WinLdrTerminalConnected)
     {
@@ -225,7 +226,7 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
             sizeof(HEADLESS_LOADER_BLOCK));
         Extension->HeadlessLoaderBlock = PaToVa(Extension->HeadlessLoaderBlock);
     }
-
+#endif
        /* Load drivers database */
        strcpy(MiscFiles, BootPath);
        strcat(MiscFiles, "AppPatch\\drvmain.sdb");
@@ -537,9 +538,10 @@ LoadAndBootWindows(PCSTR OperatingSystemName,
        /* Allocate and minimalistic-initialize LPB */
        AllocateAndInitLPB(&LoaderBlock);
     
+#ifndef _M_ARM
        /* Setup redirection support */
        WinLdrSetupEms(BootOptions);
-
+#endif
        /* Detect hardware */
        UseRealHeap = TRUE;
        LoaderBlock->ConfigurationRoot = MachHwDetect();
index 1080ee2..b6c1fc9 100644 (file)
@@ -88,7 +88,7 @@ WinLdrLoadSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
        }
 
        /* Convert address to virtual */
-       HiveDataVirtual = (PVOID)(KSEG0_BASE | HiveDataPhysical);
+    HiveDataVirtual = PaToVa((PVOID)HiveDataPhysical);
 
        /* Fill LoaderBlock's entries */
        LoaderBlock->RegistryLength = HiveFileSize;
@@ -379,7 +379,7 @@ WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
        if (NlsDataBase == 0)
                goto Failure;
 
-       NlsVirtual = (PVOID)(KSEG0_BASE | NlsDataBase);
+       NlsVirtual = PaToVa((PVOID)NlsDataBase);
        LoaderBlock->NlsData->AnsiCodePageData = NlsVirtual;
        LoaderBlock->NlsData->OemCodePageData = (PVOID)((PUCHAR)NlsVirtual +
                (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT));
index 1cfb8c8..4b08539 100644 (file)
@@ -3236,9 +3236,9 @@ LdrpGetResidentSize(PIMAGE_NT_HEADERS NTHeaders)
  */
 NTSTATUS NTAPI
 LdrVerifyImageMatchesChecksum (IN HANDLE FileHandle,
-                               ULONG Unknown1,
-                               ULONG Unknown2,
-                               ULONG Unknown3)
+                               IN PLDR_CALLBACK Callback,
+                               IN PVOID CallbackContext,
+                               OUT PUSHORT ImageCharacterstics)
 {
   FILE_STANDARD_INFORMATION FileInfo;
   IO_STATUS_BLOCK IoStatusBlock;
index 93381e7..8661085 100644 (file)
@@ -255,7 +255,7 @@ GetViewportExtEx(
 
   if ((Dc_Attr->flXform & PAGE_EXTENTS_CHANGED) && (Dc_Attr->iMapMode == MM_ISOTROPIC))
      // Something was updated, go to kernel.
-     return NtGdiGetDCPoint( hdc, GdiGetViewPortExt, (LPPOINT) lpSize );
+     return NtGdiGetDCPoint( hdc, GdiGetViewPortExt, (PPOINTL) lpSize );
   else
   {
      lpSize->cx = Dc_Attr->szlViewportExt.cx;
index eb9dcf2..7693dcc 100644 (file)
@@ -746,7 +746,7 @@ GetAspectRatioFilterEx(
                 LPSIZE lpAspectRatio
                       )
 {
-  return NtGdiGetDCPoint( hdc, GdiGetAspectRatioFilter, (LPPOINT) lpAspectRatio );
+  return NtGdiGetDCPoint( hdc, GdiGetAspectRatioFilter, (PPOINTL) lpAspectRatio );
 }
 
 
@@ -760,7 +760,7 @@ GetDCOrgEx(
     LPPOINT lpPoint
     )
 {
-  return NtGdiGetDCPoint( hdc, GdiGetDCOrg, lpPoint );
+  return NtGdiGetDCPoint( hdc, GdiGetDCOrg, (PPOINTL)lpPoint );
 }
 
 
index 7112ffb..629b69b 100644 (file)
@@ -14,7 +14,7 @@
 #include <debug.h>
 DEBUG_CHANNEL(kernel32file);
 
-#define USING_PROPER_NPFS_WAIT_SEMANTICS
+//#define USING_PROPER_NPFS_WAIT_SEMANTICS
 
 /* FUNCTIONS ****************************************************************/
 
@@ -264,6 +264,16 @@ WaitNamedPipeA(LPCSTR lpNamedPipeName,
 }
 
 
+/*
+ * When NPFS will work properly, use this code instead. It is compatible with
+ * Microsoft's NPFS.SYS. The main difference is that:
+ *      - This code actually respects the timeout instead of ignoring it!
+ *      - This code validates and creates the proper names for both UNC and local pipes
+ *      - On NT, you open the *root* pipe directory (either \DosDevices\Pipe or
+ *        \DosDevices\Unc\Server\Pipe) and then send the pipe to wait on in the
+ *        FILE_PIPE_WAIT_FOR_BUFFER structure.
+ */
+#ifdef USING_PROPER_NPFS_WAIT_SEMANTICS
 /*
  * @implemented
  */
@@ -448,6 +458,95 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
     /* Success */
     return TRUE;
 }
+#else
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+WaitNamedPipeW(LPCWSTR lpNamedPipeName,
+               DWORD nTimeOut)
+{
+    UNICODE_STRING NamedPipeName;
+    NTSTATUS Status;
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    FILE_PIPE_WAIT_FOR_BUFFER WaitPipe;
+    HANDLE FileHandle;
+    IO_STATUS_BLOCK Iosb;
+
+    if (RtlDosPathNameToNtPathName_U(lpNamedPipeName,
+                                     &NamedPipeName,
+                                     NULL,
+                                     NULL) == FALSE)
+    {
+        return FALSE;
+    }
+
+    InitializeObjectAttributes(&ObjectAttributes,
+                               &NamedPipeName,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+    Status = NtOpenFile(&FileHandle,
+                        FILE_READ_ATTRIBUTES | SYNCHRONIZE,
+                        &ObjectAttributes,
+                        &Iosb,
+                        FILE_SHARE_READ | FILE_SHARE_WRITE,
+                        FILE_SYNCHRONOUS_IO_NONALERT);
+    if (!NT_SUCCESS(Status))
+    {
+        SetLastErrorByStatus(Status);
+        RtlFreeUnicodeString(&NamedPipeName);
+        return FALSE;
+    }
+
+    /* Check what timeout we got */
+    if (nTimeOut == NMPWAIT_USE_DEFAULT_WAIT)
+    {
+        /* Don't use a timeout */
+        WaitPipe.TimeoutSpecified = FALSE;
+    }
+    else
+    {
+        /* Check if we should wait forever */
+        if (nTimeOut == NMPWAIT_WAIT_FOREVER)
+        {
+            /* Set the max */
+            WaitPipe.Timeout.LowPart = 0;
+            WaitPipe.Timeout.HighPart = 0x80000000;
+        }
+        else
+        {
+            /* Convert to NT format */
+            WaitPipe.Timeout.QuadPart = UInt32x32To64(-10000, nTimeOut);
+        }
+
+        /* In both cases, we do have a timeout */
+        WaitPipe.TimeoutSpecified = TRUE;
+    }
+
+    Status = NtFsControlFile(FileHandle,
+                             NULL,
+                             NULL,
+                             NULL,
+                             &Iosb,
+                             FSCTL_PIPE_WAIT,
+                             &WaitPipe,
+                             sizeof(WaitPipe),
+                             NULL,
+                             0);
+    NtClose(FileHandle);
+    if (!NT_SUCCESS(Status))
+    {
+        SetLastErrorByStatus(Status);
+        RtlFreeUnicodeString(&NamedPipeName);
+        return FALSE;
+    }
+
+    RtlFreeUnicodeString(&NamedPipeName);
+    return TRUE;
+}
+#endif
 
 
 /*
index 0462003..dc70991 100644 (file)
@@ -13,6 +13,8 @@
 #define NDEBUG
 #include <debug.h>
 
+//#define USING_PROPER_NPFS_WAIT_SEMANTICS
+
 /* FUNCTIONS *****************************************************************/
 
 PNPFS_FCB
@@ -103,6 +105,35 @@ NpfsSignalAndRemoveListeningServerInstance(PNPFS_FCB Fcb,
 }
 
 
+static VOID
+NpfsOpenFileSystem(PNPFS_FCB Fcb,
+                   PFILE_OBJECT FileObject,
+                   PIO_STATUS_BLOCK IoStatus)
+{
+    PNPFS_CCB Ccb;
+
+    DPRINT("NpfsOpenFileSystem()\n");
+
+    Ccb = ExAllocatePool(NonPagedPool, sizeof(NPFS_CCB));
+    if (Ccb == NULL)
+    {
+        IoStatus->Status = STATUS_NO_MEMORY;
+        return;
+    }
+
+    Ccb->Type = CCB_DEVICE;
+    Ccb->Fcb = Fcb;
+
+    FileObject->FsContext = Fcb;
+    FileObject->FsContext2 = Ccb;
+
+    IoStatus->Information = FILE_OPENED;
+    IoStatus->Status = STATUS_SUCCESS;
+
+    return;
+}
+
+
 static VOID
 NpfsOpenRootDirectory(PNPFS_FCB Fcb,
                       PFILE_OBJECT FileObject,
@@ -146,6 +177,9 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
     PNPFS_VCB Vcb;
     ACCESS_MASK DesiredAccess;
     NTSTATUS Status;
+#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
+    BOOLEAN SpecialAccess;
+#endif
 
     DPRINT("NpfsCreate(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
 
@@ -161,6 +195,32 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
 
     Irp->IoStatus.Information = 0;
 
+#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
+    SpecialAccess = ((DesiredAccess & SPECIFIC_RIGHTS_ALL) == FILE_READ_ATTRIBUTES);
+    if (SpecialAccess)
+    {
+        DPRINT("NpfsCreate() open client end for special use!\n");
+    }
+#endif
+
+    DPRINT("FileName->Length: %hu  RelatedFileObject: %p\n", FileName->Length, RelatedFileObject);
+
+    /* Open the file system */
+    if (FileName->Length == 0 &&
+        (RelatedFileObject == NULL || ((PNPFS_CCB)RelatedFileObject->FsContext2)->Type == CCB_DEVICE))
+    {
+        DPRINT("Open the file system\n");
+
+        NpfsOpenFileSystem(Vcb->DeviceFcb,
+                           FileObject,
+                           &Irp->IoStatus);
+
+        Status = Irp->IoStatus.Status;
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+        return Status;
+    }
+
+    /* Open the root directory */
     if (FileName->Length == 2 && FileName->Buffer[0] == L'\\' && RelatedFileObject == NULL)
     {
         DPRINT("Open the root directory\n");
@@ -217,8 +277,11 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
     ClientCcb->Fcb = Fcb;
     ClientCcb->PipeEnd = FILE_PIPE_CLIENT_END;
     ClientCcb->OtherSide = NULL;
-//    ClientCcb->PipeState = SpecialAccess ? 0 : FILE_PIPE_DISCONNECTED_STATE;
+#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
+    ClientCcb->PipeState = SpecialAccess ? 0 : FILE_PIPE_DISCONNECTED_STATE;
+#else
     ClientCcb->PipeState = FILE_PIPE_DISCONNECTED_STATE;
+#endif
     InitializeListHead(&ClientCcb->ReadRequestListHead);
 
     DPRINT("CCB: %p\n", ClientCcb);
@@ -256,10 +319,10 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
     /*
     * Step 3. Search for listening server CCB.
     */
-/*
+#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
     if (!SpecialAccess)
     {
-*/
+#endif
         /*
         * WARNING: Point of no return! Once we get the server CCB it's
         * possible that we completed a wait request and so we have to
@@ -315,7 +378,7 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
             /* FIXME: Merge this with the NpfsFindListeningServerInstance routine. */
             NpfsSignalAndRemoveListeningServerInstance(Fcb, ServerCcb);
         }
-/*
+#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
     }
     else if (IsListEmpty(&Fcb->ServerCcbListHead))
     {
@@ -333,7 +396,7 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
         IoCompleteRequest(Irp, IO_NO_INCREMENT);
         return STATUS_UNSUCCESSFUL;
     }
-*/
+#endif
 
     /*
     * Step 4. Add the client CCB to a list and connect it if possible.
@@ -646,6 +709,15 @@ NpfsCleanup(PDEVICE_OBJECT DeviceObject,
         return STATUS_SUCCESS;
     }
 
+    if (Ccb->Type == CCB_DEVICE)
+    {
+        DPRINT("Cleanup the file system!\n");
+        Irp->IoStatus.Status = STATUS_SUCCESS;
+        Irp->IoStatus.Information = 0;
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+        return STATUS_SUCCESS;
+    }
+
     if (Ccb->Type == CCB_DIRECTORY)
     {
         DPRINT("Cleanup the root directory!\n");
@@ -790,6 +862,20 @@ NpfsClose(PDEVICE_OBJECT DeviceObject,
         return STATUS_SUCCESS;
     }
 
+    if (Ccb->Type == CCB_DEVICE)
+    {
+        DPRINT("Closing the file system!\n");
+
+        ExFreePool(Ccb);
+        FileObject->FsContext = NULL;
+        FileObject->FsContext2 = NULL;
+
+        Irp->IoStatus.Status = STATUS_SUCCESS;
+        Irp->IoStatus.Information = 0;
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+        return STATUS_SUCCESS;
+    }
+
     if (Ccb->Type == CCB_DIRECTORY)
     {
         DPRINT("Closing the root directory!\n");
index c177969..9055bb1 100644 (file)
@@ -15,6 +15,8 @@
 #define NDEBUG
 #include <debug.h>
 
+//#define USING_PROPER_NPFS_WAIT_SEMANTICS
+
 /* FUNCTIONS *****************************************************************/
 
 static DRIVER_CANCEL NpfsListeningCancelRoutine;
@@ -293,18 +295,21 @@ NpfsWaitPipe(PIRP Irp,
              PNPFS_CCB Ccb)
 {
     PLIST_ENTRY current_entry;
-    PNPFS_VCB Vcb;
     PNPFS_FCB Fcb;
     PNPFS_CCB ServerCcb;
     PFILE_PIPE_WAIT_FOR_BUFFER WaitPipe;
     LARGE_INTEGER TimeOut;
-    UNICODE_STRING PipeName;
     NTSTATUS Status;
+#ifdef USING_PROPER_NPFS_WAIT_SEMANTICS
+    PNPFS_VCB Vcb;
+    UNICODE_STRING PipeName;
+#endif
 
     DPRINT("NpfsWaitPipe\n");
 
     WaitPipe = (PFILE_PIPE_WAIT_FOR_BUFFER)Irp->AssociatedIrp.SystemBuffer;
 
+#ifdef USING_PROPER_NPFS_WAIT_SEMANTICS
     /* Fail, if the CCB does not represent the root directory */
     if (Ccb->Type != CCB_DIRECTORY)
         return STATUS_ILLEGAL_FUNCTION;
@@ -352,6 +357,15 @@ NpfsWaitPipe(PIRP Irp,
     }
 
     DPRINT("Fcb %p\n", Fcb);
+#else
+    Fcb = Ccb->Fcb;
+
+    if (Ccb->PipeState != 0)
+    {
+        DPRINT("Pipe is not in passive (waiting) state!\n");
+        return STATUS_UNSUCCESSFUL;
+    }
+#endif
 
     /* search for listening server */
     current_entry = Fcb->ServerCcbListHead.Flink;
index 825abe3..74fe99b 100644 (file)
@@ -85,12 +85,16 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
     Vcb->DefaultQuota = 8 * PAGE_SIZE;
     Vcb->MaxQuota = 64 * PAGE_SIZE;
 
+    /* Create the device FCB */
     Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB));
-    Fcb->Type = FCB_DIRECTORY;
+    Fcb->Type = FCB_DEVICE;
     Fcb->Vcb = Vcb;
+    Vcb->DeviceFcb = Fcb;
 
-
-
+    /* Create the root directory FCB */
+    Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB));
+    Fcb->Type = FCB_DIRECTORY;
+    Fcb->Vcb = Vcb;
     Vcb->RootFcb = Fcb;
 
     return STATUS_SUCCESS;
index cb37cb0..2e47e68 100644 (file)
@@ -28,6 +28,7 @@ typedef struct _NPFS_VCB
     ULONG MinQuota;
     ULONG DefaultQuota;
     ULONG MaxQuota;
+    struct _NPFS_FCB *DeviceFcb;
     struct _NPFS_FCB *RootFcb;
 } NPFS_VCB, *PNPFS_VCB;
 
diff --git a/hal/halarm/omap3/halinit_up.c b/hal/halarm/omap3/halinit_up.c
new file mode 100644 (file)
index 0000000..2f3b06c
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * PROJECT:         ReactOS HAL
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            hal/halarm/omap3/halinit_up.c
+ * PURPOSE:         OMAP3 Board-Specific HAL Initialization
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+VOID
+HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+
+}
+
+VOID
+HalpInitPhase1(VOID)
+{
+
+}
+
+/* EOF */
diff --git a/hal/halarm/omap3/halup.rbuild b/hal/halarm/omap3/halup.rbuild
new file mode 100644 (file)
index 0000000..7486fa9
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<module name="hal" type="kernelmodedll" entrypoint="HalInitSystem" installbase="system32" installname="hal.dll">
+       <importlibrary base="hal" definition="../hal.pspec" />
+       <bootstrap installbase="$(CDOUTPUT)" nameoncd="hal.dll" />
+       <include base="hal">include</include>
+       <include base="ntoskrnl">include</include>
+       <define name="_NTHAL_" />
+       <library>hal_generic</library>
+       <library>ntoskrnl</library>
+       <library>kdcom</library>
+       <directory name="omap3">
+               <file>halinit_up.c</file>
+               <file>halup.rc</file>
+       </directory>
+</module>
diff --git a/hal/halarm/omap3/halup.rc b/hal/halarm/omap3/halup.rc
new file mode 100644 (file)
index 0000000..90af6b9
--- /dev/null
@@ -0,0 +1,5 @@
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION   "X86 Uniprocessor Hardware Abstraction Layer\0"
+#define REACTOS_STR_INTERNAL_NAME      "halup\0"
+#define REACTOS_STR_ORIGINAL_FILENAME  "halup.dll\0"
+#include <reactos/version.rc>
index 12ced3e..f5a07b3 100644 (file)
@@ -67,12 +67,40 @@ __INTRIN_INLINE char _InterlockedCompareExchange8(volatile char * const Destinat
 
 __INTRIN_INLINE short _InterlockedCompareExchange16(volatile short * const Destination, const short Exchange, const short Comperand)
 {
-       return __sync_val_compare_and_swap(Destination, Comperand, Exchange);
+       short a, b;
+
+       __asm__ __volatile__ (    "0:\n\t"
+                          "ldr %1, [%2]\n\t"
+                          "cmp %1, %4\n\t"
+                          "bne 1f\n\t"
+                          "swp %0, %3, [%2]\n\t"
+                          "cmp %0, %1\n\t"
+                          "swpne %3, %0, [%2]\n\t"
+                          "bne 0b\n\t"
+                          "1:"
+                          : "=&r" (a), "=&r" (b)
+                          : "r" (Destination), "r" (Exchange), "r" (Comperand)
+                          : "cc", "memory");
+
+       return a;
 }
 
-__INTRIN_INLINE long _InterlockedExchangeAdd16(volatile short * const Addend, const short Value)
+__INTRIN_INLINE short _InterlockedExchangeAdd16(volatile short * const Addend, const short Value)
 {
-       return __sync_fetch_and_add(Addend, Value);
+       short a, b, c;
+
+       __asm__ __volatile__ (  "0:\n\t"
+                          "ldr %0, [%3]\n\t"
+                          "add %1, %0, %4\n\t"
+                          "swp %2, %1, [%3]\n\t"
+                          "cmp %0, %2\n\t"
+                          "swpne %1, %2, [%3]\n\t"
+                          "bne 0b"
+                          : "=&r" (a), "=&r" (b), "=&r" (c)
+                          : "r" (Value), "r" (Addend)
+                          : "cc", "memory");
+
+       return a;
 }
 
 __INTRIN_INLINE long _InterlockedCompareExchange(volatile long * const dest, const long exch, const long comp)
index 2150b08..b186642 100644 (file)
@@ -129,6 +129,15 @@ extern "C" {
     SETJMP_FLOAT128 Xmm15;
   } _JUMP_BUFFER;
 
+#elif defined(_M_ARM)
+
+#define _JBLEN  11
+#define _JBTYPE int
+
+#else
+
+#error Define Setjmp for this architecture!
+
 #endif
 
 #ifndef _JMP_BUF_DEFINED
index 07b6191..97a519e 100644 (file)
@@ -366,20 +366,13 @@ typedef __WCHAR_TYPE__ wchar_t;
 #endif /* __sys_stdtypes_h */
 
 /* A null pointer constant.  */
-
-#if defined (_STDDEF_H) || defined (__need_NULL)
-#undef NULL            /* in case <stdio.h> has defined it. */
-#ifdef __GNUG__
-#define NULL __null
-#else   /* G++ */
-#ifndef __cplusplus
-#define NULL ((void *)0)
-#else   /* C++ */
+#ifndef NULL
+#ifdef __cplusplus
 #define NULL 0
-#endif  /* C++ */
-#endif  /* G++ */
-#endif /* NULL not defined and <stddef.h> or need NULL.  */
-#undef __need_NULL
+#else
+#define NULL ((void*)0)
+#endif
+#endif
 
 #ifndef offsetof
 
index 233a0c9..05f57a0 100644 (file)
@@ -9726,7 +9726,7 @@ KeQuerySystemTime(
   OUT PLARGE_INTEGER CurrentTime);
 #endif /* !_M_AMD64 */
 
-#if !defined(_X86_)
+#if !defined(_X86_) && !defined(_M_ARM)
 NTKERNELAPI
 KIRQL
 NTAPI
index bbf85af..feb0c16 100644 (file)
@@ -473,8 +473,13 @@ typedef struct _KIPCR
     ULONG StallScaleFactor;
     UCHAR SpareUnused;
     UCHAR Number;
+    UCHAR Spare0;
+    UCHAR SecondLevelCacheAssociativity;
+    ULONG VdmAlert;
+    ULONG KernelReserved[14];
+    ULONG SecondLevelCacheSize;
+    ULONG HalReserved[16];  
     // arm part
-    UCHAR Spare0[2];
     UCHAR IrqlMask[32];
     ULONG IrqlTable[32];
     PKINTERRUPT_ROUTINE InterruptRoutine[32];
index febadda..371b159 100644 (file)
@@ -68,7 +68,7 @@ typedef struct _HARDWARE_LARGE_PTE_ARMV6
     ULONG NoExecute:1;
     ULONG Domain:4;
     ULONG Ecc:1;
-    ULONG Accessed:1;
+    ULONG Sbo:1;
     ULONG Owner:1;
     ULONG CacheAttributes:3;
     ULONG ReadOnly:1;
@@ -85,7 +85,7 @@ typedef struct _HARDWARE_PTE_ARMV6
     ULONG Valid:1;
     ULONG Buffered:1;
     ULONG Cached:1;
-    ULONG Accessed:1;
+    ULONG Sbo:1;
     ULONG Owner:1;
     ULONG CacheAttributes:3;
     ULONG ReadOnly:1;
@@ -100,9 +100,9 @@ C_ASSERT(sizeof(HARDWARE_PTE_ARMV6) == sizeof(ULONG));
 
 typedef struct _MMPTE_SOFTWARE
 {
-    ULONG Valid:1;
+    ULONG Valid:2;
     ULONG PageFileLow:4;
-    ULONG Protection:5;
+    ULONG Protection:4;
     ULONG Prototype:1;
     ULONG Transition:1;
     ULONG PageFileHigh:20;
@@ -110,12 +110,12 @@ typedef struct _MMPTE_SOFTWARE
 
 typedef struct _MMPTE_TRANSITION
 {
-    ULONG Valid:1;
-    ULONG Write:1;
+    ULONG Valid:2;
+    ULONG Buffered:1;
+    ULONG Cached:1;
     ULONG Owner:1;
-    ULONG WriteThrough:1;
-    ULONG CacheDisable:1;
-    ULONG Protection:5;
+    ULONG Protection:4;
+    ULONG ReadOnly:1;
     ULONG Prototype:1;
     ULONG Transition:1;
     ULONG PageFrameNumber:20;
@@ -123,19 +123,18 @@ typedef struct _MMPTE_TRANSITION
 
 typedef struct _MMPTE_PROTOTYPE
 {
-    ULONG Valid:1;
+    ULONG Valid:2;
     ULONG ProtoAddressLow:7;
     ULONG ReadOnly:1;
-    ULONG WhichPool:1;
     ULONG Prototype:1;
     ULONG ProtoAddressHigh:21;
 } MMPTE_PROTOTYPE;
 
 typedef struct _MMPTE_SUBSECTION
 {
-    ULONG Valid:1;
+    ULONG Valid:2;
     ULONG SubsectionAddressLow:4;
-    ULONG Protection:5;
+    ULONG Protection:4;
     ULONG Prototype:1;
     ULONG SubsectionAddressHigh:20;
     ULONG WhichPool:1;
@@ -143,47 +142,38 @@ typedef struct _MMPTE_SUBSECTION
 
 typedef struct _MMPTE_LIST
 {
-    ULONG Valid:1;
+    ULONG Valid:2;
     ULONG OneEntry:1;
     ULONG filler0:8;
     ULONG NextEntry:20;
     ULONG Prototype:1;
-    ULONG filler1:1;
 } MMPTE_LIST;
 
 typedef union _MMPTE_HARDWARE
 {
-    struct
-    {
-        ULONG NoExecute:1;
-        ULONG Valid:1;
-        ULONG Buffered:1;
-        ULONG Cached:1;
-        ULONG Access:1;
-        ULONG Owner:1;
-        ULONG CacheAttributes:3;
-        ULONG ReadOnly:1;
-        ULONG Shared:1;
-        ULONG NonGlobal:1;
-        ULONG PageFrameNumber:20;
-    };
-    ULONG AsUlong;
+    ULONG NoExecute:1;
+    ULONG Valid:1;
+    ULONG Buffered:1;
+    ULONG Cached:1;
+    ULONG Sbo:1;
+    ULONG Owner:1;
+    ULONG CacheAttributes:3;
+    ULONG ReadOnly:1;
+    ULONG Prototype:1;
+    ULONG NonGlobal:1;
+    ULONG PageFrameNumber:20;
 } MMPTE_HARDWARE, *PMMPTE_HARDWARE;
 
 typedef union _MMPDE_HARDWARE
 {
-    struct
-    {
-        ULONG Valid:1;
-        ULONG LargePage:1;
-        ULONG Buffered:1;
-        ULONG Cached:1;
-        ULONG NoExecute:1;
-        ULONG Domain:4;
-        ULONG Ecc:1;
-        ULONG PageFrameNumber:22;
-    };
-    ULONG AsUlong;
+    ULONG Valid:1;
+    ULONG LargePage:1;
+    ULONG Buffered:1;
+    ULONG Cached:1;
+    ULONG NoExecute:1;
+    ULONG Domain:4;
+    ULONG Ecc:1;
+    ULONG PageFrameNumber:22;
 } MMPDE_HARDWARE, *PMMPDE_HARDWARE;
 
 typedef struct _MMPDE
index 063c3b8..308e47f 100644 (file)
@@ -296,13 +296,14 @@ LdrUnloadDll(
     IN PVOID BaseAddress
 );
 
+typedef VOID NTAPI (*PLDR_CALLBACK)(PVOID CallbackContext, PVOID Name);
 NTSTATUS
 NTAPI
 LdrVerifyImageMatchesChecksum(
     IN HANDLE FileHandle,
-    ULONG Unknown1,
-    ULONG Unknown2,
-    ULONG Unknown3
+    IN PLDR_CALLBACK Callback,
+    IN PVOID CallbackContext,
+    OUT PUSHORT ImageCharacterstics
 );
 
 #endif
diff --git a/include/psdk/specstrings.h b/include/psdk/specstrings.h
new file mode 100644 (file)
index 0000000..de2c0ba
--- /dev/null
@@ -0,0 +1,278 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+#define __specstrings
+
+#ifdef __cplusplus
+#ifndef __nothrow
+#define __nothrow __declspec(nothrow)
+#endif
+#else
+#ifndef __nothrow
+#define __nothrow
+#endif
+#endif
+
+#define __deref_in
+#define __deref_in_ecount(size)
+#define __deref_in_bcount(size)
+#define __deref_in_opt
+#define __deref_in_ecount_opt(size)
+#define __deref_in_bcount_opt(size)
+#define __deref_opt_in
+#define __deref_opt_in_ecount(size)
+#define __deref_opt_in_bcount(size)
+#define __deref_opt_in_opt
+#define __deref_opt_in_ecount_opt(size)
+#define __deref_opt_in_bcount_opt(size)
+#define __out_awcount(expr,size)
+#define __in_awcount(expr,size)
+#ifndef __cplusplus
+#define __null
+#endif
+#define __notnull
+#define __maybenull
+#define __readonly
+#define __notreadonly
+#define __maybereadonly
+#define __valid
+#define __notvalid
+#define __maybevalid
+#define __readableTo(extent)
+#define __elem_readableTo(size)
+#define __byte_readableTo(size)
+#define __writableTo(size)
+#define __elem_writableTo(size)
+#define __byte_writableTo(size)
+#define __deref
+#define __pre
+#define __post
+#define __precond(expr)
+#define __postcond(expr)
+#define __exceptthat
+#define __execeptthat
+#define __inner_success(expr)
+#define __inner_checkReturn
+#define __inner_typefix(ctype)
+#define __inner_override
+#define __inner_callback
+#define __inner_blocksOn(resource)
+#define __inner_fallthrough_dec
+#define __inner_fallthrough
+#define __refparam
+#define __inner_control_entrypoint(category)
+#define __inner_data_entrypoint(category)
+#define __ecount(size)
+#define __bcount(size)
+#ifndef __cplusplus
+#define __in
+#endif
+#define __in_opt
+#define __in_nz
+#define __in_nz_opt
+#define __in_z
+#define __in_z_opt
+#define __in_ecount(size)
+#define __in_ecount_nz(size)
+#define __in_ecount_z(size)
+#define __in_bcount(size)
+#define __in_bcount_z(size)
+#define __in_bcount_nz(size)
+#define __in_ecount_opt(size)
+#define __in_bcount_opt(size)
+#define __in_ecount_z_opt(size)
+#define __in_bcount_z_opt(size)
+#define __in_ecount_nz_opt(size)
+#define __in_bcount_nz_opt(size)
+#define __out
+#define __out_ecount(size)
+#define __out_z
+#define __out_nz
+#define __out_nz_opt
+#define __out_z_opt
+#define __out_ecount_part(size,length)
+#define __out_ecount_full(size)
+#define __out_ecount_nz(size)
+#define __out_ecount_z(size)
+#define __out_ecount_part_z(size,length)
+#define __out_ecount_full_z(size)
+#define __out_bcount(size)
+#define __out_bcount_part(size,length)
+#define __out_bcount_full(size)
+#define __out_bcount_z(size)
+#define __out_bcount_part_z(size,length)
+#define __out_bcount_full_z(size)
+#define __out_bcount_nz(size)
+#define __inout
+#define __inout_ecount(size)
+#define __inout_bcount(size)
+#define __inout_ecount_part(size,length)
+#define __inout_bcount_part(size,length)
+#define __inout_ecount_full(size)
+#define __inout_bcount_full(size)
+#define __inout_z
+#define __inout_ecount_z(size)
+#define __inout_bcount_z(size)
+#define __inout_nz
+#define __inout_ecount_nz(size)
+#define __inout_bcount_nz(size)
+#define __ecount_opt(size)
+#define __bcount_opt(size)
+#define __out_opt
+#define __out_ecount_opt(size)
+#define __out_bcount_opt(size)
+#define __out_ecount_part_opt(size,length)
+#define __out_bcount_part_opt(size,length)
+#define __out_ecount_full_opt(size)
+#define __out_bcount_full_opt(size)
+#define __out_ecount_z_opt(size)
+#define __out_bcount_z_opt(size)
+#define __out_ecount_part_z_opt(size,length)
+#define __out_bcount_part_z_opt(size,length)
+#define __out_ecount_full_z_opt(size)
+#define __out_bcount_full_z_opt(size)
+#define __out_ecount_nz_opt(size)
+#define __out_bcount_nz_opt(size)
+#define __inout_opt
+#define __inout_ecount_opt(size)
+#define __inout_bcount_opt(size)
+#define __inout_ecount_part_opt(size,length)
+#define __inout_bcount_part_opt(size,length)
+#define __inout_ecount_full_opt(size)
+#define __inout_bcount_full_opt(size)
+#define __inout_z_opt
+#define __inout_ecount_z_opt(size)
+#define __inout_bcount_z_opt(size)
+#define __inout_nz_opt
+#define __inout_ecount_nz_opt(size)
+#define __inout_bcount_nz_opt(size)
+#define __deref_ecount(size)
+#define __deref_bcount(size)
+#define __deref_out
+#define __deref_out_ecount(size)
+#define __deref_out_bcount(size)
+#define __deref_out_ecount_part(size,length)
+#define __deref_out_bcount_part(size,length)
+#define __deref_out_ecount_full(size)
+#define __deref_out_bcount_full(size)
+#define __deref_out_z
+#define __deref_out_ecount_z(size)
+#define __deref_out_bcount_z(size)
+#define __deref_out_nz
+#define __deref_out_ecount_nz(size)
+#define __deref_out_bcount_nz(size)
+#define __deref_inout
+#define __deref_inout_ecount(size)
+#define __deref_inout_bcount(size)
+#define __deref_inout_ecount_part(size,length)
+#define __deref_inout_bcount_part(size,length)
+#define __deref_inout_ecount_full(size)
+#define __deref_inout_bcount_full(size)
+#define __deref_inout_z
+#define __deref_inout_ecount_z(size)
+#define __deref_inout_bcount_z(size)
+#define __deref_inout_nz
+#define __deref_inout_ecount_nz(size)
+#define __deref_inout_bcount_nz(size)
+#define __deref_ecount_opt(size)
+#define __deref_bcount_opt(size)
+#define __deref_out_opt
+#define __deref_out_ecount_opt(size)
+#define __deref_out_bcount_opt(size)
+#define __deref_out_ecount_part_opt(size,length)
+#define __deref_out_bcount_part_opt(size,length)
+#define __deref_out_ecount_full_opt(size)
+#define __deref_out_bcount_full_opt(size)
+#define __deref_out_z_opt
+#define __deref_out_ecount_z_opt(size)
+#define __deref_out_bcount_z_opt(size)
+#define __deref_out_nz_opt
+#define __deref_out_ecount_nz_opt(size)
+#define __deref_out_bcount_nz_opt(size)
+#define __deref_inout_opt
+#define __deref_inout_ecount_opt(size)
+#define __deref_inout_bcount_opt(size)
+#define __deref_inout_ecount_part_opt(size,length)
+#define __deref_inout_bcount_part_opt(size,length)
+#define __deref_inout_ecount_full_opt(size)
+#define __deref_inout_bcount_full_opt(size)
+#define __deref_inout_z_opt
+#define __deref_inout_ecount_z_opt(size)
+#define __deref_inout_bcount_z_opt(size)
+#define __deref_inout_nz_opt
+#define __deref_inout_ecount_nz_opt(size)
+#define __deref_inout_bcount_nz_opt(size)
+#define __deref_opt_ecount(size)
+#define __deref_opt_bcount(size)
+#define __deref_opt_out
+#define __deref_opt_out_z
+#define __deref_opt_out_ecount(size)
+#define __deref_opt_out_bcount(size)
+#define __deref_opt_out_ecount_part(size,length)
+#define __deref_opt_out_bcount_part(size,length)
+#define __deref_opt_out_ecount_full(size)
+#define __deref_opt_out_bcount_full(size)
+#define __deref_opt_inout
+#define __deref_opt_inout_ecount(size)
+#define __deref_opt_inout_bcount(size)
+#define __deref_opt_inout_ecount_part(size,length)
+#define __deref_opt_inout_bcount_part(size,length)
+#define __deref_opt_inout_ecount_full(size)
+#define __deref_opt_inout_bcount_full(size)
+#define __deref_opt_inout_z
+#define __deref_opt_inout_ecount_z(size)
+#define __deref_opt_inout_bcount_z(size)
+#define __deref_opt_inout_nz
+#define __deref_opt_inout_ecount_nz(size)
+#define __deref_opt_inout_bcount_nz(size)
+#define __deref_opt_ecount_opt(size)
+#define __deref_opt_bcount_opt(size)
+#define __deref_opt_out_opt
+#define __deref_opt_out_ecount_opt(size)
+#define __deref_opt_out_bcount_opt(size)
+#define __deref_opt_out_ecount_part_opt(size,length)
+#define __deref_opt_out_bcount_part_opt(size,length)
+#define __deref_opt_out_ecount_full_opt(size)
+#define __deref_opt_out_bcount_full_opt(size)
+#define __deref_opt_out_z_opt
+#define __deref_opt_out_ecount_z_opt(size)
+#define __deref_opt_out_bcount_z_opt(size)
+#define __deref_opt_out_nz_opt
+#define __deref_opt_out_ecount_nz_opt(size)
+#define __deref_opt_out_bcount_nz_opt(size)
+#define __deref_opt_inout_opt
+#define __deref_opt_inout_ecount_opt(size)
+#define __deref_opt_inout_bcount_opt(size)
+#define __deref_opt_inout_ecount_part_opt(size,length)
+#define __deref_opt_inout_bcount_part_opt(size,length)
+#define __deref_opt_inout_ecount_full_opt(size)
+#define __deref_opt_inout_bcount_full_opt(size)
+#define __deref_opt_inout_z_opt
+#define __deref_opt_inout_ecount_z_opt(size)
+#define __deref_opt_inout_bcount_z_opt(size)
+#define __deref_opt_inout_nz_opt
+#define __deref_opt_inout_ecount_nz_opt(size)
+#define __deref_opt_inout_bcount_nz_opt(size)
+#define __success(expr)
+#define __nullterminated
+#define __nullnullterminated
+#define __reserved
+#define __checkReturn
+#define __typefix(ctype)
+#define __override
+#define __callback
+#define __format_string
+#define __blocksOn(resource)
+#define __control_entrypoint(category)
+#define __data_entrypoint(category)
+#ifndef __fallthrough
+#define __fallthrough
+#endif
+#ifndef __analysis_assume
+#define __analysis_assume(expr)
+#endif
+
+//#endif
+
index a29a959..1fa768b 100644 (file)
@@ -1,5 +1,17 @@
-#ifndef _WINDEF_H
-#define _WINDEF_H
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+#ifndef _WINDEF_
+#define _WINDEF_
+
+#define _WINDEF_H // wine ...
+
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4255)
+#endif
 
 #ifndef _M_AMD64
 #if !defined(__ROS_LONG64__)
 #endif
 #endif
 
-#ifdef __cplusplus
-extern "C" {
+#ifndef NO_STRICT
+#ifndef STRICT
+#define STRICT 1
 #endif
-
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4255)
 #endif
 
-#ifndef WINVER
-#define WINVER 0x0400
-/*
- * If you need Win32 API features newer the Win95 and WinNT then you must
- * define WINVER before including windows.h or any other method of including
- * the windef.h header.
- */
-#endif
-#ifndef _WIN32_WINNT
-#define _WIN32_WINNT WINVER
-/*
- * There may be the need to define _WIN32_WINNT to a value different from
- * the value of WINVER.  I don't have any example of why you would do that.
- * However, if you must then define _WIN32_WINNT to the value required before
- * including windows.h or any other method of including the windef.h header.
- */
-#endif
 #ifndef WIN32
 #define WIN32
 #endif
-#ifndef _WIN32
+
+#if defined(_MAC) && !defined(_WIN32)
 #define _WIN32
 #endif
-#define FAR
-#define far
-#define NEAR
-#define near
-#ifndef CONST
-#define CONST const
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef WINVER
+#define WINVER 0x0502
+#endif
+
+#ifndef BASETYPES
+#define BASETYPES
+#ifndef __ROS_LONG64__
+typedef unsigned long ULONG;
+#else
+typedef unsigned int ULONG;
 #endif
+typedef ULONG *PULONG;
+typedef unsigned short USHORT;
+typedef USHORT *PUSHORT;
+typedef unsigned char UCHAR;
+typedef UCHAR *PUCHAR;
+typedef char *PSZ;
+typedef int INT;
+#endif  /* BASETYPES */
+
 #undef MAX_PATH
 #define MAX_PATH 260
 
 #ifndef NULL
 #ifdef __cplusplus
+#ifndef _WIN64
 #define NULL 0
 #else
-#define NULL ((void*)0)
+#define NULL 0LL
+#endif  /* W64 */
+#else
+#define NULL ((void *)0)
 #endif
 #endif
+
 #ifndef FALSE
 #define FALSE 0
 #endif
+
 #ifndef TRUE
 #define TRUE 1
 #endif
 
+#ifndef _NO_W32_PSEUDO_MODIFIERS
 #ifndef IN
 #define IN
 #endif
@@ -74,50 +92,10 @@ extern "C" {
 #ifndef OPTIONAL
 #define OPTIONAL
 #endif
-
-/* needed by header files generated by WIDL */
-#ifdef __WINESRC__
-#define WINE_NO_UNICODE_MACROS
-#endif
-
-#ifdef WINE_NO_UNICODE_MACROS
-# define WINELIB_NAME_AW(func) \
-    func##_must_be_suffixed_with_W_or_A_in_this_context \
-    func##_must_be_suffixed_with_W_or_A_in_this_context
-#else  /* WINE_NO_UNICODE_MACROS */
-# ifdef UNICODE
-#  define WINELIB_NAME_AW(func) func##W
-# else
-#  define WINELIB_NAME_AW(func) func##A
-# endif
-#endif  /* WINE_NO_UNICODE_MACROS */
-
-#ifdef WINE_NO_UNICODE_MACROS
-# define DECL_WINELIB_TYPE_AW(type)  /* nothing */
-#else
-# define DECL_WINELIB_TYPE_AW(type)  typedef WINELIB_NAME_AW(type) type;
 #endif
 
 #ifdef __GNUC__
 #define PACKED __attribute__((packed))
-#ifndef _fastcall
-#define _fastcall __attribute__((fastcall))
-#endif
-#ifndef __fastcall
-#define __fastcall __attribute__((fastcall))
-#endif
-#ifndef _stdcall
-#define _stdcall __attribute__((stdcall))
-#endif
-#ifndef __stdcall
-#define __stdcall __attribute__((stdcall))
-#endif
-#ifndef _cdecl
-#define _cdecl __attribute__((cdecl))
-#endif
-#ifndef __cdecl
-#define __cdecl __attribute__((cdecl))
-#endif
 #ifndef __declspec
 #define __declspec(e) __attribute__((e))
 #endif
@@ -132,42 +110,6 @@ extern "C" {
 #define __cdecl
 #endif
 
-#undef pascal
-#undef _pascal
-#undef __pascal
-#define pascal __stdcall
-#define _pascal __stdcall
-#define __pascal __stdcall
-
-#define CDECL _cdecl
-
-#if !defined(__x86_64__) //defined(_STDCALL_SUPPORTED)
-#define CALLBACK    __stdcall
-#define WINAPI      __stdcall
-#define WINAPIV     __cdecl
-#define APIENTRY    WINAPI
-#define APIPRIVATE  __stdcall
-#define PASCAL      __stdcall
-#else
-#define CALLBACK
-#define WINAPI
-#define WINAPIV
-#define APIENTRY    WINAPI
-#define APIPRIVATE
-#define PASCAL      pascal
-#endif
-
-#define DECLSPEC_IMPORT __declspec(dllimport)
-#define DECLSPEC_EXPORT __declspec(dllexport)
-#ifndef DECLSPEC_NOINLINE
-#if (_MSC_VER >= 1300)
-#define DECLSPEC_NOINLINE  __declspec(noinline)
-#elif defined(__GNUC__)
-#define DECLSPEC_NOINLINE __attribute__((noinline))
-#else
-#define DECLSPEC_NOINLINE
-#endif
-#endif
 #ifdef __GNUC__
 #define DECLSPEC_NORETURN __declspec(noreturn)
 #define DECLARE_STDCALL_P( type ) __stdcall type
@@ -178,172 +120,116 @@ extern "C" {
 #define DECLSPEC_NORETURN __declspec(noreturn)
 #define DECLARE_STDCALL_P( type ) type __stdcall
 #endif /* __GNUC__/__WATCOMC__ */
-#define MAKEWORD(a,b)  ((WORD)(((BYTE)(a))|(((WORD)((BYTE)(b)))<<8)))
-#define MAKELONG(a,b)  ((LONG)(((WORD)(a))|(((DWORD)((WORD)(b)))<<16)))
-#define LOWORD(l)      ((WORD)((DWORD_PTR)(l)))
-#define HIWORD(l)      ((WORD)(((DWORD_PTR)(l)>>16)&0xFFFF))
-#define LOBYTE(w)      ((BYTE)(w))
-#define HIBYTE(w)      ((BYTE)(((WORD)(w)>>8)&0xFF))
 
-#ifndef __WATCOMC__
-#ifndef _export
-#define _export
-#endif
-#ifndef __export
-#define __export
+#define DECLSPEC_IMPORT __declspec(dllimport)
+#define DECLSPEC_EXPORT __declspec(dllexport)
+#ifndef DECLSPEC_NOINLINE
+#if (_MSC_VER >= 1300)
+#define DECLSPEC_NOINLINE  __declspec(noinline)
+#elif defined(__GNUC__)
+#define DECLSPEC_NOINLINE __attribute__((noinline))
+#else
+#define DECLSPEC_NOINLINE
 #endif
 #endif
 
-#ifndef NOMINMAX
-    #ifndef max
-        #define max(a,b) ((a)>(b)?(a):(b))
-    #endif
-
-    #ifndef min
-        #define min(a,b) ((a)<(b)?(a):(b))
-    #endif
-#endif
+#undef far
+#undef near
+#undef pascal
 
-#define UNREFERENCED_PARAMETER(P) {(P)=(P);}
-#define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);}
-#define DBG_UNREFERENCED_PARAMETER(P)
-#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
+#define far
+#define near
+#define pascal __stdcall
 
-#ifndef __ANONYMOUS_DEFINED
-#define __ANONYMOUS_DEFINED
+//#define cdecl _cdecl
+#ifndef CDECL
+#define CDECL _cdecl
+#endif
 
-#ifndef NONAMELESSUNION
-#ifdef __GNUC__
-#define _ANONYMOUS_UNION __extension__
-#define _ANONYMOUS_STRUCT __extension__
-#elif defined(__WATCOMC__) || defined(_MSC_VER)
-#define _ANONYMOUS_UNION
-#define _ANONYMOUS_STRUCT
-#endif /* __GNUC__/__WATCOMC__ */
-#endif /* NONAMELESSUNION */
-
-#ifndef _ANONYMOUS_UNION
-#define _ANONYMOUS_UNION
-#define _UNION_NAME(x) x
-#define DUMMYUNIONNAME u
-#define DUMMYUNIONNAME1        u1
-#define DUMMYUNIONNAME2        u2
-#define DUMMYUNIONNAME3        u3
-#define DUMMYUNIONNAME4        u4
-#define DUMMYUNIONNAME5        u5
-#define DUMMYUNIONNAME6        u6
-#define DUMMYUNIONNAME7        u7
-#define DUMMYUNIONNAME8        u8
-#else
-#define _UNION_NAME(x)
-#define DUMMYUNIONNAME
-#define DUMMYUNIONNAME1
-#define DUMMYUNIONNAME2
-#define DUMMYUNIONNAME3
-#define DUMMYUNIONNAME4
-#define DUMMYUNIONNAME5
-#define DUMMYUNIONNAME6
-#define DUMMYUNIONNAME7
-#define DUMMYUNIONNAME8
-#endif
-#ifndef _ANONYMOUS_STRUCT
-#define _ANONYMOUS_STRUCT
-#define _STRUCT_NAME(x) x
-#define DUMMYSTRUCTNAME        s
-#define DUMMYSTRUCTNAME1 s1
-#define DUMMYSTRUCTNAME2 s2
-#define DUMMYSTRUCTNAME3 s3
-#define DUMMYSTRUCTNAME4 s4
-#define DUMMYSTRUCTNAME5 s5
+#if !defined(__x86_64__) //defined(_STDCALL_SUPPORTED)
+#ifndef CALLBACK
+#define CALLBACK __stdcall
+#endif
+#ifndef WINAPI
+#define WINAPI __stdcall
+#endif
+#define WINAPIV __cdecl
+#define APIENTRY WINAPI
+#define APIPRIVATE WINAPI
+#define PASCAL WINAPI
 #else
-#define _STRUCT_NAME(x)
-#define DUMMYSTRUCTNAME
-#define DUMMYSTRUCTNAME1
-#define DUMMYSTRUCTNAME2
-#define DUMMYSTRUCTNAME3
-#define DUMMYSTRUCTNAME4
-#define DUMMYSTRUCTNAME5
+#define CALLBACK
+#define WINAPI
+#define WINAPIV
+#define APIENTRY WINAPI
+#define APIPRIVATE
+#define PASCAL pascal
 #endif
 
-#endif /* __ANONYMOUS_DEFINED */
+#undef FAR
+#undef NEAR
+#define FAR
+#define NEAR
 
-#ifndef NO_STRICT
-#ifndef STRICT
-#define STRICT 1
+#ifndef CONST
+#define CONST const
 #endif
+
+#ifndef _DEF_WINBOOL_
+#define _DEF_WINBOOL_
+typedef int WINBOOL;
+#pragma push_macro("BOOL")
+#undef BOOL
+#if !defined(__OBJC__) && !defined(__OBJC_BOOL) && !defined(__objc_INCLUDE_GNU)
+typedef int BOOL;
 #endif
+#define BOOL WINBOOL
+typedef BOOL *PBOOL;
+typedef BOOL *LPBOOL;
+#pragma pop_macro("BOOL")
+#endif /* _DEF_WINBOOL_ */
 
-#ifndef DWORD_DEFINED
-#define DWORD_DEFINED
+typedef unsigned char BYTE;
+typedef unsigned short WORD;
 #ifndef __ROS_LONG64__
     typedef unsigned long DWORD;
 #else
     typedef unsigned int DWORD;
 #endif
-#endif//DWORD_DEFINED
-
-typedef int WINBOOL,*PWINBOOL,*LPWINBOOL;
-/* FIXME: Is there a good solution to this? */
-#ifndef XFree86Server
-#ifndef __OBJC__
-typedef WINBOOL BOOL;
-#else
-#define BOOL WINBOOL
-#endif
-typedef unsigned char BYTE;
-#endif /* ndef XFree86Server */
-typedef BOOL *PBOOL,*LPBOOL;
-typedef unsigned short WORD;
 typedef float FLOAT;
 typedef FLOAT *PFLOAT;
-typedef BYTE *PBYTE,*LPBYTE;
-typedef int *PINT,*LPINT;
-typedef WORD *PWORD,*LPWORD;
+typedef BYTE *PBYTE;
+typedef BYTE *LPBYTE;
+typedef int *PINT;
+typedef int *LPINT;
+typedef WORD *PWORD;
+typedef WORD *LPWORD;
 #ifndef __ROS_LONG64__
 typedef long *LPLONG;
 #else
 typedef int *LPLONG;
 #endif
-typedef DWORD *PDWORD,*LPDWORD;
+typedef DWORD *PDWORD;
+typedef DWORD *LPDWORD;
+typedef void *LPVOID;
+#ifndef _LPCVOID_DEFINED
+#define _LPCVOID_DEFINED
 typedef CONST void *LPCVOID;
+#endif
+//typedef int INT;
+typedef unsigned int UINT;
+typedef unsigned int *PUINT;
+typedef unsigned int *LPUINT;
 
-typedef unsigned int UINT,*PUINT,*LPUINT;
 
-typedef void *LPVOID;
 
-#ifndef __ms_va_list
-# if defined(__x86_64__) && defined (__GNUC__)
-#  define __ms_va_list __builtin_ms_va_list
-#  define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
-#  define __ms_va_end(list) __builtin_ms_va_end(list)
-# else
-#  define __ms_va_list va_list
-#  define __ms_va_start(list,arg) va_start(list,arg)
-#  define __ms_va_end(list) va_end(list)
-# endif
-#endif
-
-//
-// Check if ntdef.h already defined these for us
-//
-#ifndef BASETYPES
-#define BASETYPES
-#ifndef __ROS_LONG64__
-typedef unsigned long ULONG, *PULONG;
-#else
-typedef unsigned int ULONG, *PULONG;
-#endif
-typedef unsigned short USHORT, *PUSHORT;
-typedef unsigned char UCHAR, *PUCHAR;
-typedef char *PSZ;
-typedef int INT;
-#endif  /* BASETYPES */
 
 #ifndef NT_INCLUDED
 #include <winnt.h>
 #endif
 
-typedef HANDLE *LPHANDLE;
+//#include <specstrings.h>
+
 typedef UINT_PTR WPARAM;
 typedef LONG_PTR LPARAM;
 typedef LONG_PTR LRESULT;
@@ -351,14 +237,54 @@ typedef LONG_PTR LRESULT;
 typedef LONG HRESULT;
 #define _HRESULT_DEFINED
 #endif
-#ifndef XFree86Server
+
+#ifndef NOMINMAX
+#ifndef max
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+#ifndef min
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+#endif
+
+#define MAKEWORD(a,b) ((WORD)(((BYTE)((DWORD_PTR)(a) & 0xff)) | ((WORD)((BYTE)((DWORD_PTR)(b) & 0xff))) << 8))
+#define MAKELONG(a,b) ((LONG)(((WORD)((DWORD_PTR)(a) & 0xffff)) | ((DWORD)((WORD)((DWORD_PTR)(b) & 0xffff))) << 16))
+#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xffff))
+#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16))
+#define LOBYTE(w) ((BYTE)((DWORD_PTR)(w) & 0xff))
+#define HIBYTE(w) ((BYTE)((DWORD_PTR)(w) >> 8))
+
+#ifndef WIN_INTERNAL
+DECLARE_HANDLE (HWND);
+//DECLARE_HANDLE (HHOOK);
+#ifdef WINABLE
+DECLARE_HANDLE (HEVENT);
+#endif
+#endif
+
 typedef WORD ATOM;
-#endif /* XFree86Server */
+
+typedef HANDLE *SPHANDLE;
+typedef HANDLE *LPHANDLE;
 typedef HANDLE HGLOBAL;
 typedef HANDLE HLOCAL;
 typedef HANDLE GLOBALHANDLE;
 typedef HANDLE LOCALHANDLE;
+#ifdef _WIN64
+typedef INT_PTR (WINAPI *FARPROC)();
+typedef INT_PTR (WINAPI *NEARPROC)();
+typedef INT_PTR (WINAPI *PROC)();
+#else
+typedef int (WINAPI *FARPROC)();
+typedef int (WINAPI *NEARPROC)();
+typedef int (WINAPI *PROC)();
+#endif
+
 typedef void *HGDIOBJ;
+
+DECLARE_HANDLE(HKEY);
+typedef HKEY *PHKEY;
+
 DECLARE_HANDLE(HACCEL);
 DECLARE_HANDLE(HBITMAP);
 DECLARE_HANDLE(HBRUSH);
@@ -369,16 +295,6 @@ DECLARE_HANDLE(HDESK);
 DECLARE_HANDLE(HENHMETAFILE);
 DECLARE_HANDLE(HFONT);
 DECLARE_HANDLE(HICON);
-DECLARE_HANDLE(HKEY);
-/* FIXME: How to handle these. SM_CMONITORS etc in winuser.h also. */
-/* #if (WINVER >= 0x0500) */
-DECLARE_HANDLE(HMONITOR);
-DECLARE_HANDLE(HUMPD);
-#define HMONITOR_DECLARED 1
-DECLARE_HANDLE(HTERMINAL);
-DECLARE_HANDLE(HWINEVENTHOOK);
-/* #endif */
-typedef HKEY *PHKEY;
 DECLARE_HANDLE(HMENU);
 DECLARE_HANDLE(HMETAFILE);
 DECLARE_HANDLE(HINSTANCE);
@@ -389,49 +305,182 @@ DECLARE_HANDLE(HRGN);
 DECLARE_HANDLE(HRSRC);
 DECLARE_HANDLE(HSTR);
 DECLARE_HANDLE(HTASK);
-DECLARE_HANDLE(HWND);
 DECLARE_HANDLE(HWINSTA);
 DECLARE_HANDLE(HKL);
+DECLARE_HANDLE(HMONITOR);
+DECLARE_HANDLE(HWINEVENTHOOK);
+DECLARE_HANDLE(HUMPD);
+
 typedef int HFILE;
 typedef HICON HCURSOR;
 typedef DWORD COLORREF;
-typedef DWORD* LPCOLORREF;
-#ifdef _WIN64
-typedef INT_PTR (FAR WINAPI *FARPROC)();
-typedef INT_PTR (NEAR WINAPI *NEARPROC)();
-typedef INT_PTR (WINAPI *PROC)();
-#else
-typedef int (FAR WINAPI *FARPROC)();
-typedef int (NEAR WINAPI *NEARPROC)();
-typedef int (WINAPI *PROC)();
-#endif
+typedef DWORD *LPCOLORREF;
+
+#define HFILE_ERROR ((HFILE)-1)
+
 typedef struct tagRECT {
        LONG left;
        LONG top;
        LONG right;
        LONG bottom;
-} RECT,*PRECT,*LPRECT;
+} RECT,*PRECT,*NPRECT,*LPRECT;
+
 typedef const RECT *LPCRECT;
-typedef struct tagRECTL {
+
+typedef struct _RECTL {
        LONG left;
        LONG top;
        LONG right;
        LONG bottom;
 } RECTL,*PRECTL,*LPRECTL;
+
 typedef const RECTL *LPCRECTL;
+
 typedef struct tagPOINT {
        LONG x;
        LONG y;
-} POINT,POINTL,*PPOINT,*LPPOINT,*PPOINTL,*LPPOINTL;
+} POINT,*PPOINT,*NPPOINT,*LPPOINT;
+
+typedef struct _POINTL {
+  LONG x;
+  LONG y;
+} POINTL,*PPOINTL;
+
 typedef struct tagSIZE {
        LONG cx;
        LONG cy;
-} SIZE,SIZEL,*PSIZE,*LPSIZE,*PSIZEL,*LPSIZEL;
+} SIZE,*PSIZE,*LPSIZE;
+
+typedef SIZE SIZEL;
+typedef SIZE *PSIZEL,*LPSIZEL;
+
 typedef struct tagPOINTS {
        SHORT x;
        SHORT y;
 } POINTS,*PPOINTS,*LPPOINTS;
 
+typedef struct _FILETIME {
+  DWORD dwLowDateTime;
+  DWORD dwHighDateTime;
+} FILETIME,*PFILETIME,*LPFILETIME;
+#define _FILETIME_
+
+#define DM_UPDATE 1
+#define DM_COPY 2
+#define DM_PROMPT 4
+#define DM_MODIFY 8
+
+#define DM_IN_BUFFER DM_MODIFY
+#define DM_IN_PROMPT DM_PROMPT
+#define DM_OUT_BUFFER DM_COPY
+#define DM_OUT_DEFAULT DM_UPDATE
+
+#define DC_FIELDS 1
+#define DC_PAPERS 2
+#define DC_PAPERSIZE 3
+#define DC_MINEXTENT 4
+#define DC_MAXEXTENT 5
+#define DC_BINS 6
+#define DC_DUPLEX 7
+#define DC_SIZE 8
+#define DC_EXTRA 9
+#define DC_VERSION 10
+#define DC_DRIVER 11
+#define DC_BINNAMES 12
+#define DC_ENUMRESOLUTIONS 13
+#define DC_FILEDEPENDENCIES 14
+#define DC_TRUETYPE 15
+#define DC_PAPERNAMES 16
+#define DC_ORIENTATION 17
+#define DC_COPIES 18
+
+/* needed by header files generated by WIDL */
+#ifdef __WINESRC__
+#define WINE_NO_UNICODE_MACROS
+#endif
+
+#ifdef WINE_NO_UNICODE_MACROS
+# define WINELIB_NAME_AW(func) \
+    func##_must_be_suffixed_with_W_or_A_in_this_context \
+    func##_must_be_suffixed_with_W_or_A_in_this_context
+#else  /* WINE_NO_UNICODE_MACROS */
+# ifdef UNICODE
+#  define WINELIB_NAME_AW(func) func##W
+# else
+#  define WINELIB_NAME_AW(func) func##A
+# endif
+#endif  /* WINE_NO_UNICODE_MACROS */
+
+#ifdef WINE_NO_UNICODE_MACROS
+# define DECL_WINELIB_TYPE_AW(type)  /* nothing */
+#else
+# define DECL_WINELIB_TYPE_AW(type)  typedef WINELIB_NAME_AW(type) type;
+#endif
+
+#define UNREFERENCED_PARAMETER(P) {(P)=(P);}
+#define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);}
+#define DBG_UNREFERENCED_PARAMETER(P)
+#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
+
+#ifndef __WATCOMC__
+#ifndef _export
+#define _export
+#endif
+#ifndef __export
+#define __export
+#endif
+#endif
+
+#if 0
+#ifdef __GNUC__
+#define PACKED __attribute__((packed))
+//#ifndef _fastcall
+//#define _fastcall __attribute__((fastcall))
+//#endif
+//#ifndef __fastcall
+//#define __fastcall __attribute__((fastcall))
+//#endif
+//#ifndef _stdcall
+//#define _stdcall __attribute__((stdcall))
+//#endif
+//#ifndef __stdcall
+//#define __stdcall __attribute__((stdcall))
+//#endif
+//#ifndef _cdecl
+//#define _cdecl __attribute__((cdecl))
+//#endif
+//#ifndef __cdecl
+//#define __cdecl __attribute__((cdecl))
+//#endif
+#ifndef __declspec
+#define __declspec(e) __attribute__((e))
+#endif
+#ifndef _declspec
+#define _declspec(e) __attribute__((e))
+#endif
+#elif defined(__WATCOMC__)
+#define PACKED
+#else
+#define PACKED
+#define _cdecl
+#define __cdecl
+#endif
+#endif
+
+#if 1 // needed by shlwapi.h
+#ifndef __ms_va_list
+# if defined(__x86_64__) && defined (__GNUC__)
+#  define __ms_va_list __builtin_ms_va_list
+#  define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
+#  define __ms_va_end(list) __builtin_ms_va_end(list)
+# else
+#  define __ms_va_list va_list
+#  define __ms_va_start(list,arg) va_start(list,arg)
+#  define __ms_va_end(list) va_end(list)
+# endif
+#endif
+#endif
+
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -439,4 +488,6 @@ typedef struct tagPOINTS {
 #ifdef __cplusplus
 }
 #endif
-#endif
+
+#endif /* _WINDEF_ */
+
index 50dbd6b..72bfc27 100644 (file)
 #include <msvctarget.h>
 #endif
 
+#ifndef __ANONYMOUS_DEFINED
+#define __ANONYMOUS_DEFINED
+#ifndef NONAMELESSUNION
+#ifdef __GNUC__
+#define _ANONYMOUS_UNION __extension__
+#define _ANONYMOUS_STRUCT __extension__
+#elif defined(__WATCOMC__) || defined(_MSC_VER)
+#define _ANONYMOUS_UNION
+#define _ANONYMOUS_STRUCT
+#endif /* __GNUC__/__WATCOMC__ */
+#endif /* NONAMELESSUNION */
+#ifndef _ANONYMOUS_UNION
+#define _ANONYMOUS_UNION
+#define _UNION_NAME(x) x
+#define DUMMYUNIONNAME u
+#define DUMMYUNIONNAME1        u1
+#define DUMMYUNIONNAME2        u2
+#define DUMMYUNIONNAME3        u3
+#define DUMMYUNIONNAME4        u4
+#define DUMMYUNIONNAME5        u5
+#define DUMMYUNIONNAME6        u6
+#define DUMMYUNIONNAME7        u7
+#define DUMMYUNIONNAME8        u8
+#else
+#define _UNION_NAME(x)
+#define DUMMYUNIONNAME
+#define DUMMYUNIONNAME1
+#define DUMMYUNIONNAME2
+#define DUMMYUNIONNAME3
+#define DUMMYUNIONNAME4
+#define DUMMYUNIONNAME5
+#define DUMMYUNIONNAME6
+#define DUMMYUNIONNAME7
+#define DUMMYUNIONNAME8
+#endif
+#ifndef _ANONYMOUS_STRUCT
+#define _ANONYMOUS_STRUCT
+#define _STRUCT_NAME(x) x
+#define DUMMYSTRUCTNAME        s
+#define DUMMYSTRUCTNAME1 s1
+#define DUMMYSTRUCTNAME2 s2
+#define DUMMYSTRUCTNAME3 s3
+#define DUMMYSTRUCTNAME4 s4
+#define DUMMYSTRUCTNAME5 s5
+#else
+#define _STRUCT_NAME(x)
+#define DUMMYSTRUCTNAME
+#define DUMMYSTRUCTNAME1
+#define DUMMYSTRUCTNAME2
+#define DUMMYSTRUCTNAME3
+#define DUMMYSTRUCTNAME4
+#define DUMMYSTRUCTNAME5
+#endif
+#endif /* __ANONYMOUS_DEFINED */
+
+
 #ifndef DECLSPEC_ALIGN
 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
 #  define DECLSPEC_ALIGN(x) __declspec(align(x))
@@ -5209,12 +5265,24 @@ MemoryBarrier(VOID)
 #endif
 
 #if defined(_M_IX86)
+
 #ifdef _MSC_VER
+#pragma intrinsic(__int2c)
 #pragma intrinsic(_mm_pause)
 #define YieldProcessor _mm_pause
 #else
 #define YieldProcessor() __asm__ __volatile__("pause");
+#define __int2c() __asm__ __volatile__("int $0x2c");
 #endif
+
+
+FORCEINLINE
+VOID
+DbgRaiseAssertionFailure(VOID)
+{
+    __int2c();
+}
+
 #elif defined (_M_AMD64)
 #ifdef _MSC_VER
 #pragma intrinsic(_mm_pause)
index ad235b0..97d7298 100644 (file)
@@ -173,6 +173,12 @@ typedef struct _KPCR
     ULONG StallScaleFactor;
     UCHAR SpareUnused;
     UCHAR Number;
+    UCHAR Spare0;
+    UCHAR SecondLevelCacheAssociativity;
+    ULONG VdmAlert;
+    ULONG KernelReserved[14];
+    ULONG SecondLevelCacheSize;
+    ULONG HalReserved[16];
 } KPCR, *PKPCR;
 
 //
@@ -246,6 +252,35 @@ KeRaiseIrqlToDpcLevel(
 #define KeLowerIrql(NewIrql) KfLowerIrql(NewIrql)
 #define KeRaiseIrql(NewIrql, OldIrql) *(OldIrql) = KfRaiseIrql(NewIrql)
 
+NTHALAPI
+KIRQL
+FASTCALL
+KfAcquireSpinLock(
+  IN OUT PKSPIN_LOCK SpinLock);
+#define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
+
+NTHALAPI
+VOID
+FASTCALL
+KfReleaseSpinLock(
+  IN OUT PKSPIN_LOCK SpinLock,
+  IN KIRQL NewIrql);
+#define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
+
+NTKERNELAPI
+VOID
+FASTCALL
+KefAcquireSpinLockAtDpcLevel(
+  IN OUT PKSPIN_LOCK SpinLock);
+#define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
+
+NTKERNELAPI
+VOID
+FASTCALL
+KefReleaseSpinLockFromDpcLevel(
+  IN OUT PKSPIN_LOCK SpinLock);
+#define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
+
 //
 // Cache clean and flush
 //
@@ -258,6 +293,26 @@ VOID
 HalSweepIcache(
     VOID
 );
+
+FORCEINLINE
+VOID
+_KeQueryTickCount(
+  OUT PLARGE_INTEGER CurrentCount)
+{
+  for (;;) {
+#ifdef NONAMELESSUNION
+    CurrentCount->s.HighPart = KeTickCount.High1Time;
+    CurrentCount->s.LowPart = KeTickCount.LowPart;
+    if (CurrentCount->s.HighPart == KeTickCount.High2Time) break;
+#else
+    CurrentCount->HighPart = KeTickCount.High1Time;
+    CurrentCount->LowPart = KeTickCount.LowPart;
+    if (CurrentCount->HighPart == KeTickCount.High2Time) break;
+#endif
+    YieldProcessor();
+  }
+}
+#define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount)
 #endif
 
 //
index 17ba84c..c2f23fb 100644 (file)
@@ -83,7 +83,7 @@ static inline EXCEPTION_REGISTRATION_RECORD *__wine_push_frame( EXCEPTION_REGIST
 #else
     NT_TIB *teb = (NT_TIB *)NtCurrentTeb();
     frame->Prev = teb->ExceptionList;
-    teb->ExceptionList = frame;
+    teb->ExceptionList = (PVOID)frame;
     return frame->Prev;
 #endif
 }
@@ -96,7 +96,7 @@ static inline EXCEPTION_REGISTRATION_RECORD *__wine_pop_frame( EXCEPTION_REGISTR
 #else
     NT_TIB *teb = (NT_TIB *)NtCurrentTeb();
     frame->Prev = teb->ExceptionList;
-    teb->ExceptionList = frame;
+    teb->ExceptionList = (PVOID)frame;
     return frame->Prev;
 #endif
 }
index e3ef14e..693e42d 100644 (file)
@@ -67,6 +67,6 @@ void _assert(const char *exp, const char *file, unsigned line)
     /* Does the user want to debug? */
     if (iResult == IDRETRY)
     {
-        __debugbreak();
+        DbgRaiseAssertionFailure();
     }
 }
index 64359a5..da0fd71 100644 (file)
@@ -48,6 +48,7 @@ FsRtlDissectDbcs(IN ANSI_STRING Name,
 {
     ULONG FirstPosition, i;
     ULONG SkipFirstSlash = 0;
+    PAGED_CODE();
 
     /* Zero the strings before continuing */
     RtlZeroMemory(FirstPart, sizeof(ANSI_STRING));
@@ -116,6 +117,7 @@ NTAPI
 FsRtlDoesDbcsContainWildCards(IN PANSI_STRING Name)
 {
     ULONG i;
+    PAGED_CODE();
 
     /* Check every character */
     for (i = 0; i < Name->Length; i++)
@@ -138,7 +140,7 @@ FsRtlDoesDbcsContainWildCards(IN PANSI_STRING Name)
 
 /*++
  * @name FsRtlIsDbcsInExpression
- * @implemented
+ * @halfplemented
  *
  * Check if the Name string is in the Expression string.
  *
@@ -150,7 +152,7 @@ FsRtlDoesDbcsContainWildCards(IN PANSI_STRING Name)
  *
  * @return TRUE if Name is found in Expression, FALSE otherwise
  *
- * @remarks None
+ * @remarks Implementation should be fixed to handle wildcards
  *
  *--*/
 BOOLEAN
@@ -159,7 +161,10 @@ FsRtlIsDbcsInExpression(IN PANSI_STRING Expression,
                         IN PANSI_STRING Name)
 {
     ULONG ExpressionPosition, NamePosition, MatchingChars = 0;
+    PAGED_CODE();
 
+    ASSERT(Name->Length);
+    ASSERT(Expression->Length);
     ASSERT(!FsRtlDoesDbcsContainWildCards(Name));
 
     /* One can't be null, both can be */
@@ -242,6 +247,7 @@ FsRtlIsFatDbcsLegal(IN ANSI_STRING DbcsName,
     ANSI_STRING FirstPart, RemainingPart, Name;
     BOOLEAN LastDot;
     ULONG i;
+    PAGED_CODE();
 
     /* Just quit if the string is empty */
     if (!DbcsName.Length)
@@ -378,6 +384,7 @@ FsRtlIsHpfsDbcsLegal(IN ANSI_STRING DbcsName,
 {
     ANSI_STRING FirstPart, RemainingPart, Name;
     ULONG i;
+    PAGED_CODE();
 
     /* Just quit if the string is empty */
     if (!DbcsName.Length)
index 24d88c4..89c6707 100644 (file)
@@ -3,7 +3,7 @@
  * LICENSE:         GPL - See COPYING in the top level directory
  * FILE:            ntoskrnl/fsrtl/filtrctx.c
  * PURPOSE:         File Stream Filter Context support for File System Drivers
- * PROGRAMMERS:     None.
+ * PROGRAMMERS:     Pierre Schweitzer (pierre.schweitzer@reactos.org)
  */
 
 /* INCLUDES ******************************************************************/
 #define NDEBUG
 #include <debug.h>
 
+/* PRIVATE FUNCTIONS *********************************************************/
+
+typedef struct _FILE_OBJECT_FILTER_CONTEXTS
+{
+    FAST_MUTEX FilterContextsMutex;
+    LIST_ENTRY FilterContexts;
+} FILE_OBJECT_FILTER_CONTEXTS, *PFILE_OBJECT_FILTER_CONTEXTS;
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+FsRtlPTeardownPerFileObjectContexts(IN PFILE_OBJECT FileObject)
+{
+    PFILE_OBJECT_FILTER_CONTEXTS FOContext = NULL;
+
+    ASSERT(FileObject);
+
+    if (!(FOContext = IoGetFileObjectFilterContext(FileObject)))
+    {
+        return;
+    }
+
+    ASSERT(IoChangeFileObjectFilterContext(FileObject, FOContext, FALSE) == STATUS_SUCCESS);
+    ASSERT(IsListEmpty(&(FOContext->FilterContexts)));
+
+    ExFreePoolWithTag(FOContext, 'FOCX');
+}
+
+
 /* PUBLIC FUNCTIONS **********************************************************/
 
 /*++
  * @name FsRtlIsPagingFile
- * @implemented NT 4.0
+ * @implemented NT 5.2
  *
  *     The FsRtlIsPagingFile routine checks if the FileObject is a Paging File.
  *
@@ -32,25 +63,11 @@ LOGICAL
 NTAPI
 FsRtlIsPagingFile(IN PFILE_OBJECT FileObject)
 {
-    KeBugCheck(FILE_SYSTEM);
-    return FALSE;
+    return MmIsFileObjectAPagingFile(FileObject);
 }
 
 /*
- * @unimplemented
- */
-PFSRTL_PER_STREAM_CONTEXT
-NTAPI
-FsRtlLookupPerStreamContextInternal(IN PFSRTL_ADVANCED_FCB_HEADER StreamContext,
-                                    IN PVOID OwnerId OPTIONAL,
-                                    IN PVOID InstanceId OPTIONAL)
-{
-    KeBugCheck(FILE_SYSTEM);
-    return FALSE;
-}
-
-/*
- * @unimplemented
+ * @implemented
  */
 PFSRTL_PER_FILEOBJECT_CONTEXT
 NTAPI
@@ -58,67 +75,335 @@ FsRtlLookupPerFileObjectContext(IN PFILE_OBJECT FileObject,
                                 IN PVOID OwnerId OPTIONAL,
                                 IN PVOID InstanceId OPTIONAL)
 {
-    KeBugCheck(FILE_SYSTEM);
-    return FALSE;
+    PLIST_ENTRY NextEntry;
+    PFILE_OBJECT_FILTER_CONTEXTS FOContext = NULL;
+    PFSRTL_PER_FILEOBJECT_CONTEXT TmpPerFOContext, PerFOContext = NULL;
+
+    if (!FileObject || !(FOContext = IoGetFileObjectFilterContext(FileObject)))
+    {
+        return NULL;
+    }
+
+    ExAcquireFastMutex(&(FOContext->FilterContextsMutex));
+
+    /* If list is empty, no need to browse it */
+    if (!IsListEmpty(&(FOContext->FilterContexts)))
+    {
+        for (NextEntry = FOContext->FilterContexts.Flink;
+             NextEntry != &(FOContext->FilterContexts);
+             NextEntry = NextEntry->Flink)
+        {
+            /* If we don't have any criteria for search, first entry will be enough */
+            if (!OwnerId && !InstanceId)
+            {
+                PerFOContext = (PFSRTL_PER_FILEOBJECT_CONTEXT)NextEntry;
+                break;
+            }
+            /* Else, we've to find something that matches with the parameters. */
+            else
+            {
+                TmpPerFOContext = CONTAINING_RECORD(NextEntry, FSRTL_PER_FILEOBJECT_CONTEXT, Links);
+                if ((InstanceId && TmpPerFOContext->InstanceId == InstanceId && TmpPerFOContext->OwnerId == OwnerId) ||
+                    (OwnerId && TmpPerFOContext->OwnerId == OwnerId))
+                {
+                    PerFOContext = TmpPerFOContext;
+                    break;
+                }
+            }
+        }
+    }
+
+    ExReleaseFastMutex(&(FOContext->FilterContextsMutex));
+
+    return PerFOContext;
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
-NTSTATUS
+PFSRTL_PER_STREAM_CONTEXT
 NTAPI
-FsRtlInsertPerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER PerStreamContext,
-                            IN PFSRTL_PER_STREAM_CONTEXT Ptr)
+FsRtlLookupPerStreamContextInternal(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader,
+                                    IN PVOID OwnerId OPTIONAL,
+                                    IN PVOID InstanceId OPTIONAL)
 {
-    KeBugCheck(FILE_SYSTEM);
-    return STATUS_NOT_IMPLEMENTED;
+    PLIST_ENTRY NextEntry;
+    PFSRTL_PER_STREAM_CONTEXT TmpPerStreamContext, PerStreamContext = NULL;
+
+    ASSERT(AdvFcbHeader);
+    ASSERT(FlagOn(AdvFcbHeader->Flags2, FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS));
+
+    ExAcquireFastMutex(AdvFcbHeader->FastMutex);
+
+    /* If list is empty, no need to browse it */
+    if (!IsListEmpty(&(AdvFcbHeader->FilterContexts)))
+    {
+        for (NextEntry = AdvFcbHeader->FilterContexts.Flink;
+             NextEntry != &(AdvFcbHeader->FilterContexts);
+             NextEntry = NextEntry->Flink)
+        {
+            /* If we don't have any criteria for search, first entry will be enough */
+            if (!OwnerId && !InstanceId)
+            {
+                PerStreamContext = (PFSRTL_PER_STREAM_CONTEXT)NextEntry;
+                break;
+            }
+            /* Else, we've to find something that matches with the parameters. */
+            else
+            {
+                TmpPerStreamContext = CONTAINING_RECORD(NextEntry, FSRTL_PER_STREAM_CONTEXT, Links);
+                if ((InstanceId && TmpPerStreamContext->InstanceId == InstanceId && TmpPerStreamContext->OwnerId == OwnerId) ||
+                    (OwnerId && TmpPerStreamContext->OwnerId == OwnerId))
+                {
+                    PerStreamContext = TmpPerStreamContext;
+                    break;
+                }
+            }
+        }
+    }
+
+    ExReleaseFastMutex(AdvFcbHeader->FastMutex);
+
+    return PerStreamContext;
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
-PFSRTL_PER_STREAM_CONTEXT
+NTSTATUS
 NTAPI
-FsRtlRemovePerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER StreamContext,
-                            IN PVOID OwnerId OPTIONAL,
-                            IN PVOID InstanceId OPTIONAL)
+FsRtlInsertPerFileObjectContext(IN PFILE_OBJECT FileObject,
+                                IN PFSRTL_PER_FILEOBJECT_CONTEXT Ptr)
 {
-    KeBugCheck(FILE_SYSTEM);
-    return NULL;
+    PFILE_OBJECT_FILTER_CONTEXTS FOContext = NULL;
+
+    if (!FileObject)
+    {
+        return STATUS_INVALID_PARAMETER;
+    }
+
+    if (!(FileObject->Flags & FO_FILE_OBJECT_HAS_EXTENSION))
+    {
+        return STATUS_INVALID_DEVICE_REQUEST;
+    }
+
+    /* Get filter contexts */
+    FOContext = IoGetFileObjectFilterContext(FileObject);
+    if (!FOContext)
+    {
+        /* If there's none, allocate new structure */
+        FOContext = ExAllocatePoolWithTag(NonPagedPool, sizeof(FILE_OBJECT_FILTER_CONTEXTS), 'FOCX');
+        if (!FOContext)
+        {
+            return STATUS_INSUFFICIENT_RESOURCES;
+        }
+
+        /* Initialize it */
+        ExInitializeFastMutex(&(FOContext->FilterContextsMutex));
+        InitializeListHead(&(FOContext->FilterContexts));
+
+        /* Set it */
+        if (!IoChangeFileObjectFilterContext(FileObject, FOContext, TRUE))
+        {
+            /* If it fails, it means that someone else has set it in the meanwhile */
+            ExFreePoolWithTag(FOContext, 'FOCX');
+
+            /* So, we can get it */
+            FOContext = IoGetFileObjectFilterContext(FileObject);
+            if (!FOContext)
+            {
+                /* If we fall down here, something went very bad. This shouldn't happen */
+                ASSERT(FALSE);
+                return STATUS_UNSUCCESSFUL;
+            }
+        }
+    }
+
+    /* Finally, insert */
+    ExAcquireFastMutex(&(FOContext->FilterContextsMutex));
+    InsertHeadList(&(FOContext->FilterContexts), &(Ptr->Links));
+    ExReleaseFastMutex(&(FOContext->FilterContextsMutex));
+
+    return STATUS_SUCCESS;
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 NTSTATUS
 NTAPI
-FsRtlInsertPerFileObjectContext(IN PFILE_OBJECT FileObject,
-                                IN PFSRTL_PER_FILEOBJECT_CONTEXT Ptr)
+FsRtlInsertPerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader,
+                            IN PFSRTL_PER_STREAM_CONTEXT PerStreamContext)
 {
-    KeBugCheck(FILE_SYSTEM);
-    return STATUS_NOT_IMPLEMENTED;
+    if (!(AdvFcbHeader) || !(AdvFcbHeader->Flags2 & FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS))
+    {
+        return STATUS_INVALID_DEVICE_REQUEST;
+    }
+
+    ExAcquireFastMutex(AdvFcbHeader->FastMutex);
+    InsertHeadList(&(AdvFcbHeader->FilterContexts), &(PerStreamContext->Links));
+    ExReleaseFastMutex(AdvFcbHeader->FastMutex);
+    return STATUS_SUCCESS;
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 PFSRTL_PER_FILEOBJECT_CONTEXT
 NTAPI
-FsRtlRemovePerFileObjectContext(IN PFILE_OBJECT PerFileObjectContext,
+FsRtlRemovePerFileObjectContext(IN PFILE_OBJECT FileObject,
                                 IN PVOID OwnerId OPTIONAL,
                                 IN PVOID InstanceId OPTIONAL)
 {
-    KeBugCheck(FILE_SYSTEM);
-    return NULL;
+    PLIST_ENTRY NextEntry;
+    PFILE_OBJECT_FILTER_CONTEXTS FOContext = NULL;
+    PFSRTL_PER_FILEOBJECT_CONTEXT TmpPerFOContext, PerFOContext = NULL;
+
+    if (!FileObject || !(FOContext = IoGetFileObjectFilterContext(FileObject)))
+    {
+        return NULL;
+    }
+
+    ExAcquireFastMutex(&(FOContext->FilterContextsMutex));
+
+    /* If list is empty, no need to browse it */
+    if (!IsListEmpty(&(FOContext->FilterContexts)))
+    {
+        for (NextEntry = FOContext->FilterContexts.Flink;
+             NextEntry != &(FOContext->FilterContexts);
+             NextEntry = NextEntry->Flink)
+        {
+            /* If we don't have any criteria for search, first entry will be enough */
+            if (!OwnerId && !InstanceId)
+            {
+                PerFOContext = (PFSRTL_PER_FILEOBJECT_CONTEXT)NextEntry;
+                break;
+            }
+            /* Else, we've to find something that matches with the parameters. */
+            else
+            {
+                TmpPerFOContext = CONTAINING_RECORD(NextEntry, FSRTL_PER_FILEOBJECT_CONTEXT, Links);
+                if ((InstanceId && TmpPerFOContext->InstanceId == InstanceId && TmpPerFOContext->OwnerId == OwnerId) ||
+                    (OwnerId && TmpPerFOContext->OwnerId == OwnerId))
+                {
+                    PerFOContext = TmpPerFOContext;
+                    break;
+                }
+            }
+        }
+
+        /* Finally remove entry from list */
+        if (PerFOContext)
+        {
+            RemoveEntryList(&(PerFOContext->Links));
+        }
+    }
+
+    ExReleaseFastMutex(&(FOContext->FilterContextsMutex));
+
+    return PerFOContext;
+}
+
+/*
+ * @implemented
+ */
+PFSRTL_PER_STREAM_CONTEXT
+NTAPI
+FsRtlRemovePerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader,
+                            IN PVOID OwnerId OPTIONAL,
+                            IN PVOID InstanceId OPTIONAL)
+{
+    PLIST_ENTRY NextEntry;
+    PFSRTL_PER_STREAM_CONTEXT TmpPerStreamContext, PerStreamContext = NULL;
+
+    if (!(AdvFcbHeader) || !(AdvFcbHeader->Flags2 & FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS))
+    {
+        return NULL;
+    }
+
+    ExAcquireFastMutex(AdvFcbHeader->FastMutex);
+    /* If list is empty, no need to browse it */
+    if (!IsListEmpty(&(AdvFcbHeader->FilterContexts)))
+    {
+        for (NextEntry = AdvFcbHeader->FilterContexts.Flink;
+             NextEntry != &(AdvFcbHeader->FilterContexts);
+             NextEntry = NextEntry->Flink)
+        {
+            /* If we don't have any criteria for search, first entry will be enough */
+            if (!OwnerId && !InstanceId)
+            {
+                PerStreamContext = (PFSRTL_PER_STREAM_CONTEXT)NextEntry;
+                break;
+            }
+            /* Else, we've to find something that matches with the parameters. */
+            else
+            {
+                TmpPerStreamContext = CONTAINING_RECORD(NextEntry, FSRTL_PER_STREAM_CONTEXT, Links);
+                if ((InstanceId && TmpPerStreamContext->InstanceId == InstanceId && TmpPerStreamContext->OwnerId == OwnerId) ||
+                    (OwnerId && TmpPerStreamContext->OwnerId == OwnerId))
+                {
+                    PerStreamContext = TmpPerStreamContext;
+                    break;
+                }
+            }
+        }
+
+        /* Finally remove entry from list */
+        if (PerStreamContext)
+        {
+            RemoveEntryList(&(PerStreamContext->Links));
+        }
+    }
+    ExReleaseFastMutex(AdvFcbHeader->FastMutex);
+
+    return PerStreamContext;
+
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 VOID
 NTAPI
-FsRtlTeardownPerStreamContexts(IN PFSRTL_ADVANCED_FCB_HEADER AdvancedHeader)
+FsRtlTeardownPerStreamContexts(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader)
 {
-    KeBugCheck(FILE_SYSTEM);
-}
+    PLIST_ENTRY NextEntry;
+    BOOLEAN IsMutexLocked = FALSE;
+    PFSRTL_PER_STREAM_CONTEXT PerStreamContext;
 
+    _SEH2_TRY
+    {
+        /* Acquire mutex to deal with the list */
+        ExAcquireFastMutex(AdvFcbHeader->FastMutex);
+        IsMutexLocked = TRUE;
+
+        /* While there are items... */
+        while (!IsListEmpty(&(AdvFcbHeader->FilterContexts)))
+        {
+            /* ...remove one */
+            NextEntry = RemoveHeadList(&(AdvFcbHeader->FilterContexts));
+            PerStreamContext = CONTAINING_RECORD(NextEntry, FSRTL_PER_STREAM_CONTEXT, Links);
+
+            /* Release mutex before calling callback */
+            ExReleaseFastMutex(AdvFcbHeader->FastMutex);
+            IsMutexLocked = FALSE;
+
+            /* Call the callback */
+            ASSERT(PerStreamContext->FreeCallback);
+            (*PerStreamContext->FreeCallback)(PerStreamContext);
+
+            /* Relock the list to continue */
+            ExAcquireFastMutex(AdvFcbHeader->FastMutex);
+            IsMutexLocked = TRUE;
+        }
+    }
+    _SEH2_FINALLY
+    {
+        /* If mutex was locked, release */
+        if (IsMutexLocked)
+        {
+            ExReleaseFastMutex(AdvFcbHeader->FastMutex);
+        }
+    }
+    _SEH2_END;
+}
index 1405b9f..291ecf7 100644 (file)
@@ -23,8 +23,9 @@ FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression,
                                IN PWCHAR UpcaseTable OPTIONAL)
 {
     ULONG i = 0, j, k = 0;
+    PAGED_CODE();
 
-    ASSERT(!FsRtlDoesNameContainWildCards(Name));
+    ASSERT(!IgnoreCase || UpcaseTable);
 
     while (i < Name->Length / sizeof(WCHAR) && k < Expression->Length / sizeof(WCHAR))
     {
@@ -119,6 +120,7 @@ FsRtlAreNamesEqual(IN PCUNICODE_STRING Name1,
     BOOLEAN StringsAreEqual, MemoryAllocated = FALSE;
     ULONG i;
     NTSTATUS Status;
+    PAGED_CODE();
 
     /* Well, first check their size */
     if (Name1->Length != Name2->Length) return FALSE;
@@ -210,6 +212,7 @@ FsRtlDissectName(IN UNICODE_STRING Name,
 {
     ULONG FirstPosition, i;
     ULONG SkipFirstSlash = 0;
+    PAGED_CODE();
 
     /* Zero the strings before continuing */
     RtlZeroMemory(FirstPart, sizeof(UNICODE_STRING));
@@ -272,6 +275,7 @@ NTAPI
 FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name)
 {
     PWCHAR Ptr;
+    PAGED_CODE();
 
     /* Loop through every character */
     if (Name->Length)
index 3ac4d76..cede87c 100644 (file)
@@ -1,6 +1,6 @@
 
 .macro TEXTAREA
-    .section text, "rx"
+    .section .text, "rx"
     .align 2
 .endm
 
index 03bb7bf..b73179c 100644 (file)
@@ -1,5 +1,7 @@
 #pragma once
 
+#define _MI_PAGING_LEVELS 2
+
 #define PDE_SHIFT 20
 
 //
@@ -20,6 +22,7 @@
 #define PTE_BASE    0xC0000000
 #define PTE_TOP     0xC03FFFFF
 #define PDE_BASE    0xC0400000
+#define PDE_TOP     0xC04FFFFF
 #define HYPER_SPACE 0xC0500000
 
 #if 0
@@ -106,6 +109,7 @@ PULONG MmGetPageDirectory(VOID);
 
 #define MI_MAKE_LOCAL_PAGE(x)      ((x)->u.Hard.NonGlobal = 1)
 #define MI_MAKE_DIRTY_PAGE(x)      
+#define MI_MAKE_ACCESSED_PAGE(x)      
 #define MI_MAKE_OWNER_PAGE(x)      ((x)->u.Hard.Owner = 1)
 #define MI_MAKE_WRITE_PAGE(x)      ((x)->u.Hard.ReadOnly = 0)
 #define MI_PAGE_DISABLE_CACHE(x)   ((x)->u.Hard.Cached = 0)
@@ -114,6 +118,7 @@ PULONG MmGetPageDirectory(VOID);
 #define MI_IS_PAGE_WRITEABLE(x)    ((x)->u.Hard.ReadOnly == 0)
 #define MI_IS_PAGE_COPY_ON_WRITE(x)FALSE
 #define MI_IS_PAGE_DIRTY(x)        TRUE
+#define MI_IS_PAGE_LARGE(x)        FALSE
 
 /* Easy accessing PFN in PTE */
 #define PFN_FROM_PTE(v) ((v)->u.Hard.PageFrameNumber)
@@ -129,6 +134,12 @@ PULONG MmGetPageDirectory(VOID);
                                              MI_HYPERSPACE_PTES * PAGE_SIZE)
 #define MI_ZERO_PTE                         (PMMPTE)(MI_MAPPING_RANGE_END + \
                                              PAGE_SIZE)
+#define MI_DUMMY_PTE                        (PMMPTE)(MI_MAPPING_RANGE_END + \
+                                             PAGE_SIZE)
+#define MI_VAD_BITMAP                       (PMMPTE)(MI_DUMMY_PTE + \
+                                             PAGE_SIZE)
+#define MI_WORKING_SET_LIST                 (PMMPTE)(MI_VAD_BITMAP + \
+                                             PAGE_SIZE)
 
 /* Retrives the PDE entry for the given VA */
 #define MiGetPdeAddress(x) ((PMMPDE)(PDE_BASE + (((ULONG)(x) >> 20) << 2)))
@@ -139,8 +150,10 @@ PULONG MmGetPageDirectory(VOID);
 #define MiAddressToPte(x)  MiGetPteAddress(x)
 
 /* Retrives the PDE offset for the given VA */
-#define MiGetPdeOffset(x) (((ULONG)(x)) >> 20)
-
+#define MiGetPdeOffset(x)       (((ULONG)(x)) >> 20)
+#define MiGetPteOffset(x)       ((((ULONG)(x)) << 12) >> 24)
+#define MiAddressToPteOffset(x) MiGetPteOffset(x)
+    
 /* Convert a PTE into a corresponding address */
 #define MiPteToAddress(x) ((PVOID)((ULONG)(x) << 10))
 #define MiPdeToAddress(x) ((PVOID)((ULONG)(x) << 18))
index 7997abd..b0777de 100644 (file)
@@ -53,6 +53,15 @@ FsRtlInitSystem(
     VOID
 );
 
+//
+// File contexts Routines
+//
+VOID
+NTAPI
+FsRtlPTeardownPerFileObjectContexts(
+    IN PFILE_OBJECT FileObject
+);
+
 //
 // Global data inside the File System Runtime Library
 //
index f02cc78..83b48ef 100644 (file)
@@ -39,6 +39,7 @@ PULONG MmGetPageDirectory(VOID);
 // Convert a PTE into a corresponding address
 //
 #define MiPteToAddress(PTE) ((PVOID)((ULONG)(PTE) << 10))
+#define MiPdeToAddress(PDE) ((PVOID)((ULONG)(PDE) << 10))
 
 #define ADDR_TO_PAGE_TABLE(v) (((ULONG)(v)) / (1024 * PAGE_SIZE))
 #define ADDR_TO_PDE_OFFSET(v) ((((ULONG)(v)) / (1024 * PAGE_SIZE)))
@@ -51,9 +52,11 @@ PULONG MmGetPageDirectory(VOID);
 
 #define MI_MAKE_LOCAL_PAGE(x)      ((x)->u.Hard.Global = 0)
 #define MI_MAKE_DIRTY_PAGE(x)      ((x)->u.Hard.Dirty = 1)
+#define MI_MAKE_ACCESSED_PAGE(x)   ((x)->u.Hard.Accessed = 1)
 #define MI_PAGE_DISABLE_CACHE(x)   ((x)->u.Hard.CacheDisable = 1)
 #define MI_PAGE_WRITE_THROUGH(x)   ((x)->u.Hard.WriteThrough = 1)
 #define MI_PAGE_WRITE_COMBINED(x)  ((x)->u.Hard.WriteThrough = 0)
+#define MI_IS_PAGE_LARGE(x)        ((x)->u.Hard.LargePage == 1)
 #if !defined(CONFIG_SMP)
 #define MI_IS_PAGE_WRITEABLE(x)    ((x)->u.Hard.Write == 1)
 #else
@@ -83,13 +86,13 @@ PULONG MmGetPageDirectory(VOID);
 #define MI_ZERO_PTES                        (32)
 #define MI_MAPPING_RANGE_START              (ULONG)HYPER_SPACE
 #define MI_MAPPING_RANGE_END                (MI_MAPPING_RANGE_START + \
-                                             MI_HYPERSPACE_PTES * PAGE_SIZE)
+                                                     MI_HYPERSPACE_PTES * PAGE_SIZE)
 #define MI_DUMMY_PTE                        (PMMPTE)(MI_MAPPING_RANGE_END + \
-                                             PAGE_SIZE)
+                                                     PAGE_SIZE)
 #define MI_VAD_BITMAP                       (PMMPTE)(MI_DUMMY_PTE + \
-                                             PAGE_SIZE)
+                                                     PAGE_SIZE)
 #define MI_WORKING_SET_LIST                 (PMMPTE)(MI_VAD_BITMAP + \
-                                             PAGE_SIZE)
+                                                     PAGE_SIZE)
 
 /* On x86, these two are the same */
 #define MMPDE MMPTE
index bf676b6..8edb68e 100644 (file)
@@ -1155,6 +1155,20 @@ IopCloseFile(
     IN ULONG SystemHandleCount
 );
 
+PVOID
+NTAPI
+IoGetFileObjectFilterContext(
+    IN PFILE_OBJECT FileObject
+);
+
+NTSTATUS
+NTAPI
+IoChangeFileObjectFilterContext(
+    IN PFILE_OBJECT FileObject,
+    IN PVOID FilterContext,
+    IN BOOLEAN Define
+);
+
 //
 // I/O Timer Routines
 //
index 7499571..02fa7e9 100644 (file)
@@ -486,7 +486,7 @@ typedef struct _MM_PAGED_POOL_INFO
     PRTL_BITMAP EndOfPagedPoolBitmap;
     PMMPTE FirstPteForPagedPool;
     PMMPTE LastPteForPagedPool;
-    PMMPTE NextPdeForPagedPoolExpansion;
+    PMMPDE NextPdeForPagedPoolExpansion;
     ULONG PagedPoolHint;
     SIZE_T PagedPoolCommit;
     SIZE_T AllocatedPagedPool;
@@ -778,6 +778,10 @@ VOID
 NTAPI
 MmInitPagingFile(VOID);
 
+BOOLEAN
+NTAPI
+MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject);
+
 NTSTATUS
 NTAPI
 MmReadFromSwapPage(
index e4b8bd6..ceb4800 100644 (file)
@@ -5,7 +5,7 @@
  */
 #define PLACE_IN_SECTION(s)    __attribute__((section (s)))
 #ifdef __GNUC__
-#define INIT_FUNCTION                  PLACE_IN_SECTION("INIT")
+#define INIT_FUNCTION
 #define PAGE_LOCKED_FUNCTION   PLACE_IN_SECTION("pagelk")
 #define PAGE_UNLOCKED_FUNCTION PLACE_IN_SECTION("pagepo")
 #else
index 5f738a5..0ab4105 100644 (file)
@@ -63,7 +63,11 @@ IoCreateController(IN ULONG Size)
    PAGED_CODE();
 
    /* Initialize an empty OBA */
-   InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
+   InitializeObjectAttributes(&ObjectAttributes,
+                              NULL,
+                              OBJ_KERNEL_HANDLE,
+                              NULL,
+                              NULL);
 
    /* Create the Object */
    Status = ObCreateObject(KernelMode,
@@ -87,7 +91,7 @@ IoCreateController(IN ULONG Size)
    if (!NT_SUCCESS(Status)) return NULL;
 
     /* Close the dummy handle */
-    NtClose(Handle);
+    ObCloseHandle(Handle, KernelMode);
 
     /* Zero the Object and set its data */
     RtlZeroMemory(Controller, sizeof(CONTROLLER_OBJECT) + Size);
index 46060f4..43686de 100644 (file)
@@ -1049,6 +1049,13 @@ IopDeleteFile(IN PVOID ObjectBody)
             ExFreePool(FileObject->CompletionContext);
         }
 
+        /* Check if the FO had extension */
+        if (FileObject->Flags & FO_FILE_OBJECT_HAS_EXTENSION)
+        {
+            /* Release filter context structure if any */
+            FsRtlPTeardownPerFileObjectContexts(FileObject);
+        }
+
         /* Check if dereference has been done yet */
         if (!DereferenceDone)
         {
@@ -1610,6 +1617,36 @@ IopQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes,
     return Status;
 }
 
+PVOID
+NTAPI
+IoGetFileObjectFilterContext(IN PFILE_OBJECT FileObject)
+{
+    if (FileObject->Flags & FO_FILE_OBJECT_HAS_EXTENSION)
+    {
+        UNIMPLEMENTED;
+        /* FIXME: return NULL for the moment ~ */
+        return NULL;
+    }
+
+    return NULL;
+}
+
+NTSTATUS
+NTAPI
+IoChangeFileObjectFilterContext(IN PFILE_OBJECT FileObject,
+                                IN PVOID FilterContext,
+                                IN BOOLEAN Define)
+{
+    if (!(FileObject->Flags & FO_FILE_OBJECT_HAS_EXTENSION))
+    {
+        return STATUS_INVALID_PARAMETER;
+    }
+
+    UNIMPLEMENTED;
+
+    return STATUS_NOT_IMPLEMENTED;
+}
+
 /* FUNCTIONS *****************************************************************/
 
 /*
index eff065c..5bce735 100644 (file)
     PROLOG_END KiSystemStartup
     
     /* Put us in FIQ mode, set IRQ stack */
-    msr cpsr_c, #CPSR_FIQ_MODE
+    b .
+    mrs r3, cpsr
+    orr r3, r1, #CPSR_FIQ_MODE
+    msr cpsr, r3
     ldr sp, [a1, #LpbInterruptStack]
     
     /* Repeat for IRQ mode */
index 275df6c..37d8a15 100644 (file)
@@ -57,6 +57,15 @@ KeFlushCurrentTb(VOID)
     KeFlushTb();
 }
 
+VOID
+FASTCALL
+KeZeroPages(IN PVOID Address,
+            IN ULONG Size)
+{
+    /* Not using XMMI in this routine */
+    RtlZeroMemory(Address, Size);
+}
+
 VOID
 NTAPI
 KiSaveProcessorControlState(OUT PKPROCESSOR_STATE ProcessorState)
index a8f391f..0d6bb54 100644 (file)
     TEXTAREA
     NESTED_ENTRY KiSwapContext
     PROLOG_END KiSwapContext
+
+       // BUSTEDDDD
+       b .
+
     //
     // a1 = Old Thread
     // a2 = New Thread
     b .
     
     ENTRY_END KiThreadStartup
+
+    NESTED_ENTRY KiSwitchThreads
+    PROLOG_END KiSwitchThreads
+
+       // BUSTEDDDD
+       b .
+
+    ENTRY_END KiSwitchThreads
+
+    NESTED_ENTRY KiSwapContextInternal
+    PROLOG_END KiSwapContextInternal
+
+       // BUSTEDDDD
+       b .
+
+    ENTRY_END KiSwapContextInternal
index 16700f5..cae9b75 100644 (file)
 
 /* GLOBALS ********************************************************************/
 
+typedef struct _KSWITCHFRAME
+{
+    PVOID ExceptionList;
+    BOOLEAN ApcBypassDisable;
+    PVOID RetAddr;
+} KSWITCHFRAME, *PKSWITCHFRAME;
+
 typedef struct _KUINIT_FRAME
 {
     KEXCEPTION_FRAME CtxSwitchFrame;
@@ -32,6 +39,15 @@ VOID
 NTAPI
 KiThreadStartup(VOID);
 
+VOID
+FASTCALL
+KiSwitchThreads(
+    IN PKTHREAD OldThread,
+    IN PKTHREAD NewThread
+);
+
+
+/* FIXME: THIS IS TOTALLY BUSTED NOW */
 VOID
 NTAPI
 KiInitializeContextThread(IN PKTHREAD Thread,
@@ -131,3 +147,217 @@ KiInitializeContextThread(IN PKTHREAD Thread,
     //
     Thread->KernelStack = (PVOID)CtxSwitchFrame;
 }
+
+VOID
+FASTCALL
+KiIdleLoop(VOID)
+{
+    PKPRCB Prcb = KeGetCurrentPrcb();
+    PKTHREAD OldThread, NewThread;
+
+    /* Initialize the idle loop: disable interrupts */
+    _enable();
+    YieldProcessor();
+    YieldProcessor();
+    _disable();
+
+    /* Now loop forever */
+    while (TRUE)
+    {
+        /* Check for pending timers, pending DPCs, or pending ready threads */
+        if ((Prcb->DpcData[0].DpcQueueDepth) ||
+            (Prcb->TimerRequest) ||
+            (Prcb->DeferredReadyListHead.Next))
+        {
+            /* Quiesce the DPC software interrupt */
+            HalClearSoftwareInterrupt(DISPATCH_LEVEL);
+
+            /* Handle it */
+            KiRetireDpcList(Prcb);
+        }
+
+        /* Check if a new thread is scheduled for execution */
+        if (Prcb->NextThread)
+        {
+            /* Enable interupts */
+            _enable();
+
+            /* Capture current thread data */
+            OldThread = Prcb->CurrentThread;
+            NewThread = Prcb->NextThread;
+
+            /* Set new thread data */
+            Prcb->NextThread = NULL;
+            Prcb->CurrentThread = NewThread;
+
+            /* The thread is now running */
+            NewThread->State = Running;
+
+            /* Switch away from the idle thread */
+            KiSwapContext(APC_LEVEL, OldThread);
+
+            /* We are back in the idle thread -- disable interrupts again */
+            _enable();
+            YieldProcessor();
+            YieldProcessor();
+            _disable();
+        }
+        else
+        {
+            /* Continue staying idle. Note the HAL returns with interrupts on */
+            Prcb->PowerState.IdleFunction(&Prcb->PowerState);
+        }
+    }
+}
+
+BOOLEAN
+FASTCALL
+KiSwapContextExit(IN PKTHREAD OldThread,
+                  IN PKSWITCHFRAME SwitchFrame)
+{
+    PKIPCR Pcr = (PKIPCR)KeGetPcr();
+    PKPROCESS OldProcess, NewProcess;
+    PKTHREAD NewThread;
+    ARM_TTB_REGISTER TtbRegister;
+
+    /* We are on the new thread stack now */
+    NewThread = Pcr->PrcbData.CurrentThread;
+
+    /* Now we are the new thread. Check if it's in a new process */
+    OldProcess = OldThread->ApcState.Process;
+    NewProcess = NewThread->ApcState.Process;
+    if (OldProcess != NewProcess)
+    {
+        TtbRegister.AsUlong = NewProcess->DirectoryTableBase[0];
+        ASSERT(TtbRegister.Reserved == 0);
+        KeArmTranslationTableRegisterSet(TtbRegister);
+    }
+
+    /* Increase thread context switches */
+    NewThread->ContextSwitches++;
+
+    /* Load data from switch frame */
+    Pcr->NtTib.ExceptionList = SwitchFrame->ExceptionList;
+
+    /* DPCs shouldn't be active */
+    if (Pcr->PrcbData.DpcRoutineActive)
+    {
+        /* Crash the machine */
+        KeBugCheckEx(ATTEMPTED_SWITCH_FROM_DPC,
+                     (ULONG_PTR)OldThread,
+                     (ULONG_PTR)NewThread,
+                     (ULONG_PTR)OldThread->InitialStack,
+                     0);
+    }
+
+    /* Kernel APCs may be pending */
+    if (NewThread->ApcState.KernelApcPending)
+    {
+        /* Are APCs enabled? */
+        if (!NewThread->SpecialApcDisable)
+        {
+            /* Request APC delivery */
+            if (SwitchFrame->ApcBypassDisable) HalRequestSoftwareInterrupt(APC_LEVEL);
+            return TRUE;
+        }
+    }
+
+    /* Return */
+    return FALSE;
+}
+
+VOID
+FASTCALL
+KiSwapContextEntry(IN PKSWITCHFRAME SwitchFrame,
+                   IN ULONG_PTR OldThreadAndApcFlag)
+{
+    PKIPCR Pcr = (PKIPCR)KeGetPcr();
+    PKTHREAD OldThread, NewThread;
+
+    /* Save APC bypass disable */
+    SwitchFrame->ApcBypassDisable = OldThreadAndApcFlag & 3;
+    SwitchFrame->ExceptionList = Pcr->NtTib.ExceptionList;
+
+    /* Increase context switch count and check if tracing is enabled */
+    Pcr->ContextSwitches++;
+    if (Pcr->PerfGlobalGroupMask)
+    {
+        /* We don't support this yet on x86 either */
+        DPRINT1("WMI Tracing not supported\n");
+        ASSERT(FALSE);
+    }
+
+    /* Get thread pointers */
+    OldThread = (PKTHREAD)(OldThreadAndApcFlag & ~3);
+    NewThread = Pcr->PrcbData.CurrentThread;
+
+    /* Get the old thread and set its kernel stack */
+    OldThread->KernelStack = SwitchFrame;
+
+    /* Do the switch */
+    KiSwitchThreads(OldThread, NewThread->KernelStack);
+}
+
+VOID
+NTAPI
+KiDispatchInterrupt(VOID)
+{
+    PKIPCR Pcr = (PKIPCR)KeGetPcr();
+    PKPRCB Prcb = &Pcr->PrcbData;
+    PVOID OldHandler;
+    PKTHREAD NewThread, OldThread;
+
+    /* Disable interrupts */
+    _disable();
+
+    /* Check for pending timers, pending DPCs, or pending ready threads */
+    if ((Prcb->DpcData[0].DpcQueueDepth) ||
+        (Prcb->TimerRequest) ||
+        (Prcb->DeferredReadyListHead.Next))
+    {
+        /* Switch to safe execution context */
+        OldHandler = Pcr->NtTib.ExceptionList;
+        Pcr->NtTib.ExceptionList = EXCEPTION_CHAIN_END;
+
+        /* Retire DPCs while under the DPC stack */
+        //KiRetireDpcListInDpcStack(Prcb, Prcb->DpcStack);
+        // FIXME!!! //
+        KiRetireDpcList(Prcb);
+
+        /* Restore context */
+        Pcr->NtTib.ExceptionList = OldHandler;
+    }
+
+    /* Re-enable interrupts */
+    _enable();
+
+    /* Check for quantum end */
+    if (Prcb->QuantumEnd)
+    {
+        /* Handle quantum end */
+        Prcb->QuantumEnd = FALSE;
+        KiQuantumEnd();
+    }
+    else if (Prcb->NextThread)
+    {       
+        /* Capture current thread data */
+        OldThread = Prcb->CurrentThread;
+        NewThread = Prcb->NextThread;
+
+        /* Set new thread data */
+        Prcb->NextThread = NULL;
+        Prcb->CurrentThread = NewThread;
+
+        /* The thread is now running */
+        NewThread->State = Running;
+        OldThread->WaitReason = WrDispatchInt;
+
+        /* Make the old thread ready */
+        KxQueueReadyThread(OldThread, Prcb);
+
+        /* Swap to the new thread */
+        KiSwapContext(APC_LEVEL, OldThread);
+    }
+}
+
+/* EOF */
index edfedf4..9f731bb 100644 (file)
@@ -15,6 +15,7 @@
 
 /* FUNCTIONS ******************************************************************/
 
+#if 0
 VOID
 KiIdleLoop(VOID)
 {
@@ -89,6 +90,7 @@ KiIdleLoop(VOID)
         }
     }
 }
+#endif
 
 VOID
 NTAPI
@@ -116,6 +118,7 @@ KiSwapProcess(IN PKPROCESS NewProcess,
     while (TRUE);
 }
 
+#if 0
 BOOLEAN
 KiSwapContextInternal(IN PKTHREAD OldThread,
                       IN PKTHREAD NewThread)
@@ -220,6 +223,7 @@ KiSwapContextInternal(IN PKTHREAD OldThread,
     //
     return FALSE;
 }
+#endif
 
 VOID
 KiApcInterrupt(VOID)
@@ -262,6 +266,7 @@ KiApcInterrupt(VOID)
     KiDeliverApc(PreviousMode, &ExceptionFrame, TrapFrame);
 }
 
+#if 0
 VOID
 KiDispatchInterrupt(VOID)
 {
@@ -343,6 +348,7 @@ KiDispatchInterrupt(VOID)
         KiSwapContext(OldThread, NewThread);
     }
 }
+#endif
 
 VOID
 KiInterruptHandler(IN PKTRAP_FRAME TrapFrame,
@@ -523,7 +529,7 @@ KiDataAbortHandler(IN PKTRAP_FRAME TrapFrame)
                                Address,
                                KiGetPreviousMode(TrapFrame),
                                TrapFrame);
-        if (Status == STATUS_SUCCESS) return Status;
+        if (NT_SUCCESS(Status)) return Status;
     }
 
     //
index 091d0cb..1e44b76 100644 (file)
@@ -24,10 +24,7 @@ ULONG MmMaximumNonPagedPoolInBytes;
 PVOID MmNonPagedSystemStart;
 PVOID MmNonPagedPoolStart;
 PVOID MmNonPagedPoolExpansionStart;
-PVOID MmNonPagedPoolEnd = MI_NONPAGED_POOL_END;
-PVOID MmPagedPoolStart = MI_PAGED_POOL_START;
 PVOID MmPagedPoolEnd;
-ULONG MmSizeOfPagedPoolInBytes = MI_MIN_INIT_PAGED_POOLSIZE;
 PVOID MiSessionSpaceEnd;
 PVOID MiSessionImageEnd;
 PVOID MiSessionImageStart;
@@ -42,14 +39,14 @@ ULONG MmSessionImageSize;
 PVOID MiSystemViewStart;
 ULONG MmSystemViewSize;
 PFN_NUMBER MmSystemPageDirectory[PD_COUNT];
-PMMPTE MmSystemPagePtes;
+PMMPDE MmSystemPagePtes;
 ULONG MmNumberOfSystemPtes;
 ULONG MxPfnAllocation;
 RTL_BITMAP MiPfnBitMap;
 PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock;
 PMEMORY_ALLOCATION_DESCRIPTOR MxFreeDescriptor;
 MEMORY_ALLOCATION_DESCRIPTOR MxOldFreeDescriptor;
-ULONG MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage = -1;
+ULONG MmNumberOfPhysicalPages, MmHighestPhysicalPage;
 ULONG MmBootImageSize;
 ULONG MmUserProbeAddress;
 PVOID MmHighestUserAddress;
@@ -63,8 +60,8 @@ PVOID MmHyperSpaceEnd;
 
 NTSTATUS
 NTAPI
-MmArmInitSystem(IN ULONG Phase,
-                IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+INIT_FUNCTION
+MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 {
     //
     // Always return success for now
index b3449a3..f956bb7 100644 (file)
@@ -271,7 +271,7 @@ MmFreePagesFromMdl(IN PMDL Mdl)
         //
         Pfn1->u3.e1.StartOfAllocation = 0;
         Pfn1->u3.e1.EndOfAllocation = 0;
-        Pfn1->u2.ShareCount == 0;
+        Pfn1->u2.ShareCount = 0;
         
         //
         // Dereference it
index 1220204..e50c854 100644 (file)
@@ -130,12 +130,12 @@ C_ASSERT(SYSTEM_PD_SIZE == PAGE_SIZE);
 //
 // Access Flags
 //
-#define PTE_READONLY            0
+#define PTE_READONLY            0 // Doesn't exist on x86
 #define PTE_EXECUTE             0 // Not worrying about NX yet
 #define PTE_EXECUTE_READ        0 // Not worrying about NX yet
 #define PTE_READWRITE           0x2
 #define PTE_WRITECOPY           0x200
-#define PTE_EXECUTE_READWRITE   0x0
+#define PTE_EXECUTE_READWRITE   0x2 // Not worrying about NX yet
 #define PTE_EXECUTE_WRITECOPY   0x200
 #define PTE_PROTOTYPE           0x400
 
@@ -153,6 +153,20 @@ C_ASSERT(SYSTEM_PD_SIZE == PAGE_SIZE);
 #define PTE_DISABLE_CACHE       0x10
 #define PTE_WRITECOMBINED_CACHE 0x10
 #elif defined(_M_ARM)
+#define PTE_READONLY            0x200
+#define PTE_EXECUTE             0 // Not worrying about NX yet
+#define PTE_EXECUTE_READ        0 // Not worrying about NX yet
+#define PTE_READWRITE           0 // Doesn't exist on ARM
+#define PTE_WRITECOPY           0 // Doesn't exist on ARM
+#define PTE_EXECUTE_READWRITE   0 // Not worrying about NX yet
+#define PTE_EXECUTE_WRITECOPY   0 // Not worrying about NX yet
+#define PTE_PROTOTYPE           0x400 // Using the Shared bit
+//
+// Cache flags
+//
+#define PTE_ENABLE_CACHE        0
+#define PTE_DISABLE_CACHE       0x10
+#define PTE_WRITECOMBINED_CACHE 0x10
 #else
 #error Define these please!
 #endif
@@ -187,7 +201,7 @@ extern const ULONG MmProtectToValue[32];
 #ifdef _M_IX86
 #define MM_PTE_SOFTWARE_PROTECTION_BITS   5
 #elif _M_ARM
-#define MM_PTE_SOFTWARE_PROTECTION_BITS   5
+#define MM_PTE_SOFTWARE_PROTECTION_BITS   6
 #elif _M_AMD64
 #define MM_PTE_SOFTWARE_PROTECTION_BITS   5
 #else
@@ -243,7 +257,7 @@ extern const ULONG MmProtectToValue[32];
 #define MI_GET_NEXT_COLOR(x)                (MI_GET_PAGE_COLOR(++MmSystemPageColor))
 #define MI_GET_NEXT_PROCESS_COLOR(x)        (MI_GET_PAGE_COLOR(++(x)->NextPageColor))
 
-#ifdef _M_IX86
+#ifndef _M_AMD64
 //
 // Decodes a Prototype PTE into the underlying PTE
 //
@@ -470,7 +484,7 @@ extern PMMPTE MiSessionImagePteEnd;
 extern PMMPTE MiSessionBasePte;
 extern PMMPTE MiSessionLastPte;
 extern SIZE_T MmSizeOfPagedPoolInBytes;
-extern PMMPTE MmSystemPagePtes;
+extern PMMPDE MmSystemPagePtes;
 extern PVOID MmSystemCacheStart;
 extern PVOID MmSystemCacheEnd;
 extern MMSUPPORT MmSystemCacheWs;
@@ -528,7 +542,7 @@ extern PMMWSL MmWorkingSetList;
 //
 ULONG
 FORCEINLINE
-MiDetermineUserGlobalPteMask(IN PMMPTE PointerPte)
+MiDetermineUserGlobalPteMask(IN PVOID PointerPte)
 {
     MMPTE TempPte;
     
@@ -537,14 +551,15 @@ MiDetermineUserGlobalPteMask(IN PMMPTE PointerPte)
     
     /* Make it valid and accessed */
     TempPte.u.Hard.Valid = TRUE;
-    TempPte.u.Hard.Accessed = TRUE;
+    MI_MAKE_ACCESSED_PAGE(&TempPte);
     
     /* Is this for user-mode? */
-    if ((PointerPte <= MiHighestUserPte) ||
-        ((PointerPte >= MiAddressToPde(NULL)) && (PointerPte <= MiHighestUserPde)))
+    if ((PointerPte <= (PVOID)MiHighestUserPte) ||
+        ((PointerPte >= (PVOID)MiAddressToPde(NULL)) &&
+         (PointerPte <= (PVOID)MiHighestUserPde)))
     {
         /* Set the owner bit */
-        TempPte.u.Hard.Owner = TRUE;
+        MI_MAKE_OWNER_PAGE(&TempPte);
     }
     
     /* FIXME: We should also set the global bit */
@@ -614,7 +629,7 @@ MI_MAKE_HARDWARE_PTE_USER(IN PMMPTE NewPte,
     NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
 }
 
-#ifdef _M_IX86
+#ifndef _M_AMD64
 //
 // Builds a Prototype PTE for the address of the PTE
 //
@@ -684,6 +699,33 @@ MI_WRITE_INVALID_PTE(IN PMMPTE PointerPte,
     *PointerPte = InvalidPte;
 }
 
+//
+// Writes a valid PDE
+//
+VOID
+FORCEINLINE
+MI_WRITE_VALID_PDE(IN PMMPDE PointerPde,
+                   IN MMPDE TempPde)
+{
+    /* Write the valid PDE */
+    ASSERT(PointerPde->u.Hard.Valid == 0);
+    ASSERT(TempPde.u.Hard.Valid == 1);
+    *PointerPde = TempPde;
+}
+
+//
+// Writes an invalid PDE
+//
+VOID
+FORCEINLINE
+MI_WRITE_INVALID_PDE(IN PMMPDE PointerPde,
+                     IN MMPDE InvalidPde)
+{
+    /* Write the invalid PDE */
+    ASSERT(InvalidPde.u.Hard.Valid == 0);
+    *PointerPde = InvalidPde;
+}
+
 //
 // Checks if the thread already owns a working set
 //
index 6a36dd3..b977a65 100644 (file)
@@ -161,7 +161,7 @@ SIZE_T MmSystemViewSize;
 // address.
 //
 PFN_NUMBER MmSystemPageDirectory[PD_COUNT];
-PMMPTE MmSystemPagePtes;
+PMMPDE MmSystemPagePtes;
 #endif
 
 //
@@ -679,7 +679,7 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
                 /* Yes we do, set it up */
                 Pfn1 = MiGetPfnEntry(PageFrameIndex);
                 Pfn1->u4.PteFrame = StartupPdIndex;
-                Pfn1->PteAddress = PointerPde;
+                Pfn1->PteAddress = (PMMPTE)PointerPde;
                 Pfn1->u2.ShareCount++;
                 Pfn1->u3.e2.ReferenceCount = 1;
                 Pfn1->u3.e1.PageLocation = ActiveAndValid;
@@ -771,7 +771,7 @@ MiBuildPfnDatabaseZeroPage(VOID)
         /* Make it a bogus page to catch errors */
         PointerPde = MiAddressToPde(0xFFFFFFFF);
         Pfn1->u4.PteFrame = PFN_FROM_PTE(PointerPde);
-        Pfn1->PteAddress = PointerPde;
+        Pfn1->PteAddress = (PMMPTE)PointerPde;
         Pfn1->u2.ShareCount++;
         Pfn1->u3.e2.ReferenceCount = 0xFFF0;
         Pfn1->u3.e1.PageLocation = ActiveAndValid;
@@ -1192,7 +1192,7 @@ INIT_FUNCTION
 MiAddHalIoMappings(VOID)
 {
     PVOID BaseAddress;
-    PMMPTE PointerPde;
+    PMMPDE PointerPde;
     PMMPTE PointerPte;
     ULONG i, j, PdeCount;
     PFN_NUMBER PageFrameIndex;
@@ -1203,12 +1203,12 @@ MiAddHalIoMappings(VOID)
 
     /* Check how many PDEs the heap has */
     PointerPde = MiAddressToPde(BaseAddress);
-    PdeCount = PDE_COUNT - ADDR_TO_PDE_OFFSET(BaseAddress);
+    PdeCount = PDE_COUNT - MiGetPdeOffset(BaseAddress);
     for (i = 0; i < PdeCount; i++)
     {
         /* Does the HAL own this mapping? */
         if ((PointerPde->u.Hard.Valid == 1) &&
-            (PointerPde->u.Hard.LargePage == 0))
+            (MI_IS_PAGE_LARGE(PointerPde) == FALSE))
         {
             /* Get the PTE for it and scan each page */
             PointerPte = MiAddressToPte(BaseAddress);
@@ -1556,8 +1556,10 @@ NTAPI
 INIT_FUNCTION
 MiBuildPagedPool(VOID)
 {
-    PMMPTE PointerPte, PointerPde;
+    PMMPTE PointerPte;
+    PMMPDE PointerPde;
     MMPTE TempPte = ValidKernelPte;
+    MMPDE TempPde = ValidKernelPde;
     PFN_NUMBER PageFrameIndex;
     KIRQL OldIrql;
     ULONG Size, BitMapSize;
@@ -1648,7 +1650,7 @@ MiBuildPagedPool(VOID)
 #endif
 
     RtlZeroMemory(PointerPde,
-                  (1 + MiAddressToPde(MmPagedPoolEnd) - PointerPde) * sizeof(MMPTE));
+                  (1 + MiAddressToPde(MmPagedPoolEnd) - PointerPde) * sizeof(MMPDE));
 
     //
     // Next, get the first and last PTE
@@ -1666,8 +1668,8 @@ MiBuildPagedPool(VOID)
     MI_SET_USAGE(MI_USAGE_PAGED_POOL);
     MI_SET_PROCESS2("Kernel");
     PageFrameIndex = MiRemoveZeroPage(0);
-    TempPte.u.Hard.PageFrameNumber = PageFrameIndex;
-    MI_WRITE_VALID_PTE(PointerPde, TempPte);
+    TempPde.u.Hard.PageFrameNumber = PageFrameIndex;
+    MI_WRITE_VALID_PDE(PointerPde, TempPde);
 #if (_MI_PAGING_LEVELS >= 3)
     /* Use the PPE of MmPagedPoolStart that was setup above */
 //    Bla = PFN_FROM_PTE(PpeAddress(MmPagedPool...));
@@ -1678,8 +1680,8 @@ MiBuildPagedPool(VOID)
 
     /* Initialize the PFN entry for it */
     MiInitializePfnForOtherProcess(PageFrameIndex,
-                                   PointerPde,
-                                   MmSystemPageDirectory[(PointerPde - (PMMPTE)PDE_BASE) / PDE_COUNT]);
+                                   (PMMPTE)PointerPde,
+                                   MmSystemPageDirectory[(PointerPde - (PMMPDE)PDE_BASE) / PDE_COUNT]);
 #endif
 
     //
index 41cce6d..20264a1 100644 (file)
@@ -325,7 +325,7 @@ MiResolveDemandZeroFault(IN PVOID Address,
     }
     
     /* Set it dirty if it's a writable page */
-    if (TempPte.u.Hard.Write) TempPte.u.Hard.Dirty = TRUE;
+    if (MI_IS_PAGE_WRITEABLE(&TempPte)) MI_MAKE_DIRTY_PAGE(&TempPte);
     
     /* Write it */
     MI_WRITE_VALID_PTE(PointerPte, TempPte);
@@ -899,7 +899,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction,
         ASSERT(ProtectionCode != MM_NOACCESS);
 
         /* Make the PDE demand-zero */
-        MI_WRITE_INVALID_PTE(PointerPde, DemandZeroPde);
+        MI_WRITE_INVALID_PDE(PointerPde, DemandZeroPde);
 
         /* And go dispatch the fault on the PDE. This should handle the demand-zero */
 #if MI_TRACE_PFNS
@@ -907,7 +907,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction,
 #endif
         Status = MiDispatchFault(TRUE,
                                  PointerPte,
-                                 PointerPde,
+                                 (PMMPTE)PointerPde,
                                  NULL,
                                  FALSE,
                                  PsGetCurrentProcess(),
@@ -1058,7 +1058,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction,
         }
 
         /* Write the dirty bit for writeable pages */
-        if (TempPte.u.Hard.Write) TempPte.u.Hard.Dirty = TRUE;
+        if (MI_IS_PAGE_WRITEABLE(&TempPte)) MI_MAKE_DIRTY_PAGE(&TempPte);
 
         /* And now write down the PTE, making the address valid */
         MI_WRITE_VALID_PTE(PointerPte, TempPte);
index a808ff5..1efdbc5 100644 (file)
@@ -375,7 +375,7 @@ NTAPI
 MiAllocatePoolPages(IN POOL_TYPE PoolType,
                     IN SIZE_T SizeInBytes)
 {
-    PFN_NUMBER SizeInPages, PageFrameNumber;
+    PFN_NUMBER SizeInPages, PageFrameNumber, PageTableCount;
     ULONG i;
     KIRQL OldIrql;
     PLIST_ENTRY NextEntry, NextHead, LastHead;
@@ -422,7 +422,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
             // Check if there is enougn paged pool expansion space left
             //
             if (MmPagedPoolInfo.NextPdeForPagedPoolExpansion >
-                MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool))
+                (PMMPDE)MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool))
             {
                 //
                 // Out of memory!
@@ -436,23 +436,23 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
             // Check if we'll have to expand past the last PTE we have available
             //            
             if (((i - 1) + MmPagedPoolInfo.NextPdeForPagedPoolExpansion) >
-                 MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool))
+                 (PMMPDE)MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool))
             {
                 //
                 // We can only support this much then
                 //
-                SizeInPages = MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool) - 
-                              MmPagedPoolInfo.NextPdeForPagedPoolExpansion +
-                              1;
-                ASSERT(SizeInPages < i);
-                i = SizeInPages;
+                PageTableCount = (PMMPDE)MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool) - 
+                                         MmPagedPoolInfo.NextPdeForPagedPoolExpansion +
+                                         1;
+                ASSERT(PageTableCount < i);
+                i = PageTableCount;
             }
             else
             {
                 //
                 // Otherwise, there is plenty of space left for this expansion
                 //
-                SizeInPages = i;
+                PageTableCount = i;
             }
             
             //
@@ -464,7 +464,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
             // Get the first PTE in expansion space
             //
             PointerPde = MmPagedPoolInfo.NextPdeForPagedPoolExpansion;
-            BaseVa = MiPteToAddress(PointerPde);
+            BaseVa = MiPdeToAddress(PointerPde);
             BaseVaStart = BaseVa;
             
             //
@@ -494,11 +494,11 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
                                             
                 /* Initialize the PFN */
                 MiInitializePfnForOtherProcess(PageFrameNumber,
-                                               PointerPde,
+                                               (PMMPTE)PointerPde,
                                                MmSystemPageDirectory[(PointerPde - MiAddressToPde(NULL)) / PDE_COUNT]);
                              
                 /* Write the actual PDE now */
-                MI_WRITE_VALID_PTE(PointerPde, TempPde);
+                MI_WRITE_VALID_PDE(PointerPde, TempPde);
 #endif                
                 //
                 // Move on to the next expansion address
@@ -517,26 +517,25 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
             // These pages are now available, clear their availablity bits
             //
             EndAllocation = (MmPagedPoolInfo.NextPdeForPagedPoolExpansion -
-                             MiAddressToPte(MmPagedPoolInfo.FirstPteForPagedPool)) *
+                             (PMMPDE)MiAddressToPte(MmPagedPoolInfo.FirstPteForPagedPool)) *
                              PTE_COUNT;
             RtlClearBits(MmPagedPoolInfo.PagedPoolAllocationMap,
                          EndAllocation,
-                         SizeInPages * PTE_COUNT);
+                         PageTableCount * PTE_COUNT);
                         
             //
             // Update the next expansion location
             //
-            MmPagedPoolInfo.NextPdeForPagedPoolExpansion += SizeInPages;
+            MmPagedPoolInfo.NextPdeForPagedPoolExpansion += PageTableCount;
             
             //
             // Zero out the newly available memory
             //
-            RtlZeroMemory(BaseVaStart, SizeInPages * PAGE_SIZE);
+            RtlZeroMemory(BaseVaStart, PageTableCount * PAGE_SIZE);
             
             //
             // Now try consuming the pages again
             //
-            SizeInPages = BYTES_TO_PAGES(SizeInBytes);
             i = RtlFindClearBitsAndSet(MmPagedPoolInfo.PagedPoolAllocationMap,
                                        SizeInPages,
                                        0);
index aec5af6..afedcc2 100644 (file)
@@ -971,7 +971,7 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
     /* Do the same for hyperspace */
     PointerPde = MiAddressToPde(HYPER_SPACE);
     PageFrameNumber = PFN_FROM_PTE(PointerPde);
-    MiInitializePfn(PageFrameNumber, PointerPde, TRUE);
+    MiInitializePfn(PageFrameNumber, (PMMPTE)PointerPde, TRUE);
     
     /* Setup the PFN for the PTE for the working set */
     PointerPte = MiAddressToPte(MI_WORKING_SET_LIST);
@@ -1195,7 +1195,7 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
                                 HyperIndex);
 
     /* Set it dirty and map it */
-    PdePte.u.Hard.Dirty = TRUE;
+    MI_MAKE_DIRTY_PAGE(&PdePte);
     MI_WRITE_VALID_PTE(PointerPte, PdePte);
 
     /* Now get hyperspace's page table */
@@ -1228,7 +1228,7 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
                                 PdeIndex);
 
     /* Set it dirty and map it */
-    PdePte.u.Hard.Dirty = TRUE;
+    MI_MAKE_DIRTY_PAGE(&PdePte);
     MI_WRITE_VALID_PTE(PointerPte, PdePte);
 
     /* Now get the page directory (which we'll double map, so call it a page table */
index 872c10e..a51bdab 100644 (file)
@@ -347,17 +347,17 @@ MiFillSystemPageDirectory(IN PVOID Base,
 
             /* Initialize its PFN entry, with the parent system page directory page table */
             MiInitializePfnForOtherProcess(PageFrameIndex,
-                                           PointerPde,
+                                           (PMMPTE)PointerPde,
                                            MmSystemPageDirectory[(PointerPde - MiAddressToPde(NULL)) / PDE_COUNT]);
 
             /* Make the system PDE entry valid */
-            MI_WRITE_VALID_PTE(SystemMapPde, TempPde);
+            MI_WRITE_VALID_PDE(SystemMapPde, TempPde);
             
             /* The system PDE entry might be the PDE itself, so check for this */
             if (PointerPde->u.Hard.Valid == 0)
             {
                 /* It's different, so make the real PDE valid too */
-                MI_WRITE_VALID_PTE(PointerPde, TempPde);
+                MI_WRITE_VALID_PDE(PointerPde, TempPde);
             }
         }
 
index 809d7e5..4e69411 100644 (file)
@@ -146,7 +146,7 @@ MiDeleteSystemPageableVm(IN PMMPTE PointerPte,
                 ASSERT(Pfn1->u1.WsIndex == 0);
                 
                 /* Actual valid, legitimate, pages */
-                if (ValidPages) *ValidPages++;
+                if (ValidPages) (*ValidPages)++;
                 
                 /* Get the page table entry */
                 PageTableIndex = Pfn1->u4.PteFrame;
@@ -305,7 +305,8 @@ MiDeleteVirtualAddresses(IN ULONG_PTR Va,
                          IN ULONG_PTR EndingAddress,
                          IN PMMVAD Vad)
 {
-    PMMPTE PointerPte, PointerPde, PrototypePte, LastPrototypePte;
+    PMMPTE PointerPte, PrototypePte, LastPrototypePte;
+    PMMPDE PointerPde;
     MMPTE TempPte;
     PEPROCESS CurrentProcess;
     KIRQL OldIrql;
@@ -1099,7 +1100,8 @@ MiQueryAddressState(IN PVOID Va,
                     OUT PVOID *NextVa)
 {
 
-    PMMPTE PointerPte, PointerPde;
+    PMMPTE PointerPte;
+    PMMPDE PointerPde;
     MMPTE TempPte;
     BOOLEAN DemandZeroPte = TRUE, ValidPte = FALSE;
     ULONG State = MEM_RESERVE, Protect = 0, LockChange;
index a7aed95..3211b99 100644 (file)
@@ -752,9 +752,7 @@ MiBuildPagedPool_x(VOID)
     /* Save the first and last paged pool PTE */
     MmPagedPoolInfo.FirstPteForPagedPool = MiAddressToPte(MmPagedPoolStart);
     MmPagedPoolInfo.LastPteForPagedPool = MiAddressToPte(MmPagedPoolEnd);
-
-    MmPagedPoolInfo.NextPdeForPagedPoolExpansion = 
-        MiAddressToPde(MmPagedPoolStart) + 1;
+    MmPagedPoolInfo.NextPdeForPagedPoolExpansion = MiAddressToPde(MmPagedPoolStart) + 1;
 
     // We keep track of each page via a bit, so check how big the bitmap will
     // have to be (make sure to align our page count such that it fits nicely
index c24115a..549b65a 100644 (file)
 #define NDEBUG
 #include <debug.h>
 
+#line 15 "ARM³::ARMPAGE"
+#define MODULE_INVOLVED_IN_ARM3
+#include "../ARM3/miarm.h"
+
 /* GLOBALS ********************************************************************/
 
+const
+ULONG
+MmProtectToPteMask[32] =
+{
+    //
+    // These are the base MM_ protection flags
+    //
+    0,
+    PTE_READONLY            | PTE_ENABLE_CACHE,
+    PTE_EXECUTE             | PTE_ENABLE_CACHE,
+    PTE_EXECUTE_READ        | PTE_ENABLE_CACHE,
+    PTE_READWRITE           | PTE_ENABLE_CACHE,
+    PTE_WRITECOPY           | PTE_ENABLE_CACHE,
+    PTE_EXECUTE_READWRITE   | PTE_ENABLE_CACHE,
+    PTE_EXECUTE_WRITECOPY   | PTE_ENABLE_CACHE,
+    //
+    // These OR in the MM_NOCACHE flag
+    //
+    0,
+    PTE_READONLY            | PTE_DISABLE_CACHE,
+    PTE_EXECUTE             | PTE_DISABLE_CACHE,
+    PTE_EXECUTE_READ        | PTE_DISABLE_CACHE,
+    PTE_READWRITE           | PTE_DISABLE_CACHE,
+    PTE_WRITECOPY           | PTE_DISABLE_CACHE,
+    PTE_EXECUTE_READWRITE   | PTE_DISABLE_CACHE,
+    PTE_EXECUTE_WRITECOPY   | PTE_DISABLE_CACHE,
+    //
+    // These OR in the MM_DECOMMIT flag, which doesn't seem supported on x86/64/ARM
+    //
+    0,
+    PTE_READONLY            | PTE_ENABLE_CACHE,
+    PTE_EXECUTE             | PTE_ENABLE_CACHE,
+    PTE_EXECUTE_READ        | PTE_ENABLE_CACHE,
+    PTE_READWRITE           | PTE_ENABLE_CACHE,
+    PTE_WRITECOPY           | PTE_ENABLE_CACHE,
+    PTE_EXECUTE_READWRITE   | PTE_ENABLE_CACHE,
+    PTE_EXECUTE_WRITECOPY   | PTE_ENABLE_CACHE,
+    //
+    // These OR in the MM_NOACCESS flag, which seems to enable WriteCombining?
+    //
+    0,
+    PTE_READONLY            | PTE_WRITECOMBINED_CACHE,
+    PTE_EXECUTE             | PTE_WRITECOMBINED_CACHE,
+    PTE_EXECUTE_READ        | PTE_WRITECOMBINED_CACHE,
+    PTE_READWRITE           | PTE_WRITECOMBINED_CACHE,
+    PTE_WRITECOPY           | PTE_WRITECOMBINED_CACHE,
+    PTE_EXECUTE_READWRITE   | PTE_WRITECOMBINED_CACHE,
+    PTE_EXECUTE_WRITECOPY   | PTE_WRITECOMBINED_CACHE,
+};
+
+const
+ULONG MmProtectToValue[32] =
+{
+    PAGE_NOACCESS,
+    PAGE_READONLY,
+    PAGE_EXECUTE,
+    PAGE_EXECUTE_READ,
+    PAGE_READWRITE,
+    PAGE_WRITECOPY,
+    PAGE_EXECUTE_READWRITE,
+    PAGE_EXECUTE_WRITECOPY,
+    PAGE_NOACCESS,
+    PAGE_NOCACHE | PAGE_READONLY,
+    PAGE_NOCACHE | PAGE_EXECUTE,
+    PAGE_NOCACHE | PAGE_EXECUTE_READ,
+    PAGE_NOCACHE | PAGE_READWRITE,
+    PAGE_NOCACHE | PAGE_WRITECOPY,
+    PAGE_NOCACHE | PAGE_EXECUTE_READWRITE,
+    PAGE_NOCACHE | PAGE_EXECUTE_WRITECOPY,
+    PAGE_NOACCESS,
+    PAGE_GUARD | PAGE_READONLY,
+    PAGE_GUARD | PAGE_EXECUTE,
+    PAGE_GUARD | PAGE_EXECUTE_READ,
+    PAGE_GUARD | PAGE_READWRITE,
+    PAGE_GUARD | PAGE_WRITECOPY,
+    PAGE_GUARD | PAGE_EXECUTE_READWRITE,
+    PAGE_GUARD | PAGE_EXECUTE_WRITECOPY,
+    PAGE_NOACCESS,
+    PAGE_WRITECOMBINE | PAGE_READONLY,
+    PAGE_WRITECOMBINE | PAGE_EXECUTE,
+    PAGE_WRITECOMBINE | PAGE_EXECUTE_READ,
+    PAGE_WRITECOMBINE | PAGE_READWRITE,
+    PAGE_WRITECOMBINE | PAGE_WRITECOPY,
+    PAGE_WRITECOMBINE | PAGE_EXECUTE_READWRITE,
+    PAGE_WRITECOMBINE | PAGE_EXECUTE_WRITECOPY
+};
+
 ULONG MmGlobalKernelPageDirectory[4096];
-MMPDE HyperTemplatePde;
+
+/* Template PTE and PDE for a kernel page */
+MMPDE ValidKernelPde = {.u.Hard.Valid = 1};
+MMPTE ValidKernelPte = {.u.Hard.Valid = 1, .u.Hard.Sbo = 1};
+
+/* Template PDE for a demand-zero page */
+MMPDE DemandZeroPde  = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS)};
+MMPTE DemandZeroPte  = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS)};
+
+/* Template PTE for prototype page */
+MMPTE PrototypePte = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS) | PTE_PROTOTYPE | (MI_PTE_LOOKUP_NEEDED << PAGE_SHIFT)};
 
 /* PRIVATE FUNCTIONS **********************************************************/
 
@@ -49,25 +150,6 @@ MmUpdatePageDir(IN PEPROCESS Process,
     return;
 }
 
-NTSTATUS
-NTAPI
-Mmi386ReleaseMmInfo(IN PEPROCESS Process)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return 0;
-}
-
-NTSTATUS
-NTAPI
-MmInitializeHandBuiltProcess(IN PEPROCESS Process,
-                             IN PULONG DirectoryTableBase)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_SUCCESS;
-}
-
 PULONG
 NTAPI
 MmGetPageDirectory(VOID)
@@ -246,16 +328,7 @@ MmInitGlobalKernelPageDirectory(VOID)
 {
     ULONG i;
     PULONG CurrentPageDirectory = (PULONG)PDE_BASE;
-    extern MMPTE HyperTemplatePte;
-    
-    /* Setup PTE template */
-    HyperTemplatePte.u.Long = 0;
-    HyperTemplatePte.u.Hard.Valid = 1;
-    HyperTemplatePte.u.Hard.Access = 1;
-
-    /* Setup PDE template */
-    HyperTemplatePde.u.Long = 0;
-    HyperTemplatePde.u.Hard.Valid = 1;
+
         
     /* Loop the 2GB of address space which belong to the kernel */
     for (i = MiGetPdeOffset(MmSystemRangeStart); i < 2048; i++)
index 55178c7..781ea28 100644 (file)
@@ -367,18 +367,6 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
     return TRUE;
 }
 
-VOID
-NTAPI
-MmUpdatePageDir(IN PEPROCESS Process,
-                IN PVOID Address,
-                IN ULONG Size)
-{
-    //
-    // Nothing to do
-    //
-    return;
-}
-
 NTSTATUS
 NTAPI
 Mmi386ReleaseMmInfo(IN PEPROCESS Process)
@@ -391,30 +379,6 @@ Mmi386ReleaseMmInfo(IN PEPROCESS Process)
     return 0;
 }
 
-NTSTATUS
-NTAPI
-MmInitializeHandBuiltProcess(IN PEPROCESS Process,
-                             IN PULONG DirectoryTableBase)
-{
-    //
-    // Share the directory base with the idle process
-    //
-    DirectoryTableBase[0] = PsGetCurrentProcess()->Pcb.DirectoryTableBase[0];
-    DirectoryTableBase[1] = PsGetCurrentProcess()->Pcb.DirectoryTableBase[1];
-    
-    //
-    // Initialize the Addresss Space
-    //
-    KeInitializeGuardedMutex(&Process->AddressCreationLock);
-    Process->VadRoot.BalancedRoot.u1.Parent = NULL;
-    
-    //
-    // The process now has an address space
-    //
-    Process->HasAddressSpace = TRUE;
-    return STATUS_SUCCESS;
-}
-
 PULONG
 NTAPI
 MmGetPageDirectory(VOID)
index 2b3274a..cfa5d9c 100644 (file)
@@ -132,7 +132,7 @@ MmBuildMdlFromPages(PMDL Mdl, PPFN_NUMBER Pages)
 
 BOOLEAN
 NTAPI
-MmIsFileAPagingFile(PFILE_OBJECT FileObject)
+MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject)
 {
     ULONG i;
 
index dcf9239..021abac 100644 (file)
 @ stdcall ExInterlockedAddLargeInteger(ptr long long ptr)
 @ fastcall -arch=i386,arm ExInterlockedAddLargeStatistic(ptr long)
 @ stdcall ExInterlockedAddUlong(ptr long ptr)
-@ fastcall -arch=i386,arm ExInterlockedCompareExchange64(ptr ptr ptr ptr)
-@ stdcall -arch=i386,arm ExInterlockedDecrementLong(ptr ptr)
-@ stdcall -arch=i386,arm ExInterlockedExchangeUlong(ptr long ptr)
+@ fastcall -arch=i386 ExInterlockedCompareExchange64(ptr ptr ptr ptr)
+@ stdcall -arch=i386 ExInterlockedDecrementLong(ptr ptr)
+@ stdcall -arch=i386 ExInterlockedExchangeUlong(ptr long ptr)
 @ stdcall ExInterlockedExtendZone(ptr ptr long ptr)
 @ fastcall -arch=i386,arm ExInterlockedFlushSList(ptr)
 @ stdcall -arch=i386,arm ExInterlockedIncrementLong(ptr ptr)
index 359a035..42a0bb8 100644 (file)
@@ -9,6 +9,7 @@
 
 /* INCLUDES ******************************************************************/
 
+#include "initguid.h"
 #include <ntoskrnl.h>
 #define NDEBUG
 #include <debug.h>
index 621195c..8a8bac8 100644 (file)
@@ -58,8 +58,12 @@ typedef struct _USER_MESSAGE_QUEUE
   LIST_ENTRY HardwareMessagesListHead;
   /* Lock for the hardware message list. */
   KMUTEX HardwareLock;
-  /* Pointer to the current WM_MOUSEMOVE message */
-  PUSER_MESSAGE MouseMoveMsg;
+  /* True if a WM_MOUSEMOVE is pending */
+  BOOLEAN MouseMoved;
+  /* Current WM_MOUSEMOVE message */
+  MSG MouseMoveMsg;
+  /* Last click message for translating double clicks */
+  MSG msgDblClk;
   /* True if a WM_QUIT message is pending. */
   BOOLEAN QuitPosted;
   /* The quit exit code. */
@@ -122,18 +126,25 @@ VOID FASTCALL
 MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode);
 BOOLEAN APIENTRY
 MsqPeekMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
-               IN BOOLEAN Remove,
-               IN PWND Window,
-               IN UINT MsgFilterLow,
-               IN UINT MsgFilterHigh,
-               OUT PMSG Message);
+                     IN BOOLEAN Remove,
+                     IN PWND Window,
+                     IN UINT MsgFilterLow,
+                     IN UINT MsgFilterHigh,
+                     OUT PMSG Message);
 BOOL APIENTRY
 co_MsqPeekHardwareMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
-                          IN BOOL Remove,
-                          IN PWND Window,
-                          IN UINT MsgFilterLow,
-                          IN UINT MsgFilterHigh,
-                          OUT MSG* pMsg);
+                             IN BOOL Remove,
+                             IN PWND Window,
+                             IN UINT MsgFilterLow,
+                             IN UINT MsgFilterHigh,
+                             OUT MSG* pMsg);
+BOOL APIENTRY
+co_MsqPeekMouseMove(IN PUSER_MESSAGE_QUEUE MessageQueue,
+                    IN BOOL Remove,
+                    IN PWND Window,
+                    IN UINT MsgFilterLow,
+                    IN UINT MsgFilterHigh,
+                    OUT MSG* pMsg);
 BOOLEAN FASTCALL
 MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQueue);
 VOID FASTCALL
@@ -154,9 +165,6 @@ NTSTATUS FASTCALL
 co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, PWND WndFilter,
                       UINT MsgFilterMin, UINT MsgFilterMax);
 VOID FASTCALL
-MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue,
-                    PUSER_SENT_MESSAGE_NOTIFY NotifyMessage);
-VOID FASTCALL
 MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue);
 VOID FASTCALL
 MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue);
index cee93ab..b21b910 100644 (file)
@@ -27,9 +27,8 @@ BOOLEAN FASTCALL
 co_WinPosShowWindow(PWND Window, INT Cmd);
 void FASTCALL
 co_WinPosSendSizeMove(PWND Window);
-USHORT FASTCALL
-co_WinPosWindowFromPoint(PWND ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint,
-                     PWND* Window);
+PWND FASTCALL
+co_WinPosWindowFromPoint(PWND ScopeWin, POINT *WinPoint, USHORT* HitTest);
 VOID FASTCALL co_WinPosActivateOtherWindow(PWND Window);
 
 VOID FASTCALL WinPosInitInternalPos(PWND WindowObject,
index 4d79962..eca0d4d 100644 (file)
@@ -1198,33 +1198,4 @@ NtUserGetClipboardSequenceNumber(VOID)
     return sn;
 }
 
-
-/**************** VISTA FUNCTIONS******************/
-
-BOOL APIENTRY NtUserAddClipboardFormatListener(
-    HWND hwnd
-)
-{
-    UNIMPLEMENTED;
-    return FALSE;
-}
-
-BOOL APIENTRY NtUserRemoveClipboardFormatListener(
-    HWND hwnd
-)
-{
-    UNIMPLEMENTED;
-    return FALSE;
-}
-
-BOOL APIENTRY NtUserGetUpdatedClipboardFormats(
-    PUINT lpuiFormats,
-    UINT cFormats,
-    PUINT pcFormatsOut
-)
-{
-    UNIMPLEMENTED;
-    return FALSE;
-}
-
 /* EOF */
index 7d25e91..ce738a7 100644 (file)
@@ -618,23 +618,6 @@ cleanup:
 }
 
 
-/*
- * @unimplemented
- */
-DWORD
-APIENTRY
-NtUserGetCursorFrameInfo(
-    DWORD Unknown0,
-    DWORD Unknown1,
-    DWORD Unknown2,
-    DWORD Unknown3)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
 /*
  * @implemented
  */
@@ -1176,18 +1159,6 @@ CLEANUP:
 }
 #endif
 
-/*
- * @unimplemented
- */
-BOOL
-APIENTRY
-NtUserSetSystemCursor(
-    HCURSOR hcur,
-    DWORD id)
-{
-    return FALSE;
-}
-
 /* Mostly inspired from wine code */
 BOOL
 UserDrawIconEx(
index 138b322..c4af452 100644 (file)
@@ -1685,20 +1685,6 @@ CLEANUP:
    END_CLEANUP;
 }
 
-/*
- * NtUserResolveDesktopForWOW
- *
- * Status
- *    @unimplemented
- */
-
-DWORD APIENTRY
-NtUserResolveDesktopForWOW(DWORD Unknown0)
-{
-   UNIMPLEMENTED
-   return 0;
-}
-
 /*
  * NtUserGetThreadDesktop
  *
index 0c745a2..717e8c4 100644 (file)
@@ -1012,16 +1012,6 @@ CleanupInputImp(VOID)
    return(STATUS_SUCCESS);
 }
 
-BOOL
-APIENTRY
-NtUserDragDetect(
-   HWND hWnd,
-   POINT pt) // Just like the User call.
-{
-   UNIMPLEMENTED
-   return 0;
-}
-
 BOOL FASTCALL
 IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt)
 {
index 49e643e..0870046 100644 (file)
@@ -1713,17 +1713,6 @@ CLEANUP:
    END_CLEANUP;
 }
 
-/*
- * @unimplemented
- */
-BOOL APIENTRY
-NtUserEndMenu(VOID)
-{
-   UNIMPLEMENTED
-
-   return 0;
-}
-
 /*
  * @implemented
  */
@@ -2455,25 +2444,6 @@ CLEANUP:
    END_CLEANUP;
 }
 
-/*
- * @implemented
- */
-/* NOTE: unused function */
-BOOL APIENTRY
-NtUserTrackPopupMenuEx(
-   HMENU hMenu,
-   UINT fuFlags,
-   int x,
-   int y,
-   HWND hWnd,
-   LPTPMPARAMS lptpm)
-{
-   UNIMPLEMENTED
-
-   return FALSE;
-}
-
-
 ////// ReactOS NtUserBad
 /*
  * @implemented
index 8cabf9f..01dcb73 100644 (file)
@@ -502,387 +502,6 @@ IntDispatchMessage(PMSG pMsg)
     return retval;
 }
 
-VOID FASTCALL
-co_IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg)
-{
-    if(!Msg->hwnd || ThreadQueue->CaptureWindow)
-    {
-        return;
-    }
-
-    switch(Msg->message)
-    {
-    case WM_MOUSEMOVE:
-        {
-            co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message));
-            break;
-        }
-    case WM_NCMOUSEMOVE:
-        {
-            co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message));
-            break;
-        }
-    case WM_LBUTTONDOWN:
-    case WM_MBUTTONDOWN:
-    case WM_RBUTTONDOWN:
-    case WM_XBUTTONDOWN:
-    case WM_LBUTTONDBLCLK:
-    case WM_MBUTTONDBLCLK:
-    case WM_RBUTTONDBLCLK:
-    case WM_XBUTTONDBLCLK:
-        {
-            WPARAM wParam;
-            PSYSTEM_CURSORINFO CurInfo;
-            CurInfo = IntGetSysCursorInfo();
-
-            wParam = (WPARAM)(CurInfo->ButtonsDown);
-
-            co_IntSendMessage(Msg->hwnd, WM_MOUSEMOVE, wParam, Msg->lParam);
-            co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message));
-            break;
-        }
-    case WM_NCLBUTTONDOWN:
-    case WM_NCMBUTTONDOWN:
-    case WM_NCRBUTTONDOWN:
-    case WM_NCXBUTTONDOWN:
-    case WM_NCLBUTTONDBLCLK:
-    case WM_NCMBUTTONDBLCLK:
-    case WM_NCRBUTTONDBLCLK:
-    case WM_NCXBUTTONDBLCLK:
-        {
-            co_IntSendMessage(Msg->hwnd, WM_NCMOUSEMOVE, (WPARAM)Msg->wParam, Msg->lParam);
-            co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message));
-            break;
-        }
-    }
-}
-
-BOOL FASTCALL
-co_IntActivateWindowMouse( PUSER_MESSAGE_QUEUE ThreadQueue,
-                           LPMSG Msg,
-                           PWND MsgWindow,
-                           USHORT *HitTest)
-{
-    ULONG Result;
-    PWND Parent;
-
-    ASSERT_REFS_CO(MsgWindow);
-
-    if(*HitTest == (USHORT)HTTRANSPARENT)
-    {
-        /* eat the message, search again! */
-        return TRUE;
-    }
-
-    Parent = IntGetParent(MsgWindow);//fixme: deref retval?
-
-    /* If no parent window, pass MsgWindows HWND as wParam. Fixes bug #3111 */
-    Result = co_IntSendMessage(MsgWindow->head.h,
-                               WM_MOUSEACTIVATE,
-                              (WPARAM) (Parent ? Parent->head.h : MsgWindow->head.h),
-                              (LPARAM)MAKELONG(*HitTest, Msg->message)
-    );
-
-    switch (Result)
-    {
-    case MA_NOACTIVATEANDEAT:
-        return TRUE;
-    case MA_NOACTIVATE:
-        break;
-    case MA_ACTIVATEANDEAT:
-        co_IntMouseActivateWindow(MsgWindow);
-        return TRUE;
-    default:
-        /* MA_ACTIVATE */
-        co_IntMouseActivateWindow(MsgWindow);
-        break;
-    }
-
-    return FALSE;
-}
-
-BOOL FASTCALL
-co_IntTranslateMouseMessage( PUSER_MESSAGE_QUEUE ThreadQueue,
-                             LPMSG Msg,
-                             USHORT *HitTest,
-                             BOOL Remove)
-{
-    PWND Window;
-    USER_REFERENCE_ENTRY Ref, DesktopRef;
-
-    if(!(Window = UserGetWindowObject(Msg->hwnd)))
-    {
-        /* let's just eat the message?! */
-        return TRUE;
-    }
-
-    *HitTest = HTCLIENT;
-
-    UserRefObjectCo(Window, &Ref);
-
-    if ( ThreadQueue == Window->head.pti->MessageQueue &&
-         ThreadQueue->CaptureWindow != Window->head.h)
-    {
-        /* only send WM_NCHITTEST messages if we're not capturing the window! */
-        if (Remove ) 
-        {
-            *HitTest = co_IntSendMessage(Window->head.h, WM_NCHITTEST, 0,
-                                         MAKELONG(Msg->pt.x, Msg->pt.y));
-        } 
-        /* else we are going to see this message again, but then with Remove == TRUE */
-
-        if (*HitTest == (USHORT)HTTRANSPARENT)
-        {
-            PWND DesktopWindow;
-            HWND hDesktop = IntGetDesktopWindow();
-
-            if ((DesktopWindow = UserGetWindowObject(hDesktop)))
-            {
-                PWND Wnd;
-
-                UserRefObjectCo(DesktopWindow, &DesktopRef);
-
-                co_WinPosWindowFromPoint(DesktopWindow, Window->head.pti->MessageQueue, &Msg->pt, &Wnd);
-                if (Wnd)
-                {
-                    if (Wnd != Window)
-                    {
-                        /* post the message to the other window */
-                        Msg->hwnd = Wnd->head.h;
-                        if(!(Wnd->state & WNDS_DESTROYED))
-                        {
-                            MsqPostMessage(Wnd->head.pti->MessageQueue, Msg, FALSE,
-                                           Msg->message == WM_MOUSEMOVE ? QS_MOUSEMOVE :
-                            QS_MOUSEBUTTON);
-                        }
-
-                        /* eat the message */
-                        UserDereferenceObject(Wnd);
-                        UserDerefObjectCo(DesktopWindow);
-                        UserDerefObjectCo(Window);
-                        return TRUE;
-                    }
-                    UserDereferenceObject(Wnd);
-                }
-
-                UserDerefObjectCo(DesktopWindow);
-            }
-        }
-    }
-
-    if ( gspv.bMouseClickLock &&
-        ((Msg->message == WM_LBUTTONUP) ||
-         (Msg->message == WM_LBUTTONDOWN) ) )
-    {
-        if (MsqIsClkLck(Msg, Remove))
-        {
-            // FIXME: drop the message, hack: use WM_NULL
-            Msg->message = WM_NULL;
-        }
-    }
-
-    if (IS_BTN_MESSAGE(Msg->message, DOWN))
-    {
-        /* generate double click messages, if necessary */
-        if ((((*HitTest) != HTCLIENT) ||
-            (Window->pcls->style & CS_DBLCLKS)) &&
-            MsqIsDblClk(Msg, Remove))
-        {
-            Msg->message += WM_LBUTTONDBLCLK - WM_LBUTTONDOWN;
-        }
-    }
-
-    if(Msg->message != WM_MOUSEWHEEL)
-    {
-
-        if ((*HitTest) != HTCLIENT)
-        {
-            Msg->message += WM_NCMOUSEMOVE - WM_MOUSEMOVE;
-            if ( (Msg->message == WM_NCRBUTTONUP) &&
-                 (((*HitTest) == HTCAPTION) || ((*HitTest) == HTSYSMENU)) )
-            {
-                Msg->message = WM_CONTEXTMENU;
-                Msg->wParam = (WPARAM)Window->head.h;
-            }
-            else
-            {
-                Msg->wParam = *HitTest;
-            }
-            Msg->lParam = MAKELONG(Msg->pt.x, Msg->pt.y);
-        }
-        else if ( ThreadQueue->MoveSize == NULL &&
-                  ThreadQueue->MenuOwner == NULL )
-        {
-            /* NOTE: Msg->pt should remain in screen coordinates. -- FiN */
-            Msg->lParam = MAKELONG(
-                     Msg->pt.x - (WORD)Window->rcClient.left,
-                     Msg->pt.y - (WORD)Window->rcClient.top);
-        }
-    }
-
-    UserDerefObjectCo(Window);
-    return FALSE;
-}
-
-BOOL ProcessMouseMessage(MSG* Msg, BOOLEAN RemoveMessages)
-{
-    MOUSEHOOKSTRUCT MHook;
-    EVENTMSG Event;
-    PTHREADINFO pti;
-    PUSER_MESSAGE_QUEUE ThreadQueue;
-    USER_REFERENCE_ENTRY Ref;
-    USHORT HitTest = HTNOWHERE;
-
-    pti = PsGetCurrentThreadWin32Thread();
-    ThreadQueue = pti->MessageQueue;
-
-    if(RemoveMessages)
-    {
-        PWND MsgWindow = NULL;
-
-        /* Mouse message process */
-
-        if( Msg->hwnd &&
-            ( MsgWindow = UserGetWindowObject(Msg->hwnd) ) &&
-            Msg->message >= WM_MOUSEFIRST &&
-            Msg->message <= WM_MOUSELAST )
-        {
-            USHORT HitTest;
-
-            UserRefObjectCo(MsgWindow, &Ref);
-
-            if ( co_IntTranslateMouseMessage( ThreadQueue,
-                                              Msg,
-                                             &HitTest,
-                                              TRUE))
-            /* FIXME - check message filter again, if the message doesn't match anymore,
-                    search again */
-            {
-                UserDerefObjectCo(MsgWindow);
-                /* eat the message, search again */
-                return FALSE;
-            }
-
-            if(ThreadQueue->CaptureWindow == NULL)
-            {
-                co_IntSendHitTestMessages(ThreadQueue, Msg);
-
-                if ( ( Msg->message != WM_MOUSEMOVE &&
-                       Msg->message != WM_NCMOUSEMOVE ) &&
-                       IS_BTN_MESSAGE(Msg->message, DOWN) &&
-                       co_IntActivateWindowMouse(ThreadQueue, Msg, MsgWindow, &HitTest) )
-                {
-                    UserDerefObjectCo(MsgWindow);
-                    /* eat the message, search again */
-                    return FALSE;
-                }
-            }
-
-            UserDerefObjectCo(MsgWindow);
-        }
-        else
-        {
-            co_IntSendHitTestMessages(ThreadQueue, Msg);
-        }
-
-        return TRUE;
-    }
-
-    if ( ( Msg->hwnd &&
-           Msg->message >= WM_MOUSEFIRST &&
-           Msg->message <= WM_MOUSELAST ) &&
-           co_IntTranslateMouseMessage( ThreadQueue,
-                                        Msg,
-                                       &HitTest,
-                                        FALSE) )
-    /* FIXME - check message filter again, if the message doesn't match anymore,
-            search again */
-    {
-        /* eat the message, search again */
-        return FALSE;
-    }
-
-    pti->rpdesk->htEx = HitTest; /* Now set the capture hit. */
-
-    Event.message = Msg->message;
-    Event.time    = Msg->time;
-    Event.hwnd    = Msg->hwnd;
-    Event.paramL  = Msg->pt.x;
-    Event.paramH  = Msg->pt.y;
-    co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&Event);
-
-
-    MHook.pt           = Msg->pt;
-    MHook.hwnd         = Msg->hwnd;
-    MHook.wHitTestCode = HitTest;
-    MHook.dwExtraInfo  = 0;
-    if (co_HOOK_CallHooks( WH_MOUSE,
-                           RemoveMessages ? HC_ACTION : HC_NOREMOVE,
-                           Msg->message,
-                           (LPARAM)&MHook ))
-    {
-        MHook.pt           = Msg->pt;
-        MHook.hwnd         = Msg->hwnd;
-        MHook.wHitTestCode = HitTest;
-        MHook.dwExtraInfo  = 0;
-        co_HOOK_CallHooks( WH_CBT,
-                           HCBT_CLICKSKIPPED,
-                           Msg->message,
-                           (LPARAM)&MHook);
-        DPRINT1("MouseMessage WH_CBT Call Hook return!\n");
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
-BOOL ProcessKeyboardMessage(MSG* Msg, BOOLEAN RemoveMessages)
-{
-    EVENTMSG Event;
-
-    Event.message = Msg->message;
-    Event.hwnd    = Msg->hwnd;
-    Event.time    = Msg->time;
-    Event.paramL  = (Msg->wParam & 0xFF) | (HIWORD(Msg->lParam) << 8);
-    Event.paramH  = Msg->lParam & 0x7FFF;
-    if (HIWORD(Msg->lParam) & 0x0100) Event.paramH |= 0x8000;
-    co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&Event);
-
-    if (co_HOOK_CallHooks( WH_KEYBOARD,
-                           RemoveMessages ? HC_ACTION : HC_NOREMOVE,
-                           LOWORD(Msg->wParam),
-                           Msg->lParam))
-    {
-        /* skip this message */
-        co_HOOK_CallHooks( WH_CBT,
-                           HCBT_KEYSKIPPED,
-                           LOWORD(Msg->wParam),
-                           Msg->lParam );
-        DPRINT1("KeyboardMessage WH_CBT Call Hook return!\n");
-        return FALSE;
-    }
-    return TRUE;
-}
-
-BOOL ProcessHardwareMessage(MSG* Msg, BOOLEAN RemoveMessages)
-{
-    if ( IS_MOUSE_MESSAGE(Msg->message))
-    {
-        if (!ProcessMouseMessage(Msg, RemoveMessages))
-        {
-            return FALSE;
-        }
-    }
-    else if ( IS_KBD_MESSAGE(Msg->message))
-    {
-        if(!ProcessKeyboardMessage(Msg, RemoveMessages))
-        {
-            return FALSE;
-        }
-    }
-
-    return TRUE;
-}
 /*
 * Internal version of PeekMessage() doing all the work
 */
@@ -933,27 +552,33 @@ co_IntPeekMessage( PMSG Msg,
 
         /* Now check for normal messages. */
         if (MsqPeekMessage( ThreadQueue,
-                            RemoveMessages,
-                            Window,
-                            MsgFilterMin,
-                            MsgFilterMax,
-                            Msg ))
+                               RemoveMessages,
+                               Window,
+                               MsgFilterMin,
+                               MsgFilterMax,
+                               Msg ))
         {
             return TRUE;
         }
 
         /* Check for hardware events. */
-        if(co_MsqPeekHardwareMessage( ThreadQueue,
+        if(co_MsqPeekMouseMove(ThreadQueue,
+                              RemoveMessages,
+                              Window,
+                              MsgFilterMin,
+                              MsgFilterMax,
+                              Msg ))
+        {
+            return TRUE;
+        }
+
+        if(co_MsqPeekHardwareMessage(ThreadQueue, 
                                      RemoveMessages, 
                                      Window, 
                                      MsgFilterMin, 
                                      MsgFilterMax, 
                                      Msg))
         {
-
-            if(!ProcessHardwareMessage(Msg, RemoveMessages))
-                continue;
-
             return TRUE;
         }
 
@@ -1991,15 +1616,6 @@ NtUserPostThreadMessage(DWORD idThread,
     return ret;
 }
 
-DWORD APIENTRY
-NtUserQuerySendMessage(DWORD Unknown0)
-{
-    UNIMPLEMENTED;
-
-    return 0;
-}
-
-
 ////////// API on the way out!
 LRESULT APIENTRY
 NtUserSendMessageTimeout( HWND hWnd,
index f705aed..b03ba84 100644 (file)
@@ -22,6 +22,8 @@
  * PURPOSE:          Message queues
  * FILE:             subsystems/win32/win32k/ntuser/msgqueue.c
  * PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
+                     Alexandre Julliard
+                     Maarten Lankhorst
  * REVISION HISTORY:
  *       06-06-2001  CSH  Created
  */
 
 /* GLOBALS *******************************************************************/
 
-#define SYSTEM_MESSAGE_QUEUE_SIZE           (256)
-
-static MSG SystemMessageQueue[SYSTEM_MESSAGE_QUEUE_SIZE];
-static ULONG SystemMessageQueueHead = 0;
-static ULONG SystemMessageQueueTail = 0;
-static ULONG SystemMessageQueueCount = 0;
-static KSPIN_LOCK SystemMessageQueueLock;
-
-static ULONG volatile HardwareMessageQueueStamp = 0;
-static LIST_ENTRY HardwareMessageQueueHead;
-static KMUTANT HardwareMessageQueueLock;
-
-static KEVENT HardwareMessageEvent;
-
 static PAGED_LOOKASIDE_LIST MessageLookasideList;
 
-#define IntLockSystemMessageQueue(OldIrql) \
-  KeAcquireSpinLock(&SystemMessageQueueLock, &OldIrql)
-
-#define IntUnLockSystemMessageQueue(OldIrql) \
-  KeReleaseSpinLock(&SystemMessageQueueLock, OldIrql)
-
-#define IntUnLockSystemHardwareMessageQueueLock(Wait) \
-  KeReleaseMutant(&HardwareMessageQueueLock, IO_NO_INCREMENT, FALSE, Wait)
-
 /* FUNCTIONS *****************************************************************/
 
 HANDLE FASTCALL
@@ -135,12 +114,6 @@ NTSTATUS
 NTAPI
 MsqInitializeImpl(VOID)
 {
-   /*CurrentFocusMessageQueue = NULL;*/
-   InitializeListHead(&HardwareMessageQueueHead);
-   KeInitializeEvent(&HardwareMessageEvent, NotificationEvent, 0);
-   KeInitializeSpinLock(&SystemMessageQueueLock);
-   KeInitializeMutant(&HardwareMessageQueueLock, 0);
-
    ExInitializePagedLookasideList(&MessageLookasideList,
                                   NULL,
                                   NULL,
@@ -152,13 +125,20 @@ MsqInitializeImpl(VOID)
    return(STATUS_SUCCESS);
 }
 
+VOID FASTCALL
+MsqPostMouseMove(PUSER_MESSAGE_QUEUE MessageQueue, MSG* Msg)
+{
+    MessageQueue->MouseMoveMsg = *Msg;
+    MessageQueue->MouseMoved = TRUE;
+    MsqWakeQueue(MessageQueue, QS_MOUSEMOVE);
+}
+
 VOID FASTCALL
 co_MsqInsertMouseMessage(MSG* Msg)
 {
    LARGE_INTEGER LargeTickCount;
-   KIRQL OldIrql;
-   ULONG Prev;
    MSLLHOOKSTRUCT MouseHookData;
+   PWND pwnd, pwndDesktop;
 
    KeQueryTickCount(&LargeTickCount);
    Msg->time = MsqCalculateMessageTime(&LargeTickCount);
@@ -191,556 +171,47 @@ co_MsqInsertMouseMessage(MSG* Msg)
    if (co_HOOK_CallHooks(WH_MOUSE_LL, HC_ACTION, Msg->message, (LPARAM) &MouseHookData))
       return;
 
-   /*
-    * If we got WM_MOUSEMOVE and there are already messages in the
-    * system message queue, check if the last message is mouse move
-    * and if it is then just overwrite it.
-    */
-   IntLockSystemMessageQueue(OldIrql);
-
-   /*
-    * Bail out if the queue is full. FIXME: We should handle this case
-    * more gracefully.
-    */
+   /* Get the desktop window */
+   pwndDesktop = UserGetDesktopWindow();
+   if(!pwndDesktop)
+       return;
 
-   if (SystemMessageQueueCount == SYSTEM_MESSAGE_QUEUE_SIZE)
+   /* Check if the mouse is captured */
+   Msg->hwnd = IntGetCaptureWindow();
+   if(Msg->hwnd != NULL)
    {
-      IntUnLockSystemMessageQueue(OldIrql);
-      return;
-   }
-
-   if (Msg->message == WM_MOUSEMOVE && SystemMessageQueueCount)
-   {
-      if (SystemMessageQueueTail == 0)
-         Prev = SYSTEM_MESSAGE_QUEUE_SIZE - 1;
-      else
-         Prev = SystemMessageQueueTail - 1;
-      if (SystemMessageQueue[Prev].message == WM_MOUSEMOVE)
-      {
-         SystemMessageQueueTail = Prev;
-         SystemMessageQueueCount--;
-      }
+       pwnd = UserGetWindowObject(Msg->hwnd);
    }
-
-   /*
-    * Actually insert the message into the system message queue.
-    */
-
-   SystemMessageQueue[SystemMessageQueueTail] = *Msg;
-   SystemMessageQueueTail =
-      (SystemMessageQueueTail + 1) % SYSTEM_MESSAGE_QUEUE_SIZE;
-   SystemMessageQueueCount++;
-
-   IntUnLockSystemMessageQueue(OldIrql);
-
-   KeSetEvent(&HardwareMessageEvent, IO_NO_INCREMENT, FALSE);
-}
-
-BOOL FASTCALL
-MsqIsClkLck(LPMSG Msg, BOOL Remove)
-{
-   PTHREADINFO pti;
-   PSYSTEM_CURSORINFO CurInfo;
-   BOOL Res = FALSE;
-
-   pti = PsGetCurrentThreadWin32Thread();
-   if (pti->rpdesk == NULL)
+   else
    {
-      return FALSE;
+       /* Loop all top level windows to find which one should receive input */
+       for( pwnd = pwndDesktop->spwndChild;
+            pwnd != NULL;
+            pwnd = pwnd->spwndNext )
+       {
+           if((pwnd->style & WS_VISIBLE) && 
+              IntPtInWindow(pwnd, Msg->pt.x, Msg->pt.y))
+           {
+               Msg->hwnd = pwnd->head.h;
+               break;
+           }
+       }
    }
 
-   CurInfo = IntGetSysCursorInfo();
-
-   switch (Msg->message)
+   /* Check if we found a window */
+   if(Msg->hwnd != NULL && pwnd != NULL)
    {
-     case WM_LBUTTONUP:
-       Res = ((Msg->time - CurInfo->ClickLockTime) >= gspv.dwMouseClickLockTime);
-       if (Res && (!CurInfo->ClickLockActive))
-       {
-         CurInfo->ClickLockActive = TRUE;
-       }
-       break;
-     case WM_LBUTTONDOWN:
-       if (CurInfo->ClickLockActive)
+       if(Msg->message == WM_MOUSEMOVE)
        {
-         Res = TRUE;
-         CurInfo->ClickLockActive = FALSE;
-         CurInfo->ClickLockTime = 0;
+           /* Mouse move is a special case*/
+           MsqPostMouseMove(pwnd->head.pti->MessageQueue, Msg);
        }
        else
        {
-         CurInfo->ClickLockTime = Msg->time;
+           DPRINT("Posting mouse message to hwnd=0x%x!\n", UserHMGetHandle(pwnd));
+           MsqPostMessage(pwnd->head.pti->MessageQueue, Msg, TRUE, QS_MOUSEBUTTON);
        }
-       break;
-   }
-   return Res;
-}
-
-BOOL FASTCALL
-MsqIsDblClk(LPMSG Msg, BOOL Remove)
-{
-   PTHREADINFO pti;
-   PSYSTEM_CURSORINFO CurInfo;
-   LONG dX, dY;
-   BOOL Res;
-
-   pti = PsGetCurrentThreadWin32Thread();
-   if (pti->rpdesk == NULL)
-   {
-      return FALSE;
-   }
-
-   CurInfo = IntGetSysCursorInfo();
-   Res = (Msg->hwnd == (HWND)CurInfo->LastClkWnd) &&
-         ((Msg->time - CurInfo->LastBtnDown) < gspv.iDblClickTime);
-   if(Res)
-   {
-
-      dX = CurInfo->LastBtnDownX - Msg->pt.x;
-      dY = CurInfo->LastBtnDownY - Msg->pt.y;
-      if(dX < 0)
-         dX = -dX;
-      if(dY < 0)
-         dY = -dY;
-
-      Res = (dX <= gspv.iDblClickWidth) &&
-            (dY <= gspv.iDblClickHeight);
-
-      if(Res)
-      {
-         if(CurInfo->ButtonsDown)
-           Res = (CurInfo->ButtonsDown == Msg->message);
-      }
    }
-
-   if(Remove)
-   {
-      CurInfo->LastBtnDownX = Msg->pt.x;
-      CurInfo->LastBtnDownY = Msg->pt.y;
-      CurInfo->ButtonsDown = Msg->message;
-      if (Res)
-      {
-         CurInfo->LastBtnDown = 0;
-         CurInfo->LastClkWnd = NULL;
-      }
-      else
-      {
-         CurInfo->LastClkWnd = (HANDLE)Msg->hwnd;
-         CurInfo->LastBtnDown = Msg->time;
-      }
-   }
-
-   return Res;
-}
-
-static BOOL APIENTRY
-co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, PWND Window, UINT FilterLow, UINT FilterHigh,
-                            PUSER_MESSAGE Message, BOOL Remove, PBOOL Freed,
-                            PWND ScopeWin, PPOINT ScreenPoint, BOOL FromGlobalQueue, PLIST_ENTRY *Next)
-{
-   USHORT Msg = Message->Msg.message;
-   PWND CaptureWindow = NULL;
-   HWND hCaptureWin;
-
-   /* FIXME: Mouse message can be sent before the Desktop is up and running in which case ScopeWin (Desktop) is 0.
-             Is this the best fix? */
-   if (ScopeWin == 0) return FALSE;
-
-   ASSERT_REFS_CO(ScopeWin);
-
-   /*
-   co_WinPosWindowFromPoint can return a Window, and in that case
-   that window has a ref that we need to deref. Thats why we add "dummy"
-   refs in all other cases.
-   */
-
-   hCaptureWin = IntGetCaptureWindow();
-   if (hCaptureWin == NULL)
-   {
-      if (Msg == WM_MOUSEWHEEL)
-      {
-         CaptureWindow = UserGetWindowObject(IntGetFocusWindow());
-         if (CaptureWindow) UserReferenceObject(CaptureWindow);
-      }
-      else
-      {
-         co_WinPosWindowFromPoint(ScopeWin, NULL, &Message->Msg.pt, &CaptureWindow);
-         if(CaptureWindow == NULL)
-         {
-            CaptureWindow = ScopeWin;
-            if (CaptureWindow) UserReferenceObject(CaptureWindow);
-         }
-         else
-         {
-            /* this is the one case where we dont add a ref, since the returned
-            window is already referenced */
-         }
-      }
-   }
-   else
-   {
-      /* FIXME - window messages should go to the right window if no buttons are
-                 pressed */
-      CaptureWindow = UserGetWindowObject(hCaptureWin);
-      if (CaptureWindow) UserReferenceObject(CaptureWindow);
-   }
-
-
-
-   if (CaptureWindow == NULL)
-   {
-      if(!FromGlobalQueue)
-      {
-         RemoveEntryList(&Message->ListEntry);
-         if(MessageQueue->MouseMoveMsg == Message)
-         {
-            MessageQueue->MouseMoveMsg = NULL;
-         }
-      }
-      // when FromGlobalQueue is true, the caller has already removed the Message
-      ExFreePool(Message);
-      *Freed = TRUE;
-      return(FALSE);
-   }
-
-   if (CaptureWindow->head.pti->MessageQueue != MessageQueue)
-   {
-      if (! FromGlobalQueue)
-      {
-         DPRINT("Moving msg between private queues\n");
-         /* This message is already queued in a private queue, but we need
-          * to move it to a different queue, perhaps because a new window
-          * was created which now covers the screen area previously taken
-          * by another window. To move it, we need to take it out of the
-          * old queue. Note that we're already holding the lock mutexes of the
-          * old queue */
-         RemoveEntryList(&Message->ListEntry);
-
-         /* remove the pointer for the current WM_MOUSEMOVE message in case we
-            just removed it */
-         if(MessageQueue->MouseMoveMsg == Message)
-         {
-            MessageQueue->MouseMoveMsg = NULL;
-         }
-      }
-
-      /* lock the destination message queue, so we don't get in trouble with other
-         threads, messing with it at the same time */
-      IntLockHardwareMessageQueue(CaptureWindow->head.pti->MessageQueue);
-      InsertTailList(&CaptureWindow->head.pti->MessageQueue->HardwareMessagesListHead,
-                     &Message->ListEntry);
-      if(Message->Msg.message == WM_MOUSEMOVE)
-      {
-         if(CaptureWindow->head.pti->MessageQueue->MouseMoveMsg)
-         {
-            /* remove the old WM_MOUSEMOVE message, we're processing a more recent
-               one */
-            RemoveEntryList(&CaptureWindow->head.pti->MessageQueue->MouseMoveMsg->ListEntry);
-            ExFreePool(CaptureWindow->head.pti->MessageQueue->MouseMoveMsg);
-         }
-         /* save the pointer to the WM_MOUSEMOVE message in the new queue */
-         CaptureWindow->head.pti->MessageQueue->MouseMoveMsg = Message;
-
-         MsqWakeQueue(CaptureWindow->head.pti->MessageQueue, QS_MOUSEMOVE);
-      }
-      else
-      {
-          MsqWakeQueue(CaptureWindow->head.pti->MessageQueue, QS_MOUSEBUTTON);
-      }
-      IntUnLockHardwareMessageQueue(CaptureWindow->head.pti->MessageQueue);
-
-      *Freed = FALSE;
-      UserDereferenceObject(CaptureWindow);
-      return(FALSE);
-   }
-
-   /* From here on, we're in the same message queue as the caller! */
-
-   *ScreenPoint = Message->Msg.pt;
-
-   if((Window != NULL && PtrToInt(Window) != 1 && CaptureWindow->head.h != Window->head.h) ||
-         ((FilterLow != 0 || FilterHigh != 0) && (Msg < FilterLow || Msg > FilterHigh)))
-   {
-      /* Reject the message because it doesn't match the filter */
-
-      if(FromGlobalQueue)
-      {
-         /* Lock the message queue so no other thread can mess with it.
-            Our own message queue is not locked while fetching from the global
-            queue, so we have to make sure nothing interferes! */
-         IntLockHardwareMessageQueue(CaptureWindow->head.pti->MessageQueue);
-         /* if we're from the global queue, we need to add our message to our
-            private queue so we don't loose it! */
-         InsertTailList(&CaptureWindow->head.pti->MessageQueue->HardwareMessagesListHead,
-                        &Message->ListEntry);
-      }
-
-      if (Message->Msg.message == WM_MOUSEMOVE)
-      {
-         if(CaptureWindow->head.pti->MessageQueue->MouseMoveMsg &&
-               (CaptureWindow->head.pti->MessageQueue->MouseMoveMsg != Message))
-         {
-            /* delete the old message */
-            RemoveEntryList(&CaptureWindow->head.pti->MessageQueue->MouseMoveMsg->ListEntry);
-            ExFreePool(CaptureWindow->head.pti->MessageQueue->MouseMoveMsg);
-            if (!FromGlobalQueue)
-            {
-               // We might have deleted the next one in our queue, so fix next
-               *Next = Message->ListEntry.Flink;
-            }
-         }
-         /* always save a pointer to this WM_MOUSEMOVE message here because we're
-            sure that the message is in the private queue */
-         CaptureWindow->head.pti->MessageQueue->MouseMoveMsg = Message;
-      }
-      if(FromGlobalQueue)
-      {
-         IntUnLockHardwareMessageQueue(CaptureWindow->head.pti->MessageQueue);
-      }
-
-      UserDereferenceObject(CaptureWindow);
-      *Freed = FALSE;
-      return(FALSE);
-   }
-
-   /* FIXME - only assign if removing? */
-   Message->Msg.hwnd = CaptureWindow->head.h;
-   Message->Msg.message = Msg;
-   Message->Msg.lParam = MAKELONG(Message->Msg.pt.x, Message->Msg.pt.y);
-
-   /* remove the reference to the current WM_(NC)MOUSEMOVE message, if this message
-      is it */
-   if (Message->Msg.message == WM_MOUSEMOVE ||
-         Message->Msg.message == WM_NCMOUSEMOVE)
-   {
-      if(FromGlobalQueue)
-      {
-         /* Lock the message queue so no other thread can mess with it.
-            Our own message queue is not locked while fetching from the global
-            queue, so we have to make sure nothing interferes! */
-         IntLockHardwareMessageQueue(CaptureWindow->head.pti->MessageQueue);
-         if(CaptureWindow->head.pti->MessageQueue->MouseMoveMsg)
-         {
-            /* delete the WM_(NC)MOUSEMOVE message in the private queue, we're dealing
-               with one that's been sent later */
-            RemoveEntryList(&CaptureWindow->head.pti->MessageQueue->MouseMoveMsg->ListEntry);
-            ExFreePool(CaptureWindow->head.pti->MessageQueue->MouseMoveMsg);
-            /* our message is not in the private queue so we can remove the pointer
-               instead of setting it to the current message we're processing */
-            CaptureWindow->head.pti->MessageQueue->MouseMoveMsg = NULL;
-         }
-         IntUnLockHardwareMessageQueue(CaptureWindow->head.pti->MessageQueue);
-      }
-      else if (CaptureWindow->head.pti->MessageQueue->MouseMoveMsg == Message)
-      {
-         CaptureWindow->head.pti->MessageQueue->MouseMoveMsg = NULL;
-      }
-   }
-
-   UserDereferenceObject(CaptureWindow);
-   *Freed = FALSE;
-   return(TRUE);
-}
-
-BOOL APIENTRY
-co_MsqPeekHardwareMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
-                          IN BOOL Remove,
-                          IN PWND Window,
-                          IN UINT FilterLow,
-                          IN UINT FilterHigh,
-                          OUT PMSG Message)
-{
-   KIRQL OldIrql;
-   POINT ScreenPoint;
-   BOOL Accept, Freed;
-   PLIST_ENTRY CurrentEntry;
-   PWND DesktopWindow = NULL;
-   PVOID WaitObjects[2];
-   NTSTATUS WaitStatus;
-   DECLARE_RETURN(BOOL);
-   USER_REFERENCE_ENTRY Ref;
-   PDESKTOPINFO Desk = NULL;
-
-   WaitObjects[1] = MessageQueue->NewMessages;
-   WaitObjects[0] = &HardwareMessageQueueLock;
-   do
-   {
-      UserLeaveCo();
-
-      WaitStatus = KeWaitForMultipleObjects(2, WaitObjects, WaitAny, UserRequest,
-                                            UserMode, FALSE, NULL, NULL);
-
-      UserEnterCo();
-   }
-   while (NT_SUCCESS(WaitStatus) && STATUS_WAIT_0 != WaitStatus);
-
-   DesktopWindow = UserGetWindowObject(IntGetDesktopWindow());
-
-   if (DesktopWindow)
-   {
-       UserRefObjectCo(DesktopWindow, &Ref);
-       Desk = DesktopWindow->head.pti->pDeskInfo;
-   }
-
-   /* Process messages in the message queue itself. */
-   IntLockHardwareMessageQueue(MessageQueue);
-   CurrentEntry = MessageQueue->HardwareMessagesListHead.Flink;
-   while (CurrentEntry != &MessageQueue->HardwareMessagesListHead)
-   {
-      PUSER_MESSAGE Current =
-         CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry);
-      CurrentEntry = CurrentEntry->Flink;
-      if (Current->Msg.message >= WM_MOUSEFIRST &&
-            Current->Msg.message <= WM_MOUSELAST)
-      {
-
-
-         Accept = co_MsqTranslateMouseMessage(MessageQueue, Window, FilterLow, FilterHigh,
-                                              Current, Remove, &Freed,
-                                              DesktopWindow, &ScreenPoint, FALSE, &CurrentEntry);
-         if (Accept)
-         {
-            *Message = Current->Msg;
-            if (Remove)
-            {
-               RemoveEntryList(&Current->ListEntry);
-               MsqDestroyMessage(Current);
-            }
-            IntUnLockHardwareMessageQueue(MessageQueue);
-            IntUnLockSystemHardwareMessageQueueLock(FALSE);
-          
-            if (Desk)
-                Desk->LastInputWasKbd = FALSE;
-
-            RETURN(TRUE);
-         }
-
-      }
-      else
-      {
-         *Message = Current->Msg;
-         if (Remove)
-         {
-            RemoveEntryList(&Current->ListEntry);
-            MsqDestroyMessage(Current);
-         }
-         IntUnLockHardwareMessageQueue(MessageQueue);
-         IntUnLockSystemHardwareMessageQueueLock(FALSE);
-
-         RETURN(TRUE);
-      }
-   }
-   IntUnLockHardwareMessageQueue(MessageQueue);
-
-   /* Now try the global queue. */
-
-   /* Transfer all messages from the DPC accessible queue to the main queue. */
-   IntLockSystemMessageQueue(OldIrql);
-   while (SystemMessageQueueCount > 0)
-   {
-      PUSER_MESSAGE UserMsg;
-      MSG Msg;
-
-      ASSERT(SystemMessageQueueHead < SYSTEM_MESSAGE_QUEUE_SIZE);
-      Msg = SystemMessageQueue[SystemMessageQueueHead];
-      SystemMessageQueueHead =
-         (SystemMessageQueueHead + 1) % SYSTEM_MESSAGE_QUEUE_SIZE;
-      SystemMessageQueueCount--;
-      IntUnLockSystemMessageQueue(OldIrql);
-
-      UserMsg = ExAllocateFromPagedLookasideList(&MessageLookasideList);
-      /* What to do if out of memory? For now we just panic a bit in debug */
-      ASSERT(UserMsg);
-      UserMsg->Msg = Msg;
-      InsertTailList(&HardwareMessageQueueHead, &UserMsg->ListEntry);
-
-      IntLockSystemMessageQueue(OldIrql);
-   }
-   HardwareMessageQueueStamp++;
-   IntUnLockSystemMessageQueue(OldIrql);
-
-   /* Process messages in the queue until we find one to return. */
-   CurrentEntry = HardwareMessageQueueHead.Flink;
-   while (CurrentEntry != &HardwareMessageQueueHead)
-   {
-      PUSER_MESSAGE Current =
-         CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry);
-      CurrentEntry = CurrentEntry->Flink;
-      RemoveEntryList(&Current->ListEntry);
-      HardwareMessageQueueStamp++;
-      if (Current->Msg.message >= WM_MOUSEFIRST &&
-            Current->Msg.message <= WM_MOUSELAST)
-      {
-         const ULONG ActiveStamp = HardwareMessageQueueStamp;
-         /* Translate the message. */
-         Accept = co_MsqTranslateMouseMessage(MessageQueue, Window, FilterLow, FilterHigh,
-                                              Current, Remove, &Freed,
-                                              DesktopWindow, &ScreenPoint, TRUE, NULL);
-         if (Accept)
-         {
-            /* Check for no more messages in the system queue. */
-            IntLockSystemMessageQueue(OldIrql);
-            if (SystemMessageQueueCount == 0 &&
-                  IsListEmpty(&HardwareMessageQueueHead))
-            {
-               KeClearEvent(&HardwareMessageEvent);
-            }
-            IntUnLockSystemMessageQueue(OldIrql);
-
-            /*
-            If we aren't removing the message then add it to the private
-            queue.
-            */
-            if (!Remove)
-            {
-               IntLockHardwareMessageQueue(MessageQueue);
-               if(Current->Msg.message == WM_MOUSEMOVE)
-               {
-                  if(MessageQueue->MouseMoveMsg)
-                  {
-                     RemoveEntryList(&MessageQueue->MouseMoveMsg->ListEntry);
-                     ExFreePool(MessageQueue->MouseMoveMsg);
-                  }
-                  MessageQueue->MouseMoveMsg = Current;
-               }
-               InsertTailList(&MessageQueue->HardwareMessagesListHead,
-                              &Current->ListEntry);
-               IntUnLockHardwareMessageQueue(MessageQueue);
-            }
-            IntUnLockSystemHardwareMessageQueueLock(FALSE);
-            *Message = Current->Msg;
-
-            if (Remove)
-            {
-                MsqDestroyMessage(Current);
-            }
-
-            RETURN(TRUE);
-         }
-         /* If the contents of the queue changed then restart processing. */
-         if (HardwareMessageQueueStamp != ActiveStamp)
-         {
-            CurrentEntry = HardwareMessageQueueHead.Flink;
-            continue;
-         }
-      }
-   }
-
-   /* Check if the system message queue is now empty. */
-   IntLockSystemMessageQueue(OldIrql);
-   if (SystemMessageQueueCount == 0 && IsListEmpty(&HardwareMessageQueueHead))
-   {
-      KeClearEvent(&HardwareMessageEvent);
-   }
-   IntUnLockSystemMessageQueue(OldIrql);
-   IntUnLockSystemHardwareMessageQueueLock(FALSE);
-
-   RETURN(FALSE);
-
-CLEANUP:
-   if (DesktopWindow) UserDerefObjectCo(DesktopWindow);
-
-   END_CLEANUP;
 }
 
 //
@@ -889,34 +360,6 @@ MsqDestroyMessage(PUSER_MESSAGE Message)
    ExFreeToPagedLookasideList(&MessageLookasideList, Message);
 }
 
-VOID FASTCALL
-co_MsqDispatchSentNotifyMessages(PUSER_MESSAGE_QUEUE MessageQueue)
-{
-   PLIST_ENTRY ListEntry;
-   PUSER_SENT_MESSAGE_NOTIFY Message;
-
-   while (!IsListEmpty(&MessageQueue->SentMessagesListHead))
-   {
-      ListEntry = RemoveHeadList(&MessageQueue->SentMessagesListHead);
-      Message = CONTAINING_RECORD(ListEntry, USER_SENT_MESSAGE_NOTIFY,
-                                  ListEntry);
-
-      co_IntCallSentMessageCallback(Message->CompletionCallback,
-                                    Message->hWnd,
-                                    Message->Msg,
-                                    Message->CompletionCallbackContext,
-                                    Message->Result);
-
-   }
-
-}
-
-BOOLEAN FASTCALL
-MsqPeekSentMessages(PUSER_MESSAGE_QUEUE MessageQueue)
-{
-   return(!IsListEmpty(&MessageQueue->SentMessagesListHead));
-}
-
 BOOLEAN FASTCALL
 co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue)
 {
@@ -1101,15 +544,6 @@ MsqRemoveWindowMessagesFromQueue(PVOID pWindow)
    }
 }
 
-VOID FASTCALL
-MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue,
-                     PUSER_SENT_MESSAGE_NOTIFY NotifyMessage)
-{
-   InsertTailList(&MessageQueue->NotifyMessagesListHead,
-                  &NotifyMessage->ListEntry);
-   MsqWakeQueue(MessageQueue, QS_SENDMESSAGE);
-}
-
 NTSTATUS FASTCALL
 co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
                   HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam,
@@ -1323,6 +757,421 @@ MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode)
    MsqWakeQueue(MessageQueue, QS_POSTMESSAGE);
 }
 
+/***********************************************************************
+ *           MsqSendParentNotify
+ *
+ * Send a WM_PARENTNOTIFY to all ancestors of the given window, unless
+ * the window has the WS_EX_NOPARENTNOTIFY style.
+ */
+static void MsqSendParentNotify( PWND pwnd, WORD event, WORD idChild, POINT pt )
+{
+    PWND pwndDesktop = UserGetWindowObject(IntGetDesktopWindow());
+
+    /* pt has to be in the client coordinates of the parent window */
+    pt.x += pwndDesktop->rcClient.left - pwnd->rcClient.left;
+    pt.y += pwndDesktop->rcClient.top - pwnd->rcClient.top;
+
+    for (;;)
+    {
+        PWND pwndParent;
+
+        if (!(pwnd->style & WS_CHILD)) break;
+        if (pwnd->ExStyle & WS_EX_NOPARENTNOTIFY) break;
+        if (!(pwndParent = IntGetParent(pwnd))) break;
+        if (pwndParent == pwndDesktop) break;
+        pt.x += pwnd->rcClient.left - pwndParent->rcClient.left;
+        pt.y += pwnd->rcClient.top - pwndParent->rcClient.top;
+        
+        pwnd = pwndParent;
+        co_IntSendMessage( UserHMGetHandle(pwnd), WM_PARENTNOTIFY,
+                      MAKEWPARAM( event, idChild ), MAKELPARAM( pt.x, pt.y ) );
+    }
+}
+
+BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT last)
+{
+    MSG clk_msg;
+    POINT pt;
+    UINT message;
+    USHORT hittest;
+    EVENTMSG event;
+    MOUSEHOOKSTRUCT hook;
+    BOOL eatMsg;
+
+    PWND pwndMsg, pwndDesktop;
+    PUSER_MESSAGE_QUEUE MessageQueue;
+    PTHREADINFO pti;
+    PSYSTEM_CURSORINFO CurInfo;
+    DECLARE_RETURN(BOOL);
+
+    pti = PsGetCurrentThreadWin32Thread();
+    pwndDesktop = UserGetDesktopWindow();
+    MessageQueue = pti->MessageQueue;
+    CurInfo = IntGetSysCursorInfo();
+    pwndMsg = UserGetWindowObject(msg->hwnd);
+    clk_msg = MessageQueue->msgDblClk;
+
+    /* find the window to dispatch this mouse message to */
+    if (MessageQueue->CaptureWindow)
+    {
+        hittest = HTCLIENT;
+        pwndMsg = IntGetWindowObject(MessageQueue->CaptureWindow);
+    }
+    else
+    {
+        pwndMsg = co_WinPosWindowFromPoint(pwndMsg, &msg->pt, &hittest);
+    }
+
+    DPRINT("Got mouse message for 0x%x, hittest: 0x%x\n", msg->hwnd, hittest );
+    
+    if (pwndMsg == NULL || pwndMsg->head.pti != pti)
+    {
+        /* Remove and ignore the message */
+        *RemoveMessages = TRUE;
+        RETURN(FALSE);
+    }
+
+    msg->hwnd = UserHMGetHandle(pwndMsg);
+
+#if 0
+    if (!check_hwnd_filter( msg, hwnd_filter )) RETURN(FALSE);
+#endif
+
+    pt = msg->pt;
+    message = msg->message;
+    /* Note: windows has no concept of a non-client wheel message */
+    if (message != WM_MOUSEWHEEL)
+    {
+        if (hittest != HTCLIENT)
+        {
+            message += WM_NCMOUSEMOVE - WM_MOUSEMOVE;
+            msg->wParam = hittest;
+        }
+        else
+        {
+            /* coordinates don't get translated while tracking a menu */
+            /* FIXME: should differentiate popups and top-level menus */
+            if (!(MessageQueue->MenuOwner))
+            {
+                pt.x += pwndDesktop->rcClient.left - pwndMsg->rcClient.left;
+                pt.y += pwndDesktop->rcClient.top - pwndMsg->rcClient.top;
+            }
+        }
+    }
+    msg->lParam = MAKELONG( pt.x, pt.y );
+
+    /* translate double clicks */
+
+    if ((msg->message == WM_LBUTTONDOWN) ||
+        (msg->message == WM_RBUTTONDOWN) ||
+        (msg->message == WM_MBUTTONDOWN) ||
+        (msg->message == WM_XBUTTONDOWN))
+    {
+        BOOL update = *RemoveMessages;
+
+        /* translate double clicks -
+         * note that ...MOUSEMOVEs can slip in between
+         * ...BUTTONDOWN and ...BUTTONDBLCLK messages */
+
+        if ((MessageQueue->MenuOwner || MessageQueue->MoveSize) ||
+            hittest != HTCLIENT ||
+            (pwndMsg->pcls->style & CS_DBLCLKS))
+        {
+           if ((msg->message == clk_msg.message) &&
+               (msg->hwnd == clk_msg.hwnd) &&
+               (msg->wParam == clk_msg.wParam) &&
+               (msg->time - clk_msg.time < gspv.iDblClickTime) &&
+               (abs(msg->pt.x - clk_msg.pt.x) < UserGetSystemMetrics(SM_CXDOUBLECLK)/2) &&
+               (abs(msg->pt.y - clk_msg.pt.y) < UserGetSystemMetrics(SM_CYDOUBLECLK)/2))
+           {
+               message += (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN);
+               if (update)
+               {
+                   MessageQueue->msgDblClk.message = 0;  /* clear the double click conditions */
+                   update = FALSE;
+               }
+           }
+        }
+
+        if (!((first ==  0 && last == 0) || (message >= first || message <= last))) 
+        {
+            DPRINT("Message out of range!!!\n");
+            RETURN(FALSE);
+        }
+
+        /* update static double click conditions */
+        if (update) MessageQueue->msgDblClk = *msg;
+    }
+    else
+    {
+        if (!((first ==  0 && last == 0) || (message >= first || message <= last)))
+        {
+            DPRINT("Message out of range!!!\n");
+            RETURN(FALSE);
+        }
+    }
+
+    if(gspv.bMouseClickLock)
+    {
+        BOOL IsClkLck = FALSE;
+
+        if(msg->message == WM_LBUTTONUP)
+        {
+            IsClkLck = ((msg->time - CurInfo->ClickLockTime) >= gspv.dwMouseClickLockTime);
+            if (IsClkLck && (!CurInfo->ClickLockActive))
+            {
+                CurInfo->ClickLockActive = TRUE;
+            }
+        }
+        else if (msg->message == WM_LBUTTONDOWN)
+        {
+            if (CurInfo->ClickLockActive)
+            {
+                IsClkLck = TRUE;
+                CurInfo->ClickLockActive = FALSE;
+            }
+
+            CurInfo->ClickLockTime = msg->time;
+        }
+
+        if(IsClkLck)
+        {
+            /* Remove and ignore the message */
+            *RemoveMessages = TRUE;
+            RETURN(FALSE);
+        }
+    }
+
+    /* message is accepted now (but may still get dropped) */
+
+    pti->rpdesk->htEx = hittest; /* Now set the capture hit. */
+
+    event.message = msg->message;
+    event.time    = msg->time;
+    event.hwnd    = msg->hwnd;
+    event.paramL  = msg->pt.x;
+    event.paramH  = msg->pt.y;
+    co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&event );
+
+    hook.pt           = msg->pt;
+    hook.hwnd         = msg->hwnd;
+    hook.wHitTestCode = hittest;
+    hook.dwExtraInfo  = 0/*extra_info*/;
+    if (co_HOOK_CallHooks( WH_MOUSE, *RemoveMessages ? HC_ACTION : HC_NOREMOVE,
+                        message, (LPARAM)&hook ))
+    {
+        hook.pt           = msg->pt;
+        hook.hwnd         = msg->hwnd;
+        hook.wHitTestCode = hittest;
+        hook.dwExtraInfo  = 0/*extra_info*/;
+        co_HOOK_CallHooks( WH_CBT, HCBT_CLICKSKIPPED, message, (LPARAM)&hook );
+
+        DPRINT1("WH_MOUSE dorpped mouse message!\n");
+
+        /* Remove and skip message */
+        *RemoveMessages = TRUE;
+        RETURN(FALSE);
+    }
+
+    if ((hittest == HTERROR) || (hittest == HTNOWHERE))
+    {
+        co_IntSendMessage( msg->hwnd, WM_SETCURSOR, (WPARAM)msg->hwnd,
+                      MAKELONG( hittest, msg->message ));
+
+        /* Remove and skip message */
+        *RemoveMessages = TRUE;
+        RETURN(FALSE);
+    }
+
+    if ((*RemoveMessages == FALSE) || MessageQueue->CaptureWindow)
+    {
+        /* Accept the message */
+        msg->message = message;
+        RETURN(TRUE);
+    }
+
+    eatMsg = FALSE;
+
+    if ((msg->message == WM_LBUTTONDOWN) ||
+        (msg->message == WM_RBUTTONDOWN) ||
+        (msg->message == WM_MBUTTONDOWN) ||
+        (msg->message == WM_XBUTTONDOWN))
+    {
+        /* Send the WM_PARENTNOTIFY,
+         * note that even for double/nonclient clicks
+         * notification message is still WM_L/M/RBUTTONDOWN.
+         */
+        MsqSendParentNotify(pwndMsg, msg->message, 0, msg->pt );
+
+        /* Activate the window if needed */
+
+        if (msg->hwnd != MessageQueue->ActiveWindow)
+        {
+            PWND pwndTop = pwndMsg;
+            while (pwndTop)
+            {
+                if ((pwndTop->style & (WS_POPUP|WS_CHILD)) != WS_CHILD) break;
+                pwndTop = IntGetParent( pwndTop );
+            }
+
+            if (pwndTop && pwndTop != pwndDesktop)
+            {
+                LONG ret = co_IntSendMessage( msg->hwnd, 
+                                              WM_MOUSEACTIVATE, 
+                                              (WPARAM)UserHMGetHandle(pwndTop),
+                                              MAKELONG( hittest, msg->message));
+                switch(ret)
+                {
+                case MA_NOACTIVATEANDEAT:
+                    eatMsg = TRUE;
+                    /* fall through */
+                case MA_NOACTIVATE:
+                    break;
+                case MA_ACTIVATEANDEAT:
+                    eatMsg = TRUE;
+                    /* fall through */
+                case MA_ACTIVATE:
+                case 0:
+                    if(!co_IntMouseActivateWindow(pwndMsg)) eatMsg = TRUE;
+                    break;
+                default:
+                    DPRINT1( "unknown WM_MOUSEACTIVATE code %d\n", ret );
+                    break;
+                }
+            }
+        }
+    }
+
+    /* send the WM_SETCURSOR message */
+
+    /* Windows sends the normal mouse message as the message parameter
+       in the WM_SETCURSOR message even if it's non-client mouse message */
+    co_IntSendMessage( msg->hwnd, WM_SETCURSOR, (WPARAM)msg->hwnd, MAKELONG( hittest, msg->message ));
+
+    msg->message = message;
+    RETURN(!eatMsg);
+
+CLEANUP:
+    if(pwndMsg)
+        UserDereferenceObject(pwndMsg);
+
+    END_CLEANUP;
+}
+
+BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages)
+{
+    EVENTMSG Event;
+
+    Event.message = Msg->message;
+    Event.hwnd    = Msg->hwnd;
+    Event.time    = Msg->time;
+    Event.paramL  = (Msg->wParam & 0xFF) | (HIWORD(Msg->lParam) << 8);
+    Event.paramH  = Msg->lParam & 0x7FFF;
+    if (HIWORD(Msg->lParam) & 0x0100) Event.paramH |= 0x8000;
+    co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&Event);
+
+    if (co_HOOK_CallHooks( WH_KEYBOARD,
+                           *RemoveMessages ? HC_ACTION : HC_NOREMOVE,
+                           LOWORD(Msg->wParam),
+                           Msg->lParam))
+    {
+        /* skip this message */
+        co_HOOK_CallHooks( WH_CBT,
+                           HCBT_KEYSKIPPED,
+                           LOWORD(Msg->wParam),
+                           Msg->lParam );
+        DPRINT1("KeyboardMessage WH_CBT Call Hook return!\n");
+        return FALSE;
+    }
+    return TRUE;
+}
+
+BOOL co_IntProcessHardwareMessage(MSG* Msg, BOOL* RemoveMessages, UINT first, UINT last)
+{
+    if ( IS_MOUSE_MESSAGE(Msg->message))
+    {
+        return co_IntProcessMouseMessage(Msg, RemoveMessages, first, last);
+    }
+    else if ( IS_KBD_MESSAGE(Msg->message))
+    {
+        return co_IntProcessKeyboardMessage(Msg, RemoveMessages);
+    }
+
+    return TRUE;
+}
+
+BOOL APIENTRY
+co_MsqPeekMouseMove(IN PUSER_MESSAGE_QUEUE MessageQueue,
+                   IN BOOL Remove,
+                   IN PWND Window,
+                   IN UINT MsgFilterLow,
+                   IN UINT MsgFilterHigh,
+                   OUT MSG* pMsg)
+{
+    BOOL AcceptMessage;
+    MSG msg;
+
+    if(!(MessageQueue->MouseMoved))
+        return FALSE;
+
+    msg = MessageQueue->MouseMoveMsg;
+
+    AcceptMessage = co_IntProcessMouseMessage(&msg, &Remove, MsgFilterLow, MsgFilterHigh);
+
+    if(AcceptMessage)
+        *pMsg = msg;
+
+    if(Remove)
+        MessageQueue->MouseMoved = FALSE;
+
+   return AcceptMessage;
+}
+
+BOOL APIENTRY
+co_MsqPeekHardwareMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
+                         IN BOOL Remove,
+                         IN PWND Window,
+                         IN UINT MsgFilterLow,
+                         IN UINT MsgFilterHigh,
+                         OUT MSG* pMsg)
+{
+
+    BOOL AcceptMessage;
+    PUSER_MESSAGE CurrentMessage;
+    PLIST_ENTRY ListHead, CurrentEntry = NULL;
+    MSG msg;
+
+    ListHead = &MessageQueue->HardwareMessagesListHead;
+    CurrentEntry = ListHead->Flink;
+
+    while(CurrentEntry != ListHead)
+    {
+        CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE,
+                                          ListEntry);
+
+        msg = CurrentMessage->Msg;
+
+        AcceptMessage = co_IntProcessHardwareMessage(&msg, &Remove, MsgFilterLow, MsgFilterHigh);
+
+        CurrentEntry = CurrentMessage->ListEntry.Flink;
+
+        if (Remove)
+        {
+            RemoveEntryList(&CurrentMessage->ListEntry);
+            MsqDestroyMessage(CurrentMessage);
+        }
+
+        if(AcceptMessage)
+        {
+            *pMsg = msg;
+            return TRUE;
+        }
+
+    }
+
+    return FALSE;
+}
+
 BOOLEAN APIENTRY
 MsqPeekMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
                   IN BOOLEAN Remove,
@@ -1368,19 +1217,14 @@ NTSTATUS FASTCALL
 co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, PWND WndFilter,
                          UINT MsgFilterMin, UINT MsgFilterMax)
 {
-   PVOID WaitObjects[2] = {MessageQueue->NewMessages, &HardwareMessageEvent};
    NTSTATUS ret;
 
    UserLeaveCo();
-
-   ret = KeWaitForMultipleObjects(2,
-                                  WaitObjects,
-                                  WaitAny,
-                                  Executive,
-                                  UserMode,
-                                  FALSE,
-                                  NULL,
-                                  NULL);
+   ret = KeWaitForSingleObject(MessageQueue->NewMessages,
+                              Executive,
+                              UserMode,
+                              FALSE, 
+                              NULL);
    UserEnterCo();
    return ret;
 }
index 9d4cc5b..401af3d 100644 (file)
@@ -1151,5 +1151,335 @@ NtUserCtxDisplayIOCtl(
     return 0;
 }
 
+/*
+ * @unimplemented
+ */
+DWORD
+APIENTRY
+NtUserDrawMenuBarTemp(
+   HWND hWnd,
+   HDC hDC,
+   PRECT hRect,
+   HMENU hMenu,
+   HFONT hFont)
+{
+   /* we'll use this function just for caching the menu bar */
+   UNIMPLEMENTED
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+DWORD APIENTRY
+NtUserEndDeferWindowPosEx(DWORD Unknown0,
+                          DWORD Unknown1)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * FillWindow: Called from User; Dialog, Edit and ListBox procs during a WM_ERASEBKGND.
+ */
+/*
+ * @unimplemented
+ */
+BOOL APIENTRY
+NtUserFillWindow(HWND hWndPaint,
+                 HWND hWndPaint1,
+                 HDC  hDC,
+                 HBRUSH hBrush)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL APIENTRY
+NtUserFlashWindowEx(IN PFLASHWINFO pfwi)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL APIENTRY
+NtUserLockWindowUpdate(HWND hWnd)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+DWORD APIENTRY
+NtUserRealChildWindowFromPoint(DWORD Unknown0,
+                               DWORD Unknown1,
+                               DWORD Unknown2)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+DWORD APIENTRY
+NtUserSetImeOwnerWindow(DWORD Unknown0,
+                        DWORD Unknown1)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+DWORD APIENTRY
+NtUserSetInternalWindowPos(
+   HWND    hwnd,
+   UINT    showCmd,
+   LPRECT  rect,
+   LPPOINT pt)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL APIENTRY
+NtUserSetLayeredWindowAttributes(HWND hwnd,
+                          COLORREF crKey,
+                          BYTE bAlpha,
+                          DWORD dwFlags)
+{
+  UNIMPLEMENTED;
+  return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL APIENTRY
+NtUserSetLogonNotifyWindow(HWND hWnd)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL
+APIENTRY
+NtUserUpdateLayeredWindow(
+   HWND hwnd,
+   HDC hdcDst,
+   POINT *pptDst,
+   SIZE *psize,
+   HDC hdcSrc,
+   POINT *pptSrc,
+   COLORREF crKey,
+   BLENDFUNCTION *pblend,
+   DWORD dwFlags,
+   RECT *prcDirty)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ *    @unimplemented
+ */
+HWND APIENTRY
+NtUserWindowFromPhysicalPoint(POINT Point)
+{
+   UNIMPLEMENTED
+
+   return NULL;
+}
+
+/*
+ * @unimplemented
+ */
+HDWP APIENTRY
+NtUserDeferWindowPos(HDWP WinPosInfo,
+                     HWND Wnd,
+                     HWND WndInsertAfter,
+                     int x,
+                     int y,
+                     int cx,
+                     int cy,
+                     UINT Flags)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+
+/*
+ * NtUserResolveDesktopForWOW
+ *
+ * Status
+ *    @unimplemented
+ */
+
+DWORD APIENTRY
+NtUserResolveDesktopForWOW(DWORD Unknown0)
+{
+   UNIMPLEMENTED
+   return 0;
+}
+
+BOOL
+APIENTRY
+NtUserDragDetect(
+   HWND hWnd,
+   POINT pt) // Just like the User call.
+{
+   UNIMPLEMENTED
+   return 0;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL APIENTRY
+NtUserEndMenu(VOID)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+/*
+ * @implemented
+ */
+/* NOTE: unused function */
+BOOL APIENTRY
+NtUserTrackPopupMenuEx(
+   HMENU hMenu,
+   UINT fuFlags,
+   int x,
+   int y,
+   HWND hWnd,
+   LPTPMPARAMS lptpm)
+{
+   UNIMPLEMENTED
+
+   return FALSE;
+}
+
+DWORD APIENTRY
+NtUserQuerySendMessage(DWORD Unknown0)
+{
+    UNIMPLEMENTED;
+
+    return 0;
+}
+
+/*
+ * @unimplemented
+ */
+DWORD APIENTRY
+NtUserAlterWindowStyle(DWORD Unknown0,
+                       DWORD Unknown1,
+                       DWORD Unknown2)
+{
+   UNIMPLEMENTED
+
+   return(0);
+}
+
+/*
+ * NtUserSetWindowStationUser
+ *
+ * Status
+ *    @unimplemented
+ */
+
+DWORD APIENTRY
+NtUserSetWindowStationUser(
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+BOOL APIENTRY NtUserAddClipboardFormatListener(
+    HWND hwnd
+)
+{
+    UNIMPLEMENTED;
+    return FALSE;
+}
+
+BOOL APIENTRY NtUserRemoveClipboardFormatListener(
+    HWND hwnd
+)
+{
+    UNIMPLEMENTED;
+    return FALSE;
+}
+
+BOOL APIENTRY NtUserGetUpdatedClipboardFormats(
+    PUINT lpuiFormats,
+    UINT cFormats,
+    PUINT pcFormatsOut
+)
+{
+    UNIMPLEMENTED;
+    return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+DWORD
+APIENTRY
+NtUserGetCursorFrameInfo(
+    DWORD Unknown0,
+    DWORD Unknown1,
+    DWORD Unknown2,
+    DWORD Unknown3)
+{
+    UNIMPLEMENTED
+
+    return 0;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL
+APIENTRY
+NtUserSetSystemCursor(
+    HCURSOR hcur,
+    DWORD id)
+{
+    return FALSE;
+}
 
 /* EOF */
index 7cab141..73b6d9a 100644 (file)
@@ -656,22 +656,6 @@ IntSetWindowProc(PWND pWnd,
    return Ret;
 }
 
-// Move this to user space!
-BOOL FASTCALL
-IntGetWindowInfo(PWND Wnd, PWINDOWINFO pwi)
-{
-   pwi->cbSize = sizeof(WINDOWINFO);
-   pwi->rcWindow = Wnd->rcWindow;
-   pwi->rcClient = Wnd->rcClient;
-   pwi->dwStyle = Wnd->style;
-   pwi->dwExStyle = Wnd->ExStyle;
-   pwi->dwWindowStatus = (UserGetForegroundWindow() == Wnd->head.h); /* WS_ACTIVECAPTION */
-   IntGetWindowBorderMeasures(Wnd, &pwi->cxWindowBorders, &pwi->cyWindowBorders);
-   pwi->atomWindowType = (Wnd->pcls ? Wnd->pcls->atomClassName : 0);
-   pwi->wCreatorVersion = 0x400; /* FIXME - return a real version number */
-   return TRUE;
-}
-
 static BOOL FASTCALL
 IntSetMenu(
    PWND Wnd,
@@ -800,25 +784,6 @@ IntGetClientRect(PWND Window, RECTL *Rect)
 }
 
 
-#if 0
-HWND FASTCALL
-IntGetFocusWindow(VOID)
-{
-   PUSER_MESSAGE_QUEUE Queue;
-   PDESKTOP pdo = IntGetActiveDesktop();
-
-   if( !pdo )
-      return NULL;
-
-   Queue = (PUSER_MESSAGE_QUEUE)pdo->ActiveMessageQueue;
-
-   if (Queue == NULL)
-      return(NULL);
-   else
-      return(Queue->FocusWindow);
-}
-#endif
-
 PMENU_OBJECT FASTCALL
 IntGetSystemMenu(PWND Window, BOOL bRevert, BOOL RetMenu)
 {
@@ -1274,19 +1239,6 @@ IntGetWindowPlacement(PWND Wnd, WINDOWPLACEMENT *lpwndpl)
 
 /* FUNCTIONS *****************************************************************/
 
-/*
- * @unimplemented
- */
-DWORD APIENTRY
-NtUserAlterWindowStyle(DWORD Unknown0,
-                       DWORD Unknown1,
-                       DWORD Unknown2)
-{
-   UNIMPLEMENTED
-
-   return(0);
-}
-
 /*
  * As best as I can figure, this function is used by EnumWindows,
  * EnumChildWindows, EnumDesktopWindows, & EnumThreadWindows.
@@ -2402,25 +2354,7 @@ cleanup:
 
    return hwnd;
 }
-
-/*
- * @unimplemented
- */
-HDWP APIENTRY
-NtUserDeferWindowPos(HDWP WinPosInfo,
-                     HWND Wnd,
-                     HWND WndInsertAfter,
-                     int x,
-                     int y,
-                     int cx,
-                     int cy,
-                     UINT Flags)
-{
-   UNIMPLEMENTED
-
-   return 0;
-}
-
+    
 
 BOOLEAN FASTCALL co_UserDestroyWindow(PWND Window)
 {
@@ -2604,56 +2538,6 @@ CLEANUP:
 }
 
 
-
-/*
- * @unimplemented
- */
-DWORD
-APIENTRY
-NtUserDrawMenuBarTemp(
-   HWND hWnd,
-   HDC hDC,
-   PRECT hRect,
-   HMENU hMenu,
-   HFONT hFont)
-{
-   /* we'll use this function just for caching the menu bar */
-   UNIMPLEMENTED
-   return 0;
-}
-
-
-/*
- * @unimplemented
- */
-DWORD APIENTRY
-NtUserEndDeferWindowPosEx(DWORD Unknown0,
-                          DWORD Unknown1)
-{
-   UNIMPLEMENTED
-
-   return 0;
-}
-
-
-/*
- * FillWindow: Called from User; Dialog, Edit and ListBox procs during a WM_ERASEBKGND.
- */
-/*
- * @unimplemented
- */
-BOOL APIENTRY
-NtUserFillWindow(HWND hWndPaint,
-                 HWND hWndPaint1,
-                 HDC  hDC,
-                 HBRUSH hBrush)
-{
-   UNIMPLEMENTED
-
-   return 0;
-}
-
-
 static HWND FASTCALL
 IntFindWindow(PWND Parent,
               PWND ChildAfter,
@@ -2933,18 +2817,6 @@ CLEANUP:
 }
 
 
-/*
- * @unimplemented
- */
-BOOL APIENTRY
-NtUserFlashWindowEx(IN PFLASHWINFO pfwi)
-{
-   UNIMPLEMENTED
-
-   return 0;
-}
-
-
 /*
  * @implemented
  */
@@ -3791,19 +3663,6 @@ CLEANUP:
    END_CLEANUP;
 }
 
-
-/*
- * @unimplemented
- */
-BOOL APIENTRY
-NtUserLockWindowUpdate(HWND hWnd)
-{
-   UNIMPLEMENTED
-
-   return 0;
-}
-
-
 /*
  * @implemented
  */
@@ -3892,20 +3751,6 @@ CLEANUP:
 }
 
 
-/*
- * @unimplemented
- */
-DWORD APIENTRY
-NtUserRealChildWindowFromPoint(DWORD Unknown0,
-                               DWORD Unknown1,
-                               DWORD Unknown2)
-{
-   UNIMPLEMENTED
-
-   return 0;
-}
-
-
 /*
  * @implemented
  */
@@ -3945,62 +3790,6 @@ CLEANUP:
 }
 
 
-/*
- * @unimplemented
- */
-DWORD APIENTRY
-NtUserSetImeOwnerWindow(DWORD Unknown0,
-                        DWORD Unknown1)
-{
-   UNIMPLEMENTED
-
-   return 0;
-}
-
-
-/*
- * @unimplemented
- */
-DWORD APIENTRY
-NtUserSetInternalWindowPos(
-   HWND    hwnd,
-   UINT    showCmd,
-   LPRECT  rect,
-   LPPOINT pt)
-{
-   UNIMPLEMENTED
-
-   return 0;
-
-}
-
-
-/*
- * @unimplemented
- */
-BOOL APIENTRY
-NtUserSetLayeredWindowAttributes(HWND hwnd,
-                          COLORREF crKey,
-                          BYTE bAlpha,
-                          DWORD dwFlags)
-{
-  UNIMPLEMENTED;
-  return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-BOOL APIENTRY
-NtUserSetLogonNotifyWindow(HWND hWnd)
-{
-   UNIMPLEMENTED
-
-   return 0;
-}
-
-
 /*
  * @implemented
  */
@@ -4381,40 +4170,6 @@ NtUserShowWindowAsync(HWND hWnd, LONG nCmdShow)
 #endif
 }
 
-
-/*
- * @unimplemented
- */
-BOOL
-APIENTRY
-NtUserUpdateLayeredWindow(
-   HWND hwnd,
-   HDC hdcDst,
-   POINT *pptDst,
-   SIZE *psize,
-   HDC hdcSrc,
-   POINT *pptSrc,
-   COLORREF crKey,
-   BLENDFUNCTION *pblend,
-   DWORD dwFlags,
-   RECT *prcDirty)
-{
-   UNIMPLEMENTED
-
-   return 0;
-}
-
-/*
- *    @unimplemented
- */
-HWND APIENTRY
-NtUserWindowFromPhysicalPoint(POINT Point)
-{
-   UNIMPLEMENTED
-
-   return NULL;
-}
-
 /*
  *    @implemented
  */
@@ -4424,6 +4179,7 @@ NtUserWindowFromPoint(LONG X, LONG Y)
    POINT pt;
    HWND Ret;
    PWND DesktopWindow = NULL, Window = NULL;
+   USHORT hittest;
    DECLARE_RETURN(HWND);
    USER_REFERENCE_ENTRY Ref;
 
@@ -4442,7 +4198,7 @@ NtUserWindowFromPoint(LONG X, LONG Y)
       UserRefObjectCo(DesktopWindow, &Ref);
 
       pti = PsGetCurrentThreadWin32Thread();
-      co_WinPosWindowFromPoint(DesktopWindow, pti->MessageQueue, &pt, &Window);
+      Window = co_WinPosWindowFromPoint(DesktopWindow, &pt, &hittest);
 
       if(Window)
       {
index 04c0fd7..b80c9db 100644 (file)
@@ -1578,162 +1578,99 @@ co_WinPosShowWindow(PWND Wnd, INT Cmd)
    return(WasVisible);
 }
 
-
-#if 0
-
-/* find child of 'parent' that contains the given point (in parent-relative coords) */
-PWND child_window_from_point(PWND parent, int x, int y )
-{
-    PWND Wnd;// = parent->spwndChild;
-
-//    LIST_FOR_EACH_ENTRY( Wnd, &parent->children, struct window, entry )
-    for (Wnd = parent->spwndChild; Wnd; Wnd = Wnd->spwndNext)
-    {
-        if (!IntPtInWindow( Wnd, x, y )) continue;  /* skip it */
-
-        /* if window is minimized or disabled, return at once */
-        if (Wnd->style & (WS_MINIMIZE|WS_DISABLED)) return Wnd;
-
-        /* if point is not in client area, return at once */
-        if (x < Wnd->rcClient.left || x >= Wnd->rcClient.right ||
-            y < Wnd->rcClient.top || y >= Wnd->rcClient.bottom)
-            return Wnd;
-
-        return child_window_from_point( Wnd, x - Wnd->rcClient.left, y - Wnd->rcClient.top );
-    }
-    return parent;  /* not found any child */
-}
-#endif
-
-/* wine server: child_window_from_point
-
-Caller must dereference the "returned" Window
-*/
 static
-VOID FASTCALL
+PWND FASTCALL
 co_WinPosSearchChildren(
    PWND ScopeWin,
-   PUSER_MESSAGE_QUEUE OnlyHitTests,
    POINT *Point,
-   PWND* Window,
    USHORT *HitTest
    )
 {
-   PWND Current;
-   HWND *List, *phWnd;
-   USER_REFERENCE_ENTRY Ref;
+    PWND pwndChild;
+    HWND *List, *phWnd;
 
-   ASSERT_REFS_CO(ScopeWin);
-
-   if ((List = IntWinListChildren(ScopeWin)))
-   {
-      for (phWnd = List; *phWnd; ++phWnd)
-      {
-         if (!(Current = UserGetWindowObject(*phWnd)))
-            continue;
-
-         if (!(Current->style & WS_VISIBLE))
-         {
-            continue;
-         }
-
-         if ((Current->style & (WS_POPUP | WS_CHILD | WS_DISABLED)) ==
-               (WS_CHILD | WS_DISABLED))
-         {
-            continue;
-         }
-
-         if (!IntPtInWindow(Current, Point->x, Point->y))
-         {
-             continue;
-         }
-
-         if (*Window) UserDereferenceObject(*Window);
-         *Window = Current;
-         UserReferenceObject(*Window);
+    if (!(ScopeWin->style & WS_VISIBLE))
+    {
+        return NULL;
+    }
 
-         if (Current->style & WS_MINIMIZE)
-         {
-            *HitTest = HTCAPTION;
-            break;
-         }
+    if ((ScopeWin->style & WS_DISABLED))
+    {
+        return NULL;
+    }
 
-         if (Current->style & WS_DISABLED)
-         {
-            *HitTest = HTERROR;
-            break;
-         }
+    if (!IntPtInWindow(ScopeWin, Point->x, Point->y))
+    {
+        return NULL;
+    }
 
-         UserRefObjectCo(Current, &Ref);
+    UserReferenceObject(ScopeWin);
 
-         if (OnlyHitTests && (Current->head.pti->MessageQueue == OnlyHitTests))
-         {
-            *HitTest = co_IntSendMessage(Current->head.h, WM_NCHITTEST, 0,
-                                         MAKELONG(Point->x, Point->y));
-            if ((*HitTest) == (USHORT)HTTRANSPARENT)
+    if (Point->x - ScopeWin->rcClient.left < ScopeWin->rcClient.right &&
+        Point->y - ScopeWin->rcClient.top < ScopeWin->rcClient.bottom )
+    {
+        List = IntWinListChildren(ScopeWin);
+        if(List)
+        {
+            for (phWnd = List; *phWnd; ++phWnd)
             {
-               UserDerefObjectCo(Current);
-               continue;
+                if (!(pwndChild = UserGetWindowObject(*phWnd)))
+                {
+                    continue;
+                }
+
+                pwndChild = co_WinPosSearchChildren(pwndChild, Point, HitTest);
+
+                if(pwndChild != NULL)
+                {
+                    /* We found a window. Don't send any more WM_NCHITTEST messages */
+                    UserDereferenceObject(ScopeWin);
+                    return pwndChild;
+                }
             }
-         }
-         else
-            *HitTest = HTCLIENT;
-
-         if (Point->x >= Current->rcClient.left &&
-               Point->x < Current->rcClient.right &&
-               Point->y >= Current->rcClient.top &&
-               Point->y < Current->rcClient.bottom)
-         {
-            co_WinPosSearchChildren(Current, OnlyHitTests, Point, Window, HitTest);
-         }
+        }
 
-         UserDerefObjectCo(Current);
+        ExFreePool(List);
+    }
 
-         break;
-      }
-      ExFreePool(List);
-   }
+    *HitTest = co_IntSendMessage(ScopeWin->head.h, WM_NCHITTEST, 0,
+                                 MAKELONG(Point->x, Point->y));
+    if ((*HitTest) == (USHORT)HTTRANSPARENT)
+    {
+         UserDereferenceObject(ScopeWin);
+         return NULL;
+    }
+    
+    return ScopeWin;
 }
 
-/* wine: WINPOS_WindowFromPoint */
-USHORT FASTCALL
-co_WinPosWindowFromPoint(PWND ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint,
-                         PWND* Window)
+PWND FASTCALL
+co_WinPosWindowFromPoint(PWND ScopeWin, POINT *WinPoint, USHORT* HitTest)
 {
-   HWND DesktopWindowHandle;
-   PWND DesktopWindow;
+   PWND Window;
    POINT Point = *WinPoint;
-   USHORT HitTest;
-
-   ASSERT_REFS_CO(ScopeWin);
-
-   *Window = NULL;
+   USER_REFERENCE_ENTRY Ref;
 
-   if(!ScopeWin)
+   if( ScopeWin == NULL )
    {
-      DPRINT1("WinPosWindowFromPoint(): ScopeWin == NULL!\n");
-      return(HTERROR);
+       ScopeWin = UserGetDesktopWindow();
+       if(ScopeWin == NULL)
+           return NULL;
    }
 
-   if (ScopeWin->style & WS_DISABLED)
-   {
-      return(HTERROR);
-   }
+   *HitTest = HTNOWHERE;
 
-   /* Translate the point to the space of the scope window. */
-   DesktopWindowHandle = IntGetDesktopWindow();
-   if((DesktopWindowHandle != ScopeWin->head.h) &&
-         (DesktopWindow = UserGetWindowObject(DesktopWindowHandle)))
-   {
-      Point.x += ScopeWin->rcClient.left - DesktopWindow->rcClient.left;
-      Point.y += ScopeWin->rcClient.top - DesktopWindow->rcClient.top;
-   }
+   ASSERT_REFS_CO(ScopeWin);
+   UserRefObjectCo(ScopeWin, &Ref);
 
-   HitTest = HTNOWHERE;
+   Window = co_WinPosSearchChildren(ScopeWin, &Point, HitTest);
 
-   co_WinPosSearchChildren(ScopeWin, OnlyHitTests, &Point, Window, &HitTest);
+   UserDerefObjectCo(ScopeWin);
+   if(Window)
+       ASSERT_REFS_CO(Window);
+   ASSERT_REFS_CO(ScopeWin);
 
-   return ((*Window) ? HitTest : HTNOWHERE);
+   return Window;
 }
 
 BOOL
index ca99f79..855ce9a 100644 (file)
@@ -1127,25 +1127,6 @@ NtUserUnlockWindowStation(HWINSTA hWindowStation)
    return Ret;
 }
 
-/*
- * NtUserSetWindowStationUser
- *
- * Status
- *    @unimplemented
- */
-
-DWORD APIENTRY
-NtUserSetWindowStationUser(
-   DWORD Unknown0,
-   DWORD Unknown1,
-   DWORD Unknown2,
-   DWORD Unknown3)
-{
-   UNIMPLEMENTED
-
-   return 0;
-}
-
 static NTSTATUS FASTCALL
 BuildWindowStationNameList(
    ULONG dwSize,
index 90075c8..3399183 100644 (file)
@@ -33,6 +33,9 @@ typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
 #define PRECT PRECTL
 #define LPRECT LPRECTL
 #define LPCRECT LPCRECTL
+#define POINT POINTL
+#define LPPOINT PPOINTL
+#define PPOINT PPOINTL
 
 #include <winerror.h>
 #include <wingdi.h>