VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxPci/VBoxPciInternal.h@ 36400

Last change on this file since 36400 was 36400, checked in by vboxsync, 14 years ago

PCI: work on IOMMU notifications

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
1/* $Id: VBoxPciInternal.h 36400 2011-03-24 13:14:26Z vboxsync $ */
2/** @file
3 * VBoxPci - PCI driver (Host), Internal Header.
4 */
5
6/*
7 * Copyright (C) 2011 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___VBoPciInternal_h___
19#define ___VBoxPciInternal_h___
20
21#include <VBox/sup.h>
22#include <VBox/rawpci.h>
23#include <iprt/semaphore.h>
24#include <iprt/assert.h>
25
26#ifdef RT_OS_LINUX
27
28#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
29# ifdef DEBUG_nike
30# define VBOX_WITH_IOMMU
31# endif
32#endif
33
34#ifdef VBOX_WITH_IOMMU
35#include <linux/iommu.h>
36#endif
37
38#endif
39
40RT_C_DECLS_BEGIN
41
42/* Forward declaration. */
43typedef struct VBOXRAWPCIGLOBALS *PVBOXRAWPCIGLOBALS;
44typedef struct VBOXRAWPCIDRVVM *PVBOXRAWPCIDRVVM;
45typedef struct VBOXRAWPCIINS *PVBOXRAWPCIINS;
46
47/**
48 * The per-instance data of the VBox raw PCI interface.
49 *
50 * This is data associated with a host PCI card attached to the VM.
51 *
52 */
53typedef struct VBOXRAWPCIINS
54{
55 /** Pointer to the globals. */
56 PVBOXRAWPCIGLOBALS pGlobals;
57
58 /** Mutex protecting device access. */
59 RTSEMFASTMUTEX hFastMtx;
60 /** The spinlock protecting the state variables and device access. */
61 RTSPINLOCK hSpinlock;
62 /** Pointer to the next device in the list. */
63 PVBOXRAWPCIINS pNext;
64 /** Reference count. */
65 uint32_t volatile cRefs;
66
67 /* Host PCI address of this device. */
68 uint32_t HostPciAddress;
69
70#ifdef RT_OS_LINUX
71 struct pci_dev * pPciDev;
72#endif
73 bool fMsiUsed;
74 bool fMsixUsed;
75 bool fIommuUsed;
76 bool fPad0;
77
78 /** Temporary: host IRQ we were given. Assumes single IRQ devices. */
79 int32_t iHostIrq;
80
81 /** Port, given to the outside world. */
82 RAWPCIDEVPORT DevPort;
83
84 uint32_t cHandlersCount;
85 PFNRAWPCIISR pfnIrqHandler;
86 void *pIrqContext;
87
88 PRAWPCIVM pVmCtx;
89} VBOXRAWPCIINS;
90
91/**
92 * Per-VM data of the VBox PCI driver. Pointed to by pVM->rawpci.s.pOsData.
93 *
94 */
95typedef struct VBOXRAWPCIDRVVM
96{
97 /** Mutex protecting state changes. */
98 RTSEMFASTMUTEX hFastMtx;
99
100#ifdef RT_OS_LINUX
101# ifdef VBOX_WITH_IOMMU
102 struct iommu_domain* pIommuDomain;
103# endif
104#endif
105 int32_t fFlags;
106} VBOXRAWPCIDRVVM;
107
108/**
109 * The global data of the VBox PCI driver.
110 *
111 * This contains the bit required for communicating with support driver, VBoxDrv
112 * (start out as SupDrv).
113 */
114typedef struct VBOXRAWPCIGLOBALS
115{
116 /** Mutex protecting the list of instances and state changes. */
117 RTSEMFASTMUTEX hFastMtx;
118
119 /** Pointer to a list of instance data. */
120 PVBOXRAWPCIINS pInstanceHead;
121
122 /** The raw PCI interface factory. */
123 RAWPCIFACTORY RawPciFactory;
124 /** The SUPDRV component factory registration. */
125 SUPDRVFACTORY SupDrvFactory;
126 /** The number of current factory references. */
127 int32_t volatile cFactoryRefs;
128 /** Whether the IDC connection is open or not.
129 * This is only for cleaning up correctly after the separate IDC init on Windows. */
130 bool fIDCOpen;
131 /** The SUPDRV IDC handle (opaque struct). */
132 SUPDRVIDCHANDLE SupDrvIDC;
133#ifdef RT_OS_LINUX
134 struct module * pciStubModule;
135#endif
136} VBOXRAWPCIGLOBALS;
137
138DECLHIDDEN(int) vboxPciInit(PVBOXRAWPCIGLOBALS pGlobals);
139DECLHIDDEN(void) vboxPciShutdown(PVBOXRAWPCIGLOBALS pGlobals);
140
141DECLHIDDEN(int) vboxPciOsInitVm(PVBOXRAWPCIDRVVM pThis, PVM pVM);
142DECLHIDDEN(void) vboxPciOsDeinitVm(PVBOXRAWPCIDRVVM pThis, PVM pVM);
143
144DECLHIDDEN(int) vboxPciOsDevInit (PVBOXRAWPCIINS pIns, uint32_t fFlags);
145DECLHIDDEN(int) vboxPciOsDevDeinit(PVBOXRAWPCIINS pIns, uint32_t fFlags);
146DECLHIDDEN(int) vboxPciOsDevDestroy(PVBOXRAWPCIINS pIns);
147
148DECLHIDDEN(int) vboxPciOsDevGetRegionInfo(PVBOXRAWPCIINS pIns,
149 int32_t iRegion,
150 RTHCPHYS *pRegionStart,
151 uint64_t *pu64RegionSize,
152 bool *pfPresent,
153 uint32_t *pfFlags);
154DECLHIDDEN(int) vboxPciOsDevMapRegion(PVBOXRAWPCIINS pIns,
155 int32_t iRegion,
156 RTHCPHYS pRegionStart,
157 uint64_t u64RegionSize,
158 uint32_t fFlags,
159 RTR0PTR *pRegionBase);
160DECLHIDDEN(int) vboxPciOsDevUnmapRegion(PVBOXRAWPCIINS pIns,
161 int32_t iRegion,
162 RTHCPHYS RegionStart,
163 uint64_t u64RegionSize,
164 RTR0PTR RegionBase);
165
166DECLHIDDEN(int) vboxPciOsDevPciCfgWrite(PVBOXRAWPCIINS pIns, uint32_t Register, PCIRAWMEMLOC *pValue);
167DECLHIDDEN(int) vboxPciOsDevPciCfgRead (PVBOXRAWPCIINS pIns, uint32_t Register, PCIRAWMEMLOC *pValue);
168
169DECLHIDDEN(int) vboxPciOsDevRegisterIrqHandler (PVBOXRAWPCIINS pIns, PFNRAWPCIISR pfnHandler, void* pIrqContext, int32_t *piHostIrq);
170DECLHIDDEN(int) vboxPciOsDevUnregisterIrqHandler(PVBOXRAWPCIINS pIns, int32_t iHostIrq);
171
172DECLHIDDEN(int) vboxPciOsDevPowerStateChange(PVBOXRAWPCIINS pIns, PCIRAWPOWERSTATE aState);
173
174#define VBOX_DRV_VMDATA(pIns) ((PVBOXRAWPCIDRVVM)(pIns->pVmCtx ? pIns->pVmCtx->pDriverData : NULL))
175
176RT_C_DECLS_END
177
178#endif
Note: See TracBrowser for help on using the repository browser.

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