ReactOS  0.4.15-dev-3187-ge372f2b
vbemp.c File Reference
#include "vbemp.h"
#include <devioctl.h>
Include dependency graph for vbemp.c:

Go to the source code of this file.

Macros

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

Functions

ULONG NTAPI DriverEntry (IN PVOID Context1, IN PVOID Context2)
 
VP_STATUS NTAPI VBEFindAdapter (IN PVOID HwDeviceExtension, IN PVOID HwContext, IN PWSTR ArgumentString, IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, OUT PUCHAR Again)
 
static int VBESortModesCallback (PVBE_MODEINFO VbeModeInfoA, PVBE_MODEINFO VbeModeInfoB)
 
VOID FASTCALL VBESortModes (PVBE_DEVICE_EXTENSION DeviceExtension)
 
BOOLEAN NTAPI VBEInitialize (PVOID HwDeviceExtension)
 
BOOLEAN NTAPI VBEStartIO (PVOID HwDeviceExtension, PVIDEO_REQUEST_PACKET RequestPacket)
 
BOOLEAN NTAPI VBEResetHw (PVOID DeviceExtension, ULONG Columns, ULONG Rows)
 
VP_STATUS NTAPI VBEGetPowerState (PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
 
VP_STATUS NTAPI VBESetPowerState (PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
 
BOOLEAN FASTCALL VBESetCurrentMode (PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE RequestedMode, PSTATUS_BLOCK StatusBlock)
 
BOOLEAN FASTCALL VBEResetDevice (PVBE_DEVICE_EXTENSION DeviceExtension, PSTATUS_BLOCK StatusBlock)
 
BOOLEAN FASTCALL VBEMapVideoMemory (PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MEMORY RequestedAddress, PVIDEO_MEMORY_INFORMATION MapInformation, PSTATUS_BLOCK StatusBlock)
 
BOOLEAN FASTCALL VBEUnmapVideoMemory (PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MEMORY VideoMemory, PSTATUS_BLOCK StatusBlock)
 
BOOLEAN FASTCALL VBEQueryNumAvailModes (PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_NUM_MODES Modes, PSTATUS_BLOCK StatusBlock)
 
VOID FASTCALL VBEQueryMode (PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION VideoMode, ULONG VideoModeId)
 
BOOLEAN FASTCALL VBEQueryAvailModes (PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION ReturnedModes, PSTATUS_BLOCK StatusBlock)
 
BOOLEAN FASTCALL VBEQueryCurrentMode (PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION VideoModeInfo, PSTATUS_BLOCK StatusBlock)
 
BOOLEAN FASTCALL VBESetColorRegisters (PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_CLUT ColorLookUpTable, PSTATUS_BLOCK StatusBlock)
 

Macro Definition Documentation

◆ HIWORD

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

Definition at line 37 of file vbemp.c.

◆ LOWORD

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

Definition at line 36 of file vbemp.c.

Function Documentation

◆ DriverEntry()

ULONG NTAPI DriverEntry ( IN PVOID  Context1,
IN PVOID  Context2 
)

Definition at line 42 of file vbemp.c.

43 {
45 
46  VideoPortZeroMemory(&InitData, sizeof(InitData));
48  InitData.HwFindAdapter = VBEFindAdapter;
49  InitData.HwInitialize = VBEInitialize;
50  InitData.HwStartIO = VBEStartIO;
51  InitData.HwResetHw = VBEResetHw;
56 
57  return VideoPortInitialize(Context1, Context2, &InitData, NULL);
58 }
VP_STATUS NTAPI VBEGetVideoChildDescriptor(IN PVOID HwDeviceExtension, IN PVIDEO_CHILD_ENUM_INFO ChildEnumInfo, OUT PVIDEO_CHILD_TYPE VideoChildType, OUT PUCHAR pChildDescriptor, OUT PULONG UId, OUT PULONG pUnused)
Definition: edid.c:230
BOOLEAN NTAPI VBEStartIO(PVOID HwDeviceExtension, PVIDEO_REQUEST_PACKET RequestPacket)
Definition: vbemp.c:423
PVIDEO_HW_POWER_SET HwSetPowerState
Definition: video.h:675
PVIDEO_HW_GET_CHILD_DESCRIPTOR HwGetVideoChildDescriptor
Definition: video.h:677
VP_STATUS NTAPI VBEGetPowerState(PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
Definition: vbemp.c:563
VP_STATUS NTAPI VBEFindAdapter(IN PVOID HwDeviceExtension, IN PVOID HwContext, IN PWSTR ArgumentString, IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, OUT PUCHAR Again)
Definition: vbemp.c:69
VPAPI ULONG NTAPI VideoPortInitialize(IN PVOID Argument1, IN PVOID Argument2, IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData, IN PVOID HwContext)
Definition: videoprt.c:645
PVIDEO_HW_POWER_GET HwGetPowerState
Definition: video.h:676
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
PVIDEO_HW_START_IO HwStartIO
Definition: video.h:669
VP_STATUS NTAPI VBESetPowerState(PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
Definition: vbemp.c:633
struct _VIDEO_HW_INITIALIZATION_DATA VIDEO_HW_INITIALIZATION_DATA
BOOLEAN NTAPI VBEInitialize(PVOID HwDeviceExtension)
Definition: vbemp.c:170
PVIDEO_HW_INITIALIZE HwInitialize
Definition: video.h:667
PVIDEO_HW_FIND_ADAPTER HwFindAdapter
Definition: video.h:666
PVIDEO_HW_RESET_HW HwResetHw
Definition: video.h:672
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT _In_ PTDI_PNP_CONTEXT Context2
Definition: tdikrnl.h:1094
BOOLEAN NTAPI VBEResetHw(PVOID DeviceExtension, ULONG Columns, ULONG Rows)
Definition: vbemp.c:547
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT Context1
Definition: tdikrnl.h:1094
#define NULL
Definition: types.h:112

◆ VBEFindAdapter()

VP_STATUS NTAPI VBEFindAdapter ( IN PVOID  HwDeviceExtension,
IN PVOID  HwContext,
IN PWSTR  ArgumentString,
IN OUT PVIDEO_PORT_CONFIG_INFO  ConfigInfo,
OUT PUCHAR  Again 
)

Definition at line 69 of file vbemp.c.

75 {
76  if (VideoPortIsNoVesa())
77  return ERROR_DEV_NOT_EXIST;
78 
79  ConfigInfo->VdmPhysicalVideoMemoryAddress.QuadPart = 0xa000;
80  ConfigInfo->VdmPhysicalVideoMemoryLength = 0x2000;
81  return NO_ERROR;
82 }
#define NO_ERROR
Definition: dderror.h:5
VPAPI BOOLEAN NTAPI VideoPortIsNoVesa(VOID)
Definition: videoprt.c:1619
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8

Referenced by DriverEntry().

◆ VBEGetPowerState()

VP_STATUS NTAPI VBEGetPowerState ( PVOID  HwDeviceExtension,
ULONG  HwId,
PVIDEO_POWER_MANAGEMENT  VideoPowerControl 
)

Definition at line 563 of file vbemp.c.

567 {
568  INT10_BIOS_ARGUMENTS BiosRegisters;
569  PVBE_DEVICE_EXTENSION VBEDeviceExtension =
570  (PVBE_DEVICE_EXTENSION)HwDeviceExtension;
571 
572  if (HwId != DISPLAY_ADAPTER_HW_ID ||
573  VideoPowerControl->Length < sizeof(VIDEO_POWER_MANAGEMENT))
574  return ERROR_INVALID_FUNCTION;
575 
576  /*
577  * Get general power support information.
578  */
579 
580  VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
581  BiosRegisters.Eax = VBE_POWER_MANAGEMENT_EXTENSIONS;
582  BiosRegisters.Ebx = 0;
583  BiosRegisters.Edi = 0;
584  BiosRegisters.SegEs = 0;
585  VBEDeviceExtension->Int10Interface.Int10CallBios(
586  VBEDeviceExtension->Int10Interface.Context,
587  &BiosRegisters);
588 
589  if ( VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_NOT_SUPPORTED)
590  return ERROR_DEV_NOT_EXIST;
591  if (VBE_GETRETURNCODE(BiosRegisters.Eax) != VBE_SUCCESS)
592  return ERROR_INVALID_FUNCTION;
593 
594  /*
595  * Get current power state.
596  */
597 
598  VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
599  BiosRegisters.Eax = VBE_POWER_MANAGEMENT_EXTENSIONS;
600  BiosRegisters.Ebx = 0x2;
601  BiosRegisters.Edi = 0;
602  BiosRegisters.SegEs = 0;
603  VBEDeviceExtension->Int10Interface.Int10CallBios(
604  VBEDeviceExtension->Int10Interface.Context,
605  &BiosRegisters);
606 
607  if (VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS)
608  {
609  VideoPowerControl->DPMSVersion = BiosRegisters.Ebx & 0xFF;
610  switch (BiosRegisters.Ebx >> 8)
611  {
612  case 0: VideoPowerControl->PowerState = VideoPowerOn; break;
613  case 1: VideoPowerControl->PowerState = VideoPowerStandBy; break;
614  case 2: VideoPowerControl->PowerState = VideoPowerSuspend; break;
615  case 4: VideoPowerControl->PowerState = VideoPowerOff; break;
616  case 5: VideoPowerControl->PowerState = VideoPowerOn; break;
617  default: VideoPowerControl->PowerState = VideoPowerUnspecified;
618  }
619 
620  return NO_ERROR;
621  }
622 
623  return ERROR_DEV_NOT_EXIST;
624 }
#define DISPLAY_ADAPTER_HW_ID
Definition: video.h:115
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#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
#define VBE_NOT_SUPPORTED
Definition: vbemp.h:97
VIDEO_PORT_INT10_INTERFACE Int10Interface
Definition: vbemp.h:194
#define VBE_POWER_MANAGEMENT_EXTENSIONS
Definition: vbemp.h:62
struct VBE_DEVICE_EXTENSION * PVBE_DEVICE_EXTENSION
OUT PINT10_CALL_BIOS Int10CallBios
Definition: video.h:782
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8

Referenced by DriverEntry().

◆ VBEInitialize()

BOOLEAN NTAPI VBEInitialize ( PVOID  HwDeviceExtension)

Definition at line 170 of file vbemp.c.

171 {
172  INT10_BIOS_ARGUMENTS BiosRegisters;
174  PVBE_DEVICE_EXTENSION VBEDeviceExtension =
175  (PVBE_DEVICE_EXTENSION)HwDeviceExtension;
176  ULONG Length;
177  ULONG ModeCount;
178  ULONG SuitableModeCount;
179  USHORT ModeTemp;
180  ULONG CurrentMode;
181  PVBE_MODEINFO VbeModeInfo;
182 
183  /*
184  * Get the Int 10 interface that we will use for allocating real
185  * mode memory and calling the video BIOS.
186  */
187 
189  VBEDeviceExtension->Int10Interface.Size = sizeof(VIDEO_PORT_INT10_INTERFACE);
191  HwDeviceExtension,
193  (PINTERFACE)&VBEDeviceExtension->Int10Interface);
194 
195  if (Status != NO_ERROR)
196  {
197  VideoPortDebugPrint(Error, "Failed to get Int 10 service functions (Status %x)\n", Status);
198  return FALSE;
199  }
200 
201  /*
202  * Allocate a bit of memory that will be later used for VBE transport
203  * buffer. This memory must be accessible from V86 mode so it must fit
204  * in the first megabyte of physical memory.
205  */
206 
207  Length = 0x400;
208  Status = VBEDeviceExtension->Int10Interface.Int10AllocateBuffer(
209  VBEDeviceExtension->Int10Interface.Context,
210  &VBEDeviceExtension->TrampolineMemorySegment,
211  &VBEDeviceExtension->TrampolineMemoryOffset,
212  &Length);
213 
214  if (Status != NO_ERROR)
215  {
216  VideoPortDebugPrint(Error, "Failed to allocate virtual memory (Status %x)\n", Status);
217  return FALSE;
218  }
219 
220  /*
221  * Get the VBE general information.
222  */
223 
224  VBEDeviceExtension->Int10Interface.Int10WriteMemory(
225  VBEDeviceExtension->Int10Interface.Context,
226  VBEDeviceExtension->TrampolineMemorySegment,
227  VBEDeviceExtension->TrampolineMemoryOffset,
228  "VBE2",
229  4);
230 
231  VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
232  BiosRegisters.Eax = VBE_GET_CONTROLLER_INFORMATION;
233  BiosRegisters.Edi = VBEDeviceExtension->TrampolineMemoryOffset;
234  BiosRegisters.SegEs = VBEDeviceExtension->TrampolineMemorySegment;
235  VBEDeviceExtension->Int10Interface.Int10CallBios(
236  VBEDeviceExtension->Int10Interface.Context,
237  &BiosRegisters);
238 
239  if (VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS)
240  {
241  VBEDeviceExtension->Int10Interface.Int10ReadMemory(
242  VBEDeviceExtension->Int10Interface.Context,
243  VBEDeviceExtension->TrampolineMemorySegment,
244  VBEDeviceExtension->TrampolineMemoryOffset,
245  &VBEDeviceExtension->VbeInfo,
246  sizeof(VBEDeviceExtension->VbeInfo));
247 
248  /* Verify the VBE signature. */
249  if (VideoPortCompareMemory(VBEDeviceExtension->VbeInfo.Signature, "VESA", 4) != 4)
250  {
251  VideoPortDebugPrint(Error, "No VBE BIOS present\n");
252  return FALSE;
253  }
254 
255  VideoPortDebugPrint(Trace, "VBE BIOS Present (%d.%d, %8ld Kb)\n",
256  VBEDeviceExtension->VbeInfo.Version / 0x100,
257  VBEDeviceExtension->VbeInfo.Version & 0xFF,
258  VBEDeviceExtension->VbeInfo.TotalMemory * 64);
259 
260 #ifdef VBE12_SUPPORT
261  if (VBEDeviceExtension->VbeInfo.Version < 0x102)
262 #else
263  if (VBEDeviceExtension->VbeInfo.Version < 0x200)
264 #endif
265  {
266  VideoPortDebugPrint(Error, "VBE BIOS present, but incompatible version %d.%d\n",
267  VBEDeviceExtension->VbeInfo.Version / 0x100,
268  VBEDeviceExtension->VbeInfo.Version & 0xFF);
269  return FALSE;
270  }
271  }
272  else
273  {
274  VideoPortDebugPrint(Error, "No VBE BIOS found.\n");
275  return FALSE;
276  }
277 
278  /*
279  * Build a mode list here that can be later used by
280  * IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES and IOCTL_VIDEO_QUERY_AVAIL_MODES
281  * calls.
282  */
283 
284  /*
285  * Get the number of supported video modes.
286  *
287  * No need to be map the memory. It's either in the video BIOS memory or
288  * in our trampoline memory. In either case the memory is already mapped.
289  */
290 
291  for (ModeCount = 0; ; ModeCount++)
292  {
293  /* Read the VBE mode number. */
294  VBEDeviceExtension->Int10Interface.Int10ReadMemory(
295  VBEDeviceExtension->Int10Interface.Context,
296  HIWORD(VBEDeviceExtension->VbeInfo.VideoModePtr),
297  LOWORD(VBEDeviceExtension->VbeInfo.VideoModePtr) + (ModeCount << 1),
298  &ModeTemp,
299  sizeof(ModeTemp));
300 
301  /* End of list? */
302  if (ModeTemp == 0xFFFF || ModeTemp == 0)
303  break;
304  }
305 
306  /*
307  * Allocate space for video modes information.
308  */
309 
310  VBEDeviceExtension->ModeInfo =
311  VideoPortAllocatePool(HwDeviceExtension, VpPagedPool, ModeCount * sizeof(VBE_MODEINFO), TAG_VBE);
312  VBEDeviceExtension->ModeNumbers =
313  VideoPortAllocatePool(HwDeviceExtension, VpPagedPool, ModeCount * sizeof(USHORT), TAG_VBE);
314 
315  /*
316  * Get the actual mode infos.
317  */
318 
319  for (CurrentMode = 0, SuitableModeCount = 0;
320  CurrentMode < ModeCount;
321  CurrentMode++)
322  {
323  /* Read the VBE mode number. */
324  VBEDeviceExtension->Int10Interface.Int10ReadMemory(
325  VBEDeviceExtension->Int10Interface.Context,
326  HIWORD(VBEDeviceExtension->VbeInfo.VideoModePtr),
327  LOWORD(VBEDeviceExtension->VbeInfo.VideoModePtr) + (CurrentMode << 1),
328  &ModeTemp,
329  sizeof(ModeTemp));
330 
331  /* Call VBE BIOS to read the mode info. */
332  VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
333  BiosRegisters.Eax = VBE_GET_MODE_INFORMATION;
334  BiosRegisters.Ecx = ModeTemp;
335  BiosRegisters.Edi = VBEDeviceExtension->TrampolineMemoryOffset + 0x200;
336  BiosRegisters.SegEs = VBEDeviceExtension->TrampolineMemorySegment;
337  VBEDeviceExtension->Int10Interface.Int10CallBios(
338  VBEDeviceExtension->Int10Interface.Context,
339  &BiosRegisters);
340 
341  /* Read the VBE mode info. */
342  VBEDeviceExtension->Int10Interface.Int10ReadMemory(
343  VBEDeviceExtension->Int10Interface.Context,
344  VBEDeviceExtension->TrampolineMemorySegment,
345  VBEDeviceExtension->TrampolineMemoryOffset + 0x200,
346  VBEDeviceExtension->ModeInfo + SuitableModeCount,
347  sizeof(VBE_MODEINFO));
348 
349  VbeModeInfo = VBEDeviceExtension->ModeInfo + SuitableModeCount;
350 
351  /* Is this mode acceptable? */
352  if (VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS &&
353  VbeModeInfo->XResolution >= 640 &&
354  VbeModeInfo->YResolution >= 480 &&
355  (VbeModeInfo->MemoryModel == VBE_MEMORYMODEL_PACKEDPIXEL ||
356  VbeModeInfo->MemoryModel == VBE_MEMORYMODEL_DIRECTCOLOR) &&
357  VbeModeInfo->PhysBasePtr != 0)
358  {
359  if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_LINEAR)
360  {
361  /* Bit 15 14 13 12 | 11 10 9 8 | 7 6 5 4 | 3 2 1 0 */
362  // if (ModeTemp & 0x4000)
363  //{
364  VBEDeviceExtension->ModeNumbers[SuitableModeCount] = ModeTemp | 0x4000;
365  SuitableModeCount++;
366  //}
367  }
368 #ifdef VBE12_SUPPORT
369  else
370  {
371  VBEDeviceExtension->ModeNumbers[SuitableModeCount] = ModeTemp;
372  SuitableModeCount++;
373  }
374 #endif
375  }
376  }
377 
378 
379  if (SuitableModeCount == 0)
380  {
381 
382  VideoPortDebugPrint(Warn, "VBEMP: No video modes supported\n");
383  return FALSE;
384  }
385 
386  VBEDeviceExtension->ModeCount = SuitableModeCount;
387 
388  /*
389  * Sort the video mode list according to resolution and bits per pixel.
390  */
391 
392  VBESortModes(VBEDeviceExtension);
393 
394  /*
395  * Print the supported video modes.
396  */
397 
398  for (CurrentMode = 0;
399  CurrentMode < SuitableModeCount;
400  CurrentMode++)
401  {
402  VideoPortDebugPrint(Trace, "%dx%dx%d\n",
403  VBEDeviceExtension->ModeInfo[CurrentMode].XResolution,
404  VBEDeviceExtension->ModeInfo[CurrentMode].YResolution,
405  VBEDeviceExtension->ModeInfo[CurrentMode].BitsPerPixel);
406  }
407 
408  /*
409  * Enumerate our children.
410  */
411  VideoPortEnumerateChildren(HwDeviceExtension, NULL);
412 
413  return TRUE;
414 }
#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
UCHAR BitsPerPixel
Definition: vbemp.h:147
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define TRUE
Definition: types.h:120
UCHAR MemoryModel
Definition: vbemp.h:149
#define VBE_GETRETURNCODE(x)
Definition: vbemp.h:100
USHORT XResolution
Definition: vbemp.h:142
#define NO_ERROR
Definition: dderror.h:5
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
#define VBE_GET_MODE_INFORMATION
Definition: vbemp.h:47
#define VBE_SUCCESS
Definition: vbemp.h:95
#define FALSE
Definition: types.h:117
OUT PINT10_READ_MEMORY Int10ReadMemory
Definition: video.h:780
VPAPI PVOID NTAPI VideoPortAllocatePool(IN PVOID HwDeviceExtension, IN VP_POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: resource.c:918
ULONG PhysBasePtr
Definition: vbemp.h:166
#define HIWORD(l)
Definition: vbemp.c:37
#define VBE_MEMORYMODEL_DIRECTCOLOR
Definition: vbemp.h:89
USHORT TrampolineMemorySegment
Definition: vbemp.h:197
VBE_INFO VbeInfo
Definition: vbemp.h:201
#define VBE_GET_CONTROLLER_INFORMATION
Definition: vbemp.h:46
Status
Definition: gdiplustypes.h:24
PVBE_MODEINFO ModeInfo
Definition: vbemp.h:206
Definition: video.h:581
OUT PINT10_ALLOCATE_BUFFER Int10AllocateBuffer
Definition: video.h:778
BOOL Error
Definition: chkdsk.c:66
VPAPI ULONG NTAPI VideoPortCompareMemory(IN PVOID Source1, IN PVOID Source2, IN SIZE_T Length)
USHORT ModeAttributes
Definition: vbemp.h:131
struct _VIDEO_PORT_INT10_INTERFACE VIDEO_PORT_INT10_INTERFACE
#define Trace(x)
Definition: inflate.c:42
VOID FASTCALL VBESortModes(PVBE_DEVICE_EXTENSION DeviceExtension)
Definition: vbemp.c:114
VIDEO_PORT_INT10_INTERFACE Int10Interface
Definition: vbemp.h:194
#define VBE_MODEATTR_LINEAR
Definition: vbemp.h:86
#define VBE_MEMORYMODEL_PACKEDPIXEL
Definition: vbemp.h:88
unsigned short USHORT
Definition: pedump.c:61
USHORT TrampolineMemoryOffset
Definition: vbemp.h:198
#define LOWORD(l)
Definition: vbemp.c:36
USHORT YResolution
Definition: vbemp.h:143
ULONG VideoModePtr
Definition: vbemp.h:113
#define NULL
Definition: types.h:112
struct VBE_DEVICE_EXTENSION * PVBE_DEVICE_EXTENSION
USHORT * ModeNumbers
Definition: vbemp.h:205
USHORT TotalMemory
Definition: vbemp.h:114
OUT PINT10_WRITE_MEMORY Int10WriteMemory
Definition: video.h:781
unsigned int ULONG
Definition: retypes.h:1
OUT PINT10_CALL_BIOS Int10CallBios
Definition: video.h:782
LONG VP_STATUS
Definition: video.h:153
#define TAG_VBE
Definition: vbemp.h:31
VPAPI VOID __cdecl VideoPortDebugPrint(IN VIDEO_DEBUG_LEVEL DebugPrintLevel, IN PSTR DebugMessage, IN ...)
VPAPI VP_STATUS NTAPI VideoPortEnumerateChildren(IN PVOID HwDeviceExtension, IN PVOID Reserved)
Definition: videoprt.c:1178
CHAR Signature[4]
Definition: vbemp.h:109

Referenced by DriverEntry().

◆ VBEMapVideoMemory()

BOOLEAN FASTCALL VBEMapVideoMemory ( PVBE_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_MEMORY  RequestedAddress,
PVIDEO_MEMORY_INFORMATION  MapInformation,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 750 of file vbemp.c.

755 {
757  ULONG inIoSpace = VIDEO_MEMORY_SPACE_MEMORY;
758 
759  StatusBlock->Information = sizeof(VIDEO_MEMORY_INFORMATION);
760 
761  if (DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].ModeAttributes &
763  {
764  FrameBuffer.QuadPart =
765  DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].PhysBasePtr;
766  MapInformation->VideoRamBase = RequestedAddress->RequestedVirtualAddress;
767  if (DeviceExtension->VbeInfo.Version < 0x300)
768  {
769  MapInformation->VideoRamLength =
770  DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].BytesPerScanLine *
771  DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].YResolution;
772  }
773  else
774  {
775  MapInformation->VideoRamLength =
776  DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].LinBytesPerScanLine *
777  DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].YResolution;
778  }
779  }
780 #ifdef VBE12_SUPPORT
781  else
782  {
783  FrameBuffer.QuadPart = 0xA0000;
784  MapInformation->VideoRamBase = RequestedAddress->RequestedVirtualAddress;
785  MapInformation->VideoRamLength = 0x10000;
786  }
787 #endif
788 
789  VideoPortMapMemory(DeviceExtension, FrameBuffer,
790  &MapInformation->VideoRamLength, &inIoSpace,
791  &MapInformation->VideoRamBase);
792 
793  MapInformation->FrameBufferBase = MapInformation->VideoRamBase;
794  MapInformation->FrameBufferLength = MapInformation->VideoRamLength;
795 
796  return TRUE;
797 }
USHORT BytesPerScanLine
Definition: vbemp.h:139
USHORT LinBytesPerScanLine
Definition: vbemp.h:171
USHORT Version
Definition: vbemp.h:110
#define TRUE
Definition: types.h:120
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:275
ULONG PhysBasePtr
Definition: vbemp.h:166
VBE_INFO VbeInfo
Definition: vbemp.h:201
PVBE_MODEINFO ModeInfo
Definition: vbemp.h:206
VPAPI VP_STATUS NTAPI VideoPortMapMemory(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, IN OUT PULONG Length, IN PULONG InIoSpace, IN OUT PVOID *VirtualAddress)
struct _VIDEO_MEMORY_INFORMATION VIDEO_MEMORY_INFORMATION
PVOID FrameBuffer
Definition: xboxvideo.c:28
USHORT ModeAttributes
Definition: vbemp.h:131
#define VBE_MODEATTR_LINEAR
Definition: vbemp.h:86
USHORT YResolution
Definition: vbemp.h:143
unsigned int ULONG
Definition: retypes.h:1
#define VIDEO_MEMORY_SPACE_MEMORY
Definition: video.h:132
ULONG_PTR Information
Definition: video.h:326
USHORT CurrentMode
Definition: vbemp.h:207

Referenced by VBEStartIO().

◆ VBEQueryAvailModes()

BOOLEAN FASTCALL VBEQueryAvailModes ( PVBE_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_MODE_INFORMATION  ReturnedModes,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 923 of file vbemp.c.

927 {
928  ULONG CurrentModeId;
929  PVIDEO_MODE_INFORMATION CurrentMode;
930  PVBE_MODEINFO CurrentVBEMode;
931 
932  for (CurrentModeId = 0, CurrentMode = ReturnedModes,
933  CurrentVBEMode = DeviceExtension->ModeInfo;
934  CurrentModeId < DeviceExtension->ModeCount;
935  CurrentModeId++, CurrentMode++, CurrentVBEMode++)
936  {
937  VBEQueryMode(DeviceExtension, CurrentMode, CurrentModeId);
938  }
939 
940  StatusBlock->Information =
941  sizeof(VIDEO_MODE_INFORMATION) * DeviceExtension->ModeCount;
942 
943  return TRUE;
944 }
#define TRUE
Definition: types.h:120
PVBE_MODEINFO ModeInfo
Definition: vbemp.h:206
unsigned int ULONG
Definition: retypes.h:1
VOID FASTCALL VBEQueryMode(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION VideoMode, ULONG VideoModeId)
Definition: vbemp.c:844
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
ULONG_PTR Information
Definition: video.h:326

Referenced by VBEStartIO().

◆ VBEQueryCurrentMode()

BOOLEAN FASTCALL VBEQueryCurrentMode ( PVBE_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_MODE_INFORMATION  VideoModeInfo,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 953 of file vbemp.c.

957 {
958  StatusBlock->Information = sizeof(VIDEO_MODE_INFORMATION);
959 
960  VBEQueryMode(
961  DeviceExtension,
962  VideoModeInfo,
963  DeviceExtension->CurrentMode);
964 
965  return TRUE;
966 }
#define TRUE
Definition: types.h:120
VOID FASTCALL VBEQueryMode(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION VideoMode, ULONG VideoModeId)
Definition: vbemp.c:844
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
ULONG_PTR Information
Definition: video.h:326
USHORT CurrentMode
Definition: vbemp.h:207

Referenced by VBEStartIO().

◆ VBEQueryMode()

VOID FASTCALL VBEQueryMode ( PVBE_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_MODE_INFORMATION  VideoMode,
ULONG  VideoModeId 
)

Definition at line 844 of file vbemp.c.

848 {
849  PVBE_MODEINFO VBEMode = &DeviceExtension->ModeInfo[VideoModeId];
850  ULONG dpi;
851 
852  VideoMode->Length = sizeof(VIDEO_MODE_INFORMATION);
853  VideoMode->ModeIndex = VideoModeId;
854  VideoMode->VisScreenWidth = VBEMode->XResolution;
855  VideoMode->VisScreenHeight = VBEMode->YResolution;
856  if (DeviceExtension->VbeInfo.Version < 0x300)
857  VideoMode->ScreenStride = VBEMode->BytesPerScanLine;
858  else
859  VideoMode->ScreenStride = VBEMode->LinBytesPerScanLine;
860  VideoMode->NumberOfPlanes = VBEMode->NumberOfPlanes;
861  VideoMode->BitsPerPlane = VBEMode->BitsPerPixel / VBEMode->NumberOfPlanes;
862  VideoMode->Frequency = 1;
863 
864  /* Assume 96DPI and 25.4 millimeters per inch, round to nearest */
865  dpi = 96;
866  VideoMode->XMillimeter = ((ULONGLONG)VBEMode->XResolution * 254 + (dpi * 5)) / (dpi * 10);
867  VideoMode->YMillimeter = ((ULONGLONG)VBEMode->YResolution * 254 + (dpi * 5)) / (dpi * 10);
868 
869  if (VBEMode->BitsPerPixel > 8)
870  {
871  /*
872  * Always report 16bpp modes and not 15bpp mode...
873  */
874  if (VBEMode->BitsPerPixel == 15 && VBEMode->NumberOfPlanes == 1)
875  {
876  VideoMode->BitsPerPlane = 16;
877  }
878 
879  if (DeviceExtension->VbeInfo.Version < 0x300)
880  {
881  VideoMode->NumberRedBits = VBEMode->RedMaskSize;
882  VideoMode->NumberGreenBits = VBEMode->GreenMaskSize;
883  VideoMode->NumberBlueBits = VBEMode->BlueMaskSize;
884  VideoMode->RedMask = ((1 << VBEMode->RedMaskSize) - 1) << VBEMode->RedFieldPosition;
885  VideoMode->GreenMask = ((1 << VBEMode->GreenMaskSize) - 1) << VBEMode->GreenFieldPosition;
886  VideoMode->BlueMask = ((1 << VBEMode->BlueMaskSize) - 1) << VBEMode->BlueFieldPosition;
887  }
888  else
889  {
890  VideoMode->NumberRedBits = VBEMode->LinRedMaskSize;
891  VideoMode->NumberGreenBits = VBEMode->LinGreenMaskSize;
892  VideoMode->NumberBlueBits = VBEMode->LinBlueMaskSize;
893  VideoMode->RedMask = ((1 << VBEMode->LinRedMaskSize) - 1) << VBEMode->LinRedFieldPosition;
894  VideoMode->GreenMask = ((1 << VBEMode->LinGreenMaskSize) - 1) << VBEMode->LinGreenFieldPosition;
895  VideoMode->BlueMask = ((1 << VBEMode->LinBlueMaskSize) - 1) << VBEMode->LinBlueFieldPosition;
896  }
897  }
898  else
899  {
900  VideoMode->NumberRedBits =
901  VideoMode->NumberGreenBits =
902  VideoMode->NumberBlueBits = 6;
903  VideoMode->RedMask =
904  VideoMode->GreenMask =
905  VideoMode->BlueMask = 0;
906  }
907  VideoMode->VideoMemoryBitmapWidth = VBEMode->XResolution;
908  VideoMode->VideoMemoryBitmapHeight = VBEMode->YResolution;
909  VideoMode->AttributeFlags = VIDEO_MODE_GRAPHICS | VIDEO_MODE_COLOR |
911  if (VideoMode->BitsPerPlane <= 8)
912  VideoMode->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN;
913  VideoMode->DriverSpecificAttributeFlags = 0;
914 }
USHORT BytesPerScanLine
Definition: vbemp.h:139
USHORT LinBytesPerScanLine
Definition: vbemp.h:171
USHORT Version
Definition: vbemp.h:110
UCHAR BitsPerPixel
Definition: vbemp.h:147
UCHAR RedFieldPosition
Definition: vbemp.h:156
USHORT XResolution
Definition: vbemp.h:142
#define VIDEO_MODE_NO_OFF_SCREEN
Definition: ntddvdeo.h:299
UCHAR LinGreenMaskSize
Definition: vbemp.h:176
UCHAR RedMaskSize
Definition: vbemp.h:155
UCHAR LinBlueFieldPosition
Definition: vbemp.h:179
UCHAR BlueMaskSize
Definition: vbemp.h:159
VBE_INFO VbeInfo
Definition: vbemp.h:201
PVBE_MODEINFO ModeInfo
Definition: vbemp.h:206
#define dpi
Definition: sysparams.c:22
UCHAR LinBlueMaskSize
Definition: vbemp.h:178
uint64_t ULONGLONG
Definition: typedefs.h:67
#define VIDEO_MODE_PALETTE_DRIVEN
Definition: ntddvdeo.h:296
UCHAR LinRedFieldPosition
Definition: vbemp.h:175
UCHAR GreenFieldPosition
Definition: vbemp.h:158
UCHAR BlueFieldPosition
Definition: vbemp.h:160
#define VIDEO_MODE_COLOR
Definition: ntddvdeo.h:294
USHORT YResolution
Definition: vbemp.h:143
UCHAR LinRedMaskSize
Definition: vbemp.h:174
UCHAR GreenMaskSize
Definition: vbemp.h:157
unsigned int ULONG
Definition: retypes.h:1
UCHAR NumberOfPlanes
Definition: vbemp.h:146
UCHAR LinGreenFieldPosition
Definition: vbemp.h:177
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
#define VIDEO_MODE_GRAPHICS
Definition: ntddvdeo.h:295

Referenced by VBEQueryAvailModes(), and VBEQueryCurrentMode().

◆ VBEQueryNumAvailModes()

BOOLEAN FASTCALL VBEQueryNumAvailModes ( PVBE_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_NUM_MODES  Modes,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 826 of file vbemp.c.

830 {
831  Modes->NumModes = DeviceExtension->ModeCount;
832  Modes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
833  StatusBlock->Information = sizeof(VIDEO_NUM_MODES);
834  return TRUE;
835 }
struct _VIDEO_NUM_MODES VIDEO_NUM_MODES
#define TRUE
Definition: types.h:120
static const VBE_MODE Modes[VBE_MODE_COUNT]
Definition: vbe.c:189
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
ULONG_PTR Information
Definition: video.h:326

Referenced by VBEStartIO().

◆ VBEResetDevice()

BOOLEAN FASTCALL VBEResetDevice ( PVBE_DEVICE_EXTENSION  DeviceExtension,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 726 of file vbemp.c.

729 {
730  INT10_BIOS_ARGUMENTS BiosRegisters;
731 
732  VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
733  BiosRegisters.Eax = VBE_SET_VBE_MODE;
734  BiosRegisters.Ebx = 0x3;
735  DeviceExtension->Int10Interface.Int10CallBios(
736  DeviceExtension->Int10Interface.Context,
737  &BiosRegisters);
738 
739  return VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS;
740 }
#define VBE_GETRETURNCODE(x)
Definition: vbemp.h:100
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
#define VBE_SUCCESS
Definition: vbemp.h:95
#define VBE_SET_VBE_MODE
Definition: vbemp.h:48
VIDEO_PORT_INT10_INTERFACE Int10Interface
Definition: vbemp.h:194
OUT PINT10_CALL_BIOS Int10CallBios
Definition: video.h:782

Referenced by VBEStartIO().

◆ VBEResetHw()

BOOLEAN NTAPI VBEResetHw ( PVOID  DeviceExtension,
ULONG  Columns,
ULONG  Rows 
)

Definition at line 547 of file vbemp.c.

551 {
552  /* Return FALSE to let HAL reset the display with INT10 */
553  return FALSE;
554 }
#define FALSE
Definition: types.h:117

Referenced by DriverEntry().

◆ VBESetColorRegisters()

BOOLEAN FASTCALL VBESetColorRegisters ( PVBE_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_CLUT  ColorLookUpTable,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 978 of file vbemp.c.

982 {
983  INT10_BIOS_ARGUMENTS BiosRegisters;
984  ULONG Entry;
985  PULONG OutputEntry;
986  ULONG OutputBuffer[256];
987 
988  if (ColorLookUpTable->NumEntries + ColorLookUpTable->FirstEntry > 256)
989  return FALSE;
990 
991  /*
992  * For VGA compatible adapters program the color registers directly.
993  */
994 
995  if (!(DeviceExtension->VbeInfo.Capabilities & 2))
996  {
997  for (Entry = ColorLookUpTable->FirstEntry;
998  Entry < ColorLookUpTable->NumEntries + ColorLookUpTable->FirstEntry;
999  Entry++)
1000  {
1002  VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Red);
1003  VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Green);
1004  VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Blue);
1005  }
1006 
1007  return TRUE;
1008  }
1009  else
1010  {
1011  /*
1012  * We can't just copy the values, because we need to swap the Red
1013  * and Blue values.
1014  */
1015 
1016  for (Entry = ColorLookUpTable->FirstEntry,
1017  OutputEntry = OutputBuffer;
1018  Entry < ColorLookUpTable->NumEntries + ColorLookUpTable->FirstEntry;
1019  Entry++, OutputEntry++)
1020  {
1021  *OutputEntry =
1022  (ColorLookUpTable->LookupTable[Entry].RgbArray.Red << 16) |
1023  (ColorLookUpTable->LookupTable[Entry].RgbArray.Green << 8) |
1024  (ColorLookUpTable->LookupTable[Entry].RgbArray.Blue);
1025  }
1026 
1027  DeviceExtension->Int10Interface.Int10WriteMemory(
1028  DeviceExtension->Int10Interface.Context,
1029  DeviceExtension->TrampolineMemorySegment,
1030  DeviceExtension->TrampolineMemoryOffset,
1031  OutputBuffer,
1032  (OutputEntry - OutputBuffer) * sizeof(ULONG));
1033 
1034  VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
1035  BiosRegisters.Eax = VBE_SET_GET_PALETTE_DATA;
1036  BiosRegisters.Ebx = 0;
1037  BiosRegisters.Ecx = ColorLookUpTable->NumEntries;
1038  BiosRegisters.Edx = ColorLookUpTable->FirstEntry;
1039  BiosRegisters.Edi = DeviceExtension->TrampolineMemoryOffset;
1040  BiosRegisters.SegEs = DeviceExtension->TrampolineMemorySegment;
1041  DeviceExtension->Int10Interface.Int10CallBios(
1042  DeviceExtension->Int10Interface.Context,
1043  &BiosRegisters);
1044 
1045  return VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS;
1046  }
1047 }
struct _Entry Entry
Definition: kefuncs.h:627
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
USHORT FirstEntry
Definition: ntddvdeo.h:521
#define VBE_GETRETURNCODE(x)
Definition: vbemp.h:100
VIDEO_CLUTDATA RgbArray
Definition: ntddvdeo.h:523
LONG Capabilities
Definition: vbemp.h:112
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
#define VBE_SUCCESS
Definition: vbemp.h:95
#define FALSE
Definition: types.h:117
union VIDEO_CLUT::@3094 LookupTable[1]
USHORT TrampolineMemorySegment
Definition: vbemp.h:197
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:859
VBE_INFO VbeInfo
Definition: vbemp.h:201
USHORT NumEntries
Definition: ntddvdeo.h:520
#define VBE_SET_GET_PALETTE_DATA
Definition: vbemp.h:55
VIDEO_PORT_INT10_INTERFACE Int10Interface
Definition: vbemp.h:194
USHORT TrampolineMemoryOffset
Definition: vbemp.h:198
unsigned int * PULONG
Definition: retypes.h:1
OUT PINT10_WRITE_MEMORY Int10WriteMemory
Definition: video.h:781
unsigned int ULONG
Definition: retypes.h:1
OUT PINT10_CALL_BIOS Int10CallBios
Definition: video.h:782
VPAPI VOID NTAPI VideoPortWritePortUchar(IN PUCHAR Port, IN UCHAR Value)
base of all file and directory entries
Definition: entries.h:82

Referenced by VBEStartIO().

◆ VBESetCurrentMode()

BOOLEAN FASTCALL VBESetCurrentMode ( PVBE_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_MODE  RequestedMode,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 686 of file vbemp.c.

690 {
691  INT10_BIOS_ARGUMENTS BiosRegisters;
692 
693  if (RequestedMode->RequestedMode >= DeviceExtension->ModeCount)
694  {
696  }
697 
698  VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
699  BiosRegisters.Eax = VBE_SET_VBE_MODE;
700  BiosRegisters.Ebx = DeviceExtension->ModeNumbers[RequestedMode->RequestedMode];
701  DeviceExtension->Int10Interface.Int10CallBios(
702  DeviceExtension->Int10Interface.Context,
703  &BiosRegisters);
704 
705  if (VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS)
706  {
707  DeviceExtension->CurrentMode = RequestedMode->RequestedMode;
708  }
709  else
710  {
711  VideoPortDebugPrint(Error, "VBEMP: VBESetCurrentMode failed (%x)\n", BiosRegisters.Eax);
712  DeviceExtension->CurrentMode = -1;
713  }
714 
715  return VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS;
716 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define VBE_GETRETURNCODE(x)
Definition: vbemp.h:100
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
ULONG RequestedMode
Definition: ntddvdeo.h:290
#define VBE_SUCCESS
Definition: vbemp.h:95
BOOL Error
Definition: chkdsk.c:66
#define VBE_SET_VBE_MODE
Definition: vbemp.h:48
VIDEO_PORT_INT10_INTERFACE Int10Interface
Definition: vbemp.h:194
USHORT * ModeNumbers
Definition: vbemp.h:205
OUT PINT10_CALL_BIOS Int10CallBios
Definition: video.h:782
VPAPI VOID __cdecl VideoPortDebugPrint(IN VIDEO_DEBUG_LEVEL DebugPrintLevel, IN PSTR DebugMessage, IN ...)
USHORT CurrentMode
Definition: vbemp.h:207

Referenced by VBEStartIO().

◆ VBESetPowerState()

VP_STATUS NTAPI VBESetPowerState ( PVOID  HwDeviceExtension,
ULONG  HwId,
PVIDEO_POWER_MANAGEMENT  VideoPowerControl 
)

Definition at line 633 of file vbemp.c.

637 {
638  INT10_BIOS_ARGUMENTS BiosRegisters;
639  PVBE_DEVICE_EXTENSION VBEDeviceExtension =
640  (PVBE_DEVICE_EXTENSION)HwDeviceExtension;
641 
642  if (HwId != DISPLAY_ADAPTER_HW_ID ||
643  VideoPowerControl->Length < sizeof(VIDEO_POWER_MANAGEMENT) ||
644  VideoPowerControl->PowerState < VideoPowerOn ||
645  VideoPowerControl->PowerState > VideoPowerHibernate)
646  return ERROR_INVALID_FUNCTION;
647 
648  if (VideoPowerControl->PowerState == VideoPowerHibernate)
649  return NO_ERROR;
650 
651  /*
652  * Set current power state.
653  */
654 
655  VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
656  BiosRegisters.Eax = VBE_POWER_MANAGEMENT_EXTENSIONS;
657  BiosRegisters.Ebx = 1;
658  BiosRegisters.Edi = 0;
659  BiosRegisters.SegEs = 0;
660  switch (VideoPowerControl->PowerState)
661  {
662  case VideoPowerStandBy: BiosRegisters.Ebx |= 0x100; break;
663  case VideoPowerSuspend: BiosRegisters.Ebx |= 0x200; break;
664  case VideoPowerOff: BiosRegisters.Ebx |= 0x400; break;
665  }
666 
667  VBEDeviceExtension->Int10Interface.Int10CallBios(
668  VBEDeviceExtension->Int10Interface.Context,
669  &BiosRegisters);
670 
671  if (VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_NOT_SUPPORTED)
672  return ERROR_DEV_NOT_EXIST;
673  if (VBE_GETRETURNCODE(BiosRegisters.Eax) != VBE_SUCCESS)
674  return ERROR_INVALID_FUNCTION;
675 
676  return VBE_SUCCESS;
677 }
#define DISPLAY_ADAPTER_HW_ID
Definition: video.h:115
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#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
#define VBE_NOT_SUPPORTED
Definition: vbemp.h:97
VIDEO_PORT_INT10_INTERFACE Int10Interface
Definition: vbemp.h:194
#define VBE_POWER_MANAGEMENT_EXTENSIONS
Definition: vbemp.h:62
struct VBE_DEVICE_EXTENSION * PVBE_DEVICE_EXTENSION
OUT PINT10_CALL_BIOS Int10CallBios
Definition: video.h:782
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8

Referenced by DriverEntry().

◆ VBESortModes()

VOID FASTCALL VBESortModes ( PVBE_DEVICE_EXTENSION  DeviceExtension)

Definition at line 114 of file vbemp.c.

115 {
116  BOOLEAN Finished = FALSE;
117  ULONG Pos;
118  int Result;
119  VBE_MODEINFO TempModeInfo;
120  USHORT TempModeNumber;
121 
122  while (!Finished)
123  {
124  Finished = TRUE;
125  for (Pos = 0; Pos < DeviceExtension->ModeCount - 1; Pos++)
126  {
128  DeviceExtension->ModeInfo + Pos,
129  DeviceExtension->ModeInfo + Pos + 1);
130  if (Result > 0)
131  {
132  Finished = FALSE;
133 
135  &TempModeInfo,
136  DeviceExtension->ModeInfo + Pos,
137  sizeof(VBE_MODEINFO));
138  TempModeNumber = DeviceExtension->ModeNumbers[Pos];
139 
141  DeviceExtension->ModeInfo + Pos,
142  DeviceExtension->ModeInfo + Pos + 1,
143  sizeof(VBE_MODEINFO));
144  DeviceExtension->ModeNumbers[Pos] =
145  DeviceExtension->ModeNumbers[Pos + 1];
146 
148  DeviceExtension->ModeInfo + Pos + 1,
149  &TempModeInfo,
150  sizeof(VBE_MODEINFO));
151  DeviceExtension->ModeNumbers[Pos + 1] = TempModeNumber;
152  }
153  }
154  }
155 }
#define TRUE
Definition: types.h:120
ush Pos
Definition: deflate.h:92
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
_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
PVBE_MODEINFO ModeInfo
Definition: vbemp.h:206
static int VBESortModesCallback(PVBE_MODEINFO VbeModeInfoA, PVBE_MODEINFO VbeModeInfoB)
Definition: vbemp.c:91
VPAPI VOID NTAPI VideoPortMoveMemory(IN PVOID Destination, IN PVOID Source, IN ULONG Length)
unsigned short USHORT
Definition: pedump.c:61
USHORT * ModeNumbers
Definition: vbemp.h:205
unsigned int ULONG
Definition: retypes.h:1

Referenced by VBEInitialize().

◆ VBESortModesCallback()

static int VBESortModesCallback ( PVBE_MODEINFO  VbeModeInfoA,
PVBE_MODEINFO  VbeModeInfoB 
)
static

Definition at line 91 of file vbemp.c.

92 {
93  /*
94  * FIXME: Until some reasonable method for changing video modes will
95  * be available we favor more bits per pixel. It should be changed
96  * later.
97  */
98  if (VbeModeInfoA->BitsPerPixel < VbeModeInfoB->BitsPerPixel) return -1;
99  if (VbeModeInfoA->BitsPerPixel > VbeModeInfoB->BitsPerPixel) return 1;
100  if (VbeModeInfoA->XResolution < VbeModeInfoB->XResolution) return -1;
101  if (VbeModeInfoA->XResolution > VbeModeInfoB->XResolution) return 1;
102  if (VbeModeInfoA->YResolution < VbeModeInfoB->YResolution) return -1;
103  if (VbeModeInfoA->YResolution > VbeModeInfoB->YResolution) return 1;
104  return 0;
105 }
UCHAR BitsPerPixel
Definition: vbemp.h:147
USHORT XResolution
Definition: vbemp.h:142
USHORT YResolution
Definition: vbemp.h:143

Referenced by VBESortModes().

◆ VBEStartIO()

BOOLEAN NTAPI VBEStartIO ( PVOID  HwDeviceExtension,
PVIDEO_REQUEST_PACKET  RequestPacket 
)

Definition at line 423 of file vbemp.c.

426 {
427  BOOLEAN Result;
428 
429  RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
430 
431  switch (RequestPacket->IoControlCode)
432  {
434  if (RequestPacket->InputBufferLength < sizeof(VIDEO_MODE))
435  {
436  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
437  return TRUE;
438  }
440  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
441  (PVIDEO_MODE)RequestPacket->InputBuffer,
442  RequestPacket->StatusBlock);
443  break;
444 
447  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
448  RequestPacket->StatusBlock);
449  break;
450 
452  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MEMORY_INFORMATION) ||
453  RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
454  {
455  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
456  return TRUE;
457  }
459  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
460  (PVIDEO_MEMORY)RequestPacket->InputBuffer,
461  (PVIDEO_MEMORY_INFORMATION)RequestPacket->OutputBuffer,
462  RequestPacket->StatusBlock);
463  break;
464 
466  if (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
467  {
468  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
469  return TRUE;
470  }
472  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
473  (PVIDEO_MEMORY)RequestPacket->InputBuffer,
474  RequestPacket->StatusBlock);
475  break;
476 
478  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_NUM_MODES))
479  {
480  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
481  return TRUE;
482  }
484  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
485  (PVIDEO_NUM_MODES)RequestPacket->OutputBuffer,
486  RequestPacket->StatusBlock);
487  break;
488 
490  if (RequestPacket->OutputBufferLength <
491  ((PVBE_DEVICE_EXTENSION)HwDeviceExtension)->ModeCount * sizeof(VIDEO_MODE_INFORMATION))
492  {
493  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
494  return TRUE;
495  }
497  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
498  (PVIDEO_MODE_INFORMATION)RequestPacket->OutputBuffer,
499  RequestPacket->StatusBlock);
500  break;
501 
503  if (RequestPacket->InputBufferLength < sizeof(VIDEO_CLUT) ||
504  RequestPacket->InputBufferLength <
505  (((PVIDEO_CLUT)RequestPacket->InputBuffer)->NumEntries * sizeof(ULONG)) +
506  FIELD_OFFSET(VIDEO_CLUT, LookupTable))
507  {
508  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
509  return TRUE;
510  }
512  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
513  (PVIDEO_CLUT)RequestPacket->InputBuffer,
514  RequestPacket->StatusBlock);
515  break;
516 
518  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MODE_INFORMATION))
519  {
520  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
521  return TRUE;
522  }
524  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
525  (PVIDEO_MODE_INFORMATION)RequestPacket->OutputBuffer,
526  RequestPacket->StatusBlock);
527  break;
528 
529  default:
530  RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
531  return FALSE;
532  }
533 
534  if (Result)
535  RequestPacket->StatusBlock->Status = NO_ERROR;
536 
537  return TRUE;
538 }
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define TRUE
Definition: types.h:120
#define IOCTL_VIDEO_RESET_DEVICE
Definition: ntddvdeo.h:137
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:104
ULONG InputBufferLength
Definition: video.h:333
#define NO_ERROR
Definition: dderror.h:5
#define IOCTL_VIDEO_QUERY_CURRENT_MODE
Definition: ntddvdeo.h:113
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:152
#define FALSE
Definition: types.h:117
BOOLEAN FASTCALL VBEQueryAvailModes(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION ReturnedModes, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:923
unsigned char BOOLEAN
_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
ULONG OutputBufferLength
Definition: video.h:335
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:179
BOOLEAN FASTCALL VBEResetDevice(PVBE_DEVICE_EXTENSION DeviceExtension, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:726
BOOLEAN FASTCALL VBESetColorRegisters(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_CLUT ColorLookUpTable, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:978
BOOLEAN FASTCALL VBEUnmapVideoMemory(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MEMORY VideoMemory, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:807
VP_STATUS Status
Definition: video.h:323
#define IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES
Definition: ntddvdeo.h:122
#define IOCTL_VIDEO_QUERY_AVAIL_MODES
Definition: ntddvdeo.h:107
BOOLEAN FASTCALL VBEQueryCurrentMode(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION VideoModeInfo, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:953
BOOLEAN FASTCALL VBEMapVideoMemory(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MEMORY RequestedAddress, PVIDEO_MEMORY_INFORMATION MapInformation, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:750
BOOLEAN FASTCALL VBESetCurrentMode(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE RequestedMode, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:686
BOOLEAN FASTCALL VBEQueryNumAvailModes(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_NUM_MODES Modes, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:826
PSTATUS_BLOCK StatusBlock
Definition: video.h:331
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned int ULONG
Definition: retypes.h:1
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:149
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by DriverEntry().

◆ VBEUnmapVideoMemory()

BOOLEAN FASTCALL VBEUnmapVideoMemory ( PVBE_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_MEMORY  VideoMemory,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 807 of file vbemp.c.

811 {
812  VideoPortUnmapMemory(DeviceExtension, VideoMemory->RequestedVirtualAddress,
813  NULL);
814  return TRUE;
815 }
#define TRUE
Definition: types.h:120
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:275
VPAPI VP_STATUS NTAPI VideoPortUnmapMemory(IN PVOID HwDeviceExtension, IN OUT PVOID VirtualAddress, IN HANDLE ProcessHandle)
#define NULL
Definition: types.h:112

Referenced by VBEStartIO().