Author: jimtabor
Date: Mon May 5 22:40:38 2008
New Revision: 33309
URL:
http://svn.reactos.org/svn/reactos?rev=33309&view=rev
Log:
Win32k:
- Rewrite EngAcquire/ReleaseSemaphore.
- Add internal fastcalls for them and tag.
- Fix DxEngUn/LockShareSem.
- Tested with Qemu. Needs Dx testing.
Modified:
trunk/reactos/subsystems/win32/win32k/eng/semaphor.c
trunk/reactos/subsystems/win32/win32k/include/eng.h
trunk/reactos/subsystems/win32/win32k/include/tags.h
trunk/reactos/subsystems/win32/win32k/include/win32.h
trunk/reactos/subsystems/win32/win32k/ntddraw/dxeng.c
trunk/reactos/subsystems/win32/win32k/objects/dc.c
Modified: trunk/reactos/subsystems/win32/win32k/eng/semaphor.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/en…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/eng/semaphor.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/eng/semaphor.c [iso-8859-1] Mon May 5 22:40:38
2008
@@ -11,7 +11,7 @@
EngCreateSemaphore ( VOID )
{
//
www.osr.com/ddk/graphics/gdifncs_95lz.htm
- PERESOURCE psem = ExAllocatePool ( NonPagedPool, sizeof(ERESOURCE) );
+ PERESOURCE psem = ExAllocatePoolWithTag( NonPagedPool, sizeof(ERESOURCE), TAG_GSEM );
if ( !psem )
return NULL;
if ( !NT_SUCCESS(ExInitializeResourceLite ( psem )) )
@@ -22,6 +22,14 @@
return (HSEMAPHORE)psem;
}
+VOID
+FASTCALL
+IntGdiAcquireSemaphore ( HSEMAPHORE hsem )
+{
+ KeEnterCriticalRegion();
+ ExAcquireResourceExclusiveLite ( (PERESOURCE)hsem, TRUE );
+}
+
/*
* @implemented
*/
@@ -30,9 +38,20 @@
EngAcquireSemaphore ( IN HSEMAPHORE hsem )
{
//
www.osr.com/ddk/graphics/gdifncs_14br.htm
+ PW32THREAD W32Thread;
ASSERT(hsem);
- KeEnterCriticalRegion();
- ExAcquireResourceExclusiveLite ( (PERESOURCE)hsem, TRUE );
+ IntGdiAcquireSemaphore ( hsem );
+ W32Thread = PsGetThreadWin32Thread(PsGetCurrentThread());
+ if (W32Thread) W32Thread->dwEngAcquireCount++;
+}
+
+
+VOID
+FASTCALL
+IntGdiReleaseSemaphore ( HSEMAPHORE hsem )
+{
+ ExReleaseResourceLite ( (PERESOURCE)hsem );
+ KeLeaveCriticalRegion();
}
/*
@@ -43,9 +62,11 @@
EngReleaseSemaphore ( IN HSEMAPHORE hsem )
{
//
www.osr.com/ddk/graphics/gdifncs_5u3r.htm
+ PW32THREAD W32Thread;
ASSERT(hsem);
- ExReleaseResourceLite ( (PERESOURCE)hsem );
- KeLeaveCriticalRegion();
+ W32Thread = PsGetThreadWin32Thread(PsGetCurrentThread());
+ if (W32Thread) --W32Thread->dwEngAcquireCount;
+ IntGdiReleaseSemaphore ( hsem );
}
/*
Modified: trunk/reactos/subsystems/win32/win32k/include/eng.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/eng.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/eng.h [iso-8859-1] Mon May 5 22:40:38
2008
@@ -20,4 +20,7 @@
PWINDOW_OBJECT Window,
FLONG flChanged);
+VOID FASTCALL IntGdiAcquireSemaphore ( HSEMAPHORE hsem );
+VOID FASTCALL IntGdiReleaseSemaphore ( HSEMAPHORE hsem );
+
#endif /* _WIN32K_ENG_H */
Modified: trunk/reactos/subsystems/win32/win32k/include/tags.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/tags.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/tags.h [iso-8859-1] Mon May 5 22:40:38
2008
@@ -81,6 +81,7 @@
#define TAG_WNDOBJ TAG('W', 'N', 'D', 'O') /* window
object */
#define TAG_XLATEOBJ TAG('X', 'L', 'A', 'O') /* xlate
object */
#define TAG_BITMAPOBJ TAG('B', 'M', 'P', 'O') /* bitmap
object */
+#define TAG_GSEM TAG('G', 's', 'e', 'm') /* Gdi
Semaphore */
/* misc */
#define TAG_DRIVER TAG('G', 'D', 'R', 'V') /* video
drivers */
Modified: trunk/reactos/subsystems/win32/win32k/include/win32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1] Mon May 5 22:40:38
2008
@@ -13,6 +13,7 @@
HANDLE hDesktop;
PVOID pgdiDcattr;
PVOID pgdiBrushAttr;
+ DWORD dwEngAcquireCount;
BOOLEAN IsExiting;
SINGLE_LIST_ENTRY ReferencesList;
ULONG Hooks;
Modified: trunk/reactos/subsystems/win32/win32k/ntddraw/dxeng.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntddraw/dxeng.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntddraw/dxeng.c [iso-8859-1] Mon May 5 22:40:38
2008
@@ -9,7 +9,7 @@
#include <w32k.h>
#include <debug.h>
-ERESOURCE ghsemShareDevLock;
+HSEMAPHORE ghsemShareDevLock = NULL;
ULONG gcEngFuncs = DXENG_INDEX_DxEngLoadImage + 1;
DRVFN gaEngFuncs [] =
@@ -171,23 +171,17 @@
*
* @remarks.
* It is being used in various ntuser* functions and ntgdi*
-* ReactOS specific: It is not in use yet.
+* ReactOS specific: It is not in use yet?
*SystemResourcesList
*--*/
BOOLEAN
STDCALL
DxEngLockShareSem()
{
- BOOLEAN retVal = FALSE;
DPRINT1("ReactX Calling : DxEngLockShareSem\n");
-#if 0
- if (ExIsResourceAcquiredExclusiveLite(&ghsemShareDevLock) == FALSE)
- {
- KeEnterCriticalRegion();
- retVal = ExAcquireResourceExclusiveLite(&ghsemShareDevLock, TRUE);
- }
-#endif
- return retVal;
+ if(!ghsemShareDevLock) ghsemShareDevLock = EngCreateSemaphore(); // Hax, should be in
dllmain.c
+ IntGdiAcquireSemaphore(ghsemShareDevLock);
+ return TRUE;
}
/*++
@@ -200,7 +194,7 @@
* This function returns TRUE no matter what.
*
* @remarks.
-* ReactOS specific: It is not in use yet.
+* ReactOS specific: It is not in use yet?
*
*--*/
BOOLEAN
@@ -208,14 +202,7 @@
DxEngUnlockShareSem()
{
DPRINT1("ReactX Calling : DxEngUnlockShareSem\n");
-
-#if 0
- if (ExIsResourceAcquiredExclusiveLite(&ghsemShareDevLock) == TRUE)
- {
- ExReleaseResourceLite(&ghsemShareDevLock);
- KeLeaveCriticalRegion();
- }
-#endif
+ IntGdiReleaseSemaphore(ghsemShareDevLock);
return TRUE;
}
Modified: trunk/reactos/subsystems/win32/win32k/objects/dc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dc.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dc.c [iso-8859-1] Mon May 5 22:40:38
2008
@@ -2705,21 +2705,21 @@
IntGdiReferencePdev(PGDIDEVICE pPDev)
{
if(!hsemDriverMgmt) hsemDriverMgmt = EngCreateSemaphore(); // Hax, should be in
dllmain.c
- EngAcquireSemaphore(hsemDriverMgmt);
+ IntGdiAcquireSemaphore(hsemDriverMgmt);
pPDev->cPdevRefs++;
- EngReleaseSemaphore(hsemDriverMgmt);
+ IntGdiReleaseSemaphore(hsemDriverMgmt);
}
VOID FASTCALL
IntGdiUnreferencePdev(PGDIDEVICE pPDev, DWORD CleanUpType)
{
- EngAcquireSemaphore(hsemDriverMgmt);
+ IntGdiAcquireSemaphore(hsemDriverMgmt);
pPDev->cPdevRefs--;
if (!pPDev->cPdevRefs)
{
// Handle the destruction of pPDev or GDIDEVICE or PDEVOBJ or PDEV etc.
}
- EngReleaseSemaphore(hsemDriverMgmt);
+ IntGdiReleaseSemaphore(hsemDriverMgmt);
}