- Rewrite EngAcquire/ReleaseSemaphore.
- Add internal fastcalls for them and tag.
- Fix DxEngUn/LockShareSem.
- Tested with Qemu. Needs Dx testing.

svn path=/trunk/; revision=33309
This commit is contained in:
James Tabor 2008-05-06 03:40:38 +00:00
parent ebec4882b2
commit 19381c9fed
6 changed files with 42 additions and 29 deletions

View file

@ -11,7 +11,7 @@ STDCALL
EngCreateSemaphore ( VOID ) EngCreateSemaphore ( VOID )
{ {
// www.osr.com/ddk/graphics/gdifncs_95lz.htm // www.osr.com/ddk/graphics/gdifncs_95lz.htm
PERESOURCE psem = ExAllocatePool ( NonPagedPool, sizeof(ERESOURCE) ); PERESOURCE psem = ExAllocatePoolWithTag( NonPagedPool, sizeof(ERESOURCE), TAG_GSEM );
if ( !psem ) if ( !psem )
return NULL; return NULL;
if ( !NT_SUCCESS(ExInitializeResourceLite ( psem )) ) if ( !NT_SUCCESS(ExInitializeResourceLite ( psem )) )
@ -22,6 +22,14 @@ EngCreateSemaphore ( VOID )
return (HSEMAPHORE)psem; return (HSEMAPHORE)psem;
} }
VOID
FASTCALL
IntGdiAcquireSemaphore ( HSEMAPHORE hsem )
{
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite ( (PERESOURCE)hsem, TRUE );
}
/* /*
* @implemented * @implemented
*/ */
@ -30,9 +38,20 @@ STDCALL
EngAcquireSemaphore ( IN HSEMAPHORE hsem ) EngAcquireSemaphore ( IN HSEMAPHORE hsem )
{ {
// www.osr.com/ddk/graphics/gdifncs_14br.htm // www.osr.com/ddk/graphics/gdifncs_14br.htm
PW32THREAD W32Thread;
ASSERT(hsem); ASSERT(hsem);
KeEnterCriticalRegion(); IntGdiAcquireSemaphore ( hsem );
ExAcquireResourceExclusiveLite ( (PERESOURCE)hsem, TRUE ); W32Thread = PsGetThreadWin32Thread(PsGetCurrentThread());
if (W32Thread) W32Thread->dwEngAcquireCount++;
}
VOID
FASTCALL
IntGdiReleaseSemaphore ( HSEMAPHORE hsem )
{
ExReleaseResourceLite ( (PERESOURCE)hsem );
KeLeaveCriticalRegion();
} }
/* /*
@ -43,9 +62,11 @@ STDCALL
EngReleaseSemaphore ( IN HSEMAPHORE hsem ) EngReleaseSemaphore ( IN HSEMAPHORE hsem )
{ {
// www.osr.com/ddk/graphics/gdifncs_5u3r.htm // www.osr.com/ddk/graphics/gdifncs_5u3r.htm
PW32THREAD W32Thread;
ASSERT(hsem); ASSERT(hsem);
ExReleaseResourceLite ( (PERESOURCE)hsem ); W32Thread = PsGetThreadWin32Thread(PsGetCurrentThread());
KeLeaveCriticalRegion(); if (W32Thread) --W32Thread->dwEngAcquireCount;
IntGdiReleaseSemaphore ( hsem );
} }
/* /*

View file

@ -20,4 +20,7 @@ IntEngWindowChanged(
PWINDOW_OBJECT Window, PWINDOW_OBJECT Window,
FLONG flChanged); FLONG flChanged);
VOID FASTCALL IntGdiAcquireSemaphore ( HSEMAPHORE hsem );
VOID FASTCALL IntGdiReleaseSemaphore ( HSEMAPHORE hsem );
#endif /* _WIN32K_ENG_H */ #endif /* _WIN32K_ENG_H */

View file

@ -81,6 +81,7 @@
#define TAG_WNDOBJ TAG('W', 'N', 'D', 'O') /* window object */ #define TAG_WNDOBJ TAG('W', 'N', 'D', 'O') /* window object */
#define TAG_XLATEOBJ TAG('X', 'L', 'A', 'O') /* xlate object */ #define TAG_XLATEOBJ TAG('X', 'L', 'A', 'O') /* xlate object */
#define TAG_BITMAPOBJ TAG('B', 'M', 'P', 'O') /* bitmap object */ #define TAG_BITMAPOBJ TAG('B', 'M', 'P', 'O') /* bitmap object */
#define TAG_GSEM TAG('G', 's', 'e', 'm') /* Gdi Semaphore */
/* misc */ /* misc */
#define TAG_DRIVER TAG('G', 'D', 'R', 'V') /* video drivers */ #define TAG_DRIVER TAG('G', 'D', 'R', 'V') /* video drivers */

View file

@ -13,6 +13,7 @@ typedef struct _W32THREAD
HANDLE hDesktop; HANDLE hDesktop;
PVOID pgdiDcattr; PVOID pgdiDcattr;
PVOID pgdiBrushAttr; PVOID pgdiBrushAttr;
DWORD dwEngAcquireCount;
BOOLEAN IsExiting; BOOLEAN IsExiting;
SINGLE_LIST_ENTRY ReferencesList; SINGLE_LIST_ENTRY ReferencesList;
ULONG Hooks; ULONG Hooks;

View file

@ -9,7 +9,7 @@
#include <w32k.h> #include <w32k.h>
#include <debug.h> #include <debug.h>
ERESOURCE ghsemShareDevLock; HSEMAPHORE ghsemShareDevLock = NULL;
ULONG gcEngFuncs = DXENG_INDEX_DxEngLoadImage + 1; ULONG gcEngFuncs = DXENG_INDEX_DxEngLoadImage + 1;
DRVFN gaEngFuncs [] = DRVFN gaEngFuncs [] =
@ -171,23 +171,17 @@ DxEngUnlockDC(PDC pDC)
* *
* @remarks. * @remarks.
* It is being used in various ntuser* functions and ntgdi* * 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 *SystemResourcesList
*--*/ *--*/
BOOLEAN BOOLEAN
STDCALL STDCALL
DxEngLockShareSem() DxEngLockShareSem()
{ {
BOOLEAN retVal = FALSE;
DPRINT1("ReactX Calling : DxEngLockShareSem\n"); DPRINT1("ReactX Calling : DxEngLockShareSem\n");
#if 0 if(!ghsemShareDevLock) ghsemShareDevLock = EngCreateSemaphore(); // Hax, should be in dllmain.c
if (ExIsResourceAcquiredExclusiveLite(&ghsemShareDevLock) == FALSE) IntGdiAcquireSemaphore(ghsemShareDevLock);
{ return TRUE;
KeEnterCriticalRegion();
retVal = ExAcquireResourceExclusiveLite(&ghsemShareDevLock, TRUE);
}
#endif
return retVal;
} }
/*++ /*++
@ -200,7 +194,7 @@ DxEngLockShareSem()
* This function returns TRUE no matter what. * This function returns TRUE no matter what.
* *
* @remarks. * @remarks.
* ReactOS specific: It is not in use yet. * ReactOS specific: It is not in use yet?
* *
*--*/ *--*/
BOOLEAN BOOLEAN
@ -208,14 +202,7 @@ STDCALL
DxEngUnlockShareSem() DxEngUnlockShareSem()
{ {
DPRINT1("ReactX Calling : DxEngUnlockShareSem\n"); DPRINT1("ReactX Calling : DxEngUnlockShareSem\n");
IntGdiReleaseSemaphore(ghsemShareDevLock);
#if 0
if (ExIsResourceAcquiredExclusiveLite(&ghsemShareDevLock) == TRUE)
{
ExReleaseResourceLite(&ghsemShareDevLock);
KeLeaveCriticalRegion();
}
#endif
return TRUE; return TRUE;
} }

View file

@ -2705,21 +2705,21 @@ VOID FASTCALL
IntGdiReferencePdev(PGDIDEVICE pPDev) IntGdiReferencePdev(PGDIDEVICE pPDev)
{ {
if(!hsemDriverMgmt) hsemDriverMgmt = EngCreateSemaphore(); // Hax, should be in dllmain.c if(!hsemDriverMgmt) hsemDriverMgmt = EngCreateSemaphore(); // Hax, should be in dllmain.c
EngAcquireSemaphore(hsemDriverMgmt); IntGdiAcquireSemaphore(hsemDriverMgmt);
pPDev->cPdevRefs++; pPDev->cPdevRefs++;
EngReleaseSemaphore(hsemDriverMgmt); IntGdiReleaseSemaphore(hsemDriverMgmt);
} }
VOID FASTCALL VOID FASTCALL
IntGdiUnreferencePdev(PGDIDEVICE pPDev, DWORD CleanUpType) IntGdiUnreferencePdev(PGDIDEVICE pPDev, DWORD CleanUpType)
{ {
EngAcquireSemaphore(hsemDriverMgmt); IntGdiAcquireSemaphore(hsemDriverMgmt);
pPDev->cPdevRefs--; pPDev->cPdevRefs--;
if (!pPDev->cPdevRefs) if (!pPDev->cPdevRefs)
{ {
// Handle the destruction of pPDev or GDIDEVICE or PDEVOBJ or PDEV etc. // Handle the destruction of pPDev or GDIDEVICE or PDEVOBJ or PDEV etc.
} }
EngReleaseSemaphore(hsemDriverMgmt); IntGdiReleaseSemaphore(hsemDriverMgmt);
} }