4 * Copyright (C) 2002 - 2005 ReactOS Team
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.
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.
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
24 /* PRIVATE FUNCTIONS **********************************************************/
27 IntVideoPortMapPhysicalMemory(
29 IN PHYSICAL_ADDRESS PhysicalAddress
,
32 IN OUT PVOID
*VirtualAddress OPTIONAL
)
34 OBJECT_ATTRIBUTES ObjAttribs
;
35 UNICODE_STRING UnicodeString
;
40 /* Initialize object attribs */
41 RtlInitUnicodeString(&UnicodeString
, L
"\\Device\\PhysicalMemory");
42 InitializeObjectAttributes(&ObjAttribs
,
44 OBJ_CASE_INSENSITIVE
| OBJ_KERNEL_HANDLE
,
47 /* Open physical memory section */
48 Status
= ZwOpenSection(&hMemObj
, SECTION_ALL_ACCESS
, &ObjAttribs
);
49 if (!NT_SUCCESS(Status
))
51 WARN_(VIDEOPRT
, "ZwOpenSection() failed! (0x%x)\n", Status
);
55 /* Map view of section */
57 Status
= ZwMapViewOfSection(hMemObj
,
62 (PLARGE_INTEGER
)(&PhysicalAddress
),
68 if (!NT_SUCCESS(Status
))
70 WARN_(VIDEOPRT
, "ZwMapViewOfSection() failed! (0x%x)\n", Status
);
78 IntVideoPortMapMemory(
79 IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
,
80 IN PHYSICAL_ADDRESS IoAddress
,
81 IN ULONG NumberOfUchars
,
83 IN HANDLE ProcessHandle
,
84 OUT VP_STATUS
*Status
)
86 PHYSICAL_ADDRESS TranslatedAddress
;
87 PVIDEO_PORT_ADDRESS_MAPPING AddressMapping
;
92 INFO_(VIDEOPRT
, "- IoAddress: %lx\n", IoAddress
.u
.LowPart
);
93 INFO_(VIDEOPRT
, "- NumberOfUchars: %lx\n", NumberOfUchars
);
94 INFO_(VIDEOPRT
, "- InIoSpace: %x\n", InIoSpace
);
96 InIoSpace
&= ~VIDEO_MEMORY_SPACE_DENSE
;
97 if ((InIoSpace
& VIDEO_MEMORY_SPACE_P6CACHE
) != 0)
99 INFO_(VIDEOPRT
, "VIDEO_MEMORY_SPACE_P6CACHE not supported, turning off\n");
100 InIoSpace
&= ~VIDEO_MEMORY_SPACE_P6CACHE
;
103 if (ProcessHandle
!= NULL
&& (InIoSpace
& VIDEO_MEMORY_SPACE_USER_MODE
) == 0)
105 INFO_(VIDEOPRT
, "ProcessHandle is not NULL (0x%x) but InIoSpace does not have "
106 "VIDEO_MEMORY_SPACE_USER_MODE set! Setting "
107 "VIDEO_MEMORY_SPACE_USER_MODE.\n",
109 InIoSpace
|= VIDEO_MEMORY_SPACE_USER_MODE
;
111 else if (ProcessHandle
== NULL
&& (InIoSpace
& VIDEO_MEMORY_SPACE_USER_MODE
) != 0)
113 INFO_(VIDEOPRT
, "ProcessHandle is NULL (0x%x) but InIoSpace does have "
114 "VIDEO_MEMORY_SPACE_USER_MODE set! Setting ProcessHandle "
115 "to NtCurrentProcess()\n",
117 ProcessHandle
= NtCurrentProcess();
120 if ((InIoSpace
& VIDEO_MEMORY_SPACE_USER_MODE
) == 0 &&
121 !IsListEmpty(&DeviceExtension
->AddressMappingListHead
))
123 Entry
= DeviceExtension
->AddressMappingListHead
.Flink
;
124 while (Entry
!= &DeviceExtension
->AddressMappingListHead
)
126 AddressMapping
= CONTAINING_RECORD(
128 VIDEO_PORT_ADDRESS_MAPPING
,
130 if (IoAddress
.QuadPart
== AddressMapping
->IoAddress
.QuadPart
&&
131 NumberOfUchars
<= AddressMapping
->NumberOfUchars
)
134 AddressMapping
->MappingCount
++;
137 return AddressMapping
->MappedAddress
;
140 Entry
= Entry
->Flink
;
144 AddressSpace
= (ULONG
)InIoSpace
;
145 AddressSpace
&= ~VIDEO_MEMORY_SPACE_USER_MODE
;
146 if (HalTranslateBusAddress(
147 DeviceExtension
->AdapterInterfaceType
,
148 DeviceExtension
->SystemIoBusNumber
,
151 &TranslatedAddress
) == FALSE
)
154 *Status
= ERROR_NOT_ENOUGH_MEMORY
;
160 if (AddressSpace
!= 0)
162 ASSERT(0 == TranslatedAddress
.u
.HighPart
);
166 return (PVOID
)(ULONG_PTR
)TranslatedAddress
.u
.LowPart
;
170 if ((InIoSpace
& VIDEO_MEMORY_SPACE_USER_MODE
) != 0)
173 MappedAddress
= NULL
;
174 NtStatus
= IntVideoPortMapPhysicalMemory(ProcessHandle
,
177 PAGE_READWRITE
/* | PAGE_WRITECOMBINE*/,
179 if (!NT_SUCCESS(NtStatus
))
181 WARN_(VIDEOPRT
, "IntVideoPortMapPhysicalMemory() failed! (0x%x)\n", NtStatus
);
186 INFO_(VIDEOPRT
, "Mapped user address = 0x%08x\n", MappedAddress
);
188 else /* kernel space */
190 MappedAddress
= MmMapIoSpace(
196 if (MappedAddress
!= NULL
)
202 if ((InIoSpace
& VIDEO_MEMORY_SPACE_USER_MODE
) == 0)
204 AddressMapping
= ExAllocatePoolWithTag(
206 sizeof(VIDEO_PORT_ADDRESS_MAPPING
),
209 if (AddressMapping
== NULL
)
210 return MappedAddress
;
212 RtlZeroMemory(AddressMapping
, sizeof(VIDEO_PORT_ADDRESS_MAPPING
));
213 AddressMapping
->NumberOfUchars
= NumberOfUchars
;
214 AddressMapping
->IoAddress
= IoAddress
;
215 AddressMapping
->SystemIoBusNumber
= DeviceExtension
->SystemIoBusNumber
;
216 AddressMapping
->MappedAddress
= MappedAddress
;
217 AddressMapping
->MappingCount
= 1;
219 &DeviceExtension
->AddressMappingListHead
,
220 &AddressMapping
->List
);
223 return MappedAddress
;
233 IntVideoPortUnmapMemory(
234 IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
,
235 IN PVOID MappedAddress
)
237 PVIDEO_PORT_ADDRESS_MAPPING AddressMapping
;
241 Entry
= DeviceExtension
->AddressMappingListHead
.Flink
;
242 while (Entry
!= &DeviceExtension
->AddressMappingListHead
)
244 AddressMapping
= CONTAINING_RECORD(
246 VIDEO_PORT_ADDRESS_MAPPING
,
248 if (AddressMapping
->MappedAddress
== MappedAddress
)
250 ASSERT(AddressMapping
->MappingCount
> 0);
251 AddressMapping
->MappingCount
--;
252 if (AddressMapping
->MappingCount
== 0)
255 AddressMapping
->MappedAddress
,
256 AddressMapping
->NumberOfUchars
);
257 RemoveEntryList(Entry
);
258 ExFreePool(AddressMapping
);
263 Entry
= Entry
->Flink
;
266 /* If there was no kernelmode mapping for the given address found we assume
267 * that the given address is a usermode mapping and try to unmap it.
269 * FIXME: Is it ok to use NtCurrentProcess?
271 Status
= ZwUnmapViewOfSection(NtCurrentProcess(), MappedAddress
);
272 if (!NT_SUCCESS(Status
))
274 WARN_(VIDEOPRT
, "Warning: Mapping for address 0x%p not found!\n", MappedAddress
);
278 /* PUBLIC FUNCTIONS ***********************************************************/
285 VideoPortGetDeviceBase(
286 IN PVOID HwDeviceExtension
,
287 IN PHYSICAL_ADDRESS IoAddress
,
288 IN ULONG NumberOfUchars
,
291 TRACE_(VIDEOPRT
, "VideoPortGetDeviceBase\n");
292 return IntVideoPortMapMemory(
293 VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension
),
306 VideoPortFreeDeviceBase(
307 IN PVOID HwDeviceExtension
,
308 IN PVOID MappedAddress
)
310 TRACE_(VIDEOPRT
, "VideoPortFreeDeviceBase\n");
311 IntVideoPortUnmapMemory(
312 VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension
),
321 VideoPortMapBankedMemory(
322 IN PVOID HwDeviceExtension
,
323 IN PHYSICAL_ADDRESS PhysicalAddress
,
326 OUT PVOID
*VirtualAddress
,
328 IN UCHAR ReadWriteBank
,
329 IN PBANKED_SECTION_ROUTINE BankRoutine
,
332 TRACE_(VIDEOPRT
, "VideoPortMapBankedMemory\n");
334 return ERROR_INVALID_FUNCTION
;
344 IN PVOID HwDeviceExtension
,
345 IN PHYSICAL_ADDRESS PhysicalAddress
,
348 OUT PVOID
*VirtualAddress
)
350 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
;
353 TRACE_(VIDEOPRT
, "VideoPortMapMemory\n");
354 INFO_(VIDEOPRT
, "- *VirtualAddress: 0x%x\n", *VirtualAddress
);
356 DeviceExtension
= VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension
);
357 *VirtualAddress
= IntVideoPortMapMemory(
362 (HANDLE
)*VirtualAddress
,
373 VideoPortUnmapMemory(
374 IN PVOID HwDeviceExtension
,
375 IN PVOID VirtualAddress
,
376 IN HANDLE ProcessHandle
)
378 TRACE_(VIDEOPRT
, "VideoPortFreeDeviceBase\n");
380 IntVideoPortUnmapMemory(
381 VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension
),
392 VideoPortGetAccessRanges(
393 IN PVOID HwDeviceExtension
,
394 IN ULONG NumRequestedResources
,
395 IN PIO_RESOURCE_DESCRIPTOR RequestedResources OPTIONAL
,
396 IN ULONG NumAccessRanges
,
397 IN PVIDEO_ACCESS_RANGE AccessRanges
,
402 PCI_SLOT_NUMBER PciSlotNumber
;
404 ULONG FunctionNumber
;
405 PCI_COMMON_CONFIG Config
;
406 PCM_RESOURCE_LIST AllocatedResources
;
409 CM_FULL_RESOURCE_DESCRIPTOR
*FullList
;
410 CM_PARTIAL_RESOURCE_DESCRIPTOR
*Descriptor
;
411 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
;
412 USHORT VendorIdToFind
;
413 USHORT DeviceIdToFind
;
415 ULONG ReturnedLength
;
416 BOOLEAN DeviceAndVendorFound
= FALSE
;
418 TRACE_(VIDEOPRT
, "VideoPortGetAccessRanges\n");
420 DeviceExtension
= VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension
);
422 if (NumRequestedResources
== 0)
424 AllocatedResources
= DeviceExtension
->AllocatedResources
;
425 if (AllocatedResources
== NULL
&&
426 DeviceExtension
->AdapterInterfaceType
== PCIBus
)
428 if (DeviceExtension
->PhysicalDeviceObject
!= NULL
)
430 PciSlotNumber
.u
.AsULONG
= DeviceExtension
->SystemIoSlotNumber
;
432 ReturnedLength
= HalGetBusData(
434 DeviceExtension
->SystemIoBusNumber
,
435 PciSlotNumber
.u
.AsULONG
,
437 sizeof(PCI_COMMON_CONFIG
));
439 if (ReturnedLength
!= sizeof(PCI_COMMON_CONFIG
))
441 return ERROR_NOT_ENOUGH_MEMORY
;
446 VendorIdToFind
= VendorId
!= NULL
? *(PUSHORT
)VendorId
: 0;
447 DeviceIdToFind
= DeviceId
!= NULL
? *(PUSHORT
)DeviceId
: 0;
448 SlotIdToFind
= Slot
!= NULL
? *Slot
: 0;
449 PciSlotNumber
.u
.AsULONG
= SlotIdToFind
;
451 INFO_(VIDEOPRT
, "Looking for VendorId 0x%04x DeviceId 0x%04x\n",
452 VendorIdToFind
, DeviceIdToFind
);
455 * Search for the device id and vendor id on this bus.
457 for (DeviceNumber
= 0; DeviceNumber
< PCI_MAX_DEVICES
; DeviceNumber
++)
459 PciSlotNumber
.u
.bits
.DeviceNumber
= DeviceNumber
;
460 for (FunctionNumber
= 0; FunctionNumber
< 8; FunctionNumber
++)
462 INFO_(VIDEOPRT
, "- Function number: %d\n", FunctionNumber
);
463 PciSlotNumber
.u
.bits
.FunctionNumber
= FunctionNumber
;
464 ReturnedLength
= HalGetBusData(
466 DeviceExtension
->SystemIoBusNumber
,
467 PciSlotNumber
.u
.AsULONG
,
469 sizeof(PCI_COMMON_CONFIG
));
470 INFO_(VIDEOPRT
, "- Length of data: %x\n", ReturnedLength
);
471 if (ReturnedLength
== sizeof(PCI_COMMON_CONFIG
))
473 INFO_(VIDEOPRT
, "- Slot 0x%02x (Device %d Function %d) VendorId 0x%04x "
475 PciSlotNumber
.u
.AsULONG
,
476 PciSlotNumber
.u
.bits
.DeviceNumber
,
477 PciSlotNumber
.u
.bits
.FunctionNumber
,
481 if ((VendorIdToFind
== 0 || Config
.VendorID
== VendorIdToFind
) &&
482 (DeviceIdToFind
== 0 || Config
.DeviceID
== DeviceIdToFind
))
484 DeviceAndVendorFound
= TRUE
;
489 if (DeviceAndVendorFound
) break;
491 if (FunctionNumber
== 8)
493 WARN_(VIDEOPRT
, "Didn't find device.\n");
494 return ERROR_DEV_NOT_EXIST
;
498 Status
= HalAssignSlotResources(
499 &DeviceExtension
->RegistryPath
,
501 DeviceExtension
->DriverObject
,
502 DeviceExtension
->DriverObject
->DeviceObject
,
503 DeviceExtension
->AdapterInterfaceType
,
504 DeviceExtension
->SystemIoBusNumber
,
505 PciSlotNumber
.u
.AsULONG
,
506 &AllocatedResources
);
508 if (!NT_SUCCESS(Status
))
510 WARN_(VIDEOPRT
, "HalAssignSlotResources failed with status %x.\n",Status
);
513 DeviceExtension
->AllocatedResources
= AllocatedResources
;
515 if (AllocatedResources
== NULL
)
516 return ERROR_NOT_ENOUGH_MEMORY
;
518 for (FullList
= AllocatedResources
->List
;
519 FullList
< AllocatedResources
->List
+ AllocatedResources
->Count
;
522 INFO_(VIDEOPRT
, "InterfaceType %u BusNumber List %u Device BusNumber %u Version %u Revision %u\n",
523 FullList
->InterfaceType
, FullList
->BusNumber
, DeviceExtension
->SystemIoBusNumber
, FullList
->PartialResourceList
.Version
, FullList
->PartialResourceList
.Revision
);
525 ASSERT(FullList
->InterfaceType
== PCIBus
);
526 ASSERT(FullList
->BusNumber
== DeviceExtension
->SystemIoBusNumber
);
527 ASSERT(1 == FullList
->PartialResourceList
.Version
);
528 ASSERT(1 == FullList
->PartialResourceList
.Revision
);
529 for (Descriptor
= FullList
->PartialResourceList
.PartialDescriptors
;
530 Descriptor
< FullList
->PartialResourceList
.PartialDescriptors
+ FullList
->PartialResourceList
.Count
;
533 if ((Descriptor
->Type
== CmResourceTypeMemory
||
534 Descriptor
->Type
== CmResourceTypePort
) &&
535 AssignedCount
>= NumAccessRanges
)
537 WARN_(VIDEOPRT
, "Too many access ranges found\n");
538 return ERROR_NOT_ENOUGH_MEMORY
;
540 if (Descriptor
->Type
== CmResourceTypeMemory
)
542 if (NumAccessRanges
<= AssignedCount
)
544 WARN_(VIDEOPRT
, "Too many access ranges found\n");
545 return ERROR_NOT_ENOUGH_MEMORY
;
547 INFO_(VIDEOPRT
, "Memory range starting at 0x%08x length 0x%08x\n",
548 Descriptor
->u
.Memory
.Start
.u
.LowPart
, Descriptor
->u
.Memory
.Length
);
549 AccessRanges
[AssignedCount
].RangeStart
= Descriptor
->u
.Memory
.Start
;
550 AccessRanges
[AssignedCount
].RangeLength
= Descriptor
->u
.Memory
.Length
;
551 AccessRanges
[AssignedCount
].RangeInIoSpace
= 0;
552 AccessRanges
[AssignedCount
].RangeVisible
= 0; /* FIXME: Just guessing */
553 AccessRanges
[AssignedCount
].RangeShareable
=
554 (Descriptor
->ShareDisposition
== CmResourceShareShared
);
557 else if (Descriptor
->Type
== CmResourceTypePort
)
559 INFO_(VIDEOPRT
, "Port range starting at 0x%04x length %d\n",
560 Descriptor
->u
.Memory
.Start
.u
.LowPart
, Descriptor
->u
.Memory
.Length
);
561 AccessRanges
[AssignedCount
].RangeStart
= Descriptor
->u
.Port
.Start
;
562 AccessRanges
[AssignedCount
].RangeLength
= Descriptor
->u
.Port
.Length
;
563 AccessRanges
[AssignedCount
].RangeInIoSpace
= 1;
564 AccessRanges
[AssignedCount
].RangeVisible
= 0; /* FIXME: Just guessing */
565 AccessRanges
[AssignedCount
].RangeShareable
= 0;
568 else if (Descriptor
->Type
== CmResourceTypeInterrupt
)
570 DeviceExtension
->InterruptLevel
= Descriptor
->u
.Interrupt
.Level
;
571 DeviceExtension
->InterruptVector
= Descriptor
->u
.Interrupt
.Vector
;
572 if (Descriptor
->ShareDisposition
== CmResourceShareShared
)
573 DeviceExtension
->InterruptShared
= TRUE
;
575 DeviceExtension
->InterruptShared
= FALSE
;
593 VideoPortVerifyAccessRanges(
594 IN PVOID HwDeviceExtension
,
595 IN ULONG NumAccessRanges
,
596 IN PVIDEO_ACCESS_RANGE AccessRanges
)
598 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
;
599 BOOLEAN ConflictDetected
;
601 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
602 PCM_RESOURCE_LIST ResourceList
;
603 ULONG ResourceListSize
;
606 TRACE_(VIDEOPRT
, "VideoPortVerifyAccessRanges\n");
608 DeviceExtension
= VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension
);
610 /* Create the resource list */
611 ResourceListSize
= sizeof(CM_RESOURCE_LIST
)
612 + (NumAccessRanges
- 1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
613 ResourceList
= ExAllocatePool(PagedPool
, ResourceListSize
);
616 WARN_(VIDEOPRT
, "ExAllocatePool() failed\n");
617 return ERROR_INVALID_PARAMETER
;
620 /* Fill resource list */
621 ResourceList
->Count
= 1;
622 ResourceList
->List
[0].InterfaceType
= DeviceExtension
->AdapterInterfaceType
;
623 ResourceList
->List
[0].BusNumber
= DeviceExtension
->SystemIoBusNumber
;
624 ResourceList
->List
[0].PartialResourceList
.Version
= 1;
625 ResourceList
->List
[0].PartialResourceList
.Revision
= 1;
626 ResourceList
->List
[0].PartialResourceList
.Count
= NumAccessRanges
;
627 for (i
= 0; i
< NumAccessRanges
; i
++, AccessRanges
++)
629 PartialDescriptor
= &ResourceList
->List
[0].PartialResourceList
.PartialDescriptors
[i
];
630 if (AccessRanges
->RangeInIoSpace
)
632 PartialDescriptor
->Type
= CmResourceTypePort
;
633 PartialDescriptor
->u
.Port
.Start
= AccessRanges
->RangeStart
;
634 PartialDescriptor
->u
.Port
.Length
= AccessRanges
->RangeLength
;
638 PartialDescriptor
->Type
= CmResourceTypeMemory
;
639 PartialDescriptor
->u
.Memory
.Start
= AccessRanges
->RangeStart
;
640 PartialDescriptor
->u
.Memory
.Length
= AccessRanges
->RangeLength
;
642 if (AccessRanges
->RangeShareable
)
643 PartialDescriptor
->ShareDisposition
= CmResourceShareShared
;
645 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
646 PartialDescriptor
->Flags
= 0;
647 if (AccessRanges
->RangePassive
& VIDEO_RANGE_PASSIVE_DECODE
)
648 PartialDescriptor
->Flags
|= CM_RESOURCE_PORT_PASSIVE_DECODE
;
649 if (AccessRanges
->RangePassive
& VIDEO_RANGE_10_BIT_DECODE
)
650 PartialDescriptor
->Flags
|= CM_RESOURCE_PORT_10_BIT_DECODE
;
653 /* Try to acquire all resource ranges */
654 Status
= IoReportResourceForDetection(
655 DeviceExtension
->DriverObject
,
656 NULL
, 0, /* Driver List */
657 DeviceExtension
->PhysicalDeviceObject
,
658 ResourceList
, ResourceListSize
,
660 ExFreePool(ResourceList
);
662 if (!NT_SUCCESS(Status
) || ConflictDetected
)
663 return ERROR_INVALID_PARAMETER
;
673 VideoPortGetDeviceData(
674 IN PVOID HwDeviceExtension
,
675 IN VIDEO_DEVICE_DATA_TYPE DeviceDataType
,
676 IN PMINIPORT_QUERY_DEVICE_ROUTINE CallbackRoutine
,
679 TRACE_(VIDEOPRT
, "VideoPortGetDeviceData\n");
681 return ERROR_INVALID_FUNCTION
;
689 VideoPortAllocatePool(
690 IN PVOID HwDeviceExtension
,
691 IN VP_POOL_TYPE PoolType
,
692 IN SIZE_T NumberOfBytes
,
695 TRACE_(VIDEOPRT
, "VideoPortAllocatePool\n");
696 return ExAllocatePoolWithTag(PoolType
, NumberOfBytes
, Tag
);
705 IN PVOID HwDeviceExtension
,
716 VideoPortAllocateBuffer(
717 IN PVOID HwDeviceExtension
,
721 TRACE_(VIDEOPRT
, "VideoPortAllocateBuffer\n");
722 *Buffer
= ExAllocatePoolWithTag ( PagedPool
, Size
, TAG_VIDEO_PORT_BUFFER
) ;
723 return *Buffer
== NULL
? ERROR_NOT_ENOUGH_MEMORY
: NO_ERROR
;
731 VideoPortReleaseBuffer(
732 IN PVOID HwDeviceExtension
,
735 TRACE_(VIDEOPRT
, "VideoPortReleaseBuffer\n");
745 IN PVOID HwDeviceExtension
,
746 IN PVOID BaseAddress
,
748 IN VP_LOCK_OPERATION Operation
)
752 Mdl
= IoAllocateMdl(BaseAddress
, Length
, FALSE
, FALSE
, NULL
);
758 MmProbeAndLockPages(Mdl
, KernelMode
,Operation
);
769 IN PVOID HwDeviceExtension
,
770 IN OUT PVIDEO_REQUEST_PACKET pVrp
,
772 IN PEVENT pDisplayEvent
,
773 IN DMA_FLAGS DmaFlags
)
777 /* clear output buffer */
778 pVrp
->OutputBuffer
= NULL
;
780 if (DmaFlags
!= VideoPortDmaInitOnly
)
782 /* VideoPortKeepPagesLocked / VideoPortUnlockAfterDma is no-op */
786 /* lock the buffer */
787 Buffer
= VideoPortLockBuffer(HwDeviceExtension
, pVrp
->InputBuffer
, pVrp
->InputBufferLength
, IoModifyAccess
);
791 /* store result buffer & length */
792 pVrp
->OutputBuffer
= Buffer
;
793 pVrp
->OutputBufferLength
= pVrp
->InputBufferLength
;
795 /* operation succeeded */
799 /* operation failed */
809 VideoPortUnlockBuffer(
810 IN PVOID HwDeviceExtension
,
815 MmUnlockPages((PMDL
)Mdl
);
825 VideoPortSetTrappedEmulatorPorts(
826 IN PVOID HwDeviceExtension
,
827 IN ULONG NumAccessRanges
,
828 IN PVIDEO_ACCESS_RANGE AccessRange
)
831 /* Should store the ranges in the device extension for use by ntvdm. */
841 IN PVOID HwDeviceExtension
,
842 IN BUS_DATA_TYPE BusDataType
,
848 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
;
850 TRACE_(VIDEOPRT
, "VideoPortGetBusData\n");
852 DeviceExtension
= VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension
);
854 if (BusDataType
!= Cmos
)
856 /* Legacy vs. PnP behaviour */
857 if (DeviceExtension
->PhysicalDeviceObject
!= NULL
)
858 SlotNumber
= DeviceExtension
->SystemIoSlotNumber
;
861 return HalGetBusDataByOffset(
863 DeviceExtension
->SystemIoBusNumber
,
876 IN PVOID HwDeviceExtension
,
877 IN BUS_DATA_TYPE BusDataType
,
883 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
;
885 TRACE_(VIDEOPRT
, "VideoPortSetBusData\n");
887 DeviceExtension
= VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension
);
889 if (BusDataType
!= Cmos
)
891 /* Legacy vs. PnP behaviour */
892 if (DeviceExtension
->PhysicalDeviceObject
!= NULL
)
893 SlotNumber
= DeviceExtension
->SystemIoSlotNumber
;
896 return HalSetBusDataByOffset(
898 DeviceExtension
->SystemIoBusNumber
,