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