ReactOS 0.4.15-dev-8241-g63935f8
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)
 

Variables

VIDEO_ACCESS_RANGE VBEAccessRange []
 

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 49 of file vbemp.c.

50{
52
53 VideoPortZeroMemory(&InitData, sizeof(InitData));
56 InitData.HwInitialize = VBEInitialize;
57 InitData.HwStartIO = VBEStartIO;
58 InitData.HwResetHw = VBEResetHw;
65
66 return VideoPortInitialize(Context1, Context2, &InitData, NULL);
67}
#define NULL
Definition: types.h:112
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
VP_STATUS NTAPI VBEGetVideoChildDescriptor(IN PVOID HwDeviceExtension, IN PVIDEO_CHILD_ENUM_INFO ChildEnumInfo, OUT PVIDEO_CHILD_TYPE VideoChildType, OUT PUCHAR pChildDescriptor, OUT PULONG UId, OUT PULONG pUnused)
Definition: edid.c:230
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
struct _VIDEO_HW_INITIALIZATION_DATA VIDEO_HW_INITIALIZATION_DATA
VPAPI ULONG NTAPI VideoPortInitialize(IN PVOID Argument1, IN PVOID Argument2, IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData, IN PVOID HwContext)
Definition: videoprt.c:740
PVIDEO_HW_FIND_ADAPTER HwFindAdapter
Definition: video.h:674
PVIDEO_HW_START_IO HwStartIO
Definition: video.h:677
PVIDEO_HW_POWER_SET HwSetPowerState
Definition: video.h:683
PVIDEO_HW_POWER_GET HwGetPowerState
Definition: video.h:684
PVIDEO_HW_RESET_HW HwResetHw
Definition: video.h:680
PVIDEO_HW_GET_CHILD_DESCRIPTOR HwGetVideoChildDescriptor
Definition: video.h:685
PVIDEO_ACCESS_RANGE HwLegacyResourceList
Definition: video.h:688
PVIDEO_HW_INITIALIZE HwInitialize
Definition: video.h:675
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT Context1
Definition: tdikrnl.h:1095
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT _In_ PTDI_PNP_CONTEXT Context2
Definition: tdikrnl.h:1096
BOOLEAN NTAPI VBEResetHw(PVOID DeviceExtension, ULONG Columns, ULONG Rows)
Definition: vbemp.c:566
VP_STATUS NTAPI VBEGetPowerState(PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
Definition: vbemp.c:582
VIDEO_ACCESS_RANGE VBEAccessRange[]
Definition: vbemp.c:39
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:78
BOOLEAN NTAPI VBEStartIO(PVOID HwDeviceExtension, PVIDEO_REQUEST_PACKET RequestPacket)
Definition: vbemp.c:442
BOOLEAN NTAPI VBEInitialize(PVOID HwDeviceExtension)
Definition: vbemp.c:182
VP_STATUS NTAPI VBESetPowerState(PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
Definition: vbemp.c:652

◆ 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 78 of file vbemp.c.

84{
87
88 if (ConfigInfo->Length < sizeof(VIDEO_PORT_CONFIG_INFO))
90
91 ConfigInfo->VdmPhysicalVideoMemoryAddress = VBEAccessRange[2].RangeStart;
92 ConfigInfo->VdmPhysicalVideoMemoryLength = VBEAccessRange[2].RangeLength;
93 return NO_ERROR;
94}
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
VPAPI BOOLEAN NTAPI VideoPortIsNoVesa(VOID)
Definition: videoprt.c:1738
ULONG RangeLength
Definition: video.h:216
PHYSICAL_ADDRESS RangeStart
Definition: video.h:215

Referenced by DriverEntry().

◆ VBEGetPowerState()

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

Definition at line 582 of file vbemp.c.

586{
587 INT10_BIOS_ARGUMENTS BiosRegisters;
588 PVBE_DEVICE_EXTENSION VBEDeviceExtension =
589 (PVBE_DEVICE_EXTENSION)HwDeviceExtension;
590
591 if (HwId != DISPLAY_ADAPTER_HW_ID ||
592 VideoPowerControl->Length < sizeof(VIDEO_POWER_MANAGEMENT))
594
595 /*
596 * Get general power support information.
597 */
598
599 VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
600 BiosRegisters.Eax = VBE_POWER_MANAGEMENT_EXTENSIONS;
601 BiosRegisters.Ebx = 0;
602 BiosRegisters.Edi = 0;
603 BiosRegisters.SegEs = 0;
604 VBEDeviceExtension->Int10Interface.Int10CallBios(
605 VBEDeviceExtension->Int10Interface.Context,
606 &BiosRegisters);
607
608 if ( VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_NOT_SUPPORTED)
609 return ERROR_DEV_NOT_EXIST;
610 if (VBE_GETRETURNCODE(BiosRegisters.Eax) != VBE_SUCCESS)
612
613 /*
614 * Get current power state.
615 */
616
617 VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
618 BiosRegisters.Eax = VBE_POWER_MANAGEMENT_EXTENSIONS;
619 BiosRegisters.Ebx = 0x2;
620 BiosRegisters.Edi = 0;
621 BiosRegisters.SegEs = 0;
622 VBEDeviceExtension->Int10Interface.Int10CallBios(
623 VBEDeviceExtension->Int10Interface.Context,
624 &BiosRegisters);
625
626 if (VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS)
627 {
628 VideoPowerControl->DPMSVersion = BiosRegisters.Ebx & 0xFF;
629 switch (BiosRegisters.Ebx >> 8)
630 {
631 case 0: VideoPowerControl->PowerState = VideoPowerOn; break;
632 case 1: VideoPowerControl->PowerState = VideoPowerStandBy; break;
633 case 2: VideoPowerControl->PowerState = VideoPowerSuspend; break;
634 case 4: VideoPowerControl->PowerState = VideoPowerOff; break;
635 case 5: VideoPowerControl->PowerState = VideoPowerOn; break;
636 default: VideoPowerControl->PowerState = VideoPowerUnspecified;
637 }
638
639 return NO_ERROR;
640 }
641
642 return ERROR_DEV_NOT_EXIST;
643}
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
@ VideoPowerOn
Definition: ntddvdeo.h:403
@ VideoPowerUnspecified
Definition: ntddvdeo.h:402
@ VideoPowerSuspend
Definition: ntddvdeo.h:405
@ VideoPowerOff
Definition: ntddvdeo.h:406
@ VideoPowerStandBy
Definition: ntddvdeo.h:404
#define DISPLAY_ADAPTER_HW_ID
Definition: video.h:115
VIDEO_PORT_INT10_INTERFACE Int10Interface
Definition: vbemp.h:194
OUT PINT10_CALL_BIOS Int10CallBios
Definition: video.h:790
#define VBE_SUCCESS
Definition: vbemp.h:95
#define VBE_NOT_SUPPORTED
Definition: vbemp.h:97
#define VBE_GETRETURNCODE(x)
Definition: vbemp.h:100
struct VBE_DEVICE_EXTENSION * PVBE_DEVICE_EXTENSION
#define VBE_POWER_MANAGEMENT_EXTENSIONS
Definition: vbemp.h:62

Referenced by DriverEntry().

◆ VBEInitialize()

BOOLEAN NTAPI VBEInitialize ( PVOID  HwDeviceExtension)

Definition at line 182 of file vbemp.c.

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

Referenced by DriverEntry().

◆ VBEMapVideoMemory()

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

Definition at line 769 of file vbemp.c.

774{
777
778 StatusBlock->Information = sizeof(VIDEO_MEMORY_INFORMATION);
779
780 if (DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].ModeAttributes &
782 {
783 FrameBuffer.QuadPart =
784 DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].PhysBasePtr;
785 MapInformation->VideoRamBase = RequestedAddress->RequestedVirtualAddress;
786 if (DeviceExtension->VbeInfo.Version < 0x300)
787 {
788 MapInformation->VideoRamLength =
789 DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].BytesPerScanLine *
790 DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].YResolution;
791 }
792 else
793 {
794 MapInformation->VideoRamLength =
795 DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].LinBytesPerScanLine *
796 DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].YResolution;
797 }
798 }
799#ifdef VBE12_SUPPORT
800 else
801 {
802 FrameBuffer.QuadPart = 0xA0000;
803 MapInformation->VideoRamBase = RequestedAddress->RequestedVirtualAddress;
804 MapInformation->VideoRamLength = 0x10000;
805 }
806#endif
807
808 VideoPortMapMemory(DeviceExtension, FrameBuffer,
809 &MapInformation->VideoRamLength, &inIoSpace,
810 &MapInformation->VideoRamBase);
811
812 MapInformation->FrameBufferBase = MapInformation->VideoRamBase;
813 MapInformation->FrameBufferLength = MapInformation->VideoRamLength;
814
815 return TRUE;
816}
PVOID FrameBuffer
Definition: xboxvideo.c:28
struct _VIDEO_MEMORY_INFORMATION VIDEO_MEMORY_INFORMATION
VPAPI VP_STATUS NTAPI VideoPortMapMemory(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, IN OUT PULONG Length, IN PULONG InIoSpace, IN OUT PVOID *VirtualAddress)
#define VIDEO_MEMORY_SPACE_MEMORY
Definition: video.h:132
USHORT CurrentMode
Definition: vbemp.h:207
USHORT LinBytesPerScanLine
Definition: vbemp.h:171
USHORT BytesPerScanLine
Definition: vbemp.h:139
ULONG_PTR Information
Definition: video.h:326
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:344

Referenced by VBEStartIO().

◆ VBEQueryAvailModes()

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

Definition at line 942 of file vbemp.c.

946{
947 ULONG CurrentModeId;
948 PVIDEO_MODE_INFORMATION CurrentMode;
949 PVBE_MODEINFO CurrentVBEMode;
950
951 for (CurrentModeId = 0, CurrentMode = ReturnedModes,
952 CurrentVBEMode = DeviceExtension->ModeInfo;
953 CurrentModeId < DeviceExtension->ModeCount;
954 CurrentModeId++, CurrentMode++, CurrentVBEMode++)
955 {
956 VBEQueryMode(DeviceExtension, CurrentMode, CurrentModeId);
957 }
958
959 StatusBlock->Information =
960 sizeof(VIDEO_MODE_INFORMATION) * DeviceExtension->ModeCount;
961
962 return TRUE;
963}
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
VOID FASTCALL VBEQueryMode(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION VideoMode, ULONG VideoModeId)
Definition: vbemp.c:863

Referenced by VBEStartIO().

◆ VBEQueryCurrentMode()

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

Definition at line 972 of file vbemp.c.

976{
977 StatusBlock->Information = sizeof(VIDEO_MODE_INFORMATION);
978
980 DeviceExtension,
981 VideoModeInfo,
982 DeviceExtension->CurrentMode);
983
984 return TRUE;
985}

Referenced by VBEStartIO().

◆ VBEQueryMode()

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

Definition at line 863 of file vbemp.c.

867{
868 PVBE_MODEINFO VBEMode = &DeviceExtension->ModeInfo[VideoModeId];
869 ULONG dpi;
870
871 VideoMode->Length = sizeof(VIDEO_MODE_INFORMATION);
872 VideoMode->ModeIndex = VideoModeId;
873 VideoMode->VisScreenWidth = VBEMode->XResolution;
874 VideoMode->VisScreenHeight = VBEMode->YResolution;
875 if (DeviceExtension->VbeInfo.Version < 0x300)
876 VideoMode->ScreenStride = VBEMode->BytesPerScanLine;
877 else
878 VideoMode->ScreenStride = VBEMode->LinBytesPerScanLine;
879 VideoMode->NumberOfPlanes = VBEMode->NumberOfPlanes;
880 VideoMode->BitsPerPlane = VBEMode->BitsPerPixel / VBEMode->NumberOfPlanes;
881 VideoMode->Frequency = 1;
882
883 /* Assume 96DPI and 25.4 millimeters per inch, round to nearest */
884 dpi = 96;
885 VideoMode->XMillimeter = ((ULONGLONG)VBEMode->XResolution * 254 + (dpi * 5)) / (dpi * 10);
886 VideoMode->YMillimeter = ((ULONGLONG)VBEMode->YResolution * 254 + (dpi * 5)) / (dpi * 10);
887
888 if (VBEMode->BitsPerPixel > 8)
889 {
890 /*
891 * Always report 16bpp modes and not 15bpp mode...
892 */
893 if (VBEMode->BitsPerPixel == 15 && VBEMode->NumberOfPlanes == 1)
894 {
895 VideoMode->BitsPerPlane = 16;
896 }
897
898 if (DeviceExtension->VbeInfo.Version < 0x300)
899 {
900 VideoMode->NumberRedBits = VBEMode->RedMaskSize;
901 VideoMode->NumberGreenBits = VBEMode->GreenMaskSize;
902 VideoMode->NumberBlueBits = VBEMode->BlueMaskSize;
903 VideoMode->RedMask = ((1 << VBEMode->RedMaskSize) - 1) << VBEMode->RedFieldPosition;
904 VideoMode->GreenMask = ((1 << VBEMode->GreenMaskSize) - 1) << VBEMode->GreenFieldPosition;
905 VideoMode->BlueMask = ((1 << VBEMode->BlueMaskSize) - 1) << VBEMode->BlueFieldPosition;
906 }
907 else
908 {
909 VideoMode->NumberRedBits = VBEMode->LinRedMaskSize;
910 VideoMode->NumberGreenBits = VBEMode->LinGreenMaskSize;
911 VideoMode->NumberBlueBits = VBEMode->LinBlueMaskSize;
912 VideoMode->RedMask = ((1 << VBEMode->LinRedMaskSize) - 1) << VBEMode->LinRedFieldPosition;
913 VideoMode->GreenMask = ((1 << VBEMode->LinGreenMaskSize) - 1) << VBEMode->LinGreenFieldPosition;
914 VideoMode->BlueMask = ((1 << VBEMode->LinBlueMaskSize) - 1) << VBEMode->LinBlueFieldPosition;
915 }
916 }
917 else
918 {
919 VideoMode->NumberRedBits =
920 VideoMode->NumberGreenBits =
921 VideoMode->NumberBlueBits = 6;
922 VideoMode->RedMask =
923 VideoMode->GreenMask =
924 VideoMode->BlueMask = 0;
925 }
926 VideoMode->VideoMemoryBitmapWidth = VBEMode->XResolution;
927 VideoMode->VideoMemoryBitmapHeight = VBEMode->YResolution;
930 if (VideoMode->BitsPerPlane <= 8)
931 VideoMode->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN;
932 VideoMode->DriverSpecificAttributeFlags = 0;
933}
#define VIDEO_MODE_GRAPHICS
Definition: ntddvdeo.h:364
#define VIDEO_MODE_COLOR
Definition: ntddvdeo.h:363
#define VIDEO_MODE_PALETTE_DRIVEN
Definition: ntddvdeo.h:365
#define VIDEO_MODE_NO_OFF_SCREEN
Definition: ntddvdeo.h:368
UCHAR GreenFieldPosition
Definition: vbemp.h:158
UCHAR LinRedFieldPosition
Definition: vbemp.h:175
UCHAR LinGreenFieldPosition
Definition: vbemp.h:177
UCHAR BlueFieldPosition
Definition: vbemp.h:160
UCHAR LinGreenMaskSize
Definition: vbemp.h:176
UCHAR NumberOfPlanes
Definition: vbemp.h:146
UCHAR LinBlueFieldPosition
Definition: vbemp.h:179
UCHAR RedMaskSize
Definition: vbemp.h:155
UCHAR LinBlueMaskSize
Definition: vbemp.h:178
UCHAR GreenMaskSize
Definition: vbemp.h:157
UCHAR RedFieldPosition
Definition: vbemp.h:156
UCHAR BlueMaskSize
Definition: vbemp.h:159
UCHAR LinRedMaskSize
Definition: vbemp.h:174
uint64_t ULONGLONG
Definition: typedefs.h:67
#define dpi
Definition: sysparams.c:23

Referenced by VBEQueryAvailModes(), and VBEQueryCurrentMode().

◆ VBEQueryNumAvailModes()

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

Definition at line 845 of file vbemp.c.

849{
850 Modes->NumModes = DeviceExtension->ModeCount;
851 Modes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
852 StatusBlock->Information = sizeof(VIDEO_NUM_MODES);
853 return TRUE;
854}
struct _VIDEO_NUM_MODES VIDEO_NUM_MODES
static const VBE_MODE Modes[VBE_MODE_COUNT]
Definition: vbe.c:189

Referenced by VBEStartIO().

◆ VBEResetDevice()

BOOLEAN FASTCALL VBEResetDevice ( PVBE_DEVICE_EXTENSION  DeviceExtension,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 745 of file vbemp.c.

748{
749 INT10_BIOS_ARGUMENTS BiosRegisters;
750
751 VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
752 BiosRegisters.Eax = VBE_SET_VBE_MODE;
753 BiosRegisters.Ebx = 0x3;
754 DeviceExtension->Int10Interface.Int10CallBios(
755 DeviceExtension->Int10Interface.Context,
756 &BiosRegisters);
757
758 return VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS;
759}
#define VBE_SET_VBE_MODE
Definition: vbemp.h:48

Referenced by VBEStartIO().

◆ VBEResetHw()

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

Definition at line 566 of file vbemp.c.

570{
571 /* Return FALSE to let HAL reset the display with INT10 */
572 return FALSE;
573}

Referenced by DriverEntry().

◆ VBESetColorRegisters()

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

Definition at line 997 of file vbemp.c.

1001{
1002 INT10_BIOS_ARGUMENTS BiosRegisters;
1003 ULONG Entry;
1004 PULONG OutputEntry;
1005 ULONG OutputBuffer[256];
1006
1007 if (ColorLookUpTable->NumEntries + ColorLookUpTable->FirstEntry > 256)
1008 return FALSE;
1009
1010 /*
1011 * For VGA compatible adapters program the color registers directly.
1012 */
1013
1014 if (!(DeviceExtension->VbeInfo.Capabilities & 2))
1015 {
1016 for (Entry = ColorLookUpTable->FirstEntry;
1017 Entry < ColorLookUpTable->NumEntries + ColorLookUpTable->FirstEntry;
1018 Entry++)
1019 {
1021 VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Red);
1022 VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Green);
1023 VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Blue);
1024 }
1025
1026 return TRUE;
1027 }
1028 else
1029 {
1030 /*
1031 * We can't just copy the values, because we need to swap the Red
1032 * and Blue values.
1033 */
1034
1035 for (Entry = ColorLookUpTable->FirstEntry,
1036 OutputEntry = OutputBuffer;
1037 Entry < ColorLookUpTable->NumEntries + ColorLookUpTable->FirstEntry;
1038 Entry++, OutputEntry++)
1039 {
1040 *OutputEntry =
1041 (ColorLookUpTable->LookupTable[Entry].RgbArray.Red << 16) |
1042 (ColorLookUpTable->LookupTable[Entry].RgbArray.Green << 8) |
1043 (ColorLookUpTable->LookupTable[Entry].RgbArray.Blue);
1044 }
1045
1046 DeviceExtension->Int10Interface.Int10WriteMemory(
1047 DeviceExtension->Int10Interface.Context,
1048 DeviceExtension->TrampolineMemorySegment,
1049 DeviceExtension->TrampolineMemoryOffset,
1051 (OutputEntry - OutputBuffer) * sizeof(ULONG));
1052
1053 VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
1054 BiosRegisters.Eax = VBE_SET_GET_PALETTE_DATA;
1055 BiosRegisters.Ebx = 0;
1056 BiosRegisters.Ecx = ColorLookUpTable->NumEntries;
1057 BiosRegisters.Edx = ColorLookUpTable->FirstEntry;
1058 BiosRegisters.Edi = DeviceExtension->TrampolineMemoryOffset;
1059 BiosRegisters.SegEs = DeviceExtension->TrampolineMemorySegment;
1060 DeviceExtension->Int10Interface.Int10CallBios(
1061 DeviceExtension->Int10Interface.Context,
1062 &BiosRegisters);
1063
1064 return VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS;
1065 }
1066}
VPAPI VOID NTAPI VideoPortWritePortUchar(IN PUCHAR Port, IN UCHAR Value)
base of all file and directory entries
Definition: entries.h:83
LONG Capabilities
Definition: vbemp.h:112
USHORT FirstEntry
Definition: ntddvdeo.h:590
union VIDEO_CLUT::@3192 LookupTable[1]
VIDEO_CLUTDATA RgbArray
Definition: ntddvdeo.h:592
USHORT NumEntries
Definition: ntddvdeo.h:589
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char * PUCHAR
Definition: typedefs.h:53
#define VBE_SET_GET_PALETTE_DATA
Definition: vbemp.h:55
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863

Referenced by VBEStartIO().

◆ VBESetCurrentMode()

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

Definition at line 705 of file vbemp.c.

709{
710 INT10_BIOS_ARGUMENTS BiosRegisters;
711
712 if (RequestedMode->RequestedMode >= DeviceExtension->ModeCount)
713 {
715 }
716
717 VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
718 BiosRegisters.Eax = VBE_SET_VBE_MODE;
719 BiosRegisters.Ebx = DeviceExtension->ModeNumbers[RequestedMode->RequestedMode];
720 DeviceExtension->Int10Interface.Int10CallBios(
721 DeviceExtension->Int10Interface.Context,
722 &BiosRegisters);
723
724 if (VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS)
725 {
726 DeviceExtension->CurrentMode = RequestedMode->RequestedMode;
727 }
728 else
729 {
730 VideoPortDebugPrint(Error, "VBEMP: VBESetCurrentMode failed (%x)\n", BiosRegisters.Eax);
731 DeviceExtension->CurrentMode = -1;
732 }
733
734 return VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_SUCCESS;
735}
ULONG RequestedMode
Definition: ntddvdeo.h:359

Referenced by VBEStartIO().

◆ VBESetPowerState()

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

Definition at line 652 of file vbemp.c.

656{
657 INT10_BIOS_ARGUMENTS BiosRegisters;
658 PVBE_DEVICE_EXTENSION VBEDeviceExtension =
659 (PVBE_DEVICE_EXTENSION)HwDeviceExtension;
660
661 if (HwId != DISPLAY_ADAPTER_HW_ID ||
662 VideoPowerControl->Length < sizeof(VIDEO_POWER_MANAGEMENT) ||
663 VideoPowerControl->PowerState < VideoPowerOn ||
664 VideoPowerControl->PowerState > VideoPowerHibernate)
666
667 if (VideoPowerControl->PowerState == VideoPowerHibernate)
668 return NO_ERROR;
669
670 /*
671 * Set current power state.
672 */
673
674 VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
675 BiosRegisters.Eax = VBE_POWER_MANAGEMENT_EXTENSIONS;
676 BiosRegisters.Ebx = 1;
677 BiosRegisters.Edi = 0;
678 BiosRegisters.SegEs = 0;
679 switch (VideoPowerControl->PowerState)
680 {
681 case VideoPowerStandBy: BiosRegisters.Ebx |= 0x100; break;
682 case VideoPowerSuspend: BiosRegisters.Ebx |= 0x200; break;
683 case VideoPowerOff: BiosRegisters.Ebx |= 0x400; break;
684 }
685
686 VBEDeviceExtension->Int10Interface.Int10CallBios(
687 VBEDeviceExtension->Int10Interface.Context,
688 &BiosRegisters);
689
690 if (VBE_GETRETURNCODE(BiosRegisters.Eax) == VBE_NOT_SUPPORTED)
691 return ERROR_DEV_NOT_EXIST;
692 if (VBE_GETRETURNCODE(BiosRegisters.Eax) != VBE_SUCCESS)
694
695 return VBE_SUCCESS;
696}
@ VideoPowerHibernate
Definition: ntddvdeo.h:407

Referenced by DriverEntry().

◆ VBESortModes()

VOID FASTCALL VBESortModes ( PVBE_DEVICE_EXTENSION  DeviceExtension)

Definition at line 126 of file vbemp.c.

127{
128 BOOLEAN Finished = FALSE;
129 ULONG Pos;
130 int Result;
131 VBE_MODEINFO TempModeInfo;
132 USHORT TempModeNumber;
133
134 while (!Finished)
135 {
136 Finished = TRUE;
137 for (Pos = 0; Pos < DeviceExtension->ModeCount - 1; Pos++)
138 {
140 DeviceExtension->ModeInfo + Pos,
141 DeviceExtension->ModeInfo + Pos + 1);
142 if (Result > 0)
143 {
144 Finished = FALSE;
145
147 &TempModeInfo,
148 DeviceExtension->ModeInfo + Pos,
149 sizeof(VBE_MODEINFO));
150 TempModeNumber = DeviceExtension->ModeNumbers[Pos];
151
153 DeviceExtension->ModeInfo + Pos,
154 DeviceExtension->ModeInfo + Pos + 1,
155 sizeof(VBE_MODEINFO));
156 DeviceExtension->ModeNumbers[Pos] =
157 DeviceExtension->ModeNumbers[Pos + 1];
158
160 DeviceExtension->ModeInfo + Pos + 1,
161 &TempModeInfo,
162 sizeof(VBE_MODEINFO));
163 DeviceExtension->ModeNumbers[Pos + 1] = TempModeNumber;
164 }
165 }
166 }
167}
unsigned char BOOLEAN
ush Pos
Definition: deflate.h:92
VPAPI VOID NTAPI VideoPortMoveMemory(IN PVOID Destination, IN PVOID Source, IN ULONG Length)
static int VBESortModesCallback(PVBE_MODEINFO VbeModeInfoA, PVBE_MODEINFO VbeModeInfoB)
Definition: vbemp.c:103
_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:409

Referenced by VBEInitialize().

◆ VBESortModesCallback()

static int VBESortModesCallback ( PVBE_MODEINFO  VbeModeInfoA,
PVBE_MODEINFO  VbeModeInfoB 
)
static

Definition at line 103 of file vbemp.c.

104{
105 /*
106 * FIXME: Until some reasonable method for changing video modes will
107 * be available we favor more bits per pixel. It should be changed
108 * later.
109 */
110 if (VbeModeInfoA->BitsPerPixel < VbeModeInfoB->BitsPerPixel) return -1;
111 if (VbeModeInfoA->BitsPerPixel > VbeModeInfoB->BitsPerPixel) return 1;
112 if (VbeModeInfoA->XResolution < VbeModeInfoB->XResolution) return -1;
113 if (VbeModeInfoA->XResolution > VbeModeInfoB->XResolution) return 1;
114 if (VbeModeInfoA->YResolution < VbeModeInfoB->YResolution) return -1;
115 if (VbeModeInfoA->YResolution > VbeModeInfoB->YResolution) return 1;
116 return 0;
117}

Referenced by VBESortModes().

◆ VBEStartIO()

BOOLEAN NTAPI VBEStartIO ( PVOID  HwDeviceExtension,
PVIDEO_REQUEST_PACKET  RequestPacket 
)

Definition at line 442 of file vbemp.c.

445{
447
448 RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
449
450 switch (RequestPacket->IoControlCode)
451 {
453 if (RequestPacket->InputBufferLength < sizeof(VIDEO_MODE))
454 {
456 return TRUE;
457 }
459 (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
460 (PVIDEO_MODE)RequestPacket->InputBuffer,
461 RequestPacket->StatusBlock);
462 break;
463
466 (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
467 RequestPacket->StatusBlock);
468 break;
469
471 if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MEMORY_INFORMATION) ||
472 RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
473 {
475 return TRUE;
476 }
478 (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
479 (PVIDEO_MEMORY)RequestPacket->InputBuffer,
481 RequestPacket->StatusBlock);
482 break;
483
485 if (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
486 {
488 return TRUE;
489 }
491 (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
492 (PVIDEO_MEMORY)RequestPacket->InputBuffer,
493 RequestPacket->StatusBlock);
494 break;
495
497 if (RequestPacket->OutputBufferLength < sizeof(VIDEO_NUM_MODES))
498 {
500 return TRUE;
501 }
503 (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
504 (PVIDEO_NUM_MODES)RequestPacket->OutputBuffer,
505 RequestPacket->StatusBlock);
506 break;
507
509 if (RequestPacket->OutputBufferLength <
510 ((PVBE_DEVICE_EXTENSION)HwDeviceExtension)->ModeCount * sizeof(VIDEO_MODE_INFORMATION))
511 {
513 return TRUE;
514 }
516 (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
518 RequestPacket->StatusBlock);
519 break;
520
522 if (RequestPacket->InputBufferLength < sizeof(VIDEO_CLUT) ||
523 RequestPacket->InputBufferLength <
524 (((PVIDEO_CLUT)RequestPacket->InputBuffer)->NumEntries * sizeof(ULONG)) +
525 FIELD_OFFSET(VIDEO_CLUT, LookupTable))
526 {
528 return TRUE;
529 }
531 (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
532 (PVIDEO_CLUT)RequestPacket->InputBuffer,
533 RequestPacket->StatusBlock);
534 break;
535
537 if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MODE_INFORMATION))
538 {
540 return TRUE;
541 }
543 (PVBE_DEVICE_EXTENSION)HwDeviceExtension,
545 RequestPacket->StatusBlock);
546 break;
547
548 default:
549 RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
550 return FALSE;
551 }
552
553 if (Result)
554 RequestPacket->StatusBlock->Status = NO_ERROR;
555
556 return TRUE;
557}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:173
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:248
#define IOCTL_VIDEO_QUERY_CURRENT_MODE
Definition: ntddvdeo.h:182
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:221
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:218
#define IOCTL_VIDEO_RESET_DEVICE
Definition: ntddvdeo.h:206
#define IOCTL_VIDEO_QUERY_AVAIL_MODES
Definition: ntddvdeo.h:176
#define IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES
Definition: ntddvdeo.h:191
VP_STATUS Status
Definition: video.h:323
ULONG InputBufferLength
Definition: video.h:333
PSTATUS_BLOCK StatusBlock
Definition: video.h:331
ULONG OutputBufferLength
Definition: video.h:335
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
BOOLEAN FASTCALL VBEResetDevice(PVBE_DEVICE_EXTENSION DeviceExtension, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:745
BOOLEAN FASTCALL VBEQueryAvailModes(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION ReturnedModes, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:942
BOOLEAN FASTCALL VBESetCurrentMode(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE RequestedMode, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:705
BOOLEAN FASTCALL VBEQueryCurrentMode(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION VideoModeInfo, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:972
BOOLEAN FASTCALL VBEUnmapVideoMemory(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MEMORY VideoMemory, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:826
BOOLEAN FASTCALL VBESetColorRegisters(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_CLUT ColorLookUpTable, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:997
BOOLEAN FASTCALL VBEQueryNumAvailModes(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_NUM_MODES Modes, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:845
BOOLEAN FASTCALL VBEMapVideoMemory(PVBE_DEVICE_EXTENSION DeviceExtension, PVIDEO_MEMORY RequestedAddress, PVIDEO_MEMORY_INFORMATION MapInformation, PSTATUS_BLOCK StatusBlock)
Definition: vbemp.c:769

Referenced by DriverEntry().

◆ VBEUnmapVideoMemory()

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

Definition at line 826 of file vbemp.c.

830{
831 VideoPortUnmapMemory(DeviceExtension, VideoMemory->RequestedVirtualAddress,
832 NULL);
833 return TRUE;
834}
VPAPI VP_STATUS NTAPI VideoPortUnmapMemory(IN PVOID HwDeviceExtension, IN OUT PVOID VirtualAddress, IN HANDLE ProcessHandle)

Referenced by VBEStartIO().

Variable Documentation

◆ VBEAccessRange

VIDEO_ACCESS_RANGE VBEAccessRange[]
Initial value:
=
{
{ {{0x3b0}}, 0x3bb - 0x3b0 + 1, 1, 1, 0 },
{ {{0x3c0}}, 0x3df - 0x3c0 + 1, 1, 1, 0 },
{ {{0xa0000}}, 0x20000, 0, 1, 0 },
}

Definition at line 39 of file vbemp.c.

Referenced by DriverEntry(), and VBEFindAdapter().