ReactOS  0.4.13-dev-73-gcfe54aa
vbemp.h File Reference
#include <ntdef.h>
#include <dderror.h>
#include <miniport.h>
#include <video.h>
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for vbemp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  VBE_INFO
 
struct  VBE_MODEINFO
 
struct  VBE_DEVICE_EXTENSION
 

Macros

#define TAG_VBE   ' EBV'
 
#define VBE_GET_CONTROLLER_INFORMATION   0x4F00
 
#define VBE_GET_MODE_INFORMATION   0x4F01
 
#define VBE_SET_VBE_MODE   0x4F02
 
#define VBE_GET_CURRENT_VBE_MODE   0x4F03
 
#define VBE_SAVE_RESTORE_STATE   0x4F04
 
#define VBE_DISPLAY_WINDOW_CONTROL   0x4F05
 
#define VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH   0x4F06
 
#define VBE_SET_GET_DISPLAY_START   0x4F07
 
#define VBE_SET_GET_DAC_PALETTE_FORMAT   0x4F08
 
#define VBE_SET_GET_PALETTE_DATA   0x4F09
 
#define VBE_RETURN_PROTECTED_MODE_INTERFACE   0x4F0A
 
#define VBE_GET_SET_PIXEL_CLOCK   0x4F0B
 
#define VBE_POWER_MANAGEMENT_EXTENSIONS   0x4F10
 
#define VBE_FLAT_PANEL_INTERFACE_EXTENSIONS   0x4F11
 
#define VBE_AUDIO_INTERFACE_EXTENSIONS   0x4F12
 
#define VBE_OEM_EXTENSIONS   0x4F13
 
#define VBE_DISPLAY_DATA_CHANNEL   0x4F14
 
#define VBE_DDC   0x4F15
 
#define VBE_DDC_READ_EDID   0x01
 
#define VBE_DDC_REPORT_CAPABILITIES   0x10
 
#define VBE_DDC_BEGIN_SCL_SDA_CONTROL   0x11
 
#define VBE_DDC_END_SCL_SDA_CONTROL   0x12
 
#define VBE_DDC_WRITE_SCL_CLOCK_LINE   0x13
 
#define VBE_DDC_WRITE_SDA_DATA_LINE   0x14
 
#define VBE_DDC_READ_SCL_CLOCK_LINE   0x15
 
#define VBE_DDC_READ_SDA_DATA_LINE   0x16
 
#define VBE_MODEATTR_LINEAR   0x80
 
#define VBE_MEMORYMODEL_PACKEDPIXEL   0x04
 
#define VBE_MEMORYMODEL_DIRECTCOLOR   0x06
 
#define VBE_SUCCESS   0x4F
 
#define VBE_UNSUCCESSFUL   0x14F
 
#define VBE_NOT_SUPPORTED   0x24F
 
#define VBE_FUNCTION_INVALID   0x34F
 
#define VBE_GETRETURNCODE(x)   (x & 0xFFFF)
 
#define MAX_SIZE_OF_EDID   256
 

Typedefs

typedef struct VBE_INFOPVBE_INFO
 
typedef struct VBE_MODEINFOPVBE_MODEINFO
 
typedef struct VBE_DEVICE_EXTENSIONPVBE_DEVICE_EXTENSION
 

Functions

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)
 
VP_STATUS NTAPI VBEFindAdapter (IN PVOID HwDeviceExtension, IN PVOID HwContext, IN PWSTR ArgumentString, IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, OUT PUCHAR Again)
 
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)
 
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

◆ MAX_SIZE_OF_EDID

#define MAX_SIZE_OF_EDID   256

Definition at line 187 of file vbemp.h.

◆ TAG_VBE

#define TAG_VBE   ' EBV'

Definition at line 31 of file vbemp.h.

◆ VBE_AUDIO_INTERFACE_EXTENSIONS

#define VBE_AUDIO_INTERFACE_EXTENSIONS   0x4F12

Definition at line 64 of file vbemp.h.

◆ VBE_DDC

#define VBE_DDC   0x4F15

Definition at line 67 of file vbemp.h.

◆ VBE_DDC_BEGIN_SCL_SDA_CONTROL

#define VBE_DDC_BEGIN_SCL_SDA_CONTROL   0x11

Definition at line 75 of file vbemp.h.

◆ VBE_DDC_END_SCL_SDA_CONTROL

#define VBE_DDC_END_SCL_SDA_CONTROL   0x12

Definition at line 76 of file vbemp.h.

◆ VBE_DDC_READ_EDID

#define VBE_DDC_READ_EDID   0x01

Definition at line 73 of file vbemp.h.

◆ VBE_DDC_READ_SCL_CLOCK_LINE

#define VBE_DDC_READ_SCL_CLOCK_LINE   0x15

Definition at line 79 of file vbemp.h.

◆ VBE_DDC_READ_SDA_DATA_LINE

#define VBE_DDC_READ_SDA_DATA_LINE   0x16

Definition at line 80 of file vbemp.h.

◆ VBE_DDC_REPORT_CAPABILITIES

#define VBE_DDC_REPORT_CAPABILITIES   0x10

Definition at line 74 of file vbemp.h.

◆ VBE_DDC_WRITE_SCL_CLOCK_LINE

#define VBE_DDC_WRITE_SCL_CLOCK_LINE   0x13

Definition at line 77 of file vbemp.h.

◆ VBE_DDC_WRITE_SDA_DATA_LINE

#define VBE_DDC_WRITE_SDA_DATA_LINE   0x14

Definition at line 78 of file vbemp.h.

◆ VBE_DISPLAY_DATA_CHANNEL

#define VBE_DISPLAY_DATA_CHANNEL   0x4F14

Definition at line 66 of file vbemp.h.

◆ VBE_DISPLAY_WINDOW_CONTROL

#define VBE_DISPLAY_WINDOW_CONTROL   0x4F05

Definition at line 51 of file vbemp.h.

◆ VBE_FLAT_PANEL_INTERFACE_EXTENSIONS

#define VBE_FLAT_PANEL_INTERFACE_EXTENSIONS   0x4F11

Definition at line 63 of file vbemp.h.

◆ VBE_FUNCTION_INVALID

#define VBE_FUNCTION_INVALID   0x34F

Definition at line 98 of file vbemp.h.

◆ VBE_GET_CONTROLLER_INFORMATION

#define VBE_GET_CONTROLLER_INFORMATION   0x4F00

Definition at line 46 of file vbemp.h.

◆ VBE_GET_CURRENT_VBE_MODE

#define VBE_GET_CURRENT_VBE_MODE   0x4F03

Definition at line 49 of file vbemp.h.

◆ VBE_GET_MODE_INFORMATION

#define VBE_GET_MODE_INFORMATION   0x4F01

Definition at line 47 of file vbemp.h.

◆ VBE_GET_SET_PIXEL_CLOCK

#define VBE_GET_SET_PIXEL_CLOCK   0x4F0B

Definition at line 59 of file vbemp.h.

◆ VBE_GETRETURNCODE

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

Definition at line 100 of file vbemp.h.

◆ VBE_MEMORYMODEL_DIRECTCOLOR

#define VBE_MEMORYMODEL_DIRECTCOLOR   0x06

Definition at line 89 of file vbemp.h.

◆ VBE_MEMORYMODEL_PACKEDPIXEL

#define VBE_MEMORYMODEL_PACKEDPIXEL   0x04

Definition at line 88 of file vbemp.h.

◆ VBE_MODEATTR_LINEAR

#define VBE_MODEATTR_LINEAR   0x80

Definition at line 86 of file vbemp.h.

◆ VBE_NOT_SUPPORTED

#define VBE_NOT_SUPPORTED   0x24F

Definition at line 97 of file vbemp.h.

◆ VBE_OEM_EXTENSIONS

#define VBE_OEM_EXTENSIONS   0x4F13

Definition at line 65 of file vbemp.h.

◆ VBE_POWER_MANAGEMENT_EXTENSIONS

#define VBE_POWER_MANAGEMENT_EXTENSIONS   0x4F10

Definition at line 62 of file vbemp.h.

◆ VBE_RETURN_PROTECTED_MODE_INTERFACE

#define VBE_RETURN_PROTECTED_MODE_INTERFACE   0x4F0A

Definition at line 58 of file vbemp.h.

◆ VBE_SAVE_RESTORE_STATE

#define VBE_SAVE_RESTORE_STATE   0x4F04

Definition at line 50 of file vbemp.h.

◆ VBE_SET_GET_DAC_PALETTE_FORMAT

#define VBE_SET_GET_DAC_PALETTE_FORMAT   0x4F08

Definition at line 54 of file vbemp.h.

◆ VBE_SET_GET_DISPLAY_START

#define VBE_SET_GET_DISPLAY_START   0x4F07

Definition at line 53 of file vbemp.h.

◆ VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH

#define VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH   0x4F06

Definition at line 52 of file vbemp.h.

◆ VBE_SET_GET_PALETTE_DATA

#define VBE_SET_GET_PALETTE_DATA   0x4F09

Definition at line 55 of file vbemp.h.

◆ VBE_SET_VBE_MODE

#define VBE_SET_VBE_MODE   0x4F02

Definition at line 48 of file vbemp.h.

◆ VBE_SUCCESS

#define VBE_SUCCESS   0x4F

Definition at line 95 of file vbemp.h.

◆ VBE_UNSUCCESSFUL

#define VBE_UNSUCCESSFUL   0x14F

Definition at line 96 of file vbemp.h.

Typedef Documentation

◆ PVBE_DEVICE_EXTENSION

◆ PVBE_INFO

◆ PVBE_MODEINFO

Function Documentation

◆ 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().

◆ VBEGetVideoChildDescriptor()

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 at line 218 of file edid.c.

225 {
226  PVBE_DEVICE_EXTENSION VBEDeviceExtension =
227  (PVBE_DEVICE_EXTENSION)HwDeviceExtension;
228  ULONG ChildIndex;
229 
230  /*
231  * We are called very early in device initialization, even before
232  * VBEInitialize is called. So, our Int10 interface is not set.
233  * Ignore this call, we will trigger another one later.
234  */
235  if (VBEDeviceExtension->Int10Interface.Size == 0)
237 
238  if (ChildEnumInfo->Size != sizeof(VIDEO_CHILD_ENUM_INFO))
239  {
240  VideoPortDebugPrint(Error, "VBEMP: Wrong VIDEO_CHILD_ENUM_INFO structure size\n");
242  }
243  else if (ChildEnumInfo->ChildDescriptorSize < MAX_SIZE_OF_EDID)
244  {
245  VideoPortDebugPrint(Warn, "VBEMP: Too small buffer for EDID\n");
247  }
248  else if (ChildEnumInfo->ChildIndex == DISPLAY_ADAPTER_HW_ID)
249  {
250  *VideoChildType = VideoChip;
251  *UId = 0;
252  return VIDEO_ENUM_MORE_DEVICES; /* FIXME: not sure... */
253  }
254 
255  /*
256  * Get Child ID
257  */
258  if (ChildEnumInfo->ChildIndex != 0)
259  ChildIndex = ChildEnumInfo->ChildIndex;
260  else
261  ChildIndex = ChildEnumInfo->ACPIHwId;
262  VideoPortDebugPrint(Info, "VBEMP: ChildEnumInfo->ChildIndex %lu, ChildEnumInfo->ACPIHwId %lu => %lu\n",
263  ChildEnumInfo->ChildIndex, ChildEnumInfo->ACPIHwId, ChildIndex);
264 
265  /*
266  * Try to read EDID information using 2 different methods.
267  */
268  if (VBEReadEdid(HwDeviceExtension, ChildIndex, pChildDescriptor))
269  {
270  VideoPortDebugPrint(Info, "VBEMP: EDID information read directly\n");
271  }
272  else if (VBEReadEdidUsingSCI(HwDeviceExtension, ChildIndex, pChildDescriptor))
273  {
274  VideoPortDebugPrint(Info, "VBEMP: EDID information read using IC\n");
275  }
276  else if (ChildEnumInfo->ChildIndex == 1)
277  {
278  /* We must have 1 monitor, so just report it with no EDID information */
279  VideoPortDebugPrint(Info, "VBEMP: Reporting monitor with no EDID information\n");
280  }
281  else
282  {
283  VideoPortDebugPrint(Warn, "VBEMP: Unable to read EDID information\n");
285  }
286 
287  /*
288  * Fill return data
289  */
290  *VideoChildType = Monitor;
291  if (ChildIndex == 0)
292  {
293  /*
294  * This is the actual display adapter
295  */
296  *UId = DISPLAY_ADAPTER_HW_ID;
297  }
298  else
299  *UId = ChildIndex;
300  *pUnused = 0;
302 }
#define DISPLAY_ADAPTER_HW_ID
Definition: video.h:115
static BOOLEAN VBEReadEdid(IN PVBE_DEVICE_EXTENSION VBEDeviceExtension, IN ULONG ChildIndex, OUT PVOID Edid)
Definition: edid.c:178
struct TraceInfo Info
static BOOLEAN VBEReadEdidUsingSCI(IN PVOID HwDeviceExtension, IN ULONG ChildIndex, OUT PVOID Edid)
Definition: edid.c:105
#define VIDEO_ENUM_MORE_DEVICES
Definition: video.h:139
Definition: video.h:581
#define MAX_SIZE_OF_EDID
Definition: vbemp.h:187
BOOL Error
Definition: chkdsk.c:66
VIDEO_PORT_INT10_INTERFACE Int10Interface
Definition: vbemp.h:194
Definition: video.h:270
struct VBE_DEVICE_EXTENSION * PVBE_DEVICE_EXTENSION
unsigned int ULONG
Definition: retypes.h:1
VPAPI VOID __cdecl VideoPortDebugPrint(IN VIDEO_DEBUG_LEVEL DebugPrintLevel, IN PSTR DebugMessage, IN ...)
#define VIDEO_ENUM_NO_MORE_DEVICES
Definition: video.h:140

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:912
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
static PVOID FrameBuffer
Definition: xboxvideo.c:24
#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 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().

◆ 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
union VIDEO_CLUT::@3034 LookupTable[1]
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 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().

◆ 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().