ReactOS  0.4.13-dev-247-g0f29b3f
vga.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS VGA Miniport Driver
3  * LICENSE: Microsoft NT4 DDK Sample Code License
4  * FILE: win32ss/drivers/miniport/vga_new/vga.c
5  * PURPOSE: Main Standard VGA-compatible Minport Handling Code
6  * PROGRAMMERS: Copyright (c) 1992 Microsoft Corporation
7  * ReactOS Portable Systems Group
8  */
9 
10 //---------------------------------------------------------------------------
11 
12 #include "vga.h"
13 
14 #include <devioctl.h>
15 
16 //---------------------------------------------------------------------------
17 //
18 // Function declarations
19 //
20 // Functions that start with 'VGA' are entry points for the OS port driver.
21 //
22 
24 NTAPI
26  PVOID HwDeviceExtension,
28  PWSTR ArgumentString,
29  PVIDEO_PORT_CONFIG_INFO ConfigInfo,
30  PUCHAR Again
31  );
32 
33 BOOLEAN
34 NTAPI
36  PVOID HwDeviceExtension
37  );
38 
39 BOOLEAN
40 NTAPI
42  PVOID HwDeviceExtension,
43  PVIDEO_REQUEST_PACKET RequestPacket
44  );
45 
46 //
47 // Private function prototypes.
48 //
49 
51 NTAPI
53  PHW_DEVICE_EXTENSION HwDeviceExtension,
54  PVIDEO_MODE_INFORMATION ModeInformation,
55  ULONG ModeInformationSize,
56  PULONG_PTR OutputSize
57  );
58 
60 NTAPI
62  PHW_DEVICE_EXTENSION HwDeviceExtension,
63  PVIDEO_NUM_MODES NumModes,
64  ULONG NumModesSize,
65  PULONG_PTR OutputSize
66  );
67 
69 NTAPI
71  PHW_DEVICE_EXTENSION HwDeviceExtension,
72  PVIDEO_MODE_INFORMATION ModeInformation,
73  ULONG ModeInformationSize,
74  PULONG_PTR OutputSize
75  );
76 
78 NTAPI
80  PHW_DEVICE_EXTENSION HwDeviceExtension,
82  ULONG ModeSize,
83 // eVb: 1.1 [SET MODE] - Add new output parameter for framebuffer update functionality
84  PULONG PhysPtrChange
85 // eVb: 1.1 [END]
86  );
87 
88 BOOLEAN
89 NTAPI
91  PHW_DEVICE_EXTENSION HwDeviceExtension
92  );
93 
95 NTAPI
97  PHW_DEVICE_EXTENSION HwDeviceExtension,
98  PUSHORT pusCmdStream
99  );
100 
101 VP_STATUS
102 NTAPI
104  PHW_DEVICE_EXTENSION HwDeviceExtension,
106  ULONG PaletteBufferSize
107  );
108 
109 VP_STATUS
110 NTAPI
112  PHW_DEVICE_EXTENSION HwDeviceExtension,
113  PVIDEO_CLUT ClutBuffer,
114  ULONG ClutBufferSize
115  );
116 
117 VP_STATUS
118 NTAPI
120  PVOID HwDeviceExtension,
121  PVOID Context,
122  VIDEO_DEVICE_DATA_TYPE DeviceDataType,
123  PVOID Identifier,
124  ULONG IdentifierLength,
125  PVOID ConfigurationData,
126  ULONG ConfigurationDataLength,
127  PVOID ComponentInformation,
128  ULONG ComponentInformationLength
129  );
130 
131 // eVb: 1.2 [RESOURCE] - Add new function for acquiring VGA resources (I/O, memory)
132 VP_STATUS
133 NTAPI
135  PHW_DEVICE_EXTENSION DeviceExtension
136  );
137 // eVb: 1.2 [END]
138 
139 #if defined(ALLOC_PRAGMA)
140 #pragma alloc_text(PAGE,DriverEntry)
141 #pragma alloc_text(PAGE,VgaFindAdapter)
142 #pragma alloc_text(PAGE,VgaInitialize)
143 #pragma alloc_text(PAGE,VgaStartIO)
144 #pragma alloc_text(PAGE,VgaIsPresent)
145 #pragma alloc_text(PAGE,VgaSetColorLookup)
146 #endif
147 
148 //---------------------------------------------------------------------------
149 ULONG
150 // eVb: 1.3 [GCC] - Add NTAPI for GCC support
151 NTAPI
152 // eVb: 1.3 [END]
154  PVOID Context1,
156  )
157 
158 /*++
159 
160 Routine Description:
161 
162  Installable driver initialization entry point.
163  This entry point is called directly by the I/O system.
164 
165 Arguments:
166 
167  Context1 - First context value passed by the operating system. This is
168  the value with which the miniport driver calls VideoPortInitialize().
169 
170  Context2 - Second context value passed by the operating system. This is
171  the value with which the miniport driver calls 3VideoPortInitialize().
172 
173 Return Value:
174 
175  Status from VideoPortInitialize()
176 
177 --*/
178 
179 {
180 
181  VIDEO_HW_INITIALIZATION_DATA hwInitData;
182  ULONG status;
183  ULONG initializationStatus = (ULONG) -1;
184 
185  //
186  // Zero out structure.
187  //
188 
190 
191  //
192  // Specify sizes of structure and extension.
193  //
194 
195  hwInitData.HwInitDataSize = sizeof(VIDEO_HW_INITIALIZATION_DATA);
196 
197  //
198  // Set entry points.
199  //
200 
201  hwInitData.HwFindAdapter = VgaFindAdapter;
202  hwInitData.HwInitialize = VgaInitialize;
203  hwInitData.HwInterrupt = NULL;
204  hwInitData.HwStartIO = VgaStartIO;
205 
206  //
207  // Determine the size we require for the device extension.
208  //
209 
210  hwInitData.HwDeviceExtensionSize = sizeof(HW_DEVICE_EXTENSION);
211 
212  //
213  // Always start with parameters for device0 in this case.
214  // We can leave it like this since we know we will only ever find one
215  // VGA type adapter in a machine.
216  //
217 
218  // hwInitData.StartingDeviceNumber = 0;
219 
220  //
221  // Once all the relevant information has been stored, call the video
222  // port driver to do the initialization.
223  // For this device we will repeat this call three times, for ISA, EISA
224  // and PCI.
225  // We will return the minimum of all return values.
226  //
227 
228  //
229  // We will try the PCI bus first so that our ISA detection does'nt claim
230  // PCI cards (since it is impossible to differentiate between the two
231  // by looking at the registers).
232  //
233 
234  //
235  // NOTE: since this driver only supports one adapter, we will return
236  // as soon as we find a device, without going on to the following buses.
237  // Normally one would call for each bus type and return the smallest
238  // value.
239  //
240 
241 #if !defined(_ALPHA_)
242 
243  //
244  // Before we can enable this on ALPHA we need to find a way to map a
245  // sparse view of a 4MB region successfully.
246  //
247 
248  hwInitData.AdapterInterfaceType = PCIBus;
249 
250  initializationStatus = VideoPortInitialize(Context1,
251  Context2,
252  &hwInitData,
253  NULL);
254 
255  if (initializationStatus == NO_ERROR)
256  {
257  return initializationStatus;
258  }
259 
260 #endif
261 
262  hwInitData.AdapterInterfaceType = MicroChannel;
263 
264  initializationStatus = VideoPortInitialize(Context1,
265  Context2,
266  &hwInitData,
267  NULL);
268 
269  //
270  // Return immediately instead of checkin for smallest return code.
271  //
272 
273  if (initializationStatus == NO_ERROR)
274  {
275  return initializationStatus;
276  }
277 
278 
279  hwInitData.AdapterInterfaceType = Internal;
280 
281  initializationStatus = VideoPortInitialize(Context1,
282  Context2,
283  &hwInitData,
284  NULL);
285 
286  if (initializationStatus == NO_ERROR)
287  {
288  return initializationStatus;
289  }
290 
291 
292  hwInitData.AdapterInterfaceType = Isa;
293 
294  initializationStatus = VideoPortInitialize(Context1,
295  Context2,
296  &hwInitData,
297  NULL);
298 
299  if (initializationStatus == NO_ERROR)
300  {
301  return initializationStatus;
302  }
303 
304 
305 
306  hwInitData.AdapterInterfaceType = Eisa;
307 
309  Context2,
310  &hwInitData,
311  NULL);
312 
313  if (initializationStatus > status) {
314  initializationStatus = status;
315  }
316 
317  return initializationStatus;
318 
319 } // end DriverEntry()
320 
321 //---------------------------------------------------------------------------
322 VP_STATUS
323 NTAPI
325  PVOID HwDeviceExtension,
327  PWSTR ArgumentString,
328  PVIDEO_PORT_CONFIG_INFO ConfigInfo,
329  PUCHAR Again
330  )
331 
332 /*++
333 
334 Routine Description:
335 
336  This routine is called to determine if the adapter for this driver
337  is present in the system.
338  If it is present, the function fills out some information describing
339  the adapter.
340 
341 Arguments:
342 
343  HwDeviceExtension - Supplies the miniport driver's adapter storage. This
344  storage is initialized to zero before this call.
345 
346  HwContext - Supplies the context value which was passed to
347  VideoPortInitialize().
348 
349  ArgumentString - Supplies a NULL terminated ASCII string. This string
350  originates from the user.
351 
352  ConfigInfo - Returns the configuration information structure which is
353  filled by the miniport driver. This structure is initialized with
354  any known configuration information (such as SystemIoBusNumber) by
355  the port driver. Where possible, drivers should have one set of
356  defaults which do not require any supplied configuration information.
357 
358  Again - Indicates if the miniport driver wants the port driver to call
359  its VIDEO_HW_FIND_ADAPTER function again with a new device extension
360  and the same config info. This is used by the miniport drivers which
361  can search for several adapters on a bus.
362 
363 Return Value:
364 
365  This routine must return:
366 
367  NO_ERROR - Indicates a host adapter was found and the
368  configuration information was successfully determined.
369 
370  ERROR_INVALID_PARAMETER - Indicates an adapter was found but there was an
371  error obtaining the configuration information. If possible an error
372  should be logged.
373 
374  ERROR_DEV_NOT_EXIST - Indicates no host adapter was found for the
375  supplied configuration information.
376 
377 --*/
378 
379 {
380 
381  PHW_DEVICE_EXTENSION hwDeviceExtension = HwDeviceExtension;
382 
383  //
384  // Make sure the size of the structure is at least as large as what we
385  // are expecting (check version of the config info structure).
386  //
387 
388  if (ConfigInfo->Length < sizeof(VIDEO_PORT_CONFIG_INFO)) {
389 
391 
392  }
393 // eVb: 1.4 [CIRRUS] - Remove CIRRUS-specific support
394  //
395  // Check internal VGA (MIPS and ARM systems)
396  //
397 
398  if ((ConfigInfo->AdapterInterfaceType == Internal) &&
399  (VideoPortGetDeviceData(HwDeviceExtension,
403  {
405  }
406 // eVb: 1.4 [END]
407  //
408  // No interrupt information is necessary.
409  //
410 
411  //
412  // Check to see if there is a hardware resource conflict.
413  //
414 // eVb: 1.5 [RESOURCE] - Use new function for acquiring VGA resources (I/O, memory)
415  if (VgaAcquireResources(hwDeviceExtension) != NO_ERROR) return ERROR_INVALID_PARAMETER;
416 // eVb: 1.5 [END]
417  //
418  // Get logical IO port addresses.
419  //
420 
421  if ((hwDeviceExtension->IOAddress =
422  VideoPortGetDeviceBase(hwDeviceExtension,
426  {
427  VideoDebugPrint((0, "VgaFindAdapter - Fail to get io address\n"));
428 
430  }
431 
432  //
433  // Determine whether a VGA is present.
434  //
435 
436  if (!VgaIsPresent(hwDeviceExtension)) {
437 
438  VideoDebugPrint((0, "VgaFindAdapter - VGA Failed\n"));
439  return ERROR_DEV_NOT_EXIST;
440  }
441 
442  //
443  // Minimum size of the buffer required to store the hardware state
444  // information returned by IOCTL_VIDEO_SAVE_HARDWARE_STATE.
445  //
446 
448 
449  //
450  // Pass a pointer to the emulator range we are using.
451  //
452 // eVb: 1.6 [VDM] - Disable VDM for now
453  ConfigInfo->NumEmulatorAccessEntries = 0;
454  ConfigInfo->EmulatorAccessEntries = NULL;
455  ConfigInfo->EmulatorAccessEntriesContext = 0;
456 // eVb: 1.6 [END]
457  //
458  // BUGBUG
459  //
460  // There is really no reason to have the frame buffer mapped. On an
461  // x86 we use if for save/restore (supposedly) but even then we
462  // would only need to map a 64K window, not all 16 Meg!
463  //
464 
465 #ifdef _X86_
466 
467  //
468  // Map the video memory into the system virtual address space so we can
469  // clear it out and use it for save and restore.
470  //
471 
472  if ( (hwDeviceExtension->VideoMemoryAddress =
473  VideoPortGetDeviceBase(hwDeviceExtension,
474  VgaAccessRange[2].RangeStart,
475  VgaAccessRange[2].RangeLength,
476  FALSE)) == NULL)
477  {
478  VideoDebugPrint((0, "VgaFindAdapter - Fail to get memory address\n"));
479 
481  }
482 
483  VideoDebugPrint((0, "vga mapped at %x\n", hwDeviceExtension->VideoMemoryAddress));
484 #endif
485 // eVb: 1.7 [VDM] - Disable VDM for now
486  ConfigInfo->VdmPhysicalVideoMemoryAddress.QuadPart = 0;
487  ConfigInfo->VdmPhysicalVideoMemoryLength = 0;
488 // eVb: 1.7 [END]
489  //
490  // Indicate we do not wish to be called again for another initialization.
491  //
492 
493  *Again = 0;
494 
495  //
496  // Indicate a successful completion status.
497  //
498 
499  return NO_ERROR;
500 
501 
502 } // VgaFindAdapter()
503 
504 //---------------------------------------------------------------------------
505 BOOLEAN
506 NTAPI
508  PVOID HwDeviceExtension
509  )
510 
511 /*++
512 
513 Routine Description:
514 
515  This routine does one time initialization of the device.
516 
517 Arguments:
518 
519  HwDeviceExtension - Pointer to the miniport driver's adapter information.
520 
521 Return Value:
522 
523  None.
524 
525 --*/
526 
527 {
528  PHW_DEVICE_EXTENSION hwDeviceExtension = HwDeviceExtension;
529 
530  //
531  // set up the default cursor position and type.
532  //
533 
534  hwDeviceExtension->CursorPosition.Column = 0;
535  hwDeviceExtension->CursorPosition.Row = 0;
536  hwDeviceExtension->CursorTopScanLine = 0;
537  hwDeviceExtension->CursorBottomScanLine = 31;
538  hwDeviceExtension->CursorEnable = TRUE;
539 
540 // eVb: 1.8 [VBE] - Initialize VBE modes
541  InitializeModeTable(hwDeviceExtension);
542 // eVb: 1.8 [END]
543  return TRUE;
544 
545 } // VgaInitialize()
546 
547 //---------------------------------------------------------------------------
548 BOOLEAN
549 NTAPI
551  PVOID HwDeviceExtension,
552  PVIDEO_REQUEST_PACKET RequestPacket
553  )
554 
555 /*++
556 
557 Routine Description:
558 
559  This routine is the main execution routine for the miniport driver. It
560  accepts a Video Request Packet, performs the request, and then returns
561  with the appropriate status.
562 
563 Arguments:
564 
565  HwDeviceExtension - Pointer to the miniport driver's adapter information.
566 
567  RequestPacket - Pointer to the video request packet. This structure
568  contains all the parameters passed to the VideoIoControl function.
569 
570 Return Value:
571 
572  This routine will return error codes from the various support routines
573  and will also return ERROR_INSUFFICIENT_BUFFER for incorrectly sized
574  buffers and ERROR_INVALID_FUNCTION for unsupported functions.
575 
576 --*/
577 
578 {
579  PHW_DEVICE_EXTENSION hwDeviceExtension = HwDeviceExtension;
581  VIDEO_MODE videoMode;
582  PVIDEO_MEMORY_INFORMATION memoryInformation;
583  ULONG inIoSpace;
584  ULONG Result;
585 
586  //
587  // Switch on the IoContolCode in the RequestPacket. It indicates which
588  // function must be performed by the driver.
589  //
590 // eVb: 1.9 [IOCTL] - Remove IOCTLs not needed yet
591  switch (RequestPacket->IoControlCode)
592  {
594 
595  VideoDebugPrint((2, "VgaStartIO - ShareVideoMemory\n"));
596 
598 
599  break;
600 
602 
603  VideoDebugPrint((2, "VgaStartIO - UnshareVideoMemory\n"));
604 
606 
607  break;
608 
609 
611 
612  VideoDebugPrint((2, "VgaStartIO - MapVideoMemory\n"));
613 
614  if ( (RequestPacket->OutputBufferLength <
615  (RequestPacket->StatusBlock->Information =
616  sizeof(VIDEO_MEMORY_INFORMATION))) ||
617  (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY)) )
618  {
620  }
621 
622  memoryInformation = RequestPacket->OutputBuffer;
623 
624  memoryInformation->VideoRamBase = ((PVIDEO_MEMORY)
625  (RequestPacket->InputBuffer))->RequestedVirtualAddress;
626 
627  //
628  // We reserved 16 meg for the frame buffer, however, it makes
629  // no sense to map more memory than there is on the card. So
630  // only map the amount of memory we have on the card.
631  //
632 // eVb: 1.10 [CIRRUS] - On VGA, we have VRAM size since boot, use it
633  memoryInformation->VideoRamLength =
634  hwDeviceExtension->PhysicalVideoMemoryLength;
635 // eVb: 1.10 [END]
636  //
637  // If you change to using a dense space frame buffer, make this
638  // value a 4 for the ALPHA.
639  //
640 
641  inIoSpace = 0;
642 
643  status = VideoPortMapMemory(hwDeviceExtension,
644  hwDeviceExtension->PhysicalVideoMemoryBase,
645 // eVb: 1.11 [CIRRUS] - On VGA, we have VRAM size since boot, use it
646  &memoryInformation->VideoRamLength,
647 // eVb: 1.11 [END]
648  &inIoSpace,
649  &(memoryInformation->VideoRamBase));
650 
651  if (status != NO_ERROR) {
652  VideoDebugPrint((0, "VgaStartIO - IOCTL_VIDEO_MAP_VIDEO_MEMORY failed VideoPortMapMemory (%x)\n", status));
653  }
654 
655  memoryInformation->FrameBufferBase =
656  ((PUCHAR) (memoryInformation->VideoRamBase)) +
657  hwDeviceExtension->PhysicalFrameOffset.LowPart;
658 
659  memoryInformation->FrameBufferLength =
660  hwDeviceExtension->PhysicalFrameLength ?
661  hwDeviceExtension->PhysicalFrameLength :
662  memoryInformation->VideoRamLength;
663 
664 
665  VideoDebugPrint((2, "physical VideoMemoryBase %08lx\n", hwDeviceExtension->PhysicalVideoMemoryBase));
666  VideoDebugPrint((2, "physical VideoMemoryLength %08lx\n", hwDeviceExtension->PhysicalVideoMemoryLength));
667  VideoDebugPrint((2, "VideoMemoryBase %08lx\n", memoryInformation->VideoRamBase));
668  VideoDebugPrint((2, "VideoMemoryLength %08lx\n", memoryInformation->VideoRamLength));
669 
670  VideoDebugPrint((2, "physical framebuf offset %08lx\n", hwDeviceExtension->PhysicalFrameOffset.LowPart));
671  VideoDebugPrint((2, "framebuf base %08lx\n", memoryInformation->FrameBufferBase));
672  VideoDebugPrint((2, "physical framebuf len %08lx\n", hwDeviceExtension->PhysicalFrameLength));
673  VideoDebugPrint((2, "framebuf length %08lx\n", memoryInformation->FrameBufferLength));
674 
675  break;
676 
678 
679  VideoDebugPrint((2, "VgaStartIO - UnMapVideoMemory\n"));
680 
682 
683  break;
684 
685 
687 
688  VideoDebugPrint((2, "VgaStartIO - QueryAvailableModes\n"));
689 
690  status = VgaQueryAvailableModes(HwDeviceExtension,
692  RequestPacket->OutputBuffer,
693  RequestPacket->OutputBufferLength,
694  &RequestPacket->StatusBlock->Information);
695 
696  break;
697 
698 
700 
701  VideoDebugPrint((2, "VgaStartIO - QueryNumAvailableModes\n"));
702 
703  status = VgaQueryNumberOfAvailableModes(HwDeviceExtension,
705  RequestPacket->OutputBuffer,
706  RequestPacket->OutputBufferLength,
707  &RequestPacket->StatusBlock->Information);
708 
709  break;
710 
711 
713 
714  VideoDebugPrint((2, "VgaStartIO - QueryCurrentMode\n"));
715 
716  status = VgaQueryCurrentMode(HwDeviceExtension,
717  (PVIDEO_MODE_INFORMATION) RequestPacket->OutputBuffer,
718  RequestPacket->OutputBufferLength,
719  &RequestPacket->StatusBlock->Information);
720 
721  break;
722 
723 
725 
726  VideoDebugPrint((2, "VgaStartIO - SetCurrentModes\n"));
727 
728  status = VgaSetMode(HwDeviceExtension,
729  (PVIDEO_MODE) RequestPacket->InputBuffer,
730  RequestPacket->InputBufferLength,
731 // eVb: 1.12 [SET MODE] - Use new output parameter for framebuffer update functionality
732  &Result);
733 // eVb: 1.12 [END]
734 
735  break;
736 
737 
739 
740  VideoDebugPrint((2, "VgaStartIO - Reset Device\n"));
741 
742  videoMode.RequestedMode = 0;
743 
744  VgaSetMode(HwDeviceExtension,
745  (PVIDEO_MODE) &videoMode,
746  sizeof(videoMode),
747 // eVb: 1.13 [SET MODE] - Use new output parameter for framebuffer update functionality
748  &Result);
749 // eVb: 1.13 [END]
750 
751  //
752  // Always return succcess since settings the text mode will fail on
753  // non-x86.
754  //
755  // Also, failiure to set the text mode is not fatal in any way, since
756  // this operation must be followed by another set mode operation.
757  //
758 
759  status = NO_ERROR;
760 
761  break;
762 
763 
765 
766  VideoDebugPrint((2, "VgaStartIO - LoadAndSetFont\n"));
767 
769 
770  break;
771 
772 
774 
775  VideoDebugPrint((2, "VgaStartIO - QueryCursorPosition\n"));
776 
778 
779  break;
780 
781 
783 
784  VideoDebugPrint((2, "VgaStartIO - SetCursorPosition\n"));
785 
787 
788  break;
789 
790 
792 
793  VideoDebugPrint((2, "VgaStartIO - QueryCursorAttributes\n"));
794 
796 
797  break;
798 
799 
801 
802  VideoDebugPrint((2, "VgaStartIO - SetCursorAttributes\n"));
803 
805 
806  break;
807 
808 
810 
811  VideoDebugPrint((2, "VgaStartIO - SetPaletteRegs\n"));
812 
813  status = VgaSetPaletteReg(HwDeviceExtension,
814  (PVIDEO_PALETTE_DATA) RequestPacket->InputBuffer,
815  RequestPacket->InputBufferLength);
816 
817  break;
818 
819 
821 
822  VideoDebugPrint((2, "VgaStartIO - SetColorRegs\n"));
823 
824  status = VgaSetColorLookup(HwDeviceExtension,
825  (PVIDEO_CLUT) RequestPacket->InputBuffer,
826  RequestPacket->InputBufferLength);
827 
828  break;
829 
830 
832 
833  VideoDebugPrint((2, "VgaStartIO - EnableVDM\n"));
834 
836 
837  break;
838 
839 
841 
842  VideoDebugPrint((2, "VgaStartIO - RestoreHardwareState\n"));
843 
845 
846  break;
847 
848 
850 
851  VideoDebugPrint((2, "VgaStartIO - SaveHardwareState\n"));
852 
854 
855  break;
856 
858 
859  VideoDebugPrint((2, "VgaStartIO - GetBankSelectCode\n"));
860 
862  break;
863 
865  {
866  PVIDEO_PUBLIC_ACCESS_RANGES portAccess;
867  ULONG physicalPortLength;
868 
869  VideoDebugPrint((2, "VgaStartIO - Query Public Address Ranges\n"));
870 
871  if (RequestPacket->OutputBufferLength <
873  {
875  break;
876  }
877 
878  RequestPacket->StatusBlock->Information =
880 
881  portAccess = RequestPacket->OutputBuffer;
882 
883  //
884  // The first public access range is the IO ports.
885  //
886 
887  portAccess->VirtualAddress = (PVOID) NULL;
888  portAccess->InIoSpace = TRUE;
889  portAccess->MappedInIoSpace = portAccess->InIoSpace;
890  physicalPortLength = VGA_MAX_IO_PORT - VGA_BASE_IO_PORT + 1;
891 
892  status = VideoPortMapMemory(hwDeviceExtension,
894  &physicalPortLength,
895  &(portAccess->MappedInIoSpace),
896  &(portAccess->VirtualAddress));
897 // eVb: 1.17 [GCG] - Fix lvalue error
898  portAccess->VirtualAddress = (PVOID)((ULONG_PTR)portAccess->VirtualAddress - VGA_BASE_IO_PORT);
899 // eVb: 1.17 [END]
900  VideoDebugPrint((2, "VgaStartIO - mapping ports to (%x)\n", portAccess->VirtualAddress));
901  }
902 
903  break;
904 
906 
907  VideoDebugPrint((2, "VgaStartIO - Free Public Access Ranges\n"));
908 
910  break;
911 
912  //
913  // if we get here, an invalid IoControlCode was specified.
914  //
915 
916  default:
917 
918  VideoDebugPrint((0, "Fell through vga startIO routine - invalid command\n"));
919 
921 
922  break;
923 
924  }
925 // eVb: 1.9 [END]
926  RequestPacket->StatusBlock->Status = status;
927 
928  return TRUE;
929 
930 } // VgaStartIO()
931 
932 //---------------------------------------------------------------------------
933 //
934 // private routines
935 //
936 
937 //---------------------------------------------------------------------------
938 BOOLEAN
939 NTAPI
941  PHW_DEVICE_EXTENSION HwDeviceExtension
942  )
943 
944 /*++
945 
946 Routine Description:
947 
948  This routine returns TRUE if a VGA is present. Determining whether a VGA
949  is present is a two-step process. First, this routine walks bits through
950  the Bit Mask register, to establish that there are readable indexed
951  registers (EGAs normally don't have readable registers, and other adapters
952  are unlikely to have indexed registers). This test is done first because
953  it's a non-destructive EGA rejection test (correctly rejects EGAs, but
954  doesn't potentially mess up the screen or the accessibility of display
955  memory). Normally, this would be an adequate test, but some EGAs have
956  readable registers, so next, we check for the existence of the Chain4 bit
957  in the Memory Mode register; this bit doesn't exist in EGAs. It's
958  conceivable that there are EGAs with readable registers and a register bit
959  where Chain4 is stored, although I don't know of any; if a better test yet
960  is needed, memory could be written to in Chain4 mode, and then examined
961  plane by plane in non-Chain4 mode to make sure the Chain4 bit did what it's
962  supposed to do. However, the current test should be adequate to eliminate
963  just about all EGAs, and 100% of everything else.
964 
965  If this function fails to find a VGA, it attempts to undo any damage it
966  may have inadvertently done while testing. The underlying assumption for
967  the damage control is that if there's any non-VGA adapter at the tested
968  ports, it's an EGA or an enhanced EGA, because: a) I don't know of any
969  other adapters that use 3C4/5 or 3CE/F, and b), if there are other
970  adapters, I certainly don't know how to restore their original states. So
971  all error recovery is oriented toward putting an EGA back in a writable
972  state, so that error messages are visible. The EGA's state on entry is
973  assumed to be text mode, so the Memory Mode register is restored to the
974  default state for text mode.
975 
976  If a VGA is found, the VGA is returned to its original state after
977  testing is finished.
978 
979 Arguments:
980 
981  None.
982 
983 Return Value:
984 
985  TRUE if a VGA is present, FALSE if not.
986 
987 --*/
988 
989 {
990  UCHAR originalGCAddr;
991  UCHAR originalSCAddr;
992  UCHAR originalBitMask;
993  UCHAR originalReadMap;
994  UCHAR originalMemoryMode;
995  UCHAR testMask;
996  BOOLEAN returnStatus;
997 
998  //
999  // Remember the original state of the Graphics Controller Address register.
1000  //
1001 
1002  originalGCAddr = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1004 
1005  //
1006  // Write the Read Map register with a known state so we can verify
1007  // that it isn't changed after we fool with the Bit Mask. This ensures
1008  // that we're dealing with indexed registers, since both the Read Map and
1009  // the Bit Mask are addressed at GRAPH_DATA_PORT.
1010  //
1011 
1012  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1014 
1015  //
1016  // If we can't read back the Graphics Address register setting we just
1017  // performed, it's not readable and this isn't a VGA.
1018  //
1019 
1020  if ((VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1022 
1023  return FALSE;
1024  }
1025 
1026  //
1027  // Set the Read Map register to a known state.
1028  //
1029 
1030  originalReadMap = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1031  GRAPH_DATA_PORT);
1032  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1034 
1035  if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1037 
1038  //
1039  // The Read Map setting we just performed can't be read back; not a
1040  // VGA. Restore the default Read Map state.
1041  //
1042 
1043  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1045 
1046  return FALSE;
1047  }
1048 
1049  //
1050  // Remember the original setting of the Bit Mask register.
1051  //
1052 
1053  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1055  if ((VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1057 
1058  //
1059  // The Graphics Address register setting we just made can't be read
1060  // back; not a VGA. Restore the default Read Map state.
1061  //
1062 
1063  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1065  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1067 
1068  return FALSE;
1069  }
1070 
1071  originalBitMask = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1072  GRAPH_DATA_PORT);
1073 
1074  //
1075  // Set up the initial test mask we'll write to and read from the Bit Mask.
1076  //
1077 
1078  testMask = 0xBB;
1079 
1080  do {
1081 
1082  //
1083  // Write the test mask to the Bit Mask.
1084  //
1085 
1086  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1087  GRAPH_DATA_PORT, testMask);
1088 
1089  //
1090  // Make sure the Bit Mask remembered the value.
1091  //
1092 
1093  if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1094  GRAPH_DATA_PORT) != testMask) {
1095 
1096  //
1097  // The Bit Mask is not properly writable and readable; not a VGA.
1098  // Restore the Bit Mask and Read Map to their default states.
1099  //
1100 
1101  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1103  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1105  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1107 
1108  return FALSE;
1109  }
1110 
1111  //
1112  // Cycle the mask for next time.
1113  //
1114 
1115  testMask >>= 1;
1116 
1117  } while (testMask != 0);
1118 
1119  //
1120  // There's something readable at GRAPH_DATA_PORT; now switch back and
1121  // make sure that the Read Map register hasn't changed, to verify that
1122  // we're dealing with indexed registers.
1123  //
1124 
1125  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1127  if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1129 
1130  //
1131  // The Read Map is not properly writable and readable; not a VGA.
1132  // Restore the Bit Mask and Read Map to their default states, in case
1133  // this is an EGA, so subsequent writes to the screen aren't garbled.
1134  //
1135 
1136  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1138  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1140  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1142 
1143  return FALSE;
1144  }
1145 
1146  //
1147  // We've pretty surely verified the existence of the Bit Mask register.
1148  // Put the Graphics Controller back to the original state.
1149  //
1150 
1151  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1152  GRAPH_DATA_PORT, originalReadMap);
1153  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1155  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1156  GRAPH_DATA_PORT, originalBitMask);
1157  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1158  GRAPH_ADDRESS_PORT, originalGCAddr);
1159 
1160  //
1161  // Now, check for the existence of the Chain4 bit.
1162  //
1163 
1164  //
1165  // Remember the original states of the Sequencer Address and Memory Mode
1166  // registers.
1167  //
1168 
1169  originalSCAddr = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1171  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1173  if ((VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1175 
1176  //
1177  // Couldn't read back the Sequencer Address register setting we just
1178  // performed.
1179  //
1180 
1181  return FALSE;
1182  }
1183  originalMemoryMode = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1184  SEQ_DATA_PORT);
1185 
1186  //
1187  // Toggle the Chain4 bit and read back the result. This must be done during
1188  // sync reset, since we're changing the chaining state.
1189  //
1190 
1191  //
1192  // Begin sync reset.
1193  //
1194 
1195  VideoPortWritePortUshort((PUSHORT)(HwDeviceExtension->IOAddress +
1198 
1199  //
1200  // Toggle the Chain4 bit.
1201  //
1202 
1203  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1205  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1206  SEQ_DATA_PORT, (UCHAR)(originalMemoryMode ^ CHAIN4_MASK));
1207 
1208  if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1209  SEQ_DATA_PORT) != (UCHAR) (originalMemoryMode ^ CHAIN4_MASK)) {
1210 
1211  //
1212  // Chain4 bit not there; not a VGA.
1213  // Set text mode default for Memory Mode register.
1214  //
1215 
1216  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1218  //
1219  // End sync reset.
1220  //
1221 
1222  VideoPortWritePortUshort((PUSHORT) (HwDeviceExtension->IOAddress +
1225 
1226  returnStatus = FALSE;
1227 
1228  } else {
1229 
1230  //
1231  // It's a VGA.
1232  //
1233 
1234  //
1235  // Restore the original Memory Mode setting.
1236  //
1237 
1238  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1239  SEQ_DATA_PORT, originalMemoryMode);
1240 
1241  //
1242  // End sync reset.
1243  //
1244 
1245  VideoPortWritePortUshort((PUSHORT)(HwDeviceExtension->IOAddress +
1248 
1249  //
1250  // Restore the original Sequencer Address setting.
1251  //
1252 
1253  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1254  SEQ_ADDRESS_PORT, originalSCAddr);
1255 
1256  returnStatus = TRUE;
1257  }
1258 
1259  return returnStatus;
1260 
1261 } // VgaIsPresent()
1262 
1263 //---------------------------------------------------------------------------
1264 VP_STATUS
1265 NTAPI
1267  PHW_DEVICE_EXTENSION HwDeviceExtension,
1269  ULONG PaletteBufferSize
1270  )
1271 
1272 /*++
1273 
1274 Routine Description:
1275 
1276  This routine sets a specified portion of the EGA (not DAC) palette
1277  registers.
1278 
1279 Arguments:
1280 
1281  HwDeviceExtension - Pointer to the miniport driver's device extension.
1282 
1283  PaletteBuffer - Pointer to the structure containing the palette data.
1284 
1285  PaletteBufferSize - Length of the input buffer supplied by the user.
1286 
1287 Return Value:
1288 
1289  NO_ERROR - information returned successfully
1290 
1291  ERROR_INSUFFICIENT_BUFFER - input buffer not large enough for input data.
1292 
1293  ERROR_INVALID_PARAMETER - invalid palette size.
1294 
1295 --*/
1296 
1297 {
1298  USHORT i;
1299 
1300  //
1301  // Check if the size of the data in the input buffer is large enough.
1302  //
1303 
1304  if ((PaletteBufferSize) < (sizeof(VIDEO_PALETTE_DATA)) ||
1305  (PaletteBufferSize < (sizeof(VIDEO_PALETTE_DATA) +
1306  (sizeof(USHORT) * (PaletteBuffer->NumEntries -1)) ))) {
1307 
1309 
1310  }
1311 
1312  //
1313  // Check to see if the parameters are valid.
1314  //
1315 
1316  if ( (PaletteBuffer->FirstEntry > VIDEO_MAX_COLOR_REGISTER ) ||
1317  (PaletteBuffer->NumEntries == 0) ||
1318  (PaletteBuffer->FirstEntry + PaletteBuffer->NumEntries >
1319  VIDEO_MAX_PALETTE_REGISTER + 1 ) ) {
1320 
1321  return ERROR_INVALID_PARAMETER;
1322 
1323  }
1324 
1325  //
1326  // Reset ATC to index mode
1327  //
1328 
1329  VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1331 
1332  //
1333  // Blast out our palette values.
1334  //
1335 
1336  for (i = 0; i < PaletteBuffer->NumEntries; i++) {
1337 
1338  VideoPortWritePortUchar(HwDeviceExtension->IOAddress + ATT_ADDRESS_PORT,
1339  (UCHAR)(i+PaletteBuffer->FirstEntry));
1340 
1341  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1343  (UCHAR)PaletteBuffer->Colors[i]);
1344  }
1345 
1346  VideoPortWritePortUchar(HwDeviceExtension->IOAddress + ATT_ADDRESS_PORT,
1347  VIDEO_ENABLE);
1348 
1349  return NO_ERROR;
1350 
1351 } // end VgaSetPaletteReg()
1352 
1353 //---------------------------------------------------------------------------
1354 VP_STATUS
1355 NTAPI
1357  PHW_DEVICE_EXTENSION HwDeviceExtension,
1358  PVIDEO_CLUT ClutBuffer,
1359  ULONG ClutBufferSize
1360  )
1361 
1362 /*++
1363 
1364 Routine Description:
1365 
1366  This routine sets a specified portion of the DAC color lookup table
1367  settings.
1368 
1369 Arguments:
1370 
1371  HwDeviceExtension - Pointer to the miniport driver's device extension.
1372 
1373  ClutBufferSize - Length of the input buffer supplied by the user.
1374 
1375  ClutBuffer - Pointer to the structure containing the color lookup table.
1376 
1377 Return Value:
1378 
1379  NO_ERROR - information returned successfully
1380 
1381  ERROR_INSUFFICIENT_BUFFER - input buffer not large enough for input data.
1382 
1383  ERROR_INVALID_PARAMETER - invalid clut size.
1384 
1385 --*/
1386 
1387 {
1388  PVIDEOMODE CurrentMode = HwDeviceExtension->CurrentMode;
1389  USHORT i;
1390 
1391  //
1392  // Check if the size of the data in the input buffer is large enough.
1393  //
1394 
1395  if ( (ClutBufferSize < sizeof(VIDEO_CLUT) - sizeof(ULONG)) ||
1396  (ClutBufferSize < sizeof(VIDEO_CLUT) +
1397  (sizeof(ULONG) * (ClutBuffer->NumEntries - 1)) ) ) {
1398 
1400 
1401  }
1402 
1403  //
1404  // Check to see if the parameters are valid.
1405  //
1406 
1407  if ( (ClutBuffer->NumEntries == 0) ||
1408  (ClutBuffer->FirstEntry > VIDEO_MAX_COLOR_REGISTER) ||
1409  (ClutBuffer->FirstEntry + ClutBuffer->NumEntries >
1410  VIDEO_MAX_COLOR_REGISTER + 1) ) {
1411 
1412  return ERROR_INVALID_PARAMETER;
1413 
1414  }
1415 // eVb: 1.14 [VBE] - Add VBE color support
1416  //
1417  // Check SVGA mode
1418  //
1419 
1420  if (CurrentMode->bitsPerPlane >= 8) return VbeSetColorLookup(HwDeviceExtension, ClutBuffer);
1421 // eVb: 1.14 [END]
1422  //
1423  // Path for VGA mode
1424  //
1425 // eVb: 1.15 [VBE] - Add VBE support for non-VGA-compatible detected modes
1426  if (!CurrentMode->NonVgaMode)
1427  {
1428 // eVb: 1.15 [END]
1429  //
1430  // Set CLUT registers directly on the hardware
1431  //
1432 
1433  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1434  DAC_ADDRESS_WRITE_PORT, (UCHAR) ClutBuffer->FirstEntry);
1435 
1436  for (i = 0; i < ClutBuffer->NumEntries; i++) {
1437  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1439  (UCHAR)(i + ClutBuffer->FirstEntry));
1440 
1441  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1443  ClutBuffer->LookupTable[i].RgbArray.Red);
1444 
1445  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1447  ClutBuffer->LookupTable[i].RgbArray.Green);
1448 
1449  VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
1451  ClutBuffer->LookupTable[i].RgbArray.Blue);
1452  }
1453  return NO_ERROR;
1454  }
1455 
1456  return ERROR_INVALID_PARAMETER;
1457 
1458 } // end VgaSetColorLookup()
1459 
1460 VP_STATUS
1461 NTAPI
1463  PVOID HwDeviceExtension,
1464  PVOID Context,
1465  VIDEO_DEVICE_DATA_TYPE DeviceDataType,
1466  PVOID Identifier,
1467  ULONG IdentifierLength,
1468  PVOID ConfigurationData,
1469  ULONG ConfigurationDataLength,
1470  PVOID ComponentInformation,
1471  ULONG ComponentInformationLength
1472  )
1473 
1474 /*++
1475 
1476 Routine Description:
1477 
1478  Callback routine for the VideoPortGetDeviceData function.
1479 
1480 Arguments:
1481 
1482  HwDeviceExtension - Pointer to the miniport drivers device extension.
1483 
1484  Context - Context value passed to the VideoPortGetDeviceData function.
1485 
1486  DeviceDataType - The type of data that was requested in
1487  VideoPortGetDeviceData.
1488 
1489  Identifier - Pointer to a string that contains the name of the device,
1490  as setup by the ROM or ntdetect.
1491 
1492  IdentifierLength - Length of the Identifier string.
1493 
1494  ConfigurationData - Pointer to the configuration data for the device or
1495  BUS.
1496 
1497  ConfigurationDataLength - Length of the data in the configurationData
1498  field.
1499 
1500  ComponentInformation - Undefined.
1501 
1502  ComponentInformationLength - Undefined.
1503 
1504 Return Value:
1505 
1506  Returns NO_ERROR if the function completed properly.
1507  Returns ERROR_DEV_NOT_EXIST if we did not find the device.
1508  Returns ERROR_INVALID_PARAMETER otherwise.
1509 
1510 --*/
1511 
1512 {
1513  VideoDebugPrint((Error, "Detected internal VGA chip on embedded board, todo\n"));
1514  while (TRUE);
1515  return NO_ERROR;
1516 
1517 } //end GetDeviceDataCallback()
1518 
1519 // eVb: 1.16 [RESOURCE] - Add new function for acquiring VGA resources (I/O, memory)
1520 VP_STATUS
1521 NTAPI
1523  PHW_DEVICE_EXTENSION DeviceExtension
1524  )
1525 {
1527  ULONG Ranges, i;
1528 
1529  //
1530  // Try exclusive ranges (vga + ati)
1531  //
1532 
1533  Ranges = NUM_VGA_ACCESS_RANGES;
1534  for (i = 0; i < Ranges; i++) VgaAccessRange[i].RangeShareable = FALSE;
1535  if (VideoPortVerifyAccessRanges(DeviceExtension, Ranges, VgaAccessRange) != NO_ERROR)
1536  {
1537  //
1538  // Not worked, try vga only
1539  //
1540 
1541  Ranges = 3;
1542  if (VideoPortVerifyAccessRanges(DeviceExtension, Ranges, VgaAccessRange) != NO_ERROR)
1543  {
1544  //
1545  // Still not, try shared ranges
1546  //
1547 
1548  for (i = 0; i < Ranges; i++) VgaAccessRange[i].RangeShareable = TRUE;
1549  Status = VideoPortVerifyAccessRanges(DeviceExtension, Ranges, VgaAccessRange);
1550  if (Status == NO_ERROR)
1551  {
1552  //
1553  // It did work
1554  //
1555 
1556  VideoPortVerifyAccessRanges(DeviceExtension, 0, 0);
1557  Status = NO_ERROR;
1558  }
1559  }
1560  }
1561 
1562  if (Status == NO_ERROR)
1563  {
1564  //
1565  // Worked with exclusive, also try shared
1566  //
1567 
1568  for (i = 0; i < Ranges; i++) VgaAccessRange[i].RangeShareable = TRUE;
1569  Status = VideoPortVerifyAccessRanges(DeviceExtension, Ranges, VgaAccessRange);
1570  }
1571 
1572  return Status;
1573 }
1574 // eVb: 1.16 [END]
VP_STATUS NTAPI VgaSetPaletteReg(PHW_DEVICE_EXTENSION HwDeviceExtension, PVIDEO_PALETTE_DATA PaletteBuffer, ULONG PaletteBufferSize)
Definition: vga.c:1266
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
PUCHAR IOAddress
Definition: vga.h:401
#define END_SYNC_RESET_VALUE
Definition: vga.h:157
#define TRUE
Definition: types.h:120
#define IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY
Definition: ntddvdeo.h:182
_In_ ULONG Mode
Definition: hubbusif.h:303
ULONG PhysicalFrameLength
Definition: vga.h:398
#define ATT_INITIALIZE_PORT_COLOR
Definition: vga.h:94
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define GRAPH_ADDRESS_PORT
Definition: vga.h:85
uint16_t * PWSTR
Definition: typedefs.h:54
#define VGA_BASE_IO_PORT
Definition: vga.h:42
unsigned char * PUCHAR
Definition: retypes.h:3
USHORT FirstEntry
Definition: ntddvdeo.h:520
ULONG NonVgaMode
Definition: vga.h:277
ULONG NumEmulatorAccessEntries
Definition: video.h:173
#define START_SYNC_RESET_VALUE
Definition: vga.h:155
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA _In_ PVOID HwContext
Definition: srb.h:664
#define IOCTL_VIDEO_ENABLE_VDM
Definition: ntddvdeo.h:41
VP_STATUS NTAPI VgaQueryCurrentMode(PHW_DEVICE_EXTENSION HwDeviceExtension, PVIDEO_MODE_INFORMATION ModeInformation, ULONG ModeInformationSize, PULONG_PTR OutputSize)
Definition: modeset.c:719
ULONG PhysicalVideoMemoryLength
Definition: vga.h:397
#define IOCTL_VIDEO_RESET_DEVICE
Definition: ntddvdeo.h:137
INTERFACE_TYPE AdapterInterfaceType
Definition: video.h:665
PHYSICAL_ADDRESS PhysicalVideoMemoryBase
Definition: vga.h:395
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:104
VIDEO_CLUTDATA RgbArray
Definition: ntddvdeo.h:522
#define ATT_DATA_WRITE_PORT
Definition: vga.h:62
VPAPI ULONG NTAPI VideoPortInitialize(IN PVOID Argument1, IN PVOID Argument2, IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData, IN PVOID HwContext)
Definition: videoprt.c:455
ULONG InputBufferLength
Definition: video.h:333
#define IND_READ_MAP
Definition: vga.h:143
VPAPI PVOID NTAPI VideoPortGetDeviceBase(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS IoAddress, IN ULONG NumberOfUchars, IN UCHAR InIoSpace)
Definition: resource.c:450
#define NO_ERROR
Definition: dderror.h:5
#define IOCTL_VIDEO_GET_BANK_SELECT_CODE
Definition: ntddvdeo.h:92
#define IOCTL_VIDEO_FREE_PUBLIC_ACCESS_RANGES
Definition: ntddvdeo.h:89
#define VIDEO_MAX_COLOR_REGISTER
Definition: vga.h:224
struct _VIDEO_PUBLIC_ACCESS_RANGES VIDEO_PUBLIC_ACCESS_RANGES
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
#define GRAPH_DATA_PORT
Definition: vga.h:86
PVIDEO_HW_START_IO HwStartIO
Definition: video.h:669
USHORT bitsPerPlane
Definition: vga.h:255
#define IOCTL_VIDEO_QUERY_CURRENT_MODE
Definition: ntddvdeo.h:113
Definition: vga.h:251
VP_STATUS NTAPI VgaInterpretCmdStream(PHW_DEVICE_EXTENSION HwDeviceExtension, PUSHORT pusCmdStream)
Definition: modeset.c:74
uint32_t ULONG_PTR
Definition: typedefs.h:63
INTERFACE_TYPE AdapterInterfaceType
Definition: video.h:169
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:152
#define READ_MAP_TEST_SETTING
Definition: vga.h:204
#define VGA_MAX_IO_PORT
Definition: vga.h:45
PVIDEOMODE CurrentMode
Definition: vga.h:404
#define NUM_VGA_ACCESS_RANGES
Definition: vga.h:444
VPAPI UCHAR NTAPI VideoPortReadPortUchar(IN PUCHAR Port)
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
#define READ_MAP_DEFAULT
Definition: vga.h:213
VP_STATUS NTAPI VgaSetMode(PHW_DEVICE_EXTENSION HwDeviceExtension, PVIDEO_MODE Mode, ULONG ModeSize, PULONG PhysPtrChange)
Definition: modeset.c:361
ULONG RequestedMode
Definition: ntddvdeo.h:289
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
PEMULATOR_ACCESS_ENTRY EmulatorAccessEntries
Definition: video.h:174
VP_STATUS NTAPI VgaQueryNumberOfAvailableModes(PHW_DEVICE_EXTENSION HwDeviceExtension, PVIDEO_NUM_MODES NumModes, ULONG NumModesSize, PULONG_PTR OutputSize)
Definition: modeset.c:655
#define IOCTL_VIDEO_SET_PALETTE_REGISTERS
Definition: ntddvdeo.h:161
ULONG_PTR EmulatorAccessEntriesContext
Definition: video.h:175
#define SEQ_DATA_PORT
Definition: vga.h:74
#define IOCTL_VIDEO_SET_CURSOR_POSITION
Definition: ntddvdeo.h:158
#define IND_SYNC_RESET
Definition: vga.h:147
unsigned char BOOLEAN
#define DAC_DATA_REG_PORT
Definition: vga.h:81
struct _HW_DEVICE_EXTENSION HW_DEVICE_EXTENSION
VPAPI 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:896
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension)
Definition: vbemodes.c:159
struct _VIDEO_HW_INITIALIZATION_DATA VIDEO_HW_INITIALIZATION_DATA
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
PHYSICAL_ADDRESS VdmPhysicalVideoMemoryAddress
Definition: video.h:176
#define IOCTL_VIDEO_QUERY_CURSOR_ATTR
Definition: ntddvdeo.h:116
void * PVOID
Definition: retypes.h:9
UCHAR CursorBottomScanLine
Definition: vga.h:411
PVIDEO_HW_INITIALIZE HwInitialize
Definition: video.h:667
ULONG OutputBufferLength
Definition: video.h:335
VP_STATUS NTAPI GetDeviceDataCallback(PVOID HwDeviceExtension, PVOID Context, VIDEO_DEVICE_DATA_TYPE DeviceDataType, PVOID Identifier, ULONG IdentifierLength, PVOID ConfigurationData, ULONG ConfigurationDataLength, PVOID ComponentInformation, ULONG ComponentInformationLength)
Definition: vga.c:1462
#define IOCTL_VIDEO_SET_CURSOR_ATTR
Definition: ntddvdeo.h:155
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:179
VPAPI VOID NTAPI VideoPortWritePortUshort(IN PUSHORT Port, IN USHORT Value)
#define IOCTL_VIDEO_QUERY_CURSOR_POSITION
Definition: ntddvdeo.h:119
BOOLEAN NTAPI VgaStartIO(PVOID HwDeviceExtension, PVIDEO_REQUEST_PACKET RequestPacket)
Definition: vga.c:550
#define ATT_ADDRESS_PORT
Definition: vga.h:61
USHORT NumEntries
Definition: ntddvdeo.h:519
UCHAR CursorTopScanLine
Definition: vga.h:410
VPAPI VP_STATUS NTAPI VideoPortMapMemory(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, IN OUT PULONG Length, IN PULONG InIoSpace, IN OUT PVOID *VirtualAddress)
VP_STATUS NTAPI VgaAcquireResources(PHW_DEVICE_EXTENSION DeviceExtension)
Definition: vga.c:1522
#define BIT_MASK_DEFAULT
Definition: vga.h:212
BOOLEAN NTAPI VgaIsPresent(PHW_DEVICE_EXTENSION HwDeviceExtension)
Definition: vga.c:940
#define MEMORY_MODE_TEXT_DEFAULT
Definition: vga.h:211
#define SEQ_ADDRESS_PORT
Definition: vga.h:73
PVIDEO_HW_FIND_ADAPTER HwFindAdapter
Definition: video.h:666
VP_STATUS NTAPI VgaFindAdapter(PVOID HwDeviceExtension, PVOID HwContext, PWSTR ArgumentString, PVIDEO_PORT_CONFIG_INFO ConfigInfo, PUCHAR Again)
Definition: vga.c:324
BOOL Error
Definition: chkdsk.c:66
UCHAR RangeInIoSpace
Definition: video.h:217
VIDEO_CURSOR_POSITION CursorPosition
Definition: vga.h:407
VP_STATUS Status
Definition: video.h:323
unsigned char UCHAR
Definition: xmlstorage.h:181
static WORD PaletteBuffer[]
Definition: screen.c:11
#define IOCTL_VIDEO_LOAD_AND_SET_FONT
Definition: ntddvdeo.h:101
ULONG LowPart
Definition: typedefs.h:104
#define IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES
Definition: ntddvdeo.h:122
#define VIDEO_ENABLE
Definition: vga.h:179
BOOLEAN NTAPI VgaInitialize(PVOID HwDeviceExtension)
Definition: vga.c:507
PVIDEO_HW_INTERRUPT HwInterrupt
Definition: video.h:668
#define IOCTL_VIDEO_QUERY_AVAIL_MODES
Definition: ntddvdeo.h:107
#define IND_BIT_MASK
Definition: vga.h:146
VP_STATUS NTAPI VgaSetColorLookup(PHW_DEVICE_EXTENSION HwDeviceExtension, PVIDEO_CLUT ClutBuffer, ULONG ClutBufferSize)
Definition: vga.c:1356
#define IOCTL_VIDEO_SHARE_VIDEO_MEMORY
Definition: ntddvdeo.h:173
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT _In_ PTDI_PNP_CONTEXT Context2
Definition: tdikrnl.h:1094
VIDEO_ACCESS_RANGE VgaAccessRange[]
Definition: vgadata.c:16
Status
Definition: gdiplustypes.h:24
#define DAC_ADDRESS_WRITE_PORT
Definition: vga.h:80
#define IND_MEMORY_MODE
Definition: vga.h:149
#define VideoDebugPrint(x)
Definition: video.h:75
PUCHAR VideoMemoryAddress
Definition: vga.h:402
unsigned short USHORT
Definition: pedump.c:61
struct _VIDEO_MEMORY * PVIDEO_MEMORY
union VIDEO_CLUT::@3034 LookupTable[1]
PSTATUS_BLOCK StatusBlock
Definition: video.h:331
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT Context1
Definition: tdikrnl.h:1094
enum _VIDEO_DEVICE_DATA_TYPE VIDEO_DEVICE_DATA_TYPE
unsigned int * PULONG
Definition: retypes.h:1
#define VGA_TOTAL_STATE_SIZE
Definition: vga.h:385
VPAPI VP_STATUS NTAPI VideoPortVerifyAccessRanges(IN PVOID HwDeviceExtension, IN ULONG NumAccessRanges, IN PVIDEO_ACCESS_RANGE AccessRanges)
Definition: resource.c:816
#define GRAPH_ADDR_MASK
Definition: vga.h:189
#define IOCTL_VIDEO_QUERY_PUBLIC_ACCESS_RANGES
Definition: ntddvdeo.h:134
PHYSICAL_ADDRESS PhysicalFrameOffset
Definition: vga.h:396
ULONG NTAPI DriverEntry(PVOID Context1, PVOID Context2)
Definition: vga.c:153
unsigned int ULONG
Definition: retypes.h:1
uint32_t * PULONG_PTR
Definition: typedefs.h:63
LONG VP_STATUS
Definition: video.h:153
VP_STATUS NTAPI VbeSetColorLookup(IN PHW_DEVICE_EXTENSION VgaExtension, IN PVIDEO_CLUT ClutBuffer)
Definition: vbe.c:141
VP_STATUS NTAPI VgaQueryAvailableModes(PHW_DEVICE_EXTENSION HwDeviceExtension, PVIDEO_MODE_INFORMATION ModeInformation, ULONG ModeInformationSize, PULONG_PTR OutputSize)
Definition: modeset.c:517
#define IOCTL_VIDEO_RESTORE_HARDWARE_STATE
Definition: ntddvdeo.h:140
#define SEQ_ADDR_MASK
Definition: vga.h:190
VPAPI VOID NTAPI VideoPortWritePortUchar(IN PUCHAR Port, IN UCHAR Value)
static SERVICE_STATUS status
Definition: service.c:31
#define CHAIN4_MASK
Definition: vga.h:196
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
unsigned short * PUSHORT
Definition: retypes.h:2
#define VIDEO_MAX_PALETTE_REGISTER
Definition: vga.h:230
UCHAR CursorEnable
Definition: vga.h:409
#define IOCTL_VIDEO_SAVE_HARDWARE_STATE
Definition: ntddvdeo.h:143
ULONG_PTR Information
Definition: video.h:326
ULONG VdmPhysicalVideoMemoryLength
Definition: video.h:177
LONGLONG QuadPart
Definition: typedefs.h:112
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:149
PHYSICAL_ADDRESS RangeStart
Definition: video.h:215
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
Definition: ps.c:97