1 | /* $Id: PDMDevice.cpp 3112 2007-06-14 18:23:38Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * PDM - Pluggable Device and Driver Manager, Device parts.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
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/cfgm.h>
|
---|
33 | #include <VBox/rem.h>
|
---|
34 | #include <VBox/dbgf.h>
|
---|
35 | #include <VBox/vm.h>
|
---|
36 | #include <VBox/vmm.h>
|
---|
37 | #include <VBox/hwaccm.h>
|
---|
38 |
|
---|
39 | #include <VBox/version.h>
|
---|
40 | #include <VBox/log.h>
|
---|
41 | #include <VBox/err.h>
|
---|
42 | #include <iprt/alloc.h>
|
---|
43 | #include <iprt/alloca.h>
|
---|
44 | #include <iprt/asm.h>
|
---|
45 | #include <iprt/assert.h>
|
---|
46 | #include <iprt/path.h>
|
---|
47 | #include <iprt/semaphore.h>
|
---|
48 | #include <iprt/string.h>
|
---|
49 | #include <iprt/thread.h>
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 | /*******************************************************************************
|
---|
54 | * Structures and Typedefs *
|
---|
55 | *******************************************************************************/
|
---|
56 | /**
|
---|
57 | * Internal callback structure pointer.
|
---|
58 | * The main purpose is to define the extra data we associate
|
---|
59 | * with PDMDEVREGCB so we can find the VM instance and so on.
|
---|
60 | */
|
---|
61 | typedef struct PDMDEVREGCBINT
|
---|
62 | {
|
---|
63 | /** The callback structure. */
|
---|
64 | PDMDEVREGCB Core;
|
---|
65 | /** A bit of padding. */
|
---|
66 | uint32_t u32[4];
|
---|
67 | /** VM Handle. */
|
---|
68 | PVM pVM;
|
---|
69 | } PDMDEVREGCBINT, *PPDMDEVREGCBINT;
|
---|
70 | typedef const PDMDEVREGCBINT *PCPDMDEVREGCBINT;
|
---|
71 |
|
---|
72 |
|
---|
73 | /*******************************************************************************
|
---|
74 | * Internal Functions *
|
---|
75 | *******************************************************************************/
|
---|
76 | static DECLCALLBACK(int) pdmR3DevReg_Register(PPDMDEVREGCB pCallbacks, PCPDMDEVREG pDevReg);
|
---|
77 | static DECLCALLBACK(void *) pdmR3DevReg_MMHeapAlloc(PPDMDEVREGCB pCallbacks, size_t cb);
|
---|
78 | static DECLCALLBACK(bool) pdmR3DevHlpQueueConsumer(PVM pVM, PPDMQUEUEITEMCORE pItem);
|
---|
79 |
|
---|
80 | /* VSlick regex:
|
---|
81 | search : \om/\*\*.+?\*\/\nDECLCALLBACKMEMBER\(([^,]*), *pfn([^)]*)\)\(
|
---|
82 | replace: \/\*\* @copydoc PDMDEVHLP::pfn\2 \*\/\nstatic DECLCALLBACK\(\1\) pdmR3DevHlp_\2\(
|
---|
83 | */
|
---|
84 |
|
---|
85 | /** @name R3 DevHlp
|
---|
86 | * @{
|
---|
87 | */
|
---|
88 | static DECLCALLBACK(int) pdmR3DevHlp_IOPortRegister(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTHCPTR pvUser, PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn, PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc);
|
---|
89 | static DECLCALLBACK(int) pdmR3DevHlp_IOPortRegisterGC(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTGCPTR pvUser, const char *pszOut, const char *pszIn, const char *pszOutStr, const char *pszInStr, const char *pszDesc);
|
---|
90 | static DECLCALLBACK(int) pdmR3DevHlp_IOPortRegisterR0(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTR0PTR pvUser, const char *pszOut, const char *pszIn, const char *pszOutStr, const char *pszInStr, const char *pszDesc);
|
---|
91 | static DECLCALLBACK(int) pdmR3DevHlp_IOPortDeregister(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts);
|
---|
92 | static DECLCALLBACK(int) pdmR3DevHlp_MMIORegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
|
---|
93 | PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
|
---|
94 | const char *pszDesc);
|
---|
95 | static DECLCALLBACK(int) pdmR3DevHlp_MMIORegisterGC(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
|
---|
96 | const char *pszWrite, const char *pszRead, const char *pszFill,
|
---|
97 | const char *pszDesc);
|
---|
98 | static DECLCALLBACK(int) pdmR3DevHlp_MMIORegisterR0(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTR0PTR pvUser,
|
---|
99 | const char *pszWrite, const char *pszRead, const char *pszFill,
|
---|
100 | const char *pszDesc);
|
---|
101 | static DECLCALLBACK(int) pdmR3DevHlp_MMIODeregister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange);
|
---|
102 | static DECLCALLBACK(int) pdmR3DevHlp_ROMRegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, const void *pvBinary, const char *pszDesc);
|
---|
103 | static DECLCALLBACK(int) pdmR3DevHlp_SSMRegister(PPDMDEVINS pDevIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
|
---|
104 | PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
|
---|
105 | PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone);
|
---|
106 | static DECLCALLBACK(int) pdmR3DevHlp_TMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERHC ppTimer);
|
---|
107 | static DECLCALLBACK(PTMTIMERHC) pdmR3DevHlp_TMTimerCreateExternal(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc);
|
---|
108 | static DECLCALLBACK(int) pdmR3DevHlp_PCIRegister(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev);
|
---|
109 | static DECLCALLBACK(int) pdmR3DevHlp_PCIIORegionRegister(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback);
|
---|
110 | static DECLCALLBACK(void) pdmR3DevHlp_PCISetConfigCallbacks(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
|
---|
111 | PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld);
|
---|
112 | static DECLCALLBACK(void) pdmR3DevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
|
---|
113 | static DECLCALLBACK(void) pdmR3DevHlp_PCISetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel);
|
---|
114 | static DECLCALLBACK(void) pdmR3DevHlp_ISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
|
---|
115 | static DECLCALLBACK(void) pdmR3DevHlp_ISASetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel);
|
---|
116 | static DECLCALLBACK(int) pdmR3DevHlp_DriverAttach(PPDMDEVINS pDevIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc);
|
---|
117 | static DECLCALLBACK(void *) pdmR3DevHlp_MMHeapAlloc(PPDMDEVINS pDevIns, size_t cb);
|
---|
118 | static DECLCALLBACK(void *) pdmR3DevHlp_MMHeapAllocZ(PPDMDEVINS pDevIns, size_t cb);
|
---|
119 | static DECLCALLBACK(void) pdmR3DevHlp_MMHeapFree(PPDMDEVINS pDevIns, void *pv);
|
---|
120 | static DECLCALLBACK(int) pdmR3DevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
|
---|
121 | static DECLCALLBACK(int) pdmR3DevHlp_VMSetErrorV(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va);
|
---|
122 | static DECLCALLBACK(int) pdmR3DevHlp_VMSetRuntimeError(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...);
|
---|
123 | static DECLCALLBACK(int) pdmR3DevHlp_VMSetRuntimeErrorV(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list va);
|
---|
124 | static DECLCALLBACK(bool) pdmR3DevHlp_AssertEMT(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction);
|
---|
125 | static DECLCALLBACK(bool) pdmR3DevHlp_AssertOther(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction);
|
---|
126 | static DECLCALLBACK(int) pdmR3DevHlp_DBGFStopV(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction, const char *pszFormat, va_list args);
|
---|
127 | static DECLCALLBACK(int) pdmR3DevHlp_DBGFInfoRegister(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler);
|
---|
128 | static DECLCALLBACK(void) pdmR3DevHlp_STAMRegister(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc);
|
---|
129 | static DECLCALLBACK(void) pdmR3DevHlp_STAMRegisterF(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...);
|
---|
130 | static DECLCALLBACK(void) pdmR3DevHlp_STAMRegisterV(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args);
|
---|
131 | static DECLCALLBACK(int) pdmR3DevHlp_CritSectInit(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName);
|
---|
132 | static DECLCALLBACK(PRTTIMESPEC) pdmR3DevHlp_UTCNow(PPDMDEVINS pDevIns, PRTTIMESPEC pTime);
|
---|
133 |
|
---|
134 | static DECLCALLBACK(PVM) pdmR3DevHlp_GetVM(PPDMDEVINS pDevIns);
|
---|
135 | static DECLCALLBACK(int) pdmR3DevHlp_PCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3);
|
---|
136 | static DECLCALLBACK(int) pdmR3DevHlp_PICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3);
|
---|
137 | static DECLCALLBACK(int) pdmR3DevHlp_APICRegister(PPDMDEVINS pDevIns, PPDMAPICREG pApicReg, PCPDMAPICHLPR3 *ppApicHlpR3);
|
---|
138 | static DECLCALLBACK(int) pdmR3DevHlp_IOAPICRegister(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3);
|
---|
139 | static DECLCALLBACK(int) pdmR3DevHlp_DMACRegister(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp);
|
---|
140 | static DECLCALLBACK(int) pdmR3DevHlp_RTCRegister(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp);
|
---|
141 | static DECLCALLBACK(int) pdmR3DevHlp_PDMQueueCreate(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue);
|
---|
142 | static DECLCALLBACK(void) pdmR3DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
|
---|
143 | static DECLCALLBACK(void) pdmR3DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
|
---|
144 | static DECLCALLBACK(int) pdmR3DevHlp_PhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb);
|
---|
145 | static DECLCALLBACK(int) pdmR3DevHlp_PhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb);
|
---|
146 | static DECLCALLBACK(int) pdmR3DevHlp_PhysReserve(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc);
|
---|
147 | static DECLCALLBACK(int) pdmR3DevHlp_Phys2HCVirt(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR ppvHC);
|
---|
148 | static DECLCALLBACK(int) pdmR3DevHlp_PhysGCPtr2HCPtr(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTHCPTR pHCPtr);
|
---|
149 | static DECLCALLBACK(bool) pdmR3DevHlp_A20IsEnabled(PPDMDEVINS pDevIns);
|
---|
150 | static DECLCALLBACK(void) pdmR3DevHlp_A20Set(PPDMDEVINS pDevIns, bool fEnable);
|
---|
151 | static DECLCALLBACK(int) pdmR3DevHlp_VMReset(PPDMDEVINS pDevIns);
|
---|
152 | static DECLCALLBACK(int) pdmR3DevHlp_VMPowerOff(PPDMDEVINS pDevIns);
|
---|
153 | static DECLCALLBACK(int) pdmR3DevHlp_VMSuspend(PPDMDEVINS pDevIns);
|
---|
154 | static DECLCALLBACK(int) pdmR3DevHlp_LockVM(PPDMDEVINS pDevIns);
|
---|
155 | static DECLCALLBACK(int) pdmR3DevHlp_UnlockVM(PPDMDEVINS pDevIns);
|
---|
156 | static DECLCALLBACK(bool) pdmR3DevHlp_AssertVMLock(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction);
|
---|
157 | static DECLCALLBACK(int) pdmR3DevHlp_DMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser);
|
---|
158 | static DECLCALLBACK(int) pdmR3DevHlp_DMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead);
|
---|
159 | static DECLCALLBACK(int) pdmR3DevHlp_DMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten);
|
---|
160 | static DECLCALLBACK(int) pdmR3DevHlp_DMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel);
|
---|
161 | static DECLCALLBACK(uint8_t) pdmR3DevHlp_DMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel);
|
---|
162 | static DECLCALLBACK(void) pdmR3DevHlp_DMASchedule(PPDMDEVINS pDevIns);
|
---|
163 | static DECLCALLBACK(int) pdmR3DevHlp_CMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value);
|
---|
164 | static DECLCALLBACK(int) pdmR3DevHlp_CMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value);
|
---|
165 | static DECLCALLBACK(void) pdmR3DevHlp_GetCpuId(PPDMDEVINS pDevIns, uint32_t iLeaf,
|
---|
166 | uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx);
|
---|
167 |
|
---|
168 | static DECLCALLBACK(PVM) pdmR3DevHlp_Untrusted_GetVM(PPDMDEVINS pDevIns);
|
---|
169 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3);
|
---|
170 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3);
|
---|
171 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_APICRegister(PPDMDEVINS pDevIns, PPDMAPICREG pApicReg, PCPDMAPICHLPR3 *ppApicHlpR3);
|
---|
172 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_IOAPICRegister(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3);
|
---|
173 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMACRegister(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp);
|
---|
174 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
|
---|
175 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
|
---|
176 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb);
|
---|
177 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb);
|
---|
178 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysReserve(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc);
|
---|
179 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_Phys2HCVirt(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR ppvHC);
|
---|
180 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysGCPtr2HCPtr(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTHCPTR pHCPtr);
|
---|
181 | static DECLCALLBACK(bool) pdmR3DevHlp_Untrusted_A20IsEnabled(PPDMDEVINS pDevIns);
|
---|
182 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_A20Set(PPDMDEVINS pDevIns, bool fEnable);
|
---|
183 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_VMReset(PPDMDEVINS pDevIns);
|
---|
184 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_VMPowerOff(PPDMDEVINS pDevIns);
|
---|
185 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_VMSuspend(PPDMDEVINS pDevIns);
|
---|
186 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_LockVM(PPDMDEVINS pDevIns);
|
---|
187 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_UnlockVM(PPDMDEVINS pDevIns);
|
---|
188 | static DECLCALLBACK(bool) pdmR3DevHlp_Untrusted_AssertVMLock(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction);
|
---|
189 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser);
|
---|
190 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead);
|
---|
191 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten);
|
---|
192 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel);
|
---|
193 | static DECLCALLBACK(uint8_t) pdmR3DevHlp_Untrusted_DMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel);
|
---|
194 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_DMASchedule(PPDMDEVINS pDevIns);
|
---|
195 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_CMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value);
|
---|
196 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_CMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value);
|
---|
197 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_QueryCPUId(PPDMDEVINS pDevIns, uint32_t iLeaf,
|
---|
198 | uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx);
|
---|
199 |
|
---|
200 | /** @} */
|
---|
201 |
|
---|
202 |
|
---|
203 | /** @name HC PIC Helpers
|
---|
204 | * @{
|
---|
205 | */
|
---|
206 | static DECLCALLBACK(void) pdmR3PicHlp_SetInterruptFF(PPDMDEVINS pDevIns);
|
---|
207 | static DECLCALLBACK(void) pdmR3PicHlp_ClearInterruptFF(PPDMDEVINS pDevIns);
|
---|
208 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
209 | static DECLCALLBACK(int) pdmR3PicHlp_Lock(PPDMDEVINS pDevIns, int rc);
|
---|
210 | static DECLCALLBACK(void) pdmR3PicHlp_Unlock(PPDMDEVINS pDevIns);
|
---|
211 | #endif
|
---|
212 | static DECLCALLBACK(PCPDMPICHLPGC) pdmR3PicHlp_GetGCHelpers(PPDMDEVINS pDevIns);
|
---|
213 | static DECLCALLBACK(PCPDMPICHLPR0) pdmR3PicHlp_GetR0Helpers(PPDMDEVINS pDevIns);
|
---|
214 | /** @} */
|
---|
215 |
|
---|
216 |
|
---|
217 | /** @name HC APIC Helpers
|
---|
218 | * @{
|
---|
219 | */
|
---|
220 | static DECLCALLBACK(void) pdmR3ApicHlp_SetInterruptFF(PPDMDEVINS pDevIns);
|
---|
221 | static DECLCALLBACK(void) pdmR3ApicHlp_ClearInterruptFF(PPDMDEVINS pDevIns);
|
---|
222 | static DECLCALLBACK(void) pdmR3ApicHlp_ChangeFeature(PPDMDEVINS pDevIns, bool fEnabled);
|
---|
223 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
224 | static DECLCALLBACK(int) pdmR3ApicHlp_Lock(PPDMDEVINS pDevIns, int rc);
|
---|
225 | static DECLCALLBACK(void) pdmR3ApicHlp_Unlock(PPDMDEVINS pDevIns);
|
---|
226 | #endif
|
---|
227 | static DECLCALLBACK(PCPDMAPICHLPGC) pdmR3ApicHlp_GetGCHelpers(PPDMDEVINS pDevIns);
|
---|
228 | static DECLCALLBACK(PCPDMAPICHLPR0) pdmR3ApicHlp_GetR0Helpers(PPDMDEVINS pDevIns);
|
---|
229 | /** @} */
|
---|
230 |
|
---|
231 |
|
---|
232 | /** @name HC I/O APIC Helpers
|
---|
233 | * @{
|
---|
234 | */
|
---|
235 | static DECLCALLBACK(void) pdmR3IoApicHlp_ApicBusDeliver(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
|
---|
236 | uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode);
|
---|
237 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
238 | static DECLCALLBACK(int) pdmR3IoApicHlp_Lock(PPDMDEVINS pDevIns, int rc);
|
---|
239 | static DECLCALLBACK(void) pdmR3IoApicHlp_Unlock(PPDMDEVINS pDevIns);
|
---|
240 | #endif
|
---|
241 | static DECLCALLBACK(PCPDMIOAPICHLPGC) pdmR3IoApicHlp_GetGCHelpers(PPDMDEVINS pDevIns);
|
---|
242 | static DECLCALLBACK(PCPDMIOAPICHLPR0) pdmR3IoApicHlp_GetR0Helpers(PPDMDEVINS pDevIns);
|
---|
243 | /** @} */
|
---|
244 |
|
---|
245 |
|
---|
246 | /** @name HC PCI Bus Helpers
|
---|
247 | * @{
|
---|
248 | */
|
---|
249 | static DECLCALLBACK(void) pdmR3PciHlp_IsaSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
|
---|
250 | static DECLCALLBACK(void) pdmR3PciHlp_IoApicSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
|
---|
251 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
252 | static DECLCALLBACK(int) pdmR3PciHlp_Lock(PPDMDEVINS pDevIns, int rc);
|
---|
253 | static DECLCALLBACK(void) pdmR3PciHlp_Unlock(PPDMDEVINS pDevIns);
|
---|
254 | #endif
|
---|
255 | static DECLCALLBACK(PCPDMPCIHLPGC) pdmR3PciHlp_GetGCHelpers(PPDMDEVINS pDevIns);
|
---|
256 | static DECLCALLBACK(PCPDMPCIHLPR0) pdmR3PciHlp_GetR0Helpers(PPDMDEVINS pDevIns);
|
---|
257 | /** @} */
|
---|
258 |
|
---|
259 | /** @def PDMDEV_ASSERT_DEVINS
|
---|
260 | * Asserts the validity of the driver instance.
|
---|
261 | */
|
---|
262 | #ifdef VBOX_STRICT
|
---|
263 | # define PDMDEV_ASSERT_DEVINS(pDevIns) do { Assert(pDevIns); Assert(pDevIns->u32Version == PDM_DEVINS_VERSION); Assert(pDevIns->pvInstanceDataR3 == (void *)&pDevIns->achInstanceData[0]); } while (0)
|
---|
264 | #else
|
---|
265 | # define PDMDEV_ASSERT_DEVINS(pDevIns) do { } while (0)
|
---|
266 | #endif
|
---|
267 | static int pdmR3DevLoad(PVM pVM, PPDMDEVREGCBINT pRegCB, const char *pszFilename, const char *pszName);
|
---|
268 |
|
---|
269 |
|
---|
270 | /*
|
---|
271 | * Allow physical read and writes from any thread
|
---|
272 | */
|
---|
273 | #define PDM_PHYS_READWRITE_FROM_ANY_THREAD
|
---|
274 |
|
---|
275 | /*******************************************************************************
|
---|
276 | * Global Variables *
|
---|
277 | *******************************************************************************/
|
---|
278 | /**
|
---|
279 | * The device helper structure for trusted devices.
|
---|
280 | */
|
---|
281 | const PDMDEVHLP g_pdmR3DevHlpTrusted =
|
---|
282 | {
|
---|
283 | PDM_DEVHLP_VERSION,
|
---|
284 | pdmR3DevHlp_IOPortRegister,
|
---|
285 | pdmR3DevHlp_IOPortRegisterGC,
|
---|
286 | pdmR3DevHlp_IOPortRegisterR0,
|
---|
287 | pdmR3DevHlp_IOPortDeregister,
|
---|
288 | pdmR3DevHlp_MMIORegister,
|
---|
289 | pdmR3DevHlp_MMIORegisterGC,
|
---|
290 | pdmR3DevHlp_MMIORegisterR0,
|
---|
291 | pdmR3DevHlp_MMIODeregister,
|
---|
292 | pdmR3DevHlp_ROMRegister,
|
---|
293 | pdmR3DevHlp_SSMRegister,
|
---|
294 | pdmR3DevHlp_TMTimerCreate,
|
---|
295 | pdmR3DevHlp_TMTimerCreateExternal,
|
---|
296 | pdmR3DevHlp_PCIRegister,
|
---|
297 | pdmR3DevHlp_PCIIORegionRegister,
|
---|
298 | pdmR3DevHlp_PCISetConfigCallbacks,
|
---|
299 | pdmR3DevHlp_PCISetIrq,
|
---|
300 | pdmR3DevHlp_PCISetIrqNoWait,
|
---|
301 | pdmR3DevHlp_ISASetIrq,
|
---|
302 | pdmR3DevHlp_ISASetIrqNoWait,
|
---|
303 | pdmR3DevHlp_DriverAttach,
|
---|
304 | pdmR3DevHlp_MMHeapAlloc,
|
---|
305 | pdmR3DevHlp_MMHeapAllocZ,
|
---|
306 | pdmR3DevHlp_MMHeapFree,
|
---|
307 | pdmR3DevHlp_VMSetError,
|
---|
308 | pdmR3DevHlp_VMSetErrorV,
|
---|
309 | pdmR3DevHlp_VMSetRuntimeError,
|
---|
310 | pdmR3DevHlp_VMSetRuntimeErrorV,
|
---|
311 | pdmR3DevHlp_AssertEMT,
|
---|
312 | pdmR3DevHlp_AssertOther,
|
---|
313 | pdmR3DevHlp_DBGFStopV,
|
---|
314 | pdmR3DevHlp_DBGFInfoRegister,
|
---|
315 | pdmR3DevHlp_STAMRegister,
|
---|
316 | pdmR3DevHlp_STAMRegisterF,
|
---|
317 | pdmR3DevHlp_STAMRegisterV,
|
---|
318 | pdmR3DevHlp_RTCRegister,
|
---|
319 | pdmR3DevHlp_PDMQueueCreate,
|
---|
320 | pdmR3DevHlp_CritSectInit,
|
---|
321 | pdmR3DevHlp_UTCNow,
|
---|
322 | 0,
|
---|
323 | 0,
|
---|
324 | 0,
|
---|
325 | 0,
|
---|
326 | 0,
|
---|
327 | 0,
|
---|
328 | 0,
|
---|
329 | 0,
|
---|
330 | 0,
|
---|
331 | 0,
|
---|
332 | pdmR3DevHlp_GetVM,
|
---|
333 | pdmR3DevHlp_PCIBusRegister,
|
---|
334 | pdmR3DevHlp_PICRegister,
|
---|
335 | pdmR3DevHlp_APICRegister,
|
---|
336 | pdmR3DevHlp_IOAPICRegister,
|
---|
337 | pdmR3DevHlp_DMACRegister,
|
---|
338 | pdmR3DevHlp_PhysRead,
|
---|
339 | pdmR3DevHlp_PhysWrite,
|
---|
340 | pdmR3DevHlp_PhysReadGCVirt,
|
---|
341 | pdmR3DevHlp_PhysWriteGCVirt,
|
---|
342 | pdmR3DevHlp_PhysReserve,
|
---|
343 | pdmR3DevHlp_Phys2HCVirt,
|
---|
344 | pdmR3DevHlp_PhysGCPtr2HCPtr,
|
---|
345 | pdmR3DevHlp_A20IsEnabled,
|
---|
346 | pdmR3DevHlp_A20Set,
|
---|
347 | pdmR3DevHlp_VMReset,
|
---|
348 | pdmR3DevHlp_VMSuspend,
|
---|
349 | pdmR3DevHlp_VMPowerOff,
|
---|
350 | pdmR3DevHlp_LockVM,
|
---|
351 | pdmR3DevHlp_UnlockVM,
|
---|
352 | pdmR3DevHlp_AssertVMLock,
|
---|
353 | pdmR3DevHlp_DMARegister,
|
---|
354 | pdmR3DevHlp_DMAReadMemory,
|
---|
355 | pdmR3DevHlp_DMAWriteMemory,
|
---|
356 | pdmR3DevHlp_DMASetDREQ,
|
---|
357 | pdmR3DevHlp_DMAGetChannelMode,
|
---|
358 | pdmR3DevHlp_DMASchedule,
|
---|
359 | pdmR3DevHlp_CMOSWrite,
|
---|
360 | pdmR3DevHlp_CMOSRead,
|
---|
361 | pdmR3DevHlp_GetCpuId,
|
---|
362 | PDM_DEVHLP_VERSION /* the end */
|
---|
363 | };
|
---|
364 |
|
---|
365 |
|
---|
366 | /**
|
---|
367 | * The device helper structure for non-trusted devices.
|
---|
368 | */
|
---|
369 | const PDMDEVHLP g_pdmR3DevHlpUnTrusted =
|
---|
370 | {
|
---|
371 | PDM_DEVHLP_VERSION,
|
---|
372 | pdmR3DevHlp_IOPortRegister,
|
---|
373 | pdmR3DevHlp_IOPortRegisterGC,
|
---|
374 | pdmR3DevHlp_IOPortRegisterR0,
|
---|
375 | pdmR3DevHlp_IOPortDeregister,
|
---|
376 | pdmR3DevHlp_MMIORegister,
|
---|
377 | pdmR3DevHlp_MMIORegisterGC,
|
---|
378 | pdmR3DevHlp_MMIORegisterR0,
|
---|
379 | pdmR3DevHlp_MMIODeregister,
|
---|
380 | pdmR3DevHlp_ROMRegister,
|
---|
381 | pdmR3DevHlp_SSMRegister,
|
---|
382 | pdmR3DevHlp_TMTimerCreate,
|
---|
383 | pdmR3DevHlp_TMTimerCreateExternal,
|
---|
384 | pdmR3DevHlp_PCIRegister,
|
---|
385 | pdmR3DevHlp_PCIIORegionRegister,
|
---|
386 | pdmR3DevHlp_PCISetConfigCallbacks,
|
---|
387 | pdmR3DevHlp_PCISetIrq,
|
---|
388 | pdmR3DevHlp_PCISetIrqNoWait,
|
---|
389 | pdmR3DevHlp_ISASetIrq,
|
---|
390 | pdmR3DevHlp_ISASetIrqNoWait,
|
---|
391 | pdmR3DevHlp_DriverAttach,
|
---|
392 | pdmR3DevHlp_MMHeapAlloc,
|
---|
393 | pdmR3DevHlp_MMHeapAllocZ,
|
---|
394 | pdmR3DevHlp_MMHeapFree,
|
---|
395 | pdmR3DevHlp_VMSetError,
|
---|
396 | pdmR3DevHlp_VMSetErrorV,
|
---|
397 | pdmR3DevHlp_VMSetRuntimeError,
|
---|
398 | pdmR3DevHlp_VMSetRuntimeErrorV,
|
---|
399 | pdmR3DevHlp_AssertEMT,
|
---|
400 | pdmR3DevHlp_AssertOther,
|
---|
401 | pdmR3DevHlp_DBGFStopV,
|
---|
402 | pdmR3DevHlp_DBGFInfoRegister,
|
---|
403 | pdmR3DevHlp_STAMRegister,
|
---|
404 | pdmR3DevHlp_STAMRegisterF,
|
---|
405 | pdmR3DevHlp_STAMRegisterV,
|
---|
406 | pdmR3DevHlp_RTCRegister,
|
---|
407 | pdmR3DevHlp_PDMQueueCreate,
|
---|
408 | pdmR3DevHlp_CritSectInit,
|
---|
409 | pdmR3DevHlp_UTCNow,
|
---|
410 | 0,
|
---|
411 | 0,
|
---|
412 | 0,
|
---|
413 | 0,
|
---|
414 | 0,
|
---|
415 | 0,
|
---|
416 | 0,
|
---|
417 | 0,
|
---|
418 | 0,
|
---|
419 | 0,
|
---|
420 | pdmR3DevHlp_Untrusted_GetVM,
|
---|
421 | pdmR3DevHlp_Untrusted_PCIBusRegister,
|
---|
422 | pdmR3DevHlp_Untrusted_PICRegister,
|
---|
423 | pdmR3DevHlp_Untrusted_APICRegister,
|
---|
424 | pdmR3DevHlp_Untrusted_IOAPICRegister,
|
---|
425 | pdmR3DevHlp_Untrusted_DMACRegister,
|
---|
426 | pdmR3DevHlp_Untrusted_PhysRead,
|
---|
427 | pdmR3DevHlp_Untrusted_PhysWrite,
|
---|
428 | pdmR3DevHlp_Untrusted_PhysReadGCVirt,
|
---|
429 | pdmR3DevHlp_Untrusted_PhysWriteGCVirt,
|
---|
430 | pdmR3DevHlp_Untrusted_PhysReserve,
|
---|
431 | pdmR3DevHlp_Untrusted_Phys2HCVirt,
|
---|
432 | pdmR3DevHlp_Untrusted_PhysGCPtr2HCPtr,
|
---|
433 | pdmR3DevHlp_Untrusted_A20IsEnabled,
|
---|
434 | pdmR3DevHlp_Untrusted_A20Set,
|
---|
435 | pdmR3DevHlp_Untrusted_VMReset,
|
---|
436 | pdmR3DevHlp_Untrusted_VMSuspend,
|
---|
437 | pdmR3DevHlp_Untrusted_VMPowerOff,
|
---|
438 | pdmR3DevHlp_Untrusted_LockVM,
|
---|
439 | pdmR3DevHlp_Untrusted_UnlockVM,
|
---|
440 | pdmR3DevHlp_Untrusted_AssertVMLock,
|
---|
441 | pdmR3DevHlp_Untrusted_DMARegister,
|
---|
442 | pdmR3DevHlp_Untrusted_DMAReadMemory,
|
---|
443 | pdmR3DevHlp_Untrusted_DMAWriteMemory,
|
---|
444 | pdmR3DevHlp_Untrusted_DMASetDREQ,
|
---|
445 | pdmR3DevHlp_Untrusted_DMAGetChannelMode,
|
---|
446 | pdmR3DevHlp_Untrusted_DMASchedule,
|
---|
447 | pdmR3DevHlp_Untrusted_CMOSWrite,
|
---|
448 | pdmR3DevHlp_Untrusted_CMOSRead,
|
---|
449 | pdmR3DevHlp_Untrusted_QueryCPUId,
|
---|
450 | PDM_DEVHLP_VERSION /* the end */
|
---|
451 | };
|
---|
452 |
|
---|
453 |
|
---|
454 | /**
|
---|
455 | * PIC Device Helpers.
|
---|
456 | */
|
---|
457 | const PDMPICHLPR3 g_pdmR3DevPicHlp =
|
---|
458 | {
|
---|
459 | PDM_PICHLPR3_VERSION,
|
---|
460 | pdmR3PicHlp_SetInterruptFF,
|
---|
461 | pdmR3PicHlp_ClearInterruptFF,
|
---|
462 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
463 | pdmR3PicHlp_Lock,
|
---|
464 | pdmR3PicHlp_Unlock,
|
---|
465 | #endif
|
---|
466 | pdmR3PicHlp_GetGCHelpers,
|
---|
467 | pdmR3PicHlp_GetR0Helpers,
|
---|
468 | PDM_PICHLPR3_VERSION /* the end */
|
---|
469 | };
|
---|
470 |
|
---|
471 |
|
---|
472 | /**
|
---|
473 | * APIC Device Helpers.
|
---|
474 | */
|
---|
475 | const PDMAPICHLPR3 g_pdmR3DevApicHlp =
|
---|
476 | {
|
---|
477 | PDM_APICHLPR3_VERSION,
|
---|
478 | pdmR3ApicHlp_SetInterruptFF,
|
---|
479 | pdmR3ApicHlp_ClearInterruptFF,
|
---|
480 | pdmR3ApicHlp_ChangeFeature,
|
---|
481 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
482 | pdmR3ApicHlp_Lock,
|
---|
483 | pdmR3ApicHlp_Unlock,
|
---|
484 | #endif
|
---|
485 | pdmR3ApicHlp_GetGCHelpers,
|
---|
486 | pdmR3ApicHlp_GetR0Helpers,
|
---|
487 | PDM_APICHLPR3_VERSION /* the end */
|
---|
488 | };
|
---|
489 |
|
---|
490 |
|
---|
491 | /**
|
---|
492 | * I/O APIC Device Helpers.
|
---|
493 | */
|
---|
494 | const PDMIOAPICHLPR3 g_pdmR3DevIoApicHlp =
|
---|
495 | {
|
---|
496 | PDM_IOAPICHLPR3_VERSION,
|
---|
497 | pdmR3IoApicHlp_ApicBusDeliver,
|
---|
498 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
499 | pdmR3IoApicHlp_Lock,
|
---|
500 | pdmR3IoApicHlp_Unlock,
|
---|
501 | #endif
|
---|
502 | pdmR3IoApicHlp_GetGCHelpers,
|
---|
503 | pdmR3IoApicHlp_GetR0Helpers,
|
---|
504 | PDM_IOAPICHLPR3_VERSION /* the end */
|
---|
505 | };
|
---|
506 |
|
---|
507 |
|
---|
508 | /**
|
---|
509 | * PCI Bus Device Helpers.
|
---|
510 | */
|
---|
511 | const PDMPCIHLPR3 g_pdmR3DevPciHlp =
|
---|
512 | {
|
---|
513 | PDM_PCIHLPR3_VERSION,
|
---|
514 | pdmR3PciHlp_IsaSetIrq,
|
---|
515 | pdmR3PciHlp_IoApicSetIrq,
|
---|
516 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
517 | pdmR3PciHlp_Lock,
|
---|
518 | pdmR3PciHlp_Unlock,
|
---|
519 | #endif
|
---|
520 | pdmR3PciHlp_GetGCHelpers,
|
---|
521 | pdmR3PciHlp_GetR0Helpers,
|
---|
522 | PDM_PCIHLPR3_VERSION, /* the end */
|
---|
523 | };
|
---|
524 |
|
---|
525 |
|
---|
526 | /**
|
---|
527 | * DMAC Device Helpers.
|
---|
528 | */
|
---|
529 | const PDMDMACHLP g_pdmR3DevDmacHlp =
|
---|
530 | {
|
---|
531 | PDM_DMACHLP_VERSION
|
---|
532 | };
|
---|
533 |
|
---|
534 |
|
---|
535 | /**
|
---|
536 | * RTC Device Helpers.
|
---|
537 | */
|
---|
538 | const PDMRTCHLP g_pdmR3DevRtcHlp =
|
---|
539 | {
|
---|
540 | PDM_RTCHLP_VERSION
|
---|
541 | };
|
---|
542 |
|
---|
543 |
|
---|
544 | /**
|
---|
545 | * This function will initialize the devices for this VM instance.
|
---|
546 | *
|
---|
547 | *
|
---|
548 | * First of all this mean loading the builtin device and letting them
|
---|
549 | * register themselves. Beyond that any additional device modules are
|
---|
550 | * loaded and called for registration.
|
---|
551 | *
|
---|
552 | * Then the device configuration is enumerated, the instantiation order
|
---|
553 | * is determined, and finally they are instantiated.
|
---|
554 | *
|
---|
555 | * After all device have been successfully instantiated the the primary
|
---|
556 | * PCI Bus device is called to emulate the PCI BIOS, i.e. making the
|
---|
557 | * resource assignments. If there is no PCI device, this step is of course
|
---|
558 | * skipped.
|
---|
559 | *
|
---|
560 | * Finally the init completion routines of the instantiated devices
|
---|
561 | * are called.
|
---|
562 | *
|
---|
563 | * @returns VBox status code.
|
---|
564 | * @param pVM VM Handle.
|
---|
565 | */
|
---|
566 | int pdmR3DevInit(PVM pVM)
|
---|
567 | {
|
---|
568 | LogFlow(("pdmR3DevInit:\n"));
|
---|
569 |
|
---|
570 | AssertRelease(!(RT_OFFSETOF(PDMDEVINS, achInstanceData) & 15));
|
---|
571 | AssertRelease(sizeof(pVM->pdm.s.pDevInstances->Internal.s) <= sizeof(pVM->pdm.s.pDevInstances->Internal.padding));
|
---|
572 |
|
---|
573 | /*
|
---|
574 | * Get the GC & R0 devhlps and create the devhlp R3 task queue.
|
---|
575 | */
|
---|
576 | GCPTRTYPE(PCPDMDEVHLPGC) pDevHlpGC;
|
---|
577 | int rc = PDMR3GetSymbolGC(pVM, NULL, "g_pdmGCDevHlp", &pDevHlpGC);
|
---|
578 | AssertReleaseRCReturn(rc, rc);
|
---|
579 |
|
---|
580 | R0PTRTYPE(PCPDMDEVHLPR0) pDevHlpR0;
|
---|
581 | rc = PDMR3GetSymbolR0(pVM, NULL, "g_pdmR0DevHlp", &pDevHlpR0);
|
---|
582 | AssertReleaseRCReturn(rc, rc);
|
---|
583 |
|
---|
584 | rc = PDMR3QueueCreateInternal(pVM, sizeof(PDMDEVHLPTASK), 8, 0, pdmR3DevHlpQueueConsumer, true, &pVM->pdm.s.pDevHlpQueueHC);
|
---|
585 | AssertRCReturn(rc, rc);
|
---|
586 | pVM->pdm.s.pDevHlpQueueGC = PDMQueueGCPtr(pVM->pdm.s.pDevHlpQueueHC);
|
---|
587 |
|
---|
588 |
|
---|
589 | /*
|
---|
590 | * Initialize the callback structure.
|
---|
591 | */
|
---|
592 | PDMDEVREGCBINT RegCB;
|
---|
593 | RegCB.Core.u32Version = PDM_DEVREG_CB_VERSION;
|
---|
594 | RegCB.Core.pfnRegister = pdmR3DevReg_Register;
|
---|
595 | RegCB.Core.pfnMMHeapAlloc = pdmR3DevReg_MMHeapAlloc;
|
---|
596 | RegCB.pVM = pVM;
|
---|
597 |
|
---|
598 | /*
|
---|
599 | * Load the builtin module
|
---|
600 | */
|
---|
601 | PCFGMNODE pDevicesNode = CFGMR3GetChild(CFGMR3GetRoot(pVM), "PDM/Devices");
|
---|
602 | bool fLoadBuiltin;
|
---|
603 | rc = CFGMR3QueryBool(pDevicesNode, "LoadBuiltin", &fLoadBuiltin);
|
---|
604 | if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT)
|
---|
605 | fLoadBuiltin = true;
|
---|
606 | else if (VBOX_FAILURE(rc))
|
---|
607 | {
|
---|
608 | AssertMsgFailed(("Configuration error: Querying boolean \"LoadBuiltin\" failed with %Vrc\n", rc));
|
---|
609 | return rc;
|
---|
610 | }
|
---|
611 | if (fLoadBuiltin)
|
---|
612 | {
|
---|
613 | /* make filename */
|
---|
614 | char *pszFilename = pdmR3FileR3("VBoxDD", /*fShared=*/true);
|
---|
615 | if (!pszFilename)
|
---|
616 | return VERR_NO_TMP_MEMORY;
|
---|
617 | rc = pdmR3DevLoad(pVM, &RegCB, pszFilename, "VBoxDD");
|
---|
618 | RTMemTmpFree(pszFilename);
|
---|
619 | if (VBOX_FAILURE(rc))
|
---|
620 | return rc;
|
---|
621 |
|
---|
622 | /* make filename */
|
---|
623 | pszFilename = pdmR3FileR3("VBoxDD2", /*fShared=*/true);
|
---|
624 | if (!pszFilename)
|
---|
625 | return VERR_NO_TMP_MEMORY;
|
---|
626 | rc = pdmR3DevLoad(pVM, &RegCB, pszFilename, "VBoxDD2");
|
---|
627 | RTMemTmpFree(pszFilename);
|
---|
628 | if (VBOX_FAILURE(rc))
|
---|
629 | return rc;
|
---|
630 | }
|
---|
631 |
|
---|
632 | /*
|
---|
633 | * Load additional device modules.
|
---|
634 | */
|
---|
635 | PCFGMNODE pCur;
|
---|
636 | for (pCur = CFGMR3GetFirstChild(pDevicesNode); pCur; pCur = CFGMR3GetNextChild(pCur))
|
---|
637 | {
|
---|
638 | /*
|
---|
639 | * Get the name and path.
|
---|
640 | */
|
---|
641 | char szName[PDMMOD_NAME_LEN];
|
---|
642 | rc = CFGMR3GetName(pCur, &szName[0], sizeof(szName));
|
---|
643 | if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
|
---|
644 | {
|
---|
645 | AssertMsgFailed(("configuration error: The module name is too long, cchName=%d.\n", CFGMR3GetNameLen(pCur)));
|
---|
646 | return VERR_PDM_MODULE_NAME_TOO_LONG;
|
---|
647 | }
|
---|
648 | else if (VBOX_FAILURE(rc))
|
---|
649 | {
|
---|
650 | AssertMsgFailed(("CFGMR3GetName -> %Vrc.\n", rc));
|
---|
651 | return rc;
|
---|
652 | }
|
---|
653 |
|
---|
654 | /* the path is optional, if no path the module name + path is used. */
|
---|
655 | char szFilename[RTPATH_MAX];
|
---|
656 | rc = CFGMR3QueryString(pCur, "Path", &szFilename[0], sizeof(szFilename));
|
---|
657 | if (rc == VERR_CFGM_VALUE_NOT_FOUND)
|
---|
658 | strcpy(szFilename, szName);
|
---|
659 | else if (VBOX_FAILURE(rc))
|
---|
660 | {
|
---|
661 | AssertMsgFailed(("configuration error: Failure to query the module path, rc=%Vrc.\n", rc));
|
---|
662 | return rc;
|
---|
663 | }
|
---|
664 |
|
---|
665 | /* prepend path? */
|
---|
666 | if (!RTPathHavePath(szFilename))
|
---|
667 | {
|
---|
668 | char *psz = pdmR3FileR3(szFilename);
|
---|
669 | if (!psz)
|
---|
670 | return VERR_NO_TMP_MEMORY;
|
---|
671 | size_t cch = strlen(psz) + 1;
|
---|
672 | if (cch > sizeof(szFilename))
|
---|
673 | {
|
---|
674 | RTMemTmpFree(psz);
|
---|
675 | AssertMsgFailed(("Filename too long! cch=%d '%s'\n", cch, psz));
|
---|
676 | return VERR_FILENAME_TOO_LONG;
|
---|
677 | }
|
---|
678 | memcpy(szFilename, psz, cch);
|
---|
679 | RTMemTmpFree(psz);
|
---|
680 | }
|
---|
681 |
|
---|
682 | /*
|
---|
683 | * Load the module and register it's devices.
|
---|
684 | */
|
---|
685 | rc = pdmR3DevLoad(pVM, &RegCB, szFilename, szName);
|
---|
686 | if (VBOX_FAILURE(rc))
|
---|
687 | return rc;
|
---|
688 | }
|
---|
689 |
|
---|
690 |
|
---|
691 | /*
|
---|
692 | *
|
---|
693 | * Enumerate the device instance configurations
|
---|
694 | * and come up with a instantiation order.
|
---|
695 | *
|
---|
696 | */
|
---|
697 | /* Switch to /Devices, which contains the device instantiations. */
|
---|
698 | pDevicesNode = CFGMR3GetChild(CFGMR3GetRoot(pVM), "Devices");
|
---|
699 |
|
---|
700 | /*
|
---|
701 | * Count the device instances.
|
---|
702 | */
|
---|
703 | PCFGMNODE pInstanceNode;
|
---|
704 | unsigned cDevs = 0;
|
---|
705 | for (pCur = CFGMR3GetFirstChild(pDevicesNode); pCur; pCur = CFGMR3GetNextChild(pCur))
|
---|
706 | for (pInstanceNode = CFGMR3GetFirstChild(pCur); pInstanceNode; pInstanceNode = CFGMR3GetNextChild(pInstanceNode))
|
---|
707 | cDevs++;
|
---|
708 | if (!cDevs)
|
---|
709 | {
|
---|
710 | Log(("PDM: No devices were configured!\n"));
|
---|
711 | return VINF_SUCCESS;
|
---|
712 | }
|
---|
713 | Log2(("PDM: cDevs=%d!\n", cDevs));
|
---|
714 |
|
---|
715 | /*
|
---|
716 | * Collect info on each device instance.
|
---|
717 | */
|
---|
718 | struct DEVORDER
|
---|
719 | {
|
---|
720 | /** Configuration node. */
|
---|
721 | PCFGMNODE pNode;
|
---|
722 | /** Pointer to device. */
|
---|
723 | PPDMDEV pDev;
|
---|
724 | /** Init order. */
|
---|
725 | uint32_t u32Order;
|
---|
726 | /** VBox instance number. */
|
---|
727 | uint32_t iInstance;
|
---|
728 | } *paDevs = (struct DEVORDER *)alloca(sizeof(paDevs[0]) * (cDevs + 1)); /* (One extra for swapping) */
|
---|
729 | Assert(paDevs);
|
---|
730 | unsigned i = 0;
|
---|
731 | for (pCur = CFGMR3GetFirstChild(pDevicesNode); pCur; pCur = CFGMR3GetNextChild(pCur))
|
---|
732 | {
|
---|
733 | /* Get the device name. */
|
---|
734 | char szName[sizeof(paDevs[0].pDev->pDevReg->szDeviceName)];
|
---|
735 | rc = CFGMR3GetName(pCur, szName, sizeof(szName));
|
---|
736 | AssertMsgRCReturn(rc, ("Configuration error: device name is too long (or something)! rc=%Vrc\n", rc), rc);
|
---|
737 |
|
---|
738 | /* Find the device. */
|
---|
739 | PPDMDEV pDev = pdmR3DevLookup(pVM, szName);
|
---|
740 | AssertMsgReturn(pDev, ("Configuration error: device '%s' not found!\n", szName), VERR_PDM_DEVICE_NOT_FOUND);
|
---|
741 |
|
---|
742 | /* Configured priority or use default based on device class? */
|
---|
743 | uint32_t u32Order;
|
---|
744 | rc = CFGMR3QueryU32(pCur, "Priority", &u32Order);
|
---|
745 | if (rc == VERR_CFGM_VALUE_NOT_FOUND)
|
---|
746 | {
|
---|
747 | uint32_t u32 = pDev->pDevReg->fClass;
|
---|
748 | for (u32Order = 1; !(u32 & u32Order); u32Order <<= 1)
|
---|
749 | /* nop */;
|
---|
750 | }
|
---|
751 | else
|
---|
752 | AssertMsgRCReturn(rc, ("Configuration error: reading \"Priority\" for the '%s' device failed rc=%Vrc!\n", szName, rc), rc);
|
---|
753 |
|
---|
754 | /* Enumerate the device instances. */
|
---|
755 | for (pInstanceNode = CFGMR3GetFirstChild(pCur); pInstanceNode; pInstanceNode = CFGMR3GetNextChild(pInstanceNode))
|
---|
756 | {
|
---|
757 | paDevs[i].pNode = pInstanceNode;
|
---|
758 | paDevs[i].pDev = pDev;
|
---|
759 | paDevs[i].u32Order = u32Order;
|
---|
760 |
|
---|
761 | /* Get the instance number. */
|
---|
762 | char szInstance[32];
|
---|
763 | rc = CFGMR3GetName(pInstanceNode, szInstance, sizeof(szInstance));
|
---|
764 | AssertMsgRCReturn(rc, ("Configuration error: instance name is too long (or something)! rc=%Vrc\n", rc), rc);
|
---|
765 | char *pszNext = NULL;
|
---|
766 | rc = RTStrToUInt32Ex(szInstance, &pszNext, 0, &paDevs[i].iInstance);
|
---|
767 | AssertMsgRCReturn(rc, ("Configuration error: RTStrToInt32Ex failed on the instance name '%s'! rc=%Vrc\n", szInstance, rc), rc);
|
---|
768 | AssertMsgReturn(!*pszNext, ("Configuration error: the instance name '%s' isn't all digits. (%s)\n", szInstance, pszNext), VERR_INVALID_PARAMETER);
|
---|
769 |
|
---|
770 | /* next instance */
|
---|
771 | i++;
|
---|
772 | }
|
---|
773 | } /* devices */
|
---|
774 | Assert(i == cDevs);
|
---|
775 |
|
---|
776 | /*
|
---|
777 | * Sort the device array ascending on u32Order. (bubble)
|
---|
778 | */
|
---|
779 | unsigned c = cDevs - 1;
|
---|
780 | while (c)
|
---|
781 | {
|
---|
782 | unsigned j = 0;
|
---|
783 | for (i = 0; i < c; i++)
|
---|
784 | if (paDevs[i].u32Order > paDevs[i + 1].u32Order)
|
---|
785 | {
|
---|
786 | paDevs[cDevs] = paDevs[i + 1];
|
---|
787 | paDevs[i + 1] = paDevs[i];
|
---|
788 | paDevs[i] = paDevs[cDevs];
|
---|
789 | j = i;
|
---|
790 | }
|
---|
791 | c = j;
|
---|
792 | }
|
---|
793 |
|
---|
794 |
|
---|
795 | /*
|
---|
796 | *
|
---|
797 | * Instantiate the devices.
|
---|
798 | *
|
---|
799 | */
|
---|
800 | for (i = 0; i < cDevs; i++)
|
---|
801 | {
|
---|
802 | /*
|
---|
803 | * Gather a bit of config.
|
---|
804 | */
|
---|
805 | /* trusted */
|
---|
806 | bool fTrusted;
|
---|
807 | rc = CFGMR3QueryBool(paDevs[i].pNode, "Trusted", &fTrusted);
|
---|
808 | if (rc == VERR_CFGM_VALUE_NOT_FOUND)
|
---|
809 | fTrusted = false;
|
---|
810 | else if (VBOX_FAILURE(rc))
|
---|
811 | {
|
---|
812 | AssertMsgFailed(("configuration error: failed to query boolean \"Trusted\", rc=%Vrc\n", rc));
|
---|
813 | return rc;
|
---|
814 | }
|
---|
815 | /* config node */
|
---|
816 | PCFGMNODE pConfigNode = CFGMR3GetChild(paDevs[i].pNode, "Config");
|
---|
817 | if (!pConfigNode)
|
---|
818 | {
|
---|
819 | rc = CFGMR3InsertNode(paDevs[i].pNode, "Config", &pConfigNode);
|
---|
820 | if (VBOX_FAILURE(rc))
|
---|
821 | {
|
---|
822 | AssertMsgFailed(("Failed to create Config node! rc=%Vrc\n", rc));
|
---|
823 | return rc;
|
---|
824 | }
|
---|
825 | }
|
---|
826 | CFGMR3SetRestrictedRoot(pConfigNode);
|
---|
827 |
|
---|
828 | /*
|
---|
829 | * Allocate the device instance.
|
---|
830 | */
|
---|
831 | size_t cb = RT_OFFSETOF(PDMDEVINS, achInstanceData[paDevs[i].pDev->pDevReg->cbInstance]);
|
---|
832 | cb = RT_ALIGN_Z(cb, 16);
|
---|
833 | PPDMDEVINS pDevIns;
|
---|
834 | if (paDevs[i].pDev->pDevReg->fFlags & (PDM_DEVREG_FLAGS_GC | PDM_DEVREG_FLAGS_R0))
|
---|
835 | rc = MMR3HyperAllocOnceNoRel(pVM, cb, 0, MM_TAG_PDM_DEVICE, (void **)&pDevIns);
|
---|
836 | else
|
---|
837 | rc = MMR3HeapAllocZEx(pVM, MM_TAG_PDM_DEVICE, cb, (void **)&pDevIns);
|
---|
838 | if (VBOX_FAILURE(rc))
|
---|
839 | {
|
---|
840 | AssertMsgFailed(("Failed to allocate %d bytes of instance data for device '%s'. rc=%Vrc\n",
|
---|
841 | cb, paDevs[i].pDev->pDevReg->szDeviceName, rc));
|
---|
842 | return rc;
|
---|
843 | }
|
---|
844 |
|
---|
845 | /*
|
---|
846 | * Initialize it.
|
---|
847 | */
|
---|
848 | pDevIns->u32Version = PDM_DEVINS_VERSION;
|
---|
849 | //pDevIns->Internal.s.pNextHC = NULL;
|
---|
850 | //pDevIns->Internal.s.pPerDeviceNextHC = NULL;
|
---|
851 | pDevIns->Internal.s.pDevHC = paDevs[i].pDev;
|
---|
852 | pDevIns->Internal.s.pVMHC = pVM;
|
---|
853 | pDevIns->Internal.s.pVMGC = pVM->pVMGC;
|
---|
854 | //pDevIns->Internal.s.pLunsHC = NULL;
|
---|
855 | pDevIns->Internal.s.pCfgHandle = paDevs[i].pNode;
|
---|
856 | //pDevIns->Internal.s.pPciDevice = NULL;
|
---|
857 | //pDevIns->Internal.s.pPciBus = NULL; /** @todo pci bus selection. (in 2008 perhaps) */
|
---|
858 | pDevIns->pDevHlp = fTrusted ? &g_pdmR3DevHlpTrusted : &g_pdmR3DevHlpUnTrusted;
|
---|
859 | pDevIns->pDevHlpGC = pDevHlpGC;
|
---|
860 | pDevIns->pDevHlpR0 = pDevHlpR0;
|
---|
861 | pDevIns->pDevReg = paDevs[i].pDev->pDevReg;
|
---|
862 | pDevIns->pCfgHandle = pConfigNode;
|
---|
863 | pDevIns->iInstance = paDevs[i].iInstance;
|
---|
864 | pDevIns->pvInstanceDataR3 = &pDevIns->achInstanceData[0];
|
---|
865 | pDevIns->pvInstanceDataGC = pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_GC
|
---|
866 | ? MMHyperHC2GC(pVM, pDevIns->pvInstanceDataR3) : 0;
|
---|
867 | pDevIns->pvInstanceDataR0 = pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_R0
|
---|
868 | ? MMHyperR3ToR0(pVM, pDevIns->pvInstanceDataR3) : 0;
|
---|
869 |
|
---|
870 | /*
|
---|
871 | * Link it into all the lists.
|
---|
872 | */
|
---|
873 | /* The global instance FIFO. */
|
---|
874 | PPDMDEVINS pPrev1 = pVM->pdm.s.pDevInstances;
|
---|
875 | if (!pPrev1)
|
---|
876 | pVM->pdm.s.pDevInstances = pDevIns;
|
---|
877 | else
|
---|
878 | {
|
---|
879 | while (pPrev1->Internal.s.pNextHC)
|
---|
880 | pPrev1 = pPrev1->Internal.s.pNextHC;
|
---|
881 | pPrev1->Internal.s.pNextHC = pDevIns;
|
---|
882 | }
|
---|
883 |
|
---|
884 | /* The per device instance FIFO. */
|
---|
885 | PPDMDEVINS pPrev2 = paDevs[i].pDev->pInstances;
|
---|
886 | if (!pPrev2)
|
---|
887 | paDevs[i].pDev->pInstances = pDevIns;
|
---|
888 | else
|
---|
889 | {
|
---|
890 | while (pPrev2->Internal.s.pPerDeviceNextHC)
|
---|
891 | pPrev2 = pPrev2->Internal.s.pPerDeviceNextHC;
|
---|
892 | pPrev2->Internal.s.pPerDeviceNextHC = pDevIns;
|
---|
893 | }
|
---|
894 |
|
---|
895 | /*
|
---|
896 | * Call the constructor.
|
---|
897 | */
|
---|
898 | Log(("PDM: Constructing device '%s' instance %d...\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
899 | rc = pDevIns->pDevReg->pfnConstruct(pDevIns, pDevIns->iInstance, pDevIns->pCfgHandle);
|
---|
900 | if (VBOX_FAILURE(rc))
|
---|
901 | {
|
---|
902 | AssertMsgFailed(("Failed to construct '%s'/%d! %Vra\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
903 | /* because we're damn lazy right now, we'll say that the destructor will be called even if the constructor fails. */
|
---|
904 | return rc;
|
---|
905 | }
|
---|
906 | } /* for device instances */
|
---|
907 |
|
---|
908 |
|
---|
909 | /*
|
---|
910 | *
|
---|
911 | * PCI BIOS Fake and Init Complete.
|
---|
912 | *
|
---|
913 | */
|
---|
914 | if (pVM->pdm.s.aPciBuses[0].pDevInsR3)
|
---|
915 | {
|
---|
916 | pdmLock(pVM);
|
---|
917 | rc = pVM->pdm.s.aPciBuses[0].pfnFakePCIBIOSR3(pVM->pdm.s.aPciBuses[0].pDevInsR3);
|
---|
918 | pdmUnlock(pVM);
|
---|
919 | if (VBOX_FAILURE(rc))
|
---|
920 | {
|
---|
921 | AssertMsgFailed(("PCI BIOS fake failed rc=%Vrc\n", rc));
|
---|
922 | return rc;
|
---|
923 | }
|
---|
924 | }
|
---|
925 |
|
---|
926 | for (PPDMDEVINS pDevIns = pVM->pdm.s.pDevInstances; pDevIns; pDevIns = pDevIns->Internal.s.pNextHC)
|
---|
927 | {
|
---|
928 | if (pDevIns->pDevReg->pfnInitComplete)
|
---|
929 | {
|
---|
930 | rc = pDevIns->pDevReg->pfnInitComplete(pDevIns);
|
---|
931 | if (VBOX_FAILURE(rc))
|
---|
932 | {
|
---|
933 | AssertMsgFailed(("InitComplete on device '%s'/%d failed with rc=%Vrc\n",
|
---|
934 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
935 | return rc;
|
---|
936 | }
|
---|
937 | }
|
---|
938 | }
|
---|
939 |
|
---|
940 | LogFlow(("pdmR3DevInit: returns %Vrc\n", VINF_SUCCESS));
|
---|
941 | return VINF_SUCCESS;
|
---|
942 | }
|
---|
943 |
|
---|
944 |
|
---|
945 | /**
|
---|
946 | * Lookups a device structure by name.
|
---|
947 | * @internal
|
---|
948 | */
|
---|
949 | PPDMDEV pdmR3DevLookup(PVM pVM, const char *pszName)
|
---|
950 | {
|
---|
951 | RTUINT cchName = strlen(pszName);
|
---|
952 | for (PPDMDEV pDev = pVM->pdm.s.pDevs; pDev; pDev = pDev->pNext)
|
---|
953 | if ( pDev->cchName == cchName
|
---|
954 | && !strcmp(pDev->pDevReg->szDeviceName, pszName))
|
---|
955 | return pDev;
|
---|
956 | return NULL;
|
---|
957 | }
|
---|
958 |
|
---|
959 |
|
---|
960 | /**
|
---|
961 | * Loads one device module and call the registration entry point.
|
---|
962 | *
|
---|
963 | * @returns VBox status code.
|
---|
964 | * @param pVM VM handle.
|
---|
965 | * @param pRegCB The registration callback stuff.
|
---|
966 | * @param pszFilename Module filename.
|
---|
967 | * @param pszName Module name.
|
---|
968 | */
|
---|
969 | static int pdmR3DevLoad(PVM pVM, PPDMDEVREGCBINT pRegCB, const char *pszFilename, const char *pszName)
|
---|
970 | {
|
---|
971 | /*
|
---|
972 | * Load it.
|
---|
973 | */
|
---|
974 | int rc = pdmR3LoadR3(pVM, pszFilename, pszName);
|
---|
975 | if (VBOX_SUCCESS(rc))
|
---|
976 | {
|
---|
977 | /*
|
---|
978 | * Get the registration export and call it.
|
---|
979 | */
|
---|
980 | FNPDMVBOXDEVICESREGISTER *pfnVBoxDevicesRegister;
|
---|
981 | rc = PDMR3GetSymbolR3(pVM, pszName, "VBoxDevicesRegister", (void **)&pfnVBoxDevicesRegister);
|
---|
982 | if (VBOX_SUCCESS(rc))
|
---|
983 | {
|
---|
984 | Log(("PDM: Calling VBoxDevicesRegister (%p) of %s (%s)\n", pfnVBoxDevicesRegister, pszName, pszFilename));
|
---|
985 | rc = pfnVBoxDevicesRegister(&pRegCB->Core, VBOX_VERSION);
|
---|
986 | if (VBOX_SUCCESS(rc))
|
---|
987 | Log(("PDM: Successfully loaded device module %s (%s).\n", pszName, pszFilename));
|
---|
988 | else
|
---|
989 | AssertMsgFailed(("VBoxDevicesRegister failed with rc=%Vrc for module %s (%s)\n", rc, pszName, pszFilename));
|
---|
990 | }
|
---|
991 | else
|
---|
992 | {
|
---|
993 | AssertMsgFailed(("Failed to locate 'VBoxDevicesRegister' in %s (%s) rc=%Vrc\n", pszName, pszFilename, rc));
|
---|
994 | if (rc == VERR_SYMBOL_NOT_FOUND)
|
---|
995 | rc = VERR_PDM_NO_REGISTRATION_EXPORT;
|
---|
996 | }
|
---|
997 | }
|
---|
998 | else
|
---|
999 | AssertMsgFailed(("Failed to load VBoxDD!\n"));
|
---|
1000 | return rc;
|
---|
1001 | }
|
---|
1002 |
|
---|
1003 |
|
---|
1004 |
|
---|
1005 | /**
|
---|
1006 | * Registers a device with the current VM instance.
|
---|
1007 | *
|
---|
1008 | * @returns VBox status code.
|
---|
1009 | * @param pCallbacks Pointer to the callback table.
|
---|
1010 | * @param pDevReg Pointer to the device registration record.
|
---|
1011 | * This data must be permanent and readonly.
|
---|
1012 | */
|
---|
1013 | static DECLCALLBACK(int) pdmR3DevReg_Register(PPDMDEVREGCB pCallbacks, PCPDMDEVREG pDevReg)
|
---|
1014 | {
|
---|
1015 | /*
|
---|
1016 | * Validate the registration structure.
|
---|
1017 | */
|
---|
1018 | Assert(pDevReg);
|
---|
1019 | if (pDevReg->u32Version != PDM_DEVREG_VERSION)
|
---|
1020 | {
|
---|
1021 | AssertMsgFailed(("Unknown struct version %#x!\n", pDevReg->u32Version));
|
---|
1022 | return VERR_PDM_UNKNOWN_DEVREG_VERSION;
|
---|
1023 | }
|
---|
1024 | if ( !pDevReg->szDeviceName[0]
|
---|
1025 | || strlen(pDevReg->szDeviceName) >= sizeof(pDevReg->szDeviceName))
|
---|
1026 | {
|
---|
1027 | AssertMsgFailed(("Invalid name '%s'\n", pDevReg->szDeviceName));
|
---|
1028 | return VERR_PDM_INVALID_DEVICE_REGISTRATION;
|
---|
1029 | }
|
---|
1030 | if ( (pDevReg->fFlags & PDM_DEVREG_FLAGS_GC)
|
---|
1031 | && ( !pDevReg->szGCMod[0]
|
---|
1032 | || strlen(pDevReg->szGCMod) >= sizeof(pDevReg->szGCMod)))
|
---|
1033 | {
|
---|
1034 | AssertMsgFailed(("Invalid GC module name '%s' - (Device %s)\n", pDevReg->szGCMod, pDevReg->szDeviceName));
|
---|
1035 | return VERR_PDM_INVALID_DEVICE_REGISTRATION;
|
---|
1036 | }
|
---|
1037 | if ( (pDevReg->fFlags & PDM_DEVREG_FLAGS_R0)
|
---|
1038 | && ( !pDevReg->szR0Mod[0]
|
---|
1039 | || strlen(pDevReg->szR0Mod) >= sizeof(pDevReg->szR0Mod)))
|
---|
1040 | {
|
---|
1041 | AssertMsgFailed(("Invalid R0 module name '%s' - (Device %s)\n", pDevReg->szR0Mod, pDevReg->szDeviceName));
|
---|
1042 | return VERR_PDM_INVALID_DEVICE_REGISTRATION;
|
---|
1043 | }
|
---|
1044 | if ((pDevReg->fFlags & PDM_DEVREG_FLAGS_HOST_BITS_MASK) != PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT)
|
---|
1045 | {
|
---|
1046 | AssertMsgFailed(("Invalid host bits flags! fFlags=%#x (Device %s)\n", pDevReg->fFlags, pDevReg->szDeviceName));
|
---|
1047 | return VERR_PDM_INVALID_DEVICE_HOST_BITS;
|
---|
1048 | }
|
---|
1049 | if (!(pDevReg->fFlags & PDM_DEVREG_FLAGS_GUEST_BITS_MASK))
|
---|
1050 | {
|
---|
1051 | AssertMsgFailed(("Invalid guest bits flags! fFlags=%#x (Device %s)\n", pDevReg->fFlags, pDevReg->szDeviceName));
|
---|
1052 | return VERR_PDM_INVALID_DEVICE_REGISTRATION;
|
---|
1053 | }
|
---|
1054 | if (!pDevReg->fClass)
|
---|
1055 | {
|
---|
1056 | AssertMsgFailed(("No class! (Device %s)\n", pDevReg->szDeviceName));
|
---|
1057 | return VERR_PDM_INVALID_DEVICE_REGISTRATION;
|
---|
1058 | }
|
---|
1059 | if (pDevReg->cMaxInstances <= 0)
|
---|
1060 | {
|
---|
1061 | AssertMsgFailed(("Max instances %u! (Device %s)\n", pDevReg->cMaxInstances, pDevReg->szDeviceName));
|
---|
1062 | return VERR_PDM_INVALID_DEVICE_REGISTRATION;
|
---|
1063 | }
|
---|
1064 | if (pDevReg->cbInstance > (RTUINT)(pDevReg->fFlags & (PDM_DEVREG_FLAGS_GC | PDM_DEVREG_FLAGS_R0) ? 96 * _1K : _1M))
|
---|
1065 | {
|
---|
1066 | AssertMsgFailed(("Instance size %d bytes! (Device %s)\n", pDevReg->cbInstance, pDevReg->szDeviceName));
|
---|
1067 | return VERR_PDM_INVALID_DEVICE_REGISTRATION;
|
---|
1068 | }
|
---|
1069 | if (!pDevReg->pfnConstruct)
|
---|
1070 | {
|
---|
1071 | AssertMsgFailed(("No constructore! (Device %s)\n", pDevReg->szDeviceName));
|
---|
1072 | return VERR_PDM_INVALID_DEVICE_REGISTRATION;
|
---|
1073 | }
|
---|
1074 | /* Check matching guest bits last without any asserting. Enables trial and error registration. */
|
---|
1075 | if (!(pDevReg->fFlags & PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT))
|
---|
1076 | {
|
---|
1077 | Log(("PDM: Rejected device '%s' because it didn't match the guest bits.\n", pDevReg->szDeviceName));
|
---|
1078 | return VERR_PDM_INVALID_DEVICE_GUEST_BITS;
|
---|
1079 | }
|
---|
1080 |
|
---|
1081 | /*
|
---|
1082 | * Check for duplicate and find FIFO entry at the same time.
|
---|
1083 | */
|
---|
1084 | PCPDMDEVREGCBINT pRegCB = (PCPDMDEVREGCBINT)pCallbacks;
|
---|
1085 | PPDMDEV pDevPrev = NULL;
|
---|
1086 | PPDMDEV pDev = pRegCB->pVM->pdm.s.pDevs;
|
---|
1087 | for (; pDev; pDevPrev = pDev, pDev = pDev->pNext)
|
---|
1088 | {
|
---|
1089 | if (!strcmp(pDev->pDevReg->szDeviceName, pDevReg->szDeviceName))
|
---|
1090 | {
|
---|
1091 | AssertMsgFailed(("Device '%s' already exists\n", pDevReg->szDeviceName));
|
---|
1092 | return VERR_PDM_DEVICE_NAME_CLASH;
|
---|
1093 | }
|
---|
1094 | }
|
---|
1095 |
|
---|
1096 | /*
|
---|
1097 | * Allocate new device structure and insert it into the list.
|
---|
1098 | */
|
---|
1099 | pDev = (PPDMDEV)MMR3HeapAlloc(pRegCB->pVM, MM_TAG_PDM_DEVICE, sizeof(*pDev));
|
---|
1100 | if (pDev)
|
---|
1101 | {
|
---|
1102 | pDev->pNext = NULL;
|
---|
1103 | pDev->cInstances = 0;
|
---|
1104 | pDev->pInstances = NULL;
|
---|
1105 | pDev->pDevReg = pDevReg;
|
---|
1106 | pDev->cchName = strlen(pDevReg->szDeviceName);
|
---|
1107 |
|
---|
1108 | if (pDevPrev)
|
---|
1109 | pDevPrev->pNext = pDev;
|
---|
1110 | else
|
---|
1111 | pRegCB->pVM->pdm.s.pDevs = pDev;
|
---|
1112 | Log(("PDM: Registered device '%s'\n", pDevReg->szDeviceName));
|
---|
1113 | return VINF_SUCCESS;
|
---|
1114 | }
|
---|
1115 | return VERR_NO_MEMORY;
|
---|
1116 | }
|
---|
1117 |
|
---|
1118 |
|
---|
1119 | /**
|
---|
1120 | * Allocate memory which is associated with current VM instance
|
---|
1121 | * and automatically freed on it's destruction.
|
---|
1122 | *
|
---|
1123 | * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
|
---|
1124 | * @param pCallbacks Pointer to the callback table.
|
---|
1125 | * @param cb Number of bytes to allocate.
|
---|
1126 | */
|
---|
1127 | static DECLCALLBACK(void *) pdmR3DevReg_MMHeapAlloc(PPDMDEVREGCB pCallbacks, size_t cb)
|
---|
1128 | {
|
---|
1129 | Assert(pCallbacks);
|
---|
1130 | Assert(pCallbacks->u32Version == PDM_DEVREG_CB_VERSION);
|
---|
1131 | LogFlow(("pdmR3DevReg_MMHeapAlloc: cb=%#x\n", cb));
|
---|
1132 |
|
---|
1133 | void *pv = MMR3HeapAlloc(((PPDMDEVREGCBINT)pCallbacks)->pVM, MM_TAG_PDM_DEVICE_USER, cb);
|
---|
1134 |
|
---|
1135 | LogFlow(("pdmR3DevReg_MMHeapAlloc: returns %p\n", pv));
|
---|
1136 | return pv;
|
---|
1137 | }
|
---|
1138 |
|
---|
1139 |
|
---|
1140 | /**
|
---|
1141 | * Queue consumer callback for internal component.
|
---|
1142 | *
|
---|
1143 | * @returns Success indicator.
|
---|
1144 | * If false the item will not be removed and the flushing will stop.
|
---|
1145 | * @param pVM The VM handle.
|
---|
1146 | * @param pItem The item to consume. Upon return this item will be freed.
|
---|
1147 | */
|
---|
1148 | static DECLCALLBACK(bool) pdmR3DevHlpQueueConsumer(PVM pVM, PPDMQUEUEITEMCORE pItem)
|
---|
1149 | {
|
---|
1150 | PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)pItem;
|
---|
1151 | LogFlow(("pdmR3DevHlpQueueConsumer: enmOp=%d pDevIns=%p\n", pTask->enmOp, pTask->pDevInsHC));
|
---|
1152 | switch (pTask->enmOp)
|
---|
1153 | {
|
---|
1154 | case PDMDEVHLPTASKOP_ISA_SET_IRQ:
|
---|
1155 | PDMIsaSetIrq(pVM, pTask->u.SetIRQ.iIrq, pTask->u.SetIRQ.iLevel);
|
---|
1156 | break;
|
---|
1157 |
|
---|
1158 | case PDMDEVHLPTASKOP_PCI_SET_IRQ:
|
---|
1159 | pdmR3DevHlp_PCISetIrq(pTask->pDevInsHC, pTask->u.SetIRQ.iIrq, pTask->u.SetIRQ.iLevel);
|
---|
1160 | break;
|
---|
1161 |
|
---|
1162 | case PDMDEVHLPTASKOP_IOAPIC_SET_IRQ:
|
---|
1163 | PDMIoApicSetIrq(pVM, pTask->u.SetIRQ.iIrq, pTask->u.SetIRQ.iLevel);
|
---|
1164 | break;
|
---|
1165 |
|
---|
1166 | default:
|
---|
1167 | AssertReleaseMsgFailed(("Invalid operation %d\n", pTask->enmOp));
|
---|
1168 | break;
|
---|
1169 | }
|
---|
1170 | return true;
|
---|
1171 | }
|
---|
1172 |
|
---|
1173 |
|
---|
1174 | /** @copydoc PDMDEVHLP::pfnIOPortRegister */
|
---|
1175 | static DECLCALLBACK(int) pdmR3DevHlp_IOPortRegister(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTHCPTR pvUser, PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
|
---|
1176 | PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc)
|
---|
1177 | {
|
---|
1178 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1179 | 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,
|
---|
1180 | Port, cPorts, pvUser, pfnOut, pfnIn, pfnOutStr, pfnInStr, pszDesc, pszDesc));
|
---|
1181 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
1182 |
|
---|
1183 | int rc = IOMR3IOPortRegisterR3(pDevIns->Internal.s.pVMHC, pDevIns, Port, cPorts, pvUser, pfnOut, pfnIn, pfnOutStr, pfnInStr, pszDesc);
|
---|
1184 |
|
---|
1185 | LogFlow(("pdmR3DevHlp_IOPortRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1186 | return rc;
|
---|
1187 | }
|
---|
1188 |
|
---|
1189 |
|
---|
1190 | /** @copydoc PDMDEVHLP::pfnIOPortRegisterGC */
|
---|
1191 | static DECLCALLBACK(int) pdmR3DevHlp_IOPortRegisterGC(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTGCPTR pvUser,
|
---|
1192 | const char *pszOut, const char *pszIn,
|
---|
1193 | const char *pszOutStr, const char *pszInStr, const char *pszDesc)
|
---|
1194 | {
|
---|
1195 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1196 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
1197 | 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,
|
---|
1198 | Port, cPorts, pvUser, pszOut, pszOut, pszIn, pszIn, pszOutStr, pszOutStr, pszInStr, pszInStr, pszDesc, pszDesc));
|
---|
1199 |
|
---|
1200 | /*
|
---|
1201 | * Resolve the functions (one of the can be NULL).
|
---|
1202 | */
|
---|
1203 | int rc = VINF_SUCCESS;
|
---|
1204 | if ( pDevIns->pDevReg->szGCMod[0]
|
---|
1205 | && (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_GC))
|
---|
1206 | {
|
---|
1207 | RTGCPTR GCPtrIn = 0;
|
---|
1208 | if (pszIn)
|
---|
1209 | {
|
---|
1210 | rc = PDMR3GetSymbolGCLazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szGCMod, pszIn, &GCPtrIn);
|
---|
1211 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszIn)\n", pDevIns->pDevReg->szGCMod, pszIn));
|
---|
1212 | }
|
---|
1213 | RTGCPTR GCPtrOut = 0;
|
---|
1214 | if (pszOut && VBOX_SUCCESS(rc))
|
---|
1215 | {
|
---|
1216 | rc = PDMR3GetSymbolGCLazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szGCMod, pszOut, &GCPtrOut);
|
---|
1217 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszOut)\n", pDevIns->pDevReg->szGCMod, pszOut));
|
---|
1218 | }
|
---|
1219 | RTGCPTR GCPtrInStr = 0;
|
---|
1220 | if (pszInStr && VBOX_SUCCESS(rc))
|
---|
1221 | {
|
---|
1222 | rc = PDMR3GetSymbolGCLazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szGCMod, pszInStr, &GCPtrInStr);
|
---|
1223 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszInStr)\n", pDevIns->pDevReg->szGCMod, pszInStr));
|
---|
1224 | }
|
---|
1225 | RTGCPTR GCPtrOutStr = 0;
|
---|
1226 | if (pszOutStr && VBOX_SUCCESS(rc))
|
---|
1227 | {
|
---|
1228 | rc = PDMR3GetSymbolGCLazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szGCMod, pszOutStr, &GCPtrOutStr);
|
---|
1229 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszOutStr)\n", pDevIns->pDevReg->szGCMod, pszOutStr));
|
---|
1230 | }
|
---|
1231 |
|
---|
1232 | if (VBOX_SUCCESS(rc))
|
---|
1233 | rc = IOMIOPortRegisterGC(pDevIns->Internal.s.pVMHC, pDevIns, Port, cPorts, pvUser, GCPtrOut, GCPtrIn, GCPtrOutStr, GCPtrInStr, pszDesc);
|
---|
1234 | }
|
---|
1235 | else
|
---|
1236 | {
|
---|
1237 | AssertMsgFailed(("No GC module for this driver!\n"));
|
---|
1238 | rc = VERR_INVALID_PARAMETER;
|
---|
1239 | }
|
---|
1240 |
|
---|
1241 | LogFlow(("pdmR3DevHlp_IOPortRegisterGC: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1242 | return rc;
|
---|
1243 | }
|
---|
1244 |
|
---|
1245 |
|
---|
1246 | /** @copydoc PDMDEVHLP::pfnIOPortRegisterR0 */
|
---|
1247 | static DECLCALLBACK(int) pdmR3DevHlp_IOPortRegisterR0(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTR0PTR pvUser,
|
---|
1248 | const char *pszOut, const char *pszIn,
|
---|
1249 | const char *pszOutStr, const char *pszInStr, const char *pszDesc)
|
---|
1250 | {
|
---|
1251 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1252 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
1253 | 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,
|
---|
1254 | Port, cPorts, pvUser, pszOut, pszOut, pszIn, pszIn, pszOutStr, pszOutStr, pszInStr, pszInStr, pszDesc, pszDesc));
|
---|
1255 |
|
---|
1256 | if (!HWACCMR3IsAllowed(pDevIns->Internal.s.pVMHC))
|
---|
1257 | return VINF_SUCCESS; /* NOP */
|
---|
1258 |
|
---|
1259 | /*
|
---|
1260 | * Resolve the functions (one of the can be NULL).
|
---|
1261 | */
|
---|
1262 | int rc = VINF_SUCCESS;
|
---|
1263 | if ( pDevIns->pDevReg->szR0Mod[0]
|
---|
1264 | && (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_R0))
|
---|
1265 | {
|
---|
1266 | R0PTRTYPE(PFNIOMIOPORTIN) pfnR0PtrIn = 0;
|
---|
1267 | if (pszIn)
|
---|
1268 | {
|
---|
1269 | rc = PDMR3GetSymbolR0Lazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szR0Mod, pszIn, &pfnR0PtrIn);
|
---|
1270 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszIn)\n", pDevIns->pDevReg->szR0Mod, pszIn));
|
---|
1271 | }
|
---|
1272 | R0PTRTYPE(PFNIOMIOPORTOUT) pfnR0PtrOut = 0;
|
---|
1273 | if (pszOut && VBOX_SUCCESS(rc))
|
---|
1274 | {
|
---|
1275 | rc = PDMR3GetSymbolR0Lazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szR0Mod, pszOut, &pfnR0PtrOut);
|
---|
1276 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszOut)\n", pDevIns->pDevReg->szR0Mod, pszOut));
|
---|
1277 | }
|
---|
1278 | R0PTRTYPE(PFNIOMIOPORTINSTRING) pfnR0PtrInStr = 0;
|
---|
1279 | if (pszInStr && VBOX_SUCCESS(rc))
|
---|
1280 | {
|
---|
1281 | rc = PDMR3GetSymbolR0Lazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szR0Mod, pszInStr, &pfnR0PtrInStr);
|
---|
1282 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszInStr)\n", pDevIns->pDevReg->szR0Mod, pszInStr));
|
---|
1283 | }
|
---|
1284 | R0PTRTYPE(PFNIOMIOPORTOUTSTRING) pfnR0PtrOutStr = 0;
|
---|
1285 | if (pszOutStr && VBOX_SUCCESS(rc))
|
---|
1286 | {
|
---|
1287 | rc = PDMR3GetSymbolR0Lazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szR0Mod, pszOutStr, &pfnR0PtrOutStr);
|
---|
1288 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszOutStr)\n", pDevIns->pDevReg->szR0Mod, pszOutStr));
|
---|
1289 | }
|
---|
1290 |
|
---|
1291 | if (VBOX_SUCCESS(rc))
|
---|
1292 | rc = IOMIOPortRegisterR0(pDevIns->Internal.s.pVMHC, pDevIns, Port, cPorts, pvUser, pfnR0PtrOut, pfnR0PtrIn, pfnR0PtrOutStr, pfnR0PtrInStr, pszDesc);
|
---|
1293 | }
|
---|
1294 | else
|
---|
1295 | {
|
---|
1296 | AssertMsgFailed(("No R0 module for this driver!\n"));
|
---|
1297 | rc = VERR_INVALID_PARAMETER;
|
---|
1298 | }
|
---|
1299 |
|
---|
1300 | LogFlow(("pdmR3DevHlp_IOPortRegisterR0: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1301 | return rc;
|
---|
1302 | }
|
---|
1303 |
|
---|
1304 |
|
---|
1305 | /** @copydoc PDMDEVHLP::pfnIOPortDeregister */
|
---|
1306 | static DECLCALLBACK(int) pdmR3DevHlp_IOPortDeregister(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts)
|
---|
1307 | {
|
---|
1308 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1309 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
1310 | LogFlow(("pdmR3DevHlp_IOPortDeregister: caller='%s'/%d: Port=%#x cPorts=%#x\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance,
|
---|
1311 | Port, cPorts));
|
---|
1312 |
|
---|
1313 | int rc = IOMR3IOPortDeregister(pDevIns->Internal.s.pVMHC, pDevIns, Port, cPorts);
|
---|
1314 |
|
---|
1315 | LogFlow(("pdmR3DevHlp_IOPortDeregister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1316 | return rc;
|
---|
1317 | }
|
---|
1318 |
|
---|
1319 |
|
---|
1320 | /** @copydoc PDMDEVHLP::pfnMMIORegister */
|
---|
1321 | static DECLCALLBACK(int) pdmR3DevHlp_MMIORegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
|
---|
1322 | PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
|
---|
1323 | const char *pszDesc)
|
---|
1324 | {
|
---|
1325 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1326 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
1327 | LogFlow(("pdmR3DevHlp_MMIORegister: caller='%s'/%d: GCPhysStart=%VGp cbRange=%#x pvUser=%p pfnWrite=%p pfnRead=%p pfnFill=%p pszDesc=%p:{%s}\n",
|
---|
1328 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhysStart, cbRange, pvUser, pfnWrite, pfnRead, pfnFill, pszDesc, pszDesc));
|
---|
1329 |
|
---|
1330 | int rc = IOMR3MMIORegisterR3(pDevIns->Internal.s.pVMHC, pDevIns, GCPhysStart, cbRange, pvUser, pfnWrite, pfnRead, pfnFill, pszDesc);
|
---|
1331 |
|
---|
1332 | LogFlow(("pdmR3DevHlp_MMIORegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1333 | return rc;
|
---|
1334 | }
|
---|
1335 |
|
---|
1336 |
|
---|
1337 | /** @copydoc PDMDEVHLP::pfnMMIORegisterGC */
|
---|
1338 | static DECLCALLBACK(int) pdmR3DevHlp_MMIORegisterGC(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
|
---|
1339 | const char *pszWrite, const char *pszRead, const char *pszFill,
|
---|
1340 | const char *pszDesc)
|
---|
1341 | {
|
---|
1342 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1343 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
1344 | LogFlow(("pdmR3DevHlp_MMIORegisterGC: caller='%s'/%d: GCPhysStart=%VGp cbRange=%#x pvUser=%p pszWrite=%p:{%s} pszRead=%p:{%s} pszFill=%p:{%s} pszDesc=%p:{%s}\n",
|
---|
1345 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhysStart, cbRange, pvUser, pszWrite, pszWrite, pszRead, pszRead, pszFill, pszFill, pszDesc, pszDesc));
|
---|
1346 |
|
---|
1347 | /*
|
---|
1348 | * Resolve the functions.
|
---|
1349 | * Not all function have to present, leave it to IOM to enforce this.
|
---|
1350 | */
|
---|
1351 | int rc = VINF_SUCCESS;
|
---|
1352 | if ( pDevIns->pDevReg->szGCMod[0]
|
---|
1353 | && (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_GC))
|
---|
1354 | {
|
---|
1355 | RTGCPTR GCPtrWrite = 0;
|
---|
1356 | if (pszWrite)
|
---|
1357 | rc = PDMR3GetSymbolGCLazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szGCMod, pszWrite, &GCPtrWrite);
|
---|
1358 | RTGCPTR GCPtrRead = 0;
|
---|
1359 | int rc2 = VINF_SUCCESS;
|
---|
1360 | if (pszRead)
|
---|
1361 | rc2 = PDMR3GetSymbolGCLazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szGCMod, pszRead, &GCPtrRead);
|
---|
1362 | RTGCPTR GCPtrFill = 0;
|
---|
1363 | int rc3 = VINF_SUCCESS;
|
---|
1364 | if (pszFill)
|
---|
1365 | rc3 = PDMR3GetSymbolGCLazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szGCMod, pszFill, &GCPtrFill);
|
---|
1366 | if (VBOX_SUCCESS(rc) && VBOX_SUCCESS(rc2) && VBOX_SUCCESS(rc3))
|
---|
1367 | rc = IOMMMIORegisterGC(pDevIns->Internal.s.pVMHC, pDevIns, GCPhysStart, cbRange, pvUser, GCPtrWrite, GCPtrRead, GCPtrFill, pszDesc);
|
---|
1368 | else
|
---|
1369 | {
|
---|
1370 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszWrite)\n", pDevIns->pDevReg->szGCMod, pszWrite));
|
---|
1371 | AssertMsgRC(rc2, ("Failed to resolve %s.%s (pszRead)\n", pDevIns->pDevReg->szGCMod, pszRead));
|
---|
1372 | AssertMsgRC(rc3, ("Failed to resolve %s.%s (pszFill)\n", pDevIns->pDevReg->szGCMod, pszFill));
|
---|
1373 | if (VBOX_FAILURE(rc2) && VBOX_SUCCESS(rc))
|
---|
1374 | rc = rc2;
|
---|
1375 | if (VBOX_FAILURE(rc3) && VBOX_SUCCESS(rc))
|
---|
1376 | rc = rc3;
|
---|
1377 | }
|
---|
1378 | }
|
---|
1379 | else
|
---|
1380 | {
|
---|
1381 | AssertMsgFailed(("No GC module for this driver!\n"));
|
---|
1382 | rc = VERR_INVALID_PARAMETER;
|
---|
1383 | }
|
---|
1384 |
|
---|
1385 | LogFlow(("pdmR3DevHlp_MMIORegisterGC: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1386 | return rc;
|
---|
1387 | }
|
---|
1388 |
|
---|
1389 | /** @copydoc PDMDEVHLP::pfnMMIORegisterR0 */
|
---|
1390 | static DECLCALLBACK(int) pdmR3DevHlp_MMIORegisterR0(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTR0PTR pvUser,
|
---|
1391 | const char *pszWrite, const char *pszRead, const char *pszFill,
|
---|
1392 | const char *pszDesc)
|
---|
1393 | {
|
---|
1394 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1395 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
1396 | LogFlow(("pdmR3DevHlp_MMIORegisterHC: caller='%s'/%d: GCPhysStart=%VGp cbRange=%#x pvUser=%p pszWrite=%p:{%s} pszRead=%p:{%s} pszFill=%p:{%s} pszDesc=%p:{%s}\n",
|
---|
1397 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhysStart, cbRange, pvUser, pszWrite, pszWrite, pszRead, pszRead, pszFill, pszFill, pszDesc, pszDesc));
|
---|
1398 |
|
---|
1399 | if (!HWACCMR3IsAllowed(pDevIns->Internal.s.pVMHC))
|
---|
1400 | return VINF_SUCCESS; /* NOP */
|
---|
1401 |
|
---|
1402 | /*
|
---|
1403 | * Resolve the functions.
|
---|
1404 | * Not all function have to present, leave it to IOM to enforce this.
|
---|
1405 | */
|
---|
1406 | int rc = VINF_SUCCESS;
|
---|
1407 | if ( pDevIns->pDevReg->szR0Mod[0]
|
---|
1408 | && (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_R0))
|
---|
1409 | {
|
---|
1410 | R0PTRTYPE(PFNIOMMMIOWRITE) pfnR0PtrWrite = 0;
|
---|
1411 | if (pszWrite)
|
---|
1412 | rc = PDMR3GetSymbolR0Lazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szR0Mod, pszWrite, &pfnR0PtrWrite);
|
---|
1413 | R0PTRTYPE(PFNIOMMMIOREAD) pfnR0PtrRead = 0;
|
---|
1414 | int rc2 = VINF_SUCCESS;
|
---|
1415 | if (pszRead)
|
---|
1416 | rc2 = PDMR3GetSymbolR0Lazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szR0Mod, pszRead, &pfnR0PtrRead);
|
---|
1417 | R0PTRTYPE(PFNIOMMMIOFILL) pfnR0PtrFill = 0;
|
---|
1418 | int rc3 = VINF_SUCCESS;
|
---|
1419 | if (pszFill)
|
---|
1420 | rc3 = PDMR3GetSymbolR0Lazy(pDevIns->Internal.s.pVMHC, pDevIns->pDevReg->szR0Mod, pszFill, &pfnR0PtrFill);
|
---|
1421 | if (VBOX_SUCCESS(rc) && VBOX_SUCCESS(rc2) && VBOX_SUCCESS(rc3))
|
---|
1422 | rc = IOMMMIORegisterR0(pDevIns->Internal.s.pVMHC, pDevIns, GCPhysStart, cbRange, pvUser, pfnR0PtrWrite, pfnR0PtrRead, pfnR0PtrFill, pszDesc);
|
---|
1423 | else
|
---|
1424 | {
|
---|
1425 | AssertMsgRC(rc, ("Failed to resolve %s.%s (pszWrite)\n", pDevIns->pDevReg->szR0Mod, pszWrite));
|
---|
1426 | AssertMsgRC(rc2, ("Failed to resolve %s.%s (pszRead)\n", pDevIns->pDevReg->szR0Mod, pszRead));
|
---|
1427 | AssertMsgRC(rc3, ("Failed to resolve %s.%s (pszFill)\n", pDevIns->pDevReg->szR0Mod, pszFill));
|
---|
1428 | if (VBOX_FAILURE(rc2) && VBOX_SUCCESS(rc))
|
---|
1429 | rc = rc2;
|
---|
1430 | if (VBOX_FAILURE(rc3) && VBOX_SUCCESS(rc))
|
---|
1431 | rc = rc3;
|
---|
1432 | }
|
---|
1433 | }
|
---|
1434 | else
|
---|
1435 | {
|
---|
1436 | AssertMsgFailed(("No R0 module for this driver!\n"));
|
---|
1437 | rc = VERR_INVALID_PARAMETER;
|
---|
1438 | }
|
---|
1439 |
|
---|
1440 | LogFlow(("pdmR3DevHlp_MMIORegisterR0: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1441 | return rc;
|
---|
1442 | }
|
---|
1443 |
|
---|
1444 |
|
---|
1445 | /** @copydoc PDMDEVHLP::pfnMMIODeregister */
|
---|
1446 | static DECLCALLBACK(int) pdmR3DevHlp_MMIODeregister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange)
|
---|
1447 | {
|
---|
1448 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1449 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
1450 | LogFlow(("pdmR3DevHlp_MMIODeregister: caller='%s'/%d: GCPhysStart=%VGp cbRange=%#x\n",
|
---|
1451 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhysStart, cbRange));
|
---|
1452 |
|
---|
1453 | int rc = IOMR3MMIODeregister(pDevIns->Internal.s.pVMHC, pDevIns, GCPhysStart, cbRange);
|
---|
1454 |
|
---|
1455 | LogFlow(("pdmR3DevHlp_MMIODeregister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1456 | return rc;
|
---|
1457 | }
|
---|
1458 |
|
---|
1459 |
|
---|
1460 | /** @copydoc PDMDEVHLP::pfnROMRegister */
|
---|
1461 | static DECLCALLBACK(int) pdmR3DevHlp_ROMRegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, const void *pvBinary, const char *pszDesc)
|
---|
1462 | {
|
---|
1463 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1464 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
1465 | LogFlow(("pdmR3DevHlp_ROMRegister: caller='%s'/%d: GCPhysStart=%VGp cbRange=%#x pvBinary=%p pszDesc=%p:{%s}\n",
|
---|
1466 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhysStart, cbRange, pvBinary, pszDesc, pszDesc));
|
---|
1467 |
|
---|
1468 | int rc = MMR3PhysRomRegister(pDevIns->Internal.s.pVMHC, pDevIns, GCPhysStart, cbRange, pvBinary, pszDesc);
|
---|
1469 |
|
---|
1470 | LogFlow(("pdmR3DevHlp_ROMRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1471 | return rc;
|
---|
1472 | }
|
---|
1473 |
|
---|
1474 |
|
---|
1475 | /** @copydoc PDMDEVHLP::pfnSSMRegister */
|
---|
1476 | static DECLCALLBACK(int) pdmR3DevHlp_SSMRegister(PPDMDEVINS pDevIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
|
---|
1477 | PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
|
---|
1478 | PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone)
|
---|
1479 | {
|
---|
1480 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1481 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
1482 | LogFlow(("pdmR3DevHlp_SSMRegister: caller='%s'/%d: pszName=%p:{%s} u32Instance=%#x u32Version=#x cbGuess=%#x pfnSavePrep=%p pfnSaveExec=%p pfnSaveDone=%p pszLoadPrep=%p pfnLoadExec=%p pfnLoaddone=%p\n",
|
---|
1483 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pszName, pszName, u32Instance, u32Version, cbGuess, pfnSavePrep, pfnSaveExec, pfnSaveDone, pfnLoadPrep, pfnLoadExec, pfnLoadDone));
|
---|
1484 |
|
---|
1485 | int rc = SSMR3Register(pDevIns->Internal.s.pVMHC, pDevIns, pszName, u32Instance, u32Version, cbGuess,
|
---|
1486 | pfnSavePrep, pfnSaveExec, pfnSaveDone,
|
---|
1487 | pfnLoadPrep, pfnLoadExec, pfnLoadDone);
|
---|
1488 |
|
---|
1489 | LogFlow(("pdmR3DevHlp_SSMRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1490 | return rc;
|
---|
1491 | }
|
---|
1492 |
|
---|
1493 |
|
---|
1494 | /** @copydoc PDMDEVHLP::pfnTMTimerCreate */
|
---|
1495 | static DECLCALLBACK(int) pdmR3DevHlp_TMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERHC ppTimer)
|
---|
1496 | {
|
---|
1497 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1498 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
1499 | LogFlow(("pdmR3DevHlp_TMTimerCreate: caller='%s'/%d: enmClock=%d pfnCallback=%p pszDesc=%p:{%s} ppTimer=%p\n",
|
---|
1500 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, enmClock, pfnCallback, pszDesc, pszDesc, ppTimer));
|
---|
1501 |
|
---|
1502 | int rc = TMR3TimerCreateDevice(pDevIns->Internal.s.pVMHC, pDevIns, enmClock, pfnCallback, pszDesc, ppTimer);
|
---|
1503 |
|
---|
1504 | LogFlow(("pdmR3DevHlp_TMTimerCreate: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1505 | return rc;
|
---|
1506 | }
|
---|
1507 |
|
---|
1508 |
|
---|
1509 | /** @copydoc PDMDEVHLP::pfnTMTimerCreateExternal */
|
---|
1510 | static DECLCALLBACK(PTMTIMERHC) pdmR3DevHlp_TMTimerCreateExternal(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc)
|
---|
1511 | {
|
---|
1512 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1513 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
1514 |
|
---|
1515 | return TMR3TimerCreateExternal(pDevIns->Internal.s.pVMHC, enmClock, pfnCallback, pvUser, pszDesc);
|
---|
1516 | }
|
---|
1517 |
|
---|
1518 | /** @copydoc PDMDEVHLP::pfnPCIRegister */
|
---|
1519 | static DECLCALLBACK(int) pdmR3DevHlp_PCIRegister(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev)
|
---|
1520 | {
|
---|
1521 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1522 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
1523 | VM_ASSERT_EMT(pVM);
|
---|
1524 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: pPciDev=%p:{.config={%#.256Vhxs}\n",
|
---|
1525 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pPciDev, pPciDev->config));
|
---|
1526 |
|
---|
1527 | /*
|
---|
1528 | * Validate input.
|
---|
1529 | */
|
---|
1530 | if (!pPciDev)
|
---|
1531 | {
|
---|
1532 | Assert(pPciDev);
|
---|
1533 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Vrc (pPciDev)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1534 | return VERR_INVALID_PARAMETER;
|
---|
1535 | }
|
---|
1536 | if (!pPciDev->config[0] && !pPciDev->config[1])
|
---|
1537 | {
|
---|
1538 | Assert(pPciDev->config[0] || pPciDev->config[1]);
|
---|
1539 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Vrc (vendor)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1540 | return VERR_INVALID_PARAMETER;
|
---|
1541 | }
|
---|
1542 | if (pDevIns->Internal.s.pPciDeviceHC)
|
---|
1543 | {
|
---|
1544 | /** @todo the PCI device vs. PDM device designed is a bit flawed if we have to
|
---|
1545 | * support a PDM device with multiple PCI devices. This might become a problem
|
---|
1546 | * when upgrading the chipset for instance...
|
---|
1547 | */
|
---|
1548 | AssertMsgFailed(("Only one PCI device per device is currently implemented!\n"));
|
---|
1549 | return VERR_INTERNAL_ERROR;
|
---|
1550 | }
|
---|
1551 |
|
---|
1552 | /*
|
---|
1553 | * Choose the PCI bus for the device.
|
---|
1554 | * This is simple. If the device was configured for a particular bus, it'll
|
---|
1555 | * already have one. If not, we'll just take the first one.
|
---|
1556 | */
|
---|
1557 | PPDMPCIBUS pBus = pDevIns->Internal.s.pPciBusHC;
|
---|
1558 | if (!pBus)
|
---|
1559 | pBus = pDevIns->Internal.s.pPciBusHC = &pVM->pdm.s.aPciBuses[0];
|
---|
1560 | int rc;
|
---|
1561 | if (pBus)
|
---|
1562 | {
|
---|
1563 | if (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_GC)
|
---|
1564 | pDevIns->Internal.s.pPciBusGC = MMHyperHC2GC(pVM, pDevIns->Internal.s.pPciBusHC);
|
---|
1565 |
|
---|
1566 | /*
|
---|
1567 | * Check the configuration for PCI device and function assignment.
|
---|
1568 | */
|
---|
1569 | int iDev = -1;
|
---|
1570 | uint8_t u8Device;
|
---|
1571 | rc = CFGMR3QueryU8(pDevIns->Internal.s.pCfgHandle, "PCIDeviceNo", &u8Device);
|
---|
1572 | if (VBOX_SUCCESS(rc))
|
---|
1573 | {
|
---|
1574 | if (u8Device > 31)
|
---|
1575 | {
|
---|
1576 | AssertMsgFailed(("Configuration error: PCIDeviceNo=%d, max is 31. (%s/%d)\n",
|
---|
1577 | u8Device, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1578 | return VERR_INTERNAL_ERROR;
|
---|
1579 | }
|
---|
1580 |
|
---|
1581 | uint8_t u8Function;
|
---|
1582 | rc = CFGMR3QueryU8(pDevIns->Internal.s.pCfgHandle, "PCIFunctionNo", &u8Function);
|
---|
1583 | if (VBOX_FAILURE(rc))
|
---|
1584 | {
|
---|
1585 | AssertMsgFailed(("Configuration error: PCIDeviceNo, but PCIFunctionNo query failed with rc=%Vrc (%s/%d)\n",
|
---|
1586 | rc, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1587 | return rc;
|
---|
1588 | }
|
---|
1589 | if (u8Function > 7)
|
---|
1590 | {
|
---|
1591 | AssertMsgFailed(("Configuration error: PCIFunctionNo=%d, max is 7. (%s/%d)\n",
|
---|
1592 | u8Function, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1593 | return VERR_INTERNAL_ERROR;
|
---|
1594 | }
|
---|
1595 | iDev = (u8Device << 3) | u8Function;
|
---|
1596 | }
|
---|
1597 | else if (rc != VERR_CFGM_VALUE_NOT_FOUND)
|
---|
1598 | {
|
---|
1599 | AssertMsgFailed(("Configuration error: PCIDeviceNo query failed with rc=%Vrc (%s/%d)\n",
|
---|
1600 | rc, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1601 | return rc;
|
---|
1602 | }
|
---|
1603 |
|
---|
1604 | /*
|
---|
1605 | * Call the pci bus device to do the actual registration.
|
---|
1606 | */
|
---|
1607 | pdmLock(pVM);
|
---|
1608 | rc = pBus->pfnRegisterR3(pBus->pDevInsR3, pPciDev, pDevIns->pDevReg->szDeviceName, iDev);
|
---|
1609 | pdmUnlock(pVM);
|
---|
1610 | if (VBOX_SUCCESS(rc))
|
---|
1611 | {
|
---|
1612 | pDevIns->Internal.s.pPciDeviceHC = pPciDev;
|
---|
1613 | if (pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_GC)
|
---|
1614 | pDevIns->Internal.s.pPciDeviceGC = MMHyperHC2GC(pVM, pPciDev);
|
---|
1615 | else
|
---|
1616 | pDevIns->Internal.s.pPciDeviceGC = 0;
|
---|
1617 | pPciDev->pDevIns = pDevIns;
|
---|
1618 | Log(("PDM: Registered device '%s'/%d as PCI device %d on bus %d\n",
|
---|
1619 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pPciDev->devfn, pDevIns->Internal.s.pPciBusHC->iBus));
|
---|
1620 | }
|
---|
1621 | }
|
---|
1622 | else
|
---|
1623 | {
|
---|
1624 | AssertMsgFailed(("Configuration error: No PCI bus available. This could be related to init order too!\n"));
|
---|
1625 | rc = VERR_PDM_NO_PCI_BUS;
|
---|
1626 | }
|
---|
1627 |
|
---|
1628 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1629 | return rc;
|
---|
1630 | }
|
---|
1631 |
|
---|
1632 |
|
---|
1633 | /** @copydoc PDMDEVHLP::pfnPCIIORegionRegister */
|
---|
1634 | static DECLCALLBACK(int) pdmR3DevHlp_PCIIORegionRegister(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)
|
---|
1635 | {
|
---|
1636 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1637 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
1638 | VM_ASSERT_EMT(pVM);
|
---|
1639 | LogFlow(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: iRegion=%d cbRegion=%#x enmType=%d pfnCallback=%p\n",
|
---|
1640 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iRegion, cbRegion, enmType, pfnCallback));
|
---|
1641 |
|
---|
1642 | /*
|
---|
1643 | * Validate input.
|
---|
1644 | */
|
---|
1645 | if (iRegion < 0 || iRegion >= PCI_NUM_REGIONS)
|
---|
1646 | {
|
---|
1647 | Assert(iRegion >= 0 && iRegion < PCI_NUM_REGIONS);
|
---|
1648 | LogFlow(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: returns %Vrc (iRegion)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1649 | return VERR_INVALID_PARAMETER;
|
---|
1650 | }
|
---|
1651 | switch (enmType)
|
---|
1652 | {
|
---|
1653 | case PCI_ADDRESS_SPACE_MEM:
|
---|
1654 | case PCI_ADDRESS_SPACE_IO:
|
---|
1655 | case PCI_ADDRESS_SPACE_MEM_PREFETCH:
|
---|
1656 | break;
|
---|
1657 | default:
|
---|
1658 | AssertMsgFailed(("enmType=%#x is unknown\n", enmType));
|
---|
1659 | LogFlow(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: returns %Vrc (enmType)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1660 | return VERR_INVALID_PARAMETER;
|
---|
1661 | }
|
---|
1662 | if (!pfnCallback)
|
---|
1663 | {
|
---|
1664 | Assert(pfnCallback);
|
---|
1665 | LogFlow(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: returns %Vrc (callback)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
1666 | return VERR_INVALID_PARAMETER;
|
---|
1667 | }
|
---|
1668 | AssertRelease(VMR3GetState(pVM) != VMSTATE_RUNNING);
|
---|
1669 |
|
---|
1670 | /*
|
---|
1671 | * Must have a PCI device registered!
|
---|
1672 | */
|
---|
1673 | int rc;
|
---|
1674 | PPCIDEVICE pPciDev = pDevIns->Internal.s.pPciDeviceHC;
|
---|
1675 | if (pPciDev)
|
---|
1676 | {
|
---|
1677 | /*
|
---|
1678 | * We're currently restricted to page aligned MMIO regions.
|
---|
1679 | */
|
---|
1680 | if ( (enmType == PCI_ADDRESS_SPACE_MEM || enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH)
|
---|
1681 | && cbRegion != RT_ALIGN_32(cbRegion, PAGE_SIZE))
|
---|
1682 | {
|
---|
1683 | Log(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: aligning cbRegion %#x -> %#x\n",
|
---|
1684 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cbRegion, RT_ALIGN_32(cbRegion, PAGE_SIZE)));
|
---|
1685 | cbRegion = RT_ALIGN_32(cbRegion, PAGE_SIZE);
|
---|
1686 | }
|
---|
1687 |
|
---|
1688 | PPDMPCIBUS pBus = pDevIns->Internal.s.pPciBusHC;
|
---|
1689 | Assert(pBus);
|
---|
1690 | pdmLock(pVM);
|
---|
1691 | rc = pBus->pfnIORegionRegisterR3(pBus->pDevInsR3, pPciDev, iRegion, cbRegion, enmType, pfnCallback);
|
---|
1692 | pdmUnlock(pVM);
|
---|
1693 | }
|
---|
1694 | else
|
---|
1695 | {
|
---|
1696 | AssertMsgFailed(("No PCI device registered!\n"));
|
---|
1697 | rc = VERR_PDM_NOT_PCI_DEVICE;
|
---|
1698 | }
|
---|
1699 |
|
---|
1700 | LogFlow(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
1701 | return rc;
|
---|
1702 | }
|
---|
1703 |
|
---|
1704 |
|
---|
1705 | /** @copydoc PDMDEVHLP::pfnPCISetConfigCallbacks */
|
---|
1706 | static DECLCALLBACK(void) pdmR3DevHlp_PCISetConfigCallbacks(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
|
---|
1707 | PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)
|
---|
1708 | {
|
---|
1709 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1710 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
1711 | VM_ASSERT_EMT(pVM);
|
---|
1712 | LogFlow(("pdmR3DevHlp_PCISetConfigCallbacks: caller='%s'/%d: pPciDev=%p pfnRead=%p ppfnReadOld=%p pfnWrite=%p ppfnWriteOld=%p\n",
|
---|
1713 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld));
|
---|
1714 |
|
---|
1715 | /*
|
---|
1716 | * Validate input and resolve defaults.
|
---|
1717 | */
|
---|
1718 | AssertPtr(pfnRead);
|
---|
1719 | AssertPtr(pfnWrite);
|
---|
1720 | AssertPtrNull(ppfnReadOld);
|
---|
1721 | AssertPtrNull(ppfnWriteOld);
|
---|
1722 | AssertPtrNull(pPciDev);
|
---|
1723 |
|
---|
1724 | if (!pPciDev)
|
---|
1725 | pPciDev = pDevIns->Internal.s.pPciDeviceHC;
|
---|
1726 | AssertReleaseMsg(pPciDev, ("You must register your device first!\n"));
|
---|
1727 | PPDMPCIBUS pBus = pDevIns->Internal.s.pPciBusHC;
|
---|
1728 | AssertRelease(pBus);
|
---|
1729 | AssertRelease(VMR3GetState(pVM) != VMSTATE_RUNNING);
|
---|
1730 |
|
---|
1731 | /*
|
---|
1732 | * Do the job.
|
---|
1733 | */
|
---|
1734 | pdmLock(pVM);
|
---|
1735 | pBus->pfnSetConfigCallbacksR3(pBus->pDevInsR3, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld);
|
---|
1736 | pdmUnlock(pVM);
|
---|
1737 |
|
---|
1738 | LogFlow(("pdmR3DevHlp_PCISetConfigCallbacks: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1739 | }
|
---|
1740 |
|
---|
1741 |
|
---|
1742 | /** @copydoc PDMDEVHLP::pfnPCISetIrq */
|
---|
1743 | static DECLCALLBACK(void) pdmR3DevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
|
---|
1744 | {
|
---|
1745 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1746 | LogFlow(("pdmR3DevHlp_PCISetIrq: caller='%s'/%d: iIrq=%d iLevel=%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iIrq, iLevel));
|
---|
1747 |
|
---|
1748 | /*
|
---|
1749 | * Validate input.
|
---|
1750 | */
|
---|
1751 | /** @todo iIrq and iLevel checks. */
|
---|
1752 |
|
---|
1753 | /*
|
---|
1754 | * Must have a PCI device registered!
|
---|
1755 | */
|
---|
1756 | PPCIDEVICE pPciDev = pDevIns->Internal.s.pPciDeviceHC;
|
---|
1757 | if (pPciDev)
|
---|
1758 | {
|
---|
1759 | PPDMPCIBUS pBus = pDevIns->Internal.s.pPciBusHC; /** @todo the bus should be associated with the PCI device not the PDM device. */
|
---|
1760 | Assert(pBus);
|
---|
1761 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
1762 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
1763 | pdmLock(pVM);
|
---|
1764 | pBus->pfnSetIrqR3(pBus->pDevInsR3, pPciDev, iIrq, iLevel);
|
---|
1765 | pdmUnlock(pVM);
|
---|
1766 |
|
---|
1767 | #else /* !VBOX_WITH_PDM_LOCK */
|
---|
1768 | /*
|
---|
1769 | * For the convenience of the device we put no thread restriction on this interface.
|
---|
1770 | * That means we'll have to check which thread we're in and choose our path.
|
---|
1771 | */
|
---|
1772 | if (VM_IS_EMT(pDevIns->Internal.s.pVMHC) || VMMR3LockIsOwner(pDevIns->Internal.s.pVMHC))
|
---|
1773 | pBus->pfnSetIrqR3(pBus->pDevInsR3, pPciDev, iIrq, iLevel);
|
---|
1774 | else
|
---|
1775 | {
|
---|
1776 | Log(("pdmR3DevHlp_PCISetIrq: caller='%s'/%d: Requesting call in EMT...\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1777 | PVMREQ pReq;
|
---|
1778 | int rc = VMR3ReqCallVoid(pDevIns->Internal.s.pVMHC, &pReq, RT_INDEFINITE_WAIT,
|
---|
1779 | (PFNRT)pBus->pfnSetIrqR3, 4, pBus->pDevInsR3, pPciDev, iIrq, iLevel);
|
---|
1780 | while (rc == VERR_TIMEOUT)
|
---|
1781 | rc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
|
---|
1782 | AssertReleaseRC(rc);
|
---|
1783 | VMR3ReqFree(pReq);
|
---|
1784 | }
|
---|
1785 | #endif /* !VBOX_WITH_PDM_LOCK */
|
---|
1786 | }
|
---|
1787 | else
|
---|
1788 | AssertReleaseMsgFailed(("No PCI device registered!\n"));
|
---|
1789 |
|
---|
1790 | LogFlow(("pdmR3DevHlp_PCISetIrq: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1791 | }
|
---|
1792 |
|
---|
1793 |
|
---|
1794 | /** @copydoc PDMDEVHLP::pfnPCISetIrqNoWait */
|
---|
1795 | static DECLCALLBACK(void) pdmR3DevHlp_PCISetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
|
---|
1796 | {
|
---|
1797 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
1798 | pdmR3DevHlp_PCISetIrq(pDevIns, iIrq, iLevel);
|
---|
1799 | #else /* !VBOX_WITH_PDM_LOCK */
|
---|
1800 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1801 | LogFlow(("pdmR3DevHlp_PCISetIrqNoWait: caller='%s'/%d: iIrq=%d iLevel=%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iIrq, iLevel));
|
---|
1802 |
|
---|
1803 | /*
|
---|
1804 | * Validate input.
|
---|
1805 | */
|
---|
1806 | /** @todo iIrq and iLevel checks. */
|
---|
1807 |
|
---|
1808 | /*
|
---|
1809 | * Must have a PCI device registered!
|
---|
1810 | */
|
---|
1811 | PPCIDEVICE pPciDev = pDevIns->Internal.s.pPciDeviceHC;
|
---|
1812 | if (pPciDev)
|
---|
1813 | {
|
---|
1814 | PPDMPCIBUS pBus = pDevIns->Internal.s.pPciBusHC;
|
---|
1815 | Assert(pBus);
|
---|
1816 |
|
---|
1817 | /*
|
---|
1818 | * For the convenience of the device we put no thread restriction on this interface.
|
---|
1819 | * That means we'll have to check which thread we're in and choose our path.
|
---|
1820 | */
|
---|
1821 | if (VM_IS_EMT(pDevIns->Internal.s.pVMHC) || VMMR3LockIsOwner(pDevIns->Internal.s.pVMHC))
|
---|
1822 | pBus->pfnSetIrqR3(pBus->pDevInsR3, pPciDev, iIrq, iLevel);
|
---|
1823 | else
|
---|
1824 | {
|
---|
1825 | Log(("pdmR3DevHlp_PCISetIrqNoWait: caller='%s'/%d: Queueing call in EMT...\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1826 | int rc = VMR3ReqCallEx(pDevIns->Internal.s.pVMHC, NULL, RT_INDEFINITE_WAIT, VMREQFLAGS_NO_WAIT | VMREQFLAGS_VOID,
|
---|
1827 | (PFNRT)pBus->pfnSetIrqR3, 4, pBus->pDevInsR3, pPciDev, iIrq, iLevel);
|
---|
1828 | AssertReleaseRC(rc);
|
---|
1829 | }
|
---|
1830 | }
|
---|
1831 | else
|
---|
1832 | AssertReleaseMsgFailed(("No PCI device registered!\n"));
|
---|
1833 |
|
---|
1834 | LogFlow(("pdmR3DevHlp_PCISetIrqNoWait: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1835 | #endif /* !VBOX_WITH_PDM_LOCK */
|
---|
1836 | }
|
---|
1837 |
|
---|
1838 |
|
---|
1839 | /** @copydoc PDMDEVHLP::pfnISASetIrq */
|
---|
1840 | static DECLCALLBACK(void) pdmR3DevHlp_ISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
|
---|
1841 | {
|
---|
1842 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1843 | LogFlow(("pdmR3DevHlp_ISASetIrq: caller='%s'/%d: iIrq=%d iLevel=%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iIrq, iLevel));
|
---|
1844 |
|
---|
1845 | /*
|
---|
1846 | * Validate input.
|
---|
1847 | */
|
---|
1848 | /** @todo iIrq and iLevel checks. */
|
---|
1849 |
|
---|
1850 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
1851 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
1852 | PDMIsaSetIrq(pVM, iIrq, iLevel); /* (The API takes the lock.) */
|
---|
1853 | #else /* !VBOX_WITH_PDM_LOCK */
|
---|
1854 | if (VM_IS_EMT(pDevIns->Internal.s.pVMHC) || VMMR3LockIsOwner(pDevIns->Internal.s.pVMHC))
|
---|
1855 | PDMIsaSetIrq(pVM, iIrq, iLevel);
|
---|
1856 | else
|
---|
1857 | {
|
---|
1858 | Log(("pdmR3DevHlp_ISASetIrq: caller='%s'/%d: Requesting call in EMT...\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1859 | PVMREQ pReq;
|
---|
1860 | int rc = VMR3ReqCallVoid(pDevIns->Internal.s.pVMHC, &pReq, RT_INDEFINITE_WAIT,
|
---|
1861 | (PFNRT)PDMIsaSetIrq, 3, pVM, iIrq, iLevel);
|
---|
1862 | while (rc == VERR_TIMEOUT)
|
---|
1863 | rc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
|
---|
1864 | AssertReleaseRC(rc);
|
---|
1865 | VMR3ReqFree(pReq);
|
---|
1866 | }
|
---|
1867 | #endif /* !VBOX_WITH_PDM_LOCK */
|
---|
1868 |
|
---|
1869 | LogFlow(("pdmR3DevHlp_ISASetIrq: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1870 | }
|
---|
1871 |
|
---|
1872 | /** @copydoc PDMDEVHLP::pfnISASetIrqNoWait */
|
---|
1873 | static DECLCALLBACK(void) pdmR3DevHlp_ISASetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
|
---|
1874 | {
|
---|
1875 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
1876 | pdmR3DevHlp_ISASetIrq(pDevIns, iIrq, iLevel);
|
---|
1877 | #else /* !VBOX_WITH_PDM_LOCK */
|
---|
1878 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1879 | LogFlow(("pdmR3DevHlp_ISASetIrqNoWait: caller='%s'/%d: iIrq=%d iLevel=%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iIrq, iLevel));
|
---|
1880 |
|
---|
1881 | /*
|
---|
1882 | * Validate input.
|
---|
1883 | */
|
---|
1884 | /** @todo iIrq and iLevel checks. */
|
---|
1885 |
|
---|
1886 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
1887 | /*
|
---|
1888 | * For the convenience of the device we put no thread restriction on this interface.
|
---|
1889 | * That means we'll have to check which thread we're in and choose our path.
|
---|
1890 | */
|
---|
1891 | if (VM_IS_EMT(pDevIns->Internal.s.pVMHC) || VMMR3LockIsOwner(pDevIns->Internal.s.pVMHC))
|
---|
1892 | PDMIsaSetIrq(pVM, iIrq, iLevel);
|
---|
1893 | else
|
---|
1894 | {
|
---|
1895 | Log(("pdmR3DevHlp_ISASetIrqNoWait: caller='%s'/%d: Queueing call in EMT...\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1896 | int rc = VMR3ReqCallEx(pDevIns->Internal.s.pVMHC, NULL, 0, VMREQFLAGS_NO_WAIT | VMREQFLAGS_VOID,
|
---|
1897 | (PFNRT)PDMIsaSetIrq, 3, pVM, iIrq, iLevel);
|
---|
1898 | AssertReleaseRC(rc);
|
---|
1899 | }
|
---|
1900 |
|
---|
1901 | LogFlow(("pdmR3DevHlp_ISASetIrqNoWait: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1902 | #endif /* !VBOX_WITH_PDM_LOCK */
|
---|
1903 | }
|
---|
1904 |
|
---|
1905 |
|
---|
1906 | /** @copydoc PDMDEVHLP::pfnDriverAttach */
|
---|
1907 | static DECLCALLBACK(int) pdmR3DevHlp_DriverAttach(PPDMDEVINS pDevIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
|
---|
1908 | {
|
---|
1909 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
1910 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
1911 | VM_ASSERT_EMT(pVM);
|
---|
1912 | LogFlow(("pdmR3DevHlp_DriverAttach: caller='%s'/%d: iLun=%d pBaseInterface=%p ppBaseInterface=%p pszDesc=%p:{%s}\n",
|
---|
1913 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iLun, pBaseInterface, ppBaseInterface, pszDesc, pszDesc));
|
---|
1914 |
|
---|
1915 | /*
|
---|
1916 | * Lookup the LUN, it might already be registered.
|
---|
1917 | */
|
---|
1918 | PPDMLUN pLunPrev = NULL;
|
---|
1919 | PPDMLUN pLun = pDevIns->Internal.s.pLunsHC;
|
---|
1920 | for (; pLun; pLunPrev = pLun, pLun = pLun->pNext)
|
---|
1921 | if (pLun->iLun == iLun)
|
---|
1922 | break;
|
---|
1923 |
|
---|
1924 | /*
|
---|
1925 | * Create the LUN if if wasn't found, else check if driver is already attached to it.
|
---|
1926 | */
|
---|
1927 | if (!pLun)
|
---|
1928 | {
|
---|
1929 | if ( !pBaseInterface
|
---|
1930 | || !pszDesc
|
---|
1931 | || !*pszDesc)
|
---|
1932 | {
|
---|
1933 | Assert(pBaseInterface);
|
---|
1934 | Assert(pszDesc || *pszDesc);
|
---|
1935 | return VERR_INVALID_PARAMETER;
|
---|
1936 | }
|
---|
1937 |
|
---|
1938 | pLun = (PPDMLUN)MMR3HeapAlloc(pVM, MM_TAG_PDM_LUN, sizeof(*pLun));
|
---|
1939 | if (!pLun)
|
---|
1940 | return VERR_NO_MEMORY;
|
---|
1941 |
|
---|
1942 | pLun->iLun = iLun;
|
---|
1943 | pLun->pNext = pLunPrev ? pLunPrev->pNext : NULL;
|
---|
1944 | pLun->pTop = NULL;
|
---|
1945 | pLun->pDevIns = pDevIns;
|
---|
1946 | pLun->pszDesc = pszDesc;
|
---|
1947 | pLun->pBase = pBaseInterface;
|
---|
1948 | if (!pLunPrev)
|
---|
1949 | pDevIns->Internal.s.pLunsHC = pLun;
|
---|
1950 | else
|
---|
1951 | pLunPrev->pNext = pLun;
|
---|
1952 | Log(("pdmR3DevHlp_DriverAttach: Registered LUN#%d '%s' with device '%s'/%d.\n",
|
---|
1953 | iLun, pszDesc, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
1954 | }
|
---|
1955 | else if (pLun->pTop)
|
---|
1956 | {
|
---|
1957 | AssertMsgFailed(("Already attached! The device should keep track of such things!\n"));
|
---|
1958 | LogFlow(("pdmR3DevHlp_DriverAttach: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_PDM_DRIVER_ALREADY_ATTACHED));
|
---|
1959 | return VERR_PDM_DRIVER_ALREADY_ATTACHED;
|
---|
1960 | }
|
---|
1961 | Assert(pLun->pBase == pBaseInterface);
|
---|
1962 |
|
---|
1963 |
|
---|
1964 | /*
|
---|
1965 | * Get the attached driver configuration.
|
---|
1966 | */
|
---|
1967 | int rc;
|
---|
1968 | char szNode[48];
|
---|
1969 | RTStrPrintf(szNode, sizeof(szNode), "LUN#%d", iLun);
|
---|
1970 | PCFGMNODE pNode = CFGMR3GetChild(pDevIns->Internal.s.pCfgHandle, szNode);
|
---|
1971 | if (pNode)
|
---|
1972 | {
|
---|
1973 | char *pszName;
|
---|
1974 | rc = CFGMR3QueryStringAlloc(pNode, "Driver", &pszName);
|
---|
1975 | if (VBOX_SUCCESS(rc))
|
---|
1976 | {
|
---|
1977 | /*
|
---|
1978 | * Find the driver.
|
---|
1979 | */
|
---|
1980 | PPDMDRV pDrv = pdmR3DrvLookup(pVM, pszName);
|
---|
1981 | if (pDrv)
|
---|
1982 | {
|
---|
1983 | /* config node */
|
---|
1984 | PCFGMNODE pConfigNode = CFGMR3GetChild(pNode, "Config");
|
---|
1985 | if (!pConfigNode)
|
---|
1986 | rc = CFGMR3InsertNode(pNode, "Config", &pConfigNode);
|
---|
1987 | if (VBOX_SUCCESS(rc))
|
---|
1988 | {
|
---|
1989 | CFGMR3SetRestrictedRoot(pConfigNode);
|
---|
1990 |
|
---|
1991 | /*
|
---|
1992 | * Allocate the driver instance.
|
---|
1993 | */
|
---|
1994 | size_t cb = RT_OFFSETOF(PDMDRVINS, achInstanceData[pDrv->pDrvReg->cbInstance]);
|
---|
1995 | cb = RT_ALIGN_Z(cb, 16);
|
---|
1996 | PPDMDRVINS pNew = (PPDMDRVINS)MMR3HeapAllocZ(pVM, MM_TAG_PDM_DRIVER, cb);
|
---|
1997 | if (pNew)
|
---|
1998 | {
|
---|
1999 | /*
|
---|
2000 | * Initialize the instance structure (declaration order).
|
---|
2001 | */
|
---|
2002 | pNew->u32Version = PDM_DRVINS_VERSION;
|
---|
2003 | //pNew->Internal.s.pUp = NULL;
|
---|
2004 | //pNew->Internal.s.pDown = NULL;
|
---|
2005 | pNew->Internal.s.pLun = pLun;
|
---|
2006 | pNew->Internal.s.pDrv = pDrv;
|
---|
2007 | pNew->Internal.s.pVM = pVM;
|
---|
2008 | //pNew->Internal.s.fDetaching = false;
|
---|
2009 | pNew->Internal.s.pCfgHandle = pNode;
|
---|
2010 | pNew->pDrvHlp = &g_pdmR3DrvHlp;
|
---|
2011 | pNew->pDrvReg = pDrv->pDrvReg;
|
---|
2012 | pNew->pCfgHandle = pConfigNode;
|
---|
2013 | pNew->iInstance = pDrv->cInstances++;
|
---|
2014 | pNew->pUpBase = pBaseInterface;
|
---|
2015 | //pNew->pDownBase = NULL;
|
---|
2016 | //pNew->IBase.pfnQueryInterface = NULL;
|
---|
2017 | pNew->pvInstanceData = &pNew->achInstanceData[0];
|
---|
2018 |
|
---|
2019 | /*
|
---|
2020 | * Link with LUN and call the constructor.
|
---|
2021 | */
|
---|
2022 | rc = pDrv->pDrvReg->pfnConstruct(pNew, pNew->pCfgHandle);
|
---|
2023 | if (VBOX_SUCCESS(rc))
|
---|
2024 | {
|
---|
2025 | pLun->pTop = pNew;
|
---|
2026 | MMR3HeapFree(pszName);
|
---|
2027 | *ppBaseInterface = &pNew->IBase;
|
---|
2028 | Log(("PDM: Attached driver '%s'/%d to LUN#%d on device '%s'/%d.\n",
|
---|
2029 | pDrv->pDrvReg->szDriverName, pNew->iInstance, iLun, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2030 | LogFlow(("pdmR3DevHlp_DriverAttach: caller '%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VINF_SUCCESS));
|
---|
2031 | /*
|
---|
2032 | * Might return != VINF_SUCCESS (e.g. VINF_NAT_DNS) */
|
---|
2033 | return rc;
|
---|
2034 | }
|
---|
2035 |
|
---|
2036 | /*
|
---|
2037 | * Free the driver.
|
---|
2038 | */
|
---|
2039 | pLun->pTop = NULL;
|
---|
2040 | ASMMemFill32(pNew, cb, 0xdeadd0d0);
|
---|
2041 | MMR3HeapFree(pNew);
|
---|
2042 | pDrv->cInstances--;
|
---|
2043 | }
|
---|
2044 | else
|
---|
2045 | {
|
---|
2046 | AssertMsgFailed(("Failed to allocate %d bytes for instantiating driver '%s'\n", cb, pszName));
|
---|
2047 | rc = VERR_NO_MEMORY;
|
---|
2048 | }
|
---|
2049 | }
|
---|
2050 | else
|
---|
2051 | AssertMsgFailed(("Failed to create Config node! rc=%Vrc\n", rc));
|
---|
2052 | }
|
---|
2053 | else
|
---|
2054 | {
|
---|
2055 | AssertMsgFailed(("Driver '%s' wasn't found!\n", pszName));
|
---|
2056 | rc = VERR_PDM_DRIVER_NOT_FOUND;
|
---|
2057 | }
|
---|
2058 | MMR3HeapFree(pszName);
|
---|
2059 | }
|
---|
2060 | else
|
---|
2061 | {
|
---|
2062 | AssertMsgFailed(("Query for string value of \"Driver\" -> %Vrc\n", rc));
|
---|
2063 | if (rc == VERR_CFGM_VALUE_NOT_FOUND)
|
---|
2064 | rc = VERR_PDM_CFG_MISSING_DRIVER_NAME;
|
---|
2065 | }
|
---|
2066 | }
|
---|
2067 | else
|
---|
2068 | rc = VERR_PDM_NO_ATTACHED_DRIVER;
|
---|
2069 |
|
---|
2070 |
|
---|
2071 | LogFlow(("pdmR3DevHlp_DriverAttach: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2072 | return rc;
|
---|
2073 | }
|
---|
2074 |
|
---|
2075 |
|
---|
2076 | /** @copydoc PDMDEVHLP::pfnMMHeapAlloc */
|
---|
2077 | static DECLCALLBACK(void *) pdmR3DevHlp_MMHeapAlloc(PPDMDEVINS pDevIns, size_t cb)
|
---|
2078 | {
|
---|
2079 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2080 | LogFlow(("pdmR3DevHlp_MMHeapAlloc: caller='%s'/%d: cb=%#x\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cb));
|
---|
2081 |
|
---|
2082 | void *pv = MMR3HeapAlloc(pDevIns->Internal.s.pVMHC, MM_TAG_PDM_DEVICE_USER, cb);
|
---|
2083 |
|
---|
2084 | LogFlow(("pdmR3DevHlp_MMHeapAlloc: caller='%s'/%d: returns %p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pv));
|
---|
2085 | return pv;
|
---|
2086 | }
|
---|
2087 |
|
---|
2088 |
|
---|
2089 | /** @copydoc PDMDEVHLP::pfnMMHeapAllocZ */
|
---|
2090 | static DECLCALLBACK(void *) pdmR3DevHlp_MMHeapAllocZ(PPDMDEVINS pDevIns, size_t cb)
|
---|
2091 | {
|
---|
2092 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2093 | LogFlow(("pdmR3DevHlp_MMHeapAllocZ: caller='%s'/%d: cb=%#x\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cb));
|
---|
2094 |
|
---|
2095 | void *pv = MMR3HeapAllocZ(pDevIns->Internal.s.pVMHC, MM_TAG_PDM_DEVICE_USER, cb);
|
---|
2096 |
|
---|
2097 | LogFlow(("pdmR3DevHlp_MMHeapAllocZ: caller='%s'/%d: returns %p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pv));
|
---|
2098 | return pv;
|
---|
2099 | }
|
---|
2100 |
|
---|
2101 |
|
---|
2102 | /** @copydoc PDMDEVHLP::pfnMMHeapFree */
|
---|
2103 | static DECLCALLBACK(void) pdmR3DevHlp_MMHeapFree(PPDMDEVINS pDevIns, void *pv)
|
---|
2104 | {
|
---|
2105 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2106 | LogFlow(("pdmR3DevHlp_MMHeapFree: caller='%s'/%d: pv=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pv));
|
---|
2107 |
|
---|
2108 | MMR3HeapFree(pv);
|
---|
2109 |
|
---|
2110 | LogFlow(("pdmR3DevHlp_MMHeapAlloc: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
2111 | }
|
---|
2112 |
|
---|
2113 |
|
---|
2114 | /** @copydoc PDMDEVHLP::pfnVMSetError */
|
---|
2115 | static DECLCALLBACK(int) pdmR3DevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
|
---|
2116 | {
|
---|
2117 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2118 | va_list args;
|
---|
2119 | va_start(args, pszFormat);
|
---|
2120 | int rc2 = VMSetErrorV(pDevIns->Internal.s.pVMHC, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
|
---|
2121 | va_end(args);
|
---|
2122 | return rc;
|
---|
2123 | }
|
---|
2124 |
|
---|
2125 |
|
---|
2126 | /** @copydoc PDMDEVHLP::pfnVMSetErrorV */
|
---|
2127 | static DECLCALLBACK(int) pdmR3DevHlp_VMSetErrorV(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
|
---|
2128 | {
|
---|
2129 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2130 | int rc2 = VMSetErrorV(pDevIns->Internal.s.pVMHC, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
|
---|
2131 | return rc;
|
---|
2132 | }
|
---|
2133 |
|
---|
2134 |
|
---|
2135 | /** @copydoc PDMDEVHLP::pfnVMSetRuntimeError */
|
---|
2136 | static DECLCALLBACK(int) pdmR3DevHlp_VMSetRuntimeError(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...)
|
---|
2137 | {
|
---|
2138 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2139 | va_list args;
|
---|
2140 | va_start(args, pszFormat);
|
---|
2141 | int rc = VMSetRuntimeErrorV(pDevIns->Internal.s.pVMHC, fFatal, pszErrorID, pszFormat, args);
|
---|
2142 | va_end(args);
|
---|
2143 | return rc;
|
---|
2144 | }
|
---|
2145 |
|
---|
2146 |
|
---|
2147 | /** @copydoc PDMDEVHLP::pfnVMSetRuntimeErrorV */
|
---|
2148 | static DECLCALLBACK(int) pdmR3DevHlp_VMSetRuntimeErrorV(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list va)
|
---|
2149 | {
|
---|
2150 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2151 | int rc = VMSetRuntimeErrorV(pDevIns->Internal.s.pVMHC, fFatal, pszErrorID, pszFormat, va);
|
---|
2152 | return rc;
|
---|
2153 | }
|
---|
2154 |
|
---|
2155 |
|
---|
2156 | /** @copydoc PDMDEVHLP::pfnAssertEMT */
|
---|
2157 | static DECLCALLBACK(bool) pdmR3DevHlp_AssertEMT(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction)
|
---|
2158 | {
|
---|
2159 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2160 | if (VM_IS_EMT(pDevIns->Internal.s.pVMHC))
|
---|
2161 | return true;
|
---|
2162 |
|
---|
2163 | char szMsg[100];
|
---|
2164 | RTStrPrintf(szMsg, sizeof(szMsg), "AssertEMT '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance);
|
---|
2165 | AssertMsg1(szMsg, iLine, pszFile, pszFunction);
|
---|
2166 | AssertBreakpoint();
|
---|
2167 | return false;
|
---|
2168 | }
|
---|
2169 |
|
---|
2170 |
|
---|
2171 | /** @copydoc PDMDEVHLP::pfnAssertOther */
|
---|
2172 | static DECLCALLBACK(bool) pdmR3DevHlp_AssertOther(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction)
|
---|
2173 | {
|
---|
2174 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2175 | if (!VM_IS_EMT(pDevIns->Internal.s.pVMHC))
|
---|
2176 | return true;
|
---|
2177 |
|
---|
2178 | char szMsg[100];
|
---|
2179 | RTStrPrintf(szMsg, sizeof(szMsg), "AssertOther '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance);
|
---|
2180 | AssertMsg1(szMsg, iLine, pszFile, pszFunction);
|
---|
2181 | AssertBreakpoint();
|
---|
2182 | return false;
|
---|
2183 | }
|
---|
2184 |
|
---|
2185 |
|
---|
2186 | /** @copydoc PDMDEVHLP::pfnDBGFStopV */
|
---|
2187 | static DECLCALLBACK(int) pdmR3DevHlp_DBGFStopV(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction, const char *pszFormat, va_list args)
|
---|
2188 | {
|
---|
2189 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2190 | LogFlow(("pdmR3DevHlp_DBGFStopV: caller='%s'/%d: pszFile=%p:{%s} iLine=%d pszFunction=%p:{%s} pszFormat=%p:{%s} (%N)\n",
|
---|
2191 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pszFile, pszFile, iLine, pszFunction, pszFunction, pszFormat, pszFormat, pszFormat, &args));
|
---|
2192 |
|
---|
2193 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
2194 | VM_ASSERT_EMT(pVM);
|
---|
2195 | int rc = DBGFR3EventSrcV(pVM, DBGFEVENT_DEV_STOP, pszFile, iLine, pszFunction, pszFormat, args);
|
---|
2196 |
|
---|
2197 | LogFlow(("pdmR3DevHlp_DBGFStopV: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2198 | return rc;
|
---|
2199 | }
|
---|
2200 |
|
---|
2201 |
|
---|
2202 | /** @copydoc PDMDEVHLP::pfnDBGFInfoRegister */
|
---|
2203 | static DECLCALLBACK(int) pdmR3DevHlp_DBGFInfoRegister(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler)
|
---|
2204 | {
|
---|
2205 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2206 | LogFlow(("pdmR3DevHlp_DBGFInfoRegister: caller='%s'/%d: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p\n",
|
---|
2207 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pszName, pszName, pszDesc, pszDesc, pfnHandler));
|
---|
2208 |
|
---|
2209 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
2210 | VM_ASSERT_EMT(pVM);
|
---|
2211 | int rc = DBGFR3InfoRegisterDevice(pVM, pszName, pszDesc, pfnHandler, pDevIns);
|
---|
2212 |
|
---|
2213 | LogFlow(("pdmR3DevHlp_DBGFInfoRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2214 | return rc;
|
---|
2215 | }
|
---|
2216 |
|
---|
2217 |
|
---|
2218 | /** @copydoc PDMDEVHLP::pfnSTAMRegister */
|
---|
2219 | static DECLCALLBACK(void) pdmR3DevHlp_STAMRegister(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
|
---|
2220 | {
|
---|
2221 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2222 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
2223 | VM_ASSERT_EMT(pVM);
|
---|
2224 |
|
---|
2225 | STAM_REG(pVM, pvSample, enmType, pszName, enmUnit, pszDesc);
|
---|
2226 | NOREF(pVM);
|
---|
2227 | }
|
---|
2228 |
|
---|
2229 |
|
---|
2230 |
|
---|
2231 | /** @copydoc PDMDEVHLP::pfnSTAMRegisterF */
|
---|
2232 | static DECLCALLBACK(void) pdmR3DevHlp_STAMRegisterF(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
|
---|
2233 | STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...)
|
---|
2234 | {
|
---|
2235 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2236 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
2237 | VM_ASSERT_EMT(pVM);
|
---|
2238 |
|
---|
2239 | va_list args;
|
---|
2240 | va_start(args, pszName);
|
---|
2241 | int rc = STAMR3RegisterV(pVM, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);
|
---|
2242 | va_end(args);
|
---|
2243 | AssertRC(rc);
|
---|
2244 |
|
---|
2245 | NOREF(pVM);
|
---|
2246 | }
|
---|
2247 |
|
---|
2248 |
|
---|
2249 | /** @copydoc PDMDEVHLP::pfnSTAMRegisterV */
|
---|
2250 | static DECLCALLBACK(void) pdmR3DevHlp_STAMRegisterV(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
|
---|
2251 | STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args)
|
---|
2252 | {
|
---|
2253 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2254 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
2255 | VM_ASSERT_EMT(pVM);
|
---|
2256 |
|
---|
2257 | int rc = STAMR3RegisterV(pVM, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);
|
---|
2258 | AssertRC(rc);
|
---|
2259 |
|
---|
2260 | NOREF(pVM);
|
---|
2261 | }
|
---|
2262 |
|
---|
2263 |
|
---|
2264 | /** @copydoc PDMDEVHLP::pfnRTCRegister */
|
---|
2265 | static DECLCALLBACK(int) pdmR3DevHlp_RTCRegister(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp)
|
---|
2266 | {
|
---|
2267 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2268 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
2269 | LogFlow(("pdmR3DevHlp_RTCRegister: caller='%s'/%d: pRtcReg=%p:{.u32Version=%#x, .pfnWrite=%p, .pfnRead=%p} ppRtcHlp=%p\n",
|
---|
2270 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pRtcReg, pRtcReg->u32Version, pRtcReg->pfnWrite,
|
---|
2271 | pRtcReg->pfnWrite, ppRtcHlp));
|
---|
2272 |
|
---|
2273 | /*
|
---|
2274 | * Validate input.
|
---|
2275 | */
|
---|
2276 | if (pRtcReg->u32Version != PDM_RTCREG_VERSION)
|
---|
2277 | {
|
---|
2278 | AssertMsgFailed(("u32Version=%#x expected %#x\n", pRtcReg->u32Version,
|
---|
2279 | PDM_RTCREG_VERSION));
|
---|
2280 | LogFlow(("pdmR3DevHlp_RTCRegister: caller='%s'/%d: returns %Vrc (version)\n",
|
---|
2281 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2282 | return VERR_INVALID_PARAMETER;
|
---|
2283 | }
|
---|
2284 | if ( !pRtcReg->pfnWrite
|
---|
2285 | || !pRtcReg->pfnRead)
|
---|
2286 | {
|
---|
2287 | Assert(pRtcReg->pfnWrite);
|
---|
2288 | Assert(pRtcReg->pfnRead);
|
---|
2289 | LogFlow(("pdmR3DevHlp_RTCRegister: caller='%s'/%d: returns %Vrc (callbacks)\n",
|
---|
2290 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2291 | return VERR_INVALID_PARAMETER;
|
---|
2292 | }
|
---|
2293 |
|
---|
2294 | if (!ppRtcHlp)
|
---|
2295 | {
|
---|
2296 | Assert(ppRtcHlp);
|
---|
2297 | LogFlow(("pdmR3DevHlp_RTCRegister: caller='%s'/%d: returns %Vrc (ppRtcHlp)\n",
|
---|
2298 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2299 | return VERR_INVALID_PARAMETER;
|
---|
2300 | }
|
---|
2301 |
|
---|
2302 | /*
|
---|
2303 | * Only one DMA device.
|
---|
2304 | */
|
---|
2305 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
2306 | if (pVM->pdm.s.pRtc)
|
---|
2307 | {
|
---|
2308 | AssertMsgFailed(("Only one RTC device is supported!\n"));
|
---|
2309 | LogFlow(("pdmR3DevHlp_RTCRegister: caller='%s'/%d: returns %Vrc\n",
|
---|
2310 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2311 | return VERR_INVALID_PARAMETER;
|
---|
2312 | }
|
---|
2313 |
|
---|
2314 | /*
|
---|
2315 | * Allocate and initialize pci bus structure.
|
---|
2316 | */
|
---|
2317 | int rc = VINF_SUCCESS;
|
---|
2318 | PPDMRTC pRtc = (PPDMRTC)MMR3HeapAlloc(pDevIns->Internal.s.pVMHC, MM_TAG_PDM_DEVICE, sizeof(*pRtc));
|
---|
2319 | if (pRtc)
|
---|
2320 | {
|
---|
2321 | pRtc->pDevIns = pDevIns;
|
---|
2322 | pRtc->Reg = *pRtcReg;
|
---|
2323 | pVM->pdm.s.pRtc = pRtc;
|
---|
2324 |
|
---|
2325 | /* set the helper pointer. */
|
---|
2326 | *ppRtcHlp = &g_pdmR3DevRtcHlp;
|
---|
2327 | Log(("PDM: Registered RTC device '%s'/%d pDevIns=%p\n",
|
---|
2328 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns));
|
---|
2329 | }
|
---|
2330 | else
|
---|
2331 | rc = VERR_NO_MEMORY;
|
---|
2332 |
|
---|
2333 | LogFlow(("pdmR3DevHlp_RTCRegister: caller='%s'/%d: returns %Vrc\n",
|
---|
2334 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2335 | return rc;
|
---|
2336 | }
|
---|
2337 |
|
---|
2338 |
|
---|
2339 | /** @copydoc PDMDEVHLP::pfnPDMQueueCreate */
|
---|
2340 | static DECLCALLBACK(int) pdmR3DevHlp_PDMQueueCreate(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
|
---|
2341 | PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue)
|
---|
2342 | {
|
---|
2343 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2344 | LogFlow(("pdmR3DevHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%#x cItems=%#x cMilliesInterval=%u pfnCallback=%p fGCEnabled=%RTbool ppQueue=%p\n",
|
---|
2345 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, ppQueue));
|
---|
2346 |
|
---|
2347 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
2348 | VM_ASSERT_EMT(pVM);
|
---|
2349 | int rc = PDMR3QueueCreateDevice(pVM, pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, ppQueue);
|
---|
2350 |
|
---|
2351 | LogFlow(("pdmR3DevHlp_PDMQueueCreate: caller='%s'/%d: returns %Vrc *ppQueue=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc, *ppQueue));
|
---|
2352 | return rc;
|
---|
2353 | }
|
---|
2354 |
|
---|
2355 |
|
---|
2356 | /** @copydoc PDMDEVHLP::pfnCritSectInit */
|
---|
2357 | static DECLCALLBACK(int) pdmR3DevHlp_CritSectInit(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName)
|
---|
2358 | {
|
---|
2359 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2360 | LogFlow(("pdmR3DevHlp_CritSectInit: caller='%s'/%d: pCritSect=%p pszName=%p:{%s}\n",
|
---|
2361 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pCritSect, pszName, pszName));
|
---|
2362 |
|
---|
2363 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
2364 | VM_ASSERT_EMT(pVM);
|
---|
2365 | int rc = pdmR3CritSectInitDevice(pVM, pDevIns, pCritSect, pszName);
|
---|
2366 |
|
---|
2367 | LogFlow(("pdmR3DevHlp_CritSectInit: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2368 | return rc;
|
---|
2369 | }
|
---|
2370 |
|
---|
2371 |
|
---|
2372 | /** @copydoc PDMDEVHLP::pfnUTCNow */
|
---|
2373 | static DECLCALLBACK(PRTTIMESPEC) pdmR3DevHlp_UTCNow(PPDMDEVINS pDevIns, PRTTIMESPEC pTime)
|
---|
2374 | {
|
---|
2375 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2376 | LogFlow(("pdmR3DevHlp_UTCNow: caller='%s'/%d: pTime=%p\n",
|
---|
2377 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pTime));
|
---|
2378 |
|
---|
2379 | pTime = TMR3UTCNow(pDevIns->Internal.s.pVMHC, pTime);
|
---|
2380 |
|
---|
2381 | LogFlow(("pdmR3DevHlp_UTCNow: caller='%s'/%d: returns %RU64\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, RTTimeSpecGetNano(pTime)));
|
---|
2382 | return pTime;
|
---|
2383 | }
|
---|
2384 |
|
---|
2385 |
|
---|
2386 | /** @copydoc PDMDEVHLP::pfnGetVM */
|
---|
2387 | static DECLCALLBACK(PVM) pdmR3DevHlp_GetVM(PPDMDEVINS pDevIns)
|
---|
2388 | {
|
---|
2389 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2390 | LogFlow(("pdmR3DevHlp_GetVM: caller='%s'/%d: returns %p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns->Internal.s.pVMHC));
|
---|
2391 | return pDevIns->Internal.s.pVMHC;
|
---|
2392 | }
|
---|
2393 |
|
---|
2394 |
|
---|
2395 | /** @copydoc PDMDEVHLP::pfnPCIBusRegister */
|
---|
2396 | static DECLCALLBACK(int) pdmR3DevHlp_PCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3)
|
---|
2397 | {
|
---|
2398 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2399 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
2400 | VM_ASSERT_EMT(pVM);
|
---|
2401 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: pPciBusReg=%p:{.u32Version=%#x, .pfnRegisterHC=%p, .pfnIORegionRegisterHC=%p, .pfnSetIrqHC=%p, "
|
---|
2402 | ".pfnSaveExecHC=%p, .pfnLoadExecHC=%p, .pfnFakePCIBIOSHC=%p, .pszSetIrqGC=%p:{%s}} ppPciHlpR3=%p\n",
|
---|
2403 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pPciBusReg, pPciBusReg->u32Version, pPciBusReg->pfnRegisterHC,
|
---|
2404 | pPciBusReg->pfnIORegionRegisterHC, pPciBusReg->pfnSetIrqHC, pPciBusReg->pfnSaveExecHC, pPciBusReg->pfnLoadExecHC,
|
---|
2405 | pPciBusReg->pfnFakePCIBIOSHC, pPciBusReg->pszSetIrqGC, pPciBusReg->pszSetIrqGC, ppPciHlpR3));
|
---|
2406 |
|
---|
2407 | /*
|
---|
2408 | * Validate the structure.
|
---|
2409 | */
|
---|
2410 | if (pPciBusReg->u32Version != PDM_PCIBUSREG_VERSION)
|
---|
2411 | {
|
---|
2412 | AssertMsgFailed(("u32Version=%#x expected %#x\n", pPciBusReg->u32Version, PDM_PCIBUSREG_VERSION));
|
---|
2413 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Vrc (version)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2414 | return VERR_INVALID_PARAMETER;
|
---|
2415 | }
|
---|
2416 | if ( !pPciBusReg->pfnRegisterHC
|
---|
2417 | || !pPciBusReg->pfnIORegionRegisterHC
|
---|
2418 | || !pPciBusReg->pfnSetIrqHC
|
---|
2419 | || !pPciBusReg->pfnSaveExecHC
|
---|
2420 | || !pPciBusReg->pfnLoadExecHC
|
---|
2421 | || !pPciBusReg->pfnFakePCIBIOSHC)
|
---|
2422 | {
|
---|
2423 | Assert(pPciBusReg->pfnRegisterHC);
|
---|
2424 | Assert(pPciBusReg->pfnIORegionRegisterHC);
|
---|
2425 | Assert(pPciBusReg->pfnSetIrqHC);
|
---|
2426 | Assert(pPciBusReg->pfnSaveExecHC);
|
---|
2427 | Assert(pPciBusReg->pfnLoadExecHC);
|
---|
2428 | Assert(pPciBusReg->pfnFakePCIBIOSHC);
|
---|
2429 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Vrc (HC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2430 | return VERR_INVALID_PARAMETER;
|
---|
2431 | }
|
---|
2432 | if ( pPciBusReg->pszSetIrqGC
|
---|
2433 | && !VALID_PTR(pPciBusReg->pszSetIrqGC))
|
---|
2434 | {
|
---|
2435 | Assert(VALID_PTR(pPciBusReg->pszSetIrqGC));
|
---|
2436 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Vrc (GC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2437 | return VERR_INVALID_PARAMETER;
|
---|
2438 | }
|
---|
2439 | if ( pPciBusReg->pszSetIrqR0
|
---|
2440 | && !VALID_PTR(pPciBusReg->pszSetIrqR0))
|
---|
2441 | {
|
---|
2442 | Assert(VALID_PTR(pPciBusReg->pszSetIrqR0));
|
---|
2443 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Vrc (GC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2444 | return VERR_INVALID_PARAMETER;
|
---|
2445 | }
|
---|
2446 | if (!ppPciHlpR3)
|
---|
2447 | {
|
---|
2448 | Assert(ppPciHlpR3);
|
---|
2449 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Vrc (ppPciHlpR3)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2450 | return VERR_INVALID_PARAMETER;
|
---|
2451 | }
|
---|
2452 |
|
---|
2453 | /*
|
---|
2454 | * Find free PCI bus entry.
|
---|
2455 | */
|
---|
2456 | unsigned iBus = 0;
|
---|
2457 | for (iBus = 0; iBus < ELEMENTS(pVM->pdm.s.aPciBuses); iBus++)
|
---|
2458 | if (!pVM->pdm.s.aPciBuses[iBus].pDevInsR3)
|
---|
2459 | break;
|
---|
2460 | if (iBus >= ELEMENTS(pVM->pdm.s.aPciBuses))
|
---|
2461 | {
|
---|
2462 | AssertMsgFailed(("Too many PCI buses. Max=%u\n", ELEMENTS(pVM->pdm.s.aPciBuses)));
|
---|
2463 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Vrc (pci bus)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2464 | return VERR_INVALID_PARAMETER;
|
---|
2465 | }
|
---|
2466 | PPDMPCIBUS pPciBus = &pVM->pdm.s.aPciBuses[iBus];
|
---|
2467 |
|
---|
2468 | /*
|
---|
2469 | * Resolve and init the GC bits.
|
---|
2470 | */
|
---|
2471 | if (pPciBusReg->pszSetIrqGC)
|
---|
2472 | {
|
---|
2473 | int rc = PDMR3GetSymbolGCLazy(pVM, pDevIns->pDevReg->szGCMod, pPciBusReg->pszSetIrqGC, &pPciBus->pfnSetIrqGC);
|
---|
2474 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szGCMod, pPciBusReg->pszSetIrqGC, rc));
|
---|
2475 | if (VBOX_FAILURE(rc))
|
---|
2476 | {
|
---|
2477 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2478 | return rc;
|
---|
2479 | }
|
---|
2480 | pPciBus->pDevInsGC = PDMDEVINS_2_GCPTR(pDevIns);
|
---|
2481 | }
|
---|
2482 | else
|
---|
2483 | {
|
---|
2484 | pPciBus->pfnSetIrqGC = 0;
|
---|
2485 | pPciBus->pDevInsGC = 0;
|
---|
2486 | }
|
---|
2487 |
|
---|
2488 | /*
|
---|
2489 | * Resolve and init the R0 bits.
|
---|
2490 | */
|
---|
2491 | if ( HWACCMR3IsAllowed(pVM)
|
---|
2492 | && pPciBusReg->pszSetIrqR0)
|
---|
2493 | {
|
---|
2494 | int rc = PDMR3GetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pPciBusReg->pszSetIrqR0, &pPciBus->pfnSetIrqR0);
|
---|
2495 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szR0Mod, pPciBusReg->pszSetIrqR0, rc));
|
---|
2496 | if (VBOX_FAILURE(rc))
|
---|
2497 | {
|
---|
2498 | LogFlow(("pdmR3DevHlp_PCIRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2499 | return rc;
|
---|
2500 | }
|
---|
2501 | pPciBus->pDevInsR0 = MMHyperR3ToR0(pVM, pDevIns);
|
---|
2502 | }
|
---|
2503 | else
|
---|
2504 | {
|
---|
2505 | pPciBus->pfnSetIrqR0 = 0;
|
---|
2506 | pPciBus->pDevInsR0 = 0;
|
---|
2507 | }
|
---|
2508 |
|
---|
2509 | /*
|
---|
2510 | * Init the HC bits.
|
---|
2511 | */
|
---|
2512 | pPciBus->iBus = iBus;
|
---|
2513 | pPciBus->pDevInsR3 = pDevIns;
|
---|
2514 | pPciBus->pfnRegisterR3 = pPciBusReg->pfnRegisterHC;
|
---|
2515 | pPciBus->pfnIORegionRegisterR3 = pPciBusReg->pfnIORegionRegisterHC;
|
---|
2516 | pPciBus->pfnSetConfigCallbacksR3 = pPciBusReg->pfnSetConfigCallbacksHC;
|
---|
2517 | pPciBus->pfnSetIrqR3 = pPciBusReg->pfnSetIrqHC;
|
---|
2518 | pPciBus->pfnSaveExecR3 = pPciBusReg->pfnSaveExecHC;
|
---|
2519 | pPciBus->pfnLoadExecR3 = pPciBusReg->pfnLoadExecHC;
|
---|
2520 | pPciBus->pfnFakePCIBIOSR3 = pPciBusReg->pfnFakePCIBIOSHC;
|
---|
2521 |
|
---|
2522 | Log(("PDM: Registered PCI bus device '%s'/%d pDevIns=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns));
|
---|
2523 |
|
---|
2524 | /* set the helper pointer and return. */
|
---|
2525 | *ppPciHlpR3 = &g_pdmR3DevPciHlp;
|
---|
2526 | LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VINF_SUCCESS));
|
---|
2527 | return VINF_SUCCESS;
|
---|
2528 | }
|
---|
2529 |
|
---|
2530 |
|
---|
2531 | /** @copydoc PDMDEVHLP::pfnPICRegister */
|
---|
2532 | static DECLCALLBACK(int) pdmR3DevHlp_PICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3)
|
---|
2533 | {
|
---|
2534 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2535 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
2536 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: pPicReg=%p:{.u32Version=%#x, .pfnSetIrqHC=%p, .pfnGetInterruptHC=%p, .pszGetIrqGC=%p:{%s}, .pszGetInterruptGC=%p:{%s}} ppPicHlpR3=%p\n",
|
---|
2537 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pPicReg, pPicReg->u32Version, pPicReg->pfnSetIrqHC, pPicReg->pfnGetInterruptHC,
|
---|
2538 | pPicReg->pszSetIrqGC, pPicReg->pszSetIrqGC, pPicReg->pszGetInterruptGC, pPicReg->pszGetInterruptGC, ppPicHlpR3));
|
---|
2539 |
|
---|
2540 | /*
|
---|
2541 | * Validate input.
|
---|
2542 | */
|
---|
2543 | if (pPicReg->u32Version != PDM_PICREG_VERSION)
|
---|
2544 | {
|
---|
2545 | AssertMsgFailed(("u32Version=%#x expected %#x\n", pPicReg->u32Version, PDM_PICREG_VERSION));
|
---|
2546 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Vrc (version)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2547 | return VERR_INVALID_PARAMETER;
|
---|
2548 | }
|
---|
2549 | if ( !pPicReg->pfnSetIrqHC
|
---|
2550 | || !pPicReg->pfnGetInterruptHC)
|
---|
2551 | {
|
---|
2552 | Assert(pPicReg->pfnSetIrqHC);
|
---|
2553 | Assert(pPicReg->pfnGetInterruptHC);
|
---|
2554 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Vrc (HC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2555 | return VERR_INVALID_PARAMETER;
|
---|
2556 | }
|
---|
2557 | if ( ( pPicReg->pszSetIrqGC
|
---|
2558 | || pPicReg->pszGetInterruptGC)
|
---|
2559 | && ( !VALID_PTR(pPicReg->pszSetIrqGC)
|
---|
2560 | || !VALID_PTR(pPicReg->pszGetInterruptGC))
|
---|
2561 | )
|
---|
2562 | {
|
---|
2563 | Assert(VALID_PTR(pPicReg->pszSetIrqGC));
|
---|
2564 | Assert(VALID_PTR(pPicReg->pszGetInterruptGC));
|
---|
2565 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Vrc (GC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2566 | return VERR_INVALID_PARAMETER;
|
---|
2567 | }
|
---|
2568 | if ( pPicReg->pszSetIrqGC
|
---|
2569 | && !(pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_GC))
|
---|
2570 | {
|
---|
2571 | Assert(pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_GC);
|
---|
2572 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Vrc (GC flag)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2573 | return VERR_INVALID_PARAMETER;
|
---|
2574 | }
|
---|
2575 | if ( pPicReg->pszSetIrqR0
|
---|
2576 | && !(pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_R0))
|
---|
2577 | {
|
---|
2578 | Assert(pDevIns->pDevReg->fFlags & PDM_DEVREG_FLAGS_R0);
|
---|
2579 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Vrc (R0 flag)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2580 | return VERR_INVALID_PARAMETER;
|
---|
2581 | }
|
---|
2582 | if (!ppPicHlpR3)
|
---|
2583 | {
|
---|
2584 | Assert(ppPicHlpR3);
|
---|
2585 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Vrc (ppPicHlpR3)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2586 | return VERR_INVALID_PARAMETER;
|
---|
2587 | }
|
---|
2588 |
|
---|
2589 | /*
|
---|
2590 | * Only one PIC device.
|
---|
2591 | */
|
---|
2592 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
2593 | if (pVM->pdm.s.Pic.pDevInsR3)
|
---|
2594 | {
|
---|
2595 | AssertMsgFailed(("Only one pic device is supported!\n"));
|
---|
2596 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2597 | return VERR_INVALID_PARAMETER;
|
---|
2598 | }
|
---|
2599 |
|
---|
2600 | /*
|
---|
2601 | * GC stuff.
|
---|
2602 | */
|
---|
2603 | if (pPicReg->pszSetIrqGC)
|
---|
2604 | {
|
---|
2605 | int rc = PDMR3GetSymbolGCLazy(pVM, pDevIns->pDevReg->szGCMod, pPicReg->pszSetIrqGC, &pVM->pdm.s.Pic.pfnSetIrqGC);
|
---|
2606 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szGCMod, pPicReg->pszSetIrqGC, rc));
|
---|
2607 | if (VBOX_SUCCESS(rc))
|
---|
2608 | {
|
---|
2609 | rc = PDMR3GetSymbolGCLazy(pVM, pDevIns->pDevReg->szGCMod, pPicReg->pszGetInterruptGC, &pVM->pdm.s.Pic.pfnGetInterruptGC);
|
---|
2610 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szGCMod, pPicReg->pszGetInterruptGC, rc));
|
---|
2611 | }
|
---|
2612 | if (VBOX_FAILURE(rc))
|
---|
2613 | {
|
---|
2614 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2615 | return rc;
|
---|
2616 | }
|
---|
2617 | pVM->pdm.s.Pic.pDevInsGC = PDMDEVINS_2_GCPTR(pDevIns);
|
---|
2618 | }
|
---|
2619 | else
|
---|
2620 | {
|
---|
2621 | pVM->pdm.s.Pic.pDevInsGC = 0;
|
---|
2622 | pVM->pdm.s.Pic.pfnSetIrqGC = 0;
|
---|
2623 | pVM->pdm.s.Pic.pfnGetInterruptGC = 0;
|
---|
2624 | }
|
---|
2625 |
|
---|
2626 | /*
|
---|
2627 | * R0 stuff.
|
---|
2628 | */
|
---|
2629 | if ( HWACCMR3IsAllowed(pVM)
|
---|
2630 | && pPicReg->pszSetIrqR0)
|
---|
2631 | {
|
---|
2632 | int rc = PDMR3GetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pPicReg->pszSetIrqR0, &pVM->pdm.s.Pic.pfnSetIrqR0);
|
---|
2633 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szR0Mod, pPicReg->pszSetIrqR0, rc));
|
---|
2634 | if (VBOX_SUCCESS(rc))
|
---|
2635 | {
|
---|
2636 | rc = PDMR3GetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pPicReg->pszGetInterruptR0, &pVM->pdm.s.Pic.pfnGetInterruptR0);
|
---|
2637 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szR0Mod, pPicReg->pszGetInterruptR0, rc));
|
---|
2638 | }
|
---|
2639 | if (VBOX_FAILURE(rc))
|
---|
2640 | {
|
---|
2641 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2642 | return rc;
|
---|
2643 | }
|
---|
2644 | pVM->pdm.s.Pic.pDevInsR0 = MMHyperR3ToR0(pVM, pDevIns);
|
---|
2645 | Assert(pVM->pdm.s.Pic.pDevInsR0);
|
---|
2646 | }
|
---|
2647 | else
|
---|
2648 | {
|
---|
2649 | pVM->pdm.s.Pic.pfnSetIrqR0 = 0;
|
---|
2650 | pVM->pdm.s.Pic.pfnGetInterruptR0 = 0;
|
---|
2651 | pVM->pdm.s.Pic.pDevInsR0 = 0;
|
---|
2652 | }
|
---|
2653 |
|
---|
2654 | /*
|
---|
2655 | * HC stuff.
|
---|
2656 | */
|
---|
2657 | pVM->pdm.s.Pic.pDevInsR3 = pDevIns;
|
---|
2658 | pVM->pdm.s.Pic.pfnSetIrqR3 = pPicReg->pfnSetIrqHC;
|
---|
2659 | pVM->pdm.s.Pic.pfnGetInterruptR3 = pPicReg->pfnGetInterruptHC;
|
---|
2660 | Log(("PDM: Registered PIC device '%s'/%d pDevIns=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns));
|
---|
2661 |
|
---|
2662 | /* set the helper pointer and return. */
|
---|
2663 | *ppPicHlpR3 = &g_pdmR3DevPicHlp;
|
---|
2664 | LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VINF_SUCCESS));
|
---|
2665 | return VINF_SUCCESS;
|
---|
2666 | }
|
---|
2667 |
|
---|
2668 |
|
---|
2669 | /** @copydoc PDMDEVHLP::pfnAPICRegister */
|
---|
2670 | static DECLCALLBACK(int) pdmR3DevHlp_APICRegister(PPDMDEVINS pDevIns, PPDMAPICREG pApicReg, PCPDMAPICHLPR3 *ppApicHlpR3)
|
---|
2671 | {
|
---|
2672 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2673 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
2674 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: pApicReg=%p:{.u32Version=%#x, .pfnGetInterruptHC=%p, .pfnSetBaseHC=%p, .pfnGetBaseHC=%p, "
|
---|
2675 | ".pfnSetTPRHC=%p, .pfnGetTPRHC=%p, .pfnBusDeliverHC=%p, pszGetInterruptGC=%p:{%s}, pszSetBaseGC=%p:{%s}, pszGetBaseGC=%p:{%s}, "
|
---|
2676 | ".pszSetTPRGC=%p:{%s}, .pszGetTPRGC=%p:{%s}, .pszBusDeliverGC=%p:{%s}} ppApicHlpR3=%p\n",
|
---|
2677 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pApicReg, pApicReg->u32Version, pApicReg->pfnGetInterruptHC, pApicReg->pfnSetBaseHC,
|
---|
2678 | pApicReg->pfnGetBaseHC, pApicReg->pfnSetTPRHC, pApicReg->pfnGetTPRHC, pApicReg->pfnBusDeliverHC, pApicReg->pszGetInterruptGC,
|
---|
2679 | pApicReg->pszGetInterruptGC, pApicReg->pszSetBaseGC, pApicReg->pszSetBaseGC, pApicReg->pszGetBaseGC, pApicReg->pszGetBaseGC,
|
---|
2680 | pApicReg->pszSetTPRGC, pApicReg->pszSetTPRGC, pApicReg->pszGetTPRGC, pApicReg->pszGetTPRGC, pApicReg->pszBusDeliverGC,
|
---|
2681 | pApicReg->pszBusDeliverGC, ppApicHlpR3));
|
---|
2682 |
|
---|
2683 | /*
|
---|
2684 | * Validate input.
|
---|
2685 | */
|
---|
2686 | if (pApicReg->u32Version != PDM_APICREG_VERSION)
|
---|
2687 | {
|
---|
2688 | AssertMsgFailed(("u32Version=%#x expected %#x\n", pApicReg->u32Version, PDM_APICREG_VERSION));
|
---|
2689 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Vrc (version)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2690 | return VERR_INVALID_PARAMETER;
|
---|
2691 | }
|
---|
2692 | if ( !pApicReg->pfnGetInterruptHC
|
---|
2693 | || !pApicReg->pfnSetBaseHC
|
---|
2694 | || !pApicReg->pfnGetBaseHC
|
---|
2695 | || !pApicReg->pfnSetTPRHC
|
---|
2696 | || !pApicReg->pfnGetTPRHC
|
---|
2697 | || !pApicReg->pfnBusDeliverHC)
|
---|
2698 | {
|
---|
2699 | Assert(pApicReg->pfnGetInterruptHC);
|
---|
2700 | Assert(pApicReg->pfnSetBaseHC);
|
---|
2701 | Assert(pApicReg->pfnGetBaseHC);
|
---|
2702 | Assert(pApicReg->pfnSetTPRHC);
|
---|
2703 | Assert(pApicReg->pfnGetTPRHC);
|
---|
2704 | Assert(pApicReg->pfnBusDeliverHC);
|
---|
2705 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Vrc (HC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2706 | return VERR_INVALID_PARAMETER;
|
---|
2707 | }
|
---|
2708 | if ( ( pApicReg->pszGetInterruptGC
|
---|
2709 | || pApicReg->pszSetBaseGC
|
---|
2710 | || pApicReg->pszGetBaseGC
|
---|
2711 | || pApicReg->pszSetTPRGC
|
---|
2712 | || pApicReg->pszGetTPRGC
|
---|
2713 | || pApicReg->pszBusDeliverGC)
|
---|
2714 | && ( !VALID_PTR(pApicReg->pszGetInterruptGC)
|
---|
2715 | || !VALID_PTR(pApicReg->pszSetBaseGC)
|
---|
2716 | || !VALID_PTR(pApicReg->pszGetBaseGC)
|
---|
2717 | || !VALID_PTR(pApicReg->pszSetTPRGC)
|
---|
2718 | || !VALID_PTR(pApicReg->pszGetTPRGC)
|
---|
2719 | || !VALID_PTR(pApicReg->pszBusDeliverGC))
|
---|
2720 | )
|
---|
2721 | {
|
---|
2722 | Assert(VALID_PTR(pApicReg->pszGetInterruptGC));
|
---|
2723 | Assert(VALID_PTR(pApicReg->pszSetBaseGC));
|
---|
2724 | Assert(VALID_PTR(pApicReg->pszGetBaseGC));
|
---|
2725 | Assert(VALID_PTR(pApicReg->pszSetTPRGC));
|
---|
2726 | Assert(VALID_PTR(pApicReg->pszGetTPRGC));
|
---|
2727 | Assert(VALID_PTR(pApicReg->pszBusDeliverGC));
|
---|
2728 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Vrc (GC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2729 | return VERR_INVALID_PARAMETER;
|
---|
2730 | }
|
---|
2731 | if ( ( pApicReg->pszGetInterruptR0
|
---|
2732 | || pApicReg->pszSetBaseR0
|
---|
2733 | || pApicReg->pszGetBaseR0
|
---|
2734 | || pApicReg->pszSetTPRR0
|
---|
2735 | || pApicReg->pszGetTPRR0
|
---|
2736 | || pApicReg->pszBusDeliverR0)
|
---|
2737 | && ( !VALID_PTR(pApicReg->pszGetInterruptR0)
|
---|
2738 | || !VALID_PTR(pApicReg->pszSetBaseR0)
|
---|
2739 | || !VALID_PTR(pApicReg->pszGetBaseR0)
|
---|
2740 | || !VALID_PTR(pApicReg->pszSetTPRR0)
|
---|
2741 | || !VALID_PTR(pApicReg->pszGetTPRR0)
|
---|
2742 | || !VALID_PTR(pApicReg->pszBusDeliverR0))
|
---|
2743 | )
|
---|
2744 | {
|
---|
2745 | Assert(VALID_PTR(pApicReg->pszGetInterruptR0));
|
---|
2746 | Assert(VALID_PTR(pApicReg->pszSetBaseR0));
|
---|
2747 | Assert(VALID_PTR(pApicReg->pszGetBaseR0));
|
---|
2748 | Assert(VALID_PTR(pApicReg->pszSetTPRR0));
|
---|
2749 | Assert(VALID_PTR(pApicReg->pszGetTPRR0));
|
---|
2750 | Assert(VALID_PTR(pApicReg->pszBusDeliverR0));
|
---|
2751 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Vrc (R0 callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2752 | return VERR_INVALID_PARAMETER;
|
---|
2753 | }
|
---|
2754 | if (!ppApicHlpR3)
|
---|
2755 | {
|
---|
2756 | Assert(ppApicHlpR3);
|
---|
2757 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Vrc (ppApicHlpR3)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2758 | return VERR_INVALID_PARAMETER;
|
---|
2759 | }
|
---|
2760 |
|
---|
2761 | /*
|
---|
2762 | * Only one APIC device. (malc: only in UP case actually)
|
---|
2763 | */
|
---|
2764 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
2765 | if (pVM->pdm.s.Apic.pDevInsR3)
|
---|
2766 | {
|
---|
2767 | AssertMsgFailed(("Only one apic device is supported!\n"));
|
---|
2768 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2769 | return VERR_INVALID_PARAMETER;
|
---|
2770 | }
|
---|
2771 |
|
---|
2772 | /*
|
---|
2773 | * Resolve & initialize the GC bits.
|
---|
2774 | */
|
---|
2775 | if (pApicReg->pszGetInterruptGC)
|
---|
2776 | {
|
---|
2777 | int rc = PDMR3GetSymbolGCLazy(pVM, pDevIns->pDevReg->szGCMod, pApicReg->pszGetInterruptGC, &pVM->pdm.s.Apic.pfnGetInterruptGC);
|
---|
2778 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szGCMod, pApicReg->pszGetInterruptGC, rc));
|
---|
2779 | if (RT_SUCCESS(rc))
|
---|
2780 | {
|
---|
2781 | rc = PDMR3GetSymbolGCLazy(pVM, pDevIns->pDevReg->szGCMod, pApicReg->pszSetBaseGC, &pVM->pdm.s.Apic.pfnSetBaseGC);
|
---|
2782 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szGCMod, pApicReg->pszSetBaseGC, rc));
|
---|
2783 | }
|
---|
2784 | if (RT_SUCCESS(rc))
|
---|
2785 | {
|
---|
2786 | rc = PDMR3GetSymbolGCLazy(pVM, pDevIns->pDevReg->szGCMod, pApicReg->pszGetBaseGC, &pVM->pdm.s.Apic.pfnGetBaseGC);
|
---|
2787 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szGCMod, pApicReg->pszGetBaseGC, rc));
|
---|
2788 | }
|
---|
2789 | if (RT_SUCCESS(rc))
|
---|
2790 | {
|
---|
2791 | rc = PDMR3GetSymbolGCLazy(pVM, pDevIns->pDevReg->szGCMod, pApicReg->pszSetTPRGC, &pVM->pdm.s.Apic.pfnSetTPRGC);
|
---|
2792 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szGCMod, pApicReg->pszSetTPRGC, rc));
|
---|
2793 | }
|
---|
2794 | if (RT_SUCCESS(rc))
|
---|
2795 | {
|
---|
2796 | rc = PDMR3GetSymbolGCLazy(pVM, pDevIns->pDevReg->szGCMod, pApicReg->pszGetTPRGC, &pVM->pdm.s.Apic.pfnGetTPRGC);
|
---|
2797 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szGCMod, pApicReg->pszGetTPRGC, rc));
|
---|
2798 | }
|
---|
2799 | if (RT_SUCCESS(rc))
|
---|
2800 | {
|
---|
2801 | rc = PDMR3GetSymbolGCLazy(pVM, pDevIns->pDevReg->szGCMod, pApicReg->pszBusDeliverGC, &pVM->pdm.s.Apic.pfnBusDeliverGC);
|
---|
2802 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szGCMod, pApicReg->pszBusDeliverGC, rc));
|
---|
2803 | }
|
---|
2804 | if (VBOX_FAILURE(rc))
|
---|
2805 | {
|
---|
2806 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2807 | return rc;
|
---|
2808 | }
|
---|
2809 | pVM->pdm.s.Apic.pDevInsGC = PDMDEVINS_2_GCPTR(pDevIns);
|
---|
2810 | }
|
---|
2811 | else
|
---|
2812 | {
|
---|
2813 | pVM->pdm.s.Apic.pDevInsGC = 0;
|
---|
2814 | pVM->pdm.s.Apic.pfnGetInterruptGC = 0;
|
---|
2815 | pVM->pdm.s.Apic.pfnSetBaseGC = 0;
|
---|
2816 | pVM->pdm.s.Apic.pfnGetBaseGC = 0;
|
---|
2817 | pVM->pdm.s.Apic.pfnSetTPRGC = 0;
|
---|
2818 | pVM->pdm.s.Apic.pfnGetTPRGC = 0;
|
---|
2819 | pVM->pdm.s.Apic.pfnBusDeliverGC = 0;
|
---|
2820 | }
|
---|
2821 |
|
---|
2822 | /*
|
---|
2823 | * Resolve & initialize the R0 bits.
|
---|
2824 | */
|
---|
2825 | if ( HWACCMR3IsAllowed(pVM)
|
---|
2826 | && pApicReg->pszGetInterruptR0)
|
---|
2827 | {
|
---|
2828 | int rc = PDMR3GetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszGetInterruptR0, &pVM->pdm.s.Apic.pfnGetInterruptR0);
|
---|
2829 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszGetInterruptR0, rc));
|
---|
2830 | if (RT_SUCCESS(rc))
|
---|
2831 | {
|
---|
2832 | rc = PDMR3GetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszSetBaseR0, &pVM->pdm.s.Apic.pfnSetBaseR0);
|
---|
2833 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszSetBaseR0, rc));
|
---|
2834 | }
|
---|
2835 | if (RT_SUCCESS(rc))
|
---|
2836 | {
|
---|
2837 | rc = PDMR3GetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszGetBaseR0, &pVM->pdm.s.Apic.pfnGetBaseR0);
|
---|
2838 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszGetBaseR0, rc));
|
---|
2839 | }
|
---|
2840 | if (RT_SUCCESS(rc))
|
---|
2841 | {
|
---|
2842 | rc = PDMR3GetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszSetTPRR0, &pVM->pdm.s.Apic.pfnSetTPRR0);
|
---|
2843 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszSetTPRR0, rc));
|
---|
2844 | }
|
---|
2845 | if (RT_SUCCESS(rc))
|
---|
2846 | {
|
---|
2847 | rc = PDMR3GetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszGetTPRR0, &pVM->pdm.s.Apic.pfnGetTPRR0);
|
---|
2848 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszGetTPRR0, rc));
|
---|
2849 | }
|
---|
2850 | if (RT_SUCCESS(rc))
|
---|
2851 | {
|
---|
2852 | rc = PDMR3GetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszBusDeliverR0, &pVM->pdm.s.Apic.pfnBusDeliverR0);
|
---|
2853 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszBusDeliverR0, rc));
|
---|
2854 | }
|
---|
2855 | if (VBOX_FAILURE(rc))
|
---|
2856 | {
|
---|
2857 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2858 | return rc;
|
---|
2859 | }
|
---|
2860 | pVM->pdm.s.Apic.pDevInsR0 = MMHyperR3ToR0(pVM, pDevIns);
|
---|
2861 | Assert(pVM->pdm.s.Apic.pDevInsR0);
|
---|
2862 | }
|
---|
2863 | else
|
---|
2864 | {
|
---|
2865 | pVM->pdm.s.Apic.pfnGetInterruptR0 = 0;
|
---|
2866 | pVM->pdm.s.Apic.pfnSetBaseR0 = 0;
|
---|
2867 | pVM->pdm.s.Apic.pfnGetBaseR0 = 0;
|
---|
2868 | pVM->pdm.s.Apic.pfnSetTPRR0 = 0;
|
---|
2869 | pVM->pdm.s.Apic.pfnGetTPRR0 = 0;
|
---|
2870 | pVM->pdm.s.Apic.pfnBusDeliverR0 = 0;
|
---|
2871 | pVM->pdm.s.Apic.pDevInsR0 = 0;
|
---|
2872 | }
|
---|
2873 |
|
---|
2874 | /*
|
---|
2875 | * Initialize the HC bits.
|
---|
2876 | */
|
---|
2877 | pVM->pdm.s.Apic.pDevInsR3 = pDevIns;
|
---|
2878 | pVM->pdm.s.Apic.pfnGetInterruptR3 = pApicReg->pfnGetInterruptHC;
|
---|
2879 | pVM->pdm.s.Apic.pfnSetBaseR3 = pApicReg->pfnSetBaseHC;
|
---|
2880 | pVM->pdm.s.Apic.pfnGetBaseR3 = pApicReg->pfnGetBaseHC;
|
---|
2881 | pVM->pdm.s.Apic.pfnSetTPRR3 = pApicReg->pfnSetTPRHC;
|
---|
2882 | pVM->pdm.s.Apic.pfnGetTPRR3 = pApicReg->pfnGetTPRHC;
|
---|
2883 | pVM->pdm.s.Apic.pfnBusDeliverR3 = pApicReg->pfnBusDeliverHC;
|
---|
2884 | Log(("PDM: Registered APIC device '%s'/%d pDevIns=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns));
|
---|
2885 |
|
---|
2886 | /* set the helper pointer and return. */
|
---|
2887 | *ppApicHlpR3 = &g_pdmR3DevApicHlp;
|
---|
2888 | LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VINF_SUCCESS));
|
---|
2889 | return VINF_SUCCESS;
|
---|
2890 | }
|
---|
2891 |
|
---|
2892 |
|
---|
2893 | /** @copydoc PDMDEVHLP::pfnIOAPICRegister */
|
---|
2894 | static DECLCALLBACK(int) pdmR3DevHlp_IOAPICRegister(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3)
|
---|
2895 | {
|
---|
2896 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
2897 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
2898 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: pIoApicReg=%p:{.u32Version=%#x, .pfnSetIrqHC=%p, .pszSetIrqGC=%p:{%s}} ppIoApicHlpR3=%p\n",
|
---|
2899 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pIoApicReg, pIoApicReg->u32Version, pIoApicReg->pfnSetIrqHC, pIoApicReg->pszSetIrqGC,
|
---|
2900 | pIoApicReg->pszSetIrqGC, ppIoApicHlpR3));
|
---|
2901 |
|
---|
2902 | /*
|
---|
2903 | * Validate input.
|
---|
2904 | */
|
---|
2905 | if (pIoApicReg->u32Version != PDM_IOAPICREG_VERSION)
|
---|
2906 | {
|
---|
2907 | AssertMsgFailed(("u32Version=%#x expected %#x\n", pIoApicReg->u32Version, PDM_IOAPICREG_VERSION));
|
---|
2908 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Vrc (version)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2909 | return VERR_INVALID_PARAMETER;
|
---|
2910 | }
|
---|
2911 | if (!pIoApicReg->pfnSetIrqHC)
|
---|
2912 | {
|
---|
2913 | Assert(pIoApicReg->pfnSetIrqHC);
|
---|
2914 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Vrc (HC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2915 | return VERR_INVALID_PARAMETER;
|
---|
2916 | }
|
---|
2917 | if ( pIoApicReg->pszSetIrqGC
|
---|
2918 | && !VALID_PTR(pIoApicReg->pszSetIrqGC))
|
---|
2919 | {
|
---|
2920 | Assert(VALID_PTR(pIoApicReg->pszSetIrqGC));
|
---|
2921 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Vrc (GC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2922 | return VERR_INVALID_PARAMETER;
|
---|
2923 | }
|
---|
2924 | if ( pIoApicReg->pszSetIrqR0
|
---|
2925 | && !VALID_PTR(pIoApicReg->pszSetIrqR0))
|
---|
2926 | {
|
---|
2927 | Assert(VALID_PTR(pIoApicReg->pszSetIrqR0));
|
---|
2928 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Vrc (GC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2929 | return VERR_INVALID_PARAMETER;
|
---|
2930 | }
|
---|
2931 | if (!ppIoApicHlpR3)
|
---|
2932 | {
|
---|
2933 | Assert(ppIoApicHlpR3);
|
---|
2934 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Vrc (ppApicHlp)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2935 | return VERR_INVALID_PARAMETER;
|
---|
2936 | }
|
---|
2937 |
|
---|
2938 | /*
|
---|
2939 | * The I/O APIC requires the APIC to be present (hacks++).
|
---|
2940 | * If the I/O APIC does GC stuff so must the APIC.
|
---|
2941 | */
|
---|
2942 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
2943 | if (!pVM->pdm.s.Apic.pDevInsR3)
|
---|
2944 | {
|
---|
2945 | AssertMsgFailed(("Configuration error / Init order error! No APIC!\n"));
|
---|
2946 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Vrc (no APIC)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2947 | return VERR_INVALID_PARAMETER;
|
---|
2948 | }
|
---|
2949 | if ( pIoApicReg->pszSetIrqGC
|
---|
2950 | && !pVM->pdm.s.Apic.pDevInsGC)
|
---|
2951 | {
|
---|
2952 | AssertMsgFailed(("Configuration error! APIC doesn't do GC, I/O APIC does!\n"));
|
---|
2953 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Vrc (no GC APIC)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2954 | return VERR_INVALID_PARAMETER;
|
---|
2955 | }
|
---|
2956 |
|
---|
2957 | /*
|
---|
2958 | * Only one I/O APIC device.
|
---|
2959 | */
|
---|
2960 | if (pVM->pdm.s.IoApic.pDevInsR3)
|
---|
2961 | {
|
---|
2962 | AssertMsgFailed(("Only one ioapic device is supported!\n"));
|
---|
2963 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Vrc (only one)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
2964 | return VERR_INVALID_PARAMETER;
|
---|
2965 | }
|
---|
2966 |
|
---|
2967 | /*
|
---|
2968 | * Resolve & initialize the GC bits.
|
---|
2969 | */
|
---|
2970 | if (pIoApicReg->pszSetIrqGC)
|
---|
2971 | {
|
---|
2972 | int rc = PDMR3GetSymbolGCLazy(pVM, pDevIns->pDevReg->szGCMod, pIoApicReg->pszSetIrqGC, &pVM->pdm.s.IoApic.pfnSetIrqGC);
|
---|
2973 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szGCMod, pIoApicReg->pszSetIrqGC, rc));
|
---|
2974 | if (VBOX_FAILURE(rc))
|
---|
2975 | {
|
---|
2976 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2977 | return rc;
|
---|
2978 | }
|
---|
2979 | pVM->pdm.s.IoApic.pDevInsGC = PDMDEVINS_2_GCPTR(pDevIns);
|
---|
2980 | }
|
---|
2981 | else
|
---|
2982 | {
|
---|
2983 | pVM->pdm.s.IoApic.pDevInsGC = 0;
|
---|
2984 | pVM->pdm.s.IoApic.pfnSetIrqGC = 0;
|
---|
2985 | }
|
---|
2986 |
|
---|
2987 | /*
|
---|
2988 | * Resolve & initialize the R0 bits.
|
---|
2989 | */
|
---|
2990 | if ( HWACCMR3IsAllowed(pVM)
|
---|
2991 | && pIoApicReg->pszSetIrqR0)
|
---|
2992 | {
|
---|
2993 | int rc = PDMR3GetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pIoApicReg->pszSetIrqR0, &pVM->pdm.s.IoApic.pfnSetIrqR0);
|
---|
2994 | AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szR0Mod, pIoApicReg->pszSetIrqR0, rc));
|
---|
2995 | if (VBOX_FAILURE(rc))
|
---|
2996 | {
|
---|
2997 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
2998 | return rc;
|
---|
2999 | }
|
---|
3000 | pVM->pdm.s.IoApic.pDevInsR0 = MMHyperR3ToR0(pVM, pDevIns);
|
---|
3001 | Assert(pVM->pdm.s.IoApic.pDevInsR0);
|
---|
3002 | }
|
---|
3003 | else
|
---|
3004 | {
|
---|
3005 | pVM->pdm.s.IoApic.pfnSetIrqR0 = 0;
|
---|
3006 | pVM->pdm.s.IoApic.pDevInsR0 = 0;
|
---|
3007 | }
|
---|
3008 |
|
---|
3009 | /*
|
---|
3010 | * Initialize the HC bits.
|
---|
3011 | */
|
---|
3012 | pVM->pdm.s.IoApic.pDevInsR3 = pDevIns;
|
---|
3013 | pVM->pdm.s.IoApic.pfnSetIrqR3 = pIoApicReg->pfnSetIrqHC;
|
---|
3014 | Log(("PDM: Registered I/O APIC device '%s'/%d pDevIns=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns));
|
---|
3015 |
|
---|
3016 | /* set the helper pointer and return. */
|
---|
3017 | *ppIoApicHlpR3 = &g_pdmR3DevIoApicHlp;
|
---|
3018 | LogFlow(("pdmR3DevHlp_IOAPICRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VINF_SUCCESS));
|
---|
3019 | return VINF_SUCCESS;
|
---|
3020 | }
|
---|
3021 |
|
---|
3022 |
|
---|
3023 | /** @copydoc PDMDEVHLP::pfnDMACRegister */
|
---|
3024 | static DECLCALLBACK(int) pdmR3DevHlp_DMACRegister(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp)
|
---|
3025 | {
|
---|
3026 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3027 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
3028 | 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",
|
---|
3029 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDmacReg, pDmacReg->u32Version, pDmacReg->pfnRun, pDmacReg->pfnRegister,
|
---|
3030 | pDmacReg->pfnReadMemory, pDmacReg->pfnWriteMemory, pDmacReg->pfnSetDREQ, pDmacReg->pfnGetChannelMode, ppDmacHlp));
|
---|
3031 |
|
---|
3032 | /*
|
---|
3033 | * Validate input.
|
---|
3034 | */
|
---|
3035 | if (pDmacReg->u32Version != PDM_DMACREG_VERSION)
|
---|
3036 | {
|
---|
3037 | AssertMsgFailed(("u32Version=%#x expected %#x\n", pDmacReg->u32Version,
|
---|
3038 | PDM_DMACREG_VERSION));
|
---|
3039 | LogFlow(("pdmR3DevHlp_DMACRegister: caller='%s'/%d: returns %Vrc (version)\n",
|
---|
3040 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
3041 | return VERR_INVALID_PARAMETER;
|
---|
3042 | }
|
---|
3043 | if ( !pDmacReg->pfnRun
|
---|
3044 | || !pDmacReg->pfnRegister
|
---|
3045 | || !pDmacReg->pfnReadMemory
|
---|
3046 | || !pDmacReg->pfnWriteMemory
|
---|
3047 | || !pDmacReg->pfnSetDREQ
|
---|
3048 | || !pDmacReg->pfnGetChannelMode)
|
---|
3049 | {
|
---|
3050 | Assert(pDmacReg->pfnRun);
|
---|
3051 | Assert(pDmacReg->pfnRegister);
|
---|
3052 | Assert(pDmacReg->pfnReadMemory);
|
---|
3053 | Assert(pDmacReg->pfnWriteMemory);
|
---|
3054 | Assert(pDmacReg->pfnSetDREQ);
|
---|
3055 | Assert(pDmacReg->pfnGetChannelMode);
|
---|
3056 | LogFlow(("pdmR3DevHlp_DMACRegister: caller='%s'/%d: returns %Vrc (callbacks)\n",
|
---|
3057 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
3058 | return VERR_INVALID_PARAMETER;
|
---|
3059 | }
|
---|
3060 |
|
---|
3061 | if (!ppDmacHlp)
|
---|
3062 | {
|
---|
3063 | Assert(ppDmacHlp);
|
---|
3064 | LogFlow(("pdmR3DevHlp_DMACRegister: caller='%s'/%d: returns %Vrc (ppDmacHlp)\n",
|
---|
3065 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
3066 | return VERR_INVALID_PARAMETER;
|
---|
3067 | }
|
---|
3068 |
|
---|
3069 | /*
|
---|
3070 | * Only one DMA device.
|
---|
3071 | */
|
---|
3072 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3073 | if (pVM->pdm.s.pDmac)
|
---|
3074 | {
|
---|
3075 | AssertMsgFailed(("Only one DMA device is supported!\n"));
|
---|
3076 | LogFlow(("pdmR3DevHlp_DMACRegister: caller='%s'/%d: returns %Vrc\n",
|
---|
3077 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
|
---|
3078 | return VERR_INVALID_PARAMETER;
|
---|
3079 | }
|
---|
3080 |
|
---|
3081 | /*
|
---|
3082 | * Allocate and initialize pci bus structure.
|
---|
3083 | */
|
---|
3084 | int rc = VINF_SUCCESS;
|
---|
3085 | PPDMDMAC pDmac = (PPDMDMAC)MMR3HeapAlloc(pDevIns->Internal.s.pVMHC, MM_TAG_PDM_DEVICE, sizeof(*pDmac));
|
---|
3086 | if (pDmac)
|
---|
3087 | {
|
---|
3088 | pDmac->pDevIns = pDevIns;
|
---|
3089 | pDmac->Reg = *pDmacReg;
|
---|
3090 | pVM->pdm.s.pDmac = pDmac;
|
---|
3091 |
|
---|
3092 | /* set the helper pointer. */
|
---|
3093 | *ppDmacHlp = &g_pdmR3DevDmacHlp;
|
---|
3094 | Log(("PDM: Registered DMAC device '%s'/%d pDevIns=%p\n",
|
---|
3095 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns));
|
---|
3096 | }
|
---|
3097 | else
|
---|
3098 | rc = VERR_NO_MEMORY;
|
---|
3099 |
|
---|
3100 | LogFlow(("pdmR3DevHlp_DMACRegister: caller='%s'/%d: returns %Vrc\n",
|
---|
3101 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
3102 | return rc;
|
---|
3103 | }
|
---|
3104 |
|
---|
3105 |
|
---|
3106 | /** @copydoc PDMDEVHLP::pfnPhysRead */
|
---|
3107 | static DECLCALLBACK(void) pdmR3DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
|
---|
3108 | {
|
---|
3109 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3110 | LogFlow(("pdmR3DevHlp_PhysRead: caller='%s'/%d: GCPhys=%VGp pvBuf=%p cbRead=%#x\n",
|
---|
3111 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhys, pvBuf, cbRead));
|
---|
3112 |
|
---|
3113 | /*
|
---|
3114 | * For the convenience of the device we put no thread restriction on this interface.
|
---|
3115 | * That means we'll have to check which thread we're in and choose our path.
|
---|
3116 | */
|
---|
3117 | #ifdef PDM_PHYS_READWRITE_FROM_ANY_THREAD
|
---|
3118 | PGMPhysRead(pDevIns->Internal.s.pVMHC, GCPhys, pvBuf, cbRead);
|
---|
3119 | #else
|
---|
3120 | if (VM_IS_EMT(pDevIns->Internal.s.pVMHC) || VMMR3LockIsOwner(pDevIns->Internal.s.pVMHC))
|
---|
3121 | PGMPhysRead(pDevIns->Internal.s.pVMHC, GCPhys, pvBuf, cbRead);
|
---|
3122 | else
|
---|
3123 | {
|
---|
3124 | Log(("pdmR3DevHlp_PhysRead: caller='%s'/%d: Requesting call in EMT...\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3125 | PVMREQ pReq;
|
---|
3126 | int rc = VMR3ReqCallVoid(pDevIns->Internal.s.pVMHC, &pReq, RT_INDEFINITE_WAIT,
|
---|
3127 | (PFNRT)PGMPhysRead, 4, pDevIns->Internal.s.pVMHC, GCPhys, pvBuf, cbRead);
|
---|
3128 | while (rc == VERR_TIMEOUT)
|
---|
3129 | rc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
|
---|
3130 | AssertReleaseRC(rc);
|
---|
3131 | VMR3ReqFree(pReq);
|
---|
3132 | }
|
---|
3133 | #endif
|
---|
3134 | Log(("pdmR3DevHlp_PhysRead: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3135 | }
|
---|
3136 |
|
---|
3137 |
|
---|
3138 | /** @copydoc PDMDEVHLP::pfnPhysWrite */
|
---|
3139 | static DECLCALLBACK(void) pdmR3DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
|
---|
3140 | {
|
---|
3141 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3142 | LogFlow(("pdmR3DevHlp_PhysWrite: caller='%s'/%d: GCPhys=%VGp pvBuf=%p cbWrite=%#x\n",
|
---|
3143 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhys, pvBuf, cbWrite));
|
---|
3144 |
|
---|
3145 | /*
|
---|
3146 | * For the convenience of the device we put no thread restriction on this interface.
|
---|
3147 | * That means we'll have to check which thread we're in and choose our path.
|
---|
3148 | */
|
---|
3149 | #ifdef PDM_PHYS_READWRITE_FROM_ANY_THREAD
|
---|
3150 | PGMPhysWrite(pDevIns->Internal.s.pVMHC, GCPhys, pvBuf, cbWrite);
|
---|
3151 | #else
|
---|
3152 | if (VM_IS_EMT(pDevIns->Internal.s.pVMHC) || VMMR3LockIsOwner(pDevIns->Internal.s.pVMHC))
|
---|
3153 | PGMPhysWrite(pDevIns->Internal.s.pVMHC, GCPhys, pvBuf, cbWrite);
|
---|
3154 | else
|
---|
3155 | {
|
---|
3156 | Log(("pdmR3DevHlp_PhysWrite: caller='%s'/%d: Requesting call in EMT...\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3157 | PVMREQ pReq;
|
---|
3158 | int rc = VMR3ReqCallVoid(pDevIns->Internal.s.pVMHC, &pReq, RT_INDEFINITE_WAIT,
|
---|
3159 | (PFNRT)PGMPhysWrite, 4, pDevIns->Internal.s.pVMHC, GCPhys, pvBuf, cbWrite);
|
---|
3160 | while (rc == VERR_TIMEOUT)
|
---|
3161 | rc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
|
---|
3162 | AssertReleaseRC(rc);
|
---|
3163 | VMR3ReqFree(pReq);
|
---|
3164 | }
|
---|
3165 | #endif
|
---|
3166 | Log(("pdmR3DevHlp_PhysWrite: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3167 | }
|
---|
3168 |
|
---|
3169 |
|
---|
3170 | /** @copydoc PDMDEVHLP::pfnPhysReadGCVirt */
|
---|
3171 | static DECLCALLBACK(int) pdmR3DevHlp_PhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb)
|
---|
3172 | {
|
---|
3173 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3174 | LogFlow(("pdmR3DevHlp_PhysReadGCVirt: caller='%s'/%d: pvDst=%p GCVirt=%VGv cb=%#x\n",
|
---|
3175 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pvDst, GCVirtSrc, cb));
|
---|
3176 |
|
---|
3177 | int rc = PGMPhysReadGCPtr(pDevIns->Internal.s.pVMHC, pvDst, GCVirtSrc, cb);
|
---|
3178 |
|
---|
3179 | LogFlow(("pdmR3DevHlp_PhysReadGCVirt: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
3180 |
|
---|
3181 | return rc;
|
---|
3182 | }
|
---|
3183 |
|
---|
3184 |
|
---|
3185 | /** @copydoc PDMDEVHLP::pfnPhysWriteGCVirt */
|
---|
3186 | static DECLCALLBACK(int) pdmR3DevHlp_PhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb)
|
---|
3187 | {
|
---|
3188 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3189 | LogFlow(("pdmR3DevHlp_PhysWriteGCVirt: caller='%s'/%d: GCVirtDst=%VGv pvSrc=%p cb=%#x\n",
|
---|
3190 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCVirtDst, pvSrc, cb));
|
---|
3191 |
|
---|
3192 | int rc = PGMPhysWriteGCPtr(pDevIns->Internal.s.pVMHC, GCVirtDst, pvSrc, cb);
|
---|
3193 |
|
---|
3194 | LogFlow(("pdmR3DevHlp_PhysWriteGCVirt: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
3195 |
|
---|
3196 | return rc;
|
---|
3197 | }
|
---|
3198 |
|
---|
3199 |
|
---|
3200 | /** @copydoc PDMDEVHLP::pfnPhysReserve */
|
---|
3201 | static DECLCALLBACK(int) pdmR3DevHlp_PhysReserve(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc)
|
---|
3202 | {
|
---|
3203 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3204 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
3205 | LogFlow(("pdmR3DevHlp_PhysReserve: caller='%s'/%d: GCPhys=%VGp cbRange=%#x pszDesc=%p:{%s}\n",
|
---|
3206 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhys, cbRange, pszDesc, pszDesc));
|
---|
3207 |
|
---|
3208 | int rc = MMR3PhysReserve(pDevIns->Internal.s.pVMHC, GCPhys, cbRange, pszDesc);
|
---|
3209 |
|
---|
3210 | LogFlow(("pdmR3DevHlp_PhysReserve: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
3211 |
|
---|
3212 | return rc;
|
---|
3213 | }
|
---|
3214 |
|
---|
3215 |
|
---|
3216 | /** @copydoc PDMDEVHLP::pfnPhys2HCVirt */
|
---|
3217 | static DECLCALLBACK(int) pdmR3DevHlp_Phys2HCVirt(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR ppvHC)
|
---|
3218 | {
|
---|
3219 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3220 | LogFlow(("pdmR3DevHlp_Phys2HCVirt: caller='%s'/%d: GCPhys=%VGp cbRange=%#x ppvHC=%p\n",
|
---|
3221 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhys, cbRange, ppvHC));
|
---|
3222 |
|
---|
3223 | int rc = PGMPhysGCPhys2HCPtr(pDevIns->Internal.s.pVMHC, GCPhys, cbRange, ppvHC);
|
---|
3224 |
|
---|
3225 | LogFlow(("pdmR3DevHlp_Phys2HCVirt: caller='%s'/%d: returns %Vrc *ppvHC=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc, *ppvHC));
|
---|
3226 |
|
---|
3227 | return rc;
|
---|
3228 | }
|
---|
3229 |
|
---|
3230 |
|
---|
3231 | /** @copydoc PDMDEVHLP::pfnPhysGCPtr2HCPtr */
|
---|
3232 | static DECLCALLBACK(int) pdmR3DevHlp_PhysGCPtr2HCPtr(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTHCPTR pHCPtr)
|
---|
3233 | {
|
---|
3234 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3235 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3236 | VM_ASSERT_EMT(pVM);
|
---|
3237 | LogFlow(("pdmR3DevHlp_PhysGCPtr2HCPtr: caller='%s'/%d: GCPtr=%VGv pHCPtr=%p\n",
|
---|
3238 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPtr, pHCPtr));
|
---|
3239 |
|
---|
3240 | int rc = PGMPhysGCPtr2HCPtr(pVM, GCPtr, pHCPtr);
|
---|
3241 |
|
---|
3242 | LogFlow(("pdmR3DevHlp_PhysGCPtr2HCPtr: caller='%s'/%d: returns %Vrc *pHCPtr=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc, *pHCPtr));
|
---|
3243 |
|
---|
3244 | return rc;
|
---|
3245 | }
|
---|
3246 |
|
---|
3247 |
|
---|
3248 | /** @copydoc PDMDEVHLP::pfnA20IsEnabled */
|
---|
3249 | static DECLCALLBACK(bool) pdmR3DevHlp_A20IsEnabled(PPDMDEVINS pDevIns)
|
---|
3250 | {
|
---|
3251 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3252 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
3253 |
|
---|
3254 | bool fRc = PGMPhysIsA20Enabled(pDevIns->Internal.s.pVMHC);
|
---|
3255 |
|
---|
3256 | LogFlow(("pdmR3DevHlp_A20IsEnabled: caller='%s'/%d: returns %d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, fRc));
|
---|
3257 | return fRc;
|
---|
3258 | }
|
---|
3259 |
|
---|
3260 |
|
---|
3261 | /** @copydoc PDMDEVHLP::pfnA20Set */
|
---|
3262 | static DECLCALLBACK(void) pdmR3DevHlp_A20Set(PPDMDEVINS pDevIns, bool fEnable)
|
---|
3263 | {
|
---|
3264 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3265 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
3266 | LogFlow(("pdmR3DevHlp_A20Set: caller='%s'/%d: fEnable=%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, fEnable));
|
---|
3267 | //Assert(*(unsigned *)&fEnable <= 1);
|
---|
3268 | PGMR3PhysSetA20(pDevIns->Internal.s.pVMHC, fEnable);
|
---|
3269 | }
|
---|
3270 |
|
---|
3271 |
|
---|
3272 | /** @copydoc PDMDEVHLP::pfnVMReset */
|
---|
3273 | static DECLCALLBACK(int) pdmR3DevHlp_VMReset(PPDMDEVINS pDevIns)
|
---|
3274 | {
|
---|
3275 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3276 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3277 | VM_ASSERT_EMT(pVM);
|
---|
3278 | LogFlow(("pdmR3DevHlp_VMReset: caller='%s'/%d: VM_FF_RESET %d -> 1\n",
|
---|
3279 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VM_FF_ISSET(pVM, VM_FF_RESET)));
|
---|
3280 |
|
---|
3281 | /*
|
---|
3282 | * We postpone this operation because we're likely to be inside a I/O instruction
|
---|
3283 | * and the EIP will be updated when we return.
|
---|
3284 | * We still return VINF_EM_RESET to break out of any execution loops and force FF evaluation.
|
---|
3285 | */
|
---|
3286 | bool fHaltOnReset;
|
---|
3287 | int rc = CFGMR3QueryBool(CFGMR3GetChild(CFGMR3GetRoot(pVM), "PDM"), "HaltOnReset", &fHaltOnReset);
|
---|
3288 | if (VBOX_SUCCESS(rc) && fHaltOnReset)
|
---|
3289 | {
|
---|
3290 | Log(("pdmR3DevHlp_VMReset: Halt On Reset!\n"));
|
---|
3291 | rc = VINF_EM_HALT;
|
---|
3292 | }
|
---|
3293 | else
|
---|
3294 | {
|
---|
3295 | VM_FF_SET(pVM, VM_FF_RESET);
|
---|
3296 | rc = VINF_EM_RESET;
|
---|
3297 | }
|
---|
3298 |
|
---|
3299 | LogFlow(("pdmR3DevHlp_VMReset: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
3300 | return rc;
|
---|
3301 | }
|
---|
3302 |
|
---|
3303 |
|
---|
3304 | /** @copydoc PDMDEVHLP::pfnVMSuspend */
|
---|
3305 | static DECLCALLBACK(int) pdmR3DevHlp_VMSuspend(PPDMDEVINS pDevIns)
|
---|
3306 | {
|
---|
3307 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3308 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
3309 | LogFlow(("pdmR3DevHlp_VMSuspend: caller='%s'/%d:\n",
|
---|
3310 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3311 |
|
---|
3312 | int rc = VMR3Suspend(pDevIns->Internal.s.pVMHC);
|
---|
3313 |
|
---|
3314 | LogFlow(("pdmR3DevHlp_VMSuspend: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
3315 | return rc;
|
---|
3316 | }
|
---|
3317 |
|
---|
3318 |
|
---|
3319 | /** @copydoc PDMDEVHLP::pfnVMPowerOff */
|
---|
3320 | static DECLCALLBACK(int) pdmR3DevHlp_VMPowerOff(PPDMDEVINS pDevIns)
|
---|
3321 | {
|
---|
3322 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3323 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
3324 | LogFlow(("pdmR3DevHlp_VMPowerOff: caller='%s'/%d:\n",
|
---|
3325 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3326 |
|
---|
3327 | int rc = VMR3PowerOff(pDevIns->Internal.s.pVMHC);
|
---|
3328 |
|
---|
3329 | LogFlow(("pdmR3DevHlp_VMPowerOff: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
3330 | return rc;
|
---|
3331 | }
|
---|
3332 |
|
---|
3333 |
|
---|
3334 | /** @copydoc PDMDEVHLP::pfnLockVM */
|
---|
3335 | static DECLCALLBACK(int) pdmR3DevHlp_LockVM(PPDMDEVINS pDevIns)
|
---|
3336 | {
|
---|
3337 | return VMMR3Lock(pDevIns->Internal.s.pVMHC);
|
---|
3338 | }
|
---|
3339 |
|
---|
3340 |
|
---|
3341 | /** @copydoc PDMDEVHLP::pfnUnlockVM */
|
---|
3342 | static DECLCALLBACK(int) pdmR3DevHlp_UnlockVM(PPDMDEVINS pDevIns)
|
---|
3343 | {
|
---|
3344 | return VMMR3Unlock(pDevIns->Internal.s.pVMHC);
|
---|
3345 | }
|
---|
3346 |
|
---|
3347 |
|
---|
3348 | /** @copydoc PDMDEVHLP::pfnAssertVMLock */
|
---|
3349 | static DECLCALLBACK(bool) pdmR3DevHlp_AssertVMLock(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction)
|
---|
3350 | {
|
---|
3351 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3352 | if (VMMR3LockIsOwner(pVM))
|
---|
3353 | return true;
|
---|
3354 |
|
---|
3355 | RTNATIVETHREAD NativeThreadOwner = VMMR3LockGetOwner(pVM);
|
---|
3356 | RTTHREAD ThreadOwner = RTThreadFromNative(NativeThreadOwner);
|
---|
3357 | char szMsg[100];
|
---|
3358 | RTStrPrintf(szMsg, sizeof(szMsg), "AssertVMLocked '%s'/%d ThreadOwner=%RTnthrd/%RTthrd/'%s' Self='%s'\n",
|
---|
3359 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance,
|
---|
3360 | NativeThreadOwner, ThreadOwner, RTThreadGetName(ThreadOwner), RTThreadSelfName());
|
---|
3361 | AssertMsg1(szMsg, iLine, pszFile, pszFunction);
|
---|
3362 | AssertBreakpoint();
|
---|
3363 | return false;
|
---|
3364 | }
|
---|
3365 |
|
---|
3366 | /** @copydoc PDMDEVHLP::pfnDMARegister */
|
---|
3367 | static DECLCALLBACK(int) pdmR3DevHlp_DMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser)
|
---|
3368 | {
|
---|
3369 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3370 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3371 | VM_ASSERT_EMT(pVM);
|
---|
3372 | LogFlow(("pdmR3DevHlp_DMARegister: caller='%s'/%d: uChannel=%d pfnTransferHandler=%p pvUser=%p\n",
|
---|
3373 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, uChannel, pfnTransferHandler, pvUser));
|
---|
3374 | int rc = VINF_SUCCESS;
|
---|
3375 | if (pVM->pdm.s.pDmac)
|
---|
3376 | pVM->pdm.s.pDmac->Reg.pfnRegister(pVM->pdm.s.pDmac->pDevIns, uChannel, pfnTransferHandler, pvUser);
|
---|
3377 | else
|
---|
3378 | {
|
---|
3379 | AssertMsgFailed(("Configuration error: No DMAC controller available. This could be related to init order too!\n"));
|
---|
3380 | rc = VERR_PDM_NO_DMAC_INSTANCE;
|
---|
3381 | }
|
---|
3382 | LogFlow(("pdmR3DevHlp_DMARegister: caller='%s'/%d: returns %Vrc\n",
|
---|
3383 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
3384 | return rc;
|
---|
3385 | }
|
---|
3386 |
|
---|
3387 | /** @copydoc PDMDEVHLP::pfnDMAReadMemory */
|
---|
3388 | static DECLCALLBACK(int) pdmR3DevHlp_DMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead)
|
---|
3389 | {
|
---|
3390 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3391 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3392 | VM_ASSERT_EMT(pVM);
|
---|
3393 | LogFlow(("pdmR3DevHlp_DMAReadMemory: caller='%s'/%d: uChannel=%d pvBuffer=%p off=%#x cbBlock=%#x pcbRead=%p\n",
|
---|
3394 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, uChannel, pvBuffer, off, cbBlock, pcbRead));
|
---|
3395 | int rc = VINF_SUCCESS;
|
---|
3396 | if (pVM->pdm.s.pDmac)
|
---|
3397 | {
|
---|
3398 | uint32_t cb = pVM->pdm.s.pDmac->Reg.pfnReadMemory(pVM->pdm.s.pDmac->pDevIns, uChannel, pvBuffer, off, cbBlock);
|
---|
3399 | if (pcbRead)
|
---|
3400 | *pcbRead = cb;
|
---|
3401 | }
|
---|
3402 | else
|
---|
3403 | {
|
---|
3404 | AssertMsgFailed(("Configuration error: No DMAC controller available. This could be related to init order too!\n"));
|
---|
3405 | rc = VERR_PDM_NO_DMAC_INSTANCE;
|
---|
3406 | }
|
---|
3407 | LogFlow(("pdmR3DevHlp_DMAReadMemory: caller='%s'/%d: returns %Vrc\n",
|
---|
3408 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
3409 | return rc;
|
---|
3410 | }
|
---|
3411 |
|
---|
3412 | /** @copydoc PDMDEVHLP::pfnDMAWriteMemory */
|
---|
3413 | static DECLCALLBACK(int) pdmR3DevHlp_DMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten)
|
---|
3414 | {
|
---|
3415 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3416 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3417 | VM_ASSERT_EMT(pVM);
|
---|
3418 | LogFlow(("pdmR3DevHlp_DMAWriteMemory: caller='%s'/%d: uChannel=%d pvBuffer=%p off=%#x cbBlock=%#x pcbWritten=%p\n",
|
---|
3419 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, uChannel, pvBuffer, off, cbBlock, pcbWritten));
|
---|
3420 | int rc = VINF_SUCCESS;
|
---|
3421 | if (pVM->pdm.s.pDmac)
|
---|
3422 | {
|
---|
3423 | uint32_t cb = pVM->pdm.s.pDmac->Reg.pfnWriteMemory(pVM->pdm.s.pDmac->pDevIns, uChannel, pvBuffer, off, cbBlock);
|
---|
3424 | if (pcbWritten)
|
---|
3425 | *pcbWritten = cb;
|
---|
3426 | }
|
---|
3427 | else
|
---|
3428 | {
|
---|
3429 | AssertMsgFailed(("Configuration error: No DMAC controller available. This could be related to init order too!\n"));
|
---|
3430 | rc = VERR_PDM_NO_DMAC_INSTANCE;
|
---|
3431 | }
|
---|
3432 | LogFlow(("pdmR3DevHlp_DMAWriteMemory: caller='%s'/%d: returns %Vrc\n",
|
---|
3433 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
3434 | return rc;
|
---|
3435 | }
|
---|
3436 |
|
---|
3437 | /** @copydoc PDMDEVHLP::pfnDMASetDREQ */
|
---|
3438 | static DECLCALLBACK(int) pdmR3DevHlp_DMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel)
|
---|
3439 | {
|
---|
3440 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3441 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3442 | VM_ASSERT_EMT(pVM);
|
---|
3443 | LogFlow(("pdmR3DevHlp_DMASetDREQ: caller='%s'/%d: uChannel=%d uLevel=%d\n",
|
---|
3444 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, uChannel, uLevel));
|
---|
3445 | int rc = VINF_SUCCESS;
|
---|
3446 | if (pVM->pdm.s.pDmac)
|
---|
3447 | pVM->pdm.s.pDmac->Reg.pfnSetDREQ(pVM->pdm.s.pDmac->pDevIns, uChannel, uLevel);
|
---|
3448 | else
|
---|
3449 | {
|
---|
3450 | AssertMsgFailed(("Configuration error: No DMAC controller available. This could be related to init order too!\n"));
|
---|
3451 | rc = VERR_PDM_NO_DMAC_INSTANCE;
|
---|
3452 | }
|
---|
3453 | LogFlow(("pdmR3DevHlp_DMASetDREQ: caller='%s'/%d: returns %Vrc\n",
|
---|
3454 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
3455 | return rc;
|
---|
3456 | }
|
---|
3457 |
|
---|
3458 | /** @copydoc PDMDEVHLP::pfnDMAGetChannelMode */
|
---|
3459 | static DECLCALLBACK(uint8_t) pdmR3DevHlp_DMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel)
|
---|
3460 | {
|
---|
3461 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3462 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3463 | VM_ASSERT_EMT(pVM);
|
---|
3464 | LogFlow(("pdmR3DevHlp_DMAGetChannelMode: caller='%s'/%d: uChannel=%d\n",
|
---|
3465 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, uChannel));
|
---|
3466 | uint8_t u8Mode;
|
---|
3467 | if (pVM->pdm.s.pDmac)
|
---|
3468 | u8Mode = pVM->pdm.s.pDmac->Reg.pfnGetChannelMode(pVM->pdm.s.pDmac->pDevIns, uChannel);
|
---|
3469 | else
|
---|
3470 | {
|
---|
3471 | AssertMsgFailed(("Configuration error: No DMAC controller available. This could be related to init order too!\n"));
|
---|
3472 | u8Mode = 3 << 2 /* illegal mode type */;
|
---|
3473 | }
|
---|
3474 | LogFlow(("pdmR3DevHlp_DMAGetChannelMode: caller='%s'/%d: returns %#04x\n",
|
---|
3475 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, u8Mode));
|
---|
3476 | return u8Mode;
|
---|
3477 | }
|
---|
3478 |
|
---|
3479 | /** @copydoc PDMDEVHLP::pfnDMASchedule */
|
---|
3480 | static DECLCALLBACK(void) pdmR3DevHlp_DMASchedule(PPDMDEVINS pDevIns)
|
---|
3481 | {
|
---|
3482 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3483 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3484 | VM_ASSERT_EMT(pVM);
|
---|
3485 | LogFlow(("pdmR3DevHlp_DMASchedule: caller='%s'/%d: VM_FF_PDM_DMA %d -> 1\n",
|
---|
3486 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VM_FF_ISSET(pVM, VM_FF_PDM_DMA)));
|
---|
3487 |
|
---|
3488 | AssertMsg(pVM->pdm.s.pDmac, ("Configuration error: No DMAC controller available. This could be related to init order too!\n"));
|
---|
3489 | VM_FF_SET(pVM, VM_FF_PDM_DMA);
|
---|
3490 | REMR3NotifyDmaPending(pVM);
|
---|
3491 | VMR3NotifyFF(pVM, true);
|
---|
3492 | }
|
---|
3493 |
|
---|
3494 |
|
---|
3495 | /** @copydoc PDMDEVHLP::pfnCMOSWrite */
|
---|
3496 | static DECLCALLBACK(int) pdmR3DevHlp_CMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value)
|
---|
3497 | {
|
---|
3498 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3499 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3500 | VM_ASSERT_EMT(pVM);
|
---|
3501 |
|
---|
3502 | LogFlow(("pdmR3DevHlp_CMOSWrite: caller='%s'/%d: iReg=%#04x u8Value=%#04x\n",
|
---|
3503 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iReg, u8Value));
|
---|
3504 | int rc;
|
---|
3505 | if (pVM->pdm.s.pRtc)
|
---|
3506 | rc = pVM->pdm.s.pRtc->Reg.pfnWrite(pVM->pdm.s.pRtc->pDevIns, iReg, u8Value);
|
---|
3507 | else
|
---|
3508 | rc = VERR_PDM_NO_RTC_INSTANCE;
|
---|
3509 |
|
---|
3510 | LogFlow(("pdmR3DevHlp_CMOSWrite: caller='%s'/%d: return %Vrc\n",
|
---|
3511 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
3512 | return rc;
|
---|
3513 | }
|
---|
3514 |
|
---|
3515 |
|
---|
3516 | /** @copydoc PDMDEVHLP::pfnCMOSRead */
|
---|
3517 | static DECLCALLBACK(int) pdmR3DevHlp_CMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value)
|
---|
3518 | {
|
---|
3519 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3520 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3521 | VM_ASSERT_EMT(pVM);
|
---|
3522 |
|
---|
3523 | LogFlow(("pdmR3DevHlp_CMOSWrite: caller='%s'/%d: iReg=%#04x pu8Value=%p\n",
|
---|
3524 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iReg, pu8Value));
|
---|
3525 | int rc;
|
---|
3526 | if (pVM->pdm.s.pRtc)
|
---|
3527 | rc = pVM->pdm.s.pRtc->Reg.pfnRead(pVM->pdm.s.pRtc->pDevIns, iReg, pu8Value);
|
---|
3528 | else
|
---|
3529 | rc = VERR_PDM_NO_RTC_INSTANCE;
|
---|
3530 |
|
---|
3531 | LogFlow(("pdmR3DevHlp_CMOSWrite: caller='%s'/%d: return %Vrc\n",
|
---|
3532 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
|
---|
3533 | return rc;
|
---|
3534 | }
|
---|
3535 |
|
---|
3536 |
|
---|
3537 | /** @copydoc PDMDEVHLP::pfnGetCpuId */
|
---|
3538 | static DECLCALLBACK(void) pdmR3DevHlp_GetCpuId(PPDMDEVINS pDevIns, uint32_t iLeaf,
|
---|
3539 | uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx)
|
---|
3540 | {
|
---|
3541 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3542 | LogFlow(("pdmR3DevHlp_GetCpuId: caller='%s'/%d: iLeaf=%d pEax=%p pEbx=%p pEcx=%p pEdx=%p\n",
|
---|
3543 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iLeaf, pEax, pEbx, pEcx, pEdx));
|
---|
3544 | AssertPtr(pEax); AssertPtr(pEbx); AssertPtr(pEcx); AssertPtr(pEdx);
|
---|
3545 |
|
---|
3546 | CPUMGetGuestCpuId(pDevIns->Internal.s.pVMHC, iLeaf, pEax, pEbx, pEcx, pEdx);
|
---|
3547 |
|
---|
3548 | LogFlow(("pdmR3DevHlp_GetCpuId: caller='%s'/%d: returns void - *pEax=%#x *pEbx=%#x *pEcx=%#x *pEdx=%#x\n",
|
---|
3549 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, *pEax, *pEbx, *pEcx, *pEdx));
|
---|
3550 | }
|
---|
3551 |
|
---|
3552 |
|
---|
3553 |
|
---|
3554 |
|
---|
3555 | /** @copydoc PDMDEVHLP::pfnGetVM */
|
---|
3556 | static DECLCALLBACK(PVM) pdmR3DevHlp_Untrusted_GetVM(PPDMDEVINS pDevIns)
|
---|
3557 | {
|
---|
3558 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3559 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3560 | return NULL;
|
---|
3561 | }
|
---|
3562 |
|
---|
3563 |
|
---|
3564 | /** @copydoc PDMDEVHLP::pfnPCIBusRegister */
|
---|
3565 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3)
|
---|
3566 | {
|
---|
3567 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3568 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3569 | NOREF(pPciBusReg);
|
---|
3570 | NOREF(ppPciHlpR3);
|
---|
3571 | return VERR_ACCESS_DENIED;
|
---|
3572 | }
|
---|
3573 |
|
---|
3574 |
|
---|
3575 | /** @copydoc PDMDEVHLP::pfnPICRegister */
|
---|
3576 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3)
|
---|
3577 | {
|
---|
3578 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3579 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3580 | NOREF(pPicReg);
|
---|
3581 | NOREF(ppPicHlpR3);
|
---|
3582 | return VERR_ACCESS_DENIED;
|
---|
3583 | }
|
---|
3584 |
|
---|
3585 |
|
---|
3586 | /** @copydoc PDMDEVHLP::pfnAPICRegister */
|
---|
3587 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_APICRegister(PPDMDEVINS pDevIns, PPDMAPICREG pApicReg, PCPDMAPICHLPR3 *ppApicHlpR3)
|
---|
3588 | {
|
---|
3589 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3590 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3591 | NOREF(pApicReg);
|
---|
3592 | NOREF(ppApicHlpR3);
|
---|
3593 | return VERR_ACCESS_DENIED;
|
---|
3594 | }
|
---|
3595 |
|
---|
3596 |
|
---|
3597 | /** @copydoc PDMDEVHLP::pfnIOAPICRegister */
|
---|
3598 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_IOAPICRegister(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3)
|
---|
3599 | {
|
---|
3600 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3601 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3602 | NOREF(pIoApicReg);
|
---|
3603 | NOREF(ppIoApicHlpR3);
|
---|
3604 | return VERR_ACCESS_DENIED;
|
---|
3605 | }
|
---|
3606 |
|
---|
3607 |
|
---|
3608 | /** @copydoc PDMDEVHLP::pfnDMACRegister */
|
---|
3609 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMACRegister(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp)
|
---|
3610 | {
|
---|
3611 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3612 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3613 | NOREF(pDmacReg);
|
---|
3614 | NOREF(ppDmacHlp);
|
---|
3615 | return VERR_ACCESS_DENIED;
|
---|
3616 | }
|
---|
3617 |
|
---|
3618 |
|
---|
3619 | /** @copydoc PDMDEVHLP::pfnPhysRead */
|
---|
3620 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
|
---|
3621 | {
|
---|
3622 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3623 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3624 | NOREF(GCPhys);
|
---|
3625 | NOREF(pvBuf);
|
---|
3626 | NOREF(cbRead);
|
---|
3627 | }
|
---|
3628 |
|
---|
3629 |
|
---|
3630 | /** @copydoc PDMDEVHLP::pfnPhysWrite */
|
---|
3631 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
|
---|
3632 | {
|
---|
3633 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3634 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3635 | NOREF(GCPhys);
|
---|
3636 | NOREF(pvBuf);
|
---|
3637 | NOREF(cbWrite);
|
---|
3638 | }
|
---|
3639 |
|
---|
3640 |
|
---|
3641 | /** @copydoc PDMDEVHLP::pfnPhysReadGCVirt */
|
---|
3642 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb)
|
---|
3643 | {
|
---|
3644 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3645 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3646 | NOREF(pvDst);
|
---|
3647 | NOREF(GCVirtSrc);
|
---|
3648 | NOREF(cb);
|
---|
3649 | return VERR_ACCESS_DENIED;
|
---|
3650 | }
|
---|
3651 |
|
---|
3652 |
|
---|
3653 | /** @copydoc PDMDEVHLP::pfnPhysWriteGCVirt */
|
---|
3654 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb)
|
---|
3655 | {
|
---|
3656 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3657 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3658 | NOREF(GCVirtDst);
|
---|
3659 | NOREF(pvSrc);
|
---|
3660 | NOREF(cb);
|
---|
3661 | return VERR_ACCESS_DENIED;
|
---|
3662 | }
|
---|
3663 |
|
---|
3664 |
|
---|
3665 | /** @copydoc PDMDEVHLP::pfnPhysReserve */
|
---|
3666 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysReserve(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc)
|
---|
3667 | {
|
---|
3668 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3669 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3670 | NOREF(GCPhys);
|
---|
3671 | NOREF(cbRange);
|
---|
3672 | return VERR_ACCESS_DENIED;
|
---|
3673 | }
|
---|
3674 |
|
---|
3675 |
|
---|
3676 | /** @copydoc PDMDEVHLP::pfnPhys2HCVirt */
|
---|
3677 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_Phys2HCVirt(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR ppvHC)
|
---|
3678 | {
|
---|
3679 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3680 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3681 | NOREF(GCPhys);
|
---|
3682 | NOREF(cbRange);
|
---|
3683 | NOREF(ppvHC);
|
---|
3684 | return VERR_ACCESS_DENIED;
|
---|
3685 | }
|
---|
3686 |
|
---|
3687 |
|
---|
3688 | /** @copydoc PDMDEVHLP::pfnPhysGCPtr2HCPtr */
|
---|
3689 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysGCPtr2HCPtr(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTHCPTR pHCPtr)
|
---|
3690 | {
|
---|
3691 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3692 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3693 | NOREF(GCPtr);
|
---|
3694 | NOREF(pHCPtr);
|
---|
3695 | return VERR_ACCESS_DENIED;
|
---|
3696 | }
|
---|
3697 |
|
---|
3698 |
|
---|
3699 | /** @copydoc PDMDEVHLP::pfnA20IsEnabled */
|
---|
3700 | static DECLCALLBACK(bool) pdmR3DevHlp_Untrusted_A20IsEnabled(PPDMDEVINS pDevIns)
|
---|
3701 | {
|
---|
3702 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3703 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3704 | return false;
|
---|
3705 | }
|
---|
3706 |
|
---|
3707 |
|
---|
3708 | /** @copydoc PDMDEVHLP::pfnA20Set */
|
---|
3709 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_A20Set(PPDMDEVINS pDevIns, bool fEnable)
|
---|
3710 | {
|
---|
3711 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3712 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3713 | NOREF(fEnable);
|
---|
3714 | }
|
---|
3715 |
|
---|
3716 |
|
---|
3717 | /** @copydoc PDMDEVHLP::pfnVMReset */
|
---|
3718 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_VMReset(PPDMDEVINS pDevIns)
|
---|
3719 | {
|
---|
3720 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3721 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3722 | return VERR_ACCESS_DENIED;
|
---|
3723 | }
|
---|
3724 |
|
---|
3725 |
|
---|
3726 | /** @copydoc PDMDEVHLP::pfnVMSuspend */
|
---|
3727 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_VMSuspend(PPDMDEVINS pDevIns)
|
---|
3728 | {
|
---|
3729 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3730 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3731 | return VERR_ACCESS_DENIED;
|
---|
3732 | }
|
---|
3733 |
|
---|
3734 |
|
---|
3735 | /** @copydoc PDMDEVHLP::pfnVMPowerOff */
|
---|
3736 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_VMPowerOff(PPDMDEVINS pDevIns)
|
---|
3737 | {
|
---|
3738 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3739 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3740 | return VERR_ACCESS_DENIED;
|
---|
3741 | }
|
---|
3742 |
|
---|
3743 |
|
---|
3744 | /** @copydoc PDMDEVHLP::pfnLockVM */
|
---|
3745 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_LockVM(PPDMDEVINS pDevIns)
|
---|
3746 | {
|
---|
3747 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3748 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3749 | return VERR_ACCESS_DENIED;
|
---|
3750 | }
|
---|
3751 |
|
---|
3752 |
|
---|
3753 | /** @copydoc PDMDEVHLP::pfnUnlockVM */
|
---|
3754 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_UnlockVM(PPDMDEVINS pDevIns)
|
---|
3755 | {
|
---|
3756 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3757 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3758 | return VERR_ACCESS_DENIED;
|
---|
3759 | }
|
---|
3760 |
|
---|
3761 |
|
---|
3762 | /** @copydoc PDMDEVHLP::pfnAssertVMLock */
|
---|
3763 | static DECLCALLBACK(bool) pdmR3DevHlp_Untrusted_AssertVMLock(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction)
|
---|
3764 | {
|
---|
3765 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3766 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3767 | return false;
|
---|
3768 | }
|
---|
3769 |
|
---|
3770 |
|
---|
3771 | /** @copydoc PDMDEVHLP::pfnDMARegister */
|
---|
3772 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser)
|
---|
3773 | {
|
---|
3774 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3775 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3776 | return VERR_ACCESS_DENIED;
|
---|
3777 | }
|
---|
3778 |
|
---|
3779 |
|
---|
3780 | /** @copydoc PDMDEVHLP::pfnDMAReadMemory */
|
---|
3781 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead)
|
---|
3782 | {
|
---|
3783 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3784 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3785 | if (pcbRead)
|
---|
3786 | *pcbRead = 0;
|
---|
3787 | return VERR_ACCESS_DENIED;
|
---|
3788 | }
|
---|
3789 |
|
---|
3790 |
|
---|
3791 | /** @copydoc PDMDEVHLP::pfnDMAWriteMemory */
|
---|
3792 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten)
|
---|
3793 | {
|
---|
3794 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3795 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3796 | if (pcbWritten)
|
---|
3797 | *pcbWritten = 0;
|
---|
3798 | return VERR_ACCESS_DENIED;
|
---|
3799 | }
|
---|
3800 |
|
---|
3801 |
|
---|
3802 | /** @copydoc PDMDEVHLP::pfnDMASetDREQ */
|
---|
3803 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_DMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel)
|
---|
3804 | {
|
---|
3805 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3806 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3807 | return VERR_ACCESS_DENIED;
|
---|
3808 | }
|
---|
3809 |
|
---|
3810 |
|
---|
3811 | /** @copydoc PDMDEVHLP::pfnDMAGetChannelMode */
|
---|
3812 | static DECLCALLBACK(uint8_t) pdmR3DevHlp_Untrusted_DMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel)
|
---|
3813 | {
|
---|
3814 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3815 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3816 | return 3 << 2 /* illegal mode type */;
|
---|
3817 | }
|
---|
3818 |
|
---|
3819 |
|
---|
3820 | /** @copydoc PDMDEVHLP::pfnDMASchedule */
|
---|
3821 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_DMASchedule(PPDMDEVINS pDevIns)
|
---|
3822 | {
|
---|
3823 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3824 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3825 | }
|
---|
3826 |
|
---|
3827 |
|
---|
3828 | /** @copydoc PDMDEVHLP::pfnCMOSWrite */
|
---|
3829 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_CMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value)
|
---|
3830 | {
|
---|
3831 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3832 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3833 | return VERR_ACCESS_DENIED;
|
---|
3834 | }
|
---|
3835 |
|
---|
3836 |
|
---|
3837 | /** @copydoc PDMDEVHLP::pfnCMOSRead */
|
---|
3838 | static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_CMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value)
|
---|
3839 | {
|
---|
3840 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3841 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3842 | return VERR_ACCESS_DENIED;
|
---|
3843 | }
|
---|
3844 |
|
---|
3845 |
|
---|
3846 | /** @copydoc PDMDEVHLP::pfnQueryCPUId */
|
---|
3847 | static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_QueryCPUId(PPDMDEVINS pDevIns, uint32_t iLeaf,
|
---|
3848 | uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx)
|
---|
3849 | {
|
---|
3850 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3851 | AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
|
---|
3852 | }
|
---|
3853 |
|
---|
3854 |
|
---|
3855 | /** @copydoc PDMPICHLPR3::pfnSetInterruptFF */
|
---|
3856 | static DECLCALLBACK(void) pdmR3PicHlp_SetInterruptFF(PPDMDEVINS pDevIns)
|
---|
3857 | {
|
---|
3858 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3859 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3860 | LogFlow(("pdmR3PicHlp_SetInterruptFF: caller='%s'/%d: VM_FF_INTERRUPT_PIC %d -> 1\n",
|
---|
3861 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VM_FF_ISSET(pVM, VM_FF_INTERRUPT_PIC)));
|
---|
3862 | VM_FF_SET(pVM, VM_FF_INTERRUPT_PIC);
|
---|
3863 | REMR3NotifyInterruptSet(pVM);
|
---|
3864 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
3865 | VMR3NotifyFF(pVM, true);
|
---|
3866 | #endif
|
---|
3867 | }
|
---|
3868 |
|
---|
3869 |
|
---|
3870 | /** @copydoc PDMPICHLPR3::pfnClearInterruptFF */
|
---|
3871 | static DECLCALLBACK(void) pdmR3PicHlp_ClearInterruptFF(PPDMDEVINS pDevIns)
|
---|
3872 | {
|
---|
3873 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3874 | LogFlow(("pdmR3PicHlp_ClearInterruptFF: caller='%s'/%d: VM_FF_INTERRUPT_PIC %d -> 0\n",
|
---|
3875 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VM_FF_ISSET(pDevIns->Internal.s.pVMHC, VM_FF_INTERRUPT_PIC)));
|
---|
3876 | VM_FF_CLEAR(pDevIns->Internal.s.pVMHC, VM_FF_INTERRUPT_PIC);
|
---|
3877 | REMR3NotifyInterruptClear(pDevIns->Internal.s.pVMHC);
|
---|
3878 | }
|
---|
3879 |
|
---|
3880 |
|
---|
3881 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
3882 | /** @copydoc PDMPICHLPR3::pfnLock */
|
---|
3883 | static DECLCALLBACK(int) pdmR3PicHlp_Lock(PPDMDEVINS pDevIns, int rc)
|
---|
3884 | {
|
---|
3885 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3886 | return pdmLockEx(pDevIns->Internal.s.pVMHC, rc);
|
---|
3887 | }
|
---|
3888 |
|
---|
3889 |
|
---|
3890 | /** @copydoc PDMPICHLPR3::pfnUnlock */
|
---|
3891 | static DECLCALLBACK(void) pdmR3PicHlp_Unlock(PPDMDEVINS pDevIns)
|
---|
3892 | {
|
---|
3893 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3894 | pdmUnlock(pDevIns->Internal.s.pVMHC);
|
---|
3895 | }
|
---|
3896 | #endif /* VBOX_WITH_PDM_LOCK */
|
---|
3897 |
|
---|
3898 |
|
---|
3899 | /** @copydoc PDMPICHLPR3::pfnGetGCHelpers */
|
---|
3900 | static DECLCALLBACK(PCPDMPICHLPGC) pdmR3PicHlp_GetGCHelpers(PPDMDEVINS pDevIns)
|
---|
3901 | {
|
---|
3902 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3903 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
3904 | RTGCPTR pGCHelpers = 0;
|
---|
3905 | int rc = PDMR3GetSymbolGC(pDevIns->Internal.s.pVMHC, NULL, "g_pdmGCPicHlp", &pGCHelpers);
|
---|
3906 | AssertReleaseRC(rc);
|
---|
3907 | AssertRelease(pGCHelpers);
|
---|
3908 | LogFlow(("pdmR3PicHlp_GetGCHelpers: caller='%s'/%d: returns %VGv\n",
|
---|
3909 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pGCHelpers));
|
---|
3910 | return pGCHelpers;
|
---|
3911 | }
|
---|
3912 |
|
---|
3913 |
|
---|
3914 | /** @copydoc PDMPICHLPR3::pfnGetR0Helpers */
|
---|
3915 | static DECLCALLBACK(PCPDMPICHLPR0) pdmR3PicHlp_GetR0Helpers(PPDMDEVINS pDevIns)
|
---|
3916 | {
|
---|
3917 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3918 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
3919 | PCPDMPICHLPR0 pR0Helpers = 0;
|
---|
3920 | int rc = PDMR3GetSymbolR0(pDevIns->Internal.s.pVMHC, NULL, "g_pdmR0PicHlp", &pR0Helpers);
|
---|
3921 | AssertReleaseRC(rc);
|
---|
3922 | AssertRelease(pR0Helpers);
|
---|
3923 | LogFlow(("pdmR3PicHlp_GetR0Helpers: caller='%s'/%d: returns %VHv\n",
|
---|
3924 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pR0Helpers));
|
---|
3925 | return pR0Helpers;
|
---|
3926 | }
|
---|
3927 |
|
---|
3928 |
|
---|
3929 | /** @copydoc PDMAPICHLPR3::pfnSetInterruptFF */
|
---|
3930 | static DECLCALLBACK(void) pdmR3ApicHlp_SetInterruptFF(PPDMDEVINS pDevIns)
|
---|
3931 | {
|
---|
3932 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3933 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
3934 | LogFlow(("pdmR3ApicHlp_SetInterruptFF: caller='%s'/%d: VM_FF_INTERRUPT %d -> 1\n",
|
---|
3935 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VM_FF_ISSET(pVM, VM_FF_INTERRUPT_APIC)));
|
---|
3936 | VM_FF_SET(pVM, VM_FF_INTERRUPT_APIC);
|
---|
3937 | REMR3NotifyInterruptSet(pVM);
|
---|
3938 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
3939 | VMR3NotifyFF(pVM, true);
|
---|
3940 | #endif
|
---|
3941 | }
|
---|
3942 |
|
---|
3943 |
|
---|
3944 | /** @copydoc PDMAPICHLPR3::pfnClearInterruptFF */
|
---|
3945 | static DECLCALLBACK(void) pdmR3ApicHlp_ClearInterruptFF(PPDMDEVINS pDevIns)
|
---|
3946 | {
|
---|
3947 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3948 | LogFlow(("pdmR3ApicHlp_ClearInterruptFF: caller='%s'/%d: VM_FF_INTERRUPT %d -> 0\n",
|
---|
3949 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VM_FF_ISSET(pDevIns->Internal.s.pVMHC, VM_FF_INTERRUPT_APIC)));
|
---|
3950 | VM_FF_CLEAR(pDevIns->Internal.s.pVMHC, VM_FF_INTERRUPT_APIC);
|
---|
3951 | REMR3NotifyInterruptClear(pDevIns->Internal.s.pVMHC);
|
---|
3952 | }
|
---|
3953 |
|
---|
3954 |
|
---|
3955 | /** @copydoc PDMAPICHLPR3::pfnChangeFeature */
|
---|
3956 | static DECLCALLBACK(void) pdmR3ApicHlp_ChangeFeature(PPDMDEVINS pDevIns, bool fEnabled)
|
---|
3957 | {
|
---|
3958 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3959 | LogFlow(("pdmR3ApicHlp_ClearInterruptFF: caller='%s'/%d: fEnabled=%RTbool\n",
|
---|
3960 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, fEnabled));
|
---|
3961 | if (fEnabled)
|
---|
3962 | CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMHC, CPUMCPUIDFEATURE_APIC);
|
---|
3963 | else
|
---|
3964 | CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMHC, CPUMCPUIDFEATURE_APIC);
|
---|
3965 | }
|
---|
3966 |
|
---|
3967 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
3968 | /** @copydoc PDMAPICHLPR3::pfnLock */
|
---|
3969 | static DECLCALLBACK(int) pdmR3ApicHlp_Lock(PPDMDEVINS pDevIns, int rc)
|
---|
3970 | {
|
---|
3971 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3972 | return pdmLockEx(pDevIns->Internal.s.pVMHC, rc);
|
---|
3973 | }
|
---|
3974 |
|
---|
3975 |
|
---|
3976 | /** @copydoc PDMAPICHLPR3::pfnUnlock */
|
---|
3977 | static DECLCALLBACK(void) pdmR3ApicHlp_Unlock(PPDMDEVINS pDevIns)
|
---|
3978 | {
|
---|
3979 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3980 | pdmUnlock(pDevIns->Internal.s.pVMHC);
|
---|
3981 | }
|
---|
3982 | #endif /* VBOX_WITH_PDM_LOCK */
|
---|
3983 |
|
---|
3984 |
|
---|
3985 | /** @copydoc PDMAPICHLPR3::pfnGetGCHelpers */
|
---|
3986 | static DECLCALLBACK(PCPDMAPICHLPGC) pdmR3ApicHlp_GetGCHelpers(PPDMDEVINS pDevIns)
|
---|
3987 | {
|
---|
3988 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
3989 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
3990 | RTGCPTR pGCHelpers = 0;
|
---|
3991 | int rc = PDMR3GetSymbolGC(pDevIns->Internal.s.pVMHC, NULL, "g_pdmGCApicHlp", &pGCHelpers);
|
---|
3992 | AssertReleaseRC(rc);
|
---|
3993 | AssertRelease(pGCHelpers);
|
---|
3994 | LogFlow(("pdmR3ApicHlp_GetGCHelpers: caller='%s'/%d: returns %VGv\n",
|
---|
3995 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pGCHelpers));
|
---|
3996 | return pGCHelpers;
|
---|
3997 | }
|
---|
3998 |
|
---|
3999 |
|
---|
4000 | /** @copydoc PDMAPICHLPR3::pfnGetR0Helpers */
|
---|
4001 | static DECLCALLBACK(PCPDMAPICHLPR0) pdmR3ApicHlp_GetR0Helpers(PPDMDEVINS pDevIns)
|
---|
4002 | {
|
---|
4003 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
4004 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
4005 | PCPDMAPICHLPR0 pR0Helpers = 0;
|
---|
4006 | int rc = PDMR3GetSymbolR0(pDevIns->Internal.s.pVMHC, NULL, "g_pdmR0ApicHlp", &pR0Helpers);
|
---|
4007 | AssertReleaseRC(rc);
|
---|
4008 | AssertRelease(pR0Helpers);
|
---|
4009 | LogFlow(("pdmR3ApicHlp_GetR0Helpers: caller='%s'/%d: returns %VHv\n",
|
---|
4010 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pR0Helpers));
|
---|
4011 | return pR0Helpers;
|
---|
4012 | }
|
---|
4013 |
|
---|
4014 |
|
---|
4015 | /** @copydoc PDMIOAPICHLPR3::pfnApicBusDeliver */
|
---|
4016 | static DECLCALLBACK(void) pdmR3IoApicHlp_ApicBusDeliver(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
|
---|
4017 | uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode)
|
---|
4018 | {
|
---|
4019 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
4020 | PVM pVM = pDevIns->Internal.s.pVMHC;
|
---|
4021 | #ifndef VBOX_WITH_PDM_LOCK
|
---|
4022 | VM_ASSERT_EMT(pVM);
|
---|
4023 | #endif
|
---|
4024 | LogFlow(("pdmR3IoApicHlp_ApicBusDeliver: caller='%s'/%d: u8Dest=%RX8 u8DestMode=%RX8 u8DeliveryMode=%RX8 iVector=%RX8 u8Polarity=%RX8 u8TriggerMode=%RX8\n",
|
---|
4025 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, u8Dest, u8DestMode, u8DeliveryMode, iVector, u8Polarity, u8TriggerMode));
|
---|
4026 | if (pVM->pdm.s.Apic.pfnBusDeliverR3)
|
---|
4027 | pVM->pdm.s.Apic.pfnBusDeliverR3(pVM->pdm.s.Apic.pDevInsR3, u8Dest, u8DestMode, u8DeliveryMode, iVector, u8Polarity, u8TriggerMode);
|
---|
4028 | }
|
---|
4029 |
|
---|
4030 |
|
---|
4031 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
4032 | /** @copydoc PDMIOAPICHLPR3::pfnLock */
|
---|
4033 | static DECLCALLBACK(int) pdmR3IoApicHlp_Lock(PPDMDEVINS pDevIns, int rc)
|
---|
4034 | {
|
---|
4035 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
4036 | return pdmLockEx(pDevIns->Internal.s.pVMHC, rc);
|
---|
4037 | }
|
---|
4038 |
|
---|
4039 |
|
---|
4040 | /** @copydoc PDMIOAPICHLPR3::pfnUnlock */
|
---|
4041 | static DECLCALLBACK(void) pdmR3IoApicHlp_Unlock(PPDMDEVINS pDevIns)
|
---|
4042 | {
|
---|
4043 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
4044 | pdmUnlock(pDevIns->Internal.s.pVMHC);
|
---|
4045 | }
|
---|
4046 | #endif /* VBOX_WITH_PDM_LOCK */
|
---|
4047 |
|
---|
4048 |
|
---|
4049 | /** @copydoc PDMIOAPICHLPR3::pfnGetGCHelpers */
|
---|
4050 | static DECLCALLBACK(PCPDMIOAPICHLPGC) pdmR3IoApicHlp_GetGCHelpers(PPDMDEVINS pDevIns)
|
---|
4051 | {
|
---|
4052 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
4053 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
4054 | RTGCPTR pGCHelpers = 0;
|
---|
4055 | int rc = PDMR3GetSymbolGC(pDevIns->Internal.s.pVMHC, NULL, "g_pdmGCIoApicHlp", &pGCHelpers);
|
---|
4056 | AssertReleaseRC(rc);
|
---|
4057 | AssertRelease(pGCHelpers);
|
---|
4058 | LogFlow(("pdmR3IoApicHlp_GetGCHelpers: caller='%s'/%d: returns %VGv\n",
|
---|
4059 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pGCHelpers));
|
---|
4060 | return pGCHelpers;
|
---|
4061 | }
|
---|
4062 |
|
---|
4063 |
|
---|
4064 | /** @copydoc PDMIOAPICHLPR3::pfnGetR0Helpers */
|
---|
4065 | static DECLCALLBACK(PCPDMIOAPICHLPR0) pdmR3IoApicHlp_GetR0Helpers(PPDMDEVINS pDevIns)
|
---|
4066 | {
|
---|
4067 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
4068 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
4069 | PCPDMIOAPICHLPR0 pR0Helpers = 0;
|
---|
4070 | int rc = PDMR3GetSymbolR0(pDevIns->Internal.s.pVMHC, NULL, "g_pdmR0IoApicHlp", &pR0Helpers);
|
---|
4071 | AssertReleaseRC(rc);
|
---|
4072 | AssertRelease(pR0Helpers);
|
---|
4073 | LogFlow(("pdmR3IoApicHlp_GetR0Helpers: caller='%s'/%d: returns %VHv\n",
|
---|
4074 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pR0Helpers));
|
---|
4075 | return pR0Helpers;
|
---|
4076 | }
|
---|
4077 |
|
---|
4078 |
|
---|
4079 | /** @copydoc PDMPCIHLPR3::pfnIsaSetIrq */
|
---|
4080 | static DECLCALLBACK(void) pdmR3PciHlp_IsaSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
|
---|
4081 | {
|
---|
4082 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
4083 | #ifndef VBOX_WITH_PDM_LOCK
|
---|
4084 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
4085 | #endif
|
---|
4086 | Log4(("pdmR3PciHlp_IsaSetIrq: iIrq=%d iLevel=%d\n", iIrq, iLevel));
|
---|
4087 | PDMIsaSetIrq(pDevIns->Internal.s.pVMHC, iIrq, iLevel);
|
---|
4088 | }
|
---|
4089 |
|
---|
4090 |
|
---|
4091 | /** @copydoc PDMPCIHLPR3::pfnIoApicSetIrq */
|
---|
4092 | static DECLCALLBACK(void) pdmR3PciHlp_IoApicSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
|
---|
4093 | {
|
---|
4094 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
4095 | #ifndef VBOX_WITH_PDM_LOCK
|
---|
4096 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
4097 | #endif
|
---|
4098 | Log4(("pdmR3PciHlp_IsaSetIrq: iIrq=%d iLevel=%d\n", iIrq, iLevel));
|
---|
4099 | PDMIoApicSetIrq(pDevIns->Internal.s.pVMHC, iIrq, iLevel);
|
---|
4100 | }
|
---|
4101 |
|
---|
4102 |
|
---|
4103 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
4104 | /** @copydoc PDMPCIHLPR3::pfnLock */
|
---|
4105 | static DECLCALLBACK(int) pdmR3PciHlp_Lock(PPDMDEVINS pDevIns, int rc)
|
---|
4106 | {
|
---|
4107 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
4108 | return pdmLockEx(pDevIns->Internal.s.pVMHC, rc);
|
---|
4109 | }
|
---|
4110 |
|
---|
4111 |
|
---|
4112 | /** @copydoc PDMPCIHLPR3::pfnUnlock */
|
---|
4113 | static DECLCALLBACK(void) pdmR3PciHlp_Unlock(PPDMDEVINS pDevIns)
|
---|
4114 | {
|
---|
4115 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
4116 | pdmUnlock(pDevIns->Internal.s.pVMHC);
|
---|
4117 | }
|
---|
4118 | #endif /* VBOX_WITH_PDM_LOCK */
|
---|
4119 |
|
---|
4120 |
|
---|
4121 | /** @copydoc PDMPCIHLPR3::pfnGetGCHelpers */
|
---|
4122 | static DECLCALLBACK(PCPDMPCIHLPGC) pdmR3PciHlp_GetGCHelpers(PPDMDEVINS pDevIns)
|
---|
4123 | {
|
---|
4124 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
4125 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
4126 | RTGCPTR pGCHelpers = 0;
|
---|
4127 | int rc = PDMR3GetSymbolGC(pDevIns->Internal.s.pVMHC, NULL, "g_pdmGCPciHlp", &pGCHelpers);
|
---|
4128 | AssertReleaseRC(rc);
|
---|
4129 | AssertRelease(pGCHelpers);
|
---|
4130 | LogFlow(("pdmR3IoApicHlp_GetGCHelpers: caller='%s'/%d: returns %VGv\n",
|
---|
4131 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pGCHelpers));
|
---|
4132 | return pGCHelpers;
|
---|
4133 | }
|
---|
4134 |
|
---|
4135 |
|
---|
4136 | /** @copydoc PDMPCIHLPR3::pfnGetR0Helpers */
|
---|
4137 | static DECLCALLBACK(PCPDMPCIHLPR0) pdmR3PciHlp_GetR0Helpers(PPDMDEVINS pDevIns)
|
---|
4138 | {
|
---|
4139 | PDMDEV_ASSERT_DEVINS(pDevIns);
|
---|
4140 | VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
|
---|
4141 | PCPDMPCIHLPR0 pR0Helpers = 0;
|
---|
4142 | int rc = PDMR3GetSymbolR0(pDevIns->Internal.s.pVMHC, NULL, "g_pdmR0PciHlp", &pR0Helpers);
|
---|
4143 | AssertReleaseRC(rc);
|
---|
4144 | AssertRelease(pR0Helpers);
|
---|
4145 | LogFlow(("pdmR3IoApicHlp_GetR0Helpers: caller='%s'/%d: returns %VHv\n",
|
---|
4146 | pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pR0Helpers));
|
---|
4147 | return pR0Helpers;
|
---|
4148 | }
|
---|
4149 |
|
---|
4150 |
|
---|
4151 | /**
|
---|
4152 | * Locates a LUN.
|
---|
4153 | *
|
---|
4154 | * @returns VBox status code.
|
---|
4155 | * @param pVM VM Handle.
|
---|
4156 | * @param pszDevice Device name.
|
---|
4157 | * @param iInstance Device instance.
|
---|
4158 | * @param iLun The Logical Unit to obtain the interface of.
|
---|
4159 | * @param ppLun Where to store the pointer to the LUN if found.
|
---|
4160 | * @thread Try only do this in EMT...
|
---|
4161 | */
|
---|
4162 | int pdmR3DevFindLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMLUN *ppLun)
|
---|
4163 | {
|
---|
4164 | /*
|
---|
4165 | * Iterate registered devices looking for the device.
|
---|
4166 | */
|
---|
4167 | RTUINT cchDevice = strlen(pszDevice);
|
---|
4168 | for (PPDMDEV pDev = pVM->pdm.s.pDevs; pDev; pDev = pDev->pNext)
|
---|
4169 | {
|
---|
4170 | if ( pDev->cchName == cchDevice
|
---|
4171 | && !memcmp(pDev->pDevReg->szDeviceName, pszDevice, cchDevice))
|
---|
4172 | {
|
---|
4173 | /*
|
---|
4174 | * Iterate device instances.
|
---|
4175 | */
|
---|
4176 | for (PPDMDEVINS pDevIns = pDev->pInstances; pDevIns; pDevIns = pDevIns->Internal.s.pPerDeviceNextHC)
|
---|
4177 | {
|
---|
4178 | if (pDevIns->iInstance == iInstance)
|
---|
4179 | {
|
---|
4180 | /*
|
---|
4181 | * Iterate luns.
|
---|
4182 | */
|
---|
4183 | for (PPDMLUN pLun = pDevIns->Internal.s.pLunsHC; pLun; pLun = pLun->pNext)
|
---|
4184 | {
|
---|
4185 | if (pLun->iLun == iLun)
|
---|
4186 | {
|
---|
4187 | *ppLun = pLun;
|
---|
4188 | return VINF_SUCCESS;
|
---|
4189 | }
|
---|
4190 | }
|
---|
4191 | return VERR_PDM_LUN_NOT_FOUND;
|
---|
4192 | }
|
---|
4193 | }
|
---|
4194 | return VERR_PDM_DEVICE_INSTANCE_NOT_FOUND;
|
---|
4195 | }
|
---|
4196 | }
|
---|
4197 | return VERR_PDM_DEVICE_NOT_FOUND;
|
---|
4198 | }
|
---|
4199 |
|
---|
4200 |
|
---|
4201 | /**
|
---|
4202 | * Attaches a preconfigured driver to an existing device instance.
|
---|
4203 | *
|
---|
4204 | * This is used to change drivers and suchlike at runtime.
|
---|
4205 | *
|
---|
4206 | * @returns VBox status code.
|
---|
4207 | * @param pVM VM Handle.
|
---|
4208 | * @param pszDevice Device name.
|
---|
4209 | * @param iInstance Device instance.
|
---|
4210 | * @param iLun The Logical Unit to obtain the interface of.
|
---|
4211 | * @param ppBase Where to store the base interface pointer. Optional.
|
---|
4212 | * @thread EMT
|
---|
4213 | */
|
---|
4214 | PDMR3DECL(int) PDMR3DeviceAttach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMIBASE *ppBase)
|
---|
4215 | {
|
---|
4216 | VM_ASSERT_EMT(pVM);
|
---|
4217 | LogFlow(("PDMR3DeviceAttach: pszDevice=%p:{%s} iInstance=%d iLun=%d ppBase=%p\n",
|
---|
4218 | pszDevice, pszDevice, iInstance, iLun, ppBase));
|
---|
4219 |
|
---|
4220 | /*
|
---|
4221 | * Find the LUN in question.
|
---|
4222 | */
|
---|
4223 | PPDMLUN pLun;
|
---|
4224 | int rc = pdmR3DevFindLun(pVM, pszDevice, iInstance, iLun, &pLun);
|
---|
4225 | if (VBOX_SUCCESS(rc))
|
---|
4226 | {
|
---|
4227 | /*
|
---|
4228 | * Can we attach anything at runtime?
|
---|
4229 | */
|
---|
4230 | PPDMDEVINS pDevIns = pLun->pDevIns;
|
---|
4231 | if (pDevIns->pDevReg->pfnAttach)
|
---|
4232 | {
|
---|
4233 | if (!pLun->pTop)
|
---|
4234 | {
|
---|
4235 | rc = pDevIns->pDevReg->pfnAttach(pDevIns, iLun);
|
---|
4236 |
|
---|
4237 | }
|
---|
4238 | else
|
---|
4239 | rc = VERR_PDM_DRIVER_ALREADY_ATTACHED;
|
---|
4240 | }
|
---|
4241 | else
|
---|
4242 | rc = VERR_PDM_DEVICE_NO_RT_ATTACH;
|
---|
4243 |
|
---|
4244 | if (ppBase)
|
---|
4245 | *ppBase = pLun->pTop ? &pLun->pTop->IBase : NULL;
|
---|
4246 | }
|
---|
4247 | else if (ppBase)
|
---|
4248 | *ppBase = NULL;
|
---|
4249 |
|
---|
4250 | if (ppBase)
|
---|
4251 | LogFlow(("PDMR3DeviceAttach: returns %Vrc *ppBase=%p\n", rc, *ppBase));
|
---|
4252 | else
|
---|
4253 | LogFlow(("PDMR3DeviceAttach: returns %Vrc\n", rc));
|
---|
4254 | return rc;
|
---|
4255 | }
|
---|
4256 |
|
---|
4257 |
|
---|
4258 | /**
|
---|
4259 | * Detaches a driver from an existing device instance.
|
---|
4260 | *
|
---|
4261 | * This is used to change drivers and suchlike at runtime.
|
---|
4262 | *
|
---|
4263 | * @returns VBox status code.
|
---|
4264 | * @param pVM VM Handle.
|
---|
4265 | * @param pszDevice Device name.
|
---|
4266 | * @param iInstance Device instance.
|
---|
4267 | * @param iLun The Logical Unit to obtain the interface of.
|
---|
4268 | * @thread EMT
|
---|
4269 | */
|
---|
4270 | PDMR3DECL(int) PDMR3DeviceDetach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun)
|
---|
4271 | {
|
---|
4272 | VM_ASSERT_EMT(pVM);
|
---|
4273 | LogFlow(("PDMR3DeviceDetach: pszDevice=%p:{%s} iInstance=%d iLun=%d\n",
|
---|
4274 | pszDevice, pszDevice, iInstance, iLun));
|
---|
4275 |
|
---|
4276 | /*
|
---|
4277 | * Find the LUN in question.
|
---|
4278 | */
|
---|
4279 | PPDMLUN pLun;
|
---|
4280 | int rc = pdmR3DevFindLun(pVM, pszDevice, iInstance, iLun, &pLun);
|
---|
4281 | if (VBOX_SUCCESS(rc))
|
---|
4282 | {
|
---|
4283 | /*
|
---|
4284 | * Can we detach anything at runtime?
|
---|
4285 | */
|
---|
4286 | PPDMDEVINS pDevIns = pLun->pDevIns;
|
---|
4287 | if (pDevIns->pDevReg->pfnDetach)
|
---|
4288 | {
|
---|
4289 | if (pLun->pTop)
|
---|
4290 | rc = pdmR3DrvDetach(pLun->pTop);
|
---|
4291 | else
|
---|
4292 | rc = VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN;
|
---|
4293 | }
|
---|
4294 | else
|
---|
4295 | rc = VERR_PDM_DEVICE_NO_RT_DETACH;
|
---|
4296 | }
|
---|
4297 |
|
---|
4298 | LogFlow(("PDMR3DeviceDetach: returns %Vrc\n", rc));
|
---|
4299 | return rc;
|
---|
4300 | }
|
---|
4301 |
|
---|