1 | /* $Id: PDMDevMiscHlp.cpp 84678 2020-06-04 13:26:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * PDM - Pluggable Device and Driver Manager, Misc. Device Helpers.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2020 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 |
|
---|
19 | /*********************************************************************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *********************************************************************************************************************************/
|
---|
22 | #define LOG_GROUP LOG_GROUP_PDM_DEVICE
|
---|
23 | #include "PDMInternal.h"
|
---|
24 | #include <VBox/vmm/pdm.h>
|
---|
25 | #include <VBox/vmm/pgm.h>
|
---|
26 | #include <VBox/vmm/hm.h>
|
---|
27 | #include <VBox/vmm/apic.h>
|
---|
28 | #include <VBox/vmm/vm.h>
|
---|
29 | #include <VBox/vmm/vmm.h>
|
---|
30 |
|
---|
31 | #include <VBox/log.h>
|
---|
32 | #include <VBox/err.h>
|
---|
33 | #include <VBox/msi.h>
|
---|
34 | #include <iprt/asm.h>
|
---|
35 | #include <iprt/assert.h>
|
---|
36 | #include <iprt/thread.h>
|
---|
37 |
|
---|
38 |
|
---|
39 | #include "PDMInline.h"
|
---|
40 | #include "dtrace/VBoxVMM.h"
|
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 | /** @name Ring-3 PIC Helpers
|
---|
45 | * @{
|
---|
46 | */
|
---|
47 |
|
---|
48 | /** @interface_method_impl{PDMPICHLP,pfnSetInterruptFF} */
|
---|
49 | static DECLCALLBACK(void) pdmR3PicHlp_SetInterruptFF(PPDMDEVINS pDevIns)
|
---|
50 | {
|
---|
51 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
52 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
53 | PVMCPU pVCpu = pVM->apCpusR3[0]; /* for PIC we always deliver to CPU 0, SMP uses APIC */
|
---|
54 |
|
---|
55 | /* IRQ state should be loaded as-is by "LoadExec". Changes can be made from LoadDone. */
|
---|
56 | Assert(pVM->enmVMState != VMSTATE_LOADING || pVM->pdm.s.fStateLoaded);
|
---|
57 |
|
---|
58 | APICLocalInterrupt(pVCpu, 0 /* u8Pin */, 1 /* u8Level */, VINF_SUCCESS /* rcRZ */);
|
---|
59 | }
|
---|
60 |
|
---|
61 |
|
---|
62 | /** @interface_method_impl{PDMPICHLP,pfnClearInterruptFF} */
|
---|
63 | static DECLCALLBACK(void) pdmR3PicHlp_ClearInterruptFF(PPDMDEVINS pDevIns)
|
---|
64 | {
|
---|
65 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
66 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
67 | PVMCPU pVCpu = pVM->apCpusR3[0]; /* for PIC we always deliver to CPU 0, SMP uses APIC */
|
---|
68 |
|
---|
69 | /* IRQ state should be loaded as-is by "LoadExec". Changes can be made from LoadDone. */
|
---|
70 | Assert(pVM->enmVMState != VMSTATE_LOADING || pVM->pdm.s.fStateLoaded);
|
---|
71 |
|
---|
72 | APICLocalInterrupt(pVCpu, 0 /* u8Pin */, 0 /* u8Level */, VINF_SUCCESS /* rcRZ */);
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|
76 | /** @interface_method_impl{PDMPICHLP,pfnLock} */
|
---|
77 | static DECLCALLBACK(int) pdmR3PicHlp_Lock(PPDMDEVINS pDevIns, int rc)
|
---|
78 | {
|
---|
79 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
80 | return pdmLockEx(pDevIns->Internal.s.pVMR3, rc);
|
---|
81 | }
|
---|
82 |
|
---|
83 |
|
---|
84 | /** @interface_method_impl{PDMPICHLP,pfnUnlock} */
|
---|
85 | static DECLCALLBACK(void) pdmR3PicHlp_Unlock(PPDMDEVINS pDevIns)
|
---|
86 | {
|
---|
87 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
88 | pdmUnlock(pDevIns->Internal.s.pVMR3);
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * PIC Device Helpers.
|
---|
94 | */
|
---|
95 | const PDMPICHLP g_pdmR3DevPicHlp =
|
---|
96 | {
|
---|
97 | PDM_PICHLP_VERSION,
|
---|
98 | pdmR3PicHlp_SetInterruptFF,
|
---|
99 | pdmR3PicHlp_ClearInterruptFF,
|
---|
100 | pdmR3PicHlp_Lock,
|
---|
101 | pdmR3PicHlp_Unlock,
|
---|
102 | PDM_PICHLP_VERSION /* the end */
|
---|
103 | };
|
---|
104 |
|
---|
105 | /** @} */
|
---|
106 |
|
---|
107 |
|
---|
108 | /** @name Ring-3 I/O APIC Helpers
|
---|
109 | * @{
|
---|
110 | */
|
---|
111 |
|
---|
112 | /** @interface_method_impl{PDMIOAPICHLP,pfnApicBusDeliver} */
|
---|
113 | static DECLCALLBACK(int) pdmR3IoApicHlp_ApicBusDeliver(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode,
|
---|
114 | uint8_t u8DeliveryMode, uint8_t uVector, uint8_t u8Polarity,
|
---|
115 | uint8_t u8TriggerMode, uint32_t uTagSrc)
|
---|
116 | {
|
---|
117 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
118 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
119 | LogFlow(("pdmR3IoApicHlp_ApicBusDeliver: caller='%s'/%d: u8Dest=%RX8 u8DestMode=%RX8 u8DeliveryMode=%RX8 uVector=%RX8 u8Polarity=%RX8 u8TriggerMode=%RX8 uTagSrc=%#x\n",
|
---|
120 | pDevIns->pReg->szName, pDevIns->iInstance, u8Dest, u8DestMode, u8DeliveryMode, uVector, u8Polarity, u8TriggerMode, uTagSrc));
|
---|
121 | return APICBusDeliver(pVM, u8Dest, u8DestMode, u8DeliveryMode, uVector, u8Polarity, u8TriggerMode, uTagSrc);
|
---|
122 | }
|
---|
123 |
|
---|
124 |
|
---|
125 | /** @interface_method_impl{PDMIOAPICHLP,pfnLock} */
|
---|
126 | static DECLCALLBACK(int) pdmR3IoApicHlp_Lock(PPDMDEVINS pDevIns, int rc)
|
---|
127 | {
|
---|
128 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
129 | LogFlow(("pdmR3IoApicHlp_Lock: caller='%s'/%d: rc=%Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
|
---|
130 | return pdmLockEx(pDevIns->Internal.s.pVMR3, rc);
|
---|
131 | }
|
---|
132 |
|
---|
133 |
|
---|
134 | /** @interface_method_impl{PDMIOAPICHLP,pfnUnlock} */
|
---|
135 | static DECLCALLBACK(void) pdmR3IoApicHlp_Unlock(PPDMDEVINS pDevIns)
|
---|
136 | {
|
---|
137 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
138 | LogFlow(("pdmR3IoApicHlp_Unlock: caller='%s'/%d:\n", pDevIns->pReg->szName, pDevIns->iInstance));
|
---|
139 | pdmUnlock(pDevIns->Internal.s.pVMR3);
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | /** @interface_method_impl{PDMIOAPICHLP,pfnIommuMsiRemap} */
|
---|
144 | static DECLCALLBACK(int) pdmR3IoApicHlp_IommuMsiRemap(PPDMDEVINS pDevIns, uint16_t uDevId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)
|
---|
145 | {
|
---|
146 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
147 | LogFlow(("pdmR3IoApicHlp_IommuRemapMsi: caller='%s'/%d: pMsiIn=(%#RX64, %#RU32)\n", pDevIns->pReg->szName,
|
---|
148 | pDevIns->iInstance, pMsiIn->Addr.u64, pMsiIn->Data.u32));
|
---|
149 |
|
---|
150 | #ifdef VBOX_WITH_IOMMU_AMD
|
---|
151 | /** @todo IOMMU: Optimize/re-organize things here later. */
|
---|
152 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
153 | PPDMIOMMU pIommu = &pVM->pdm.s.aIommus[0];
|
---|
154 | PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns);
|
---|
155 | if ( pDevInsIommu
|
---|
156 | && pDevInsIommu != pDevIns)
|
---|
157 | {
|
---|
158 | int rc = pIommu->pfnMsiRemap(pDevInsIommu, uDevId, pMsiIn, pMsiOut);
|
---|
159 | if (RT_FAILURE(rc))
|
---|
160 | {
|
---|
161 | Log(("pdmR3IoApicHlp_IommuRemapMsi: IOMMU MSI remap failed. uDevId=%#x pMsiIn=(%#RX64, %#RU32) rc=%Rrc\n",
|
---|
162 | uDevId, pMsiIn->Addr.u64, pMsiIn->Data.u32, rc));
|
---|
163 | return rc;
|
---|
164 | }
|
---|
165 | }
|
---|
166 | #else
|
---|
167 | RT_NOREF(pDevIns, uDevId);
|
---|
168 | *pMsiOut = *pMsiIn;
|
---|
169 | #endif
|
---|
170 | return VINF_SUCCESS;
|
---|
171 | }
|
---|
172 |
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * I/O APIC Device Helpers.
|
---|
176 | */
|
---|
177 | const PDMIOAPICHLP g_pdmR3DevIoApicHlp =
|
---|
178 | {
|
---|
179 | PDM_IOAPICHLP_VERSION,
|
---|
180 | pdmR3IoApicHlp_ApicBusDeliver,
|
---|
181 | pdmR3IoApicHlp_Lock,
|
---|
182 | pdmR3IoApicHlp_Unlock,
|
---|
183 | pdmR3IoApicHlp_IommuMsiRemap,
|
---|
184 | PDM_IOAPICHLP_VERSION /* the end */
|
---|
185 | };
|
---|
186 |
|
---|
187 | /** @} */
|
---|
188 |
|
---|
189 |
|
---|
190 |
|
---|
191 |
|
---|
192 | /** @name Ring-3 PCI Bus Helpers
|
---|
193 | * @{
|
---|
194 | */
|
---|
195 |
|
---|
196 | /** @interface_method_impl{PDMPCIHLPR3,pfnIsaSetIrq} */
|
---|
197 | static DECLCALLBACK(void) pdmR3PciHlp_IsaSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc)
|
---|
198 | {
|
---|
199 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
200 | Log4(("pdmR3PciHlp_IsaSetIrq: iIrq=%d iLevel=%d uTagSrc=%#x\n", iIrq, iLevel, uTagSrc));
|
---|
201 | PDMIsaSetIrq(pDevIns->Internal.s.pVMR3, iIrq, iLevel, uTagSrc);
|
---|
202 | }
|
---|
203 |
|
---|
204 |
|
---|
205 | /** @interface_method_impl{PDMPCIHLPR3,pfnIoApicSetIrq} */
|
---|
206 | static DECLCALLBACK(void) pdmR3PciHlp_IoApicSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc)
|
---|
207 | {
|
---|
208 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
209 | Log4(("pdmR3PciHlp_IoApicSetIrq: iIrq=%d iLevel=%d uTagSrc=%#x\n", iIrq, iLevel, uTagSrc));
|
---|
210 | PDMIoApicSetIrq(pDevIns->Internal.s.pVMR3, iIrq, iLevel, uTagSrc);
|
---|
211 | }
|
---|
212 |
|
---|
213 |
|
---|
214 | /** @interface_method_impl{PDMPCIHLPR3,pfnIoApicSendMsi} */
|
---|
215 | static DECLCALLBACK(void) pdmR3PciHlp_IoApicSendMsi(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue, uint32_t uTagSrc)
|
---|
216 | {
|
---|
217 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
218 | Log4(("pdmR3PciHlp_IoApicSendMsi: address=%p value=%x uTagSrc=%#x\n", GCPhys, uValue, uTagSrc));
|
---|
219 | PDMIoApicSendMsi(pDevIns->Internal.s.pVMR3, GCPhys, uValue, uTagSrc);
|
---|
220 | }
|
---|
221 |
|
---|
222 |
|
---|
223 | /** @interface_method_impl{PDMPCIHLPR3,pfnLock} */
|
---|
224 | static DECLCALLBACK(int) pdmR3PciHlp_Lock(PPDMDEVINS pDevIns, int rc)
|
---|
225 | {
|
---|
226 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
227 | LogFlow(("pdmR3PciHlp_Lock: caller='%s'/%d: rc=%Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
|
---|
228 | return pdmLockEx(pDevIns->Internal.s.pVMR3, rc);
|
---|
229 | }
|
---|
230 |
|
---|
231 |
|
---|
232 | /** @interface_method_impl{PDMPCIHLPR3,pfnUnlock} */
|
---|
233 | static DECLCALLBACK(void) pdmR3PciHlp_Unlock(PPDMDEVINS pDevIns)
|
---|
234 | {
|
---|
235 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
236 | LogFlow(("pdmR3PciHlp_Unlock: caller='%s'/%d:\n", pDevIns->pReg->szName, pDevIns->iInstance));
|
---|
237 | pdmUnlock(pDevIns->Internal.s.pVMR3);
|
---|
238 | }
|
---|
239 |
|
---|
240 |
|
---|
241 | /** @interface_method_impl{PDMPCIHLPR3,pfnGetBusByNo} */
|
---|
242 | static DECLCALLBACK(PPDMDEVINS) pdmR3PciHlp_GetBusByNo(PPDMDEVINS pDevIns, uint32_t idxPdmBus)
|
---|
243 | {
|
---|
244 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
245 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
246 | AssertReturn(idxPdmBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses), NULL);
|
---|
247 | PPDMDEVINS pRetDevIns = pVM->pdm.s.aPciBuses[idxPdmBus].pDevInsR3;
|
---|
248 | LogFlow(("pdmR3PciHlp_GetBusByNo: caller='%s'/%d: returns %p\n", pDevIns->pReg->szName, pDevIns->iInstance, pRetDevIns));
|
---|
249 | return pRetDevIns;
|
---|
250 | }
|
---|
251 |
|
---|
252 |
|
---|
253 | /**
|
---|
254 | * PCI Bus Device Helpers.
|
---|
255 | */
|
---|
256 | const PDMPCIHLPR3 g_pdmR3DevPciHlp =
|
---|
257 | {
|
---|
258 | PDM_PCIHLPR3_VERSION,
|
---|
259 | pdmR3PciHlp_IsaSetIrq,
|
---|
260 | pdmR3PciHlp_IoApicSetIrq,
|
---|
261 | pdmR3PciHlp_IoApicSendMsi,
|
---|
262 | pdmR3PciHlp_Lock,
|
---|
263 | pdmR3PciHlp_Unlock,
|
---|
264 | pdmR3PciHlp_GetBusByNo,
|
---|
265 | PDM_PCIHLPR3_VERSION, /* the end */
|
---|
266 | };
|
---|
267 |
|
---|
268 | /** @} */
|
---|
269 |
|
---|
270 |
|
---|
271 | /**
|
---|
272 | * IOMMU Device Helpers.
|
---|
273 | */
|
---|
274 | const PDMIOMMUHLPR3 g_pdmR3DevIommuHlp =
|
---|
275 | {
|
---|
276 | PDM_IOMMUHLPR3_VERSION,
|
---|
277 | PDM_IOMMUHLPR3_VERSION /* the end */
|
---|
278 | };
|
---|
279 |
|
---|
280 |
|
---|
281 | /** @name Ring-3 HPET Helpers
|
---|
282 | * @{
|
---|
283 | */
|
---|
284 |
|
---|
285 | /** @interface_method_impl{PDMHPETHLPR3,pfnSetLegacyMode} */
|
---|
286 | static DECLCALLBACK(int) pdmR3HpetHlp_SetLegacyMode(PPDMDEVINS pDevIns, bool fActivated)
|
---|
287 | {
|
---|
288 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
289 | LogFlow(("pdmR3HpetHlp_SetLegacyMode: caller='%s'/%d: fActivated=%RTbool\n", pDevIns->pReg->szName, pDevIns->iInstance, fActivated));
|
---|
290 |
|
---|
291 | size_t i;
|
---|
292 | int rc = VINF_SUCCESS;
|
---|
293 | static const char * const s_apszDevsToNotify[] =
|
---|
294 | {
|
---|
295 | "i8254",
|
---|
296 | "mc146818"
|
---|
297 | };
|
---|
298 | for (i = 0; i < RT_ELEMENTS(s_apszDevsToNotify); i++)
|
---|
299 | {
|
---|
300 | PPDMIBASE pBase;
|
---|
301 | rc = PDMR3QueryDevice(pDevIns->Internal.s.pVMR3->pUVM, "i8254", 0, &pBase);
|
---|
302 | if (RT_SUCCESS(rc))
|
---|
303 | {
|
---|
304 | PPDMIHPETLEGACYNOTIFY pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIHPETLEGACYNOTIFY);
|
---|
305 | AssertLogRelMsgBreakStmt(pPort, ("%s\n", s_apszDevsToNotify[i]), rc = VERR_PDM_HPET_LEGACY_NOTIFY_MISSING);
|
---|
306 | pPort->pfnModeChanged(pPort, fActivated);
|
---|
307 | }
|
---|
308 | else if ( rc == VERR_PDM_DEVICE_NOT_FOUND
|
---|
309 | || rc == VERR_PDM_DEVICE_INSTANCE_NOT_FOUND)
|
---|
310 | rc = VINF_SUCCESS; /* the device isn't configured, ignore. */
|
---|
311 | else
|
---|
312 | AssertLogRelMsgFailedBreak(("%s -> %Rrc\n", s_apszDevsToNotify[i], rc));
|
---|
313 | }
|
---|
314 |
|
---|
315 | /* Don't bother cleaning up, any failure here will cause a guru meditation. */
|
---|
316 |
|
---|
317 | LogFlow(("pdmR3HpetHlp_SetLegacyMode: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
|
---|
318 | return rc;
|
---|
319 | }
|
---|
320 |
|
---|
321 |
|
---|
322 | /** @interface_method_impl{PDMHPETHLPR3,pfnSetIrq} */
|
---|
323 | static DECLCALLBACK(int) pdmR3HpetHlp_SetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
|
---|
324 | {
|
---|
325 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
326 | LogFlow(("pdmR3HpetHlp_SetIrq: caller='%s'/%d: iIrq=%d iLevel=%d\n", pDevIns->pReg->szName, pDevIns->iInstance, iIrq, iLevel));
|
---|
327 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
328 |
|
---|
329 | pdmLock(pVM);
|
---|
330 | uint32_t uTagSrc;
|
---|
331 | if (iLevel & PDM_IRQ_LEVEL_HIGH)
|
---|
332 | {
|
---|
333 | pDevIns->Internal.s.uLastIrqTag = uTagSrc = pdmCalcIrqTag(pVM, pDevIns->idTracing);
|
---|
334 | if (iLevel == PDM_IRQ_LEVEL_HIGH)
|
---|
335 | VBOXVMM_PDM_IRQ_HIGH(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
|
---|
336 | else
|
---|
337 | VBOXVMM_PDM_IRQ_HILO(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
|
---|
338 | }
|
---|
339 | else
|
---|
340 | uTagSrc = pDevIns->Internal.s.uLastIrqTag;
|
---|
341 |
|
---|
342 | PDMIsaSetIrq(pVM, iIrq, iLevel, uTagSrc); /* (The API takes the lock recursively.) */
|
---|
343 |
|
---|
344 | if (iLevel == PDM_IRQ_LEVEL_LOW)
|
---|
345 | VBOXVMM_PDM_IRQ_LOW(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
|
---|
346 | pdmUnlock(pVM);
|
---|
347 | return 0;
|
---|
348 | }
|
---|
349 |
|
---|
350 |
|
---|
351 | /**
|
---|
352 | * HPET Device Helpers.
|
---|
353 | */
|
---|
354 | const PDMHPETHLPR3 g_pdmR3DevHpetHlp =
|
---|
355 | {
|
---|
356 | PDM_HPETHLPR3_VERSION,
|
---|
357 | pdmR3HpetHlp_SetLegacyMode,
|
---|
358 | pdmR3HpetHlp_SetIrq,
|
---|
359 | PDM_HPETHLPR3_VERSION, /* the end */
|
---|
360 | };
|
---|
361 |
|
---|
362 | /** @} */
|
---|
363 |
|
---|
364 |
|
---|
365 | /** @name Ring-3 Raw PCI Device Helpers
|
---|
366 | * @{
|
---|
367 | */
|
---|
368 |
|
---|
369 | /** @interface_method_impl{PDMPCIRAWHLPR3,pfnGetRCHelpers} */
|
---|
370 | static DECLCALLBACK(PCPDMPCIRAWHLPRC) pdmR3PciRawHlp_GetRCHelpers(PPDMDEVINS pDevIns)
|
---|
371 | {
|
---|
372 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
373 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
374 | VM_ASSERT_EMT(pVM);
|
---|
375 |
|
---|
376 | RTRCPTR pRCHelpers = NIL_RTRCPTR;
|
---|
377 | if (VM_IS_RAW_MODE_ENABLED(pVM))
|
---|
378 | {
|
---|
379 | int rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_pdmRCPciRawHlp", &pRCHelpers);
|
---|
380 | AssertReleaseRC(rc);
|
---|
381 | AssertRelease(pRCHelpers);
|
---|
382 | }
|
---|
383 |
|
---|
384 | LogFlow(("pdmR3PciRawHlp_GetGCHelpers: caller='%s'/%d: returns %RRv\n",
|
---|
385 | pDevIns->pReg->szName, pDevIns->iInstance, pRCHelpers));
|
---|
386 | return pRCHelpers;
|
---|
387 | }
|
---|
388 |
|
---|
389 |
|
---|
390 | /** @interface_method_impl{PDMPCIRAWHLPR3,pfnGetR0Helpers} */
|
---|
391 | static DECLCALLBACK(PCPDMPCIRAWHLPR0) pdmR3PciRawHlp_GetR0Helpers(PPDMDEVINS pDevIns)
|
---|
392 | {
|
---|
393 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
394 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
395 | VM_ASSERT_EMT(pVM);
|
---|
396 | PCPDMHPETHLPR0 pR0Helpers = NIL_RTR0PTR;
|
---|
397 | int rc = PDMR3LdrGetSymbolR0(pVM, NULL, "g_pdmR0PciRawHlp", &pR0Helpers);
|
---|
398 | AssertReleaseRC(rc);
|
---|
399 | AssertRelease(pR0Helpers);
|
---|
400 | LogFlow(("pdmR3PciRawHlp_GetR0Helpers: caller='%s'/%d: returns %RHv\n",
|
---|
401 | pDevIns->pReg->szName, pDevIns->iInstance, pR0Helpers));
|
---|
402 | return pR0Helpers;
|
---|
403 | }
|
---|
404 |
|
---|
405 |
|
---|
406 | /**
|
---|
407 | * Raw PCI Device Helpers.
|
---|
408 | */
|
---|
409 | const PDMPCIRAWHLPR3 g_pdmR3DevPciRawHlp =
|
---|
410 | {
|
---|
411 | PDM_PCIRAWHLPR3_VERSION,
|
---|
412 | pdmR3PciRawHlp_GetRCHelpers,
|
---|
413 | pdmR3PciRawHlp_GetR0Helpers,
|
---|
414 | PDM_PCIRAWHLPR3_VERSION, /* the end */
|
---|
415 | };
|
---|
416 |
|
---|
417 | /** @} */
|
---|
418 |
|
---|
419 |
|
---|
420 | /* none yet */
|
---|
421 |
|
---|
422 | /**
|
---|
423 | * Firmware Device Helpers.
|
---|
424 | */
|
---|
425 | const PDMFWHLPR3 g_pdmR3DevFirmwareHlp =
|
---|
426 | {
|
---|
427 | PDM_FWHLPR3_VERSION,
|
---|
428 | PDM_FWHLPR3_VERSION
|
---|
429 | };
|
---|
430 |
|
---|
431 | /**
|
---|
432 | * DMAC Device Helpers.
|
---|
433 | */
|
---|
434 | const PDMDMACHLP g_pdmR3DevDmacHlp =
|
---|
435 | {
|
---|
436 | PDM_DMACHLP_VERSION
|
---|
437 | };
|
---|
438 |
|
---|
439 |
|
---|
440 |
|
---|
441 |
|
---|
442 | /* none yet */
|
---|
443 |
|
---|
444 | /**
|
---|
445 | * RTC Device Helpers.
|
---|
446 | */
|
---|
447 | const PDMRTCHLP g_pdmR3DevRtcHlp =
|
---|
448 | {
|
---|
449 | PDM_RTCHLP_VERSION
|
---|
450 | };
|
---|
451 |
|
---|