VirtualBox

Changeset 81375 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Oct 19, 2019 1:57:55 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134088
Message:

IOM,PDM,PCI: Making new MMIO code work with PCI. bugref:9218

Location:
trunk/include/VBox/vmm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/iom.h

    r81333 r81375  
    462462VMMDECL(int)            IOMMMIOResetRegion(PVMCC pVM, RTGCPHYS GCPhys);
    463463
    464 VMM_INT_DECL(VBOXSTRICTRC)  IOMMmioPhysHandler(PVMCC pVM, PVMCPUCC pVCpu, uint32_t uErrorCode, RTGCPHYS GCPhysFault);
     464VMM_INT_DECL(VBOXSTRICTRC)  IOMMmioPhysHandlerNew(PVMCC pVM, PVMCPUCC pVCpu, uint32_t uErrorCode, RTGCPHYS GCPhysFault);
    465465VMM_INT_DECL(int)           IOMMmioMapMmio2Page(PVMCC pVM, PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS offRegion,
    466466                                                uint64_t hMmio2, RTGCPHYS offMmio2, uint64_t fPageFlags);
     
    493493VMMR3_INT_DECL(int)  IOMR3IoPortMap(PVM pVM, PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts, RTIOPORT Port);
    494494VMMR3_INT_DECL(int)  IOMR3IoPortUnmap(PVM pVM, PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts);
     495VMMR3_INT_DECL(int)  IOMR3IoPortValidateHandle(PVM pVM, PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts);
    495496
    496497VMMR3_INT_DECL(int)  IOMR3MmioCreate(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS cbRegion, uint32_t fFlags, PPDMPCIDEV pPciDev,
     
    500501VMMR3_INT_DECL(int)  IOMR3MmioUnmap(PVM pVM, PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion);
    501502VMMR3_INT_DECL(int)  IOMR3MmioReduce(PVM pVM, PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS cbRegion);
     503VMMR3_INT_DECL(int)  IOMR3MmioValidateHandle(PVM pVM, PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion);
    502504
    503505/** @name obsolete
  • trunk/include/VBox/vmm/pdmdev.h

    r81333 r81375  
    857857     * @param   iRegion         The region number.
    858858     * @param   cbRegion        Size of the region.
    859      * @param   enmType         PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
    860      * @param   pfnCallback     Callback for doing the mapping.
     859     * @param   enmType         PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or
     860     *                          PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally with
     861     *                          PCI_ADDRESS_SPACE_BAR64 or'ed in.
     862     * @param   fFlags          PDMPCIDEV_IORGN_F_XXX.
     863     * @param   hHandle         An I/O port, MMIO or MMIO2 handle according to
     864     *                          @a fFlags, UINT64_MAX if no handle is passed
     865     *                          (old style).
     866     * @param   pfnCallback     Callback for doing the mapping. Optional if a handle
     867     *                          is given.
    861868     * @remarks Caller enters the PDM critical section.
    862869     */
    863     DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iRegion, RTGCPHYS cbRegion,
    864                                                      PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
     870    DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
     871                                                     RTGCPHYS cbRegion, PCIADDRESSSPACE enmType, uint32_t fFlags,
     872                                                     uint64_t hHandle, PFNPCIIOREGIONMAP pfnCallback));
    865873
    866874    /**
     
    930938typedef PDMPCIBUSREGR3 *PPDMPCIBUSREGR3;
    931939/** Current PDMPCIBUSREGR3 version number. */
    932 #define PDM_PCIBUSREGR3_VERSION                 PDM_VERSION_MAKE(0xff86, 1, 0)
     940#define PDM_PCIBUSREGR3_VERSION                 PDM_VERSION_MAKE(0xff86, 2, 0)
    933941
    934942/**
     
    22232231
    22242232
     2233/** @name Flags for PCI I/O region registration
     2234 * @{ */
     2235/** No handle is passed. */
     2236#define PDMPCIDEV_IORGN_F_NO_HANDLE         UINT32_C(0x00000000)
     2237/** An I/O port handle is passed. */
     2238#define PDMPCIDEV_IORGN_F_IOPORT_HANDLE     UINT32_C(0x00000001)
     2239/** An MMIO range handle is passed. */
     2240#define PDMPCIDEV_IORGN_F_MMIO_HANDLE       UINT32_C(0x00000002)
     2241/** An MMIO2 handle is passed. */
     2242#define PDMPCIDEV_IORGN_F_MMIO2_HANDLE      UINT32_C(0x00000003)
     2243/** Handle type mask.  */
     2244#define PDMPCIDEV_IORGN_F_HANDLE_MASK       UINT32_C(0x00000003)
     2245/** Mask of valid flags.   */
     2246#define PDMPCIDEV_IORGN_F_VALID_MASK        UINT32_C(0x00000003)
     2247/** @} */
     2248
     2249
    22252250#ifdef IN_RING3
    22262251
    22272252/** @name Special values for PDMDEVHLPR3::pfnPCIRegister parameters.
    2228  * @{  */
     2253 * @{ */
    22292254/** Same device number (and bus) as the previous PCI device registered with the PDM device.
    22302255 * This is handy when registering multiple PCI device functions and the device
     
    22442269/** Valid flag mask. */
    22452270# define PDMPCIDEVREG_F_VALID_MASK          UINT32_C(0x00000003)
    2246 /** @}   */
     2271/** @} */
    22472272
    22482273/** Current PDMDEVHLPR3 version number. */
    2249 #define PDM_DEVHLPR3_VERSION                    PDM_VERSION_MAKE_PP(0xffe7, 24, 0)
     2274#define PDM_DEVHLPR3_VERSION                    PDM_VERSION_MAKE_PP(0xffe7, 25, 0)
    22502275
    22512276/**
     
    34463471     * @param   cbRegion            Size of the region.
    34473472     * @param   enmType             PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
    3448      * @param   pfnCallback         Callback for doing the mapping.
    3449      * @remarks The callback will be invoked holding the PDM lock. The device lock
    3450      *          is NOT take because that is very likely be a lock order violation.
    3451      */
    3452     DECLR3CALLBACKMEMBER(int, pfnPCIIORegionRegister,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS cbRegion,
    3453                                                       PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
     3473     * @param   fFlags              PDMPCIDEV_IORGN_F_XXX.
     3474     * @param   hHandle             An I/O port, MMIO or MMIO2 handle according to
     3475     *                              @a fFlags, UINT64_MAX if no handle is passed
     3476     *                              (old style).
     3477     * @param   pfnCallback         Callback for doing the mapping, optional when a
     3478     *                              handle is specified.  The callback will be
     3479     *                              invoked holding only the PDM lock.  The device
     3480     *                              lock will _not_ be taken (due to lock order).
     3481     */
     3482    DECLR3CALLBACKMEMBER(int, pfnPCIIORegionRegister,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
     3483                                                      RTGCPHYS cbRegion, PCIADDRESSSPACE enmType, uint32_t fFlags,
     3484                                                      uint64_t hHandle, PFNPCIIOREGIONMAP pfnCallback));
    34543485
    34553486    /**
     
    51185149typedef struct PDMDEVINSR3
    51195150{
    5120     /** Structure version. PDM_DEVINS_VERSION defines the current version. */
     5151    /** Structure version. PDM_DEVINSR3_VERSION defines the current version. */
    51215152    uint32_t                        u32Version;
    51225153    /** Device instance number. */
     
    52065237
    52075238/** Current PDMDEVINSR3 version number. */
    5208 #define PDM_DEVINSR3_VERSION        PDM_VERSION_MAKE(0xff82, 3, 0)
     5239#define PDM_DEVINSR3_VERSION        PDM_VERSION_MAKE(0xff82, 4, 0)
    52095240
    52105241/** Converts a pointer to the PDMDEVINSR3::IBase to a pointer to PDMDEVINS. */
     
    52845315
    52855316/** Current PDMDEVINSR0 version number. */
    5286 #define PDM_DEVINSR0_VERSION        PDM_VERSION_MAKE(0xff83, 3, 0)
     5317#define PDM_DEVINSR0_VERSION        PDM_VERSION_MAKE(0xff83, 4, 0)
    52875318
    52885319
     
    53445375
    53455376/** Current PDMDEVINSR0 version number. */
    5346 #define PDM_DEVINSRC_VERSION        PDM_VERSION_MAKE(0xff84, 3, 0)
     5377#define PDM_DEVINSRC_VERSION        PDM_VERSION_MAKE(0xff84, 4, 0)
    53475378
    53485379
     
    59305961{
    59315962    return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, NULL /*pszBefore*/,
    5932                                               NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/,  NULL /*pfnLiveDone*/,
    5933                                               NULL /*pfnSavePrep*/, pfnSaveExec,           NULL /*pfnSaveDone*/,
    5934                                               NULL /*pfnLoadPrep*/, pfnLoadExec,           NULL /*pfnLoadDone*/);
     5963                                           NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/,  NULL /*pfnLiveDone*/,
     5964                                           NULL /*pfnSavePrep*/, pfnSaveExec,           NULL /*pfnSaveDone*/,
     5965                                           NULL /*pfnLoadPrep*/, pfnLoadExec,           NULL /*pfnLoadDone*/);
    59355966}
    59365967
     
    59515982{
    59525983    return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, NULL /*pszBefore*/,
    5953                                               NULL /*pfnLivePrep*/, pfnLiveExec,  NULL /*pfnLiveDone*/,
    5954                                               NULL /*pfnSavePrep*/, pfnSaveExec,  NULL /*pfnSaveDone*/,
    5955                                               NULL /*pfnLoadPrep*/, pfnLoadExec,  NULL /*pfnLoadDone*/);
     5984                                           NULL /*pfnLivePrep*/, pfnLiveExec,  NULL /*pfnLiveDone*/,
     5985                                           NULL /*pfnSavePrep*/, pfnSaveExec,  NULL /*pfnSaveDone*/,
     5986                                           NULL /*pfnLoadPrep*/, pfnLoadExec,  NULL /*pfnLoadDone*/);
    59565987}
    59575988
     
    64356466
    64366467/**
     6468 * Initialize MSI emulation support for the first PCI device.
     6469 *
     6470 * @returns VBox status code.
     6471 * @param   pDevIns             The device instance.
     6472 * @param   pMsiReg             MSI emulation registration structure.
     6473 */
     6474DECLINLINE(int) PDMDevHlpPCIRegisterMsi(PPDMDEVINS pDevIns, PPDMMSIREG pMsiReg)
     6475{
     6476    return pDevIns->pHlpR3->pfnPCIRegisterMsi(pDevIns, NULL, pMsiReg);
     6477}
     6478
     6479/**
     6480 * @copydoc PDMDEVHLPR3::pfnPCIRegisterMsi
     6481 */
     6482DECLINLINE(int) PDMDevHlpPCIRegisterMsiEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg)
     6483{
     6484    return pDevIns->pHlpR3->pfnPCIRegisterMsi(pDevIns, pPciDev, pMsiReg);
     6485}
     6486
     6487/**
    64376488 * Registers a I/O region (memory mapped or I/O ports) for the default PCI
    64386489 * device.
     
    64476498 *          is NOT take because that is very likely be a lock order violation.
    64486499 */
    6449 DECLINLINE(int) PDMDevHlpPCIIORegionRegister(PPDMDEVINS pDevIns, int iRegion, RTGCPHYS cbRegion,
     6500DECLINLINE(int) PDMDevHlpPCIIORegionRegister(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cbRegion,
    64506501                                             PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)
    64516502{
    6452     return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, NULL, iRegion, cbRegion, enmType, pfnCallback);
     6503    return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, NULL, iRegion, cbRegion, enmType,
     6504                                                   PDMPCIDEV_IORGN_F_NO_HANDLE, UINT64_MAX, pfnCallback);
    64536505}
    64546506
     
    64566508 * @copydoc PDMDEVHLPR3::pfnPCIIORegionRegister
    64576509 */
    6458 DECLINLINE(int) PDMDevHlpPCIIORegionRegisterEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iRegion, RTGCPHYS cbRegion,
     6510DECLINLINE(int) PDMDevHlpPCIIORegionRegisterEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS cbRegion,
    64596511                                               PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)
    64606512{
    6461     return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, pPciDev, iRegion, cbRegion, enmType, pfnCallback);
    6462 }
    6463 
    6464 /**
    6465  * Initialize MSI emulation support for the first PCI device.
     6513    return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, pPciDev, iRegion, cbRegion, enmType,
     6514                                                   PDMPCIDEV_IORGN_F_NO_HANDLE, UINT64_MAX, pfnCallback);
     6515}
     6516
     6517/**
     6518 * Registers a I/O port region for the default PCI device.
    64666519 *
    64676520 * @returns VBox status code.
    6468  * @param   pDevIns             The device instance.
    6469  * @param   pMsiReg             MSI emulation registration structure.
    6470  */
    6471 DECLINLINE(int) PDMDevHlpPCIRegisterMsi(PPDMDEVINS pDevIns, PPDMMSIREG pMsiReg)
    6472 {
    6473     return pDevIns->pHlpR3->pfnPCIRegisterMsi(pDevIns, NULL, pMsiReg);
    6474 }
    6475 
    6476 /**
    6477  * @copydoc PDMDEVHLPR3::pfnPCIRegisterMsi
    6478  */
    6479 DECLINLINE(int) PDMDevHlpPCIRegisterMsiEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg)
    6480 {
    6481     return pDevIns->pHlpR3->pfnPCIRegisterMsi(pDevIns, pPciDev, pMsiReg);
    6482 }
     6521 * @param   pDevIns         The device instance.
     6522 * @param   iRegion         The region number.
     6523 * @param   cbRegion        Size of the region.
     6524 * @param   hIoPorts        Handle to the I/O port region.
     6525 * @param   pfnCallback     Callback for doing the mapping, optional.  The
     6526 *                          callback will be invoked holding only the PDM lock.
     6527 *                          The device lock will _not_ be taken (due to lock
     6528 *                          order).
     6529 */
     6530DECLINLINE(int) PDMDevHlpPCIIORegionRegisterIo(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cbRegion,
     6531                                               IOMIOPORTHANDLE hIoPorts, PFNPCIIOREGIONMAP pfnCallback)
     6532{
     6533    return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, NULL, iRegion, cbRegion, PCI_ADDRESS_SPACE_IO,
     6534                                                   PDMPCIDEV_IORGN_F_IOPORT_HANDLE, hIoPorts, pfnCallback);
     6535}
     6536
     6537/**
     6538 * Registers an MMIO port region for the default PCI device.
     6539 *
     6540 * @returns VBox status code.
     6541 * @param   pDevIns         The device instance.
     6542 * @param   iRegion         The region number.
     6543 * @param   cbRegion        Size of the region.
     6544 * @param   enmType         PCI_ADDRESS_SPACE_MEM or
     6545 *                          PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally or-ing in
     6546 *                          PCI_ADDRESS_SPACE_BAR64 or PCI_ADDRESS_SPACE_BAR32.
     6547 * @param   hMmioRegion     Handle to the MMIO region.
     6548 * @param   pfnCallback     Callback for doing the mapping, optional.  The
     6549 *                          callback will be invoked holding only the PDM lock.
     6550 *                          The device lock will _not_ be taken (due to lock
     6551 *                          order).
     6552 */
     6553DECLINLINE(int) PDMDevHlpPCIIORegionRegisterMmio(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cbRegion, PCIADDRESSSPACE enmType,
     6554                                                 IOMMMIOHANDLE hMmioRegion, PFNPCIIOREGIONMAP pfnCallback)
     6555{
     6556    return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, NULL, iRegion, cbRegion, enmType,
     6557                                                   PDMPCIDEV_IORGN_F_MMIO_HANDLE, hMmioRegion, pfnCallback);
     6558}
     6559
    64836560
    64846561/**
  • trunk/include/VBox/vmm/pdmpcidev.h

    r81031 r81375  
    9191 * Callback function for mapping an PCI I/O region.
    9292 *
     93 * This is called when a PCI I/O region is mapped, and for new-style devices
     94 * also when unmapped (address set to NIL_RTGCPHYS).  For new-style devices,
     95 * this callback is optional as the PCI bus calls IOM to map and unmap the
     96 * regions.
     97 *
     98 * Old style devices have to call IOM to map the region themselves, while
     99 * unmapping is done by the PCI bus like with the new style devices.
     100 *
    93101 * @returns VBox status code.
    94102 * @param   pDevIns         Pointer to the device instance the PCI device
     
    96104 * @param   pPciDev         Pointer to the PCI device.
    97105 * @param   iRegion         The region number.
    98  * @param   GCPhysAddress   Physical address of the region. If enmType is PCI_ADDRESS_SPACE_IO, this
    99  *                          is an I/O port, otherwise it's a physical address.
    100  *
    101  *                          NIL_RTGCPHYS indicates that a MMIO2 mapping is about to be unmapped and
    102  *                          that the device deregister access handlers for it and update its internal
    103  *                          state to reflect this.
     106 * @param   GCPhysAddress   Physical address of the region.  If @a enmType is
     107 *                          PCI_ADDRESS_SPACE_IO, this is an I/O port, otherwise
     108 *                          it's a physical address.
     109 *
     110 *                          NIL_RTGCPHYS indicates that a mapping is about to be
     111 *                          unmapped and that the device deregister access
     112 *                          handlers for it and update its internal state to
     113 *                          reflect this.
    104114 *
    105115 * @param   cb              Size of the region in bytes.
     
    213223                                                         PFNPCIIOREGIONSWAP pfnSwapRegion));
    214224
     225    /** Reserved for future stuff. */
     226    uint64_t au64Reserved[4 + (R3_ARCH_BITS == 32 ? 1 : 0)];
     227
    215228    /** Internal data. */
    216229    union
     
    219232        PDMPCIDEVINT        s;
    220233#endif
    221         uint8_t             padding[HC_ARCH_BITS == 32 ? 0x60 + 8 : 0x140];
     234        uint8_t             padding[0x180];
    222235    } Int;
    223236
  • trunk/include/VBox/vmm/pdmpcidevint.h

    r81035 r81375  
    4949typedef struct PCIIOREGION
    5050{
    51     /** Current PCI mapping address, 0xffffffff means not mapped. */
     51    /** Current PCI mapping address, INVALID_PCI_ADDRESS (0xffffffff) means not mapped. */
    5252    uint64_t                        addr;
     53    /** The region size.  Power of 2. */
    5354    uint64_t                        size;
    54     uint8_t                         type; /* PCIADDRESSSPACE */
    55     uint8_t                         padding[HC_ARCH_BITS == 32 ? 3 : 7];
    56     /** Callback called when the region is mapped. */
    57     R3PTRTYPE(PFNPCIIOREGIONMAP)    map_func;
    58 } PCIIOREGION, PCIIORegion;
    59 /** Pointer to PCI I/O region. */
     55    /** Handle or UINT64_MAX (see PDMPCIDEV_IORGN_F_HANDLE_MASK in fFlags). */
     56    uint64_t                        hHandle;
     57    /** PDMPCIDEV_IORGN_F_XXXX. */
     58    uint32_t                        fFlags;
     59    /** PCIADDRESSSPACE */
     60    uint8_t                         type;
     61    uint8_t                         abPadding0[3];
     62    /** Callback called when the region is mapped or unmapped (new style devs). */
     63    R3PTRTYPE(PFNPCIIOREGIONMAP)    pfnMap;
     64#if R3_ARCH_BITS == 32
     65    uint32_t                        u32Padding2;
     66#endif
     67} PCIIOREGION;
     68AssertCompileSize(PCIIOREGION, 5*8);
     69/** Pointer to a PCI I/O region. */
    6070typedef PCIIOREGION *PPCIIOREGION;
     71/** Pointer to a const PCI I/O region. */
     72typedef PCIIOREGION const *PCPCIIOREGION;
    6173
    6274/**
     
    200212} PDMPCIDEVINT;
    201213AssertCompileMemberAlignment(PDMPCIDEVINT, aIORegions, 8);
    202 AssertCompileSize(PDMPCIDEVINT, HC_ARCH_BITS == 32 ? 0x60 : 0x140);
     214AssertCompileSize(PDMPCIDEVINT, HC_ARCH_BITS == 32 ? 0x98 : 0x178);
    203215
    204216/** Indicate that PDMPCIDEV::Int.s can be declared. */
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