ReactOS 0.4.15-dev-7887-g64a59a1
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 */
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;
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);
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
193VOID
195 _In_ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
196{
198 BOOLEAN ConflictDetected;
199 // An empty CM_RESOURCE_LIST
200 UCHAR EmptyResourceList[FIELD_OFFSET(CM_RESOURCE_LIST, List)] = {0};
201
203 DeviceExtension->DriverObject,
204 NULL, 0, /* Driver List */
205 DeviceExtension->PhysicalDeviceObject,
206 (PCM_RESOURCE_LIST)EmptyResourceList,
207 sizeof(EmptyResourceList),
208 &ConflictDetected);
209
210 if (!NT_SUCCESS(Status))
211 {
212 DPRINT1("VideoPortReleaseResources IoReportResource failed with 0x%08lx ; ConflictDetected: %s\n",
213 Status, ConflictDetected ? "TRUE" : "FALSE");
214 }
215 /* Ignore the returned status however... */
216}
217
222 IN ULONG SizeInBytes,
225{
226 OBJECT_ATTRIBUTES ObjAttribs;
228 HANDLE hMemObj;
230 SIZE_T Size;
231
232 /* Initialize object attribs */
233 RtlInitUnicodeString(&UnicodeString, L"\\Device\\PhysicalMemory");
234 InitializeObjectAttributes(&ObjAttribs,
237 NULL, NULL);
238
239 /* Open physical memory section */
240 Status = ZwOpenSection(&hMemObj, SECTION_ALL_ACCESS, &ObjAttribs);
241 if (!NT_SUCCESS(Status))
242 {
243 WARN_(VIDEOPRT, "ZwOpenSection() failed! (0x%x)\n", Status);
244 return Status;
245 }
246
247 /* Map view of section */
248 Size = SizeInBytes;
249 Status = ZwMapViewOfSection(hMemObj,
250 Process,
252 0,
253 Size,
255 &Size,
256 ViewUnmap,
257 0,
258 Protect);
259 ZwClose(hMemObj);
260 if (!NT_SUCCESS(Status))
261 {
262 WARN_(VIDEOPRT, "ZwMapViewOfSection() failed! (0x%x)\n", Status);
263 }
264
265 return Status;
266}
267
268
271 IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
272 IN PHYSICAL_ADDRESS IoAddress,
273 IN ULONG NumberOfUchars,
274 IN ULONG InIoSpace,
277{
279 PVIDEO_PORT_ADDRESS_MAPPING AddressMapping;
281 PVOID MappedAddress;
283
284 INFO_(VIDEOPRT, "- IoAddress: %lx\n", IoAddress.u.LowPart);
285 INFO_(VIDEOPRT, "- NumberOfUchars: %lx\n", NumberOfUchars);
286 INFO_(VIDEOPRT, "- InIoSpace: %x\n", InIoSpace);
287
288 InIoSpace &= ~VIDEO_MEMORY_SPACE_DENSE;
289 if ((InIoSpace & VIDEO_MEMORY_SPACE_P6CACHE) != 0)
290 {
291 INFO_(VIDEOPRT, "VIDEO_MEMORY_SPACE_P6CACHE not supported, turning off\n");
292 InIoSpace &= ~VIDEO_MEMORY_SPACE_P6CACHE;
293 }
294
295 if (ProcessHandle != NULL && (InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) == 0)
296 {
297 INFO_(VIDEOPRT, "ProcessHandle is not NULL (0x%x) but InIoSpace does not have "
298 "VIDEO_MEMORY_SPACE_USER_MODE set! Setting "
299 "VIDEO_MEMORY_SPACE_USER_MODE.\n",
301 InIoSpace |= VIDEO_MEMORY_SPACE_USER_MODE;
302 }
303 else if (ProcessHandle == NULL && (InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) != 0)
304 {
305 INFO_(VIDEOPRT, "ProcessHandle is NULL (0x%x) but InIoSpace does have "
306 "VIDEO_MEMORY_SPACE_USER_MODE set! Setting ProcessHandle "
307 "to NtCurrentProcess()\n",
310 }
311
312 if ((InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) == 0 &&
313 !IsListEmpty(&DeviceExtension->AddressMappingListHead))
314 {
315 Entry = DeviceExtension->AddressMappingListHead.Flink;
316 while (Entry != &DeviceExtension->AddressMappingListHead)
317 {
318 AddressMapping = CONTAINING_RECORD(
319 Entry,
321 List);
322 if (IoAddress.QuadPart == AddressMapping->IoAddress.QuadPart &&
323 NumberOfUchars <= AddressMapping->NumberOfUchars)
324 {
325 {
326 AddressMapping->MappingCount++;
327 if (Status)
328 *Status = NO_ERROR;
329 return AddressMapping->MappedAddress;
330 }
331 }
332 Entry = Entry->Flink;
333 }
334 }
335
336 AddressSpace = (ULONG)InIoSpace;
337 AddressSpace &= ~VIDEO_MEMORY_SPACE_USER_MODE;
339 DeviceExtension->AdapterInterfaceType,
340 DeviceExtension->SystemIoBusNumber,
341 IoAddress,
344 {
345 if (Status)
347
348 return NULL;
349 }
350
351 /* I/O space */
352 if (AddressSpace != 0)
353 {
354 ASSERT(0 == TranslatedAddress.u.HighPart);
355 if (Status)
356 *Status = NO_ERROR;
357
358 return (PVOID)(ULONG_PTR)TranslatedAddress.u.LowPart;
359 }
360
361 /* user space */
362 if ((InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) != 0)
363 {
364 NTSTATUS NtStatus;
365 MappedAddress = NULL;
368 NumberOfUchars,
369 PAGE_READWRITE/* | PAGE_WRITECOMBINE*/,
370 &MappedAddress);
371 if (!NT_SUCCESS(NtStatus))
372 {
373 WARN_(VIDEOPRT, "IntVideoPortMapPhysicalMemory() failed! (0x%x)\n", NtStatus);
374 if (Status)
375 *Status = NO_ERROR;
376 return NULL;
377 }
378 INFO_(VIDEOPRT, "Mapped user address = 0x%08x\n", MappedAddress);
379 }
380 else /* kernel space */
381 {
382 MappedAddress = MmMapIoSpace(
384 NumberOfUchars,
386 }
387
388 if (MappedAddress != NULL)
389 {
390 if (Status)
391 {
392 *Status = NO_ERROR;
393 }
394 if ((InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) == 0)
395 {
396 AddressMapping = ExAllocatePoolWithTag(
397 PagedPool,
400
401 if (AddressMapping == NULL)
402 return MappedAddress;
403
404 RtlZeroMemory(AddressMapping, sizeof(VIDEO_PORT_ADDRESS_MAPPING));
405 AddressMapping->NumberOfUchars = NumberOfUchars;
406 AddressMapping->IoAddress = IoAddress;
407 AddressMapping->SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
408 AddressMapping->MappedAddress = MappedAddress;
409 AddressMapping->MappingCount = 1;
411 &DeviceExtension->AddressMappingListHead,
412 &AddressMapping->List);
413 }
414
415 return MappedAddress;
416 }
417
418 if (Status)
419 *Status = NO_ERROR;
420
421 return NULL;
422}
423
426 IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
427 IN PVOID MappedAddress)
428{
429 PVIDEO_PORT_ADDRESS_MAPPING AddressMapping;
432
433 Entry = DeviceExtension->AddressMappingListHead.Flink;
434 while (Entry != &DeviceExtension->AddressMappingListHead)
435 {
436 AddressMapping = CONTAINING_RECORD(
437 Entry,
439 List);
440 if (AddressMapping->MappedAddress == MappedAddress)
441 {
442 ASSERT(AddressMapping->MappingCount > 0);
443 AddressMapping->MappingCount--;
444 if (AddressMapping->MappingCount == 0)
445 {
447 AddressMapping->MappedAddress,
448 AddressMapping->NumberOfUchars);
450 ExFreePool(AddressMapping);
451 }
452 return;
453 }
454
455 Entry = Entry->Flink;
456 }
457
458 /* If there was no kernelmode mapping for the given address found we assume
459 * that the given address is a usermode mapping and try to unmap it.
460 *
461 * FIXME: Is it ok to use NtCurrentProcess?
462 */
463 Status = ZwUnmapViewOfSection(NtCurrentProcess(), MappedAddress);
464 if (!NT_SUCCESS(Status))
465 {
466 WARN_(VIDEOPRT, "Warning: Mapping for address 0x%p not found!\n", MappedAddress);
467 }
468}
469
470/* PUBLIC FUNCTIONS ***********************************************************/
471
472/*
473 * @implemented
474 */
475
478 IN PVOID HwDeviceExtension,
479 IN PHYSICAL_ADDRESS IoAddress,
480 IN ULONG NumberOfUchars,
481 IN UCHAR InIoSpace)
482{
483 TRACE_(VIDEOPRT, "VideoPortGetDeviceBase\n");
485 VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
486 IoAddress,
487 NumberOfUchars,
488 InIoSpace,
489 NULL,
490 NULL);
491}
492
493/*
494 * @implemented
495 */
496
499 IN PVOID HwDeviceExtension,
500 IN PVOID MappedAddress)
501{
502 TRACE_(VIDEOPRT, "VideoPortFreeDeviceBase\n");
504 VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
505 MappedAddress);
506}
507
508/*
509 * @unimplemented
510 */
511
514 IN PVOID HwDeviceExtension,
517 IN PULONG InIoSpace,
519 IN ULONG BankLength,
520 IN UCHAR ReadWriteBank,
521 IN PBANKED_SECTION_ROUTINE BankRoutine,
523{
524 TRACE_(VIDEOPRT, "VideoPortMapBankedMemory\n");
527}
528
529
530/*
531 * @implemented
532 */
533
536 IN PVOID HwDeviceExtension,
539 IN PULONG InIoSpace,
541{
542 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
544
545 TRACE_(VIDEOPRT, "VideoPortMapMemory\n");
546 INFO_(VIDEOPRT, "- *VirtualAddress: 0x%x\n", *VirtualAddress);
547
548 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
550 DeviceExtension,
552 *Length,
553 *InIoSpace,
555 &Status);
556
557 return Status;
558}
559
560/*
561 * @implemented
562 */
563
566 IN PVOID HwDeviceExtension,
569{
570 TRACE_(VIDEOPRT, "VideoPortFreeDeviceBase\n");
571
573 VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
575
576 return NO_ERROR;
577}
578
625NTAPI
627 _In_ PVOID HwDeviceExtension,
628 _In_opt_ ULONG NumRequestedResources,
629 _In_reads_opt_(NumRequestedResources)
630 PIO_RESOURCE_DESCRIPTOR RequestedResources,
631 _In_ ULONG NumAccessRanges,
632 _Out_writes_(NumAccessRanges) PVIDEO_ACCESS_RANGE AccessRanges,
633 _In_ PVOID VendorId,
634 _In_ PVOID DeviceId,
635 _Out_ PULONG Slot)
636{
637 PCI_SLOT_NUMBER PciSlotNumber;
639 ULONG FunctionNumber;
643 UINT AssignedCount = 0;
646 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
648 USHORT VendorIdToFind;
649 USHORT DeviceIdToFind;
651 PVIDEO_ACCESS_RANGE LegacyAccessRanges;
652 ULONG LegacyAccessRangeCount;
654 ULONG ListSize;
656 BOOLEAN DeviceAndVendorFound = FALSE;
657
658 TRACE_(VIDEOPRT, "VideoPortGetAccessRanges(%d, %p, %d, %p)\n",
659 NumRequestedResources, RequestedResources, NumAccessRanges, AccessRanges);
660
661 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
662 DriverObject = DeviceExtension->DriverObject;
664
665 if (NumRequestedResources == 0)
666 {
667 AllocatedResources = DeviceExtension->AllocatedResources;
668 if (AllocatedResources == NULL &&
669 DeviceExtension->AdapterInterfaceType == PCIBus)
670 {
671 if (DeviceExtension->PhysicalDeviceObject != NULL)
672 {
673 PciSlotNumber.u.AsULONG = DeviceExtension->SystemIoSlotNumber;
674
676 DeviceExtension->SystemIoBusNumber,
677 PciSlotNumber.u.AsULONG,
678 &Config,
679 sizeof(Config));
680
681 if (ReturnedLength != sizeof(Config))
682 {
684 }
685 }
686 else
687 {
688 VendorIdToFind = VendorId != NULL ? *(PUSHORT)VendorId : 0;
689 DeviceIdToFind = DeviceId != NULL ? *(PUSHORT)DeviceId : 0;
690
691 if (VendorIdToFind == 0 && DeviceIdToFind == 0)
692 {
693 /* We're screwed */
694 return ERROR_DEV_NOT_EXIST;
695 }
696
697 INFO_(VIDEOPRT, "Looking for VendorId 0x%04x DeviceId 0x%04x\n",
698 VendorIdToFind, DeviceIdToFind);
699
700 /*
701 * Search for the device id and vendor id on this bus.
702 */
703 PciSlotNumber.u.bits.Reserved = 0;
705 {
706 PciSlotNumber.u.bits.DeviceNumber = DeviceNumber;
707 for (FunctionNumber = 0; FunctionNumber < PCI_MAX_FUNCTION; FunctionNumber++)
708 {
709 INFO_(VIDEOPRT, "- Function number: %d\n", FunctionNumber);
710 PciSlotNumber.u.bits.FunctionNumber = FunctionNumber;
712 DeviceExtension->SystemIoBusNumber,
713 PciSlotNumber.u.AsULONG,
714 &Config,
715 sizeof(Config));
716
717 INFO_(VIDEOPRT, "- Length of data: %x\n", ReturnedLength);
718
719 if (ReturnedLength == sizeof(Config))
720 {
721 INFO_(VIDEOPRT, "- Slot 0x%02x (Device %d Function %d) VendorId 0x%04x "
722 "DeviceId 0x%04x\n",
723 PciSlotNumber.u.AsULONG,
724 PciSlotNumber.u.bits.DeviceNumber,
725 PciSlotNumber.u.bits.FunctionNumber,
726 Config.VendorID,
727 Config.DeviceID);
728
729 if ((VendorIdToFind == 0 || Config.VendorID == VendorIdToFind) &&
730 (DeviceIdToFind == 0 || Config.DeviceID == DeviceIdToFind))
731 {
732 DeviceAndVendorFound = TRUE;
733 break;
734 }
735 }
736 }
737 if (DeviceAndVendorFound)
738 break;
739 }
740 if (FunctionNumber == PCI_MAX_FUNCTION)
741 {
742 WARN_(VIDEOPRT, "Didn't find device.\n");
743 return ERROR_DEV_NOT_EXIST;
744 }
745 }
746
747 Status = HalAssignSlotResources(&DeviceExtension->RegistryPath,
748 NULL,
749 DeviceExtension->DriverObject,
750 DeviceExtension->DriverObject->DeviceObject,
751 DeviceExtension->AdapterInterfaceType,
752 DeviceExtension->SystemIoBusNumber,
753 PciSlotNumber.u.AsULONG,
755 if (!NT_SUCCESS(Status))
756 {
757 WARN_(VIDEOPRT, "HalAssignSlotResources failed with status %x.\n",Status);
758 return Status;
759 }
760 DeviceExtension->AllocatedResources = AllocatedResources;
761 DeviceExtension->SystemIoSlotNumber = PciSlotNumber.u.AsULONG;
762
763 /* Add legacy resources to the resources from HAL */
765 &LegacyAccessRanges, &LegacyAccessRangeCount);
766 if (!NT_SUCCESS(Status))
767 return ERROR_DEV_NOT_EXIST;
768
769 if (NumAccessRanges < LegacyAccessRangeCount)
770 {
771 ERR_(VIDEOPRT, "Too many legacy access ranges found\n");
772 return ERROR_NOT_ENOUGH_MEMORY; // ERROR_MORE_DATA;
773 }
774
775 RtlCopyMemory(AccessRanges, LegacyAccessRanges, LegacyAccessRangeCount * sizeof(VIDEO_ACCESS_RANGE));
776 AssignedCount = LegacyAccessRangeCount;
777 }
778 }
779 else
780 {
781 ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + (NumRequestedResources - 1) * sizeof(IO_RESOURCE_DESCRIPTOR);
782 ResReqList = ExAllocatePool(NonPagedPool, ListSize);
783 if (!ResReqList)
785
786 ResReqList->ListSize = ListSize;
787 ResReqList->InterfaceType = DeviceExtension->AdapterInterfaceType;
788 ResReqList->BusNumber = DeviceExtension->SystemIoBusNumber;
789 ResReqList->SlotNumber = DeviceExtension->SystemIoSlotNumber;
790 ResReqList->AlternativeLists = 1;
791 ResReqList->List[0].Version = 1;
792 ResReqList->List[0].Revision = 1;
793 ResReqList->List[0].Count = NumRequestedResources;
794
795 /* Copy in the caller's resource list */
796 RtlCopyMemory(ResReqList->List[0].Descriptors,
797 RequestedResources,
798 NumRequestedResources * sizeof(IO_RESOURCE_DESCRIPTOR));
799
800 Status = IoAssignResources(&DeviceExtension->RegistryPath,
801 NULL,
802 DeviceExtension->DriverObject,
803 DeviceExtension->PhysicalDeviceObject ?
804 DeviceExtension->PhysicalDeviceObject :
805 DeviceExtension->DriverObject->DeviceObject,
806 ResReqList,
808
809 if (!NT_SUCCESS(Status))
810 return Status;
811
812 if (!DeviceExtension->AllocatedResources)
813 DeviceExtension->AllocatedResources = AllocatedResources;
814 }
815
818
819 /* Return the slot number if the caller wants it */
820 if (Slot != NULL) *Slot = DeviceExtension->SystemIoBusNumber;
821
822 FullList = AllocatedResources->List;
823 ASSERT(AllocatedResources->Count == 1);
824 INFO_(VIDEOPRT, "InterfaceType %u BusNumber List %u Device BusNumber %u Version %u Revision %u\n",
825 FullList->InterfaceType, FullList->BusNumber, DeviceExtension->SystemIoBusNumber,
827
828 ASSERT(FullList->InterfaceType == PCIBus);
829 ASSERT(FullList->BusNumber == DeviceExtension->SystemIoBusNumber);
830 ASSERT(1 == FullList->PartialResourceList.Version);
831 ASSERT(1 == FullList->PartialResourceList.Revision);
832
834 Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
835 Descriptor++)
836 {
837 if ((Descriptor->Type == CmResourceTypeMemory ||
838 Descriptor->Type == CmResourceTypePort) &&
839 AssignedCount >= NumAccessRanges)
840 {
841 ERR_(VIDEOPRT, "Too many access ranges found\n");
842 return ERROR_MORE_DATA;
843 }
844 else if (Descriptor->Type == CmResourceTypeMemory)
845 {
846 INFO_(VIDEOPRT, "Memory range starting at 0x%08x length 0x%08x\n",
847 Descriptor->u.Memory.Start.u.LowPart, Descriptor->u.Memory.Length);
848 AccessRanges[AssignedCount].RangeStart = Descriptor->u.Memory.Start;
849 AccessRanges[AssignedCount].RangeLength = Descriptor->u.Memory.Length;
850 AccessRanges[AssignedCount].RangeInIoSpace = 0;
851 AccessRanges[AssignedCount].RangeVisible = 0; /* FIXME: Just guessing */
852 AccessRanges[AssignedCount].RangeShareable =
853 (Descriptor->ShareDisposition == CmResourceShareShared);
854 AccessRanges[AssignedCount].RangePassive = 0;
855 AssignedCount++;
856 }
857 else if (Descriptor->Type == CmResourceTypePort)
858 {
859 INFO_(VIDEOPRT, "Port range starting at 0x%04x length %d\n",
860 Descriptor->u.Port.Start.u.LowPart, Descriptor->u.Port.Length);
861 AccessRanges[AssignedCount].RangeStart = Descriptor->u.Port.Start;
862 AccessRanges[AssignedCount].RangeLength = Descriptor->u.Port.Length;
863 AccessRanges[AssignedCount].RangeInIoSpace = 1;
864 AccessRanges[AssignedCount].RangeVisible = 0; /* FIXME: Just guessing */
865 AccessRanges[AssignedCount].RangeShareable =
866 (Descriptor->ShareDisposition == CmResourceShareShared);
867 AccessRanges[AssignedCount].RangePassive = 0;
869 AccessRanges[AssignedCount].RangePassive |= VIDEO_RANGE_10_BIT_DECODE;
871 AccessRanges[AssignedCount].RangePassive |= VIDEO_RANGE_PASSIVE_DECODE;
872 AssignedCount++;
873 }
874 else if (Descriptor->Type == CmResourceTypeInterrupt)
875 {
876 DeviceExtension->InterruptLevel = Descriptor->u.Interrupt.Level;
877 DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
878 if (Descriptor->ShareDisposition == CmResourceShareShared)
879 DeviceExtension->InterruptShared = TRUE;
880 else
881 DeviceExtension->InterruptShared = FALSE;
882 }
883 // else if (Descriptor->Type == CmResourceTypeDma) // TODO!
884 else
885 {
886 ASSERT(FALSE);
888 }
889 }
890
891 return NO_ERROR;
892}
893
915NTAPI
917 _In_ PVOID HwDeviceExtension,
918 _In_opt_ ULONG NumAccessRanges,
919 _In_reads_opt_(NumAccessRanges) PVIDEO_ACCESS_RANGE AccessRanges)
920{
921 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
922 BOOLEAN ConflictDetected;
923 ULONG ResourceListSize;
925 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
926 ULONG i;
928
929 TRACE_(VIDEOPRT, "VideoPortVerifyAccessRanges\n");
930
931 /* Verify parameters */
932 if (NumAccessRanges && !AccessRanges)
934
935 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
936
937 if (NumAccessRanges == 0)
938 {
939 /* Release the resources and do nothing more for now... */
940 IntVideoPortReleaseResources(DeviceExtension);
941 return NO_ERROR;
942 }
943
944 /* Create the resource list */
945 ResourceListSize = sizeof(CM_RESOURCE_LIST)
946 + (NumAccessRanges - 1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
948 if (!ResourceList)
949 {
950 WARN_(VIDEOPRT, "ExAllocatePool() failed\n");
952 }
953
954 /* Fill resource list */
955 ResourceList->Count = 1;
956 ResourceList->List[0].InterfaceType = DeviceExtension->AdapterInterfaceType;
957 ResourceList->List[0].BusNumber = DeviceExtension->SystemIoBusNumber;
958 ResourceList->List[0].PartialResourceList.Version = 1;
959 ResourceList->List[0].PartialResourceList.Revision = 1;
960 ResourceList->List[0].PartialResourceList.Count = NumAccessRanges;
961 for (i = 0; i < NumAccessRanges; i++, AccessRanges++)
962 {
963 PartialDescriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i];
964 if (AccessRanges->RangeInIoSpace)
965 {
966 PartialDescriptor->Type = CmResourceTypePort;
967 PartialDescriptor->u.Port.Start = AccessRanges->RangeStart;
968 PartialDescriptor->u.Port.Length = AccessRanges->RangeLength;
969 }
970 else
971 {
972 PartialDescriptor->Type = CmResourceTypeMemory;
973 PartialDescriptor->u.Memory.Start = AccessRanges->RangeStart;
974 PartialDescriptor->u.Memory.Length = AccessRanges->RangeLength;
975 }
976 if (AccessRanges->RangeShareable)
977 PartialDescriptor->ShareDisposition = CmResourceShareShared;
978 else
980 PartialDescriptor->Flags = 0;
981 if (AccessRanges->RangePassive & VIDEO_RANGE_PASSIVE_DECODE)
982 PartialDescriptor->Flags |= CM_RESOURCE_PORT_PASSIVE_DECODE;
983 if (AccessRanges->RangePassive & VIDEO_RANGE_10_BIT_DECODE)
984 PartialDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE;
985 }
986
987 /* Try to acquire all resource ranges */
989 DeviceExtension->DriverObject,
990 NULL, 0, /* Driver List */
991 DeviceExtension->PhysicalDeviceObject,
992 ResourceList, ResourceListSize,
993 &ConflictDetected);
994
996
997 if (!NT_SUCCESS(Status) || ConflictDetected)
999 else
1000 return NO_ERROR;
1001}
1002
1003/*
1004 * @unimplemented
1005 */
1006
1009 IN PVOID HwDeviceExtension,
1010 IN VIDEO_DEVICE_DATA_TYPE DeviceDataType,
1013{
1014 TRACE_(VIDEOPRT, "VideoPortGetDeviceData\n");
1017}
1018
1019/*
1020 * @implemented
1021 */
1022
1025 IN PVOID HwDeviceExtension,
1028 IN ULONG Tag)
1029{
1030 TRACE_(VIDEOPRT, "VideoPortAllocatePool\n");
1032}
1033
1034/*
1035 * @implemented
1036 */
1037
1038VOID NTAPI
1040 IN PVOID HwDeviceExtension,
1041 IN PVOID Ptr)
1042{
1043 ExFreePool(Ptr);
1044}
1045
1046/*
1047 * @implemented
1048 */
1049
1052 IN PVOID HwDeviceExtension,
1053 IN ULONG Size,
1054 OUT PVOID *Buffer)
1055{
1056 TRACE_(VIDEOPRT, "VideoPortAllocateBuffer\n");
1059}
1060
1061/*
1062 * @implemented
1063 */
1064
1065VOID NTAPI
1067 IN PVOID HwDeviceExtension,
1068 IN PVOID Ptr)
1069{
1070 TRACE_(VIDEOPRT, "VideoPortReleaseBuffer\n");
1071 ExFreePool(Ptr);
1072}
1073
1074/*
1075 * @implemented
1076 */
1077
1080 IN PVOID HwDeviceExtension,
1082 IN ULONG Length,
1084{
1085 PMDL Mdl;
1086
1088 if (!Mdl)
1089 {
1090 return NULL;
1091 }
1092 /* FIXME use seh */
1094 return Mdl;
1095}
1096
1097/*
1098 * @implemented
1099 */
1100
1101BOOLEAN
1102NTAPI
1104 IN PVOID HwDeviceExtension,
1106 IN PEVENT pUEvent,
1107 IN PEVENT pDisplayEvent,
1108 IN DMA_FLAGS DmaFlags)
1109{
1110 PVOID Buffer;
1111
1112 /* clear output buffer */
1113 pVrp->OutputBuffer = NULL;
1114
1115 if (DmaFlags != VideoPortDmaInitOnly)
1116 {
1117 /* VideoPortKeepPagesLocked / VideoPortUnlockAfterDma is no-op */
1118 return FALSE;
1119 }
1120
1121 /* lock the buffer */
1122 Buffer = VideoPortLockBuffer(HwDeviceExtension, pVrp->InputBuffer, pVrp->InputBufferLength, IoModifyAccess);
1123
1124 if (Buffer)
1125 {
1126 /* store result buffer & length */
1127 pVrp->OutputBuffer = Buffer;
1128 pVrp->OutputBufferLength = pVrp->InputBufferLength;
1129
1130 /* operation succeeded */
1131 return TRUE;
1132 }
1133
1134 /* operation failed */
1135 return FALSE;
1136}
1137
1138
1139/*
1140 * @implemented
1141 */
1142
1143VOID NTAPI
1145 IN PVOID HwDeviceExtension,
1146 IN PVOID Mdl)
1147{
1148 if (Mdl)
1149 {
1151 IoFreeMdl(Mdl);
1152 }
1153}
1154
1155/*
1156 * @unimplemented
1157 */
1158
1161 IN PVOID HwDeviceExtension,
1162 IN ULONG NumAccessRanges,
1163 IN PVIDEO_ACCESS_RANGE AccessRange)
1164{
1166 /* Should store the ranges in the device extension for use by ntvdm. */
1167 return NO_ERROR;
1168}
1169
1170/*
1171 * @implemented
1172 */
1173
1176 IN PVOID HwDeviceExtension,
1177 IN BUS_DATA_TYPE BusDataType,
1180 IN ULONG Offset,
1181 IN ULONG Length)
1182{
1183 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1184
1185 TRACE_(VIDEOPRT, "VideoPortGetBusData\n");
1186
1187 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1188
1189 if (BusDataType != Cmos)
1190 {
1191 /* Legacy vs. PnP behaviour */
1192 if (DeviceExtension->PhysicalDeviceObject != NULL)
1193 SlotNumber = DeviceExtension->SystemIoSlotNumber;
1194 }
1195
1196 return HalGetBusDataByOffset(
1197 BusDataType,
1198 DeviceExtension->SystemIoBusNumber,
1199 SlotNumber,
1200 Buffer,
1201 Offset,
1202 Length);
1203}
1204
1205/*
1206 * @implemented
1207 */
1208
1211 IN PVOID HwDeviceExtension,
1212 IN BUS_DATA_TYPE BusDataType,
1214 IN PVOID Buffer,
1215 IN ULONG Offset,
1216 IN ULONG Length)
1217{
1218 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1219
1220 TRACE_(VIDEOPRT, "VideoPortSetBusData\n");
1221
1222 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
1223
1224 if (BusDataType != Cmos)
1225 {
1226 /* Legacy vs. PnP behaviour */
1227 if (DeviceExtension->PhysicalDeviceObject != NULL)
1228 SlotNumber = DeviceExtension->SystemIoSlotNumber;
1229 }
1230
1231 return HalSetBusDataByOffset(
1232 BusDataType,
1233 DeviceExtension->SystemIoBusNumber,
1234 SlotNumber,
1235 Buffer,
1236 Offset,
1237 Length);
1238}
ULONG ReadLength
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
struct _IO_RESOURCE_DESCRIPTOR * PIO_RESOURCE_DESCRIPTOR
struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR
struct _IO_RESOURCE_REQUIREMENTS_LIST IO_RESOURCE_REQUIREMENTS_LIST
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:188
#define UNIMPLEMENTED
Definition: debug.h:115
Definition: bufpool.h:45
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1230
_In_ PIRP Irp
Definition: csq.h:116
#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:32
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define TRACE_(x)
Definition: compat.h:76
#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
struct _CM_RESOURCE_LIST CM_RESOURCE_LIST
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
@ PCIBus
Definition: hwresource.cpp:142
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR CM_PARTIAL_RESOURCE_DESCRIPTOR
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#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
#define _Out_writes_(size)
Definition: ms_sal.h:348
#define _Out_
Definition: ms_sal.h:345
#define _In_reads_opt_(size)
Definition: ms_sal.h:320
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
unsigned int UINT
Definition: ndis.h:50
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4643
#define KernelMode
Definition: asm.h:34
#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
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 PAGE_READWRITE
Definition: nt_native.h:1304
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define NtCurrentProcess()
Definition: nt_native.h:1657
@ ViewUnmap
Definition: nt_native.h:1279
_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:1904
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define L(x)
Definition: ntvdm.h:50
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
@ 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
#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: hwresource.cpp:160
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@393 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@393::@398 Memory
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@393::@395 Port
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2277
union _IO_RESOURCE_DESCRIPTOR::@21 u
struct _IO_RESOURCE_DESCRIPTOR::@21::@22 Port
UCHAR ShareDisposition
Definition: edit.c:61
struct _IO_RESOURCE_DESCRIPTOR::@21::@23 Memory
ULONG Count
Definition: edit.c:124
USHORT Revision
Definition: edit.c:123
USHORT Version
Definition: edit.c:122
IO_RESOURCE_DESCRIPTOR Descriptors[1]
Definition: edit.c:125
INTERFACE_TYPE InterfaceType
Definition: edit.c:130
IO_RESOURCE_LIST List[1]
Definition: edit.c:135
Definition: typedefs.h:120
union _PCI_SLOT_NUMBER::@4022 u
struct _PCI_SLOT_NUMBER::@4022::@4023 bits
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
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::@2295 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:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_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:498
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:626
NTSTATUS NTAPI IntVideoPortMapPhysicalMemory(IN HANDLE Process, IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG SizeInBytes, IN ULONG Protect, IN OUT PVOID *VirtualAddress OPTIONAL)
Definition: resource.c:219
VOID NTAPI VideoPortUnlockBuffer(IN PVOID HwDeviceExtension, IN PVOID Mdl)
Definition: resource.c:1144
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:1210
VP_STATUS NTAPI VideoPortMapMemory(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, IN PULONG Length, IN PULONG InIoSpace, OUT PVOID *VirtualAddress)
Definition: resource.c:535
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:513
PVOID NTAPI VideoPortLockBuffer(IN PVOID HwDeviceExtension, IN PVOID BaseAddress, IN ULONG Length, IN VP_LOCK_OPERATION Operation)
Definition: resource.c:1079
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:270
VOID NTAPI VideoPortFreePool(IN PVOID HwDeviceExtension, IN PVOID Ptr)
Definition: resource.c:1039
VOID NTAPI IntVideoPortUnmapMemory(IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension, IN PVOID MappedAddress)
Definition: resource.c:425
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:1175
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:1008
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:916
PVOID NTAPI VideoPortAllocatePool(IN PVOID HwDeviceExtension, IN VP_POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: resource.c:1024
VP_STATUS NTAPI VideoPortSetTrappedEmulatorPorts(IN PVOID HwDeviceExtension, IN ULONG NumAccessRanges, IN PVIDEO_ACCESS_RANGE AccessRange)
Definition: resource.c:1160
NTSTATUS NTAPI IntVideoPortFilterResourceRequirements(IN PDEVICE_OBJECT DeviceObject, IN PIO_STACK_LOCATION IrpStack, IN PIRP Irp)
Definition: resource.c:77
VP_STATUS NTAPI VideoPortUnmapMemory(IN PVOID HwDeviceExtension, IN PVOID VirtualAddress, IN HANDLE ProcessHandle)
Definition: resource.c:565
VP_STATUS NTAPI VideoPortAllocateBuffer(IN PVOID HwDeviceExtension, IN ULONG Size, OUT PVOID *Buffer)
Definition: resource.c:1051
VOID NTAPI VideoPortReleaseBuffer(IN PVOID HwDeviceExtension, IN PVOID Ptr)
Definition: resource.c:1066
VOID IntVideoPortReleaseResources(_In_ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: resource.c:194
PVOID NTAPI VideoPortGetDeviceBase(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS IoAddress, IN ULONG NumberOfUchars, IN UCHAR InIoSpace)
Definition: resource.c:477
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:1103
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
@ 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:3599
#define PCI_MAX_DEVICES
Definition: iotypes.h:3598
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036
@ IoModifyAccess
Definition: ketypes.h:865
@ MmNonCached
Definition: mmtypes.h:129
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