2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Native driver for dxg implementation
5 * FILE: drivers/directx/dxg/main.c
6 * PROGRAMER: Magnus olsen (magnus@greatlord.com)
8 * 15/10-2007 Magnus Olsen
12 #include "dxg_driver.h"
14 LONG gcDummyPageRefCnt
= 0;
15 HSEMAPHORE ghsemDummyPage
= NULL
;
16 VOID
*gpDummyPage
= NULL
;
17 PEPROCESS gpepSession
= NULL
;
18 PLARGE_INTEGER gpLockShortDelay
= NULL
;
21 const ULONG gcDxgFuncs
= DXG_INDEX_DxDdIoctl
+ 1;
25 DriverEntry(IN PVOID Context1
,
33 DxDdStartupDxGraphics (ULONG SizeEngDrv
,
34 PDRVENABLEDATA pDxEngDrv
,
36 PDRVENABLEDATA pDxgDrv
,
37 PULONG DirectDrawContext
,
44 /* Test see if the data is vaild we got from win32k.sys */
45 if ((SizeEngDrv
!= sizeof(DRVENABLEDATA
)) ||
46 (SizeDxgDrv
!= sizeof(DRVENABLEDATA
)))
48 return STATUS_BUFFER_TOO_SMALL
;
51 /* rest static value */
53 gcDummyPageRefCnt
= 0;
54 ghsemDummyPage
= NULL
;
57 * Setup internal driver functions list we got from dxg driver functions list
59 pDxgDrv
->iDriverVersion
= 0x80000; /* Note 12/1-2004 : DirectX 8 ? */
60 pDxgDrv
->c
= gcDxgFuncs
;
61 pDxgDrv
->pdrvfn
= gaDxgFuncs
;
63 /* check how many driver functions and fail if the value does not match */
64 if (pDxEngDrv
->c
!= DXENG_INDEX_DxEngLoadImage
+ 1)
66 return STATUS_INTERNAL_ERROR
;
70 * Check if all drv functions are sorted right
71 * and if it really are exported
74 for (i
=1 ; i
< DXENG_INDEX_DxEngLoadImage
+ 1; i
++)
76 drv_func
= &pDxEngDrv
->pdrvfn
[i
];
78 if ((drv_func
->iFunc
!= i
) ||
79 (drv_func
->pfn
== NULL
))
81 return STATUS_INTERNAL_ERROR
;
85 gpEngFuncs
= pDxEngDrv
->pdrvfn
;
87 /* Note 12/1-2004 : Why is this set to 0x618 */
88 *DirectDrawContext
= 0x618;
92 ghsemDummyPage
= EngCreateSemaphore();
97 return STATUS_SUCCESS
;
105 EngDeleteSemaphore(ghsemDummyPage
);
109 return STATUS_NO_MEMORY
;
114 DxDdCleanupDxGraphics(VOID
)
118 if (ghsemDummyPage
!= 0 )
120 if (gpDummyPage
!= 0 )
122 ExFreePoolWithTag(gpDummyPage
,0);
124 gcDummyPageRefCnt
= 0;
126 EngDeleteSemaphore(ghsemDummyPage
);