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 13 #define NDEBUG 14 #include <debug.h> 15 16 /* GLOBALS ********************************************************************/ 17 18 PHW_DEVICE_EXTENSION VmxDeviceExtensionArray[SVGA_MAX_DISPLAYS]; 19 static WCHAR AdapterString[] = L"VMware SVGA II"; 20 21 /* FUNCTIONS ******************************************************************/ 22 23 ULONG 24 NTAPI 25 VmxReadUlong(IN PHW_DEVICE_EXTENSION DeviceExtension, 26 IN ULONG Index) 27 { 28 /* Program the index first, then read the value */ 29 VideoPortWritePortUlong(DeviceExtension->IndexPort, Index); 30 return VideoPortReadPortUlong(DeviceExtension->ValuePort); 31 } 32 33 VOID 34 NTAPI 35 VmxWriteUlong(IN PHW_DEVICE_EXTENSION DeviceExtension, 36 IN ULONG Index, 37 IN ULONG Value) 38 { 39 /* Program the index first, then write the value */ 40 VideoPortWritePortUlong(DeviceExtension->IndexPort, Index); 41 VideoPortWritePortUlong(DeviceExtension->ValuePort, Value); 42 } 43 44 ULONG 45 NTAPI 46 VmxInitModes(IN PHW_DEVICE_EXTENSION DeviceExtension) 47 { 48 /* Not here yet */ 49 UNIMPLEMENTED; 50 while (TRUE); 51 return 0; 52 } 53 54 VP_STATUS 55 NTAPI 56 VmxInitDevice(IN PHW_DEVICE_EXTENSION DeviceExtension) 57 { 58 /* Not here yet */ 59 UNIMPLEMENTED; 60 while (TRUE); 61 return NO_ERROR; 62 } 63 64 BOOLEAN 65 NTAPI 66 VmxIsMultiMon(IN PHW_DEVICE_EXTENSION DeviceExtension) 67 { 68 ULONG Capabilities; 69 70 /* Get the caps */ 71 Capabilities = DeviceExtension->Capabilities; 72 73 /* Check for multi-mon support */ 74 if ((Capabilities & SVGA_CAP_MULTIMON) && (Capabilities & SVGA_CAP_PITCHLOCK)) 75 { 76 /* Query the monitor count */ 77 if (VmxReadUlong(DeviceExtension, SVGA_REG_NUM_DISPLAYS) > 1) return TRUE; 78 } 79 80 /* Either no support, or just one screen */ 81 return FALSE; 82 } 83 84 VP_STATUS 85 NTAPI 86 VmxFindAdapter(IN PVOID HwDeviceExtension, 87 IN PVOID HwContext, 88 IN PWSTR ArgumentString, 89 IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, 90 OUT PUCHAR Again) 91 { 92 VP_STATUS Status; 93 PHW_DEVICE_EXTENSION DeviceExtension = HwDeviceExtension; 94 DPRINT("VMX searching for adapter\n"); 95 96 /* Zero out the fields */ 97 VideoPortZeroMemory(DeviceExtension, sizeof(HW_DEVICE_EXTENSION)); 98 99 /* Validate the Config Info */ 100 if (ConfigInfo->Length < sizeof(VIDEO_PORT_CONFIG_INFO)) 101 { 102 /* Incorrect OS version? */ 103 DPRINT1("Invalid configuration info\n"); 104 return ERROR_INVALID_PARAMETER; 105 } 106 107 /* Initialize the device extension and find the adapter */ 108 Status = VmxInitDevice(DeviceExtension); 109 DPRINT("Init status: %lx\n", Status); 110 if (Status != NO_ERROR) return ERROR_DEV_NOT_EXIST; 111 112 /* Save this adapter extension */ 113 VmxDeviceExtensionArray[0] = DeviceExtension; 114 115 /* Create the sync event */ 116 VideoPortCreateEvent(DeviceExtension, 117 NOTIFICATION_EVENT, 118 NULL, 119 &DeviceExtension->SyncEvent); 120 121 /* Check for multi-monitor configuration */ 122 if (VmxIsMultiMon(DeviceExtension)) 123 { 124 /* Let's not go so far */ 125 UNIMPLEMENTED; 126 while (TRUE); 127 } 128 129 /* Zero the frame buffer */ 130 VideoPortZeroMemory((PVOID)(ULONG_PTR)DeviceExtension->FrameBuffer.QuadPart, 131 DeviceExtension->VramSize.LowPart); 132 133 /* Initialize the video modes */ 134 VmxInitModes(DeviceExtension); 135 136 /* Setup registry keys */ 137 VideoPortSetRegistryParameters(DeviceExtension, 138 L"HardwareInformation.ChipType", 139 AdapterString, 140 sizeof(AdapterString)); 141 VideoPortSetRegistryParameters(DeviceExtension, 142 L"HardwareInformation.DacType", 143 AdapterString, 144 sizeof(AdapterString)); 145 VideoPortSetRegistryParameters(DeviceExtension, 146 L"HardwareInformation.MemorySize", 147 &DeviceExtension->VramSize.LowPart, 148 sizeof(ULONG)); 149 VideoPortSetRegistryParameters(DeviceExtension, 150 L"HardwareInformation.AdapterString", 151 AdapterString, 152 sizeof(AdapterString)); 153 VideoPortSetRegistryParameters(DeviceExtension, 154 L"HardwareInformation.BiosString", 155 AdapterString, 156 sizeof(AdapterString)); 157 158 /* No VDM support */ 159 ConfigInfo->NumEmulatorAccessEntries = 0; 160 ConfigInfo->EmulatorAccessEntries = 0; 161 ConfigInfo->EmulatorAccessEntriesContext = 0; 162 ConfigInfo->HardwareStateSize = 0; 163 ConfigInfo->VdmPhysicalVideoMemoryAddress.QuadPart = 0; 164 ConfigInfo->VdmPhysicalVideoMemoryLength = 0; 165 166 /* Write that this is Windows XP or higher */ 167 VmxWriteUlong(DeviceExtension, SVGA_REG_GUEST_ID, 0x5000 | 0x08); 168 return NO_ERROR; 169 } 170 171 BOOLEAN 172 NTAPI 173 VmxInitialize(IN PVOID HwDeviceExtension) 174 { 175 UNIMPLEMENTED; 176 while (TRUE); 177 return TRUE; 178 } 179 180 BOOLEAN 181 NTAPI 182 VmxStartIO(IN PVOID HwDeviceExtension, 183 IN PVIDEO_REQUEST_PACKET RequestPacket) 184 { 185 UNIMPLEMENTED; 186 while (TRUE); 187 return TRUE; 188 } 189 190 BOOLEAN 191 NTAPI 192 VmxResetHw(IN PVOID DeviceExtension, 193 IN ULONG Columns, 194 IN ULONG Rows) 195 { 196 UNIMPLEMENTED; 197 while (TRUE); 198 return FALSE; 199 } 200 201 VP_STATUS 202 NTAPI 203 VmxGetPowerState(IN PVOID HwDeviceExtension, 204 IN ULONG HwId, 205 IN PVIDEO_POWER_MANAGEMENT VideoPowerControl) 206 { 207 UNIMPLEMENTED; 208 while (TRUE); 209 return NO_ERROR; 210 } 211 212 VP_STATUS 213 NTAPI 214 VmxSetPowerState(IN PVOID HwDeviceExtension, 215 IN ULONG HwId, 216 IN PVIDEO_POWER_MANAGEMENT VideoPowerControl) 217 { 218 UNIMPLEMENTED; 219 while (TRUE); 220 return NO_ERROR; 221 } 222 223 BOOLEAN 224 NTAPI 225 VmxInterrupt(IN PVOID HwDeviceExtension) 226 { 227 UNIMPLEMENTED; 228 while (TRUE); 229 return TRUE; 230 } 231 232 VP_STATUS 233 NTAPI 234 VmxGetVideoChildDescriptor(IN PVOID HwDeviceExtension, 235 IN PVIDEO_CHILD_ENUM_INFO ChildEnumInfo, 236 OUT PVIDEO_CHILD_TYPE VideoChildType, 237 OUT PUCHAR pChildDescriptor, 238 OUT PULONG UId, 239 OUT PULONG pUnused) 240 { 241 UNIMPLEMENTED; 242 while (TRUE); 243 return NO_ERROR; 244 } 245 246 ULONG 247 NTAPI 248 DriverEntry(IN PVOID Context1, 249 IN PVOID Context2) 250 { 251 VIDEO_HW_INITIALIZATION_DATA InitData; 252 253 /* Zero initialization structure and array of extensions, one per screen */ 254 DPRINT("VMX-SVGAII Loading...\n"); 255 VideoPortZeroMemory(VmxDeviceExtensionArray, sizeof(VmxDeviceExtensionArray)); 256 VideoPortZeroMemory(&InitData, sizeof(InitData)); 257 258 /* Setup the initialization structure with VideoPort */ 259 InitData.HwInitDataSize = sizeof(VIDEO_HW_INITIALIZATION_DATA); 260 InitData.HwFindAdapter = VmxFindAdapter; 261 InitData.HwInitialize = VmxInitialize; 262 InitData.HwInterrupt = VmxInterrupt; 263 InitData.HwStartIO = VmxStartIO; 264 InitData.HwResetHw = VmxResetHw; 265 InitData.HwGetPowerState = VmxGetPowerState; 266 InitData.HwSetPowerState = VmxSetPowerState; 267 InitData.HwGetVideoChildDescriptor = VmxGetVideoChildDescriptor; 268 InitData.AdapterInterfaceType = PCIBus; 269 InitData.HwInitDataSize = sizeof(VIDEO_HW_INITIALIZATION_DATA); 270 InitData.HwDeviceExtensionSize = sizeof(HW_DEVICE_EXTENSION); 271 return VideoPortInitialize(Context1, Context2, &InitData, NULL); 272 } 273