ReactOS  0.4.13-dev-259-g5ca9c9c
vmx_svga.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Boot Loader
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: win32ss/drivers/miniport/vmx_svga/vmx_svga.c
5  * PURPOSE: VMWARE SVGA-II Card Main Driver File
6  * PROGRAMMERS: ReactOS Portable Systems Group
7  */
8 
9 /* INCLUDES *******************************************************************/
10 
11 #include "precomp.h"
12 #include "debug.h"
13 
14 /* GLOBALS ********************************************************************/
15 
17 static WCHAR AdapterString[] = L"VMware SVGA II";
18 
19 /* FUNCTIONS ******************************************************************/
20 
21 ULONG
22 NTAPI
24  IN ULONG Index)
25 {
26  /* Program the index first, then read the value */
27  VideoPortWritePortUlong(DeviceExtension->IndexPort, Index);
28  return VideoPortReadPortUlong(DeviceExtension->ValuePort);
29 }
30 
31 VOID
32 NTAPI
34  IN ULONG Index,
35  IN ULONG Value)
36 {
37  /* Program the index first, then write the value */
38  VideoPortWritePortUlong(DeviceExtension->IndexPort, Index);
39  VideoPortWritePortUlong(DeviceExtension->ValuePort, Value);
40 }
41 
42 ULONG
43 NTAPI
45 {
46  /* Not here yet */
48  while (TRUE);
49  return 0;
50 }
51 
53 NTAPI
55 {
56  /* Not here yet */
58  while (TRUE);
59  return NO_ERROR;
60 }
61 
62 BOOLEAN
63 NTAPI
65 {
67 
68  /* Get the caps */
69  Capabilities = DeviceExtension->Capabilities;
70 
71  /* Check for multi-mon support */
73  {
74  /* Query the monitor count */
75  if (VmxReadUlong(DeviceExtension, SVGA_REG_NUM_DISPLAYS) > 1) return TRUE;
76  }
77 
78  /* Either no support, or just one screen */
79  return FALSE;
80 }
81 
83 NTAPI
84 VmxFindAdapter(IN PVOID HwDeviceExtension,
86  IN PWSTR ArgumentString,
87  IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo,
88  OUT PUCHAR Again)
89 {
91  PHW_DEVICE_EXTENSION DeviceExtension = HwDeviceExtension;
92  DPRINT1("VMX searching for adapter\n");
93 
94  /* Zero out the fields */
95  VideoPortZeroMemory(DeviceExtension, sizeof(HW_DEVICE_EXTENSION));
96 
97  /* Validate the Config Info */
98  if (ConfigInfo->Length < sizeof(VIDEO_PORT_CONFIG_INFO))
99  {
100  /* Incorrect OS version? */
101  DPRINT1("Invalid configuration info\n");
103  }
104 
105  /* Initialize the device extension and find the adapter */
106  Status = VmxInitDevice(DeviceExtension);
107  DPRINT1("Init status: %lx\n", Status);
108  if (Status != NO_ERROR) return ERROR_DEV_NOT_EXIST;
109 
110  /* Save this adapter extension */
111  VmxDeviceExtensionArray[0] = DeviceExtension;
112 
113  /* Create the sync event */
114  VideoPortCreateEvent(DeviceExtension,
116  NULL,
117  &DeviceExtension->SyncEvent);
118 
119  /* Check for multi-monitor configuration */
120  if (VmxIsMultiMon(DeviceExtension))
121  {
122  /* Let's not go so far */
124  while (TRUE);
125  }
126 
127  /* Zero the frame buffer */
129  DeviceExtension->VramSize.LowPart);
130 
131  /* Initialize the video modes */
132  VmxInitModes(DeviceExtension);
133 
134  /* Setup registry keys */
135  VideoPortSetRegistryParameters(DeviceExtension,
136  L"HardwareInformation.ChipType",
138  sizeof(AdapterString));
139  VideoPortSetRegistryParameters(DeviceExtension,
140  L"HardwareInformation.DacType",
142  sizeof(AdapterString));
143  VideoPortSetRegistryParameters(DeviceExtension,
144  L"HardwareInformation.MemorySize",
145  &DeviceExtension->VramSize.LowPart,
146  sizeof(ULONG));
147  VideoPortSetRegistryParameters(DeviceExtension,
148  L"HardwareInformation.AdapterString",
150  sizeof(AdapterString));
151  VideoPortSetRegistryParameters(DeviceExtension,
152  L"HardwareInformation.BiosString",
154  sizeof(AdapterString));
155 
156  /* No VDM support */
157  ConfigInfo->NumEmulatorAccessEntries = 0;
158  ConfigInfo->EmulatorAccessEntries = 0;
159  ConfigInfo->EmulatorAccessEntriesContext = 0;
160  ConfigInfo->HardwareStateSize = 0;
161  ConfigInfo->VdmPhysicalVideoMemoryAddress.QuadPart = 0;
162  ConfigInfo->VdmPhysicalVideoMemoryLength = 0;
163 
164  /* Write that this is Windows XP or higher */
165  VmxWriteUlong(DeviceExtension, SVGA_REG_GUEST_ID, 0x5000 | 0x08);
166  return NO_ERROR;
167 }
168 
169 BOOLEAN
170 NTAPI
171 VmxInitialize(IN PVOID HwDeviceExtension)
172 {
174  while (TRUE);
175  return TRUE;
176 }
177 
178 BOOLEAN
179 NTAPI
180 VmxStartIO(IN PVOID HwDeviceExtension,
181  IN PVIDEO_REQUEST_PACKET RequestPacket)
182 {
184  while (TRUE);
185  return TRUE;
186 }
187 
188 BOOLEAN
189 NTAPI
190 VmxResetHw(IN PVOID DeviceExtension,
191  IN ULONG Columns,
192  IN ULONG Rows)
193 {
195  while (TRUE);
196  return FALSE;
197 }
198 
199 VP_STATUS
200 NTAPI
201 VmxGetPowerState(IN PVOID HwDeviceExtension,
202  IN ULONG HwId,
203  IN PVIDEO_POWER_MANAGEMENT VideoPowerControl)
204 {
206  while (TRUE);
207  return NO_ERROR;
208 }
209 
210 VP_STATUS
211 NTAPI
212 VmxSetPowerState(IN PVOID HwDeviceExtension,
213  IN ULONG HwId,
214  IN PVIDEO_POWER_MANAGEMENT VideoPowerControl)
215 {
217  while (TRUE);
218  return NO_ERROR;
219 }
220 
221 BOOLEAN
222 NTAPI
223 VmxInterrupt(IN PVOID HwDeviceExtension)
224 {
226  while (TRUE);
227  return TRUE;
228 }
229 
230 VP_STATUS
231 NTAPI
233  IN PVIDEO_CHILD_ENUM_INFO ChildEnumInfo,
234  OUT PVIDEO_CHILD_TYPE VideoChildType,
235  OUT PUCHAR pChildDescriptor,
236  OUT PULONG UId,
237  OUT PULONG pUnused)
238 {
240  while (TRUE);
241  return NO_ERROR;
242 }
243 
244 ULONG
245 NTAPI
247  IN PVOID Context2)
248 {
250 
251  /* Zero initialization structure and array of extensions, one per screen */
252  DPRINT1("VMX-SVGAII Loading...\n");
254  VideoPortZeroMemory(&InitData, sizeof(InitData));
255 
256  /* Setup the initialization structure with VideoPort */
257  InitData.HwInitDataSize = sizeof(VIDEO_HW_INITIALIZATION_DATA);
258  InitData.HwFindAdapter = VmxFindAdapter;
259  InitData.HwInitialize = VmxInitialize;
260  InitData.HwInterrupt = VmxInterrupt;
261  InitData.HwStartIO = VmxStartIO;
262  InitData.HwResetHw = VmxResetHw;
266  InitData.AdapterInterfaceType = PCIBus;
267  InitData.HwInitDataSize = sizeof(VIDEO_HW_INITIALIZATION_DATA);
268  InitData.HwDeviceExtensionSize = sizeof(HW_DEVICE_EXTENSION);
269  return VideoPortInitialize(Context1, Context2, &InitData, NULL);
270 }
VPAPI ULONG NTAPI VideoPortReadPortUlong(IN PULONG Port)
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
VP_STATUS NTAPI VmxGetPowerState(IN PVOID HwDeviceExtension, IN ULONG HwId, IN PVIDEO_POWER_MANAGEMENT VideoPowerControl)
Definition: vmx_svga.c:201
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
PVIDEO_HW_POWER_SET HwSetPowerState
Definition: video.h:675
#define SVGA_CAP_MULTIMON
Definition: vmx_regs.h:50
PVIDEO_HW_GET_CHILD_DESCRIPTOR HwGetVideoChildDescriptor
Definition: video.h:677
VPAPI VOID NTAPI VideoPortWritePortUlong(IN PULONG Port, IN ULONG Value)
uint16_t * PWSTR
Definition: typedefs.h:54
VPAPI VP_STATUS NTAPI VideoPortCreateEvent(IN PVOID HwDeviceExtension, IN ULONG EventFlag, IN PVOID Unused, OUT PEVENT *ppEvent)
Definition: event.c:24
VP_STATUS NTAPI VmxInitDevice(IN PHW_DEVICE_EXTENSION DeviceExtension)
Definition: vmx_svga.c:54
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA _In_ PVOID HwContext
Definition: srb.h:664
INTERFACE_TYPE AdapterInterfaceType
Definition: video.h:665
BOOLEAN NTAPI VmxIsMultiMon(IN PHW_DEVICE_EXTENSION DeviceExtension)
Definition: vmx_svga.c:64
ULONG NTAPI VmxReadUlong(IN PHW_DEVICE_EXTENSION DeviceExtension, IN ULONG Index)
Definition: vmx_svga.c:23
VPAPI ULONG NTAPI VideoPortInitialize(IN PVOID Argument1, IN PVOID Argument2, IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData, IN PVOID HwContext)
Definition: videoprt.c:455
PVIDEO_HW_POWER_GET HwGetPowerState
Definition: video.h:676
#define NO_ERROR
Definition: dderror.h:5
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
BOOLEAN NTAPI VmxInitialize(IN PVOID HwDeviceExtension)
Definition: vmx_svga.c:171
PVIDEO_HW_START_IO HwStartIO
Definition: video.h:669
uint32_t ULONG_PTR
Definition: typedefs.h:63
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define NOTIFICATION_EVENT
Definition: video.h:109
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
VP_STATUS NTAPI VmxFindAdapter(IN PVOID HwDeviceExtension, IN PVOID HwContext, IN PWSTR ArgumentString, IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, OUT PUCHAR Again)
Definition: vmx_svga.c:84
unsigned char BOOLEAN
struct _HW_DEVICE_EXTENSION HW_DEVICE_EXTENSION
smooth NULL
Definition: ftsmooth.c:416
struct _VIDEO_HW_INITIALIZATION_DATA VIDEO_HW_INITIALIZATION_DATA
_In_ ULONG Rows
Definition: haltypes.h:7
BOOLEAN NTAPI VmxResetHw(IN PVOID DeviceExtension, IN ULONG Columns, IN ULONG Rows)
Definition: vmx_svga.c:190
VOID NTAPI VmxWriteUlong(IN PHW_DEVICE_EXTENSION DeviceExtension, IN ULONG Index, IN ULONG Value)
Definition: vmx_svga.c:33
PVIDEO_HW_INITIALIZE HwInitialize
Definition: video.h:667
PHYSICAL_ADDRESS FrameBuffer
Definition: precomp.h:18
__wchar_t WCHAR
Definition: xmlstorage.h:180
PVIDEO_HW_FIND_ADAPTER HwFindAdapter
Definition: video.h:666
static const UCHAR Index[8]
Definition: usbohci.c:18
ULONG NTAPI VmxInitModes(IN PHW_DEVICE_EXTENSION DeviceExtension)
Definition: vmx_svga.c:44
PENG_EVENT SyncEvent
Definition: precomp.h:28
static const WCHAR L[]
Definition: oid.c:1250
PVIDEO_HW_RESET_HW HwResetHw
Definition: video.h:672
static WCHAR AdapterString[]
Definition: vmx_svga.c:17
ULONG LowPart
Definition: typedefs.h:104
PVIDEO_HW_INTERRUPT HwInterrupt
Definition: video.h:668
PHW_DEVICE_EXTENSION VmxDeviceExtensionArray[SVGA_MAX_DISPLAYS]
Definition: vmx_svga.c:16
VP_STATUS NTAPI VmxGetVideoChildDescriptor(IN PVOID HwDeviceExtension, IN PVIDEO_CHILD_ENUM_INFO ChildEnumInfo, OUT PVIDEO_CHILD_TYPE VideoChildType, OUT PUCHAR pChildDescriptor, OUT PULONG UId, OUT PULONG pUnused)
Definition: vmx_svga.c:232
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT _In_ PTDI_PNP_CONTEXT Context2
Definition: tdikrnl.h:1094
Status
Definition: gdiplustypes.h:24
static const COLUMN_LIST Columns[]
Definition: listview.c:19
ULONG NTAPI DriverEntry(IN PVOID Context1, IN PVOID Context2)
Definition: vmx_svga.c:246
LARGE_INTEGER VramSize
Definition: precomp.h:19
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT Context1
Definition: tdikrnl.h:1094
unsigned int * PULONG
Definition: retypes.h:1
#define DPRINT1
Definition: precomp.h:8
VPAPI VP_STATUS NTAPI VideoPortSetRegistryParameters(IN PVOID HwDeviceExtension, IN PWSTR ValueName, IN PVOID ValueData, IN ULONG ValueLength)
Definition: videoprt.c:785
BOOLEAN NTAPI VmxInterrupt(IN PVOID HwDeviceExtension)
Definition: vmx_svga.c:223
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:114
VP_STATUS NTAPI VmxSetPowerState(IN PVOID HwDeviceExtension, IN ULONG HwId, IN PVIDEO_POWER_MANAGEMENT VideoPowerControl)
Definition: vmx_svga.c:212
LONG VP_STATUS
Definition: video.h:153
enum _VIDEO_CHILD_TYPE * PVIDEO_CHILD_TYPE
BOOLEAN NTAPI VmxStartIO(IN PVOID HwDeviceExtension, IN PVIDEO_REQUEST_PACKET RequestPacket)
Definition: vmx_svga.c:180
#define SVGA_MAX_DISPLAYS
Definition: vmx_regs.h:75
#define SVGA_CAP_PITCHLOCK
Definition: vmx_regs.h:51
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
LONGLONG QuadPart
Definition: typedefs.h:112