7ba18612ab647d598fc7adaf117fe84ef915e756
[reactos.git] / reactos / win32ss / drivers / videoprt / videoprt.h
1 /*
2 * VideoPort driver
3 *
4 * Copyright (C) 2002, 2003, 2004 ReactOS Team
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22 #ifndef VIDEOPRT_H
23 #define VIDEOPRT_H
24
25 #include <stdio.h>
26
27 #include <ntifs.h>
28 #include <ndk/exfuncs.h>
29 #include <ndk/halfuncs.h>
30 #include <ndk/inbvfuncs.h>
31 #include <ndk/kefuncs.h>
32 #include <ndk/rtlfuncs.h>
33 #include <ndk/obfuncs.h>
34
35 #define __BROKEN__
36 #include <miniport.h>
37 #include <video.h>
38 #include <ntagp.h>
39 #include <dderror.h>
40 #include <windef.h>
41 #include <initguid.h>
42 #include <wdmguid.h>
43
44 #include <debug.h>
45
46 #define TAG_VIDEO_PORT 'PDIV'
47 #define TAG_VIDEO_PORT_BUFFER '\0mpV'
48 #define TAG_REQUEST_PACKET 'qRpV'
49
50 #define GUID_STRING_LENGTH 38 * sizeof(WCHAR)
51
52 typedef struct _VIDEO_PORT_ADDRESS_MAPPING
53 {
54 LIST_ENTRY List;
55 PVOID MappedAddress;
56 ULONG NumberOfUchars;
57 PHYSICAL_ADDRESS IoAddress;
58 ULONG SystemIoBusNumber;
59 UINT MappingCount;
60 } VIDEO_PORT_ADDRESS_MAPPING, *PVIDEO_PORT_ADDRESS_MAPPING;
61
62 struct _VIDEO_PORT_AGP_VIRTUAL_MAPPING;
63
64 typedef struct _VIDEO_PORT_AGP_MAPPING
65 {
66 ULONG NumberOfPages;
67 PVOID MapHandle;
68 PHYSICAL_ADDRESS PhysicalAddress;
69 } VIDEO_PORT_AGP_MAPPING, *PVIDEO_PORT_AGP_MAPPING;
70
71 typedef struct _VIDEO_PORT_AGP_VIRTUAL_MAPPING
72 {
73 PVIDEO_PORT_AGP_MAPPING AgpMapping;
74 HANDLE ProcessHandle;
75 PVOID MappedAddress;
76 } VIDEO_PORT_AGP_VIRTUAL_MAPPING, *PVIDEO_PORT_AGP_VIRTUAL_MAPPING;
77
78 typedef struct _VIDEO_PORT_DRIVER_EXTENSION
79 {
80 VIDEO_HW_INITIALIZATION_DATA InitializationData;
81 PVOID HwContext;
82 UNICODE_STRING RegistryPath;
83 } VIDEO_PORT_DRIVER_EXTENSION, *PVIDEO_PORT_DRIVER_EXTENSION;
84
85 typedef struct _VIDEO_PORT_COMMON_EXTENSION
86 {
87 BOOLEAN Fdo;
88 } VIDEO_PORT_COMMON_EXTENSION, *PVIDEO_PORT_COMMON_EXTENSION;
89
90 typedef struct _VIDEO_PORT_DEVICE_EXTENSTION
91 {
92 VIDEO_PORT_COMMON_EXTENSION Common;
93 ULONG DeviceNumber;
94 PDRIVER_OBJECT DriverObject;
95 PDEVICE_OBJECT PhysicalDeviceObject;
96 PDEVICE_OBJECT FunctionalDeviceObject;
97 PDEVICE_OBJECT NextDeviceObject;
98 UNICODE_STRING RegistryPath;
99 UNICODE_STRING NewRegistryPath;
100 PKINTERRUPT InterruptObject;
101 KSPIN_LOCK InterruptSpinLock;
102 PCM_RESOURCE_LIST AllocatedResources;
103 ULONG InterruptVector;
104 ULONG InterruptLevel;
105 BOOLEAN InterruptShared;
106 INTERFACE_TYPE AdapterInterfaceType;
107 ULONG SystemIoBusNumber;
108 ULONG SystemIoSlotNumber;
109 LIST_ENTRY AddressMappingListHead;
110 KDPC DpcObject;
111 VIDEO_PORT_DRIVER_EXTENSION *DriverExtension;
112 ULONG DeviceOpened;
113 AGP_BUS_INTERFACE_STANDARD AgpInterface;
114 KMUTEX DeviceLock;
115 LIST_ENTRY DmaAdapterList, ChildDeviceList;
116 CHAR MiniPortDeviceExtension[1];
117 } VIDEO_PORT_DEVICE_EXTENSION, *PVIDEO_PORT_DEVICE_EXTENSION;
118
119 typedef struct _VIDEO_PORT_CHILD_EXTENSION
120 {
121 VIDEO_PORT_COMMON_EXTENSION Common;
122
123 ULONG ChildId;
124 VIDEO_CHILD_TYPE ChildType;
125 UCHAR ChildDescriptor[256];
126
127 BOOLEAN EdidValid;
128
129 PDRIVER_OBJECT DriverObject;
130 PDEVICE_OBJECT PhysicalDeviceObject;
131
132 LIST_ENTRY ListEntry;
133
134 CHAR ChildDeviceExtension[1];
135 } VIDEO_PORT_CHILD_EXTENSION, *PVIDEO_PORT_CHILD_EXTENSION;
136
137 #define VIDEO_PORT_GET_CHILD_EXTENSION(MiniportExtension) \
138 CONTAINING_RECORD( \
139 MiniportExtension, \
140 VIDEO_PORT_CHILD_EXTENSION, \
141 ChildDeviceExtension)
142
143 #define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension) \
144 CONTAINING_RECORD( \
145 MiniportExtension, \
146 VIDEO_PORT_DEVICE_EXTENSION, \
147 MiniPortDeviceExtension)
148
149 typedef struct _VIDEO_PORT_EVENT
150 {
151 ENG_EVENT;
152 } VIDEO_PORT_EVENT, *PVIDEO_PORT_EVENT;
153
154 /* agp.c */
155
156 NTSTATUS
157 IopInitiatePnpIrp(
158 PDEVICE_OBJECT DeviceObject,
159 PIO_STATUS_BLOCK IoStatusBlock,
160 UCHAR MinorFunction,
161 PIO_STACK_LOCATION Stack OPTIONAL);
162
163 NTSTATUS NTAPI
164 IntAgpGetInterface(
165 IN PVOID HwDeviceExtension,
166 IN OUT PINTERFACE Interface);
167
168 /* child.c */
169
170 NTSTATUS NTAPI
171 IntVideoPortDispatchPdoPnp(
172 IN PDEVICE_OBJECT DeviceObject,
173 IN PIRP Irp);
174
175 /* dispatch.c */
176
177 NTSTATUS NTAPI
178 IntVideoPortAddDevice(
179 IN PDRIVER_OBJECT DriverObject,
180 IN PDEVICE_OBJECT PhysicalDeviceObject);
181
182 NTSTATUS NTAPI
183 IntVideoPortDispatchOpen(
184 IN PDEVICE_OBJECT DeviceObject,
185 IN PIRP Irp);
186
187 NTSTATUS NTAPI
188 IntVideoPortDispatchClose(
189 IN PDEVICE_OBJECT DeviceObject,
190 IN PIRP Irp);
191
192 NTSTATUS NTAPI
193 IntVideoPortDispatchCleanup(
194 IN PDEVICE_OBJECT DeviceObject,
195 IN PIRP Irp);
196
197 NTSTATUS NTAPI
198 IntVideoPortDispatchDeviceControl(
199 IN PDEVICE_OBJECT DeviceObject,
200 IN PIRP Irp);
201
202 NTSTATUS NTAPI
203 IntVideoPortDispatchPnp(
204 IN PDEVICE_OBJECT DeviceObject,
205 IN PIRP Irp);
206
207 NTSTATUS NTAPI
208 IntVideoPortDispatchPower(
209 IN PDEVICE_OBJECT DeviceObject,
210 IN PIRP Irp);
211
212 NTSTATUS NTAPI
213 IntVideoPortDispatchSystemControl(
214 IN PDEVICE_OBJECT DeviceObject,
215 IN PIRP Irp);
216
217 NTSTATUS NTAPI
218 IntVideoPortDispatchWrite(
219 IN PDEVICE_OBJECT DeviceObject,
220 IN PIRP Irp);
221
222 VOID NTAPI
223 IntVideoPortUnload(PDRIVER_OBJECT DriverObject);
224
225 /* timer.c */
226
227 BOOLEAN NTAPI
228 IntVideoPortSetupTimer(
229 IN PDEVICE_OBJECT DeviceObject,
230 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension);
231
232 /* interrupt.c */
233
234 BOOLEAN NTAPI
235 IntVideoPortSetupInterrupt(
236 IN PDEVICE_OBJECT DeviceObject,
237 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
238 IN PVIDEO_PORT_CONFIG_INFO ConfigInfo);
239
240 /* resource.c */
241
242 NTSTATUS NTAPI
243 IntVideoPortFilterResourceRequirements(
244 IN PDEVICE_OBJECT DeviceObject,
245 IN PIRP Irp);
246
247 NTSTATUS NTAPI
248 IntVideoPortMapPhysicalMemory(
249 IN HANDLE Process,
250 IN PHYSICAL_ADDRESS PhysicalAddress,
251 IN ULONG SizeInBytes,
252 IN ULONG Protect,
253 IN OUT PVOID *VirtualAddress OPTIONAL);
254
255 /* videoprt.c */
256
257 extern ULONG CsrssInitialized;
258 extern PKPROCESS Csrss;
259 extern ULONG VideoPortDeviceNumber;
260
261 VOID FASTCALL
262 IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState);
263
264 VOID FASTCALL
265 IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState);
266
267 NTSTATUS NTAPI
268 IntVideoPortCreateAdapterDeviceObject(
269 IN PDRIVER_OBJECT DriverObject,
270 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
271 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
272 OUT PDEVICE_OBJECT *DeviceObject OPTIONAL);
273
274 NTSTATUS NTAPI
275 IntVideoPortFindAdapter(
276 IN PDRIVER_OBJECT DriverObject,
277 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
278 IN PDEVICE_OBJECT DeviceObject);
279
280 PVOID NTAPI
281 IntVideoPortGetProcAddress(
282 IN PVOID HwDeviceExtension,
283 IN PUCHAR FunctionName);
284
285 /* int10.c */
286
287 NTSTATUS
288 NTAPI
289 IntInitializeVideoAddressSpace(VOID);
290
291 VP_STATUS NTAPI
292 IntInt10AllocateBuffer(
293 IN PVOID Context,
294 OUT PUSHORT Seg,
295 OUT PUSHORT Off,
296 IN OUT PULONG Length);
297
298 VP_STATUS NTAPI
299 IntInt10FreeBuffer(
300 IN PVOID Context,
301 IN USHORT Seg,
302 IN USHORT Off);
303
304 VP_STATUS NTAPI
305 IntInt10ReadMemory(
306 IN PVOID Context,
307 IN USHORT Seg,
308 IN USHORT Off,
309 OUT PVOID Buffer,
310 IN ULONG Length);
311
312 VP_STATUS NTAPI
313 IntInt10WriteMemory(
314 IN PVOID Context,
315 IN USHORT Seg,
316 IN USHORT Off,
317 IN PVOID Buffer,
318 IN ULONG Length);
319
320 VP_STATUS NTAPI
321 IntInt10CallBios(
322 IN PVOID Context,
323 IN OUT PINT10_BIOS_ARGUMENTS BiosArguments);
324
325 /* registry.c */
326
327 NTSTATUS
328 NTAPI
329 IntCopyRegistryKey(
330 _In_ HANDLE SourceKeyHandle,
331 _In_ HANDLE DestKeyHandle);
332
333 NTSTATUS
334 NTAPI
335 IntCopyRegistryValue(
336 HANDLE SourceKeyHandle,
337 HANDLE DestKeyHandle,
338 PWSTR ValueName);
339
340 NTSTATUS
341 NTAPI
342 IntSetupDeviceSettingsKey(
343 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension);
344
345 NTSTATUS
346 NTAPI
347 IntCreateNewRegistryPath(
348 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension);
349
350 NTSTATUS
351 NTAPI
352 IntCreateRegistryPath(
353 IN PCUNICODE_STRING DriverRegistryPath,
354 OUT PUNICODE_STRING DeviceRegistryPath);
355
356
357 #endif /* VIDEOPRT_H */