ReactOS  0.4.15-dev-4934-gfd1e799
resource.c
Go to the documentation of this file.
1 /*
2  * VideoPort driver
3  *
4  * Copyright (C) 2002 - 2005 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 #define NDEBUG
25 #include <debug.h>
26 
27 /* PRIVATE FUNCTIONS **********************************************************/
28 
32  IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
33  OUT PVIDEO_ACCESS_RANGE *AccessRanges,
34  OUT PULONG AccessRangeCount)
35 {
36  PCI_COMMON_CONFIG PciConfig;
38 
39  if (!DriverExtension->InitializationData.HwGetLegacyResources &&
40  !DriverExtension->InitializationData.HwLegacyResourceCount)
41  {
42  /* No legacy resources to report */
43  *AccessRangeCount = 0;
44  return STATUS_SUCCESS;
45  }
46 
47  if (DriverExtension->InitializationData.HwGetLegacyResources)
48  {
50  DeviceExtension->SystemIoBusNumber,
51  DeviceExtension->SystemIoSlotNumber,
52  &PciConfig,
53  sizeof(PciConfig));
54  if (ReadLength != sizeof(PciConfig))
55  {
56  /* This device doesn't exist */
57  return STATUS_NO_SUCH_DEVICE;
58  }
59 
60  DriverExtension->InitializationData.HwGetLegacyResources(PciConfig.VendorID,
61  PciConfig.DeviceID,
62  AccessRanges,
63  AccessRangeCount);
64  }
65  else
66  {
67  *AccessRanges = DriverExtension->InitializationData.HwLegacyResourceList;
68  *AccessRangeCount = DriverExtension->InitializationData.HwLegacyResourceCount;
69  }
70 
71  INFO_(VIDEOPRT, "Got %d legacy access ranges\n", *AccessRangeCount);
72 
73  return STATUS_SUCCESS;
74 }
75 
79  IN PIO_STACK_LOCATION IrpStack,
80  IN PIRP Irp)
81 {
84  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
85  PVIDEO_ACCESS_RANGE AccessRanges;
86  ULONG AccessRangeCount, ListSize, i;
88  PIO_RESOURCE_REQUIREMENTS_LIST OldResList = IrpStack->Parameters.FilterResourceRequirements.IoResourceRequirementList;
89  PIO_RESOURCE_DESCRIPTOR CurrentDescriptor;
91 
92  DriverObject = DeviceObject->DriverObject;
94  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
95 
96  Status = IntVideoPortGetLegacyResources(DriverExtension, DeviceExtension, &AccessRanges, &AccessRangeCount);
97  if (!NT_SUCCESS(Status))
98  return Status;
99  if (!AccessRangeCount)
100  {
101  /* No legacy resources to report */
102  return Irp->IoStatus.Status;
103  }
104 
105  /* OK, we've got the access ranges now. Let's set up the resource requirements list */
106 
107  if (OldResList)
108  {
109  /* Already one there so let's add to it */
110  ListSize = OldResList->ListSize + sizeof(IO_RESOURCE_DESCRIPTOR) * AccessRangeCount;
111  ResList = ExAllocatePool(NonPagedPool,
112  ListSize);
113  if (!ResList) return STATUS_NO_MEMORY;
114 
115  RtlCopyMemory(ResList, OldResList, OldResList->ListSize);
116 
117  ASSERT(ResList->AlternativeLists == 1);
118 
119  ResList->ListSize = ListSize;
120  ResList->List[0].Count += AccessRangeCount;
121 
122  CurrentDescriptor = (PIO_RESOURCE_DESCRIPTOR)((PUCHAR)ResList + OldResList->ListSize);
123 
124  ExFreePool(OldResList);
125  Irp->IoStatus.Information = 0;
126  }
127  else
128  {
129  /* We need to make a new one */
130  ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR) * (AccessRangeCount - 1);
131  ResList = ExAllocatePool(NonPagedPool,
132  ListSize);
133  if (!ResList) return STATUS_NO_MEMORY;
134 
135  RtlZeroMemory(ResList, ListSize);
136 
137  /* We need to initialize some fields */
138  ResList->ListSize = ListSize;
139  ResList->InterfaceType = DeviceExtension->AdapterInterfaceType;
140  ResList->BusNumber = DeviceExtension->SystemIoBusNumber;
141  ResList->SlotNumber = DeviceExtension->SystemIoSlotNumber;
142  ResList->AlternativeLists = 1;
143  ResList->List[0].Version = 1;
144  ResList->List[0].Revision = 1;
145  ResList->List[0].Count = AccessRangeCount;
146 
147  CurrentDescriptor = ResList->List[0].Descriptors;
148  }
149 
150  for (i = 0; i < AccessRangeCount; i++)
151  {
152  /* This is a required resource */
153  CurrentDescriptor->Option = 0;
154 
155  if (AccessRanges[i].RangeInIoSpace)
156  CurrentDescriptor->Type = CmResourceTypePort;
157  else
158  CurrentDescriptor->Type = CmResourceTypeMemory;
159 
160  CurrentDescriptor->ShareDisposition =
162 
163  CurrentDescriptor->Flags = 0;
164 
165  if (CurrentDescriptor->Type == CmResourceTypePort)
166  {
167  CurrentDescriptor->u.Port.Length = AccessRanges[i].RangeLength;
168  CurrentDescriptor->u.Port.MinimumAddress = AccessRanges[i].RangeStart;
169  CurrentDescriptor->u.Port.MaximumAddress.QuadPart = AccessRanges[i].RangeStart.QuadPart + AccessRanges[i].RangeLength - 1;
170  CurrentDescriptor->u.Port.Alignment = 1;
171  if (AccessRanges[i].RangePassive & VIDEO_RANGE_PASSIVE_DECODE)
172  CurrentDescriptor->Flags |= CM_RESOURCE_PORT_PASSIVE_DECODE;
173  if (AccessRanges[i].RangePassive & VIDEO_RANGE_10_BIT_DECODE)
174  CurrentDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE;
175  }
176  else
177  {
178  CurrentDescriptor->u.Memory.Length = AccessRanges[i].RangeLength;
179  CurrentDescriptor->u.Memory.MinimumAddress = AccessRanges[i].RangeStart;
180  CurrentDescriptor->u.Memory.MaximumAddress.QuadPart = AccessRanges[i].RangeStart.QuadPart + AccessRanges[i].RangeLength - 1;
181  CurrentDescriptor->u.Memory.Alignment = 1;
182  CurrentDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE;
183  }
184 
185  CurrentDescriptor++;
186  }
187 
188  Irp->IoStatus.Information = (ULONG_PTR)ResList;
189 
190  return STATUS_SUCCESS;
191 }
192 
195  IN HANDLE Process,
197  IN ULONG SizeInBytes,
198  IN ULONG Protect,
200 {
201  OBJECT_ATTRIBUTES ObjAttribs;
203  HANDLE hMemObj;
205  SIZE_T Size;
206 
207  /* Initialize object attribs */
208  RtlInitUnicodeString(&UnicodeString, L"\\Device\\PhysicalMemory");
209  InitializeObjectAttributes(&ObjAttribs,
210  &UnicodeString,
212  NULL, NULL);
213 
214  /* Open physical memory section */
215  Status = ZwOpenSection(&hMemObj, SECTION_ALL_ACCESS, &ObjAttribs);
216  if (!NT_SUCCESS(Status))
217  {
218  WARN_(VIDEOPRT, "ZwOpenSection() failed! (0x%x)\n", Status);
219  return Status;
220  }
221 
222  /* Map view of section */
223  Size = SizeInBytes;
224  Status = ZwMapViewOfSection(hMemObj,
225  Process,
227  0,
228  Size,
230  &Size,
231  ViewUnmap,
232  0,
233  Protect);
234  ZwClose(hMemObj);
235  if (!NT_SUCCESS(Status))
236  {
237  WARN_(VIDEOPRT, "ZwMapViewOfSection() failed! (0x%x)\n", Status);
238  }
239 
240  return Status;
241 }
242 
243 
244 PVOID NTAPI
246  IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
247  IN PHYSICAL_ADDRESS IoAddress,
248  IN ULONG NumberOfUchars,
249  IN ULONG InIoSpace,
252 {
254  PVIDEO_PORT_ADDRESS_MAPPING AddressMapping;
256  PVOID MappedAddress;
258 
259  INFO_(VIDEOPRT, "- IoAddress: %lx\n", IoAddress.u.LowPart);
260  INFO_(VIDEOPRT, "- NumberOfUchars: %lx\n", NumberOfUchars);
261  INFO_(VIDEOPRT, "- InIoSpace: %x\n", InIoSpace);
262 
263  InIoSpace &= ~VIDEO_MEMORY_SPACE_DENSE;
264  if ((InIoSpace & VIDEO_MEMORY_SPACE_P6CACHE) != 0)
265  {
266  INFO_(VIDEOPRT, "VIDEO_MEMORY_SPACE_P6CACHE not supported, turning off\n");
267  InIoSpace &= ~VIDEO_MEMORY_SPACE_P6CACHE;
268  }
269 
270  if (ProcessHandle != NULL && (InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) == 0)
271  {
272  INFO_(VIDEOPRT, "ProcessHandle is not NULL (0x%x) but InIoSpace does not have "
273  "VIDEO_MEMORY_SPACE_USER_MODE set! Setting "
274  "VIDEO_MEMORY_SPACE_USER_MODE.\n",
275  ProcessHandle);
276  InIoSpace |= VIDEO_MEMORY_SPACE_USER_MODE;
277  }
278  else if (ProcessHandle == NULL && (InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) != 0)
279  {
280  INFO_(VIDEOPRT, "ProcessHandle is NULL (0x%x) but InIoSpace does have "
281  "VIDEO_MEMORY_SPACE_USER_MODE set! Setting ProcessHandle "
282  "to NtCurrentProcess()\n",
283  ProcessHandle);
285  }
286 
287  if ((InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) == 0 &&
288  !IsListEmpty(&DeviceExtension->AddressMappingListHead))
289  {
290  Entry = DeviceExtension->AddressMappingListHead.Flink;
291  while (Entry != &DeviceExtension->AddressMappingListHead)
292  {
293  AddressMapping = CONTAINING_RECORD(
294  Entry,
296  List);
297  if (IoAddress.QuadPart == AddressMapping->IoAddress.QuadPart &&
298  NumberOfUchars <= AddressMapping->NumberOfUchars)
299  {
300  {
301  AddressMapping->MappingCount++;
302  if (Status)
303  *Status = NO_ERROR;
304  return AddressMapping->MappedAddress;
305  }
306  }
307  Entry = Entry->Flink;
308  }
309  }
310 
311  AddressSpace = (ULONG)InIoSpace;
314  DeviceExtension->AdapterInterfaceType,
315  DeviceExtension->SystemIoBusNumber,
316  IoAddress,
317  &AddressSpace,
319  {
320  if (Status)
322 
323  return NULL;
324  }
325 
326  /* I/O space */
327  if (AddressSpace != 0)
328  {
329  ASSERT(0 == TranslatedAddress.u.HighPart);
330  if (Status)
331  *Status = NO_ERROR;
332 
333  return (PVOID)(ULONG_PTR)TranslatedAddress.u.LowPart;
334  }
335 
336  /* user space */
337  if ((InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) != 0)
338  {
339  NTSTATUS NtStatus;
340  MappedAddress = NULL;
343  NumberOfUchars,
344  PAGE_READWRITE/* | PAGE_WRITECOMBINE*/,
345  &MappedAddress);
346  if (!NT_SUCCESS(NtStatus))
347  {
348  WARN_(VIDEOPRT, "IntVideoPortMapPhysicalMemory() failed! (0x%x)\n", NtStatus);
349  if (Status)
350  *Status = NO_ERROR;
351  return NULL;
352  }
353  INFO_(VIDEOPRT, "Mapped user address = 0x%08x\n", MappedAddress);
354  }
355  else /* kernel space */
356  {
357  MappedAddress = MmMapIoSpace(
359  NumberOfUchars,
360  MmNonCached);
361  }
362 
363  if (MappedAddress != NULL)
364  {
365  if (Status)
366  {
367  *Status = NO_ERROR;
368  }
369  if ((InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) == 0)
370  {
371  AddressMapping = ExAllocatePoolWithTag(
372  PagedPool,
375 
376  if (AddressMapping == NULL)
377  return MappedAddress;
378 
379  RtlZeroMemory(AddressMapping, sizeof(VIDEO_PORT_ADDRESS_MAPPING));
380  AddressMapping->NumberOfUchars = NumberOfUchars;
381  AddressMapping->IoAddress = IoAddress;
382  AddressMapping->SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
383  AddressMapping->MappedAddress = MappedAddress;
384  AddressMapping->MappingCount = 1;
386  &DeviceExtension->AddressMappingListHead,
387  &AddressMapping->List);
388  }
389 
390  return MappedAddress;
391  }
392 
393  if (Status)
394  *Status = NO_ERROR;
395 
396  return NULL;
397 }
398 
399 VOID NTAPI
401  IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
402  IN PVOID MappedAddress)
403 {
404  PVIDEO_PORT_ADDRESS_MAPPING AddressMapping;
407 
408  Entry = DeviceExtension->AddressMappingListHead.Flink;
409  while (Entry != &DeviceExtension->AddressMappingListHead)
410  {
411  AddressMapping = CONTAINING_RECORD(
412  Entry,
414  List);
415  if (AddressMapping->MappedAddress == MappedAddress)
416  {
417  ASSERT(AddressMapping->MappingCount > 0);
418  AddressMapping->MappingCount--;
419  if (AddressMapping->MappingCount == 0)
420  {
422  AddressMapping->MappedAddress,
423  AddressMapping->NumberOfUchars);
425  ExFreePool(AddressMapping);
426  }
427  return;
428  }
429 
430  Entry = Entry->Flink;
431  }
432 
433  /* If there was no kernelmode mapping for the given address found we assume
434  * that the given address is a usermode mapping and try to unmap it.
435  *
436  * FIXME: Is it ok to use NtCurrentProcess?
437  */
438  Status = ZwUnmapViewOfSection(NtCurrentProcess(), MappedAddress);
439  if (!NT_SUCCESS(Status))
440  {
441  WARN_(VIDEOPRT, "Warning: Mapping for address 0x%p not found!\n", MappedAddress);
442  }
443 }
444 
445 /* PUBLIC FUNCTIONS ***********************************************************/
446 
447 /*
448  * @implemented
449  */
450 
451 PVOID NTAPI
453  IN PVOID HwDeviceExtension,
454  IN PHYSICAL_ADDRESS IoAddress,
455  IN ULONG NumberOfUchars,
456  IN UCHAR InIoSpace)
457 {
458  TRACE_(VIDEOPRT, "VideoPortGetDeviceBase\n");
459  return IntVideoPortMapMemory(
460  VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
461  IoAddress,
462  NumberOfUchars,
463  InIoSpace,
464  NULL,
465  NULL);
466 }
467 
468 /*
469  * @implemented
470  */
471 
472 VOID NTAPI
474  IN PVOID HwDeviceExtension,
475  IN PVOID MappedAddress)
476 {
477  TRACE_(VIDEOPRT, "VideoPortFreeDeviceBase\n");
479  VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
480  MappedAddress);
481 }
482 
483 /*
484  * @unimplemented
485  */
486 
489  IN PVOID HwDeviceExtension,
491  IN PULONG Length,
492  IN PULONG InIoSpace,
494  IN ULONG BankLength,
495  IN UCHAR ReadWriteBank,
496  IN PBANKED_SECTION_ROUTINE BankRoutine,
497  IN PVOID Context)
498 {
499  TRACE_(VIDEOPRT, "VideoPortMapBankedMemory\n");
501  return ERROR_INVALID_FUNCTION;
502 }
503 
504 
505 /*
506  * @implemented
507  */
508 
511  IN PVOID HwDeviceExtension,
513  IN PULONG Length,
514  IN PULONG InIoSpace,
516 {
517  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
519 
520  TRACE_(VIDEOPRT, "VideoPortMapMemory\n");
521  INFO_(VIDEOPRT, "- *VirtualAddress: 0x%x\n", *VirtualAddress);
522 
523  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
525  DeviceExtension,
527  *Length,
528  *InIoSpace,
530  &Status);
531 
532  return Status;
533 }
534 
535 /*
536  * @implemented
537  */
538 
541  IN PVOID HwDeviceExtension,
544 {
545  TRACE_(VIDEOPRT, "VideoPortFreeDeviceBase\n");
546 
548  VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
550 
551  return NO_ERROR;
552 }
553 
554 /*
555  * @implemented
556  */
557 
560  IN PVOID HwDeviceExtension,
561  IN ULONG NumRequestedResources,
562  IN PIO_RESOURCE_DESCRIPTOR RequestedResources OPTIONAL,
563  IN ULONG NumAccessRanges,
564  IN PVIDEO_ACCESS_RANGE AccessRanges,
565  IN PVOID VendorId,
566  IN PVOID DeviceId,
567  OUT PULONG Slot)
568 {
569  PCI_SLOT_NUMBER PciSlotNumber;
571  ULONG FunctionNumber;
575  UINT AssignedCount = 0;
576  CM_FULL_RESOURCE_DESCRIPTOR *FullList;
578  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
580  USHORT VendorIdToFind;
581  USHORT DeviceIdToFind;
583  PVIDEO_ACCESS_RANGE LegacyAccessRanges;
584  ULONG LegacyAccessRangeCount;
586  ULONG ListSize;
588  BOOLEAN DeviceAndVendorFound = FALSE;
589 
590  TRACE_(VIDEOPRT, "VideoPortGetAccessRanges(%d, %p, %d, %p)\n", NumRequestedResources, RequestedResources, NumAccessRanges, AccessRanges);
591 
592  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
593  DriverObject = DeviceExtension->DriverObject;
595 
596  if (NumRequestedResources == 0)
597  {
598  AllocatedResources = DeviceExtension->AllocatedResources;
599  if (AllocatedResources == NULL &&
600  DeviceExtension->AdapterInterfaceType == PCIBus)
601  {
602  if (DeviceExtension->PhysicalDeviceObject != NULL)
603  {
604  PciSlotNumber.u.AsULONG = DeviceExtension->SystemIoSlotNumber;
605 
607  DeviceExtension->SystemIoBusNumber,
608  PciSlotNumber.u.AsULONG,
609  &Config,
610  sizeof(PCI_COMMON_CONFIG));
611 
612  if (ReturnedLength != sizeof(PCI_COMMON_CONFIG))
613  {
615  }
616  }
617  else
618  {
619  VendorIdToFind = VendorId != NULL ? *(PUSHORT)VendorId : 0;
620  DeviceIdToFind = DeviceId != NULL ? *(PUSHORT)DeviceId : 0;
621 
622  if (VendorIdToFind == 0 && DeviceIdToFind == 0)
623  {
624  /* We're screwed */
625  return ERROR_DEV_NOT_EXIST;
626  }
627 
628  INFO_(VIDEOPRT, "Looking for VendorId 0x%04x DeviceId 0x%04x\n",
629  VendorIdToFind, DeviceIdToFind);
630 
631  /*
632  * Search for the device id and vendor id on this bus.
633  */
634  PciSlotNumber.u.bits.Reserved = 0;
636  {
637  PciSlotNumber.u.bits.DeviceNumber = DeviceNumber;
638  for (FunctionNumber = 0; FunctionNumber < PCI_MAX_FUNCTION; FunctionNumber++)
639  {
640  INFO_(VIDEOPRT, "- Function number: %d\n", FunctionNumber);
641  PciSlotNumber.u.bits.FunctionNumber = FunctionNumber;
643  DeviceExtension->SystemIoBusNumber,
644  PciSlotNumber.u.AsULONG,
645  &Config,
646  sizeof(PCI_COMMON_CONFIG));
647  INFO_(VIDEOPRT, "- Length of data: %x\n", ReturnedLength);
648  if (ReturnedLength == sizeof(PCI_COMMON_CONFIG))
649  {
650  INFO_(VIDEOPRT, "- Slot 0x%02x (Device %d Function %d) VendorId 0x%04x "
651  "DeviceId 0x%04x\n",
652  PciSlotNumber.u.AsULONG,
653  PciSlotNumber.u.bits.DeviceNumber,
654  PciSlotNumber.u.bits.FunctionNumber,
655  Config.VendorID,
656  Config.DeviceID);
657 
658  if ((VendorIdToFind == 0 || Config.VendorID == VendorIdToFind) &&
659  (DeviceIdToFind == 0 || Config.DeviceID == DeviceIdToFind))
660  {
661  DeviceAndVendorFound = TRUE;
662  break;
663  }
664  }
665  }
666  if (DeviceAndVendorFound) break;
667  }
668  if (FunctionNumber == PCI_MAX_FUNCTION)
669  {
670  WARN_(VIDEOPRT, "Didn't find device.\n");
671  return ERROR_DEV_NOT_EXIST;
672  }
673  }
674 
675  Status = HalAssignSlotResources(&DeviceExtension->RegistryPath,
676  NULL,
677  DeviceExtension->DriverObject,
678  DeviceExtension->DriverObject->DeviceObject,
679  DeviceExtension->AdapterInterfaceType,
680  DeviceExtension->SystemIoBusNumber,
681  PciSlotNumber.u.AsULONG,
683 
684  if (!NT_SUCCESS(Status))
685  {
686  WARN_(VIDEOPRT, "HalAssignSlotResources failed with status %x.\n",Status);
687  return Status;
688  }
689  DeviceExtension->AllocatedResources = AllocatedResources;
690  DeviceExtension->SystemIoSlotNumber = PciSlotNumber.u.AsULONG;
691 
692  /* Add legacy resources to the resources from HAL */
694  &LegacyAccessRanges, &LegacyAccessRangeCount);
695  if (!NT_SUCCESS(Status))
696  return ERROR_DEV_NOT_EXIST;
697 
698  if (NumAccessRanges < LegacyAccessRangeCount)
699  {
700  ERR_(VIDEOPRT, "Too many legacy access ranges found\n");
702  }
703 
704  RtlCopyMemory(AccessRanges, LegacyAccessRanges, LegacyAccessRangeCount * sizeof(VIDEO_ACCESS_RANGE));
705  AssignedCount = LegacyAccessRangeCount;
706  }
707  }
708  else
709  {
710  ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + (NumRequestedResources - 1) * sizeof(IO_RESOURCE_DESCRIPTOR);
711  ResReqList = ExAllocatePool(NonPagedPool, ListSize);
712  if (!ResReqList) return ERROR_NOT_ENOUGH_MEMORY;
713 
714  ResReqList->ListSize = ListSize;
715  ResReqList->InterfaceType = DeviceExtension->AdapterInterfaceType;
716  ResReqList->BusNumber = DeviceExtension->SystemIoBusNumber;
717  ResReqList->SlotNumber = DeviceExtension->SystemIoSlotNumber;
718  ResReqList->AlternativeLists = 1;
719  ResReqList->List[0].Version = 1;
720  ResReqList->List[0].Revision = 1;
721  ResReqList->List[0].Count = NumRequestedResources;
722 
723  /* Copy in the caller's resource list */
724  RtlCopyMemory(ResReqList->List[0].Descriptors,
725  RequestedResources,
726  NumRequestedResources * sizeof(IO_RESOURCE_DESCRIPTOR));
727 
728  Status = IoAssignResources(&DeviceExtension->RegistryPath,
729  NULL,
730  DeviceExtension->DriverObject,
731  DeviceExtension->PhysicalDeviceObject ?
732  DeviceExtension->PhysicalDeviceObject :
733  DeviceExtension->DriverObject->DeviceObject,
734  ResReqList,
736 
737  if (!NT_SUCCESS(Status))
738  return Status;
739 
740  if (!DeviceExtension->AllocatedResources)
741  DeviceExtension->AllocatedResources = AllocatedResources;
742  }
743 
744  if (AllocatedResources == NULL)
746 
747  /* Return the slot number if the caller wants it */
748  if (Slot != NULL) *Slot = DeviceExtension->SystemIoBusNumber;
749 
750  FullList = AllocatedResources->List;
751  ASSERT(AllocatedResources->Count == 1);
752  INFO_(VIDEOPRT, "InterfaceType %u BusNumber List %u Device BusNumber %u Version %u Revision %u\n",
753  FullList->InterfaceType, FullList->BusNumber, DeviceExtension->SystemIoBusNumber, FullList->PartialResourceList.Version, FullList->PartialResourceList.Revision);
754 
755  ASSERT(FullList->InterfaceType == PCIBus);
756  ASSERT(FullList->BusNumber == DeviceExtension->SystemIoBusNumber);
757  ASSERT(1 == FullList->PartialResourceList.Version);
758  ASSERT(1 == FullList->PartialResourceList.Revision);
760  Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
761  Descriptor++)
762  {
763  if ((Descriptor->Type == CmResourceTypeMemory ||
764  Descriptor->Type == CmResourceTypePort) &&
765  AssignedCount >= NumAccessRanges)
766  {
767  ERR_(VIDEOPRT, "Too many access ranges found\n");
769  }
770  else if (Descriptor->Type == CmResourceTypeMemory)
771  {
772  INFO_(VIDEOPRT, "Memory range starting at 0x%08x length 0x%08x\n",
773  Descriptor->u.Memory.Start.u.LowPart, Descriptor->u.Memory.Length);
774  AccessRanges[AssignedCount].RangeStart = Descriptor->u.Memory.Start;
775  AccessRanges[AssignedCount].RangeLength = Descriptor->u.Memory.Length;
776  AccessRanges[AssignedCount].RangeInIoSpace = 0;
777  AccessRanges[AssignedCount].RangeVisible = 0; /* FIXME: Just guessing */
778  AccessRanges[AssignedCount].RangeShareable =
779  (Descriptor->ShareDisposition == CmResourceShareShared);
780  AccessRanges[AssignedCount].RangePassive = 0;
781  AssignedCount++;
782  }
783  else if (Descriptor->Type == CmResourceTypePort)
784  {
785  INFO_(VIDEOPRT, "Port range starting at 0x%04x length %d\n",
786  Descriptor->u.Port.Start.u.LowPart, Descriptor->u.Port.Length);
787  AccessRanges[AssignedCount].RangeStart = Descriptor->u.Port.Start;
788  AccessRanges[AssignedCount].RangeLength = Descriptor->u.Port.Length;
789  AccessRanges[AssignedCount].RangeInIoSpace = 1;
790  AccessRanges[AssignedCount].RangeVisible = 0; /* FIXME: Just guessing */
791  AccessRanges[AssignedCount].RangeShareable =
792  (Descriptor->ShareDisposition == CmResourceShareShared);
793  AccessRanges[AssignedCount].RangePassive = 0;
795  AccessRanges[AssignedCount].RangePassive |= VIDEO_RANGE_10_BIT_DECODE;
797  AccessRanges[AssignedCount].RangePassive |= VIDEO_RANGE_PASSIVE_DECODE;
798  AssignedCount++;
799  }
800  else if (Descriptor->Type == CmResourceTypeInterrupt)
801  {
802  DeviceExtension->InterruptLevel = Descriptor->u.Interrupt.Level;
803  DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
804  if (Descriptor->ShareDisposition == CmResourceShareShared)
805  DeviceExtension->InterruptShared = TRUE;
806  else
807  DeviceExtension->InterruptShared = FALSE;
808  }
809  else
810  {
811  ASSERT(FALSE);
813  }
814  }
815 
816  return NO_ERROR;
817 }
818 
819 /*
820  * @implemented
821  */
822 
825  IN PVOID HwDeviceExtension,
826  IN ULONG NumAccessRanges,
827  IN PVIDEO_ACCESS_RANGE AccessRanges)
828 {
829  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
830  BOOLEAN ConflictDetected;
831  ULONG i;
832  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
834  ULONG ResourceListSize;
836 
837  TRACE_(VIDEOPRT, "VideoPortVerifyAccessRanges\n");
838 
839  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
840 
841  /* Create the resource list */
842  ResourceListSize = sizeof(CM_RESOURCE_LIST)
843  + (NumAccessRanges - 1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
844  ResourceList = ExAllocatePool(PagedPool, ResourceListSize);
845  if (!ResourceList)
846  {
847  WARN_(VIDEOPRT, "ExAllocatePool() failed\n");
849  }
850 
851  /* Fill resource list */
852  ResourceList->Count = 1;
853  ResourceList->List[0].InterfaceType = DeviceExtension->AdapterInterfaceType;
854  ResourceList->List[0].BusNumber = DeviceExtension->SystemIoBusNumber;
855  ResourceList->List[0].PartialResourceList.Version = 1;
856  ResourceList->List[0].PartialResourceList.Revision = 1;
857  ResourceList->List[0].PartialResourceList.Count = NumAccessRanges;
858  for (i = 0; i < NumAccessRanges; i++, AccessRanges++)
859  {
860  PartialDescriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i];
861  if (AccessRanges->RangeInIoSpace)
862  {
863  PartialDescriptor->Type = CmResourceTypePort;
864  PartialDescriptor->u.Port.Start = AccessRanges->RangeStart;
865  PartialDescriptor->u.Port.Length = AccessRanges->RangeLength;
866  }
867  else
868  {
869  PartialDescriptor->Type = CmResourceTypeMemory;
870  PartialDescriptor->u.Memory.Start = AccessRanges->RangeStart;
871  PartialDescriptor->u.Memory.Length = AccessRanges->RangeLength;
872  }
873  if (AccessRanges->RangeShareable)
874  PartialDescriptor->ShareDisposition = CmResourceShareShared;
875  else
877  PartialDescriptor->Flags = 0;
878  if (AccessRanges->RangePassive & VIDEO_RANGE_PASSIVE_DECODE)
879  PartialDescriptor->Flags |= CM_RESOURCE_PORT_PASSIVE_DECODE;
880  if (AccessRanges->RangePassive & VIDEO_RANGE_10_BIT_DECODE)
881  PartialDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE;
882  }
883 
884  /* Try to acquire all resource ranges */
886  DeviceExtension->DriverObject,
887  NULL, 0, /* Driver List */
888  DeviceExtension->PhysicalDeviceObject,
889  ResourceList, ResourceListSize,
890  &ConflictDetected);
892 
893  if (!NT_SUCCESS(Status) || ConflictDetected)
895  else
896  return NO_ERROR;
897 }
898 
899 /*
900  * @unimplemented
901  */
902 
905  IN PVOID HwDeviceExtension,
906  IN VIDEO_DEVICE_DATA_TYPE DeviceDataType,
908  IN PVOID Context)
909 {
910  TRACE_(VIDEOPRT, "VideoPortGetDeviceData\n");
912  return ERROR_INVALID_FUNCTION;
913 }
914 
915 /*
916  * @implemented
917  */
918 
919 PVOID NTAPI
921  IN PVOID HwDeviceExtension,
924  IN ULONG Tag)
925 {
926  TRACE_(VIDEOPRT, "VideoPortAllocatePool\n");
928 }
929 
930 /*
931  * @implemented
932  */
933 
934 VOID NTAPI
936  IN PVOID HwDeviceExtension,
937  IN PVOID Ptr)
938 {
939  ExFreePool(Ptr);
940 }
941 
942 /*
943  * @implemented
944  */
945 
948  IN PVOID HwDeviceExtension,
949  IN ULONG Size,
950  OUT PVOID *Buffer)
951 {
952  TRACE_(VIDEOPRT, "VideoPortAllocateBuffer\n");
955 }
956 
957 /*
958  * @implemented
959  */
960 
961 VOID NTAPI
963  IN PVOID HwDeviceExtension,
964  IN PVOID Ptr)
965 {
966  TRACE_(VIDEOPRT, "VideoPortReleaseBuffer\n");
967  ExFreePool(Ptr);
968 }
969 
970 /*
971  * @implemented
972  */
973 
974 PVOID NTAPI
976  IN PVOID HwDeviceExtension,
978  IN ULONG Length,
980 {
981  PMDL Mdl;
982 
984  if (!Mdl)
985  {
986  return NULL;
987  }
988  /* FIXME use seh */
990  return Mdl;
991 }
992 
993 /*
994  * @implemented
995  */
996 
997 BOOLEAN
998 NTAPI
1000  IN PVOID HwDeviceExtension,
1002  IN PEVENT pUEvent,
1003  IN PEVENT pDisplayEvent,
1004  IN DMA_FLAGS DmaFlags)
1005 {
1006  PVOID Buffer;
1007 
1008  /* clear output buffer */
1009  pVrp->OutputBuffer = NULL;
1010 
1011  if (DmaFlags != VideoPortDmaInitOnly)
1012  {
1013  /* VideoPortKeepPagesLocked / VideoPortUnlockAfterDma is no-op */
1014  return FALSE;
1015  }
1016 
1017  /* lock the buffer */
1018  Buffer = VideoPortLockBuffer(HwDeviceExtension, pVrp->InputBuffer, pVrp->InputBufferLength, IoModifyAccess);
1019 
1020  if (Buffer)
1021  {
1022  /* store result buffer & length */
1023  pVrp->OutputBuffer = Buffer;
1024  pVrp->OutputBufferLength = pVrp->InputBufferLength;
1025 
1026  /* operation succeeded */
1027  return TRUE;
1028  }
1029 
1030  /* operation failed */
1031  return FALSE;
1032 }
1033 
1034 
1035 /*
1036  * @implemented
1037  */
1038 
1039 VOID NTAPI
1041  IN PVOID HwDeviceExtension,
1042  IN PVOID Mdl)
1043 {
1044  if (Mdl)
1045  {
1047  IoFreeMdl(Mdl);
1048  }
1049 }
1050 
1051 /*
1052  * @unimplemented
1053  */
1054 
1057  IN PVOID HwDeviceExtension,
1058  IN ULONG NumAccessRanges,
1059  IN PVIDEO_ACCESS_RANGE AccessRange)
1060 {
1061  UNIMPLEMENTED;
1062  /* Should store the ranges in the device extension for use by ntvdm. */
1063  return NO_ERROR;
1064 }
1065 
1066 /*
1067  * @implemented
1068  */
1069 
1070 ULONG NTAPI
1072  IN PVOID HwDeviceExtension,
1073  IN BUS_DATA_TYPE BusDataType,
1075  OUT PVOID Buffer,
1076  IN ULONG Offset,
1077  IN ULONG Length)
1078 {
1079  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1080 
1081  TRACE_(VIDEOPRT, "VideoPortGetBusData\n");
1082 
1083  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1084 
1085  if (BusDataType != Cmos)
1086  {
1087  /* Legacy vs. PnP behaviour */
1088  if (DeviceExtension->PhysicalDeviceObject != NULL)
1089  SlotNumber = DeviceExtension->SystemIoSlotNumber;
1090  }
1091 
1092  return HalGetBusDataByOffset(
1093  BusDataType,
1094  DeviceExtension->SystemIoBusNumber,
1095  SlotNumber,
1096  Buffer,
1097  Offset,
1098  Length);
1099 }
1100 
1101 /*
1102  * @implemented
1103  */
1104 
1105 ULONG NTAPI
1107  IN PVOID HwDeviceExtension,
1108  IN BUS_DATA_TYPE BusDataType,
1110  IN PVOID Buffer,
1111  IN ULONG Offset,
1112  IN ULONG Length)
1113 {
1114  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1115 
1116  TRACE_(VIDEOPRT, "VideoPortSetBusData\n");
1117 
1118  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1119 
1120  if (BusDataType != Cmos)
1121  {
1122  /* Legacy vs. PnP behaviour */
1123  if (DeviceExtension->PhysicalDeviceObject != NULL)
1124  SlotNumber = DeviceExtension->SystemIoSlotNumber;
1125  }
1126 
1127  return HalSetBusDataByOffset(
1128  BusDataType,
1129  DeviceExtension->SystemIoBusNumber,
1130  SlotNumber,
1131  Buffer,
1132  Offset,
1133  Length);
1134 }
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:65
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
struct _IO_RESOURCE_REQUIREMENTS_LIST IO_RESOURCE_REQUIREMENTS_LIST
#define VIDEO_MEMORY_SPACE_DENSE
Definition: video.h:135
VP_STATUS NTAPI VideoPortAllocateBuffer(IN PVOID HwDeviceExtension, IN ULONG Size, OUT PVOID *Buffer)
Definition: resource.c:947
#define IN
Definition: typedefs.h:39
#define TAG_VIDEO_PORT
Definition: videoprt.h:38
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID NTAPI VideoPortFreePool(IN PVOID HwDeviceExtension, IN PVOID Ptr)
Definition: resource.c:935
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
NTSTATUS NTAPI IntVideoPortGetLegacyResources(IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension, OUT PVIDEO_ACCESS_RANGE *AccessRanges, OUT PULONG AccessRangeCount)
Definition: resource.c:30
ULONG NTAPI VideoPortGetBusData(IN PVOID HwDeviceExtension, IN BUS_DATA_TYPE BusDataType, IN ULONG SlotNumber, OUT PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: resource.c:1071
struct _IO_RESOURCE_DESCRIPTOR::@1529::@1530 Port
#define INFO_(ch,...)
Definition: debug.h:159
struct _Entry Entry
Definition: kefuncs.h:629
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG _In_ ULONG Protect
Definition: zwfuncs.h:214
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4640
#define VIDEO_MEMORY_SPACE_P6CACHE
Definition: video.h:136
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
enum _BUS_DATA_TYPE BUS_DATA_TYPE
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2272
VOID NTAPI VideoPortFreeDeviceBase(IN PVOID HwDeviceExtension, IN PVOID MappedAddress)
Definition: resource.c:473
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
PHYSICAL_ADDRESS IoAddress
Definition: videoprt.h:49
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IoReportResourceForDetection(IN PDRIVER_OBJECT DriverObject, IN PCM_RESOURCE_LIST DriverList OPTIONAL, IN ULONG DriverListSize OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PCM_RESOURCE_LIST DeviceList OPTIONAL, IN ULONG DeviceListSize OPTIONAL, OUT PBOOLEAN ConflictDetected)
Definition: pnpreport.c:393
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
PVOID NTAPI VideoPortLockBuffer(IN PVOID HwDeviceExtension, IN PVOID BaseAddress, IN ULONG Length, IN VP_LOCK_OPERATION Operation)
Definition: resource.c:975
VP_STATUS NTAPI VideoPortMapMemory(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, IN PULONG Length, IN PULONG InIoSpace, OUT PVOID *VirtualAddress)
Definition: resource.c:510
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
PCM_RESOURCE_LIST AllocatedResources
Definition: videoprt.h:94
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1435
union _PCI_SLOT_NUMBER::@3802 u
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension)
Definition: videoprt.h:140
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PCUNICODE_STRING UnicodeString
Definition: wdfstring.h:64
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378 u
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2272
#define NO_ERROR
Definition: dderror.h:5
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:304
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR CM_PARTIAL_RESOURCE_DESCRIPTOR
NTSTATUS NTAPI IntVideoPortMapPhysicalMemory(IN HANDLE Process, IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG SizeInBytes, IN ULONG Protect, IN OUT PVOID *VirtualAddress OPTIONAL)
Definition: resource.c:194
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:120
#define CmResourceTypePort
Definition: hwresource.cpp:123
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
VP_STATUS NTAPI VideoPortGetAccessRanges(IN PVOID HwDeviceExtension, IN ULONG NumRequestedResources, IN PIO_RESOURCE_DESCRIPTOR RequestedResources OPTIONAL, IN ULONG NumAccessRanges, IN PVIDEO_ACCESS_RANGE AccessRanges, IN PVOID VendorId, IN PVOID DeviceId, OUT PULONG Slot)
Definition: resource.c:559
_Must_inspect_result_ _In_ PFLT_GET_OPERATION_STATUS_CALLBACK CallbackRoutine
Definition: fltkernel.h:1035
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define L(x)
Definition: ntvdm.h:50
VOID(NTAPI * PBANKED_SECTION_ROUTINE)(IN ULONG ReadBank, IN ULONG WriteBank, IN PVOID Context)
Definition: miniport.h:50
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define TAG_VIDEO_PORT_BUFFER
Definition: videoprt.h:39
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378::@380 Port
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:87
#define VIDEO_RANGE_PASSIVE_DECODE
Definition: video.h:98
unsigned char BOOLEAN
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378::@383 Memory
#define VIDEO_RANGE_10_BIT_DECODE
Definition: video.h:99
ULONG ReadLength
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
VP_STATUS(NTAPI * PMINIPORT_QUERY_DEVICE_ROUTINE)(IN PVOID HwDeviceExtension, IN PVOID Context, IN VIDEO_DEVICE_DATA_TYPE DeviceDataType, IN PVOID Identifier, IN ULONG IdentifierLength, IN PVOID ConfigurationData, IN ULONG ConfigurationDataLength, IN OUT PVOID ComponentInformation, IN ULONG ComponentInformationLength)
Definition: video.h:498
VP_STATUS NTAPI VideoPortSetTrappedEmulatorPorts(IN PVOID HwDeviceExtension, IN ULONG NumAccessRanges, IN PVIDEO_ACCESS_RANGE AccessRange)
Definition: resource.c:1056
NTHALAPI NTSTATUS NTAPI HalAssignSlotResources(PUNICODE_STRING, PUNICODE_STRING, PDRIVER_OBJECT, PDEVICE_OBJECT, INTERFACE_TYPE, ULONG, ULONG, PCM_RESOURCE_LIST *)
#define CM_RESOURCE_PORT_10_BIT_DECODE
Definition: cmtypes.h:110
enum _VP_LOCK_OPERATION VP_LOCK_OPERATION
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
union _IO_RESOURCE_DESCRIPTOR::@1529 u
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
PVOID NTAPI VideoPortAllocatePool(IN PVOID HwDeviceExtension, IN VP_POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: resource.c:920
#define NtCurrentProcess()
Definition: nt_native.h:1657
struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
IO_RESOURCE_DESCRIPTOR Descriptors[1]
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
BOOLEAN NTAPI VideoPortLockPages(IN PVOID HwDeviceExtension, IN OUT PVIDEO_REQUEST_PACKET pVrp, IN PEVENT pUEvent, IN PEVENT pDisplayEvent, IN DMA_FLAGS DmaFlags)
Definition: resource.c:999
VP_STATUS NTAPI VideoPortUnmapMemory(IN PVOID HwDeviceExtension, IN PVOID VirtualAddress, IN HANDLE ProcessHandle)
Definition: resource.c:540
Definition: miniport.h:89
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define PCI_MAX_DEVICES
Definition: iotypes.h:3598
#define CM_RESOURCE_PORT_PASSIVE_DECODE
Definition: cmtypes.h:114
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
struct _PCI_SLOT_NUMBER::@3802::@3803 bits
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UCHAR RangeShareable
Definition: video.h:219
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098
unsigned char UCHAR
Definition: xmlstorage.h:181
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
struct _IO_RESOURCE_DESCRIPTOR * PIO_RESOURCE_DESCRIPTOR
ULONG NTAPI HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bus.c:73
ULONG NTAPI VideoPortSetBusData(IN PVOID HwDeviceExtension, IN BUS_DATA_TYPE BusDataType, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: resource.c:1106
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1875
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:187
Definition: typedefs.h:119
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
struct _CM_RESOURCE_LIST CM_RESOURCE_LIST
VOID NTAPI VideoPortUnlockBuffer(IN PVOID HwDeviceExtension, IN PVOID Mdl)
Definition: resource.c:1040
enum _VP_POOL_TYPE VP_POOL_TYPE
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:474
BOOLEAN NTAPI HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: bus.c:140
#define PCI_MAX_FUNCTION
Definition: iotypes.h:3599
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:86
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:931
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
PVOID NTAPI VideoPortGetDeviceBase(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS IoAddress, IN ULONG NumberOfUchars, IN UCHAR InIoSpace)
Definition: resource.c:452
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
VOID NTAPI VideoPortReleaseBuffer(IN PVOID HwDeviceExtension, IN PVOID Ptr)
Definition: resource.c:962
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
enum _VIDEO_DEVICE_DATA_TYPE VIDEO_DEVICE_DATA_TYPE
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1035
unsigned int * PULONG
Definition: retypes.h:1
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define VIDEO_MEMORY_SPACE_USER_MODE
Definition: video.h:134
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
unsigned int ULONG
Definition: retypes.h:1
enum _DMA_FLAGS DMA_FLAGS
VP_STATUS NTAPI VideoPortVerifyAccessRanges(IN PVOID HwDeviceExtension, IN ULONG NumAccessRanges, IN PVIDEO_ACCESS_RANGE AccessRanges)
Definition: resource.c:824
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNIMPLEMENTED
Definition: debug.h:115
NTHALAPI ULONG NTAPI HalGetBusData(BUS_DATA_TYPE, ULONG, ULONG, PVOID, ULONG)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1467
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
struct _LARGE_INTEGER::@2247 u
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
LONG VP_STATUS
Definition: video.h:153
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
struct _IO_RESOURCE_DESCRIPTOR::@1529::@1531 Memory
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1229
NTSYSAPI NTSTATUS NTAPI ZwOpenSection(_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:98
ULONG NTAPI HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bus.c:123
NTSTATUS NTAPI IntVideoPortFilterResourceRequirements(IN PDEVICE_OBJECT DeviceObject, IN PIO_STACK_LOCATION IrpStack, IN PIRP Irp)
Definition: resource.c:77
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
#define WARN_(ch,...)
Definition: debug.h:157
VP_STATUS NTAPI VideoPortMapBankedMemory(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, IN PULONG Length, IN PULONG InIoSpace, OUT PVOID *VirtualAddress, IN ULONG BankLength, IN UCHAR ReadWriteBank, IN PBANKED_SECTION_ROUTINE BankRoutine, IN PVOID Context)
Definition: resource.c:488
ULONG RangeLength
Definition: video.h:216
unsigned short * PUSHORT
Definition: retypes.h:2
base of all file and directory entries
Definition: entries.h:82
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2277
LONGLONG QuadPart
Definition: typedefs.h:114
NTSTATUS NTAPI IoAssignResources(IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName, IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject, IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources, IN OUT PCM_RESOURCE_LIST *AllocatedResources)
Definition: iorsrce.c:953
PVOID NTAPI IntVideoPortMapMemory(IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension, IN PHYSICAL_ADDRESS IoAddress, IN ULONG NumberOfUchars, IN ULONG InIoSpace, IN HANDLE ProcessHandle, OUT VP_STATUS *Status)
Definition: resource.c:245
PHYSICAL_ADDRESS RangeStart
Definition: video.h:215
#define PAGE_READWRITE
Definition: nt_native.h:1304
VOID NTAPI IntVideoPortUnmapMemory(IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension, IN PVOID MappedAddress)
Definition: resource.c:400
VP_STATUS NTAPI VideoPortGetDeviceData(IN PVOID HwDeviceExtension, IN VIDEO_DEVICE_DATA_TYPE DeviceDataType, IN PMINIPORT_QUERY_DEVICE_ROUTINE CallbackRoutine, IN PVOID Context)
Definition: resource.c:904
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68