ReactOS 0.4.16-dev-1946-g52006dd
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
27extern BOOLEAN VpBaseVideo;
28
29/* PRIVATE FUNCTIONS **********************************************************/
30
31static BOOLEAN
33 IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
34{
35 UNICODE_STRING VgaSave = RTL_CONSTANT_STRING(L"\\Driver\\VgaSave");
36 return RtlEqualUnicodeString(&VgaSave, &DeviceExtension->DriverObject->DriverName, TRUE);
37}
38
42 IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
43 OUT PVIDEO_ACCESS_RANGE *AccessRanges,
44 OUT PULONG AccessRangeCount)
45{
46 PCI_COMMON_CONFIG PciConfig;
48
49 if (!DriverExtension->InitializationData.HwGetLegacyResources &&
50 !DriverExtension->InitializationData.HwLegacyResourceCount)
51 {
52 /* No legacy resources to report */
53 *AccessRangeCount = 0;
54 return STATUS_SUCCESS;
55 }
56
57 if (DriverExtension->InitializationData.HwGetLegacyResources)
58 {
60 DeviceExtension->SystemIoBusNumber,
61 DeviceExtension->SystemIoSlotNumber,
62 &PciConfig,
63 sizeof(PciConfig));
64 if (ReadLength != sizeof(PciConfig))
65 {
66 /* This device doesn't exist */
68 }
69
70 DriverExtension->InitializationData.HwGetLegacyResources(PciConfig.VendorID,
71 PciConfig.DeviceID,
72 AccessRanges,
73 AccessRangeCount);
74 }
75 else
76 {
77 *AccessRanges = DriverExtension->InitializationData.HwLegacyResourceList;
78 *AccessRangeCount = DriverExtension->InitializationData.HwLegacyResourceCount;
79 }
80
81 INFO_(VIDEOPRT, "Got %d legacy access ranges\n", *AccessRangeCount);
82
83 return STATUS_SUCCESS;
84}
85
89 IN PIO_STACK_LOCATION IrpStack,
90 IN PIRP Irp)
91{
94 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
95 PVIDEO_ACCESS_RANGE AccessRanges;
96 ULONG AccessRangeCount, ListSize, i;
98 PIO_RESOURCE_REQUIREMENTS_LIST OldResList = IrpStack->Parameters.FilterResourceRequirements.IoResourceRequirementList;
99 PIO_RESOURCE_DESCRIPTOR CurrentDescriptor;
101
102 DriverObject = DeviceObject->DriverObject;
104 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
105
106 Status = IntVideoPortGetLegacyResources(DriverExtension, DeviceExtension, &AccessRanges, &AccessRangeCount);
107 if (!NT_SUCCESS(Status))
108 return Status;
109 if (!AccessRangeCount)
110 {
111 /* No legacy resources to report */
112 return Irp->IoStatus.Status;
113 }
114
115 /* OK, we've got the access ranges now. Let's set up the resource requirements list */
116
117 if (OldResList)
118 {
119 /* Already one there so let's add to it */
120 ListSize = OldResList->ListSize + sizeof(IO_RESOURCE_DESCRIPTOR) * AccessRangeCount;
122 ListSize);
123 if (!ResList) return STATUS_NO_MEMORY;
124
125 RtlCopyMemory(ResList, OldResList, OldResList->ListSize);
126
127 ASSERT(ResList->AlternativeLists == 1);
128
129 ResList->ListSize = ListSize;
130 ResList->List[0].Count += AccessRangeCount;
131
132 CurrentDescriptor = (PIO_RESOURCE_DESCRIPTOR)((PUCHAR)ResList + OldResList->ListSize);
133
134 ExFreePool(OldResList);
135 Irp->IoStatus.Information = 0;
136 }
137 else
138 {
139 /* We need to make a new one */
140 ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR) * (AccessRangeCount - 1);
142 ListSize);
143 if (!ResList) return STATUS_NO_MEMORY;
144
145 RtlZeroMemory(ResList, ListSize);
146
147 /* We need to initialize some fields */
148 ResList->ListSize = ListSize;
149 ResList->InterfaceType = DeviceExtension->AdapterInterfaceType;
150 ResList->BusNumber = DeviceExtension->SystemIoBusNumber;
151 ResList->SlotNumber = DeviceExtension->SystemIoSlotNumber;
152 ResList->AlternativeLists = 1;
153 ResList->List[0].Version = 1;
154 ResList->List[0].Revision = 1;
155 ResList->List[0].Count = AccessRangeCount;
156
157 CurrentDescriptor = ResList->List[0].Descriptors;
158 }
159
160 for (i = 0; i < AccessRangeCount; i++)
161 {
162 /* This is a required resource */
163 CurrentDescriptor->Option = 0;
164
165 if (AccessRanges[i].RangeInIoSpace)
166 CurrentDescriptor->Type = CmResourceTypePort;
167 else
168 CurrentDescriptor->Type = CmResourceTypeMemory;
169
170 CurrentDescriptor->ShareDisposition =
172
173 CurrentDescriptor->Flags = 0;
174
175 if (CurrentDescriptor->Type == CmResourceTypePort)
176 {
177 CurrentDescriptor->u.Port.Length = AccessRanges[i].RangeLength;
178 CurrentDescriptor->u.Port.MinimumAddress = AccessRanges[i].RangeStart;
179 CurrentDescriptor->u.Port.MaximumAddress.QuadPart = AccessRanges[i].RangeStart.QuadPart + AccessRanges[i].RangeLength - 1;
180 CurrentDescriptor->u.Port.Alignment = 1;
181 if (AccessRanges[i].RangePassive & VIDEO_RANGE_PASSIVE_DECODE)
182 CurrentDescriptor->Flags |= CM_RESOURCE_PORT_PASSIVE_DECODE;
183 if (AccessRanges[i].RangePassive & VIDEO_RANGE_10_BIT_DECODE)
184 CurrentDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE;
185 }
186 else
187 {
188 CurrentDescriptor->u.Memory.Length = AccessRanges[i].RangeLength;
189 CurrentDescriptor->u.Memory.MinimumAddress = AccessRanges[i].RangeStart;
190 CurrentDescriptor->u.Memory.MaximumAddress.QuadPart = AccessRanges[i].RangeStart.QuadPart + AccessRanges[i].RangeLength - 1;
191 CurrentDescriptor->u.Memory.Alignment = 1;
192 CurrentDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE;
193 }
194
195 CurrentDescriptor++;
196 }
197
198 Irp->IoStatus.Information = (ULONG_PTR)ResList;
199
200 return STATUS_SUCCESS;
201}
202
203VOID
205 _In_ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
206{
208 BOOLEAN ConflictDetected;
209 // An empty CM_RESOURCE_LIST
210 UCHAR EmptyResourceList[FIELD_OFFSET(CM_RESOURCE_LIST, List)] = {0};
211
213 DeviceExtension->DriverObject,
214 NULL, 0, /* Driver List */
215 DeviceExtension->PhysicalDeviceObject,
216 (PCM_RESOURCE_LIST)EmptyResourceList,
217 sizeof(EmptyResourceList),
218 &ConflictDetected);
219
220 if (!NT_SUCCESS(Status))
221 {
222 ERR_(VIDEOPRT,
223 "VideoPortReleaseResources IoReportResource failed with 0x%08lx ; ConflictDetected: %s\n",
224 Status, ConflictDetected ? "TRUE" : "FALSE");
225 }
226 /* Ignore the returned status however... */
227}
228
233 IN ULONG SizeInBytes,
236{
237 OBJECT_ATTRIBUTES ObjAttribs;
239 HANDLE hMemObj;
241 SIZE_T Size;
242
243 /* Initialize object attribs */
244 RtlInitUnicodeString(&UnicodeString, L"\\Device\\PhysicalMemory");
245 InitializeObjectAttributes(&ObjAttribs,
248 NULL, NULL);
249
250 /* Open physical memory section */
251 Status = ZwOpenSection(&hMemObj, SECTION_ALL_ACCESS, &ObjAttribs);
252 if (!NT_SUCCESS(Status))
253 {
254 WARN_(VIDEOPRT, "ZwOpenSection() failed! (0x%x)\n", Status);
255 return Status;
256 }
257
258 /* Map view of section */
259 Size = SizeInBytes;
260 Status = ZwMapViewOfSection(hMemObj,
261 Process,
263 0,
264 Size,
266 &Size,
267 ViewUnmap,
268 0,
269 Protect);
270 ZwClose(hMemObj);
271 if (!NT_SUCCESS(Status))
272 {
273 WARN_(VIDEOPRT, "ZwMapViewOfSection() failed! (0x%x)\n", Status);
274 }
275
276 return Status;
277}
278
279
282 IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
283 IN PHYSICAL_ADDRESS IoAddress,
284 IN ULONG NumberOfUchars,
285 IN ULONG InIoSpace,
288{
290 PVIDEO_PORT_ADDRESS_MAPPING AddressMapping;
292 PVOID MappedAddress;
294
295 INFO_(VIDEOPRT, "- IoAddress: %lx\n", IoAddress.u.LowPart);
296 INFO_(VIDEOPRT, "- NumberOfUchars: %lx\n", NumberOfUchars);
297 INFO_(VIDEOPRT, "- InIoSpace: %x\n", InIoSpace);
298
299 InIoSpace &= ~VIDEO_MEMORY_SPACE_DENSE;
300
301 if (ProcessHandle != NULL && (InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) == 0)
302 {
303 INFO_(VIDEOPRT, "ProcessHandle is not NULL (0x%x) but InIoSpace does not have "
304 "VIDEO_MEMORY_SPACE_USER_MODE set! Setting "
305 "VIDEO_MEMORY_SPACE_USER_MODE.\n",
307 InIoSpace |= VIDEO_MEMORY_SPACE_USER_MODE;
308 }
309 else if (ProcessHandle == NULL && (InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) != 0)
310 {
311 INFO_(VIDEOPRT, "ProcessHandle is NULL (0x%x) but InIoSpace does have "
312 "VIDEO_MEMORY_SPACE_USER_MODE set! Setting ProcessHandle "
313 "to NtCurrentProcess()\n",
316 }
317
318 if ((InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) == 0 &&
319 !IsListEmpty(&DeviceExtension->AddressMappingListHead))
320 {
321 Entry = DeviceExtension->AddressMappingListHead.Flink;
322 while (Entry != &DeviceExtension->AddressMappingListHead)
323 {
324 AddressMapping = CONTAINING_RECORD(
325 Entry,
327 List);
328 if (IoAddress.QuadPart == AddressMapping->IoAddress.QuadPart &&
329 NumberOfUchars <= AddressMapping->NumberOfUchars)
330 {
331 {
332 AddressMapping->MappingCount++;
333 if (Status)
334 *Status = NO_ERROR;
335 return AddressMapping->MappedAddress;
336 }
337 }
338 Entry = Entry->Flink;
339 }
340 }
341
342 AddressSpace = (ULONG)InIoSpace;
345 DeviceExtension->AdapterInterfaceType,
346 DeviceExtension->SystemIoBusNumber,
347 IoAddress,
350 {
351 if (Status)
353
354 return NULL;
355 }
356
357 /* I/O space */
358 if (AddressSpace != 0)
359 {
360 ASSERT(0 == TranslatedAddress.u.HighPart);
361 if (Status)
362 *Status = NO_ERROR;
363
364 return (PVOID)(ULONG_PTR)TranslatedAddress.u.LowPart;
365 }
366
367 /* user space */
368 if ((InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) != 0)
369 {
370 NTSTATUS NtStatus;
372 if (InIoSpace & VIDEO_MEMORY_SPACE_P6CACHE)
374 else
376 MappedAddress = NULL;
379 NumberOfUchars,
380 Protect,
381 &MappedAddress);
382 if (!NT_SUCCESS(NtStatus))
383 {
384 ERR_(VIDEOPRT, "IntVideoPortMapPhysicalMemory() failed! (0x%x)\n", NtStatus);
385 if (Status)
387 return NULL;
388 }
389 INFO_(VIDEOPRT, "Mapped user address = 0x%08x\n", MappedAddress);
390 }
391 else /* kernel space */
392 {
393 MappedAddress = MmMapIoSpace(
395 NumberOfUchars,
397 }
398
399 if (MappedAddress != NULL)
400 {
401 if (Status)
402 {
403 *Status = NO_ERROR;
404 }
405 if ((InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) == 0)
406 {
407 AddressMapping = ExAllocatePoolWithTag(
408 PagedPool,
411
412 if (AddressMapping == NULL)
413 return MappedAddress;
414
415 RtlZeroMemory(AddressMapping, sizeof(VIDEO_PORT_ADDRESS_MAPPING));
416 AddressMapping->NumberOfUchars = NumberOfUchars;
417 AddressMapping->IoAddress = IoAddress;
418 AddressMapping->SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
419 AddressMapping->MappedAddress = MappedAddress;
420 AddressMapping->MappingCount = 1;
422 &DeviceExtension->AddressMappingListHead,
423 &AddressMapping->List);
424 }
425
426 return MappedAddress;
427 }
428
429 ERR_(VIDEOPRT,
430 "Couldn't map video memory. IoAddress: 0x%lx, NumberOfUchars: 0x%lx, InIoSpace: 0x%x\n",
431 IoAddress.u.LowPart, NumberOfUchars, InIoSpace);
432 if (Status)
434
435 return NULL;
436}
437
440 IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
441 IN PVOID MappedAddress)
442{
443 PVIDEO_PORT_ADDRESS_MAPPING AddressMapping;
446
447 Entry = DeviceExtension->AddressMappingListHead.Flink;
448 while (Entry != &DeviceExtension->AddressMappingListHead)
449 {
450 AddressMapping = CONTAINING_RECORD(
451 Entry,
453 List);
454 if (AddressMapping->MappedAddress == MappedAddress)
455 {
456 ASSERT(AddressMapping->MappingCount > 0);
457 AddressMapping->MappingCount--;
458 if (AddressMapping->MappingCount == 0)
459 {
461 AddressMapping->MappedAddress,
462 AddressMapping->NumberOfUchars);
464 ExFreePool(AddressMapping);
465 }
466 return;
467 }
468
469 Entry = Entry->Flink;
470 }
471
472 /* If there was no kernelmode mapping for the given address found we assume
473 * that the given address is a usermode mapping and try to unmap it.
474 *
475 * FIXME: Is it ok to use NtCurrentProcess?
476 */
477 Status = ZwUnmapViewOfSection(NtCurrentProcess(), MappedAddress);
478 if (!NT_SUCCESS(Status))
479 {
480 WARN_(VIDEOPRT, "Warning: Mapping for address 0x%p not found!\n", MappedAddress);
481 }
482}
483
484/* PUBLIC FUNCTIONS ***********************************************************/
485
486/*
487 * @implemented
488 */
489
492 IN PVOID HwDeviceExtension,
493 IN PHYSICAL_ADDRESS IoAddress,
494 IN ULONG NumberOfUchars,
495 IN UCHAR InIoSpace)
496{
497 TRACE_(VIDEOPRT, "VideoPortGetDeviceBase\n");
499 VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
500 IoAddress,
501 NumberOfUchars,
502 InIoSpace,
503 NULL,
504 NULL);
505}
506
507/*
508 * @implemented
509 */
510
513 IN PVOID HwDeviceExtension,
514 IN PVOID MappedAddress)
515{
516 TRACE_(VIDEOPRT, "VideoPortFreeDeviceBase\n");
518 VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
519 MappedAddress);
520}
521
522/*
523 * @unimplemented
524 */
525
528 IN PVOID HwDeviceExtension,
531 IN PULONG InIoSpace,
533 IN ULONG BankLength,
534 IN UCHAR ReadWriteBank,
535 IN PBANKED_SECTION_ROUTINE BankRoutine,
537{
538 TRACE_(VIDEOPRT, "VideoPortMapBankedMemory\n");
541}
542
543
544/*
545 * @implemented
546 */
547
550 IN PVOID HwDeviceExtension,
553 IN PULONG InIoSpace,
555{
556 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
558
559 TRACE_(VIDEOPRT, "VideoPortMapMemory\n");
560 INFO_(VIDEOPRT, "- *VirtualAddress: 0x%x\n", *VirtualAddress);
561
562 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
564 DeviceExtension,
566 *Length,
567 *InIoSpace,
569 &Status);
570
571 return Status;
572}
573
574/*
575 * @implemented
576 */
577
580 IN PVOID HwDeviceExtension,
583{
584 TRACE_(VIDEOPRT, "VideoPortFreeDeviceBase\n");
585
587 VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
589
590 return NO_ERROR;
591}
592
639NTAPI
641 _In_ PVOID HwDeviceExtension,
642 _In_opt_ ULONG NumRequestedResources,
643 _In_reads_opt_(NumRequestedResources)
644 PIO_RESOURCE_DESCRIPTOR RequestedResources,
645 _In_ ULONG NumAccessRanges,
646 _Out_writes_(NumAccessRanges) PVIDEO_ACCESS_RANGE AccessRanges,
647 _In_ PVOID VendorId,
648 _In_ PVOID DeviceId,
649 _Out_ PULONG Slot)
650{
651 PCI_SLOT_NUMBER PciSlotNumber;
653 ULONG FunctionNumber;
657 UINT AssignedCount = 0;
660 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
662 USHORT VendorIdToFind;
663 USHORT DeviceIdToFind;
665 PVIDEO_ACCESS_RANGE LegacyAccessRanges;
666 ULONG LegacyAccessRangeCount;
668 ULONG ListSize;
670 BOOLEAN DeviceAndVendorFound = FALSE;
671
672 TRACE_(VIDEOPRT, "VideoPortGetAccessRanges(%d, %p, %d, %p)\n",
673 NumRequestedResources, RequestedResources, NumAccessRanges, AccessRanges);
674
675 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
676 DriverObject = DeviceExtension->DriverObject;
678
679 if (NumRequestedResources == 0)
680 {
681 AllocatedResources = DeviceExtension->AllocatedResources;
682 if (AllocatedResources == NULL &&
683 DeviceExtension->AdapterInterfaceType == PCIBus)
684 {
685 if (DeviceExtension->PhysicalDeviceObject != NULL)
686 {
687 PciSlotNumber.u.AsULONG = DeviceExtension->SystemIoSlotNumber;
688
690 DeviceExtension->SystemIoBusNumber,
691 PciSlotNumber.u.AsULONG,
692 &Config,
693 sizeof(Config));
694
695 if (ReturnedLength != sizeof(Config))
696 {
698 }
699 }
700 else
701 {
702 VendorIdToFind = VendorId != NULL ? *(PUSHORT)VendorId : 0;
703 DeviceIdToFind = DeviceId != NULL ? *(PUSHORT)DeviceId : 0;
704
705 if (VendorIdToFind == 0 && DeviceIdToFind == 0)
706 {
707 /* We're screwed */
708 return ERROR_DEV_NOT_EXIST;
709 }
710
711 INFO_(VIDEOPRT, "Looking for VendorId 0x%04x DeviceId 0x%04x\n",
712 VendorIdToFind, DeviceIdToFind);
713
714 /*
715 * Search for the device id and vendor id on this bus.
716 */
717 PciSlotNumber.u.bits.Reserved = 0;
719 {
720 PciSlotNumber.u.bits.DeviceNumber = DeviceNumber;
721 for (FunctionNumber = 0; FunctionNumber < PCI_MAX_FUNCTION; FunctionNumber++)
722 {
723 INFO_(VIDEOPRT, "- Function number: %d\n", FunctionNumber);
724 PciSlotNumber.u.bits.FunctionNumber = FunctionNumber;
726 DeviceExtension->SystemIoBusNumber,
727 PciSlotNumber.u.AsULONG,
728 &Config,
729 sizeof(Config));
730
731 INFO_(VIDEOPRT, "- Length of data: %x\n", ReturnedLength);
732
733 if (ReturnedLength == sizeof(Config))
734 {
735 INFO_(VIDEOPRT, "- Slot 0x%02x (Device %d Function %d) VendorId 0x%04x "
736 "DeviceId 0x%04x\n",
737 PciSlotNumber.u.AsULONG,
738 PciSlotNumber.u.bits.DeviceNumber,
739 PciSlotNumber.u.bits.FunctionNumber,
740 Config.VendorID,
741 Config.DeviceID);
742
743 if ((VendorIdToFind == 0 || Config.VendorID == VendorIdToFind) &&
744 (DeviceIdToFind == 0 || Config.DeviceID == DeviceIdToFind))
745 {
746 DeviceAndVendorFound = TRUE;
747 break;
748 }
749 }
750 }
751 if (DeviceAndVendorFound)
752 break;
753 }
754 if (FunctionNumber == PCI_MAX_FUNCTION)
755 {
756 WARN_(VIDEOPRT, "Didn't find device.\n");
757 return ERROR_DEV_NOT_EXIST;
758 }
759 }
760
761 Status = HalAssignSlotResources(&DeviceExtension->RegistryPath,
762 NULL,
763 DeviceExtension->DriverObject,
764 DeviceExtension->DriverObject->DeviceObject,
765 DeviceExtension->AdapterInterfaceType,
766 DeviceExtension->SystemIoBusNumber,
767 PciSlotNumber.u.AsULONG,
769 if (!NT_SUCCESS(Status))
770 {
771 WARN_(VIDEOPRT, "HalAssignSlotResources failed with status %x.\n",Status);
772 return Status;
773 }
774 DeviceExtension->AllocatedResources = AllocatedResources;
775 DeviceExtension->SystemIoSlotNumber = PciSlotNumber.u.AsULONG;
776
777 /* Add legacy resources to the resources from HAL */
779 &LegacyAccessRanges, &LegacyAccessRangeCount);
780 if (!NT_SUCCESS(Status))
781 return ERROR_DEV_NOT_EXIST;
782
783 if (NumAccessRanges < LegacyAccessRangeCount)
784 {
785 ERR_(VIDEOPRT, "Too many legacy access ranges found\n");
786 return ERROR_NOT_ENOUGH_MEMORY; // ERROR_MORE_DATA;
787 }
788
789 RtlCopyMemory(AccessRanges, LegacyAccessRanges, LegacyAccessRangeCount * sizeof(VIDEO_ACCESS_RANGE));
790 AssignedCount = LegacyAccessRangeCount;
791 }
792 }
793 else
794 {
795 ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + (NumRequestedResources - 1) * sizeof(IO_RESOURCE_DESCRIPTOR);
796 ResReqList = ExAllocatePool(NonPagedPool, ListSize);
797 if (!ResReqList)
799
800 ResReqList->ListSize = ListSize;
801 ResReqList->InterfaceType = DeviceExtension->AdapterInterfaceType;
802 ResReqList->BusNumber = DeviceExtension->SystemIoBusNumber;
803 ResReqList->SlotNumber = DeviceExtension->SystemIoSlotNumber;
804 ResReqList->AlternativeLists = 1;
805 ResReqList->List[0].Version = 1;
806 ResReqList->List[0].Revision = 1;
807 ResReqList->List[0].Count = NumRequestedResources;
808
809 /* Copy in the caller's resource list */
810 RtlCopyMemory(ResReqList->List[0].Descriptors,
811 RequestedResources,
812 NumRequestedResources * sizeof(IO_RESOURCE_DESCRIPTOR));
813
814 Status = IoAssignResources(&DeviceExtension->RegistryPath,
815 NULL,
816 DeviceExtension->DriverObject,
817 DeviceExtension->PhysicalDeviceObject ?
818 DeviceExtension->PhysicalDeviceObject :
819 DeviceExtension->DriverObject->DeviceObject,
820 ResReqList,
822
823 if (!NT_SUCCESS(Status))
824 return Status;
825
826 if (!DeviceExtension->AllocatedResources)
827 DeviceExtension->AllocatedResources = AllocatedResources;
828 }
829
832
833 /* Return the slot number if the caller wants it */
834 if (Slot != NULL) *Slot = DeviceExtension->SystemIoBusNumber;
835
836 FullList = AllocatedResources->List;
837 ASSERT(AllocatedResources->Count == 1);
838 INFO_(VIDEOPRT, "InterfaceType %u BusNumber List %u Device BusNumber %u Version %u Revision %u\n",
839 FullList->InterfaceType, FullList->BusNumber, DeviceExtension->SystemIoBusNumber,
841
842 ASSERT(FullList->InterfaceType == PCIBus);
843 ASSERT(FullList->BusNumber == DeviceExtension->SystemIoBusNumber);
844 ASSERT(1 == FullList->PartialResourceList.Version);
845 ASSERT(1 == FullList->PartialResourceList.Revision);
846
848 Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
849 Descriptor++)
850 {
851 if ((Descriptor->Type == CmResourceTypeMemory ||
852 Descriptor->Type == CmResourceTypePort) &&
853 AssignedCount >= NumAccessRanges)
854 {
855 ERR_(VIDEOPRT, "Too many access ranges found\n");
856 return ERROR_MORE_DATA;
857 }
858 else if (Descriptor->Type == CmResourceTypeMemory)
859 {
860 INFO_(VIDEOPRT, "Memory range starting at 0x%08x length 0x%08x\n",
861 Descriptor->u.Memory.Start.u.LowPart, Descriptor->u.Memory.Length);
862 AccessRanges[AssignedCount].RangeStart = Descriptor->u.Memory.Start;
863 AccessRanges[AssignedCount].RangeLength = Descriptor->u.Memory.Length;
864 AccessRanges[AssignedCount].RangeInIoSpace = 0;
865 AccessRanges[AssignedCount].RangeVisible = 0; /* FIXME: Just guessing */
866 AccessRanges[AssignedCount].RangeShareable =
867 (Descriptor->ShareDisposition == CmResourceShareShared);
868 AccessRanges[AssignedCount].RangePassive = 0;
869 AssignedCount++;
870 }
871 else if (Descriptor->Type == CmResourceTypePort)
872 {
873 INFO_(VIDEOPRT, "Port range starting at 0x%04x length %d\n",
874 Descriptor->u.Port.Start.u.LowPart, Descriptor->u.Port.Length);
875 AccessRanges[AssignedCount].RangeStart = Descriptor->u.Port.Start;
876 AccessRanges[AssignedCount].RangeLength = Descriptor->u.Port.Length;
877 AccessRanges[AssignedCount].RangeInIoSpace = 1;
878 AccessRanges[AssignedCount].RangeVisible = 0; /* FIXME: Just guessing */
879 AccessRanges[AssignedCount].RangeShareable =
880 (Descriptor->ShareDisposition == CmResourceShareShared);
881 AccessRanges[AssignedCount].RangePassive = 0;
883 AccessRanges[AssignedCount].RangePassive |= VIDEO_RANGE_10_BIT_DECODE;
885 AccessRanges[AssignedCount].RangePassive |= VIDEO_RANGE_PASSIVE_DECODE;
886 AssignedCount++;
887 }
888 else if (Descriptor->Type == CmResourceTypeInterrupt)
889 {
890 DeviceExtension->InterruptLevel = Descriptor->u.Interrupt.Level;
891 DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
892 if (Descriptor->ShareDisposition == CmResourceShareShared)
893 DeviceExtension->InterruptShared = TRUE;
894 else
895 DeviceExtension->InterruptShared = FALSE;
896 }
897 // else if (Descriptor->Type == CmResourceTypeDma) // TODO!
898 else
899 {
900 ASSERT(FALSE);
902 }
903 }
904
905 return NO_ERROR;
906}
907
929NTAPI
931 _In_ PVOID HwDeviceExtension,
932 _In_opt_ ULONG NumAccessRanges,
933 _In_reads_opt_(NumAccessRanges) PVIDEO_ACCESS_RANGE AccessRanges)
934{
935 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
936 BOOLEAN ConflictDetected;
937 ULONG ResourceListSize;
939 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
940 ULONG i;
942
943 TRACE_(VIDEOPRT, "VideoPortVerifyAccessRanges\n");
944
945 /* Verify parameters */
946 if (NumAccessRanges && !AccessRanges)
948
949 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
950
951 if (NumAccessRanges == 0)
952 {
953 /* Release the resources and do nothing more for now... */
954 IntVideoPortReleaseResources(DeviceExtension);
955 return NO_ERROR;
956 }
957
958 /* Create the resource list */
959 ResourceListSize = sizeof(CM_RESOURCE_LIST)
960 + (NumAccessRanges - 1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
962 if (!ResourceList)
963 {
964 WARN_(VIDEOPRT, "ExAllocatePool() failed\n");
966 }
967
968 /* Fill resource list */
969 ResourceList->Count = 1;
970 ResourceList->List[0].InterfaceType = DeviceExtension->AdapterInterfaceType;
971 ResourceList->List[0].BusNumber = DeviceExtension->SystemIoBusNumber;
972 ResourceList->List[0].PartialResourceList.Version = 1;
973 ResourceList->List[0].PartialResourceList.Revision = 1;
974 ResourceList->List[0].PartialResourceList.Count = NumAccessRanges;
975 for (i = 0; i < NumAccessRanges; i++, AccessRanges++)
976 {
977 PartialDescriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i];
978 if (AccessRanges->RangeInIoSpace)
979 {
980 PartialDescriptor->Type = CmResourceTypePort;
981 PartialDescriptor->u.Port.Start = AccessRanges->RangeStart;
982 PartialDescriptor->u.Port.Length = AccessRanges->RangeLength;
983 }
984 else
985 {
986 PartialDescriptor->Type = CmResourceTypeMemory;
987 PartialDescriptor->u.Memory.Start = AccessRanges->RangeStart;
988 PartialDescriptor->u.Memory.Length = AccessRanges->RangeLength;
989 }
990 if (AccessRanges->RangeShareable)
991 PartialDescriptor->ShareDisposition = CmResourceShareShared;
992 else
994 PartialDescriptor->Flags = 0;
995 if (AccessRanges->RangePassive & VIDEO_RANGE_PASSIVE_DECODE)
996 PartialDescriptor->Flags |= CM_RESOURCE_PORT_PASSIVE_DECODE;
997 if (AccessRanges->RangePassive & VIDEO_RANGE_10_BIT_DECODE)
998 PartialDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE;
999 }
1000
1001 /* Try to acquire all resource ranges */
1003 DeviceExtension->DriverObject,
1004 NULL, 0, /* Driver List */
1005 DeviceExtension->PhysicalDeviceObject,
1006 ResourceList, ResourceListSize,
1007 &ConflictDetected);
1008
1010
1011 /* If VgaSave driver is conflicting and we don't explicitely want
1012 * to use it, ignore the problem (because win32k will try to use
1013 * this driver only if all other ones are failing). */
1015 IntIsVgaSaveDriver(DeviceExtension) &&
1016 !VpBaseVideo)
1017 {
1018 return NO_ERROR;
1019 }
1020
1021 if (!NT_SUCCESS(Status) || ConflictDetected)
1023 else
1024 return NO_ERROR;
1025}
1026
1027/*
1028 * @unimplemented
1029 */
1030
1033 IN PVOID HwDeviceExtension,
1034 IN VIDEO_DEVICE_DATA_TYPE DeviceDataType,
1037{
1038 TRACE_(VIDEOPRT, "VideoPortGetDeviceData\n");
1041}
1042
1043/*
1044 * @implemented
1045 */
1046
1049 IN PVOID HwDeviceExtension,
1052 IN ULONG Tag)
1053{
1054 TRACE_(VIDEOPRT, "VideoPortAllocatePool\n");
1056}
1057
1058/*
1059 * @implemented
1060 */
1061
1062VOID NTAPI
1064 IN PVOID HwDeviceExtension,
1065 IN PVOID Ptr)
1066{
1067 ExFreePool(Ptr);
1068}
1069
1070/*
1071 * @implemented
1072 */
1073
1076 IN PVOID HwDeviceExtension,
1077 IN ULONG Size,
1078 OUT PVOID *Buffer)
1079{
1080 TRACE_(VIDEOPRT, "VideoPortAllocateBuffer\n");
1083}
1084
1085/*
1086 * @implemented
1087 */
1088
1089VOID NTAPI
1091 IN PVOID HwDeviceExtension,
1092 IN PVOID Ptr)
1093{
1094 TRACE_(VIDEOPRT, "VideoPortReleaseBuffer\n");
1095 ExFreePool(Ptr);
1096}
1097
1098/*
1099 * @implemented
1100 */
1101
1104 IN PVOID HwDeviceExtension,
1106 IN ULONG Length,
1108{
1109 PMDL Mdl;
1110
1112 if (!Mdl)
1113 {
1114 return NULL;
1115 }
1116 /* FIXME use seh */
1118 return Mdl;
1119}
1120
1121/*
1122 * @implemented
1123 */
1124
1125BOOLEAN
1126NTAPI
1128 IN PVOID HwDeviceExtension,
1130 IN PEVENT pUEvent,
1131 IN PEVENT pDisplayEvent,
1132 IN DMA_FLAGS DmaFlags)
1133{
1134 PVOID Buffer;
1135
1136 /* clear output buffer */
1137 pVrp->OutputBuffer = NULL;
1138
1139 if (DmaFlags != VideoPortDmaInitOnly)
1140 {
1141 /* VideoPortKeepPagesLocked / VideoPortUnlockAfterDma is no-op */
1142 return FALSE;
1143 }
1144
1145 /* lock the buffer */
1146 Buffer = VideoPortLockBuffer(HwDeviceExtension, pVrp->InputBuffer, pVrp->InputBufferLength, IoModifyAccess);
1147
1148 if (Buffer)
1149 {
1150 /* store result buffer & length */
1151 pVrp->OutputBuffer = Buffer;
1152 pVrp->OutputBufferLength = pVrp->InputBufferLength;
1153
1154 /* operation succeeded */
1155 return TRUE;
1156 }
1157
1158 /* operation failed */
1159 return FALSE;
1160}
1161
1162
1163/*
1164 * @implemented
1165 */
1166
1167VOID NTAPI
1169 IN PVOID HwDeviceExtension,
1170 IN PVOID Mdl)
1171{
1172 if (Mdl)
1173 {
1175 IoFreeMdl(Mdl);
1176 }
1177}
1178
1179/*
1180 * @unimplemented
1181 */
1182
1185 IN PVOID HwDeviceExtension,
1186 IN ULONG NumAccessRanges,
1187 IN PVIDEO_ACCESS_RANGE AccessRange)
1188{
1190 /* Should store the ranges in the device extension for use by ntvdm. */
1191 return NO_ERROR;
1192}
1193
1194/*
1195 * @implemented
1196 */
1197
1200 IN PVOID HwDeviceExtension,
1201 IN BUS_DATA_TYPE BusDataType,
1204 IN ULONG Offset,
1205 IN ULONG Length)
1206{
1207 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1208
1209 TRACE_(VIDEOPRT, "VideoPortGetBusData\n");
1210
1211 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1212
1213 if (BusDataType != Cmos)
1214 {
1215 /* Legacy vs. PnP behaviour */
1216 if (DeviceExtension->PhysicalDeviceObject != NULL)
1217 SlotNumber = DeviceExtension->SystemIoSlotNumber;
1218 }
1219
1220 return HalGetBusDataByOffset(
1221 BusDataType,
1222 DeviceExtension->SystemIoBusNumber,
1223 SlotNumber,
1224 Buffer,
1225 Offset,
1226 Length);
1227}
1228
1229/*
1230 * @implemented
1231 */
1232
1235 IN PVOID HwDeviceExtension,
1236 IN BUS_DATA_TYPE BusDataType,
1238 IN PVOID Buffer,
1239 IN ULONG Offset,
1240 IN ULONG Length)
1241{
1242 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1243
1244 TRACE_(VIDEOPRT, "VideoPortSetBusData\n");
1245
1246 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1247
1248 if (BusDataType != Cmos)
1249 {
1250 /* Legacy vs. PnP behaviour */
1251 if (DeviceExtension->PhysicalDeviceObject != NULL)
1252 SlotNumber = DeviceExtension->SystemIoSlotNumber;
1253 }
1254
1255 return HalSetBusDataByOffset(
1256 BusDataType,
1257 DeviceExtension->SystemIoBusNumber,
1258 SlotNumber,
1259 Buffer,
1260 Offset,
1261 Length);
1262}
ULONG ReadLength
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:188
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
Definition: bufpool.h:45
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1230
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define TRACE_(x)
Definition: compat.h:76
#define L(x)
Definition: resources.c:13
#define ULONG_PTR
Definition: config.h:101
NTHALAPI NTSTATUS NTAPI HalAssignSlotResources(PUNICODE_STRING, PUNICODE_STRING, PDRIVER_OBJECT, PDEVICE_OBJECT, INTERFACE_TYPE, ULONG, ULONG, PCM_RESOURCE_LIST *)
NTHALAPI ULONG NTAPI HalGetBusData(BUS_DATA_TYPE, ULONG, ULONG, PVOID, ULONG)
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertHeadList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
#define PagedPool
Definition: env_spec_w32.h:308
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
_Must_inspect_result_ _In_ PFLT_GET_OPERATION_STATUS_CALLBACK CallbackRoutine
Definition: fltkernel.h:1035
FP_OP Operation
Definition: fpcontrol.c:150
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define IoFreeMdl
Definition: fxmdl.h:89
#define IoAllocateMdl
Definition: fxmdl.h:88
Status
Definition: gdiplustypes.h:25
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
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
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
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
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSTATUS NTAPI IoAssignResources(_In_ PUNICODE_STRING RegistryPath, _In_opt_ PUNICODE_STRING DriverClassName, _In_ PDRIVER_OBJECT DriverObject, _In_opt_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources, _Inout_ PCM_RESOURCE_LIST *AllocatedResources)
Definition: iorsrce.c:1134
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:931
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1435
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4643
unsigned int UINT
Definition: ndis.h:50
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:120
#define CM_RESOURCE_PORT_PASSIVE_DECODE
Definition: cmtypes.h:114
#define CM_RESOURCE_PORT_10_BIT_DECODE
Definition: cmtypes.h:110
#define KernelMode
Definition: asm.h:38
NTSYSAPI NTSTATUS NTAPI ZwOpenSection(_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define _Out_writes_(s)
Definition: no_sal2.h:176
#define _Out_
Definition: no_sal2.h:160
#define _In_reads_opt_(s)
Definition: no_sal2.h:222
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define PAGE_NOCACHE
Definition: nt_native.h:1314
#define PAGE_READWRITE
Definition: nt_native.h:1307
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1296
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define NtCurrentProcess()
Definition: nt_native.h:1660
@ ViewUnmap
Definition: nt_native.h:1282
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1916
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:354
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
unsigned short USHORT
Definition: pedump.c:61
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:394
struct _CM_RESOURCE_LIST CM_RESOURCE_LIST
#define CmResourceTypeMemory
Definition: restypes.h:106
@ PCIBus
Definition: restypes.h:126
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR CM_PARTIAL_RESOURCE_DESCRIPTOR
#define CmResourceTypePort
Definition: restypes.h:104
#define CmResourceTypeInterrupt
Definition: restypes.h:105
struct _IO_RESOURCE_DESCRIPTOR * PIO_RESOURCE_DESCRIPTOR
@ Cmos
Definition: miniport.h:89
@ PCIConfiguration
Definition: miniport.h:93
enum _BUS_DATA_TYPE BUS_DATA_TYPE
VOID(NTAPI * PBANKED_SECTION_ROUTINE)(IN ULONG ReadBank, IN ULONG WriteBank, IN PVOID Context)
Definition: miniport.h:50
struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR
#define VIDEO_RANGE_10_BIT_DECODE
Definition: video.h:99
LONG VP_STATUS
Definition: video.h:153
@ VideoPortDmaInitOnly
Definition: video.h:551
#define VIDEO_MEMORY_SPACE_USER_MODE
Definition: video.h:134
enum _DMA_FLAGS DMA_FLAGS
enum _VP_POOL_TYPE VP_POOL_TYPE
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
#define VIDEO_MEMORY_SPACE_P6CACHE
Definition: video.h:136
enum _VIDEO_DEVICE_DATA_TYPE VIDEO_DEVICE_DATA_TYPE
#define VIDEO_RANGE_PASSIVE_DECODE
Definition: video.h:98
enum _VP_LOCK_OPERATION VP_LOCK_OPERATION
#define INFO_(ch,...)
Definition: debug.h:159
#define ERR_(ch,...)
Definition: debug.h:156
#define WARN_(ch,...)
Definition: debug.h:157
#define STATUS_SUCCESS
Definition: shellext.h:65
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
base of all file and directory entries
Definition: entries.h:83
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: restypes.h:144
INTERFACE_TYPE InterfaceType
Definition: restypes.h:142
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@430::@435 Memory
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@430::@432 Port
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@430 u
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: restypes.h:100
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2279
union _IO_RESOURCE_DESCRIPTOR::@2227 u
struct _IO_RESOURCE_DESCRIPTOR::@2227::@2229 Memory
struct _IO_RESOURCE_DESCRIPTOR::@2227::@2228 Port
IO_RESOURCE_DESCRIPTOR Descriptors[1]
Definition: iotypes.h:2739
INTERFACE_TYPE InterfaceType
Definition: iotypes.h:2744
IO_RESOURCE_LIST List[1]
Definition: iotypes.h:2749
Definition: typedefs.h:120
struct _PCI_SLOT_NUMBER::@4322::@4323 bits
union _PCI_SLOT_NUMBER::@4322 u
ULONG RangeLength
Definition: video.h:216
UCHAR RangeShareable
Definition: video.h:219
PHYSICAL_ADDRESS RangeStart
Definition: video.h:215
PHYSICAL_ADDRESS IoAddress
Definition: videoprt.h:49
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:87
PCM_RESOURCE_LIST AllocatedResources
Definition: videoprt.h:94
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:98
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:86
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint16_t * PUSHORT
Definition: typedefs.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2479 u
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension)
Definition: videoprt.h:140
#define TAG_VIDEO_PORT
Definition: videoprt.h:38
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
#define TAG_VIDEO_PORT_BUFFER
Definition: videoprt.h:39
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:476
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4071
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3821
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:68
VOID NTAPI VideoPortFreeDeviceBase(IN PVOID HwDeviceExtension, IN PVOID MappedAddress)
Definition: resource.c:512
VP_STATUS NTAPI VideoPortGetAccessRanges(_In_ PVOID HwDeviceExtension, _In_opt_ ULONG NumRequestedResources, _In_reads_opt_(NumRequestedResources) PIO_RESOURCE_DESCRIPTOR RequestedResources, _In_ ULONG NumAccessRanges, _Out_writes_(NumAccessRanges) PVIDEO_ACCESS_RANGE AccessRanges, _In_ PVOID VendorId, _In_ PVOID DeviceId, _Out_ PULONG Slot)
Retrieves bus-relative (mainly PCI) hardware resources access ranges and, if possible,...
Definition: resource.c:640
NTSTATUS NTAPI IntVideoPortMapPhysicalMemory(IN HANDLE Process, IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG SizeInBytes, IN ULONG Protect, IN OUT PVOID *VirtualAddress OPTIONAL)
Definition: resource.c:230
VOID NTAPI VideoPortUnlockBuffer(IN PVOID HwDeviceExtension, IN PVOID Mdl)
Definition: resource.c:1168
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:1234
VP_STATUS NTAPI VideoPortMapMemory(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, IN PULONG Length, IN PULONG InIoSpace, OUT PVOID *VirtualAddress)
Definition: resource.c:549
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:527
PVOID NTAPI VideoPortLockBuffer(IN PVOID HwDeviceExtension, IN PVOID BaseAddress, IN ULONG Length, IN VP_LOCK_OPERATION Operation)
Definition: resource.c:1103
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:281
VOID NTAPI VideoPortFreePool(IN PVOID HwDeviceExtension, IN PVOID Ptr)
Definition: resource.c:1063
static BOOLEAN IntIsVgaSaveDriver(IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: resource.c:32
VOID NTAPI IntVideoPortUnmapMemory(IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension, IN PVOID MappedAddress)
Definition: resource.c:439
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:1199
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:1032
VP_STATUS NTAPI VideoPortVerifyAccessRanges(_In_ PVOID HwDeviceExtension, _In_opt_ ULONG NumAccessRanges, _In_reads_opt_(NumAccessRanges) PVIDEO_ACCESS_RANGE AccessRanges)
Claims or releases a range of hardware resources and checks for conflicts.
Definition: resource.c:930
PVOID NTAPI VideoPortAllocatePool(IN PVOID HwDeviceExtension, IN VP_POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: resource.c:1048
VP_STATUS NTAPI VideoPortSetTrappedEmulatorPorts(IN PVOID HwDeviceExtension, IN ULONG NumAccessRanges, IN PVIDEO_ACCESS_RANGE AccessRange)
Definition: resource.c:1184
NTSTATUS NTAPI IntVideoPortFilterResourceRequirements(IN PDEVICE_OBJECT DeviceObject, IN PIO_STACK_LOCATION IrpStack, IN PIRP Irp)
Definition: resource.c:87
BOOLEAN VpBaseVideo
Definition: videoprt.c:36
VP_STATUS NTAPI VideoPortUnmapMemory(IN PVOID HwDeviceExtension, IN PVOID VirtualAddress, IN HANDLE ProcessHandle)
Definition: resource.c:579
VP_STATUS NTAPI VideoPortAllocateBuffer(IN PVOID HwDeviceExtension, IN ULONG Size, OUT PVOID *Buffer)
Definition: resource.c:1075
VOID NTAPI VideoPortReleaseBuffer(IN PVOID HwDeviceExtension, IN PVOID Ptr)
Definition: resource.c:1090
VOID IntVideoPortReleaseResources(_In_ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: resource.c:204
PVOID NTAPI VideoPortGetDeviceBase(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS IoAddress, IN ULONG NumberOfUchars, IN UCHAR InIoSpace)
Definition: resource.c:491
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:1127
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:40
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241
@ CmResourceShareShared
Definition: cmtypes.h:243
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2275
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2274
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098
#define PCI_MAX_FUNCTION
Definition: iotypes.h:3601
#define PCI_MAX_DEVICES
Definition: iotypes.h:3600
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036
struct _IO_RESOURCE_REQUIREMENTS_LIST IO_RESOURCE_REQUIREMENTS_LIST
@ IoModifyAccess
Definition: ketypes.h:917
@ MmNonCached
Definition: mmtypes.h:129
#define PAGE_WRITECOMBINE
Definition: mmtypes.h:78
unsigned char UCHAR
Definition: xmlstorage.h:181
_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:221