xref: /reactos/win32ss/drivers/videoprt/videoprt.h (revision 0c42866e)
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 <ntifs.h>
26 
27 #define __BROKEN__
28 #include <miniport.h>
29 #include <video.h>
30 #include <ntagp.h>
31 #include <dderror.h>
32 #include <windef.h>
33 #include <wdmguid.h>
34 
35 /* PSEH for SEH Support */
36 #include <pseh/pseh2.h>
37 
38 #define TAG_VIDEO_PORT          'PDIV'
39 #define TAG_VIDEO_PORT_BUFFER   '\0mpV'
40 #define TAG_REQUEST_PACKET      'qRpV'
41 
42 #define GUID_STRING_LENGTH (38 * sizeof(WCHAR))
43 
44 typedef struct _VIDEO_PORT_ADDRESS_MAPPING
45 {
46    LIST_ENTRY List;
47    PVOID MappedAddress;
48    ULONG NumberOfUchars;
49    PHYSICAL_ADDRESS IoAddress;
50    ULONG SystemIoBusNumber;
51    UINT MappingCount;
52 } VIDEO_PORT_ADDRESS_MAPPING, *PVIDEO_PORT_ADDRESS_MAPPING;
53 
54 struct _VIDEO_PORT_AGP_VIRTUAL_MAPPING;
55 
56 typedef struct _VIDEO_PORT_AGP_MAPPING
57 {
58    ULONG NumberOfPages;
59    PVOID MapHandle;
60    PHYSICAL_ADDRESS PhysicalAddress;
61 } VIDEO_PORT_AGP_MAPPING, *PVIDEO_PORT_AGP_MAPPING;
62 
63 typedef struct _VIDEO_PORT_AGP_VIRTUAL_MAPPING
64 {
65    PVIDEO_PORT_AGP_MAPPING AgpMapping;
66    HANDLE ProcessHandle;
67    PVOID MappedAddress;
68 } VIDEO_PORT_AGP_VIRTUAL_MAPPING, *PVIDEO_PORT_AGP_VIRTUAL_MAPPING;
69 
70 typedef struct _VIDEO_PORT_DRIVER_EXTENSION
71 {
72    VIDEO_HW_INITIALIZATION_DATA InitializationData;
73    PVOID HwContext;
74    UNICODE_STRING RegistryPath;
75 } VIDEO_PORT_DRIVER_EXTENSION, *PVIDEO_PORT_DRIVER_EXTENSION;
76 
77 typedef struct _VIDEO_PORT_COMMON_EXTENSION
78 {
79     BOOLEAN Fdo;
80 } VIDEO_PORT_COMMON_EXTENSION, *PVIDEO_PORT_COMMON_EXTENSION;
81 
82 typedef struct _VIDEO_PORT_DEVICE_EXTENSTION
83 {
84    VIDEO_PORT_COMMON_EXTENSION Common;
85    ULONG DeviceNumber;
86    PDRIVER_OBJECT DriverObject;
87    PDEVICE_OBJECT PhysicalDeviceObject;
88    PDEVICE_OBJECT FunctionalDeviceObject;
89    PDEVICE_OBJECT NextDeviceObject;
90    UNICODE_STRING RegistryPath;
91    UNICODE_STRING NewRegistryPath;
92    PKINTERRUPT InterruptObject;
93    KSPIN_LOCK InterruptSpinLock;
94    PCM_RESOURCE_LIST AllocatedResources;
95    ULONG InterruptVector;
96    ULONG InterruptLevel;
97    BOOLEAN InterruptShared;
98    INTERFACE_TYPE AdapterInterfaceType;
99    ULONG SystemIoBusNumber;
100    ULONG SystemIoSlotNumber;
101    LIST_ENTRY AddressMappingListHead;
102    KDPC DpcObject;
103    VIDEO_PORT_DRIVER_EXTENSION *DriverExtension;
104    ULONG DeviceOpened;
105    AGP_BUS_INTERFACE_STANDARD AgpInterface;
106    KMUTEX DeviceLock;
107    LIST_ENTRY DmaAdapterList, ChildDeviceList;
108    LIST_ENTRY HwResetListEntry;
109    ULONG SessionId;
110    USHORT AdapterNumber;
111    USHORT DisplayNumber;
112    ULONG NumberOfSecondaryDisplays;
113    CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1];
114 } VIDEO_PORT_DEVICE_EXTENSION, *PVIDEO_PORT_DEVICE_EXTENSION;
115 
116 typedef struct _VIDEO_PORT_CHILD_EXTENSION
117 {
118     VIDEO_PORT_COMMON_EXTENSION Common;
119 
120     ULONG ChildId;
121     VIDEO_CHILD_TYPE ChildType;
122     UCHAR ChildDescriptor[256];
123 
124     BOOLEAN EdidValid;
125 
126     PDRIVER_OBJECT DriverObject;
127     PDEVICE_OBJECT PhysicalDeviceObject;
128 
129     LIST_ENTRY ListEntry;
130 
131     CHAR ChildDeviceExtension[1];
132 } VIDEO_PORT_CHILD_EXTENSION, *PVIDEO_PORT_CHILD_EXTENSION;
133 
134 #define VIDEO_PORT_GET_CHILD_EXTENSION(MiniportExtension) \
135    CONTAINING_RECORD( \
136        MiniportExtension, \
137        VIDEO_PORT_CHILD_EXTENSION, \
138        ChildDeviceExtension)
139 
140 #define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension) \
141    CONTAINING_RECORD( \
142       MiniportExtension, \
143       VIDEO_PORT_DEVICE_EXTENSION, \
144       MiniPortDeviceExtension)
145 
146 typedef struct _VIDEO_PORT_EVENT
147 {
148     ENG_EVENT;
149 } VIDEO_PORT_EVENT, *PVIDEO_PORT_EVENT;
150 
151 /* agp.c */
152 
153 NTSTATUS
154 IopInitiatePnpIrp(
155   PDEVICE_OBJECT DeviceObject,
156   PIO_STATUS_BLOCK IoStatusBlock,
157   UCHAR MinorFunction,
158   PIO_STACK_LOCATION Stack OPTIONAL);
159 
160 NTSTATUS NTAPI
161 IntAgpGetInterface(
162    IN PVOID HwDeviceExtension,
163    IN OUT PINTERFACE Interface);
164 
165 /* child.c */
166 
167 NTSTATUS NTAPI
168 IntVideoPortDispatchPdoPnp(
169    IN PDEVICE_OBJECT DeviceObject,
170    IN PIRP Irp);
171 
172 /* dispatch.c */
173 
174 NTSTATUS NTAPI
175 IntVideoPortAddDevice(
176    IN PDRIVER_OBJECT DriverObject,
177    IN PDEVICE_OBJECT PhysicalDeviceObject);
178 
179 NTSTATUS NTAPI
180 IntVideoPortDispatchOpen(
181    IN PDEVICE_OBJECT DeviceObject,
182    IN PIRP Irp);
183 
184 NTSTATUS NTAPI
185 IntVideoPortDispatchClose(
186    IN PDEVICE_OBJECT DeviceObject,
187    IN PIRP Irp);
188 
189 NTSTATUS NTAPI
190 IntVideoPortDispatchCleanup(
191    IN PDEVICE_OBJECT DeviceObject,
192    IN PIRP Irp);
193 
194 NTSTATUS NTAPI
195 IntVideoPortDispatchDeviceControl(
196    IN PDEVICE_OBJECT DeviceObject,
197    IN PIRP Irp);
198 
199 NTSTATUS NTAPI
200 IntVideoPortDispatchPnp(
201    IN PDEVICE_OBJECT DeviceObject,
202    IN PIRP Irp);
203 
204 NTSTATUS NTAPI
205 IntVideoPortDispatchPower(
206    IN PDEVICE_OBJECT DeviceObject,
207    IN PIRP Irp);
208 
209 NTSTATUS NTAPI
210 IntVideoPortDispatchSystemControl(
211    IN PDEVICE_OBJECT DeviceObject,
212    IN PIRP Irp);
213 
214 VOID NTAPI
215 IntVideoPortUnload(PDRIVER_OBJECT DriverObject);
216 
217 /* timer.c */
218 
219 BOOLEAN NTAPI
220 IntVideoPortSetupTimer(
221    IN PDEVICE_OBJECT DeviceObject,
222    IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension);
223 
224 /* interrupt.c */
225 
226 BOOLEAN NTAPI
227 IntVideoPortSetupInterrupt(
228    IN PDEVICE_OBJECT DeviceObject,
229    IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
230    IN PVIDEO_PORT_CONFIG_INFO ConfigInfo);
231 
232 /* resource.c */
233 
234 NTSTATUS NTAPI
235 IntVideoPortFilterResourceRequirements(
236    IN PDEVICE_OBJECT DeviceObject,
237    IN PIO_STACK_LOCATION IrpStack,
238    IN PIRP Irp);
239 
240 NTSTATUS NTAPI
241 IntVideoPortMapPhysicalMemory(
242    IN HANDLE Process,
243    IN PHYSICAL_ADDRESS PhysicalAddress,
244    IN ULONG SizeInBytes,
245    IN ULONG Protect,
246    IN OUT PVOID *VirtualAddress  OPTIONAL);
247 
248 /* videoprt.c */
249 
250 extern PKPROCESS CsrProcess;
251 extern ULONG VideoPortDeviceNumber;
252 extern BOOLEAN VideoPortUseNewKey;
253 extern KMUTEX VideoPortInt10Mutex;
254 extern KSPIN_LOCK HwResetAdaptersLock;
255 extern LIST_ENTRY HwResetAdaptersList;
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_opt_ PDEVICE_OBJECT PhysicalDeviceObject,
268    _In_ USHORT AdapterNumber,
269    _In_ USHORT DisplayNumber,
270    _Out_opt_ PDEVICE_OBJECT *DeviceObject);
271 
272 NTSTATUS NTAPI
273 IntVideoPortFindAdapter(
274    IN PDRIVER_OBJECT DriverObject,
275    IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
276    IN PDEVICE_OBJECT DeviceObject);
277 
278 PVOID NTAPI
279 IntVideoPortGetProcAddress(
280    IN PVOID HwDeviceExtension,
281    IN PUCHAR FunctionName);
282 
283 NTSTATUS NTAPI
284 IntVideoPortEnumerateChildren(
285     IN PDEVICE_OBJECT DeviceObject,
286     IN PIRP Irp);
287 
288 /* int10.c */
289 
290 NTSTATUS
291 NTAPI
292 IntInitializeVideoAddressSpace(VOID);
293 
294 VP_STATUS NTAPI
295 IntInt10AllocateBuffer(
296    IN PVOID Context,
297    OUT PUSHORT Seg,
298    OUT PUSHORT Off,
299    IN OUT PULONG Length);
300 
301 VP_STATUS NTAPI
302 IntInt10FreeBuffer(
303    IN PVOID Context,
304    IN USHORT Seg,
305    IN USHORT Off);
306 
307 VP_STATUS NTAPI
308 IntInt10ReadMemory(
309    IN PVOID Context,
310    IN USHORT Seg,
311    IN USHORT Off,
312    OUT PVOID Buffer,
313    IN ULONG Length);
314 
315 VP_STATUS NTAPI
316 IntInt10WriteMemory(
317    IN PVOID Context,
318    IN USHORT Seg,
319    IN USHORT Off,
320    IN PVOID Buffer,
321    IN ULONG Length);
322 
323 VP_STATUS NTAPI
324 IntInt10CallBios(
325    IN PVOID Context,
326    IN OUT PINT10_BIOS_ARGUMENTS BiosArguments);
327 
328 /* registry.c */
329 
330 NTSTATUS
331 NTAPI
332 IntCopyRegistryKey(
333     _In_ HANDLE SourceKeyHandle,
334     _In_ HANDLE DestKeyHandle);
335 
336 NTSTATUS
337 NTAPI
338 IntCopyRegistryValue(
339     HANDLE SourceKeyHandle,
340     HANDLE DestKeyHandle,
341     PWSTR ValueName);
342 
343 NTSTATUS
344 NTAPI
345 IntSetupDeviceSettingsKey(
346     PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension);
347 
348 NTSTATUS
349 NTAPI
350 IntCreateNewRegistryPath(
351     PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension);
352 
353 NTSTATUS
354 NTAPI
355 IntCreateRegistryPath(
356     IN PCUNICODE_STRING DriverRegistryPath,
357     IN ULONG DeviceNumber,
358     OUT PUNICODE_STRING DeviceRegistryPath);
359 
360 
361 #endif /* VIDEOPRT_H */
362