1 | /* $Id: VBoxPciInternal.h 36253 2011-03-10 15:59:21Z 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 | #define VBOX_WITH_IOMMU
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #ifdef VBOX_WITH_IOMMU
|
---|
33 | #include <linux/iommu.h>
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | RT_C_DECLS_BEGIN
|
---|
39 |
|
---|
40 | /* Forward declaration. */
|
---|
41 | typedef struct VBOXRAWPCIGLOBALS *PVBOXRAWPCIGLOBALS;
|
---|
42 | typedef struct VBOXRAWPCIINS *PVBOXRAWPCIINS;
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * The per-instance data of the VBox raw PCI interface.
|
---|
46 | *
|
---|
47 | * This is data associated with a host PCI card which
|
---|
48 | * the filter driver has been or may be attached to. When possible it is
|
---|
49 | * attached dynamically, but this may not be possible on all OSes so we have
|
---|
50 | * to be flexible about things.
|
---|
51 | *
|
---|
52 | */
|
---|
53 | typedef struct VBOXRAWPCIINS
|
---|
54 | {
|
---|
55 | /** Pointer to the globals. */
|
---|
56 | PVBOXRAWPCIGLOBALS pGlobals;
|
---|
57 | /** The spinlock protecting the state variables and host interface handle. */
|
---|
58 | RTSPINLOCK hSpinlock;
|
---|
59 | /** Pointer to the next device in the list. */
|
---|
60 | PVBOXRAWPCIINS pNext;
|
---|
61 | /** Reference count. */
|
---|
62 | uint32_t volatile cRefs;
|
---|
63 |
|
---|
64 | /* Host PCI address of this device. */
|
---|
65 | uint32_t HostPciAddress;
|
---|
66 |
|
---|
67 | #ifdef RT_OS_LINUX
|
---|
68 | struct pci_dev * pPciDev;
|
---|
69 | #endif
|
---|
70 |
|
---|
71 | /** The session this interface is associated with. */
|
---|
72 | PSUPDRVSESSION pSession;
|
---|
73 | /** The SUPR0 object id. */
|
---|
74 | void *pvObj;
|
---|
75 |
|
---|
76 | /** Port, given to the outside world. */
|
---|
77 | RAWPCIDEVPORT DevPort;
|
---|
78 |
|
---|
79 | PFNRAWPCIISR pfnIrqHandler;
|
---|
80 | void *pIrqContext;
|
---|
81 | } VBOXRAWPCIINS;
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * The global data of the VBox PCI driver.
|
---|
85 | *
|
---|
86 | * This contains the bit required for communicating with support driver, VBoxDrv
|
---|
87 | * (start out as SupDrv).
|
---|
88 | */
|
---|
89 | typedef struct VBOXRAWPCIGLOBALS
|
---|
90 | {
|
---|
91 | /** Mutex protecting the list of instances and state changes. */
|
---|
92 | RTSEMFASTMUTEX hFastMtx;
|
---|
93 |
|
---|
94 | /** Pointer to a list of instance data. */
|
---|
95 | PVBOXRAWPCIINS pInstanceHead;
|
---|
96 |
|
---|
97 | /** The raw PCI interface factory. */
|
---|
98 | RAWPCIFACTORY RawPciFactory;
|
---|
99 | /** The SUPDRV component factory registration. */
|
---|
100 | SUPDRVFACTORY SupDrvFactory;
|
---|
101 | /** The number of current factory references. */
|
---|
102 | int32_t volatile cFactoryRefs;
|
---|
103 | /** Whether the IDC connection is open or not.
|
---|
104 | * This is only for cleaning up correctly after the separate IDC init on Windows. */
|
---|
105 | bool fIDCOpen;
|
---|
106 | /** The SUPDRV IDC handle (opaque struct). */
|
---|
107 | SUPDRVIDCHANDLE SupDrvIDC;
|
---|
108 | #ifdef RT_OS_LINUX
|
---|
109 | struct module * pciStubModule;
|
---|
110 | #endif
|
---|
111 |
|
---|
112 | } VBOXRAWPCIGLOBALS;
|
---|
113 |
|
---|
114 | DECLHIDDEN(int) vboxPciInit(PVBOXRAWPCIGLOBALS pGlobals);
|
---|
115 | DECLHIDDEN(void) vboxPciShutdown(PVBOXRAWPCIGLOBALS pGlobals);
|
---|
116 |
|
---|
117 | DECLHIDDEN(int) vboxPciOsDevInit (PVBOXRAWPCIINS pIns, uint32_t fFlags);
|
---|
118 | DECLHIDDEN(int) vboxPciOsDevDeinit(PVBOXRAWPCIINS pIns, uint32_t fFlags);
|
---|
119 |
|
---|
120 | DECLHIDDEN(int) vboxPciOsDevGetRegionInfo(PVBOXRAWPCIINS pIns,
|
---|
121 | int32_t iRegion,
|
---|
122 | RTHCPHYS *pRegionStart,
|
---|
123 | uint64_t *pu64RegionSize,
|
---|
124 | bool *pfPresent,
|
---|
125 | uint32_t *pfFlags);
|
---|
126 | DECLHIDDEN(int) vboxPciOsDevMapRegion(PVBOXRAWPCIINS pIns,
|
---|
127 | int32_t iRegion,
|
---|
128 | RTHCPHYS pRegionStart,
|
---|
129 | uint64_t u64RegionSize,
|
---|
130 | uint32_t fFlags,
|
---|
131 | RTR0PTR *pRegionBase);
|
---|
132 | DECLHIDDEN(int) vboxPciOsDevUnmapRegion(PVBOXRAWPCIINS pIns,
|
---|
133 | int32_t iRegion,
|
---|
134 | RTHCPHYS RegionStart,
|
---|
135 | uint64_t u64RegionSize,
|
---|
136 | RTR0PTR RegionBase);
|
---|
137 |
|
---|
138 | DECLHIDDEN(int) vboxPciOsDevPciCfgWrite(PVBOXRAWPCIINS pIns, uint32_t Register, PCIRAWMEMLOC *pValue);
|
---|
139 | DECLHIDDEN(int) vboxPciOsDevPciCfgRead (PVBOXRAWPCIINS pIns, uint32_t Register, PCIRAWMEMLOC *pValue);
|
---|
140 |
|
---|
141 | DECLHIDDEN(int) vboxPciOsDevRegisterIrqHandler (PVBOXRAWPCIINS pIns, PFNRAWPCIISR pfnHandler, void* pIrqContext, int32_t *piHostIrq);
|
---|
142 | DECLHIDDEN(int) vboxPciOsDevUnregisterIrqHandler(PVBOXRAWPCIINS pIns, int32_t iHostIrq);
|
---|
143 |
|
---|
144 | RT_C_DECLS_END
|
---|
145 |
|
---|
146 | #endif
|
---|