ReactOS  0.4.14-dev-583-g2a1ba2c
vbe.h File Reference
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for vbe.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _VBE_CONTROLLER_INFO
 
struct  _VBE_MODE_INFO
 
struct  _VBE_INFO
 
struct  _VBE_COLOR_REGISTER
 

Macros

#define LOWORD(l)   ((USHORT)((ULONG_PTR)(l)))
 
#define HIWORD(l)   ((USHORT)(((ULONG_PTR)(l)>>16)&0xFFFF))
 
#define VBE_GET_CONTROLLER_INFORMATION   0x4F00
 
#define VBE_GET_MODE_INFORMATION   0x4F01
 
#define VBE_SET_VBE_MODE   0x4F02
 
#define VBE_GET_CURRENT_VBE_MODE   0x4F03
 
#define VBE_SAVE_RESTORE_STATE   0x4F04
 
#define VBE_DISPLAY_WINDOW_CONTROL   0x4F05
 
#define VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH   0x4F06
 
#define VBE_SET_GET_DISPLAY_START   0x4F07
 
#define VBE_SET_GET_DAC_PALETTE_FORMAT   0x4F08
 
#define VBE_SET_GET_PALETTE_DATA   0x4F09
 
#define VBE_RETURN_PROTECTED_MODE_INTERFACE   0x4F0A
 
#define VBE_GET_SET_PIXEL_CLOCK   0x4F0B
 
#define VBE_POWER_MANAGEMENT_EXTENSIONS   0x4F10
 
#define VBE_FLAT_PANEL_INTERFACE_EXTENSIONS   0x4F11
 
#define VBE_AUDIO_INTERFACE_EXTENSIONS   0x4F12
 
#define VBE_OEM_EXTENSIONS   0x4F13
 
#define VBE_DISPLAY_DATA_CHANNEL   0x4F14
 
#define VBE_DDC   0x4F15
 
#define VBE_DDC_READ_EDID   0x01
 
#define VBE_DDC_REPORT_CAPABILITIES   0x10
 
#define VBE_DDC_BEGIN_SCL_SDA_CONTROL   0x11
 
#define VBE_DDC_END_SCL_SDA_CONTROL   0x12
 
#define VBE_DDC_WRITE_SCL_CLOCK_LINE   0x13
 
#define VBE_DDC_WRITE_SDA_DATA_LINE   0x14
 
#define VBE_DDC_READ_SCL_CLOCK_LINE   0x15
 
#define VBE_DDC_READ_SDA_DATA_LINE   0x16
 
#define VBE_MODEATTR_VALID   0x01
 
#define VBE_MODEATTR_COLOR   0x08
 
#define VBE_MODEATTR_GRAPHICS   0x10
 
#define VBE_MODEATTR_NON_VGA   0x20
 
#define VBE_MODEATTR_NO_BANK_SWITCH   0x40
 
#define VBE_MODEATTR_LINEAR   0x80
 
#define VBE_MODE_BITS   8
 
#define VBE_MODE_RESERVED_1   0x200
 
#define VBE_MODE_RESERVED_2   0x400
 
#define VBE_MODE_REFRESH_CONTROL   0x800
 
#define VBE_MODE_ACCELERATED_1   0x1000
 
#define VBE_MODE_ACCELERATED_2   0x2000
 
#define VBE_MODE_LINEAR_FRAMEBUFFER   0x4000
 
#define VBE_MODE_PRESERVE_DISPLAY   0x8000
 
#define VBE_MODE_MASK   ((1 << (VBE_MODE_BITS + 1)) - 1)
 
#define VBE_MEMORYMODEL_PACKEDPIXEL   0x04
 
#define VBE_MEMORYMODEL_DIRECTCOLOR   0x06
 
#define VBE_SUCCESS   0x4F
 
#define VBE_UNSUCCESSFUL   0x14F
 
#define VBE_NOT_SUPPORTED   0x24F
 
#define VBE_FUNCTION_INVALID   0x34F
 
#define VBE_GETRETURNCODE(x)   (x & 0xFFFF)
 
#define VBE2_MAGIC   ('V' + ('B' << 8) + ('E' << 16) + ('2' << 24))
 

Typedefs

typedef struct _VBE_CONTROLLER_INFO VBE_CONTROLLER_INFO
 
typedef struct _VBE_CONTROLLER_INFOPVBE_CONTROLLER_INFO
 
typedef struct _VBE_MODE_INFO VBE_MODE_INFO
 
typedef struct _VBE_MODE_INFOPVBE_MODE_INFO
 
typedef struct _VBE_INFO VBE_INFO
 
typedef struct _VBE_INFOPVBE_INFO
 
typedef struct _VBE_COLOR_REGISTER VBE_COLOR_REGISTER
 
typedef struct _VBE_COLOR_REGISTERPVBE_COLOR_REGISTER
 

Functions

 C_ASSERT (sizeof(VBE_CONTROLLER_INFO)==0x200)
 
 C_ASSERT (sizeof(VBE_MODE_INFO)==0x100)
 
VOID NTAPI InitializeModeTable (IN PHW_DEVICE_EXTENSION VgaExtension)
 
VP_STATUS NTAPI VbeSetMode (IN PHW_DEVICE_EXTENSION VgaDeviceExtension, IN PVIDEOMODE VgaMode, OUT PULONG PhysPtrChange)
 
VP_STATUS NTAPI VbeSetColorLookup (IN PHW_DEVICE_EXTENSION VgaExtension, IN PVIDEO_CLUT ClutBuffer)
 
BOOLEAN NTAPI ValidateVbeInfo (IN PHW_DEVICE_EXTENSION VgaExtension, IN PVBE_INFO VbeInfo)
 

Variables

BOOLEAN g_bIntelBrookdaleBIOS
 

Macro Definition Documentation

◆ HIWORD

#define HIWORD (   l)    ((USHORT)(((ULONG_PTR)(l)>>16)&0xFFFF))

Definition at line 12 of file vbe.h.

◆ LOWORD

#define LOWORD (   l)    ((USHORT)((ULONG_PTR)(l)))

Definition at line 11 of file vbe.h.

◆ VBE2_MAGIC

#define VBE2_MAGIC   ('V' + ('B' << 8) + ('E' << 16) + ('2' << 24))

Definition at line 219 of file vbe.h.

◆ VBE_AUDIO_INTERFACE_EXTENSIONS

#define VBE_AUDIO_INTERFACE_EXTENSIONS   0x4F12

Definition at line 37 of file vbe.h.

◆ VBE_DDC

#define VBE_DDC   0x4F15

Definition at line 40 of file vbe.h.

◆ VBE_DDC_BEGIN_SCL_SDA_CONTROL

#define VBE_DDC_BEGIN_SCL_SDA_CONTROL   0x11

Definition at line 48 of file vbe.h.

◆ VBE_DDC_END_SCL_SDA_CONTROL

#define VBE_DDC_END_SCL_SDA_CONTROL   0x12

Definition at line 49 of file vbe.h.

◆ VBE_DDC_READ_EDID

#define VBE_DDC_READ_EDID   0x01

Definition at line 46 of file vbe.h.

◆ VBE_DDC_READ_SCL_CLOCK_LINE

#define VBE_DDC_READ_SCL_CLOCK_LINE   0x15

Definition at line 52 of file vbe.h.

◆ VBE_DDC_READ_SDA_DATA_LINE

#define VBE_DDC_READ_SDA_DATA_LINE   0x16

Definition at line 53 of file vbe.h.

◆ VBE_DDC_REPORT_CAPABILITIES

#define VBE_DDC_REPORT_CAPABILITIES   0x10

Definition at line 47 of file vbe.h.

◆ VBE_DDC_WRITE_SCL_CLOCK_LINE

#define VBE_DDC_WRITE_SCL_CLOCK_LINE   0x13

Definition at line 50 of file vbe.h.

◆ VBE_DDC_WRITE_SDA_DATA_LINE

#define VBE_DDC_WRITE_SDA_DATA_LINE   0x14

Definition at line 51 of file vbe.h.

◆ VBE_DISPLAY_DATA_CHANNEL

#define VBE_DISPLAY_DATA_CHANNEL   0x4F14

Definition at line 39 of file vbe.h.

◆ VBE_DISPLAY_WINDOW_CONTROL

#define VBE_DISPLAY_WINDOW_CONTROL   0x4F05

Definition at line 24 of file vbe.h.

◆ VBE_FLAT_PANEL_INTERFACE_EXTENSIONS

#define VBE_FLAT_PANEL_INTERFACE_EXTENSIONS   0x4F11

Definition at line 36 of file vbe.h.

◆ VBE_FUNCTION_INVALID

#define VBE_FUNCTION_INVALID   0x34F

Definition at line 85 of file vbe.h.

◆ VBE_GET_CONTROLLER_INFORMATION

#define VBE_GET_CONTROLLER_INFORMATION   0x4F00

Definition at line 19 of file vbe.h.

◆ VBE_GET_CURRENT_VBE_MODE

#define VBE_GET_CURRENT_VBE_MODE   0x4F03

Definition at line 22 of file vbe.h.

◆ VBE_GET_MODE_INFORMATION

#define VBE_GET_MODE_INFORMATION   0x4F01

Definition at line 20 of file vbe.h.

◆ VBE_GET_SET_PIXEL_CLOCK

#define VBE_GET_SET_PIXEL_CLOCK   0x4F0B

Definition at line 32 of file vbe.h.

◆ VBE_GETRETURNCODE

#define VBE_GETRETURNCODE (   x)    (x & 0xFFFF)

Definition at line 87 of file vbe.h.

◆ VBE_MEMORYMODEL_DIRECTCOLOR

#define VBE_MEMORYMODEL_DIRECTCOLOR   0x06

Definition at line 76 of file vbe.h.

◆ VBE_MEMORYMODEL_PACKEDPIXEL

#define VBE_MEMORYMODEL_PACKEDPIXEL   0x04

Definition at line 75 of file vbe.h.

◆ VBE_MODE_ACCELERATED_1

#define VBE_MODE_ACCELERATED_1   0x1000

Definition at line 69 of file vbe.h.

◆ VBE_MODE_ACCELERATED_2

#define VBE_MODE_ACCELERATED_2   0x2000

Definition at line 70 of file vbe.h.

◆ VBE_MODE_BITS

#define VBE_MODE_BITS   8

Definition at line 65 of file vbe.h.

◆ VBE_MODE_LINEAR_FRAMEBUFFER

#define VBE_MODE_LINEAR_FRAMEBUFFER   0x4000

Definition at line 71 of file vbe.h.

◆ VBE_MODE_MASK

#define VBE_MODE_MASK   ((1 << (VBE_MODE_BITS + 1)) - 1)

Definition at line 73 of file vbe.h.

◆ VBE_MODE_PRESERVE_DISPLAY

#define VBE_MODE_PRESERVE_DISPLAY   0x8000

Definition at line 72 of file vbe.h.

◆ VBE_MODE_REFRESH_CONTROL

#define VBE_MODE_REFRESH_CONTROL   0x800

Definition at line 68 of file vbe.h.

◆ VBE_MODE_RESERVED_1

#define VBE_MODE_RESERVED_1   0x200

Definition at line 66 of file vbe.h.

◆ VBE_MODE_RESERVED_2

#define VBE_MODE_RESERVED_2   0x400

Definition at line 67 of file vbe.h.

◆ VBE_MODEATTR_COLOR

#define VBE_MODEATTR_COLOR   0x08

Definition at line 59 of file vbe.h.

◆ VBE_MODEATTR_GRAPHICS

#define VBE_MODEATTR_GRAPHICS   0x10

Definition at line 60 of file vbe.h.

◆ VBE_MODEATTR_LINEAR

#define VBE_MODEATTR_LINEAR   0x80

Definition at line 63 of file vbe.h.

◆ VBE_MODEATTR_NO_BANK_SWITCH

#define VBE_MODEATTR_NO_BANK_SWITCH   0x40

Definition at line 62 of file vbe.h.

◆ VBE_MODEATTR_NON_VGA

#define VBE_MODEATTR_NON_VGA   0x20

Definition at line 61 of file vbe.h.

◆ VBE_MODEATTR_VALID

#define VBE_MODEATTR_VALID   0x01

Definition at line 58 of file vbe.h.

◆ VBE_NOT_SUPPORTED

#define VBE_NOT_SUPPORTED   0x24F

Definition at line 84 of file vbe.h.

◆ VBE_OEM_EXTENSIONS

#define VBE_OEM_EXTENSIONS   0x4F13

Definition at line 38 of file vbe.h.

◆ VBE_POWER_MANAGEMENT_EXTENSIONS

#define VBE_POWER_MANAGEMENT_EXTENSIONS   0x4F10

Definition at line 35 of file vbe.h.

◆ VBE_RETURN_PROTECTED_MODE_INTERFACE

#define VBE_RETURN_PROTECTED_MODE_INTERFACE   0x4F0A

Definition at line 31 of file vbe.h.

◆ VBE_SAVE_RESTORE_STATE

#define VBE_SAVE_RESTORE_STATE   0x4F04

Definition at line 23 of file vbe.h.

◆ VBE_SET_GET_DAC_PALETTE_FORMAT

#define VBE_SET_GET_DAC_PALETTE_FORMAT   0x4F08

Definition at line 27 of file vbe.h.

◆ VBE_SET_GET_DISPLAY_START

#define VBE_SET_GET_DISPLAY_START   0x4F07

Definition at line 26 of file vbe.h.

◆ VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH

#define VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH   0x4F06

Definition at line 25 of file vbe.h.

◆ VBE_SET_GET_PALETTE_DATA

#define VBE_SET_GET_PALETTE_DATA   0x4F09

Definition at line 28 of file vbe.h.

◆ VBE_SET_VBE_MODE

#define VBE_SET_VBE_MODE   0x4F02

Definition at line 21 of file vbe.h.

◆ VBE_SUCCESS

#define VBE_SUCCESS   0x4F

Definition at line 82 of file vbe.h.

◆ VBE_UNSUCCESSFUL

#define VBE_UNSUCCESSFUL   0x14F

Definition at line 83 of file vbe.h.

Typedef Documentation

◆ PVBE_COLOR_REGISTER

◆ PVBE_CONTROLLER_INFO

◆ PVBE_INFO

◆ PVBE_MODE_INFO

◆ VBE_COLOR_REGISTER

◆ VBE_CONTROLLER_INFO

◆ VBE_INFO

◆ VBE_MODE_INFO

Function Documentation

◆ C_ASSERT() [1/2]

C_ASSERT ( sizeof(VBE_CONTROLLER_INFO = =0x200)

◆ C_ASSERT() [2/2]

C_ASSERT ( sizeof(VBE_MODE_INFO = =0x100)

◆ InitializeModeTable()

VOID NTAPI InitializeModeTable ( IN PHW_DEVICE_EXTENSION  VgaExtension)

Definition at line 159 of file vbemodes.c.

160 {
161  ULONG ModeCount = 0;
162  ULONG Length = 4 * 1024;
163  ULONG TotalMemory;
165  INT10_BIOS_ARGUMENTS BiosArguments;
166  PVBE_INFO VbeInfo;
167  PVBE_MODE_INFO VbeModeInfo;
168  PVOID Context;
169  USHORT TrampolineMemorySegment;
170  USHORT TrampolineMemoryOffset;
171  ULONG VbeVersion;
172  ULONG NewModes = 0;
173  BOOLEAN FourBppModeFound = FALSE;
174  USHORT ModeResult;
175  USHORT Mode;
176  PUSHORT ThisMode;
177  BOOLEAN LinearAddressing;
178  ULONG Size, ScreenSize;
181  ULONG ScreenStride;
183 
184  /* Enable only default vga modes if no vesa */
186  if (VideoPortIsNoVesa())
187  {
188  VgaExtension->Int10Interface.Size = 0;
189  VgaExtension->Int10Interface.Version = 0;
190  return;
191  }
192 
193  /* Query INT10 interface */
194  VgaExtension->Int10Interface.Version = VIDEO_PORT_INT10_INTERFACE_VERSION_1;
195  VgaExtension->Int10Interface.Size = sizeof(VIDEO_PORT_INT10_INTERFACE);
196  if (VideoPortQueryServices(VgaExtension,
198  (PINTERFACE)&VgaExtension->Int10Interface))
199  {
200  VgaExtension->Int10Interface.Size = 0;
201  VgaExtension->Int10Interface.Version = 0;
202  }
203 
204  /* Add ref */
205  VideoDebugPrint((0, "have int10 iface\n"));
206  VgaExtension->Int10Interface.InterfaceReference(VgaExtension->Int10Interface.Context);
207  Context = VgaExtension->Int10Interface.Context;
208 
209  /* Allocate scratch area and context */
210  Status = VgaExtension->Int10Interface.Int10AllocateBuffer(Context,
211  &TrampolineMemorySegment,
212  &TrampolineMemoryOffset,
213  &Length);
214  if (Status != NO_ERROR) return;
215  VbeInfo = VideoPortAllocatePool(VgaExtension, 1, sizeof(VBE_INFO), ' agV');
216  if (!VbeInfo) return;
217 
218  VbeModeInfo = &VbeInfo->Modes;
219 
220  /* Init VBE data and write to card buffer */
221  VideoDebugPrint((0, "have int10 data\n"));
222  VbeInfo->ModeArray[128] = 0xFFFF;
223  VbeInfo->Info.Signature = VBE2_MAGIC;
224  Status = VgaExtension->Int10Interface.Int10WriteMemory(Context,
225  TrampolineMemorySegment,
226  TrampolineMemoryOffset,
227  &VbeInfo->Info.Signature,
228  4);
229  if (Status != NO_ERROR) return;
230 
231  /* Get controller info */
232  VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
233  BiosArguments.Edi = TrampolineMemoryOffset;
234  BiosArguments.SegEs = TrampolineMemorySegment;
235  BiosArguments.Eax = VBE_GET_CONTROLLER_INFORMATION;
236  Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments);
237  if (Status != NO_ERROR) return;
238  if(VBE_GETRETURNCODE(BiosArguments.Eax) != VBE_SUCCESS)
239  {
240  VideoDebugPrint((0, "BiosArguments.Eax %lx\n", BiosArguments.Eax));
241  return;
242  }
243  Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
244  TrampolineMemorySegment,
245  TrampolineMemoryOffset,
246  VbeInfo,
247  512);
248  if (Status != NO_ERROR) return;
249 
250  /* Check correct VBE BIOS */
251  VideoDebugPrint((0, "have vbe data\n"));
252  TotalMemory = VbeInfo->Info.TotalMemory << 16;
253  VbeVersion = VbeInfo->Info.Version;
254  VideoDebugPrint((0, "vbe version %lx memory %lx\n", VbeVersion, TotalMemory));
255  if (!ValidateVbeInfo(VgaExtension, VbeInfo)) return;
256 
257  /* Read modes */
258  VideoDebugPrint((0, "read modes from %p\n", VbeInfo->Info.VideoModePtr));
259  Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
260  HIWORD(VbeInfo->Info.VideoModePtr),
261  LOWORD(VbeInfo->Info.VideoModePtr),
262  VbeInfo->ModeArray,
263  128 * sizeof(USHORT));
264  if (Status != NO_ERROR) return;
265  VideoDebugPrint((0, "Read modes at: %p\n", VbeInfo->ModeArray));
266 
267  /* Count modes, check for new 4bpp SVGA modes */
268  ThisMode = VbeInfo->ModeArray;
269  ModeResult = VbeInfo->ModeArray[0];
270  while (ModeResult != 0xFFFF)
271  {
272  Mode = ModeResult & 0x1FF;
273  VideoDebugPrint((0, "Mode found: %lx\n", Mode));
274  if ((Mode == 0x102) || (Mode == 0x6A)) FourBppModeFound = TRUE;
275  ModeResult = *++ThisMode;
276  NewModes++;
277  }
278 
279  /* Remove the built-in mode if not supported by card and check max modes */
280  if (!FourBppModeFound) --NumVideoModes;
281  if ((NewModes >= 128) && (NumVideoModes > 8)) goto Cleanup;
282 
283  /* Switch to new SVGA mode list, copy VGA modes */
284  VgaModeList = VideoPortAllocatePool(VgaExtension, 1, (NewModes + NumVideoModes) * sizeof(VIDEOMODE), ' agV');
285  if (!VgaModeList) goto Cleanup;
287 
288  /* Apply fixup for Intel Brookdale */
290  {
291  VideoDebugPrint((0, "Intel Brookdale-G Video BIOS Not Support!\n"));
292  while (TRUE);
293  }
294 
295  /* Scan SVGA modes */
296  VideoDebugPrint((0, "Static modes: %d\n", NumVideoModes));
298  ThisMode = VbeInfo->ModeArray;
299  VideoDebugPrint((0, "new modes: %d\n", NewModes));
300  while (NewModes--)
301  {
302  /* Get info on mode */
303  VideoDebugPrint((0, "Getting info of mode %lx.\n", *ThisMode));
304  VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
305  BiosArguments.Eax = VBE_GET_MODE_INFORMATION;
306  BiosArguments.Ecx = *ThisMode;
307  BiosArguments.Edi = TrampolineMemoryOffset;
308  BiosArguments.SegEs = TrampolineMemorySegment;
309  Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments);
310  if (Status != NO_ERROR) goto Next;
311  if (VBE_GETRETURNCODE(BiosArguments.Eax) != VBE_SUCCESS) goto Next;
312  Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
313  TrampolineMemorySegment,
314  TrampolineMemoryOffset,
315  VbeModeInfo,
316  256);
317  if (Status != NO_ERROR) goto Next;
318 
319  /* Parse graphics modes only if linear framebuffer support */
320  VideoDebugPrint((0, "attr: %lx\n", VbeModeInfo->ModeAttributes));
321  if (!(VbeModeInfo->ModeAttributes & (VBE_MODEATTR_VALID |
322  VBE_MODEATTR_GRAPHICS))) goto Next;
323  LinearAddressing = ((VbeVersion >= 0x200) &&
324  (VbeModeInfo->PhysBasePtr) &&
325  (VbeModeInfo->ModeAttributes & VBE_MODEATTR_LINEAR)) ?
326  TRUE : FALSE;
327 
328  /* Check SVGA modes if 8bpp or higher */
329  VideoDebugPrint((0, "PhysBase: %lx\n", VbeModeInfo->PhysBasePtr));
330  if ((VbeModeInfo->XResolution >= 640) &&
331  (VbeModeInfo->YResolution >= 480) &&
332  (VbeModeInfo->NumberOfPlanes >= 1) &&
333  (VbeModeInfo->BitsPerPixel >= 8))
334  {
335  /* Copy VGA mode info */
337  VgaMode->numPlanes = VbeModeInfo->NumberOfPlanes;
338  VgaMode->hres = VbeModeInfo->XResolution;
339  VgaMode->vres = VbeModeInfo->YResolution;
340  VgaMode->Frequency = 1;
341  VgaMode->Mode = (*ThisMode << 16) | VBE_SET_VBE_MODE;
342  VgaMode->Granularity = VbeModeInfo->WinGranularity << 10;
343  VideoDebugPrint((0, "Mode %lx (Granularity %d)\n", VgaMode->Mode, VgaMode->Granularity));
344 
345  /* Set flags */
346  if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_COLOR) VgaMode->fbType |= VIDEO_MODE_COLOR;
347  if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_GRAPHICS) VgaMode->fbType |= VIDEO_MODE_GRAPHICS;
348  if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_NON_VGA) VgaMode->NonVgaMode = TRUE;
349 
350  /* If no char data, say 80x25 */
351  VgaMode->col = VbeModeInfo->XCharSize ? VbeModeInfo->XResolution / VbeModeInfo->XCharSize : 80;
352  VgaMode->row = VbeModeInfo->YCharSize ? VbeModeInfo->YResolution / VbeModeInfo->YCharSize : 25;
353  VideoDebugPrint((0, "%d by %d rows\n", VgaMode->col, VgaMode->row));
354 
355  /* Check RGB555 (15bpp only) */
356  VgaMode->bitsPerPlane = VbeModeInfo->BitsPerPixel / VbeModeInfo->NumberOfPlanes;
357  if ((VgaMode->bitsPerPlane == 16) && (VbeModeInfo->GreenMaskSize == 5)) VgaMode->bitsPerPlane = 15;
358  VideoDebugPrint((0, "BPP: %d\n", VgaMode->bitsPerPlane));
359 
360  /* Do linear or banked frame buffers */
361  VgaMode->FrameBufferBase = 0;
362  if (!LinearAddressing)
363  {
364  /* Read the screen stride (scanline size) */
365  ScreenStride = RaiseToPower2(VbeModeInfo->BytesPerScanLine);
366  //ASSERT(ScreenStride <= MAX_USHORT);
367  VgaMode->wbytes = (USHORT)ScreenStride;
368  VideoDebugPrint((0, "ScanLines: %lx Stride: %lx\n", VbeModeInfo->BytesPerScanLine, VgaMode->wbytes));
369 
370  /* Size of frame buffer is Height X ScanLine, align to bank/page size */
371  ScreenSize = VgaMode->hres * ScreenStride;
372  VideoDebugPrint((0, "Size: %lx\n", ScreenSize));
373  Size = (ScreenSize + ((64 * 1024) - 1)) & ((64 * 1024) - 1);
374  VideoDebugPrint((0, "Size: %lx\n", ScreenSize));
375  if (Size > TotalMemory) Size = (Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1);
376  VideoDebugPrint((0, "Size: %lx\n", ScreenSize));
377 
378  /* Banked VGA at 0xA0000 (64K) */
379  VideoDebugPrint((0, "Final size: %lx\n", Size));
380  VgaMode->fbType |= VIDEO_MODE_BANKED;
381  VgaMode->sbytes = Size;
382  VgaMode->PhysSize = 64 * 1024;
383  VgaMode->FrameBufferSize = 64 * 1024;
384  VgaMode->NoBankSwitch = TRUE;
385  VgaMode->PhysBase = 0xA0000;
386  VgaMode->LogicalWidth = RaiseToPower2(VgaMode->hres);
387  }
388  else
389  {
390  /* VBE 3.00+ has specific field, read legacy field if not */
391  VideoDebugPrint((0, "LINEAR MODE!!!\n"));
392  ScreenStride = (VbeVersion >= 0x300) ? VbeModeInfo->LinBytesPerScanLine : 0;
393  if (!ScreenStride) ScreenStride = VbeModeInfo->BytesPerScanLine;
394  //ASSERT(ScreenStride <= MAX_USHORT);
395  VgaMode->wbytes = (USHORT)ScreenStride;
396  VideoDebugPrint((0, "ScanLines: %lx Stride: %lx\n", VbeModeInfo->BytesPerScanLine, VgaMode->wbytes));
397 
398  /* Size of frame buffer is Height X ScanLine, align to page size */
399  ScreenSize = VgaMode->hres * LOWORD(VgaMode->wbytes);
400  VideoDebugPrint((0, "Size: %lx\n", ScreenSize));
401  Size = RaiseToPower2Ulong(ScreenSize);
402  VideoDebugPrint((0, "Size: %lx\n", ScreenSize));
403  if (Size > TotalMemory) Size = (Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1);
404  VideoDebugPrint((0, "Size: %lx\n", ScreenSize));
405 
406  /* Linear VGA must read settings from VBE */
407  VgaMode->fbType |= VIDEO_MODE_LINEAR;
408  VgaMode->sbytes = Size;
409  VgaMode->PhysSize = Size;
410  VgaMode->FrameBufferSize = Size;
411  VgaMode->NoBankSwitch = FALSE;
412  VgaMode->PhysBase = VbeModeInfo->PhysBasePtr;
413  VgaMode->LogicalWidth = VgaMode->hres;
414 
415  /* Make VBE_SET_VBE_MODE command use Linear Framebuffer Select */
416  VgaMode->Mode |= (VBE_MODE_LINEAR_FRAMEBUFFER << 16);
417  }
418 
419  /* Override bank switch if not support by card */
420  if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_NO_BANK_SWITCH) VgaMode->NoBankSwitch = TRUE;
421 
422  /* Next */
423  if (ScreenSize <= TotalMemory)
424  {
425  VgaMode++;
426  ModeCount++;
427  }
428  }
429 Next:
430  /* Next */
431  ThisMode++;
432  }
433 
434  /* Check if last mode was color to do test */
435  VideoDebugPrint((0, "mode scan complete. Total modes: %d\n", ModeCount));
436  if (--VgaMode->fbType & VIDEO_MODE_COLOR)
437  {
438  /* Try map physical buffer and free if worked */
439  PhysicalAddress.QuadPart = VgaMode->PhysBase;
440  BaseAddress = VideoPortGetDeviceBase(VgaExtension, PhysicalAddress, 4 * 1024, FALSE);
441  if (BaseAddress)
442  {
443  VideoPortFreeDeviceBase(VgaExtension, BaseAddress);
444  }
445  else
446  {
447  /* Not work, so throw out VBE data */
448  ModeCount = 0;
449  }
450  }
451 
452  /* Cleanup sucess path */
453  VideoPortFreePool(VgaExtension, VbeInfo);
454  VgaExtension->Int10Interface.Int10FreeBuffer(Context,
455  TrampolineMemorySegment,
456  TrampolineMemoryOffset);
457  NumVideoModes += ModeCount;
458  return;
459 
460 Cleanup:
461  /* Cleanup failure path, reset standard VGA and free memory */
463  VideoPortFreePool(VgaExtension, VbeInfo);
464  VgaExtension->Int10Interface.Int10FreeBuffer(Context,
465  TrampolineMemorySegment,
466  TrampolineMemoryOffset);
467 }
ULONG PhysBasePtr
Definition: vbe.h:155
#define VIDEO_PORT_INT10_INTERFACE_VERSION_1
Definition: video.h:127
VPAPI VP_STATUS NTAPI VideoPortQueryServices(IN PVOID HwDeviceExtension, IN VIDEO_PORT_SERVICES ServicesType, IN OUT PINTERFACE Interface)
Definition: services.c:40
USHORT Version
Definition: vbemp.h:110
#define TRUE
Definition: types.h:120
ULONG NumVideoModes
Definition: vgadata.c:433
_In_ ULONG Mode
Definition: hubbusif.h:303
#define VBE2_MAGIC
Definition: vbe.h:219
BYTE GreenMaskSize
Definition: vbe.h:82
USHORT ModeAttributes
Definition: vbe.h:120
#define VBE_MODEATTR_NON_VGA
Definition: vbe.h:61
#define VBE_GETRETURNCODE(x)
Definition: vbemp.h:100
UCHAR XCharSize
Definition: vbe.h:133
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
PVIDEOMODE VgaModeList
Definition: vgadata.c:434
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
Definition: vga.h:250
#define VBE_GET_MODE_INFORMATION
Definition: vbemp.h:47
#define VBE_MODEATTR_NO_BANK_SWITCH
Definition: vbe.h:62
VIDEOMODE ModesVGA[]
Definition: vgadata.c:281
#define VBE_SUCCESS
Definition: vbemp.h:95
VPAPI PVOID NTAPI VideoPortAllocatePool(IN PVOID HwDeviceExtension, IN VP_POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: resource.c:913
ULONG NTAPI RaiseToPower2Ulong(IN ULONG Value)
Definition: vbemodes.c:17
unsigned char BOOLEAN
#define VBE_MODEATTR_COLOR
Definition: vbe.h:59
BOOLEAN NTAPI ValidateVbeInfo(IN PHW_DEVICE_EXTENSION VgaExtension, IN PVBE_INFO VbeInfo)
Definition: vbe.c:78
VPAPI VOID NTAPI VideoPortFreePool(IN PVOID HwDeviceExtension, IN PVOID Ptr)
Definition: resource.c:928
#define VBE_MODEATTR_GRAPHICS
Definition: vbe.h:60
#define VBE_GET_CONTROLLER_INFORMATION
Definition: vbemp.h:46
USHORT WinGranularity
Definition: vbe.h:123
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
BOOLEAN g_bIntelBrookdaleBIOS
Definition: vbe.c:31
if(!(yy_init))
Definition: macro.lex.yy.c:714
USHORT LinBytesPerScanLine
Definition: vbe.h:160
BYTE BitsPerPixel
Definition: vbe.h:74
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define VIDEO_MODE_BANKED
Definition: ntddvdeo.h:300
#define VBE_MODE_LINEAR_FRAMEBUFFER
Definition: vbe.h:71
USHORT BytesPerScanLine
Definition: vbe.h:128
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1061
#define VBE_SET_VBE_MODE
Definition: vbemp.h:48
struct _VIDEO_PORT_INT10_INTERFACE VIDEO_PORT_INT10_INTERFACE
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
static const WCHAR Cleanup[]
Definition: register.c:80
USHORT XResolution
Definition: vbe.h:131
Status
Definition: gdiplustypes.h:24
#define VBE_MODEATTR_LINEAR
Definition: vbemp.h:86
VPAPI BOOLEAN NTAPI VideoPortIsNoVesa(VOID)
Definition: videoprt.c:1406
VPAPI VOID NTAPI VideoPortMoveMemory(IN PVOID Destination, IN PVOID Source, IN ULONG Length)
#define VideoDebugPrint(x)
Definition: video.h:75
#define VIDEO_MODE_LINEAR
Definition: ntddvdeo.h:301
unsigned short USHORT
Definition: pedump.c:61
#define VIDEO_MODE_COLOR
Definition: ntddvdeo.h:293
VPAPI VOID NTAPI VideoPortFreeDeviceBase(IN PVOID HwDeviceExtension, IN PVOID MappedAddress)
Definition: resource.c:471
ULONG VideoModePtr
Definition: vbemp.h:113
USHORT TotalMemory
Definition: vbemp.h:114
static BOOLEAN VgaMode
Definition: options.c:87
UCHAR YCharSize
Definition: vbe.h:134
struct tagContext Context
Definition: acpixf.h:1030
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
LONG VP_STATUS
Definition: video.h:153
UCHAR NumberOfPlanes
Definition: vbe.h:135
ULONG NTAPI RaiseToPower2(IN USHORT Value)
Definition: vbemodes.c:26
#define LOWORD(l)
Definition: pedump.c:82
unsigned short * PUSHORT
Definition: retypes.h:2
#define VBE_MODEATTR_VALID
Definition: vbe.h:58
LONGLONG QuadPart
Definition: typedefs.h:112
CHAR Signature[4]
Definition: vbemp.h:109
USHORT YResolution
Definition: vbe.h:132
#define VIDEO_MODE_GRAPHICS
Definition: ntddvdeo.h:294

Referenced by VgaInitialize().

◆ ValidateVbeInfo()

BOOLEAN NTAPI ValidateVbeInfo ( IN PHW_DEVICE_EXTENSION  VgaExtension,
IN PVBE_INFO  VbeInfo 
)

Definition at line 78 of file vbe.c.

80 {
81  BOOLEAN VesaBiosOk;
82  PVOID Context;
83  CHAR ProductRevision[80];
84  CHAR OemString[80];
85  CHAR ProductName[80];
86  CHAR VendorName[80];
88 
89  /* Set default */
90  VesaBiosOk = FALSE;
91  Context = VgaExtension->Int10Interface.Context;
92 
93  /* Check magic and version */
94  if (VbeInfo->Info.Signature != VESA_MAGIC) return VesaBiosOk;
95  if (VbeInfo->Info.Version < 0x102) return VesaBiosOk;
96 
97  /* Read strings */
98  Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
99  HIWORD(VbeInfo->Info.OemStringPtr),
100  LOWORD(VbeInfo->Info.OemStringPtr),
101  OemString,
102  sizeof(OemString));
103  if (Status != NO_ERROR) return VesaBiosOk;
104  Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
105  HIWORD(VbeInfo->Info.OemVendorNamePtr),
106  LOWORD(VbeInfo->Info.OemVendorNamePtr),
107  VendorName,
108  sizeof(VendorName));
109  if (Status != NO_ERROR) return VesaBiosOk;
110  Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
111  HIWORD(VbeInfo->Info.OemProductNamePtr),
112  LOWORD(VbeInfo->Info.OemProductNamePtr),
113  ProductName,
114  sizeof(ProductName));
115  if (Status != NO_ERROR) return VesaBiosOk;
116  Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
117  HIWORD(VbeInfo->Info.OemProductRevPtr),
118  LOWORD(VbeInfo->Info.OemProductRevPtr),
119  ProductRevision,
120  sizeof(ProductRevision));
121  if (Status != NO_ERROR) return VesaBiosOk;
122 
123  /* Null-terminate strings */
124  VendorName[sizeof(OemString) - 1] = ANSI_NULL;
125  ProductName[sizeof(OemString) - 1] = ANSI_NULL;
126  ProductRevision[sizeof(OemString) - 1] = ANSI_NULL;
127  OemString[sizeof(OemString) - 1] = ANSI_NULL;
128 
129  /* Check for known bad BIOS */
130  VesaBiosOk = IsVesaBiosOk(&VgaExtension->Int10Interface,
131  VbeInfo->Info.OemSoftwareRevision,
132  VendorName,
133  ProductName,
134  ProductRevision);
135  VgaExtension->VesaBiosOk = VesaBiosOk;
136  return VesaBiosOk;
137 }
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1561
char CHAR
Definition: xmlstorage.h:175
#define NO_ERROR
Definition: dderror.h:5
#define ANSI_NULL
unsigned char BOOLEAN
BOOLEAN NTAPI IsVesaBiosOk(IN PVIDEO_PORT_INT10_INTERFACE Interface, IN ULONG OemRevision, IN PCHAR Vendor, IN PCHAR Product, IN PCHAR Revision)
Definition: vbe.c:37
Status
Definition: gdiplustypes.h:24
struct tagContext Context
Definition: acpixf.h:1030
#define HIWORD(l)
Definition: typedefs.h:246
LONG VP_STATUS
Definition: video.h:153
#define VESA_MAGIC
Definition: vga.h:448
#define LOWORD(l)
Definition: pedump.c:82

Referenced by InitializeModeTable().

◆ VbeSetColorLookup()

VP_STATUS NTAPI VbeSetColorLookup ( IN PHW_DEVICE_EXTENSION  VgaExtension,
IN PVIDEO_CLUT  ClutBuffer 
)

Definition at line 141 of file vbe.c.

143 {
144  PVBE_COLOR_REGISTER VesaClut;
145  INT10_BIOS_ARGUMENTS BiosArguments;
146  PVOID Context;
147  ULONG Entries;
148  ULONG BufferSize = 4 * 1024;
149  USHORT TrampolineMemorySegment, TrampolineMemoryOffset;
151  USHORT i;
152  PVIDEOMODE CurrentMode = VgaExtension->CurrentMode;
153 
154  Entries = ClutBuffer->NumEntries;
155 
156  VideoDebugPrint((0, "Setting %lu entries.\n", Entries));
157 
158  /*
159  * For Vga compatible modes, write them directly.
160  * Otherwise, the LGPL VGABIOS (used in bochs) fails!
161  * It is also said that this way is faster.
162  */
163  if(!CurrentMode->NonVgaMode)
164  {
165  for (i=ClutBuffer->FirstEntry; i<ClutBuffer->FirstEntry + Entries; i++)
166  {
167  VideoPortWritePortUchar((PUCHAR)0x03c8, i);
168  VideoPortWritePortUchar((PUCHAR)0x03c9, ClutBuffer->LookupTable[i].RgbArray.Red);
169  VideoPortWritePortUchar((PUCHAR)0x03c9, ClutBuffer->LookupTable[i].RgbArray.Green);
170  VideoPortWritePortUchar((PUCHAR)0x03c9, ClutBuffer->LookupTable[i].RgbArray.Blue);
171  }
172  return NO_ERROR;
173  }
174 
175  /* Allocate INT10 context/buffer */
176  VesaClut = VideoPortAllocatePool(VgaExtension, 1, sizeof(ULONG) * Entries, ' agV');
177  if (!VesaClut) return ERROR_INVALID_PARAMETER;
178  if (!VgaExtension->Int10Interface.Size) return ERROR_INVALID_PARAMETER;
179  Context = VgaExtension->Int10Interface.Context;
180  Status = VgaExtension->Int10Interface.Int10AllocateBuffer(Context,
181  &TrampolineMemorySegment,
182  &TrampolineMemoryOffset,
183  &BufferSize);
184  if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER;
185 
186  /* VESA has color registers backward! */
187  for (i = 0; i < Entries; i++)
188  {
189  VesaClut[i].Blue = ClutBuffer->LookupTable[i].RgbArray.Blue;
190  VesaClut[i].Green = ClutBuffer->LookupTable[i].RgbArray.Green;
191  VesaClut[i].Red = ClutBuffer->LookupTable[i].RgbArray.Red;
192  VesaClut[i].Pad = 0;
193  }
194  Status = VgaExtension->Int10Interface.Int10WriteMemory(Context,
195  TrampolineMemorySegment,
196  TrampolineMemoryOffset,
197  VesaClut,
198  Entries * sizeof(ULONG));
199  if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER;
200 
201  /* Write the palette */
202  VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
203  BiosArguments.Ebx = 0;
204  BiosArguments.Ecx = Entries;
205  BiosArguments.Edx = ClutBuffer->FirstEntry;
206  BiosArguments.Edi = TrampolineMemoryOffset;
207  BiosArguments.SegEs = TrampolineMemorySegment;
208  BiosArguments.Eax = VBE_SET_GET_PALETTE_DATA;
209  Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments);
210  if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER;
211  VideoPortFreePool(VgaExtension, VesaClut);
212  VideoDebugPrint((Error, "VBE Status: %lx\n", BiosArguments.Eax));
213  if (VBE_GETRETURNCODE(BiosArguments.Eax) == VBE_SUCCESS)
214  return NO_ERROR;
216 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
unsigned char * PUCHAR
Definition: retypes.h:3
ULONG NonVgaMode
Definition: vga.h:276
#define VBE_GETRETURNCODE(x)
Definition: vbemp.h:100
#define NO_ERROR
Definition: dderror.h:5
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
Definition: vga.h:250
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 VBE_SUCCESS
Definition: vbemp.h:95
VPAPI PVOID NTAPI VideoPortAllocatePool(IN PVOID HwDeviceExtension, IN VP_POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: resource.c:913
VPAPI VOID NTAPI VideoPortFreePool(IN PVOID HwDeviceExtension, IN PVOID Ptr)
Definition: resource.c:928
#define BufferSize
Definition: classpnp.h:419
BOOL Error
Definition: chkdsk.c:66
#define VBE_SET_GET_PALETTE_DATA
Definition: vbemp.h:55
Status
Definition: gdiplustypes.h:24
#define VideoDebugPrint(x)
Definition: video.h:75
LIST_ENTRY Entries[5]
Definition: ExDoubleList.c:8
unsigned short USHORT
Definition: pedump.c:61
struct tagContext Context
Definition: acpixf.h:1030
unsigned int ULONG
Definition: retypes.h:1
LONG VP_STATUS
Definition: video.h:153
VPAPI VOID NTAPI VideoPortWritePortUchar(IN PUCHAR Port, IN UCHAR Value)

Referenced by VgaSetColorLookup().

◆ VbeSetMode()

VP_STATUS NTAPI VbeSetMode ( IN PHW_DEVICE_EXTENSION  VgaDeviceExtension,
IN PVIDEOMODE  VgaMode,
OUT PULONG  PhysPtrChange 
)

Definition at line 88 of file vbemodes.c.

91 {
93  VIDEO_X86_BIOS_ARGUMENTS BiosArguments;
94  ULONG ModeIndex;
96 
97  VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
98  ModeIndex = VgaMode->Mode;
99  BiosArguments.Eax = VBE_SET_VBE_MODE;
100  BiosArguments.Ebx = HIWORD(ModeIndex);
101  VideoDebugPrint((0, "Switching to %lx %lx\n", BiosArguments.Eax, BiosArguments.Ebx));
102  Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments);
103  if (Status != NO_ERROR) return Status;
104  if(VBE_GETRETURNCODE(BiosArguments.Eax) != VBE_SUCCESS)
105  {
106  VideoDebugPrint((0, "Changing VBE mode failed, Eax %lx", BiosArguments.Eax));
108  }
109 
110  /* Check for VESA mode */
111  if (ModeIndex >> 16)
112  {
113  /* Mode set fail */
114  if (VBE_GETRETURNCODE(BiosArguments.Eax) != VBE_SUCCESS)
116 
117  /* Check current mode is desired mode */
118  VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
119  BiosArguments.Eax = VBE_GET_CURRENT_VBE_MODE;
120  Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments);
121  if ((Status == NO_ERROR) &&
122  (VBE_GETRETURNCODE(BiosArguments.Eax) == VBE_SUCCESS) &&
123  ((BiosArguments.Ebx ^ (ModeIndex >> 16)) & VBE_MODE_BITS))
124  {
126  }
127 
128  /* Set logical scanline width if different from physical */
129  if (VgaMode->LogicalWidth != VgaMode->hres)
130  {
131  /* Check setting works after being set */
132  VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
134  BiosArguments.Ecx = VgaMode->LogicalWidth;
135  BiosArguments.Ebx = 0;
136  Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments);
137  if ((Status != NO_ERROR) ||
138  (VBE_GETRETURNCODE(BiosArguments.Eax) != VBE_SUCCESS) ||
139  (BiosArguments.Ecx != VgaMode->LogicalWidth))
140  {
142  }
143  }
144  }
145 
146  /* Get VRAM address to update changes */
147  BaseAddress = VbeGetVideoMemoryBaseAddress(VgaDeviceExtension, VgaMode);
148  if ((BaseAddress) && (VgaMode->PhysBase != BaseAddress))
149  {
150  *PhysPtrChange = TRUE;
151  VgaMode->PhysBase = BaseAddress;
152  }
153 
154  return NO_ERROR;
155 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define VBE_MODE_BITS
Definition: vbe.h:65
ULONG NTAPI VbeGetVideoMemoryBaseAddress(IN PHW_DEVICE_EXTENSION VgaExtension, IN PVIDEOMODE VgaMode)
Definition: vbemodes.c:35
#define TRUE
Definition: types.h:120
#define VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH
Definition: vbemp.h:52
#define VBE_GETRETURNCODE(x)
Definition: vbemp.h:100
#define NO_ERROR
Definition: dderror.h:5
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
#define VBE_SUCCESS
Definition: vbemp.h:95
VPAPI VP_STATUS NTAPI VideoPortInt10(IN PVOID HwDeviceExtension, IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments)
Definition: int10.c:389
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define VBE_GET_CURRENT_VBE_MODE
Definition: vbemp.h:49
#define VBE_SET_VBE_MODE
Definition: vbemp.h:48
Status
Definition: gdiplustypes.h:24
#define VideoDebugPrint(x)
Definition: video.h:75
static BOOLEAN VgaMode
Definition: options.c:87
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
LONG VP_STATUS
Definition: video.h:153

Referenced by VgaSetMode().

Variable Documentation

◆ g_bIntelBrookdaleBIOS

BOOLEAN g_bIntelBrookdaleBIOS

Definition at line 31 of file vbe.c.

Referenced by InitializeModeTable(), and IsVesaBiosOk().