2007-10-21 23:38:13 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PURPOSE: Native driver for dxg implementation
|
2015-11-10 17:41:55 +00:00
|
|
|
* FILE: win32ss/reactx/dxg/main.c
|
2007-10-21 23:38:13 +00:00
|
|
|
* PROGRAMER: Magnus olsen (magnus@greatlord.com)
|
|
|
|
* REVISION HISTORY:
|
|
|
|
* 15/10-2007 Magnus Olsen
|
|
|
|
*/
|
|
|
|
|
2007-10-22 16:26:59 +00:00
|
|
|
#include <dxg_int.h>
|
2007-10-23 19:06:11 +00:00
|
|
|
#include "dxg_driver.h"
|
2007-10-22 21:15:10 +00:00
|
|
|
|
|
|
|
LONG gcDummyPageRefCnt = 0;
|
|
|
|
HSEMAPHORE ghsemDummyPage = NULL;
|
|
|
|
VOID *gpDummyPage = NULL;
|
|
|
|
PEPROCESS gpepSession = NULL;
|
2007-10-24 11:05:44 +00:00
|
|
|
PLARGE_INTEGER gpLockShortDelay = NULL;
|
|
|
|
|
2017-03-14 19:45:23 +00:00
|
|
|
DXENG_FUNCTIONS gpEngFuncs;
|
|
|
|
|
2007-10-22 21:15:10 +00:00
|
|
|
const ULONG gcDxgFuncs = DXG_INDEX_DxDdIoctl + 1;
|
2007-10-22 19:42:53 +00:00
|
|
|
|
|
|
|
|
2008-08-09 09:25:21 +00:00
|
|
|
NTSTATUS NTAPI
|
2007-10-22 16:26:59 +00:00
|
|
|
DriverEntry(IN PVOID Context1,
|
|
|
|
IN PVOID Context2)
|
2007-10-21 23:38:13 +00:00
|
|
|
{
|
2007-10-22 16:26:59 +00:00
|
|
|
return 0;
|
2007-10-21 23:38:13 +00:00
|
|
|
}
|
|
|
|
|
2007-10-22 16:26:59 +00:00
|
|
|
NTSTATUS
|
|
|
|
APIENTRY
|
|
|
|
DxDdStartupDxGraphics (ULONG SizeEngDrv,
|
|
|
|
PDRVENABLEDATA pDxEngDrv,
|
|
|
|
ULONG SizeDxgDrv,
|
|
|
|
PDRVENABLEDATA pDxgDrv,
|
|
|
|
PULONG DirectDrawContext,
|
|
|
|
PEPROCESS Proc )
|
|
|
|
{
|
2007-10-22 19:42:53 +00:00
|
|
|
|
2007-10-22 16:26:59 +00:00
|
|
|
PDRVFN drv_func;
|
2019-01-06 22:41:52 +00:00
|
|
|
PFN *peng_funcs;
|
2008-12-07 21:52:22 +00:00
|
|
|
UINT i;
|
2007-10-22 16:26:59 +00:00
|
|
|
|
|
|
|
/* Test see if the data is vaild we got from win32k.sys */
|
2007-10-22 19:42:53 +00:00
|
|
|
if ((SizeEngDrv != sizeof(DRVENABLEDATA)) ||
|
|
|
|
(SizeDxgDrv != sizeof(DRVENABLEDATA)))
|
2007-10-22 16:26:59 +00:00
|
|
|
{
|
|
|
|
return STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* rest static value */
|
2007-10-22 21:15:10 +00:00
|
|
|
gpDummyPage = NULL;
|
2007-10-22 16:26:59 +00:00
|
|
|
gcDummyPageRefCnt = 0;
|
2007-10-22 21:15:10 +00:00
|
|
|
ghsemDummyPage = NULL;
|
2007-10-22 16:26:59 +00:00
|
|
|
|
2007-12-28 20:32:30 +00:00
|
|
|
/*
|
2007-10-22 16:26:59 +00:00
|
|
|
* Setup internal driver functions list we got from dxg driver functions list
|
|
|
|
*/
|
|
|
|
pDxgDrv->iDriverVersion = 0x80000; /* Note 12/1-2004 : DirectX 8 ? */
|
|
|
|
pDxgDrv->c = gcDxgFuncs;
|
|
|
|
pDxgDrv->pdrvfn = gaDxgFuncs;
|
|
|
|
|
|
|
|
/* check how many driver functions and fail if the value does not match */
|
|
|
|
if (pDxEngDrv->c != DXENG_INDEX_DxEngLoadImage + 1)
|
|
|
|
{
|
|
|
|
return STATUS_INTERNAL_ERROR;
|
|
|
|
}
|
2007-10-22 21:15:10 +00:00
|
|
|
|
2007-10-22 16:26:59 +00:00
|
|
|
/*
|
2007-12-28 20:32:30 +00:00
|
|
|
* Check if all drv functions are sorted right
|
|
|
|
* and if it really are exported
|
2007-10-22 16:26:59 +00:00
|
|
|
*/
|
|
|
|
|
2019-01-06 22:41:52 +00:00
|
|
|
peng_funcs = (PFN*)&gpEngFuncs;
|
2017-03-14 19:45:23 +00:00
|
|
|
|
2019-01-06 22:41:52 +00:00
|
|
|
for (i = 1; i < DXENG_INDEX_DxEngLoadImage + 1; i++)
|
2007-10-22 16:26:59 +00:00
|
|
|
{
|
2007-10-22 21:15:10 +00:00
|
|
|
drv_func = &pDxEngDrv->pdrvfn[i];
|
2007-10-22 16:26:59 +00:00
|
|
|
|
|
|
|
if ((drv_func->iFunc != i) ||
|
Merge from branch ReactX to Trunk,
Please make a clean build after this update
Add dxg.sys driver
----------------------------------------------------------------
This driver contains all DirectX graphic APIs called by win32k. Most of them
are stubbed, and the following APIs are implemented:
DxDxgGenericThunk, DxDdIoctl, DriverEntry, DxDdStartupDxGraphics, DxDdCleanupDxGraphics
Add dxgthk.sys driver, which is 100% finished
---------------------------------------------------------
The following APIs are implemented (almost all are forwarders):
DriverEntry, EngAcquireSemaphore, EngAllocMem, EngAllocUserMem,
EngCopyBits, EngCreateBitmap, EngCreatePalette, EngCreateSemaphore,
EngDeletePalette, EngDeleteSemaphore, EngDeleteSurface,
EngFindImageProcAddress, EngFreeMem, EngFreeUserMem,
EngLoadImage, EngLockSurface, EngReleaseSemaphore,
EngSetLastError, EngUnloadImage, EngUnlockSurface
Add dxapi.sys driver
--------------------------------------------------------------
Most of the APIs used by the graphic card's driver or win32k are stubs.
The following APIs are implemented:
DriverEntry, GsDriverEntry, DxApiGetVersion, DxApi.
All APIs which DxApi wraps are stubs.
Changes in win32k
-------------------------------------------------------------------
Move _DC struct to include\reactos\win32k\ntgdihdl.h
--------------------------------------------------------------------------
Implement NtGdiDdCanCreateD3DBuffer, NtGdiD3dContextDestroy,
NtGdiD3dContextDestroyAll, NtGdiDdCreateD3DBuffer, NtGdiDdDestroyD3DBuffer,
NtGdiD3dDrawPrimitives2, NtGdiDdLockD3D, NtGdiD3dValidateTextureStageState,
NtGdiDdUnlockD3D, NtGdiDdCreateSurface, NtGdiDdWaitForVerticalBlank,
NtGdiDdCanCreateSurface, NtGdiDdGetScanLine, NtGdiDdCreateSurfaceEx,
DxDdStartupDxGraphics, NtGdiDdCreateDirectDrawObject, NtGdiDxgGenericThunk,
NtGdiDdGetDriverState, NtGdiDdColorControl, NtGdiDdCreateSurfaceObject,
NtGdiDdCreateSurfaceObject, NtGdiDdDeleteDirectDrawObject, NtGdiDdDeleteSurfaceObject,
NtGdiDdQueryDirectDrawObject, NtGdiDdReenableDirectDrawObject, NtGdiDdGetDriverInfo,
NtGdiDdGetAvailDriverMemory, NtGdiDdSetExclusiveMode, NtGdiDdFlipToGDISurface,
NtGdiDdGetDC, NtGdiDdGetDxHandle, NtGdiDdReleaseDC, NtGdiDdResetVisrgn,
NtGdiDdSetGammaRamp, NtGdiDdDestroySurface, NtGdiDdFlip, NtGdiDdLock, NtGdiDdUnlock,
NtGdiDdBlt, NtGdiDdSetColorKey, NtGdiDdAddAttachedSurface, NtGdiDdGetBltStatus,
NtGdiDdGetFlipStatus, NtGdiDdUpdateOverlay, NtGdiDdSetOverlayPosition,
NtGdiDdAlphaBlt, NtGdiDdAttachSurface, NtGdiDdUnattachSurface,
NtGdiDvpCanCreateVideoPort, NtGdiDvpColorControl, NtGdiDvpCreateVideoPort,
NtGdiDvpDestroyVideoPort, NtGdiDvpFlipVideoPort, NtGdiDvpGetVideoPortBandwidth,
NtGdiDvpGetVideoPortFlipStatus, NtGdiDvpGetVideoPortInputFormats,
NtGdiDvpGetVideoPortLine, NtGdiDvpGetVideoPortOutputFormats,
NtGdiDvpGetVideoPortConnectInfo, NtGdiDvpGetVideoSignalStatus,
NtGdiDvpUpdateVideoPort, NtGdiDvpWaitForVideoPortSync,
NtGdiDvpAcquireNotification, NtGdiDvpReleaseNotification,
NtGdiDvpGetVideoPortField, NtGdiDdBeginMoCompFrame,
NtGdiDdCreateMoComp, NtGdiDdDestroyMoComp,
NtGdiDdEndMoCompFrame, NtGdiDdGetInternalMoCompInfo,
NtGdiDdGetMoCompBuffInfo, NtGdiDdGetMoCompFormats,
NtGdiDdGetMoCompGuids, NtGdiDdQueryMoCompStatus,
NtGdiDdRenderMoComp, HeapVidMemAllocAligned,
VidMemFree, EngAllocPrivateUserMem, EngFreePrivateUserMem,
EngLockDirectDrawSurface, EngUnlockDirectDrawSurface
But all those functions are stubbed in dxg.sys
----------------------------------------------------------------------------
Implemented APIsL
DxEngLockDC, DxEngUnlockDC, DxEngGetDCState, EngDxIoctl
----------------------------------------------------------------------------
Stubbed APIs:
DxEngNUIsTermSrv, DxEngRedrawDesktop, DxEngDispUniq, DxEngVisRgnUniq,
DxEngEnumerateHdev, DxEngGetDeviceGammaRamp, DxEngCreateMemoryDC,
DxEngScreenAccessCheck, DxEngLockShareSem, DxEngUnlockShareSem,
DxEngLockHdev, DxEngUnlockHdev, DxEngReferenceHdev,
DxEngIsHdevLockedByCurrentThread, DxEngUnreferenceHdev,
DxEngSetDeviceGammaRamp, DxEngSpTearDownSprites,
DxEngSpUnTearDownSprites, DxEngSpSpritesVisible,
DxEngGetHdevData, DxEngSetHdevData, DxEngGetDesktopDC,
DxEngDeleteDC, DxEngCleanDC, DxEngSetDCOwner,
DxEngSetDCState, DxEngSelectBitmap,DxEngSetBitmapOwner,
DxEngDeleteSurface, DxEngGetSurfaceData, DxEngAltLockSurface,
DxEngUploadPaletteEntryToSurface, DxEngMarkSurfaceAsDirectDraw,
DxEngSelectPaletteToSurface, DxEngSyncPaletteTableWithDevice,
DxEngSetPaletteState, DxEngGetRedirectionBitmap, DxEngLoadImage,
DxEngIncDispUniq
----------------------------------------------------------------------------
Remember we need the DxEng APIs implemented and HeapVidMemAllocAligned,
VidMemFree, EngAllocPrivateUserMem, EngFreePrivateUserMem,
EngLockDirectDrawSurface, EngUnlockDirectDrawSurface implemented
before it's possible to have full DirectX support at kmode.
svn path=/trunk/; revision=30328
2007-11-10 15:31:49 +00:00
|
|
|
(drv_func->pfn == NULL))
|
2007-10-22 16:26:59 +00:00
|
|
|
{
|
|
|
|
return STATUS_INTERNAL_ERROR;
|
|
|
|
}
|
2019-01-06 22:41:52 +00:00
|
|
|
|
|
|
|
peng_funcs[i] = drv_func->pfn;
|
2007-10-22 16:26:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Note 12/1-2004 : Why is this set to 0x618 */
|
|
|
|
*DirectDrawContext = 0x618;
|
|
|
|
|
|
|
|
if (DdHmgCreate())
|
|
|
|
{
|
|
|
|
ghsemDummyPage = EngCreateSemaphore();
|
|
|
|
|
|
|
|
if (ghsemDummyPage)
|
|
|
|
{
|
|
|
|
gpepSession = Proc;
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DdHmgDestroy();
|
|
|
|
|
|
|
|
if (ghsemDummyPage)
|
|
|
|
{
|
|
|
|
EngDeleteSemaphore(ghsemDummyPage);
|
|
|
|
ghsemDummyPage = 0;
|
|
|
|
}
|
2007-10-22 21:15:10 +00:00
|
|
|
|
2007-10-22 16:26:59 +00:00
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
2007-10-21 23:38:13 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
2008-08-09 09:25:21 +00:00
|
|
|
APIENTRY
|
2009-08-24 20:10:03 +00:00
|
|
|
DxDdCleanupDxGraphics(VOID)
|
2007-10-21 23:38:13 +00:00
|
|
|
{
|
2007-10-22 16:26:59 +00:00
|
|
|
DdHmgDestroy();
|
|
|
|
|
2007-12-28 20:32:30 +00:00
|
|
|
if (ghsemDummyPage != 0 )
|
2007-10-22 16:26:59 +00:00
|
|
|
{
|
2007-12-28 20:32:30 +00:00
|
|
|
if (gpDummyPage != 0 )
|
2007-10-22 16:26:59 +00:00
|
|
|
{
|
|
|
|
ExFreePoolWithTag(gpDummyPage,0);
|
2007-10-22 21:15:10 +00:00
|
|
|
gpDummyPage = NULL;
|
2007-10-22 16:26:59 +00:00
|
|
|
gcDummyPageRefCnt = 0;
|
|
|
|
}
|
2007-10-22 21:15:10 +00:00
|
|
|
EngDeleteSemaphore(ghsemDummyPage);
|
2007-12-28 20:32:30 +00:00
|
|
|
ghsemDummyPage = 0;
|
2007-10-22 16:26:59 +00:00
|
|
|
}
|
2007-10-22 21:15:10 +00:00
|
|
|
|
2007-10-21 23:38:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|