migrate substitution keywords to SVN
[reactos.git] / reactos / drivers / video / videoprt / resource.c
1 /*
2 * VideoPort driver
3 *
4 * Copyright (C) 2002, 2003, 2004 ReactOS Team
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 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 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; see the file COPYING.LIB.
18 * If not, write to the Free Software Foundation,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 * $Id$
22 */
23
24 #include "videoprt.h"
25
26 /* PRIVATE FUNCTIONS **********************************************************/
27
28 PVOID STDCALL
29 IntVideoPortMapMemory(
30 IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
31 IN PHYSICAL_ADDRESS IoAddress,
32 IN ULONG NumberOfUchars,
33 IN UCHAR InIoSpace,
34 OUT VP_STATUS *Status)
35 {
36 PHYSICAL_ADDRESS TranslatedAddress;
37 PVIDEO_PORT_ADDRESS_MAPPING AddressMapping = NULL;
38 ULONG AddressSpace;
39 PVOID MappedAddress;
40 PLIST_ENTRY Entry;
41
42 DPRINT("- IoAddress: %lx\n", IoAddress.u.LowPart);
43 DPRINT("- NumberOfUchars: %lx\n", NumberOfUchars);
44 DPRINT("- InIoSpace: %x\n", InIoSpace);
45
46 InIoSpace &= ~VIDEO_MEMORY_SPACE_DENSE;
47 if ((InIoSpace & VIDEO_MEMORY_SPACE_P6CACHE) != 0)
48 {
49 DPRINT("VIDEO_MEMORY_SPACE_P6CACHE not supported, turning off\n");
50 InIoSpace &= ~VIDEO_MEMORY_SPACE_P6CACHE;
51 }
52
53 if (!IsListEmpty(&DeviceExtension->AddressMappingListHead))
54 {
55 Entry = DeviceExtension->AddressMappingListHead.Flink;
56 while (Entry != &DeviceExtension->AddressMappingListHead)
57 {
58 AddressMapping = CONTAINING_RECORD(
59 Entry,
60 VIDEO_PORT_ADDRESS_MAPPING,
61 List);
62 if (IoAddress.QuadPart == AddressMapping->IoAddress.QuadPart &&
63 NumberOfUchars <= AddressMapping->NumberOfUchars)
64 {
65 if ((InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) != 0 &&
66 AddressMapping->MappedUserAddress != NULL)
67 {
68 AddressMapping->UserMappingCount++;
69 if (Status)
70 *Status = NO_ERROR;
71 return AddressMapping->MappedUserAddress;
72 }
73 else if ((InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) == 0 &&
74 AddressMapping->MappedUserAddress != NULL)
75 {
76 AddressMapping->MappingCount++;
77 if (Status)
78 *Status = NO_ERROR;
79 return AddressMapping->MappedAddress;
80 }
81 break;
82 }
83 Entry = Entry->Flink;
84 }
85 if (Entry == &DeviceExtension->AddressMappingListHead)
86 AddressMapping = NULL;
87 }
88
89 AddressSpace = (ULONG)InIoSpace;
90 AddressSpace &= ~VIDEO_MEMORY_SPACE_USER_MODE;
91 if (HalTranslateBusAddress(
92 DeviceExtension->AdapterInterfaceType,
93 DeviceExtension->SystemIoBusNumber,
94 IoAddress,
95 &AddressSpace,
96 &TranslatedAddress) == FALSE)
97 {
98 if (Status)
99 *Status = ERROR_NOT_ENOUGH_MEMORY;
100
101 return NULL;
102 }
103
104 /* I/O space */
105 if (AddressSpace != 0)
106 {
107 ASSERT(0 == TranslatedAddress.u.HighPart);
108 if (Status)
109 *Status = NO_ERROR;
110
111 return (PVOID)TranslatedAddress.u.LowPart;
112 }
113
114 /* user space */
115 if ((InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) != 0)
116 {
117 OBJECT_ATTRIBUTES ObjAttribs;
118 UNICODE_STRING UnicodeString;
119 HANDLE hMemObj;
120 NTSTATUS NtStatus;
121 SIZE_T Size;
122
123 RtlInitUnicodeString(&UnicodeString, L"\\Device\\PhysicalMemory");
124 InitializeObjectAttributes(&ObjAttribs,
125 &UnicodeString,
126 OBJ_CASE_INSENSITIVE/* | OBJ_KERNEL_HANDLE*/,
127 NULL, NULL);
128 NtStatus = ZwOpenSection(&hMemObj, SECTION_ALL_ACCESS, &ObjAttribs);
129 if (!NT_SUCCESS(NtStatus))
130 {
131 DPRINT("ZwOpenSection() failed! (0x%x)\n", NtStatus);
132 if (Status)
133 *Status = NO_ERROR;
134 return NULL;
135 }
136 Size = NumberOfUchars;
137 MappedAddress = NULL;
138 NtStatus = ZwMapViewOfSection(hMemObj,
139 NtCurrentProcess(),
140 &MappedAddress,
141 0,
142 NumberOfUchars,
143 (PLARGE_INTEGER)(&TranslatedAddress),
144 &Size,
145 ViewUnmap,
146 0,
147 PAGE_READWRITE/* | PAGE_WRITECOMBINE*/);
148 if (!NT_SUCCESS(NtStatus))
149 {
150 DPRINT("ZwMapViewOfSection() failed! (0x%x)\n", NtStatus);
151 ZwClose(hMemObj);
152 if (Status)
153 *Status = NO_ERROR;
154 return NULL;
155 }
156 ZwClose(hMemObj);
157 DPRINT("Mapped user address = 0x%08x\n", MappedAddress);
158 }
159 else /* kernel space */
160 {
161 MappedAddress = MmMapIoSpace(
162 TranslatedAddress,
163 NumberOfUchars,
164 MmNonCached);
165 }
166
167 if (MappedAddress != NULL)
168 {
169 BOOL InsertIntoList = FALSE;
170
171 if (Status)
172 {
173 *Status = NO_ERROR;
174 }
175 if (AddressMapping == NULL)
176 {
177 AddressMapping = ExAllocatePoolWithTag(
178 PagedPool,
179 sizeof(VIDEO_PORT_ADDRESS_MAPPING),
180 TAG_VIDEO_PORT);
181
182 if (AddressMapping == NULL)
183 return MappedAddress;
184
185 InsertIntoList = TRUE;
186 RtlZeroMemory(AddressMapping, sizeof(VIDEO_PORT_ADDRESS_MAPPING));
187 AddressMapping->NumberOfUchars = NumberOfUchars;
188 AddressMapping->IoAddress = IoAddress;
189 AddressMapping->SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
190 }
191
192 if ((InIoSpace & VIDEO_MEMORY_SPACE_USER_MODE) != 0)
193 {
194 AddressMapping->MappedUserAddress = MappedAddress;
195 AddressMapping->UserMappingCount = 1;
196 }
197 else
198 {
199 AddressMapping->MappedAddress = MappedAddress;
200 AddressMapping->MappingCount = 1;
201 }
202
203 if (InsertIntoList)
204 {
205 InsertHeadList(
206 &DeviceExtension->AddressMappingListHead,
207 &AddressMapping->List);
208 }
209
210 return MappedAddress;
211 }
212
213 if (Status)
214 *Status = NO_ERROR;
215
216 return NULL;
217 }
218
219 VOID STDCALL
220 IntVideoPortUnmapMemory(
221 IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
222 IN PVOID MappedAddress)
223 {
224 PVIDEO_PORT_ADDRESS_MAPPING AddressMapping;
225 PLIST_ENTRY Entry;
226
227 Entry = DeviceExtension->AddressMappingListHead.Flink;
228 while (Entry != &DeviceExtension->AddressMappingListHead)
229 {
230 AddressMapping = CONTAINING_RECORD(
231 Entry,
232 VIDEO_PORT_ADDRESS_MAPPING,
233 List);
234 if (AddressMapping->MappedUserAddress == MappedAddress)
235 {
236 ASSERT(AddressMapping->UserMappingCount > 0);
237 AddressMapping->UserMappingCount--;
238 if (AddressMapping->UserMappingCount == 0)
239 {
240 ZwUnmapViewOfSection(NtCurrentProcess(),
241 AddressMapping->MappedUserAddress);
242 AddressMapping->MappedUserAddress = NULL;
243 if (AddressMapping->MappingCount == 0)
244 {
245 RemoveEntryList(Entry);
246 ExFreePool(AddressMapping);
247 }
248 }
249 return;
250 }
251 else if (AddressMapping->MappedAddress == MappedAddress)
252 {
253 ASSERT(AddressMapping->MappingCount > 0);
254 AddressMapping->MappingCount--;
255 if (AddressMapping->MappingCount == 0)
256 {
257 MmUnmapIoSpace(
258 AddressMapping->MappedAddress,
259 AddressMapping->NumberOfUchars);
260 AddressMapping->MappedAddress = NULL;
261 if (AddressMapping->UserMappingCount == 0)
262 {
263 RemoveEntryList(Entry);
264 ExFreePool(AddressMapping);
265 }
266 }
267 return;
268 }
269
270 Entry = Entry->Flink;
271 }
272 }
273
274 /* PUBLIC FUNCTIONS ***********************************************************/
275
276 /*
277 * @implemented
278 */
279
280 PVOID STDCALL
281 VideoPortGetDeviceBase(
282 IN PVOID HwDeviceExtension,
283 IN PHYSICAL_ADDRESS IoAddress,
284 IN ULONG NumberOfUchars,
285 IN UCHAR InIoSpace)
286 {
287 DPRINT("VideoPortGetDeviceBase\n");
288 return IntVideoPortMapMemory(
289 VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
290 IoAddress,
291 NumberOfUchars,
292 InIoSpace,
293 NULL);
294 }
295
296 /*
297 * @implemented
298 */
299
300 VOID STDCALL
301 VideoPortFreeDeviceBase(
302 IN PVOID HwDeviceExtension,
303 IN PVOID MappedAddress)
304 {
305 DPRINT("VideoPortFreeDeviceBase\n");
306 IntVideoPortUnmapMemory(
307 VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
308 MappedAddress);
309 }
310
311 /*
312 * @unimplemented
313 */
314
315 VP_STATUS STDCALL
316 VideoPortMapBankedMemory(
317 IN PVOID HwDeviceExtension,
318 IN PHYSICAL_ADDRESS PhysicalAddress,
319 IN PULONG Length,
320 IN PULONG InIoSpace,
321 OUT PVOID *VirtualAddress,
322 IN ULONG BankLength,
323 IN UCHAR ReadWriteBank,
324 IN PBANKED_SECTION_ROUTINE BankRoutine,
325 IN PVOID Context)
326 {
327 DPRINT("VideoPortMapBankedMemory\n");
328 UNIMPLEMENTED;
329 return ERROR_CALL_NOT_IMPLEMENTED;
330 }
331
332
333 /*
334 * @implemented
335 */
336
337 VP_STATUS STDCALL
338 VideoPortMapMemory(
339 IN PVOID HwDeviceExtension,
340 IN PHYSICAL_ADDRESS PhysicalAddress,
341 IN PULONG Length,
342 IN PULONG InIoSpace,
343 OUT PVOID *VirtualAddress)
344 {
345 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
346 NTSTATUS Status;
347
348 DPRINT("VideoPortMapMemory\n");
349
350 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
351 *VirtualAddress = IntVideoPortMapMemory(
352 DeviceExtension,
353 PhysicalAddress,
354 *Length,
355 *InIoSpace,
356 &Status);
357
358 return Status;
359 }
360
361 /*
362 * @implemented
363 */
364
365 VP_STATUS STDCALL
366 VideoPortUnmapMemory(
367 IN PVOID HwDeviceExtension,
368 IN PVOID VirtualAddress,
369 IN HANDLE ProcessHandle)
370 {
371 DPRINT("VideoPortFreeDeviceBase\n");
372
373 IntVideoPortUnmapMemory(
374 VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
375 VirtualAddress);
376
377 return NO_ERROR;
378 }
379
380 /*
381 * @implemented
382 */
383
384 VP_STATUS STDCALL
385 VideoPortGetAccessRanges(
386 IN PVOID HwDeviceExtension,
387 IN ULONG NumRequestedResources,
388 IN PIO_RESOURCE_DESCRIPTOR RequestedResources OPTIONAL,
389 IN ULONG NumAccessRanges,
390 IN PVIDEO_ACCESS_RANGE AccessRanges,
391 IN PVOID VendorId,
392 IN PVOID DeviceId,
393 IN PULONG Slot)
394 {
395 PCI_SLOT_NUMBER PciSlotNumber;
396 ULONG FunctionNumber;
397 PCI_COMMON_CONFIG Config;
398 PCM_RESOURCE_LIST AllocatedResources;
399 NTSTATUS Status;
400 UINT AssignedCount;
401 CM_FULL_RESOURCE_DESCRIPTOR *FullList;
402 CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor;
403 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
404 USHORT VendorIdToFind;
405 USHORT DeviceIdToFind;
406 ULONG SlotIdToFind;
407 ULONG ReturnedLength;
408
409 DPRINT("VideoPortGetAccessRanges\n");
410
411 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
412
413 if (NumRequestedResources == 0 &&
414 DeviceExtension->AdapterInterfaceType == PCIBus)
415 {
416 if (DeviceExtension->PhysicalDeviceObject != NULL)
417 {
418 PciSlotNumber.u.AsULONG = DeviceExtension->SystemIoSlotNumber;
419
420 ReturnedLength = HalGetBusData(
421 PCIConfiguration,
422 DeviceExtension->SystemIoBusNumber,
423 PciSlotNumber.u.AsULONG,
424 &Config,
425 sizeof(PCI_COMMON_CONFIG));
426
427 if (ReturnedLength != sizeof(PCI_COMMON_CONFIG))
428 {
429 return ERROR_NO_SYSTEM_RESOURCES;
430 }
431 }
432 else
433 {
434 VendorIdToFind = VendorId != NULL ? *(PUSHORT)VendorId : 0;
435 DeviceIdToFind = DeviceId != NULL ? *(PUSHORT)DeviceId : 0;
436 SlotIdToFind = Slot != NULL ? *Slot : 0;
437 PciSlotNumber.u.AsULONG = SlotIdToFind;
438
439 DPRINT("Looking for VendorId 0x%04x DeviceId 0x%04x\n",
440 VendorIdToFind, DeviceIdToFind);
441
442 /*
443 * Search for the device id and vendor id on this bus.
444 */
445
446 for (FunctionNumber = 0; FunctionNumber < 8; FunctionNumber++)
447 {
448 DPRINT("- Function number: %d\n", FunctionNumber);
449 PciSlotNumber.u.bits.FunctionNumber = FunctionNumber;
450 ReturnedLength = HalGetBusData(
451 PCIConfiguration,
452 DeviceExtension->SystemIoBusNumber,
453 PciSlotNumber.u.AsULONG,
454 &Config,
455 sizeof(PCI_COMMON_CONFIG));
456 DPRINT("- Length of data: %x\n", ReturnedLength);
457 if (ReturnedLength == sizeof(PCI_COMMON_CONFIG))
458 {
459 DPRINT("- Slot 0x%02x (Device %d Function %d) VendorId 0x%04x "
460 "DeviceId 0x%04x\n",
461 PciSlotNumber.u.AsULONG,
462 PciSlotNumber.u.bits.DeviceNumber,
463 PciSlotNumber.u.bits.FunctionNumber,
464 Config.VendorID,
465 Config.DeviceID);
466
467 if ((VendorIdToFind == 0 || Config.VendorID == VendorIdToFind) &&
468 (DeviceIdToFind == 0 || Config.DeviceID == DeviceIdToFind))
469 {
470 break;
471 }
472 }
473 }
474
475 if (FunctionNumber == 8)
476 {
477 DPRINT("Didn't find device.\n");
478 return ERROR_DEV_NOT_EXIST;
479 }
480 }
481
482 Status = HalAssignSlotResources(
483 NULL, NULL, NULL, NULL,
484 DeviceExtension->AdapterInterfaceType,
485 DeviceExtension->SystemIoBusNumber,
486 PciSlotNumber.u.AsULONG,
487 &AllocatedResources);
488
489 if (!NT_SUCCESS(Status))
490 {
491 return Status;
492 }
493
494 AssignedCount = 0;
495 for (FullList = AllocatedResources->List;
496 FullList < AllocatedResources->List + AllocatedResources->Count;
497 FullList++)
498 {
499 ASSERT(FullList->InterfaceType == PCIBus &&
500 FullList->BusNumber == DeviceExtension->SystemIoBusNumber &&
501 1 == FullList->PartialResourceList.Version &&
502 1 == FullList->PartialResourceList.Revision);
503 for (Descriptor = FullList->PartialResourceList.PartialDescriptors;
504 Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
505 Descriptor++)
506 {
507 if ((Descriptor->Type == CmResourceTypeMemory ||
508 Descriptor->Type == CmResourceTypePort) &&
509 AssignedCount >= NumAccessRanges)
510 {
511 DPRINT1("Too many access ranges found\n");
512 ExFreePool(AllocatedResources);
513 return ERROR_NO_SYSTEM_RESOURCES;
514 }
515 if (Descriptor->Type == CmResourceTypeMemory)
516 {
517 if (NumAccessRanges <= AssignedCount)
518 {
519 DPRINT1("Too many access ranges found\n");
520 ExFreePool(AllocatedResources);
521 return ERROR_NO_SYSTEM_RESOURCES;
522 }
523 DPRINT("Memory range starting at 0x%08x length 0x%08x\n",
524 Descriptor->u.Memory.Start.u.LowPart, Descriptor->u.Memory.Length);
525 AccessRanges[AssignedCount].RangeStart = Descriptor->u.Memory.Start;
526 AccessRanges[AssignedCount].RangeLength = Descriptor->u.Memory.Length;
527 AccessRanges[AssignedCount].RangeInIoSpace = 0;
528 AccessRanges[AssignedCount].RangeVisible = 0; /* FIXME: Just guessing */
529 AccessRanges[AssignedCount].RangeShareable =
530 (Descriptor->ShareDisposition == CmResourceShareShared);
531 AssignedCount++;
532 }
533 else if (Descriptor->Type == CmResourceTypePort)
534 {
535 DPRINT("Port range starting at 0x%04x length %d\n",
536 Descriptor->u.Memory.Start.u.LowPart, Descriptor->u.Memory.Length);
537 AccessRanges[AssignedCount].RangeStart = Descriptor->u.Port.Start;
538 AccessRanges[AssignedCount].RangeLength = Descriptor->u.Port.Length;
539 AccessRanges[AssignedCount].RangeInIoSpace = 1;
540 AccessRanges[AssignedCount].RangeVisible = 0; /* FIXME: Just guessing */
541 AccessRanges[AssignedCount].RangeShareable = 0;
542 AssignedCount++;
543 }
544 else if (Descriptor->Type == CmResourceTypeInterrupt)
545 {
546 DeviceExtension->InterruptLevel = Descriptor->u.Interrupt.Level;
547 DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
548 }
549 }
550 }
551 ExFreePool(AllocatedResources);
552 }
553 else
554 {
555 UNIMPLEMENTED
556 }
557
558 return NO_ERROR;
559 }
560
561 /*
562 * @unimplemented
563 */
564
565 VP_STATUS STDCALL
566 VideoPortVerifyAccessRanges(
567 IN PVOID HwDeviceExtension,
568 IN ULONG NumAccessRanges,
569 IN PVIDEO_ACCESS_RANGE AccessRanges)
570 {
571 DPRINT1("VideoPortVerifyAccessRanges not implemented\n");
572 return NO_ERROR;
573 }
574
575 /*
576 * @unimplemented
577 */
578
579 VP_STATUS STDCALL
580 VideoPortGetDeviceData(
581 IN PVOID HwDeviceExtension,
582 IN VIDEO_DEVICE_DATA_TYPE DeviceDataType,
583 IN PMINIPORT_QUERY_DEVICE_ROUTINE CallbackRoutine,
584 IN PVOID Context)
585 {
586 DPRINT("VideoPortGetDeviceData\n");
587 UNIMPLEMENTED;
588 return ERROR_CALL_NOT_IMPLEMENTED;
589 }
590
591 /*
592 * @implemented
593 */
594
595 PVOID STDCALL
596 VideoPortAllocatePool(
597 IN PVOID HwDeviceExtension,
598 IN VP_POOL_TYPE PoolType,
599 IN SIZE_T NumberOfBytes,
600 IN ULONG Tag)
601 {
602 DPRINT("VideoPortAllocatePool\n");
603 return ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag);
604 }
605
606 /*
607 * @implemented
608 */
609
610 VOID STDCALL
611 VideoPortFreePool(
612 IN PVOID HwDeviceExtension,
613 IN PVOID Ptr)
614 {
615 ExFreePool(Ptr);
616 }
617
618 /*
619 * @implemented
620 */
621
622 VP_STATUS STDCALL
623 VideoPortAllocateBuffer(
624 IN PVOID HwDeviceExtension,
625 IN ULONG Size,
626 OUT PVOID *Buffer)
627 {
628 DPRINT("VideoPortAllocateBuffer\n");
629 *Buffer = ExAllocatePool(PagedPool, Size);
630 return *Buffer == NULL ? ERROR_NOT_ENOUGH_MEMORY : NO_ERROR;
631 }
632
633 /*
634 * @implemented
635 */
636
637 VOID STDCALL
638 VideoPortReleaseBuffer(
639 IN PVOID HwDeviceExtension,
640 IN PVOID Ptr)
641 {
642 DPRINT("VideoPortReleaseBuffer\n");
643 ExFreePool(Ptr);
644 }
645
646 /*
647 * @unimplemented
648 */
649
650 PVOID STDCALL
651 VideoPortLockBuffer(
652 IN PVOID HwDeviceExtension,
653 IN PVOID BaseAddress,
654 IN ULONG Length,
655 IN VP_LOCK_OPERATION Operation)
656 {
657 DPRINT1("VideoPortLockBuffer: Unimplemented.\n");
658 return NULL;
659 }
660
661 /*
662 * @unimplemented
663 */
664
665 VOID STDCALL
666 VideoPortUnlockBuffer(
667 IN PVOID HwDeviceExtension,
668 IN PVOID Mdl)
669 {
670 DPRINT1("VideoPortUnlockBuffer: Unimplemented.\n");
671 }
672
673 /*
674 * @unimplemented
675 */
676
677 VP_STATUS STDCALL
678 VideoPortSetTrappedEmulatorPorts(
679 IN PVOID HwDeviceExtension,
680 IN ULONG NumAccessRanges,
681 IN PVIDEO_ACCESS_RANGE AccessRange)
682 {
683 DPRINT("VideoPortSetTrappedEmulatorPorts\n");
684 /* Should store the ranges in the device extension for use by ntvdm. */
685 return NO_ERROR;
686 }
687
688 /*
689 * @implemented
690 */
691
692 ULONG STDCALL
693 VideoPortGetBusData(
694 IN PVOID HwDeviceExtension,
695 IN BUS_DATA_TYPE BusDataType,
696 IN ULONG SlotNumber,
697 OUT PVOID Buffer,
698 IN ULONG Offset,
699 IN ULONG Length)
700 {
701 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
702
703 DPRINT("VideoPortGetBusData\n");
704
705 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
706
707 if (BusDataType != Cmos)
708 {
709 /* Legacy vs. PnP behaviour */
710 if (DeviceExtension->PhysicalDeviceObject != NULL)
711 SlotNumber = DeviceExtension->SystemIoSlotNumber;
712 }
713
714 return HalGetBusDataByOffset(
715 BusDataType,
716 DeviceExtension->SystemIoBusNumber,
717 SlotNumber,
718 Buffer,
719 Offset,
720 Length);
721 }
722
723 /*
724 * @implemented
725 */
726
727 ULONG STDCALL
728 VideoPortSetBusData(
729 IN PVOID HwDeviceExtension,
730 IN BUS_DATA_TYPE BusDataType,
731 IN ULONG SlotNumber,
732 IN PVOID Buffer,
733 IN ULONG Offset,
734 IN ULONG Length)
735 {
736 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
737
738 DPRINT("VideoPortSetBusData\n");
739
740 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
741
742 if (BusDataType != Cmos)
743 {
744 /* Legacy vs. PnP behaviour */
745 if (DeviceExtension->PhysicalDeviceObject != NULL)
746 SlotNumber = DeviceExtension->SystemIoSlotNumber;
747 }
748
749 return HalSetBusDataByOffset(
750 BusDataType,
751 DeviceExtension->SystemIoBusNumber,
752 SlotNumber,
753 Buffer,
754 Offset,
755 Length);
756 }