ReactOS  0.4.14-dev-57-g333b8f1
modeset.c File Reference
#include "vga.h"
Include dependency graph for modeset.c:

Go to the source code of this file.

Functions

VP_STATUS NTAPI VgaInterpretCmdStream (PHW_DEVICE_EXTENSION HwDeviceExtension, PUSHORT pusCmdStream)
 
VP_STATUS NTAPI VgaSetMode (PHW_DEVICE_EXTENSION HwDeviceExtension, PVIDEO_MODE Mode, ULONG ModeSize, PULONG PhysPtrChange)
 
VP_STATUS NTAPI VgaQueryAvailableModes (PHW_DEVICE_EXTENSION HwDeviceExtension, PVIDEO_MODE_INFORMATION ModeInformation, ULONG ModeInformationSize, PULONG_PTR OutputSize)
 
VP_STATUS NTAPI VgaQueryNumberOfAvailableModes (PHW_DEVICE_EXTENSION HwDeviceExtension, PVIDEO_NUM_MODES NumModes, ULONG NumModesSize, PULONG_PTR OutputSize)
 
VP_STATUS NTAPI VgaQueryCurrentMode (PHW_DEVICE_EXTENSION HwDeviceExtension, PVIDEO_MODE_INFORMATION ModeInformation, ULONG ModeInformationSize, PULONG_PTR OutputSize)
 
VOID NTAPI VgaZeroVideoMemory (PHW_DEVICE_EXTENSION HwDeviceExtension)
 

Function Documentation

◆ VgaInterpretCmdStream()

VP_STATUS NTAPI VgaInterpretCmdStream ( PHW_DEVICE_EXTENSION  HwDeviceExtension,
PUSHORT  pusCmdStream 
)

Definition at line 74 of file modeset.c.

100 {
101  ULONG ulCmd;
102  ULONG_PTR ulPort;
103  UCHAR jValue;
104  USHORT usValue;
105  ULONG culCount;
106  ULONG ulIndex;
107  ULONG_PTR ulBase;
108 
109  if (pusCmdStream == NULL) {
110 
111  VideoDebugPrint((1, "VgaInterpretCmdStream - Invalid pusCmdStream\n"));
112  return TRUE;
113  }
114 
115  ulBase = (ULONG_PTR)HwDeviceExtension->IOAddress;
116 
117  //
118  // Now set the adapter to the desired mode.
119  //
120 
121  while ((ulCmd = *pusCmdStream++) != EOD) {
122 
123  //
124  // Determine major command type
125  //
126 
127  switch (ulCmd & 0xF0) {
128 
129  //
130  // Basic input/output command
131  //
132 
133  case INOUT:
134 
135  //
136  // Determine type of inout instruction
137  //
138 
139  if (!(ulCmd & IO)) {
140 
141  //
142  // Out instruction. Single or multiple outs?
143  //
144 
145  if (!(ulCmd & MULTI)) {
146 
147  //
148  // Single out. Byte or word out?
149  //
150 
151  if (!(ulCmd & BW)) {
152 
153  //
154  // Single byte out
155  //
156 
157  ulPort = *pusCmdStream++;
158  jValue = (UCHAR) *pusCmdStream++;
159  VideoPortWritePortUchar((PUCHAR)(ulBase+ulPort),
160  jValue);
161 
162  } else {
163 
164  //
165  // Single word out
166  //
167 
168  ulPort = *pusCmdStream++;
169  usValue = *pusCmdStream++;
170  VideoPortWritePortUshort((PUSHORT)(ulBase+ulPort),
171  usValue);
172 
173  }
174 
175  } else {
176 
177  //
178  // Output a string of values
179  // Byte or word outs?
180  //
181 
182  if (!(ulCmd & BW)) {
183 
184  //
185  // String byte outs. Do in a loop; can't use
186  // VideoPortWritePortBufferUchar because the data
187  // is in USHORT form
188  //
189 
190  ulPort = ulBase + *pusCmdStream++;
191  culCount = *pusCmdStream++;
192 
193  while (culCount--) {
194  jValue = (UCHAR) *pusCmdStream++;
196  jValue);
197 
198  }
199 
200  } else {
201 
202  //
203  // String word outs
204  //
205 
206  ulPort = *pusCmdStream++;
207  culCount = *pusCmdStream++;
209  (ulBase + ulPort), pusCmdStream, culCount);
210  pusCmdStream += culCount;
211 
212  }
213  }
214 
215  } else {
216 
217  // In instruction
218  //
219  // Currently, string in instructions aren't supported; all
220  // in instructions are handled as single-byte ins
221  //
222  // Byte or word in?
223  //
224 
225  if (!(ulCmd & BW)) {
226  //
227  // Single byte in
228  //
229 
230  ulPort = *pusCmdStream++;
231  jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort);
232 
233  } else {
234 
235  //
236  // Single word in
237  //
238 
239  ulPort = *pusCmdStream++;
240  usValue = VideoPortReadPortUshort((PUSHORT)
241  (ulBase+ulPort));
242 
243  }
244 
245  }
246 
247  break;
248 
249  //
250  // Higher-level input/output commands
251  //
252 
253  case METAOUT:
254 
255  //
256  // Determine type of metaout command, based on minor
257  // command field
258  //
259  switch (ulCmd & 0x0F) {
260 
261  //
262  // Indexed outs
263  //
264 
265  case INDXOUT:
266 
267  ulPort = ulBase + *pusCmdStream++;
268  culCount = *pusCmdStream++;
269  ulIndex = *pusCmdStream++;
270 
271  while (culCount--) {
272 
273  usValue = (USHORT) (ulIndex +
274  (((ULONG)(*pusCmdStream++)) << 8));
275  VideoPortWritePortUshort((PUSHORT)ulPort, usValue);
276 
277  ulIndex++;
278 
279  }
280 
281  break;
282 
283  //
284  // Masked out (read, AND, XOR, write)
285  //
286 
287  case MASKOUT:
288 
289  ulPort = *pusCmdStream++;
290  jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort);
291  jValue &= *pusCmdStream++;
292  jValue ^= *pusCmdStream++;
293  VideoPortWritePortUchar((PUCHAR)ulBase + ulPort,
294  jValue);
295  break;
296 
297  //
298  // Attribute Controller out
299  //
300 
301  case ATCOUT:
302 
303  ulPort = ulBase + *pusCmdStream++;
304  culCount = *pusCmdStream++;
305  ulIndex = *pusCmdStream++;
306 
307  while (culCount--) {
308 
309  // Write Attribute Controller index
311  (UCHAR)ulIndex);
312 
313  // Write Attribute Controller data
314  jValue = (UCHAR) *pusCmdStream++;
315  VideoPortWritePortUchar((PUCHAR)ulPort, jValue);
316 
317  ulIndex++;
318 
319  }
320 
321  break;
322 
323  //
324  // None of the above; error
325  //
326  default:
327 
328  return FALSE;
329 
330  }
331 
332 
333  break;
334 
335  //
336  // NOP
337  //
338 
339  case NCMD:
340 
341  break;
342 
343  //
344  // Unknown command; error
345  //
346 
347  default:
348 
349  return FALSE;
350 
351  }
352 
353  }
354 
355  return TRUE;
356 
357 } // end VgaInterpretCmdStream()
PUCHAR IOAddress
Definition: vga.h:400
#define METAOUT
Definition: cmdcnst.h:62
#define TRUE
Definition: types.h:120
VPAPI VOID NTAPI VideoPortWritePortBufferUshort(IN PUSHORT Port, IN PUSHORT Buffer, IN ULONG Count)
#define MULTI
Definition: cmdcnst.h:69
unsigned char * PUCHAR
Definition: retypes.h:3
VPAPI USHORT NTAPI VideoPortReadPortUshort(IN PUSHORT Port)
#define BW
Definition: cmdcnst.h:70
uint32_t ULONG_PTR
Definition: typedefs.h:63
while(1)
Definition: macro.lex.yy.c:740
VPAPI UCHAR NTAPI VideoPortReadPortUchar(IN PUCHAR Port)
smooth NULL
Definition: ftsmooth.c:416
#define MASKOUT
Definition: cmdcnst.h:77
VPAPI VOID NTAPI VideoPortWritePortUshort(IN PUSHORT Port, IN USHORT Value)
unsigned char UCHAR
Definition: xmlstorage.h:181
#define INDXOUT
Definition: cmdcnst.h:75
#define INOUT
Definition: cmdcnst.h:61
#define IO
Definition: cmdcnst.h:71
ULONG ulIndex
Definition: symbols.c:92
#define VideoDebugPrint(x)
Definition: video.h:75
unsigned short USHORT
Definition: pedump.c:61
#define ATCOUT
Definition: cmdcnst.h:76
#define NCMD
Definition: cmdcnst.h:63
#define EOD
Definition: cmdcnst.h:60
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
VPAPI VOID NTAPI VideoPortWritePortUchar(IN PUCHAR Port, IN UCHAR Value)
unsigned short * PUSHORT
Definition: retypes.h:2

Referenced by VgaSetMode(), and VgaZeroVideoMemory().

◆ VgaQueryAvailableModes()

VP_STATUS NTAPI VgaQueryAvailableModes ( PHW_DEVICE_EXTENSION  HwDeviceExtension,
PVIDEO_MODE_INFORMATION  ModeInformation,
ULONG  ModeInformationSize,
PULONG_PTR  OutputSize 
)

Definition at line 517 of file modeset.c.

553 {
554  PVIDEO_MODE_INFORMATION videoModes = ModeInformation;
555  ULONG i;
556 
557  //
558  // Find out the size of the data to be put in the buffer and return
559  // that in the status information (whether or not the information is
560  // there). If the buffer passed in is not large enough return an
561  // appropriate error code.
562  //
563 
564  if (ModeInformationSize < (*OutputSize =
565 // eVb: 2.10 [VBE] - We store VBE/VGA mode count in this global, not in DevExt like Cirrus
566  NumVideoModes *
567 // eVb: 2.10 [END]
568  sizeof(VIDEO_MODE_INFORMATION)) ) {
569 
571 
572  }
573 
574  //
575  // For each mode supported by the card, store the mode characteristics
576  // in the output buffer.
577  //
578 
579  for (i = 0; i < NumVideoModes; i++)
580  {
581  videoModes->Length = sizeof(VIDEO_MODE_INFORMATION);
582  videoModes->ModeIndex = i;
583 // eVb: 2.11 [VBE] - Use dynamic VBE mode list instead of hard-coded VGA list
584  videoModes->VisScreenWidth = VgaModeList[i].hres;
585  videoModes->ScreenStride = VgaModeList[i].wbytes;
586  videoModes->VisScreenHeight = VgaModeList[i].vres;
587  videoModes->NumberOfPlanes = VgaModeList[i].numPlanes;
588  videoModes->BitsPerPlane = VgaModeList[i].bitsPerPlane;
589  videoModes->Frequency = VgaModeList[i].Frequency;
590  videoModes->XMillimeter = 320; // temporary hardcoded constant
591  videoModes->YMillimeter = 240; // temporary hardcoded constant
592  videoModes->AttributeFlags = VgaModeList[i].fbType;
593 // eVb: 2.11 [END]
594 
595  if ((VgaModeList[i].bitsPerPlane == 32) ||
596  (VgaModeList[i].bitsPerPlane == 24))
597  {
598 
599  videoModes->NumberRedBits = 8;
600  videoModes->NumberGreenBits = 8;
601  videoModes->NumberBlueBits = 8;
602  videoModes->RedMask = 0xff0000;
603  videoModes->GreenMask = 0x00ff00;
604  videoModes->BlueMask = 0x0000ff;
605 
606  }
607  else if (VgaModeList[i].bitsPerPlane == 16)
608  {
609 
610  videoModes->NumberRedBits = 6;
611  videoModes->NumberGreenBits = 6;
612  videoModes->NumberBlueBits = 6;
613  videoModes->RedMask = 0x1F << 11;
614  videoModes->GreenMask = 0x3F << 5;
615  videoModes->BlueMask = 0x1F;
616 
617  }
618 // eVb: 2.12 [VGA] - Add support for 15bpp modes, which Cirrus doesn't support
619  else if (VgaModeList[i].bitsPerPlane == 15)
620  {
621 
622  videoModes->NumberRedBits = 6;
623  videoModes->NumberGreenBits = 6;
624  videoModes->NumberBlueBits = 6;
625  videoModes->RedMask = 0x3E << 9;
626  videoModes->GreenMask = 0x1F << 5;
627  videoModes->BlueMask = 0x1F;
628  }
629 // eVb: 2.12 [END]
630  else
631  {
632 
633  videoModes->NumberRedBits = 6;
634  videoModes->NumberGreenBits = 6;
635  videoModes->NumberBlueBits = 6;
636  videoModes->RedMask = 0;
637  videoModes->GreenMask = 0;
638  videoModes->BlueMask = 0;
639  }
640 
641 // eVb: 2.13 [VGA] - All modes are palette managed/driven, unlike Cirrus
644 // eVb: 2.13 [END]
645  videoModes++;
646 
647  }
648 
649  return NO_ERROR;
650 
651 } // end VgaGetAvailableModes()
USHORT vres
Definition: vga.h:258
ULONG NumVideoModes
Definition: vgadata.c:433
#define VIDEO_MODE_MANAGED_PALETTE
Definition: ntddvdeo.h:296
ULONG Frequency
Definition: vga.h:260
USHORT numPlanes
Definition: vga.h:253
USHORT hres
Definition: vga.h:257
#define NO_ERROR
Definition: dderror.h:5
PVIDEOMODE VgaModeList
Definition: vgadata.c:434
USHORT bitsPerPlane
Definition: vga.h:254
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
USHORT fbType
Definition: vga.h:251
USHORT wbytes
Definition: vga.h:262
#define VIDEO_MODE_PALETTE_DRIVEN
Definition: ntddvdeo.h:295
unsigned int ULONG
Definition: retypes.h:1
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by VgaStartIO().

◆ VgaQueryCurrentMode()

VP_STATUS NTAPI VgaQueryCurrentMode ( PHW_DEVICE_EXTENSION  HwDeviceExtension,
PVIDEO_MODE_INFORMATION  ModeInformation,
ULONG  ModeInformationSize,
PULONG_PTR  OutputSize 
)

Definition at line 719 of file modeset.c.

754 {
755  //
756  // check if a mode has been set
757  //
758 
759  if (HwDeviceExtension->CurrentMode == NULL ) {
760 
761  return ERROR_INVALID_FUNCTION;
762 
763  }
764 
765  //
766  // Find out the size of the data to be put in the the buffer and return
767  // that in the status information (whether or not the information is
768  // there). If the buffer passed in is not large enough return an
769  // appropriate error code.
770  //
771 
772  if (ModeInformationSize < (*OutputSize = sizeof(VIDEO_MODE_INFORMATION))) {
773 
775 
776  }
777 
778  //
779  // Store the characteristics of the current mode into the buffer.
780  //
781 
782  ModeInformation->Length = sizeof(VIDEO_MODE_INFORMATION);
783  ModeInformation->ModeIndex = HwDeviceExtension->ModeIndex;
784  ModeInformation->VisScreenWidth = HwDeviceExtension->CurrentMode->hres;
785  ModeInformation->ScreenStride = HwDeviceExtension->CurrentMode->wbytes;
786  ModeInformation->VisScreenHeight = HwDeviceExtension->CurrentMode->vres;
787  ModeInformation->NumberOfPlanes = HwDeviceExtension->CurrentMode->numPlanes;
788  ModeInformation->BitsPerPlane = HwDeviceExtension->CurrentMode->bitsPerPlane;
789  ModeInformation->Frequency = HwDeviceExtension->CurrentMode->Frequency;
790  ModeInformation->XMillimeter = 320; // temporary hardcoded constant
791  ModeInformation->YMillimeter = 240; // temporary hardcoded constant
792 
793  ModeInformation->AttributeFlags = HwDeviceExtension->CurrentMode->fbType;
794 
795  if ((ModeInformation->BitsPerPlane == 32) ||
796  (ModeInformation->BitsPerPlane == 24))
797  {
798 
799  ModeInformation->NumberRedBits = 8;
800  ModeInformation->NumberGreenBits = 8;
801  ModeInformation->NumberBlueBits = 8;
802  ModeInformation->RedMask = 0xff0000;
803  ModeInformation->GreenMask = 0x00ff00;
804  ModeInformation->BlueMask = 0x0000ff;
805 
806  }
807  else if (ModeInformation->BitsPerPlane == 16)
808  {
809 
810  ModeInformation->NumberRedBits = 6;
811  ModeInformation->NumberGreenBits = 6;
812  ModeInformation->NumberBlueBits = 6;
813  ModeInformation->RedMask = 0x1F << 11;
814  ModeInformation->GreenMask = 0x3F << 5;
815  ModeInformation->BlueMask = 0x1F;
816 
817  }
818 // eVb: 2.12 [VGA] - Add support for 15bpp modes, which Cirrus doesn't support
819  else if (ModeInformation->BitsPerPlane == 15)
820  {
821 
822  ModeInformation->NumberRedBits = 6;
823  ModeInformation->NumberGreenBits = 6;
824  ModeInformation->NumberBlueBits = 6;
825  ModeInformation->RedMask = 0x3E << 9;
826  ModeInformation->GreenMask = 0x1F << 5;
827  ModeInformation->BlueMask = 0x1F;
828  }
829 // eVb: 2.12 [END]
830  else
831  {
832 
833  ModeInformation->NumberRedBits = 6;
834  ModeInformation->NumberGreenBits = 6;
835  ModeInformation->NumberBlueBits = 6;
836  ModeInformation->RedMask = 0;
837  ModeInformation->GreenMask = 0;
838  ModeInformation->BlueMask = 0;
839  }
840 
841 // eVb: 2.13 [VGA] - All modes are palette managed/driven, unlike Cirrus
842  ModeInformation->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN |
844 // eVb: 2.13 [END]
845 
846  return NO_ERROR;
847 
848 } // end VgaQueryCurrentMode()
USHORT vres
Definition: vga.h:258
#define VIDEO_MODE_MANAGED_PALETTE
Definition: ntddvdeo.h:296
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
ULONG Frequency
Definition: vga.h:260
USHORT numPlanes
Definition: vga.h:253
USHORT hres
Definition: vga.h:257
#define NO_ERROR
Definition: dderror.h:5
USHORT bitsPerPlane
Definition: vga.h:254
PVIDEOMODE CurrentMode
Definition: vga.h:403
USHORT fbType
Definition: vga.h:251
smooth NULL
Definition: ftsmooth.c:416
ULONG ModeIndex
Definition: vga.h:402
USHORT wbytes
Definition: vga.h:262
#define VIDEO_MODE_PALETTE_DRIVEN
Definition: ntddvdeo.h:295
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by VgaStartIO().

◆ VgaQueryNumberOfAvailableModes()

VP_STATUS NTAPI VgaQueryNumberOfAvailableModes ( PHW_DEVICE_EXTENSION  HwDeviceExtension,
PVIDEO_NUM_MODES  NumModes,
ULONG  NumModesSize,
PULONG_PTR  OutputSize 
)

Definition at line 655 of file modeset.c.

690 {
691  //
692  // Find out the size of the data to be put in the the buffer and return
693  // that in the status information (whether or not the information is
694  // there). If the buffer passed in is not large enough return an
695  // appropriate error code.
696  //
697 
698  if (NumModesSize < (*OutputSize = sizeof(VIDEO_NUM_MODES)) ) {
699 
701 
702  }
703 
704  //
705  // Store the number of modes into the buffer.
706  //
707 
708 // eVb: 2.14 [VBE] - We store VBE/VGA mode count in this global, not in DevExt like Cirrus
709  NumModes->NumModes = NumVideoModes;
710 // eVb: 2.14 [END]
711  NumModes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
712 
713  return NO_ERROR;
714 
715 } // end VgaGetNumberOfAvailableModes()
ULONG ModeInformationLength
Definition: ntddvdeo.h:328
ULONG NumVideoModes
Definition: vgadata.c:433
#define NO_ERROR
Definition: dderror.h:5
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by VgaStartIO().

◆ VgaSetMode()

VP_STATUS NTAPI VgaSetMode ( PHW_DEVICE_EXTENSION  HwDeviceExtension,
PVIDEO_MODE  Mode,
ULONG  ModeSize,
PULONG  PhysPtrChange 
)

Definition at line 361 of file modeset.c.

396 {
397  PVIDEOMODE pRequestedMode;
399  ULONG RequestedModeNum;
400 // eVb: 2.3 [SET MODE] - Add new output parameter for framebuffer update functionality
401  *PhysPtrChange = FALSE;
402 // eVb: 2.3 [END]
403  //
404  // Check if the size of the data in the input buffer is large enough.
405  //
406 
407  if (ModeSize < sizeof(VIDEO_MODE))
408  {
410  }
411 
412  //
413  // Extract the clear memory, and map linear bits.
414  //
415 
416  RequestedModeNum = Mode->RequestedMode &
418 
419 
420  if (!(Mode->RequestedMode & VIDEO_MODE_NO_ZERO_MEMORY))
421  {
422 #if defined(_X86_)
423  VgaZeroVideoMemory(HwDeviceExtension);
424 #endif
425  }
426 
427  //
428  // Check to see if we are requesting a valid mode
429  //
430 // eVb: 2.4 [CIRRUS] - Remove Cirrus-specific check for valid mode
431  if ( (RequestedModeNum >= NumVideoModes) )
432 // eVb: 2.4 [END]
433  {
434  VideoDebugPrint((0, "Invalide Mode Number = %d!\n", RequestedModeNum));
435 
437  }
438 
439  VideoDebugPrint((2, "Attempting to set mode %d\n",
440  RequestedModeNum));
441 // eVb: 2.5 [VBE] - Use dynamic VBE mode list instead of hard-coded VGA list
442  pRequestedMode = &VgaModeList[RequestedModeNum];
443 // eVb: 2.5 [END]
444  VideoDebugPrint((2, "Info on Requested Mode:\n"
445  "\tResolution: %dx%d\n",
446  pRequestedMode->hres,
447  pRequestedMode->vres ));
448 
449  //
450  // VESA BIOS mode switch
451  //
452 // eVb: 2.6 [VBE] - VBE Mode Switch Support
453  status = VbeSetMode(HwDeviceExtension, pRequestedMode, PhysPtrChange);
455  {
456  //
457  // VGA mode switch
458  //
459 
460  if (!pRequestedMode->CmdStream) return ERROR_INVALID_FUNCTION;
461  if (!VgaInterpretCmdStream(HwDeviceExtension, pRequestedMode->CmdStream)) return ERROR_INVALID_FUNCTION;
462  goto Cleanup;
463  }
464  else if (status != NO_ERROR) return status;
465 // eVb: 2.6 [END]
466 // eVb: 2.7 [MODE-X] - Windows VGA Miniport Supports Mode-X, we should too
467  //
468  // ModeX check
469  //
470 
471  if (pRequestedMode->hres == 320)
472  {
473  VideoDebugPrint((0, "ModeX not support!!!\n"));
475  }
476 // eVb: 2.7 [END]
477  //
478  // Text mode check
479  //
480 
481  if (!(pRequestedMode->fbType & VIDEO_MODE_GRAPHICS))
482  {
483 // eVb: 2.8 [TODO] - This code path is not implemented yet
484  VideoDebugPrint((0, "Text-mode not support!!!\n"));
486 // eVb: 2.8 [END]
487  }
488 
489 Cleanup:
490  //
491  // Update the location of the physical frame buffer within video memory.
492  //
493 // eVb: 2.9 [VBE] - Linear and banked support is unified in VGA, unlike Cirrus
494  HwDeviceExtension->PhysicalVideoMemoryBase.LowPart = pRequestedMode->PhysBase;
495  HwDeviceExtension->PhysicalVideoMemoryLength = pRequestedMode->PhysSize;
496 
497  HwDeviceExtension->PhysicalFrameLength =
498  pRequestedMode->FrameBufferSize;
499 
500  HwDeviceExtension->PhysicalFrameOffset.LowPart =
501  pRequestedMode->FrameBufferBase;
502 // eVb: 2.9 [END]
503 
504  //
505  // Store the new mode value.
506  //
507 
508  HwDeviceExtension->CurrentMode = pRequestedMode;
509  HwDeviceExtension->ModeIndex = Mode->RequestedMode;
510 
511  return NO_ERROR;
512 
513 } //end VgaSetMode()
ULONG PhysSize
Definition: vga.h:274
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
USHORT vres
Definition: vga.h:258
ULONG NumVideoModes
Definition: vgadata.c:433
_In_ ULONG Mode
Definition: hubbusif.h:303
PUSHORT CmdStream
Definition: vga.h:268
ULONG PhysicalFrameLength
Definition: vga.h:397
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
ULONG FrameBufferSize
Definition: vga.h:273
ULONG FrameBufferBase
Definition: vga.h:272
#define VIDEO_MODE_NO_ZERO_MEMORY
Definition: ntddvdeo.h:286
ULONG PhysicalVideoMemoryLength
Definition: vga.h:396
USHORT hres
Definition: vga.h:257
PHYSICAL_ADDRESS PhysicalVideoMemoryBase
Definition: vga.h:394
#define NO_ERROR
Definition: dderror.h:5
PVIDEOMODE VgaModeList
Definition: vgadata.c:434
Definition: vga.h:250
PVIDEOMODE CurrentMode
Definition: vga.h:403
USHORT fbType
Definition: vga.h:251
ULONG PhysBase
Definition: vga.h:271
#define VIDEO_MODE_MAP_MEM_LINEAR
Definition: ntddvdeo.h:285
VP_STATUS NTAPI VgaInterpretCmdStream(PHW_DEVICE_EXTENSION HwDeviceExtension, PUSHORT pusCmdStream)
Definition: modeset.c:74
ULONG ModeIndex
Definition: vga.h:402
ULONG LowPart
Definition: typedefs.h:104
static const WCHAR Cleanup[]
Definition: register.c:80
#define VideoDebugPrint(x)
Definition: video.h:75
VOID NTAPI VgaZeroVideoMemory(PHW_DEVICE_EXTENSION HwDeviceExtension)
Definition: modeset.c:852
PHYSICAL_ADDRESS PhysicalFrameOffset
Definition: vga.h:395
unsigned int ULONG
Definition: retypes.h:1
LONG VP_STATUS
Definition: video.h:153
static SERVICE_STATUS status
Definition: service.c:31
VP_STATUS NTAPI VbeSetMode(IN PHW_DEVICE_EXTENSION VgaDeviceExtension, IN PVIDEOMODE VgaMode, OUT PULONG PhysPtrChange)
Definition: vbemodes.c:88
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define VIDEO_MODE_GRAPHICS
Definition: ntddvdeo.h:294
Definition: ps.c:97

Referenced by VgaStartIO().

◆ VgaZeroVideoMemory()

VOID NTAPI VgaZeroVideoMemory ( PHW_DEVICE_EXTENSION  HwDeviceExtension)

Definition at line 852 of file modeset.c.

872 {
873  UCHAR temp;
874 
875  //
876  // Map font buffer at A0000
877  //
878 
879  VgaInterpretCmdStream(HwDeviceExtension, EnableA000Data);
880 
881  //
882  // Enable all planes.
883  //
884 
886  IND_MAP_MASK);
887 
888  temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
889  SEQ_DATA_PORT) | (UCHAR)0x0F;
890 
891  VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_DATA_PORT,
892  temp);
893 
894  VideoPortZeroDeviceMemory(HwDeviceExtension->VideoMemoryAddress, 0xFFFF);
895 
896  VgaInterpretCmdStream(HwDeviceExtension, DisableA000Color);
897 
898 }
PUCHAR IOAddress
Definition: vga.h:400
VPAPI VOID NTAPI VideoPortZeroDeviceMemory(IN PVOID Destination, IN ULONG Length)
VPAPI UCHAR NTAPI VideoPortReadPortUchar(IN PUCHAR Port)
#define IND_MAP_MASK
Definition: vga.h:116
#define SEQ_DATA_PORT
Definition: vga.h:70
VP_STATUS NTAPI VgaInterpretCmdStream(PHW_DEVICE_EXTENSION HwDeviceExtension, PUSHORT pusCmdStream)
Definition: modeset.c:74
USHORT EnableA000Data[]
Definition: vgadata.c:447
unsigned char UCHAR
Definition: xmlstorage.h:181
USHORT DisableA000Color[]
Definition: vgadata.c:473
#define SEQ_ADDRESS_PORT
Definition: vga.h:69
PUCHAR VideoMemoryAddress
Definition: vga.h:401
static calc_node_t temp
Definition: rpn_ieee.c:38
VPAPI VOID NTAPI VideoPortWritePortUchar(IN PUCHAR Port, IN UCHAR Value)

Referenced by VgaSetMode().