1 | /* $Id: PDMDevHlp.cpp 22480 2009-08-26 17:14:13Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * PDM - Pluggable Device and Driver Manager, Device Helpers.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 |
|
---|
23 | /*******************************************************************************
|
---|
24 | * Header Files *
|
---|
25 | *******************************************************************************/
|
---|
26 | #define LOG_GROUP LOG_GROUP_PDM_DEVICE
|
---|
27 | #include "PDMInternal.h"
|
---|
28 | #include <VBox/pdm.h>
|
---|
29 | #include <VBox/mm.h>
|
---|
30 | #include <VBox/pgm.h>
|
---|
31 | #include <VBox/iom.h>
|
---|
32 | #include <VBox/rem.h>
|
---|
33 | #include <VBox/dbgf.h>
|
---|
34 | #include <VBox/vm.h>
|
---|
35 | #include <VBox/vmm.h>
|
---|
36 |
|
---|
37 | #include <VBox/version.h>
|
---|
38 | #include <VBox/log.h>
|
---|
39 | #include <VBox/err.h>
|
---|
40 | #include <iprt/asm.h>
|
---|
41 | #include <iprt/assert.h>
|
---|
42 | #include <iprt/string.h>
|
---|
43 | #include <iprt/thread.h>
|
---|
44 |
|
---|
45 |
|
---|
46 | /*******************************************************************************
|
---|
47 | * Defined Constants And Macros *
|
---|
48 | *******************************************************************************/
|
---|
49 | /** @def PDM_DEVHLP_DEADLOCK_DETECTION
|
---|
50 | * Define this to enable the deadlock detection when accessing physical memory.
|
---|
51 | */
|
---|
52 | #if /*defined(DEBUG_bird) ||*/ defined(DOXYGEN_RUNNING)
|
---|
53 | # define PDM_DEVHLP_DEADLOCK_DETECTION
|
---|
54 | #endif
|
---|
55 |
|
---|
56 |
|
---|
57 | /*******************************************************************************
|
---|
58 | * Defined Constants And Macros *
|
---|
59 | *******************************************************************************/
|
---|
60 | /** @name R3 DevHlp
|
---|
61 | * @{
|
---|
62 | */
|
---|
63 |
|
---|
64 |
|
---|
65 | /** @copydoc PDMDEVHLPR3::pfnIOPortRegister */
|
---|
66 | static DECLCALLBACK(int) pdmR3DevHlp_IOPortRegister(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTHCPTR pvUser, PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
|
---|
67 | PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc)
|
---|
68 | {
|
---|
69 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
70 | LogFlow(("pdmR3DevHlp_IOPortRegister: caller='%s'/%d: Port=%#x cPorts=%#x pvUser=%p pfnOut=%p pfnIn=%p pfnOutStr=%p pfnInStr=%p p32_tszDesc=%p:{%s}\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance,
|
---|
71 | Port, cPorts, pvUser, pfnOut, pfnIn, pfnOutStr, pfnInStr, pszDesc, pszDesc));
|
---|
72 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
73 |
|
---|
74 | #if 0 /** @todo needs a real string cache for this */
|
---|
75 | if (pDevIns->iInstance > 0)
|
---|
76 | {
|
---|
77 | char *pszDesc2 = MMR3HeapAPrintf(pVM, MM_TAG_PDM_DEVICE_DESC, "%s [%u]", pszDesc, pDevIns->iInstance);
|
---|
78 | if (pszDesc2)
|
---|
79 | pszDesc = pszDesc2;
|
---|
80 | }
|
---|
81 | #endif
|
---|
82 |
|
---|
83 | int rc = IOMR3IOPortRegisterR3(pDevIns->Internal.s.pVMR3, pDevIns, Port, cPorts, pvUser, pfnOut, pfnIn, pfnOutStr, pfnInStr, pszDesc);
|
---|
84 |
|
---|
85 | LogFlow(("pdmR3DevHlp_IOPortRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
86 | return rc;
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 | /** @copydoc PDMDEVHLPR3::pfnIOPortRegisterGC */
|
---|
91 | static DECLCALLBACK(int) pdmR3DevHlp_IOPortRegisterGC(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTRCPTR pvUser,
|
---|
92 | const char *pszOut, const char *pszIn,
|
---|
93 | const char *pszOutStr, const char *pszInStr, const char *pszDesc)
|
---|
94 | {
|
---|
95 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
96 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
97 | LogFlow(("pdmR3DevHlp_IOPortRegister: caller='%s'/%d: Port=%#x cPorts=%#x pvUser=%p pszOut=%p:{%s} pszIn=%p:{%s} pszOutStr=%p:{%s} pszInStr=%p:{%s} pszDesc=%p:{%s}\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance,
|
---|
98 | Port, cPorts, pvUser, pszOut, pszOut, pszIn, pszIn, pszOutStr, pszOutStr, pszInStr, pszInStr, pszDesc, pszDesc));
|
---|
99 |
|
---|
100 | /*
|
---|
101 | * Resolve the functions (one of the can be NULL).
|
---|
102 | */
|
---|
103 | int rc = VINF_SUCCESS;
|
---|
104 | if ( pDevIns->pDevReg->szRCMod[0]
|
---|
105 | && (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_RC))
|
---|
106 | {
|
---|
107 | RTRCPTR RCPtrIn = NIL_RTRCPTR;
|
---|
108 | if (pszIn)
|
---|
109 | {
|
---|
110 | rc = PDMR3LdrGetSymbolRCLazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szRCMod, pszIn, &RCPtrIn);
|
---|
111 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszIn)\n", pDevIns->pDevReg->szRCMod, pszIn));
|
---|
112 | }
|
---|
113 | RTRCPTR RCPtrOut = NIL_RTRCPTR;
|
---|
114 | if (pszOut && RT_SUCCESS(rc))
|
---|
115 | {
|
---|
116 | rc = PDMR3LdrGetSymbolRCLazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szRCMod, pszOut, &RCPtrOut);
|
---|
117 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszOut)\n", pDevIns->pDevReg->szRCMod, pszOut));
|
---|
118 | }
|
---|
119 | RTRCPTR RCPtrInStr = NIL_RTRCPTR;
|
---|
120 | if (pszInStr && RT_SUCCESS(rc))
|
---|
121 | {
|
---|
122 | rc = PDMR3LdrGetSymbolRCLazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szRCMod, pszInStr, &RCPtrInStr);
|
---|
123 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszInStr)\n", pDevIns->pDevReg->szRCMod, pszInStr));
|
---|
124 | }
|
---|
125 | RTRCPTR RCPtrOutStr = NIL_RTRCPTR;
|
---|
126 | if (pszOutStr && RT_SUCCESS(rc))
|
---|
127 | {
|
---|
128 | rc = PDMR3LdrGetSymbolRCLazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szRCMod, pszOutStr, &RCPtrOutStr);
|
---|
129 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszOutStr)\n", pDevIns->pDevReg->szRCMod, pszOutStr));
|
---|
130 | }
|
---|
131 |
|
---|
132 | if (RT_SUCCESS(rc))
|
---|
133 | {
|
---|
134 | #if 0 /** @todo needs a real string cache for this */
|
---|
135 | if (pDevIns->iInstance > 0)
|
---|
136 | {
|
---|
137 | char *pszDesc2 = MMR3HeapAPrintf(pVM, MM_TAG_PDM_DEVICE_DESC, "%s [%u]", pszDesc, pDevIns->iInstance);
|
---|
138 | if (pszDesc2)
|
---|
139 | pszDesc = pszDesc2;
|
---|
140 | }
|
---|
141 | #endif
|
---|
142 |
|
---|
143 | rc = IOMR3IOPortRegisterRC(pDevIns->Internal.s.pVMR3, pDevIns, Port, cPorts, pvUser, RCPtrOut, RCPtrIn, RCPtrOutStr, RCPtrInStr, pszDesc);
|
---|
144 | }
|
---|
145 | }
|
---|
146 | else
|
---|
147 | {
|
---|
148 | AssertMsgFailed(("No GC module for this driver!\n"));
|
---|
149 | rc = VERR_INVALID_PARAMETER;
|
---|
150 | }
|
---|
151 |
|
---|
152 | LogFlow(("pdmR3DevHlp_IOPortRegisterGC: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
153 | return rc;
|
---|
154 | }
|
---|
155 |
|
---|
156 |
|
---|
157 | /** @copydoc PDMDEVHLPR3::pfnIOPortRegisterR0 */
|
---|
158 | static DECLCALLBACK(int) pdmR3DevHlp_IOPortRegisterR0(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTR0PTR pvUser,
|
---|
159 | const char *pszOut, const char *pszIn,
|
---|
160 | const char *pszOutStr, const char *pszInStr, const char *pszDesc)
|
---|
161 | {
|
---|
162 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
163 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
164 | LogFlow(("pdmR3DevHlp_IOPortRegisterR0: caller='%s'/%d: Port=%#x cPorts=%#x pvUser=%p pszOut=%p:{%s} pszIn=%p:{%s} pszOutStr=%p:{%s} pszInStr=%p:{%s} pszDesc=%p:{%s}\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance,
|
---|
165 | Port, cPorts, pvUser, pszOut, pszOut, pszIn, pszIn, pszOutStr, pszOutStr, pszInStr, pszInStr, pszDesc, pszDesc));
|
---|
166 |
|
---|
167 | /*
|
---|
168 | * Resolve the functions (one of the can be NULL).
|
---|
169 | */
|
---|
170 | int rc = VINF_SUCCESS;
|
---|
171 | if ( pDevIns->pDevReg->szR0Mod[0]
|
---|
172 | && (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_R0))
|
---|
173 | {
|
---|
174 | R0PTRTYPE(PFNIOMIOPORTIN) pfnR0PtrIn = 0;
|
---|
175 | if (pszIn)
|
---|
176 | {
|
---|
177 | rc = PDMR3LdrGetSymbolR0Lazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szR0Mod, pszIn, &pfnR0PtrIn);
|
---|
178 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszIn)\n", pDevIns->pDevReg->szR0Mod, pszIn));
|
---|
179 | }
|
---|
180 | R0PTRTYPE(PFNIOMIOPORTOUT) pfnR0PtrOut = 0;
|
---|
181 | if (pszOut && RT_SUCCESS(rc))
|
---|
182 | {
|
---|
183 | rc = PDMR3LdrGetSymbolR0Lazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szR0Mod, pszOut, &pfnR0PtrOut);
|
---|
184 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszOut)\n", pDevIns->pDevReg->szR0Mod, pszOut));
|
---|
185 | }
|
---|
186 | R0PTRTYPE(PFNIOMIOPORTINSTRING) pfnR0PtrInStr = 0;
|
---|
187 | if (pszInStr && RT_SUCCESS(rc))
|
---|
188 | {
|
---|
189 | rc = PDMR3LdrGetSymbolR0Lazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szR0Mod, pszInStr, &pfnR0PtrInStr);
|
---|
190 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszInStr)\n", pDevIns->pDevReg->szR0Mod, pszInStr));
|
---|
191 | }
|
---|
192 | R0PTRTYPE(PFNIOMIOPORTOUTSTRING) pfnR0PtrOutStr = 0;
|
---|
193 | if (pszOutStr && RT_SUCCESS(rc))
|
---|
194 | {
|
---|
195 | rc = PDMR3LdrGetSymbolR0Lazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szR0Mod, pszOutStr, &pfnR0PtrOutStr);
|
---|
196 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszOutStr)\n", pDevIns->pDevReg->szR0Mod, pszOutStr));
|
---|
197 | }
|
---|
198 |
|
---|
199 | if (RT_SUCCESS(rc))
|
---|
200 | {
|
---|
201 | #if 0 /** @todo needs a real string cache for this */
|
---|
202 | if (pDevIns->iInstance > 0)
|
---|
203 | {
|
---|
204 | char *pszDesc2 = MMR3HeapAPrintf(pVM, MM_TAG_PDM_DEVICE_DESC, "%s [%u]", pszDesc, pDevIns->iInstance);
|
---|
205 | if (pszDesc2)
|
---|
206 | pszDesc = pszDesc2;
|
---|
207 | }
|
---|
208 | #endif
|
---|
209 |
|
---|
210 | rc = IOMR3IOPortRegisterR0(pDevIns->Internal.s.pVMR3, pDevIns, Port, cPorts, pvUser, pfnR0PtrOut, pfnR0PtrIn, pfnR0PtrOutStr, pfnR0PtrInStr, pszDesc);
|
---|
211 | }
|
---|
212 | }
|
---|
213 | else
|
---|
214 | {
|
---|
215 | AssertMsgFailed(("No R0 module for this driver!\n"));
|
---|
216 | rc = VERR_INVALID_PARAMETER;
|
---|
217 | }
|
---|
218 |
|
---|
219 | LogFlow(("pdmR3DevHlp_IOPortRegisterR0: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
220 | return rc;
|
---|
221 | }
|
---|
222 |
|
---|
223 |
|
---|
224 | /** @copydoc PDMDEVHLPR3::pfnIOPortDeregister */
|
---|
225 | static DECLCALLBACK(int) pdmR3DevHlp_IOPortDeregister(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts)
|
---|
226 | {
|
---|
227 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
228 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
229 | LogFlow(("pdmR3DevHlp_IOPortDeregister: caller='%s'/%d: Port=%#x cPorts=%#x\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance,
|
---|
230 | Port, cPorts));
|
---|
231 |
|
---|
232 | int rc = IOMR3IOPortDeregister(pDevIns->Internal.s.pVMR3, pDevIns, Port, cPorts);
|
---|
233 |
|
---|
234 | LogFlow(("pdmR3DevHlp_IOPortDeregister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
235 | return rc;
|
---|
236 | }
|
---|
237 |
|
---|
238 |
|
---|
239 | /** @copydoc PDMDEVHLPR3::pfnMMIORegister */
|
---|
240 | static DECLCALLBACK(int) pdmR3DevHlp_MMIORegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
|
---|
241 | PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
|
---|
242 | const char *pszDesc)
|
---|
243 | {
|
---|
244 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
245 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
246 | LogFlow(("pdmR3DevHlp_MMIORegister: caller='%s'/%d: GCPhysStart=%RGp cbRange=%#x pvUser=%p pfnWrite=%p pfnRead=%p pfnFill=%p pszDesc=%p:{%s}\n",
|
---|
247 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhysStart, cbRange, pvUser, pfnWrite, pfnRead, pfnFill, pszDesc, pszDesc));
|
---|
248 |
|
---|
249 | /** @todo IOMR3MMIORegisterR3 mangles the description, move it here. */
|
---|
250 | int rc = IOMR3MMIORegisterR3(pDevIns->Internal.s.pVMR3, pDevIns, GCPhysStart, cbRange, pvUser, pfnWrite, pfnRead, pfnFill, pszDesc);
|
---|
251 |
|
---|
252 | LogFlow(("pdmR3DevHlp_MMIORegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
253 | return rc;
|
---|
254 | }
|
---|
255 |
|
---|
256 |
|
---|
257 | /** @copydoc PDMDEVHLPR3::pfnMMIORegisterGC */
|
---|
258 | static DECLCALLBACK(int) pdmR3DevHlp_MMIORegisterGC(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
|
---|
259 | const char *pszWrite, const char *pszRead, const char *pszFill,
|
---|
260 | const char *pszDesc)
|
---|
261 | {
|
---|
262 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
263 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
264 | LogFlow(("pdmR3DevHlp_MMIORegisterGC: caller='%s'/%d: GCPhysStart=%RGp cbRange=%#x pvUser=%p pszWrite=%p:{%s} pszRead=%p:{%s} pszFill=%p:{%s}\n",
|
---|
265 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhysStart, cbRange, pvUser, pszWrite, pszWrite, pszRead, pszRead, pszFill, pszFill));
|
---|
266 |
|
---|
267 | /** @todo pszDesc is unused here, drop it. */
|
---|
268 |
|
---|
269 | /*
|
---|
270 | * Resolve the functions.
|
---|
271 | * Not all function have to present, leave it to IOM to enforce this.
|
---|
272 | */
|
---|
273 | int rc = VINF_SUCCESS;
|
---|
274 | if ( pDevIns->pDevReg->szRCMod[0]
|
---|
275 | && (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_RC))
|
---|
276 | {
|
---|
277 | RTRCPTR RCPtrWrite = NIL_RTRCPTR;
|
---|
278 | if (pszWrite)
|
---|
279 | rc = PDMR3LdrGetSymbolRCLazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szRCMod, pszWrite, &RCPtrWrite);
|
---|
280 |
|
---|
281 | RTRCPTR RCPtrRead = NIL_RTRCPTR;
|
---|
282 | int rc2 = VINF_SUCCESS;
|
---|
283 | if (pszRead)
|
---|
284 | rc2 = PDMR3LdrGetSymbolRCLazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szRCMod, pszRead, &RCPtrRead);
|
---|
285 |
|
---|
286 | RTRCPTR RCPtrFill = NIL_RTRCPTR;
|
---|
287 | int rc3 = VINF_SUCCESS;
|
---|
288 | if (pszFill)
|
---|
289 | rc3 = PDMR3LdrGetSymbolRCLazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szRCMod, pszFill, &RCPtrFill);
|
---|
290 |
|
---|
291 | if (RT_SUCCESS(rc) && RT_SUCCESS(rc2) && RT_SUCCESS(rc3))
|
---|
292 | rc = IOMR3MMIORegisterRC(pDevIns->Internal.s.pVMR3, pDevIns, GCPhysStart, cbRange, pvUser, RCPtrWrite, RCPtrRead, RCPtrFill);
|
---|
293 | else
|
---|
294 | {
|
---|
295 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszWrite)\n", pDevIns->pDevReg->szRCMod, pszWrite));
|
---|
296 | AssertMsgRC(rc2, ("Failed to resolve %s.%s (pszRead)\n", pDevIns->pDevReg->szRCMod, pszRead));
|
---|
297 | AssertMsgRC(rc3, ("Failed to resolve %s.%s (pszFill)\n", pDevIns->pDevReg->szRCMod, pszFill));
|
---|
298 | if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
|
---|
299 | rc = rc2;
|
---|
300 | if (RT_FAILURE(rc3) && RT_SUCCESS(rc))
|
---|
301 | rc = rc3;
|
---|
302 | }
|
---|
303 | }
|
---|
304 | else
|
---|
305 | {
|
---|
306 | AssertMsgFailed(("No GC module for this driver!\n"));
|
---|
307 | rc = VERR_INVALID_PARAMETER;
|
---|
308 | }
|
---|
309 |
|
---|
310 | LogFlow(("pdmR3DevHlp_MMIORegisterGC: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
311 | return rc;
|
---|
312 | }
|
---|
313 |
|
---|
314 | /** @copydoc PDMDEVHLPR3::pfnMMIORegisterR0 */
|
---|
315 | static DECLCALLBACK(int) pdmR3DevHlp_MMIORegisterR0(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTR0PTR pvUser,
|
---|
316 | const char *pszWrite, const char *pszRead, const char *pszFill,
|
---|
317 | const char *pszDesc)
|
---|
318 | {
|
---|
319 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
320 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
321 | LogFlow(("pdmR3DevHlp_MMIORegisterHC: caller='%s'/%d: GCPhysStart=%RGp cbRange=%#x pvUser=%p pszWrite=%p:{%s} pszRead=%p:{%s} pszFill=%p:{%s}\n",
|
---|
322 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhysStart, cbRange, pvUser, pszWrite, pszWrite, pszRead, pszRead, pszFill, pszFill));
|
---|
323 |
|
---|
324 | /** @todo pszDesc is unused here, remove it. */
|
---|
325 |
|
---|
326 | /*
|
---|
327 | * Resolve the functions.
|
---|
328 | * Not all function have to present, leave it to IOM to enforce this.
|
---|
329 | */
|
---|
330 | int rc = VINF_SUCCESS;
|
---|
331 | if ( pDevIns->pDevReg->szR0Mod[0]
|
---|
332 | && (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_R0))
|
---|
333 | {
|
---|
334 | R0PTRTYPE(PFNIOMMMIOWRITE) pfnR0PtrWrite = 0;
|
---|
335 | if (pszWrite)
|
---|
336 | rc = PDMR3LdrGetSymbolR0Lazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szR0Mod, pszWrite, &pfnR0PtrWrite);
|
---|
337 | R0PTRTYPE(PFNIOMMMIOREAD) pfnR0PtrRead = 0;
|
---|
338 | int rc2 = VINF_SUCCESS;
|
---|
339 | if (pszRead)
|
---|
340 | rc2 = PDMR3LdrGetSymbolR0Lazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szR0Mod, pszRead, &pfnR0PtrRead);
|
---|
341 | R0PTRTYPE(PFNIOMMMIOFILL) pfnR0PtrFill = 0;
|
---|
342 | int rc3 = VINF_SUCCESS;
|
---|
343 | if (pszFill)
|
---|
344 | rc3 = PDMR3LdrGetSymbolR0Lazy(pDevIns->Internal.s.pVMR3, pDevIns->pDevReg->szR0Mod, pszFill, &pfnR0PtrFill);
|
---|
345 | if (RT_SUCCESS(rc) && RT_SUCCESS(rc2) && RT_SUCCESS(rc3))
|
---|
346 | rc = IOMR3MMIORegisterR0(pDevIns->Internal.s.pVMR3, pDevIns, GCPhysStart, cbRange, pvUser, pfnR0PtrWrite, pfnR0PtrRead, pfnR0PtrFill);
|
---|
347 | else
|
---|
348 | {
|
---|
349 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszWrite)\n", pDevIns->pDevReg->szR0Mod, pszWrite));
|
---|
350 | AssertMsgRC(rc2, ("Failed to resolve %s.%s (pszRead)\n", pDevIns->pDevReg->szR0Mod, pszRead));
|
---|
351 | AssertMsgRC(rc3, ("Failed to resolve %s.%s (pszFill)\n", pDevIns->pDevReg->szR0Mod, pszFill));
|
---|
352 | if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
|
---|
353 | rc = rc2;
|
---|
354 | if (RT_FAILURE(rc3) && RT_SUCCESS(rc))
|
---|
355 | rc = rc3;
|
---|
356 | }
|
---|
357 | }
|
---|
358 | else
|
---|
359 | {
|
---|
360 | AssertMsgFailed(("No R0 module for this driver!\n"));
|
---|
361 | rc = VERR_INVALID_PARAMETER;
|
---|
362 | }
|
---|
363 |
|
---|
364 | LogFlow(("pdmR3DevHlp_MMIORegisterR0: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
365 | return rc;
|
---|
366 | }
|
---|
367 |
|
---|
368 |
|
---|
369 | /** @copydoc PDMDEVHLPR3::pfnMMIODeregister */
|
---|
370 | static DECLCALLBACK(int) pdmR3DevHlp_MMIODeregister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange)
|
---|
371 | {
|
---|
372 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
373 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
374 | LogFlow(("pdmR3DevHlp_MMIODeregister: caller='%s'/%d: GCPhysStart=%RGp cbRange=%#x\n",
|
---|
375 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhysStart, cbRange));
|
---|
376 |
|
---|
377 | int rc = IOMR3MMIODeregister(pDevIns->Internal.s.pVMR3, pDevIns, GCPhysStart, cbRange);
|
---|
378 |
|
---|
379 | LogFlow(("pdmR3DevHlp_MMIODeregister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
380 | return rc;
|
---|
381 | }
|
---|
382 |
|
---|
383 |
|
---|
384 | /** @copydoc PDMDEVHLPR3::pfnROMRegister */
|
---|
385 | static DECLCALLBACK(int) pdmR3DevHlp_ROMRegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, const void *pvBinary, uint32_t fFlags, const char *pszDesc)
|
---|
386 | {
|
---|
387 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
388 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
389 | LogFlow(("pdmR3DevHlp_ROMRegister: caller='%s'/%d: GCPhysStart=%RGp cbRange=%#x pvBinary=%p fFlags=%#RX32 pszDesc=%p:{%s}\n",
|
---|
390 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhysStart, cbRange, pvBinary, fFlags, pszDesc, pszDesc));
|
---|
391 |
|
---|
392 | /** @todo can we mangle pszDesc? */
|
---|
393 | int rc = PGMR3PhysRomRegister(pDevIns->Internal.s.pVMR3, pDevIns, GCPhysStart, cbRange, pvBinary, fFlags, pszDesc);
|
---|
394 |
|
---|
395 | LogFlow(("pdmR3DevHlp_ROMRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
396 | return rc;
|
---|
397 | }
|
---|
398 |
|
---|
399 |
|
---|
400 | /** @copydoc PDMDEVHLPR3::pfnSSMRegister */
|
---|
401 | static DECLCALLBACK(int) pdmR3DevHlp_SSMRegister(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
|
---|
402 | PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
|
---|
403 | PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
|
---|
404 | PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone)
|
---|
405 | {
|
---|
406 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
407 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
408 | LogFlow(("pdmR3DevHlp_SSMRegister: caller='%s'/%d: uVersion=#x cbGuess=%#x pszBefore=%p:{%s}\n"
|
---|
409 | " pfnLivePrep=%p pfnLiveExec=%p pfnLiveVote=%p pfnSavePrep=%p pfnSaveExec=%p pfnSaveDone=%p pszLoadPrep=%p pfnLoadExec=%p pfnLoadDone=%p\n",
|
---|
410 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, uVersion, cbGuess, pszBefore, pszBefore,
|
---|
411 | pfnLivePrep, pfnLiveExec, pfnLiveVote,
|
---|
412 | pfnSavePrep, pfnSaveExec, pfnSaveDone,
|
---|
413 | pfnLoadPrep, pfnLoadExec, pfnLoadDone));
|
---|
414 |
|
---|
415 | int rc = SSMR3RegisterDevice(pDevIns->Internal.s.pVMR3, pDevIns, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance,
|
---|
416 | uVersion, cbGuess, pszBefore,
|
---|
417 | pfnLivePrep, pfnLiveExec, pfnLiveVote,
|
---|
418 | pfnSavePrep, pfnSaveExec, pfnSaveDone,
|
---|
419 | pfnLoadPrep, pfnLoadExec, pfnLoadDone);
|
---|
420 |
|
---|
421 | LogFlow(("pdmR3DevHlp_SSMRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
422 | return rc;
|
---|
423 | }
|
---|
424 |
|
---|
425 |
|
---|
426 | /** @copydoc PDMDEVHLPR3::pfnTMTimerCreate */
|
---|
427 | static DECLCALLBACK(int) pdmR3DevHlp_TMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
|
---|
428 | {
|
---|
429 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
430 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
431 | VM_ASSERT_EMT(pVM);
|
---|
432 | LogFlow(("pdmR3DevHlp_TMTimerCreate: caller='%s'/%d: enmClock=%d pfnCallback=%p pvUser=%p fFlags=%#x pszDesc=%p:{%s} ppTimer=%p\n",
|
---|
433 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, enmClock, pfnCallback, pvUser, fFlags, pszDesc, pszDesc, ppTimer));
|
---|
434 |
|
---|
435 | if (pDevIns->iInstance > 0) /** @todo use a string cache here later. */
|
---|
436 | {
|
---|
437 | char *pszDesc2 = MMR3HeapAPrintf(pVM, MM_TAG_PDM_DEVICE_DESC, "%s [%u]", pszDesc, pDevIns->iInstance);
|
---|
438 | if (pszDesc2)
|
---|
439 | pszDesc = pszDesc2;
|
---|
440 | }
|
---|
441 |
|
---|
442 | int rc = TMR3TimerCreateDevice(pVM, pDevIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
|
---|
443 |
|
---|
444 | LogFlow(("pdmR3DevHlp_TMTimerCreate: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
445 | return rc;
|
---|
446 | }
|
---|
447 |
|
---|
448 |
|
---|
449 | /** @copydoc PDMDEVHLPR3::pfnPCIRegister */
|
---|
450 | static DECLCALLBACK(int) pdmR3DevHlp_PCIRegister(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev)
|
---|
451 | {
|
---|
452 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
453 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
454 | VM_ASSERT_EMT(pVM);
|
---|
455 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: pPciDev=%p:{.config={%#.256Rhxs}\n",
|
---|
456 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pPciDev, pPciDev->config));
|
---|
457 |
|
---|
458 | /*
|
---|
459 | * Validate input.
|
---|
460 | */
|
---|
461 | if (!pPciDev)
|
---|
462 | {
|
---|
463 | Assert(pPciDev);
|
---|
464 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Rrc (pPciDev)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
465 | return VERR_INVALID_PARAMETER;
|
---|
466 | }
|
---|
467 | if (!pPciDev->config[0] && !pPciDev->config[1])
|
---|
468 | {
|
---|
469 | Assert(pPciDev->config[0] || pPciDev->config[1]);
|
---|
470 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Rrc (vendor)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
471 | return VERR_INVALID_PARAMETER;
|
---|
472 | }
|
---|
473 | if (pDevIns->Internal.s.pPciDeviceR3)
|
---|
474 | {
|
---|
475 | /** @todo the PCI device vs. PDM device designed is a bit flawed if we have to
|
---|
476 | * support a PDM device with multiple PCI devices. This might become a problem
|
---|
477 | * when upgrading the chipset for instance because of multiple functions in some
|
---|
478 | * devices...
|
---|
479 | */
|
---|
480 | AssertMsgFailed(("Only one PCI device per device is currently implemented!\n"));
|
---|
481 | return VERR_INTERNAL_ERROR;
|
---|
482 | }
|
---|
483 |
|
---|
484 | /*
|
---|
485 | * Choose the PCI bus for the device.
|
---|
486 | *
|
---|
487 | * This is simple. If the device was configured for a particular bus, the PCIBusNo
|
---|
488 | * configuration value will be set. If not the default bus is 0.
|
---|
489 | */
|
---|
490 | int rc;
|
---|
491 | PPDMPCIBUS pBus = pDevIns->Internal.s.pPciBusR3;
|
---|
492 | if (!pBus)
|
---|
493 | {
|
---|
494 | uint8_t u8Bus;
|
---|
495 | rc = CFGMR3QueryU8Def(pDevIns->Internal.s.pCfgHandle, "PCIBusNo", &u8Bus, 0);
|
---|
496 | AssertLogRelMsgRCReturn(rc, ("Configuration error: PCIBusNo query failed with rc=%Rrc (%s/%d)\n",
|
---|
497 | rc, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance), rc);
|
---|
498 | AssertLogRelMsgReturn(u8Bus < RT_ELEMENTS(pVM->pdm.s.aPciBuses),
|
---|
499 | ("Configuration error: PCIBusNo=%d, max is %d. (%s/%d)\n", u8Bus,
|
---|
500 | RT_ELEMENTS(pVM->pdm.s.aPciBuses), pDevIns->pDevReg->szDeviceName, pDevIns->iInstance),
|
---|
501 | VERR_PDM_NO_PCI_BUS);
|
---|
502 | pBus = pDevIns->Internal.s.pPciBusR3 = &pVM->pdm.s.aPciBuses[u8Bus];
|
---|
503 | }
|
---|
504 | if (pBus->pDevInsR3)
|
---|
505 | {
|
---|
506 | if (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_RC)
|
---|
507 | pDevIns->Internal.s.pPciBusR0 = MMHyperR3ToR0(pVM, pDevIns->Internal.s.pPciBusR3);
|
---|
508 | else
|
---|
509 | pDevIns->Internal.s.pPciBusR0 = NIL_RTR0PTR;
|
---|
510 |
|
---|
511 | if (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_RC)
|
---|
512 | pDevIns->Internal.s.pPciBusRC = MMHyperR3ToRC(pVM, pDevIns->Internal.s.pPciBusR3);
|
---|
513 | else
|
---|
514 | pDevIns->Internal.s.pPciBusRC = NIL_RTRCPTR;
|
---|
515 |
|
---|
516 | /*
|
---|
517 | * Check the configuration for PCI device and function assignment.
|
---|
518 | */
|
---|
519 | int iDev = -1;
|
---|
520 | uint8_t u8Device;
|
---|
521 | rc = CFGMR3QueryU8(pDevIns->Internal.s.pCfgHandle, "PCIDeviceNo", &u8Device);
|
---|
522 | if (RT_SUCCESS(rc))
|
---|
523 | {
|
---|
524 | if (u8Device > 31)
|
---|
525 | {
|
---|
526 | AssertMsgFailed(("Configuration error: PCIDeviceNo=%d, max is 31. (%s/%d)\n",
|
---|
527 | u8Device, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
528 | return VERR_INTERNAL_ERROR;
|
---|
529 | }
|
---|
530 |
|
---|
531 | uint8_t u8Function;
|
---|
532 | rc = CFGMR3QueryU8(pDevIns->Internal.s.pCfgHandle, "PCIFunctionNo", &u8Function);
|
---|
533 | if (RT_FAILURE(rc))
|
---|
534 | {
|
---|
535 | AssertMsgFailed(("Configuration error: PCIDeviceNo, but PCIFunctionNo query failed with rc=%Rrc (%s/%d)\n",
|
---|
536 | rc, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
537 | return rc;
|
---|
538 | }
|
---|
539 | if (u8Function > 7)
|
---|
540 | {
|
---|
541 | AssertMsgFailed(("Configuration error: PCIFunctionNo=%d, max is 7. (%s/%d)\n",
|
---|
542 | u8Function, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
543 | return VERR_INTERNAL_ERROR;
|
---|
544 | }
|
---|
545 | iDev = (u8Device << 3) | u8Function;
|
---|
546 | }
|
---|
547 | else if (rc != VERR_CFGM_VALUE_NOT_FOUND)
|
---|
548 | {
|
---|
549 | AssertMsgFailed(("Configuration error: PCIDeviceNo query failed with rc=%Rrc (%s/%d)\n",
|
---|
550 | rc, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
551 | return rc;
|
---|
552 | }
|
---|
553 |
|
---|
554 | /*
|
---|
555 | * Call the pci bus device to do the actual registration.
|
---|
556 | */
|
---|
557 | pdmLock(pVM);
|
---|
558 | rc = pBus->pfnRegisterR3(pBus->pDevInsR3, pPciDev, pDevIns->pDevReg->szDeviceName, iDev);
|
---|
559 | pdmUnlock(pVM);
|
---|
560 | if (RT_SUCCESS(rc))
|
---|
561 | {
|
---|
562 | pPciDev->pDevIns = pDevIns;
|
---|
563 |
|
---|
564 | pDevIns->Internal.s.pPciDeviceR3 = pPciDev;
|
---|
565 | if (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_R0)
|
---|
566 | pDevIns->Internal.s.pPciDeviceR0 = MMHyperR3ToR0(pVM, pPciDev);
|
---|
567 | else
|
---|
568 | pDevIns->Internal.s.pPciDeviceR0 = NIL_RTR0PTR;
|
---|
569 |
|
---|
570 | if (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_RC)
|
---|
571 | pDevIns->Internal.s.pPciDeviceRC = MMHyperR3ToRC(pVM, pPciDev);
|
---|
572 | else
|
---|
573 | pDevIns->Internal.s.pPciDeviceRC = NIL_RTRCPTR;
|
---|
574 |
|
---|
575 | Log(("PDM: Registered device '%s'/%d as PCI device %d on bus %d\n",
|
---|
576 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pPciDev->devfn, pDevIns->Internal.s.pPciBusR3->iBus));
|
---|
577 | }
|
---|
578 | }
|
---|
579 | else
|
---|
580 | {
|
---|
581 | AssertLogRelMsgFailed(("Configuration error: No PCI bus available. This could be related to init order too!\n"));
|
---|
582 | rc = VERR_PDM_NO_PCI_BUS;
|
---|
583 | }
|
---|
584 |
|
---|
585 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
586 | return rc;
|
---|
587 | }
|
---|
588 |
|
---|
589 |
|
---|
590 | /** @copydoc PDMDEVHLPR3::pfnPCIIORegionRegister */
|
---|
591 | static DECLCALLBACK(int) pdmR3DevHlp_PCIIORegionRegister(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)
|
---|
592 | {
|
---|
593 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
594 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
595 | VM_ASSERT_EMT(pVM);
|
---|
596 | LogFlow(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: iRegion=%d cbRegion=%#x enmType=%d pfnCallback=%p\n",
|
---|
597 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iRegion, cbRegion, enmType, pfnCallback));
|
---|
598 |
|
---|
599 | /*
|
---|
600 | * Validate input.
|
---|
601 | */
|
---|
602 | if (iRegion < 0 || iRegion >= PCI_NUM_REGIONS)
|
---|
603 | {
|
---|
604 | Assert(iRegion >= 0 && iRegion < PCI_NUM_REGIONS);
|
---|
605 | LogFlow(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: returns %Rrc (iRegion)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
606 | return VERR_INVALID_PARAMETER;
|
---|
607 | }
|
---|
608 | switch (enmType)
|
---|
609 | {
|
---|
610 | case PCI_ADDRESS_SPACE_IO:
|
---|
611 | /*
|
---|
612 | * Sanity check: don't allow to register more than 32K of the PCI I/O space.
|
---|
613 | */
|
---|
614 | AssertMsgReturn(cbRegion <= _32K,
|
---|
615 | ("caller='%s'/%d: %#x\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cbRegion),
|
---|
616 | VERR_INVALID_PARAMETER);
|
---|
617 | break;
|
---|
618 |
|
---|
619 | case PCI_ADDRESS_SPACE_MEM:
|
---|
620 | case PCI_ADDRESS_SPACE_MEM_PREFETCH:
|
---|
621 | /*
|
---|
622 | * Sanity check: don't allow to register more than 512MB of the PCI MMIO space for
|
---|
623 | * now. If this limit is increased beyond 2GB, adapt the aligned check below as well!
|
---|
624 | */
|
---|
625 | AssertMsgReturn(cbRegion <= 512 * _1M,
|
---|
626 | ("caller='%s'/%d: %#x\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cbRegion),
|
---|
627 | VERR_INVALID_PARAMETER);
|
---|
628 | break;
|
---|
629 | default:
|
---|
630 | AssertMsgFailed(("enmType=%#x is unknown\n", enmType));
|
---|
631 | LogFlow(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: returns %Rrc (enmType)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
632 | return VERR_INVALID_PARAMETER;
|
---|
633 | }
|
---|
634 | if (!pfnCallback)
|
---|
635 | {
|
---|
636 | Assert(pfnCallback);
|
---|
637 | LogFlow(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: returns %Rrc (callback)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
638 | return VERR_INVALID_PARAMETER;
|
---|
639 | }
|
---|
640 | AssertRelease(VMR3GetState(pVM) != VMSTATE_RUNNING);
|
---|
641 |
|
---|
642 | /*
|
---|
643 | * Must have a PCI device registered!
|
---|
644 | */
|
---|
645 | int rc;
|
---|
646 | PPCIDEVICE pPciDev = pDevIns->Internal.s.pPciDeviceR3;
|
---|
647 | if (pPciDev)
|
---|
648 | {
|
---|
649 | /*
|
---|
650 | * We're currently restricted to page aligned MMIO regions.
|
---|
651 | */
|
---|
652 | if ( (enmType == PCI_ADDRESS_SPACE_MEM || enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH)
|
---|
653 | && cbRegion != RT_ALIGN_32(cbRegion, PAGE_SIZE))
|
---|
654 | {
|
---|
655 | Log(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: aligning cbRegion %#x -> %#x\n",
|
---|
656 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cbRegion, RT_ALIGN_32(cbRegion, PAGE_SIZE)));
|
---|
657 | cbRegion = RT_ALIGN_32(cbRegion, PAGE_SIZE);
|
---|
658 | }
|
---|
659 |
|
---|
660 | /*
|
---|
661 | * For registering PCI MMIO memory or PCI I/O memory, the size of the region must be a power of 2!
|
---|
662 | */
|
---|
663 | int iLastSet = ASMBitLastSetU32(cbRegion);
|
---|
664 | Assert(iLastSet > 0);
|
---|
665 | uint32_t cbRegionAligned = RT_BIT_32(iLastSet - 1);
|
---|
666 | if (cbRegion > cbRegionAligned)
|
---|
667 | cbRegion = cbRegionAligned * 2; /* round up */
|
---|
668 |
|
---|
669 | PPDMPCIBUS pBus = pDevIns->Internal.s.pPciBusR3;
|
---|
670 | Assert(pBus);
|
---|
671 | pdmLock(pVM);
|
---|
672 | rc = pBus->pfnIORegionRegisterR3(pBus->pDevInsR3, pPciDev, iRegion, cbRegion, enmType, pfnCallback);
|
---|
673 | pdmUnlock(pVM);
|
---|
674 | }
|
---|
675 | else
|
---|
676 | {
|
---|
677 | AssertMsgFailed(("No PCI device registered!\n"));
|
---|
678 | rc = VERR_PDM_NOT_PCI_DEVICE;
|
---|
679 | }
|
---|
680 |
|
---|
681 | LogFlow(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
682 | return rc;
|
---|
683 | }
|
---|
684 |
|
---|
685 |
|
---|
686 | /** @copydoc PDMDEVHLPR3::pfnPCISetConfigCallbacks */
|
---|
687 | static DECLCALLBACK(void) pdmR3DevHlp_PCISetConfigCallbacks(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
|
---|
688 | PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)
|
---|
689 | {
|
---|
690 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
691 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
692 | VM_ASSERT_EMT(pVM);
|
---|
693 | LogFlow(("pdmR3DevHlp_PCISetConfigCallbacks: caller='%s'/%d: pPciDev=%p pfnRead=%p ppfnReadOld=%p pfnWrite=%p ppfnWriteOld=%p\n",
|
---|
694 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld));
|
---|
695 |
|
---|
696 | /*
|
---|
697 | * Validate input and resolve defaults.
|
---|
698 | */
|
---|
699 | AssertPtr(pfnRead);
|
---|
700 | AssertPtr(pfnWrite);
|
---|
701 | AssertPtrNull(ppfnReadOld);
|
---|
702 | AssertPtrNull(ppfnWriteOld);
|
---|
703 | AssertPtrNull(pPciDev);
|
---|
704 |
|
---|
705 | if (!pPciDev)
|
---|
706 | pPciDev = pDevIns->Internal.s.pPciDeviceR3;
|
---|
707 | AssertReleaseMsg(pPciDev, ("You must register your device first!\n"));
|
---|
708 | PPDMPCIBUS pBus = pDevIns->Internal.s.pPciBusR3;
|
---|
709 | AssertRelease(pBus);
|
---|
710 | AssertRelease(VMR3GetState(pVM) != VMSTATE_RUNNING);
|
---|
711 |
|
---|
712 | /*
|
---|
713 | * Do the job.
|
---|
714 | */
|
---|
715 | pdmLock(pVM);
|
---|
716 | pBus->pfnSetConfigCallbacksR3(pBus->pDevInsR3, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld);
|
---|
717 | pdmUnlock(pVM);
|
---|
718 |
|
---|
719 | LogFlow(("pdmR3DevHlp_PCISetConfigCallbacks: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
720 | }
|
---|
721 |
|
---|
722 |
|
---|
723 | /** @copydoc PDMDEVHLPR3::pfnPCISetIrq */
|
---|
724 | static DECLCALLBACK(void) pdmR3DevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
|
---|
725 | {
|
---|
726 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
727 | LogFlow(("pdmR3DevHlp_PCISetIrq: caller='%s'/%d: iIrq=%d iLevel=%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iIrq, iLevel));
|
---|
728 |
|
---|
729 | /*
|
---|
730 | * Validate input.
|
---|
731 | */
|
---|
732 | /** @todo iIrq and iLevel checks. */
|
---|
733 |
|
---|
734 | /*
|
---|
735 | * Must have a PCI device registered!
|
---|
736 | */
|
---|
737 | PPCIDEVICE pPciDev = pDevIns->Internal.s.pPciDeviceR3;
|
---|
738 | if (pPciDev)
|
---|
739 | {
|
---|
740 | PPDMPCIBUS pBus = pDevIns->Internal.s.pPciBusR3; /** @todo the bus should be associated with the PCI device not the PDM device. */
|
---|
741 | Assert(pBus);
|
---|
742 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
743 | pdmLock(pVM);
|
---|
744 | pBus->pfnSetIrqR3(pBus->pDevInsR3, pPciDev, iIrq, iLevel);
|
---|
745 | pdmUnlock(pVM);
|
---|
746 | }
|
---|
747 | else
|
---|
748 | AssertReleaseMsgFailed(("No PCI device registered!\n"));
|
---|
749 |
|
---|
750 | LogFlow(("pdmR3DevHlp_PCISetIrq: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
751 | }
|
---|
752 |
|
---|
753 |
|
---|
754 | /** @copydoc PDMDEVHLPR3::pfnPCISetIrqNoWait */
|
---|
755 | static DECLCALLBACK(void) pdmR3DevHlp_PCISetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
|
---|
756 | {
|
---|
757 | pdmR3DevHlp_PCISetIrq(pDevIns, iIrq, iLevel);
|
---|
758 | }
|
---|
759 |
|
---|
760 |
|
---|
761 | /** @copydoc PDMDEVHLPR3::pfnISASetIrq */
|
---|
762 | static DECLCALLBACK(void) pdmR3DevHlp_ISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
|
---|
763 | {
|
---|
764 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
765 | LogFlow(("pdmR3DevHlp_ISASetIrq: caller='%s'/%d: iIrq=%d iLevel=%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iIrq, iLevel));
|
---|
766 |
|
---|
767 | /*
|
---|
768 | * Validate input.
|
---|
769 | */
|
---|
770 | /** @todo iIrq and iLevel checks. */
|
---|
771 |
|
---|
772 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
773 | PDMIsaSetIrq(pVM, iIrq, iLevel); /* (The API takes the lock.) */
|
---|
774 |
|
---|
775 | LogFlow(("pdmR3DevHlp_ISASetIrq: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
776 | }
|
---|
777 |
|
---|
778 |
|
---|
779 | /** @copydoc PDMDEVHLPR3::pfnISASetIrqNoWait */
|
---|
780 | static DECLCALLBACK(void) pdmR3DevHlp_ISASetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
|
---|
781 | {
|
---|
782 | pdmR3DevHlp_ISASetIrq(pDevIns, iIrq, iLevel);
|
---|
783 | }
|
---|
784 |
|
---|
785 |
|
---|
786 | /** @copydoc PDMDEVHLPR3::pfnDriverAttach */
|
---|
787 | static DECLCALLBACK(int) pdmR3DevHlp_DriverAttach(PPDMDEVINS pDevIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
|
---|
788 | {
|
---|
789 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
790 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
791 | VM_ASSERT_EMT(pVM);
|
---|
792 | LogFlow(("pdmR3DevHlp_DriverAttach: caller='%s'/%d: iLun=%d pBaseInterface=%p ppBaseInterface=%p pszDesc=%p:{%s}\n",
|
---|
793 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iLun, pBaseInterface, ppBaseInterface, pszDesc, pszDesc));
|
---|
794 |
|
---|
795 | /*
|
---|
796 | * Lookup the LUN, it might already be registered.
|
---|
797 | */
|
---|
798 | PPDMLUN pLunPrev = NULL;
|
---|
799 | PPDMLUN pLun = pDevIns->Internal.s.pLunsR3;
|
---|
800 | for (; pLun; pLunPrev = pLun, pLun = pLun->pNext)
|
---|
801 | if (pLun->iLun == iLun)
|
---|
802 | break;
|
---|
803 |
|
---|
804 | /*
|
---|
805 | * Create the LUN if if wasn't found, else check if driver is already attached to it.
|
---|
806 | */
|
---|
807 | if (!pLun)
|
---|
808 | {
|
---|
809 | if ( !pBaseInterface
|
---|
810 | || !pszDesc
|
---|
811 | || !*pszDesc)
|
---|
812 | {
|
---|
813 | Assert(pBaseInterface);
|
---|
814 | Assert(pszDesc || *pszDesc);
|
---|
815 | return VERR_INVALID_PARAMETER;
|
---|
816 | }
|
---|
817 |
|
---|
818 | pLun = (PPDMLUN)MMR3HeapAlloc(pVM, MM_TAG_PDM_LUN, sizeof(*pLun));
|
---|
819 | if (!pLun)
|
---|
820 | return VERR_NO_MEMORY;
|
---|
821 |
|
---|
822 | pLun->iLun = iLun;
|
---|
823 | pLun->pNext = pLunPrev ? pLunPrev->pNext : NULL;
|
---|
824 | pLun->pTop = NULL;
|
---|
825 | pLun->pBottom = NULL;
|
---|
826 | pLun->pDevIns = pDevIns;
|
---|
827 | pLun->pszDesc = pszDesc;
|
---|
828 | pLun->pBase = pBaseInterface;
|
---|
829 | if (!pLunPrev)
|
---|
830 | pDevIns->Internal.s.pLunsR3 = pLun;
|
---|
831 | else
|
---|
832 | pLunPrev->pNext = pLun;
|
---|
833 | Log(("pdmR3DevHlp_DriverAttach: Registered LUN#%d '%s' with device '%s'/%d.\n",
|
---|
834 | iLun, pszDesc, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
835 | }
|
---|
836 | else if (pLun->pTop)
|
---|
837 | {
|
---|
838 | AssertMsgFailed(("Already attached! The device should keep track of such things!\n"));
|
---|
839 | LogFlow(("pdmR3DevHlp_DriverAttach: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_PDM_DRIVER_ALREADY_ATTACHED));
|
---|
840 | return VERR_PDM_DRIVER_ALREADY_ATTACHED;
|
---|
841 | }
|
---|
842 | Assert(pLun->pBase == pBaseInterface);
|
---|
843 |
|
---|
844 |
|
---|
845 | /*
|
---|
846 | * Get the attached driver configuration.
|
---|
847 | */
|
---|
848 | int rc;
|
---|
849 | char szNode[48];
|
---|
850 | RTStrPrintf(szNode, sizeof(szNode), "LUN#%d", iLun);
|
---|
851 | PCFGMNODE pNode = CFGMR3GetChild(pDevIns->Internal.s.pCfgHandle, szNode);
|
---|
852 | if (pNode)
|
---|
853 | {
|
---|
854 | char *pszName;
|
---|
855 | rc = CFGMR3QueryStringAlloc(pNode, "Driver", &pszName);
|
---|
856 | if (RT_SUCCESS(rc))
|
---|
857 | {
|
---|
858 | /*
|
---|
859 | * Find the driver.
|
---|
860 | */
|
---|
861 | PPDMDRV pDrv = pdmR3DrvLookup(pVM, pszName);
|
---|
862 | if (pDrv)
|
---|
863 | {
|
---|
864 | /* config node */
|
---|
865 | PCFGMNODE pConfigNode = CFGMR3GetChild(pNode, "Config");
|
---|
866 | if (!pConfigNode)
|
---|
867 | rc = CFGMR3InsertNode(pNode, "Config", &pConfigNode);
|
---|
868 | if (RT_SUCCESS(rc))
|
---|
869 | {
|
---|
870 | CFGMR3SetRestrictedRoot(pConfigNode);
|
---|
871 |
|
---|
872 | /*
|
---|
873 | * Allocate the driver instance.
|
---|
874 | */
|
---|
875 | size_t cb = RT_OFFSETOF(PDMDRVINS, achInstanceData[pDrv->pDrvReg->cbInstance]);
|
---|
876 | cb = RT_ALIGN_Z(cb, 16);
|
---|
877 | PPDMDRVINS pNew = (PPDMDRVINS)MMR3HeapAllocZ(pVM, MM_TAG_PDM_DRIVER, cb);
|
---|
878 | if (pNew)
|
---|
879 | {
|
---|
880 | /*
|
---|
881 | * Initialize the instance structure (declaration order).
|
---|
882 | */
|
---|
883 | pNew->u32Version = PDM_DRVINS_VERSION;
|
---|
884 | //pNew->Internal.s.pUp = NULL;
|
---|
885 | //pNew->Internal.s.pDown = NULL;
|
---|
886 | pNew->Internal.s.pLun = pLun;
|
---|
887 | pNew->Internal.s.pDrv = pDrv;
|
---|
888 | pNew->Internal.s.pVM = pVM;
|
---|
889 | //pNew->Internal.s.fDetaching = false;
|
---|
890 | pNew->Internal.s.pCfgHandle = pNode;
|
---|
891 | pNew->pDrvHlp = &g_pdmR3DrvHlp;
|
---|
892 | pNew->pDrvReg = pDrv->pDrvReg;
|
---|
893 | pNew->pCfgHandle = pConfigNode;
|
---|
894 | pNew->iInstance = pDrv->cInstances++;
|
---|
895 | pNew->pUpBase = pBaseInterface;
|
---|
896 | //pNew->pDownBase = NULL;
|
---|
897 | //pNew->IBase.pfnQueryInterface = NULL;
|
---|
898 | pNew->pvInstanceData = &pNew->achInstanceData[0];
|
---|
899 |
|
---|
900 | /*
|
---|
901 | * Link with LUN and call the constructor.
|
---|
902 | */
|
---|
903 | pLun->pTop = pLun->pBottom = pNew;
|
---|
904 | rc = pDrv->pDrvReg->pfnConstruct(pNew, pNew->pCfgHandle, 0 /*fFlags*/);
|
---|
905 | if (RT_SUCCESS(rc))
|
---|
906 | {
|
---|
907 | MMR3HeapFree(pszName);
|
---|
908 | *ppBaseInterface = &pNew->IBase;
|
---|
909 | Log(("PDM: Attached driver '%s'/%d to LUN#%d on device '%s'/%d.\n",
|
---|
910 | pDrv->pDrvReg->szDriverName, pNew->iInstance, iLun, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
911 | LogFlow(("pdmR3DevHlp_DriverAttach: caller '%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VINF_SUCCESS));
|
---|
912 |
|
---|
913 | return rc; /* Might return != VINF_SUCCESS (e.g. VINF_NAT_DNS). */
|
---|
914 | }
|
---|
915 |
|
---|
916 | /*
|
---|
917 | * Free the driver.
|
---|
918 | */
|
---|
919 | pLun->pTop = pLun->pBottom = NULL;
|
---|
920 | ASMMemFill32(pNew, cb, 0xdeadd0d0);
|
---|
921 | MMR3HeapFree(pNew);
|
---|
922 | pDrv->cInstances--;
|
---|
923 | }
|
---|
924 | else
|
---|
925 | {
|
---|
926 | AssertMsgFailed(("Failed to allocate %d bytes for instantiating driver '%s'\n", cb, pszName));
|
---|
927 | rc = VERR_NO_MEMORY;
|
---|
928 | }
|
---|
929 | }
|
---|
930 | else
|
---|
931 | AssertMsgFailed(("Failed to create Config node! rc=%Rrc\n", rc));
|
---|
932 | }
|
---|
933 | else
|
---|
934 | {
|
---|
935 | AssertMsgFailed(("Driver '%s' wasn't found!\n", pszName));
|
---|
936 | rc = VERR_PDM_DRIVER_NOT_FOUND;
|
---|
937 | }
|
---|
938 | MMR3HeapFree(pszName);
|
---|
939 | }
|
---|
940 | else
|
---|
941 | {
|
---|
942 | AssertMsgFailed(("Query for string value of \"Driver\" -> %Rrc\n", rc));
|
---|
943 | if (rc == VERR_CFGM_VALUE_NOT_FOUND)
|
---|
944 | rc = VERR_PDM_CFG_MISSING_DRIVER_NAME;
|
---|
945 | }
|
---|
946 | }
|
---|
947 | else
|
---|
948 | rc = VERR_PDM_NO_ATTACHED_DRIVER;
|
---|
949 |
|
---|
950 |
|
---|
951 | LogFlow(("pdmR3DevHlp_DriverAttach: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
952 | return rc;
|
---|
953 | }
|
---|
954 |
|
---|
955 |
|
---|
956 | /** @copydoc PDMDEVHLPR3::pfnMMHeapAlloc */
|
---|
957 | static DECLCALLBACK(void *) pdmR3DevHlp_MMHeapAlloc(PPDMDEVINS pDevIns, size_t cb)
|
---|
958 | {
|
---|
959 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
960 | LogFlow(("pdmR3DevHlp_MMHeapAlloc: caller='%s'/%d: cb=%#x\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cb));
|
---|
961 |
|
---|
962 | void *pv = MMR3HeapAlloc(pDevIns->Internal.s.pVMR3, MM_TAG_PDM_DEVICE_USER, cb);
|
---|
963 |
|
---|
964 | LogFlow(("pdmR3DevHlp_MMHeapAlloc: caller='%s'/%d: returns %p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pv));
|
---|
965 | return pv;
|
---|
966 | }
|
---|
967 |
|
---|
968 |
|
---|
969 | /** @copydoc PDMDEVHLPR3::pfnMMHeapAllocZ */
|
---|
970 | static DECLCALLBACK(void *) pdmR3DevHlp_MMHeapAllocZ(PPDMDEVINS pDevIns, size_t cb)
|
---|
971 | {
|
---|
972 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
973 | LogFlow(("pdmR3DevHlp_MMHeapAllocZ: caller='%s'/%d: cb=%#x\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cb));
|
---|
974 |
|
---|
975 | void *pv = MMR3HeapAllocZ(pDevIns->Internal.s.pVMR3, MM_TAG_PDM_DEVICE_USER, cb);
|
---|
976 |
|
---|
977 | LogFlow(("pdmR3DevHlp_MMHeapAllocZ: caller='%s'/%d: returns %p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pv));
|
---|
978 | return pv;
|
---|
979 | }
|
---|
980 |
|
---|
981 |
|
---|
982 | /** @copydoc PDMDEVHLPR3::pfnMMHeapFree */
|
---|
983 | static DECLCALLBACK(void) pdmR3DevHlp_MMHeapFree(PPDMDEVINS pDevIns, void *pv)
|
---|
984 | {
|
---|
985 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
986 | LogFlow(("pdmR3DevHlp_MMHeapFree: caller='%s'/%d: pv=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pv));
|
---|
987 |
|
---|
988 | MMR3HeapFree(pv);
|
---|
989 |
|
---|
990 | LogFlow(("pdmR3DevHlp_MMHeapAlloc: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
991 | }
|
---|
992 |
|
---|
993 |
|
---|
994 | /** @copydoc PDMDEVHLPR3::pfnVMSetError */
|
---|
995 | static DECLCALLBACK(int) pdmR3DevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
|
---|
996 | {
|
---|
997 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
998 | va_list args;
|
---|
999 | va_start(args, pszFormat);
|
---|
1000 | int rc2 = VMSetErrorV(pDevIns->Internal.s.pVMR3, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
|
---|
1001 | va_end(args);
|
---|
1002 | return rc;
|
---|
1003 | }
|
---|
1004 |
|
---|
1005 |
|
---|
1006 | /** @copydoc PDMDEVHLPR3::pfnVMSetErrorV */
|
---|
1007 | static DECLCALLBACK(int) pdmR3DevHlp_VMSetErrorV(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
|
---|
1008 | {
|
---|
1009 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1010 | int rc2 = VMSetErrorV(pDevIns->Internal.s.pVMR3, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
|
---|
1011 | return rc;
|
---|
1012 | }
|
---|
1013 |
|
---|
1014 |
|
---|
1015 | /** @copydoc PDMDEVHLPR3::pfnVMSetRuntimeError */
|
---|
1016 | static DECLCALLBACK(int) pdmR3DevHlp_VMSetRuntimeError(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
|
---|
1017 | {
|
---|
1018 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1019 | va_list args;
|
---|
1020 | va_start(args, pszFormat);
|
---|
1021 | int rc = VMSetRuntimeErrorV(pDevIns->Internal.s.pVMR3, fFlags, pszErrorId, pszFormat, args);
|
---|
1022 | va_end(args);
|
---|
1023 | return rc;
|
---|
1024 | }
|
---|
1025 |
|
---|
1026 |
|
---|
1027 | /** @copydoc PDMDEVHLPR3::pfnVMSetRuntimeErrorV */
|
---|
1028 | static DECLCALLBACK(int) pdmR3DevHlp_VMSetRuntimeErrorV(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
|
---|
1029 | {
|
---|
1030 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1031 | int rc = VMSetRuntimeErrorV(pDevIns->Internal.s.pVMR3, fFlags, pszErrorId, pszFormat, va);
|
---|
1032 | return rc;
|
---|
1033 | }
|
---|
1034 |
|
---|
1035 |
|
---|
1036 | /** @copydoc PDMDEVHLPR3::pfnAssertEMT */
|
---|
1037 | static DECLCALLBACK(bool) pdmR3DevHlp_AssertEMT(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction)
|
---|
1038 | {
|
---|
1039 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1040 | if (VM_IS_EMT(pDevIns->Internal.s.pVMR3))
|
---|
1041 | return true;
|
---|
1042 |
|
---|
1043 | char szMsg[100];
|
---|
1044 | RTStrPrintf(szMsg, sizeof(szMsg), "AssertEMT '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance);
|
---|
1045 | AssertMsg1(szMsg, iLine, pszFile, pszFunction);
|
---|
1046 | AssertBreakpoint();
|
---|
1047 | return false;
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 |
|
---|
1051 | /** @copydoc PDMDEVHLPR3::pfnAssertOther */
|
---|
1052 | static DECLCALLBACK(bool) pdmR3DevHlp_AssertOther(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction)
|
---|
1053 | {
|
---|
1054 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1055 | if (!VM_IS_EMT(pDevIns->Internal.s.pVMR3))
|
---|
1056 | return true;
|
---|
1057 |
|
---|
1058 | char szMsg[100];
|
---|
1059 | RTStrPrintf(szMsg, sizeof(szMsg), "AssertOther '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance);
|
---|
1060 | AssertMsg1(szMsg, iLine, pszFile, pszFunction);
|
---|
1061 | AssertBreakpoint();
|
---|
1062 | return false;
|
---|
1063 | }
|
---|
1064 |
|
---|
1065 |
|
---|
1066 | /** @copydoc PDMDEVHLPR3::pfnDBGFStopV */
|
---|
1067 | static DECLCALLBACK(int) pdmR3DevHlp_DBGFStopV(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction, const char *pszFormat, va_list args)
|
---|
1068 | {
|
---|
1069 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1070 | #ifdef LOG_ENABLED
|
---|
1071 | va_list va2;
|
---|
1072 | va_copy(va2, args);
|
---|
1073 | LogFlow(("pdmR3DevHlp_DBGFStopV: caller='%s'/%d: pszFile=%p:{%s} iLine=%d pszFunction=%p:{%s} pszFormat=%p:{%s} (%N)\n",
|
---|
1074 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pszFile, pszFile, iLine, pszFunction, pszFunction, pszFormat, pszFormat, pszFormat, &va2));
|
---|
1075 | va_end(va2);
|
---|
1076 | #endif
|
---|
1077 |
|
---|
1078 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
1079 | VM_ASSERT_EMT(pVM);
|
---|
1080 | int rc = DBGFR3EventSrcV(pVM, DBGFEVENT_DEV_STOP, pszFile, iLine, pszFunction, pszFormat, args);
|
---|
1081 |
|
---|
1082 | LogFlow(("pdmR3DevHlp_DBGFStopV: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1083 | return rc;
|
---|
1084 | }
|
---|
1085 |
|
---|
1086 |
|
---|
1087 | /** @copydoc PDMDEVHLPR3::pfnDBGFInfoRegister */
|
---|
1088 | static DECLCALLBACK(int) pdmR3DevHlp_DBGFInfoRegister(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler)
|
---|
1089 | {
|
---|
1090 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1091 | LogFlow(("pdmR3DevHlp_DBGFInfoRegister: caller='%s'/%d: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p\n",
|
---|
1092 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pszName, pszName, pszDesc, pszDesc, pfnHandler));
|
---|
1093 |
|
---|
1094 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
1095 | VM_ASSERT_EMT(pVM);
|
---|
1096 | int rc = DBGFR3InfoRegisterDevice(pVM, pszName, pszDesc, pfnHandler, pDevIns);
|
---|
1097 |
|
---|
1098 | LogFlow(("pdmR3DevHlp_DBGFInfoRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1099 | return rc;
|
---|
1100 | }
|
---|
1101 |
|
---|
1102 |
|
---|
1103 | /** @copydoc PDMDEVHLPR3::pfnSTAMRegister */
|
---|
1104 | static DECLCALLBACK(void) pdmR3DevHlp_STAMRegister(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
|
---|
1105 | {
|
---|
1106 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1107 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
1108 | VM_ASSERT_EMT(pVM);
|
---|
1109 |
|
---|
1110 | STAM_REG(pVM, pvSample, enmType, pszName, enmUnit, pszDesc);
|
---|
1111 | NOREF(pVM);
|
---|
1112 | }
|
---|
1113 |
|
---|
1114 |
|
---|
1115 |
|
---|
1116 | /** @copydoc PDMDEVHLPR3::pfnSTAMRegisterF */
|
---|
1117 | static DECLCALLBACK(void) pdmR3DevHlp_STAMRegisterF(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
|
---|
1118 | STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...)
|
---|
1119 | {
|
---|
1120 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1121 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
1122 | VM_ASSERT_EMT(pVM);
|
---|
1123 |
|
---|
1124 | va_list args;
|
---|
1125 | va_start(args, pszName);
|
---|
1126 | int rc = STAMR3RegisterV(pVM, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);
|
---|
1127 | va_end(args);
|
---|
1128 | AssertRC(rc);
|
---|
1129 |
|
---|
1130 | NOREF(pVM);
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 |
|
---|
1134 | /** @copydoc PDMDEVHLPR3::pfnSTAMRegisterV */
|
---|
1135 | static DECLCALLBACK(void) pdmR3DevHlp_STAMRegisterV(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
|
---|
1136 | STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args)
|
---|
1137 | {
|
---|
1138 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1139 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
1140 | VM_ASSERT_EMT(pVM);
|
---|
1141 |
|
---|
1142 | int rc = STAMR3RegisterV(pVM, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);
|
---|
1143 | AssertRC(rc);
|
---|
1144 |
|
---|
1145 | NOREF(pVM);
|
---|
1146 | }
|
---|
1147 |
|
---|
1148 |
|
---|
1149 | /** @copydoc PDMDEVHLPR3::pfnRTCRegister */
|
---|
1150 | static DECLCALLBACK(int) pdmR3DevHlp_RTCRegister(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp)
|
---|
1151 | {
|
---|
1152 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1153 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
1154 | LogFlow(("pdmR3DevHlp_RTCRegister: caller='%s'/%d: pRtcReg=%p:{.u32Version=%#x, .pfnWrite=%p, .pfnRead=%p} ppRtcHlp=%p\n",
|
---|
1155 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pRtcReg, pRtcReg->u32Version, pRtcReg->pfnWrite,
|
---|
1156 | pRtcReg->pfnWrite, ppRtcHlp));
|
---|
1157 |
|
---|
1158 | /*
|
---|
1159 | * Validate input.
|
---|
1160 | */
|
---|
1161 | if (pRtcReg->u32Version != PDM_RTCREG_VERSION)
|
---|
1162 | {
|
---|
1163 | AssertMsgFailed(("u32Version=%#x expected %#x\n", pRtcReg->u32Version,
|
---|
1164 | PDM_RTCREG_VERSION));
|
---|
1165 | LogFlow(("pdmR3DevHlp_RTCRegister: caller='%s'/%d: returns %Rrc (version)\n",
|
---|
1166 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1167 | return VERR_INVALID_PARAMETER;
|
---|
1168 | }
|
---|
1169 | if ( !pRtcReg->pfnWrite
|
---|
1170 | || !pRtcReg->pfnRead)
|
---|
1171 | {
|
---|
1172 | Assert(pRtcReg->pfnWrite);
|
---|
1173 | Assert(pRtcReg->pfnRead);
|
---|
1174 | LogFlow(("pdmR3DevHlp_RTCRegister: caller='%s'/%d: returns %Rrc (callbacks)\n",
|
---|
1175 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1176 | return VERR_INVALID_PARAMETER;
|
---|
1177 | }
|
---|
1178 |
|
---|
1179 | if (!ppRtcHlp)
|
---|
1180 | {
|
---|
1181 | Assert(ppRtcHlp);
|
---|
1182 | LogFlow(("pdmR3DevHlp_RTCRegister: caller='%s'/%d: returns %Rrc (ppRtcHlp)\n",
|
---|
1183 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1184 | return VERR_INVALID_PARAMETER;
|
---|
1185 | }
|
---|
1186 |
|
---|
1187 | /*
|
---|
1188 | * Only one DMA device.
|
---|
1189 | */
|
---|
1190 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
1191 | if (pVM->pdm.s.pRtc)
|
---|
1192 | {
|
---|
1193 | AssertMsgFailed(("Only one RTC device is supported!\n"));
|
---|
1194 | LogFlow(("pdmR3DevHlp_RTCRegister: caller='%s'/%d: returns %Rrc\n",
|
---|
1195 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1196 | return VERR_INVALID_PARAMETER;
|
---|
1197 | }
|
---|
1198 |
|
---|
1199 | /*
|
---|
1200 | * Allocate and initialize pci bus structure.
|
---|
1201 | */
|
---|
1202 | int rc = VINF_SUCCESS;
|
---|
1203 | PPDMRTC pRtc = (PPDMRTC)MMR3HeapAlloc(pDevIns->Internal.s.pVMR3, MM_TAG_PDM_DEVICE, sizeof(*pRtc));
|
---|
1204 | if (pRtc)
|
---|
1205 | {
|
---|
1206 | pRtc->pDevIns = pDevIns;
|
---|
1207 | pRtc->Reg = *pRtcReg;
|
---|
1208 | pVM->pdm.s.pRtc = pRtc;
|
---|
1209 |
|
---|
1210 | /* set the helper pointer. */
|
---|
1211 | *ppRtcHlp = &g_pdmR3DevRtcHlp;
|
---|
1212 | Log(("PDM: Registered RTC device '%s'/%d pDevIns=%p\n",
|
---|
1213 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns));
|
---|
1214 | }
|
---|
1215 | else
|
---|
1216 | rc = VERR_NO_MEMORY;
|
---|
1217 |
|
---|
1218 | LogFlow(("pdmR3DevHlp_RTCRegister: caller='%s'/%d: returns %Rrc\n",
|
---|
1219 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1220 | return rc;
|
---|
1221 | }
|
---|
1222 |
|
---|
1223 |
|
---|
1224 | /** @copydoc PDMDEVHLPR3::pfnPDMQueueCreate */
|
---|
1225 | static DECLCALLBACK(int) pdmR3DevHlp_PDMQueueCreate(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
|
---|
1226 | PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, const char *pszName, PPDMQUEUE *ppQueue)
|
---|
1227 | {
|
---|
1228 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1229 | LogFlow(("pdmR3DevHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%#x cItems=%#x cMilliesInterval=%u pfnCallback=%p fGCEnabled=%RTbool pszName=%p:{%s} ppQueue=%p\n",
|
---|
1230 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, pszName, pszName, ppQueue));
|
---|
1231 |
|
---|
1232 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
1233 | VM_ASSERT_EMT(pVM);
|
---|
1234 |
|
---|
1235 | if (pDevIns->iInstance > 0)
|
---|
1236 | {
|
---|
1237 | pszName = MMR3HeapAPrintf(pVM, MM_TAG_PDM_DEVICE_DESC, "%s_%u", pszName, pDevIns->iInstance);
|
---|
1238 | AssertLogRelReturn(pszName, VERR_NO_MEMORY);
|
---|
1239 | }
|
---|
1240 |
|
---|
1241 | int rc = PDMR3QueueCreateDevice(pVM, pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, pszName, ppQueue);
|
---|
1242 |
|
---|
1243 | LogFlow(("pdmR3DevHlp_PDMQueueCreate: caller='%s'/%d: returns %Rrc *ppQueue=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc, *ppQueue));
|
---|
1244 | return rc;
|
---|
1245 | }
|
---|
1246 |
|
---|
1247 |
|
---|
1248 | /** @copydoc PDMDEVHLPR3::pfnCritSectInit */
|
---|
1249 | static DECLCALLBACK(int) pdmR3DevHlp_CritSectInit(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName)
|
---|
1250 | {
|
---|
1251 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1252 | LogFlow(("pdmR3DevHlp_CritSectInit: caller='%s'/%d: pCritSect=%p pszName=%p:{%s}\n",
|
---|
1253 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pCritSect, pszName, pszName));
|
---|
1254 |
|
---|
1255 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
1256 | VM_ASSERT_EMT(pVM);
|
---|
1257 | int rc = pdmR3CritSectInitDevice(pVM, pDevIns, pCritSect, pszName);
|
---|
1258 |
|
---|
1259 | LogFlow(("pdmR3DevHlp_CritSectInit: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1260 | return rc;
|
---|
1261 | }
|
---|
1262 |
|
---|
1263 |
|
---|
1264 | /** @copydoc PDMDEVHLPR3::pfnUTCNow */
|
---|
1265 | static DECLCALLBACK(PRTTIMESPEC) pdmR3DevHlp_UTCNow(PPDMDEVINS pDevIns, PRTTIMESPEC pTime)
|
---|
1266 | {
|
---|
1267 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1268 | LogFlow(("pdmR3DevHlp_UTCNow: caller='%s'/%d: pTime=%p\n",
|
---|
1269 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pTime));
|
---|
1270 |
|
---|
1271 | pTime = TMR3UTCNow(pDevIns->Internal.s.pVMR3, pTime);
|
---|
1272 |
|
---|
1273 | LogFlow(("pdmR3DevHlp_UTCNow: caller='%s'/%d: returns %RU64\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, RTTimeSpecGetNano(pTime)));
|
---|
1274 | return pTime;
|
---|
1275 | }
|
---|
1276 |
|
---|
1277 |
|
---|
1278 | /** @copydoc PDMDEVHLPR3::pfnPDMThreadCreate */
|
---|
1279 | static DECLCALLBACK(int) pdmR3DevHlp_PDMThreadCreate(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
|
---|
1280 | PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
|
---|
1281 | {
|
---|
1282 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1283 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
1284 | LogFlow(("pdmR3DevHlp_PDMThreadCreate: caller='%s'/%d: ppThread=%p pvUser=%p pfnThread=%p pfnWakeup=%p cbStack=%#zx enmType=%d pszName=%p:{%s}\n",
|
---|
1285 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName, pszName));
|
---|
1286 |
|
---|
1287 | int rc = pdmR3ThreadCreateDevice(pDevIns->Internal.s.pVMR3, pDevIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
|
---|
1288 |
|
---|
1289 | LogFlow(("pdmR3DevHlp_PDMThreadCreate: caller='%s'/%d: returns %Rrc *ppThread=%RTthrd\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance,
|
---|
1290 | rc, *ppThread));
|
---|
1291 | return rc;
|
---|
1292 | }
|
---|
1293 |
|
---|
1294 |
|
---|
1295 | /** @copydoc PDMDEVHLPR3::pfnGetVM */
|
---|
1296 | static DECLCALLBACK(PVM) pdmR3DevHlp_GetVM(PPDMDEVINS pDevIns)
|
---|
1297 | {
|
---|
1298 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1299 | LogFlow(("pdmR3DevHlp_GetVM: caller='%s'/%d: returns %p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns->Internal.s.pVMR3));
|
---|
1300 | return pDevIns->Internal.s.pVMR3;
|
---|
1301 | }
|
---|
1302 |
|
---|
1303 |
|
---|
1304 | /** @copydoc PDMDEVHLPR3::pfnGetVMCPU */
|
---|
1305 | static DECLCALLBACK(PVMCPU) pdmR3DevHlp_GetVMCPU(PPDMDEVINS pDevIns)
|
---|
1306 | {
|
---|
1307 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1308 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
1309 | LogFlow(("pdmR3DevHlp_GetVMCPU: caller='%s'/%d for CPU %u\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VMMGetCpuId(pDevIns->Internal.s.pVMR3)));
|
---|
1310 | return VMMGetCpu(pDevIns->Internal.s.pVMR3);
|
---|
1311 | }
|
---|
1312 |
|
---|
1313 |
|
---|
1314 | /** @copydoc PDMDEVHLPR3::pfnPCIBusRegister */
|
---|
1315 | static DECLCALLBACK(int) pdmR3DevHlp_PCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3)
|
---|
1316 | {
|
---|
1317 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1318 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
1319 | VM_ASSERT_EMT(pVM);
|
---|
1320 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: pPciBusReg=%p:{.u32Version=%#x, .pfnRegisterR3=%p, .pfnIORegionRegisterR3=%p, .pfnSetIrqR3=%p, "
|
---|
1321 | ".pfnSaveExecR3=%p, .pfnLoadExecR3=%p, .pfnFakePCIBIOSR3=%p, .pszSetIrqRC=%p:{%s}, .pszSetIrqR0=%p:{%s}} ppPciHlpR3=%p\n",
|
---|
1322 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pPciBusReg, pPciBusReg->u32Version, pPciBusReg->pfnRegisterR3,
|
---|
1323 | pPciBusReg->pfnIORegionRegisterR3, pPciBusReg->pfnSetIrqR3, pPciBusReg->pfnSaveExecR3, pPciBusReg->pfnLoadExecR3,
|
---|
1324 | pPciBusReg->pfnFakePCIBIOSR3, pPciBusReg->pszSetIrqRC, pPciBusReg->pszSetIrqRC, pPciBusReg->pszSetIrqR0, pPciBusReg->pszSetIrqR0, ppPciHlpR3));
|
---|
1325 |
|
---|
1326 | /*
|
---|
1327 | * Validate the structure.
|
---|
1328 | */
|
---|
1329 | if (pPciBusReg->u32Version != PDM_PCIBUSREG_VERSION)
|
---|
1330 | {
|
---|
1331 | AssertMsgFailed(("u32Version=%#x expected %#x\n", pPciBusReg->u32Version, PDM_PCIBUSREG_VERSION));
|
---|
1332 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Rrc (version)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1333 | return VERR_INVALID_PARAMETER;
|
---|
1334 | }
|
---|
1335 | if ( !pPciBusReg->pfnRegisterR3
|
---|
1336 | || !pPciBusReg->pfnIORegionRegisterR3
|
---|
1337 | || !pPciBusReg->pfnSetIrqR3
|
---|
1338 | || !pPciBusReg->pfnSaveExecR3
|
---|
1339 | || !pPciBusReg->pfnLoadExecR3
|
---|
1340 | || (!pPciBusReg->pfnFakePCIBIOSR3 && !pVM->pdm.s.aPciBuses[0].pDevInsR3)) /* Only the first bus needs to do the BIOS work. */
|
---|
1341 | {
|
---|
1342 | Assert(pPciBusReg->pfnRegisterR3);
|
---|
1343 | Assert(pPciBusReg->pfnIORegionRegisterR3);
|
---|
1344 | Assert(pPciBusReg->pfnSetIrqR3);
|
---|
1345 | Assert(pPciBusReg->pfnSaveExecR3);
|
---|
1346 | Assert(pPciBusReg->pfnLoadExecR3);
|
---|
1347 | Assert(pPciBusReg->pfnFakePCIBIOSR3);
|
---|
1348 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Rrc (R3 callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1349 | return VERR_INVALID_PARAMETER;
|
---|
1350 | }
|
---|
1351 | if ( pPciBusReg->pszSetIrqRC
|
---|
1352 | && !VALID_PTR(pPciBusReg->pszSetIrqRC))
|
---|
1353 | {
|
---|
1354 | Assert(VALID_PTR(pPciBusReg->pszSetIrqRC));
|
---|
1355 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Rrc (GC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1356 | return VERR_INVALID_PARAMETER;
|
---|
1357 | }
|
---|
1358 | if ( pPciBusReg->pszSetIrqR0
|
---|
1359 | && !VALID_PTR(pPciBusReg->pszSetIrqR0))
|
---|
1360 | {
|
---|
1361 | Assert(VALID_PTR(pPciBusReg->pszSetIrqR0));
|
---|
1362 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Rrc (GC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1363 | return VERR_INVALID_PARAMETER;
|
---|
1364 | }
|
---|
1365 | if (!ppPciHlpR3)
|
---|
1366 | {
|
---|
1367 | Assert(ppPciHlpR3);
|
---|
1368 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Rrc (ppPciHlpR3)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1369 | return VERR_INVALID_PARAMETER;
|
---|
1370 | }
|
---|
1371 |
|
---|
1372 | /*
|
---|
1373 | * Find free PCI bus entry.
|
---|
1374 | */
|
---|
1375 | unsigned iBus = 0;
|
---|
1376 | for (iBus = 0; iBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses); iBus++)
|
---|
1377 | if (!pVM->pdm.s.aPciBuses[iBus].pDevInsR3)
|
---|
1378 | break;
|
---|
1379 | if (iBus >= RT_ELEMENTS(pVM->pdm.s.aPciBuses))
|
---|
1380 | {
|
---|
1381 | AssertMsgFailed(("Too many PCI buses. Max=%u\n", RT_ELEMENTS(pVM->pdm.s.aPciBuses)));
|
---|
1382 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Rrc (pci bus)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1383 | return VERR_INVALID_PARAMETER;
|
---|
1384 | }
|
---|
1385 | PPDMPCIBUS pPciBus = &pVM->pdm.s.aPciBuses[iBus];
|
---|
1386 |
|
---|
1387 | /*
|
---|
1388 | * Resolve and init the RC bits.
|
---|
1389 | */
|
---|
1390 | if (pPciBusReg->pszSetIrqRC)
|
---|
1391 | {
|
---|
1392 | int rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pPciBusReg->pszSetIrqRC, &pPciBus->pfnSetIrqRC);
|
---|
1393 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szRCMod, pPciBusReg->pszSetIrqRC, rc));
|
---|
1394 | if (RT_FAILURE(rc))
|
---|
1395 | {
|
---|
1396 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1397 | return rc;
|
---|
1398 | }
|
---|
1399 | pPciBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
|
---|
1400 | }
|
---|
1401 | else
|
---|
1402 | {
|
---|
1403 | pPciBus->pfnSetIrqRC = 0;
|
---|
1404 | pPciBus->pDevInsRC = 0;
|
---|
1405 | }
|
---|
1406 |
|
---|
1407 | /*
|
---|
1408 | * Resolve and init the R0 bits.
|
---|
1409 | */
|
---|
1410 | if (pPciBusReg->pszSetIrqR0)
|
---|
1411 | {
|
---|
1412 | int rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pPciBusReg->pszSetIrqR0, &pPciBus->pfnSetIrqR0);
|
---|
1413 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szR0Mod, pPciBusReg->pszSetIrqR0, rc));
|
---|
1414 | if (RT_FAILURE(rc))
|
---|
1415 | {
|
---|
1416 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1417 | return rc;
|
---|
1418 | }
|
---|
1419 | pPciBus->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
|
---|
1420 | }
|
---|
1421 | else
|
---|
1422 | {
|
---|
1423 | pPciBus->pfnSetIrqR0 = 0;
|
---|
1424 | pPciBus->pDevInsR0 = 0;
|
---|
1425 | }
|
---|
1426 |
|
---|
1427 | /*
|
---|
1428 | * Init the R3 bits.
|
---|
1429 | */
|
---|
1430 | pPciBus->iBus = iBus;
|
---|
1431 | pPciBus->pDevInsR3 = pDevIns;
|
---|
1432 | pPciBus->pfnRegisterR3 = pPciBusReg->pfnRegisterR3;
|
---|
1433 | pPciBus->pfnIORegionRegisterR3 = pPciBusReg->pfnIORegionRegisterR3;
|
---|
1434 | pPciBus->pfnSetConfigCallbacksR3 = pPciBusReg->pfnSetConfigCallbacksR3;
|
---|
1435 | pPciBus->pfnSetIrqR3 = pPciBusReg->pfnSetIrqR3;
|
---|
1436 | pPciBus->pfnSaveExecR3 = pPciBusReg->pfnSaveExecR3;
|
---|
1437 | pPciBus->pfnLoadExecR3 = pPciBusReg->pfnLoadExecR3;
|
---|
1438 | pPciBus->pfnFakePCIBIOSR3 = pPciBusReg->pfnFakePCIBIOSR3;
|
---|
1439 |
|
---|
1440 | Log(("PDM: Registered PCI bus device '%s'/%d pDevIns=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns));
|
---|
1441 |
|
---|
1442 | /* set the helper pointer and return. */
|
---|
1443 | *ppPciHlpR3 = &g_pdmR3DevPciHlp;
|
---|
1444 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VINF_SUCCESS));
|
---|
1445 | return VINF_SUCCESS;
|
---|
1446 | }
|
---|
1447 |
|
---|
1448 |
|
---|
1449 | /** @copydoc PDMDEVHLPR3::pfnPICRegister */
|
---|
1450 | static DECLCALLBACK(int) pdmR3DevHlp_PICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3)
|
---|
1451 | {
|
---|
1452 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1453 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
1454 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: pPicReg=%p:{.u32Version=%#x, .pfnSetIrqR3=%p, .pfnGetInterruptR3=%p, .pszGetIrqRC=%p:{%s}, .pszGetInterruptRC=%p:{%s}, .pszGetIrqR0=%p:{%s}, .pszGetInterruptR0=%p:{%s} } ppPicHlpR3=%p\n",
|
---|
1455 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pPicReg, pPicReg->u32Version, pPicReg->pfnSetIrqR3, pPicReg->pfnGetInterruptR3,
|
---|
1456 | pPicReg->pszSetIrqRC, pPicReg->pszSetIrqRC, pPicReg->pszGetInterruptRC, pPicReg->pszGetInterruptRC,
|
---|
1457 | pPicReg->pszSetIrqR0, pPicReg->pszSetIrqR0, pPicReg->pszGetInterruptR0, pPicReg->pszGetInterruptR0,
|
---|
1458 | ppPicHlpR3));
|
---|
1459 |
|
---|
1460 | /*
|
---|
1461 | * Validate input.
|
---|
1462 | */
|
---|
1463 | if (pPicReg->u32Version != PDM_PICREG_VERSION)
|
---|
1464 | {
|
---|
1465 | AssertMsgFailed(("u32Version=%#x expected %#x\n", pPicReg->u32Version, PDM_PICREG_VERSION));
|
---|
1466 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (version)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1467 | return VERR_INVALID_PARAMETER;
|
---|
1468 | }
|
---|
1469 | if ( !pPicReg->pfnSetIrqR3
|
---|
1470 | || !pPicReg->pfnGetInterruptR3)
|
---|
1471 | {
|
---|
1472 | Assert(pPicReg->pfnSetIrqR3);
|
---|
1473 | Assert(pPicReg->pfnGetInterruptR3);
|
---|
1474 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (R3 callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1475 | return VERR_INVALID_PARAMETER;
|
---|
1476 | }
|
---|
1477 | if ( ( pPicReg->pszSetIrqRC
|
---|
1478 | || pPicReg->pszGetInterruptRC)
|
---|
1479 | && ( !VALID_PTR(pPicReg->pszSetIrqRC)
|
---|
1480 | || !VALID_PTR(pPicReg->pszGetInterruptRC))
|
---|
1481 | )
|
---|
1482 | {
|
---|
1483 | Assert(VALID_PTR(pPicReg->pszSetIrqRC));
|
---|
1484 | Assert(VALID_PTR(pPicReg->pszGetInterruptRC));
|
---|
1485 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (RC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1486 | return VERR_INVALID_PARAMETER;
|
---|
1487 | }
|
---|
1488 | if ( pPicReg->pszSetIrqRC
|
---|
1489 | && !(pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_RC))
|
---|
1490 | {
|
---|
1491 | Assert(pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_RC);
|
---|
1492 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (RC flag)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1493 | return VERR_INVALID_PARAMETER;
|
---|
1494 | }
|
---|
1495 | if ( pPicReg->pszSetIrqR0
|
---|
1496 | && !(pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_R0))
|
---|
1497 | {
|
---|
1498 | Assert(pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_R0);
|
---|
1499 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (R0 flag)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1500 | return VERR_INVALID_PARAMETER;
|
---|
1501 | }
|
---|
1502 | if (!ppPicHlpR3)
|
---|
1503 | {
|
---|
1504 | Assert(ppPicHlpR3);
|
---|
1505 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (ppPicHlpR3)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1506 | return VERR_INVALID_PARAMETER;
|
---|
1507 | }
|
---|
1508 |
|
---|
1509 | /*
|
---|
1510 | * Only one PIC device.
|
---|
1511 | */
|
---|
1512 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
1513 | if (pVM->pdm.s.Pic.pDevInsR3)
|
---|
1514 | {
|
---|
1515 | AssertMsgFailed(("Only one pic device is supported!\n"));
|
---|
1516 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1517 | return VERR_INVALID_PARAMETER;
|
---|
1518 | }
|
---|
1519 |
|
---|
1520 | /*
|
---|
1521 | * RC stuff.
|
---|
1522 | */
|
---|
1523 | if (pPicReg->pszSetIrqRC)
|
---|
1524 | {
|
---|
1525 | int rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pPicReg->pszSetIrqRC, &pVM->pdm.s.Pic.pfnSetIrqRC);
|
---|
1526 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szRCMod, pPicReg->pszSetIrqRC, rc));
|
---|
1527 | if (RT_SUCCESS(rc))
|
---|
1528 | {
|
---|
1529 | rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pPicReg->pszGetInterruptRC, &pVM->pdm.s.Pic.pfnGetInterruptRC);
|
---|
1530 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szRCMod, pPicReg->pszGetInterruptRC, rc));
|
---|
1531 | }
|
---|
1532 | if (RT_FAILURE(rc))
|
---|
1533 | {
|
---|
1534 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1535 | return rc;
|
---|
1536 | }
|
---|
1537 | pVM->pdm.s.Pic.pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
|
---|
1538 | }
|
---|
1539 | else
|
---|
1540 | {
|
---|
1541 | pVM->pdm.s.Pic.pDevInsRC = 0;
|
---|
1542 | pVM->pdm.s.Pic.pfnSetIrqRC = 0;
|
---|
1543 | pVM->pdm.s.Pic.pfnGetInterruptRC = 0;
|
---|
1544 | }
|
---|
1545 |
|
---|
1546 | /*
|
---|
1547 | * R0 stuff.
|
---|
1548 | */
|
---|
1549 | if (pPicReg->pszSetIrqR0)
|
---|
1550 | {
|
---|
1551 | int rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pPicReg->pszSetIrqR0, &pVM->pdm.s.Pic.pfnSetIrqR0);
|
---|
1552 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szR0Mod, pPicReg->pszSetIrqR0, rc));
|
---|
1553 | if (RT_SUCCESS(rc))
|
---|
1554 | {
|
---|
1555 | rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pPicReg->pszGetInterruptR0, &pVM->pdm.s.Pic.pfnGetInterruptR0);
|
---|
1556 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szR0Mod, pPicReg->pszGetInterruptR0, rc));
|
---|
1557 | }
|
---|
1558 | if (RT_FAILURE(rc))
|
---|
1559 | {
|
---|
1560 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1561 | return rc;
|
---|
1562 | }
|
---|
1563 | pVM->pdm.s.Pic.pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
|
---|
1564 | Assert(pVM->pdm.s.Pic.pDevInsR0);
|
---|
1565 | }
|
---|
1566 | else
|
---|
1567 | {
|
---|
1568 | pVM->pdm.s.Pic.pfnSetIrqR0 = 0;
|
---|
1569 | pVM->pdm.s.Pic.pfnGetInterruptR0 = 0;
|
---|
1570 | pVM->pdm.s.Pic.pDevInsR0 = 0;
|
---|
1571 | }
|
---|
1572 |
|
---|
1573 | /*
|
---|
1574 | * R3 stuff.
|
---|
1575 | */
|
---|
1576 | pVM->pdm.s.Pic.pDevInsR3 = pDevIns;
|
---|
1577 | pVM->pdm.s.Pic.pfnSetIrqR3 = pPicReg->pfnSetIrqR3;
|
---|
1578 | pVM->pdm.s.Pic.pfnGetInterruptR3 = pPicReg->pfnGetInterruptR3;
|
---|
1579 | Log(("PDM: Registered PIC device '%s'/%d pDevIns=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns));
|
---|
1580 |
|
---|
1581 | /* set the helper pointer and return. */
|
---|
1582 | *ppPicHlpR3 = &g_pdmR3DevPicHlp;
|
---|
1583 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VINF_SUCCESS));
|
---|
1584 | return VINF_SUCCESS;
|
---|
1585 | }
|
---|
1586 |
|
---|
1587 |
|
---|
1588 | /** @copydoc PDMDEVHLPR3::pfnAPICRegister */
|
---|
1589 | static DECLCALLBACK(int) pdmR3DevHlp_APICRegister(PPDMDEVINS pDevIns, PPDMAPICREG pApicReg, PCPDMAPICHLPR3 *ppApicHlpR3)
|
---|
1590 | {
|
---|
1591 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1592 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
1593 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: pApicReg=%p:{.u32Version=%#x, .pfnGetInterruptR3=%p, .pfnSetBaseR3=%p, .pfnGetBaseR3=%p, "
|
---|
1594 | ".pfnSetTPRR3=%p, .pfnGetTPRR3=%p, .pfnWriteMSR3=%p, .pfnReadMSR3=%p, .pfnBusDeliverR3=%p, pszGetInterruptRC=%p:{%s}, pszSetBaseRC=%p:{%s}, pszGetBaseRC=%p:{%s}, "
|
---|
1595 | ".pszSetTPRRC=%p:{%s}, .pszGetTPRRC=%p:{%s}, .pszWriteMSRRC=%p:{%s}, .pszReadMSRRC=%p:{%s}, .pszBusDeliverRC=%p:{%s}} ppApicHlpR3=%p\n",
|
---|
1596 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pApicReg, pApicReg->u32Version, pApicReg->pfnGetInterruptR3, pApicReg->pfnSetBaseR3,
|
---|
1597 | pApicReg->pfnGetBaseR3, pApicReg->pfnSetTPRR3, pApicReg->pfnGetTPRR3, pApicReg->pfnWriteMSRR3, pApicReg->pfnReadMSRR3, pApicReg->pfnBusDeliverR3, pApicReg->pszGetInterruptRC,
|
---|
1598 | pApicReg->pszGetInterruptRC, pApicReg->pszSetBaseRC, pApicReg->pszSetBaseRC, pApicReg->pszGetBaseRC, pApicReg->pszGetBaseRC,
|
---|
1599 | pApicReg->pszSetTPRRC, pApicReg->pszSetTPRRC, pApicReg->pszGetTPRRC, pApicReg->pszGetTPRRC, pApicReg->pszWriteMSRRC, pApicReg->pszWriteMSRRC, pApicReg->pszReadMSRRC, pApicReg->pszReadMSRRC, pApicReg->pszBusDeliverRC,
|
---|
1600 | pApicReg->pszBusDeliverRC, ppApicHlpR3));
|
---|
1601 |
|
---|
1602 | /*
|
---|
1603 | * Validate input.
|
---|
1604 | */
|
---|
1605 | if (pApicReg->u32Version != PDM_APICREG_VERSION)
|
---|
1606 | {
|
---|
1607 | AssertMsgFailed(("u32Version=%#x expected %#x\n", pApicReg->u32Version, PDM_APICREG_VERSION));
|
---|
1608 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Rrc (version)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1609 | return VERR_INVALID_PARAMETER;
|
---|
1610 | }
|
---|
1611 | if ( !pApicReg->pfnGetInterruptR3
|
---|
1612 | || !pApicReg->pfnHasPendingIrqR3
|
---|
1613 | || !pApicReg->pfnSetBaseR3
|
---|
1614 | || !pApicReg->pfnGetBaseR3
|
---|
1615 | || !pApicReg->pfnSetTPRR3
|
---|
1616 | || !pApicReg->pfnGetTPRR3
|
---|
1617 | || !pApicReg->pfnWriteMSRR3
|
---|
1618 | || !pApicReg->pfnReadMSRR3
|
---|
1619 | || !pApicReg->pfnBusDeliverR3)
|
---|
1620 | {
|
---|
1621 | Assert(pApicReg->pfnGetInterruptR3);
|
---|
1622 | Assert(pApicReg->pfnHasPendingIrqR3);
|
---|
1623 | Assert(pApicReg->pfnSetBaseR3);
|
---|
1624 | Assert(pApicReg->pfnGetBaseR3);
|
---|
1625 | Assert(pApicReg->pfnSetTPRR3);
|
---|
1626 | Assert(pApicReg->pfnGetTPRR3);
|
---|
1627 | Assert(pApicReg->pfnWriteMSRR3);
|
---|
1628 | Assert(pApicReg->pfnReadMSRR3);
|
---|
1629 | Assert(pApicReg->pfnBusDeliverR3);
|
---|
1630 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Rrc (R3 callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1631 | return VERR_INVALID_PARAMETER;
|
---|
1632 | }
|
---|
1633 | if ( ( pApicReg->pszGetInterruptRC
|
---|
1634 | || pApicReg->pszHasPendingIrqRC
|
---|
1635 | || pApicReg->pszSetBaseRC
|
---|
1636 | || pApicReg->pszGetBaseRC
|
---|
1637 | || pApicReg->pszSetTPRRC
|
---|
1638 | || pApicReg->pszGetTPRRC
|
---|
1639 | || pApicReg->pszWriteMSRRC
|
---|
1640 | || pApicReg->pszReadMSRRC
|
---|
1641 | || pApicReg->pszBusDeliverRC)
|
---|
1642 | && ( !VALID_PTR(pApicReg->pszGetInterruptRC)
|
---|
1643 | || !VALID_PTR(pApicReg->pszHasPendingIrqRC)
|
---|
1644 | || !VALID_PTR(pApicReg->pszSetBaseRC)
|
---|
1645 | || !VALID_PTR(pApicReg->pszGetBaseRC)
|
---|
1646 | || !VALID_PTR(pApicReg->pszSetTPRRC)
|
---|
1647 | || !VALID_PTR(pApicReg->pszGetTPRRC)
|
---|
1648 | || !VALID_PTR(pApicReg->pszWriteMSRRC)
|
---|
1649 | || !VALID_PTR(pApicReg->pszReadMSRRC)
|
---|
1650 | || !VALID_PTR(pApicReg->pszBusDeliverRC))
|
---|
1651 | )
|
---|
1652 | {
|
---|
1653 | Assert(VALID_PTR(pApicReg->pszGetInterruptRC));
|
---|
1654 | Assert(VALID_PTR(pApicReg->pszHasPendingIrqRC));
|
---|
1655 | Assert(VALID_PTR(pApicReg->pszSetBaseRC));
|
---|
1656 | Assert(VALID_PTR(pApicReg->pszGetBaseRC));
|
---|
1657 | Assert(VALID_PTR(pApicReg->pszSetTPRRC));
|
---|
1658 | Assert(VALID_PTR(pApicReg->pszGetTPRRC));
|
---|
1659 | Assert(VALID_PTR(pApicReg->pszReadMSRRC));
|
---|
1660 | Assert(VALID_PTR(pApicReg->pszWriteMSRRC));
|
---|
1661 | Assert(VALID_PTR(pApicReg->pszBusDeliverRC));
|
---|
1662 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Rrc (RC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1663 | return VERR_INVALID_PARAMETER;
|
---|
1664 | }
|
---|
1665 | if ( ( pApicReg->pszGetInterruptR0
|
---|
1666 | || pApicReg->pszHasPendingIrqR0
|
---|
1667 | || pApicReg->pszSetBaseR0
|
---|
1668 | || pApicReg->pszGetBaseR0
|
---|
1669 | || pApicReg->pszSetTPRR0
|
---|
1670 | || pApicReg->pszGetTPRR0
|
---|
1671 | || pApicReg->pszWriteMSRR0
|
---|
1672 | || pApicReg->pszReadMSRR0
|
---|
1673 | || pApicReg->pszBusDeliverR0)
|
---|
1674 | && ( !VALID_PTR(pApicReg->pszGetInterruptR0)
|
---|
1675 | || !VALID_PTR(pApicReg->pszHasPendingIrqR0)
|
---|
1676 | || !VALID_PTR(pApicReg->pszSetBaseR0)
|
---|
1677 | || !VALID_PTR(pApicReg->pszGetBaseR0)
|
---|
1678 | || !VALID_PTR(pApicReg->pszSetTPRR0)
|
---|
1679 | || !VALID_PTR(pApicReg->pszGetTPRR0)
|
---|
1680 | || !VALID_PTR(pApicReg->pszReadMSRR0)
|
---|
1681 | || !VALID_PTR(pApicReg->pszWriteMSRR0)
|
---|
1682 | || !VALID_PTR(pApicReg->pszBusDeliverR0))
|
---|
1683 | )
|
---|
1684 | {
|
---|
1685 | Assert(VALID_PTR(pApicReg->pszGetInterruptR0));
|
---|
1686 | Assert(VALID_PTR(pApicReg->pszHasPendingIrqR0));
|
---|
1687 | Assert(VALID_PTR(pApicReg->pszSetBaseR0));
|
---|
1688 | Assert(VALID_PTR(pApicReg->pszGetBaseR0));
|
---|
1689 | Assert(VALID_PTR(pApicReg->pszSetTPRR0));
|
---|
1690 | Assert(VALID_PTR(pApicReg->pszGetTPRR0));
|
---|
1691 | Assert(VALID_PTR(pApicReg->pszReadMSRR0));
|
---|
1692 | Assert(VALID_PTR(pApicReg->pszWriteMSRR0));
|
---|
1693 | Assert(VALID_PTR(pApicReg->pszBusDeliverR0));
|
---|
1694 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Rrc (R0 callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1695 | return VERR_INVALID_PARAMETER;
|
---|
1696 | }
|
---|
1697 | if (!ppApicHlpR3)
|
---|
1698 | {
|
---|
1699 | Assert(ppApicHlpR3);
|
---|
1700 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Rrc (ppApicHlpR3)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1701 | return VERR_INVALID_PARAMETER;
|
---|
1702 | }
|
---|
1703 |
|
---|
1704 | /*
|
---|
1705 | * Only one APIC device. On SMP we have single logical device covering all LAPICs,
|
---|
1706 | * as they need to communicate and share state easily.
|
---|
1707 | */
|
---|
1708 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
1709 | if (pVM->pdm.s.Apic.pDevInsR3)
|
---|
1710 | {
|
---|
1711 | AssertMsgFailed(("Only one apic device is supported!\n"));
|
---|
1712 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1713 | return VERR_INVALID_PARAMETER;
|
---|
1714 | }
|
---|
1715 |
|
---|
1716 | /*
|
---|
1717 | * Resolve & initialize the RC bits.
|
---|
1718 | */
|
---|
1719 | if (pApicReg->pszGetInterruptRC)
|
---|
1720 | {
|
---|
1721 | int rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pApicReg->pszGetInterruptRC, &pVM->pdm.s.Apic.pfnGetInterruptRC);
|
---|
1722 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szRCMod, pApicReg->pszGetInterruptRC, rc));
|
---|
1723 | if (RT_SUCCESS(rc))
|
---|
1724 | {
|
---|
1725 | rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pApicReg->pszHasPendingIrqRC, &pVM->pdm.s.Apic.pfnHasPendingIrqRC);
|
---|
1726 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szRCMod, pApicReg->pszHasPendingIrqRC, rc));
|
---|
1727 | }
|
---|
1728 | if (RT_SUCCESS(rc))
|
---|
1729 | {
|
---|
1730 | rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pApicReg->pszSetBaseRC, &pVM->pdm.s.Apic.pfnSetBaseRC);
|
---|
1731 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szRCMod, pApicReg->pszSetBaseRC, rc));
|
---|
1732 | }
|
---|
1733 | if (RT_SUCCESS(rc))
|
---|
1734 | {
|
---|
1735 | rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pApicReg->pszGetBaseRC, &pVM->pdm.s.Apic.pfnGetBaseRC);
|
---|
1736 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szRCMod, pApicReg->pszGetBaseRC, rc));
|
---|
1737 | }
|
---|
1738 | if (RT_SUCCESS(rc))
|
---|
1739 | {
|
---|
1740 | rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pApicReg->pszSetTPRRC, &pVM->pdm.s.Apic.pfnSetTPRRC);
|
---|
1741 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szRCMod, pApicReg->pszSetTPRRC, rc));
|
---|
1742 | }
|
---|
1743 | if (RT_SUCCESS(rc))
|
---|
1744 | {
|
---|
1745 | rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pApicReg->pszGetTPRRC, &pVM->pdm.s.Apic.pfnGetTPRRC);
|
---|
1746 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szRCMod, pApicReg->pszGetTPRRC, rc));
|
---|
1747 | }
|
---|
1748 | if (RT_SUCCESS(rc))
|
---|
1749 | {
|
---|
1750 | rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pApicReg->pszWriteMSRRC, &pVM->pdm.s.Apic.pfnWriteMSRRC);
|
---|
1751 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szRCMod, pApicReg->pszWriteMSRRC, rc));
|
---|
1752 | }
|
---|
1753 | if (RT_SUCCESS(rc))
|
---|
1754 | {
|
---|
1755 | rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pApicReg->pszReadMSRRC, &pVM->pdm.s.Apic.pfnReadMSRRC);
|
---|
1756 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szRCMod, pApicReg->pszReadMSRRC, rc));
|
---|
1757 | }
|
---|
1758 | if (RT_SUCCESS(rc))
|
---|
1759 | {
|
---|
1760 | rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pApicReg->pszBusDeliverRC, &pVM->pdm.s.Apic.pfnBusDeliverRC);
|
---|
1761 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szRCMod, pApicReg->pszBusDeliverRC, rc));
|
---|
1762 | }
|
---|
1763 | if (RT_FAILURE(rc))
|
---|
1764 | {
|
---|
1765 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1766 | return rc;
|
---|
1767 | }
|
---|
1768 | pVM->pdm.s.Apic.pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
|
---|
1769 | }
|
---|
1770 | else
|
---|
1771 | {
|
---|
1772 | pVM->pdm.s.Apic.pDevInsRC = 0;
|
---|
1773 | pVM->pdm.s.Apic.pfnGetInterruptRC = 0;
|
---|
1774 | pVM->pdm.s.Apic.pfnHasPendingIrqRC = 0;
|
---|
1775 | pVM->pdm.s.Apic.pfnSetBaseRC = 0;
|
---|
1776 | pVM->pdm.s.Apic.pfnGetBaseRC = 0;
|
---|
1777 | pVM->pdm.s.Apic.pfnSetTPRRC = 0;
|
---|
1778 | pVM->pdm.s.Apic.pfnGetTPRRC = 0;
|
---|
1779 | pVM->pdm.s.Apic.pfnWriteMSRRC = 0;
|
---|
1780 | pVM->pdm.s.Apic.pfnReadMSRRC = 0;
|
---|
1781 | pVM->pdm.s.Apic.pfnBusDeliverRC = 0;
|
---|
1782 | }
|
---|
1783 |
|
---|
1784 | /*
|
---|
1785 | * Resolve & initialize the R0 bits.
|
---|
1786 | */
|
---|
1787 | if (pApicReg->pszGetInterruptR0)
|
---|
1788 | {
|
---|
1789 | int rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszGetInterruptR0, &pVM->pdm.s.Apic.pfnGetInterruptR0);
|
---|
1790 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszGetInterruptR0, rc));
|
---|
1791 | if (RT_SUCCESS(rc))
|
---|
1792 | {
|
---|
1793 | rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszHasPendingIrqR0, &pVM->pdm.s.Apic.pfnHasPendingIrqR0);
|
---|
1794 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszHasPendingIrqR0, rc));
|
---|
1795 | }
|
---|
1796 | if (RT_SUCCESS(rc))
|
---|
1797 | {
|
---|
1798 | rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszSetBaseR0, &pVM->pdm.s.Apic.pfnSetBaseR0);
|
---|
1799 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszSetBaseR0, rc));
|
---|
1800 | }
|
---|
1801 | if (RT_SUCCESS(rc))
|
---|
1802 | {
|
---|
1803 | rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszGetBaseR0, &pVM->pdm.s.Apic.pfnGetBaseR0);
|
---|
1804 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszGetBaseR0, rc));
|
---|
1805 | }
|
---|
1806 | if (RT_SUCCESS(rc))
|
---|
1807 | {
|
---|
1808 | rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszSetTPRR0, &pVM->pdm.s.Apic.pfnSetTPRR0);
|
---|
1809 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszSetTPRR0, rc));
|
---|
1810 | }
|
---|
1811 | if (RT_SUCCESS(rc))
|
---|
1812 | {
|
---|
1813 | rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszGetTPRR0, &pVM->pdm.s.Apic.pfnGetTPRR0);
|
---|
1814 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszGetTPRR0, rc));
|
---|
1815 | }
|
---|
1816 | if (RT_SUCCESS(rc))
|
---|
1817 | {
|
---|
1818 | rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszWriteMSRR0, &pVM->pdm.s.Apic.pfnWriteMSRR0);
|
---|
1819 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszWriteMSRR0, rc));
|
---|
1820 | }
|
---|
1821 | if (RT_SUCCESS(rc))
|
---|
1822 | {
|
---|
1823 | rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszReadMSRR0, &pVM->pdm.s.Apic.pfnReadMSRR0);
|
---|
1824 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszReadMSRR0, rc));
|
---|
1825 | }
|
---|
1826 | if (RT_SUCCESS(rc))
|
---|
1827 | {
|
---|
1828 | rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszBusDeliverR0, &pVM->pdm.s.Apic.pfnBusDeliverR0);
|
---|
1829 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszBusDeliverR0, rc));
|
---|
1830 | }
|
---|
1831 | if (RT_FAILURE(rc))
|
---|
1832 | {
|
---|
1833 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1834 | return rc;
|
---|
1835 | }
|
---|
1836 | pVM->pdm.s.Apic.pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
|
---|
1837 | Assert(pVM->pdm.s.Apic.pDevInsR0);
|
---|
1838 | }
|
---|
1839 | else
|
---|
1840 | {
|
---|
1841 | pVM->pdm.s.Apic.pfnGetInterruptR0 = 0;
|
---|
1842 | pVM->pdm.s.Apic.pfnHasPendingIrqR0 = 0;
|
---|
1843 | pVM->pdm.s.Apic.pfnSetBaseR0 = 0;
|
---|
1844 | pVM->pdm.s.Apic.pfnGetBaseR0 = 0;
|
---|
1845 | pVM->pdm.s.Apic.pfnSetTPRR0 = 0;
|
---|
1846 | pVM->pdm.s.Apic.pfnGetTPRR0 = 0;
|
---|
1847 | pVM->pdm.s.Apic.pfnWriteMSRR0 = 0;
|
---|
1848 | pVM->pdm.s.Apic.pfnReadMSRR0 = 0;
|
---|
1849 | pVM->pdm.s.Apic.pfnBusDeliverR0 = 0;
|
---|
1850 | pVM->pdm.s.Apic.pDevInsR0 = 0;
|
---|
1851 | }
|
---|
1852 |
|
---|
1853 | /*
|
---|
1854 | * Initialize the HC bits.
|
---|
1855 | */
|
---|
1856 | pVM->pdm.s.Apic.pDevInsR3 = pDevIns;
|
---|
1857 | pVM->pdm.s.Apic.pfnGetInterruptR3 = pApicReg->pfnGetInterruptR3;
|
---|
1858 | pVM->pdm.s.Apic.pfnHasPendingIrqR3 = pApicReg->pfnHasPendingIrqR3;
|
---|
1859 | pVM->pdm.s.Apic.pfnSetBaseR3 = pApicReg->pfnSetBaseR3;
|
---|
1860 | pVM->pdm.s.Apic.pfnGetBaseR3 = pApicReg->pfnGetBaseR3;
|
---|
1861 | pVM->pdm.s.Apic.pfnSetTPRR3 = pApicReg->pfnSetTPRR3;
|
---|
1862 | pVM->pdm.s.Apic.pfnGetTPRR3 = pApicReg->pfnGetTPRR3;
|
---|
1863 | pVM->pdm.s.Apic.pfnWriteMSRR3 = pApicReg->pfnWriteMSRR3;
|
---|
1864 | pVM->pdm.s.Apic.pfnReadMSRR3 = pApicReg->pfnReadMSRR3;
|
---|
1865 | pVM->pdm.s.Apic.pfnBusDeliverR3 = pApicReg->pfnBusDeliverR3;
|
---|
1866 | Log(("PDM: Registered APIC device '%s'/%d pDevIns=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns));
|
---|
1867 |
|
---|
1868 | /* set the helper pointer and return. */
|
---|
1869 | *ppApicHlpR3 = &g_pdmR3DevApicHlp;
|
---|
1870 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VINF_SUCCESS));
|
---|
1871 | return VINF_SUCCESS;
|
---|
1872 | }
|
---|
1873 |
|
---|
1874 |
|
---|
1875 | /** @copydoc PDMDEVHLPR3::pfnIOAPICRegister */
|
---|
1876 | static DECLCALLBACK(int) pdmR3DevHlp_IOAPICRegister(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3)
|
---|
1877 | {
|
---|
1878 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1879 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
1880 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: pIoApicReg=%p:{.u32Version=%#x, .pfnSetIrqR3=%p, .pszSetIrqRC=%p:{%s}, .pszSetIrqR0=%p:{%s}} ppIoApicHlpR3=%p\n",
|
---|
1881 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pIoApicReg, pIoApicReg->u32Version, pIoApicReg->pfnSetIrqR3,
|
---|
1882 | pIoApicReg->pszSetIrqRC, pIoApicReg->pszSetIrqRC, pIoApicReg->pszSetIrqR0, pIoApicReg->pszSetIrqR0, ppIoApicHlpR3));
|
---|
1883 |
|
---|
1884 | /*
|
---|
1885 | * Validate input.
|
---|
1886 | */
|
---|
1887 | if (pIoApicReg->u32Version != PDM_IOAPICREG_VERSION)
|
---|
1888 | {
|
---|
1889 | AssertMsgFailed(("u32Version=%#x expected %#x\n", pIoApicReg->u32Version, PDM_IOAPICREG_VERSION));
|
---|
1890 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Rrc (version)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1891 | return VERR_INVALID_PARAMETER;
|
---|
1892 | }
|
---|
1893 | if (!pIoApicReg->pfnSetIrqR3)
|
---|
1894 | {
|
---|
1895 | Assert(pIoApicReg->pfnSetIrqR3);
|
---|
1896 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Rrc (R3 callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1897 | return VERR_INVALID_PARAMETER;
|
---|
1898 | }
|
---|
1899 | if ( pIoApicReg->pszSetIrqRC
|
---|
1900 | && !VALID_PTR(pIoApicReg->pszSetIrqRC))
|
---|
1901 | {
|
---|
1902 | Assert(VALID_PTR(pIoApicReg->pszSetIrqRC));
|
---|
1903 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Rrc (GC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1904 | return VERR_INVALID_PARAMETER;
|
---|
1905 | }
|
---|
1906 | if ( pIoApicReg->pszSetIrqR0
|
---|
1907 | && !VALID_PTR(pIoApicReg->pszSetIrqR0))
|
---|
1908 | {
|
---|
1909 | Assert(VALID_PTR(pIoApicReg->pszSetIrqR0));
|
---|
1910 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Rrc (GC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1911 | return VERR_INVALID_PARAMETER;
|
---|
1912 | }
|
---|
1913 | if (!ppIoApicHlpR3)
|
---|
1914 | {
|
---|
1915 | Assert(ppIoApicHlpR3);
|
---|
1916 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Rrc (ppApicHlp)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1917 | return VERR_INVALID_PARAMETER;
|
---|
1918 | }
|
---|
1919 |
|
---|
1920 | /*
|
---|
1921 | * The I/O APIC requires the APIC to be present (hacks++).
|
---|
1922 | * If the I/O APIC does GC stuff so must the APIC.
|
---|
1923 | */
|
---|
1924 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
1925 | if (!pVM->pdm.s.Apic.pDevInsR3)
|
---|
1926 | {
|
---|
1927 | AssertMsgFailed(("Configuration error / Init order error! No APIC!\n"));
|
---|
1928 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Rrc (no APIC)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1929 | return VERR_INVALID_PARAMETER;
|
---|
1930 | }
|
---|
1931 | if ( pIoApicReg->pszSetIrqRC
|
---|
1932 | && !pVM->pdm.s.Apic.pDevInsRC)
|
---|
1933 | {
|
---|
1934 | AssertMsgFailed(("Configuration error! APIC doesn't do GC, I/O APIC does!\n"));
|
---|
1935 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Rrc (no GC APIC)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1936 | return VERR_INVALID_PARAMETER;
|
---|
1937 | }
|
---|
1938 |
|
---|
1939 | /*
|
---|
1940 | * Only one I/O APIC device.
|
---|
1941 | */
|
---|
1942 | if (pVM->pdm.s.IoApic.pDevInsR3)
|
---|
1943 | {
|
---|
1944 | AssertMsgFailed(("Only one ioapic device is supported!\n"));
|
---|
1945 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Rrc (only one)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1946 | return VERR_INVALID_PARAMETER;
|
---|
1947 | }
|
---|
1948 |
|
---|
1949 | /*
|
---|
1950 | * Resolve & initialize the GC bits.
|
---|
1951 | */
|
---|
1952 | if (pIoApicReg->pszSetIrqRC)
|
---|
1953 | {
|
---|
1954 | int rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pIoApicReg->pszSetIrqRC, &pVM->pdm.s.IoApic.pfnSetIrqRC);
|
---|
1955 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szRCMod, pIoApicReg->pszSetIrqRC, rc));
|
---|
1956 | if (RT_FAILURE(rc))
|
---|
1957 | {
|
---|
1958 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1959 | return rc;
|
---|
1960 | }
|
---|
1961 | pVM->pdm.s.IoApic.pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
|
---|
1962 | }
|
---|
1963 | else
|
---|
1964 | {
|
---|
1965 | pVM->pdm.s.IoApic.pDevInsRC = 0;
|
---|
1966 | pVM->pdm.s.IoApic.pfnSetIrqRC = 0;
|
---|
1967 | }
|
---|
1968 |
|
---|
1969 | /*
|
---|
1970 | * Resolve & initialize the R0 bits.
|
---|
1971 | */
|
---|
1972 | if (pIoApicReg->pszSetIrqR0)
|
---|
1973 | {
|
---|
1974 | int rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pIoApicReg->pszSetIrqR0, &pVM->pdm.s.IoApic.pfnSetIrqR0);
|
---|
1975 | AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pDevReg->szR0Mod, pIoApicReg->pszSetIrqR0, rc));
|
---|
1976 | if (RT_FAILURE(rc))
|
---|
1977 | {
|
---|
1978 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1979 | return rc;
|
---|
1980 | }
|
---|
1981 | pVM->pdm.s.IoApic.pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
|
---|
1982 | Assert(pVM->pdm.s.IoApic.pDevInsR0);
|
---|
1983 | }
|
---|
1984 | else
|
---|
1985 | {
|
---|
1986 | pVM->pdm.s.IoApic.pfnSetIrqR0 = 0;
|
---|
1987 | pVM->pdm.s.IoApic.pDevInsR0 = 0;
|
---|
1988 | }
|
---|
1989 |
|
---|
1990 | /*
|
---|
1991 | * Initialize the R3 bits.
|
---|
1992 | */
|
---|
1993 | pVM->pdm.s.IoApic.pDevInsR3 = pDevIns;
|
---|
1994 | pVM->pdm.s.IoApic.pfnSetIrqR3 = pIoApicReg->pfnSetIrqR3;
|
---|
1995 | Log(("PDM: Registered I/O APIC device '%s'/%d pDevIns=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns));
|
---|
1996 |
|
---|
1997 | /* set the helper pointer and return. */
|
---|
1998 | *ppIoApicHlpR3 = &g_pdmR3DevIoApicHlp;
|
---|
1999 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VINF_SUCCESS));
|
---|
2000 | return VINF_SUCCESS;
|
---|
2001 | }
|
---|
2002 |
|
---|
2003 |
|
---|
2004 | /** @copydoc PDMDEVHLPR3::pfnDMACRegister */
|
---|
2005 | static DECLCALLBACK(int) pdmR3DevHlp_DMACRegister(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp)
|
---|
2006 | {
|
---|
2007 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2008 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
2009 | LogFlow(("pdmR3DevHlp_DMACRegister: caller='%s'/%d: pDmacReg=%p:{.u32Version=%#x, .pfnRun=%p, .pfnRegister=%p, .pfnReadMemory=%p, .pfnWriteMemory=%p, .pfnSetDREQ=%p, .pfnGetChannelMode=%p} ppDmacHlp=%p\n",
|
---|
2010 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDmacReg, pDmacReg->u32Version, pDmacReg->pfnRun, pDmacReg->pfnRegister,
|
---|
2011 | pDmacReg->pfnReadMemory, pDmacReg->pfnWriteMemory, pDmacReg->pfnSetDREQ, pDmacReg->pfnGetChannelMode, ppDmacHlp));
|
---|
2012 |
|
---|
2013 | /*
|
---|
2014 | * Validate input.
|
---|
2015 | */
|
---|
2016 | if (pDmacReg->u32Version != PDM_DMACREG_VERSION)
|
---|
2017 | {
|
---|
2018 | AssertMsgFailed(("u32Version=%#x expected %#x\n", pDmacReg->u32Version,
|
---|
2019 | PDM_DMACREG_VERSION));
|
---|
2020 | LogFlow(("pdmR3DevHlp_DMACRegister: caller='%s'/%d: returns %Rrc (version)\n",
|
---|
2021 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2022 | return VERR_INVALID_PARAMETER;
|
---|
2023 | }
|
---|
2024 | if ( !pDmacReg->pfnRun
|
---|
2025 | || !pDmacReg->pfnRegister
|
---|
2026 | || !pDmacReg->pfnReadMemory
|
---|
2027 | || !pDmacReg->pfnWriteMemory
|
---|
2028 | || !pDmacReg->pfnSetDREQ
|
---|
2029 | || !pDmacReg->pfnGetChannelMode)
|
---|
2030 | {
|
---|
2031 | Assert(pDmacReg->pfnRun);
|
---|
2032 | Assert(pDmacReg->pfnRegister);
|
---|
2033 | Assert(pDmacReg->pfnReadMemory);
|
---|
2034 | Assert(pDmacReg->pfnWriteMemory);
|
---|
2035 | Assert(pDmacReg->pfnSetDREQ);
|
---|
2036 | Assert(pDmacReg->pfnGetChannelMode);
|
---|
2037 | LogFlow(("pdmR3DevHlp_DMACRegister: caller='%s'/%d: returns %Rrc (callbacks)\n",
|
---|
2038 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2039 | return VERR_INVALID_PARAMETER;
|
---|
2040 | }
|
---|
2041 |
|
---|
2042 | if (!ppDmacHlp)
|
---|
2043 | {
|
---|
2044 | Assert(ppDmacHlp);
|
---|
2045 | LogFlow(("pdmR3DevHlp_DMACRegister: caller='%s'/%d: returns %Rrc (ppDmacHlp)\n",
|
---|
2046 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2047 | return VERR_INVALID_PARAMETER;
|
---|
2048 | }
|
---|
2049 |
|
---|
2050 | /*
|
---|
2051 | * Only one DMA device.
|
---|
2052 | */
|
---|
2053 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2054 | if (pVM->pdm.s.pDmac)
|
---|
2055 | {
|
---|
2056 | AssertMsgFailed(("Only one DMA device is supported!\n"));
|
---|
2057 | LogFlow(("pdmR3DevHlp_DMACRegister: caller='%s'/%d: returns %Rrc\n",
|
---|
2058 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2059 | return VERR_INVALID_PARAMETER;
|
---|
2060 | }
|
---|
2061 |
|
---|
2062 | /*
|
---|
2063 | * Allocate and initialize pci bus structure.
|
---|
2064 | */
|
---|
2065 | int rc = VINF_SUCCESS;
|
---|
2066 | PPDMDMAC pDmac = (PPDMDMAC)MMR3HeapAlloc(pDevIns->Internal.s.pVMR3, MM_TAG_PDM_DEVICE, sizeof(*pDmac));
|
---|
2067 | if (pDmac)
|
---|
2068 | {
|
---|
2069 | pDmac->pDevIns = pDevIns;
|
---|
2070 | pDmac->Reg = *pDmacReg;
|
---|
2071 | pVM->pdm.s.pDmac = pDmac;
|
---|
2072 |
|
---|
2073 | /* set the helper pointer. */
|
---|
2074 | *ppDmacHlp = &g_pdmR3DevDmacHlp;
|
---|
2075 | Log(("PDM: Registered DMAC device '%s'/%d pDevIns=%p\n",
|
---|
2076 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns));
|
---|
2077 | }
|
---|
2078 | else
|
---|
2079 | rc = VERR_NO_MEMORY;
|
---|
2080 |
|
---|
2081 | LogFlow(("pdmR3DevHlp_DMACRegister: caller='%s'/%d: returns %Rrc\n",
|
---|
2082 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2083 | return rc;
|
---|
2084 | }
|
---|
2085 |
|
---|
2086 |
|
---|
2087 | /** @copydoc PDMDEVHLPR3::pfnPhysRead */
|
---|
2088 | static DECLCALLBACK(int) pdmR3DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
|
---|
2089 | {
|
---|
2090 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2091 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2092 | LogFlow(("pdmR3DevHlp_PhysRead: caller='%s'/%d: GCPhys=%RGp pvBuf=%p cbRead=%#x\n",
|
---|
2093 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhys, pvBuf, cbRead));
|
---|
2094 |
|
---|
2095 | #if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
|
---|
2096 | if (!VM_IS_EMT(pVM)) /** @todo not true for SMP. oh joy! */
|
---|
2097 | {
|
---|
2098 | char szNames[128];
|
---|
2099 | uint32_t cLocks = PDMR3CritSectCountOwned(pVM, szNames, sizeof(szNames));
|
---|
2100 | AssertMsg(cLocks == 0, ("cLocks=%u %s\n", cLocks, szNames));
|
---|
2101 | }
|
---|
2102 | #endif
|
---|
2103 |
|
---|
2104 | int rc;
|
---|
2105 | if (VM_IS_EMT(pVM))
|
---|
2106 | rc = PGMPhysRead(pVM, GCPhys, pvBuf, cbRead);
|
---|
2107 | else
|
---|
2108 | rc = PGMR3PhysReadExternal(pVM, GCPhys, pvBuf, cbRead);
|
---|
2109 |
|
---|
2110 | Log(("pdmR3DevHlp_PhysRead: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2111 | return rc;
|
---|
2112 | }
|
---|
2113 |
|
---|
2114 |
|
---|
2115 | /** @copydoc PDMDEVHLPR3::pfnPhysWrite */
|
---|
2116 | static DECLCALLBACK(int) pdmR3DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
|
---|
2117 | {
|
---|
2118 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2119 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2120 | LogFlow(("pdmR3DevHlp_PhysWrite: caller='%s'/%d: GCPhys=%RGp pvBuf=%p cbWrite=%#x\n",
|
---|
2121 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhys, pvBuf, cbWrite));
|
---|
2122 |
|
---|
2123 | #if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
|
---|
2124 | if (!VM_IS_EMT(pVM)) /** @todo not true for SMP. oh joy! */
|
---|
2125 | {
|
---|
2126 | char szNames[128];
|
---|
2127 | uint32_t cLocks = PDMR3CritSectCountOwned(pVM, szNames, sizeof(szNames));
|
---|
2128 | AssertMsg(cLocks == 0, ("cLocks=%u %s\n", cLocks, szNames));
|
---|
2129 | }
|
---|
2130 | #endif
|
---|
2131 |
|
---|
2132 | int rc;
|
---|
2133 | if (VM_IS_EMT(pVM))
|
---|
2134 | rc = PGMPhysWrite(pVM, GCPhys, pvBuf, cbWrite);
|
---|
2135 | else
|
---|
2136 | rc = PGMR3PhysWriteExternal(pVM, GCPhys, pvBuf, cbWrite);
|
---|
2137 |
|
---|
2138 | Log(("pdmR3DevHlp_PhysWrite: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2139 | return rc;
|
---|
2140 | }
|
---|
2141 |
|
---|
2142 |
|
---|
2143 | /** @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtr */
|
---|
2144 | static DECLCALLBACK(int) pdmR3DevHlp_PhysGCPhys2CCPtr(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock)
|
---|
2145 | {
|
---|
2146 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2147 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2148 | LogFlow(("pdmR3DevHlp_PhysGCPhys2CCPtr: caller='%s'/%d: GCPhys=%RGp fFlags=%#x ppv=%p pLock=%p\n",
|
---|
2149 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhys, fFlags, ppv, pLock));
|
---|
2150 | AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
|
---|
2151 |
|
---|
2152 | #if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
|
---|
2153 | if (!VM_IS_EMT(pVM)) /** @todo not true for SMP. oh joy! */
|
---|
2154 | {
|
---|
2155 | char szNames[128];
|
---|
2156 | uint32_t cLocks = PDMR3CritSectCountOwned(pVM, szNames, sizeof(szNames));
|
---|
2157 | AssertMsg(cLocks == 0, ("cLocks=%u %s\n", cLocks, szNames));
|
---|
2158 | }
|
---|
2159 | #endif
|
---|
2160 |
|
---|
2161 | int rc = PGMR3PhysGCPhys2CCPtrExternal(pVM, GCPhys, ppv, pLock);
|
---|
2162 |
|
---|
2163 | Log(("pdmR3DevHlp_PhysGCPhys2CCPtr: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2164 | return rc;
|
---|
2165 | }
|
---|
2166 |
|
---|
2167 |
|
---|
2168 | /** @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtrReadOnly */
|
---|
2169 | static DECLCALLBACK(int) pdmR3DevHlp_PhysGCPhys2CCPtrReadOnly(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, const void **ppv, PPGMPAGEMAPLOCK pLock)
|
---|
2170 | {
|
---|
2171 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2172 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2173 | LogFlow(("pdmR3DevHlp_PhysGCPhys2CCPtrReadOnly: caller='%s'/%d: GCPhys=%RGp fFlags=%#x ppv=%p pLock=%p\n",
|
---|
2174 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhys, fFlags, ppv, pLock));
|
---|
2175 | AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
|
---|
2176 |
|
---|
2177 | #if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
|
---|
2178 | if (!VM_IS_EMT(pVM)) /** @todo not true for SMP. oh joy! */
|
---|
2179 | {
|
---|
2180 | char szNames[128];
|
---|
2181 | uint32_t cLocks = PDMR3CritSectCountOwned(pVM, szNames, sizeof(szNames));
|
---|
2182 | AssertMsg(cLocks == 0, ("cLocks=%u %s\n", cLocks, szNames));
|
---|
2183 | }
|
---|
2184 | #endif
|
---|
2185 |
|
---|
2186 | int rc = PGMR3PhysGCPhys2CCPtrReadOnlyExternal(pVM, GCPhys, ppv, pLock);
|
---|
2187 |
|
---|
2188 | Log(("pdmR3DevHlp_PhysGCPhys2CCPtrReadOnly: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2189 | return rc;
|
---|
2190 | }
|
---|
2191 |
|
---|
2192 |
|
---|
2193 | /** @copydoc PDMDEVHLPR3::pfnPhysReleasePageMappingLock */
|
---|
2194 | static DECLCALLBACK(void) pdmR3DevHlp_PhysReleasePageMappingLock(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock)
|
---|
2195 | {
|
---|
2196 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2197 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2198 | LogFlow(("pdmR3DevHlp_PhysReleasePageMappingLock: caller='%s'/%d: pLock=%p\n",
|
---|
2199 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pLock));
|
---|
2200 |
|
---|
2201 | PGMPhysReleasePageMappingLock(pVM, pLock);
|
---|
2202 |
|
---|
2203 | Log(("pdmR3DevHlp_PhysReleasePageMappingLock: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2204 | }
|
---|
2205 |
|
---|
2206 |
|
---|
2207 | /** @copydoc PDMDEVHLPR3::pfnPhysReadGCVirt */
|
---|
2208 | static DECLCALLBACK(int) pdmR3DevHlp_PhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb)
|
---|
2209 | {
|
---|
2210 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2211 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2212 | VM_ASSERT_EMT(pVM);
|
---|
2213 | LogFlow(("pdmR3DevHlp_PhysReadGCVirt: caller='%s'/%d: pvDst=%p GCVirt=%RGv cb=%#x\n",
|
---|
2214 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pvDst, GCVirtSrc, cb));
|
---|
2215 |
|
---|
2216 | PVMCPU pVCpu = VMMGetCpu(pVM);
|
---|
2217 | if (!pVCpu)
|
---|
2218 | return VERR_ACCESS_DENIED;
|
---|
2219 | #if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
|
---|
2220 | /** @todo SMP. */
|
---|
2221 | #endif
|
---|
2222 |
|
---|
2223 | int rc = PGMPhysSimpleReadGCPtr(pVCpu, pvDst, GCVirtSrc, cb);
|
---|
2224 |
|
---|
2225 | LogFlow(("pdmR3DevHlp_PhysReadGCVirt: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2226 |
|
---|
2227 | return rc;
|
---|
2228 | }
|
---|
2229 |
|
---|
2230 |
|
---|
2231 | /** @copydoc PDMDEVHLPR3::pfnPhysWriteGCVirt */
|
---|
2232 | static DECLCALLBACK(int) pdmR3DevHlp_PhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb)
|
---|
2233 | {
|
---|
2234 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2235 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2236 | VM_ASSERT_EMT(pVM);
|
---|
2237 | LogFlow(("pdmR3DevHlp_PhysWriteGCVirt: caller='%s'/%d: GCVirtDst=%RGv pvSrc=%p cb=%#x\n",
|
---|
2238 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCVirtDst, pvSrc, cb));
|
---|
2239 |
|
---|
2240 | PVMCPU pVCpu = VMMGetCpu(pVM);
|
---|
2241 | if (!pVCpu)
|
---|
2242 | return VERR_ACCESS_DENIED;
|
---|
2243 | #if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
|
---|
2244 | /** @todo SMP. */
|
---|
2245 | #endif
|
---|
2246 |
|
---|
2247 | int rc = PGMPhysSimpleWriteGCPtr(pVCpu, GCVirtDst, pvSrc, cb);
|
---|
2248 |
|
---|
2249 | LogFlow(("pdmR3DevHlp_PhysWriteGCVirt: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2250 |
|
---|
2251 | return rc;
|
---|
2252 | }
|
---|
2253 |
|
---|
2254 |
|
---|
2255 | /** @copydoc PDMDEVHLPR3::pfnPhysGCPtr2GCPhys */
|
---|
2256 | static DECLCALLBACK(int) pdmR3DevHlp_PhysGCPtr2GCPhys(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTGCPHYS pGCPhys)
|
---|
2257 | {
|
---|
2258 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2259 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2260 | VM_ASSERT_EMT(pVM);
|
---|
2261 | LogFlow(("pdmR3DevHlp_PhysGCPtr2GCPhys: caller='%s'/%d: GCPtr=%RGv pGCPhys=%p\n",
|
---|
2262 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPtr, pGCPhys));
|
---|
2263 |
|
---|
2264 | PVMCPU pVCpu = VMMGetCpu(pVM);
|
---|
2265 | if (!pVCpu)
|
---|
2266 | return VERR_ACCESS_DENIED;
|
---|
2267 | #if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
|
---|
2268 | /** @todo SMP. */
|
---|
2269 | #endif
|
---|
2270 |
|
---|
2271 | int rc = PGMPhysGCPtr2GCPhys(pVCpu, GCPtr, pGCPhys);
|
---|
2272 |
|
---|
2273 | LogFlow(("pdmR3DevHlp_PhysGCPtr2GCPhys: caller='%s'/%d: returns %Rrc *pGCPhys=%RGp\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc, *pGCPhys));
|
---|
2274 |
|
---|
2275 | return rc;
|
---|
2276 | }
|
---|
2277 |
|
---|
2278 |
|
---|
2279 | /** @copydoc PDMDEVHLPR3::pfnVMState */
|
---|
2280 | static DECLCALLBACK(VMSTATE) pdmR3DevHlp_VMState(PPDMDEVINS pDevIns)
|
---|
2281 | {
|
---|
2282 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2283 |
|
---|
2284 | VMSTATE enmVMState = VMR3GetState(pDevIns->Internal.s.pVMR3);
|
---|
2285 |
|
---|
2286 | LogFlow(("pdmR3DevHlp_VMState: caller='%s'/%d: returns %d (%s)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance,
|
---|
2287 | enmVMState, VMR3GetStateName(enmVMState)));
|
---|
2288 | return enmVMState;
|
---|
2289 | }
|
---|
2290 |
|
---|
2291 |
|
---|
2292 | /** @copydoc PDMDEVHLPR3::pfnA20IsEnabled */
|
---|
2293 | static DECLCALLBACK(bool) pdmR3DevHlp_A20IsEnabled(PPDMDEVINS pDevIns)
|
---|
2294 | {
|
---|
2295 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2296 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
2297 |
|
---|
2298 | bool fRc = PGMPhysIsA20Enabled(VMMGetCpu(pDevIns->Internal.s.pVMR3));
|
---|
2299 |
|
---|
2300 | LogFlow(("pdmR3DevHlp_A20IsEnabled: caller='%s'/%d: returns %d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, fRc));
|
---|
2301 | return fRc;
|
---|
2302 | }
|
---|
2303 |
|
---|
2304 |
|
---|
2305 | /** @copydoc PDMDEVHLPR3::pfnA20Set */
|
---|
2306 | static DECLCALLBACK(void) pdmR3DevHlp_A20Set(PPDMDEVINS pDevIns, bool fEnable)
|
---|
2307 | {
|
---|
2308 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2309 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
2310 | LogFlow(("pdmR3DevHlp_A20Set: caller='%s'/%d: fEnable=%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, fEnable));
|
---|
2311 | PGMR3PhysSetA20(VMMGetCpu(pDevIns->Internal.s.pVMR3), fEnable);
|
---|
2312 | }
|
---|
2313 |
|
---|
2314 |
|
---|
2315 | /** @copydoc PDMDEVHLPR3::pfnVMReset */
|
---|
2316 | static DECLCALLBACK(int) pdmR3DevHlp_VMReset(PPDMDEVINS pDevIns)
|
---|
2317 | {
|
---|
2318 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2319 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2320 | VM_ASSERT_EMT(pVM);
|
---|
2321 | LogFlow(("pdmR3DevHlp_VMReset: caller='%s'/%d: VM_FF_RESET %d -> 1\n",
|
---|
2322 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VM_FF_ISSET(pVM, VM_FF_RESET)));
|
---|
2323 |
|
---|
2324 | /*
|
---|
2325 | * We postpone this operation because we're likely to be inside a I/O instruction
|
---|
2326 | * and the EIP will be updated when we return.
|
---|
2327 | * We still return VINF_EM_RESET to break out of any execution loops and force FF evaluation.
|
---|
2328 | */
|
---|
2329 | bool fHaltOnReset;
|
---|
2330 | int rc = CFGMR3QueryBool(CFGMR3GetChild(CFGMR3GetRoot(pVM), "PDM"), "HaltOnReset", &fHaltOnReset);
|
---|
2331 | if (RT_SUCCESS(rc) && fHaltOnReset)
|
---|
2332 | {
|
---|
2333 | Log(("pdmR3DevHlp_VMReset: Halt On Reset!\n"));
|
---|
2334 | rc = VINF_EM_HALT;
|
---|
2335 | }
|
---|
2336 | else
|
---|
2337 | {
|
---|
2338 | VM_FF_SET(pVM, VM_FF_RESET);
|
---|
2339 | rc = VINF_EM_RESET;
|
---|
2340 | }
|
---|
2341 |
|
---|
2342 | LogFlow(("pdmR3DevHlp_VMReset: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2343 | return rc;
|
---|
2344 | }
|
---|
2345 |
|
---|
2346 |
|
---|
2347 | /** @copydoc PDMDEVHLPR3::pfnVMSuspend */
|
---|
2348 | static DECLCALLBACK(int) pdmR3DevHlp_VMSuspend(PPDMDEVINS pDevIns)
|
---|
2349 | {
|
---|
2350 | int rc;
|
---|
2351 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2352 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2353 | VM_ASSERT_EMT(pVM);
|
---|
2354 | LogFlow(("pdmR3DevHlp_VMSuspend: caller='%s'/%d:\n",
|
---|
2355 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2356 |
|
---|
2357 | if (pVM->cCPUs > 1)
|
---|
2358 | {
|
---|
2359 | /* We own the IOM lock here and could cause a deadlock by waiting for a VCPU that is blocking on the IOM lock. */
|
---|
2360 | PVMREQ pReq;
|
---|
2361 | rc = VMR3ReqCallU(pVM->pUVM, VMCPUID_ANY_QUEUE, &pReq, 0, VMREQFLAGS_NO_WAIT,
|
---|
2362 | (PFNRT)VMR3Suspend, 1, pVM);
|
---|
2363 | AssertRC(rc);
|
---|
2364 | rc = VINF_EM_SUSPEND;
|
---|
2365 | }
|
---|
2366 | else
|
---|
2367 | rc = VMR3Suspend(pVM);
|
---|
2368 |
|
---|
2369 | LogFlow(("pdmR3DevHlp_VMSuspend: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2370 | return rc;
|
---|
2371 | }
|
---|
2372 |
|
---|
2373 |
|
---|
2374 | /** @copydoc PDMDEVHLPR3::pfnVMPowerOff */
|
---|
2375 | static DECLCALLBACK(int) pdmR3DevHlp_VMPowerOff(PPDMDEVINS pDevIns)
|
---|
2376 | {
|
---|
2377 | int rc;
|
---|
2378 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2379 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2380 | VM_ASSERT_EMT(pVM);
|
---|
2381 | LogFlow(("pdmR3DevHlp_VMPowerOff: caller='%s'/%d:\n",
|
---|
2382 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2383 |
|
---|
2384 | if (pVM->cCPUs > 1)
|
---|
2385 | {
|
---|
2386 | /* We own the IOM lock here and could cause a deadlock by waiting for a VCPU that is blocking on the IOM lock. */
|
---|
2387 | PVMREQ pReq;
|
---|
2388 | rc = VMR3ReqCallU(pVM->pUVM, VMCPUID_ANY_QUEUE, &pReq, 0, VMREQFLAGS_NO_WAIT,
|
---|
2389 | (PFNRT)VMR3PowerOff, 1, pVM);
|
---|
2390 | AssertRC(rc);
|
---|
2391 | /* Set the VCPU state to stopped here as well to make sure no
|
---|
2392 | * inconsistency with the EM state occurs.
|
---|
2393 | */
|
---|
2394 | VMCPU_SET_STATE(VMMGetCpu(pVM), VMCPUSTATE_STOPPED);
|
---|
2395 | rc = VINF_EM_OFF;
|
---|
2396 | }
|
---|
2397 | else
|
---|
2398 | rc = VMR3PowerOff(pVM);
|
---|
2399 |
|
---|
2400 | LogFlow(("pdmR3DevHlp_VMPowerOff: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2401 | return rc;
|
---|
2402 | }
|
---|
2403 |
|
---|
2404 | /** @copydoc PDMDEVHLPR3::pfnDMARegister */
|
---|
2405 | static DECLCALLBACK(int) pdmR3DevHlp_DMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser)
|
---|
2406 | {
|
---|
2407 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2408 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2409 | VM_ASSERT_EMT(pVM);
|
---|
2410 | LogFlow(("pdmR3DevHlp_DMARegister: caller='%s'/%d: uChannel=%d pfnTransferHandler=%p pvUser=%p\n",
|
---|
2411 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, uChannel, pfnTransferHandler, pvUser));
|
---|
2412 | int rc = VINF_SUCCESS;
|
---|
2413 | if (pVM->pdm.s.pDmac)
|
---|
2414 | pVM->pdm.s.pDmac->Reg.pfnRegister(pVM->pdm.s.pDmac->pDevIns, uChannel, pfnTransferHandler, pvUser);
|
---|
2415 | else
|
---|
2416 | {
|
---|
2417 | AssertMsgFailed(("Configuration error: No DMAC controller available. This could be related to init order too!\n"));
|
---|
2418 | rc = VERR_PDM_NO_DMAC_INSTANCE;
|
---|
2419 | }
|
---|
2420 | LogFlow(("pdmR3DevHlp_DMARegister: caller='%s'/%d: returns %Rrc\n",
|
---|
2421 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2422 | return rc;
|
---|
2423 | }
|
---|
2424 |
|
---|
2425 | /** @copydoc PDMDEVHLPR3::pfnDMAReadMemory */
|
---|
2426 | static DECLCALLBACK(int) pdmR3DevHlp_DMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead)
|
---|
2427 | {
|
---|
2428 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2429 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2430 | VM_ASSERT_EMT(pVM);
|
---|
2431 | LogFlow(("pdmR3DevHlp_DMAReadMemory: caller='%s'/%d: uChannel=%d pvBuffer=%p off=%#x cbBlock=%#x pcbRead=%p\n",
|
---|
2432 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, uChannel, pvBuffer, off, cbBlock, pcbRead));
|
---|
2433 | int rc = VINF_SUCCESS;
|
---|
2434 | if (pVM->pdm.s.pDmac)
|
---|
2435 | {
|
---|
2436 | uint32_t cb = pVM->pdm.s.pDmac->Reg.pfnReadMemory(pVM->pdm.s.pDmac->pDevIns, uChannel, pvBuffer, off, cbBlock);
|
---|
2437 | if (pcbRead)
|
---|
2438 | *pcbRead = cb;
|
---|
2439 | }
|
---|
2440 | else
|
---|
2441 | {
|
---|
2442 | AssertMsgFailed(("Configuration error: No DMAC controller available. This could be related to init order too!\n"));
|
---|
2443 | rc = VERR_PDM_NO_DMAC_INSTANCE;
|
---|
2444 | }
|
---|
2445 | LogFlow(("pdmR3DevHlp_DMAReadMemory: caller='%s'/%d: returns %Rrc\n",
|
---|
2446 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2447 | return rc;
|
---|
2448 | }
|
---|
2449 |
|
---|
2450 | /** @copydoc PDMDEVHLPR3::pfnDMAWriteMemory */
|
---|
2451 | static DECLCALLBACK(int) pdmR3DevHlp_DMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten)
|
---|
2452 | {
|
---|
2453 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2454 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2455 | VM_ASSERT_EMT(pVM);
|
---|
2456 | LogFlow(("pdmR3DevHlp_DMAWriteMemory: caller='%s'/%d: uChannel=%d pvBuffer=%p off=%#x cbBlock=%#x pcbWritten=%p\n",
|
---|
2457 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, uChannel, pvBuffer, off, cbBlock, pcbWritten));
|
---|
2458 | int rc = VINF_SUCCESS;
|
---|
2459 | if (pVM->pdm.s.pDmac)
|
---|
2460 | {
|
---|
2461 | uint32_t cb = pVM->pdm.s.pDmac->Reg.pfnWriteMemory(pVM->pdm.s.pDmac->pDevIns, uChannel, pvBuffer, off, cbBlock);
|
---|
2462 | if (pcbWritten)
|
---|
2463 | *pcbWritten = cb;
|
---|
2464 | }
|
---|
2465 | else
|
---|
2466 | {
|
---|
2467 | AssertMsgFailed(("Configuration error: No DMAC controller available. This could be related to init order too!\n"));
|
---|
2468 | rc = VERR_PDM_NO_DMAC_INSTANCE;
|
---|
2469 | }
|
---|
2470 | LogFlow(("pdmR3DevHlp_DMAWriteMemory: caller='%s'/%d: returns %Rrc\n",
|
---|
2471 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2472 | return rc;
|
---|
2473 | }
|
---|
2474 |
|
---|
2475 | /** @copydoc PDMDEVHLPR3::pfnDMASetDREQ */
|
---|
2476 | static DECLCALLBACK(int) pdmR3DevHlp_DMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel)
|
---|
2477 | {
|
---|
2478 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2479 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2480 | VM_ASSERT_EMT(pVM);
|
---|
2481 | LogFlow(("pdmR3DevHlp_DMASetDREQ: caller='%s'/%d: uChannel=%d uLevel=%d\n",
|
---|
2482 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, uChannel, uLevel));
|
---|
2483 | int rc = VINF_SUCCESS;
|
---|
2484 | if (pVM->pdm.s.pDmac)
|
---|
2485 | pVM->pdm.s.pDmac->Reg.pfnSetDREQ(pVM->pdm.s.pDmac->pDevIns, uChannel, uLevel);
|
---|
2486 | else
|
---|
2487 | {
|
---|
2488 | AssertMsgFailed(("Configuration error: No DMAC controller available. This could be related to init order too!\n"));
|
---|
2489 | rc = VERR_PDM_NO_DMAC_INSTANCE;
|
---|
2490 | }
|
---|
2491 | LogFlow(("pdmR3DevHlp_DMASetDREQ: caller='%s'/%d: returns %Rrc\n",
|
---|
2492 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2493 | return rc;
|
---|
2494 | }
|
---|
2495 |
|
---|
2496 | /** @copydoc PDMDEVHLPR3::pfnDMAGetChannelMode */
|
---|
2497 | static DECLCALLBACK(uint8_t) pdmR3DevHlp_DMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel)
|
---|
2498 | {
|
---|
2499 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2500 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2501 | VM_ASSERT_EMT(pVM);
|
---|
2502 | LogFlow(("pdmR3DevHlp_DMAGetChannelMode: caller='%s'/%d: uChannel=%d\n",
|
---|
2503 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, uChannel));
|
---|
2504 | uint8_t u8Mode;
|
---|
2505 | if (pVM->pdm.s.pDmac)
|
---|
2506 | u8Mode = pVM->pdm.s.pDmac->Reg.pfnGetChannelMode(pVM->pdm.s.pDmac->pDevIns, uChannel);
|
---|
2507 | else
|
---|
2508 | {
|
---|
2509 | AssertMsgFailed(("Configuration error: No DMAC controller available. This could be related to init order too!\n"));
|
---|
2510 | u8Mode = 3 << 2 /* illegal mode type */;
|
---|
2511 | }
|
---|
2512 | LogFlow(("pdmR3DevHlp_DMAGetChannelMode: caller='%s'/%d: returns %#04x\n",
|
---|
2513 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, u8Mode));
|
---|
2514 | return u8Mode;
|
---|
2515 | }
|
---|
2516 |
|
---|
2517 | /** @copydoc PDMDEVHLPR3::pfnDMASchedule */
|
---|
2518 | static DECLCALLBACK(void) pdmR3DevHlp_DMASchedule(PPDMDEVINS pDevIns)
|
---|
2519 | {
|
---|
2520 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2521 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2522 | VM_ASSERT_EMT(pVM);
|
---|
2523 | LogFlow(("pdmR3DevHlp_DMASchedule: caller='%s'/%d: VM_FF_PDM_DMA %d -> 1\n",
|
---|
2524 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VM_FF_ISSET(pVM, VM_FF_PDM_DMA)));
|
---|
2525 |
|
---|
2526 | AssertMsg(pVM->pdm.s.pDmac, ("Configuration error: No DMAC controller available. This could be related to init order too!\n"));
|
---|
2527 | VM_FF_SET(pVM, VM_FF_PDM_DMA);
|
---|
2528 | REMR3NotifyDmaPending(pVM);
|
---|
2529 | VMR3NotifyGlobalFFU(pVM->pUVM, VMNOTIFYFF_FLAGS_DONE_REM);
|
---|
2530 | }
|
---|
2531 |
|
---|
2532 |
|
---|
2533 | /** @copydoc PDMDEVHLPR3::pfnCMOSWrite */
|
---|
2534 | static DECLCALLBACK(int) pdmR3DevHlp_CMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value)
|
---|
2535 | {
|
---|
2536 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2537 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2538 | VM_ASSERT_EMT(pVM);
|
---|
2539 |
|
---|
2540 | LogFlow(("pdmR3DevHlp_CMOSWrite: caller='%s'/%d: iReg=%#04x u8Value=%#04x\n",
|
---|
2541 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iReg, u8Value));
|
---|
2542 | int rc;
|
---|
2543 | if (pVM->pdm.s.pRtc)
|
---|
2544 | rc = pVM->pdm.s.pRtc->Reg.pfnWrite(pVM->pdm.s.pRtc->pDevIns, iReg, u8Value);
|
---|
2545 | else
|
---|
2546 | rc = VERR_PDM_NO_RTC_INSTANCE;
|
---|
2547 |
|
---|
2548 | LogFlow(("pdmR3DevHlp_CMOSWrite: caller='%s'/%d: return %Rrc\n",
|
---|
2549 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2550 | return rc;
|
---|
2551 | }
|
---|
2552 |
|
---|
2553 |
|
---|
2554 | /** @copydoc PDMDEVHLPR3::pfnCMOSRead */
|
---|
2555 | static DECLCALLBACK(int) pdmR3DevHlp_CMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value)
|
---|
2556 | {
|
---|
2557 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2558 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2559 | VM_ASSERT_EMT(pVM);
|
---|
2560 |
|
---|
2561 | LogFlow(("pdmR3DevHlp_CMOSWrite: caller='%s'/%d: iReg=%#04x pu8Value=%p\n",
|
---|
2562 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iReg, pu8Value));
|
---|
2563 | int rc;
|
---|
2564 | if (pVM->pdm.s.pRtc)
|
---|
2565 | rc = pVM->pdm.s.pRtc->Reg.pfnRead(pVM->pdm.s.pRtc->pDevIns, iReg, pu8Value);
|
---|
2566 | else
|
---|
2567 | rc = VERR_PDM_NO_RTC_INSTANCE;
|
---|
2568 |
|
---|
2569 | LogFlow(("pdmR3DevHlp_CMOSWrite: caller='%s'/%d: return %Rrc\n",
|
---|
2570 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2571 | return rc;
|
---|
2572 | }
|
---|
2573 |
|
---|
2574 |
|
---|
2575 | /** @copydoc PDMDEVHLPR3::pfnGetCpuId */
|
---|
2576 | static DECLCALLBACK(void) pdmR3DevHlp_GetCpuId(PPDMDEVINS pDevIns, uint32_t iLeaf,
|
---|
2577 | uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx)
|
---|
2578 | {
|
---|
2579 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2580 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
2581 |
|
---|
2582 | LogFlow(("pdmR3DevHlp_GetCpuId: caller='%s'/%d: iLeaf=%d pEax=%p pEbx=%p pEcx=%p pEdx=%p\n",
|
---|
2583 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iLeaf, pEax, pEbx, pEcx, pEdx));
|
---|
2584 | AssertPtr(pEax); AssertPtr(pEbx); AssertPtr(pEcx); AssertPtr(pEdx);
|
---|
2585 |
|
---|
2586 | CPUMGetGuestCpuId(VMMGetCpu(pDevIns->Internal.s.pVMR3), iLeaf, pEax, pEbx, pEcx, pEdx);
|
---|
2587 |
|
---|
2588 | LogFlow(("pdmR3DevHlp_GetCpuId: caller='%s'/%d: returns void - *pEax=%#x *pEbx=%#x *pEcx=%#x *pEdx=%#x\n",
|
---|
2589 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, *pEax, *pEbx, *pEcx, *pEdx));
|
---|
2590 | }
|
---|
2591 |
|
---|
2592 |
|
---|
2593 | /** @copydoc PDMDEVHLPR3::pfnROMProtectShadow */
|
---|
2594 | static DECLCALLBACK(int) pdmR3DevHlp_ROMProtectShadow(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, PGMROMPROT enmProt)
|
---|
2595 | {
|
---|
2596 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2597 | LogFlow(("pdmR3DevHlp_ROMProtectShadow: caller='%s'/%d: GCPhysStart=%RGp cbRange=%#x enmProt=%d\n",
|
---|
2598 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhysStart, cbRange, enmProt));
|
---|
2599 |
|
---|
2600 | int rc = PGMR3PhysRomProtect(pDevIns->Internal.s.pVMR3, GCPhysStart, cbRange, enmProt);
|
---|
2601 |
|
---|
2602 | LogFlow(("pdmR3DevHlp_ROMProtectShadow: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2603 | return rc;
|
---|
2604 | }
|
---|
2605 |
|
---|
2606 |
|
---|
2607 | /**
|
---|
2608 | * @copydoc PDMDEVHLPR3::pfnMMIO2Register
|
---|
2609 | */
|
---|
2610 | static DECLCALLBACK(int) pdmR3DevHlp_MMIO2Register(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc)
|
---|
2611 | {
|
---|
2612 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2613 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
2614 | LogFlow(("pdmR3DevHlp_MMIO2Register: caller='%s'/%d: iRegion=#x cb=%#RGp fFlags=%RX32 ppv=%p pszDescp=%p:{%s}\n",
|
---|
2615 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iRegion, cb, fFlags, ppv, pszDesc, pszDesc));
|
---|
2616 |
|
---|
2617 | /** @todo PGMR3PhysMMIO2Register mangles the description, move it here and
|
---|
2618 | * use a real string cache. */
|
---|
2619 | int rc = PGMR3PhysMMIO2Register(pDevIns->Internal.s.pVMR3, pDevIns, iRegion, cb, fFlags, ppv, pszDesc);
|
---|
2620 |
|
---|
2621 | LogFlow(("pdmR3DevHlp_MMIO2Register: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2622 | return rc;
|
---|
2623 | }
|
---|
2624 |
|
---|
2625 |
|
---|
2626 | /**
|
---|
2627 | * @copydoc PDMDEVHLPR3::pfnMMIO2Deregister
|
---|
2628 | */
|
---|
2629 | static DECLCALLBACK(int) pdmR3DevHlp_MMIO2Deregister(PPDMDEVINS pDevIns, uint32_t iRegion)
|
---|
2630 | {
|
---|
2631 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2632 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
2633 | LogFlow(("pdmR3DevHlp_MMIO2Deregister: caller='%s'/%d: iRegion=#x\n",
|
---|
2634 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iRegion));
|
---|
2635 |
|
---|
2636 | AssertReturn(iRegion == UINT32_MAX, VERR_INVALID_PARAMETER);
|
---|
2637 |
|
---|
2638 | int rc = PGMR3PhysMMIO2Deregister(pDevIns->Internal.s.pVMR3, pDevIns, iRegion);
|
---|
2639 |
|
---|
2640 | LogFlow(("pdmR3DevHlp_MMIO2Deregister: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2641 | return rc;
|
---|
2642 | }
|
---|
2643 |
|
---|
2644 |
|
---|
2645 | /**
|
---|
2646 | * @copydoc PDMDEVHLPR3::pfnMMIO2Map
|
---|
2647 | */
|
---|
2648 | static DECLCALLBACK(int) pdmR3DevHlp_MMIO2Map(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys)
|
---|
2649 | {
|
---|
2650 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2651 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
2652 | LogFlow(("pdmR3DevHlp_MMIO2Map: caller='%s'/%d: iRegion=#x GCPhys=%#RGp\n",
|
---|
2653 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iRegion, GCPhys));
|
---|
2654 |
|
---|
2655 | int rc = PGMR3PhysMMIO2Map(pDevIns->Internal.s.pVMR3, pDevIns, iRegion, GCPhys);
|
---|
2656 |
|
---|
2657 | LogFlow(("pdmR3DevHlp_MMIO2Map: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2658 | return rc;
|
---|
2659 | }
|
---|
2660 |
|
---|
2661 |
|
---|
2662 | /**
|
---|
2663 | * @copydoc PDMDEVHLPR3::pfnMMIO2Unmap
|
---|
2664 | */
|
---|
2665 | static DECLCALLBACK(int) pdmR3DevHlp_MMIO2Unmap(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys)
|
---|
2666 | {
|
---|
2667 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2668 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
2669 | LogFlow(("pdmR3DevHlp_MMIO2Unmap: caller='%s'/%d: iRegion=#x GCPhys=%#RGp\n",
|
---|
2670 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iRegion, GCPhys));
|
---|
2671 |
|
---|
2672 | int rc = PGMR3PhysMMIO2Unmap(pDevIns->Internal.s.pVMR3, pDevIns, iRegion, GCPhys);
|
---|
2673 |
|
---|
2674 | LogFlow(("pdmR3DevHlp_MMIO2Unmap: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2675 | return rc;
|
---|
2676 | }
|
---|
2677 |
|
---|
2678 |
|
---|
2679 | /**
|
---|
2680 | * @copydoc PDMDEVHLPR3::pfnMMHyperMapMMIO2
|
---|
2681 | */
|
---|
2682 | static DECLCALLBACK(int) pdmR3DevHlp_MMHyperMapMMIO2(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
|
---|
2683 | const char *pszDesc, PRTRCPTR pRCPtr)
|
---|
2684 | {
|
---|
2685 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2686 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2687 | VM_ASSERT_EMT(pVM);
|
---|
2688 | LogFlow(("pdmR3DevHlp_MMHyperMapMMIO2: caller='%s'/%d: iRegion=#x off=%RGp cb=%RGp pszDesc=%p:{%s} pRCPtr=%p\n",
|
---|
2689 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iRegion, off, cb, pszDesc, pszDesc, pRCPtr));
|
---|
2690 |
|
---|
2691 | if (pDevIns->iInstance > 0)
|
---|
2692 | {
|
---|
2693 | char *pszDesc2 = MMR3HeapAPrintf(pVM, MM_TAG_PDM_DEVICE_DESC, "%s [%u]", pszDesc, pDevIns->iInstance);
|
---|
2694 | if (pszDesc2)
|
---|
2695 | pszDesc = pszDesc2;
|
---|
2696 | }
|
---|
2697 |
|
---|
2698 | int rc = MMR3HyperMapMMIO2(pVM, pDevIns, iRegion, off, cb, pszDesc, pRCPtr);
|
---|
2699 |
|
---|
2700 | LogFlow(("pdmR3DevHlp_MMHyperMapMMIO2: caller='%s'/%d: returns %Rrc *pRCPtr=%RRv\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc, *pRCPtr));
|
---|
2701 | return rc;
|
---|
2702 | }
|
---|
2703 |
|
---|
2704 |
|
---|
2705 | /**
|
---|
2706 | * @copydoc PDMDEVHLPR3::pfnMMIO2MapKernel
|
---|
2707 | */
|
---|
2708 | static DECLCALLBACK(int) pdmR3DevHlp_MMIO2MapKernel(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
|
---|
2709 | const char *pszDesc, PRTR0PTR pR0Ptr)
|
---|
2710 | {
|
---|
2711 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2712 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
2713 | VM_ASSERT_EMT(pVM);
|
---|
2714 | LogFlow(("pdmR3DevHlp_MMIO2MapKernel: caller='%s'/%d: iRegion=#x off=%RGp cb=%RGp pszDesc=%p:{%s} pR0Ptr=%p\n",
|
---|
2715 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iRegion, off, cb, pszDesc, pszDesc, pR0Ptr));
|
---|
2716 |
|
---|
2717 | if (pDevIns->iInstance > 0)
|
---|
2718 | {
|
---|
2719 | char *pszDesc2 = MMR3HeapAPrintf(pVM, MM_TAG_PDM_DEVICE_DESC, "%s [%u]", pszDesc, pDevIns->iInstance);
|
---|
2720 | if (pszDesc2)
|
---|
2721 | pszDesc = pszDesc2;
|
---|
2722 | }
|
---|
2723 |
|
---|
2724 | int rc = PGMR3PhysMMIO2MapKernel(pVM, pDevIns, iRegion, off, cb, pszDesc, pR0Ptr);
|
---|
2725 |
|
---|
2726 | LogFlow(("pdmR3DevHlp_MMIO2MapKernel: caller='%s'/%d: returns %Rrc *pR0Ptr=%RHv\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc, *pR0Ptr));
|
---|
2727 | return rc;
|
---|
2728 | }
|
---|
2729 |
|
---|
2730 |
|
---|
2731 | /**
|
---|
2732 | * @copydoc PDMDEVHLPR3::pfnRegisterVMMDevHeap
|
---|
2733 | */
|
---|
2734 | static DECLCALLBACK(int) pdmR3DevHlp_RegisterVMMDevHeap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTR3PTR pvHeap, unsigned cbSize)
|
---|
2735 | {
|
---|
2736 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2737 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
2738 |
|
---|
2739 | int rc = PDMR3RegisterVMMDevHeap(pDevIns->Internal.s.pVMR3, GCPhys, pvHeap, cbSize);
|
---|
2740 | return rc;
|
---|
2741 | }
|
---|
2742 |
|
---|
2743 |
|
---|
2744 | /**
|
---|
2745 | * @copydoc PDMDEVHLPR3::pfnUnregisterVMMDevHeap
|
---|
2746 | */
|
---|
2747 | static DECLCALLBACK(int) pdmR3DevHlp_UnregisterVMMDevHeap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys)
|
---|
2748 | {
|
---|
2749 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2750 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
2751 |
|
---|
2752 | int rc = PDMR3UnregisterVMMDevHeap(pDevIns->Internal.s.pVMR3, GCPhys);
|
---|
2753 | return rc;
|
---|
2754 | }
|
---|
2755 |
|
---|
2756 |
|
---|
2757 | /**
|
---|
2758 | * The device helper structure for trusted devices.
|
---|
2759 | */
|
---|
2760 | const PDMDEVHLPR3 g_pdmR3DevHlpTrusted =
|
---|
2761 | {
|
---|
2762 | PDM_DEVHLP_VERSION,
|
---|
2763 | pdmR3DevHlp_IOPortRegister,
|
---|
2764 | pdmR3DevHlp_IOPortRegisterGC,
|
---|
2765 | pdmR3DevHlp_IOPortRegisterR0,
|
---|
2766 | pdmR3DevHlp_IOPortDeregister,
|
---|
2767 | pdmR3DevHlp_MMIORegister,
|
---|
2768 | pdmR3DevHlp_MMIORegisterGC,
|
---|
2769 | pdmR3DevHlp_MMIORegisterR0,
|
---|
2770 | pdmR3DevHlp_MMIODeregister,
|
---|
2771 | pdmR3DevHlp_ROMRegister,
|
---|
2772 | pdmR3DevHlp_SSMRegister,
|
---|
2773 | pdmR3DevHlp_TMTimerCreate,
|
---|
2774 | pdmR3DevHlp_PCIRegister,
|
---|
2775 | pdmR3DevHlp_PCIIORegionRegister,
|
---|
2776 | pdmR3DevHlp_PCISetConfigCallbacks,
|
---|
2777 | pdmR3DevHlp_PCISetIrq,
|
---|
2778 | pdmR3DevHlp_PCISetIrqNoWait,
|
---|
2779 | pdmR3DevHlp_ISASetIrq,
|
---|
2780 | pdmR3DevHlp_ISASetIrqNoWait,
|
---|
2781 | pdmR3DevHlp_DriverAttach,
|
---|
2782 | pdmR3DevHlp_MMHeapAlloc,
|
---|
2783 | pdmR3DevHlp_MMHeapAllocZ,
|
---|
2784 | pdmR3DevHlp_MMHeapFree,
|
---|
2785 | pdmR3DevHlp_VMSetError,
|
---|
2786 | pdmR3DevHlp_VMSetErrorV,
|
---|
2787 | pdmR3DevHlp_VMSetRuntimeError,
|
---|
2788 | pdmR3DevHlp_VMSetRuntimeErrorV,
|
---|
2789 | pdmR3DevHlp_AssertEMT,
|
---|
2790 | pdmR3DevHlp_AssertOther,
|
---|
2791 | pdmR3DevHlp_DBGFStopV,
|
---|
2792 | pdmR3DevHlp_DBGFInfoRegister,
|
---|
2793 | pdmR3DevHlp_STAMRegister,
|
---|
2794 | pdmR3DevHlp_STAMRegisterF,
|
---|
2795 | pdmR3DevHlp_STAMRegisterV,
|
---|
2796 | pdmR3DevHlp_RTCRegister,
|
---|
2797 | pdmR3DevHlp_PDMQueueCreate,
|
---|
2798 | pdmR3DevHlp_CritSectInit,
|
---|
2799 | pdmR3DevHlp_UTCNow,
|
---|
2800 | pdmR3DevHlp_PDMThreadCreate,
|
---|
2801 | pdmR3DevHlp_PhysGCPtr2GCPhys,
|
---|
2802 | pdmR3DevHlp_VMState,
|
---|
2803 | 0,
|
---|
2804 | 0,
|
---|
2805 | 0,
|
---|
2806 | 0,
|
---|
2807 | 0,
|
---|
2808 | 0,
|
---|
2809 | 0,
|
---|
2810 | pdmR3DevHlp_GetVM,
|
---|
2811 | pdmR3DevHlp_PCIBusRegister,
|
---|
2812 | pdmR3DevHlp_PICRegister,
|
---|
2813 | pdmR3DevHlp_APICRegister,
|
---|
2814 | pdmR3DevHlp_IOAPICRegister,
|
---|
2815 | pdmR3DevHlp_DMACRegister,
|
---|
2816 | pdmR3DevHlp_PhysRead,
|
---|
2817 | pdmR3DevHlp_PhysWrite,
|
---|
2818 | pdmR3DevHlp_PhysGCPhys2CCPtr,
|
---|
2819 | pdmR3DevHlp_PhysGCPhys2CCPtrReadOnly,
|
---|
2820 | pdmR3DevHlp_PhysReleasePageMappingLock,
|
---|
2821 | pdmR3DevHlp_PhysReadGCVirt,
|
---|
2822 | pdmR3DevHlp_PhysWriteGCVirt,
|
---|
2823 | pdmR3DevHlp_A20IsEnabled,
|
---|
2824 | pdmR3DevHlp_A20Set,
|
---|
2825 | pdmR3DevHlp_VMReset,
|
---|
2826 | pdmR3DevHlp_VMSuspend,
|
---|
2827 | pdmR3DevHlp_VMPowerOff,
|
---|
2828 | pdmR3DevHlp_DMARegister,
|
---|
2829 | pdmR3DevHlp_DMAReadMemory,
|
---|
2830 | pdmR3DevHlp_DMAWriteMemory,
|
---|
2831 | pdmR3DevHlp_DMASetDREQ,
|
---|
2832 | pdmR3DevHlp_DMAGetChannelMode,
|
---|
2833 | pdmR3DevHlp_DMASchedule,
|
---|
2834 | pdmR3DevHlp_CMOSWrite,
|
---|
2835 | pdmR3DevHlp_CMOSRead,
|
---|
2836 | pdmR3DevHlp_GetCpuId,
|
---|
2837 | pdmR3DevHlp_ROMProtectShadow,
|
---|
2838 | pdmR3DevHlp_MMIO2Register,
|
---|
2839 | pdmR3DevHlp_MMIO2Deregister,
|
---|
2840 | pdmR3DevHlp_MMIO2Map,
|
---|
2841 | pdmR3DevHlp_MMIO2Unmap,
|
---|
2842 | pdmR3DevHlp_MMHyperMapMMIO2,
|
---|
2843 | pdmR3DevHlp_MMIO2MapKernel,
|
---|
2844 | pdmR3DevHlp_RegisterVMMDevHeap,
|
---|
2845 | pdmR3DevHlp_UnregisterVMMDevHeap,
|
---|
2846 | pdmR3DevHlp_GetVMCPU,
|
---|
2847 | PDM_DEVHLP_VERSION /* the end */
|
---|
2848 | };
|
---|
2849 |
|
---|
2850 |
|
---|
2851 |
|
---|
2852 |
|
---|
2853 | /** @copydoc PDMDEVHLPR3::pfnGetVM */
|
---|
2854 | static DECLCALLBACK(PVM) pdmR3DevHlp_Untrusted_GetVM(PPDMDEVINS pDevIns)
|
---|
2855 | {
|
---|
2856 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2857 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2858 | return NULL;
|
---|
2859 | }
|
---|
2860 |
|
---|
2861 |
|
---|
2862 | /** @copydoc PDMDEVHLPR3::pfnPCIBusRegister */
|
---|
2863 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3)
|
---|
2864 | {
|
---|
2865 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2866 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2867 | NOREF(pPciBusReg);
|
---|
2868 | NOREF(ppPciHlpR3);
|
---|
2869 | return VERR_ACCESS_DENIED;
|
---|
2870 | }
|
---|
2871 |
|
---|
2872 |
|
---|
2873 | /** @copydoc PDMDEVHLPR3::pfnPICRegister */
|
---|
2874 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3)
|
---|
2875 | {
|
---|
2876 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2877 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2878 | NOREF(pPicReg);
|
---|
2879 | NOREF(ppPicHlpR3);
|
---|
2880 | return VERR_ACCESS_DENIED;
|
---|
2881 | }
|
---|
2882 |
|
---|
2883 |
|
---|
2884 | /** @copydoc PDMDEVHLPR3::pfnAPICRegister */
|
---|
2885 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_APICRegister(PPDMDEVINS pDevIns, PPDMAPICREG pApicReg, PCPDMAPICHLPR3 *ppApicHlpR3)
|
---|
2886 | {
|
---|
2887 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2888 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2889 | NOREF(pApicReg);
|
---|
2890 | NOREF(ppApicHlpR3);
|
---|
2891 | return VERR_ACCESS_DENIED;
|
---|
2892 | }
|
---|
2893 |
|
---|
2894 |
|
---|
2895 | /** @copydoc PDMDEVHLPR3::pfnIOAPICRegister */
|
---|
2896 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_IOAPICRegister(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3)
|
---|
2897 | {
|
---|
2898 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2899 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2900 | NOREF(pIoApicReg);
|
---|
2901 | NOREF(ppIoApicHlpR3);
|
---|
2902 | return VERR_ACCESS_DENIED;
|
---|
2903 | }
|
---|
2904 |
|
---|
2905 |
|
---|
2906 | /** @copydoc PDMDEVHLPR3::pfnDMACRegister */
|
---|
2907 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMACRegister(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp)
|
---|
2908 | {
|
---|
2909 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2910 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2911 | NOREF(pDmacReg);
|
---|
2912 | NOREF(ppDmacHlp);
|
---|
2913 | return VERR_ACCESS_DENIED;
|
---|
2914 | }
|
---|
2915 |
|
---|
2916 |
|
---|
2917 | /** @copydoc PDMDEVHLPR3::pfnPhysRead */
|
---|
2918 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
|
---|
2919 | {
|
---|
2920 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2921 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2922 | NOREF(GCPhys);
|
---|
2923 | NOREF(pvBuf);
|
---|
2924 | NOREF(cbRead);
|
---|
2925 | return VERR_ACCESS_DENIED;
|
---|
2926 | }
|
---|
2927 |
|
---|
2928 |
|
---|
2929 | /** @copydoc PDMDEVHLPR3::pfnPhysWrite */
|
---|
2930 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
|
---|
2931 | {
|
---|
2932 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2933 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2934 | NOREF(GCPhys);
|
---|
2935 | NOREF(pvBuf);
|
---|
2936 | NOREF(cbWrite);
|
---|
2937 | return VERR_ACCESS_DENIED;
|
---|
2938 | }
|
---|
2939 |
|
---|
2940 |
|
---|
2941 | /** @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtr */
|
---|
2942 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysGCPhys2CCPtr(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock)
|
---|
2943 | {
|
---|
2944 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2945 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2946 | NOREF(GCPhys);
|
---|
2947 | NOREF(fFlags);
|
---|
2948 | NOREF(ppv);
|
---|
2949 | NOREF(pLock);
|
---|
2950 | return VERR_ACCESS_DENIED;
|
---|
2951 | }
|
---|
2952 |
|
---|
2953 |
|
---|
2954 | /** @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtrReadOnly */
|
---|
2955 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysGCPhys2CCPtrReadOnly(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, const void **ppv, PPGMPAGEMAPLOCK pLock)
|
---|
2956 | {
|
---|
2957 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2958 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2959 | NOREF(GCPhys);
|
---|
2960 | NOREF(fFlags);
|
---|
2961 | NOREF(ppv);
|
---|
2962 | NOREF(pLock);
|
---|
2963 | return VERR_ACCESS_DENIED;
|
---|
2964 | }
|
---|
2965 |
|
---|
2966 |
|
---|
2967 | /** @copydoc PDMDEVHLPR3::pfnPhysReleasePageMappingLock */
|
---|
2968 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_PhysReleasePageMappingLock(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock)
|
---|
2969 | {
|
---|
2970 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2971 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2972 | NOREF(pLock);
|
---|
2973 | }
|
---|
2974 |
|
---|
2975 |
|
---|
2976 | /** @copydoc PDMDEVHLPR3::pfnPhysReadGCVirt */
|
---|
2977 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb)
|
---|
2978 | {
|
---|
2979 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2980 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2981 | NOREF(pvDst);
|
---|
2982 | NOREF(GCVirtSrc);
|
---|
2983 | NOREF(cb);
|
---|
2984 | return VERR_ACCESS_DENIED;
|
---|
2985 | }
|
---|
2986 |
|
---|
2987 |
|
---|
2988 | /** @copydoc PDMDEVHLPR3::pfnPhysWriteGCVirt */
|
---|
2989 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb)
|
---|
2990 | {
|
---|
2991 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2992 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2993 | NOREF(GCVirtDst);
|
---|
2994 | NOREF(pvSrc);
|
---|
2995 | NOREF(cb);
|
---|
2996 | return VERR_ACCESS_DENIED;
|
---|
2997 | }
|
---|
2998 |
|
---|
2999 |
|
---|
3000 | /** @copydoc PDMDEVHLPR3::pfnA20IsEnabled */
|
---|
3001 | static DECLCALLBACK(bool) pdmR3DevHlp_Untrusted_A20IsEnabled(PPDMDEVINS pDevIns)
|
---|
3002 | {
|
---|
3003 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3004 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3005 | return false;
|
---|
3006 | }
|
---|
3007 |
|
---|
3008 |
|
---|
3009 | /** @copydoc PDMDEVHLPR3::pfnA20Set */
|
---|
3010 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_A20Set(PPDMDEVINS pDevIns, bool fEnable)
|
---|
3011 | {
|
---|
3012 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3013 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3014 | NOREF(fEnable);
|
---|
3015 | }
|
---|
3016 |
|
---|
3017 |
|
---|
3018 | /** @copydoc PDMDEVHLPR3::pfnVMReset */
|
---|
3019 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_VMReset(PPDMDEVINS pDevIns)
|
---|
3020 | {
|
---|
3021 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3022 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3023 | return VERR_ACCESS_DENIED;
|
---|
3024 | }
|
---|
3025 |
|
---|
3026 |
|
---|
3027 | /** @copydoc PDMDEVHLPR3::pfnVMSuspend */
|
---|
3028 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_VMSuspend(PPDMDEVINS pDevIns)
|
---|
3029 | {
|
---|
3030 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3031 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3032 | return VERR_ACCESS_DENIED;
|
---|
3033 | }
|
---|
3034 |
|
---|
3035 |
|
---|
3036 | /** @copydoc PDMDEVHLPR3::pfnVMPowerOff */
|
---|
3037 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_VMPowerOff(PPDMDEVINS pDevIns)
|
---|
3038 | {
|
---|
3039 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3040 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3041 | return VERR_ACCESS_DENIED;
|
---|
3042 | }
|
---|
3043 |
|
---|
3044 | /** @copydoc PDMDEVHLPR3::pfnDMARegister */
|
---|
3045 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser)
|
---|
3046 | {
|
---|
3047 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3048 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3049 | return VERR_ACCESS_DENIED;
|
---|
3050 | }
|
---|
3051 |
|
---|
3052 |
|
---|
3053 | /** @copydoc PDMDEVHLPR3::pfnDMAReadMemory */
|
---|
3054 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead)
|
---|
3055 | {
|
---|
3056 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3057 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3058 | if (pcbRead)
|
---|
3059 | *pcbRead = 0;
|
---|
3060 | return VERR_ACCESS_DENIED;
|
---|
3061 | }
|
---|
3062 |
|
---|
3063 |
|
---|
3064 | /** @copydoc PDMDEVHLPR3::pfnDMAWriteMemory */
|
---|
3065 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten)
|
---|
3066 | {
|
---|
3067 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3068 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3069 | if (pcbWritten)
|
---|
3070 | *pcbWritten = 0;
|
---|
3071 | return VERR_ACCESS_DENIED;
|
---|
3072 | }
|
---|
3073 |
|
---|
3074 |
|
---|
3075 | /** @copydoc PDMDEVHLPR3::pfnDMASetDREQ */
|
---|
3076 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel)
|
---|
3077 | {
|
---|
3078 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3079 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3080 | return VERR_ACCESS_DENIED;
|
---|
3081 | }
|
---|
3082 |
|
---|
3083 |
|
---|
3084 | /** @copydoc PDMDEVHLPR3::pfnDMAGetChannelMode */
|
---|
3085 | static DECLCALLBACK(uint8_t) pdmR3DevHlp_Untrusted_DMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel)
|
---|
3086 | {
|
---|
3087 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3088 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3089 | return 3 << 2 /* illegal mode type */;
|
---|
3090 | }
|
---|
3091 |
|
---|
3092 |
|
---|
3093 | /** @copydoc PDMDEVHLPR3::pfnDMASchedule */
|
---|
3094 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_DMASchedule(PPDMDEVINS pDevIns)
|
---|
3095 | {
|
---|
3096 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3097 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3098 | }
|
---|
3099 |
|
---|
3100 |
|
---|
3101 | /** @copydoc PDMDEVHLPR3::pfnCMOSWrite */
|
---|
3102 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_CMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value)
|
---|
3103 | {
|
---|
3104 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3105 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3106 | return VERR_ACCESS_DENIED;
|
---|
3107 | }
|
---|
3108 |
|
---|
3109 |
|
---|
3110 | /** @copydoc PDMDEVHLPR3::pfnCMOSRead */
|
---|
3111 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_CMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value)
|
---|
3112 | {
|
---|
3113 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3114 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3115 | return VERR_ACCESS_DENIED;
|
---|
3116 | }
|
---|
3117 |
|
---|
3118 |
|
---|
3119 | /** @copydoc PDMDEVHLPR3::pfnGetCpuId */
|
---|
3120 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_GetCpuId(PPDMDEVINS pDevIns, uint32_t iLeaf,
|
---|
3121 | uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx)
|
---|
3122 | {
|
---|
3123 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3124 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3125 | }
|
---|
3126 |
|
---|
3127 |
|
---|
3128 | /** @copydoc PDMDEVHLPR3::pfnROMProtectShadow */
|
---|
3129 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_ROMProtectShadow(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, PGMROMPROT enmProt)
|
---|
3130 | {
|
---|
3131 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3132 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3133 | return VERR_ACCESS_DENIED;
|
---|
3134 | }
|
---|
3135 |
|
---|
3136 |
|
---|
3137 | /** @copydoc PDMDEVHLPR3::pfnMMIO2Register */
|
---|
3138 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_MMIO2Register(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc)
|
---|
3139 | {
|
---|
3140 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3141 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3142 | return VERR_ACCESS_DENIED;
|
---|
3143 | }
|
---|
3144 |
|
---|
3145 |
|
---|
3146 | /** @copydoc PDMDEVHLPR3::pfnMMIO2Deregister */
|
---|
3147 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_MMIO2Deregister(PPDMDEVINS pDevIns, uint32_t iRegion)
|
---|
3148 | {
|
---|
3149 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3150 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3151 | return VERR_ACCESS_DENIED;
|
---|
3152 | }
|
---|
3153 |
|
---|
3154 |
|
---|
3155 | /** @copydoc PDMDEVHLPR3::pfnMMIO2Map */
|
---|
3156 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_MMIO2Map(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys)
|
---|
3157 | {
|
---|
3158 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3159 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3160 | return VERR_ACCESS_DENIED;
|
---|
3161 | }
|
---|
3162 |
|
---|
3163 |
|
---|
3164 | /** @copydoc PDMDEVHLPR3::pfnMMIO2Unmap */
|
---|
3165 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_MMIO2Unmap(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys)
|
---|
3166 | {
|
---|
3167 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3168 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3169 | return VERR_ACCESS_DENIED;
|
---|
3170 | }
|
---|
3171 |
|
---|
3172 |
|
---|
3173 | /** @copydoc PDMDEVHLPR3::pfnMMHyperMapMMIO2 */
|
---|
3174 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_MMHyperMapMMIO2(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb, const char *pszDesc, PRTRCPTR pRCPtr)
|
---|
3175 | {
|
---|
3176 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3177 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3178 | return VERR_ACCESS_DENIED;
|
---|
3179 | }
|
---|
3180 |
|
---|
3181 |
|
---|
3182 | /** @copydoc PDMDEVHLPR3::pfnMMIO2MapKernel */
|
---|
3183 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_MMIO2MapKernel(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb, const char *pszDesc, PRTR0PTR pR0Ptr)
|
---|
3184 | {
|
---|
3185 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3186 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3187 | return VERR_ACCESS_DENIED;
|
---|
3188 | }
|
---|
3189 |
|
---|
3190 |
|
---|
3191 | /** @copydoc PDMDEVHLPR3::pfnRegisterVMMDevHeap */
|
---|
3192 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_RegisterVMMDevHeap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTR3PTR pvHeap, unsigned cbSize)
|
---|
3193 | {
|
---|
3194 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3195 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3196 | return VERR_ACCESS_DENIED;
|
---|
3197 | }
|
---|
3198 |
|
---|
3199 |
|
---|
3200 | /** @copydoc PDMDEVHLPR3::pfnUnregisterVMMDevHeap */
|
---|
3201 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_UnregisterVMMDevHeap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys)
|
---|
3202 | {
|
---|
3203 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3204 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3205 | return VERR_ACCESS_DENIED;
|
---|
3206 | }
|
---|
3207 |
|
---|
3208 |
|
---|
3209 | /** @copydoc PDMDEVHLPR3::pfnGetVMCPU */
|
---|
3210 | static DECLCALLBACK(PVMCPU) pdmR3DevHlp_Untrusted_GetVMCPU(PPDMDEVINS pDevIns)
|
---|
3211 | {
|
---|
3212 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3213 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3214 | return NULL;
|
---|
3215 | }
|
---|
3216 |
|
---|
3217 |
|
---|
3218 | /**
|
---|
3219 | * The device helper structure for non-trusted devices.
|
---|
3220 | */
|
---|
3221 | const PDMDEVHLPR3 g_pdmR3DevHlpUnTrusted =
|
---|
3222 | {
|
---|
3223 | PDM_DEVHLP_VERSION,
|
---|
3224 | pdmR3DevHlp_IOPortRegister,
|
---|
3225 | pdmR3DevHlp_IOPortRegisterGC,
|
---|
3226 | pdmR3DevHlp_IOPortRegisterR0,
|
---|
3227 | pdmR3DevHlp_IOPortDeregister,
|
---|
3228 | pdmR3DevHlp_MMIORegister,
|
---|
3229 | pdmR3DevHlp_MMIORegisterGC,
|
---|
3230 | pdmR3DevHlp_MMIORegisterR0,
|
---|
3231 | pdmR3DevHlp_MMIODeregister,
|
---|
3232 | pdmR3DevHlp_ROMRegister,
|
---|
3233 | pdmR3DevHlp_SSMRegister,
|
---|
3234 | pdmR3DevHlp_TMTimerCreate,
|
---|
3235 | pdmR3DevHlp_PCIRegister,
|
---|
3236 | pdmR3DevHlp_PCIIORegionRegister,
|
---|
3237 | pdmR3DevHlp_PCISetConfigCallbacks,
|
---|
3238 | pdmR3DevHlp_PCISetIrq,
|
---|
3239 | pdmR3DevHlp_PCISetIrqNoWait,
|
---|
3240 | pdmR3DevHlp_ISASetIrq,
|
---|
3241 | pdmR3DevHlp_ISASetIrqNoWait,
|
---|
3242 | pdmR3DevHlp_DriverAttach,
|
---|
3243 | pdmR3DevHlp_MMHeapAlloc,
|
---|
3244 | pdmR3DevHlp_MMHeapAllocZ,
|
---|
3245 | pdmR3DevHlp_MMHeapFree,
|
---|
3246 | pdmR3DevHlp_VMSetError,
|
---|
3247 | pdmR3DevHlp_VMSetErrorV,
|
---|
3248 | pdmR3DevHlp_VMSetRuntimeError,
|
---|
3249 | pdmR3DevHlp_VMSetRuntimeErrorV,
|
---|
3250 | pdmR3DevHlp_AssertEMT,
|
---|
3251 | pdmR3DevHlp_AssertOther,
|
---|
3252 | pdmR3DevHlp_DBGFStopV,
|
---|
3253 | pdmR3DevHlp_DBGFInfoRegister,
|
---|
3254 | pdmR3DevHlp_STAMRegister,
|
---|
3255 | pdmR3DevHlp_STAMRegisterF,
|
---|
3256 | pdmR3DevHlp_STAMRegisterV,
|
---|
3257 | pdmR3DevHlp_RTCRegister,
|
---|
3258 | pdmR3DevHlp_PDMQueueCreate,
|
---|
3259 | pdmR3DevHlp_CritSectInit,
|
---|
3260 | pdmR3DevHlp_UTCNow,
|
---|
3261 | pdmR3DevHlp_PDMThreadCreate,
|
---|
3262 | pdmR3DevHlp_PhysGCPtr2GCPhys,
|
---|
3263 | pdmR3DevHlp_VMState,
|
---|
3264 | 0,
|
---|
3265 | 0,
|
---|
3266 | 0,
|
---|
3267 | 0,
|
---|
3268 | 0,
|
---|
3269 | 0,
|
---|
3270 | 0,
|
---|
3271 | pdmR3DevHlp_Untrusted_GetVM,
|
---|
3272 | pdmR3DevHlp_Untrusted_PCIBusRegister,
|
---|
3273 | pdmR3DevHlp_Untrusted_PICRegister,
|
---|
3274 | pdmR3DevHlp_Untrusted_APICRegister,
|
---|
3275 | pdmR3DevHlp_Untrusted_IOAPICRegister,
|
---|
3276 | pdmR3DevHlp_Untrusted_DMACRegister,
|
---|
3277 | pdmR3DevHlp_Untrusted_PhysRead,
|
---|
3278 | pdmR3DevHlp_Untrusted_PhysWrite,
|
---|
3279 | pdmR3DevHlp_Untrusted_PhysGCPhys2CCPtr,
|
---|
3280 | pdmR3DevHlp_Untrusted_PhysGCPhys2CCPtrReadOnly,
|
---|
3281 | pdmR3DevHlp_Untrusted_PhysReleasePageMappingLock,
|
---|
3282 | pdmR3DevHlp_Untrusted_PhysReadGCVirt,
|
---|
3283 | pdmR3DevHlp_Untrusted_PhysWriteGCVirt,
|
---|
3284 | pdmR3DevHlp_Untrusted_A20IsEnabled,
|
---|
3285 | pdmR3DevHlp_Untrusted_A20Set,
|
---|
3286 | pdmR3DevHlp_Untrusted_VMReset,
|
---|
3287 | pdmR3DevHlp_Untrusted_VMSuspend,
|
---|
3288 | pdmR3DevHlp_Untrusted_VMPowerOff,
|
---|
3289 | pdmR3DevHlp_Untrusted_DMARegister,
|
---|
3290 | pdmR3DevHlp_Untrusted_DMAReadMemory,
|
---|
3291 | pdmR3DevHlp_Untrusted_DMAWriteMemory,
|
---|
3292 | pdmR3DevHlp_Untrusted_DMASetDREQ,
|
---|
3293 | pdmR3DevHlp_Untrusted_DMAGetChannelMode,
|
---|
3294 | pdmR3DevHlp_Untrusted_DMASchedule,
|
---|
3295 | pdmR3DevHlp_Untrusted_CMOSWrite,
|
---|
3296 | pdmR3DevHlp_Untrusted_CMOSRead,
|
---|
3297 | pdmR3DevHlp_Untrusted_GetCpuId,
|
---|
3298 | pdmR3DevHlp_Untrusted_ROMProtectShadow,
|
---|
3299 | pdmR3DevHlp_Untrusted_MMIO2Register,
|
---|
3300 | pdmR3DevHlp_Untrusted_MMIO2Deregister,
|
---|
3301 | pdmR3DevHlp_Untrusted_MMIO2Map,
|
---|
3302 | pdmR3DevHlp_Untrusted_MMIO2Unmap,
|
---|
3303 | pdmR3DevHlp_Untrusted_MMHyperMapMMIO2,
|
---|
3304 | pdmR3DevHlp_Untrusted_MMIO2MapKernel,
|
---|
3305 | pdmR3DevHlp_Untrusted_RegisterVMMDevHeap,
|
---|
3306 | pdmR3DevHlp_Untrusted_UnregisterVMMDevHeap,
|
---|
3307 | pdmR3DevHlp_Untrusted_GetVMCPU,
|
---|
3308 | PDM_DEVHLP_VERSION /* the end */
|
---|
3309 | };
|
---|
3310 |
|
---|
3311 |
|
---|
3312 |
|
---|
3313 | /**
|
---|
3314 | * Queue consumer callback for internal component.
|
---|
3315 | *
|
---|
3316 | * @returns Success indicator.
|
---|
3317 | * If false the item will not be removed and the flushing will stop.
|
---|
3318 | * @param pVM The VM handle.
|
---|
3319 | * @param pItem The item to consume. Upon return this item will be freed.
|
---|
3320 | */
|
---|
3321 | DECLCALLBACK(bool) pdmR3DevHlpQueueConsumer(PVM pVM, PPDMQUEUEITEMCORE pItem)
|
---|
3322 | {
|
---|
3323 | PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)pItem;
|
---|
3324 | LogFlow(("pdmR3DevHlpQueueConsumer: enmOp=%d pDevIns=%p\n", pTask->enmOp, pTask->pDevInsR3));
|
---|
3325 | switch (pTask->enmOp)
|
---|
3326 | {
|
---|
3327 | case PDMDEVHLPTASKOP_ISA_SET_IRQ:
|
---|
3328 | PDMIsaSetIrq(pVM, pTask->u.SetIRQ.iIrq, pTask->u.SetIRQ.iLevel);
|
---|
3329 | break;
|
---|
3330 |
|
---|
3331 | case PDMDEVHLPTASKOP_PCI_SET_IRQ:
|
---|
3332 | pdmR3DevHlp_PCISetIrq(pTask->pDevInsR3, pTask->u.SetIRQ.iIrq, pTask->u.SetIRQ.iLevel);
|
---|
3333 | break;
|
---|
3334 |
|
---|
3335 | case PDMDEVHLPTASKOP_IOAPIC_SET_IRQ:
|
---|
3336 | PDMIoApicSetIrq(pVM, pTask->u.SetIRQ.iIrq, pTask->u.SetIRQ.iLevel);
|
---|
3337 | break;
|
---|
3338 |
|
---|
3339 | default:
|
---|
3340 | AssertReleaseMsgFailed(("Invalid operation %d\n", pTask->enmOp));
|
---|
3341 | break;
|
---|
3342 | }
|
---|
3343 | return true;
|
---|
3344 | }
|
---|
3345 |
|
---|
3346 | /** @} */
|
---|
3347 |
|
---|