1 | /* $Id: PDMDevMiscHlp.cpp 62643 2016-07-28 21:25:37Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * PDM - Pluggable Device and Driver Manager, Misc. Device Helpers.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2016 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 | #ifdef VBOX_WITH_REM
|
---|
28 | # include <VBox/vmm/rem.h>
|
---|
29 | #endif
|
---|
30 | #include <VBox/vmm/vm.h>
|
---|
31 | #include <VBox/vmm/vmm.h>
|
---|
32 |
|
---|
33 | #include <VBox/log.h>
|
---|
34 | #include <VBox/err.h>
|
---|
35 | #include <iprt/asm.h>
|
---|
36 | #include <iprt/assert.h>
|
---|
37 | #include <iprt/thread.h>
|
---|
38 |
|
---|
39 |
|
---|
40 | #include "PDMInline.h"
|
---|
41 | #include "dtrace/VBoxVMM.h"
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 | /** @name Ring-3 PIC Helpers
|
---|
46 | * @{
|
---|
47 | */
|
---|
48 |
|
---|
49 | /** @interface_method_impl{PDMPICHLPR3,pfnSetInterruptFF} */
|
---|
50 | static DECLCALLBACK(void) pdmR3PicHlp_SetInterruptFF(PPDMDEVINS pDevIns)
|
---|
51 | {
|
---|
52 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
53 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
54 | PVMCPU pVCpu = &pVM->aCpus[0]; /* for PIC we always deliver to CPU 0, MP use APIC */
|
---|
55 |
|
---|
56 | if (pVM->pdm.s.Apic.pfnLocalInterruptR3)
|
---|
57 | {
|
---|
58 | LogFlow(("pdmR3PicHlp_SetInterruptFF: caller='%s'/%d: Setting local interrupt on LAPIC\n",
|
---|
59 | pDevIns->pReg->szName, pDevIns->iInstance));
|
---|
60 |
|
---|
61 | /* Raise the LAPIC's LINT0 line instead of signaling the CPU directly. */
|
---|
62 | /** @todo 'rcRZ' propagation to pfnLocalInterrupt from caller. */
|
---|
63 | pVM->pdm.s.Apic.pfnLocalInterruptR3(pVM->pdm.s.Apic.pDevInsR3, pVCpu, 0 /* u8Pin */, 1 /* u8Level */,
|
---|
64 | VINF_SUCCESS /* rcRZ */);
|
---|
65 | return;
|
---|
66 | }
|
---|
67 |
|
---|
68 | LogFlow(("pdmR3PicHlp_SetInterruptFF: caller='%s'/%d: VMCPU_FF_INTERRUPT_PIC %d -> 1\n",
|
---|
69 | pDevIns->pReg->szName, pDevIns->iInstance, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_PIC)));
|
---|
70 |
|
---|
71 | VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_PIC);
|
---|
72 | #ifdef VBOX_WITH_REM
|
---|
73 | REMR3NotifyInterruptSet(pVM, pVCpu);
|
---|
74 | #endif
|
---|
75 | VMR3NotifyCpuFFU(pVCpu->pUVCpu, VMNOTIFYFF_FLAGS_DONE_REM | VMNOTIFYFF_FLAGS_POKE);
|
---|
76 | }
|
---|
77 |
|
---|
78 |
|
---|
79 | /** @interface_method_impl{PDMPICHLPR3,pfnClearInterruptFF} */
|
---|
80 | static DECLCALLBACK(void) pdmR3PicHlp_ClearInterruptFF(PPDMDEVINS pDevIns)
|
---|
81 | {
|
---|
82 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
83 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
84 | PVMCPU pVCpu = &pVM->aCpus[0]; /* for PIC we always deliver to CPU 0, MP use APIC */
|
---|
85 |
|
---|
86 | if (pVM->pdm.s.Apic.pfnLocalInterruptR3)
|
---|
87 | {
|
---|
88 | /* Raise the LAPIC's LINT0 line instead of signaling the CPU directly. */
|
---|
89 | LogFlow(("pdmR3PicHlp_ClearInterruptFF: caller='%s'/%d: Clearing local interrupt on LAPIC\n",
|
---|
90 | pDevIns->pReg->szName, pDevIns->iInstance));
|
---|
91 |
|
---|
92 | /* Lower the LAPIC's LINT0 line instead of signaling the CPU directly. */
|
---|
93 | /** @todo 'rcRZ' propagation to pfnLocalInterrupt from caller. */
|
---|
94 | pVM->pdm.s.Apic.pfnLocalInterruptR3(pVM->pdm.s.Apic.pDevInsR3, pVCpu, 0 /* u8Pin */, 0 /* u8Level */,
|
---|
95 | VINF_SUCCESS /* rcRZ */);
|
---|
96 | return;
|
---|
97 | }
|
---|
98 |
|
---|
99 | LogFlow(("pdmR3PicHlp_ClearInterruptFF: caller='%s'/%d: VMCPU_FF_INTERRUPT_PIC %d -> 0\n",
|
---|
100 | pDevIns->pReg->szName, pDevIns->iInstance, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_PIC)));
|
---|
101 |
|
---|
102 | VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_PIC);
|
---|
103 | #ifdef VBOX_WITH_REM
|
---|
104 | REMR3NotifyInterruptClear(pVM, pVCpu);
|
---|
105 | #endif
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 | /** @interface_method_impl{PDMPICHLPR3,pfnLock} */
|
---|
110 | static DECLCALLBACK(int) pdmR3PicHlp_Lock(PPDMDEVINS pDevIns, int rc)
|
---|
111 | {
|
---|
112 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
113 | return pdmLockEx(pDevIns->Internal.s.pVMR3, rc);
|
---|
114 | }
|
---|
115 |
|
---|
116 |
|
---|
117 | /** @interface_method_impl{PDMPICHLPR3,pfnUnlock} */
|
---|
118 | static DECLCALLBACK(void) pdmR3PicHlp_Unlock(PPDMDEVINS pDevIns)
|
---|
119 | {
|
---|
120 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
121 | pdmUnlock(pDevIns->Internal.s.pVMR3);
|
---|
122 | }
|
---|
123 |
|
---|
124 |
|
---|
125 | /** @interface_method_impl{PDMPICHLPR3,pfnGetRCHelpers} */
|
---|
126 | static DECLCALLBACK(PCPDMPICHLPRC) pdmR3PicHlp_GetRCHelpers(PPDMDEVINS pDevIns)
|
---|
127 | {
|
---|
128 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
129 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
130 | VM_ASSERT_EMT(pVM);
|
---|
131 |
|
---|
132 | RTRCPTR pRCHelpers = NIL_RTRCPTR;
|
---|
133 | if (!HMIsEnabled(pVM))
|
---|
134 | {
|
---|
135 | int rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_pdmRCPicHlp", &pRCHelpers);
|
---|
136 | AssertReleaseRC(rc);
|
---|
137 | AssertRelease(pRCHelpers);
|
---|
138 | }
|
---|
139 |
|
---|
140 | LogFlow(("pdmR3PicHlp_GetRCHelpers: caller='%s'/%d: returns %RRv\n",
|
---|
141 | pDevIns->pReg->szName, pDevIns->iInstance, pRCHelpers));
|
---|
142 | return pRCHelpers;
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 | /** @interface_method_impl{PDMPICHLPR3,pfnGetR0Helpers} */
|
---|
147 | static DECLCALLBACK(PCPDMPICHLPR0) pdmR3PicHlp_GetR0Helpers(PPDMDEVINS pDevIns)
|
---|
148 | {
|
---|
149 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
150 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
151 | VM_ASSERT_EMT(pVM);
|
---|
152 | PCPDMPICHLPR0 pR0Helpers = 0;
|
---|
153 | int rc = PDMR3LdrGetSymbolR0(pVM, NULL, "g_pdmR0PicHlp", &pR0Helpers);
|
---|
154 | AssertReleaseRC(rc);
|
---|
155 | AssertRelease(pR0Helpers);
|
---|
156 | LogFlow(("pdmR3PicHlp_GetR0Helpers: caller='%s'/%d: returns %RHv\n",
|
---|
157 | pDevIns->pReg->szName, pDevIns->iInstance, pR0Helpers));
|
---|
158 | return pR0Helpers;
|
---|
159 | }
|
---|
160 |
|
---|
161 |
|
---|
162 | /**
|
---|
163 | * PIC Device Helpers.
|
---|
164 | */
|
---|
165 | const PDMPICHLPR3 g_pdmR3DevPicHlp =
|
---|
166 | {
|
---|
167 | PDM_PICHLPR3_VERSION,
|
---|
168 | pdmR3PicHlp_SetInterruptFF,
|
---|
169 | pdmR3PicHlp_ClearInterruptFF,
|
---|
170 | pdmR3PicHlp_Lock,
|
---|
171 | pdmR3PicHlp_Unlock,
|
---|
172 | pdmR3PicHlp_GetRCHelpers,
|
---|
173 | pdmR3PicHlp_GetR0Helpers,
|
---|
174 | PDM_PICHLPR3_VERSION /* the end */
|
---|
175 | };
|
---|
176 |
|
---|
177 | /** @} */
|
---|
178 |
|
---|
179 |
|
---|
180 |
|
---|
181 |
|
---|
182 | /** @name R3 APIC Helpers
|
---|
183 | * @{
|
---|
184 | */
|
---|
185 |
|
---|
186 | /** @interface_method_impl{PDMAPICHLPR3,pfnSetInterruptFF} */
|
---|
187 | static DECLCALLBACK(void) pdmR3ApicHlp_SetInterruptFF(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu)
|
---|
188 | {
|
---|
189 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
190 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
191 | PVMCPU pVCpu = &pVM->aCpus[idCpu];
|
---|
192 |
|
---|
193 | AssertReturnVoid(idCpu < pVM->cCpus);
|
---|
194 |
|
---|
195 | LogFlow(("pdmR3ApicHlp_SetInterruptFF: caller='%s'/%d: VMCPU_FF_INTERRUPT_APIC(%d) %d -> 1\n",
|
---|
196 | pDevIns->pReg->szName, pDevIns->iInstance, idCpu, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_APIC)));
|
---|
197 |
|
---|
198 | switch (enmType)
|
---|
199 | {
|
---|
200 | case PDMAPICIRQ_UPDATE_PENDING:
|
---|
201 | VMCPU_FF_SET(pVCpu, VMCPU_FF_UPDATE_APIC);
|
---|
202 | break;
|
---|
203 | case PDMAPICIRQ_HARDWARE:
|
---|
204 | #ifdef VBOX_WITH_NEW_APIC
|
---|
205 | VMCPU_ASSERT_EMT_OR_NOT_RUNNING(pVCpu);
|
---|
206 | #endif
|
---|
207 | VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_APIC);
|
---|
208 | break;
|
---|
209 | case PDMAPICIRQ_NMI:
|
---|
210 | VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_NMI);
|
---|
211 | break;
|
---|
212 | case PDMAPICIRQ_SMI:
|
---|
213 | VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_SMI);
|
---|
214 | break;
|
---|
215 | case PDMAPICIRQ_EXTINT:
|
---|
216 | VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_PIC);
|
---|
217 | break;
|
---|
218 | default:
|
---|
219 | AssertMsgFailed(("enmType=%d\n", enmType));
|
---|
220 | break;
|
---|
221 | }
|
---|
222 | #ifdef VBOX_WITH_REM
|
---|
223 | REMR3NotifyInterruptSet(pVM, pVCpu);
|
---|
224 | #endif
|
---|
225 |
|
---|
226 | #ifdef VBOX_WITH_NEW_APIC
|
---|
227 | if (enmType != PDMAPICIRQ_HARDWARE)
|
---|
228 | VMR3NotifyCpuFFU(pVCpu->pUVCpu, VMNOTIFYFF_FLAGS_DONE_REM | VMNOTIFYFF_FLAGS_POKE);
|
---|
229 | #else
|
---|
230 | VMR3NotifyCpuFFU(pVCpu->pUVCpu, VMNOTIFYFF_FLAGS_DONE_REM | VMNOTIFYFF_FLAGS_POKE);
|
---|
231 | #endif
|
---|
232 | }
|
---|
233 |
|
---|
234 |
|
---|
235 | /** @interface_method_impl{PDMAPICHLPR3,pfnClearInterruptFF} */
|
---|
236 | static DECLCALLBACK(void) pdmR3ApicHlp_ClearInterruptFF(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu)
|
---|
237 | {
|
---|
238 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
239 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
240 | PVMCPU pVCpu = &pVM->aCpus[idCpu];
|
---|
241 |
|
---|
242 | AssertReturnVoid(idCpu < pVM->cCpus);
|
---|
243 |
|
---|
244 | LogFlow(("pdmR3ApicHlp_ClearInterruptFF: caller='%s'/%d: VMCPU_FF_INTERRUPT_APIC(%d) %d -> 0\n",
|
---|
245 | pDevIns->pReg->szName, pDevIns->iInstance, idCpu, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_APIC)));
|
---|
246 |
|
---|
247 | /* Note: NMI/SMI can't be cleared. */
|
---|
248 | switch (enmType)
|
---|
249 | {
|
---|
250 | case PDMAPICIRQ_HARDWARE:
|
---|
251 | VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_APIC);
|
---|
252 | break;
|
---|
253 | case PDMAPICIRQ_EXTINT:
|
---|
254 | VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_PIC);
|
---|
255 | break;
|
---|
256 | case PDMAPICIRQ_UPDATE_PENDING:
|
---|
257 | VMCPU_ASSERT_EMT_OR_NOT_RUNNING(pVCpu);
|
---|
258 | VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_UPDATE_APIC);
|
---|
259 | break;
|
---|
260 | default:
|
---|
261 | AssertMsgFailed(("enmType=%d\n", enmType));
|
---|
262 | break;
|
---|
263 | }
|
---|
264 | #ifdef VBOX_WITH_REM
|
---|
265 | REMR3NotifyInterruptClear(pVM, pVCpu);
|
---|
266 | #endif
|
---|
267 | }
|
---|
268 |
|
---|
269 |
|
---|
270 | /** @interface_method_impl{PDMAPICHLPR3,pfnBusBroadcastEoi} */
|
---|
271 | static DECLCALLBACK(int) pdmR3ApicHlp_BusBroadcastEoi(PPDMDEVINS pDevIns, uint8_t u8Vector)
|
---|
272 | {
|
---|
273 | /* pfnSetEoi will be NULL in the old IOAPIC code as it's not implemented. */
|
---|
274 | #ifdef VBOX_WITH_NEW_IOAPIC
|
---|
275 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
276 | PVM pVM = pDevIns->Internal.s.CTX_SUFF(pVM);
|
---|
277 |
|
---|
278 | /* At present, we support only a maximum of one I/O APIC per-VM. If we ever implement having
|
---|
279 | multiple I/O APICs per-VM, we'll have to broadcast this EOI to all of the I/O APICs. */
|
---|
280 | if (pVM->pdm.s.IoApic.CTX_SUFF(pDevIns))
|
---|
281 | {
|
---|
282 | Assert(pVM->pdm.s.IoApic.CTX_SUFF(pfnSetEoi));
|
---|
283 | return pVM->pdm.s.IoApic.CTX_SUFF(pfnSetEoi)(pVM->pdm.s.IoApic.CTX_SUFF(pDevIns), u8Vector);
|
---|
284 | }
|
---|
285 | #endif
|
---|
286 | return VINF_SUCCESS;
|
---|
287 | }
|
---|
288 |
|
---|
289 |
|
---|
290 | /** @interface_method_impl{PDMAPICHLPR3,pfnCalcIrqTag} */
|
---|
291 | static DECLCALLBACK(uint32_t) pdmR3ApicHlp_CalcIrqTag(PPDMDEVINS pDevIns, uint8_t u8Level)
|
---|
292 | {
|
---|
293 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
294 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
295 | Assert(u8Level == PDM_IRQ_LEVEL_HIGH || u8Level == PDM_IRQ_LEVEL_FLIP_FLOP);
|
---|
296 |
|
---|
297 | pdmLock(pVM);
|
---|
298 |
|
---|
299 | uint32_t uTagSrc = pdmCalcIrqTag(pVM, pDevIns->idTracing);
|
---|
300 | if (u8Level == PDM_IRQ_LEVEL_HIGH)
|
---|
301 | VBOXVMM_PDM_IRQ_HIGH(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
|
---|
302 | else
|
---|
303 | VBOXVMM_PDM_IRQ_HILO(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
|
---|
304 |
|
---|
305 |
|
---|
306 | pdmUnlock(pVM);
|
---|
307 | LogFlow(("pdmR3ApicHlp_CalcIrqTag: caller='%s'/%d: returns %#x (u8Level=%d)\n",
|
---|
308 | pDevIns->pReg->szName, pDevIns->iInstance, uTagSrc, u8Level));
|
---|
309 | return uTagSrc;
|
---|
310 | }
|
---|
311 |
|
---|
312 |
|
---|
313 | /** @interface_method_impl{PDMAPICHLPR3,pfnSetFeatureLevel} */
|
---|
314 | static DECLCALLBACK(void) pdmR3ApicHlp_SetFeatureLevel(PPDMDEVINS pDevIns, PDMAPICMODE enmMode)
|
---|
315 | {
|
---|
316 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
317 | LogFlow(("pdmR3ApicHlp_SetFeatureLevel: caller='%s'/%d: mode=%d\n",
|
---|
318 | pDevIns->pReg->szName, pDevIns->iInstance, (int)enmMode));
|
---|
319 | switch (enmMode)
|
---|
320 | {
|
---|
321 | case PDMAPICMODE_NONE:
|
---|
322 | CPUMR3ClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC);
|
---|
323 | CPUMR3ClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC);
|
---|
324 | break;
|
---|
325 | case PDMAPICMODE_APIC:
|
---|
326 | CPUMR3ClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC);
|
---|
327 | CPUMR3SetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC);
|
---|
328 | break;
|
---|
329 | case PDMAPICMODE_X2APIC:
|
---|
330 | CPUMR3SetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC);
|
---|
331 | CPUMR3SetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC);
|
---|
332 | break;
|
---|
333 | default:
|
---|
334 | AssertMsgFailed(("Unknown APIC mode: %d\n", (int)enmMode));
|
---|
335 | }
|
---|
336 | }
|
---|
337 |
|
---|
338 | /** @interface_method_impl{PDMAPICHLPR3,pfnGetCpuId} */
|
---|
339 | static DECLCALLBACK(VMCPUID) pdmR3ApicHlp_GetCpuId(PPDMDEVINS pDevIns)
|
---|
340 | {
|
---|
341 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
342 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
343 | return VMMGetCpuId(pDevIns->Internal.s.pVMR3);
|
---|
344 | }
|
---|
345 |
|
---|
346 |
|
---|
347 | /** @interface_method_impl{PDMAPICHLPR3,pfnSendStartupIpi} */
|
---|
348 | static DECLCALLBACK(void) pdmR3ApicHlp_SendStartupIpi(PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t uVector)
|
---|
349 | {
|
---|
350 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
351 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
352 | VMMR3SendStartupIpi(pDevIns->Internal.s.pVMR3, idCpu, uVector);
|
---|
353 | }
|
---|
354 |
|
---|
355 |
|
---|
356 | /** @interface_method_impl{PDMAPICHLPR3,pfnSendInitIpi} */
|
---|
357 | static DECLCALLBACK(void) pdmR3ApicHlp_SendInitIpi(PPDMDEVINS pDevIns, VMCPUID idCpu)
|
---|
358 | {
|
---|
359 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
360 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
361 | VMMR3SendInitIpi(pDevIns->Internal.s.pVMR3, idCpu);
|
---|
362 | }
|
---|
363 |
|
---|
364 |
|
---|
365 | /** @interface_method_impl{PDMAPICHLPR3,pfnGetRCHelpers} */
|
---|
366 | static DECLCALLBACK(PCPDMAPICHLPRC) pdmR3ApicHlp_GetRCHelpers(PPDMDEVINS pDevIns)
|
---|
367 | {
|
---|
368 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
369 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
370 | VM_ASSERT_EMT(pVM);
|
---|
371 |
|
---|
372 | RTRCPTR pRCHelpers = NIL_RTRCPTR;
|
---|
373 | if (!HMIsEnabled(pVM))
|
---|
374 | {
|
---|
375 | int rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_pdmRCApicHlp", &pRCHelpers);
|
---|
376 | AssertReleaseRC(rc);
|
---|
377 | AssertRelease(pRCHelpers);
|
---|
378 | }
|
---|
379 |
|
---|
380 | LogFlow(("pdmR3ApicHlp_GetRCHelpers: caller='%s'/%d: returns %RRv\n",
|
---|
381 | pDevIns->pReg->szName, pDevIns->iInstance, pRCHelpers));
|
---|
382 | return pRCHelpers;
|
---|
383 | }
|
---|
384 |
|
---|
385 |
|
---|
386 | /** @interface_method_impl{PDMAPICHLPR3,pfnGetR0Helpers} */
|
---|
387 | static DECLCALLBACK(PCPDMAPICHLPR0) pdmR3ApicHlp_GetR0Helpers(PPDMDEVINS pDevIns)
|
---|
388 | {
|
---|
389 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
390 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
391 | VM_ASSERT_EMT(pVM);
|
---|
392 | PCPDMAPICHLPR0 pR0Helpers = 0;
|
---|
393 | int rc = PDMR3LdrGetSymbolR0(pVM, NULL, "g_pdmR0ApicHlp", &pR0Helpers);
|
---|
394 | AssertReleaseRC(rc);
|
---|
395 | AssertRelease(pR0Helpers);
|
---|
396 | LogFlow(("pdmR3ApicHlp_GetR0Helpers: caller='%s'/%d: returns %RHv\n",
|
---|
397 | pDevIns->pReg->szName, pDevIns->iInstance, pR0Helpers));
|
---|
398 | return pR0Helpers;
|
---|
399 | }
|
---|
400 |
|
---|
401 |
|
---|
402 | /** @interface_method_impl{PDMAPICHLPR3,pfnGetR3CritSect} */
|
---|
403 | static DECLCALLBACK(R3PTRTYPE(PPDMCRITSECT)) pdmR3ApicHlp_GetR3CritSect(PPDMDEVINS pDevIns)
|
---|
404 | {
|
---|
405 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
406 | LogFlow(("pdmR3ApicHlp_Lock: caller='%s'/%d\n", pDevIns->pReg->szName, pDevIns->iInstance));
|
---|
407 | return &pDevIns->Internal.s.pVMR3->pdm.s.CritSect;
|
---|
408 | }
|
---|
409 |
|
---|
410 |
|
---|
411 | /** @interface_method_impl{PDMAPICHLPR3,pfnGetRCCritSect} */
|
---|
412 | static DECLCALLBACK(RCPTRTYPE(PPDMCRITSECT)) pdmR3ApicHlp_GetRCCritSect(PPDMDEVINS pDevIns)
|
---|
413 | {
|
---|
414 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
415 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
416 | RTRCPTR RCPtr = MMHyperCCToRC(pVM, &pVM->pdm.s.CritSect);
|
---|
417 | LogFlow(("pdmR3ApicHlp_GetR0CritSect: caller='%s'/%d: return %RRv\n", pDevIns->pReg->szName, pDevIns->iInstance, RCPtr));
|
---|
418 | return RCPtr;
|
---|
419 | }
|
---|
420 |
|
---|
421 |
|
---|
422 | /** @interface_method_impl{PDMAPICHLPR3,pfnGetR3CritSect} */
|
---|
423 | static DECLCALLBACK(R0PTRTYPE(PPDMCRITSECT)) pdmR3ApicHlp_GetR0CritSect(PPDMDEVINS pDevIns)
|
---|
424 | {
|
---|
425 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
426 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
427 | RTR0PTR R0Ptr = MMHyperCCToR0(pVM, &pVM->pdm.s.CritSect);
|
---|
428 | LogFlow(("pdmR3ApicHlp_GetR0CritSect: caller='%s'/%d: return %RHv\n", pDevIns->pReg->szName, pDevIns->iInstance, R0Ptr));
|
---|
429 | return R0Ptr;
|
---|
430 | }
|
---|
431 |
|
---|
432 |
|
---|
433 |
|
---|
434 | /**
|
---|
435 | * APIC Device Helpers.
|
---|
436 | */
|
---|
437 | const PDMAPICHLPR3 g_pdmR3DevApicHlp =
|
---|
438 | {
|
---|
439 | PDM_APICHLPR3_VERSION,
|
---|
440 | pdmR3ApicHlp_SetInterruptFF,
|
---|
441 | pdmR3ApicHlp_ClearInterruptFF,
|
---|
442 | pdmR3ApicHlp_BusBroadcastEoi,
|
---|
443 | pdmR3ApicHlp_CalcIrqTag,
|
---|
444 | pdmR3ApicHlp_SetFeatureLevel,
|
---|
445 | pdmR3ApicHlp_GetCpuId,
|
---|
446 | pdmR3ApicHlp_SendStartupIpi,
|
---|
447 | pdmR3ApicHlp_SendInitIpi,
|
---|
448 | pdmR3ApicHlp_GetRCHelpers,
|
---|
449 | pdmR3ApicHlp_GetR0Helpers,
|
---|
450 | pdmR3ApicHlp_GetR3CritSect,
|
---|
451 | pdmR3ApicHlp_GetRCCritSect,
|
---|
452 | pdmR3ApicHlp_GetR0CritSect,
|
---|
453 | PDM_APICHLPR3_VERSION /* the end */
|
---|
454 | };
|
---|
455 |
|
---|
456 | /** @} */
|
---|
457 |
|
---|
458 |
|
---|
459 |
|
---|
460 |
|
---|
461 | /** @name Ring-3 I/O APIC Helpers
|
---|
462 | * @{
|
---|
463 | */
|
---|
464 |
|
---|
465 | /** @interface_method_impl{PDMIOAPICHLPR3,pfnApicBusDeliver} */
|
---|
466 | static DECLCALLBACK(int) pdmR3IoApicHlp_ApicBusDeliver(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
|
---|
467 | uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode, uint32_t uTagSrc)
|
---|
468 | {
|
---|
469 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
470 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
471 | LogFlow(("pdmR3IoApicHlp_ApicBusDeliver: caller='%s'/%d: u8Dest=%RX8 u8DestMode=%RX8 u8DeliveryMode=%RX8 iVector=%RX8 u8Polarity=%RX8 u8TriggerMode=%RX8 uTagSrc=%#x\n",
|
---|
472 | pDevIns->pReg->szName, pDevIns->iInstance, u8Dest, u8DestMode, u8DeliveryMode, iVector, u8Polarity, u8TriggerMode, uTagSrc));
|
---|
473 | if (pVM->pdm.s.Apic.pfnBusDeliverR3)
|
---|
474 | return pVM->pdm.s.Apic.pfnBusDeliverR3(pVM->pdm.s.Apic.pDevInsR3, u8Dest, u8DestMode, u8DeliveryMode, iVector, u8Polarity, u8TriggerMode, uTagSrc);
|
---|
475 | return VINF_SUCCESS;
|
---|
476 | }
|
---|
477 |
|
---|
478 |
|
---|
479 | /** @interface_method_impl{PDMIOAPICHLPR3,pfnLock} */
|
---|
480 | static DECLCALLBACK(int) pdmR3IoApicHlp_Lock(PPDMDEVINS pDevIns, int rc)
|
---|
481 | {
|
---|
482 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
483 | LogFlow(("pdmR3IoApicHlp_Lock: caller='%s'/%d: rc=%Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
|
---|
484 | return pdmLockEx(pDevIns->Internal.s.pVMR3, rc);
|
---|
485 | }
|
---|
486 |
|
---|
487 |
|
---|
488 | /** @interface_method_impl{PDMIOAPICHLPR3,pfnUnlock} */
|
---|
489 | static DECLCALLBACK(void) pdmR3IoApicHlp_Unlock(PPDMDEVINS pDevIns)
|
---|
490 | {
|
---|
491 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
492 | LogFlow(("pdmR3IoApicHlp_Unlock: caller='%s'/%d:\n", pDevIns->pReg->szName, pDevIns->iInstance));
|
---|
493 | pdmUnlock(pDevIns->Internal.s.pVMR3);
|
---|
494 | }
|
---|
495 |
|
---|
496 |
|
---|
497 | /** @interface_method_impl{PDMIOAPICHLPR3,pfnGetRCHelpers} */
|
---|
498 | static DECLCALLBACK(PCPDMIOAPICHLPRC) pdmR3IoApicHlp_GetRCHelpers(PPDMDEVINS pDevIns)
|
---|
499 | {
|
---|
500 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
501 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
502 | VM_ASSERT_EMT(pVM);
|
---|
503 |
|
---|
504 | RTRCPTR pRCHelpers = NIL_RTRCPTR;
|
---|
505 | if (!HMIsEnabled(pVM))
|
---|
506 | {
|
---|
507 | int rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_pdmRCIoApicHlp", &pRCHelpers);
|
---|
508 | AssertReleaseRC(rc);
|
---|
509 | AssertRelease(pRCHelpers);
|
---|
510 | }
|
---|
511 |
|
---|
512 | LogFlow(("pdmR3IoApicHlp_GetRCHelpers: caller='%s'/%d: returns %RRv\n",
|
---|
513 | pDevIns->pReg->szName, pDevIns->iInstance, pRCHelpers));
|
---|
514 | return pRCHelpers;
|
---|
515 | }
|
---|
516 |
|
---|
517 |
|
---|
518 | /** @interface_method_impl{PDMIOAPICHLPR3,pfnGetR0Helpers} */
|
---|
519 | static DECLCALLBACK(PCPDMIOAPICHLPR0) pdmR3IoApicHlp_GetR0Helpers(PPDMDEVINS pDevIns)
|
---|
520 | {
|
---|
521 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
522 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
523 | VM_ASSERT_EMT(pVM);
|
---|
524 | PCPDMIOAPICHLPR0 pR0Helpers = 0;
|
---|
525 | int rc = PDMR3LdrGetSymbolR0(pVM, NULL, "g_pdmR0IoApicHlp", &pR0Helpers);
|
---|
526 | AssertReleaseRC(rc);
|
---|
527 | AssertRelease(pR0Helpers);
|
---|
528 | LogFlow(("pdmR3IoApicHlp_GetR0Helpers: caller='%s'/%d: returns %RHv\n",
|
---|
529 | pDevIns->pReg->szName, pDevIns->iInstance, pR0Helpers));
|
---|
530 | return pR0Helpers;
|
---|
531 | }
|
---|
532 |
|
---|
533 |
|
---|
534 | /**
|
---|
535 | * I/O APIC Device Helpers.
|
---|
536 | */
|
---|
537 | const PDMIOAPICHLPR3 g_pdmR3DevIoApicHlp =
|
---|
538 | {
|
---|
539 | PDM_IOAPICHLPR3_VERSION,
|
---|
540 | pdmR3IoApicHlp_ApicBusDeliver,
|
---|
541 | pdmR3IoApicHlp_Lock,
|
---|
542 | pdmR3IoApicHlp_Unlock,
|
---|
543 | pdmR3IoApicHlp_GetRCHelpers,
|
---|
544 | pdmR3IoApicHlp_GetR0Helpers,
|
---|
545 | PDM_IOAPICHLPR3_VERSION /* the end */
|
---|
546 | };
|
---|
547 |
|
---|
548 | /** @} */
|
---|
549 |
|
---|
550 |
|
---|
551 |
|
---|
552 |
|
---|
553 | /** @name Ring-3 PCI Bus Helpers
|
---|
554 | * @{
|
---|
555 | */
|
---|
556 |
|
---|
557 | /** @interface_method_impl{PDMPCIHLPR3,pfnIsaSetIrq} */
|
---|
558 | static DECLCALLBACK(void) pdmR3PciHlp_IsaSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc)
|
---|
559 | {
|
---|
560 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
561 | Log4(("pdmR3PciHlp_IsaSetIrq: iIrq=%d iLevel=%d uTagSrc=%#x\n", iIrq, iLevel, uTagSrc));
|
---|
562 | PDMIsaSetIrq(pDevIns->Internal.s.pVMR3, iIrq, iLevel, uTagSrc);
|
---|
563 | }
|
---|
564 |
|
---|
565 | /** @interface_method_impl{PDMPCIHLPR3,pfnIoApicSetIrq} */
|
---|
566 | static DECLCALLBACK(void) pdmR3PciHlp_IoApicSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc)
|
---|
567 | {
|
---|
568 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
569 | Log4(("pdmR3PciHlp_IoApicSetIrq: iIrq=%d iLevel=%d uTagSrc=%#x\n", iIrq, iLevel, uTagSrc));
|
---|
570 | PDMIoApicSetIrq(pDevIns->Internal.s.pVMR3, iIrq, iLevel, uTagSrc);
|
---|
571 | }
|
---|
572 |
|
---|
573 | /** @interface_method_impl{PDMPCIHLPR3,pfnIoApicSendMsi} */
|
---|
574 | static DECLCALLBACK(void) pdmR3PciHlp_IoApicSendMsi(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue, uint32_t uTagSrc)
|
---|
575 | {
|
---|
576 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
577 | Log4(("pdmR3PciHlp_IoApicSendMsi: address=%p value=%x uTagSrc=%#x\n", GCPhys, uValue, uTagSrc));
|
---|
578 | PDMIoApicSendMsi(pDevIns->Internal.s.pVMR3, GCPhys, uValue, uTagSrc);
|
---|
579 | }
|
---|
580 |
|
---|
581 | /** @interface_method_impl{PDMPCIHLPR3,pfnIsMMIO2Base} */
|
---|
582 | static DECLCALLBACK(bool) pdmR3PciHlp_IsMMIO2Base(PPDMDEVINS pDevIns, PPDMDEVINS pOwner, RTGCPHYS GCPhys)
|
---|
583 | {
|
---|
584 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
585 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
|
---|
586 | bool fRc = PGMR3PhysMMIO2IsBase(pDevIns->Internal.s.pVMR3, pOwner, GCPhys);
|
---|
587 | Log4(("pdmR3PciHlp_IsMMIO2Base: pOwner=%p GCPhys=%RGp -> %RTbool\n", pOwner, GCPhys, fRc));
|
---|
588 | return fRc;
|
---|
589 | }
|
---|
590 |
|
---|
591 |
|
---|
592 | /** @interface_method_impl{PDMPCIHLPR3,pfnLock} */
|
---|
593 | static DECLCALLBACK(int) pdmR3PciHlp_Lock(PPDMDEVINS pDevIns, int rc)
|
---|
594 | {
|
---|
595 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
596 | LogFlow(("pdmR3PciHlp_Lock: caller='%s'/%d: rc=%Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
|
---|
597 | return pdmLockEx(pDevIns->Internal.s.pVMR3, rc);
|
---|
598 | }
|
---|
599 |
|
---|
600 |
|
---|
601 | /** @interface_method_impl{PDMPCIHLPR3,pfnUnlock} */
|
---|
602 | static DECLCALLBACK(void) pdmR3PciHlp_Unlock(PPDMDEVINS pDevIns)
|
---|
603 | {
|
---|
604 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
605 | LogFlow(("pdmR3PciHlp_Unlock: caller='%s'/%d:\n", pDevIns->pReg->szName, pDevIns->iInstance));
|
---|
606 | pdmUnlock(pDevIns->Internal.s.pVMR3);
|
---|
607 | }
|
---|
608 |
|
---|
609 |
|
---|
610 | /** @interface_method_impl{PDMPCIHLPR3,pfnGetRCHelpers} */
|
---|
611 | static DECLCALLBACK(PCPDMPCIHLPRC) pdmR3PciHlp_GetRCHelpers(PPDMDEVINS pDevIns)
|
---|
612 | {
|
---|
613 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
614 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
615 | VM_ASSERT_EMT(pVM);
|
---|
616 |
|
---|
617 | RTRCPTR pRCHelpers = NIL_RTRCPTR;
|
---|
618 | if (!HMIsEnabled(pVM))
|
---|
619 | {
|
---|
620 | int rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_pdmRCPciHlp", &pRCHelpers);
|
---|
621 | AssertReleaseRC(rc);
|
---|
622 | AssertRelease(pRCHelpers);
|
---|
623 | }
|
---|
624 |
|
---|
625 | LogFlow(("pdmR3PciHlp_GetRCHelpers: caller='%s'/%d: returns %RRv\n",
|
---|
626 | pDevIns->pReg->szName, pDevIns->iInstance, pRCHelpers));
|
---|
627 | return pRCHelpers;
|
---|
628 | }
|
---|
629 |
|
---|
630 |
|
---|
631 | /** @interface_method_impl{PDMPCIHLPR3,pfnGetR0Helpers} */
|
---|
632 | static DECLCALLBACK(PCPDMPCIHLPR0) pdmR3PciHlp_GetR0Helpers(PPDMDEVINS pDevIns)
|
---|
633 | {
|
---|
634 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
635 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
636 | VM_ASSERT_EMT(pVM);
|
---|
637 | PCPDMPCIHLPR0 pR0Helpers = 0;
|
---|
638 | int rc = PDMR3LdrGetSymbolR0(pVM, NULL, "g_pdmR0PciHlp", &pR0Helpers);
|
---|
639 | AssertReleaseRC(rc);
|
---|
640 | AssertRelease(pR0Helpers);
|
---|
641 | LogFlow(("pdmR3PciHlp_GetR0Helpers: caller='%s'/%d: returns %RHv\n",
|
---|
642 | pDevIns->pReg->szName, pDevIns->iInstance, pR0Helpers));
|
---|
643 | return pR0Helpers;
|
---|
644 | }
|
---|
645 |
|
---|
646 |
|
---|
647 | /**
|
---|
648 | * PCI Bus Device Helpers.
|
---|
649 | */
|
---|
650 | const PDMPCIHLPR3 g_pdmR3DevPciHlp =
|
---|
651 | {
|
---|
652 | PDM_PCIHLPR3_VERSION,
|
---|
653 | pdmR3PciHlp_IsaSetIrq,
|
---|
654 | pdmR3PciHlp_IoApicSetIrq,
|
---|
655 | pdmR3PciHlp_IoApicSendMsi,
|
---|
656 | pdmR3PciHlp_IsMMIO2Base,
|
---|
657 | pdmR3PciHlp_GetRCHelpers,
|
---|
658 | pdmR3PciHlp_GetR0Helpers,
|
---|
659 | pdmR3PciHlp_Lock,
|
---|
660 | pdmR3PciHlp_Unlock,
|
---|
661 | PDM_PCIHLPR3_VERSION, /* the end */
|
---|
662 | };
|
---|
663 |
|
---|
664 | /** @} */
|
---|
665 |
|
---|
666 |
|
---|
667 |
|
---|
668 |
|
---|
669 | /** @name Ring-3 HPET Helpers
|
---|
670 | * {@
|
---|
671 | */
|
---|
672 |
|
---|
673 | /** @interface_method_impl{PDMHPETHLPR3,pfnSetLegacyMode} */
|
---|
674 | static DECLCALLBACK(int) pdmR3HpetHlp_SetLegacyMode(PPDMDEVINS pDevIns, bool fActivated)
|
---|
675 | {
|
---|
676 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
677 | LogFlow(("pdmR3HpetHlp_SetLegacyMode: caller='%s'/%d: fActivated=%RTbool\n", pDevIns->pReg->szName, pDevIns->iInstance, fActivated));
|
---|
678 |
|
---|
679 | size_t i;
|
---|
680 | int rc = VINF_SUCCESS;
|
---|
681 | static const char * const s_apszDevsToNotify[] =
|
---|
682 | {
|
---|
683 | "i8254",
|
---|
684 | "mc146818"
|
---|
685 | };
|
---|
686 | for (i = 0; i < RT_ELEMENTS(s_apszDevsToNotify); i++)
|
---|
687 | {
|
---|
688 | PPDMIBASE pBase;
|
---|
689 | rc = PDMR3QueryDevice(pDevIns->Internal.s.pVMR3->pUVM, "i8254", 0, &pBase);
|
---|
690 | if (RT_SUCCESS(rc))
|
---|
691 | {
|
---|
692 | PPDMIHPETLEGACYNOTIFY pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIHPETLEGACYNOTIFY);
|
---|
693 | AssertLogRelMsgBreakStmt(pPort, ("%s\n", s_apszDevsToNotify[i]), rc = VERR_PDM_HPET_LEGACY_NOTIFY_MISSING);
|
---|
694 | pPort->pfnModeChanged(pPort, fActivated);
|
---|
695 | }
|
---|
696 | else if ( rc == VERR_PDM_DEVICE_NOT_FOUND
|
---|
697 | || rc == VERR_PDM_DEVICE_INSTANCE_NOT_FOUND)
|
---|
698 | rc = VINF_SUCCESS; /* the device isn't configured, ignore. */
|
---|
699 | else
|
---|
700 | AssertLogRelMsgFailedBreak(("%s -> %Rrc\n", s_apszDevsToNotify[i], rc));
|
---|
701 | }
|
---|
702 |
|
---|
703 | /* Don't bother cleaning up, any failure here will cause a guru meditation. */
|
---|
704 |
|
---|
705 | LogFlow(("pdmR3HpetHlp_SetLegacyMode: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
|
---|
706 | return rc;
|
---|
707 | }
|
---|
708 |
|
---|
709 |
|
---|
710 | /** @interface_method_impl{PDMHPETHLPR3,pfnSetIrq} */
|
---|
711 | static DECLCALLBACK(int) pdmR3HpetHlp_SetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
|
---|
712 | {
|
---|
713 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
714 | LogFlow(("pdmR3HpetHlp_SetIrq: caller='%s'/%d: iIrq=%d iLevel=%d\n", pDevIns->pReg->szName, pDevIns->iInstance, iIrq, iLevel));
|
---|
715 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
716 |
|
---|
717 | pdmLock(pVM);
|
---|
718 | uint32_t uTagSrc;
|
---|
719 | if (iLevel & PDM_IRQ_LEVEL_HIGH)
|
---|
720 | {
|
---|
721 | pDevIns->Internal.s.uLastIrqTag = uTagSrc = pdmCalcIrqTag(pVM, pDevIns->idTracing);
|
---|
722 | if (iLevel == PDM_IRQ_LEVEL_HIGH)
|
---|
723 | VBOXVMM_PDM_IRQ_HIGH(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
|
---|
724 | else
|
---|
725 | VBOXVMM_PDM_IRQ_HILO(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
|
---|
726 | }
|
---|
727 | else
|
---|
728 | uTagSrc = pDevIns->Internal.s.uLastIrqTag;
|
---|
729 |
|
---|
730 | PDMIsaSetIrq(pVM, iIrq, iLevel, uTagSrc); /* (The API takes the lock recursively.) */
|
---|
731 |
|
---|
732 | if (iLevel == PDM_IRQ_LEVEL_LOW)
|
---|
733 | VBOXVMM_PDM_IRQ_LOW(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
|
---|
734 | pdmUnlock(pVM);
|
---|
735 | return 0;
|
---|
736 | }
|
---|
737 |
|
---|
738 |
|
---|
739 | /** @interface_method_impl{PDMHPETHLPR3,pfnGetRCHelpers} */
|
---|
740 | static DECLCALLBACK(PCPDMHPETHLPRC) pdmR3HpetHlp_GetRCHelpers(PPDMDEVINS pDevIns)
|
---|
741 | {
|
---|
742 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
743 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
744 | VM_ASSERT_EMT(pVM);
|
---|
745 |
|
---|
746 | RTRCPTR pRCHelpers = NIL_RTRCPTR;
|
---|
747 | if (!HMIsEnabled(pVM))
|
---|
748 | {
|
---|
749 | int rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_pdmRCHpetHlp", &pRCHelpers);
|
---|
750 | AssertReleaseRC(rc);
|
---|
751 | AssertRelease(pRCHelpers);
|
---|
752 | }
|
---|
753 |
|
---|
754 | LogFlow(("pdmR3HpetHlp_GetGCHelpers: caller='%s'/%d: returns %RRv\n",
|
---|
755 | pDevIns->pReg->szName, pDevIns->iInstance, pRCHelpers));
|
---|
756 | return pRCHelpers;
|
---|
757 | }
|
---|
758 |
|
---|
759 |
|
---|
760 | /** @interface_method_impl{PDMHPETHLPR3,pfnGetR0Helpers} */
|
---|
761 | static DECLCALLBACK(PCPDMHPETHLPR0) pdmR3HpetHlp_GetR0Helpers(PPDMDEVINS pDevIns)
|
---|
762 | {
|
---|
763 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
764 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
765 | VM_ASSERT_EMT(pVM);
|
---|
766 | PCPDMHPETHLPR0 pR0Helpers = 0;
|
---|
767 | int rc = PDMR3LdrGetSymbolR0(pVM, NULL, "g_pdmR0HpetHlp", &pR0Helpers);
|
---|
768 | AssertReleaseRC(rc);
|
---|
769 | AssertRelease(pR0Helpers);
|
---|
770 | LogFlow(("pdmR3HpetHlp_GetR0Helpers: caller='%s'/%d: returns %RHv\n",
|
---|
771 | pDevIns->pReg->szName, pDevIns->iInstance, pR0Helpers));
|
---|
772 | return pR0Helpers;
|
---|
773 | }
|
---|
774 |
|
---|
775 |
|
---|
776 | /**
|
---|
777 | * HPET Device Helpers.
|
---|
778 | */
|
---|
779 | const PDMHPETHLPR3 g_pdmR3DevHpetHlp =
|
---|
780 | {
|
---|
781 | PDM_HPETHLPR3_VERSION,
|
---|
782 | pdmR3HpetHlp_GetRCHelpers,
|
---|
783 | pdmR3HpetHlp_GetR0Helpers,
|
---|
784 | pdmR3HpetHlp_SetLegacyMode,
|
---|
785 | pdmR3HpetHlp_SetIrq,
|
---|
786 | PDM_HPETHLPR3_VERSION, /* the end */
|
---|
787 | };
|
---|
788 |
|
---|
789 | /** @} */
|
---|
790 |
|
---|
791 |
|
---|
792 | /** @name Ring-3 Raw PCI Device Helpers
|
---|
793 | * {@
|
---|
794 | */
|
---|
795 |
|
---|
796 | /** @interface_method_impl{PDMPCIRAWHLPR3,pfnGetRCHelpers} */
|
---|
797 | static DECLCALLBACK(PCPDMPCIRAWHLPRC) pdmR3PciRawHlp_GetRCHelpers(PPDMDEVINS pDevIns)
|
---|
798 | {
|
---|
799 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
800 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
801 | VM_ASSERT_EMT(pVM);
|
---|
802 |
|
---|
803 | RTRCPTR pRCHelpers = NIL_RTRCPTR;
|
---|
804 | if (!HMIsEnabled(pVM))
|
---|
805 | {
|
---|
806 | int rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_pdmRCPciRawHlp", &pRCHelpers);
|
---|
807 | AssertReleaseRC(rc);
|
---|
808 | AssertRelease(pRCHelpers);
|
---|
809 | }
|
---|
810 |
|
---|
811 | LogFlow(("pdmR3PciRawHlp_GetGCHelpers: caller='%s'/%d: returns %RRv\n",
|
---|
812 | pDevIns->pReg->szName, pDevIns->iInstance, pRCHelpers));
|
---|
813 | return pRCHelpers;
|
---|
814 | }
|
---|
815 |
|
---|
816 |
|
---|
817 | /** @interface_method_impl{PDMPCIRAWHLPR3,pfnGetR0Helpers} */
|
---|
818 | static DECLCALLBACK(PCPDMPCIRAWHLPR0) pdmR3PciRawHlp_GetR0Helpers(PPDMDEVINS pDevIns)
|
---|
819 | {
|
---|
820 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
821 | PVM pVM = pDevIns->Internal.s.pVMR3;
|
---|
822 | VM_ASSERT_EMT(pVM);
|
---|
823 | PCPDMHPETHLPR0 pR0Helpers = NIL_RTR0PTR;
|
---|
824 | int rc = PDMR3LdrGetSymbolR0(pVM, NULL, "g_pdmR0PciRawHlp", &pR0Helpers);
|
---|
825 | AssertReleaseRC(rc);
|
---|
826 | AssertRelease(pR0Helpers);
|
---|
827 | LogFlow(("pdmR3PciRawHlp_GetR0Helpers: caller='%s'/%d: returns %RHv\n",
|
---|
828 | pDevIns->pReg->szName, pDevIns->iInstance, pR0Helpers));
|
---|
829 | return pR0Helpers;
|
---|
830 | }
|
---|
831 |
|
---|
832 |
|
---|
833 | /**
|
---|
834 | * Raw PCI Device Helpers.
|
---|
835 | */
|
---|
836 | const PDMPCIRAWHLPR3 g_pdmR3DevPciRawHlp =
|
---|
837 | {
|
---|
838 | PDM_PCIRAWHLPR3_VERSION,
|
---|
839 | pdmR3PciRawHlp_GetRCHelpers,
|
---|
840 | pdmR3PciRawHlp_GetR0Helpers,
|
---|
841 | PDM_PCIRAWHLPR3_VERSION, /* the end */
|
---|
842 | };
|
---|
843 |
|
---|
844 | /** @} */
|
---|
845 |
|
---|
846 |
|
---|
847 | /* none yet */
|
---|
848 |
|
---|
849 | /**
|
---|
850 | * Firmware Device Helpers.
|
---|
851 | */
|
---|
852 | const PDMFWHLPR3 g_pdmR3DevFirmwareHlp =
|
---|
853 | {
|
---|
854 | PDM_FWHLPR3_VERSION,
|
---|
855 | PDM_FWHLPR3_VERSION
|
---|
856 | };
|
---|
857 |
|
---|
858 | /**
|
---|
859 | * DMAC Device Helpers.
|
---|
860 | */
|
---|
861 | const PDMDMACHLP g_pdmR3DevDmacHlp =
|
---|
862 | {
|
---|
863 | PDM_DMACHLP_VERSION
|
---|
864 | };
|
---|
865 |
|
---|
866 |
|
---|
867 |
|
---|
868 |
|
---|
869 | /* none yet */
|
---|
870 |
|
---|
871 | /**
|
---|
872 | * RTC Device Helpers.
|
---|
873 | */
|
---|
874 | const PDMRTCHLP g_pdmR3DevRtcHlp =
|
---|
875 | {
|
---|
876 | PDM_RTCHLP_VERSION
|
---|
877 | };
|
---|
878 |
|
---|