xref: /reactos/win32ss/drivers/videoprt/videoprt.h (revision 3f976713)
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 KMUTEX VideoPortInt10Mutex;
253 extern KSPIN_LOCK HwResetAdaptersLock;
254 extern LIST_ENTRY HwResetAdaptersList;
255 
256 VOID FASTCALL
257 IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState);
258 
259 VOID FASTCALL
260 IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState);
261 
262 NTSTATUS NTAPI
263 IntVideoPortCreateAdapterDeviceObject(
264    _In_ PDRIVER_OBJECT DriverObject,
265    _In_ PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
266    _In_opt_ PDEVICE_OBJECT PhysicalDeviceObject,
267    _In_ USHORT AdapterNumber,
268    _In_ USHORT DisplayNumber,
269    _Out_opt_ PDEVICE_OBJECT *DeviceObject);
270 
271 NTSTATUS NTAPI
272 IntVideoPortFindAdapter(
273    IN PDRIVER_OBJECT DriverObject,
274    IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
275    IN PDEVICE_OBJECT DeviceObject);
276 
277 PVOID NTAPI
278 IntVideoPortGetProcAddress(
279    IN PVOID HwDeviceExtension,
280    IN PUCHAR FunctionName);
281 
282 /* int10.c */
283 
284 NTSTATUS
285 NTAPI
286 IntInitializeVideoAddressSpace(VOID);
287 
288 VP_STATUS NTAPI
289 IntInt10AllocateBuffer(
290    IN PVOID Context,
291    OUT PUSHORT Seg,
292    OUT PUSHORT Off,
293    IN OUT PULONG Length);
294 
295 VP_STATUS NTAPI
296 IntInt10FreeBuffer(
297    IN PVOID Context,
298    IN USHORT Seg,
299    IN USHORT Off);
300 
301 VP_STATUS NTAPI
302 IntInt10ReadMemory(
303    IN PVOID Context,
304    IN USHORT Seg,
305    IN USHORT Off,
306    OUT PVOID Buffer,
307    IN ULONG Length);
308 
309 VP_STATUS NTAPI
310 IntInt10WriteMemory(
311    IN PVOID Context,
312    IN USHORT Seg,
313    IN USHORT Off,
314    IN PVOID Buffer,
315    IN ULONG Length);
316 
317 VP_STATUS NTAPI
318 IntInt10CallBios(
319    IN PVOID Context,
320    IN OUT PINT10_BIOS_ARGUMENTS BiosArguments);
321 
322 /* registry.c */
323 
324 NTSTATUS
325 NTAPI
326 IntCopyRegistryKey(
327     _In_ HANDLE SourceKeyHandle,
328     _In_ HANDLE DestKeyHandle);
329 
330 NTSTATUS
331 NTAPI
332 IntCopyRegistryValue(
333     HANDLE SourceKeyHandle,
334     HANDLE DestKeyHandle,
335     PWSTR ValueName);
336 
337 NTSTATUS
338 NTAPI
339 IntSetupDeviceSettingsKey(
340     PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension);
341 
342 NTSTATUS
343 NTAPI
344 IntCreateNewRegistryPath(
345     PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension);
346 
347 NTSTATUS
348 NTAPI
349 IntCreateRegistryPath(
350     IN PCUNICODE_STRING DriverRegistryPath,
351     IN ULONG DeviceNumber,
352     OUT PUNICODE_STRING DeviceRegistryPath);
353 
354 
355 #endif /* VIDEOPRT_H */
356