ReactOS  0.4.15-dev-3173-g40ee59d
videoprt.c
Go to the documentation of this file.
1 /*
2  * VideoPort driver
3  *
4  * Copyright (C) 2002-2004, 2007 ReactOS Team
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  *
20  */
21 
22 #include "videoprt.h"
23 
24 #include <stdio.h>
25 #include <ndk/exfuncs.h>
26 #include <ndk/obfuncs.h>
27 #include <ndk/rtlfuncs.h>
28 
29 #define NDEBUG
30 #include <debug.h>
31 
32 /* GLOBAL VARIABLES ***********************************************************/
33 
35 
38 
44 
45 /* PRIVATE FUNCTIONS **********************************************************/
46 
47 ULONG
48 NTAPI
52 {
53  return STATUS_SUCCESS;
54 }
55 
56 static
59  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
60 {
61  WCHAR DeviceBuffer[20];
63  WCHAR SymlinkBuffer[20];
64  UNICODE_STRING SymlinkName;
67 
68  /* Create a unicode device name. */
69  DeviceNumber = DeviceExtension->DeviceNumber;
70  swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
71 
72  /* Add entry to DEVICEMAP\VIDEO key in registry. */
74  L"VIDEO",
75  DeviceBuffer,
76  REG_SZ,
77  DeviceExtension->NewRegistryPath.Buffer,
78  DeviceExtension->NewRegistryPath.Length + sizeof(UNICODE_NULL));
79  if (!NT_SUCCESS(Status))
80  {
81  ERR_(VIDEOPRT, "Failed to create DEViCEMAP registry entry: 0x%X\n", Status);
82  return Status;
83  }
84 
86  L"VIDEO",
87  L"MaxObjectNumber",
88  REG_DWORD,
89  &DeviceNumber,
90  sizeof(DeviceNumber));
91  if (!NT_SUCCESS(Status))
92  {
93  ERR_(VIDEOPRT, "Failed to write MaxObjectNumber: 0x%X\n", Status);
94  return Status;
95  }
96 
97  /* Create symbolic link "\??\DISPLAYx" */
98  swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DeviceNumber + 1);
99  RtlInitUnicodeString(&SymlinkName, SymlinkBuffer);
100  RtlInitUnicodeString(&DeviceName, DeviceBuffer);
101  Status = IoCreateSymbolicLink(&SymlinkName, &DeviceName);
102  if (!NT_SUCCESS(Status))
103  {
104  ERR_(VIDEOPRT, "Failed to create symbolic link: 0x%X\n", Status);
105  return Status;
106  }
107 
108  /* Update MaxObjectNumber */
110 
111  return STATUS_SUCCESS;
112 }
113 
114 PVOID
115 NTAPI
119 {
120  PIMAGE_NT_HEADERS NtHeader;
121  ULONG Va;
122 
123  NtHeader = RtlImageNtHeader(BaseAddress);
124  if (NtHeader == NULL)
125  return NULL;
126 
128  return NULL;
129 
131  if (Va == 0)
132  return NULL;
133 
134  return (PVOID)((ULONG_PTR)BaseAddress + Va);
135 }
136 
137 VOID
138 NTAPI
140  IN PKDPC Dpc,
144 {
145  PVOID HwDeviceExtension =
146  &((PVIDEO_PORT_DEVICE_EXTENSION)DeferredContext)->MiniPortDeviceExtension;
148 }
149 
150 NTSTATUS
151 NTAPI
156  _In_ USHORT AdapterNumber,
157  _In_ USHORT DisplayNumber,
159 {
160  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
162  ULONG PciSlotNumber;
164  ULONG Size;
166  WCHAR DeviceBuffer[20];
168  PDEVICE_OBJECT DeviceObject_;
169 
170  if (DeviceObject == NULL)
171  DeviceObject = &DeviceObject_;
172 
173  /*
174  * Find the first free device number that can be used for video device
175  * object names and symlinks.
176  */
178  if (DeviceNumber == (ULONG)-1)
179  {
180  WARN_(VIDEOPRT, "Can't find free device number\n");
181  return STATUS_UNSUCCESSFUL;
182  }
183 
184  /*
185  * Create the device object.
186  */
187 
188  /* Create a unicode device name. */
189  swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
190  RtlInitUnicodeString(&DeviceName, DeviceBuffer);
191 
192  INFO_(VIDEOPRT, "HwDeviceExtension size is: 0x%x\n",
193  DriverExtension->InitializationData.HwDeviceExtensionSize);
194 
195  /* Create the device object. */
197  DriverExtension->InitializationData.HwDeviceExtensionSize;
199  Size,
200  &DeviceName,
202  0,
203  TRUE,
204  DeviceObject);
205 
206  if (!NT_SUCCESS(Status))
207  {
208  WARN_(VIDEOPRT, "IoCreateDevice call failed with status 0x%08x\n", Status);
209  return Status;
210  }
211 
212  /*
213  * Set the buffering strategy here. If you change this, remember
214  * to change VidDispatchDeviceControl too.
215  */
216 
217  (*DeviceObject)->Flags |= DO_BUFFERED_IO;
218 
219  /* Initialize device extension. */
220  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)((*DeviceObject)->DeviceExtension);
221  DeviceExtension->Common.Fdo = TRUE;
222  DeviceExtension->DeviceNumber = DeviceNumber;
223  DeviceExtension->DriverObject = DriverObject;
224  DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
225  DeviceExtension->FunctionalDeviceObject = *DeviceObject;
226  DeviceExtension->DriverExtension = DriverExtension;
227  DeviceExtension->SessionId = -1;
228  DeviceExtension->AdapterNumber = AdapterNumber;
229  DeviceExtension->DisplayNumber = DisplayNumber;
230 
231  InitializeListHead(&DeviceExtension->ChildDeviceList);
232 
233  /* Get the registry path associated with this device. */
235  DeviceExtension->AdapterNumber,
236  &DeviceExtension->RegistryPath);
237  if (!NT_SUCCESS(Status))
238  {
239  WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status);
241  *DeviceObject = NULL;
242  return Status;
243  }
244 
245  if (PhysicalDeviceObject != NULL)
246  {
247  /* Get bus number from the upper level bus driver. */
248  Size = sizeof(ULONG);
251  Size,
252  &DeviceExtension->SystemIoBusNumber,
253  &Size);
254  if (!NT_SUCCESS(Status))
255  {
256  WARN_(VIDEOPRT, "Couldn't get an information from bus driver. We will try to\n"
257  "use legacy detection method, but even that doesn't mean that\n"
258  "it will work.\n");
259  DeviceExtension->PhysicalDeviceObject = NULL;
260  }
261  }
262 
263  DeviceExtension->AdapterInterfaceType =
264  DriverExtension->InitializationData.AdapterInterfaceType;
265 
266  if (PhysicalDeviceObject != NULL)
267  {
268  /* Get bus type from the upper level bus driver. */
269  Size = sizeof(ULONG);
272  Size,
273  &DeviceExtension->AdapterInterfaceType,
274  &Size);
275 
276  /* Get bus device address from the upper level bus driver. */
277  Size = sizeof(ULONG);
280  Size,
281  &PciSlotNumber,
282  &Size);
283 
284  /* Convert slotnumber to PCI_SLOT_NUMBER */
285  SlotNumber.u.AsULONG = 0;
286  SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
287  SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
288  DeviceExtension->SystemIoSlotNumber = SlotNumber.u.AsULONG;
289  }
290 
291  InitializeListHead(&DeviceExtension->AddressMappingListHead);
292  InitializeListHead(&DeviceExtension->DmaAdapterList);
293 
294  KeInitializeDpc(&DeviceExtension->DpcObject,
296  DeviceExtension);
297 
298  KeInitializeMutex(&DeviceExtension->DeviceLock, 0);
299 
300  /* Attach the device. */
301  if ((PhysicalDeviceObject != NULL) && (DisplayNumber == 0))
303  *DeviceObject,
305 
306  Status = IntCreateNewRegistryPath(DeviceExtension);
307  if (!NT_SUCCESS(Status))
308  {
309  ERR_(VIDEOPRT, "IntCreateNewRegistryPath() failed with status 0x%08x\n", Status);
311  *DeviceObject = NULL;
312  return Status;
313  }
314 
315  IntSetupDeviceSettingsKey(DeviceExtension);
316 
317  /* Remove the initailizing flag */
318  (*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
319 
320  /* Set up the VIDEO/DEVICEMAP registry keys */
321  Status = IntVideoPortAddDeviceMapLink(DeviceExtension);
322  if (!NT_SUCCESS(Status))
323  {
324  ERR_(VIDEOPRT, "IntVideoPortAddDeviceMapLink() failed with status 0x%08x\n", Status);
326  *DeviceObject = NULL;
327  return Status;
328  }
329 
330  if (DisplayNumber == 0)
331  {
332  DriverExtension->InitializationData.StartingDeviceNumber++;
333  }
334 
335  return STATUS_SUCCESS;
336 }
337 
338 
339 NTSTATUS
340 NTAPI
345 {
346  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
348  VIDEO_PORT_CONFIG_INFO ConfigInfo;
350  UCHAR Again = FALSE;
351  BOOL LegacyDetection = FALSE;
352 
353  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
354 
355  /* Setup a ConfigInfo structure that we will pass to HwFindAdapter. */
356  RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO));
357  ConfigInfo.Length = sizeof(VIDEO_PORT_CONFIG_INFO);
358  ConfigInfo.AdapterInterfaceType = DeviceExtension->AdapterInterfaceType;
359  if (ConfigInfo.AdapterInterfaceType == PCIBus)
360  ConfigInfo.InterruptMode = LevelSensitive;
361  else
362  ConfigInfo.InterruptMode = Latched;
363  ConfigInfo.DriverRegistryPath = DriverExtension->RegistryPath.Buffer;
365  ConfigInfo.SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
366  ConfigInfo.BusInterruptLevel = DeviceExtension->InterruptLevel;
367  ConfigInfo.BusInterruptVector = DeviceExtension->InterruptVector;
368 
371  sizeof(SystemBasicInfo),
372  NULL);
373  if (NT_SUCCESS(Status))
374  {
377  }
378 
379  // FIXME: Check the adapter key and update VideoDebugLevel variable.
380 
381  /*
382  * Call miniport HwVidFindAdapter entry point to detect if
383  * particular device is present. There are two possible code
384  * paths. The first one is for Legacy drivers (NT4) and cases
385  * when we don't have information about what bus we're on. The
386  * second case is the standard one for Plug & Play drivers.
387  */
388  if (DeviceExtension->PhysicalDeviceObject == NULL)
389  {
390  LegacyDetection = TRUE;
391  }
392 
393  if (LegacyDetection)
394  {
395  ULONG BusNumber, MaxBuses;
396 
397  MaxBuses = DeviceExtension->AdapterInterfaceType == PCIBus ? PCI_MAX_BRIDGE_NUMBER : 1;
398 
399  for (BusNumber = 0; BusNumber < MaxBuses; BusNumber++)
400  {
401  DeviceExtension->SystemIoBusNumber =
402  ConfigInfo.SystemIoBusNumber = BusNumber;
403 
404  RtlZeroMemory(&DeviceExtension->MiniPortDeviceExtension,
405  DriverExtension->InitializationData.HwDeviceExtensionSize);
406 
407  /* FIXME: Need to figure out what string to pass as param 3. */
408  Status = DriverExtension->InitializationData.HwFindAdapter(
409  &DeviceExtension->MiniPortDeviceExtension,
410  DriverExtension->HwContext,
411  NULL,
412  &ConfigInfo,
413  &Again);
414 
416  {
417  continue;
418  }
419  else if (Status == NO_ERROR)
420  {
421  break;
422  }
423  else
424  {
425  ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status);
426  goto Failure;
427  }
428  }
429  }
430  else
431  {
432  /* FIXME: Need to figure out what string to pass as param 3. */
433  Status = DriverExtension->InitializationData.HwFindAdapter(
434  &DeviceExtension->MiniPortDeviceExtension,
435  DriverExtension->HwContext,
436  NULL,
437  &ConfigInfo,
438  &Again);
439  }
440 
441  if (Status != NO_ERROR)
442  {
443  ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status);
444  goto Failure;
445  }
446 
447  /*
448  * Now we know the device is present, so let's do all additional tasks
449  * such as creating symlinks or setting up interrupts and timer.
450  */
451 
452  /* FIXME: Allocate hardware resources for device. */
453 
454  /* Allocate interrupt for device. */
456  {
458  goto Failure;
459  }
460 
461  /* Allocate timer for device. */
463  {
464  if (DeviceExtension->InterruptObject != NULL)
465  IoDisconnectInterrupt(DeviceExtension->InterruptObject);
466  ERR_(VIDEOPRT, "IntVideoPortSetupTimer failed\n");
468  goto Failure;
469  }
470 
471  /* If the device can be reset, insert it in the list of resettable adapters */
472  InitializeListHead(&DeviceExtension->HwResetListEntry);
473  if (DriverExtension->InitializationData.HwResetHw != NULL)
474  {
476  &DeviceExtension->HwResetListEntry,
478  }
479 
480  /* Query children of the device. */
482 
483  INFO_(VIDEOPRT, "STATUS_SUCCESS\n");
484  return STATUS_SUCCESS;
485 
486 Failure:
487  RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
488  if (DeviceExtension->NextDeviceObject)
489  IoDetachDevice(DeviceExtension->NextDeviceObject);
491  return Status;
492 }
493 
494 VOID
495 FASTCALL
497  PKPROCESS *CallingProcess,
499 {
500  *CallingProcess = (PKPROCESS)PsGetCurrentProcess();
501  if (*CallingProcess != CsrProcess)
502  {
504  }
505 }
506 
507 VOID
508 FASTCALL
510  PKPROCESS *CallingProcess,
512 {
513  if (*CallingProcess != CsrProcess)
514  {
516  }
517 }
518 
519 VOID
520 FASTCALL
522 {
525  UNICODE_STRING Path = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control");
526  UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"SystemStartOptions");
530 
531  /* Initialize object attributes with the path we want */
533  &Path,
535  NULL,
536  NULL);
537 
538  /* Open the key */
539  Status = ZwOpenKey(&KeyHandle,
542  if (!NT_SUCCESS(Status))
543  {
544  VideoPortDebugPrint(Error, "ZwOpenKey failed (0x%x)\n", Status);
545  return;
546  }
547 
548  /* Find out how large our buffer should be */
549  Status = ZwQueryValueKey(KeyHandle,
550  &ValueName,
552  NULL,
553  0,
554  &Length);
556  {
557  VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status);
559  return;
560  }
561 
562  /* Allocate it */
564  if (!KeyInfo)
565  {
566  VideoPortDebugPrint(Error, "Out of memory\n");
568  return;
569  }
570 
571  /* Now for real this time */
572  Status = ZwQueryValueKey(KeyHandle,
573  &ValueName,
575  KeyInfo,
576  Length,
577  &NewLength);
579 
580  if (!NT_SUCCESS(Status))
581  {
582  VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status);
584  return;
585  }
586 
587  /* Sanity check */
588  if (KeyInfo->Type != REG_SZ)
589  {
590  VideoPortDebugPrint(Error, "Invalid type for SystemStartOptions\n");
592  return;
593  }
594 
595  /* Check if BASEVIDEO or NOVESA is present in the start options */
596  if (wcsstr((PWCHAR)KeyInfo->Data, L"BASEVIDEO"))
597  VpBaseVideo = TRUE;
598  if (wcsstr((PWCHAR)KeyInfo->Data, L"NOVESA"))
599  VpNoVesa = TRUE;
600 
602 
603  /* FIXME: Old ReactOS-compatibility... */
604  if (VpBaseVideo) VpNoVesa = TRUE;
605 
606  if (VpNoVesa)
607  VideoPortDebugPrint(Info, "VESA mode disabled\n");
608  else
609  VideoPortDebugPrint(Info, "VESA mode enabled\n");
610 
611  /* If we are in BASEVIDEO, create the volatile registry key for Win32k */
612  if (VpBaseVideo)
613  {
614  RtlInitUnicodeString(&Path, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\GraphicsDrivers\\BaseVideo");
615 
617  &Path,
619  NULL,
620  NULL);
621 
622  Status = ZwCreateKey(&KeyHandle,
623  KEY_WRITE,
625  0,
626  NULL,
628  NULL);
629  if (NT_SUCCESS(Status))
631  else
632  ERR_(VIDEOPRT, "Failed to create the BaseVideo key (0x%x)\n", Status);
633  }
634 
635  return;
636 }
637 
638 /* PUBLIC FUNCTIONS ***********************************************************/
639 
640 /*
641  * @implemented
642  */
643 ULONG
644 NTAPI
646  IN PVOID Context1,
647  IN PVOID Context2,
650 {
655  BOOLEAN PnpDriver = FALSE, LegacyDetection = FALSE;
656  static BOOLEAN FirstInitialization;
657 
658  TRACE_(VIDEOPRT, "VideoPortInitialize\n");
659 
660  if (!FirstInitialization)
661  {
662  FirstInitialization = TRUE;
666  }
667 
668  /* As a first thing do parameter checks. */
669  if (HwInitializationData->HwInitDataSize > sizeof(VIDEO_HW_INITIALIZATION_DATA))
670  {
671  ERR_(VIDEOPRT, "Invalid HwInitializationData\n");
673  }
674 
675  if ((HwInitializationData->HwFindAdapter == NULL) ||
676  (HwInitializationData->HwInitialize == NULL) ||
677  (HwInitializationData->HwStartIO == NULL))
678  {
679  ERR_(VIDEOPRT, "Invalid HwInitializationData\n");
681  }
682 
683  switch (HwInitializationData->HwInitDataSize)
684  {
685  /*
686  * NT4 drivers are special case, because we must use legacy method
687  * of detection instead of the Plug & Play one.
688  */
690  INFO_(VIDEOPRT, "We were loaded by a Windows NT miniport driver.\n");
691  break;
692 
694  INFO_(VIDEOPRT, "We were loaded by a Windows 2000 miniport driver.\n");
695  break;
696 
697  case sizeof(VIDEO_HW_INITIALIZATION_DATA):
698  INFO_(VIDEOPRT, "We were loaded by a Windows XP or later miniport driver.\n");
699  break;
700 
701  default:
702  ERR_(VIDEOPRT, "Invalid HwInitializationData size.\n");
703  return STATUS_UNSUCCESSFUL;
704  }
705 
706  /* Set dispatching routines */
709  DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
711  DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] =
713  DriverObject->DriverUnload = IntVideoPortUnload;
714 
715  /* Determine type of the miniport driver */
716  if ((HwInitializationData->HwInitDataSize >=
717  FIELD_OFFSET(VIDEO_HW_INITIALIZATION_DATA, HwQueryInterface)) &&
718  (HwInitializationData->HwSetPowerState != NULL) &&
719  (HwInitializationData->HwGetPowerState != NULL) &&
720  (HwInitializationData->HwGetVideoChildDescriptor != NULL))
721  {
722  INFO_(VIDEOPRT, "The miniport is a PnP miniport driver\n");
723  PnpDriver = TRUE;
724  }
725 
726  /* Check if legacy detection should be applied */
727  if (!PnpDriver || HwContext)
728  {
729  INFO_(VIDEOPRT, "Legacy detection for adapter interface %d\n",
730  HwInitializationData->AdapterInterfaceType);
731 
732  /* FIXME: Move the code for legacy detection
733  to another function and call it here */
734  LegacyDetection = TRUE;
735  }
736 
737  /*
738  * NOTE:
739  * The driver extension can be already allocated in case that we were
740  * called by legacy driver and failed detecting device. Some miniport
741  * drivers in that case adjust parameters and call VideoPortInitialize
742  * again.
743  */
745  if (DriverExtension == NULL)
746  {
748  DriverObject,
750  (PVOID *)&DriverExtension);
751  if (!NT_SUCCESS(Status))
752  {
753  ERR_(VIDEOPRT, "IoAllocateDriverObjectExtension failed 0x%x\n", Status);
754  return Status;
755  }
756 
757  /*
758  * Save the registry path. This should be done only once even if
759  * VideoPortInitialize is called multiple times.
760  */
761  if (RegistryPath->Length != 0)
762  {
763  DriverExtension->RegistryPath.Length = 0;
764  DriverExtension->RegistryPath.MaximumLength =
765  RegistryPath->Length + sizeof(UNICODE_NULL);
766  DriverExtension->RegistryPath.Buffer =
768  PagedPool,
769  DriverExtension->RegistryPath.MaximumLength,
770  'RTSU');
771  if (DriverExtension->RegistryPath.Buffer == NULL)
772  {
773  RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL);
775  }
776 
778  INFO_(VIDEOPRT, "RegistryPath: %wZ\n", &DriverExtension->RegistryPath);
779  }
780  else
781  {
782  RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL);
783  }
784  }
785 
786  /* Copy the correct miniport initialization data to the device extension. */
787  RtlCopyMemory(&DriverExtension->InitializationData,
789  HwInitializationData->HwInitDataSize);
790  if (HwInitializationData->HwInitDataSize <
792  {
793  RtlZeroMemory((PVOID)((ULONG_PTR)&DriverExtension->InitializationData +
794  HwInitializationData->HwInitDataSize),
796  HwInitializationData->HwInitDataSize);
797  }
798  DriverExtension->HwContext = HwContext;
799 
800  /*
801  * Plug & Play drivers registers the device in AddDevice routine.
802  * For legacy drivers we must do it now.
803  */
804  if (LegacyDetection)
805  {
807 
809  {
810  /* Power management */
812  }
813 
816  NULL,
817  DriverExtension->InitializationData.StartingDeviceNumber,
818  0,
819  &DeviceObject);
820  if (!NT_SUCCESS(Status))
821  {
822  ERR_(VIDEOPRT, "IntVideoPortCreateAdapterDeviceObject returned 0x%x\n", Status);
823  return Status;
824  }
825 
827  if (!NT_SUCCESS(Status))
828  ERR_(VIDEOPRT, "IntVideoPortFindAdapter returned 0x%x\n", Status);
829 
830  return Status;
831  }
832  else
833  {
834  DriverObject->DriverExtension->AddDevice = IntVideoPortAddDevice;
838 
839  return STATUS_SUCCESS;
840  }
841 }
842 
843 /*
844  * @implemented
845  */
846 VOID
848  IN VIDEO_DEBUG_LEVEL DebugPrintLevel,
849  IN PCHAR DebugMessage,
850  ...)
851 {
852  va_list ap;
853 
854  if (VideoDebugLevel >= DebugPrintLevel)
855  DebugPrintLevel = Error;
856 
857  va_start(ap, DebugMessage);
858  vDbgPrintEx(DPFLTR_IHVVIDEO_ID, DebugPrintLevel, DebugMessage, ap);
859  va_end(ap);
860 }
861 
862 /*
863  * @unimplemented
864  */
865 VOID
866 NTAPI
868  IN PVOID HwDeviceExtension,
871  IN ULONG UniqueId)
872 {
874 
875  INFO_(VIDEOPRT, "VideoPortLogError ErrorCode %d (0x%x) UniqueId %lu (0x%lx)\n",
876  ErrorCode, ErrorCode, UniqueId, UniqueId);
877  if (Vrp)
878  INFO_(VIDEOPRT, "Vrp->IoControlCode %lu (0x%lx)\n", Vrp->IoControlCode, Vrp->IoControlCode);
879 }
880 
881 /*
882  * @implemented
883  */
884 UCHAR
885 NTAPI
887 {
888  return KeGetCurrentIrql();
889 }
890 
892 {
897 
898 static
899 NTSTATUS
900 NTAPI
906  IN PVOID Context,
908 {
910 
911  INFO_(VIDEOPRT, "Found registry value for name %S: type %d, length %d\n",
913  return (*(CallbackContext->HwGetRegistryRoutine))(
914  CallbackContext->HwDeviceExtension,
915  CallbackContext->HwContext,
916  ValueName,
917  ValueData,
918  ValueLength);
919 }
920 
921 /*
922  * @unimplemented
923  */
924 
925 VP_STATUS
926 NTAPI
928  IN PVOID HwDeviceExtension,
930  IN UCHAR IsParameterFileName,
931  IN PMINIPORT_GET_REGISTRY_ROUTINE GetRegistryRoutine,
933 {
936  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
938 
939  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
940 
941  TRACE_(VIDEOPRT, "VideoPortGetRegistryParameters ParameterName %S, RegPath: %wZ\n",
942  ParameterName, &DeviceExtension->RegistryPath);
943 
944  Context.HwDeviceExtension = HwDeviceExtension;
945  Context.HwContext = HwContext;
946  Context.HwGetRegistryRoutine = GetRegistryRoutine;
947 
951 
953  DeviceExtension->RegistryPath.Buffer,
954  QueryTable,
955  &Context,
956  NULL);
957  if (!NT_SUCCESS(Status))
958  {
959  WARN_(VIDEOPRT, "VideoPortGetRegistryParameters could not find the "
960  "requested parameter\n");
962  }
963 
964  if (IsParameterFileName)
965  {
966  /* FIXME: need to read the contents of the file */
968  }
969 
970  return NO_ERROR;
971 }
972 
973 /*
974  * @implemented
975  */
976 VP_STATUS
977 NTAPI
979  IN PVOID HwDeviceExtension,
983 {
984  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
986 
987  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
988  TRACE_(VIDEOPRT, "VideoPortSetRegistryParameters ParameterName %S, RegPath: %wZ\n",
989  ValueName,
990  &DeviceExtension->RegistryPath);
993  DeviceExtension->RegistryPath.Buffer,
994  ValueName,
995  REG_BINARY,
996  ValueData,
997  ValueLength);
998  if (Status != NO_ERROR)
999  WARN_(VIDEOPRT, "VideoPortSetRegistryParameters error 0x%x\n", Status);
1000 
1001  return Status;
1002 }
1003 
1004 /*
1005  * @implemented
1006  */
1007 VP_STATUS
1008 NTAPI
1010  IN PVOID HwDeviceExtension,
1011  OUT PULONG VgaStatus)
1012 {
1013  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1014 
1015  TRACE_(VIDEOPRT, "VideoPortGetVgaStatus\n");
1016 
1017  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1019  {
1020  if (DeviceExtension->AdapterInterfaceType == PCIBus)
1021  {
1022  /* VgaStatus: 0 == VGA not enabled, 1 == VGA enabled. */
1023  /* Assumed for now */
1024  *VgaStatus = 1;
1025  return NO_ERROR;
1026  }
1027  }
1028 
1029  return ERROR_INVALID_FUNCTION;
1030 }
1031 
1032 /*
1033  * @implemented
1034  */
1035 PVOID
1036 NTAPI
1038  IN PVOID HwDeviceExtension,
1039  IN PVOID Unused1,
1040  IN ULONG Unused2,
1041  IN ULONG Length)
1042 {
1043  static PVOID RomImageBuffer = NULL;
1044  PKPROCESS CallingProcess;
1046 
1047  TRACE_(VIDEOPRT, "VideoPortGetRomImage(HwDeviceExtension 0x%X Length 0x%X)\n",
1048  HwDeviceExtension, Length);
1049 
1050  /* If the length is zero then free the existing buffer. */
1051  if (Length == 0)
1052  {
1053  if (RomImageBuffer != NULL)
1054  {
1055  ExFreePool(RomImageBuffer);
1056  RomImageBuffer = NULL;
1057  }
1058  return NULL;
1059  }
1060  else
1061  {
1062  /*
1063  * The DDK says we shouldn't use the legacy C0000 method but get the
1064  * rom base address from the corresponding pci or acpi register but
1065  * lets ignore that and use C0000 anyway. We have already mapped the
1066  * bios area into memory so we'll copy from there.
1067  */
1068 
1069  /* Copy the bios. */
1070  Length = min(Length, 0x10000);
1071  if (RomImageBuffer != NULL)
1072  {
1073  ExFreePool(RomImageBuffer);
1074  }
1075 
1076  RomImageBuffer = ExAllocatePool(PagedPool, Length);
1077  if (RomImageBuffer == NULL)
1078  {
1079  return NULL;
1080  }
1081 
1082  IntAttachToCSRSS(&CallingProcess, &ApcState);
1083  RtlCopyMemory(RomImageBuffer, (PUCHAR)0xC0000, Length);
1084  IntDetachFromCSRSS(&CallingProcess, &ApcState);
1085 
1086  return RomImageBuffer;
1087  }
1088 }
1089 
1090 /*
1091  * @implemented
1092  */
1093 BOOLEAN
1094 NTAPI
1096  IN PVOID HwDeviceExtension,
1097  IN PUCHAR RomBase,
1098  IN ULONG RomLength,
1099  IN PUCHAR String)
1100 {
1101  SIZE_T StringLength;
1102  BOOLEAN Found;
1103  PUCHAR SearchLocation;
1104 
1105  TRACE_(VIDEOPRT, "VideoPortScanRom RomBase %p RomLength 0x%x String %s\n", RomBase, RomLength, String);
1106 
1107  StringLength = strlen((PCHAR)String);
1108  Found = FALSE;
1109  for (SearchLocation = RomBase;
1110  !Found && SearchLocation < RomBase + RomLength - StringLength;
1111  SearchLocation++)
1112  {
1113  Found = (RtlCompareMemory(SearchLocation, String, StringLength) == StringLength);
1114  if (Found)
1115  {
1116  INFO_(VIDEOPRT, "Match found at %p\n", SearchLocation);
1117  }
1118  }
1119 
1120  return Found;
1121 }
1122 
1123 /*
1124  * @implemented
1125  */
1126 BOOLEAN
1127 NTAPI
1129  IN PVOID HwDeviceExtension,
1132  OUT PVOID Context)
1133 {
1134  BOOLEAN Ret;
1135  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1136  KIRQL OldIrql;
1137 
1138  switch (Priority)
1139  {
1140  case VpLowPriority:
1141  Ret = (*SynchronizeRoutine)(Context);
1142  break;
1143 
1144  case VpMediumPriority:
1145  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1146  if (DeviceExtension->InterruptObject == NULL)
1147  Ret = (*SynchronizeRoutine)(Context);
1148  else
1149  Ret = KeSynchronizeExecution(
1150  DeviceExtension->InterruptObject,
1152  Context);
1153  break;
1154 
1155  case VpHighPriority:
1157  if (OldIrql < SYNCH_LEVEL)
1159 
1160  Ret = (*SynchronizeRoutine)(Context);
1161 
1162  if (OldIrql < SYNCH_LEVEL)
1164  break;
1165 
1166  default:
1167  Ret = FALSE;
1168  }
1169 
1170  return Ret;
1171 }
1172 
1173 /*
1174  * @implemented
1175  */
1176 VP_STATUS
1177 NTAPI
1179  IN PVOID HwDeviceExtension,
1180  IN PVOID Reserved)
1181 {
1182  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1183  ULONG Status;
1184  VIDEO_CHILD_ENUM_INFO ChildEnumInfo;
1185  BOOLEAN bHaveLastMonitorID = FALSE;
1186  UCHAR LastMonitorID[10];
1187  ULONG Unused;
1188  UINT i;
1189  PDEVICE_OBJECT ChildDeviceObject;
1190  PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
1191 
1192  INFO_(VIDEOPRT, "Starting child device probe\n");
1193  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1195  {
1196  WARN_(VIDEOPRT, "Miniport's HwGetVideoChildDescriptor is NULL!\n");
1197  return NO_ERROR;
1198  }
1199 
1200  if (!IsListEmpty(&DeviceExtension->ChildDeviceList))
1201  {
1202  ERR_(VIDEOPRT, "FIXME: Support calling VideoPortEnumerateChildren again!\n");
1203  return NO_ERROR;
1204  }
1205 
1206  /* Enumerate the children */
1207  for (i = 1; ; i++)
1208  {
1209  Status = IoCreateDevice(DeviceExtension->DriverObject,
1210  sizeof(VIDEO_PORT_CHILD_EXTENSION) +
1212  NULL,
1215  FALSE,
1216  &ChildDeviceObject);
1217  if (!NT_SUCCESS(Status))
1218  return Status;
1219 
1220  ChildExtension = ChildDeviceObject->DeviceExtension;
1221 
1222  RtlZeroMemory(ChildExtension,
1223  sizeof(VIDEO_PORT_CHILD_EXTENSION) +
1225 
1226  ChildExtension->Common.Fdo = FALSE;
1227  ChildExtension->ChildId = i;
1228  ChildExtension->PhysicalDeviceObject = ChildDeviceObject;
1229  ChildExtension->DriverObject = DeviceExtension->DriverObject;
1230 
1231  /* Setup the ChildEnumInfo */
1232  ChildEnumInfo.Size = sizeof(ChildEnumInfo);
1233  ChildEnumInfo.ChildDescriptorSize = sizeof(ChildExtension->ChildDescriptor);
1234  ChildEnumInfo.ACPIHwId = 0;
1235 
1237  ChildEnumInfo.ChildHwDeviceExtension = VIDEO_PORT_GET_CHILD_EXTENSION(ChildExtension);
1238  else
1239  ChildEnumInfo.ChildHwDeviceExtension = NULL;
1240 
1241  ChildEnumInfo.ChildIndex = ChildExtension->ChildId;
1242 
1243  INFO_(VIDEOPRT, "Probing child: %d\n", ChildEnumInfo.ChildIndex);
1245  HwDeviceExtension,
1246  &ChildEnumInfo,
1247  &ChildExtension->ChildType,
1248  ChildExtension->ChildDescriptor,
1249  &ChildExtension->ChildId,
1250  &Unused);
1252  {
1253  if (ChildExtension->ChildType == Monitor)
1254  {
1255  // Check if the EDID is valid
1256  if (ChildExtension->ChildDescriptor[0] == 0x00 &&
1257  ChildExtension->ChildDescriptor[1] == 0xFF &&
1258  ChildExtension->ChildDescriptor[2] == 0xFF &&
1259  ChildExtension->ChildDescriptor[3] == 0xFF &&
1260  ChildExtension->ChildDescriptor[4] == 0xFF &&
1261  ChildExtension->ChildDescriptor[5] == 0xFF &&
1262  ChildExtension->ChildDescriptor[6] == 0xFF &&
1263  ChildExtension->ChildDescriptor[7] == 0x00)
1264  {
1265  if (bHaveLastMonitorID)
1266  {
1267  // Compare the previous monitor ID with the current one, break the loop if they are identical
1268  if (RtlCompareMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID)) == sizeof(LastMonitorID))
1269  {
1270  INFO_(VIDEOPRT, "Found identical Monitor ID two times, stopping enumeration\n");
1271  IoDeleteDevice(ChildDeviceObject);
1272  break;
1273  }
1274  }
1275 
1276  // Copy 10 bytes from the EDID, which can be used to uniquely identify the monitor
1277  RtlCopyMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID));
1278  bHaveLastMonitorID = TRUE;
1279 
1280  /* Mark it valid */
1281  ChildExtension->EdidValid = TRUE;
1282  }
1283  else
1284  {
1285  /* Mark it invalid */
1286  ChildExtension->EdidValid = FALSE;
1287  }
1288  }
1289  }
1290  else if (Status == VIDEO_ENUM_INVALID_DEVICE)
1291  {
1292  WARN_(VIDEOPRT, "Child device %d is invalid!\n", ChildEnumInfo.ChildIndex);
1293  IoDeleteDevice(ChildDeviceObject);
1294  continue;
1295  }
1296  else if (Status == VIDEO_ENUM_NO_MORE_DEVICES)
1297  {
1298  INFO_(VIDEOPRT, "End of child enumeration! (%d children enumerated)\n", i - 1);
1299  IoDeleteDevice(ChildDeviceObject);
1300  break;
1301  }
1302  else
1303  {
1304  WARN_(VIDEOPRT, "HwGetVideoChildDescriptor returned unknown status code 0x%x!\n", Status);
1305  IoDeleteDevice(ChildDeviceObject);
1306  break;
1307  }
1308 
1309  if (ChildExtension->ChildType == Monitor)
1310  {
1311  UINT j;
1312  PUCHAR p = ChildExtension->ChildDescriptor;
1313  INFO_(VIDEOPRT, "Monitor device enumerated! (ChildId = 0x%x)\n", ChildExtension->ChildId);
1314  for (j = 0; j < sizeof (ChildExtension->ChildDescriptor); j += 8)
1315  {
1316  INFO_(VIDEOPRT, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
1317  p[j + 0], p[j + 1], p[j + 2], p[j + 3],
1318  p[j + 4], p[j + 5], p[j + 6], p[j + 7]);
1319  }
1320  }
1321  else if (ChildExtension->ChildType == Other)
1322  {
1323  INFO_(VIDEOPRT, "\"Other\" device enumerated: DeviceId = %S\n", (PWSTR)ChildExtension->ChildDescriptor);
1324  }
1325  else
1326  {
1327  ERR_(VIDEOPRT, "HwGetVideoChildDescriptor returned unsupported type: %d\n", ChildExtension->ChildType);
1328  }
1329 
1330  /* Clear the init flag */
1331  ChildDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
1332 
1333  InsertTailList(&DeviceExtension->ChildDeviceList,
1334  &ChildExtension->ListEntry);
1335  }
1336 
1337  /* Trigger reenumeration by the PnP manager */
1339 
1340  return NO_ERROR;
1341 }
1342 
1343 /*
1344  * @unimplemented
1345  */
1346 VP_STATUS
1347 NTAPI
1349  IN PVOID HwDeviceExtension,
1350  IN OUT PVOID *SecondaryDeviceExtension,
1351  IN ULONG Flag)
1352 {
1354  PVIDEO_PORT_DEVICE_EXTENSION FirstDeviceExtension, DeviceExtension;
1355  NTSTATUS Status;
1356 
1357  ASSERT(SecondaryDeviceExtension);
1358 
1359  if (Flag != 0)
1360  {
1361  UNIMPLEMENTED;
1362  }
1363 
1364  FirstDeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1365 
1366  if (FirstDeviceExtension->DisplayNumber != 0)
1367  {
1368  DPRINT1("Calling VideoPortCreateSecondaryDisplay for InstanceId %lu\n",
1369  FirstDeviceExtension->DisplayNumber);
1370  }
1371 
1373  FirstDeviceExtension->DriverExtension,
1374  FirstDeviceExtension->PhysicalDeviceObject,
1375  FirstDeviceExtension->AdapterNumber,
1376  FirstDeviceExtension->NumberOfSecondaryDisplays + 1,
1377  &DeviceObject);
1378  if (!NT_SUCCESS(Status))
1379  {
1380  DPRINT1("IntVideoPortCreateAdapterDeviceObject() failed with status 0x%08x\n", Status);
1381  return ERROR_DEV_NOT_EXIST;
1382  }
1383 
1384  DeviceExtension = DeviceObject->DeviceExtension;
1385 
1386  /* Increment secondary display count */
1387  FirstDeviceExtension->NumberOfSecondaryDisplays++;
1388 
1389  *SecondaryDeviceExtension = DeviceExtension->MiniPortDeviceExtension;
1390  return NO_ERROR;
1391 }
1392 
1393 /*
1394  * @implemented
1395  */
1396 BOOLEAN
1397 NTAPI
1399  IN PVOID HwDeviceExtension,
1401  IN PVOID Context)
1402 {
1403  return KeInsertQueueDpc(
1404  &VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->DpcObject,
1406  (PVOID)Context);
1407 }
1408 
1409 /*
1410  * @implemented
1411  */
1412 PVOID
1413 NTAPI
1416 {
1417  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1418 
1419  TRACE_(VIDEOPRT, "VideoPortGetAssociatedDeviceExtension\n");
1420  DeviceExtension = ((PDEVICE_OBJECT)DeviceObject)->DeviceExtension;
1421  if (!DeviceExtension)
1422  return NULL;
1423  return DeviceExtension->MiniPortDeviceExtension;
1424 }
1425 
1426 /*
1427  * @implemented
1428  */
1429 VP_STATUS
1430 NTAPI
1432  IN PVOID HwDeviceExtension,
1433  IN OUT PVPOSVERSIONINFO VpOsVersionInfo)
1434 {
1436 
1437  Version.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
1438  if (VpOsVersionInfo->Size >= sizeof(VPOSVERSIONINFO))
1439  {
1440 #if 1
1442  {
1443  VpOsVersionInfo->MajorVersion = Version.dwMajorVersion;
1444  VpOsVersionInfo->MinorVersion = Version.dwMinorVersion;
1445  VpOsVersionInfo->BuildNumber = Version.dwBuildNumber;
1446  VpOsVersionInfo->ServicePackMajor = Version.wServicePackMajor;
1447  VpOsVersionInfo->ServicePackMinor = Version.wServicePackMinor;
1448  return NO_ERROR;
1449  }
1450  return ERROR_INVALID_PARAMETER;
1451 #else
1452  VpOsVersionInfo->MajorVersion = 5;
1453  VpOsVersionInfo->MinorVersion = 0;
1454  VpOsVersionInfo->BuildNumber = 2195;
1455  VpOsVersionInfo->ServicePackMajor = 4;
1456  VpOsVersionInfo->ServicePackMinor = 0;
1457  return NO_ERROR;
1458 #endif
1459  }
1460 
1461  return ERROR_INVALID_PARAMETER;
1462 }
1463 
1464 /*
1465  * @implemented
1466  */
1467 BOOLEAN
1468 NTAPI
1470  IN PVOID HwDeviceExtension,
1471  IN USHORT VendorId,
1472  IN USHORT DeviceId,
1473  IN UCHAR RevisionId,
1474  IN USHORT SubVendorId,
1475  IN USHORT SubSystemId,
1476  IN ULONG Flags)
1477 {
1478  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1481  IO_STACK_LOCATION IoStack;
1482  ULONG PciFlags = 0;
1483  NTSTATUS Status;
1484  BOOL DevicePresent;
1485 
1486  TRACE_(VIDEOPRT, "VideoPortCheckForDeviceExistence\n");
1487 
1489  {
1490  WARN_(VIDEOPRT, "VideoPortCheckForDeviceExistence: Unknown flags 0x%lx\n", Flags & ~(CDE_USE_REVISION | CDE_USE_SUBSYSTEM_IDS));
1491  return FALSE;
1492  }
1493 
1494  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1495 
1497  PciDevicePresentInterface.Version = 1;
1499  IoStack.Parameters.QueryInterface.Version = PciDevicePresentInterface.Version;
1501  IoStack.Parameters.QueryInterface.InterfaceType =
1502  &GUID_PCI_DEVICE_PRESENT_INTERFACE;
1503  Status = IopInitiatePnpIrp(DeviceExtension->NextDeviceObject,
1505  if (!NT_SUCCESS(Status))
1506  {
1507  WARN_(VIDEOPRT, "IopInitiatePnpIrp() failed! (Status 0x%lx)\n", Status);
1508  return FALSE;
1509  }
1510 
1511  if (Flags & CDE_USE_REVISION)
1512  PciFlags |= PCI_USE_REVISION;
1514  PciFlags |= PCI_USE_SUBSYSTEM_IDS;
1515 
1516  DevicePresent = PciDevicePresentInterface.IsDevicePresent(
1517  VendorId, DeviceId, RevisionId,
1518  SubVendorId, SubSystemId, PciFlags);
1519 
1520  PciDevicePresentInterface.InterfaceDereference(PciDevicePresentInterface.Context);
1521 
1522  return DevicePresent;
1523 }
1524 
1525 /*
1526  * @unimplemented
1527  */
1528 VP_STATUS
1529 NTAPI
1531  IN PVOID HwDeviceExtension,
1532  IN ULONG BugcheckCode,
1534  IN ULONG BugcheckDataSize)
1535 {
1536  UNIMPLEMENTED;
1537  return NO_ERROR;
1538 }
1539 
1540 /*
1541  * @implemented
1542  */
1543 LONGLONG
1544 NTAPI
1546  IN PVOID HwDeviceExtension,
1547  OUT PLONGLONG PerformanceFrequency OPTIONAL)
1548 {
1550 
1551  TRACE_(VIDEOPRT, "VideoPortQueryPerformanceCounter\n");
1552  Result = KeQueryPerformanceCounter((PLARGE_INTEGER)PerformanceFrequency);
1553  return Result.QuadPart;
1554 }
1555 
1556 /*
1557  * @implemented
1558  */
1559 VOID
1560 NTAPI
1562  IN PVOID HwDeviceExtension)
1563 {
1564  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1565 
1566  TRACE_(VIDEOPRT, "VideoPortAcquireDeviceLock\n");
1567  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1569  // ASSERT(Status == STATUS_SUCCESS);
1570 }
1571 
1572 /*
1573  * @implemented
1574  */
1575 VOID
1576 NTAPI
1578  IN PVOID HwDeviceExtension)
1579 {
1580  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1581 
1582  TRACE_(VIDEOPRT, "VideoPortReleaseDeviceLock\n");
1583  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1584  KeReleaseMutex(&DeviceExtension->DeviceLock, FALSE);
1585  //ASSERT(Status == STATUS_SUCCESS);
1586 }
1587 
1588 /*
1589  * @unimplemented
1590  */
1591 VOID
1592 NTAPI
1595  IN PVOID Data)
1596 {
1597  UNIMPLEMENTED;
1598 }
1599 
1600 /*
1601  * @implemented
1602  */
1603 PVOID
1604 NTAPI
1606  IN PVOID HwDeviceExtension,
1609 )
1610 {
1612 }
1613 
1614 /*
1615  * @implemented
1616  */
1617 BOOLEAN
1618 NTAPI
1620 {
1621  return VpNoVesa;
1622 }
VOID FASTCALL IntLoadRegistryParameters(VOID)
Definition: videoprt.c:521
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
NTSTATUS NTAPI IntVideoPortFindAdapter(IN PDRIVER_OBJECT DriverObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PDEVICE_OBJECT DeviceObject)
Definition: videoprt.c:341
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:65
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:325
signed char * PCHAR
Definition: retypes.h:7
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
PVOID NTAPI IntVideoPortImageDirectoryEntryToData(PVOID BaseAddress, ULONG Directory)
Definition: videoprt.c:116
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ typedef _In_ PVOID Unused
Definition: iotypes.h:1166
#define ASSERT_IRQL_LESS_OR_EQUAL(x)
Definition: debug.h:251
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:4155
#define IN
Definition: typedefs.h:39
UNICODE_STRING NewRegistryPath
Definition: videoprt.h:91
VOID NTAPI VpNotifyEaData(IN PDEVICE_OBJECT DeviceObject, IN PVOID Data)
Definition: videoprt.c:1593
NTSTATUS NTAPI IntVideoPortDispatchPower(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1118
LARGE_INTEGER NTAPI KeQueryPerformanceCounter(IN PLARGE_INTEGER PerformanceFreq)
Definition: timer.c:138
#define TAG_VIDEO_PORT
Definition: videoprt.h:38
KAPC_STATE
Definition: ketypes.h:1280
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PCI_MAX_BRIDGE_NUMBER
Definition: iotypes.h:3600
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
PDEVICE_OBJECT FunctionalDeviceObject
Definition: videoprt.h:88
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VIDEO_CHILD_TYPE ChildType
Definition: videoprt.h:121
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR _In_ ULONGLONG _In_ ULONGLONG _In_opt_ PEVENT_FILTER_DESCRIPTOR _Inout_opt_ PVOID CallbackContext
Definition: wmitypes.h:55
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
Definition: wdfdpc.h:107
NTSTATUS NTAPI IntCreateNewRegistryPath(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:358
VOID NTAPI IntVideoPortDeferredRoutine(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: videoprt.c:139
#define _In_opt_
Definition: ms_sal.h:309
BOOLEAN VpBaseVideo
Definition: videoprt.c:36
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
#define INFO_(ch,...)
Definition: debug.h:159
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1799
#define KeWaitForMutexObject
Definition: kefuncs.h:555
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
PVIDEO_HW_GET_CHILD_DESCRIPTOR HwGetVideoChildDescriptor
Definition: video.h:677
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
NTSTATUS NTAPI IntCreateRegistryPath(IN PCUNICODE_STRING DriverRegistryPath, IN ULONG DeviceNumber, OUT PUNICODE_STRING DeviceRegistryPath)
Definition: registry.c:542
#define IRP_MJ_SHUTDOWN
#define REG_BINARY
Definition: nt_native.h:1496
PVOID NTAPI VideoPortAllocateContiguousMemory(IN PVOID HwDeviceExtension, IN ULONG NumberOfBytes, IN PHYSICAL_ADDRESS HighestAcceptableAddress)
Definition: videoprt.c:1605
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
struct _DEVICE_OBJECT * PDEVICE_OBJECT
uint16_t * PWSTR
Definition: typedefs.h:56
VIDEO_HW_INITIALIZATION_DATA InitializationData
Definition: videoprt.h:72
unsigned char * PUCHAR
Definition: retypes.h:3
BOOLEAN NTAPI VideoPortScanRom(IN PVOID HwDeviceExtension, IN PUCHAR RomBase, IN ULONG RomLength, IN PUCHAR String)
Definition: videoprt.c:1095
BOOLEAN NTAPI IntVideoPortSetupTimer(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension)
Definition: timer.c:43
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define ERR_(ch,...)
Definition: debug.h:156
BOOLEAN NTAPI KeInsertQueueDpc(IN PKDPC Dpc, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: dpc.c:725
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
PVOID NTAPI VideoPortGetAssociatedDeviceExtension(IN PVOID DeviceObject)
Definition: videoprt.c:1414
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA _In_ PVOID HwContext
Definition: srb.h:897
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
VP_STATUS NTAPI VideoPortGetVersion(IN PVOID HwDeviceExtension, IN OUT PVPOSVERSIONINFO VpOsVersionInfo)
Definition: videoprt.c:1431
VP_STATUS NTAPI VideoPortRegisterBugcheckCallback(IN PVOID HwDeviceExtension, IN ULONG BugcheckCode, IN PVIDEO_BUGCHECK_CALLBACK Callback, IN ULONG BugcheckDataSize)
Definition: videoprt.c:1530
KMUTEX VideoPortInt10Mutex
Definition: videoprt.c:41
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
struct QueryRegistryCallbackContext QUERY_REGISTRY_CALLBACK_CONTEXT
ULONG ChildDescriptorSize
Definition: video.h:262
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension)
Definition: videoprt.h:140
LIST_ENTRY AddressMappingListHead
Definition: videoprt.h:101
PKPROCESS CsrProcess
Definition: videoprt.c:39
BOOLEAN NTAPI VideoPortSynchronizeExecution(IN PVOID HwDeviceExtension, IN VIDEO_SYNCHRONIZE_PRIORITY Priority, IN PMINIPORT_SYNCHRONIZE_ROUTINE SynchronizeRoutine, OUT PVOID Context)
Definition: videoprt.c:1128
NTSTATUS NTAPI IntSetupDeviceSettingsKey(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:297
struct _PCI_DEVICE_PRESENT_INTERFACE PCI_DEVICE_PRESENT_INTERFACE
uint16_t * PWCHAR
Definition: typedefs.h:56
#define swprintf
Definition: precomp.h:40
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
#define InsertTailList(ListHead, Entry)
NTSTATUS NTAPI IntVideoPortDispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:717
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189
#define NO_ERROR
Definition: dderror.h:5
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
Definition: wdfregistry.h:279
#define FASTCALL
Definition: nt_native.h:50
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
BOOLEAN(NTAPI * PMINIPORT_SYNCHRONIZE_ROUTINE)(IN PVOID Context)
Definition: video.h:523
VP_STATUS NTAPI VideoPortSetRegistryParameters(IN PVOID HwDeviceExtension, IN PWSTR ValueName, IN PVOID ValueData, IN ULONG ValueLength)
Definition: videoprt.c:978
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
LONGLONG NTAPI VideoPortQueryPerformanceCounter(IN PVOID HwDeviceExtension, OUT PLONGLONG PerformanceFrequency OPTIONAL)
Definition: videoprt.c:1545
#define PCI_USE_REVISION
Definition: iotypes.h:867
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
static USHORT USHORT * NewLength
uint32_t ULONG_PTR
Definition: typedefs.h:65
INTERFACE_TYPE AdapterInterfaceType
Definition: video.h:169
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
__GNU_EXTENSION typedef __int64 * PLONGLONG
Definition: ntbasedef.h:382
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ PFLT_GET_OPERATION_STATUS_CALLBACK CallbackRoutine
Definition: fltkernel.h:1035
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
struct QueryRegistryCallbackContext * PQUERY_REGISTRY_CALLBACK_CONTEXT
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine
Definition: nt_native.h:109
PVOID NTAPI IntVideoPortGetProcAddress(IN PVOID HwDeviceExtension, IN PUCHAR FunctionName)
Definition: funclist.c:100
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:110
#define va_end(ap)
Definition: acmsvcex.h:90
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
#define CDE_USE_REVISION
Definition: video.h:147
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:704
NTSYSAPI NTSTATUS WINAPI RtlWriteRegistryValue(ULONG, PCWSTR, PCWSTR, ULONG, PVOID, ULONG)
unsigned int BOOL
Definition: ntddk_ex.h:94
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:87
UCHAR NTAPI VideoPortGetCurrentIrql(VOID)
Definition: videoprt.c:886
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
VOID NTAPI IntVideoPortUnload(PDRIVER_OBJECT DriverObject)
Definition: dispatch.c:1174
VP_STATUS NTAPI VideoPortEnumerateChildren(IN PVOID HwDeviceExtension, IN PVOID Reserved)
Definition: videoprt.c:1178
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define VIDEO_PORT_GET_CHILD_EXTENSION(MiniportExtension)
Definition: videoprt.h:134
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
NTSYSAPI NTSTATUS NTAPI ZwQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:118
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:4155
struct _OSVERSIONINFOEXW RTL_OSVERSIONINFOEXW
PVIDEO_PORT_GET_PROC_ADDRESS VideoPortGetProcAddress
Definition: video.h:193
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:140
struct _VIDEO_HW_INITIALIZATION_DATA VIDEO_HW_INITIALIZATION_DATA
_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
#define _In_
Definition: ms_sal.h:308
KSPIN_LOCK HwResetAdaptersLock
Definition: videoprt.c:42
char * va_list
Definition: acmsvcex.h:78
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
static ULONG VideoPortMaxObjectNumber
Definition: videoprt.c:40
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
#define VIDEO_ENUM_MORE_DEVICES
Definition: video.h:139
return Found
Definition: dirsup.c:1270
struct _INTERFACE * PINTERFACE
NTSTATUS NTAPI IntVideoPortDispatchClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:432
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:126
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:901
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:152
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
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
KIRQL OldIrql
Definition: mm.h:1502
Status
Definition: gdiplustypes.h:24
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
#define KEY_WRITE
Definition: nt_native.h:1031
#define TRACE_(x)
Definition: compat.h:76
int64_t LONGLONG
Definition: typedefs.h:68
ULONGLONG SystemMemorySize
Definition: video.h:195
#define CDE_USE_SUBSYSTEM_IDS
Definition: video.h:146
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
VP_STATUS(NTAPI * PMINIPORT_GET_REGISTRY_ROUTINE)(IN PVOID HwDeviceExtension, IN PVOID Context, IN OUT PWSTR ValueName, IN OUT PVOID ValueData, IN ULONG ValueLength)
Definition: video.h:510
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
VP_STATUS NTAPI VideoPortGetVgaStatus(IN PVOID HwDeviceExtension, OUT PULONG VgaStatus)
Definition: videoprt.c:1009
_In_ PKSYNCHRONIZE_ROUTINE SynchronizeRoutine
Definition: kefuncs.h:536
#define ASSERT(a)
Definition: mode.c:44
ULONG VideoDebugLevel
Definition: videoprt.c:34
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FILE_DEVICE_VIDEO
Definition: winioctl.h:141
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
ULONG NTAPI DriverEntry(IN PVOID Context1, IN PVOID Context2)
Definition: videoprt.c:49
#define SIZE_OF_NT4_VIDEO_HW_INITIALIZATION_DATA
Definition: video.h:119
Definition: video.h:273
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
Definition: xml2sdb.h:79
VOID NTAPI VideoPortLogError(IN PVOID HwDeviceExtension, IN PVIDEO_REQUEST_PACKET Vrp OPTIONAL, IN VP_STATUS ErrorCode, IN ULONG UniqueId)
Definition: videoprt.c:867
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
NTSTATUS NTAPI IntVideoPortDispatchSystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1152
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
va_start(ap, x)
BOOL Error
Definition: chkdsk.c:66
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1]
Definition: videoprt.h:113
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:361
#define IRP_MN_QUERY_INTERFACE
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct _VIDEO_PORT_CONFIG_INFO VIDEO_PORT_CONFIG_INFO
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
BOOLEAN VpNoVesa
Definition: videoprt.c:37
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:651
unsigned char UCHAR
Definition: xmlstorage.h:181
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3375
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
#define IRP_MJ_POWER
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
VIDEO_SYNCHRONIZE_PRIORITY
Definition: video.h:534
static const WCHAR L[]
Definition: oid.c:1250
PWSTR DriverRegistryPath
Definition: video.h:194
NTSTATUS NTAPI IntVideoPortAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: dispatch.c:334
VOID(NTAPI * PMINIPORT_DPC_ROUTINE)(IN PVOID HwDeviceExtension, IN PVOID Context)
Definition: video.h:518
Definition: ketypes.h:687
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
_In_opt_ PWSTR _In_ PWSTR ParameterName
Definition: cdrom.h:960
VOID NTAPI VideoPortAcquireDeviceLock(IN PVOID HwDeviceExtension)
Definition: videoprt.c:1561
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1877
_Out_ PNDIS_HANDLE _Out_ PUINT _In_ PNDIS_STRING _In_ NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress
Definition: ndis.h:3227
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
#define SYNCH_LEVEL
Definition: env_spec_w32.h:704
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
#define IRP_MJ_SYSTEM_CONTROL
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT _In_ PTDI_PNP_CONTEXT Context2
Definition: tdikrnl.h:1094
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:86
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:456
struct _VIDEO_PORT_DEVICE_EXTENSTION VIDEO_PORT_DEVICE_EXTENSION
VOID VideoPortDebugPrint(IN VIDEO_DEBUG_LEVEL DebugPrintLevel, IN PCHAR DebugMessage,...)
Definition: videoprt.c:847
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
VOID(NTAPI * PVIDEO_BUGCHECK_CALLBACK)(IN PVOID HwDeviceExtension, IN ULONG BugcheckCode, IN PUCHAR Buffer, IN ULONG BufferSize)
Definition: video.h:527
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:2342
PRTL_UNICODE_STRING_BUFFER Path
Definition: video.h:270
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:496
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
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
unsigned short USHORT
Definition: pedump.c:61
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
BOOLEAN NTAPI IntVideoPortSetupInterrupt(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PVIDEO_PORT_CONFIG_INFO ConfigInfo)
Definition: interrupt.c:45
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1679
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT Context1
Definition: tdikrnl.h:1094
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
static NTSTATUS IntVideoPortAddDeviceMapLink(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: videoprt.c:58
ULONG NTAPI VideoPortInitialize(IN PVOID Context1, IN PVOID Context2, IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData, IN PVOID HwContext)
Definition: videoprt.c:645
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define _Out_opt_
Definition: ms_sal.h:346
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1035
unsigned int * PULONG
Definition: retypes.h:1
BOOLEAN NTAPI VideoPortIsNoVesa(VOID)
Definition: videoprt.c:1619
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
PVOID NTAPI MmAllocateContiguousMemory(IN SIZE_T NumberOfBytes, IN PHYSICAL_ADDRESS HighestAcceptableAddress)
Definition: contmem.c:626
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:84
#define DPRINT1
Definition: precomp.h:8
#define RtlImageNtHeader
Definition: compat.h:665
NTSTATUS NTAPI IntVideoPortDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1086
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
struct tagContext Context
Definition: acpixf.h:1034
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
#define OUT
Definition: typedefs.h:40
NTSTATUS NTAPI IntVideoPortDispatchOpen(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:369
VIDEO_DEBUG_LEVEL
Definition: video.h:579
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:127
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:509
unsigned int ULONG
Definition: retypes.h:1
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
base for all directory entries
Definition: entries.h:138
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNIMPLEMENTED
Definition: debug.h:115
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
RTL_STATIC_LIST_HEAD(HwResetAdaptersList)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
BOOLEAN NTAPI KeSynchronizeExecution(IN OUT PKINTERRUPT Interrupt, IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, IN PVOID SynchronizeContext OPTIONAL)
Definition: interrupt.c:165
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
LIST_ENTRY HwResetAdaptersList
LONG VP_STATUS
Definition: video.h:153
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
PVOID ChildHwDeviceExtension
Definition: video.h:265
PCI_INTERFACE PciDevicePresentInterface
Definition: devhere.c:18
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
PVOID NTAPI VideoPortGetRomImage(IN PVOID HwDeviceExtension, IN PVOID Unused1, IN ULONG Unused2, IN ULONG Length)
Definition: videoprt.c:1037
#define STATUS_SUCCESS
Definition: shellext.h:65
#define SIZE_OF_W2K_VIDEO_HW_INITIALIZATION_DATA
Definition: video.h:120
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1229
GLfloat GLfloat p
Definition: glext.h:8902
#define RTL_REGISTRY_DEVICEMAP
Definition: nt_native.h:165
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
VP_STATUS NTAPI VideoPortGetRegistryParameters(IN PVOID HwDeviceExtension, IN PWSTR ParameterName, IN UCHAR IsParameterFileName, IN PMINIPORT_GET_REGISTRY_ROUTINE GetRegistryRoutine, IN PVOID HwContext)
Definition: videoprt.c:927
_In_ BOOLEAN _In_ USHORT Directory
Definition: rtlfuncs.h:3885
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:98
#define RTL_QUERY_REGISTRY_REQUIRED
Definition: nt_native.h:132
#define REG_DWORD
Definition: sdbapi.c:596
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define VIDEO_ENUM_NO_MORE_DEVICES
Definition: video.h:140
NTSTATUS NTAPI IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject, IN PIO_STATUS_BLOCK IoStatusBlock, IN UCHAR MinorFunction, IN PIO_STACK_LOCATION Stack)
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
#define WARN_(ch,...)
Definition: debug.h:157
BOOLEAN NTAPI VideoPortQueueDpc(IN PVOID HwDeviceExtension, IN PMINIPORT_DPC_ROUTINE CallbackRoutine, IN PVOID Context)
Definition: videoprt.c:1398
PMINIPORT_GET_REGISTRY_ROUTINE HwGetRegistryRoutine
Definition: videoprt.c:895
VP_STATUS NTAPI VideoPortCreateSecondaryDisplay(IN PVOID HwDeviceExtension, IN OUT PVOID *SecondaryDeviceExtension, IN ULONG Flag)
Definition: videoprt.c:1348
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
* PKAPC_STATE
Definition: ketypes.h:1280
ULONG BusInterruptVector
Definition: video.h:171
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA * HwInitializationData
Definition: srb.h:897
#define PCI_USE_SUBSYSTEM_IDS
Definition: iotypes.h:866
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: videoprt.c:1469
KINTERRUPT_MODE InterruptMode
Definition: video.h:172
VOID NTAPI VideoPortReleaseDeviceLock(IN PVOID HwDeviceExtension)
Definition: videoprt.c:1577
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define VIDEO_ENUM_INVALID_DEVICE
Definition: video.h:141
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define REG_SZ
Definition: layer.c:22
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:271
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675