- Implement ProtocolResetComplete
[reactos.git] / drivers / directx / dxg / main.c
1
2 /*
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * PURPOSE: Native driver for dxg implementation
6 * FILE: drivers/directx/dxg/main.c
7 * PROGRAMER: Magnus olsen (magnus@greatlord.com)
8 * REVISION HISTORY:
9 * 15/10-2007 Magnus Olsen
10 */
11
12
13 #include <dxg_int.h>
14 #include "dxg_driver.h"
15
16 LONG gcDummyPageRefCnt = 0;
17 HSEMAPHORE ghsemDummyPage = NULL;
18 VOID *gpDummyPage = NULL;
19 PEPROCESS gpepSession = NULL;
20 PLARGE_INTEGER gpLockShortDelay = NULL;
21
22
23 PDRVFN gpEngFuncs;
24 const ULONG gcDxgFuncs = DXG_INDEX_DxDdIoctl + 1;
25
26
27
28 NTSTATUS
29 DriverEntry(IN PVOID Context1,
30 IN PVOID Context2)
31 {
32 return 0;
33 }
34
35 NTSTATUS
36 APIENTRY
37 DxDdStartupDxGraphics (ULONG SizeEngDrv,
38 PDRVENABLEDATA pDxEngDrv,
39 ULONG SizeDxgDrv,
40 PDRVENABLEDATA pDxgDrv,
41 PULONG DirectDrawContext,
42 PEPROCESS Proc )
43 {
44
45 PDRVFN drv_func;
46 INT i;
47
48 /* Test see if the data is vaild we got from win32k.sys */
49 if ((SizeEngDrv != sizeof(DRVENABLEDATA)) ||
50 (SizeDxgDrv != sizeof(DRVENABLEDATA)))
51 {
52 return STATUS_BUFFER_TOO_SMALL;
53 }
54
55 /* rest static value */
56 gpDummyPage = NULL;
57 gcDummyPageRefCnt = 0;
58 ghsemDummyPage = NULL;
59
60 /*
61 * Setup internal driver functions list we got from dxg driver functions list
62 */
63 pDxgDrv->iDriverVersion = 0x80000; /* Note 12/1-2004 : DirectX 8 ? */
64 pDxgDrv->c = gcDxgFuncs;
65 pDxgDrv->pdrvfn = gaDxgFuncs;
66
67 /* check how many driver functions and fail if the value does not match */
68 if (pDxEngDrv->c != DXENG_INDEX_DxEngLoadImage + 1)
69 {
70 return STATUS_INTERNAL_ERROR;
71 }
72
73 /*
74 * Check if all drv functions are sorted right
75 * and if it really are exported
76 */
77
78 for (i=1 ; i < DXENG_INDEX_DxEngLoadImage + 1; i++)
79 {
80 drv_func = &pDxEngDrv->pdrvfn[i];
81
82 if ((drv_func->iFunc != i) ||
83 (drv_func->pfn == NULL))
84 {
85 return STATUS_INTERNAL_ERROR;
86 }
87 }
88
89 gpEngFuncs = pDxEngDrv->pdrvfn;
90
91 /* Note 12/1-2004 : Why is this set to 0x618 */
92 *DirectDrawContext = 0x618;
93
94 if (DdHmgCreate())
95 {
96 ghsemDummyPage = EngCreateSemaphore();
97
98 if (ghsemDummyPage)
99 {
100 gpepSession = Proc;
101 return STATUS_SUCCESS;
102 }
103 }
104
105 DdHmgDestroy();
106
107 if (ghsemDummyPage)
108 {
109 EngDeleteSemaphore(ghsemDummyPage);
110 ghsemDummyPage = 0;
111 }
112
113 return STATUS_NO_MEMORY;
114 }
115
116
117
118
119 NTSTATUS
120 DxDdCleanupDxGraphics()
121 {
122 DdHmgDestroy();
123
124 if (ghsemDummyPage != 0 )
125 {
126 if (gpDummyPage != 0 )
127 {
128 ExFreePoolWithTag(gpDummyPage,0);
129 gpDummyPage = NULL;
130 gcDummyPageRefCnt = 0;
131 }
132 EngDeleteSemaphore(ghsemDummyPage);
133 ghsemDummyPage = 0;
134 }
135
136 return 0;
137 }
138
139
140
141
142
143
144
145