VirtualBox

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

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

PCI: try to reattach previous PCI driver on VM exit

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/* $Id: VBoxPciInternal.h 36719 2011-04-18 15:56:31Z 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, 35)
29# define VBOX_WITH_IOMMU
30#endif
31
32#ifdef VBOX_WITH_IOMMU
33#include <linux/errno.h>
34#include <linux/iommu.h>
35#endif
36
37#endif
38
39RT_C_DECLS_BEGIN
40
41/* Forward declaration. */
42typedef struct VBOXRAWPCIGLOBALS *PVBOXRAWPCIGLOBALS;
43typedef struct VBOXRAWPCIDRVVM *PVBOXRAWPCIDRVVM;
44typedef struct VBOXRAWPCIINS *PVBOXRAWPCIINS;
45
46typedef struct VBOXRAWPCIISRDESC
47{
48 /** Handler function. */
49 PFNRAWPCIISR pfnIrqHandler;
50 /** Handler context. */
51 void *pIrqContext;
52 /** Host IRQ. */
53 int32_t iHostIrq;
54} VBOXRAWPCIISRDESC;
55typedef struct VBOXRAWPCIISRDESC *PVBOXRAWPCIISRDESC;
56
57/**
58 * The per-instance data of the VBox raw PCI interface.
59 *
60 * This is data associated with a host PCI card attached to the VM.
61 *
62 */
63typedef struct VBOXRAWPCIINS
64{
65 /** Pointer to the globals. */
66 PVBOXRAWPCIGLOBALS pGlobals;
67
68 /** Mutex protecting device access. */
69 RTSEMFASTMUTEX hFastMtx;
70 /** The spinlock protecting the state variables and device access. */
71 RTSPINLOCK hSpinlock;
72 /** Pointer to the next device in the list. */
73 PVBOXRAWPCIINS pNext;
74 /** Reference count. */
75 uint32_t volatile cRefs;
76
77 /* Host PCI address of this device. */
78 uint32_t HostPciAddress;
79
80#ifdef RT_OS_LINUX
81 struct pci_dev * pPciDev;
82 char szPrevDriver[64];
83#endif
84 bool fMsiUsed;
85 bool fMsixUsed;
86 bool fIommuUsed;
87 bool fPad0;
88
89 /** Port, given to the outside world. */
90 RAWPCIDEVPORT DevPort;
91
92 /** IRQ handler. */
93 VBOXRAWPCIISRDESC IrqHandler;
94
95 /** Pointer to per-VM context in hypervisor data. */
96 PRAWPCIPERVM pVmCtx;
97} VBOXRAWPCIINS;
98
99/**
100 * Per-VM data of the VBox PCI driver. Pointed to by pGVM->rawpci.s.pDriverData.
101 *
102 */
103typedef struct VBOXRAWPCIDRVVM
104{
105 /** Mutex protecting state changes. */
106 RTSEMFASTMUTEX hFastMtx;
107
108#ifdef RT_OS_LINUX
109# ifdef VBOX_WITH_IOMMU
110 /* IOMMU domain. */
111 struct iommu_domain* pIommuDomain;
112# endif
113#endif
114 /* Back pointer to pGVM->rawpci.s. */
115 PRAWPCIPERVM pPerVmData;
116} VBOXRAWPCIDRVVM;
117
118/**
119 * The global data of the VBox PCI driver.
120 *
121 * This contains the bit required for communicating with support driver, VBoxDrv
122 * (start out as SupDrv).
123 */
124typedef struct VBOXRAWPCIGLOBALS
125{
126 /** Mutex protecting the list of instances and state changes. */
127 RTSEMFASTMUTEX hFastMtx;
128
129 /** Pointer to a list of instance data. */
130 PVBOXRAWPCIINS pInstanceHead;
131
132 /** The raw PCI interface factory. */
133 RAWPCIFACTORY RawPciFactory;
134 /** The SUPDRV component factory registration. */
135 SUPDRVFACTORY SupDrvFactory;
136 /** The number of current factory references. */
137 int32_t volatile cFactoryRefs;
138 /** Whether the IDC connection is open or not.
139 * This is only for cleaning up correctly after the separate IDC init on Windows. */
140 bool fIDCOpen;
141 /** The SUPDRV IDC handle (opaque struct). */
142 SUPDRVIDCHANDLE SupDrvIDC;
143#ifdef RT_OS_LINUX
144 struct module * pciStubModule;
145#endif
146} VBOXRAWPCIGLOBALS;
147
148DECLHIDDEN(int) vboxPciInit(PVBOXRAWPCIGLOBALS pGlobals);
149DECLHIDDEN(void) vboxPciShutdown(PVBOXRAWPCIGLOBALS pGlobals);
150
151DECLHIDDEN(int) vboxPciOsInitVm(PVBOXRAWPCIDRVVM pThis, PVM pVM, PRAWPCIPERVM pVmData);
152DECLHIDDEN(void) vboxPciOsDeinitVm(PVBOXRAWPCIDRVVM pThis, PVM pVM);
153
154DECLHIDDEN(int) vboxPciOsDevInit (PVBOXRAWPCIINS pIns, uint32_t fFlags);
155DECLHIDDEN(int) vboxPciOsDevDeinit(PVBOXRAWPCIINS pIns, uint32_t fFlags);
156DECLHIDDEN(int) vboxPciOsDevDestroy(PVBOXRAWPCIINS pIns);
157
158DECLHIDDEN(int) vboxPciOsDevGetRegionInfo(PVBOXRAWPCIINS pIns,
159 int32_t iRegion,
160 RTHCPHYS *pRegionStart,
161 uint64_t *pu64RegionSize,
162 bool *pfPresent,
163 uint32_t *pfFlags);
164DECLHIDDEN(int) vboxPciOsDevMapRegion(PVBOXRAWPCIINS pIns,
165 int32_t iRegion,
166 RTHCPHYS pRegionStart,
167 uint64_t u64RegionSize,
168 uint32_t fFlags,
169 RTR0PTR *pRegionBase);
170DECLHIDDEN(int) vboxPciOsDevUnmapRegion(PVBOXRAWPCIINS pIns,
171 int32_t iRegion,
172 RTHCPHYS RegionStart,
173 uint64_t u64RegionSize,
174 RTR0PTR RegionBase);
175
176DECLHIDDEN(int) vboxPciOsDevPciCfgWrite(PVBOXRAWPCIINS pIns, uint32_t Register, PCIRAWMEMLOC *pValue);
177DECLHIDDEN(int) vboxPciOsDevPciCfgRead (PVBOXRAWPCIINS pIns, uint32_t Register, PCIRAWMEMLOC *pValue);
178
179DECLHIDDEN(int) vboxPciOsDevRegisterIrqHandler (PVBOXRAWPCIINS pIns, PFNRAWPCIISR pfnHandler, void* pIrqContext, int32_t *piHostIrq);
180DECLHIDDEN(int) vboxPciOsDevUnregisterIrqHandler(PVBOXRAWPCIINS pIns, int32_t iHostIrq);
181
182DECLHIDDEN(int) vboxPciOsDevPowerStateChange(PVBOXRAWPCIINS pIns, PCIRAWPOWERSTATE aState);
183
184#define VBOX_DRV_VMDATA(pIns) ((PVBOXRAWPCIDRVVM)(pIns->pVmCtx ? pIns->pVmCtx->pDriverData : NULL))
185
186RT_C_DECLS_END
187
188#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