1754d1fd024b859b250700f3e322c4cab293f86a
[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
34 #define __BROKEN__
35 #include <miniport.h>
36 #include <video.h>
37 #include <ntagp.h>
38 #include <dderror.h>
39 #include <windef.h>
40 #include <initguid.h>
41 #include <wdmguid.h>
42
43 #include <debug.h>
44
45 #define TAG_VIDEO_PORT 'PDIV'
46 #define TAG_VIDEO_PORT_BUFFER '\0mpV'
47 #define TAG_REQUEST_PACKET 'qRpV'
48
49 typedef struct _VIDEO_PORT_ADDRESS_MAPPING
50 {
51 LIST_ENTRY List;
52 PVOID MappedAddress;
53 ULONG NumberOfUchars;
54 PHYSICAL_ADDRESS IoAddress;
55 ULONG SystemIoBusNumber;
56 UINT MappingCount;
57 } VIDEO_PORT_ADDRESS_MAPPING, *PVIDEO_PORT_ADDRESS_MAPPING;
58
59 struct _VIDEO_PORT_AGP_VIRTUAL_MAPPING;
60
61 typedef struct _VIDEO_PORT_AGP_MAPPING
62 {
63 ULONG NumberOfPages;
64 PVOID MapHandle;
65 PHYSICAL_ADDRESS PhysicalAddress;
66 } VIDEO_PORT_AGP_MAPPING, *PVIDEO_PORT_AGP_MAPPING;
67
68 typedef struct _VIDEO_PORT_AGP_VIRTUAL_MAPPING
69 {
70 PVIDEO_PORT_AGP_MAPPING AgpMapping;
71 HANDLE ProcessHandle;
72 PVOID MappedAddress;
73 } VIDEO_PORT_AGP_VIRTUAL_MAPPING, *PVIDEO_PORT_AGP_VIRTUAL_MAPPING;
74
75 typedef struct _VIDEO_PORT_DRIVER_EXTENSION
76 {
77 VIDEO_HW_INITIALIZATION_DATA InitializationData;
78 PVOID HwContext;
79 UNICODE_STRING RegistryPath;
80 } VIDEO_PORT_DRIVER_EXTENSION, *PVIDEO_PORT_DRIVER_EXTENSION;
81
82 typedef struct _VIDEO_PORT_COMMON_EXTENSION
83 {
84 BOOLEAN Fdo;
85 } VIDEO_PORT_COMMON_EXTENSION, *PVIDEO_PORT_COMMON_EXTENSION;
86
87 typedef struct _VIDEO_PORT_DEVICE_EXTENSTION
88 {
89 VIDEO_PORT_COMMON_EXTENSION Common;
90 ULONG DeviceNumber;
91 PDRIVER_OBJECT DriverObject;
92 PDEVICE_OBJECT PhysicalDeviceObject;
93 PDEVICE_OBJECT FunctionalDeviceObject;
94 PDEVICE_OBJECT NextDeviceObject;
95 UNICODE_STRING RegistryPath;
96 PKINTERRUPT InterruptObject;
97 KSPIN_LOCK InterruptSpinLock;
98 PCM_RESOURCE_LIST AllocatedResources;
99 ULONG InterruptVector;
100 ULONG InterruptLevel;
101 BOOLEAN InterruptShared;
102 INTERFACE_TYPE AdapterInterfaceType;
103 ULONG SystemIoBusNumber;
104 ULONG SystemIoSlotNumber;
105 LIST_ENTRY AddressMappingListHead;
106 KDPC DpcObject;
107 VIDEO_PORT_DRIVER_EXTENSION *DriverExtension;
108 ULONG DeviceOpened;
109 AGP_BUS_INTERFACE_STANDARD AgpInterface;
110 KMUTEX DeviceLock;
111 LIST_ENTRY DmaAdapterList, ChildDeviceList;
112 CHAR MiniPortDeviceExtension[1];
113 } VIDEO_PORT_DEVICE_EXTENSION, *PVIDEO_PORT_DEVICE_EXTENSION;
114
115 typedef struct _VIDEO_PORT_CHILD_EXTENSION
116 {
117 VIDEO_PORT_COMMON_EXTENSION Common;
118
119 ULONG ChildId;
120 VIDEO_CHILD_TYPE ChildType;
121 UCHAR ChildDescriptor[256];
122
123 BOOLEAN EdidValid;
124
125 PDRIVER_OBJECT DriverObject;
126 PDEVICE_OBJECT PhysicalDeviceObject;
127
128 LIST_ENTRY ListEntry;
129
130 CHAR ChildDeviceExtension[1];
131 } VIDEO_PORT_CHILD_EXTENSION, *PVIDEO_PORT_CHILD_EXTENSION;
132
133 #define VIDEO_PORT_GET_CHILD_EXTENSION(MiniportExtension) \
134 CONTAINING_RECORD( \
135 MiniportExtension, \
136 VIDEO_PORT_CHILD_EXTENSION, \
137 ChildDeviceExtension)
138
139 #define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension) \
140 CONTAINING_RECORD( \
141 MiniportExtension, \
142 VIDEO_PORT_DEVICE_EXTENSION, \
143 MiniPortDeviceExtension)
144
145 typedef struct _VIDEO_PORT_EVENT
146 {
147 ENG_EVENT;
148 } VIDEO_PORT_EVENT, *PVIDEO_PORT_EVENT;
149
150 /* agp.c */
151
152 NTSTATUS
153 IopInitiatePnpIrp(
154 PDEVICE_OBJECT DeviceObject,
155 PIO_STATUS_BLOCK IoStatusBlock,
156 UCHAR MinorFunction,
157 PIO_STACK_LOCATION Stack OPTIONAL);
158
159 NTSTATUS NTAPI
160 IntAgpGetInterface(
161 IN PVOID HwDeviceExtension,
162 IN OUT PINTERFACE Interface);
163
164 /* child.c */
165
166 NTSTATUS NTAPI
167 IntVideoPortDispatchPdoPnp(
168 IN PDEVICE_OBJECT DeviceObject,
169 IN PIRP Irp);
170
171 /* dispatch.c */
172
173 NTSTATUS NTAPI
174 IntVideoPortAddDevice(
175 IN PDRIVER_OBJECT DriverObject,
176 IN PDEVICE_OBJECT PhysicalDeviceObject);
177
178 NTSTATUS NTAPI
179 IntVideoPortDispatchOpen(
180 IN PDEVICE_OBJECT DeviceObject,
181 IN PIRP Irp);
182
183 NTSTATUS NTAPI
184 IntVideoPortDispatchClose(
185 IN PDEVICE_OBJECT DeviceObject,
186 IN PIRP Irp);
187
188 NTSTATUS NTAPI
189 IntVideoPortDispatchCleanup(
190 IN PDEVICE_OBJECT DeviceObject,
191 IN PIRP Irp);
192
193 NTSTATUS NTAPI
194 IntVideoPortDispatchDeviceControl(
195 IN PDEVICE_OBJECT DeviceObject,
196 IN PIRP Irp);
197
198 NTSTATUS NTAPI
199 IntVideoPortDispatchPnp(
200 IN PDEVICE_OBJECT DeviceObject,
201 IN PIRP Irp);
202
203 NTSTATUS NTAPI
204 IntVideoPortDispatchPower(
205 IN PDEVICE_OBJECT DeviceObject,
206 IN PIRP Irp);
207
208 NTSTATUS NTAPI
209 IntVideoPortDispatchSystemControl(
210 IN PDEVICE_OBJECT DeviceObject,
211 IN PIRP Irp);
212
213 NTSTATUS NTAPI
214 IntVideoPortDispatchWrite(
215 IN PDEVICE_OBJECT DeviceObject,
216 IN PIRP Irp);
217
218 VOID NTAPI
219 IntVideoPortUnload(PDRIVER_OBJECT DriverObject);
220
221 /* timer.c */
222
223 BOOLEAN NTAPI
224 IntVideoPortSetupTimer(
225 IN PDEVICE_OBJECT DeviceObject,
226 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension);
227
228 /* interrupt.c */
229
230 BOOLEAN NTAPI
231 IntVideoPortSetupInterrupt(
232 IN PDEVICE_OBJECT DeviceObject,
233 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
234 IN PVIDEO_PORT_CONFIG_INFO ConfigInfo);
235
236 /* resource.c */
237
238 NTSTATUS NTAPI
239 IntVideoPortFilterResourceRequirements(
240 IN PDEVICE_OBJECT DeviceObject,
241 IN PIRP Irp);
242
243 NTSTATUS NTAPI
244 IntVideoPortMapPhysicalMemory(
245 IN HANDLE Process,
246 IN PHYSICAL_ADDRESS PhysicalAddress,
247 IN ULONG SizeInBytes,
248 IN ULONG Protect,
249 IN OUT PVOID *VirtualAddress OPTIONAL);
250
251 /* videoprt.c */
252
253 extern ULONG CsrssInitialized;
254 extern PKPROCESS Csrss;
255 extern ULONG VideoPortDeviceNumber;
256
257 VOID FASTCALL
258 IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState);
259
260 VOID FASTCALL
261 IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState);
262
263 NTSTATUS NTAPI
264 IntVideoPortCreateAdapterDeviceObject(
265 IN PDRIVER_OBJECT DriverObject,
266 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
267 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
268 OUT PDEVICE_OBJECT *DeviceObject OPTIONAL);
269
270 NTSTATUS NTAPI
271 IntVideoPortFindAdapter(
272 IN PDRIVER_OBJECT DriverObject,
273 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
274 IN PDEVICE_OBJECT DeviceObject);
275
276 PVOID NTAPI
277 IntVideoPortGetProcAddress(
278 IN PVOID HwDeviceExtension,
279 IN PUCHAR FunctionName);
280
281 /* int10.c */
282
283 VP_STATUS NTAPI
284 IntInt10AllocateBuffer(
285 IN PVOID Context,
286 OUT PUSHORT Seg,
287 OUT PUSHORT Off,
288 IN OUT PULONG Length);
289
290 VP_STATUS NTAPI
291 IntInt10FreeBuffer(
292 IN PVOID Context,
293 IN USHORT Seg,
294 IN USHORT Off);
295
296 VP_STATUS NTAPI
297 IntInt10ReadMemory(
298 IN PVOID Context,
299 IN USHORT Seg,
300 IN USHORT Off,
301 OUT PVOID Buffer,
302 IN ULONG Length);
303
304 VP_STATUS NTAPI
305 IntInt10WriteMemory(
306 IN PVOID Context,
307 IN USHORT Seg,
308 IN USHORT Off,
309 IN PVOID Buffer,
310 IN ULONG Length);
311
312 VP_STATUS NTAPI
313 IntInt10CallBios(
314 IN PVOID Context,
315 IN OUT PINT10_BIOS_ARGUMENTS BiosArguments);
316
317 #endif /* VIDEOPRT_H */