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 16 PHW_DEVICE_EXTENSION VmxDeviceExtensionArray[SVGA_MAX_DISPLAYS]; 17 static WCHAR AdapterString[] = L"VMware SVGA II"; 18 19 /* FUNCTIONS ******************************************************************/ 20 21 ULONG 22 NTAPI 23 VmxReadUlong(IN PHW_DEVICE_EXTENSION DeviceExtension, 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 33 VmxWriteUlong(IN PHW_DEVICE_EXTENSION DeviceExtension, 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 44 VmxInitModes(IN PHW_DEVICE_EXTENSION DeviceExtension) 45 { 46 /* Not here yet */ 47 UNIMPLEMENTED; 48 while (TRUE); 49 return 0; 50 } 51 52 VP_STATUS 53 NTAPI 54 VmxInitDevice(IN PHW_DEVICE_EXTENSION DeviceExtension) 55 { 56 /* Not here yet */ 57 UNIMPLEMENTED; 58 while (TRUE); 59 return NO_ERROR; 60 } 61 62 BOOLEAN 63 NTAPI 64 VmxIsMultiMon(IN PHW_DEVICE_EXTENSION DeviceExtension) 65 { 66 ULONG Capabilities; 67 68 /* Get the caps */ 69 Capabilities = DeviceExtension->Capabilities; 70 71 /* Check for multi-mon support */ 72 if ((Capabilities & SVGA_CAP_MULTIMON) && (Capabilities & SVGA_CAP_PITCHLOCK)) 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 82 VP_STATUS 83 NTAPI 84 VmxFindAdapter(IN PVOID HwDeviceExtension, 85 IN PVOID HwContext, 86 IN PWSTR ArgumentString, 87 IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, 88 OUT PUCHAR Again) 89 { 90 VP_STATUS Status; 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"); 102 return ERROR_INVALID_PARAMETER; 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, 115 NOTIFICATION_EVENT, 116 NULL, 117 &DeviceExtension->SyncEvent); 118 119 /* Check for multi-monitor configuration */ 120 if (VmxIsMultiMon(DeviceExtension)) 121 { 122 /* Let's not go so far */ 123 UNIMPLEMENTED; 124 while (TRUE); 125 } 126 127 /* Zero the frame buffer */ 128 VideoPortZeroMemory((PVOID)(ULONG_PTR)DeviceExtension->FrameBuffer.QuadPart, 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", 137 AdapterString, 138 sizeof(AdapterString)); 139 VideoPortSetRegistryParameters(DeviceExtension, 140 L"HardwareInformation.DacType", 141 AdapterString, 142 sizeof(AdapterString)); 143 VideoPortSetRegistryParameters(DeviceExtension, 144 L"HardwareInformation.MemorySize", 145 &DeviceExtension->VramSize.LowPart, 146 sizeof(ULONG)); 147 VideoPortSetRegistryParameters(DeviceExtension, 148 L"HardwareInformation.AdapterString", 149 AdapterString, 150 sizeof(AdapterString)); 151 VideoPortSetRegistryParameters(DeviceExtension, 152 L"HardwareInformation.BiosString", 153 AdapterString, 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 { 173 UNIMPLEMENTED; 174 while (TRUE); 175 return TRUE; 176 } 177 178 BOOLEAN 179 NTAPI 180 VmxStartIO(IN PVOID HwDeviceExtension, 181 IN PVIDEO_REQUEST_PACKET RequestPacket) 182 { 183 UNIMPLEMENTED; 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 { 194 UNIMPLEMENTED; 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 { 205 UNIMPLEMENTED; 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 { 216 UNIMPLEMENTED; 217 while (TRUE); 218 return NO_ERROR; 219 } 220 221 BOOLEAN 222 NTAPI 223 VmxInterrupt(IN PVOID HwDeviceExtension) 224 { 225 UNIMPLEMENTED; 226 while (TRUE); 227 return TRUE; 228 } 229 230 VP_STATUS 231 NTAPI 232 VmxGetVideoChildDescriptor(IN PVOID HwDeviceExtension, 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 { 239 UNIMPLEMENTED; 240 while (TRUE); 241 return NO_ERROR; 242 } 243 244 ULONG 245 NTAPI 246 DriverEntry(IN PVOID Context1, 247 IN PVOID Context2) 248 { 249 VIDEO_HW_INITIALIZATION_DATA InitData; 250 251 /* Zero initialization structure and array of extensions, one per screen */ 252 DPRINT1("VMX-SVGAII Loading...\n"); 253 VideoPortZeroMemory(VmxDeviceExtensionArray, sizeof(VmxDeviceExtensionArray)); 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; 263 InitData.HwGetPowerState = VmxGetPowerState; 264 InitData.HwSetPowerState = VmxSetPowerState; 265 InitData.HwGetVideoChildDescriptor = VmxGetVideoChildDescriptor; 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 } 271