Changeset 33876 in vbox for trunk/src/VBox/Additions/WINNT/Graphics
- Timestamp:
- Nov 8, 2010 9:32:28 PM (14 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/Miniport
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
r33869 r33876 17 17 #include "VBoxVideo.h" 18 18 #include "Helper.h" 19 #ifdef VBOX_WITH_WDDM 20 #include "wddm/VBoxVideoMisc.h" 21 #endif 19 22 20 23 #include <iprt/log.h> … … 99 102 PULONG pUnused); 100 103 104 /******************************************************************************* 105 * Internal Functions * 106 *******************************************************************************/ 107 101 108 #ifndef VBOX_WITH_WDDM 109 /*+++ 110 111 Routine Description: 112 113 This routine is used to read back various registry values. 114 115 Arguments: 116 117 HwDeviceExtension 118 Supplies a pointer to the miniport's device extension. 119 120 Context 121 Context value passed to the get registry parameters routine. 122 If this is not null assume it's a ULONG* and save the data value in it. 123 124 ValueName 125 Name of the value requested. 126 127 ValueData 128 Pointer to the requested data. 129 130 ValueLength 131 Length of the requested data. 132 133 Return Value: 134 135 If the variable doesn't exist return an error, 136 else if a context is supplied assume it's a PULONG and fill in the value 137 and return no error, else if the value is non-zero return an error. 138 139 ---*/ 140 static VP_STATUS VBoxRegistryCallback(PVOID HwDeviceExtension, PVOID Context, 141 PWSTR ValueName, PVOID ValueData, 142 ULONG ValueLength) 143 { 144 //dprintf(("VBoxVideo::VBoxRegistryCallback: Context: %p, ValueName: %S, ValueData: %p, ValueLength: %d\n", 145 // Context, ValueName, ValueData, ValueLength)); 146 if (ValueLength) 147 { 148 if (Context) 149 *(ULONG *)Context = *(PULONG)ValueData; 150 else if (*((PULONG)ValueData) != 0) 151 return ERROR_INVALID_PARAMETER; 152 return NO_ERROR; 153 } 154 else 155 return ERROR_INVALID_PARAMETER; 156 } 157 #endif /* #ifndef VBOX_WITH_WDDM */ 158 159 static VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal) 160 { 161 #ifndef VBOX_WITH_WDDM 162 return VideoPortGetRegistryParameters(Reg, pName, FALSE, VBoxRegistryCallback, pVal); 163 #else 164 if(!Reg) 165 return ERROR_INVALID_PARAMETER; 166 NTSTATUS Status = vboxWddmRegQueryValueDword(Reg, pName, (PDWORD)pVal); 167 return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER; 168 #endif 169 } 170 171 static VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val) 172 { 173 #ifndef VBOX_WITH_WDDM 174 return VideoPortSetRegistryParameters(Reg, pName, &Val, sizeof(Val)); 175 #else 176 if(!Reg) 177 return ERROR_INVALID_PARAMETER; 178 NTSTATUS Status = vboxWddmRegSetValueDword(Reg, pName, Val); 179 return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER; 180 #endif 181 } 182 183 static VP_STATUS VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg) 184 { 185 #ifndef VBOX_WITH_WDDM 186 *pReg = pDeviceExtension->pPrimary; 187 return NO_ERROR; 188 #else 189 WCHAR Buf[512]; 190 ULONG cbBuf = sizeof(Buf); 191 NTSTATUS Status = vboxWddmRegQueryDrvKeyName(pDeviceExtension, cbBuf, Buf, &cbBuf); 192 Assert(Status == STATUS_SUCCESS); 193 if (Status == STATUS_SUCCESS) 194 { 195 Status = vboxWddmRegOpenKey(pReg, Buf, GENERIC_READ | GENERIC_WRITE); 196 Assert(Status == STATUS_SUCCESS); 197 if(Status == STATUS_SUCCESS) 198 return NO_ERROR; 199 } 200 201 /* fall-back to make the subsequent VBoxVideoCmnRegXxx calls treat the fail accordingly 202 * basically needed to make as less modifications to the current XPDM code as possible */ 203 *pReg = NULL; 204 205 return ERROR_INVALID_PARAMETER; 206 #endif 207 } 208 209 static VP_STATUS VBoxVideoCmnRegFini(IN VBOXCMNREG Reg) 210 { 211 #ifndef VBOX_WITH_WDDM 212 return NO_ERROR; 213 #else 214 if(!Reg) 215 return ERROR_INVALID_PARAMETER; 216 217 NTSTATUS Status = ZwClose(Reg); 218 return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER; 219 #endif 220 } 221 222 void VBoxVideoCmnSignalEvent(PVBOXVIDEO_COMMON pCommon, uint64_t pvEvent) 223 { 224 PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon); 225 #ifndef VBOX_WITH_WDDM 226 PEVENT pEvent = (PEVENT)pvEvent; 227 PrimaryExtension->u.primary.VideoPortProcs.pfnSetEvent(PrimaryExtension, 228 pEvent); 229 #else 230 PKEVENT pEvent = (PKEVENT)pvEvent; 231 KeSetEvent(pEvent, 0, FALSE); 232 #endif 233 } 234 235 236 #define MEM_TAG 'HVBV' 237 238 void *VBoxVideoCmnMemAllocDriver(PVBOXVIDEO_COMMON pCommon, size_t cb) 239 { 240 ULONG Tag = MEM_TAG; 241 #ifndef VBOX_WITH_WDDM 242 PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon); 243 return PrimaryExtension->u.primary.VideoPortProcs.pfnAllocatePool(PrimaryExtension, (VBOXVP_POOL_TYPE)VpNonPagedPool, cb, Tag); 244 #else 245 return ExAllocatePoolWithTag(NonPagedPool, cb, Tag); 246 #endif 247 } 248 249 250 void VBoxVideoCmnMemFreeDriver(PVBOXVIDEO_COMMON pCommon, void *pv) 251 { 252 #ifndef VBOX_WITH_WDDM 253 PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon); 254 PrimaryExtension->u.primary.VideoPortProcs.pfnFreePool(PrimaryExtension, 255 pv); 256 #else 257 ExFreePool(pv); 258 #endif 259 } 260 261 static VOID VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem) 262 { 263 #ifndef VBOX_WITH_WDDM 264 VideoPortZeroMemory(pvMem, cbMem); 265 #else 266 memset(pvMem, 0, cbMem); 267 #endif 268 } 269 270 271 #ifndef VBOX_WITH_WDDM 272 static void VBoxSetupVideoPortFunctions(PDEVICE_EXTENSION PrimaryExtension, 273 VBOXVIDEOPORTPROCS *pCallbacks, 274 PVIDEO_PORT_CONFIG_INFO pConfigInfo); 275 102 276 ULONG DriverEntry(IN PVOID Context1, IN PVOID Context2) 103 277 { … … 147 321 return rc; 148 322 } 149 150 /*+++ 151 152 Routine Description: 153 154 This routine is used to read back various registry values. 155 156 Arguments: 157 158 HwDeviceExtension 159 Supplies a pointer to the miniport's device extension. 160 161 Context 162 Context value passed to the get registry parameters routine. 163 If this is not null assume it's a ULONG* and save the data value in it. 164 165 ValueName 166 Name of the value requested. 167 168 ValueData 169 Pointer to the requested data. 170 171 ValueLength 172 Length of the requested data. 173 174 Return Value: 175 176 If the variable doesn't exist return an error, 177 else if a context is supplied assume it's a PULONG and fill in the value 178 and return no error, else if the value is non-zero return an error. 179 180 ---*/ 181 VP_STATUS VBoxRegistryCallback(PVOID HwDeviceExtension, PVOID Context, 182 PWSTR ValueName, PVOID ValueData, ULONG ValueLength) 183 { 184 //dprintf(("VBoxVideo::VBoxRegistryCallback: Context: %p, ValueName: %S, ValueData: %p, ValueLength: %d\n", 185 // Context, ValueName, ValueData, ValueLength)); 186 if (ValueLength) 187 { 188 if (Context) 189 *(ULONG *)Context = *(PULONG)ValueData; 190 else if (*((PULONG)ValueData) != 0) 191 return ERROR_INVALID_PARAMETER; 192 return NO_ERROR; 193 } 194 else 195 return ERROR_INVALID_PARAMETER; 196 } 197 198 VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal) 199 { 200 return VideoPortGetRegistryParameters(Reg, pName, FALSE, VBoxRegistryCallback, pVal); 201 } 202 203 VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val) 204 { 205 return VideoPortSetRegistryParameters(Reg, pName, &Val, sizeof(Val)); 206 } 207 208 void VBoxVideoCmnSignalEvent(PVBOXVIDEO_COMMON pCommon, uint64_t pvEvent) 209 { 210 PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon); 211 #ifndef VBOX_WITH_WDDM 212 PEVENT pEvent = (PEVENT)pvEvent; 213 PrimaryExtension->u.primary.VideoPortProcs.pfnSetEvent(PrimaryExtension, 214 pEvent); 215 #else 216 PKEVENT pEvent = (PKEVENT)pvEvent; 217 KeSetEvent(pEvent, 0, FALSE); 218 #endif 219 } 220 221 222 #define MEM_TAG 'HVBV' 223 224 void *VBoxVideoCmnMemAllocDriver(PVBOXVIDEO_COMMON pCommon, size_t cb) 225 { 226 ULONG Tag = MEM_TAG; 227 #ifndef VBOX_WITH_WDDM 228 PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon); 229 return PrimaryExtension->u.primary.VideoPortProcs.pfnAllocatePool(PrimaryExtension, (VBOXVP_POOL_TYPE)VpNonPagedPool, cb, Tag); 230 #else 231 return ExAllocatePoolWithTag(NonPagedPool, cb, Tag); 232 #endif 233 } 234 235 236 void VBoxVideoCmnMemFreeDriver(PVBOXVIDEO_COMMON pCommon, void *pv) 237 { 238 #ifndef VBOX_WITH_WDDM 239 PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon); 240 PrimaryExtension->u.primary.VideoPortProcs.pfnFreePool(PrimaryExtension, 241 pv); 242 #else 243 ExFreePool(pv); 244 #endif 245 } 246 247 248 static void VBoxSetupVideoPortFunctions(PDEVICE_EXTENSION PrimaryExtension, 249 VBOXVIDEOPORTPROCS *pCallbacks, 250 PVIDEO_PORT_CONFIG_INFO pConfigInfo); 251 252 #endif /* #ifndef VBOX_WITH_WDDM */ 323 #endif 253 324 254 325 #ifdef VBOX_WITH_GENERIC_MULTIMONITOR … … 2327 2398 #endif 2328 2399 2400 void VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value) 2401 { 2402 #ifndef VBOX_WITH_WDDM 2403 VideoPortWritePortUchar((PUCHAR)Port,Value); 2404 #else 2405 WRITE_PORT_UCHAR((PUCHAR)Port,Value); 2406 #endif 2407 } 2408 2409 void VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value) 2410 { 2411 #ifndef VBOX_WITH_WDDM 2412 VideoPortWritePortUshort((PUSHORT)Port,Value); 2413 #else 2414 WRITE_PORT_USHORT((PUSHORT)Port,Value); 2415 #endif 2416 } 2417 2418 void VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value) 2419 { 2420 #ifndef VBOX_WITH_WDDM 2421 VideoPortWritePortUlong((PULONG)Port,Value); 2422 #else 2423 WRITE_PORT_ULONG((PULONG)Port,Value); 2424 #endif 2425 } 2426 2427 uint8_t VBoxVideoCmnPortReadUchar(RTIOPORT Port) 2428 { 2429 #ifndef VBOX_WITH_WDDM 2430 return VideoPortReadPortUchar((PUCHAR)Port); 2431 #else 2432 return READ_PORT_UCHAR((PUCHAR)Port); 2433 #endif 2434 } 2435 2436 uint16_t VBoxVideoCmnPortReadUshort(RTIOPORT Port) 2437 { 2438 #ifndef VBOX_WITH_WDDM 2439 return VideoPortReadPortUshort((PUSHORT)Port); 2440 #else 2441 return READ_PORT_USHORT((PUSHORT)Port); 2442 #endif 2443 } 2444 2445 uint32_t VBoxVideoCmnPortReadUlong(RTIOPORT Port) 2446 { 2447 #ifndef VBOX_WITH_WDDM 2448 return VideoPortReadPortUlong((PULONG)Port); 2449 #else 2450 return READ_PORT_ULONG((PULONG)Port); 2451 #endif 2452 } 2453 2329 2454 int VBoxMapAdapterMemory (PVBOXVIDEO_COMMON pCommon, void **ppv, ULONG ulOffset, ULONG ulSize) 2330 2455 { … … 3646 3771 { 3647 3772 /* set the mode characteristics */ 3648 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES);3649 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_DATA, width);3650 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES);3651 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_DATA, height);3652 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);3653 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_DATA, bpp);3773 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES); 3774 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, width); 3775 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES); 3776 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, height); 3777 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP); 3778 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, bpp); 3654 3779 /* enable the mode */ 3655 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ENABLE);3656 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);3780 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ENABLE); 3781 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED); 3657 3782 #ifdef VBOX_WITH_WDDM 3658 3783 /* encode linear offDisplay to xOffset & yOffset to ensure offset fits USHORT */ … … 3671 3796 Assert(xOffset <= 0xffff); 3672 3797 Assert(yOffset <= 0xffff); 3673 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_X_OFFSET);3674 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_DATA, (USHORT)xOffset);3675 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_Y_OFFSET);3676 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_DATA, (USHORT)yOffset);3798 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_X_OFFSET); 3799 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, (USHORT)xOffset); 3800 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_Y_OFFSET); 3801 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, (USHORT)yOffset); 3677 3802 #endif 3678 3803 /** @todo read from the port to see if the mode switch was successful */ … … 3903 4028 Entry++) 3904 4029 { 3905 VBoxVideoCmnPortWriteUchar( (PUCHAR)0x03c8, (UCHAR)Entry);3906 VBoxVideoCmnPortWriteUchar( (PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Red);3907 VBoxVideoCmnPortWriteUchar( (PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Green);3908 VBoxVideoCmnPortWriteUchar( (PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Blue);4030 VBoxVideoCmnPortWriteUchar(0x03c8, (UCHAR)Entry); 4031 VBoxVideoCmnPortWriteUchar(0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Red); 4032 VBoxVideoCmnPortWriteUchar(0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Green); 4033 VBoxVideoCmnPortWriteUchar(0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Blue); 3909 4034 } 3910 4035 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
r33868 r33876 112 112 typedef UCHAR VBOXVCMNIRQL, *PVBOXVCMNIRQL; 113 113 114 typedef PEVENT VBOXVCMNEVENT;115 typedef VBOXVCMNEVENT *PVBOXVCMNEVENT;116 117 114 typedef struct _DEVICE_EXTENSION * VBOXCMNREG; 118 115 #else … … 137 134 typedef KSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK; 138 135 typedef KIRQL VBOXVCMNIRQL, *PVBOXVCMNIRQL; 139 140 typedef KEVENT VBOXVCMNEVENT;141 typedef VBOXVCMNEVENT *PVBOXVCMNEVENT;142 136 143 137 typedef HANDLE VBOXCMNREG; … … 384 378 void VBoxVideoCmnMemFreeDriver(PVBOXVIDEO_COMMON pCommon, void *pv); 385 379 380 /** Write an 8-bit value to an I/O port. */ 381 void VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value); 382 383 /** Write a 16-bit value to an I/O port. */ 384 void VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value); 385 386 /** Write a 32-bit value to an I/O port. */ 387 void VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value); 388 389 /** Read an 8-bit value from an I/O port. */ 390 uint8_t VBoxVideoCmnPortReadUchar(RTIOPORT Port); 391 392 /** Read a 16-bit value from an I/O port. */ 393 uint16_t VBoxVideoCmnPortReadUshort(RTIOPORT Port); 394 395 /** Read a 32-bit value from an I/O port. */ 396 uint32_t VBoxVideoCmnPortReadUlong(RTIOPORT Port); 397 386 398 #ifndef VBOX_WITH_WDDM 387 399 /* XPDM-WDDM common API */ 388 400 389 typedef PEVENT VBOXVCMNEVENT;390 typedef VBOXVCMNEVENT *PVBOXVCMNEVENT;391 392 DECLINLINE(VOID) VBoxVideoCmnPortWriteUchar(IN PUCHAR Port, IN UCHAR Value)393 {394 VideoPortWritePortUchar(Port,Value);395 }396 397 DECLINLINE(VOID) VBoxVideoCmnPortWriteUshort(IN PUSHORT Port, IN USHORT Value)398 {399 VideoPortWritePortUshort(Port,Value);400 }401 402 DECLINLINE(VOID) VBoxVideoCmnPortWriteUlong(IN PULONG Port, IN ULONG Value)403 {404 VideoPortWritePortUlong(Port,Value);405 }406 407 DECLINLINE(UCHAR) VBoxVideoCmnPortReadUchar(IN PUCHAR Port)408 {409 return VideoPortReadPortUchar(Port);410 }411 412 DECLINLINE(USHORT) VBoxVideoCmnPortReadUshort(IN PUSHORT Port)413 {414 return VideoPortReadPortUshort(Port);415 }416 417 DECLINLINE(ULONG) VBoxVideoCmnPortReadUlong(IN PULONG Port)418 {419 return VideoPortReadPortUlong(Port);420 }421 422 DECLINLINE(VOID) VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem)423 {424 VideoPortZeroMemory(pvMem, cbMem);425 }426 427 401 DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql) 428 402 { … … 430 404 } 431 405 432 DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)433 {434 pDeviceExtension->u.primary.VideoPortProcs.pfnAcquireSpinLockAtDpcLevel(pDeviceExtension, *SpinLock);435 }436 437 406 DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql) 438 407 { … … 440 409 } 441 410 442 DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)443 {444 pDeviceExtension->u.primary.VideoPortProcs.pfnReleaseSpinLockFromDpcLevel(pDeviceExtension, *SpinLock);445 }446 447 411 DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock) 448 412 { … … 454 418 return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteSpinLock(pDeviceExtension, *SpinLock); 455 419 } 456 457 DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)458 {459 return pDeviceExtension->u.primary.VideoPortProcs.pfnSetEvent(pDeviceExtension, (VBOXPEVENT)*pEvent); /** @todo slightly bogus cast */460 }461 462 DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)463 {464 ULONG fFlags = NOTIFICATION_EVENT;465 if(bSignaled)466 fFlags |= INITIAL_EVENT_SIGNALED;467 468 return pDeviceExtension->u.primary.VideoPortProcs.pfnCreateEvent(pDeviceExtension, fFlags, NULL, (VBOXPEVENT *)pEvent); /** @todo slightly bogus cast */469 }470 471 DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)472 {473 return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteEvent(pDeviceExtension, (VBOXPEVENT)*pEvent); /** @todo slightly bogus cast */474 }475 476 DECLINLINE(VP_STATUS) VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg)477 {478 *pReg = pDeviceExtension->pPrimary;479 return NO_ERROR;480 }481 482 DECLINLINE(VP_STATUS) VBoxVideoCmnRegFini(IN VBOXCMNREG Reg)483 {484 return NO_ERROR;485 }486 487 VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal);488 489 VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val);490 420 491 421 /* */ … … 498 428 499 429 /* XPDM-WDDM common API */ 500 DECLINLINE(VOID) VBoxVideoCmnPortWriteUchar(IN PUCHAR Port, IN UCHAR Value)501 {502 WRITE_PORT_UCHAR(Port,Value);503 }504 505 DECLINLINE(VOID) VBoxVideoCmnPortWriteUshort(IN PUSHORT Port, IN USHORT Value)506 {507 WRITE_PORT_USHORT(Port,Value);508 }509 510 DECLINLINE(VOID) VBoxVideoCmnPortWriteUlong(IN PULONG Port, IN ULONG Value)511 {512 WRITE_PORT_ULONG(Port,Value);513 }514 515 DECLINLINE(UCHAR) VBoxVideoCmnPortReadUchar(IN PUCHAR Port)516 {517 return READ_PORT_UCHAR(Port);518 }519 520 DECLINLINE(USHORT) VBoxVideoCmnPortReadUshort(IN PUSHORT Port)521 {522 return READ_PORT_USHORT(Port);523 }524 525 DECLINLINE(ULONG) VBoxVideoCmnPortReadUlong(IN PULONG Port)526 {527 return READ_PORT_ULONG(Port);528 }529 530 DECLINLINE(VOID) VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem)531 {532 memset(pvMem, 0, cbMem);533 }534 430 535 431 DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql) … … 538 434 } 539 435 540 DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)541 {542 KeAcquireSpinLockAtDpcLevel(SpinLock);543 }544 545 436 DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql) 546 437 { 547 438 KeReleaseSpinLock(SpinLock, NewIrql); 548 }549 550 DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)551 {552 KeReleaseSpinLockFromDpcLevel(SpinLock);553 439 } 554 440 … … 563 449 return NO_ERROR; 564 450 } 565 566 DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)567 {568 return KeSetEvent(pEvent, 0, FALSE);569 }570 571 DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)572 {573 KeInitializeEvent(pEvent, NotificationEvent, bSignaled);574 return NO_ERROR;575 }576 577 DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)578 {579 return NO_ERROR;580 }581 582 VP_STATUS VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg);583 584 DECLINLINE(VP_STATUS) VBoxVideoCmnRegFini(IN VBOXCMNREG Reg)585 {586 if(!Reg)587 return ERROR_INVALID_PARAMETER;588 589 NTSTATUS Status = ZwClose(Reg);590 return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;591 }592 593 VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal);594 595 VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val);596 451 597 452 /* */ … … 801 656 DECLINLINE(void) VBoxHGSMIHostWrite(PVBOXVIDEO_COMMON pCommon, ULONG data) 802 657 { 803 VBoxVideoCmnPortWriteUlong( (PULONG)pCommon->IOPortHost, data);658 VBoxVideoCmnPortWriteUlong(pCommon->IOPortHost, data); 804 659 } 805 660 806 661 DECLINLINE(ULONG) VBoxHGSMIHostRead(PVBOXVIDEO_COMMON pCommon) 807 662 { 808 return VBoxVideoCmnPortReadUlong( (PULONG)pCommon->IOPortHost);663 return VBoxVideoCmnPortReadUlong(pCommon->IOPortHost); 809 664 } 810 665 811 666 DECLINLINE(void) VBoxHGSMIGuestWrite(PVBOXVIDEO_COMMON pCommon, ULONG data) 812 667 { 813 VBoxVideoCmnPortWriteUlong( (PULONG)pCommon->IOPortGuest, data);668 VBoxVideoCmnPortWriteUlong(pCommon->IOPortGuest, data); 814 669 } 815 670 816 671 DECLINLINE(ULONG) VBoxHGSMIGuestRead(PVBOXVIDEO_COMMON pCommon) 817 672 { 818 return VBoxVideoCmnPortReadUlong( (PULONG)pCommon->IOPortGuest);673 return VBoxVideoCmnPortReadUlong(pCommon->IOPortGuest); 819 674 } 820 675 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp
r33800 r33876 97 97 USHORT DispiId; 98 98 99 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);100 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID_HGSMI);101 102 DispiId = VBoxVideoCmnPortReadUshort( (PUSHORT)VBE_DISPI_IOPORT_DATA);99 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID); 100 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID_HGSMI); 101 102 DispiId = VBoxVideoCmnPortReadUshort(VBE_DISPI_IOPORT_DATA); 103 103 104 104 return (DispiId == VBE_DISPI_ID_HGSMI); -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r33869 r33876 307 307 308 308 309 VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal)310 {311 if(!Reg)312 return ERROR_INVALID_PARAMETER;313 NTSTATUS Status = vboxWddmRegQueryValueDword(Reg, pName, (PDWORD)pVal);314 return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;315 }316 317 VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val)318 {319 if(!Reg)320 return ERROR_INVALID_PARAMETER;321 NTSTATUS Status = vboxWddmRegSetValueDword(Reg, pName, Val);322 return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;323 }324 325 VP_STATUS VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg)326 {327 WCHAR Buf[512];328 ULONG cbBuf = sizeof(Buf);329 NTSTATUS Status = vboxWddmRegQueryDrvKeyName(pDeviceExtension, cbBuf, Buf, &cbBuf);330 Assert(Status == STATUS_SUCCESS);331 if (Status == STATUS_SUCCESS)332 {333 Status = vboxWddmRegOpenKey(pReg, Buf, GENERIC_READ | GENERIC_WRITE);334 Assert(Status == STATUS_SUCCESS);335 if(Status == STATUS_SUCCESS)336 return NO_ERROR;337 }338 339 /* fall-back to make the subsequent VBoxVideoCmnRegXxx calls treat the fail accordingly340 * basically needed to make as less modifications to the current XPDM code as possible */341 *pReg = NULL;342 343 return ERROR_INVALID_PARAMETER;344 }345 346 309 D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo) 347 310 { … … 416 379 *pAdapterMemorySize = VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES; 417 380 418 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);419 VBoxVideoCmnPortWriteUshort( (PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID2);420 DispiId = VBoxVideoCmnPortReadUshort( (PUSHORT)VBE_DISPI_IOPORT_DATA);381 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID); 382 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID2); 383 DispiId = VBoxVideoCmnPortReadUshort(VBE_DISPI_IOPORT_DATA); 421 384 if (DispiId == VBE_DISPI_ID2) 422 385 { … … 431 394 * an ULONG from the data port without setting an index before. 432 395 */ 433 *pAdapterMemorySize = VBoxVideoCmnPortReadUlong( (PULONG)VBE_DISPI_IOPORT_DATA);396 *pAdapterMemorySize = VBoxVideoCmnPortReadUlong(VBE_DISPI_IOPORT_DATA); 434 397 if (VBoxHGSMIIsSupported ()) 435 398 {
Note:
See TracChangeset
for help on using the changeset viewer.