1 | /** @file
|
---|
2 | * PDM - Pluggable Device Manager, Core API.
|
---|
3 | *
|
---|
4 | * The 'Core API' has been put in a different header because everyone
|
---|
5 | * is currently including pdm.h. So, pdm.h is for including all of the
|
---|
6 | * PDM stuff, while pdmapi.h is for the core stuff.
|
---|
7 | */
|
---|
8 |
|
---|
9 | /*
|
---|
10 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
11 | *
|
---|
12 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
13 | * available from http://www.virtualbox.org. This file is free software;
|
---|
14 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
15 | * General Public License (GPL) as published by the Free Software
|
---|
16 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
17 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
18 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
19 | *
|
---|
20 | * The contents of this file may alternatively be used under the terms
|
---|
21 | * of the Common Development and Distribution License Version 1.0
|
---|
22 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
23 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
24 | * CDDL are applicable instead of those of the GPL.
|
---|
25 | *
|
---|
26 | * You may elect to license modified versions of this file under the
|
---|
27 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #ifndef VBOX_INCLUDED_vmm_pdmapi_h
|
---|
31 | #define VBOX_INCLUDED_vmm_pdmapi_h
|
---|
32 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
33 | # pragma once
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | #include <VBox/vmm/pdmcommon.h>
|
---|
37 | #ifdef IN_RING3
|
---|
38 | # include <VBox/vmm/vmapi.h>
|
---|
39 | #endif
|
---|
40 | #include <VBox/sup.h>
|
---|
41 |
|
---|
42 |
|
---|
43 | RT_C_DECLS_BEGIN
|
---|
44 |
|
---|
45 | /** @defgroup grp_pdm The Pluggable Device Manager API
|
---|
46 | * @ingroup grp_vmm
|
---|
47 | * @{
|
---|
48 | */
|
---|
49 |
|
---|
50 | VMMDECL(int) PDMGetInterrupt(PVMCPU pVCpu, uint8_t *pu8Interrupt);
|
---|
51 | VMMDECL(int) PDMIsaSetIrq(PVM pVM, uint8_t u8Irq, uint8_t u8Level, uint32_t uTagSrc);
|
---|
52 | VMM_INT_DECL(bool) PDMHasIoApic(PVM pVM);
|
---|
53 | VMM_INT_DECL(bool) PDMHasApic(PVM pVM);
|
---|
54 | VMM_INT_DECL(int) PDMIoApicSetIrq(PVM pVM, uint8_t u8Irq, uint8_t u8Level, uint32_t uTagSrc);
|
---|
55 | VMM_INT_DECL(int) PDMIoApicBroadcastEoi(PVM pVM, uint8_t uVector);
|
---|
56 | VMM_INT_DECL(int) PDMIoApicSendMsi(PVM pVM, RTGCPHYS GCAddr, uint32_t uValue, uint32_t uTagSrc);
|
---|
57 | VMM_INT_DECL(int) PDMVmmDevHeapR3ToGCPhys(PVM pVM, RTR3PTR pv, RTGCPHYS *pGCPhys);
|
---|
58 | VMM_INT_DECL(bool) PDMVmmDevHeapIsEnabled(PVM pVM);
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Mapping/unmapping callback for an VMMDev heap allocation.
|
---|
62 | *
|
---|
63 | * @param pVM The cross context VM structure.
|
---|
64 | * @param pvAllocation The allocation address (ring-3).
|
---|
65 | * @param GCPhysAllocation The guest physical address of the mapping if
|
---|
66 | * it's being mapped, NIL_RTGCPHYS if it's being
|
---|
67 | * unmapped.
|
---|
68 | */
|
---|
69 | typedef DECLCALLBACK(void) FNPDMVMMDEVHEAPNOTIFY(PVM pVM, void *pvAllocation, RTGCPHYS GCPhysAllocation);
|
---|
70 | /** Pointer (ring-3) to a FNPDMVMMDEVHEAPNOTIFY function. */
|
---|
71 | typedef R3PTRTYPE(FNPDMVMMDEVHEAPNOTIFY *) PFNPDMVMMDEVHEAPNOTIFY;
|
---|
72 |
|
---|
73 |
|
---|
74 | #if defined(IN_RING3) || defined(DOXYGEN_RUNNING)
|
---|
75 | /** @defgroup grp_pdm_r3 The PDM Host Context Ring-3 API
|
---|
76 | * @{
|
---|
77 | */
|
---|
78 | VMMR3_INT_DECL(int) PDMR3InitUVM(PUVM pUVM);
|
---|
79 | VMMR3_INT_DECL(int) PDMR3LdrLoadVMMR0U(PUVM pUVM);
|
---|
80 | VMMR3_INT_DECL(int) PDMR3Init(PVM pVM);
|
---|
81 | VMMR3_INT_DECL(int) PDMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
|
---|
82 | VMMR3DECL(void) PDMR3PowerOn(PVM pVM);
|
---|
83 | VMMR3_INT_DECL(bool) PDMR3GetResetInfo(PVM pVM, uint32_t fOverride, uint32_t *pfResetFlags);
|
---|
84 | VMMR3_INT_DECL(void) PDMR3ResetCpu(PVMCPU pVCpu);
|
---|
85 | VMMR3_INT_DECL(void) PDMR3Reset(PVM pVM);
|
---|
86 | VMMR3_INT_DECL(void) PDMR3MemSetup(PVM pVM, bool fAtReset);
|
---|
87 | VMMR3_INT_DECL(void) PDMR3SoftReset(PVM pVM, uint32_t fResetFlags);
|
---|
88 | VMMR3_INT_DECL(void) PDMR3Suspend(PVM pVM);
|
---|
89 | VMMR3_INT_DECL(void) PDMR3Resume(PVM pVM);
|
---|
90 | VMMR3DECL(void) PDMR3PowerOff(PVM pVM);
|
---|
91 | VMMR3_INT_DECL(void) PDMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
92 | VMMR3_INT_DECL(int) PDMR3Term(PVM pVM);
|
---|
93 | VMMR3_INT_DECL(void) PDMR3TermUVM(PUVM pUVM);
|
---|
94 |
|
---|
95 | /** PDM loader context indicator. */
|
---|
96 | typedef enum PDMLDRCTX
|
---|
97 | {
|
---|
98 | /** Invalid zero value. */
|
---|
99 | PDMLDRCTX_INVALID = 0,
|
---|
100 | /** Ring-0 context. */
|
---|
101 | PDMLDRCTX_RING_0,
|
---|
102 | /** Ring-3 context. */
|
---|
103 | PDMLDRCTX_RING_3,
|
---|
104 | /** Raw-mode context. */
|
---|
105 | PDMLDRCTX_RAW_MODE,
|
---|
106 | /** End of valid context values. */
|
---|
107 | PDMLDRCTX_END,
|
---|
108 | /** 32-bit type hack. */
|
---|
109 | PDMLDRCTX_32BIT_HACK = 0x7fffffff
|
---|
110 | } PDMLDRCTX;
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * Module enumeration callback function.
|
---|
114 | *
|
---|
115 | * @returns VBox status.
|
---|
116 | * Failure will stop the search and return the return code.
|
---|
117 | * Warnings will be ignored and not returned.
|
---|
118 | * @param pVM The cross context VM structure.
|
---|
119 | * @param pszFilename Module filename.
|
---|
120 | * @param pszName Module name. (short and unique)
|
---|
121 | * @param ImageBase Address where to executable image is loaded.
|
---|
122 | * @param cbImage Size of the executable image.
|
---|
123 | * @param enmCtx The context the module is loaded into.
|
---|
124 | * @param pvArg User argument.
|
---|
125 | */
|
---|
126 | typedef DECLCALLBACK(int) FNPDMR3ENUM(PVM pVM, const char *pszFilename, const char *pszName,
|
---|
127 | RTUINTPTR ImageBase, size_t cbImage, PDMLDRCTX enmCtx, void *pvArg);
|
---|
128 | /** Pointer to a FNPDMR3ENUM() function. */
|
---|
129 | typedef FNPDMR3ENUM *PFNPDMR3ENUM;
|
---|
130 | VMMR3DECL(int) PDMR3LdrEnumModules(PVM pVM, PFNPDMR3ENUM pfnCallback, void *pvArg);
|
---|
131 | VMMR3_INT_DECL(void) PDMR3LdrRelocateU(PUVM pUVM, RTGCINTPTR offDelta);
|
---|
132 | VMMR3_INT_DECL(int) PDMR3LdrGetSymbolR3(PVM pVM, const char *pszModule, const char *pszSymbol, void **ppvValue);
|
---|
133 | VMMR3DECL(int) PDMR3LdrGetSymbolR0(PVM pVM, const char *pszModule, const char *pszSymbol, PRTR0PTR ppvValue);
|
---|
134 | VMMR3DECL(int) PDMR3LdrGetSymbolR0Lazy(PVM pVM, const char *pszModule, const char *pszSearchPath, const char *pszSymbol, PRTR0PTR ppvValue);
|
---|
135 | VMMR3DECL(int) PDMR3LdrLoadRC(PVM pVM, const char *pszFilename, const char *pszName);
|
---|
136 | VMMR3DECL(int) PDMR3LdrGetSymbolRC(PVM pVM, const char *pszModule, const char *pszSymbol, PRTRCPTR pRCPtrValue);
|
---|
137 | VMMR3DECL(int) PDMR3LdrGetSymbolRCLazy(PVM pVM, const char *pszModule, const char *pszSearchPath, const char *pszSymbol,
|
---|
138 | PRTRCPTR pRCPtrValue);
|
---|
139 | VMMR3_INT_DECL(int) PDMR3LdrQueryRCModFromPC(PVM pVM, RTRCPTR uPC,
|
---|
140 | char *pszModName, size_t cchModName, PRTRCPTR pMod,
|
---|
141 | char *pszNearSym1, size_t cchNearSym1, PRTRCPTR pNearSym1,
|
---|
142 | char *pszNearSym2, size_t cchNearSym2, PRTRCPTR pNearSym2);
|
---|
143 | VMMR3_INT_DECL(int) PDMR3LdrQueryR0ModFromPC(PVM pVM, RTR0PTR uPC,
|
---|
144 | char *pszModName, size_t cchModName, PRTR0PTR pMod,
|
---|
145 | char *pszNearSym1, size_t cchNearSym1, PRTR0PTR pNearSym1,
|
---|
146 | char *pszNearSym2, size_t cchNearSym2, PRTR0PTR pNearSym2);
|
---|
147 | VMMR3_INT_DECL(int) PDMR3LdrGetInterfaceSymbols(PVM pVM, void *pvInterface, size_t cbInterface,
|
---|
148 | const char *pszModule, const char *pszSearchPath,
|
---|
149 | const char *pszSymPrefix, const char *pszSymList,
|
---|
150 | bool fRing0OrRC);
|
---|
151 |
|
---|
152 | VMMR3DECL(int) PDMR3QueryDevice(PUVM pUVM, const char *pszDevice, unsigned iInstance, PPPDMIBASE ppBase);
|
---|
153 | VMMR3DECL(int) PDMR3QueryDeviceLun(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMIBASE ppBase);
|
---|
154 | VMMR3DECL(int) PDMR3QueryLun(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMIBASE ppBase);
|
---|
155 | VMMR3DECL(int) PDMR3QueryDriverOnLun(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun,
|
---|
156 | const char *pszDriver, PPPDMIBASE ppBase);
|
---|
157 | VMMR3DECL(int) PDMR3DeviceAttach(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun, uint32_t fFlags,
|
---|
158 | PPDMIBASE *ppBase);
|
---|
159 | VMMR3DECL(int) PDMR3DeviceDetach(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun, uint32_t fFlags);
|
---|
160 | VMMR3_INT_DECL(PPDMCRITSECT) PDMR3DevGetCritSect(PVM pVM, PPDMDEVINS pDevIns);
|
---|
161 | VMMR3DECL(int) PDMR3DriverAttach(PUVM pUVM, const char *pszDevice, unsigned iDevIns, unsigned iLun, uint32_t fFlags,
|
---|
162 | PPPDMIBASE ppBase);
|
---|
163 | VMMR3DECL(int) PDMR3DriverDetach(PUVM pUVM, const char *pszDevice, unsigned iDevIns, unsigned iLun,
|
---|
164 | const char *pszDriver, unsigned iOccurrence, uint32_t fFlags);
|
---|
165 | VMMR3DECL(int) PDMR3DriverReattach(PUVM pVM, const char *pszDevice, unsigned iDevIns, unsigned iLun,
|
---|
166 | const char *pszDriver, unsigned iOccurrence, uint32_t fFlags, PCFGMNODE pCfg,
|
---|
167 | PPPDMIBASE ppBase);
|
---|
168 | VMMR3DECL(void) PDMR3DmaRun(PVM pVM);
|
---|
169 | VMMR3_INT_DECL(int) PDMR3LockCall(PVM pVM);
|
---|
170 |
|
---|
171 | VMMR3_INT_DECL(int) PDMR3VmmDevHeapAlloc(PVM pVM, size_t cbSize, PFNPDMVMMDEVHEAPNOTIFY pfnNotify, RTR3PTR *ppv);
|
---|
172 | VMMR3_INT_DECL(int) PDMR3VmmDevHeapFree(PVM pVM, RTR3PTR pv);
|
---|
173 | VMMR3_INT_DECL(int) PDMR3TracingConfig(PVM pVM, const char *pszName, size_t cchName, bool fEnable, bool fApply);
|
---|
174 | VMMR3_INT_DECL(bool) PDMR3TracingAreAll(PVM pVM, bool fEnabled);
|
---|
175 | VMMR3_INT_DECL(int) PDMR3TracingQueryConfig(PVM pVM, char *pszConfig, size_t cbConfig);
|
---|
176 | /** @} */
|
---|
177 | #endif /* IN_RING3 */
|
---|
178 |
|
---|
179 |
|
---|
180 |
|
---|
181 | /** @defgroup grp_pdm_rc The PDM Raw-Mode Context API
|
---|
182 | * @{
|
---|
183 | */
|
---|
184 | /** @} */
|
---|
185 |
|
---|
186 |
|
---|
187 |
|
---|
188 | /** @defgroup grp_pdm_r0 The PDM Ring-0 Context API
|
---|
189 | * @{
|
---|
190 | */
|
---|
191 |
|
---|
192 | /**
|
---|
193 | * Request buffer for PDMR0DriverCallReqHandler / VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER.
|
---|
194 | * @see PDMR0DriverCallReqHandler.
|
---|
195 | */
|
---|
196 | typedef struct PDMDRIVERCALLREQHANDLERREQ
|
---|
197 | {
|
---|
198 | /** The header. */
|
---|
199 | SUPVMMR0REQHDR Hdr;
|
---|
200 | /** The driver instance. */
|
---|
201 | PPDMDRVINSR0 pDrvInsR0;
|
---|
202 | /** The operation. */
|
---|
203 | uint32_t uOperation;
|
---|
204 | /** Explicit alignment padding. */
|
---|
205 | uint32_t u32Alignment;
|
---|
206 | /** Optional 64-bit integer argument. */
|
---|
207 | uint64_t u64Arg;
|
---|
208 | } PDMDRIVERCALLREQHANDLERREQ;
|
---|
209 | /** Pointer to a PDMR0DriverCallReqHandler / VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER
|
---|
210 | * request buffer. */
|
---|
211 | typedef PDMDRIVERCALLREQHANDLERREQ *PPDMDRIVERCALLREQHANDLERREQ;
|
---|
212 |
|
---|
213 | VMMR0_INT_DECL(int) PDMR0DriverCallReqHandler(PGVM pGVM, PVM pVM, PPDMDRIVERCALLREQHANDLERREQ pReq);
|
---|
214 |
|
---|
215 | /**
|
---|
216 | * Request buffer for PDMR0DeviceCallReqHandler / VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER.
|
---|
217 | * @see PDMR0DeviceCallReqHandler.
|
---|
218 | */
|
---|
219 | typedef struct PDMDEVICECALLREQHANDLERREQ
|
---|
220 | {
|
---|
221 | /** The header. */
|
---|
222 | SUPVMMR0REQHDR Hdr;
|
---|
223 | /** The device instance. */
|
---|
224 | PPDMDEVINSR0 pDevInsR0;
|
---|
225 | /** The request handler for the device. */
|
---|
226 | PFNPDMDEVREQHANDLERR0 pfnReqHandlerR0;
|
---|
227 | /** The operation. */
|
---|
228 | uint32_t uOperation;
|
---|
229 | /** Explicit alignment padding. */
|
---|
230 | uint32_t u32Alignment;
|
---|
231 | /** Optional 64-bit integer argument. */
|
---|
232 | uint64_t u64Arg;
|
---|
233 | } PDMDEVICECALLREQHANDLERREQ;
|
---|
234 | /** Pointer to a PDMR0DeviceCallReqHandler /
|
---|
235 | * VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER request buffer. */
|
---|
236 | typedef PDMDEVICECALLREQHANDLERREQ *PPDMDEVICECALLREQHANDLERREQ;
|
---|
237 |
|
---|
238 | VMMR0_INT_DECL(int) PDMR0DeviceCallReqHandler(PGVM pGVM, PVM pVM, PPDMDEVICECALLREQHANDLERREQ pReq);
|
---|
239 |
|
---|
240 | /** @} */
|
---|
241 |
|
---|
242 | RT_C_DECLS_END
|
---|
243 |
|
---|
244 | /** @} */
|
---|
245 |
|
---|
246 | #endif
|
---|