ReactOS  0.4.15-dev-1200-gc3b3fcd
xboxvmp.c File Reference
#include "xboxvmp.h"
#include <debug.h>
#include <dpfilter.h>
#include <drivers/xbox/xgpu.h>
Include dependency graph for xboxvmp.c:

Go to the source code of this file.

Functions

ULONG NTAPI DriverEntry (IN PVOID Context1, IN PVOID Context2)
 
VP_STATUS NTAPI XboxVmpFindAdapter (IN PVOID HwDeviceExtension, IN PVOID HwContext, IN PWSTR ArgumentString, IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, OUT PUCHAR Again)
 
BOOLEAN NTAPI XboxVmpInitialize (PVOID HwDeviceExtension)
 
BOOLEAN NTAPI XboxVmpStartIO (PVOID HwDeviceExtension, PVIDEO_REQUEST_PACKET RequestPacket)
 
BOOLEAN NTAPI XboxVmpResetHw (PVOID DeviceExtension, ULONG Columns, ULONG Rows)
 
VP_STATUS NTAPI XboxVmpGetPowerState (PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
 
VP_STATUS NTAPI XboxVmpSetPowerState (PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
 
BOOLEAN FASTCALL XboxVmpSetCurrentMode (PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE RequestedMode, PSTATUS_BLOCK StatusBlock)
 
BOOLEAN FASTCALL XboxVmpResetDevice (PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PSTATUS_BLOCK StatusBlock)
 
BOOLEAN FASTCALL XboxVmpMapVideoMemory (PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PVIDEO_MEMORY RequestedAddress, PVIDEO_MEMORY_INFORMATION MapInformation, PSTATUS_BLOCK StatusBlock)
 
BOOLEAN FASTCALL XboxVmpUnmapVideoMemory (PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PVIDEO_MEMORY VideoMemory, PSTATUS_BLOCK StatusBlock)
 
BOOLEAN FASTCALL XboxVmpQueryNumAvailModes (PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PVIDEO_NUM_MODES Modes, PSTATUS_BLOCK StatusBlock)
 
BOOLEAN FASTCALL XboxVmpQueryAvailModes (PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION VideoMode, PSTATUS_BLOCK StatusBlock)
 
UCHAR NvGetCrtc (PXBOXVMP_DEVICE_EXTENSION DeviceExtension, UCHAR Index)
 
UCHAR NvGetBytesPerPixel (PXBOXVMP_DEVICE_EXTENSION DeviceExtension, ULONG ScreenWidth)
 
BOOLEAN FASTCALL XboxVmpQueryCurrentMode (PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION VideoMode, PSTATUS_BLOCK StatusBlock)
 

Function Documentation

◆ DriverEntry()

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

Definition at line 28 of file xboxvmp.c.

31 {
33 
34  VideoPortZeroMemory(&InitData, sizeof(InitData));
35  InitData.AdapterInterfaceType = PCIBus;
39  InitData.HwStartIO = XboxVmpStartIO;
40  InitData.HwResetHw = XboxVmpResetHw;
44 
45  return VideoPortInitialize(Context1, Context2, &InitData, NULL);
46 }
BOOLEAN NTAPI XboxVmpStartIO(PVOID HwDeviceExtension, PVIDEO_REQUEST_PACKET RequestPacket)
Definition: xboxvmp.c:135
PVIDEO_HW_POWER_SET HwSetPowerState
Definition: video.h:675
BOOLEAN NTAPI XboxVmpInitialize(PVOID HwDeviceExtension)
Definition: xboxvmp.c:95
INTERFACE_TYPE AdapterInterfaceType
Definition: video.h:665
VPAPI ULONG NTAPI VideoPortInitialize(IN PVOID Argument1, IN PVOID Argument2, IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData, IN PVOID HwContext)
Definition: videoprt.c:592
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 XboxVmpGetPowerState(PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
Definition: xboxvmp.c:307
VP_STATUS NTAPI XboxVmpFindAdapter(IN PVOID HwDeviceExtension, IN PVOID HwContext, IN PWSTR ArgumentString, IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, OUT PUCHAR Again)
Definition: xboxvmp.c:56
smooth NULL
Definition: ftsmooth.c:416
struct _VIDEO_HW_INITIALIZATION_DATA VIDEO_HW_INITIALIZATION_DATA
PVIDEO_HW_INITIALIZE HwInitialize
Definition: video.h:667
VP_STATUS NTAPI XboxVmpSetPowerState(PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
Definition: xboxvmp.c:325
PVIDEO_HW_FIND_ADAPTER HwFindAdapter
Definition: video.h:666
PVIDEO_HW_RESET_HW HwResetHw
Definition: video.h:672
BOOLEAN NTAPI XboxVmpResetHw(PVOID DeviceExtension, ULONG Columns, ULONG Rows)
Definition: xboxvmp.c:284
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT _In_ PTDI_PNP_CONTEXT Context2
Definition: tdikrnl.h:1094
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT Context1
Definition: tdikrnl.h:1094

◆ NvGetBytesPerPixel()

UCHAR NvGetBytesPerPixel ( PXBOXVMP_DEVICE_EXTENSION  DeviceExtension,
ULONG  ScreenWidth 
)

Definition at line 505 of file xboxvmp.c.

508 {
510 
511  /* Get BPP directly from NV2A CRTC (magic constants are from Cromwell) */
512  BytesPerPixel = 8 * (((NvGetCrtc(DeviceExtension, 0x19) & 0xE0) << 3) | (NvGetCrtc(DeviceExtension, 0x13) & 0xFF)) / ScreenWidth;
513 
514  if (BytesPerPixel == 4)
515  {
516  ASSERT((NvGetCrtc(DeviceExtension, 0x28) & 0xF) == BytesPerPixel - 1);
517  }
518  else
519  {
520  ASSERT((NvGetCrtc(DeviceExtension, 0x28) & 0xF) == BytesPerPixel);
521  }
522 
523  return BytesPerPixel;
524 }
static ULONG BytesPerPixel
Definition: xboxvideo.c:32
UCHAR NvGetCrtc(PXBOXVMP_DEVICE_EXTENSION DeviceExtension, UCHAR Index)
Definition: xboxvmp.c:496
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
static ULONG ScreenWidth
Definition: pcvideo.c:114

Referenced by XboxVmpQueryCurrentMode().

◆ NvGetCrtc()

UCHAR NvGetCrtc ( PXBOXVMP_DEVICE_EXTENSION  DeviceExtension,
UCHAR  Index 
)

Definition at line 496 of file xboxvmp.c.

499 {
502 }
uint32_t ULONG_PTR
Definition: typedefs.h:65
static const UCHAR Index[8]
Definition: usbohci.c:18
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
#define NV2A_CRTC_REGISTER_VALUE
Definition: xgpu.h:23
#define NV2A_CRTC_REGISTER_INDEX
Definition: xgpu.h:22
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)

Referenced by NvGetBytesPerPixel().

◆ XboxVmpFindAdapter()

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

Definition at line 56 of file xboxvmp.c.

62 {
63  PXBOXVMP_DEVICE_EXTENSION XboxVmpDeviceExtension;
64  VIDEO_ACCESS_RANGE AccessRanges[3];
66  USHORT VendorId = 0x10DE; /* NVIDIA Corporation */
67  USHORT DeviceId = 0x02A0; /* NV2A XGPU */
68 
69  TRACE_(IHVVIDEO, "XboxVmpFindAdapter\n");
70 
71  XboxVmpDeviceExtension = (PXBOXVMP_DEVICE_EXTENSION)HwDeviceExtension;
72 
73  Status = VideoPortGetAccessRanges(HwDeviceExtension, 0, NULL, 3, AccessRanges,
74  &VendorId, &DeviceId, NULL);
75 
76  if (Status == NO_ERROR)
77  {
78  XboxVmpDeviceExtension->PhysControlStart = AccessRanges[0].RangeStart;
79  XboxVmpDeviceExtension->ControlLength = AccessRanges[0].RangeLength;
80  XboxVmpDeviceExtension->PhysFrameBufferStart = AccessRanges[1].RangeStart;
81  }
82 
83  return Status;
84 }
PHYSICAL_ADDRESS PhysControlStart
Definition: xboxvmp.h:28
#define NO_ERROR
Definition: dderror.h:5
smooth NULL
Definition: ftsmooth.c:416
PHYSICAL_ADDRESS PhysFrameBufferStart
Definition: xboxvmp.h:31
#define TRACE_(x)
Definition: compat.h:76
Status
Definition: gdiplustypes.h:24
unsigned short USHORT
Definition: pedump.c:61
VPAPI VP_STATUS NTAPI VideoPortGetAccessRanges(IN PVOID HwDeviceExtension, IN ULONG NumRequestedResources, IN PIO_RESOURCE_DESCRIPTOR RequestedResources OPTIONAL, IN ULONG NumAccessRanges, OUT PVIDEO_ACCESS_RANGE AccessRanges, IN PVOID VendorId, IN PVOID DeviceId, OUT PULONG Slot)
struct XBOXVMP_DEVICE_EXTENSION * PXBOXVMP_DEVICE_EXTENSION
LONG VP_STATUS
Definition: video.h:153
ULONG RangeLength
Definition: video.h:216
PHYSICAL_ADDRESS RangeStart
Definition: video.h:215

Referenced by DriverEntry().

◆ XboxVmpGetPowerState()

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

Definition at line 307 of file xboxvmp.c.

311 {
312  ERR_(IHVVIDEO, "XboxVmpGetPowerState is not supported\n");
313 
314  return ERROR_INVALID_FUNCTION;
315 }
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define ERR_(ch,...)
Definition: debug.h:156

Referenced by DriverEntry().

◆ XboxVmpInitialize()

BOOLEAN NTAPI XboxVmpInitialize ( PVOID  HwDeviceExtension)

Definition at line 95 of file xboxvmp.c.

97 {
98  PXBOXVMP_DEVICE_EXTENSION XboxVmpDeviceExtension;
99  ULONG inIoSpace = VIDEO_MEMORY_SPACE_MEMORY;
100  ULONG Length;
101 
102  TRACE_(IHVVIDEO, "XboxVmpInitialize\n");
103 
104  XboxVmpDeviceExtension = (PXBOXVMP_DEVICE_EXTENSION)HwDeviceExtension;
105 
106  Length = XboxVmpDeviceExtension->ControlLength;
107  XboxVmpDeviceExtension->VirtControlStart = NULL;
108 
109  if (VideoPortMapMemory(HwDeviceExtension,
110  XboxVmpDeviceExtension->PhysControlStart,
111  &Length,
112  &inIoSpace,
113  &XboxVmpDeviceExtension->VirtControlStart) != NO_ERROR)
114  {
115  ERR_(IHVVIDEO, "Failed to map control memory\n");
116  return FALSE;
117  }
118 
119  INFO_(IHVVIDEO, "Mapped 0x%x bytes of control mem at 0x%x to virt addr 0x%x\n",
120  XboxVmpDeviceExtension->ControlLength,
121  XboxVmpDeviceExtension->PhysControlStart.u.LowPart,
122  XboxVmpDeviceExtension->VirtControlStart);
123 
124  return TRUE;
125 }
#define INFO_(ch,...)
Definition: debug.h:159
#define TRUE
Definition: types.h:120
#define ERR_(ch,...)
Definition: debug.h:156
PHYSICAL_ADDRESS PhysControlStart
Definition: xboxvmp.h:28
#define NO_ERROR
Definition: dderror.h:5
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define TRACE_(x)
Definition: compat.h:76
VPAPI VP_STATUS NTAPI VideoPortMapMemory(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, IN OUT PULONG Length, IN PULONG InIoSpace, IN OUT PVOID *VirtualAddress)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
struct XBOXVMP_DEVICE_EXTENSION * PXBOXVMP_DEVICE_EXTENSION
unsigned int ULONG
Definition: retypes.h:1
struct _LARGE_INTEGER::@2267 u
#define VIDEO_MEMORY_SPACE_MEMORY
Definition: video.h:132

Referenced by DriverEntry().

◆ XboxVmpMapVideoMemory()

BOOLEAN FASTCALL XboxVmpMapVideoMemory ( PXBOXVMP_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_MEMORY  RequestedAddress,
PVIDEO_MEMORY_INFORMATION  MapInformation,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 386 of file xboxvmp.c.

391 {
393  ULONG inIoSpace = VIDEO_MEMORY_SPACE_MEMORY;
394 
395  StatusBlock->Information = sizeof(VIDEO_MEMORY_INFORMATION);
396 
397  /* Reuse framebuffer that was set up by firmware */
399  /* Framebuffer address offset value is coming from the GPU within
400  * memory mapped I/O address space, so we're comparing only low
401  * 28 bits of the address within actual RAM address space */
402  FrameBuffer.QuadPart &= 0x0FFFFFFF;
403  if (FrameBuffer.QuadPart != 0x3C00000 && FrameBuffer.QuadPart != 0x7C00000)
404  {
405  /* Check framebuffer address (high 4 MB of either 64 or 128 MB RAM) */
406  WARN_(IHVVIDEO, "Non-standard framebuffer address 0x%p\n", FrameBuffer.QuadPart);
407  }
408  /* Verify that framebuffer address is page-aligned */
409  ASSERT(FrameBuffer.QuadPart % PAGE_SIZE == 0);
410 
411  /* Return the address back to GPU memory mapped I/O */
412  FrameBuffer.QuadPart += DeviceExtension->PhysFrameBufferStart.QuadPart;
413  MapInformation->VideoRamBase = RequestedAddress->RequestedVirtualAddress;
414  /* FIXME: obtain fb size from firmware somehow (Cromwell reserves high 4 MB of RAM) */
415  MapInformation->VideoRamLength = NV2A_VIDEO_MEMORY_SIZE;
416 
418  DeviceExtension,
419  FrameBuffer,
420  &MapInformation->VideoRamLength,
421  &inIoSpace,
422  &MapInformation->VideoRamBase);
423 
424  MapInformation->FrameBufferBase = MapInformation->VideoRamBase;
425  MapInformation->FrameBufferLength = MapInformation->VideoRamLength;
426 
427  /* Tell the nVidia controller about the framebuffer */
429 
430  INFO_(IHVVIDEO, "Mapped 0x%x bytes of phys mem at 0x%lx to virt addr 0x%p\n",
431  MapInformation->VideoRamLength, FrameBuffer.u.LowPart, MapInformation->VideoRamBase);
432 
433  return TRUE;
434 }
#define NV2A_VIDEO_MEMORY_SIZE
Definition: xgpu.h:16
NTKERNELAPI VOID NTAPI WRITE_REGISTER_ULONG(IN PULONG Register, IN ULONG Value)
#define INFO_(ch,...)
Definition: debug.h:159
#define TRUE
Definition: types.h:120
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:274
NTKERNELAPI ULONG NTAPI READ_REGISTER_ULONG(IN PULONG Register)
uint32_t ULONG_PTR
Definition: typedefs.h:65
PHYSICAL_ADDRESS PhysFrameBufferStart
Definition: xboxvmp.h:31
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
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PVOID FrameBuffer
Definition: xboxvideo.c:28
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define NV2A_CRTC_FRAMEBUFFER_START
Definition: xgpu.h:21
unsigned int ULONG
Definition: retypes.h:1
#define VIDEO_MEMORY_SPACE_MEMORY
Definition: video.h:132
#define WARN_(ch,...)
Definition: debug.h:157
ULONG_PTR Information
Definition: video.h:326
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by XboxVmpStartIO().

◆ XboxVmpQueryAvailModes()

BOOLEAN FASTCALL XboxVmpQueryAvailModes ( PXBOXVMP_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_MODE_INFORMATION  VideoMode,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 487 of file xboxvmp.c.

491 {
492  return XboxVmpQueryCurrentMode(DeviceExtension, VideoMode, StatusBlock);
493 }
BOOLEAN FASTCALL XboxVmpQueryCurrentMode(PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION VideoMode, PSTATUS_BLOCK StatusBlock)
Definition: xboxvmp.c:534

Referenced by XboxVmpStartIO().

◆ XboxVmpQueryCurrentMode()

BOOLEAN FASTCALL XboxVmpQueryCurrentMode ( PXBOXVMP_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_MODE_INFORMATION  VideoMode,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 534 of file xboxvmp.c.

538 {
540 
541  VideoMode->Length = sizeof(VIDEO_MODE_INFORMATION);
542  VideoMode->ModeIndex = 0;
543 
544  VideoMode->VisScreenWidth = READ_REGISTER_ULONG((ULONG_PTR)DeviceExtension->VirtControlStart + NV2A_RAMDAC_FP_HVALID_END) + 1;
545  VideoMode->VisScreenHeight = READ_REGISTER_ULONG((ULONG_PTR)DeviceExtension->VirtControlStart + NV2A_RAMDAC_FP_VVALID_END) + 1;
546 
547  if (VideoMode->VisScreenWidth <= 1 || VideoMode->VisScreenHeight <= 1)
548  {
549  ERR_(IHVVIDEO, "Cannot obtain current screen resolution!\n");
550  return FALSE;
551  }
552 
553  BytesPerPixel = NvGetBytesPerPixel(DeviceExtension, VideoMode->VisScreenWidth);
554  ASSERT(BytesPerPixel >= 1 && BytesPerPixel <= 4);
555 
556  VideoMode->ScreenStride = VideoMode->VisScreenWidth * BytesPerPixel;
557  VideoMode->NumberOfPlanes = 1;
558  VideoMode->BitsPerPlane = BytesPerPixel * 8;
559  VideoMode->Frequency = 1;
560  VideoMode->XMillimeter = 0; /* FIXME */
561  VideoMode->YMillimeter = 0; /* FIXME */
562  if (BytesPerPixel >= 3)
563  {
564  VideoMode->NumberRedBits = 8;
565  VideoMode->NumberGreenBits = 8;
566  VideoMode->NumberBlueBits = 8;
567  VideoMode->RedMask = 0xFF0000;
568  VideoMode->GreenMask = 0x00FF00;
569  VideoMode->BlueMask = 0x0000FF;
570  }
571  else
572  {
573  /* FIXME: not implemented */
574  WARN_(IHVVIDEO, "BytesPerPixel %d - not implemented\n", BytesPerPixel);
575  }
576  VideoMode->VideoMemoryBitmapWidth = VideoMode->VisScreenWidth;
577  VideoMode->VideoMemoryBitmapHeight = VideoMode->VisScreenHeight;
578  VideoMode->AttributeFlags = VIDEO_MODE_GRAPHICS | VIDEO_MODE_COLOR |
580  VideoMode->DriverSpecificAttributeFlags = 0;
581 
582  StatusBlock->Information = sizeof(VIDEO_MODE_INFORMATION);
583 
584  /* Verify that screen fits framebuffer size */
585  if (VideoMode->VisScreenWidth * VideoMode->VisScreenHeight * (VideoMode->BitsPerPlane / 8) > NV2A_VIDEO_MEMORY_SIZE)
586  {
587  ERR_(IHVVIDEO, "Current screen resolution exceeds video memory bounds!\n");
588  return FALSE;
589  }
590 
591  return TRUE;
592 }
#define NV2A_VIDEO_MEMORY_SIZE
Definition: xgpu.h:16
static ULONG BytesPerPixel
Definition: xboxvideo.c:32
#define TRUE
Definition: types.h:120
#define ERR_(ch,...)
Definition: debug.h:156
NTKERNELAPI ULONG NTAPI READ_REGISTER_ULONG(IN PULONG Register)
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define VIDEO_MODE_NO_OFF_SCREEN
Definition: ntddvdeo.h:298
#define FALSE
Definition: types.h:117
UCHAR NvGetBytesPerPixel(PXBOXVMP_DEVICE_EXTENSION DeviceExtension, ULONG ScreenWidth)
Definition: xboxvmp.c:505
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
#define NV2A_RAMDAC_FP_HVALID_END
Definition: xgpu.h:25
#define NV2A_RAMDAC_FP_VVALID_END
Definition: xgpu.h:26
#define VIDEO_MODE_COLOR
Definition: ntddvdeo.h:293
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
#define WARN_(ch,...)
Definition: debug.h:157
ULONG_PTR Information
Definition: video.h:326
#define VIDEO_MODE_GRAPHICS
Definition: ntddvdeo.h:294

Referenced by XboxVmpQueryAvailModes(), and XboxVmpStartIO().

◆ XboxVmpQueryNumAvailModes()

BOOLEAN FASTCALL XboxVmpQueryNumAvailModes ( PXBOXVMP_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_NUM_MODES  Modes,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 468 of file xboxvmp.c.

472 {
473  Modes->NumModes = 1;
474  Modes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
475  StatusBlock->Information = sizeof(VIDEO_NUM_MODES);
476  return TRUE;
477 }
struct _VIDEO_NUM_MODES VIDEO_NUM_MODES
#define TRUE
Definition: types.h:120
static const VBE_MODE Modes[VBE_MODE_COUNT]
Definition: vbe.c:189
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
ULONG_PTR Information
Definition: video.h:326

Referenced by XboxVmpStartIO().

◆ XboxVmpResetDevice()

BOOLEAN FASTCALL XboxVmpResetDevice ( PXBOXVMP_DEVICE_EXTENSION  DeviceExtension,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 368 of file xboxvmp.c.

371 {
372  /* There is nothing to be done here */
373 
374  return TRUE;
375 }
#define TRUE
Definition: types.h:120

Referenced by XboxVmpResetHw(), and XboxVmpStartIO().

◆ XboxVmpResetHw()

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

Definition at line 284 of file xboxvmp.c.

288 {
289  TRACE_(IHVVIDEO, "XboxVmpResetHw\n");
290 
291  if (!XboxVmpResetDevice((PXBOXVMP_DEVICE_EXTENSION)DeviceExtension, NULL))
292  {
293  return FALSE;
294  }
295 
296  return TRUE;
297 }
#define TRUE
Definition: types.h:120
BOOLEAN FASTCALL XboxVmpResetDevice(PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PSTATUS_BLOCK StatusBlock)
Definition: xboxvmp.c:368
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define TRACE_(x)
Definition: compat.h:76

Referenced by DriverEntry().

◆ XboxVmpSetCurrentMode()

BOOLEAN FASTCALL XboxVmpSetCurrentMode ( PXBOXVMP_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_MODE  RequestedMode,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 343 of file xboxvmp.c.

347 {
348  if (RequestedMode->RequestedMode != 0)
349  {
350  return FALSE;
351  }
352 
353  /* Nothing to do, really. We only support a single mode and we're already
354  * in that mode
355  */
356  return TRUE;
357 }
#define TRUE
Definition: types.h:120
ULONG RequestedMode
Definition: ntddvdeo.h:289
#define FALSE
Definition: types.h:117

Referenced by XboxVmpStartIO().

◆ XboxVmpSetPowerState()

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

Definition at line 325 of file xboxvmp.c.

329 {
330  ERR_(IHVVIDEO, "XboxVmpSetPowerState not supported\n");
331 
332  return ERROR_INVALID_FUNCTION;
333 }
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define ERR_(ch,...)
Definition: debug.h:156

Referenced by DriverEntry().

◆ XboxVmpStartIO()

BOOLEAN NTAPI XboxVmpStartIO ( PVOID  HwDeviceExtension,
PVIDEO_REQUEST_PACKET  RequestPacket 
)

Definition at line 135 of file xboxvmp.c.

138 {
139  BOOLEAN Result;
140 
141  RequestPacket->StatusBlock->Status = ERROR_INVALID_PARAMETER;
142 
143  switch (RequestPacket->IoControlCode)
144  {
146  {
147  TRACE_(IHVVIDEO, "XboxVmpStartIO IOCTL_VIDEO_SET_CURRENT_MODE\n");
148 
149  if (RequestPacket->InputBufferLength < sizeof(VIDEO_MODE))
150  {
151  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
152  return TRUE;
153  }
154 
156  (PXBOXVMP_DEVICE_EXTENSION)HwDeviceExtension,
157  (PVIDEO_MODE)RequestPacket->InputBuffer,
158  RequestPacket->StatusBlock);
159  break;
160  }
161 
163  {
164  TRACE_(IHVVIDEO, "XboxVmpStartIO IOCTL_VIDEO_RESET_DEVICE\n");
165 
167  (PXBOXVMP_DEVICE_EXTENSION)HwDeviceExtension,
168  RequestPacket->StatusBlock);
169  break;
170  }
171 
173  {
174  TRACE_(IHVVIDEO, "XboxVmpStartIO IOCTL_VIDEO_MAP_VIDEO_MEMORY\n");
175 
176  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MEMORY_INFORMATION) ||
177  RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
178  {
179  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
180  return TRUE;
181  }
182 
184  (PXBOXVMP_DEVICE_EXTENSION)HwDeviceExtension,
185  (PVIDEO_MEMORY)RequestPacket->InputBuffer,
186  (PVIDEO_MEMORY_INFORMATION)RequestPacket->OutputBuffer,
187  RequestPacket->StatusBlock);
188  break;
189  }
190 
192  {
193  TRACE_(IHVVIDEO, "XboxVmpStartIO IOCTL_VIDEO_UNMAP_VIDEO_MEMORY\n");
194 
195  if (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
196  {
197  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
198  return TRUE;
199  }
200 
202  (PXBOXVMP_DEVICE_EXTENSION)HwDeviceExtension,
203  (PVIDEO_MEMORY)RequestPacket->InputBuffer,
204  RequestPacket->StatusBlock);
205  break;
206  }
207 
209  {
210  TRACE_(IHVVIDEO, "XboxVmpStartIO IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES\n");
211 
212  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_NUM_MODES))
213  {
214  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
215  return TRUE;
216  }
217 
219  (PXBOXVMP_DEVICE_EXTENSION)HwDeviceExtension,
220  (PVIDEO_NUM_MODES)RequestPacket->OutputBuffer,
221  RequestPacket->StatusBlock);
222  break;
223  }
224 
226  {
227  TRACE_(IHVVIDEO, "XboxVmpStartIO IOCTL_VIDEO_QUERY_AVAIL_MODES\n");
228 
229  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MODE_INFORMATION))
230  {
231  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
232  return TRUE;
233  }
234 
236  (PXBOXVMP_DEVICE_EXTENSION)HwDeviceExtension,
237  (PVIDEO_MODE_INFORMATION)RequestPacket->OutputBuffer,
238  RequestPacket->StatusBlock);
239  break;
240  }
241 
243  {
244  TRACE_(IHVVIDEO, "XboxVmpStartIO IOCTL_VIDEO_QUERY_CURRENT_MODE\n");
245 
246  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MODE_INFORMATION))
247  {
248  RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
249  return TRUE;
250  }
251 
253  (PXBOXVMP_DEVICE_EXTENSION)HwDeviceExtension,
254  (PVIDEO_MODE_INFORMATION)RequestPacket->OutputBuffer,
255  RequestPacket->StatusBlock);
256  break;
257  }
258 
259  default:
260  {
261  WARN_(IHVVIDEO, "XboxVmpStartIO 0x%x not implemented\n", RequestPacket->IoControlCode);
262 
263  RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
264  return FALSE;
265  }
266  }
267 
268  if (Result)
269  {
270  RequestPacket->StatusBlock->Status = NO_ERROR;
271  }
272 
273  return TRUE;
274 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
BOOLEAN FASTCALL XboxVmpQueryCurrentMode(PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION VideoMode, PSTATUS_BLOCK StatusBlock)
Definition: xboxvmp.c:534
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define TRUE
Definition: types.h:120
#define IOCTL_VIDEO_RESET_DEVICE
Definition: ntddvdeo.h:137
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:104
BOOLEAN FASTCALL XboxVmpSetCurrentMode(PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE RequestedMode, PSTATUS_BLOCK StatusBlock)
Definition: xboxvmp.c:343
ULONG InputBufferLength
Definition: video.h:333
#define NO_ERROR
Definition: dderror.h:5
BOOLEAN FASTCALL XboxVmpResetDevice(PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PSTATUS_BLOCK StatusBlock)
Definition: xboxvmp.c:368
#define IOCTL_VIDEO_QUERY_CURRENT_MODE
Definition: ntddvdeo.h:113
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:152
#define FALSE
Definition: types.h:117
BOOLEAN FASTCALL XboxVmpQueryAvailModes(PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PVIDEO_MODE_INFORMATION VideoMode, PSTATUS_BLOCK StatusBlock)
Definition: xboxvmp.c:487
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
#define TRACE_(x)
Definition: compat.h:76
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 XboxVmpQueryNumAvailModes(PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PVIDEO_NUM_MODES Modes, PSTATUS_BLOCK StatusBlock)
Definition: xboxvmp.c:468
PSTATUS_BLOCK StatusBlock
Definition: video.h:331
BOOLEAN FASTCALL XboxVmpMapVideoMemory(PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PVIDEO_MEMORY RequestedAddress, PVIDEO_MEMORY_INFORMATION MapInformation, PSTATUS_BLOCK StatusBlock)
Definition: xboxvmp.c:386
BOOLEAN FASTCALL XboxVmpUnmapVideoMemory(PXBOXVMP_DEVICE_EXTENSION DeviceExtension, PVIDEO_MEMORY VideoMemory, PSTATUS_BLOCK StatusBlock)
Definition: xboxvmp.c:445
#define WARN_(ch,...)
Definition: debug.h:157
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by DriverEntry().

◆ XboxVmpUnmapVideoMemory()

BOOLEAN FASTCALL XboxVmpUnmapVideoMemory ( PXBOXVMP_DEVICE_EXTENSION  DeviceExtension,
PVIDEO_MEMORY  VideoMemory,
PSTATUS_BLOCK  StatusBlock 
)

Definition at line 445 of file xboxvmp.c.

449 {
451  DeviceExtension,
452  VideoMemory->RequestedVirtualAddress,
453  NULL);
454 
455  return TRUE;
456 }
#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 XboxVmpStartIO().