Author: greatlrd
Date: Mon Dec 31 00:14:20 2007
New Revision: 31505
URL:
http://svn.reactos.org/svn/reactos?rev=31505&view=rev
Log:
Add : struct _DD_BASEOBJECT base on alex and own and jim informations
Add : struct _DD_ENTRY base on alex info
change : gpentDdHmgr and gpentDdHmgrLast to PDD_ENTRY pointer
change : move all DdHmg releated api to own file
Implement : DdHmgLock not yet use
Implement : VerifyObjectOwner it verify how own the DD_ENTRY
Added:
trunk/reactos/drivers/directx/dxg/ddhmg.c (with props)
Modified:
trunk/reactos/drivers/directx/dxg/dxg.rbuild
trunk/reactos/drivers/directx/dxg/dxg_int.h
trunk/reactos/drivers/directx/dxg/main.c
Added: trunk/reactos/drivers/directx/dxg/ddhmg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/directx/dxg/ddhmg.…
==============================================================================
--- trunk/reactos/drivers/directx/dxg/ddhmg.c (added)
+++ trunk/reactos/drivers/directx/dxg/ddhmg.c Mon Dec 31 00:14:20 2007
@@ -1,0 +1,128 @@
+
+
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * PURPOSE: Native driver for dxg implementation
+ * FILE: drivers/directx/dxg/ddhmg.c
+ * PROGRAMER: Magnus olsen (magnus(a)greatlord.com)
+ * REVISION HISTORY:
+ * 30/12-2007 Magnus Olsen
+ */
+
+#include <dxg_int.h>
+
+/* The DdHmgr manger stuff */
+ULONG gcSizeDdHmgr = 64 * sizeof(DD_ENTRY);
+PDD_ENTRY gpentDdHmgr = NULL;
+
+ULONG gcMaxDdHmgr = 0;
+PDD_ENTRY gpentDdHmgrLast = NULL;
+
+HANDLE ghFreeDdHmgr = 0;
+HSEMAPHORE ghsemHmgr = NULL;
+
+BOOL
+FASTCALL
+VerifyObjectOwner(PDD_ENTRY pEntry)
+{
+ DWORD Pid = (DWORD) PsGetCurrentProcessId() & 0xFFFFFFFC;
+ DWORD check = pEntry->ObjectOwner.ulObj & 0xFFFFFFFE;
+ return ( (check == Pid) || (!check));
+}
+
+BOOL
+FASTCALL
+DdHmgCreate()
+{
+ gpentDdHmgr = EngAllocMem(FL_ZERO_MEMORY, gcSizeDdHmgr, TAG_THDD);
+ ghFreeDdHmgr = 0;
+ gcMaxDdHmgr = 1;
+
+ if (gpentDdHmgr)
+ {
+ ghsemHmgr = EngCreateSemaphore();
+
+ if (ghsemHmgr)
+ {
+ gpLockShortDelay = EngAllocMem(FL_ZERO_MEMORY | FL_NONPAGED_MEMORY,
sizeof(LARGE_INTEGER), TAG_GINI);
+
+ if (gpLockShortDelay)
+ {
+ gpLockShortDelay->HighPart = -1;
+ return TRUE;
+ }
+
+ EngDeleteSemaphore(ghsemHmgr);
+ ghsemHmgr = NULL;
+ }
+
+ EngFreeMem(gpentDdHmgr);
+ gpentDdHmgr = NULL;
+ }
+
+ return FALSE;
+}
+
+BOOL
+FASTCALL
+DdHmgDestroy()
+{
+ gcMaxDdHmgr = 0;
+ gcSizeDdHmgr = 0;
+ ghFreeDdHmgr = 0;
+ gpentDdHmgrLast = NULL;
+
+ if (gpentDdHmgr)
+ {
+ EngFreeMem(gpentDdHmgr);
+ gpentDdHmgr = NULL;
+ }
+
+ if (ghsemHmgr)
+ {
+ EngDeleteSemaphore(ghsemHmgr);
+ ghsemHmgr = NULL;
+ }
+
+ return TRUE;
+}
+
+PVOID
+FASTCALL
+DdHmgLock( HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned)
+{
+
+ DWORD Index = (DWORD)DdHandle & 0x1FFFFF;
+ PDD_ENTRY pEntry = NULL;
+ PVOID Object = NULL;
+
+ if ( !LockOwned )
+ {
+ EngAcquireSemaphore(ghsemHmgr);
+ }
+
+ if ( Index < gcMaxDdHmgr )
+ {
+ pEntry = (PDD_ENTRY)((PBYTE)gpentDdHmgr + (sizeof(DD_ENTRY) * Index));
+ if ( VerifyObjectOwner(pEntry) )
+ {
+ if ( (pEntry->Objt == ObjectType ) &&
+ (pEntry->FullUnique == (((DWORD)DdHandle >> 21) & 0x7FF) )
&&
+ (pEntry->pobj->cExclusiveLock == 0) &&
+ (pEntry->pobj->Tid == PsGetCurrentThread()))
+ {
+ InterlockedIncrement(&pEntry->pobj->cExclusiveLock);
+ pEntry->pobj->Tid = PsGetCurrentThread();
+ Object = pEntry->pobj;
+ }
+ }
+ }
+
+ if ( !LockOwned )
+ {
+ EngDeleteSemaphore(ghsemHmgr);
+ }
+
+ return Object;
+}
Propchange: trunk/reactos/drivers/directx/dxg/ddhmg.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/drivers/directx/dxg/dxg.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/directx/dxg/dxg.rb…
==============================================================================
--- trunk/reactos/drivers/directx/dxg/dxg.rbuild (original)
+++ trunk/reactos/drivers/directx/dxg/dxg.rbuild Mon Dec 31 00:14:20 2007
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
-<module name="dxg" type="kernelmodedriver"
+<module name="dxg" type="kernelmodedriver"
installbase="system32/drivers" installname="dxg.sys">
<importlibrary definition="dxg.def" />
<include base="dxg">.</include>
@@ -8,6 +8,7 @@
<library>dxgthk</library>
<library>ntoskrnl</library>
<file>main.c</file>
+ <file>ddhmg.c</file>
<file>eng.c</file>
<file>historic.c</file>
<file>dxg.rc</file>
Modified: trunk/reactos/drivers/directx/dxg/dxg_int.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/directx/dxg/dxg_in…
==============================================================================
--- trunk/reactos/drivers/directx/dxg/dxg_int.h (original)
+++ trunk/reactos/drivers/directx/dxg/dxg_int.h Mon Dec 31 00:14:20 2007
@@ -31,11 +31,58 @@
#include "tags.h"
+typedef struct _DD_BASEOBJECT
+{
+ HANDLE hHmgr;
+ ULONG ulShareCount;
+ LONG cExclusiveLock;
+ PVOID Tid;
+} DD_BASEOBJECT, *PDD_BASEOBJECT, *POBJ;
+
+ typedef struct _DD_ENTRY
+{
+ union
+ {
+ POBJ pobj;
+ HANDLE hFree;
+ };
+ union
+ {
+ ULONG ulObj;
+ struct
+ {
+ USHORT Count;
+ USHORT Lock;
+ HANDLE Pid;
+ };
+ } ObjectOwner;
+ USHORT FullUnique;
+ UCHAR Objt;
+ UCHAR Flags;
+ PVOID pUser;
+} DD_ENTRY, *PDD_ENTRY;
+
+
+
/* exported functions */
NTSTATUS DriverEntry(IN PVOID Context1, IN PVOID Context2);
NTSTATUS GsDriverEntry(IN PVOID Context1, IN PVOID Context2);
NTSTATUS DxDdCleanupDxGraphics();
+
+/* Global pointers */
+extern ULONG gcSizeDdHmgr;
+extern PDD_ENTRY gpentDdHmgr;
+extern ULONG gcMaxDdHmgr;
+extern PDD_ENTRY gpentDdHmgrLast;
+extern HANDLE ghFreeDdHmgr;
+extern HSEMAPHORE ghsemHmgr;
+extern LONG gcDummyPageRefCnt;
+extern HSEMAPHORE ghsemDummyPage;
+extern VOID *gpDummyPage;
+extern PEPROCESS gpepSession;
+extern PLARGE_INTEGER gpLockShortDelay;
+
/* Driver list export functions */
@@ -43,8 +90,12 @@
DWORD STDCALL DxDdIoctl(ULONG ulIoctl, PVOID pBuffer, ULONG ulBufferSize);
/* Internel functions */
-BOOL DdHmgCreate();
-BOOL DdHmgDestroy();
+BOOL FASTCALL VerifyObjectOwner(PDD_ENTRY pEntry);
+BOOL FASTCALL DdHmgCreate();
+BOOL FASTCALL DdHmgDestroy();
+PVOID FASTCALL DdHmgLock( HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned);
+
+
/* define stuff */
#define drvDxEngLockDC gpEngFuncs[DXENG_INDEX_DxEngLockDC]
@@ -53,3 +104,4 @@
#define drvDxEngUnlockDC gpEngFuncs[DXENG_INDEX_DxEngUnlockDC]
#define drvDxEngUnlockHdev gpEngFuncs[DXENG_INDEX_DxEngUnlockHdev]
#define drvDxEngLockHdev gpEngFuncs[DXENG_INDEX_DxEngLockHdev]
+
Modified: trunk/reactos/drivers/directx/dxg/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/directx/dxg/main.c…
==============================================================================
--- trunk/reactos/drivers/directx/dxg/main.c (original)
+++ trunk/reactos/drivers/directx/dxg/main.c Mon Dec 31 00:14:20 2007
@@ -13,17 +13,11 @@
#include <dxg_int.h>
#include "dxg_driver.h"
-ULONG gcMaxDdHmgr = 0;
-ULONG gcSizeDdHmgr = 0;
LONG gcDummyPageRefCnt = 0;
-HSEMAPHORE ghsemHmgr = NULL;
HSEMAPHORE ghsemDummyPage = NULL;
VOID *gpDummyPage = NULL;
PEPROCESS gpepSession = NULL;
PLARGE_INTEGER gpLockShortDelay = NULL;
-HANDLE ghFreeDdHmgr = 0;
-VOID *gpentDdHmgr = NULL;
-VOID *gpentDdHmgrLast = NULL;
PDRVFN gpEngFuncs;
@@ -142,61 +136,10 @@
return 0;
}
-BOOL
-DdHmgDestroy()
-{
- gcMaxDdHmgr = 0;
- gcSizeDdHmgr = 0;
- ghFreeDdHmgr = 0;
- gpentDdHmgrLast = NULL;
-
- if (gpentDdHmgr)
- {
- EngFreeMem(gpentDdHmgr);
- gpentDdHmgr = NULL;
- }
-
- if (ghsemHmgr)
- {
- EngDeleteSemaphore(ghsemHmgr);
- ghsemHmgr = NULL;
- }
-
- return TRUE;
-}
-
-
-BOOL
-DdHmgCreate()
-{
- gpentDdHmgr = EngAllocMem(FL_ZERO_MEMORY, gcSizeDdHmgr, TAG_THDD);
- ghFreeDdHmgr = 0;
- gcMaxDdHmgr = 1;
-
- if (gpentDdHmgr)
- {
- ghsemHmgr = EngCreateSemaphore();
-
- if (ghsemHmgr)
- {
- gpLockShortDelay = EngAllocMem(FL_ZERO_MEMORY | FL_NONPAGED_MEMORY,
sizeof(LARGE_INTEGER), TAG_GINI);
-
- if (gpLockShortDelay)
- {
- gpLockShortDelay->HighPart = -1;
- return TRUE;
- }
-
- EngDeleteSemaphore(ghsemHmgr);
- ghsemHmgr = NULL;
- }
-
- EngFreeMem(gpentDdHmgr);
- gpentDdHmgr = NULL;
- }
-
- return FALSE;
-}
+
+
+
+