VirtualBox

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

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

PCI: guest power management

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1/* $Id: VBoxPciInternal.h 36340 2011-03-22 13:19:08Z 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* iommu_domain;
103# endif
104#endif
105} VBOXRAWPCIDRVVM;
106
107/**
108 * The global data of the VBox PCI driver.
109 *
110 * This contains the bit required for communicating with support driver, VBoxDrv
111 * (start out as SupDrv).
112 */
113typedef struct VBOXRAWPCIGLOBALS
114{
115 /** Mutex protecting the list of instances and state changes. */
116 RTSEMFASTMUTEX hFastMtx;
117
118 /** Pointer to a list of instance data. */
119 PVBOXRAWPCIINS pInstanceHead;
120
121 /** The raw PCI interface factory. */
122 RAWPCIFACTORY RawPciFactory;
123 /** The SUPDRV component factory registration. */
124 SUPDRVFACTORY SupDrvFactory;
125 /** The number of current factory references. */
126 int32_t volatile cFactoryRefs;
127 /** Whether the IDC connection is open or not.
128 * This is only for cleaning up correctly after the separate IDC init on Windows. */
129 bool fIDCOpen;
130 /** The SUPDRV IDC handle (opaque struct). */
131 SUPDRVIDCHANDLE SupDrvIDC;
132#ifdef RT_OS_LINUX
133 struct module * pciStubModule;
134#endif
135} VBOXRAWPCIGLOBALS;
136
137DECLHIDDEN(int) vboxPciInit(PVBOXRAWPCIGLOBALS pGlobals);
138DECLHIDDEN(void) vboxPciShutdown(PVBOXRAWPCIGLOBALS pGlobals);
139
140DECLHIDDEN(int) vboxPciOsInitVm(PVBOXRAWPCIDRVVM pThis, PVM pVM);
141DECLHIDDEN(void) vboxPciOsDeinitVm(PVBOXRAWPCIDRVVM pThis, PVM pVM);
142
143DECLHIDDEN(int) vboxPciOsDevInit (PVBOXRAWPCIINS pIns, uint32_t fFlags);
144DECLHIDDEN(int) vboxPciOsDevDeinit(PVBOXRAWPCIINS pIns, uint32_t fFlags);
145DECLHIDDEN(int) vboxPciOsDevDestroy(PVBOXRAWPCIINS pIns);
146
147DECLHIDDEN(int) vboxPciOsDevGetRegionInfo(PVBOXRAWPCIINS pIns,
148 int32_t iRegion,
149 RTHCPHYS *pRegionStart,
150 uint64_t *pu64RegionSize,
151 bool *pfPresent,
152 uint32_t *pfFlags);
153DECLHIDDEN(int) vboxPciOsDevMapRegion(PVBOXRAWPCIINS pIns,
154 int32_t iRegion,
155 RTHCPHYS pRegionStart,
156 uint64_t u64RegionSize,
157 uint32_t fFlags,
158 RTR0PTR *pRegionBase);
159DECLHIDDEN(int) vboxPciOsDevUnmapRegion(PVBOXRAWPCIINS pIns,
160 int32_t iRegion,
161 RTHCPHYS RegionStart,
162 uint64_t u64RegionSize,
163 RTR0PTR RegionBase);
164
165DECLHIDDEN(int) vboxPciOsDevPciCfgWrite(PVBOXRAWPCIINS pIns, uint32_t Register, PCIRAWMEMLOC *pValue);
166DECLHIDDEN(int) vboxPciOsDevPciCfgRead (PVBOXRAWPCIINS pIns, uint32_t Register, PCIRAWMEMLOC *pValue);
167
168DECLHIDDEN(int) vboxPciOsDevRegisterIrqHandler (PVBOXRAWPCIINS pIns, PFNRAWPCIISR pfnHandler, void* pIrqContext, int32_t *piHostIrq);
169DECLHIDDEN(int) vboxPciOsDevUnregisterIrqHandler(PVBOXRAWPCIINS pIns, int32_t iHostIrq);
170
171DECLHIDDEN(int) vboxPciOsDevPowerStateChange(PVBOXRAWPCIINS pIns, PCIRAWPOWERSTATE aState);
172
173#define VBOX_DRV_VMDATA(pIns) ((PVBOXRAWPCIDRVVM)(pIns->pVmCtx->pDriverData))
174
175RT_C_DECLS_END
176
177#endif
Note: See TracBrowser for help on using the repository browser.

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