Changeset 22444 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Aug 25, 2009 5:03:25 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 51441
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.