Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenddhmg.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS kernel 00004 * PURPOSE: Native driver for dxg implementation 00005 * FILE: drivers/directx/dxg/ddhmg.c 00006 * PROGRAMER: Magnus olsen (magnus@greatlord.com) 00007 * REVISION HISTORY: 00008 * 30/12-2007 Magnus Olsen 00009 */ 00010 00011 #include <dxg_int.h> 00012 00013 /* The DdHmgr manger stuff */ 00014 ULONG gcSizeDdHmgr = 64 * sizeof(DD_ENTRY); 00015 PDD_ENTRY gpentDdHmgr = NULL; 00016 00017 ULONG gcMaxDdHmgr = 0; 00018 PDD_ENTRY gpentDdHmgrLast = NULL; 00019 00020 HANDLE ghFreeDdHmgr = 0; 00021 HSEMAPHORE ghsemHmgr = NULL; 00022 00023 BOOL 00024 FASTCALL 00025 VerifyObjectOwner(PDD_ENTRY pEntry) 00026 { 00027 DWORD Pid = (DWORD)(DWORD_PTR)PsGetCurrentProcessId() & 0xFFFFFFFC; 00028 DWORD check = pEntry->ObjectOwner.ulObj & 0xFFFFFFFE; 00029 return ( (check == Pid) || (!check)); 00030 } 00031 00032 /*++ 00033 * @name DdHmgCreate 00034 * @implemented 00035 * 00036 * The function DdHmgCreate is used internally in dxg.sys 00037 * It creates all DX kernel objects that are need it for creation of DX objects. 00038 * 00039 * @return 00040 * Return FALSE for failure and TRUE for success in creating the DX object 00041 * 00042 * @remarks. 00043 * Only used internally in dxg.sys 00044 *--*/ 00045 BOOL 00046 FASTCALL 00047 DdHmgCreate(VOID) 00048 { 00049 gpentDdHmgr = EngAllocMem(FL_ZERO_MEMORY, gcSizeDdHmgr, TAG_THDD); 00050 ghFreeDdHmgr = 0; 00051 gcMaxDdHmgr = 1; 00052 00053 if (gpentDdHmgr) 00054 { 00055 ghsemHmgr = EngCreateSemaphore(); 00056 00057 if (ghsemHmgr) 00058 { 00059 gpLockShortDelay = EngAllocMem(FL_ZERO_MEMORY | FL_NONPAGED_MEMORY, sizeof(LARGE_INTEGER), TAG_GINI); 00060 00061 if (gpLockShortDelay) 00062 { 00063 gpLockShortDelay->HighPart = -1; 00064 return TRUE; 00065 } 00066 00067 EngDeleteSemaphore(ghsemHmgr); 00068 ghsemHmgr = NULL; 00069 } 00070 00071 EngFreeMem(gpentDdHmgr); 00072 gpentDdHmgr = NULL; 00073 } 00074 00075 return FALSE; 00076 } 00077 00078 /*++ 00079 * @name DdHmgDestroy 00080 * @implemented 00081 * 00082 * The function DdHmgDestroy is used internally in dxg.sys 00083 * It destroys all DX kernel objects 00084 * 00085 * @return 00086 * Always returns true, as a failure here would result in a BSOD. 00087 * 00088 * @remarks. 00089 * Only used internally in dxg.sys 00090 *--*/ 00091 BOOL 00092 FASTCALL 00093 DdHmgDestroy(VOID) 00094 { 00095 gcMaxDdHmgr = 0; 00096 gcSizeDdHmgr = 0; 00097 ghFreeDdHmgr = 0; 00098 gpentDdHmgrLast = NULL; 00099 00100 if (gpentDdHmgr) 00101 { 00102 EngFreeMem(gpentDdHmgr); 00103 gpentDdHmgr = NULL; 00104 } 00105 00106 if (ghsemHmgr) 00107 { 00108 EngDeleteSemaphore(ghsemHmgr); 00109 ghsemHmgr = NULL; 00110 } 00111 00112 return TRUE; 00113 } 00114 00115 /*++ 00116 * @name DdHmgLock 00117 * @implemented 00118 * 00119 * The function DdHmgLock is used internally in dxg.sys 00120 * It locks a DX kernel object 00121 * 00122 * @param HANDLE DdHandle 00123 * The handle we want locked 00124 * 00125 * @param UCHAR ObjectType 00126 * The type of the object we expected the handle to contain 00127 * value 0 is for ? 00128 * value 1 is for EDD_DIRECTDRAW_LOCAL 00129 * value 2 is for EDD_SURFACE 00130 * value 3 is for ? 00131 * value 4 is for EDD_VIDEOPORT 00132 * value 5 is for EDD_MOTIONCOMP 00133 00134 * @param BOOLEAN LockOwned 00135 * If it needs to call EngAcquireSemaphore or not 00136 * 00137 * @return 00138 * Returns an EDD_* object, or NULL if it fails 00139 * 00140 * @remarks. 00141 * Only used internally in dxg.sys 00142 *--*/ 00143 PVOID 00144 FASTCALL 00145 DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned) 00146 { 00147 00148 DWORD Index = (DWORD)(DWORD_PTR)DdHandle & 0x1FFFFF; 00149 PDD_ENTRY pEntry = NULL; 00150 PVOID Object = NULL; 00151 00152 if ( !LockOwned ) 00153 { 00154 EngAcquireSemaphore(ghsemHmgr); 00155 } 00156 00157 if ( Index < gcMaxDdHmgr ) 00158 { 00159 pEntry = (PDD_ENTRY)((PBYTE)gpentDdHmgr + (sizeof(DD_ENTRY) * Index)); 00160 if ( VerifyObjectOwner(pEntry) ) 00161 { 00162 /* FIXME 00163 if ( (pEntry->Objt == ObjectType ) && 00164 (pEntry->FullUnique == (((DWORD)DdHandle >> 21) & 0x7FF) ) && 00165 (pEntry->pobj->cExclusiveLock == 0) && 00166 (pEntry->pobj->Tid == PsGetCurrentThread())) 00167 { 00168 InterlockedIncrement(&pEntry->pobj->cExclusiveLock); 00169 pEntry->pobj->Tid = PsGetCurrentThread(); 00170 Object = pEntry->pobj; 00171 } 00172 */ 00173 } 00174 } 00175 00176 if ( !LockOwned ) 00177 { 00178 EngDeleteSemaphore(ghsemHmgr); 00179 } 00180 00181 return Object; 00182 } Generated on Sat May 26 2012 04:37:17 for ReactOS by
1.7.6.1
|