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 CHAR MiniPortDeviceExtension[1]; 111 } VIDEO_PORT_DEVICE_EXTENSION, *PVIDEO_PORT_DEVICE_EXTENSION; 112 113 typedef struct _VIDEO_PORT_CHILD_EXTENSION 114 { 115 VIDEO_PORT_COMMON_EXTENSION Common; 116 117 ULONG ChildId; 118 VIDEO_CHILD_TYPE ChildType; 119 UCHAR ChildDescriptor[256]; 120 121 BOOLEAN EdidValid; 122 123 PDRIVER_OBJECT DriverObject; 124 PDEVICE_OBJECT PhysicalDeviceObject; 125 126 LIST_ENTRY ListEntry; 127 128 CHAR ChildDeviceExtension[1]; 129 } VIDEO_PORT_CHILD_EXTENSION, *PVIDEO_PORT_CHILD_EXTENSION; 130 131 #define VIDEO_PORT_GET_CHILD_EXTENSION(MiniportExtension) \ 132 CONTAINING_RECORD( \ 133 MiniportExtension, \ 134 VIDEO_PORT_CHILD_EXTENSION, \ 135 ChildDeviceExtension) 136 137 #define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension) \ 138 CONTAINING_RECORD( \ 139 MiniportExtension, \ 140 VIDEO_PORT_DEVICE_EXTENSION, \ 141 MiniPortDeviceExtension) 142 143 typedef struct _VIDEO_PORT_EVENT 144 { 145 ENG_EVENT; 146 } VIDEO_PORT_EVENT, *PVIDEO_PORT_EVENT; 147 148 /* agp.c */ 149 150 NTSTATUS 151 IopInitiatePnpIrp( 152 PDEVICE_OBJECT DeviceObject, 153 PIO_STATUS_BLOCK IoStatusBlock, 154 UCHAR MinorFunction, 155 PIO_STACK_LOCATION Stack OPTIONAL); 156 157 NTSTATUS NTAPI 158 IntAgpGetInterface( 159 IN PVOID HwDeviceExtension, 160 IN OUT PINTERFACE Interface); 161 162 /* child.c */ 163 164 NTSTATUS NTAPI 165 IntVideoPortDispatchPdoPnp( 166 IN PDEVICE_OBJECT DeviceObject, 167 IN PIRP Irp); 168 169 /* dispatch.c */ 170 171 NTSTATUS NTAPI 172 IntVideoPortAddDevice( 173 IN PDRIVER_OBJECT DriverObject, 174 IN PDEVICE_OBJECT PhysicalDeviceObject); 175 176 NTSTATUS NTAPI 177 IntVideoPortDispatchOpen( 178 IN PDEVICE_OBJECT DeviceObject, 179 IN PIRP Irp); 180 181 NTSTATUS NTAPI 182 IntVideoPortDispatchClose( 183 IN PDEVICE_OBJECT DeviceObject, 184 IN PIRP Irp); 185 186 NTSTATUS NTAPI 187 IntVideoPortDispatchCleanup( 188 IN PDEVICE_OBJECT DeviceObject, 189 IN PIRP Irp); 190 191 NTSTATUS NTAPI 192 IntVideoPortDispatchDeviceControl( 193 IN PDEVICE_OBJECT DeviceObject, 194 IN PIRP Irp); 195 196 NTSTATUS NTAPI 197 IntVideoPortDispatchPnp( 198 IN PDEVICE_OBJECT DeviceObject, 199 IN PIRP Irp); 200 201 NTSTATUS NTAPI 202 IntVideoPortDispatchPower( 203 IN PDEVICE_OBJECT DeviceObject, 204 IN PIRP Irp); 205 206 NTSTATUS NTAPI 207 IntVideoPortDispatchSystemControl( 208 IN PDEVICE_OBJECT DeviceObject, 209 IN PIRP Irp); 210 211 VOID NTAPI 212 IntVideoPortUnload(PDRIVER_OBJECT DriverObject); 213 214 /* timer.c */ 215 216 BOOLEAN NTAPI 217 IntVideoPortSetupTimer( 218 IN PDEVICE_OBJECT DeviceObject, 219 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension); 220 221 /* interrupt.c */ 222 223 BOOLEAN NTAPI 224 IntVideoPortSetupInterrupt( 225 IN PDEVICE_OBJECT DeviceObject, 226 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, 227 IN PVIDEO_PORT_CONFIG_INFO ConfigInfo); 228 229 /* resource.c */ 230 231 NTSTATUS NTAPI 232 IntVideoPortFilterResourceRequirements( 233 IN PDEVICE_OBJECT DeviceObject, 234 IN PIRP Irp); 235 236 NTSTATUS NTAPI 237 IntVideoPortMapPhysicalMemory( 238 IN HANDLE Process, 239 IN PHYSICAL_ADDRESS PhysicalAddress, 240 IN ULONG SizeInBytes, 241 IN ULONG Protect, 242 IN OUT PVOID *VirtualAddress OPTIONAL); 243 244 /* videoprt.c */ 245 246 extern PKPROCESS CsrProcess; 247 extern ULONG VideoPortDeviceNumber; 248 extern KMUTEX VideoPortInt10Mutex; 249 extern KSPIN_LOCK HwResetAdaptersLock; 250 extern LIST_ENTRY HwResetAdaptersList; 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_opt_ PDEVICE_OBJECT PhysicalDeviceObject, 263 _Out_opt_ PDEVICE_OBJECT *DeviceObject); 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