VirtualBox

Changeset 44722 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Feb 15, 2013 6:19:53 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83823
Message:

VMMDev: More cleanups.

Location:
trunk/src/VBox/Devices
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r44721 r44722  
    6060*   Defined Constants And Macros                                               *
    6161*******************************************************************************/
    62 #define VMMDEVSTATE_2_DEVINS(pVMMDevState)         ( (pVMMDevState)->pDevIns )
    63 
    6462#define VBOX_GUEST_INTERFACE_VERSION_1_03(s) \
    6563    (   RT_HIWORD((s)->guestInfo.interfaceVersion) == 1 \
     
    131129 */
    132130
    133 static void vmmdevSetIRQ_Legacy_EMT (VMMDevState *pVMMDevState)
     131static void vmmdevSetIRQ_Legacy_EMT(VMMDevState *pVMMDevState)
    134132{
    135133    if (!pVMMDevState->fu32AdditionsOk)
     
    167165    /* Set IRQ level for pin 0 */
    168166    /** @todo make IRQ pin configurable, at least a symbolic constant */
    169     PPDMDEVINS pDevIns = VMMDEVSTATE_2_DEVINS(pVMMDevState);
     167    PPDMDEVINS pDevIns = pVMMDevState->pDevIns;
    170168    PDMDevHlpPCISetIrqNoWait(pDevIns, 0, u32IRQLevel);
    171169    Log(("vmmdevSetIRQ: IRQ set %d\n", u32IRQLevel));
    172170}
    173171
    174 static void vmmdevMaybeSetIRQ_EMT (VMMDevState *pVMMDevState)
    175 {
    176     PPDMDEVINS pDevIns = VMMDEVSTATE_2_DEVINS (pVMMDevState);
    177 
     172static void vmmdevMaybeSetIRQ_EMT(VMMDevState *pVMMDevState)
     173{
    178174    Log3(("vmmdevMaybeSetIRQ_EMT: u32HostEventFlags = 0x%08X, u32GuestFilterMask = 0x%08X.\n",
    179175          pVMMDevState->u32HostEventFlags, pVMMDevState->u32GuestFilterMask));
     
    182178    {
    183179        pVMMDevState->pVMMDevRAMR3->V.V1_04.fHaveEvents = true;
    184         PDMDevHlpPCISetIrqNoWait (pDevIns, 0, 1);
     180        PDMDevHlpPCISetIrqNoWait(pVMMDevState->pDevIns, 0, 1);
    185181        Log3(("vmmdevMaybeSetIRQ_EMT: IRQ set.\n"));
    186182    }
    187183}
    188184
    189 static void vmmdevNotifyGuest_EMT (VMMDevState *pVMMDevState, uint32_t u32EventMask)
     185static void vmmdevNotifyGuest_EMT(VMMDevState *pVMMDevState, uint32_t u32EventMask)
    190186{
    191187    Log3(("VMMDevNotifyGuest_EMT: u32EventMask = 0x%08X.\n", u32EventMask));
    192188
    193     if (VBOX_GUEST_INTERFACE_VERSION_1_03 (pVMMDevState))
     189    if (VBOX_GUEST_INTERFACE_VERSION_1_03(pVMMDevState))
    194190    {
    195191        Log3(("VMMDevNotifyGuest_EMT: Old additions detected.\n"));
    196192
    197193        pVMMDevState->u32HostEventFlags |= u32EventMask;
    198         vmmdevSetIRQ_Legacy_EMT (pVMMDevState);
     194        vmmdevSetIRQ_Legacy_EMT(pVMMDevState);
    199195    }
    200196    else
     
    252248void VMMDevNotifyGuest (VMMDevState *pVMMDevState, uint32_t u32EventMask)
    253249{
    254     PPDMDEVINS pDevIns = VMMDEVSTATE_2_DEVINS(pVMMDevState);
     250    PPDMDEVINS pDevIns = pVMMDevState->pDevIns;
    255251
    256252    Log3(("VMMDevNotifyGuest: u32EventMask = 0x%08X.\n", u32EventMask));
     
    17101706            else
    17111707            {
    1712                 if (VBOX_GUEST_INTERFACE_VERSION_1_03 (pThis))
     1708                if (VBOX_GUEST_INTERFACE_VERSION_1_03(pThis))
    17131709                {
    1714                     vmmdevSetIRQ_Legacy_EMT (pThis);
     1710                    vmmdevSetIRQ_Legacy_EMT(pThis);
    17151711                }
    17161712                else
     
    24782474
    24792475/**
    2480  * Callback function for mapping an PCI I/O region.
    2481  *
    2482  * @return VBox status code.
    2483  * @param   pPciDev         Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
    2484  * @param   iRegion         The region number.
    2485  * @param   GCPhysAddress   Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an
    2486  *                          I/O port, else it's a physical address.
    2487  *                          This address is *NOT* relative to pci_mem_base like earlier!
    2488  * @param   enmType         One of the PCI_ADDRESS_SPACE_* values.
    2489  */
    2490 static DECLCALLBACK(int) vmmdevIORAMRegionMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
     2476 * @interface_method_impl{FNPCIIOREGIONMAP, MMIO/MMIO2 regions}
     2477 */
     2478static DECLCALLBACK(int)
     2479vmmdevIORAMRegionMap(PPCIDEVICE pPciDev, int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
    24912480{
    24922481    LogFlow(("vmmdevR3IORAMRegionMap: iRegion=%d GCPhysAddress=%RGp cb=%#x enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
     
    25522541
    25532542/**
    2554  * Callback function for mapping a PCI I/O region.
    2555  *
    2556  * @return VBox status code.
    2557  * @param   pPciDev         Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
    2558  * @param   iRegion         The region number.
    2559  * @param   GCPhysAddress   Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an
    2560  *                          I/O port, else it's a physical address.
    2561  *                          This address is *NOT* relative to pci_mem_base like earlier!
    2562  * @param   enmType         One of the PCI_ADDRESS_SPACE_* values.
    2563  */
    2564 static DECLCALLBACK(int) vmmdevIOPortRegionMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
     2543 * @interface_method_impl{FNPCIIOREGIONMAP, I/O Port Region}
     2544 */
     2545static DECLCALLBACK(int)
     2546vmmdevIOPortRegionMap(PPCIDEVICE pPciDev, int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
    25652547{
    25662548    PVMMDEV pThis = RT_FROM_MEMBER(pPciDev, VMMDEV, PciDev);
    2567     int         rc = VINF_SUCCESS;
    25682549
    25692550    Assert(enmType == PCI_ADDRESS_SPACE_IO);
     
    25722553
    25732554    /*
    2574      * Save the base port address to simplify Port offset calculations.
    2575      */
    2576     pThis->PortBase = (RTIOPORT)GCPhysAddress;
    2577 
    2578     /*
    25792555     * Register our port IO handlers.
    25802556     */
    2581     rc = PDMDevHlpIOPortRegister(pPciDev->pDevIns,
    2582                                  (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST, 1,
    2583                                  (void*)pThis, vmmdevRequestHandler,
    2584                                  NULL, NULL, NULL, "VMMDev Request Handler");
     2557    int rc = PDMDevHlpIOPortRegister(pPciDev->pDevIns, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST, 1,
     2558                                     pThis, vmmdevRequestHandler, NULL, NULL, NULL, "VMMDev Request Handler");
    25852559    AssertRC(rc);
    25862560    return rc;
     
    26322606/* -=-=-=-=-=- PDMIVMMDEVPORT (VMMDEV::IPort) -=-=-=-=-=- */
    26332607
    2634 /** Converts a VMMDev port interface pointer to a VMMDev state pointer. */
    2635 #define IVMMDEVPORT_2_VMMDEVSTATE(pInterface) ( (VMMDevState*)((uintptr_t)pInterface - RT_OFFSETOF(VMMDevState, IPort)) )
    2636 
    2637 
    26382608/**
    26392609 * @interface_method_impl{PDMIVMMDEVPORT, pfnQueryAbsoluteMouse}
     
    26432613    PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
    26442614
     2615    /** @todo at the first sign of trouble in this area, just enter the critsect.
     2616     * As indicated by the comment below, the atomic reads serves no real purpose
     2617     * here since we can assume cache coherency protocoles and int32_t alignment
     2618     * rules making sure we won't see a halfwritten value. */
    26452619    if (pxAbs)
    26462620        *pxAbs = ASMAtomicReadS32(&pThis->mouseXAbs); /* why the atomic read? */
    26472621    if (pyAbs)
    26482622        *pyAbs = ASMAtomicReadS32(&pThis->mouseYAbs);
     2623
    26492624    return VINF_SUCCESS;
    26502625}
     
    27172692
    27182693    if (idxDisplay >= RT_ELEMENTS(pThis->displayChangeData.aRequests))
    2719     {
    27202694        return VERR_INVALID_PARAMETER;
    2721     }
    27222695
    27232696    PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
     
    29212894    Log(("vmmdevIPort_VBVAChange: fEnabled = %d\n", fEnabled));
    29222895
     2896    /* Only used by saved state, which I guess is why we don't bother with locking here. */
    29232897    pThis->u32VideoAccelEnabled = fEnabled;
    29242898}
     
    29292903static DECLCALLBACK(int) vmmdevIPort_CpuHotUnplug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
    29302904{
    2931     int rc = VINF_SUCCESS;
    29322905    PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
     2906    int     rc    = VINF_SUCCESS;
    29332907
    29342908    Log(("vmmdevIPort_CpuHotUnplug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage));
     
    29552929static DECLCALLBACK(int) vmmdevIPort_CpuHotPlug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
    29562930{
    2957     int rc = VINF_SUCCESS;
    29582931    PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
     2932    int     rc    = VINF_SUCCESS;
    29592933
    29602934    Log(("vmmdevCpuPlug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage));
  • trunk/src/VBox/Devices/VMMDev/VMMDevState.h

    r44709 r44722  
    158158    /** message buffer index. */
    159159    uint32_t iMsg;
    160     /** Base port in the assigned I/O space. */
    161     RTIOPORT PortBase;
    162     /** Alignment padding.  */
    163     RTIOPORT PortAlignment2;
     160    /** Alignment padding. */
     161    uint32_t u32Alignment2;
    164162
    165163    /** IRQ number assigned to the device */
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r44720 r44722  
    14271427    GEN_CHECK_OFF(VMMDEV, szMsg);
    14281428    GEN_CHECK_OFF(VMMDEV, iMsg);
    1429     GEN_CHECK_OFF(VMMDEV, PortBase);
    14301429    GEN_CHECK_OFF(VMMDEV, irq);
    14311430    GEN_CHECK_OFF(VMMDEV, u32HostEventFlags);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette