2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Native driver for dxg implementation
5 * FILE: win32ss/reactx/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
;
20 DXENG_FUNCTIONS gpEngFuncs
;
22 const ULONG gcDxgFuncs
= DXG_INDEX_DxDdIoctl
+ 1;
26 DriverEntry(IN PVOID Context1
,
34 DxDdStartupDxGraphics (ULONG SizeEngDrv
,
35 PDRVENABLEDATA pDxEngDrv
,
37 PDRVENABLEDATA pDxgDrv
,
38 PULONG DirectDrawContext
,
48 /* Test see if the data is vaild we got from win32k.sys */
49 if ((SizeEngDrv
!= sizeof(DRVENABLEDATA
)) ||
50 (SizeDxgDrv
!= sizeof(DRVENABLEDATA
)))
52 return STATUS_BUFFER_TOO_SMALL
;
55 /* rest static value */
57 gcDummyPageRefCnt
= 0;
58 ghsemDummyPage
= NULL
;
61 * Setup internal driver functions list we got from dxg driver functions list
63 pDxgDrv
->iDriverVersion
= 0x80000; /* Note 12/1-2004 : DirectX 8 ? */
64 pDxgDrv
->c
= gcDxgFuncs
;
65 pDxgDrv
->pdrvfn
= gaDxgFuncs
;
67 /* check how many driver functions and fail if the value does not match */
68 if (pDxEngDrv
->c
!= DXENG_INDEX_DxEngLoadImage
+ 1)
70 return STATUS_INTERNAL_ERROR
;
74 * Check if all drv functions are sorted right
75 * and if it really are exported
78 peng_funcs
= (ULONG
)&gpEngFuncs
;
80 for (i
=1 ; i
< DXENG_INDEX_DxEngLoadImage
+ 1; i
++)
82 drv_func
= &pDxEngDrv
->pdrvfn
[i
];
84 if ((drv_func
->iFunc
!= i
) ||
85 (drv_func
->pfn
== NULL
))
87 return STATUS_INTERNAL_ERROR
;
89 peng_func
= (PULONG
)(peng_funcs
+(i
* sizeof(ULONG
)));
90 *peng_func
= (ULONG
)drv_func
->pfn
;
93 /* Note 12/1-2004 : Why is this set to 0x618 */
94 *DirectDrawContext
= 0x618;
98 ghsemDummyPage
= EngCreateSemaphore();
103 return STATUS_SUCCESS
;
111 EngDeleteSemaphore(ghsemDummyPage
);
115 return STATUS_NO_MEMORY
;
120 DxDdCleanupDxGraphics(VOID
)
124 if (ghsemDummyPage
!= 0 )
126 if (gpDummyPage
!= 0 )
128 ExFreePoolWithTag(gpDummyPage
,0);
130 gcDummyPageRefCnt
= 0;
132 EngDeleteSemaphore(ghsemDummyPage
);