-dont return NULL when realloc to 0 bytes (fixes one kernel32_winetest heap test)
[reactos.git] / reactos / drivers / video / 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 Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 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 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; see the file COPYING.LIB.
18 * If not, write to the Free Software Foundation,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 * $Id$
22 */
23
24 #ifndef VIDEOPRT_H
25 #define VIDEOPRT_H
26
27 #include <stdio.h>
28 #include <ddk/ntddk.h>
29 #include <ddk/miniport.h>
30 #include <ddk/video.h>
31 #include <ddk/ntddvdeo.h>
32 #include <ddk/ntagp.h>
33 #include <ddk/ntifs.h>
34 #include <ndk/ntndk.h>
35 #include <reactos/helper.h>
36
37 #define NDEBUG
38 #include <debug.h>
39
40 #define TAG_VIDEO_PORT TAG('V', 'I', 'D', 'P')
41
42 typedef struct _VIDEO_PORT_ADDRESS_MAPPING
43 {
44 LIST_ENTRY List;
45 PVOID MappedAddress;
46 ULONG NumberOfUchars;
47 PHYSICAL_ADDRESS IoAddress;
48 ULONG SystemIoBusNumber;
49 UINT MappingCount;
50 } VIDEO_PORT_ADDRESS_MAPPING, *PVIDEO_PORT_ADDRESS_MAPPING;
51
52 struct _VIDEO_PORT_AGP_VIRTUAL_MAPPING;
53
54 typedef struct _VIDEO_PORT_AGP_MAPPING
55 {
56 ULONG NumberOfPages;
57 PVOID MapHandle;
58 PHYSICAL_ADDRESS PhysicalAddress;
59 } VIDEO_PORT_AGP_MAPPING, *PVIDEO_PORT_AGP_MAPPING;
60
61 typedef struct _VIDEO_PORT_AGP_VIRTUAL_MAPPING
62 {
63 PVIDEO_PORT_AGP_MAPPING AgpMapping;
64 HANDLE ProcessHandle;
65 PVOID MappedAddress;
66 } VIDEO_PORT_AGP_VIRTUAL_MAPPING, *PVIDEO_PORT_AGP_VIRTUAL_MAPPING;
67
68 typedef struct _VIDEO_PORT_DRIVER_EXTENSION
69 {
70 VIDEO_HW_INITIALIZATION_DATA InitializationData;
71 PVOID HwContext;
72 UNICODE_STRING RegistryPath;
73 } VIDEO_PORT_DRIVER_EXTENSION, *PVIDEO_PORT_DRIVER_EXTENSION;
74
75 typedef struct _VIDEO_PORT_DEVICE_EXTENSTION
76 {
77 ULONG DeviceNumber;
78 PDRIVER_OBJECT DriverObject;
79 PDEVICE_OBJECT PhysicalDeviceObject;
80 PDEVICE_OBJECT FunctionalDeviceObject;
81 PDEVICE_OBJECT NextDeviceObject;
82 UNICODE_STRING RegistryPath;
83 PKINTERRUPT InterruptObject;
84 KSPIN_LOCK InterruptSpinLock;
85 PCM_RESOURCE_LIST AllocatedResources;
86 ULONG InterruptVector;
87 ULONG InterruptLevel;
88 BOOLEAN InterruptShared;
89 INTERFACE_TYPE AdapterInterfaceType;
90 ULONG SystemIoBusNumber;
91 ULONG SystemIoSlotNumber;
92 LIST_ENTRY AddressMappingListHead;
93 KDPC DpcObject;
94 VIDEO_PORT_DRIVER_EXTENSION *DriverExtension;
95 ULONG DeviceOpened;
96 AGP_BUS_INTERFACE_STANDARD AgpInterface;
97 KMUTEX DeviceLock;
98 CHAR MiniPortDeviceExtension[1];
99 } VIDEO_PORT_DEVICE_EXTENSION, *PVIDEO_PORT_DEVICE_EXTENSION;
100
101 #define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension) \
102 CONTAINING_RECORD( \
103 HwDeviceExtension, \
104 VIDEO_PORT_DEVICE_EXTENSION, \
105 MiniPortDeviceExtension)
106
107 /* agp.c */
108
109 NTSTATUS NTAPI
110 IntAgpGetInterface(
111 IN PVOID HwDeviceExtension,
112 IN OUT PINTERFACE Interface);
113
114 /* dispatch.c */
115
116 NTSTATUS NTAPI
117 IntVideoPortAddDevice(
118 IN PDRIVER_OBJECT DriverObject,
119 IN PDEVICE_OBJECT PhysicalDeviceObject);
120
121 NTSTATUS NTAPI
122 IntVideoPortDispatchOpen(
123 IN PDEVICE_OBJECT DeviceObject,
124 IN PIRP Irp);
125
126 NTSTATUS NTAPI
127 IntVideoPortDispatchClose(
128 IN PDEVICE_OBJECT DeviceObject,
129 IN PIRP Irp);
130
131 NTSTATUS NTAPI
132 IntVideoPortDispatchCleanup(
133 IN PDEVICE_OBJECT DeviceObject,
134 IN PIRP Irp);
135
136 NTSTATUS NTAPI
137 IntVideoPortDispatchDeviceControl(
138 IN PDEVICE_OBJECT DeviceObject,
139 IN PIRP Irp);
140
141 NTSTATUS NTAPI
142 IntVideoPortDispatchPnp(
143 IN PDEVICE_OBJECT DeviceObject,
144 IN PIRP Irp);
145
146 NTSTATUS NTAPI
147 IntVideoPortDispatchPower(
148 IN PDEVICE_OBJECT DeviceObject,
149 IN PIRP Irp);
150
151 VOID NTAPI
152 IntVideoPortUnload(PDRIVER_OBJECT DriverObject);
153
154 /* timer.c */
155
156 BOOLEAN NTAPI
157 IntVideoPortSetupTimer(
158 IN PDEVICE_OBJECT DeviceObject,
159 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension);
160
161 /* interrupt.c */
162
163 BOOLEAN NTAPI
164 IntVideoPortSetupInterrupt(
165 IN PDEVICE_OBJECT DeviceObject,
166 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
167 IN PVIDEO_PORT_CONFIG_INFO ConfigInfo);
168
169 /* resource.c */
170
171 NTSTATUS NTAPI
172 IntVideoPortMapPhysicalMemory(
173 IN HANDLE Process,
174 IN PHYSICAL_ADDRESS PhysicalAddress,
175 IN ULONG SizeInBytes,
176 IN ULONG Protect,
177 IN OUT PVOID *VirtualAddress OPTIONAL);
178
179 /* videoprt.c */
180
181 extern ULONG CsrssInitialized;
182 extern PKPROCESS Csrss;
183
184 VP_STATUS NTAPI
185 VideoPortEnumerateChildren(
186 IN PVOID HwDeviceExtension,
187 IN PVOID Reserved);
188
189 PVOID NTAPI
190 VideoPortGetProcAddress(
191 IN PVOID HwDeviceExtension,
192 IN PUCHAR FunctionName);
193
194 VOID FASTCALL
195 IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState);
196
197 VOID FASTCALL
198 IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState);
199
200 NTSTATUS NTAPI
201 IntVideoPortCreateAdapterDeviceObject(
202 IN PDRIVER_OBJECT DriverObject,
203 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
204 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
205 OUT PDEVICE_OBJECT *DeviceObject OPTIONAL);
206
207 NTSTATUS NTAPI
208 IntVideoPortFindAdapter(
209 IN PDRIVER_OBJECT DriverObject,
210 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
211 IN PDEVICE_OBJECT DeviceObject);
212
213 /* int10.c */
214
215 VP_STATUS NTAPI
216 IntInt10AllocateBuffer(
217 IN PVOID Context,
218 OUT PUSHORT Seg,
219 OUT PUSHORT Off,
220 IN OUT PULONG Length);
221
222 VP_STATUS NTAPI
223 IntInt10FreeBuffer(
224 IN PVOID Context,
225 IN USHORT Seg,
226 IN USHORT Off);
227
228 VP_STATUS NTAPI
229 IntInt10ReadMemory(
230 IN PVOID Context,
231 IN USHORT Seg,
232 IN USHORT Off,
233 OUT PVOID Buffer,
234 IN ULONG Length);
235
236 VP_STATUS NTAPI
237 IntInt10WriteMemory(
238 IN PVOID Context,
239 IN USHORT Seg,
240 IN USHORT Off,
241 IN PVOID Buffer,
242 IN ULONG Length);
243
244 VP_STATUS NTAPI
245 IntInt10CallBios(
246 IN PVOID Context,
247 IN OUT PINT10_BIOS_ARGUMENTS BiosArguments);
248
249 VP_STATUS NTAPI
250 VideoPortInt10(
251 IN PVOID HwDeviceExtension,
252 IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments);
253
254 #endif /* VIDEOPRT_H */