ReactOS  0.4.14-dev-384-g5b37caa
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:218
BOOLEAN NTAPI VBEStartIO(PVOID HwDeviceExtension, PVIDEO_REQUEST_PACKET RequestPacket)
Definition: vbemp.c:427
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:567
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:455
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:637
smooth NULL
Definition: ftsmooth.c:416
struct _VIDEO_HW_INITIALIZATION_DATA VIDEO_HW_INITIALIZATION_DATA
BOOLEAN NTAPI VBEInitialize(PVOID HwDeviceExtension)
Definition: vbemp.c:174
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:551
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT Context1
Definition: tdikrnl.h:1094

◆ 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  return NO_ERROR;
80 }
#define NO_ERROR
Definition: dderror.h:5
VPAPI BOOLEAN NTAPI VideoPortIsNoVesa(VOID)
Definition: videoprt.c:1397
#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 567 of file vbemp.c.

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

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

759 {
761  ULONG inIoSpace = VIDEO_MEMORY_SPACE_MEMORY;
762 
763  StatusBlock->Information = sizeof(VIDEO_MEMORY_INFORMATION);
764 
765  if (DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].ModeAttributes &
767  {
768  FrameBuffer.QuadPart =
769  DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].PhysBasePtr;
770  MapInformation->VideoRamBase = RequestedAddress->RequestedVirtualAddress;
771  if (DeviceExtension->VbeInfo.Version < 0x300)
772  {
773  MapInformation->VideoRamLength =
774  DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].BytesPerScanLine *
775  DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].YResolution;
776  }
777  else
778  {
779  MapInformation->VideoRamLength =
780  DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].LinBytesPerScanLine *
781  DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].YResolution;
782  }
783  }
784 #ifdef VBE12_SUPPORT
785  else
786  {
787  FrameBuffer.QuadPart = 0xA0000;
788  MapInformation->VideoRamBase = RequestedAddress->RequestedVirtualAddress;
789  MapInformation->VideoRamLength = 0x10000;
790  }
791 #endif
792 
793  VideoPortMapMemory(DeviceExtension, FrameBuffer,
794  &MapInformation->VideoRamLength, &inIoSpace,
795  &MapInformation->VideoRamBase);
796 
797  MapInformation->FrameBufferBase = MapInformation->VideoRamBase;
798  MapInformation->FrameBufferLength = MapInformation->VideoRamLength;
799 
800  return TRUE;
801 }
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:274
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
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
PVOID FrameBuffer
Definition: xboxvideo.c:27
#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 927 of file vbemp.c.

931 {
932  ULONG CurrentModeId;
933  PVIDEO_MODE_INFORMATION CurrentMode;
934  PVBE_MODEINFO CurrentVBEMode;
935 
936  for (CurrentModeId = 0, CurrentMode = ReturnedModes,
937  CurrentVBEMode = DeviceExtension->ModeInfo;
938  CurrentModeId < DeviceExtension->ModeCount;
939  CurrentModeId++, CurrentMode++, CurrentVBEMode++)
940  {
941  VBEQueryMode(DeviceExtension, CurrentMode, CurrentModeId);
942  }
943 
944  StatusBlock->Information =
945  sizeof(VIDEO_MODE_INFORMATION) * DeviceExtension->ModeCount;
946 
947  return TRUE;
948 }
#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:848
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 957 of file vbemp.c.

961 {
962  StatusBlock->Information = sizeof(VIDEO_MODE_INFORMATION);
963 
964  VBEQueryMode(
965  DeviceExtension,
966  VideoModeInfo,
967  DeviceExtension->CurrentMode);
968 
969  return TRUE;
970 }
#define TRUE
Definition: types.h:120
VOID FASTCALL VBEQueryMode(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION VideoMode, ULONG VideoModeId)
Definition: vbemp.c:848
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 848 of file vbemp.c.

852 {
853  PVBE_MODEINFO VBEMode = &DeviceExtension->ModeInfo[VideoModeId];
854  ULONG dpi;
855 
856  VideoMode->Length = sizeof(VIDEO_MODE_INFORMATION);
857  VideoMode->ModeIndex = VideoModeId;
858  VideoMode->VisScreenWidth = VBEMode->XResolution;
859  VideoMode->VisScreenHeight = VBEMode->YResolution;
860  if (DeviceExtension->VbeInfo.Version < 0x300)
861  VideoMode->ScreenStride = VBEMode->BytesPerScanLine;
862  else
863  VideoMode->ScreenStride = VBEMode->LinBytesPerScanLine;
864  VideoMode->NumberOfPlanes = VBEMode->NumberOfPlanes;
865  VideoMode->BitsPerPlane = VBEMode->BitsPerPixel / VBEMode->NumberOfPlanes;
866  VideoMode->Frequency = 1;
867 
868  /* Assume 96DPI and 25.4 millimeters per inch, round to nearest */
869  dpi = 96;
870  VideoMode->XMillimeter = ((ULONGLONG)VBEMode->XResolution * 254 + (dpi * 5)) / (dpi * 10);
871  VideoMode->YMillimeter = ((ULONGLONG)VBEMode->YResolution * 254 + (dpi * 5)) / (dpi * 10);
872 
873  if (VBEMode->BitsPerPixel > 8)
874  {
875  /*
876  * Always report 16bpp modes and not 15bpp mode...
877  */
878  if (VBEMode->BitsPerPixel == 15 && VBEMode->NumberOfPlanes == 1)
879  {
880  VideoMode->BitsPerPlane = 16;
881  }
882 
883  if (DeviceExtension->VbeInfo.Version < 0x300)
884  {
885  VideoMode->NumberRedBits = VBEMode->RedMaskSize;
886  VideoMode->NumberGreenBits = VBEMode->GreenMaskSize;
887  VideoMode->NumberBlueBits = VBEMode->BlueMaskSize;
888  VideoMode->RedMask = ((1 << VBEMode->RedMaskSize) - 1) << VBEMode->RedFieldPosition;
889  VideoMode->GreenMask = ((1 << VBEMode->GreenMaskSize) - 1) << VBEMode->GreenFieldPosition;
890  VideoMode->BlueMask = ((1 << VBEMode->BlueMaskSize) - 1) << VBEMode->BlueFieldPosition;
891  }
892  else
893  {
894  VideoMode->NumberRedBits = VBEMode->LinRedMaskSize;
895  VideoMode->NumberGreenBits = VBEMode->LinGreenMaskSize;
896  VideoMode->NumberBlueBits = VBEMode->LinBlueMaskSize;
897  VideoMode->RedMask = ((1 << VBEMode->LinRedMaskSize) - 1) << VBEMode->LinRedFieldPosition;
898  VideoMode->GreenMask = ((1 << VBEMode->LinGreenMaskSize) - 1) << VBEMode->LinGreenFieldPosition;
899  VideoMode->BlueMask = ((1 << VBEMode->LinBlueMaskSize) - 1) << VBEMode->LinBlueFieldPosition;
900  }
901  }
902  else
903  {
904  VideoMode->NumberRedBits =
905  VideoMode->NumberGreenBits =
906  VideoMode->NumberBlueBits = 6;
907  VideoMode->RedMask =
908  VideoMode->GreenMask =
909  VideoMode->BlueMask = 0;
910  }
911  VideoMode->VideoMemoryBitmapWidth = VBEMode->XResolution;
912  VideoMode->VideoMemoryBitmapHeight = VBEMode->YResolution;
913  VideoMode->AttributeFlags = VIDEO_MODE_GRAPHICS | VIDEO_MODE_COLOR |
915  if (VideoMode->BitsPerPlane <= 8)
916  VideoMode->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN;
917  VideoMode->DriverSpecificAttributeFlags = 0;
918 }
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:298
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:65
#define VIDEO_MODE_PALETTE_DRIVEN
Definition: ntddvdeo.h:295
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:293
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:294

Referenced by VBEQueryAvailModes(), and VBEQueryCurrentMode().

◆ VBEQueryNumAvailModes()

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

Definition at line 830 of file vbemp.c.

834 {
835  Modes->NumModes = DeviceExtension->ModeCount;
836  Modes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
837  StatusBlock->Information = sizeof(VIDEO_NUM_MODES);
838  return TRUE;
839 }
#define TRUE
Definition: types.h:120
struct _VIDEO_NUM_MODES VIDEO_NUM_MODES
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 730 of file vbemp.c.

733 {
734  INT10_BIOS_ARGUMENTS BiosRegisters;
735 
736  VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
737  BiosRegisters.Eax = VBE_SET_VBE_MODE;
738  BiosRegisters.Ebx = 0x3;
739  DeviceExtension->Int10Interface.Int10CallBios(
740  DeviceExtension->Int10Interface.Context,
741  &BiosRegisters);
742 
743  return VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS;
744 }
#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 551 of file vbemp.c.

555 {
556  /* Return FALSE to let HAL reset the display with INT10 */
557  return FALSE;
558 }

Referenced by DriverEntry().

◆ VBESetColorRegisters()

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

Definition at line 982 of file vbemp.c.

986 {
987  INT10_BIOS_ARGUMENTS BiosRegisters;
988  ULONG Entry;
989  PULONG OutputEntry;
990  ULONG OutputBuffer[256];
991 
992  if (ColorLookUpTable->NumEntries + ColorLookUpTable->FirstEntry > 256)
993  return FALSE;
994 
995  /*
996  * For VGA compatible adapters program the color registers directly.
997  */
998 
999  if (!(DeviceExtension->VbeInfo.Capabilities & 2))
1000  {
1001  for (Entry = ColorLookUpTable->FirstEntry;
1002  Entry < ColorLookUpTable->NumEntries + ColorLookUpTable->FirstEntry;
1003  Entry++)
1004  {
1006  VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Red);
1007  VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Green);
1008  VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Blue);
1009  }
1010 
1011  return TRUE;
1012  }
1013  else
1014  {
1015  /*
1016  * We can't just copy the values, because we need to swap the Red
1017  * and Blue values.
1018  */
1019 
1020  for (Entry = ColorLookUpTable->FirstEntry,
1021  OutputEntry = OutputBuffer;
1022  Entry < ColorLookUpTable->NumEntries + ColorLookUpTable->FirstEntry;
1023  Entry++, OutputEntry++)
1024  {
1025  *OutputEntry =
1026  (ColorLookUpTable->LookupTable[Entry].RgbArray.Red << 16) |
1027  (ColorLookUpTable->LookupTable[Entry].RgbArray.Green << 8) |
1028  (ColorLookUpTable->LookupTable[Entry].RgbArray.Blue);
1029  }
1030 
1031  DeviceExtension->Int10Interface.Int10WriteMemory(
1032  DeviceExtension->Int10Interface.Context,
1033  DeviceExtension->TrampolineMemorySegment,
1034  DeviceExtension->TrampolineMemoryOffset,
1035  OutputBuffer,
1036  (OutputEntry - OutputBuffer) * sizeof(ULONG));
1037 
1038  VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
1039  BiosRegisters.Eax = VBE_SET_GET_PALETTE_DATA;
1040  BiosRegisters.Ebx = 0;
1041  BiosRegisters.Ecx = ColorLookUpTable->NumEntries;
1042  BiosRegisters.Edx = ColorLookUpTable->FirstEntry;
1043  BiosRegisters.Edi = DeviceExtension->TrampolineMemoryOffset;
1044  BiosRegisters.SegEs = DeviceExtension->TrampolineMemorySegment;
1045  DeviceExtension->Int10Interface.Int10CallBios(
1046  DeviceExtension->Int10Interface.Context,
1047  &BiosRegisters);
1048 
1049  return VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS;
1050  }
1051 }
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:640
unsigned char * PUCHAR
Definition: retypes.h:3
USHORT FirstEntry
Definition: ntddvdeo.h:520
#define VBE_GETRETURNCODE(x)
Definition: vbemp.h:100
VIDEO_CLUTDATA RgbArray
Definition: ntddvdeo.h:522
LONG Capabilities
Definition: vbemp.h:112
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
#define VBE_SUCCESS
Definition: vbemp.h:95
USHORT TrampolineMemorySegment
Definition: vbemp.h:197
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
VBE_INFO VbeInfo
Definition: vbemp.h:201
USHORT NumEntries
Definition: ntddvdeo.h:519
#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
union VIDEO_CLUT::@3066 LookupTable[1]
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 690 of file vbemp.c.

694 {
695  INT10_BIOS_ARGUMENTS BiosRegisters;
696 
697  if (RequestedMode->RequestedMode >= DeviceExtension->ModeCount)
698  {
700  }
701 
702  VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
703  BiosRegisters.Eax = VBE_SET_VBE_MODE;
704  BiosRegisters.Ebx = DeviceExtension->ModeNumbers[RequestedMode->RequestedMode];
705  DeviceExtension->Int10Interface.Int10CallBios(
706  DeviceExtension->Int10Interface.Context,
707  &BiosRegisters);
708 
709  if (VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS)
710  {
711  DeviceExtension->CurrentMode = RequestedMode->RequestedMode;
712  }
713  else
714  {
715  VideoPortDebugPrint(Error, "VBEMP: VBESetCurrentMode failed (%x)\n", BiosRegisters.Eax);
716  DeviceExtension->CurrentMode = -1;
717  }
718 
719  return VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS;
720 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define VBE_GETRETURNCODE(x)
Definition: vbemp.h:100
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
ULONG RequestedMode
Definition: ntddvdeo.h:289
#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 637 of file vbemp.c.

641 {
642  INT10_BIOS_ARGUMENTS BiosRegisters;
643  PVBE_DEVICE_EXTENSION VBEDeviceExtension =
644  (PVBE_DEVICE_EXTENSION)HwDeviceExtension;
645 
646  if (HwId != DISPLAY_ADAPTER_HW_ID ||
647  VideoPowerControl->Length < sizeof(VIDEO_POWER_MANAGEMENT) ||
648  VideoPowerControl->PowerState < VideoPowerOn ||
649  VideoPowerControl->PowerState > VideoPowerHibernate)
650  return ERROR_INVALID_FUNCTION;
651 
652  if (VideoPowerControl->PowerState == VideoPowerHibernate)
653  return NO_ERROR;
654 
655  /*
656  * Set current power state.
657  */
658 
659  VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
660  BiosRegisters.Eax = VBE_POWER_MANAGEMENT_EXTENSIONS;
661  BiosRegisters.Ebx = 1;
662  BiosRegisters.Edi = 0;
663  BiosRegisters.SegEs = 0;
664  switch (VideoPowerControl->PowerState)
665  {
666  case VideoPowerStandBy: BiosRegisters.Ebx |= 0x100; break;
667  case VideoPowerSuspend: BiosRegisters.Ebx |= 0x200; break;
668  case VideoPowerOff: BiosRegisters.Ebx |= 0x400; break;
669  }
670 
671  VBEDeviceExtension->Int10Interface.Int10CallBios(
672  VBEDeviceExtension->Int10Interface.Context,
673  &BiosRegisters);
674 
675  if (VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_NOT_SUPPORTED)
676  return ERROR_DEV_NOT_EXIST;
677  if (VBE_GETRETURNCODE(BiosRegisters.Eax) != VBE_SUCCESS)
678  return ERROR_INVALID_FUNCTION;
679 
680  return VBE_SUCCESS;
681 }
#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 118 of file vbemp.c.

119 {
120  BOOLEAN Finished = FALSE;
121  ULONG Pos;
122  int Result;
123  VBE_MODEINFO TempModeInfo;
124  USHORT TempModeNumber;
125 
126  while (!Finished)
127  {
128  Finished = TRUE;
129  for (Pos = 0; Pos < DeviceExtension->ModeCount - 1; Pos++)
130  {
132  DeviceExtension->ModeInfo + Pos,
133  DeviceExtension->ModeInfo + Pos + 1);
134  if (Result > 0)
135  {
136  Finished = FALSE;
137 
139  &TempModeInfo,
140  DeviceExtension->ModeInfo + Pos,
141  sizeof(VBE_MODEINFO));
142  TempModeNumber = DeviceExtension->ModeNumbers[Pos];
143 
145  DeviceExtension->ModeInfo + Pos,
146  DeviceExtension->ModeInfo + Pos + 1,
147  sizeof(VBE_MODEINFO));
148  DeviceExtension->ModeNumbers[Pos] =
149  DeviceExtension->ModeNumbers[Pos + 1];
150 
152  DeviceExtension->ModeInfo + Pos + 1,
153  &TempModeInfo,
154  sizeof(VBE_MODEINFO));
155  DeviceExtension->ModeNumbers[Pos + 1] = TempModeNumber;
156  }
157  }
158  }
159 }
#define TRUE
Definition: types.h:120
ush Pos
Definition: deflate.h:92
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:89
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 89 of file vbemp.c.

90 {
91  VideoPortDebugPrint(Info, "VBESortModesCallback: %dx%dx%d / %dx%dx%d\n",
92  VbeModeInfoA->XResolution, VbeModeInfoA->YResolution,
93  VbeModeInfoA->BitsPerPixel,
94  VbeModeInfoB->XResolution, VbeModeInfoB->YResolution,
95  VbeModeInfoB->BitsPerPixel);
96 
97  /*
98  * FIXME: Until some reasonable method for changing video modes will
99  * be available we favor more bits per pixel. It should be changed
100  * later.
101  */
102  if (VbeModeInfoA->BitsPerPixel < VbeModeInfoB->BitsPerPixel) return -1;
103  if (VbeModeInfoA->BitsPerPixel > VbeModeInfoB->BitsPerPixel) return 1;
104  if (VbeModeInfoA->XResolution < VbeModeInfoB->XResolution) return -1;
105  if (VbeModeInfoA->XResolution > VbeModeInfoB->XResolution) return 1;
106  if (VbeModeInfoA->YResolution < VbeModeInfoB->YResolution) return -1;
107  if (VbeModeInfoA->YResolution > VbeModeInfoB->YResolution) return 1;
108  return 0;
109 }
UCHAR BitsPerPixel
Definition: vbemp.h:147
USHORT XResolution
Definition: vbemp.h:142
struct TraceInfo Info
USHORT YResolution
Definition: vbemp.h:143
VPAPI VOID __cdecl VideoPortDebugPrint(IN VIDEO_DEBUG_LEVEL DebugPrintLevel, IN PSTR DebugMessage, IN ...)

Referenced by VBESortModes().

◆ VBEStartIO()

BOOLEAN NTAPI VBEStartIO ( PVOID  HwDeviceExtension,
PVIDEO_REQUEST_PACKET  RequestPacket 
)

Definition at line 427 of file vbemp.c.

430 {
431  BOOLEAN Result;
432 
433  RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
434 
435  switch (RequestPacket->IoControlCode)
436  {
438  if (RequestPacket->InputBufferLength < sizeof(VIDEO_MODE))
439  {
440  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
441  return TRUE;
442  }
444  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
445  (PVIDEO_MODE)RequestPacket->InputBuffer,
446  RequestPacket->StatusBlock);
447  break;
448 
451  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
452  RequestPacket->StatusBlock);
453  break;
454 
456  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MEMORY_INFORMATION) ||
457  RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
458  {
459  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
460  return TRUE;
461  }
463  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
464  (PVIDEO_MEMORY)RequestPacket->InputBuffer,
465  (PVIDEO_MEMORY_INFORMATION)RequestPacket->OutputBuffer,
466  RequestPacket->StatusBlock);
467  break;
468 
470  if (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
471  {
472  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
473  return TRUE;
474  }
476  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
477  (PVIDEO_MEMORY)RequestPacket->InputBuffer,
478  RequestPacket->StatusBlock);
479  break;
480 
482  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_NUM_MODES))
483  {
484  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
485  return TRUE;
486  }
488  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
489  (PVIDEO_NUM_MODES)RequestPacket->OutputBuffer,
490  RequestPacket->StatusBlock);
491  break;
492 
494  if (RequestPacket->OutputBufferLength <
495  ((PVBE_DEVICE_EXTENSION)HwDeviceExtension)->ModeCount * sizeof(VIDEO_MODE_INFORMATION))
496  {
497  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
498  return TRUE;
499  }
501  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
502  (PVIDEO_MODE_INFORMATION)RequestPacket->OutputBuffer,
503  RequestPacket->StatusBlock);
504  break;
505 
507  if (RequestPacket->InputBufferLength < sizeof(VIDEO_CLUT) ||
508  RequestPacket->InputBufferLength <
509  (((PVIDEO_CLUT)RequestPacket->InputBuffer)->NumEntries * sizeof(ULONG)) +
510  FIELD_OFFSET(VIDEO_CLUT, LookupTable))
511  {
512  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
513  return TRUE;
514  }
516  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
517  (PVIDEO_CLUT)RequestPacket->InputBuffer,
518  RequestPacket->StatusBlock);
519  break;
520 
522  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MODE_INFORMATION))
523  {
524  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
525  return TRUE;
526  }
528  (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
529  (PVIDEO_MODE_INFORMATION)RequestPacket->OutputBuffer,
530  RequestPacket->StatusBlock);
531  break;
532 
533  default:
534  RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
535  return FALSE;
536  }
537 
538  if (Result)
539  RequestPacket->StatusBlock->Status = NO_ERROR;
540 
541  return TRUE;
542 }
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#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
BOOLEAN FASTCALL VBEQueryAvailModes(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION ReturnedModes, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:927
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:730
BOOLEAN FASTCALL VBESetColorRegisters(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_CLUT ColorLookUpTable, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:982
BOOLEAN FASTCALL VBEUnmapVideoMemory(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MEMORY VideoMemory, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:811
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:957
BOOLEAN FASTCALL VBEMapVideoMemory(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MEMORY RequestedAddress, PVIDEO_MEMORY_INFORMATION MapInformation, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:754
BOOLEAN FASTCALL VBESetCurrentMode(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE RequestedMode, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:690
BOOLEAN FASTCALL VBEQueryNumAvailModes(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_NUM_MODES Modes, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:830
PSTATUS_BLOCK StatusBlock
Definition: video.h:331
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
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 811 of file vbemp.c.

815 {
816  VideoPortUnmapMemory(DeviceExtension, VideoMemory->RequestedVirtualAddress,
817  NULL);
818  return TRUE;
819 }
#define TRUE
Definition: types.h:120
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:274
smooth NULL
Definition: ftsmooth.c:416
VPAPI VP_STATUS NTAPI VideoPortUnmapMemory(IN PVOID HwDeviceExtension, IN OUT PVOID VirtualAddress, IN HANDLE ProcessHandle)

Referenced by VBEStartIO().