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