ReactOS 0.4.15-dev-5896-g3f5bcf5
videoprt.c File Reference
#include "videoprt.h"
#include <stdio.h>
#include <ndk/exfuncs.h>
#include <ndk/obfuncs.h>
#include <ndk/rtlfuncs.h>
#include <debug.h>
Include dependency graph for videoprt.c:

Go to the source code of this file.

Classes

struct  QueryRegistryCallbackContext
 

Macros

#define NDEBUG
 

Typedefs

typedef struct QueryRegistryCallbackContext QUERY_REGISTRY_CALLBACK_CONTEXT
 
typedef struct QueryRegistryCallbackContextPQUERY_REGISTRY_CALLBACK_CONTEXT
 

Functions

 RTL_STATIC_LIST_HEAD (HwResetAdaptersList)
 
ULONG NTAPI DriverEntry (IN PVOID Context1, IN PVOID Context2)
 
static NTSTATUS IntVideoPortAddDeviceMapLink (PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
 
PVOID NTAPI IntVideoPortImageDirectoryEntryToData (PVOID BaseAddress, ULONG Directory)
 
VOID NTAPI IntVideoPortDeferredRoutine (IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
NTSTATUS NTAPI IntVideoPortCreateAdapterDeviceObject (_In_ PDRIVER_OBJECT DriverObject, _In_ PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, _In_opt_ PDEVICE_OBJECT PhysicalDeviceObject, _In_ USHORT AdapterNumber, _In_ USHORT DisplayNumber, _Out_opt_ PDEVICE_OBJECT *DeviceObject)
 
NTSTATUS NTAPI IntVideoPortFindAdapter (IN PDRIVER_OBJECT DriverObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PDEVICE_OBJECT DeviceObject)
 
VOID FASTCALL IntAttachToCSRSS (PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
 
VOID FASTCALL IntDetachFromCSRSS (PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
 
VOID FASTCALL IntLoadRegistryParameters (VOID)
 
ULONG NTAPI VideoPortInitialize (IN PVOID Context1, IN PVOID Context2, IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData, IN PVOID HwContext)
 
VOID VideoPortDebugPrint (IN VIDEO_DEBUG_LEVEL DebugPrintLevel, IN PCHAR DebugMessage,...)
 
VOID NTAPI VideoPortLogError (IN PVOID HwDeviceExtension, IN PVIDEO_REQUEST_PACKET Vrp OPTIONAL, IN VP_STATUS ErrorCode, IN ULONG UniqueId)
 
UCHAR NTAPI VideoPortGetCurrentIrql (VOID)
 
static NTSTATUS NTAPI QueryRegistryCallback (IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
 
VP_STATUS NTAPI VideoPortGetRegistryParameters (IN PVOID HwDeviceExtension, IN PWSTR ParameterName, IN UCHAR IsParameterFileName, IN PMINIPORT_GET_REGISTRY_ROUTINE GetRegistryRoutine, IN PVOID HwContext)
 
VP_STATUS NTAPI VideoPortSetRegistryParameters (IN PVOID HwDeviceExtension, IN PWSTR ValueName, IN PVOID ValueData, IN ULONG ValueLength)
 
VP_STATUS NTAPI VideoPortGetVgaStatus (IN PVOID HwDeviceExtension, OUT PULONG VgaStatus)
 
PVOID NTAPI VideoPortGetRomImage (IN PVOID HwDeviceExtension, IN PVOID Unused1, IN ULONG Unused2, IN ULONG Length)
 
BOOLEAN NTAPI VideoPortScanRom (IN PVOID HwDeviceExtension, IN PUCHAR RomBase, IN ULONG RomLength, IN PUCHAR String)
 
BOOLEAN NTAPI VideoPortSynchronizeExecution (IN PVOID HwDeviceExtension, IN VIDEO_SYNCHRONIZE_PRIORITY Priority, IN PMINIPORT_SYNCHRONIZE_ROUTINE SynchronizeRoutine, OUT PVOID Context)
 
NTSTATUS NTAPI IntVideoPortEnumerateChildren (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VP_STATUS NTAPI VideoPortEnumerateChildren (IN PVOID HwDeviceExtension, IN PVOID Reserved)
 
VP_STATUS NTAPI VideoPortCreateSecondaryDisplay (IN PVOID HwDeviceExtension, IN OUT PVOID *SecondaryDeviceExtension, IN ULONG Flag)
 
BOOLEAN NTAPI VideoPortQueueDpc (IN PVOID HwDeviceExtension, IN PMINIPORT_DPC_ROUTINE CallbackRoutine, IN PVOID Context)
 
PVOID NTAPI VideoPortGetAssociatedDeviceExtension (IN PVOID DeviceObject)
 
VP_STATUS NTAPI VideoPortGetVersion (IN PVOID HwDeviceExtension, IN OUT PVPOSVERSIONINFO VpOsVersionInfo)
 
BOOLEAN NTAPI VideoPortCheckForDeviceExistence (IN PVOID HwDeviceExtension, IN USHORT VendorId, IN USHORT DeviceId, IN UCHAR RevisionId, IN USHORT SubVendorId, IN USHORT SubSystemId, IN ULONG Flags)
 
VP_STATUS NTAPI VideoPortRegisterBugcheckCallback (IN PVOID HwDeviceExtension, IN ULONG BugcheckCode, IN PVIDEO_BUGCHECK_CALLBACK Callback, IN ULONG BugcheckDataSize)
 
LONGLONG NTAPI VideoPortQueryPerformanceCounter (IN PVOID HwDeviceExtension, OUT PLONGLONG PerformanceFrequency OPTIONAL)
 
VOID NTAPI VideoPortAcquireDeviceLock (IN PVOID HwDeviceExtension)
 
VOID NTAPI VideoPortReleaseDeviceLock (IN PVOID HwDeviceExtension)
 
VOID NTAPI VpNotifyEaData (IN PDEVICE_OBJECT DeviceObject, IN PVOID Data)
 
PVOID NTAPI VideoPortAllocateContiguousMemory (IN PVOID HwDeviceExtension, IN ULONG NumberOfBytes, IN PHYSICAL_ADDRESS HighestAcceptableAddress)
 
BOOLEAN NTAPI VideoPortIsNoVesa (VOID)
 

Variables

ULONG VideoDebugLevel = 0
 
BOOLEAN VpBaseVideo = FALSE
 
BOOLEAN VpNoVesa = FALSE
 
PKPROCESS CsrProcess = NULL
 
static ULONG VideoPortMaxObjectNumber = -1
 
BOOLEAN VideoPortUseNewKey = FALSE
 
KMUTEX VideoPortInt10Mutex
 
KSPIN_LOCK HwResetAdaptersLock
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 29 of file videoprt.c.

Typedef Documentation

◆ PQUERY_REGISTRY_CALLBACK_CONTEXT

◆ QUERY_REGISTRY_CALLBACK_CONTEXT

Function Documentation

◆ DriverEntry()

ULONG NTAPI DriverEntry ( IN PVOID  Context1,
IN PVOID  Context2 
)

Definition at line 50 of file videoprt.c.

53{
54 return STATUS_SUCCESS;
55}
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ IntAttachToCSRSS()

VOID FASTCALL IntAttachToCSRSS ( PKPROCESS CallingProcess,
PKAPC_STATE  ApcState 
)

Definition at line 498 of file videoprt.c.

501{
502 *CallingProcess = (PKPROCESS)PsGetCurrentProcess();
503 if (*CallingProcess != CsrProcess)
504 {
506 }
507}
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1727
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:704
PKPROCESS CsrProcess
Definition: videoprt.c:39
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:201
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by IntInt10AllocateBuffer(), IntInt10CallBios(), IntInt10FreeBuffer(), IntInt10ReadMemory(), IntInt10WriteMemory(), and VideoPortGetRomImage().

◆ IntDetachFromCSRSS()

VOID FASTCALL IntDetachFromCSRSS ( PKPROCESS CallingProcess,
PKAPC_STATE  ApcState 
)

Definition at line 511 of file videoprt.c.

514{
515 if (*CallingProcess != CsrProcess)
516 {
518 }
519}
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756

Referenced by IntInt10AllocateBuffer(), IntInt10CallBios(), IntInt10FreeBuffer(), IntInt10ReadMemory(), IntInt10WriteMemory(), and VideoPortGetRomImage().

◆ IntLoadRegistryParameters()

VOID FASTCALL IntLoadRegistryParameters ( VOID  )

Definition at line 523 of file videoprt.c.

524{
527 UNICODE_STRING UseNewKeyPath = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\GraphicsDrivers\\UseNewKey");
528 UNICODE_STRING Path = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control");
529 UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"SystemStartOptions");
533
534 /* Check if we need to use new registry */
536 &UseNewKeyPath,
538 NULL,
539 NULL);
540 Status = ZwOpenKey(&KeyHandle,
543 if (NT_SUCCESS(Status))
544 {
547 }
548
549 /* Initialize object attributes with the path we want */
551 &Path,
553 NULL,
554 NULL);
555
556 /* Open the key */
557 Status = ZwOpenKey(&KeyHandle,
560 if (!NT_SUCCESS(Status))
561 {
562 VideoPortDebugPrint(Error, "ZwOpenKey failed (0x%x)\n", Status);
563 return;
564 }
565
566 /* Find out how large our buffer should be */
567 Status = ZwQueryValueKey(KeyHandle,
568 &ValueName,
570 NULL,
571 0,
572 &Length);
574 {
575 VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status);
577 return;
578 }
579
580 /* Allocate it */
582 if (!KeyInfo)
583 {
584 VideoPortDebugPrint(Error, "Out of memory\n");
586 return;
587 }
588
589 /* Now for real this time */
590 Status = ZwQueryValueKey(KeyHandle,
591 &ValueName,
593 KeyInfo,
594 Length,
595 &NewLength);
597
598 if (!NT_SUCCESS(Status))
599 {
600 VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status);
602 return;
603 }
604
605 /* Sanity check */
606 if (KeyInfo->Type != REG_SZ)
607 {
608 VideoPortDebugPrint(Error, "Invalid type for SystemStartOptions\n");
610 return;
611 }
612
613 /* Check if BASEVIDEO or NOVESA is present in the start options */
614 if (wcsstr((PWCHAR)KeyInfo->Data, L"BASEVIDEO"))
616 if (wcsstr((PWCHAR)KeyInfo->Data, L"NOVESA"))
617 VpNoVesa = TRUE;
618
620
621 /* FIXME: Old ReactOS-compatibility... */
623
624 if (VpNoVesa)
625 VideoPortDebugPrint(Info, "VESA mode disabled\n");
626 else
627 VideoPortDebugPrint(Info, "VESA mode enabled\n");
628
629 /* If we are in BASEVIDEO, create the volatile registry key for Win32k */
630 if (VpBaseVideo)
631 {
632 RtlInitUnicodeString(&Path, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\GraphicsDrivers\\BaseVideo");
633
635 &Path,
637 NULL,
638 NULL);
639
640 Status = ZwCreateKey(&KeyHandle,
641 READ_CONTROL, // Non-0 placeholder: no use for this handle.
643 0,
644 NULL,
646 NULL);
647 if (NT_SUCCESS(Status))
649 else
650 ERR_(VIDEOPRT, "Failed to create the BaseVideo key (0x%x)\n", Status);
651 }
652
653 return;
654}
static USHORT USHORT * NewLength
PRTL_UNICODE_STRING_BUFFER Path
LONG NTSTATUS
Definition: precomp.h:26
BOOL Error
Definition: chkdsk.c:66
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define GENERIC_READ
Definition: compat.h:135
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define REG_SZ
Definition: layer.c:22
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
#define KernelMode
Definition: asm.h:34
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyValuePartialInformation
Definition: nt_native.h:1182
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define READ_CONTROL
Definition: nt_native.h:58
#define GENERIC_WRITE
Definition: nt_native.h:90
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
#define ERR_(ch,...)
Definition: debug.h:156
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
BOOLEAN VideoPortUseNewKey
Definition: videoprt.c:41
BOOLEAN VpNoVesa
Definition: videoprt.c:37
VOID VideoPortDebugPrint(IN VIDEO_DEBUG_LEVEL DebugPrintLevel, IN PCHAR DebugMessage,...)
Definition: videoprt.c:873
BOOLEAN VpBaseVideo
Definition: videoprt.c:36
#define TAG_VIDEO_PORT
Definition: videoprt.h:38
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243

Referenced by VideoPortInitialize().

◆ IntVideoPortAddDeviceMapLink()

static NTSTATUS IntVideoPortAddDeviceMapLink ( PVIDEO_PORT_DEVICE_EXTENSION  DeviceExtension)
static

Definition at line 59 of file videoprt.c.

61{
63 WCHAR DeviceBuffer[20];
65 WCHAR SymlinkBuffer[20];
66 UNICODE_STRING SymlinkName;
69
70 /* Create a unicode device name. */
71 DeviceNumber = DeviceExtension->DeviceNumber;
72 swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
73
75 RegistryPath = &DeviceExtension->NewRegistryPath;
76 else
77 RegistryPath = &DeviceExtension->RegistryPath;
78
79 /* Add entry to DEVICEMAP\VIDEO key in registry. */
81 L"VIDEO",
82 DeviceBuffer,
83 REG_SZ,
84 RegistryPath->Buffer,
85 RegistryPath->Length + sizeof(UNICODE_NULL));
86 if (!NT_SUCCESS(Status))
87 {
88 ERR_(VIDEOPRT, "Failed to create DEVICEMAP registry entry: 0x%X\n", Status);
89 return Status;
90 }
91
93 L"VIDEO",
94 L"MaxObjectNumber",
97 sizeof(DeviceNumber));
98 if (!NT_SUCCESS(Status))
99 {
100 ERR_(VIDEOPRT, "Failed to write MaxObjectNumber: 0x%X\n", Status);
101 return Status;
102 }
103
104 /* Create symbolic link "\??\DISPLAYx" */
105 swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DeviceNumber + 1);
106 RtlInitUnicodeString(&SymlinkName, SymlinkBuffer);
107 RtlInitUnicodeString(&DeviceName, DeviceBuffer);
108 Status = IoCreateSymbolicLink(&SymlinkName, &DeviceName);
109 if (!NT_SUCCESS(Status))
110 {
111 ERR_(VIDEOPRT, "Failed to create symbolic link: 0x%X\n", Status);
112 return Status;
113 }
114
115 /* Update MaxObjectNumber */
117
118 return STATUS_SUCCESS;
119}
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1230
#define swprintf
Definition: precomp.h:40
NTSYSAPI NTSTATUS WINAPI RtlWriteRegistryValue(ULONG, PCWSTR, PCWSTR, ULONG, PVOID, ULONG)
#define RTL_REGISTRY_DEVICEMAP
Definition: nt_native.h:165
#define UNICODE_NULL
#define REG_DWORD
Definition: sdbapi.c:596
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
UNICODE_STRING NewRegistryPath
Definition: videoprt.h:91
static ULONG VideoPortMaxObjectNumber
Definition: videoprt.c:40
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntVideoPortCreateAdapterDeviceObject()

NTSTATUS NTAPI IntVideoPortCreateAdapterDeviceObject ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ PVIDEO_PORT_DRIVER_EXTENSION  DriverExtension,
_In_opt_ PDEVICE_OBJECT  PhysicalDeviceObject,
_In_ USHORT  AdapterNumber,
_In_ USHORT  DisplayNumber,
_Out_opt_ PDEVICE_OBJECT DeviceObject 
)

Definition at line 159 of file videoprt.c.

166{
167 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
169 ULONG PciSlotNumber;
171 ULONG Size;
173 WCHAR DeviceBuffer[20];
175 PDEVICE_OBJECT DeviceObject_;
176
177 if (DeviceObject == NULL)
178 DeviceObject = &DeviceObject_;
179
180 /*
181 * Find the first free device number that can be used for video device
182 * object names and symlinks.
183 */
185 if (DeviceNumber == (ULONG)-1)
186 {
187 WARN_(VIDEOPRT, "Can't find free device number\n");
188 return STATUS_UNSUCCESSFUL;
189 }
190
191 /*
192 * Create the device object.
193 */
194
195 /* Create a unicode device name. */
196 swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
197 RtlInitUnicodeString(&DeviceName, DeviceBuffer);
198
199 INFO_(VIDEOPRT, "HwDeviceExtension size is: 0x%x\n",
200 DriverExtension->InitializationData.HwDeviceExtensionSize);
201
202 /* Create the device object. */
204 DriverExtension->InitializationData.HwDeviceExtensionSize;
206 Size,
207 &DeviceName,
209 0,
210 TRUE,
212
213 if (!NT_SUCCESS(Status))
214 {
215 WARN_(VIDEOPRT, "IoCreateDevice call failed with status 0x%08x\n", Status);
216 return Status;
217 }
218
219 /*
220 * Set the buffering strategy here. If you change this, remember
221 * to change VidDispatchDeviceControl too.
222 */
223
224 (*DeviceObject)->Flags |= DO_BUFFERED_IO;
225
226 /* Initialize device extension. */
227 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)((*DeviceObject)->DeviceExtension);
228 DeviceExtension->Common.Fdo = TRUE;
229 DeviceExtension->DeviceNumber = DeviceNumber;
230 DeviceExtension->DriverObject = DriverObject;
232 DeviceExtension->FunctionalDeviceObject = *DeviceObject;
233 DeviceExtension->DriverExtension = DriverExtension;
234 DeviceExtension->SessionId = -1;
235 DeviceExtension->AdapterNumber = AdapterNumber;
236 DeviceExtension->DisplayNumber = DisplayNumber;
237
238 InitializeListHead(&DeviceExtension->ChildDeviceList);
239
240 /* Get the registry path associated with this device. */
242 DeviceExtension->AdapterNumber,
243 &DeviceExtension->RegistryPath);
244 if (!NT_SUCCESS(Status))
245 {
246 WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status);
247 goto Failure;
248 }
249
251 {
252 /* Get bus number from the upper level bus driver. */
253 Size = sizeof(ULONG);
256 Size,
257 &DeviceExtension->SystemIoBusNumber,
258 &Size);
259 if (!NT_SUCCESS(Status))
260 {
261 WARN_(VIDEOPRT, "Couldn't get an information from bus driver. We will try to\n"
262 "use legacy detection method, but even that doesn't mean that\n"
263 "it will work.\n");
264 DeviceExtension->PhysicalDeviceObject = NULL;
265 }
266 }
267
268 DeviceExtension->AdapterInterfaceType =
269 DriverExtension->InitializationData.AdapterInterfaceType;
270
272 {
273 /* Get bus type from the upper level bus driver. */
274 Size = sizeof(ULONG);
277 Size,
278 &DeviceExtension->AdapterInterfaceType,
279 &Size);
280
281 /* Get bus device address from the upper level bus driver. */
282 Size = sizeof(ULONG);
285 Size,
286 &PciSlotNumber,
287 &Size);
288
289 /* Convert slotnumber to PCI_SLOT_NUMBER */
290 SlotNumber.u.AsULONG = 0;
291 SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
292 SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
293 DeviceExtension->SystemIoSlotNumber = SlotNumber.u.AsULONG;
294 }
295
297 InitializeListHead(&DeviceExtension->DmaAdapterList);
298
299 KeInitializeDpc(&DeviceExtension->DpcObject,
301 DeviceExtension);
302
303 KeInitializeMutex(&DeviceExtension->DeviceLock, 0);
304
305 /* Attach the device. */
306 if ((PhysicalDeviceObject != NULL) && (DisplayNumber == 0))
310
311 Status = IntCreateNewRegistryPath(DeviceExtension);
312 if (!NT_SUCCESS(Status))
313 {
314 ERR_(VIDEOPRT, "IntCreateNewRegistryPath() failed with status 0x%08x\n", Status);
315 goto Failure;
316 }
317
318 IntSetupDeviceSettingsKey(DeviceExtension);
319
320 /* Remove the initailizing flag */
321 (*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
322
323 /* Set up the VIDEO/DEVICEMAP registry keys */
324 Status = IntVideoPortAddDeviceMapLink(DeviceExtension);
325 if (!NT_SUCCESS(Status))
326 {
327 ERR_(VIDEOPRT, "IntVideoPortAddDeviceMapLink() failed with status 0x%08x\n", Status);
328 goto Failure;
329 }
330
331 if (DisplayNumber == 0)
332 {
333 DriverExtension->InitializationData.StartingDeviceNumber++;
334 }
335
336 return STATUS_SUCCESS;
337
338Failure:
339 if (DeviceExtension->NextDeviceObject)
340 IoDetachDevice(DeviceExtension->NextDeviceObject);
343 return Status;
344}
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1952
#define FILE_DEVICE_VIDEO
Definition: winioctl.h:141
#define INFO_(ch,...)
Definition: debug.h:159
#define WARN_(ch,...)
Definition: debug.h:157
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:87
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:98
LIST_ENTRY AddressMappingListHead
Definition: videoprt.h:101
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:84
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:86
PDEVICE_OBJECT FunctionalDeviceObject
Definition: videoprt.h:88
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
VOID NTAPI IntVideoPortDeferredRoutine(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: videoprt.c:146
static NTSTATUS IntVideoPortAddDeviceMapLink(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: videoprt.c:59
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
struct _VIDEO_PORT_DEVICE_EXTENSTION VIDEO_PORT_DEVICE_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:68
NTSTATUS NTAPI IntCreateRegistryPath(IN PCUNICODE_STRING DriverRegistryPath, IN ULONG DeviceNumber, OUT PUNICODE_STRING DeviceRegistryPath)
Definition: registry.c:601
NTSTATUS NTAPI IntCreateNewRegistryPath(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:407
NTSTATUS NTAPI IntSetupDeviceSettingsKey(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:297
@ DevicePropertyAddress
Definition: iotypes.h:1211
@ DevicePropertyBusNumber
Definition: iotypes.h:1209
@ DevicePropertyLegacyBusType
Definition: iotypes.h:1208

Referenced by IntVideoPortAddDevice(), VideoPortCreateSecondaryDisplay(), and VideoPortInitialize().

◆ IntVideoPortDeferredRoutine()

VOID NTAPI IntVideoPortDeferredRoutine ( IN PKDPC  Dpc,
IN PVOID  DeferredContext,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2 
)

Definition at line 146 of file videoprt.c.

151{
152 PVOID HwDeviceExtension =
153 &((PVIDEO_PORT_DEVICE_EXTENSION)DeferredContext)->MiniPortDeviceExtension;
155}
VOID(NTAPI * PMINIPORT_DPC_ROUTINE)(IN PVOID HwDeviceExtension, IN PVOID Context)
Definition: video.h:518
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:676
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:677

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntVideoPortEnumerateChildren()

NTSTATUS NTAPI IntVideoPortEnumerateChildren ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 1203 of file videoprt.c.

1206{
1207 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1208 ULONG Status;
1209 VIDEO_CHILD_ENUM_INFO ChildEnumInfo;
1210 BOOLEAN bHaveLastMonitorID = FALSE;
1211 UCHAR LastMonitorID[10];
1212 ULONG Unused;
1213 UINT i;
1214 PDEVICE_OBJECT ChildDeviceObject;
1215 PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
1216
1217 INFO_(VIDEOPRT, "Starting child device probe\n");
1218 DeviceExtension = DeviceObject->DeviceExtension;
1220 {
1221 WARN_(VIDEOPRT, "Miniport's HwGetVideoChildDescriptor is NULL!\n");
1222 return STATUS_SUCCESS;
1223 }
1224
1225 if (!IsListEmpty(&DeviceExtension->ChildDeviceList))
1226 {
1227 ERR_(VIDEOPRT, "FIXME: Support calling VideoPortEnumerateChildren again!\n");
1228 return STATUS_SUCCESS;
1229 }
1230
1231 /* Enumerate the children */
1232 for (i = 1; ; i++)
1233 {
1234 Status = IoCreateDevice(DeviceExtension->DriverObject,
1237 NULL,
1240 FALSE,
1241 &ChildDeviceObject);
1242 if (!NT_SUCCESS(Status))
1243 return Status;
1244
1245 ChildExtension = ChildDeviceObject->DeviceExtension;
1246
1247 RtlZeroMemory(ChildExtension,
1250
1251 ChildExtension->Common.Fdo = FALSE;
1252 ChildExtension->ChildId = i;
1253 ChildExtension->PhysicalDeviceObject = ChildDeviceObject;
1254 ChildExtension->DriverObject = DeviceExtension->DriverObject;
1255
1256 /* Setup the ChildEnumInfo */
1257 ChildEnumInfo.Size = sizeof(ChildEnumInfo);
1258 ChildEnumInfo.ChildDescriptorSize = sizeof(ChildExtension->ChildDescriptor);
1259 ChildEnumInfo.ACPIHwId = 0;
1260
1262 ChildEnumInfo.ChildHwDeviceExtension = VIDEO_PORT_GET_CHILD_EXTENSION(ChildExtension);
1263 else
1264 ChildEnumInfo.ChildHwDeviceExtension = NULL;
1265
1266 ChildEnumInfo.ChildIndex = ChildExtension->ChildId;
1267
1268 INFO_(VIDEOPRT, "Probing child: %d\n", ChildEnumInfo.ChildIndex);
1270 DeviceExtension->MiniPortDeviceExtension,
1271 &ChildEnumInfo,
1272 &ChildExtension->ChildType,
1273 ChildExtension->ChildDescriptor,
1274 &ChildExtension->ChildId,
1275 &Unused);
1277 {
1278 if (ChildExtension->ChildType == Monitor)
1279 {
1280 // Check if the EDID is valid
1281 if (ChildExtension->ChildDescriptor[0] == 0x00 &&
1282 ChildExtension->ChildDescriptor[1] == 0xFF &&
1283 ChildExtension->ChildDescriptor[2] == 0xFF &&
1284 ChildExtension->ChildDescriptor[3] == 0xFF &&
1285 ChildExtension->ChildDescriptor[4] == 0xFF &&
1286 ChildExtension->ChildDescriptor[5] == 0xFF &&
1287 ChildExtension->ChildDescriptor[6] == 0xFF &&
1288 ChildExtension->ChildDescriptor[7] == 0x00)
1289 {
1290 if (bHaveLastMonitorID)
1291 {
1292 // Compare the previous monitor ID with the current one, break the loop if they are identical
1293 if (RtlCompareMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID)) == sizeof(LastMonitorID))
1294 {
1295 INFO_(VIDEOPRT, "Found identical Monitor ID two times, stopping enumeration\n");
1296 IoDeleteDevice(ChildDeviceObject);
1297 break;
1298 }
1299 }
1300
1301 // Copy 10 bytes from the EDID, which can be used to uniquely identify the monitor
1302 RtlCopyMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID));
1303 bHaveLastMonitorID = TRUE;
1304
1305 /* Mark it valid */
1306 ChildExtension->EdidValid = TRUE;
1307 }
1308 else
1309 {
1310 /* Mark it invalid */
1311 ChildExtension->EdidValid = FALSE;
1312 }
1313 }
1314 }
1316 {
1317 WARN_(VIDEOPRT, "Child device %d is invalid!\n", ChildEnumInfo.ChildIndex);
1318 IoDeleteDevice(ChildDeviceObject);
1319 continue;
1320 }
1322 {
1323 INFO_(VIDEOPRT, "End of child enumeration! (%d children enumerated)\n", i - 1);
1324 IoDeleteDevice(ChildDeviceObject);
1325 break;
1326 }
1327 else
1328 {
1329 WARN_(VIDEOPRT, "HwGetVideoChildDescriptor returned unknown status code 0x%x!\n", Status);
1330 IoDeleteDevice(ChildDeviceObject);
1331 break;
1332 }
1333
1334 if (ChildExtension->ChildType == Monitor)
1335 {
1336 UINT j;
1337 PUCHAR p = ChildExtension->ChildDescriptor;
1338 INFO_(VIDEOPRT, "Monitor device enumerated! (ChildId = 0x%x)\n", ChildExtension->ChildId);
1339 for (j = 0; j < sizeof (ChildExtension->ChildDescriptor); j += 8)
1340 {
1341 INFO_(VIDEOPRT, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
1342 p[j + 0], p[j + 1], p[j + 2], p[j + 3],
1343 p[j + 4], p[j + 5], p[j + 6], p[j + 7]);
1344 }
1345 }
1346 else if (ChildExtension->ChildType == Other)
1347 {
1348 INFO_(VIDEOPRT, "\"Other\" device enumerated: DeviceId = %S\n", (PWSTR)ChildExtension->ChildDescriptor);
1349 }
1350 else
1351 {
1352 ERR_(VIDEOPRT, "HwGetVideoChildDescriptor returned unsupported type: %d\n", ChildExtension->ChildType);
1353 }
1354
1355 /* Clear the init flag */
1356 ChildDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
1357
1358 InsertTailList(&DeviceExtension->ChildDeviceList,
1359 &ChildExtension->ListEntry);
1360 }
1361
1362 return STATUS_SUCCESS;
1363}
unsigned char BOOLEAN
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define FALSE
Definition: types.h:117
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define Unused(x)
Definition: atlwin.h:28
unsigned int UINT
Definition: ndis.h:50
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:110
#define VIDEO_ENUM_INVALID_DEVICE
Definition: video.h:141
#define VIDEO_ENUM_NO_MORE_DEVICES
Definition: video.h:140
@ Monitor
Definition: video.h:270
@ Other
Definition: video.h:273
#define VIDEO_ENUM_MORE_DEVICES
Definition: video.h:139
PVOID DeviceExtension
Definition: env_spec_w32.h:418
ULONG ChildDescriptorSize
Definition: video.h:262
PVOID ChildHwDeviceExtension
Definition: video.h:265
PVIDEO_HW_GET_CHILD_DESCRIPTOR HwGetVideoChildDescriptor
Definition: video.h:677
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:127
VIDEO_CHILD_TYPE ChildType
Definition: videoprt.h:121
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:126
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:118
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1]
Definition: videoprt.h:113
VIDEO_HW_INITIALIZATION_DATA InitializationData
Definition: videoprt.h:72
uint16_t * PWSTR
Definition: typedefs.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
unsigned char * PUCHAR
Definition: typedefs.h:53
#define VIDEO_PORT_GET_CHILD_EXTENSION(MiniportExtension)
Definition: videoprt.h:134
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by IntVideoPortQueryBusRelations().

◆ IntVideoPortFindAdapter()

NTSTATUS NTAPI IntVideoPortFindAdapter ( IN PDRIVER_OBJECT  DriverObject,
IN PVIDEO_PORT_DRIVER_EXTENSION  DriverExtension,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 349 of file videoprt.c.

353{
354 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
356 VP_STATUS vpStatus;
357 VIDEO_PORT_CONFIG_INFO ConfigInfo;
359 UCHAR Again = FALSE;
360 BOOL LegacyDetection = FALSE;
361
362 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
363
364 /* Setup a ConfigInfo structure that we will pass to HwFindAdapter. */
365 RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO));
366 ConfigInfo.Length = sizeof(VIDEO_PORT_CONFIG_INFO);
367 ConfigInfo.AdapterInterfaceType = DeviceExtension->AdapterInterfaceType;
368 if (ConfigInfo.AdapterInterfaceType == PCIBus)
369 ConfigInfo.InterruptMode = LevelSensitive;
370 else
371 ConfigInfo.InterruptMode = Latched;
372 ConfigInfo.DriverRegistryPath = DriverExtension->RegistryPath.Buffer;
374 ConfigInfo.SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
375 ConfigInfo.BusInterruptLevel = DeviceExtension->InterruptLevel;
376 ConfigInfo.BusInterruptVector = DeviceExtension->InterruptVector;
377
380 sizeof(SystemBasicInfo),
381 NULL);
382 if (NT_SUCCESS(Status))
383 {
386 }
387
388 // FIXME: Check the adapter key and update VideoDebugLevel variable.
389
390 /*
391 * Call miniport HwVidFindAdapter entry point to detect if
392 * particular device is present. There are two possible code
393 * paths. The first one is for Legacy drivers (NT4) and cases
394 * when we don't have information about what bus we're on. The
395 * second case is the standard one for Plug & Play drivers.
396 */
397 if (DeviceExtension->PhysicalDeviceObject == NULL)
398 {
399 LegacyDetection = TRUE;
400 }
401
402 if (LegacyDetection)
403 {
404 ULONG BusNumber, MaxBuses;
405
406 MaxBuses = DeviceExtension->AdapterInterfaceType == PCIBus ? PCI_MAX_BRIDGE_NUMBER : 1;
407
408 for (BusNumber = 0; BusNumber < MaxBuses; BusNumber++)
409 {
410 DeviceExtension->SystemIoBusNumber =
411 ConfigInfo.SystemIoBusNumber = BusNumber;
412
413 RtlZeroMemory(&DeviceExtension->MiniPortDeviceExtension,
414 DriverExtension->InitializationData.HwDeviceExtensionSize);
415
416 /* FIXME: Need to figure out what string to pass as param 3. */
417 vpStatus = DriverExtension->InitializationData.HwFindAdapter(
418 &DeviceExtension->MiniPortDeviceExtension,
419 DriverExtension->HwContext,
420 NULL,
421 &ConfigInfo,
422 &Again);
423
424 if (vpStatus == ERROR_DEV_NOT_EXIST)
425 {
426 continue;
427 }
428 else
429 {
430 break;
431 }
432 }
433 }
434 else
435 {
436 /* FIXME: Need to figure out what string to pass as param 3. */
437 vpStatus = DriverExtension->InitializationData.HwFindAdapter(
438 &DeviceExtension->MiniPortDeviceExtension,
439 DriverExtension->HwContext,
440 NULL,
441 &ConfigInfo,
442 &Again);
443 }
444
445 if (vpStatus != NO_ERROR)
446 {
447 ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", vpStatus);
449 goto Failure;
450 }
451
452 /*
453 * Now we know the device is present, so let's do all additional tasks
454 * such as creating symlinks or setting up interrupts and timer.
455 */
456
457 /* FIXME: Allocate hardware resources for device. */
458
459 /* Allocate interrupt for device. */
461 {
463 goto Failure;
464 }
465
466 /* Allocate timer for device. */
468 {
469 if (DeviceExtension->InterruptObject != NULL)
470 IoDisconnectInterrupt(DeviceExtension->InterruptObject);
471 ERR_(VIDEOPRT, "IntVideoPortSetupTimer failed\n");
473 goto Failure;
474 }
475
476 /* If the device can be reset, insert it in the list of resettable adapters */
477 InitializeListHead(&DeviceExtension->HwResetListEntry);
478 if (DriverExtension->InitializationData.HwResetHw != NULL)
479 {
481 &DeviceExtension->HwResetListEntry,
483 }
484
485 INFO_(VIDEOPRT, "STATUS_SUCCESS\n");
486 return STATUS_SUCCESS;
487
488Failure:
489 RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
490 if (DeviceExtension->NextDeviceObject)
491 IoDetachDevice(DeviceExtension->NextDeviceObject);
493 return Status;
494}
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
#define NO_ERROR
Definition: dderror.h:5
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI NTSTATUS NTAPI ZwQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
@ SystemBasicInformation
Definition: ntddk_ex.h:11
PVOID NTAPI IntVideoPortGetProcAddress(IN PVOID HwDeviceExtension, IN PUCHAR FunctionName)
Definition: funclist.c:100
@ PCIBus
Definition: hwresource.cpp:142
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:140
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
@ Latched
Definition: miniport.h:81
@ LevelSensitive
Definition: miniport.h:80
LONG VP_STATUS
Definition: video.h:153
struct _VIDEO_PORT_CONFIG_INFO VIDEO_PORT_CONFIG_INFO
KINTERRUPT_MODE InterruptMode
Definition: video.h:172
INTERFACE_TYPE AdapterInterfaceType
Definition: video.h:169
PVIDEO_PORT_GET_PROC_ADDRESS VideoPortGetProcAddress
Definition: video.h:193
ULONG BusInterruptVector
Definition: video.h:171
ULONGLONG SystemMemorySize
Definition: video.h:195
PWSTR DriverRegistryPath
Definition: video.h:194
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
KSPIN_LOCK HwResetAdaptersLock
Definition: videoprt.c:43
LIST_ENTRY HwResetAdaptersList
BOOLEAN NTAPI IntVideoPortSetupInterrupt(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PVIDEO_PORT_CONFIG_INFO ConfigInfo)
Definition: interrupt.c:45
BOOLEAN NTAPI IntVideoPortSetupTimer(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension)
Definition: timer.c:43
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160
#define PCI_MAX_BRIDGE_NUMBER
Definition: iotypes.h:3600

Referenced by IntVideoPortPnPStartDevice(), and VideoPortInitialize().

◆ IntVideoPortImageDirectoryEntryToData()

PVOID NTAPI IntVideoPortImageDirectoryEntryToData ( PVOID  BaseAddress,
ULONG  Directory 
)

Definition at line 123 of file videoprt.c.

126{
127 PIMAGE_NT_HEADERS NtHeader;
128 ULONG Va;
129
130 NtHeader = RtlImageNtHeader(BaseAddress);
131 if (NtHeader == NULL)
132 return NULL;
133
135 return NULL;
136
138 if (Va == 0)
139 return NULL;
140
141 return (PVOID)((ULONG_PTR)BaseAddress + Va);
142}
#define RtlImageNtHeader
Definition: compat.h:806
#define ULONG_PTR
Definition: config.h:101
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
base for all directory entries
Definition: entries.h:138
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178

◆ QueryRegistryCallback()

static NTSTATUS NTAPI QueryRegistryCallback ( IN PWSTR  ValueName,
IN ULONG  ValueType,
IN PVOID  ValueData,
IN ULONG  ValueLength,
IN PVOID  Context,
IN PVOID  EntryContext 
)
static

Definition at line 927 of file videoprt.c.

934{
936
937 INFO_(VIDEOPRT, "Found registry value for name %S: type %d, length %d\n",
939 return (*(CallbackContext->HwGetRegistryRoutine))(
940 CallbackContext->HwDeviceExtension,
941 CallbackContext->HwContext,
942 ValueName,
943 ValueData,
945}
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:312
struct QueryRegistryCallbackContext * PQUERY_REGISTRY_CALLBACK_CONTEXT
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
Definition: wdfregistry.h:282
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:275
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR _In_ ULONGLONG _In_ ULONGLONG _In_opt_ PEVENT_FILTER_DESCRIPTOR _Inout_opt_ PVOID CallbackContext
Definition: wmitypes.h:60

Referenced by VideoPortGetRegistryParameters().

◆ RTL_STATIC_LIST_HEAD()

RTL_STATIC_LIST_HEAD ( HwResetAdaptersList  )

◆ VideoPortAcquireDeviceLock()

VOID NTAPI VideoPortAcquireDeviceLock ( IN PVOID  HwDeviceExtension)

Definition at line 1603 of file videoprt.c.

1605{
1606 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1607
1608 TRACE_(VIDEOPRT, "VideoPortAcquireDeviceLock\n");
1609 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1611 // ASSERT(Status == STATUS_SUCCESS);
1612}
#define TRACE_(x)
Definition: compat.h:76
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension)
Definition: videoprt.h:140
#define KeWaitForMutexObject
Definition: kefuncs.h:557
@ Executive
Definition: ketypes.h:403

◆ VideoPortAllocateContiguousMemory()

PVOID NTAPI VideoPortAllocateContiguousMemory ( IN PVOID  HwDeviceExtension,
IN ULONG  NumberOfBytes,
IN PHYSICAL_ADDRESS  HighestAcceptableAddress 
)

Definition at line 1647 of file videoprt.c.

1652{
1654}
PVOID NTAPI MmAllocateContiguousMemory(IN SIZE_T NumberOfBytes, IN PHYSICAL_ADDRESS HighestAcceptableAddress)
Definition: contmem.c:626
_Out_ PNDIS_HANDLE _Out_ PUINT _In_ PNDIS_STRING _In_ NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress
Definition: ndis.h:3230
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036

◆ VideoPortCheckForDeviceExistence()

BOOLEAN NTAPI VideoPortCheckForDeviceExistence ( IN PVOID  HwDeviceExtension,
IN USHORT  VendorId,
IN USHORT  DeviceId,
IN UCHAR  RevisionId,
IN USHORT  SubVendorId,
IN USHORT  SubSystemId,
IN ULONG  Flags 
)

Definition at line 1511 of file videoprt.c.

1519{
1520 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1523 IO_STACK_LOCATION IoStack;
1524 ULONG PciFlags = 0;
1526 BOOL DevicePresent;
1527
1528 TRACE_(VIDEOPRT, "VideoPortCheckForDeviceExistence\n");
1529
1531 {
1532 WARN_(VIDEOPRT, "VideoPortCheckForDeviceExistence: Unknown flags 0x%lx\n", Flags & ~(CDE_USE_REVISION | CDE_USE_SUBSYSTEM_IDS));
1533 return FALSE;
1534 }
1535
1536 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1537
1539 PciDevicePresentInterface.Version = 1;
1541 IoStack.Parameters.QueryInterface.Version = PciDevicePresentInterface.Version;
1543 IoStack.Parameters.QueryInterface.InterfaceType =
1544 &GUID_PCI_DEVICE_PRESENT_INTERFACE;
1545 Status = IopInitiatePnpIrp(DeviceExtension->NextDeviceObject,
1547 if (!NT_SUCCESS(Status))
1548 {
1549 WARN_(VIDEOPRT, "IopInitiatePnpIrp() failed! (Status 0x%lx)\n", Status);
1550 return FALSE;
1551 }
1552
1553 if (Flags & CDE_USE_REVISION)
1554 PciFlags |= PCI_USE_REVISION;
1556 PciFlags |= PCI_USE_SUBSYSTEM_IDS;
1557
1558 DevicePresent = PciDevicePresentInterface.IsDevicePresent(
1559 VendorId, DeviceId, RevisionId,
1560 SubVendorId, SubSystemId, PciFlags);
1561
1562 PciDevicePresentInterface.InterfaceDereference(PciDevicePresentInterface.Context);
1563
1564 return DevicePresent;
1565}
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
PCI_INTERFACE PciDevicePresentInterface
Definition: devhere.c:18
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSTATUS NTAPI IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject, IN PIO_STATUS_BLOCK IoStatusBlock, IN UCHAR MinorFunction, IN PIO_STACK_LOCATION Stack)
struct _INTERFACE * PINTERFACE
#define CDE_USE_REVISION
Definition: video.h:147
#define CDE_USE_SUBSYSTEM_IDS
Definition: video.h:146
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define IRP_MN_QUERY_INTERFACE
struct _PCI_DEVICE_PRESENT_INTERFACE PCI_DEVICE_PRESENT_INTERFACE
#define PCI_USE_REVISION
Definition: iotypes.h:867
#define PCI_USE_SUBSYSTEM_IDS
Definition: iotypes.h:866

◆ VideoPortCreateSecondaryDisplay()

VP_STATUS NTAPI VideoPortCreateSecondaryDisplay ( IN PVOID  HwDeviceExtension,
IN OUT PVOID SecondaryDeviceExtension,
IN ULONG  Flag 
)

Definition at line 1390 of file videoprt.c.

1394{
1396 PVIDEO_PORT_DEVICE_EXTENSION FirstDeviceExtension, DeviceExtension;
1398
1399 ASSERT(SecondaryDeviceExtension);
1400
1401 if (Flag != 0)
1402 {
1404 }
1405
1406 FirstDeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1407
1408 if (FirstDeviceExtension->DisplayNumber != 0)
1409 {
1410 DPRINT1("Calling VideoPortCreateSecondaryDisplay for InstanceId %lu\n",
1411 FirstDeviceExtension->DisplayNumber);
1412 }
1413
1415 FirstDeviceExtension->DriverExtension,
1416 FirstDeviceExtension->PhysicalDeviceObject,
1417 FirstDeviceExtension->AdapterNumber,
1418 FirstDeviceExtension->NumberOfSecondaryDisplays + 1,
1419 &DeviceObject);
1420 if (!NT_SUCCESS(Status))
1421 {
1422 DPRINT1("IntVideoPortCreateAdapterDeviceObject() failed with status 0x%08x\n", Status);
1423 return ERROR_DEV_NOT_EXIST;
1424 }
1425
1426 DeviceExtension = DeviceObject->DeviceExtension;
1427
1428 /* Increment secondary display count */
1429 FirstDeviceExtension->NumberOfSecondaryDisplays++;
1430
1431 *SecondaryDeviceExtension = DeviceExtension->MiniPortDeviceExtension;
1432 return NO_ERROR;
1433}
#define DPRINT1
Definition: precomp.h:8
#define UNIMPLEMENTED
Definition: debug.h:115
#define ASSERT(a)
Definition: mode.c:44
Definition: xml2sdb.h:80
NTSTATUS NTAPI IntVideoPortCreateAdapterDeviceObject(_In_ PDRIVER_OBJECT DriverObject, _In_ PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, _In_opt_ PDEVICE_OBJECT PhysicalDeviceObject, _In_ USHORT AdapterNumber, _In_ USHORT DisplayNumber, _Out_opt_ PDEVICE_OBJECT *DeviceObject)
Definition: videoprt.c:159

◆ VideoPortDebugPrint()

VOID VideoPortDebugPrint ( IN VIDEO_DEBUG_LEVEL  DebugPrintLevel,
IN PCHAR  DebugMessage,
  ... 
)

Definition at line 873 of file videoprt.c.

877{
878 va_list ap;
879
880 if (VideoDebugLevel >= DebugPrintLevel)
881 DebugPrintLevel = Error;
882
883 va_start(ap, DebugMessage);
884 vDbgPrintEx(DPFLTR_IHVVIDEO_ID, DebugPrintLevel, DebugMessage, ap);
885 va_end(ap);
886}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
@ DPFLTR_IHVVIDEO_ID
Definition: dpfilter.h:106
ULONG VideoDebugLevel
Definition: videoprt.c:34
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

Referenced by IntLoadRegistryParameters().

◆ VideoPortEnumerateChildren()

VP_STATUS NTAPI VideoPortEnumerateChildren ( IN PVOID  HwDeviceExtension,
IN PVOID  Reserved 
)

Definition at line 1367 of file videoprt.c.

1370{
1371 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1372
1373 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1374 ASSERT(DeviceExtension);
1375
1376 if (DeviceExtension->PhysicalDeviceObject)
1377 {
1378 /* Trigger reenumeration by the PnP manager */
1380 }
1381
1382 return NO_ERROR;
1383}
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:2342
@ BusRelations
Definition: iotypes.h:2152

Referenced by IntVideoPortDispatchOpen(), and VBEInitialize().

◆ VideoPortGetAssociatedDeviceExtension()

PVOID NTAPI VideoPortGetAssociatedDeviceExtension ( IN PVOID  DeviceObject)

Definition at line 1456 of file videoprt.c.

1458{
1459 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1460
1461 TRACE_(VIDEOPRT, "VideoPortGetAssociatedDeviceExtension\n");
1462 DeviceExtension = ((PDEVICE_OBJECT)DeviceObject)->DeviceExtension;
1463 if (!DeviceExtension)
1464 return NULL;
1465 return DeviceExtension->MiniPortDeviceExtension;
1466}
struct _DEVICE_OBJECT * PDEVICE_OBJECT

◆ VideoPortGetCurrentIrql()

UCHAR NTAPI VideoPortGetCurrentIrql ( VOID  )

Definition at line 912 of file videoprt.c.

913{
914 return KeGetCurrentIrql();
915}
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706

◆ VideoPortGetRegistryParameters()

VP_STATUS NTAPI VideoPortGetRegistryParameters ( IN PVOID  HwDeviceExtension,
IN PWSTR  ParameterName,
IN UCHAR  IsParameterFileName,
IN PMINIPORT_GET_REGISTRY_ROUTINE  GetRegistryRoutine,
IN PVOID  HwContext 
)

Definition at line 953 of file videoprt.c.

959{
962 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
964
965 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
966
967 TRACE_(VIDEOPRT, "VideoPortGetRegistryParameters ParameterName %S, RegPath: %wZ\n",
968 ParameterName, &DeviceExtension->RegistryPath);
969
970 Context.HwDeviceExtension = HwDeviceExtension;
971 Context.HwContext = HwContext;
972 Context.HwGetRegistryRoutine = GetRegistryRoutine;
973
977
979 DeviceExtension->RegistryPath.Buffer,
981 &Context,
982 NULL);
983 if (!NT_SUCCESS(Status))
984 {
985 WARN_(VIDEOPRT, "VideoPortGetRegistryParameters could not find the "
986 "requested parameter\n");
988 }
989
990 if (IsParameterFileName)
991 {
992 /* FIXME: need to read the contents of the file */
994 }
995
996 return NO_ERROR;
997}
_In_opt_ PWSTR _In_ PWSTR ParameterName
Definition: cdrom.h:961
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:4197
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
#define RTL_QUERY_REGISTRY_REQUIRED
Definition: nt_native.h:132
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA _In_ PVOID HwContext
Definition: srb.h:898
PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine
Definition: nt_native.h:109
static NTSTATUS NTAPI QueryRegistryCallback(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: videoprt.c:927

◆ VideoPortGetRomImage()

PVOID NTAPI VideoPortGetRomImage ( IN PVOID  HwDeviceExtension,
IN PVOID  Unused1,
IN ULONG  Unused2,
IN ULONG  Length 
)

Definition at line 1063 of file videoprt.c.

1068{
1069 static PVOID RomImageBuffer = NULL;
1070 PKPROCESS CallingProcess;
1072
1073 TRACE_(VIDEOPRT, "VideoPortGetRomImage(HwDeviceExtension 0x%X Length 0x%X)\n",
1074 HwDeviceExtension, Length);
1075
1076 /* If the length is zero then free the existing buffer. */
1077 if (Length == 0)
1078 {
1079 if (RomImageBuffer != NULL)
1080 {
1081 ExFreePool(RomImageBuffer);
1082 RomImageBuffer = NULL;
1083 }
1084 return NULL;
1085 }
1086 else
1087 {
1088 /*
1089 * The DDK says we shouldn't use the legacy C0000 method but get the
1090 * rom base address from the corresponding pci or acpi register but
1091 * lets ignore that and use C0000 anyway. We have already mapped the
1092 * bios area into memory so we'll copy from there.
1093 */
1094
1095 /* Copy the bios. */
1096 Length = min(Length, 0x10000);
1097 if (RomImageBuffer != NULL)
1098 {
1099 ExFreePool(RomImageBuffer);
1100 }
1101
1102 RomImageBuffer = ExAllocatePool(PagedPool, Length);
1103 if (RomImageBuffer == NULL)
1104 {
1105 return NULL;
1106 }
1107
1108 IntAttachToCSRSS(&CallingProcess, &ApcState);
1109 RtlCopyMemory(RomImageBuffer, (PUCHAR)0xC0000, Length);
1110 IntDetachFromCSRSS(&CallingProcess, &ApcState);
1111
1112 return RomImageBuffer;
1113 }
1114}
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define min(a, b)
Definition: monoChain.cc:55
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:511
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:498
KAPC_STATE
Definition: ketypes.h:1285

◆ VideoPortGetVersion()

VP_STATUS NTAPI VideoPortGetVersion ( IN PVOID  HwDeviceExtension,
IN OUT PVPOSVERSIONINFO  VpOsVersionInfo 
)

Definition at line 1473 of file videoprt.c.

1476{
1478
1479 Version.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
1480 if (VpOsVersionInfo->Size >= sizeof(VPOSVERSIONINFO))
1481 {
1482#if 1
1484 {
1485 VpOsVersionInfo->MajorVersion = Version.dwMajorVersion;
1486 VpOsVersionInfo->MinorVersion = Version.dwMinorVersion;
1487 VpOsVersionInfo->BuildNumber = Version.dwBuildNumber;
1488 VpOsVersionInfo->ServicePackMajor = Version.wServicePackMajor;
1489 VpOsVersionInfo->ServicePackMinor = Version.wServicePackMinor;
1490 return NO_ERROR;
1491 }
1493#else
1494 VpOsVersionInfo->MajorVersion = 5;
1495 VpOsVersionInfo->MinorVersion = 0;
1496 VpOsVersionInfo->BuildNumber = 2195;
1497 VpOsVersionInfo->ServicePackMajor = 4;
1498 VpOsVersionInfo->ServicePackMinor = 0;
1499 return NO_ERROR;
1500#endif
1501 }
1502
1504}
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
struct _OSVERSIONINFOEXW RTL_OSVERSIONINFOEXW

◆ VideoPortGetVgaStatus()

VP_STATUS NTAPI VideoPortGetVgaStatus ( IN PVOID  HwDeviceExtension,
OUT PULONG  VgaStatus 
)

Definition at line 1035 of file videoprt.c.

1038{
1039 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1040
1041 TRACE_(VIDEOPRT, "VideoPortGetVgaStatus\n");
1042
1043 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1045 {
1046 if (DeviceExtension->AdapterInterfaceType == PCIBus)
1047 {
1048 /* VgaStatus: 0 == VGA not enabled, 1 == VGA enabled. */
1049 /* Assumed for now */
1050 *VgaStatus = 1;
1051 return NO_ERROR;
1052 }
1053 }
1054
1056}
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693

◆ VideoPortInitialize()

ULONG NTAPI VideoPortInitialize ( IN PVOID  Context1,
IN PVOID  Context2,
IN PVIDEO_HW_INITIALIZATION_DATA  HwInitializationData,
IN PVOID  HwContext 
)

Definition at line 663 of file videoprt.c.

668{
673 BOOLEAN PnpDriver = FALSE, LegacyDetection = FALSE;
674 static BOOLEAN FirstInitialization;
675
676 TRACE_(VIDEOPRT, "VideoPortInitialize\n");
677
678 if (!FirstInitialization)
679 {
680 FirstInitialization = TRUE;
684 }
685
686 /* As a first thing do parameter checks. */
687 if (HwInitializationData->HwInitDataSize > sizeof(VIDEO_HW_INITIALIZATION_DATA))
688 {
689 ERR_(VIDEOPRT, "Invalid HwInitializationData\n");
691 }
692
693 if ((HwInitializationData->HwFindAdapter == NULL) ||
694 (HwInitializationData->HwInitialize == NULL) ||
695 (HwInitializationData->HwStartIO == NULL))
696 {
697 ERR_(VIDEOPRT, "Invalid HwInitializationData\n");
699 }
700
701 switch (HwInitializationData->HwInitDataSize)
702 {
703 /*
704 * NT4 drivers are special case, because we must use legacy method
705 * of detection instead of the Plug & Play one.
706 */
708 INFO_(VIDEOPRT, "We were loaded by a Windows NT miniport driver.\n");
709 break;
710
712 INFO_(VIDEOPRT, "We were loaded by a Windows 2000 miniport driver.\n");
713 break;
714
715 case sizeof(VIDEO_HW_INITIALIZATION_DATA):
716 INFO_(VIDEOPRT, "We were loaded by a Windows XP or later miniport driver.\n");
717 break;
718
719 default:
720 ERR_(VIDEOPRT, "Invalid HwInitializationData size.\n");
721 return STATUS_UNSUCCESSFUL;
722 }
723
724 /* Set dispatching routines */
727 DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
729 DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] =
731 DriverObject->DriverUnload = IntVideoPortUnload;
732
733 /* Determine type of the miniport driver */
734 if ((HwInitializationData->HwInitDataSize >=
735 FIELD_OFFSET(VIDEO_HW_INITIALIZATION_DATA, HwQueryInterface)) &&
736 (HwInitializationData->HwSetPowerState != NULL) &&
737 (HwInitializationData->HwGetPowerState != NULL) &&
738 (HwInitializationData->HwGetVideoChildDescriptor != NULL))
739 {
740 INFO_(VIDEOPRT, "The miniport is a PnP miniport driver\n");
741 PnpDriver = TRUE;
742 }
743
744 /* Check if legacy detection should be applied */
745 if (!PnpDriver || HwContext)
746 {
747 INFO_(VIDEOPRT, "Legacy detection for adapter interface %d\n",
748 HwInitializationData->AdapterInterfaceType);
749
750 /* FIXME: Move the code for legacy detection
751 to another function and call it here */
752 LegacyDetection = TRUE;
753 }
754
755 /*
756 * NOTE:
757 * The driver extension can be already allocated in case that we were
758 * called by legacy driver and failed detecting device. Some miniport
759 * drivers in that case adjust parameters and call VideoPortInitialize
760 * again.
761 */
763 if (DriverExtension == NULL)
764 {
769 if (!NT_SUCCESS(Status))
770 {
771 ERR_(VIDEOPRT, "IoAllocateDriverObjectExtension failed 0x%x\n", Status);
772 return Status;
773 }
774
775 /*
776 * Save the registry path. This should be done only once even if
777 * VideoPortInitialize is called multiple times.
778 */
779 if (RegistryPath->Length != 0)
780 {
781 DriverExtension->RegistryPath.Length = 0;
782 DriverExtension->RegistryPath.MaximumLength =
783 RegistryPath->Length + sizeof(UNICODE_NULL);
784 DriverExtension->RegistryPath.Buffer =
786 PagedPool,
787 DriverExtension->RegistryPath.MaximumLength,
788 'RTSU');
789 if (DriverExtension->RegistryPath.Buffer == NULL)
790 {
793 }
794
796
797 /* There is a bug in Spice guest agent, which searches 'System' case-sensitively.
798 * Replace 'SYSTEM' by 'System' to fix that.
799 * Probably for similar reason, Windows also replaces 'MACHINE' by 'Machine'.
800 */
801 wcsncpy(wcsstr(DriverExtension->RegistryPath.Buffer, L"\\SYSTEM\\"), L"\\System\\", ARRAYSIZE(L"\\SYSTEM\\") - 1);
802 wcsncpy(wcsstr(DriverExtension->RegistryPath.Buffer, L"\\MACHINE\\"), L"\\Machine\\", ARRAYSIZE(L"\\MACHINE\\") - 1);
803
804 INFO_(VIDEOPRT, "RegistryPath: %wZ\n", &DriverExtension->RegistryPath);
805 }
806 else
807 {
809 }
810 }
811
812 /* Copy the correct miniport initialization data to the device extension. */
813 RtlCopyMemory(&DriverExtension->InitializationData,
815 HwInitializationData->HwInitDataSize);
816 if (HwInitializationData->HwInitDataSize <
818 {
819 RtlZeroMemory((PVOID)((ULONG_PTR)&DriverExtension->InitializationData +
820 HwInitializationData->HwInitDataSize),
822 HwInitializationData->HwInitDataSize);
823 }
824 DriverExtension->HwContext = HwContext;
825
826 /*
827 * Plug & Play drivers registers the device in AddDevice routine.
828 * For legacy drivers we must do it now.
829 */
830 if (LegacyDetection)
831 {
833
835 {
836 /* Power management */
838 }
839
842 NULL,
843 DriverExtension->InitializationData.StartingDeviceNumber,
844 0,
845 &DeviceObject);
846 if (!NT_SUCCESS(Status))
847 {
848 ERR_(VIDEOPRT, "IntVideoPortCreateAdapterDeviceObject returned 0x%x\n", Status);
849 return Status;
850 }
851
853 if (!NT_SUCCESS(Status))
854 ERR_(VIDEOPRT, "IntVideoPortFindAdapter returned 0x%x\n", Status);
855
856 return Status;
857 }
858 else
859 {
860 DriverObject->DriverExtension->AddDevice = IntVideoPortAddDevice;
864
865 return STATUS_SUCCESS;
866 }
867}
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1889
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1811
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:325
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA * HwInitializationData
Definition: srb.h:897
struct _VIDEO_HW_INITIALIZATION_DATA VIDEO_HW_INITIALIZATION_DATA
#define SIZE_OF_NT4_VIDEO_HW_INITIALIZATION_DATA
Definition: video.h:119
#define SIZE_OF_W2K_VIDEO_HW_INITIALIZATION_DATA
Definition: video.h:120
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT Context1
Definition: tdikrnl.h:1095
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT _In_ PTDI_PNP_CONTEXT Context2
Definition: tdikrnl.h:1096
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
VOID FASTCALL IntLoadRegistryParameters(VOID)
Definition: videoprt.c:523
NTSTATUS NTAPI IntVideoPortFindAdapter(IN PDRIVER_OBJECT DriverObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PDEVICE_OBJECT DeviceObject)
Definition: videoprt.c:349
KMUTEX VideoPortInt10Mutex
Definition: videoprt.c:42
NTSTATUS NTAPI IntVideoPortDispatchClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:436
VOID NTAPI IntVideoPortUnload(PDRIVER_OBJECT DriverObject)
Definition: dispatch.c:1197
NTSTATUS NTAPI IntVideoPortDispatchOpen(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:369
NTSTATUS NTAPI IntVideoPortDispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:723
NTSTATUS NTAPI IntVideoPortDispatchSystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1175
NTSTATUS NTAPI IntVideoPortDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1109
NTSTATUS NTAPI IntVideoPortAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: dispatch.c:334
NTSTATUS NTAPI IntVideoPortDispatchPower(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1141
#define IRP_MJ_SYSTEM_CONTROL
#define IRP_MJ_SHUTDOWN
#define IRP_MJ_POWER

Referenced by DriverEntry().

◆ VideoPortIsNoVesa()

BOOLEAN NTAPI VideoPortIsNoVesa ( VOID  )

Definition at line 1661 of file videoprt.c.

1662{
1663 return VpNoVesa;
1664}

Referenced by InitializeModeTable(), VBEFindAdapter(), and VBEInitialize().

◆ VideoPortLogError()

VOID NTAPI VideoPortLogError ( IN PVOID  HwDeviceExtension,
IN PVIDEO_REQUEST_PACKET Vrp  OPTIONAL,
IN VP_STATUS  ErrorCode,
IN ULONG  UniqueId 
)

Definition at line 893 of file videoprt.c.

898{
900
901 INFO_(VIDEOPRT, "VideoPortLogError ErrorCode %d (0x%x) UniqueId %lu (0x%lx)\n",
902 ErrorCode, ErrorCode, UniqueId, UniqueId);
903 if (Vrp)
904 INFO_(VIDEOPRT, "Vrp->IoControlCode %lu (0x%lx)\n", Vrp->IoControlCode, Vrp->IoControlCode);
905}
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436

◆ VideoPortQueryPerformanceCounter()

LONGLONG NTAPI VideoPortQueryPerformanceCounter ( IN PVOID  HwDeviceExtension,
OUT PLONGLONG PerformanceFrequency  OPTIONAL 
)

Definition at line 1587 of file videoprt.c.

1590{
1592
1593 TRACE_(VIDEOPRT, "VideoPortQueryPerformanceCounter\n");
1594 Result = KeQueryPerformanceCounter((PLARGE_INTEGER)PerformanceFrequency);
1595 return Result.QuadPart;
1596}
LARGE_INTEGER NTAPI KeQueryPerformanceCounter(IN PLARGE_INTEGER PerformanceFreq)
Definition: timer.c:138
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426

◆ VideoPortQueueDpc()

BOOLEAN NTAPI VideoPortQueueDpc ( IN PVOID  HwDeviceExtension,
IN PMINIPORT_DPC_ROUTINE  CallbackRoutine,
IN PVOID  Context 
)

Definition at line 1440 of file videoprt.c.

1444{
1445 return KeInsertQueueDpc(
1446 &VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->DpcObject,
1448 (PVOID)Context);
1449}
BOOLEAN NTAPI KeInsertQueueDpc(IN PKDPC Dpc, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: dpc.c:725
_Must_inspect_result_ _In_ PFLT_GET_OPERATION_STATUS_CALLBACK CallbackRoutine
Definition: fltkernel.h:1035
@ DpcObject
Definition: ketypes.h:458

◆ VideoPortRegisterBugcheckCallback()

VP_STATUS NTAPI VideoPortRegisterBugcheckCallback ( IN PVOID  HwDeviceExtension,
IN ULONG  BugcheckCode,
IN PVIDEO_BUGCHECK_CALLBACK  Callback,
IN ULONG  BugcheckDataSize 
)

Definition at line 1572 of file videoprt.c.

1577{
1579 return NO_ERROR;
1580}

◆ VideoPortReleaseDeviceLock()

VOID NTAPI VideoPortReleaseDeviceLock ( IN PVOID  HwDeviceExtension)

Definition at line 1619 of file videoprt.c.

1621{
1622 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1623
1624 TRACE_(VIDEOPRT, "VideoPortReleaseDeviceLock\n");
1625 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1626 KeReleaseMutex(&DeviceExtension->DeviceLock, FALSE);
1627 //ASSERT(Status == STATUS_SUCCESS);
1628}
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189

◆ VideoPortScanRom()

BOOLEAN NTAPI VideoPortScanRom ( IN PVOID  HwDeviceExtension,
IN PUCHAR  RomBase,
IN ULONG  RomLength,
IN PUCHAR  String 
)

Definition at line 1121 of file videoprt.c.

1126{
1127 SIZE_T StringLength;
1128 BOOLEAN Found;
1129 PUCHAR SearchLocation;
1130
1131 TRACE_(VIDEOPRT, "VideoPortScanRom RomBase %p RomLength 0x%x String %s\n", RomBase, RomLength, String);
1132
1133 StringLength = strlen((PCHAR)String);
1134 Found = FALSE;
1135 for (SearchLocation = RomBase;
1136 !Found && SearchLocation < RomBase + RomLength - StringLength;
1137 SearchLocation++)
1138 {
1139 Found = (RtlCompareMemory(SearchLocation, String, StringLength) == StringLength);
1140 if (Found)
1141 {
1142 INFO_(VIDEOPRT, "Match found at %p\n", SearchLocation);
1143 }
1144 }
1145
1146 return Found;
1147}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
return Found
Definition: dirsup.c:1270
ULONG_PTR SIZE_T
Definition: typedefs.h:80
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

◆ VideoPortSetRegistryParameters()

VP_STATUS NTAPI VideoPortSetRegistryParameters ( IN PVOID  HwDeviceExtension,
IN PWSTR  ValueName,
IN PVOID  ValueData,
IN ULONG  ValueLength 
)

Definition at line 1004 of file videoprt.c.

1009{
1010 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1012
1013 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1014 TRACE_(VIDEOPRT, "VideoPortSetRegistryParameters ParameterName %S, RegPath: %wZ\n",
1015 ValueName,
1016 &DeviceExtension->RegistryPath);
1019 DeviceExtension->RegistryPath.Buffer,
1020 ValueName,
1021 REG_BINARY,
1022 ValueData,
1023 ValueLength);
1024 if (Status != NO_ERROR)
1025 WARN_(VIDEOPRT, "VideoPortSetRegistryParameters error 0x%x\n", Status);
1026
1027 return Status;
1028}
#define REG_BINARY
Definition: nt_native.h:1496
#define ASSERT_IRQL_LESS_OR_EQUAL(x)
Definition: debug.h:251

Referenced by BochsGetControllerInfo(), Pc98VidFindAdapter(), and VmxFindAdapter().

◆ VideoPortSynchronizeExecution()

BOOLEAN NTAPI VideoPortSynchronizeExecution ( IN PVOID  HwDeviceExtension,
IN VIDEO_SYNCHRONIZE_PRIORITY  Priority,
IN PMINIPORT_SYNCHRONIZE_ROUTINE  SynchronizeRoutine,
OUT PVOID  Context 
)

Definition at line 1154 of file videoprt.c.

1159{
1160 BOOLEAN Ret;
1161 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1162 KIRQL OldIrql;
1163
1164 switch (Priority)
1165 {
1166 case VpLowPriority:
1167 Ret = (*SynchronizeRoutine)(Context);
1168 break;
1169
1170 case VpMediumPriority:
1171 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1172 if (DeviceExtension->InterruptObject == NULL)
1173 Ret = (*SynchronizeRoutine)(Context);
1174 else
1176 DeviceExtension->InterruptObject,
1178 Context);
1179 break;
1180
1181 case VpHighPriority:
1183 if (OldIrql < SYNCH_LEVEL)
1185
1186 Ret = (*SynchronizeRoutine)(Context);
1187
1188 if (OldIrql < SYNCH_LEVEL)
1190 break;
1191
1192 default:
1193 Ret = FALSE;
1194 }
1195
1196 return Ret;
1197}
static KSYNCHRONIZE_ROUTINE SynchronizeRoutine
Definition: IoInterrupt.c:30
#define SYNCH_LEVEL
Definition: env_spec_w32.h:704
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
BOOLEAN NTAPI KeSynchronizeExecution(IN OUT PKINTERRUPT Interrupt, IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, IN PVOID SynchronizeContext OPTIONAL)
Definition: interrupt.c:231
@ VpMediumPriority
Definition: video.h:536
@ VpLowPriority
Definition: video.h:535
@ VpHighPriority
Definition: video.h:537
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:655
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792

◆ VpNotifyEaData()

VOID NTAPI VpNotifyEaData ( IN PDEVICE_OBJECT  DeviceObject,
IN PVOID  Data 
)

Definition at line 1635 of file videoprt.c.

1638{
1640}

Variable Documentation

◆ CsrProcess

◆ HwResetAdaptersLock

KSPIN_LOCK HwResetAdaptersLock

◆ VideoDebugLevel

ULONG VideoDebugLevel = 0

Definition at line 34 of file videoprt.c.

Referenced by VideoPortDebugPrint().

◆ VideoPortInt10Mutex

KMUTEX VideoPortInt10Mutex

Definition at line 42 of file videoprt.c.

Referenced by IntInt10CallBios(), and VideoPortInitialize().

◆ VideoPortMaxObjectNumber

ULONG VideoPortMaxObjectNumber = -1
static

◆ VideoPortUseNewKey

BOOLEAN VideoPortUseNewKey = FALSE

◆ VpBaseVideo

BOOLEAN VpBaseVideo = FALSE

Definition at line 36 of file videoprt.c.

Referenced by IntLoadRegistryParameters().

◆ VpNoVesa

BOOLEAN VpNoVesa = FALSE

Definition at line 37 of file videoprt.c.

Referenced by IntLoadRegistryParameters(), and VideoPortIsNoVesa().