Changeset 22444 in vbox
- Timestamp:
- Aug 25, 2009 5:03:25 PM (15 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
r22414 r22444 1206 1206 VBoxBiosString, 1207 1207 sizeof(VBoxBiosString)); 1208 #if defined(VBOX_WITH_HGSMI) && defined(VBOX_WITH_VIDEOHWACCEL) 1209 VIDEO_ACCESS_RANGE tmpRanges[1]; 1210 ULONG slot; 1211 1212 /* need to call VideoPortGetAccessRanges to ensure interrupt info in ConfigInfo gets set up */ 1213 VP_STATUS status = VideoPortGetAccessRanges(HwDeviceExtension, 1214 0, 1215 NULL, 1216 1, 1217 tmpRanges, 1218 NULL, 1219 NULL, 1220 (PULONG) &slot); 1221 Assert(status == NO_ERROR ); 1222 // Assert(AccessRanges[0].RangeStart.QuadPart == tmpRanges[0].RangeStart.QuadPart); 1223 // Assert(AccessRanges[0].RangeLength == tmpRanges[0].RangeLength); 1224 // Assert(AccessRanges[0].RangeInIoSpace == tmpRanges[0].RangeInIoSpace); 1225 // Assert(AccessRanges[0].RangeVisible == tmpRanges[0].RangeVisible); 1226 // Assert(AccessRanges[0].RangeShareable == tmpRanges[0].RangeShareable); 1227 // Assert(AccessRanges[0].RangePassive == tmpRanges[0].RangePassive); 1228 1229 /* no matter what we get with VideoPortGetAccessRanges, we assert the default ranges */ 1230 #endif 1208 #ifdef VBOX_WITH_HGSMI 1209 if (VBoxHGSMIIsSupported ((PDEVICE_EXTENSION)HwDeviceExtension)) 1210 { 1211 dprintf(("VBoxVideo::VBoxVideoFindAdapter: calling VideoPortGetAccessRanges\n")); 1212 1213 /* Ports not yet found. */ 1214 ((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.IOPortHost = 0; 1215 ((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.IOPortGuest = 0; 1216 1217 VIDEO_ACCESS_RANGE tmpRanges[2]; 1218 ULONG slot; 1219 1220 /* need to call VideoPortGetAccessRanges to ensure interrupt info in ConfigInfo gets set up */ 1221 VP_STATUS status = VideoPortGetAccessRanges(HwDeviceExtension, 1222 0, 1223 NULL, 1224 sizeof (tmpRanges)/sizeof (tmpRanges[0]), 1225 tmpRanges, 1226 NULL, 1227 NULL, 1228 (PULONG) &slot); 1229 if (status == NO_ERROR) 1230 { 1231 ULONG iRange = 0; 1232 for (; iRange < sizeof (tmpRanges)/sizeof (tmpRanges[0]); iRange++) 1233 { 1234 dprintf(("VBoxVideo::VBoxVideoFindAdapter: range[%i]:\n" 1235 " RangeStart = 0x%llx\n" 1236 " RangeLength = %d\n" 1237 " RangeInIoSpace = %d\n" 1238 " RangeVisible = %d\n" 1239 " RangeShareable = %d\n" 1240 " RangePassive = %d\n", 1241 iRange, 1242 tmpRanges[iRange].RangeStart.QuadPart, 1243 tmpRanges[iRange].RangeLength, 1244 tmpRanges[iRange].RangeInIoSpace, 1245 tmpRanges[iRange].RangeVisible, 1246 tmpRanges[iRange].RangeShareable, 1247 tmpRanges[iRange].RangePassive)); 1248 if (tmpRanges[iRange].RangeInIoSpace) 1249 { 1250 PVOID ioBase = VideoPortGetDeviceBase(HwDeviceExtension, tmpRanges[iRange].RangeStart, 8, VIDEO_MEMORY_SPACE_IO); 1251 dprintf (("ioBase %p\n", ioBase)); 1252 1253 ((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.IOPortHost = (RTIOPORT)ioBase + VGA_PORT_OFF_HGSMI_HOST; 1254 ((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.IOPortGuest = (RTIOPORT)ioBase + VGA_PORT_OFF_HGSMI_GUEST; 1255 } 1256 } 1257 } 1258 1259 /* no matter what we get with VideoPortGetAccessRanges, we assert the default ranges */ 1260 } 1261 #endif /* VBOX_WITH_HGSMI */ 1231 1262 rc = VideoPortVerifyAccessRanges(HwDeviceExtension, 1, AccessRanges); 1232 1263 dprintf(("VBoxVideo::VBoxVideoFindAdapter: VideoPortVerifyAccessRanges returned 0x%x\n", rc)); … … 1777 1808 VideoPortWritePortUlong((PULONG)VBE_DISPI_IOPORT_DATA, VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE + pDevExt->iDevice); 1778 1809 #else 1779 VBoxVideo HostWriteUlong(((PDEVICE_EXTENSION)HwDeviceExtension)->pPrimary, VBE_DISPI_INDEX_VBOX_VIDEO, VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE + pDevExt->iDevice);1810 VBoxVideoVBEWriteUlong(((PDEVICE_EXTENSION)HwDeviceExtension)->pPrimary, VBE_DISPI_INDEX_VBOX_VIDEO, VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE + pDevExt->iDevice); 1780 1811 #endif 1781 1812 } … … 2044 2075 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_DISABLED); 2045 2076 #else 2046 VBoxVideo HostWriteUshort(((PDEVICE_EXTENSION)HwDeviceExtension)->pPrimary, VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED);2077 VBoxVideoVBEWriteUshort(((PDEVICE_EXTENSION)HwDeviceExtension)->pPrimary, VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED); 2047 2078 #endif 2048 2079 … … 2159 2190 /** @todo read from the port to see if the mode switch was successful */ 2160 2191 #else 2161 VBoxVideo HostWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_XRES, (USHORT)ModeInfo->VisScreenWidth);2162 VBoxVideo HostWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_YRES, (USHORT)ModeInfo->VisScreenHeight);2163 VBoxVideo HostWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_BPP, (USHORT)ModeInfo->BitsPerPlane);2164 VBoxVideo HostWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);2192 VBoxVideoVBEWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_XRES, (USHORT)ModeInfo->VisScreenWidth); 2193 VBoxVideoVBEWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_YRES, (USHORT)ModeInfo->VisScreenHeight); 2194 VBoxVideoVBEWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_BPP, (USHORT)ModeInfo->BitsPerPlane); 2195 VBoxVideoVBEWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED); 2165 2196 #endif 2166 2197 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
r22136 r22444 51 51 #define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7 52 52 #define VBE_DISPI_INDEX_VBOX_VIDEO 0xa 53 #ifdef VBOX_WITH_HGSMI54 #define VBE_DISPI_INDEX_VBVA_HOST 0xb55 #define VBE_DISPI_INDEX_VBVA_GUEST 0xc56 #endif /* VBOX_WITH_HGSMI */57 53 58 54 #define VBE_DISPI_ID2 0xB0C2 … … 70 66 #define VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES (VBE_DISPI_TOTAL_VIDEO_MEMORY_KB * 1024) 71 67 68 #ifdef VBOX_WITH_HGSMI 69 #define VGA_PORT_OFF_HGSMI_HOST 0 70 #define VGA_PORT_OFF_HGSMI_GUEST 4 71 #endif /* VBOX_WITH_HGSMI */ 72 72 73 typedef struct _DEVICE_EXTENSION 73 74 { … … 142 143 143 144 PSPIN_LOCK pGHRWLock; /* lock for making guest->host read/writes atomic */ 145 146 /* The IO Port Number for host commands. */ 147 RTIOPORT IOPortHost; 148 149 /* The IO Port Number for guest commands. */ 150 RTIOPORT IOPortGuest; 144 151 #endif /* VBOX_WITH_HGSMI */ 145 152 } primary; … … 256 263 #ifdef VBOX_WITH_HGSMI 257 264 258 DECLINLINE(void) VBoxVideo HostWriteUlongLocked(USHORT dataType, ULONG data)265 DECLINLINE(void) VBoxVideoVBEWriteUlongLocked(USHORT dataType, ULONG data) 259 266 { 260 267 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, dataType); … … 262 269 } 263 270 264 DECLINLINE(void) VBoxVideo HostWriteUshortLocked(USHORT dataType, USHORT data)271 DECLINLINE(void) VBoxVideoVBEWriteUshortLocked(USHORT dataType, USHORT data) 265 272 { 266 273 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, dataType); … … 268 275 } 269 276 270 DECLINLINE(ULONG) VBoxVideo HostReadUlongLocked (USHORT dataType)277 DECLINLINE(ULONG) VBoxVideoVBEReadUlongLocked (USHORT dataType) 271 278 { 272 279 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, dataType); … … 274 281 } 275 282 276 DECLINLINE(void) VBoxVideo HostWriteUlong(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType, ULONG data)283 DECLINLINE(void) VBoxVideoVBEWriteUlong(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType, ULONG data) 277 284 { 278 285 UCHAR oldIrql; … … 280 287 PrimaryExtension->u.primary.pGHRWLock, 281 288 &oldIrql); 282 VBoxVideo HostWriteUlongLocked(dataType, data);289 VBoxVideoVBEWriteUlongLocked(dataType, data); 283 290 VideoPortReleaseSpinLock(PrimaryExtension, 284 291 PrimaryExtension->u.primary.pGHRWLock, … … 286 293 } 287 294 288 DECLINLINE(void) VBoxVideo HostWriteUshort(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType, USHORT data)295 DECLINLINE(void) VBoxVideoVBEWriteUshort(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType, USHORT data) 289 296 { 290 297 UCHAR oldIrql; … … 292 299 PrimaryExtension->u.primary.pGHRWLock, 293 300 &oldIrql); 294 VBoxVideo HostWriteUshortLocked(dataType, data);301 VBoxVideoVBEWriteUshortLocked(dataType, data); 295 302 VideoPortReleaseSpinLock(PrimaryExtension, 296 303 PrimaryExtension->u.primary.pGHRWLock, … … 298 305 } 299 306 300 DECLINLINE(ULONG) VBoxVideo HostReadUlong(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType)301 { 302 307 DECLINLINE(ULONG) VBoxVideoVBEReadUlong(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType) 308 { 309 ULONG data; 303 310 UCHAR oldIrql; 304 311 VideoPortAcquireSpinLock(PrimaryExtension, 305 312 PrimaryExtension->u.primary.pGHRWLock, 306 313 &oldIrql); 307 data = VBoxVideoHostReadUlongLocked(dataType);314 data = VBoxVideoVBEReadUlongLocked(dataType); 308 315 VideoPortReleaseSpinLock(PrimaryExtension, 309 316 PrimaryExtension->u.primary.pGHRWLock, 310 317 oldIrql); 311 318 return data; 319 } 320 321 /* 322 * Host and Guest port IO helpers. 323 */ 324 DECLINLINE(void) VBoxHGSMIHostWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data) 325 { 326 VideoPortWritePortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost, data); 327 } 328 329 DECLINLINE(ULONG) VBoxHGSMIHostRead(PDEVICE_EXTENSION PrimaryExtension) 330 { 331 return VideoPortReadPortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost); 332 } 333 334 DECLINLINE(void) VBoxHGSMIGuestWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data) 335 { 336 VideoPortWritePortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest, data); 337 } 338 339 DECLINLINE(ULONG) VBoxHGSMIGuestRead(PDEVICE_EXTENSION PrimaryExtension) 340 { 341 return VideoPortReadPortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest); 312 342 } 313 343 -
trunk/src/VBox/Devices/Graphics/DevVGA.cpp
r22416 r22444 71 71 #define VGA_MAPPING_SIZE _512K 72 72 73 #ifdef VBOX_WITH_HGSMI 74 #define PCIDEV_2_VGASTATE(pPciDev) ((VGAState *)((uintptr_t)pPciDev - RT_OFFSETOF(VGAState, Dev))) 75 #endif /* VBOX_WITH_HGSMI */ 73 76 /** Converts a vga adaptor state pointer to a device instance pointer. */ 74 77 #define VGASTATE2DEVINS(pVgaState) ((pVgaState)->CTX_SUFF(pDevIns)) … … 3414 3417 } 3415 3418 3419 #ifdef VBOX_WITH_HGSMI 3420 #ifdef IN_RING3 3421 /** 3422 * Port I/O Handler for PCI Ports OUT operations. 3423 * 3424 * @returns VBox status code. 3425 * 3426 * @param pDevIns The device instance. 3427 * @param pvUser User argument - ignored. 3428 * @param Port Port number used for the operation. 3429 * @param u32 The value to output. 3430 * @param cb The value size in bytes. 3431 */ 3432 static DECLCALLBACK(int) vgaR3IOPortPCIWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 3433 { 3434 LogFlowFunc(("Port 0x%x, u32 0x%x, cb %d\n", Port, u32, cb)); 3435 VGAState *s = PDMINS_2_DATA(pDevIns, PVGASTATE); 3436 3437 int rc = PDMCritSectEnter(&s->lock, VERR_SEM_BUSY); 3438 if (rc != VINF_SUCCESS) 3439 return rc; 3440 3441 NOREF(pvUser); 3442 3443 if (cb == 4) 3444 { 3445 RTIOPORT portOffset = Port - s->IOPortBase; 3446 3447 switch (portOffset) 3448 { 3449 case VGA_PORT_OFF_HGSMI_HOST: 3450 { 3451 #if defined(VBOX_WITH_VIDEOHWACCEL) 3452 if(u32 == HGSMIOFFSET_VOID) 3453 { 3454 PDMDevHlpPCISetIrq(pDevIns, 0, PDM_IRQ_LEVEL_LOW); 3455 HGSMIClearHostGuestFlags(s->pHGSMI, HGSMIHOSTFLAGS_IRQ); 3456 } 3457 else 3458 #endif 3459 { 3460 HGSMIHostWrite(s->pHGSMI, u32); 3461 } 3462 } break; 3463 3464 case VGA_PORT_OFF_HGSMI_GUEST: 3465 { 3466 HGSMIGuestWrite(s->pHGSMI, u32); 3467 } break; 3468 3469 default: 3470 { 3471 AssertMsgFailed(("vgaR3IOPortPCIWrite: Port=%#x cb=%d u32=%#x\n", Port, cb, u32)); 3472 } break; 3473 } 3474 } 3475 else 3476 { 3477 AssertMsgFailed(("vgaR3IOPortPCIWrite: Port=%#x cb=%d u32=%#x\n", Port, cb, u32)); 3478 } 3479 3480 PDMCritSectLeave(&s->lock); 3481 return VINF_SUCCESS; 3482 } 3483 3484 /** 3485 * Port I/O Handler for PCI Port IN operations. 3486 * 3487 * @returns VBox status code. 3488 * 3489 * @param pDevIns The device instance. 3490 * @param pvUser User argument - ignored. 3491 * @param Port Port number used for the operation. 3492 * @param pu32 Where to store the result. 3493 * @param cb Number of bytes to read. 3494 */ 3495 static DECLCALLBACK(int) vgaR3IOPortPCIRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 3496 { 3497 LogFlowFunc(("Port 0x%x, cb %d\n", Port, cb)); 3498 VGAState *s = PDMINS_2_DATA(pDevIns, PVGASTATE); 3499 3500 int rc = PDMCritSectEnter(&s->lock, VERR_SEM_BUSY); 3501 if (rc != VINF_SUCCESS) 3502 return rc; 3503 3504 NOREF(pvUser); 3505 3506 if (cb == 4) 3507 { 3508 RTIOPORT portOffset = Port - s->IOPortBase; 3509 3510 switch (portOffset) 3511 { 3512 case VGA_PORT_OFF_HGSMI_HOST: 3513 { 3514 *pu32 = HGSMIHostRead(s->pHGSMI); 3515 } break; 3516 case VGA_PORT_OFF_HGSMI_GUEST: 3517 { 3518 *pu32 = HGSMIGuestRead(s->pHGSMI); 3519 } break; 3520 default: 3521 { 3522 AssertMsgFailed(("vgaR3IOPortPCIRead: Port=%#x cb=%d\n", Port, cb)); 3523 rc = VERR_IOM_IOPORT_UNUSED; 3524 } break; 3525 } 3526 } 3527 else 3528 { 3529 AssertMsgFailed(("vgaR3IOPortPCIRead: Port=%#x cb=%d\n", Port, cb)); 3530 rc = VERR_IOM_IOPORT_UNUSED; 3531 } 3532 3533 PDMCritSectLeave(&s->lock); 3534 return rc; 3535 } 3536 #endif /* IN_RING3 */ 3537 #endif /* VBOX_WITH_HGSMI */ 3416 3538 3417 3539 … … 5640 5762 } 5641 5763 5642 5764 #ifdef VBOX_WITH_HGSMI 5765 #ifdef IN_RING3 5766 /** 5767 * Callback function for mapping a PCI I/O region. 5768 * 5769 * @return VBox status code. 5770 * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance. 5771 * @param iRegion The region number. 5772 * @param GCPhysAddress Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an 5773 * I/O port, else it's a physical address. 5774 * This address is *NOT* relative to pci_mem_base like earlier! 5775 * @param enmType One of the PCI_ADDRESS_SPACE_* values. 5776 */ 5777 static DECLCALLBACK(int) vgaR3IOPortRegionMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType) 5778 { 5779 VGAState *pThis = PCIDEV_2_VGASTATE(pPciDev); 5780 int rc = VINF_SUCCESS; 5781 5782 Assert(enmType == PCI_ADDRESS_SPACE_IO); 5783 Assert(iRegion == 1); 5784 AssertMsg(RT_ALIGN(GCPhysAddress, 8) == GCPhysAddress, ("Expected 8 byte alignment. GCPhysAddress=%#x\n", GCPhysAddress)); 5785 5786 /* 5787 * Save the base port address to simplify Port offset calculations. 5788 */ 5789 pThis->IOPortBase = (RTIOPORT)GCPhysAddress; 5790 5791 /* 5792 * Register port IO handlers. 5793 */ 5794 rc = PDMDevHlpIOPortRegister(pPciDev->pDevIns, 5795 (RTIOPORT)GCPhysAddress, cb, 5796 (void*)pThis, vgaR3IOPortPCIWrite, vgaR3IOPortPCIRead, 5797 NULL, NULL, "VGA PCI IO Ports"); 5798 AssertRC(rc); 5799 return rc; 5800 } 5801 #endif /* IN_RING3 */ 5802 #endif /* VBOX_WITH_HGSMI */ 5643 5803 5644 5804 /** … … 5980 6140 if (RT_FAILURE(rc)) 5981 6141 return rc; 6142 #ifdef VBOX_WITH_HGSMI 6143 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, 0x10, PCI_ADDRESS_SPACE_IO, vgaR3IOPortRegionMap); 6144 if (RT_FAILURE(rc)) 6145 return rc; 6146 #endif /* VBOX_WITH_HGSMI */ 5982 6147 5983 6148 /* Initialize the PDM lock. */ -
trunk/src/VBox/Devices/Graphics/DevVGA.h
r22412 r22444 47 47 #ifdef VBOX_WITH_HGSMI 48 48 #include "HGSMI/HGSMIHost.h" 49 50 #define VGA_PORT_OFF_HGSMI_HOST 0 51 #define VGA_PORT_OFF_HGSMI_GUEST 4 49 52 #endif /* VBOX_WITH_HGSMI */ 50 53 … … 398 401 uint32_t au32LogoPalette[256]; 399 402 #endif /* VBOX */ 403 #ifdef VBOX_WITH_HGSMI 404 /** Base port in the assigned PCI I/O space. */ 405 RTIOPORT IOPortBase; 406 uint8_t Padding11[6]; /**< Alignment padding. */ 407 #endif /* VBOX_WITH_HGSMI */ 400 408 } VGAState; 401 409 #ifdef VBOX
Note:
See TracChangeset
for help on using the changeset viewer.