ReactOS 0.4.16-dev-2354-g16de117
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)
 
static BOOLEAN IntIsVgaSaveDriver (_In_ PDRIVER_OBJECT DriverObject)
 
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)
 
static NTSTATUS NTAPI IntVideoPortEnumBusCallback (_In_ PVOID Context, _In_ PUNICODE_STRING PathName, _In_ INTERFACE_TYPE BusType, _In_ ULONG BusNumber, _In_ PKEY_VALUE_FULL_INFORMATION *BusInformation, _In_ CONFIGURATION_TYPE ControllerType, _In_ ULONG ControllerNumber, _In_ PKEY_VALUE_FULL_INFORMATION *ControllerInformation, _In_ CONFIGURATION_TYPE PeripheralType, _In_ ULONG PeripheralNumber, _In_ PKEY_VALUE_FULL_INFORMATION *PeripheralInformation)
 A PIO_QUERY_DEVICE_ROUTINE callback for IoQueryDeviceDescription() to return success when an enumerated bus has been found.
 
static NTSTATUS IntVideoPortEnumBuses (_In_ INTERFACE_TYPE AdapterInterfaceType, _Inout_ PULONG BusNumber)
 Enumerates all supported buses on the system.
 
NTSTATUS NTAPI IntVideoPortFindAdapter (IN PDRIVER_OBJECT DriverObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN FASTCALL IntAttachToCSRSS (_Outptr_ PKPROCESS *CallingProcess, _Out_ PKAPC_STATE ApcState)
 Attach the current thread to the CSRSS process. The caller must detach from the process by invoking IntDetachFromCSRSS() after operating in its context.
 
VOID FASTCALL IntDetachFromCSRSS (_In_ PKPROCESS CallingProcess, _In_ PKAPC_STATE ApcState)
 Detach the current thread from the CSRSS process. This routine is to be invoked after a previous successful IntAttachToCSRSS() call.
 
VOID FASTCALL IntLoadRegistryParameters (VOID)
 
ULONG NTAPI VideoPortInitialize (IN PVOID Context1, IN PVOID Context2, IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData, IN PVOID HwContext)
 
VOID __cdecl VideoPortDebugPrint (_In_ VIDEO_DEBUG_LEVEL DebugPrintLevel, _In_ PSTR DebugMessage, _In_ ...)
 
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
 
KSPIN_LOCK HwResetAdaptersLock
 
KMUTEX VgaSyncLock
 
PVIDEO_PORT_DEVICE_EXTENSION VgaDeviceExtension = NULL
 
PVIDEO_ACCESS_RANGE VgaRanges = NULL
 
ULONG NumOfVgaRanges = 0
 

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 62 of file videoprt.c.

65{
66 return STATUS_SUCCESS;
67}
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ IntAttachToCSRSS()

BOOLEAN FASTCALL IntAttachToCSRSS ( _Outptr_ PKPROCESS CallingProcess,
_Out_ PKAPC_STATE  ApcState 
)

Attach the current thread to the CSRSS process. The caller must detach from the process by invoking IntDetachFromCSRSS() after operating in its context.

Parameters
[out]CallingProcessPointer to a PKPROCESS variable that receives the current process.
[out]ApcStatePointer to a caller-provided KAPC_STATE structure that will be initialized.
Returns
TRUE if attachment succeeded (the CSRSS process exists); FALSE if not.

Definition at line 736 of file videoprt.c.

739{
740 if (!CsrProcess)
741 return FALSE;
742
743 *CallingProcess = (PKPROCESS)PsGetCurrentProcess();
744 if (*CallingProcess != CsrProcess)
746 return TRUE;
747}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1769
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 VideoPortGetRomImage().

◆ IntDetachFromCSRSS()

VOID FASTCALL IntDetachFromCSRSS ( _In_ PKPROCESS  CallingProcess,
_In_ PKAPC_STATE  ApcState 
)

Detach the current thread from the CSRSS process. This routine is to be invoked after a previous successful IntAttachToCSRSS() call.

Parameters
[in]CallingProcessThe calling process that previously invoked IntAttachToCSRSS().
[in]ApcStatePointer to the KAPC_STATE structure that was initialized by a previous IntAttachToCSRSS() call.

Definition at line 763 of file videoprt.c.

766{
768 if (CallingProcess != CsrProcess)
770}
#define ASSERT(a)
Definition: mode.c:44
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756

Referenced by VideoPortGetRomImage().

◆ IntIsVgaSaveDriver()

static BOOLEAN IntIsVgaSaveDriver ( _In_ PDRIVER_OBJECT  DriverObject)
static

Definition at line 53 of file videoprt.c.

55{
56 static const UNICODE_STRING VgaSave = RTL_CONSTANT_STRING(L"\\Driver\\VgaSave");
57 return RtlEqualUnicodeString(&VgaSave, &DriverObject->DriverName, TRUE);
58}
#define RTL_CONSTANT_STRING(s)
Definition: combase.c:35
#define L(x)
Definition: resources.c:13
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntLoadRegistryParameters()

VOID FASTCALL IntLoadRegistryParameters ( VOID  )

Definition at line 774 of file videoprt.c.

775{
778 UNICODE_STRING KeyPath;
779 UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"SystemStartOptions");
783
784 /* Check if we need to use new registry */
785 RtlInitUnicodeString(&KeyPath, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\GraphicsDrivers\\UseNewKey");
787 &KeyPath,
789 NULL,
790 NULL);
791 Status = ZwOpenKey(&KeyHandle,
794 if (NT_SUCCESS(Status))
795 {
798 }
799
800#ifdef _M_IX86
801 /* Check whether we need to use the 32-bit x86 emulator instead of V86 mode */
802 RtlInitUnicodeString(&KeyPath, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\GraphicsDrivers\\DisableEmulator");
804 &KeyPath,
806 NULL,
807 NULL);
808 Status = ZwOpenKey(&KeyHandle,
811 if (NT_SUCCESS(Status))
812 {
813 VideoPortDisableX86Emulator = TRUE;
815 }
816 DPRINT1("Using %s\n", VideoPortDisableX86Emulator ? "V86 mode" : "x86 emulator");
817#endif // _M_IX86
818
819 /* Initialize object attributes with the path we want */
820 RtlInitUnicodeString(&KeyPath, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control");
822 &KeyPath,
824 NULL,
825 NULL);
826
827 /* Open the key */
828 Status = ZwOpenKey(&KeyHandle,
831 if (!NT_SUCCESS(Status))
832 {
833 VideoPortDebugPrint(Error, "ZwOpenKey failed (0x%x)\n", Status);
834 return;
835 }
836
837 /* Find out how large our buffer should be */
838 Status = ZwQueryValueKey(KeyHandle,
839 &ValueName,
841 NULL,
842 0,
843 &Length);
845 {
846 VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status);
848 return;
849 }
850
851 /* Allocate it */
853 if (!KeyInfo)
854 {
855 VideoPortDebugPrint(Error, "Out of memory\n");
857 return;
858 }
859
860 /* Now for real this time */
861 Status = ZwQueryValueKey(KeyHandle,
862 &ValueName,
864 KeyInfo,
865 Length,
866 &NewLength);
868
869 if (!NT_SUCCESS(Status))
870 {
871 VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status);
873 return;
874 }
875
876 /* Sanity check */
877 if (KeyInfo->Type != REG_SZ)
878 {
879 VideoPortDebugPrint(Error, "Invalid type for SystemStartOptions\n");
881 return;
882 }
883
884 /* Check if BASEVIDEO or NOVESA is present in the start options */
885 if (wcsstr((PWCHAR)KeyInfo->Data, L"BASEVIDEO"))
887 if (wcsstr((PWCHAR)KeyInfo->Data, L"NOVESA"))
888 VpNoVesa = TRUE;
889
891
892 /* FIXME: Old ReactOS-compatibility... */
894
895 if (VpNoVesa)
896 VideoPortDebugPrint(Info, "VESA mode disabled\n");
897 else
898 VideoPortDebugPrint(Info, "VESA mode enabled\n");
899
900 /* If we are in BASEVIDEO, create the volatile registry key for Win32k */
901 if (VpBaseVideo)
902 {
903 RtlInitUnicodeString(&KeyPath, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\GraphicsDrivers\\BaseVideo");
905 &KeyPath,
907 NULL,
908 NULL);
909
910 Status = ZwCreateKey(&KeyHandle,
911 READ_CONTROL, // Non-0 placeholder: no use for this handle.
913 0,
914 NULL,
916 NULL);
917 if (NT_SUCCESS(Status))
919 else
920 ERR_(VIDEOPRT, "Failed to create the BaseVideo key (0x%x)\n", Status);
921 }
922
923 return;
924}
static USHORT USHORT * NewLength
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
BOOL Error
Definition: chkdsk.c:66
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
_ACRTIMP wchar_t *__cdecl wcsstr(const wchar_t *, const wchar_t *)
Definition: wcs.c:2993
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
#define REG_SZ
Definition: layer.c:22
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#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
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyValuePartialInformation
Definition: nt_native.h:1185
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define READ_CONTROL
Definition: nt_native.h:58
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1063
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ERR_(ch,...)
Definition: debug.h:156
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
BOOLEAN VideoPortUseNewKey
Definition: videoprt.c:41
VOID __cdecl VideoPortDebugPrint(_In_ VIDEO_DEBUG_LEVEL DebugPrintLevel, _In_ PSTR DebugMessage, _In_ ...)
Definition: videoprt.c:1156
BOOLEAN VpNoVesa
Definition: videoprt.c:37
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 71 of file videoprt.c.

73{
75 WCHAR DeviceBuffer[20];
77 WCHAR SymlinkBuffer[20];
78 UNICODE_STRING SymlinkName;
81
82 /* Create a unicode device name. */
83 DeviceNumber = DeviceExtension->DeviceNumber;
84 swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
85
87 RegistryPath = &DeviceExtension->NewRegistryPath;
88 else
89 RegistryPath = &DeviceExtension->RegistryPath;
90
91 /* Add entry to DEVICEMAP\VIDEO key in registry. */
93 L"VIDEO",
94 DeviceBuffer,
95 REG_SZ,
96 RegistryPath->Buffer,
97 RegistryPath->Length + sizeof(UNICODE_NULL));
98 if (!NT_SUCCESS(Status))
99 {
100 ERR_(VIDEOPRT, "Failed to create DEVICEMAP registry entry: 0x%X\n", Status);
101 return Status;
102 }
103
105 L"VIDEO",
106 L"MaxObjectNumber",
107 REG_DWORD,
109 sizeof(DeviceNumber));
110 if (!NT_SUCCESS(Status))
111 {
112 ERR_(VIDEOPRT, "Failed to write MaxObjectNumber: 0x%X\n", Status);
113 return Status;
114 }
115
116 /* Create symbolic link "\??\DISPLAYx" */
117 swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DeviceNumber + 1);
118 RtlInitUnicodeString(&SymlinkName, SymlinkBuffer);
119 RtlInitUnicodeString(&DeviceName, DeviceBuffer);
120 Status = IoCreateSymbolicLink(&SymlinkName, &DeviceName);
121 if (!NT_SUCCESS(Status))
122 {
123 ERR_(VIDEOPRT, "Failed to create symbolic link: 0x%X\n", Status);
124 return Status;
125 }
126
127 /* Update MaxObjectNumber */
129
130 return STATUS_SUCCESS;
131}
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1230
#define swprintf
Definition: precomp.h:40
#define RTL_REGISTRY_DEVICEMAP
Definition: nt_native.h:165
#define UNICODE_NULL
#define REG_DWORD
Definition: sdbapi.c:615
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:3281
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
NTSYSAPI NTSTATUS WINAPI RtlWriteRegistryValue(ULONG, PCWSTR, PCWSTR, ULONG, PVOID, ULONG)
__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 171 of file videoprt.c.

178{
179 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
181 ULONG PciSlotNumber;
183 ULONG Size;
185 WCHAR DeviceBuffer[20];
187 PDEVICE_OBJECT DeviceObject_;
188
189 if (DeviceObject == NULL)
190 DeviceObject = &DeviceObject_;
191
192 /*
193 * Find the first free device number that can be used for video device
194 * object names and symlinks.
195 */
197 if (DeviceNumber == (ULONG)-1)
198 {
199 WARN_(VIDEOPRT, "Can't find free device number\n");
200 return STATUS_UNSUCCESSFUL;
201 }
202
203 /*
204 * Create the device object.
205 */
206
207 /* Create a unicode device name. */
208 swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
209 RtlInitUnicodeString(&DeviceName, DeviceBuffer);
210
211 INFO_(VIDEOPRT, "HwDeviceExtension size is: 0x%x\n",
212 DriverExtension->InitializationData.HwDeviceExtensionSize);
213
214 /* Create the device object. */
216 DriverExtension->InitializationData.HwDeviceExtensionSize;
218 Size,
219 &DeviceName,
221 0,
222 TRUE,
224
225 if (!NT_SUCCESS(Status))
226 {
227 WARN_(VIDEOPRT, "IoCreateDevice call failed with status 0x%08x\n", Status);
228 return Status;
229 }
230
231 /*
232 * Set the buffering strategy here. If you change this, remember
233 * to change VidDispatchDeviceControl too.
234 */
235
236 (*DeviceObject)->Flags |= DO_BUFFERED_IO;
237
238 /* Initialize device extension. */
239 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)((*DeviceObject)->DeviceExtension);
240 DeviceExtension->Common.Fdo = TRUE;
241 DeviceExtension->DeviceNumber = DeviceNumber;
242 DeviceExtension->DriverObject = DriverObject;
244 DeviceExtension->FunctionalDeviceObject = *DeviceObject;
245 DeviceExtension->DriverExtension = DriverExtension;
246 DeviceExtension->SessionId = -1;
247 DeviceExtension->AdapterNumber = AdapterNumber;
248 DeviceExtension->DisplayNumber = DisplayNumber;
249 DeviceExtension->IsVgaDriver = IntIsVgaSaveDriver(DriverObject);
250
251 InitializeListHead(&DeviceExtension->ChildDeviceList);
252
253 /*
254 * Miniport owns this blob; many miniports assume it's initially zeroed.
255 * Removing this crashes the NVIDIA GPU driver.
256 */
257 RtlZeroMemory(DeviceExtension->MiniPortDeviceExtension,
258 DriverExtension->InitializationData.HwDeviceExtensionSize);
259
260 /* Get the registry path associated with this device. */
262 DeviceExtension->AdapterNumber,
263 &DeviceExtension->RegistryPath);
264 if (!NT_SUCCESS(Status))
265 {
266 WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status);
267 goto Failure;
268 }
269
271 {
272 /* Get bus number from the upper level bus driver. */
273 Size = sizeof(ULONG);
276 Size,
277 &DeviceExtension->SystemIoBusNumber,
278 &Size);
279 if (!NT_SUCCESS(Status))
280 {
281 WARN_(VIDEOPRT, "Couldn't get an information from bus driver. We will try to\n"
282 "use legacy detection method, but even that doesn't mean that\n"
283 "it will work.\n");
284 DeviceExtension->PhysicalDeviceObject = NULL;
285 }
286 }
287
288 DeviceExtension->AdapterInterfaceType =
289 DriverExtension->InitializationData.AdapterInterfaceType;
290
292 {
293 /* Get bus type from the upper level bus driver. */
294 Size = sizeof(ULONG);
297 Size,
298 &DeviceExtension->AdapterInterfaceType,
299 &Size);
300
301 /* Get bus device address from the upper level bus driver. */
302 Size = sizeof(ULONG);
305 Size,
306 &PciSlotNumber,
307 &Size);
308
309 /* Convert slotnumber to PCI_SLOT_NUMBER */
310 SlotNumber.u.AsULONG = 0;
311 SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
312 SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
313 DeviceExtension->SystemIoSlotNumber = SlotNumber.u.AsULONG;
314 }
315
317 InitializeListHead(&DeviceExtension->DmaAdapterList);
318
319 KeInitializeDpc(&DeviceExtension->DpcObject,
321 DeviceExtension);
322
323 KeInitializeMutex(&DeviceExtension->DeviceLock, 0);
324
325 /* Attach the device. */
326 if ((PhysicalDeviceObject != NULL) && (DisplayNumber == 0))
330
331 Status = IntCreateNewRegistryPath(DeviceExtension);
332 if (!NT_SUCCESS(Status))
333 {
334 ERR_(VIDEOPRT, "IntCreateNewRegistryPath() failed with status 0x%08x\n", Status);
335 goto Failure;
336 }
337
338 IntSetupDeviceSettingsKey(DeviceExtension);
339
340 /* Remove the initializing flag */
341 (*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
342
343 /* Set up the VIDEO/DEVICEMAP registry keys */
344 Status = IntVideoPortAddDeviceMapLink(DeviceExtension);
345 if (!NT_SUCCESS(Status))
346 {
347 ERR_(VIDEOPRT, "IntVideoPortAddDeviceMapLink() failed with status 0x%08x\n", Status);
348 goto Failure;
349 }
350
351 if (DisplayNumber == 0)
352 {
353 DriverExtension->InitializationData.StartingDeviceNumber++;
354 }
355
356 return STATUS_SUCCESS;
357
358Failure:
359 if (DeviceExtension->NextDeviceObject)
360 IoDetachDevice(DeviceExtension->NextDeviceObject);
363 return Status;
364}
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:1382
#define FILE_DEVICE_VIDEO
Definition: winioctl.h:80
#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
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1]
Definition: videoprt.h:118
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 RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#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:158
static BOOLEAN IntIsVgaSaveDriver(_In_ PDRIVER_OBJECT DriverObject)
Definition: videoprt.c:53
static NTSTATUS IntVideoPortAddDeviceMapLink(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: videoprt.c:71
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:2061
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_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:603
NTSTATUS NTAPI IntCreateNewRegistryPath(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:408
NTSTATUS NTAPI IntSetupDeviceSettingsKey(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:298
@ 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 158 of file videoprt.c.

163{
164 PVOID HwDeviceExtension =
165 &((PVIDEO_PORT_DEVICE_EXTENSION)DeferredContext)->MiniPortDeviceExtension;
167}
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:740
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:739
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:741

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntVideoPortEnumBusCallback()

static NTSTATUS NTAPI IntVideoPortEnumBusCallback ( _In_ PVOID  Context,
_In_ PUNICODE_STRING  PathName,
_In_ INTERFACE_TYPE  BusType,
_In_ ULONG  BusNumber,
_In_ PKEY_VALUE_FULL_INFORMATION BusInformation,
_In_ CONFIGURATION_TYPE  ControllerType,
_In_ ULONG  ControllerNumber,
_In_ PKEY_VALUE_FULL_INFORMATION ControllerInformation,
_In_ CONFIGURATION_TYPE  PeripheralType,
_In_ ULONG  PeripheralNumber,
_In_ PKEY_VALUE_FULL_INFORMATION PeripheralInformation 
)
static

A PIO_QUERY_DEVICE_ROUTINE callback for IoQueryDeviceDescription() to return success when an enumerated bus has been found.

Definition at line 373 of file videoprt.c.

385{
387 UNREFERENCED_PARAMETER(PathName);
391 UNREFERENCED_PARAMETER(ControllerType);
392 UNREFERENCED_PARAMETER(ControllerNumber);
393 UNREFERENCED_PARAMETER(ControllerInformation);
394 UNREFERENCED_PARAMETER(PeripheralType);
395 UNREFERENCED_PARAMETER(PeripheralNumber);
396 UNREFERENCED_PARAMETER(PeripheralInformation);
397
398 /* The bus has been found */
399 return STATUS_SUCCESS;
400}
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
_In_ PVOID Context
Definition: storport.h:2269
_In_ WDFDEVICE _In_ PPNP_BUS_INFORMATION BusInformation
Definition: wdfdevice.h:3921
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE BusType
Definition: halfuncs.h:159

Referenced by IntVideoPortEnumBuses().

◆ IntVideoPortEnumBuses()

static NTSTATUS IntVideoPortEnumBuses ( _In_ INTERFACE_TYPE  AdapterInterfaceType,
_Inout_ PULONG  BusNumber 
)
static

Enumerates all supported buses on the system.

Definition at line 407 of file videoprt.c.

410{
411 // TODO: Forward-compatibility with Windows 7+:
412 // In case AdapterInterfaceType == PCIBus, check for the
413 // \Registry\HARDWARE\DESCRIPTION\System\VideoAdapterBusses
414 // key (created by pci.sys) that enumerates the PCI buses that
415 // are known to have video display adapters on them.
416 // This is a handy shortcut for videoprt, that would otherwise
417 // have to enumerate all the PCI buses (PCI_MAX_BRIDGE_NUMBER)
418 // to locate any video adapter.
419 // Otherwise, fall back to the usual method done below.
420
421 /* Find the next bus of the given type */
422 return IoQueryDeviceDescription(&AdapterInterfaceType,
423 BusNumber,
424 NULL,
425 NULL,
426 NULL,
427 NULL,
429 NULL);
430}
NTSTATUS NTAPI IoQueryDeviceDescription(_In_opt_ PINTERFACE_TYPE BusType, _In_opt_ PULONG BusNumber, _In_opt_ PCONFIGURATION_TYPE ControllerType, _In_opt_ PULONG ControllerNumber, _In_opt_ PCONFIGURATION_TYPE PeripheralType, _In_opt_ PULONG PeripheralNumber, _In_ PIO_QUERY_DEVICE_ROUTINE CalloutRoutine, _In_opt_ PVOID Context)
Reads and returns Hardware information from the appropriate hardware registry key.
Definition: iorsrce.c:1213
static NTSTATUS NTAPI IntVideoPortEnumBusCallback(_In_ PVOID Context, _In_ PUNICODE_STRING PathName, _In_ INTERFACE_TYPE BusType, _In_ ULONG BusNumber, _In_ PKEY_VALUE_FULL_INFORMATION *BusInformation, _In_ CONFIGURATION_TYPE ControllerType, _In_ ULONG ControllerNumber, _In_ PKEY_VALUE_FULL_INFORMATION *ControllerInformation, _In_ CONFIGURATION_TYPE PeripheralType, _In_ ULONG PeripheralNumber, _In_ PKEY_VALUE_FULL_INFORMATION *PeripheralInformation)
A PIO_QUERY_DEVICE_ROUTINE callback for IoQueryDeviceDescription() to return success when an enumerat...
Definition: videoprt.c:373

Referenced by IntVideoPortFindAdapter().

◆ IntVideoPortEnumerateChildren()

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

Definition at line 1489 of file videoprt.c.

1492{
1493 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1494 ULONG Status;
1495 VIDEO_CHILD_ENUM_INFO ChildEnumInfo;
1496 BOOLEAN bHaveLastMonitorID = FALSE;
1497 UCHAR LastMonitorID[10];
1498 ULONG Uid, Unused;
1499 UINT i;
1500 PDEVICE_OBJECT ChildDeviceObject;
1501 PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
1502
1503 INFO_(VIDEOPRT, "Starting child device probe\n");
1504 DeviceExtension = DeviceObject->DeviceExtension;
1506 {
1507 WARN_(VIDEOPRT, "Miniport's HwGetVideoChildDescriptor is NULL!\n");
1508 return STATUS_SUCCESS;
1509 }
1510
1511 if (!IsListEmpty(&DeviceExtension->ChildDeviceList))
1512 {
1513 ERR_(VIDEOPRT, "FIXME: Support calling VideoPortEnumerateChildren again!\n");
1514 return STATUS_SUCCESS;
1515 }
1516
1517 /* Enumerate the children */
1518 for (i = 1; ; i++)
1519 {
1520 Status = IoCreateDevice(DeviceExtension->DriverObject,
1523 NULL,
1526 FALSE,
1527 &ChildDeviceObject);
1528 if (!NT_SUCCESS(Status))
1529 return Status;
1530
1531 ChildExtension = ChildDeviceObject->DeviceExtension;
1532
1533 RtlZeroMemory(ChildExtension,
1536
1537 ChildExtension->Common.Fdo = FALSE;
1538 ChildExtension->ChildId = i;
1539 ChildExtension->PhysicalDeviceObject = ChildDeviceObject;
1540 ChildExtension->DriverObject = DeviceExtension->DriverObject;
1541
1542 /* Setup the ChildEnumInfo */
1543 ChildEnumInfo.Size = sizeof(ChildEnumInfo);
1544 ChildEnumInfo.ChildDescriptorSize = sizeof(ChildExtension->ChildDescriptor);
1545 ChildEnumInfo.ACPIHwId = 0;
1546
1548 ChildEnumInfo.ChildHwDeviceExtension = VIDEO_PORT_GET_CHILD_EXTENSION(ChildExtension);
1549 else
1550 ChildEnumInfo.ChildHwDeviceExtension = NULL;
1551
1552 ChildEnumInfo.ChildIndex = ChildExtension->ChildId;
1553
1554 INFO_(VIDEOPRT, "Probing child: %d\n", ChildEnumInfo.ChildIndex);
1556 DeviceExtension->MiniPortDeviceExtension,
1557 &ChildEnumInfo,
1558 &ChildExtension->ChildType,
1559 ChildExtension->ChildDescriptor,
1560 &Uid,
1561 &Unused);
1563 {
1564 if (ChildExtension->ChildType == Monitor)
1565 {
1566 // Check if the EDID is valid
1567 if (ChildExtension->ChildDescriptor[0] == 0x00 &&
1568 ChildExtension->ChildDescriptor[1] == 0xFF &&
1569 ChildExtension->ChildDescriptor[2] == 0xFF &&
1570 ChildExtension->ChildDescriptor[3] == 0xFF &&
1571 ChildExtension->ChildDescriptor[4] == 0xFF &&
1572 ChildExtension->ChildDescriptor[5] == 0xFF &&
1573 ChildExtension->ChildDescriptor[6] == 0xFF &&
1574 ChildExtension->ChildDescriptor[7] == 0x00)
1575 {
1576 if (bHaveLastMonitorID)
1577 {
1578 // Compare the previous monitor ID with the current one, break the loop if they are identical
1579 if (RtlCompareMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID)) == sizeof(LastMonitorID))
1580 {
1581 INFO_(VIDEOPRT, "Found identical Monitor ID two times, stopping enumeration\n");
1582 IoDeleteDevice(ChildDeviceObject);
1583 break;
1584 }
1585 }
1586
1587 // Copy 10 bytes from the EDID, which can be used to uniquely identify the monitor
1588 RtlCopyMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID));
1589 bHaveLastMonitorID = TRUE;
1590
1591 /* Mark it valid */
1592 ChildExtension->EdidValid = TRUE;
1593 }
1594 else
1595 {
1596 /* Mark it invalid */
1597 ChildExtension->EdidValid = FALSE;
1598 }
1599 }
1600 }
1602 {
1603 WARN_(VIDEOPRT, "Child device %d is invalid!\n", ChildEnumInfo.ChildIndex);
1604 IoDeleteDevice(ChildDeviceObject);
1605 continue;
1606 }
1608 {
1609 INFO_(VIDEOPRT, "End of child enumeration! (%d children enumerated)\n", i - 1);
1610 IoDeleteDevice(ChildDeviceObject);
1611 break;
1612 }
1613 else
1614 {
1615 WARN_(VIDEOPRT, "HwGetVideoChildDescriptor returned unknown status code 0x%x!\n", Status);
1616 IoDeleteDevice(ChildDeviceObject);
1617 break;
1618 }
1619
1620 if (ChildExtension->ChildType == Monitor)
1621 {
1622 UINT j;
1623 PUCHAR p = ChildExtension->ChildDescriptor;
1624 INFO_(VIDEOPRT, "Monitor device enumerated! (ChildId = 0x%x)\n", ChildExtension->ChildId);
1625 for (j = 0; j < sizeof (ChildExtension->ChildDescriptor); j += 8)
1626 {
1627 INFO_(VIDEOPRT, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
1628 p[j + 0], p[j + 1], p[j + 2], p[j + 3],
1629 p[j + 4], p[j + 5], p[j + 6], p[j + 7]);
1630 }
1631 }
1632 else if (ChildExtension->ChildType == Other)
1633 {
1634 INFO_(VIDEOPRT, "\"Other\" device enumerated: DeviceId = %S\n", (PWSTR)ChildExtension->ChildDescriptor);
1635 }
1636 else
1637 {
1638 ERR_(VIDEOPRT, "HwGetVideoChildDescriptor returned unsupported type: %d\n", ChildExtension->ChildType);
1639 }
1640
1641 /* Clear the init flag */
1642 ChildDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
1643
1644 InsertTailList(&DeviceExtension->ChildDeviceList,
1645 &ChildExtension->ListEntry);
1646 }
1647
1648 return STATUS_SUCCESS;
1649}
unsigned char BOOLEAN
Definition: actypes.h:127
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#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:49
#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:685
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:132
VIDEO_CHILD_TYPE ChildType
Definition: videoprt.h:126
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:131
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:123
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
unsigned char * PUCHAR
Definition: typedefs.h:53
#define VIDEO_PORT_GET_CHILD_EXTENSION(MiniportExtension)
Definition: videoprt.h:139
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 434 of file videoprt.c.

438{
439 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
441 VP_STATUS vpStatus;
442 VIDEO_PORT_CONFIG_INFO ConfigInfo;
444 UCHAR Again = FALSE;
445 BOOL LegacyDetection = FALSE;
446 BOOLEAN VgaResourcesReleased = FALSE;
447
448 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
449 DeviceExtension->IsVgaDetect = DeviceExtension->IsVgaDriver;
450 DeviceExtension->IsLegacyDetect = FALSE;
451 DeviceExtension->ReportDevice = FALSE;
452
453 /* Setup a ConfigInfo structure that we will pass to HwFindAdapter */
454 RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO));
455 ConfigInfo.Length = sizeof(VIDEO_PORT_CONFIG_INFO);
456 ConfigInfo.AdapterInterfaceType = DeviceExtension->AdapterInterfaceType;
457 if (ConfigInfo.AdapterInterfaceType == PCIBus)
458 ConfigInfo.InterruptMode = LevelSensitive;
459 else
460 ConfigInfo.InterruptMode = Latched;
461 ConfigInfo.DriverRegistryPath = DriverExtension->RegistryPath.Buffer;
463 ConfigInfo.SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
464 ConfigInfo.BusInterruptLevel = DeviceExtension->InterruptLevel;
465 ConfigInfo.BusInterruptVector = DeviceExtension->InterruptVector;
466
469 sizeof(SystemBasicInfo),
470 NULL);
471 if (NT_SUCCESS(Status))
472 {
475 }
476
477 // FIXME: Check the adapter key and update VideoDebugLevel variable.
478
479 /*
480 * Call miniport HwVidFindAdapter entry point to detect if
481 * particular device is present. There are two possible code
482 * paths. The first one is for Legacy drivers (NT4) and cases
483 * when we don't have information about what bus we're on. The
484 * second case is the standard one for Plug & Play drivers.
485 */
486 if (DeviceExtension->PhysicalDeviceObject == NULL)
487 {
488 LegacyDetection = TRUE;
489 DeviceExtension->IsLegacyDevice = TRUE;
490 DeviceExtension->IsLegacyDetect = TRUE;
491 }
492 else
493 {
494 DeviceExtension->IsLegacyDevice = FALSE;
495 }
496
497 /* If we already have a VGA miniport and are about to probe for additional adapters,
498 * release its resources temporarily so conflicts are visible during detection.
499 * We'll reclaim them later if no new adapter successfully claims them. */
502 {
503 INFO_(VIDEOPRT, "Temporarily releasing VGA resources for adapter probing\n");
505 VgaResourcesReleased = TRUE;
506 }
508
509 if (LegacyDetection)
510 {
512
513 /* Suppose first we may not find any suitable device */
514 vpStatus = ERROR_DEV_NOT_EXIST; // ERROR_NO_MORE_DEVICES;
515
516 /* Enumerate all buses of the given type, call HwFindAdapter for each
517 * to find whether a video adapter is recognized there. Stop when an
518 * adapter has been found. */
519 for (BusNumber = 0;
520 (BusNumber < MAXULONG) &&
522 &BusNumber));
523 ++BusNumber)
524 {
525 DPRINT("Bus Type %lu, Number %lu\n",
526 DeviceExtension->AdapterInterfaceType, BusNumber);
527
528 DeviceExtension->SystemIoBusNumber =
529 ConfigInfo.SystemIoBusNumber = BusNumber;
530
531 RtlZeroMemory(&DeviceExtension->MiniPortDeviceExtension,
532 DriverExtension->InitializationData.HwDeviceExtensionSize);
533
534 /* FIXME: Need to figure out what string to pass as param 3. */
535 // FIXME: Handle the 'Again' parameter for legacy detection.
536 vpStatus = DriverExtension->InitializationData.HwFindAdapter(
537 &DeviceExtension->MiniPortDeviceExtension,
538 DriverExtension->HwContext,
539 NULL,
540 &ConfigInfo,
541 &Again);
542
543 if (vpStatus == ERROR_DEV_NOT_EXIST)
544 {
545 continue;
546 }
547 else
548 {
549 break;
550 }
551 }
552 }
553 else
554 {
555 /* FIXME: Need to figure out what string to pass as param 3. */
556 vpStatus = DriverExtension->InitializationData.HwFindAdapter(
557 &DeviceExtension->MiniPortDeviceExtension,
558 DriverExtension->HwContext,
559 NULL,
560 &ConfigInfo,
561 &Again);
562 }
563
564 if (vpStatus != NO_ERROR)
565 {
566 ERR_(VIDEOPRT, "HwFindAdapter failed (vpStatus=0x%X) bus=%u iface=%u legacy=%u vga=%u detect(VGA=%u LEGACY=%u)\n",
567 vpStatus,
568 DeviceExtension->SystemIoBusNumber,
569 DeviceExtension->AdapterInterfaceType,
570 DeviceExtension->IsLegacyDevice,
571 DeviceExtension->IsVgaDriver,
572 DeviceExtension->IsVgaDetect,
573 DeviceExtension->IsLegacyDetect);
574 /* If we released VGA resources, reclaim them so VGA fallback still works */
575 if (VgaResourcesReleased)
576 {
578 {
579 INFO_(VIDEOPRT, "Reclaiming VGA resources after failed probe\n");
583 {
584 WARN_(VIDEOPRT, "Failed to reclaim VGA resources after probe failure\n");
585 }
586 }
587 }
589 goto Failure;
590 }
591
592 /*
593 * Now we know the device is present, so let's do all additional tasks
594 * such as creating symlinks or setting up interrupts and timer.
595 */
596
597 /* FIXME: Allocate hardware resources for device. */
598
599 /* Allocate interrupt for device. */
601 {
603 goto Failure;
604 }
605
606 /* Allocate timer for device. */
608 {
609 if (DeviceExtension->InterruptObject != NULL)
610 IoDisconnectInterrupt(DeviceExtension->InterruptObject);
611 ERR_(VIDEOPRT, "IntVideoPortSetupTimer failed\n");
613 goto Failure;
614 }
615
616 /* If the device can be reset, insert it in the list of resettable adapters */
617 InitializeListHead(&DeviceExtension->HwResetListEntry);
618 if (DriverExtension->InitializationData.HwResetHw != NULL)
619 {
621 &DeviceExtension->HwResetListEntry,
623 }
624
625 if (DeviceExtension->IsVgaDriver)
626 {
629 {
630 VgaDeviceExtension = DeviceExtension;
631 }
633 }
634
635 DeviceExtension->IsVgaDetect = FALSE;
636 DeviceExtension->IsLegacyDetect = FALSE;
637
638 /* For legacy (non-PnP) adapters we should report a detected device so that
639 * a PDO exists for higher layers to enumerate consistently (mirrors ScsiPort).*/
640 if (DeviceExtension->IsLegacyDevice && !DeviceExtension->ReportDevice)
641 {
642 PDEVICE_OBJECT ReportedPdo = NULL;
644 DeviceExtension->AdapterInterfaceType,
645 DeviceExtension->SystemIoBusNumber,
646 DeviceExtension->SystemIoSlotNumber,
647 NULL,
648 NULL,
649 FALSE,
650 &ReportedPdo);
651 if (!NT_SUCCESS(repStatus))
652 {
653 WARN_(VIDEOPRT, "IoReportDetectedDevice failed 0x%08lx (bus=%u slot=%u)\n",
654 repStatus,
655 DeviceExtension->SystemIoBusNumber,
656 DeviceExtension->SystemIoSlotNumber);
657 }
658 else
659 {
660 INFO_(VIDEOPRT, "Reported legacy adapter PDO %p (bus=%u slot=%u)\n",
661 ReportedPdo,
662 DeviceExtension->SystemIoBusNumber,
663 DeviceExtension->SystemIoSlotNumber);
664 DeviceExtension->ReportDevice = TRUE;
665 }
666 }
667
668 /* Attempt to reclaim VGA resources after probing if a VGA device exists */
670 {
671 VP_STATUS vr;
672 INFO_(VIDEOPRT, "Attempt VGA reclaim after probe (ranges=%lu)\n", NumOfVgaRanges);
675 VgaRanges);
676 if (vr != NO_ERROR)
677 {
678 /* Another driver has taken VGA resources; drop fallback state */
679 WARN_(VIDEOPRT, "VGA reclaim failed (vpStatus=0x%X); releasing fallback state\n", vr);
682 VgaRanges = NULL;
683 NumOfVgaRanges = 0;
686
687 }
688 else
689 {
690 INFO_(VIDEOPRT, "VGA reclaim succeeded\n");
691 }
692 }
693
694 INFO_(VIDEOPRT, "STATUS_SUCCESS\n");
695 return STATUS_SUCCESS;
696
697Failure:
698 RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
699 if (DeviceExtension->NextDeviceObject)
700 IoDetachDevice(DeviceExtension->NextDeviceObject);
701
702 /* Explicitly reclaim VGA resources on complete failure */
703 if (VgaResourcesReleased)
704 {
706 {
707 INFO_(VIDEOPRT, "Final reclaim attempt of VGA resources during failure cleanup\n");
711 {
712 WARN_(VIDEOPRT, "VGA reclaim failed during failure cleanup\n");
713 }
714 }
715 }
717 return Status;
718}
#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:106
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
#define KernelMode
Definition: asm.h:38
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:142
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:30
NTSTATUS NTAPI IoReportDetectedDevice(_In_ PDRIVER_OBJECT DriverObject, _In_ INTERFACE_TYPE LegacyBusType, _In_ ULONG BusNumber, _In_ ULONG SlotNumber, _In_opt_ PCM_RESOURCE_LIST ResourceList, _In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements, _In_ BOOLEAN ResourceAssigned, _Inout_ PDEVICE_OBJECT *DeviceObject)
Definition: pnpreport.c:148
@ PCIBus
Definition: restypes.h:126
@ Latched
Definition: miniport.h:81
@ LevelSensitive
Definition: miniport.h:80
VPAPI VP_STATUS NTAPI VideoPortVerifyAccessRanges(_In_ PVOID HwDeviceExtension, _In_opt_ ULONG NumAccessRanges, _In_reads_opt_(NumAccessRanges) PVIDEO_ACCESS_RANGE AccessRanges)
Claims or releases a range of hardware resources and checks for conflicts.
Definition: resource.c:976
LONG VP_STATUS
Definition: video.h:153
struct _VIDEO_PORT_CONFIG_INFO VIDEO_PORT_CONFIG_INFO
#define DPRINT
Definition: sndvol32.h:73
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 MAXULONG
Definition: typedefs.h:251
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
ULONG NumOfVgaRanges
Definition: videoprt.c:48
PVIDEO_PORT_DEVICE_EXTENSION VgaDeviceExtension
Definition: videoprt.c:46
KMUTEX VgaSyncLock
Definition: videoprt.c:45
static NTSTATUS IntVideoPortEnumBuses(_In_ INTERFACE_TYPE AdapterInterfaceType, _Inout_ PULONG BusNumber)
Enumerates all supported buses on the system.
Definition: videoprt.c:407
KSPIN_LOCK HwResetAdaptersLock
Definition: videoprt.c:43
PVIDEO_ACCESS_RANGE VgaRanges
Definition: videoprt.c:47
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
VOID IntVideoPortReleaseResources(_In_ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: resource.c:198
BOOLEAN NTAPI IntVideoPortSetupTimer(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension)
Definition: timer.c:43
#define KeWaitForMutexObject
Definition: kefuncs.h:543
@ Executive
Definition: ketypes.h:467

Referenced by IntVideoPortPnPStartDevice(), and VideoPortInitialize().

◆ IntVideoPortImageDirectoryEntryToData()

PVOID NTAPI IntVideoPortImageDirectoryEntryToData ( PVOID  BaseAddress,
ULONG  Directory 
)

Definition at line 135 of file videoprt.c.

138{
139 PIMAGE_NT_HEADERS NtHeader;
140 ULONG Va;
141
142 NtHeader = RtlImageNtHeader(BaseAddress);
143 if (NtHeader == NULL)
144 return NULL;
145
147 return NULL;
148
150 if (Va == 0)
151 return NULL;
152
153 return (PVOID)((ULONG_PTR)BaseAddress + Va);
154}
#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 1210 of file videoprt.c.

1217{
1219
1220 INFO_(VIDEOPRT, "Found registry value for name %S: type %d, length %d\n",
1222 return (*(CallbackContext->HwGetRegistryRoutine))(
1223 CallbackContext->HwDeviceExtension,
1224 CallbackContext->HwContext,
1225 ValueName,
1226 ValueData,
1227 ValueLength);
1228}
_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 1889 of file videoprt.c.

1891{
1892 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1893
1894 TRACE_(VIDEOPRT, "VideoPortAcquireDeviceLock\n");
1895 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1897 // ASSERT(Status == STATUS_SUCCESS);
1898}
#define TRACE_(x)
Definition: compat.h:76
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension)
Definition: videoprt.h:145

◆ VideoPortAllocateContiguousMemory()

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

Definition at line 1933 of file videoprt.c.

1938{
1940}
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 1797 of file videoprt.c.

1805{
1806 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1809 IO_STACK_LOCATION IoStack;
1810 ULONG PciFlags = 0;
1812 BOOL DevicePresent;
1813
1814 TRACE_(VIDEOPRT, "VideoPortCheckForDeviceExistence\n");
1815
1817 {
1818 WARN_(VIDEOPRT, "VideoPortCheckForDeviceExistence: Unknown flags 0x%lx\n", Flags & ~(CDE_USE_REVISION | CDE_USE_SUBSYSTEM_IDS));
1819 return FALSE;
1820 }
1821
1822 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1823
1825 PciDevicePresentInterface.Version = 1;
1827 IoStack.Parameters.QueryInterface.Version = PciDevicePresentInterface.Version;
1829 IoStack.Parameters.QueryInterface.InterfaceType =
1830 &GUID_PCI_DEVICE_PRESENT_INTERFACE;
1831 Status = IopInitiatePnpIrp(DeviceExtension->NextDeviceObject,
1833 if (!NT_SUCCESS(Status))
1834 {
1835 WARN_(VIDEOPRT, "IopInitiatePnpIrp() failed! (Status 0x%lx)\n", Status);
1836 return FALSE;
1837 }
1838
1839 if (Flags & CDE_USE_REVISION)
1840 PciFlags |= PCI_USE_REVISION;
1842 PciFlags |= PCI_USE_SUBSYSTEM_IDS;
1843
1844 DevicePresent = PciDevicePresentInterface.IsDevicePresent(
1845 VendorId, DeviceId, RevisionId,
1846 SubVendorId, SubSystemId, PciFlags);
1847
1848 PciDevicePresentInterface.InterfaceDereference(PciDevicePresentInterface.Context);
1849
1850 return DevicePresent;
1851}
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
union _IO_STACK_LOCATION::@1672 Parameters
struct _IO_STACK_LOCATION::@4302::@4328 QueryInterface
_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 1676 of file videoprt.c.

1680{
1682 PVIDEO_PORT_DEVICE_EXTENSION FirstDeviceExtension, DeviceExtension;
1684
1685 ASSERT(SecondaryDeviceExtension);
1686
1687 if (Flag != 0)
1688 {
1690 }
1691
1692 FirstDeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1693
1694 if (FirstDeviceExtension->DisplayNumber != 0)
1695 {
1696 DPRINT1("Calling VideoPortCreateSecondaryDisplay for InstanceId %lu\n",
1697 FirstDeviceExtension->DisplayNumber);
1698 }
1699
1701 FirstDeviceExtension->DriverExtension,
1702 FirstDeviceExtension->PhysicalDeviceObject,
1703 FirstDeviceExtension->AdapterNumber,
1704 FirstDeviceExtension->NumberOfSecondaryDisplays + 1,
1705 &DeviceObject);
1706 if (!NT_SUCCESS(Status))
1707 {
1708 DPRINT1("IntVideoPortCreateAdapterDeviceObject() failed with status 0x%08x\n", Status);
1709 return ERROR_DEV_NOT_EXIST;
1710 }
1711
1712 DeviceExtension = DeviceObject->DeviceExtension;
1713
1714 /* Increment secondary display count */
1715 FirstDeviceExtension->NumberOfSecondaryDisplays++;
1716
1717 *SecondaryDeviceExtension = DeviceExtension->MiniPortDeviceExtension;
1718 return NO_ERROR;
1719}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
Definition: xml2sdb.h:97
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:171

◆ VideoPortDebugPrint()

VOID __cdecl VideoPortDebugPrint ( _In_ VIDEO_DEBUG_LEVEL  DebugPrintLevel,
_In_ PSTR  DebugMessage,
_In_ ...   
)

Definition at line 1156 of file videoprt.c.

1160{
1161 va_list ap;
1162
1163 if (VideoDebugLevel >= DebugPrintLevel)
1164 DebugPrintLevel = Error;
1165
1166 va_start(ap, DebugMessage);
1167 vDbgPrintEx(DPFLTR_VIDEO_ID, DebugPrintLevel, DebugMessage, ap);
1168 va_end(ap);
1169}
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
char * va_list
Definition: vadefs.h:50
@ DPFLTR_VIDEO_ID
Definition: dpfilter.h:55
ULONG VideoDebugLevel
Definition: videoprt.c:34
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

Referenced by IntLoadRegistryParameters(), VBEGetVideoChildDescriptor(), VBEInitialize(), VBEReadEdid(), VBEReadEdidUsingSCI(), VBESetCurrentMode(), and VGASetCurrentMode().

◆ VideoPortEnumerateChildren()

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

Definition at line 1653 of file videoprt.c.

1656{
1657 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1658
1659 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1660 ASSERT(DeviceExtension);
1661
1662 if (DeviceExtension->PhysicalDeviceObject)
1663 {
1664 /* Trigger reenumeration by the PnP manager */
1666 }
1667
1668 return NO_ERROR;
1669}
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:1772
@ BusRelations
Definition: iotypes.h:2154

Referenced by IntVideoPortDispatchOpen(), and VBEInitialize().

◆ VideoPortGetAssociatedDeviceExtension()

PVOID NTAPI VideoPortGetAssociatedDeviceExtension ( IN PVOID  DeviceObject)

Definition at line 1742 of file videoprt.c.

1744{
1745 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1746
1747 TRACE_(VIDEOPRT, "VideoPortGetAssociatedDeviceExtension\n");
1748 DeviceExtension = ((PDEVICE_OBJECT)DeviceObject)->DeviceExtension;
1749 if (!DeviceExtension)
1750 return NULL;
1751 return DeviceExtension->MiniPortDeviceExtension;
1752}
struct _DEVICE_OBJECT * PDEVICE_OBJECT

◆ VideoPortGetCurrentIrql()

UCHAR NTAPI VideoPortGetCurrentIrql ( VOID  )

Definition at line 1195 of file videoprt.c.

1196{
1197 return KeGetCurrentIrql();
1198}
#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 1236 of file videoprt.c.

1242{
1245 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1247
1248 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1249
1250 TRACE_(VIDEOPRT, "VideoPortGetRegistryParameters ParameterName %S, RegPath: %wZ\n",
1251 ParameterName, &DeviceExtension->RegistryPath);
1252
1253 Context.HwDeviceExtension = HwDeviceExtension;
1254 Context.HwContext = HwContext;
1255 Context.HwGetRegistryRoutine = GetRegistryRoutine;
1256
1260
1262 DeviceExtension->RegistryPath.Buffer,
1263 QueryTable,
1264 &Context,
1265 NULL);
1266 if (!NT_SUCCESS(Status))
1267 {
1268 WARN_(VIDEOPRT, "VideoPortGetRegistryParameters could not find the "
1269 "requested parameter\n");
1271 }
1272
1273 if (IsParameterFileName)
1274 {
1275 /* FIXME: need to read the contents of the file */
1277 }
1278
1279 return NO_ERROR;
1280}
_In_opt_ PWSTR _In_ PWSTR ParameterName
Definition: cdrom.h:961
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:4211
#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:907
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:1210
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)

◆ VideoPortGetRomImage()

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

Definition at line 1346 of file videoprt.c.

1351{
1352 static PVOID RomImageBuffer = NULL;
1353 PKPROCESS CallingProcess;
1355
1356 TRACE_(VIDEOPRT, "VideoPortGetRomImage(HwDeviceExtension 0x%X Length 0x%X)\n",
1357 HwDeviceExtension, Length);
1358
1359 /* If the length is zero then free the existing buffer */
1360 if (Length == 0)
1361 {
1362 if (RomImageBuffer != NULL)
1363 {
1364 ExFreePool(RomImageBuffer);
1365 RomImageBuffer = NULL;
1366 }
1367 return NULL;
1368 }
1369 else
1370 {
1371 /*
1372 * The DDK says we shouldn't use the legacy C0000 method but get the
1373 * ROM base address from the corresponding PCI or ACPI register but
1374 * lets ignore that and use C0000 anyway. We have already mapped the
1375 * BIOS area into memory so we'll copy from there.
1376 */
1377
1378 /* Copy the BIOS */
1379 Length = min(Length, 0x10000);
1380 if (RomImageBuffer != NULL)
1381 ExFreePool(RomImageBuffer);
1382
1383 RomImageBuffer = ExAllocatePool(PagedPool, Length);
1384 if (RomImageBuffer == NULL)
1385 return NULL;
1386
1387 /* Perform the copy in the CSRSS context */
1388 if (IntAttachToCSRSS(&CallingProcess, &ApcState))
1389 {
1390 RtlCopyMemory(RomImageBuffer, (PUCHAR)0xC0000, Length);
1391 IntDetachFromCSRSS(CallingProcess, &ApcState);
1392 }
1393 else
1394 {
1395 ExFreePool(RomImageBuffer);
1396 RomImageBuffer = NULL;
1397 }
1398 return RomImageBuffer;
1399 }
1400}
#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(_In_ PKPROCESS CallingProcess, _In_ PKAPC_STATE ApcState)
Detach the current thread from the CSRSS process. This routine is to be invoked after a previous succ...
Definition: videoprt.c:763
BOOLEAN FASTCALL IntAttachToCSRSS(_Outptr_ PKPROCESS *CallingProcess, _Out_ PKAPC_STATE ApcState)
Attach the current thread to the CSRSS process. The caller must detach from the process by invoking I...
Definition: videoprt.c:736
KAPC_STATE
Definition: ketypes.h:1711

◆ VideoPortGetVersion()

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

Definition at line 1759 of file videoprt.c.

1762{
1764
1765 Version.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
1766 if (VpOsVersionInfo->Size >= sizeof(VPOSVERSIONINFO))
1767 {
1768#if 1
1770 {
1771 VpOsVersionInfo->MajorVersion = Version.dwMajorVersion;
1772 VpOsVersionInfo->MinorVersion = Version.dwMinorVersion;
1773 VpOsVersionInfo->BuildNumber = Version.dwBuildNumber;
1774 VpOsVersionInfo->ServicePackMajor = Version.wServicePackMajor;
1775 VpOsVersionInfo->ServicePackMinor = Version.wServicePackMinor;
1776 return NO_ERROR;
1777 }
1779#else
1780 VpOsVersionInfo->MajorVersion = 5;
1781 VpOsVersionInfo->MinorVersion = 0;
1782 VpOsVersionInfo->BuildNumber = 2195;
1783 VpOsVersionInfo->ServicePackMajor = 4;
1784 VpOsVersionInfo->ServicePackMinor = 0;
1785 return NO_ERROR;
1786#endif
1787 }
1788
1790}
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:182
_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 1318 of file videoprt.c.

1321{
1322 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1323
1324 TRACE_(VIDEOPRT, "VideoPortGetVgaStatus\n");
1325
1326 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1328 {
1329 if (DeviceExtension->AdapterInterfaceType == PCIBus)
1330 {
1331 /* VgaStatus: 0 == VGA not enabled, 1 == VGA enabled. */
1332 /* Assumed for now */
1333 *VgaStatus = 1;
1334 return NO_ERROR;
1335 }
1336 }
1337
1339}
#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 933 of file videoprt.c.

938{
943 BOOLEAN PnpDriver = FALSE, LegacyDetection = FALSE;
944 static BOOLEAN FirstInitialization = FALSE;
945
946 TRACE_(VIDEOPRT, "VideoPortInitialize\n");
947
948 if (!FirstInitialization)
949 {
950 FirstInitialization = TRUE;
955
957 if (!NT_SUCCESS(Status))
958 {
959 ERR_(VIDEOPRT, "IntInitializeInt10(FirstInit) failed: 0x%lx\n", Status);
960 // return Status; // Let's continue and hope for the best...
961 }
962 }
963
964 /* As a first thing do parameter checks. */
965 if (HwInitializationData->HwInitDataSize > sizeof(VIDEO_HW_INITIALIZATION_DATA))
966 {
967 ERR_(VIDEOPRT, "Invalid HwInitializationData\n");
969 }
970
971 if ((HwInitializationData->HwFindAdapter == NULL) ||
972 (HwInitializationData->HwInitialize == NULL) ||
973 (HwInitializationData->HwStartIO == NULL))
974 {
975 ERR_(VIDEOPRT, "Invalid HwInitializationData\n");
977 }
978
979 switch (HwInitializationData->HwInitDataSize)
980 {
981 /*
982 * NT4 drivers are special case, because we must use legacy method
983 * of detection instead of the Plug & Play one.
984 */
986 INFO_(VIDEOPRT, "We were loaded by a Windows NT miniport driver.\n");
987 break;
988
990 INFO_(VIDEOPRT, "We were loaded by a Windows 2000 miniport driver.\n");
991 break;
992
993 case sizeof(VIDEO_HW_INITIALIZATION_DATA):
994 INFO_(VIDEOPRT, "We were loaded by a Windows XP or later miniport driver.\n");
995 break;
996
997 default:
998 ERR_(VIDEOPRT, "Invalid HwInitializationData size %lu (expected %lu, %lu or %lu)\n",
999 HwInitializationData->HwInitDataSize,
1003 return STATUS_UNSUCCESSFUL;
1004 }
1005
1006 /* Set dispatching routines */
1009 DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
1011 DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] =
1013 DriverObject->DriverUnload = IntVideoPortUnload;
1014
1015 /* Determine type of the miniport driver */
1016 if ((HwInitializationData->HwInitDataSize >=
1017 FIELD_OFFSET(VIDEO_HW_INITIALIZATION_DATA, HwQueryInterface)) &&
1018 (HwInitializationData->HwSetPowerState != NULL) &&
1019 (HwInitializationData->HwGetPowerState != NULL) &&
1020 (HwInitializationData->HwGetVideoChildDescriptor != NULL))
1021 {
1022 INFO_(VIDEOPRT, "The miniport is a PnP miniport driver\n");
1023 PnpDriver = TRUE;
1024 }
1025
1026 /* Check if legacy detection should be applied */
1027 if (!PnpDriver || HwContext)
1028 {
1029 INFO_(VIDEOPRT, "Legacy detection for adapter interface %d\n",
1030 HwInitializationData->AdapterInterfaceType);
1031
1032 /* FIXME: Move the code for legacy detection
1033 to another function and call it here */
1034 LegacyDetection = TRUE;
1035 }
1036
1037 /*
1038 * NOTE:
1039 * The driver extension can be already allocated in case that we were
1040 * called by legacy driver and failed detecting device. Some miniport
1041 * drivers in that case adjust parameters and call VideoPortInitialize
1042 * again.
1043 */
1045 if (DriverExtension == NULL)
1046 {
1051 if (!NT_SUCCESS(Status))
1052 {
1053 ERR_(VIDEOPRT, "IoAllocateDriverObjectExtension failed 0x%x\n", Status);
1054 return Status;
1055 }
1056
1057 /*
1058 * Save the registry path. This should be done only once even if
1059 * VideoPortInitialize is called multiple times.
1060 */
1061 if (RegistryPath->Length != 0)
1062 {
1063 DriverExtension->RegistryPath.Length = 0;
1064 DriverExtension->RegistryPath.MaximumLength =
1065 RegistryPath->Length + sizeof(UNICODE_NULL);
1066 DriverExtension->RegistryPath.Buffer =
1068 PagedPool,
1069 DriverExtension->RegistryPath.MaximumLength,
1070 'RTSU');
1071 if (DriverExtension->RegistryPath.Buffer == NULL)
1072 {
1073 RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL);
1075 }
1076
1078
1079 /* There is a bug in Spice guest agent, which searches 'System' case-sensitively.
1080 * Replace 'SYSTEM' by 'System' to fix that.
1081 * Probably for similar reason, Windows also replaces 'MACHINE' by 'Machine'.
1082 */
1083 wcsncpy(wcsstr(DriverExtension->RegistryPath.Buffer, L"\\SYSTEM\\"), L"\\System\\", ARRAYSIZE(L"\\SYSTEM\\") - 1);
1084 wcsncpy(wcsstr(DriverExtension->RegistryPath.Buffer, L"\\MACHINE\\"), L"\\Machine\\", ARRAYSIZE(L"\\MACHINE\\") - 1);
1085
1086 INFO_(VIDEOPRT, "RegistryPath: %wZ\n", &DriverExtension->RegistryPath);
1087 }
1088 else
1089 {
1090 RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL);
1091 }
1092 }
1093
1094 /* Copy the correct miniport initialization data to the device extension. */
1095 RtlCopyMemory(&DriverExtension->InitializationData,
1097 HwInitializationData->HwInitDataSize);
1098 if (HwInitializationData->HwInitDataSize <
1100 {
1101 RtlZeroMemory((PVOID)((ULONG_PTR)&DriverExtension->InitializationData +
1102 HwInitializationData->HwInitDataSize),
1104 HwInitializationData->HwInitDataSize);
1105 }
1106 DriverExtension->HwContext = HwContext;
1107
1108 /*
1109 * Plug & Play drivers registers the device in AddDevice routine.
1110 * For legacy drivers we must do it now.
1111 */
1112 if (LegacyDetection)
1113 {
1115
1117 {
1118 /* Power management */
1120 }
1121
1124 NULL,
1125 DriverExtension->InitializationData.StartingDeviceNumber,
1126 0,
1127 &DeviceObject);
1128 if (!NT_SUCCESS(Status))
1129 {
1130 ERR_(VIDEOPRT, "IntVideoPortCreateAdapterDeviceObject returned 0x%x\n", Status);
1131 return Status;
1132 }
1133
1135 if (!NT_SUCCESS(Status))
1136 ERR_(VIDEOPRT, "IntVideoPortFindAdapter returned 0x%x\n", Status);
1137
1138 return Status;
1139 }
1140 else
1141 {
1142 DriverObject->DriverExtension->AddDevice = IntVideoPortAddDevice;
1146
1147 return STATUS_SUCCESS;
1148 }
1149}
#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
NTSTATUS IntInitializeInt10(VOID)
Definition: int10.c:766
KMUTEX VideoPortInt10Mutex
Definition: int10.c:41
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1916
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1838
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:419
#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
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA * HwInitializationData
Definition: srb.h:906
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
wcsncpy
_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:774
NTSTATUS NTAPI IntVideoPortFindAdapter(IN PDRIVER_OBJECT DriverObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PDEVICE_OBJECT DeviceObject)
Definition: videoprt.c:434
NTSTATUS NTAPI IntVideoPortDispatchClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:434
VOID NTAPI IntVideoPortUnload(PDRIVER_OBJECT DriverObject)
Definition: dispatch.c:1288
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:766
NTSTATUS NTAPI IntVideoPortDispatchSystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1266
NTSTATUS NTAPI IntVideoPortDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1200
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:1232
#define IRP_MJ_SYSTEM_CONTROL
#define IRP_MJ_SHUTDOWN
#define IRP_MJ_POWER

Referenced by DriverEntry().

◆ VideoPortIsNoVesa()

BOOLEAN NTAPI VideoPortIsNoVesa ( VOID  )

Definition at line 1947 of file videoprt.c.

1948{
1949 return VpNoVesa;
1950}

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 1176 of file videoprt.c.

1181{
1183
1184 INFO_(VIDEOPRT, "VideoPortLogError ErrorCode %d (0x%x) UniqueId %lu (0x%lx)\n",
1185 ErrorCode, ErrorCode, UniqueId, UniqueId);
1186 if (Vrp)
1187 INFO_(VIDEOPRT, "Vrp->IoControlCode %lu (0x%lx)\n", Vrp->IoControlCode, Vrp->IoControlCode);
1188}
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436

◆ VideoPortQueryPerformanceCounter()

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

Definition at line 1873 of file videoprt.c.

1876{
1878
1879 TRACE_(VIDEOPRT, "VideoPortQueryPerformanceCounter\n");
1880 Result = KeQueryPerformanceCounter((PLARGE_INTEGER)PerformanceFrequency);
1881 return Result.QuadPart;
1882}
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:409

◆ VideoPortQueueDpc()

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

Definition at line 1726 of file videoprt.c.

1730{
1731 return KeInsertQueueDpc(
1732 &VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->DpcObject,
1734 (PVOID)Context);
1735}
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:425

◆ VideoPortRegisterBugcheckCallback()

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

Definition at line 1858 of file videoprt.c.

1863{
1865 return NO_ERROR;
1866}

◆ VideoPortReleaseDeviceLock()

VOID NTAPI VideoPortReleaseDeviceLock ( IN PVOID  HwDeviceExtension)

Definition at line 1905 of file videoprt.c.

1907{
1908 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1909
1910 TRACE_(VIDEOPRT, "VideoPortReleaseDeviceLock\n");
1911 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1912 KeReleaseMutex(&DeviceExtension->DeviceLock, FALSE);
1913 //ASSERT(Status == STATUS_SUCCESS);
1914}

◆ VideoPortScanRom()

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

Definition at line 1407 of file videoprt.c.

1412{
1413 SIZE_T StringLength;
1414 BOOLEAN Found;
1415 PUCHAR SearchLocation;
1416
1417 TRACE_(VIDEOPRT, "VideoPortScanRom RomBase %p RomLength 0x%x String %s\n", RomBase, RomLength, String);
1418
1419 StringLength = strlen((PCHAR)String);
1420 Found = FALSE;
1421 for (SearchLocation = RomBase;
1422 !Found && SearchLocation < RomBase + RomLength - StringLength;
1423 SearchLocation++)
1424 {
1425 Found = (RtlCompareMemory(SearchLocation, String, StringLength) == StringLength);
1426 if (Found)
1427 {
1428 INFO_(VIDEOPRT, "Match found at %p\n", SearchLocation);
1429 }
1430 }
1431
1432 return Found;
1433}
return Found
Definition: dirsup.c:1270
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
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:2439

◆ VideoPortSetRegistryParameters()

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

Definition at line 1287 of file videoprt.c.

1292{
1293 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1295
1296 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1297 TRACE_(VIDEOPRT, "VideoPortSetRegistryParameters ParameterName %S, RegPath: %wZ\n",
1298 ValueName,
1299 &DeviceExtension->RegistryPath);
1302 DeviceExtension->RegistryPath.Buffer,
1303 ValueName,
1304 REG_BINARY,
1305 ValueData,
1306 ValueLength);
1307 if (Status != NO_ERROR)
1308 WARN_(VIDEOPRT, "VideoPortSetRegistryParameters error 0x%x\n", Status);
1309
1310 return Status;
1311}
#define REG_BINARY
Definition: nt_native.h:1499
#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 1440 of file videoprt.c.

1445{
1446 BOOLEAN Ret;
1447 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1448 KIRQL OldIrql;
1449
1450 switch (Priority)
1451 {
1452 case VpLowPriority:
1453 Ret = (*SynchronizeRoutine)(Context);
1454 break;
1455
1456 case VpMediumPriority:
1457 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1458 if (DeviceExtension->InterruptObject == NULL)
1459 Ret = (*SynchronizeRoutine)(Context);
1460 else
1462 DeviceExtension->InterruptObject,
1464 Context);
1465 break;
1466
1467 case VpHighPriority:
1469 if (OldIrql < SYNCH_LEVEL)
1471
1472 Ret = (*SynchronizeRoutine)(Context);
1473
1474 if (OldIrql < SYNCH_LEVEL)
1476 break;
1477
1478 default:
1479 Ret = FALSE;
1480 }
1481
1482 return Ret;
1483}
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:237
@ 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:778

◆ VpNotifyEaData()

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

Definition at line 1921 of file videoprt.c.

1924{
1926}

Variable Documentation

◆ CsrProcess

◆ HwResetAdaptersLock

KSPIN_LOCK HwResetAdaptersLock

◆ NumOfVgaRanges

ULONG NumOfVgaRanges = 0

Definition at line 48 of file videoprt.c.

Referenced by IntVideoPortFindAdapter(), and VideoPortVerifyAccessRanges().

◆ VgaDeviceExtension

PVIDEO_PORT_DEVICE_EXTENSION VgaDeviceExtension = NULL

Definition at line 46 of file videoprt.c.

Referenced by IntVideoPortFindAdapter(), VbeSetMode(), and VideoPortVerifyAccessRanges().

◆ VgaRanges

Definition at line 47 of file videoprt.c.

Referenced by IntVideoPortFindAdapter(), and VideoPortVerifyAccessRanges().

◆ VgaSyncLock

KMUTEX VgaSyncLock

◆ VideoDebugLevel

ULONG VideoDebugLevel = 0

Definition at line 34 of file videoprt.c.

Referenced by VideoPortDebugPrint().

◆ VideoPortMaxObjectNumber

ULONG VideoPortMaxObjectNumber = -1
static

◆ VideoPortUseNewKey

BOOLEAN VideoPortUseNewKey = FALSE

◆ VpBaseVideo

BOOLEAN VpBaseVideo = FALSE

Definition at line 36 of file videoprt.c.

Referenced by IntLoadRegistryParameters(), and VideoPortVerifyAccessRanges().

◆ VpNoVesa

BOOLEAN VpNoVesa = FALSE

Definition at line 37 of file videoprt.c.

Referenced by IntLoadRegistryParameters(), and VideoPortIsNoVesa().