VirtualBox

source: vbox/trunk/include/VBox/vmm/pdmapi.h@ 80531

Last change on this file since 80531 was 80531, checked in by vboxsync, 6 years ago

VMM,Devices: Some PDM device model refactoring. bugref:9218

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 16.1 KB
Line 
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.215389.xyz. 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
43RT_C_DECLS_BEGIN
44
45/** @defgroup grp_pdm The Pluggable Device Manager API
46 * @ingroup grp_vmm
47 * @{
48 */
49
50VMMDECL(int) PDMGetInterrupt(PVMCPUCC pVCpu, uint8_t *pu8Interrupt);
51VMMDECL(int) PDMIsaSetIrq(PVMCC pVM, uint8_t u8Irq, uint8_t u8Level, uint32_t uTagSrc);
52VMM_INT_DECL(bool) PDMHasIoApic(PVM pVM);
53VMM_INT_DECL(bool) PDMHasApic(PVM pVM);
54VMM_INT_DECL(int) PDMIoApicSetIrq(PVM pVM, uint8_t u8Irq, uint8_t u8Level, uint32_t uTagSrc);
55VMM_INT_DECL(int) PDMIoApicBroadcastEoi(PVM pVM, uint8_t uVector);
56VMM_INT_DECL(int) PDMIoApicSendMsi(PVM pVM, RTGCPHYS GCAddr, uint32_t uValue, uint32_t uTagSrc);
57VMM_INT_DECL(int) PDMVmmDevHeapR3ToGCPhys(PVM pVM, RTR3PTR pv, RTGCPHYS *pGCPhys);
58VMM_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 */
69typedef DECLCALLBACK(void) FNPDMVMMDEVHEAPNOTIFY(PVM pVM, void *pvAllocation, RTGCPHYS GCPhysAllocation);
70/** Pointer (ring-3) to a FNPDMVMMDEVHEAPNOTIFY function. */
71typedef 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 */
78VMMR3_INT_DECL(int) PDMR3InitUVM(PUVM pUVM);
79VMMR3_INT_DECL(int) PDMR3LdrLoadVMMR0U(PUVM pUVM);
80VMMR3_INT_DECL(int) PDMR3Init(PVM pVM);
81VMMR3_INT_DECL(int) PDMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
82VMMR3DECL(void) PDMR3PowerOn(PVM pVM);
83VMMR3_INT_DECL(bool) PDMR3GetResetInfo(PVM pVM, uint32_t fOverride, uint32_t *pfResetFlags);
84VMMR3_INT_DECL(void) PDMR3ResetCpu(PVMCPU pVCpu);
85VMMR3_INT_DECL(void) PDMR3Reset(PVM pVM);
86VMMR3_INT_DECL(void) PDMR3MemSetup(PVM pVM, bool fAtReset);
87VMMR3_INT_DECL(void) PDMR3SoftReset(PVM pVM, uint32_t fResetFlags);
88VMMR3_INT_DECL(void) PDMR3Suspend(PVM pVM);
89VMMR3_INT_DECL(void) PDMR3Resume(PVM pVM);
90VMMR3DECL(void) PDMR3PowerOff(PVM pVM);
91VMMR3_INT_DECL(void) PDMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
92VMMR3_INT_DECL(int) PDMR3Term(PVM pVM);
93VMMR3_INT_DECL(void) PDMR3TermUVM(PUVM pUVM);
94VMMR3_INT_DECL(bool) PDMR3HasLoadedState(PVM pVM);
95
96/** PDM loader context indicator. */
97typedef enum PDMLDRCTX
98{
99 /** Invalid zero value. */
100 PDMLDRCTX_INVALID = 0,
101 /** Ring-0 context. */
102 PDMLDRCTX_RING_0,
103 /** Ring-3 context. */
104 PDMLDRCTX_RING_3,
105 /** Raw-mode context. */
106 PDMLDRCTX_RAW_MODE,
107 /** End of valid context values. */
108 PDMLDRCTX_END,
109 /** 32-bit type hack. */
110 PDMLDRCTX_32BIT_HACK = 0x7fffffff
111} PDMLDRCTX;
112
113/**
114 * Module enumeration callback function.
115 *
116 * @returns VBox status.
117 * Failure will stop the search and return the return code.
118 * Warnings will be ignored and not returned.
119 * @param pVM The cross context VM structure.
120 * @param pszFilename Module filename.
121 * @param pszName Module name. (short and unique)
122 * @param ImageBase Address where to executable image is loaded.
123 * @param cbImage Size of the executable image.
124 * @param enmCtx The context the module is loaded into.
125 * @param pvArg User argument.
126 */
127typedef DECLCALLBACK(int) FNPDMR3ENUM(PVM pVM, const char *pszFilename, const char *pszName,
128 RTUINTPTR ImageBase, size_t cbImage, PDMLDRCTX enmCtx, void *pvArg);
129/** Pointer to a FNPDMR3ENUM() function. */
130typedef FNPDMR3ENUM *PFNPDMR3ENUM;
131VMMR3DECL(int) PDMR3LdrEnumModules(PVM pVM, PFNPDMR3ENUM pfnCallback, void *pvArg);
132VMMR3_INT_DECL(void) PDMR3LdrRelocateU(PUVM pUVM, RTGCINTPTR offDelta);
133VMMR3_INT_DECL(int) PDMR3LdrLoadR0(PUVM pUVM, const char *pszModule);
134VMMR3_INT_DECL(int) PDMR3LdrGetSymbolR3(PVM pVM, const char *pszModule, const char *pszSymbol, void **ppvValue);
135VMMR3DECL(int) PDMR3LdrGetSymbolR0(PVM pVM, const char *pszModule, const char *pszSymbol, PRTR0PTR ppvValue);
136VMMR3DECL(int) PDMR3LdrGetSymbolR0Lazy(PVM pVM, const char *pszModule, const char *pszSearchPath, const char *pszSymbol, PRTR0PTR ppvValue);
137VMMR3DECL(int) PDMR3LdrLoadRC(PVM pVM, const char *pszFilename, const char *pszName);
138VMMR3DECL(int) PDMR3LdrGetSymbolRC(PVM pVM, const char *pszModule, const char *pszSymbol, PRTRCPTR pRCPtrValue);
139VMMR3DECL(int) PDMR3LdrGetSymbolRCLazy(PVM pVM, const char *pszModule, const char *pszSearchPath, const char *pszSymbol,
140 PRTRCPTR pRCPtrValue);
141VMMR3_INT_DECL(int) PDMR3LdrQueryRCModFromPC(PVM pVM, RTRCPTR uPC,
142 char *pszModName, size_t cchModName, PRTRCPTR pMod,
143 char *pszNearSym1, size_t cchNearSym1, PRTRCPTR pNearSym1,
144 char *pszNearSym2, size_t cchNearSym2, PRTRCPTR pNearSym2);
145VMMR3_INT_DECL(int) PDMR3LdrQueryR0ModFromPC(PVM pVM, RTR0PTR uPC,
146 char *pszModName, size_t cchModName, PRTR0PTR pMod,
147 char *pszNearSym1, size_t cchNearSym1, PRTR0PTR pNearSym1,
148 char *pszNearSym2, size_t cchNearSym2, PRTR0PTR pNearSym2);
149VMMR3_INT_DECL(int) PDMR3LdrGetInterfaceSymbols(PVM pVM, void *pvInterface, size_t cbInterface,
150 const char *pszModule, const char *pszSearchPath,
151 const char *pszSymPrefix, const char *pszSymList,
152 bool fRing0OrRC);
153
154VMMR3DECL(int) PDMR3QueryDevice(PUVM pUVM, const char *pszDevice, unsigned iInstance, PPPDMIBASE ppBase);
155VMMR3DECL(int) PDMR3QueryDeviceLun(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMIBASE ppBase);
156VMMR3DECL(int) PDMR3QueryLun(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMIBASE ppBase);
157VMMR3DECL(int) PDMR3QueryDriverOnLun(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun,
158 const char *pszDriver, PPPDMIBASE ppBase);
159VMMR3DECL(int) PDMR3DeviceAttach(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun, uint32_t fFlags,
160 PPDMIBASE *ppBase);
161VMMR3DECL(int) PDMR3DeviceDetach(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun, uint32_t fFlags);
162VMMR3_INT_DECL(PPDMCRITSECT) PDMR3DevGetCritSect(PVM pVM, PPDMDEVINS pDevIns);
163VMMR3DECL(int) PDMR3DriverAttach(PUVM pUVM, const char *pszDevice, unsigned iDevIns, unsigned iLun, uint32_t fFlags,
164 PPPDMIBASE ppBase);
165VMMR3DECL(int) PDMR3DriverDetach(PUVM pUVM, const char *pszDevice, unsigned iDevIns, unsigned iLun,
166 const char *pszDriver, unsigned iOccurrence, uint32_t fFlags);
167VMMR3DECL(int) PDMR3DriverReattach(PUVM pVM, const char *pszDevice, unsigned iDevIns, unsigned iLun,
168 const char *pszDriver, unsigned iOccurrence, uint32_t fFlags, PCFGMNODE pCfg,
169 PPPDMIBASE ppBase);
170VMMR3DECL(void) PDMR3DmaRun(PVM pVM);
171VMMR3_INT_DECL(int) PDMR3LockCall(PVM pVM);
172
173VMMR3_INT_DECL(int) PDMR3VmmDevHeapAlloc(PVM pVM, size_t cbSize, PFNPDMVMMDEVHEAPNOTIFY pfnNotify, RTR3PTR *ppv);
174VMMR3_INT_DECL(int) PDMR3VmmDevHeapFree(PVM pVM, RTR3PTR pv);
175VMMR3_INT_DECL(int) PDMR3TracingConfig(PVM pVM, const char *pszName, size_t cchName, bool fEnable, bool fApply);
176VMMR3_INT_DECL(bool) PDMR3TracingAreAll(PVM pVM, bool fEnabled);
177VMMR3_INT_DECL(int) PDMR3TracingQueryConfig(PVM pVM, char *pszConfig, size_t cbConfig);
178/** @} */
179#endif /* IN_RING3 */
180
181
182
183/** @defgroup grp_pdm_rc The PDM Raw-Mode Context API
184 * @{
185 */
186/** @} */
187
188
189
190/** @defgroup grp_pdm_r0 The PDM Ring-0 Context API
191 * @{
192 */
193VMMR0_INT_DECL(void) PDMR0Init(void *hMod);
194VMMR0DECL(int) PDMR0DeviceRegisterModule(void *hMod, struct PDMDEVMODREGR0 *pModReg);
195VMMR0DECL(int) PDMR0DeviceDeregisterModule(void *hMod, struct PDMDEVMODREGR0 *pModReg);
196
197VMMR0_INT_DECL(void) PDMR0InitPerVMData(PGVM pGVM);
198VMMR0_INT_DECL(void) PDMR0CleanupVM(PGVM pGVM);
199
200/**
201 * Request buffer for PDMR0DriverCallReqHandler / VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER.
202 * @see PDMR0DriverCallReqHandler.
203 */
204typedef struct PDMDRIVERCALLREQHANDLERREQ
205{
206 /** The header. */
207 SUPVMMR0REQHDR Hdr;
208 /** The driver instance. */
209 PPDMDRVINSR0 pDrvInsR0;
210 /** The operation. */
211 uint32_t uOperation;
212 /** Explicit alignment padding. */
213 uint32_t u32Alignment;
214 /** Optional 64-bit integer argument. */
215 uint64_t u64Arg;
216} PDMDRIVERCALLREQHANDLERREQ;
217/** Pointer to a PDMR0DriverCallReqHandler / VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER
218 * request buffer. */
219typedef PDMDRIVERCALLREQHANDLERREQ *PPDMDRIVERCALLREQHANDLERREQ;
220
221VMMR0_INT_DECL(int) PDMR0DriverCallReqHandler(PGVM pGVM, PPDMDRIVERCALLREQHANDLERREQ pReq);
222
223/**
224 * Request buffer for PDMR0DeviceCallReqHandler / VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER.
225 * @see PDMR0DeviceCallReqHandler.
226 */
227typedef struct PDMDEVICECALLREQHANDLERREQ
228{
229 /** The header. */
230 SUPVMMR0REQHDR Hdr;
231 /** The device instance. */
232 PPDMDEVINSR0 pDevInsR0;
233 /** The request handler for the device. */
234 PFNPDMDEVREQHANDLERR0 pfnReqHandlerR0;
235 /** The operation. */
236 uint32_t uOperation;
237 /** Explicit alignment padding. */
238 uint32_t u32Alignment;
239 /** Optional 64-bit integer argument. */
240 uint64_t u64Arg;
241} PDMDEVICECALLREQHANDLERREQ;
242/** Pointer to a PDMR0DeviceCallReqHandler /
243 * VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER request buffer. */
244typedef PDMDEVICECALLREQHANDLERREQ *PPDMDEVICECALLREQHANDLERREQ;
245
246VMMR0_INT_DECL(int) PDMR0DeviceCallReqHandler(PGVM pGVM, PPDMDEVICECALLREQHANDLERREQ pReq);
247
248
249/**
250 * Request buffer for PDMR0DeviceCreateReqHandler / VMMR0_DO_PDM_DEVICE_CREATE.
251 * @see PDMR0DeviceCreateReqHandler.
252 */
253typedef struct PDMDEVICECREATEREQ
254{
255 /** The header. */
256 SUPVMMR0REQHDR Hdr;
257 /** Out: Where to return the address of the ring-3 device instance. */
258 PPDMDEVINSR3 pDevInsR3;
259
260 /** Copy of PDMDEVREGR3::fFlags for matching with PDMDEVREGR0::fFlags. */
261 uint32_t fFlags;
262 /** Copy of PDMDEVREGR3::fClass for matching with PDMDEVREGR0::fFlags. */
263 uint32_t fClass;
264 /** Copy of PDMDEVREGR3::cMaxInstances for matching with
265 * PDMDEVREGR0::cMaxInstances. */
266 uint32_t cMaxInstances;
267 /** Copy of PDMDEVREGR3::uSharedVersion for matching with
268 * PDMDEVREGR0::uSharedVersion. */
269 uint32_t uSharedVersion;
270 /** Copy of PDMDEVREGR3::cbInstanceShared for matching with
271 * PDMDEVREGR0::cbInstanceShared. */
272 uint32_t cbInstanceShared;
273 /** Copy of PDMDEVREGR3::cbInstanceCC. */
274 uint32_t cbInstanceR3;
275 /** Copy of PDMDEVREGR3::cbInstanceRC for matching with
276 * PDMDEVREGR0::cbInstanceRC. */
277 uint32_t cbInstanceRC;
278
279 /** The device instance ordinal. */
280 uint32_t iInstance;
281 /** Set if the raw-mode component is desired. */
282 bool fRCEnabled;
283 /** Explicit padding. */
284 bool afReserved[3];
285
286 /** In: Device name. */
287 char szDevName[32];
288 /** In: The module name (no path). */
289 char szModName[32];
290} PDMDEVICECREATEREQ;
291/** Pointer to a PDMR0DeviceCreate / VMMR0_DO_PDM_DEVICE_CREATE request buffer. */
292typedef PDMDEVICECREATEREQ *PPDMDEVICECREATEREQ;
293
294VMMR0_INT_DECL(int) PDMR0DeviceCreateReqHandler(PGVM pGVM, PPDMDEVICECREATEREQ pReq);
295
296/**
297 * The ring-0 device call to make.
298 */
299typedef enum PDMDEVICEGENCALL
300{
301 PDMDEVICEGENCALL_INVALID = 0,
302 PDMDEVICEGENCALL_CONSTRUCT,
303 PDMDEVICEGENCALL_DESTRUCT,
304 PDMDEVICEGENCALL_END,
305 PDMDEVICEGENCALL_32BIT_HACK = 0x7fffffff
306} PDMDEVICEGENCALL;
307
308/**
309 * Request buffer for PDMR0DeviceGenCallReqHandler / VMMR0_DO_PDM_DEVICE_GEN_CALL.
310 * @see PDMR0DeviceGenCallReqHandler.
311 */
312typedef struct PDMDEVICEGENCALLREQ
313{
314 /** The header. */
315 SUPVMMR0REQHDR Hdr;
316 /** The ring-3 device instance. */
317 PPDMDEVINSR3 pDevInsR3;
318 /** The ring-0 device handle. */
319 uint32_t idxR0Device;
320 /** The call to make. */
321 PDMDEVICEGENCALL enmCall;
322} PDMDEVICEGENCALLREQ;
323/** Pointer to a PDMR0DeviceGenCallReqHandler / VMMR0_DO_PDM_DEVICE_GEN_CALL request buffer. */
324typedef PDMDEVICEGENCALLREQ *PPDMDEVICEGENCALLREQ;
325
326VMMR0_INT_DECL(int) PDMR0DeviceGenCallReqHandler(PGVM pGVM, PPDMDEVICEGENCALLREQ pReq);
327
328/**
329 * Request buffer for PDMR0DeviceCompatSetCritSectReqHandler / VMMR0_DO_PDM_DEVICE_COMPAT_SET_CRITSECT
330 * @see PDMR0DeviceCompatSetCritSectReqHandler.
331 */
332typedef struct PDMDEVICECOMPATSETCRITSECTREQ
333{
334 /** The header. */
335 SUPVMMR0REQHDR Hdr;
336 /** The ring-3 device instance. */
337 PPDMDEVINSR3 pDevInsR3;
338 /** The ring-0 device handle. */
339 uint32_t idxR0Device;
340 /** The critical section address (ring-3). */
341 R3PTRTYPE(PPDMCRITSECT) pCritSectR3;
342} PDMDEVICECOMPATSETCRITSECTREQ;
343/** Pointer to a PDMR0DeviceGenCallReqHandler / VMMR0_DO_PDM_DEVICE_GEN_CALL request buffer. */
344typedef PDMDEVICECOMPATSETCRITSECTREQ *PPDMDEVICECOMPATSETCRITSECTREQ;
345
346VMMR0_INT_DECL(int) PDMR0DeviceCompatSetCritSectReqHandler(PGVM pGVM, PPDMDEVICECOMPATSETCRITSECTREQ pReq);
347
348/**
349 * Request buffer for PDMR0DeviceCompatRegPciDevReqHandler / VMMR0_DO_PDM_DEVICE_COMPAT_REG_PCIDEV
350 * @see PDMR0DeviceCompatRegPciDevReqHandler.
351 */
352typedef struct PDMDEVICECOMPATREGPCIDEVREQ
353{
354 /** The header. */
355 SUPVMMR0REQHDR Hdr;
356 /** The ring-3 device instance. */
357 PPDMDEVINSR3 pDevInsR3;
358 /** The ring-0 device handle. */
359 uint32_t idxR0Device;
360 /** The PCI device address (ring-3). */
361 R3PTRTYPE(PPDMPCIDEV) pPciDevR3;
362} PDMDEVICECOMPATREGPCIDEVREQ;
363/** Pointer to a PDMR0DeviceGenCallReqHandler / VMMR0_DO_PDM_DEVICE_GEN_CALL request buffer. */
364typedef PDMDEVICECOMPATREGPCIDEVREQ *PPDMDEVICECOMPATREGPCIDEVREQ;
365
366VMMR0_INT_DECL(int) PDMR0DeviceCompatRegPciDevReqHandler(PGVM pGVM, PPDMDEVICECOMPATREGPCIDEVREQ pReq);
367
368/** @} */
369
370RT_C_DECLS_END
371
372/** @} */
373
374#endif /* !VBOX_INCLUDED_vmm_pdmapi_h */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette