added agp.c First try of implementing the AGP functions (Untested)
[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 <ddk/miniport.h>
28 #include <ddk/video.h>
29 #include <ddk/ntddvdeo.h>
30 #include <ddk/ntapi.h>
31 #include <ddk/ntagp.h>
32 //#define NDEBUG
33 #include <debug.h>
34
35 int swprintf(wchar_t *buf, const wchar_t *fmt, ...);
36 int vsprintf(char *buf, const char *fmt, va_list args);
37
38 BOOLEAN STDCALL
39 HalDisableSystemInterrupt(ULONG Vector,
40 KIRQL Irql);
41
42 BOOLEAN STDCALL
43 HalEnableSystemInterrupt(ULONG Vector,
44 KIRQL Irql,
45 KINTERRUPT_MODE InterruptMode);
46
47 PIMAGE_NT_HEADERS STDCALL RtlImageNtHeader(IN PVOID BaseAddress);
48
49 #define TAG_VIDEO_PORT TAG('V', 'I', 'D', 'P')
50
51 typedef struct _VIDEO_PORT_ADDRESS_MAPPING
52 {
53 LIST_ENTRY List;
54 PVOID MappedAddress;
55 ULONG NumberOfUchars;
56 PHYSICAL_ADDRESS IoAddress;
57 ULONG SystemIoBusNumber;
58 UINT MappingCount;
59 } VIDEO_PORT_ADDRESS_MAPPING, *PVIDEO_PORT_ADDRESS_MAPPING;
60
61 struct _VIDEO_PORT_AGP_VIRTUAL_MAPPING;
62
63 typedef struct _VIDEO_PORT_AGP_MAPPING
64 {
65 ULONG NumberOfPages;
66 PVOID MapHandle;
67 PHYSICAL_ADDRESS PhysicalAddress;
68 } VIDEO_PORT_AGP_MAPPING, *PVIDEO_PORT_AGP_MAPPING;
69
70 typedef struct _VIDEO_PORT_AGP_VIRTUAL_MAPPING
71 {
72 PVIDEO_PORT_AGP_MAPPING AgpMapping;
73 HANDLE ProcessHandle;
74 PVOID MappedAddress;
75 } VIDEO_PORT_AGP_VIRTUAL_MAPPING, *PVIDEO_PORT_AGP_VIRTUAL_MAPPING;
76
77 typedef struct _VIDEO_PORT_DRIVER_EXTENSION
78 {
79 VIDEO_HW_INITIALIZATION_DATA InitializationData;
80 PVOID HwContext;
81 UNICODE_STRING RegistryPath;
82 } VIDEO_PORT_DRIVER_EXTENSION, *PVIDEO_PORT_DRIVER_EXTENSION;
83
84 typedef struct _VIDEO_PORT_DEVICE_EXTENSTION
85 {
86 ULONG DeviceNumber;
87 PDEVICE_OBJECT PhysicalDeviceObject;
88 PDEVICE_OBJECT FunctionalDeviceObject;
89 PDEVICE_OBJECT NextDeviceObject;
90 UNICODE_STRING RegistryPath;
91 PKINTERRUPT InterruptObject;
92 KSPIN_LOCK InterruptSpinLock;
93 PCM_RESOURCE_LIST AllocatedResources;
94 ULONG InterruptVector;
95 ULONG InterruptLevel;
96 ULONG AdapterInterfaceType;
97 ULONG SystemIoBusNumber;
98 ULONG SystemIoSlotNumber;
99 LIST_ENTRY AddressMappingListHead;
100 KDPC DpcObject;
101 VIDEO_PORT_DRIVER_EXTENSION *DriverExtension;
102 ULONG DeviceOpened;
103 AGP_BUS_INTERFACE_STANDARD AgpInterface;
104 KMUTEX DeviceLock;
105 CHAR MiniPortDeviceExtension[1];
106 } VIDEO_PORT_DEVICE_EXTENSION, *PVIDEO_PORT_DEVICE_EXTENSION;
107
108 #define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension) \
109 CONTAINING_RECORD( \
110 HwDeviceExtension, \
111 VIDEO_PORT_DEVICE_EXTENSION, \
112 MiniPortDeviceExtension)
113
114 /* agp.c */
115
116 NTSTATUS STDCALL
117 IntAgpGetInterface(
118 IN PVOID HwDeviceExtension,
119 IN OUT PINTERFACE Interface);
120
121 /* dispatch.c */
122
123 NTSTATUS STDCALL
124 IntVideoPortAddDevice(
125 IN PDRIVER_OBJECT DriverObject,
126 IN PDEVICE_OBJECT PhysicalDeviceObject);
127
128 NTSTATUS STDCALL
129 IntVideoPortDispatchOpen(
130 IN PDEVICE_OBJECT DeviceObject,
131 IN PIRP Irp);
132
133 NTSTATUS STDCALL
134 IntVideoPortDispatchClose(
135 IN PDEVICE_OBJECT DeviceObject,
136 IN PIRP Irp);
137
138 NTSTATUS STDCALL
139 IntVideoPortDispatchCleanup(
140 IN PDEVICE_OBJECT DeviceObject,
141 IN PIRP Irp);
142
143 NTSTATUS STDCALL
144 IntVideoPortDispatchDeviceControl(
145 IN PDEVICE_OBJECT DeviceObject,
146 IN PIRP Irp);
147
148 NTSTATUS STDCALL
149 IntVideoPortDispatchPnp(
150 IN PDEVICE_OBJECT DeviceObject,
151 IN PIRP Irp);
152
153 NTSTATUS STDCALL
154 IntVideoPortDispatchPower(
155 IN PDEVICE_OBJECT DeviceObject,
156 IN PIRP Irp);
157
158 VOID STDCALL
159 IntVideoPortUnload(PDRIVER_OBJECT DriverObject);
160
161 /* timer.c */
162
163 BOOLEAN STDCALL
164 IntVideoPortSetupTimer(
165 IN PDEVICE_OBJECT DeviceObject,
166 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension);
167
168 /* interrupt.c */
169
170 BOOLEAN STDCALL
171 IntVideoPortSetupInterrupt(
172 IN PDEVICE_OBJECT DeviceObject,
173 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
174 IN PVIDEO_PORT_CONFIG_INFO ConfigInfo);
175
176 /* resource.c */
177
178 NTSTATUS STDCALL
179 IntVideoPortMapPhysicalMemory(
180 IN HANDLE Process,
181 IN PHYSICAL_ADDRESS PhysicalAddress,
182 IN ULONG SizeInBytes,
183 IN ULONG Protect,
184 IN OUT PVOID *VirtualAddress OPTIONAL);
185
186 /* videoprt.c */
187
188 extern ULONG CsrssInitialized;
189 extern PEPROCESS Csrss;
190
191 VP_STATUS STDCALL
192 VideoPortEnumerateChildren(
193 IN PVOID HwDeviceExtension,
194 IN PVOID Reserved);
195
196 PVOID STDCALL
197 VideoPortGetProcAddress(
198 IN PVOID HwDeviceExtension,
199 IN PUCHAR FunctionName);
200
201 VOID FASTCALL
202 IntAttachToCSRSS(PEPROCESS *CallingProcess, PEPROCESS *PrevAttachedProcess);
203
204 VOID FASTCALL
205 IntDetachFromCSRSS(PEPROCESS *CallingProcess, PEPROCESS *PrevAttachedProcess);
206
207 NTSTATUS STDCALL
208 IntVideoPortCreateAdapterDeviceObject(
209 IN PDRIVER_OBJECT DriverObject,
210 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
211 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
212 OUT PDEVICE_OBJECT *DeviceObject OPTIONAL);
213
214 NTSTATUS STDCALL
215 IntVideoPortFindAdapter(
216 IN PDRIVER_OBJECT DriverObject,
217 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
218 IN PDEVICE_OBJECT DeviceObject);
219
220 /* int10.c */
221
222 VP_STATUS STDCALL
223 IntInt10AllocateBuffer(
224 IN PVOID Context,
225 OUT PUSHORT Seg,
226 OUT PUSHORT Off,
227 IN OUT PULONG Length);
228
229 VP_STATUS STDCALL
230 IntInt10FreeBuffer(
231 IN PVOID Context,
232 IN USHORT Seg,
233 IN USHORT Off);
234
235 VP_STATUS STDCALL
236 IntInt10ReadMemory(
237 IN PVOID Context,
238 IN USHORT Seg,
239 IN USHORT Off,
240 OUT PVOID Buffer,
241 IN ULONG Length);
242
243 VP_STATUS STDCALL
244 IntInt10WriteMemory(
245 IN PVOID Context,
246 IN USHORT Seg,
247 IN USHORT Off,
248 IN PVOID Buffer,
249 IN ULONG Length);
250
251 VP_STATUS STDCALL
252 IntInt10CallBios(
253 IN PVOID Context,
254 IN OUT PINT10_BIOS_ARGUMENTS BiosArguments);
255
256 VP_STATUS STDCALL
257 VideoPortInt10(
258 IN PVOID HwDeviceExtension,
259 IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments);
260
261 #endif /* VIDEOPRT_H */