VirtualBox

Changeset 36448 in vbox


Ignore:
Timestamp:
Mar 28, 2011 12:37:43 PM (14 years ago)
Author:
vboxsync
Message:

PCI: refactoring, further IOMMU work

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/rawpci.h

    r36441 r36448  
    5050} PCIRAWMEMINFOACTION;
    5151
     52/**
     53 * Per-VM capability flag bits.
     54 */
     55typedef enum PCIRAWVMFLAGS
     56{
     57    /** If we can use IOMMU in this VM. */
     58    PCIRAW_VMFLAGS_HAS_IOMMU = (1 << 0),
     59    PCIRAW_VMFLAGS_32BIT_HACK = 0x7fffffff
     60} PCIRAWVMFLAGS;
     61
    5262/* Forward declaration. */
    53 struct RAWPCIVM;
     63struct RAWPCIPERVM;
    5464
    5565/**
     
    6979 * @param   Action        Action performed (i.e. if page was mapped or unmapped).
    7080 */
    71 typedef DECLCALLBACK(int) FNRAWPCICONTIGPHYSMEMINFO(struct RAWPCIVM* pVmData, RTHCPHYS HostStart, RTGCPHYS GuestStart, uint64_t cMemSize, PCIRAWMEMINFOACTION Action);
     81typedef DECLCALLBACK(int) FNRAWPCICONTIGPHYSMEMINFO(struct RAWPCIPERVM* pVmData, RTHCPHYS HostStart, RTGCPHYS GuestStart, uint64_t cMemSize, PCIRAWMEMINFOACTION Action);
    7282typedef FNRAWPCICONTIGPHYSMEMINFO *PFNRAWPCICONTIGPHYSMEMINFO;
    7383
    7484/** Data being part of the VM structure. */
    75 typedef struct RAWPCIVM
     85typedef struct RAWPCIPERVM
    7686{
    7787    /** Shall only be interpreted by the host PCI driver. */
     
    7989    /** Callback called when mapping of host pages to the guest changes. */
    8090    PFNRAWPCICONTIGPHYSMEMINFO  pfnContigMemInfo;
    81 } RAWPCIVM;
    82 typedef RAWPCIVM *PRAWPCIVM;
     91    /** Flags describing VM capabilities (such as IOMMU presence). */
     92    uint32_t                    fVmCaps;
     93} RAWPCIPERVM;
     94typedef RAWPCIPERVM *PRAWPCIPERVM;
    8395
    8496/** Parameters buffer for PCIRAWR0_DO_OPEN_DEVICE call */
     
    90102    /* out */
    91103    PCIRAWDEVHANDLE Device;
     104    uint32_t        fDevFlags;
    92105} PCIRAWREQOPENDEVICE;
    93106
     
    496509                                                   uint32_t             u32HostAddress,
    497510                                                   uint32_t             fFlags,
    498                                                    PRAWPCIVM            pVmCtx,
    499                                                    PRAWPCIDEVPORT       *ppDevPort));
     511                                                   PRAWPCIPERVM         pVmCtx,
     512                                                   PRAWPCIDEVPORT       *ppDevPort,
     513                                                   uint32_t             *pfDevFlags));
    500514
    501515
     
    511525    DECLR0CALLBACKMEMBER(int, pfnInitVm,(PRAWPCIFACTORY       pFactory,
    512526                                         PVM                  pVM,
    513                                          PRAWPCIVM            pPciData));
     527                                         PRAWPCIPERVM         pPciData));
    514528
    515529    /**
     
    524538    DECLR0CALLBACKMEMBER(void, pfnDeinitVm,(PRAWPCIFACTORY       pFactory,
    525539                                            PVM                  pVM,
    526                                             PRAWPCIVM            pPciData));
     540                                            PRAWPCIPERVM         pPciData));
    527541} RAWPCIFACTORY;
    528542
  • trunk/include/VBox/vmm/gvm.h

    r35361 r36448  
    102102        uint8_t             padding[256];
    103103    } gmm;
     104   
     105    /** The RAWPCIVM per vm data. */
     106    union
     107    {
     108#ifdef ___VBox_rawpci_h
     109        struct RAWPCIPERVM s;
     110#endif
     111        uint8_t     padding[64];
     112    } rawpci;
     113
    104114
    105115    /** GVMCPU array for the configured number of virtual CPUs. */
  • trunk/include/VBox/vmm/vm.h

    r36329 r36448  
    10131013    } cfgm;
    10141014
    1015     /** RAWPCIVM part. */
    1016     union
    1017     {
    1018 #ifdef ___VBox_rawpci_h
    1019         struct RAWPCIVM s;
    1020 #endif
    1021         uint8_t     padding[64];         /* multiple of 8 */
    1022     } rawpci;
    10231015
    10241016    /** Padding for aligning the cpu array on a page boundary. */
    1025     uint8_t         abAlignment2[1438];
     1017    uint8_t         abAlignment2[1502];
    10261018
    10271019    /* ---- end small stuff ---- */
  • trunk/src/VBox/HostDrivers/VBoxPci/VBoxPci.c

    r36436 r36448  
    409409                              uint32_t           u32HostAddress,
    410410                              uint32_t           fFlags,
    411                               PRAWPCIVM          pVmCtx,
    412                               PRAWPCIDEVPORT     *ppDevPort)
     411                              PRAWPCIPERVM       pVmCtx,
     412                              PRAWPCIDEVPORT     *ppDevPort,
     413                              uint32_t           *pfDevFlags)
    413414{
    414415    int             rc;
     
    476477                                                        uint32_t             u32HostAddress,
    477478                                                        uint32_t             fFlags,
    478                                                         PRAWPCIVM            pVmCtx,
    479                                                         PRAWPCIDEVPORT       *ppDevPort)
     479                                                        PRAWPCIPERVM         pVmCtx,
     480                                                        PRAWPCIDEVPORT       *ppDevPort,
     481                                                        uint32_t             *pfDevFlags)
    480482{
    481483    PVBOXRAWPCIGLOBALS pGlobals = (PVBOXRAWPCIGLOBALS)((uint8_t *)pFactory - RT_OFFSETOF(VBOXRAWPCIGLOBALS, RawPciFactory));
     
    496498    }
    497499
    498     rc = vboxPciNewInstance(pGlobals, u32HostAddress, fFlags, pVmCtx, ppDevPort);
     500    rc = vboxPciNewInstance(pGlobals, u32HostAddress, fFlags, pVmCtx, ppDevPort, pfDevFlags);
    499501
    500502unlock:
     
    521523static DECLCALLBACK(int)  vboxPciFactoryInitVm(PRAWPCIFACTORY       pFactory,
    522524                                               PVM                  pVM,
    523                                                PRAWPCIVM            pVmData)
     525                                               PRAWPCIPERVM         pVmData)
    524526{
    525527    PVBOXRAWPCIDRVVM pThis = (PVBOXRAWPCIDRVVM)RTMemAllocZ(sizeof(VBOXRAWPCIDRVVM));
     
    533535    {
    534536        rc = vboxPciOsInitVm(pThis, pVM, pVmData);
    535 #ifdef VBOX_WITH_IOMMU
    536         /* If IOMMU notification routine in pVmData->pfnContigMemInfo
    537            is not set - we have no IOMMU hardware. */
    538 #endif
    539537
    540538        if (RT_SUCCESS(rc))
    541539        {
     540#ifdef VBOX_WITH_IOMMU
     541            /* If IOMMU notification routine in pVmData->pfnContigMemInfo
     542               is set - we have functional IOMMU hardware. */
     543            if (pVmData->pfnContigMemInfo)
     544                pVmData->fVmCaps |= PCIRAW_VMFLAGS_HAS_IOMMU;
     545#endif
    542546            pVmData->pDriverData = pThis;
    543547            return VINF_SUCCESS;
     
    557561static DECLCALLBACK(void)  vboxPciFactoryDeinitVm(PRAWPCIFACTORY       pFactory,
    558562                                                  PVM                  pVM,
    559                                                   PRAWPCIVM            pPciData)
     563                                                  PRAWPCIPERVM         pPciData)
    560564{
    561565    if (pPciData->pDriverData)
  • trunk/src/VBox/HostDrivers/VBoxPci/VBoxPciInternal.h

    r36422 r36448  
    8686    void              *pIrqContext;
    8787
    88     PRAWPCIVM         pVmCtx;
     88    PRAWPCIPERVM       pVmCtx;
    8989} VBOXRAWPCIINS;
    9090
     
    139139DECLHIDDEN(void) vboxPciShutdown(PVBOXRAWPCIGLOBALS pGlobals);
    140140
    141 DECLHIDDEN(int)  vboxPciOsInitVm(PVBOXRAWPCIDRVVM pThis,   PVM pVM, PRAWPCIVM pVmData);
     141DECLHIDDEN(int)  vboxPciOsInitVm(PVBOXRAWPCIDRVVM pThis,   PVM pVM, PRAWPCIPERVM pVmData);
    142142DECLHIDDEN(void) vboxPciOsDeinitVm(PVBOXRAWPCIDRVVM pThis, PVM pVM);
    143143
  • trunk/src/VBox/VMM/VMMR0/PGMR0.cpp

    r36441 r36448  
    2020*******************************************************************************/
    2121#define LOG_GROUP LOG_GROUP_PGM
     22#include <VBox/rawpci.h>
    2223#include <VBox/vmm/pgm.h>
    2324#include <VBox/vmm/gmm.h>
     25#include <VBox/vmm/gvm.h>
    2426#include "PGMInternal.h"
    2527#include <VBox/vmm/vm.h>
     
    194196   manager.  It shall use the global VM handle, not the user VM handle to
    195197   store the per-VM info (domain) since that is all ring-0 stuff, thus
    196    passing pGVM here.  I've tentitively prefixed the functions 'GPicRawR0',
     198   passing pGVM here.  I've tentitively prefixed the functions 'GPciRawR0',
    197199   we can discuss the PciRaw code re-organtization when I'm back from
    198200   vacation.
     
    235237    AssertReturn(!(GCPhys & PAGE_OFFSET_MASK), VERR_INTERNAL_ERROR_3);
    236238    AssertReturn(!(HCPhys & PAGE_OFFSET_MASK), VERR_INTERNAL_ERROR_3);
     239
     240    if (pGVM->rawpci.s.pfnContigMemInfo)
     241        /** @todo: what do we do on failure? */
     242        pGVM->rawpci.s.pfnContigMemInfo(&pGVM->rawpci.s, HCPhys, GCPhys, PAGE_SIZE, PCIRAW_MEMINFO_MAP);
     243
    237244    return VINF_SUCCESS;
    238245}
     
    254261{
    255262    AssertReturn(!(GCPhys & PAGE_OFFSET_MASK), VERR_INTERNAL_ERROR_3);
     263
     264    if (pGVM->rawpci.s.pfnContigMemInfo)
     265        /** @todo: what do we do on failure? */
     266        pGVM->rawpci.s.pfnContigMemInfo(&pGVM->rawpci.s, 0, GCPhys, PAGE_SIZE, PCIRAW_MEMINFO_UNMAP);
     267
    256268    return VINF_SUCCESS;
    257269}
Note: See TracChangeset for help on using the changeset viewer.

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