VirtualBox

source: vbox/trunk/include/VBox/vmm/pdmusb.h@ 99582

Last change on this file since 99582 was 98122, checked in by vboxsync, 2 years ago

VMM/PDM: Fixed assertion in PDMR3ResumeUsb after attaching a virtual MSD.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 66.5 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, USB Devices.
3 */
4
5/*
6 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef VBOX_INCLUDED_vmm_pdmusb_h
37#define VBOX_INCLUDED_vmm_pdmusb_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <VBox/vmm/pdmqueue.h>
43#include <VBox/vmm/pdmcritsect.h>
44#include <VBox/vmm/pdmthread.h>
45#include <VBox/vmm/pdmifs.h>
46#include <VBox/vmm/pdmins.h>
47#include <VBox/vmm/pdmcommon.h>
48#include <VBox/vmm/tm.h>
49#include <VBox/vmm/ssm.h>
50#include <VBox/vmm/cfgm.h>
51#include <VBox/vmm/dbgf.h>
52#include <VBox/vmm/mm.h>
53#include <VBox/vusb.h>
54#include <iprt/errcore.h>
55#include <iprt/stdarg.h>
56
57RT_C_DECLS_BEGIN
58
59/** @defgroup grp_pdm_usbdev The USB Devices API
60 * @ingroup grp_pdm
61 * @{
62 */
63
64
65/**
66 * A string entry for the USB descriptor cache.
67 */
68typedef struct PDMUSBDESCCACHESTRING
69{
70 /** The string index. */
71 uint8_t idx;
72 /** The UTF-8 representation of the string. */
73 const char *psz;
74} PDMUSBDESCCACHESTRING;
75/** Pointer to a const string entry. */
76typedef PDMUSBDESCCACHESTRING const *PCPDMUSBDESCCACHESTRING;
77
78
79/**
80 * A language entry for the USB descriptor cache.
81 */
82typedef struct PDMUSBDESCCACHELANG
83{
84 /** The language ID for the strings in this block. */
85 uint16_t idLang;
86 /** The number of strings in the array. */
87 uint16_t cStrings;
88 /** Pointer to an array of associated strings.
89 * This must be sorted in ascending order by string index as a binary lookup
90 * will be performed. */
91 PCPDMUSBDESCCACHESTRING paStrings;
92} PDMUSBDESCCACHELANG;
93/** Pointer to a const language entry. */
94typedef PDMUSBDESCCACHELANG const *PCPDMUSBDESCCACHELANG;
95
96
97/**
98 * USB descriptor cache.
99 *
100 * This structure is owned by the USB device but provided to the PDM/VUSB layer
101 * thru the PDMUSBREG::pfnGetDescriptorCache method. PDM/VUSB will use the
102 * information here to map addresses to endpoints, perform SET_CONFIGURATION
103 * requests, and optionally perform GET_DESCRIPTOR requests (see flag).
104 *
105 * Currently, only device and configuration descriptors are cached.
106 */
107typedef struct PDMUSBDESCCACHE
108{
109 /** USB device descriptor */
110 PCVUSBDESCDEVICE pDevice;
111 /** USB Descriptor arrays (pDev->bNumConfigurations) */
112 PCVUSBDESCCONFIGEX paConfigs;
113 /** Language IDs and their associated strings.
114 * This must be sorted in ascending order by language ID as a binary lookup
115 * will be used. */
116 PCPDMUSBDESCCACHELANG paLanguages;
117 /** The number of entries in the array pointed to by paLanguages. */
118 uint16_t cLanguages;
119 /** Use the cached descriptors for GET_DESCRIPTOR requests. */
120 bool fUseCachedDescriptors;
121 /** Use the cached string descriptors. */
122 bool fUseCachedStringsDescriptors;
123} PDMUSBDESCCACHE;
124/** Pointer to an USB descriptor cache. */
125typedef PDMUSBDESCCACHE *PPDMUSBDESCCACHE;
126/** Pointer to a const USB descriptor cache. */
127typedef const PDMUSBDESCCACHE *PCPDMUSBDESCCACHE;
128
129
130/** PDM Device Flags.
131 * @{ */
132/** A high-speed capable USB 2.0 device (also required to support full-speed). */
133#define PDM_USBREG_HIGHSPEED_CAPABLE RT_BIT(0)
134/** Indicates that the device implements the saved state handlers. */
135#define PDM_USBREG_SAVED_STATE_SUPPORTED RT_BIT(1)
136/** A SuperSpeed USB 3.0 device. */
137#define PDM_USBREG_SUPERSPEED_CAPABLE RT_BIT(2)
138/** @} */
139
140/** PDM USB Device Registration Structure,
141 *
142 * This structure is used when registering a device from VBoxUsbRegister() in HC Ring-3.
143 * The PDM will make use of this structure until the VM is destroyed.
144 */
145typedef struct PDMUSBREG
146{
147 /** Structure version. PDM_DEVREG_VERSION defines the current version. */
148 uint32_t u32Version;
149 /** Device name. */
150 char szName[32];
151 /** The description of the device. The UTF-8 string pointed to shall, like this structure,
152 * remain unchanged from registration till VM destruction. */
153 const char *pszDescription;
154
155 /** Flags, combination of the PDM_USBREG_FLAGS_* \#defines. */
156 RTUINT fFlags;
157 /** Maximum number of instances (per VM). */
158 RTUINT cMaxInstances;
159 /** Size of the instance data. */
160 RTUINT cbInstance;
161
162
163 /**
164 * Construct an USB device instance for a VM.
165 *
166 * @returns VBox status.
167 * @param pUsbIns The USB device instance data.
168 * If the registration structure is needed, it will be
169 * accessible thru pUsbDev->pReg.
170 * @param iInstance Instance number. Use this to figure out which registers
171 * and such to use. The instance number is also found in
172 * pUsbDev->iInstance, but since it's likely to be
173 * frequently used PDM passes it as parameter.
174 * @param pCfg Configuration node handle for the device. Use this to
175 * obtain the configuration of the device instance. It is
176 * also found in pUsbDev->pCfg, but since it is primary
177 * usage will in this function it is passed as a parameter.
178 * @param pCfgGlobal Handle to the global device configuration. Also found
179 * in pUsbDev->pCfgGlobal.
180 * @remarks This callback is required.
181 */
182 DECLR3CALLBACKMEMBER(int, pfnConstruct,(PPDMUSBINS pUsbIns, int iInstance, PCFGMNODE pCfg, PCFGMNODE pCfgGlobal));
183
184 /**
185 * Destruct an USB device instance.
186 *
187 * Most VM resources are freed by the VM. This callback is provided so that any non-VM
188 * resources can be freed correctly.
189 *
190 * This method will be called regardless of the pfnConstruct result to avoid
191 * complicated failure paths.
192 *
193 * @param pUsbIns The USB device instance data.
194 * @remarks Optional.
195 */
196 DECLR3CALLBACKMEMBER(void, pfnDestruct,(PPDMUSBINS pUsbIns));
197
198
199 /**
200 * Init complete notification.
201 *
202 * This can be done to do communication with other devices and other
203 * initialization which requires everything to be in place.
204 *
205 * @returns VBOX status code.
206 * @param pUsbIns The USB device instance data.
207 * @remarks Optional.
208 * @remarks Not called when hotplugged.
209 */
210 DECLR3CALLBACKMEMBER(int, pfnVMInitComplete,(PPDMUSBINS pUsbIns));
211
212 /**
213 * VM Power On notification.
214 *
215 * @returns VBox status.
216 * @param pUsbIns The USB device instance data.
217 * @remarks Optional.
218 */
219 DECLR3CALLBACKMEMBER(void, pfnVMPowerOn,(PPDMUSBINS pUsbIns));
220
221 /**
222 * VM Reset notification.
223 *
224 * @returns VBox status.
225 * @param pUsbIns The USB device instance data.
226 * @remarks Optional.
227 */
228 DECLR3CALLBACKMEMBER(void, pfnVMReset,(PPDMUSBINS pUsbIns));
229
230 /**
231 * VM Suspend notification.
232 *
233 * @returns VBox status.
234 * @param pUsbIns The USB device instance data.
235 * @remarks Optional.
236 */
237 DECLR3CALLBACKMEMBER(void, pfnVMSuspend,(PPDMUSBINS pUsbIns));
238
239 /**
240 * VM Resume notification.
241 *
242 * This is not called when the device is hotplugged device, instead
243 * pfnHotPlugged will be called.
244 *
245 * @returns VBox status.
246 * @param pUsbIns The USB device instance data.
247 * @remarks Optional.
248 */
249 DECLR3CALLBACKMEMBER(void, pfnVMResume,(PPDMUSBINS pUsbIns));
250
251 /**
252 * VM Power Off notification.
253 *
254 * This is only called when the VMR3PowerOff call is made on a running VM. This
255 * means that there is no notification if the VM was suspended before being
256 * powered of. There will also be no callback when hot plugging devices.
257 *
258 * @param pUsbIns The USB device instance data.
259 */
260 DECLR3CALLBACKMEMBER(void, pfnVMPowerOff,(PPDMUSBINS pUsbIns));
261
262 /**
263 * Called after the constructor when attaching a device at run time.
264 *
265 * This can be used to do tasks normally assigned to pfnInitComplete and/or
266 * pfnVMPowerOn. There will not be a call to pfnVMResume following this.
267 *
268 * @returns VBox status.
269 * @param pUsbIns The USB device instance data.
270 * @remarks Optional.
271 */
272 DECLR3CALLBACKMEMBER(void, pfnHotPlugged,(PPDMUSBINS pUsbIns));
273
274 /**
275 * Called before the destructor when a device is unplugged at run time.
276 *
277 * This can be used to do tasks normally assigned to pfnVMSuspend and/or pfnVMPowerOff.
278 *
279 * @returns VBox status.
280 * @param pUsbIns The USB device instance data.
281 * @remarks Optional.
282 */
283 DECLR3CALLBACKMEMBER(void, pfnHotUnplugged,(PPDMUSBINS pUsbIns));
284 /**
285 * Driver Attach command.
286 *
287 * This is called to let the USB device attach to a driver for a specified LUN
288 * at runtime. This is not called during VM construction, the device constructor
289 * have to attach to all the available drivers.
290 *
291 * @returns VBox status code.
292 * @param pUsbIns The USB device instance data.
293 * @param iLUN The logical unit which is being detached.
294 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines.
295 * @remarks Optional.
296 */
297 DECLR3CALLBACKMEMBER(int, pfnDriverAttach,(PPDMUSBINS pUsbIns, unsigned iLUN, uint32_t fFlags));
298
299 /**
300 * Driver Detach notification.
301 *
302 * This is called when a driver is detaching itself from a LUN of the device.
303 * The device should adjust it's state to reflect this.
304 *
305 * @param pUsbIns The USB device instance data.
306 * @param iLUN The logical unit which is being detached.
307 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines.
308 * @remarks Optional.
309 */
310 DECLR3CALLBACKMEMBER(void, pfnDriverDetach,(PPDMUSBINS pUsbIns, unsigned iLUN, uint32_t fFlags));
311
312 /**
313 * Query the base interface of a logical unit.
314 *
315 * @returns VBOX status code.
316 * @param pUsbIns The USB device instance data.
317 * @param iLUN The logicial unit to query.
318 * @param ppBase Where to store the pointer to the base interface of the LUN.
319 * @remarks Optional.
320 */
321 DECLR3CALLBACKMEMBER(int, pfnQueryInterface,(PPDMUSBINS pUsbIns, unsigned iLUN, PPDMIBASE *ppBase));
322
323 /**
324 * Requests the USB device to reset.
325 *
326 * @returns VBox status code.
327 * @param pUsbIns The USB device instance.
328 * @param fResetOnLinux A hint to the usb proxy.
329 * Don't use this unless you're the linux proxy device.
330 * @thread Any thread.
331 * @remarks Optional.
332 */
333 DECLR3CALLBACKMEMBER(int, pfnUsbReset,(PPDMUSBINS pUsbIns, bool fResetOnLinux));
334
335 /**
336 * Query device and configuration descriptors for the caching and servicing
337 * relevant GET_DESCRIPTOR requests.
338 *
339 * @returns Pointer to the descriptor cache (read-only).
340 * @param pUsbIns The USB device instance.
341 * @remarks Mandatory.
342 */
343 DECLR3CALLBACKMEMBER(PCPDMUSBDESCCACHE, pfnUsbGetDescriptorCache,(PPDMUSBINS pUsbIns));
344
345 /**
346 * SET_CONFIGURATION request.
347 *
348 * @returns VBox status code.
349 * @param pUsbIns The USB device instance.
350 * @param bConfigurationValue The bConfigurationValue of the new configuration.
351 * @param pvOldCfgDesc Internal - for the device proxy.
352 * @param pvOldIfState Internal - for the device proxy.
353 * @param pvNewCfgDesc Internal - for the device proxy.
354 * @remarks Optional.
355 */
356 DECLR3CALLBACKMEMBER(int, pfnUsbSetConfiguration,(PPDMUSBINS pUsbIns, uint8_t bConfigurationValue,
357 const void *pvOldCfgDesc, const void *pvOldIfState, const void *pvNewCfgDesc));
358
359 /**
360 * SET_INTERFACE request.
361 *
362 * @returns VBox status code.
363 * @param pUsbIns The USB device instance.
364 * @param bInterfaceNumber The interface number.
365 * @param bAlternateSetting The alternate setting.
366 * @remarks Optional.
367 */
368 DECLR3CALLBACKMEMBER(int, pfnUsbSetInterface,(PPDMUSBINS pUsbIns, uint8_t bInterfaceNumber, uint8_t bAlternateSetting));
369
370 /**
371 * Clears the halted state of an endpoint. (Optional)
372 *
373 * This called when VUSB sees a CLEAR_FEATURE(ENDPOINT_HALT) on request
374 * on the zero pipe.
375 *
376 * @returns VBox status code.
377 * @param pUsbIns The USB device instance.
378 * @param uEndpoint The endpoint to clear.
379 * @remarks Optional.
380 */
381 DECLR3CALLBACKMEMBER(int, pfnUsbClearHaltedEndpoint,(PPDMUSBINS pUsbIns, unsigned uEndpoint));
382
383 /**
384 * Allocates an URB.
385 *
386 * This can be used to make use of shared user/kernel mode buffers.
387 *
388 * @returns VBox status code.
389 * @param pUsbIns The USB device instance.
390 * @param cbData The size of the data buffer.
391 * @param cTds The number of TDs.
392 * @param enmType The type of URB.
393 * @param ppUrb Where to store the allocated URB.
394 * @remarks Optional.
395 * @remarks Not implemented yet.
396 */
397 DECLR3CALLBACKMEMBER(int, pfnUrbNew,(PPDMUSBINS pUsbIns, size_t cbData, size_t cTds, VUSBXFERTYPE enmType, PVUSBURB *ppUrb));
398
399 /**
400 * Queues an URB for processing.
401 *
402 * @returns VBox status code.
403 * @retval VINF_SUCCESS on success.
404 * @retval VERR_VUSB_DEVICE_NOT_ATTACHED if the device has been disconnected.
405 * @retval VERR_VUSB_FAILED_TO_QUEUE_URB as a general failure kind of thing.
406 * @retval TBD - document new stuff!
407 *
408 * @param pUsbIns The USB device instance.
409 * @param pUrb The URB to process.
410 * @remarks Mandatory.
411 */
412 DECLR3CALLBACKMEMBER(int, pfnUrbQueue,(PPDMUSBINS pUsbIns, PVUSBURB pUrb));
413
414 /**
415 * Cancels an URB.
416 *
417 * @returns VBox status code.
418 * @param pUsbIns The USB device instance.
419 * @param pUrb The URB to cancel.
420 * @remarks Mandatory.
421 */
422 DECLR3CALLBACKMEMBER(int, pfnUrbCancel,(PPDMUSBINS pUsbIns, PVUSBURB pUrb));
423
424 /**
425 * Reaps an URB.
426 *
427 * @returns A ripe URB, NULL if none.
428 * @param pUsbIns The USB device instance.
429 * @param cMillies How log to wait for an URB to become ripe.
430 * @remarks Mandatory.
431 */
432 DECLR3CALLBACKMEMBER(PVUSBURB, pfnUrbReap,(PPDMUSBINS pUsbIns, RTMSINTERVAL cMillies));
433
434 /**
435 * Wakes a thread waiting in pfnUrbReap.
436 *
437 * @returns VBox status code.
438 * @param pUsbIns The USB device instance.
439 */
440 DECLR3CALLBACKMEMBER(int, pfnWakeup,(PPDMUSBINS pUsbIns));
441
442 /** Just some init precaution. Must be set to PDM_USBREG_VERSION. */
443 uint32_t u32TheEnd;
444} PDMUSBREG;
445/** Pointer to a PDM USB Device Structure. */
446typedef PDMUSBREG *PPDMUSBREG;
447/** Const pointer to a PDM USB Device Structure. */
448typedef PDMUSBREG const *PCPDMUSBREG;
449
450/** Current USBREG version number. */
451#define PDM_USBREG_VERSION PDM_VERSION_MAKE(0xeeff, 2, 0)
452
453/** PDM USB Device Flags.
454 * @{ */
455/* none yet */
456/** @} */
457
458
459#ifdef IN_RING3
460
461/**
462 * PDM USB Device API.
463 */
464typedef struct PDMUSBHLP
465{
466 /** Structure version. PDM_USBHLP_VERSION defines the current version. */
467 uint32_t u32Version;
468
469 /**
470 * Attaches a driver (chain) to the USB device.
471 *
472 * The first call for a LUN this will serve as a registration of the LUN. The pBaseInterface and
473 * the pszDesc string will be registered with that LUN and kept around for PDMR3QueryUSBDeviceLun().
474 *
475 * @returns VBox status code.
476 * @param pUsbIns The USB device instance.
477 * @param iLun The logical unit to attach.
478 * @param pBaseInterface Pointer to the base interface for that LUN. (device side / down)
479 * @param ppBaseInterface Where to store the pointer to the base interface. (driver side / up)
480 * @param pszDesc Pointer to a string describing the LUN. This string must remain valid
481 * for the live of the device instance.
482 */
483 DECLR3CALLBACKMEMBER(int, pfnDriverAttach,(PPDMUSBINS pUsbIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc));
484
485 /**
486 * Assert that the current thread is the emulation thread.
487 *
488 * @returns True if correct.
489 * @returns False if wrong.
490 * @param pUsbIns The USB device instance.
491 * @param pszFile Filename of the assertion location.
492 * @param iLine Linenumber of the assertion location.
493 * @param pszFunction Function of the assertion location.
494 */
495 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMUSBINS pUsbIns, const char *pszFile, unsigned iLine, const char *pszFunction));
496
497 /**
498 * Assert that the current thread is NOT the emulation thread.
499 *
500 * @returns True if correct.
501 * @returns False if wrong.
502 * @param pUsbIns The USB device instance.
503 * @param pszFile Filename of the assertion location.
504 * @param iLine Linenumber of the assertion location.
505 * @param pszFunction Function of the assertion location.
506 */
507 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMUSBINS pUsbIns, const char *pszFile, unsigned iLine, const char *pszFunction));
508
509 /**
510 * Stops the VM and enters the debugger to look at the guest state.
511 *
512 * Use the PDMUsbDBGFStop() inline function with the RT_SRC_POS macro instead of
513 * invoking this function directly.
514 *
515 * @returns VBox status code which must be passed up to the VMM.
516 * @param pUsbIns The USB device instance.
517 * @param pszFile Filename of the assertion location.
518 * @param iLine The linenumber of the assertion location.
519 * @param pszFunction Function of the assertion location.
520 * @param pszFormat Message. (optional)
521 * @param va Message parameters.
522 */
523 DECLR3CALLBACKMEMBER(int, pfnDBGFStopV,(PPDMUSBINS pUsbIns, const char *pszFile, unsigned iLine, const char *pszFunction,
524 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(5, 0));
525
526 /**
527 * Register a info handler with DBGF, argv style.
528 *
529 * @returns VBox status code.
530 * @param pUsbIns The USB device instance.
531 * @param pszName The identifier of the info.
532 * @param pszDesc The description of the info and any arguments the handler may take.
533 * @param pfnHandler The handler function to be called to display the info.
534 */
535 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegisterArgv,(PPDMUSBINS pUsbIns, const char *pszName, const char *pszDesc, PFNDBGFINFOARGVUSB pfnHandler));
536
537 /**
538 * Allocate memory which is associated with current VM instance
539 * and automatically freed on it's destruction.
540 *
541 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
542 * @param pUsbIns The USB device instance.
543 * @param cb Number of bytes to allocate.
544 */
545 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMUSBINS pUsbIns, size_t cb));
546
547 /**
548 * Allocate memory which is associated with current VM instance
549 * and automatically freed on it's destruction. The memory is ZEROed.
550 *
551 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
552 * @param pUsbIns The USB device instance.
553 * @param cb Number of bytes to allocate.
554 */
555 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAllocZ,(PPDMUSBINS pUsbIns, size_t cb));
556
557 /**
558 * Free memory allocated with pfnMMHeapAlloc() and pfnMMHeapAllocZ().
559 *
560 * @param pUsbIns The USB device instance.
561 * @param pv Pointer to the memory to free.
562 */
563 DECLR3CALLBACKMEMBER(void, pfnMMHeapFree,(PPDMUSBINS pUsbIns, void *pv));
564
565 /**
566 * Create a queue.
567 *
568 * @returns VBox status code.
569 * @param pUsbIns The USB device instance.
570 * @param cbItem Size a queue item.
571 * @param cItems Number of items in the queue.
572 * @param cMilliesInterval Number of milliseconds between polling the queue.
573 * If 0 then the emulation thread will be notified whenever an item arrives.
574 * @param pfnCallback The consumer function.
575 * @param pszName The queue base name. The instance number will be
576 * appended automatically.
577 * @param ppQueue Where to store the queue handle on success.
578 * @thread The emulation thread.
579 */
580 DECLR3CALLBACKMEMBER(int, pfnPDMQueueCreate,(PPDMUSBINS pUsbIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
581 PFNPDMQUEUEUSB pfnCallback, const char *pszName, PPDMQUEUE *ppQueue));
582
583 /**
584 * Register a save state data unit.
585 *
586 * @returns VBox status.
587 * @param pUsbIns The USB device instance.
588 * @param uVersion Data layout version number.
589 * @param cbGuess The approximate amount of data in the unit.
590 * Only for progress indicators.
591 *
592 * @param pfnLivePrep Prepare live save callback, optional.
593 * @param pfnLiveExec Execute live save callback, optional.
594 * @param pfnLiveVote Vote live save callback, optional.
595 *
596 * @param pfnSavePrep Prepare save callback, optional.
597 * @param pfnSaveExec Execute save callback, optional.
598 * @param pfnSaveDone Done save callback, optional.
599 *
600 * @param pfnLoadPrep Prepare load callback, optional.
601 * @param pfnLoadExec Execute load callback, optional.
602 * @param pfnLoadDone Done load callback, optional.
603 */
604 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMUSBINS pUsbIns, uint32_t uVersion, size_t cbGuess,
605 PFNSSMUSBLIVEPREP pfnLivePrep, PFNSSMUSBLIVEEXEC pfnLiveExec, PFNSSMUSBLIVEVOTE pfnLiveVote,
606 PFNSSMUSBSAVEPREP pfnSavePrep, PFNSSMUSBSAVEEXEC pfnSaveExec, PFNSSMUSBSAVEDONE pfnSaveDone,
607 PFNSSMUSBLOADPREP pfnLoadPrep, PFNSSMUSBLOADEXEC pfnLoadExec, PFNSSMUSBLOADDONE pfnLoadDone));
608
609 /** @name Exported SSM Functions
610 * @{ */
611 DECLR3CALLBACKMEMBER(int, pfnSSMPutStruct,(PSSMHANDLE pSSM, const void *pvStruct, PCSSMFIELD paFields));
612 DECLR3CALLBACKMEMBER(int, pfnSSMPutStructEx,(PSSMHANDLE pSSM, const void *pvStruct, size_t cbStruct, uint32_t fFlags, PCSSMFIELD paFields, void *pvUser));
613 DECLR3CALLBACKMEMBER(int, pfnSSMPutBool,(PSSMHANDLE pSSM, bool fBool));
614 DECLR3CALLBACKMEMBER(int, pfnSSMPutU8,(PSSMHANDLE pSSM, uint8_t u8));
615 DECLR3CALLBACKMEMBER(int, pfnSSMPutS8,(PSSMHANDLE pSSM, int8_t i8));
616 DECLR3CALLBACKMEMBER(int, pfnSSMPutU16,(PSSMHANDLE pSSM, uint16_t u16));
617 DECLR3CALLBACKMEMBER(int, pfnSSMPutS16,(PSSMHANDLE pSSM, int16_t i16));
618 DECLR3CALLBACKMEMBER(int, pfnSSMPutU32,(PSSMHANDLE pSSM, uint32_t u32));
619 DECLR3CALLBACKMEMBER(int, pfnSSMPutS32,(PSSMHANDLE pSSM, int32_t i32));
620 DECLR3CALLBACKMEMBER(int, pfnSSMPutU64,(PSSMHANDLE pSSM, uint64_t u64));
621 DECLR3CALLBACKMEMBER(int, pfnSSMPutS64,(PSSMHANDLE pSSM, int64_t i64));
622 DECLR3CALLBACKMEMBER(int, pfnSSMPutU128,(PSSMHANDLE pSSM, uint128_t u128));
623 DECLR3CALLBACKMEMBER(int, pfnSSMPutS128,(PSSMHANDLE pSSM, int128_t i128));
624 DECLR3CALLBACKMEMBER(int, pfnSSMPutUInt,(PSSMHANDLE pSSM, RTUINT u));
625 DECLR3CALLBACKMEMBER(int, pfnSSMPutSInt,(PSSMHANDLE pSSM, RTINT i));
626 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCUInt,(PSSMHANDLE pSSM, RTGCUINT u));
627 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCUIntReg,(PSSMHANDLE pSSM, RTGCUINTREG u));
628 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPhys32,(PSSMHANDLE pSSM, RTGCPHYS32 GCPhys));
629 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPhys64,(PSSMHANDLE pSSM, RTGCPHYS64 GCPhys));
630 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPhys,(PSSMHANDLE pSSM, RTGCPHYS GCPhys));
631 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPtr,(PSSMHANDLE pSSM, RTGCPTR GCPtr));
632 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCUIntPtr,(PSSMHANDLE pSSM, RTGCUINTPTR GCPtr));
633 DECLR3CALLBACKMEMBER(int, pfnSSMPutRCPtr,(PSSMHANDLE pSSM, RTRCPTR RCPtr));
634 DECLR3CALLBACKMEMBER(int, pfnSSMPutIOPort,(PSSMHANDLE pSSM, RTIOPORT IOPort));
635 DECLR3CALLBACKMEMBER(int, pfnSSMPutSel,(PSSMHANDLE pSSM, RTSEL Sel));
636 DECLR3CALLBACKMEMBER(int, pfnSSMPutMem,(PSSMHANDLE pSSM, const void *pv, size_t cb));
637 DECLR3CALLBACKMEMBER(int, pfnSSMPutStrZ,(PSSMHANDLE pSSM, const char *psz));
638 DECLR3CALLBACKMEMBER(int, pfnSSMGetStruct,(PSSMHANDLE pSSM, void *pvStruct, PCSSMFIELD paFields));
639 DECLR3CALLBACKMEMBER(int, pfnSSMGetStructEx,(PSSMHANDLE pSSM, void *pvStruct, size_t cbStruct, uint32_t fFlags, PCSSMFIELD paFields, void *pvUser));
640 DECLR3CALLBACKMEMBER(int, pfnSSMGetBool,(PSSMHANDLE pSSM, bool *pfBool));
641 DECLR3CALLBACKMEMBER(int, pfnSSMGetBoolV,(PSSMHANDLE pSSM, bool volatile *pfBool));
642 DECLR3CALLBACKMEMBER(int, pfnSSMGetU8,(PSSMHANDLE pSSM, uint8_t *pu8));
643 DECLR3CALLBACKMEMBER(int, pfnSSMGetU8V,(PSSMHANDLE pSSM, uint8_t volatile *pu8));
644 DECLR3CALLBACKMEMBER(int, pfnSSMGetS8,(PSSMHANDLE pSSM, int8_t *pi8));
645 DECLR3CALLBACKMEMBER(int, pfnSSMGetS8V,(PSSMHANDLE pSSM, int8_t volatile *pi8));
646 DECLR3CALLBACKMEMBER(int, pfnSSMGetU16,(PSSMHANDLE pSSM, uint16_t *pu16));
647 DECLR3CALLBACKMEMBER(int, pfnSSMGetU16V,(PSSMHANDLE pSSM, uint16_t volatile *pu16));
648 DECLR3CALLBACKMEMBER(int, pfnSSMGetS16,(PSSMHANDLE pSSM, int16_t *pi16));
649 DECLR3CALLBACKMEMBER(int, pfnSSMGetS16V,(PSSMHANDLE pSSM, int16_t volatile *pi16));
650 DECLR3CALLBACKMEMBER(int, pfnSSMGetU32,(PSSMHANDLE pSSM, uint32_t *pu32));
651 DECLR3CALLBACKMEMBER(int, pfnSSMGetU32V,(PSSMHANDLE pSSM, uint32_t volatile *pu32));
652 DECLR3CALLBACKMEMBER(int, pfnSSMGetS32,(PSSMHANDLE pSSM, int32_t *pi32));
653 DECLR3CALLBACKMEMBER(int, pfnSSMGetS32V,(PSSMHANDLE pSSM, int32_t volatile *pi32));
654 DECLR3CALLBACKMEMBER(int, pfnSSMGetU64,(PSSMHANDLE pSSM, uint64_t *pu64));
655 DECLR3CALLBACKMEMBER(int, pfnSSMGetU64V,(PSSMHANDLE pSSM, uint64_t volatile *pu64));
656 DECLR3CALLBACKMEMBER(int, pfnSSMGetS64,(PSSMHANDLE pSSM, int64_t *pi64));
657 DECLR3CALLBACKMEMBER(int, pfnSSMGetS64V,(PSSMHANDLE pSSM, int64_t volatile *pi64));
658 DECLR3CALLBACKMEMBER(int, pfnSSMGetU128,(PSSMHANDLE pSSM, uint128_t *pu128));
659 DECLR3CALLBACKMEMBER(int, pfnSSMGetU128V,(PSSMHANDLE pSSM, uint128_t volatile *pu128));
660 DECLR3CALLBACKMEMBER(int, pfnSSMGetS128,(PSSMHANDLE pSSM, int128_t *pi128));
661 DECLR3CALLBACKMEMBER(int, pfnSSMGetS128V,(PSSMHANDLE pSSM, int128_t volatile *pi128));
662 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys32,(PSSMHANDLE pSSM, PRTGCPHYS32 pGCPhys));
663 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys32V,(PSSMHANDLE pSSM, RTGCPHYS32 volatile *pGCPhys));
664 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys64,(PSSMHANDLE pSSM, PRTGCPHYS64 pGCPhys));
665 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys64V,(PSSMHANDLE pSSM, RTGCPHYS64 volatile *pGCPhys));
666 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys,(PSSMHANDLE pSSM, PRTGCPHYS pGCPhys));
667 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhysV,(PSSMHANDLE pSSM, RTGCPHYS volatile *pGCPhys));
668 DECLR3CALLBACKMEMBER(int, pfnSSMGetUInt,(PSSMHANDLE pSSM, PRTUINT pu));
669 DECLR3CALLBACKMEMBER(int, pfnSSMGetSInt,(PSSMHANDLE pSSM, PRTINT pi));
670 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCUInt,(PSSMHANDLE pSSM, PRTGCUINT pu));
671 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCUIntReg,(PSSMHANDLE pSSM, PRTGCUINTREG pu));
672 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPtr,(PSSMHANDLE pSSM, PRTGCPTR pGCPtr));
673 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCUIntPtr,(PSSMHANDLE pSSM, PRTGCUINTPTR pGCPtr));
674 DECLR3CALLBACKMEMBER(int, pfnSSMGetRCPtr,(PSSMHANDLE pSSM, PRTRCPTR pRCPtr));
675 DECLR3CALLBACKMEMBER(int, pfnSSMGetIOPort,(PSSMHANDLE pSSM, PRTIOPORT pIOPort));
676 DECLR3CALLBACKMEMBER(int, pfnSSMGetSel,(PSSMHANDLE pSSM, PRTSEL pSel));
677 DECLR3CALLBACKMEMBER(int, pfnSSMGetMem,(PSSMHANDLE pSSM, void *pv, size_t cb));
678 DECLR3CALLBACKMEMBER(int, pfnSSMGetStrZ,(PSSMHANDLE pSSM, char *psz, size_t cbMax));
679 DECLR3CALLBACKMEMBER(int, pfnSSMGetStrZEx,(PSSMHANDLE pSSM, char *psz, size_t cbMax, size_t *pcbStr));
680 DECLR3CALLBACKMEMBER(int, pfnSSMSkip,(PSSMHANDLE pSSM, size_t cb));
681 DECLR3CALLBACKMEMBER(int, pfnSSMSkipToEndOfUnit,(PSSMHANDLE pSSM));
682 DECLR3CALLBACKMEMBER(int, pfnSSMSetLoadError,(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
683 DECLR3CALLBACKMEMBER(int, pfnSSMSetLoadErrorV,(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
684 DECLR3CALLBACKMEMBER(int, pfnSSMSetCfgError,(PSSMHANDLE pSSM, RT_SRC_POS_DECL, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(5, 6));
685 DECLR3CALLBACKMEMBER(int, pfnSSMSetCfgErrorV,(PSSMHANDLE pSSM, RT_SRC_POS_DECL, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(5, 0));
686 DECLR3CALLBACKMEMBER(int, pfnSSMHandleGetStatus,(PSSMHANDLE pSSM));
687 DECLR3CALLBACKMEMBER(SSMAFTER, pfnSSMHandleGetAfter,(PSSMHANDLE pSSM));
688 DECLR3CALLBACKMEMBER(bool, pfnSSMHandleIsLiveSave,(PSSMHANDLE pSSM));
689 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleMaxDowntime,(PSSMHANDLE pSSM));
690 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleHostBits,(PSSMHANDLE pSSM));
691 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleRevision,(PSSMHANDLE pSSM));
692 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleVersion,(PSSMHANDLE pSSM));
693 DECLR3CALLBACKMEMBER(const char *, pfnSSMHandleHostOSAndArch,(PSSMHANDLE pSSM));
694 /** @} */
695
696 /** @name Exported CFGM Functions.
697 * @{ */
698 DECLR3CALLBACKMEMBER(bool, pfnCFGMExists,( PCFGMNODE pNode, const char *pszName));
699 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryType,( PCFGMNODE pNode, const char *pszName, PCFGMVALUETYPE penmType));
700 DECLR3CALLBACKMEMBER(int, pfnCFGMQuerySize,( PCFGMNODE pNode, const char *pszName, size_t *pcb));
701 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryInteger,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64));
702 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryIntegerDef,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64, uint64_t u64Def));
703 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryString,( PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString));
704 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryStringDef,( PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString, const char *pszDef));
705 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryBytes,( PCFGMNODE pNode, const char *pszName, void *pvData, size_t cbData));
706 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU64,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64));
707 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU64Def,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64, uint64_t u64Def));
708 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS64,( PCFGMNODE pNode, const char *pszName, int64_t *pi64));
709 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS64Def,( PCFGMNODE pNode, const char *pszName, int64_t *pi64, int64_t i64Def));
710 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU32,( PCFGMNODE pNode, const char *pszName, uint32_t *pu32));
711 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU32Def,( PCFGMNODE pNode, const char *pszName, uint32_t *pu32, uint32_t u32Def));
712 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS32,( PCFGMNODE pNode, const char *pszName, int32_t *pi32));
713 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS32Def,( PCFGMNODE pNode, const char *pszName, int32_t *pi32, int32_t i32Def));
714 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU16,( PCFGMNODE pNode, const char *pszName, uint16_t *pu16));
715 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU16Def,( PCFGMNODE pNode, const char *pszName, uint16_t *pu16, uint16_t u16Def));
716 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS16,( PCFGMNODE pNode, const char *pszName, int16_t *pi16));
717 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS16Def,( PCFGMNODE pNode, const char *pszName, int16_t *pi16, int16_t i16Def));
718 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU8,( PCFGMNODE pNode, const char *pszName, uint8_t *pu8));
719 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU8Def,( PCFGMNODE pNode, const char *pszName, uint8_t *pu8, uint8_t u8Def));
720 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS8,( PCFGMNODE pNode, const char *pszName, int8_t *pi8));
721 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS8Def,( PCFGMNODE pNode, const char *pszName, int8_t *pi8, int8_t i8Def));
722 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryBool,( PCFGMNODE pNode, const char *pszName, bool *pf));
723 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryBoolDef,( PCFGMNODE pNode, const char *pszName, bool *pf, bool fDef));
724 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPort,( PCFGMNODE pNode, const char *pszName, PRTIOPORT pPort));
725 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPortDef,( PCFGMNODE pNode, const char *pszName, PRTIOPORT pPort, RTIOPORT PortDef));
726 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryUInt,( PCFGMNODE pNode, const char *pszName, unsigned int *pu));
727 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryUIntDef,( PCFGMNODE pNode, const char *pszName, unsigned int *pu, unsigned int uDef));
728 DECLR3CALLBACKMEMBER(int, pfnCFGMQuerySInt,( PCFGMNODE pNode, const char *pszName, signed int *pi));
729 DECLR3CALLBACKMEMBER(int, pfnCFGMQuerySIntDef,( PCFGMNODE pNode, const char *pszName, signed int *pi, signed int iDef));
730 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtr,( PCFGMNODE pNode, const char *pszName, PRTGCPTR pGCPtr));
731 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrDef,( PCFGMNODE pNode, const char *pszName, PRTGCPTR pGCPtr, RTGCPTR GCPtrDef));
732 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrU,( PCFGMNODE pNode, const char *pszName, PRTGCUINTPTR pGCPtr));
733 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrUDef,( PCFGMNODE pNode, const char *pszName, PRTGCUINTPTR pGCPtr, RTGCUINTPTR GCPtrDef));
734 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrS,( PCFGMNODE pNode, const char *pszName, PRTGCINTPTR pGCPtr));
735 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrSDef,( PCFGMNODE pNode, const char *pszName, PRTGCINTPTR pGCPtr, RTGCINTPTR GCPtrDef));
736 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryStringAlloc,( PCFGMNODE pNode, const char *pszName, char **ppszString));
737 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryStringAllocDef,(PCFGMNODE pNode, const char *pszName, char **ppszString, const char *pszDef));
738 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetParent,(PCFGMNODE pNode));
739 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetChild,(PCFGMNODE pNode, const char *pszPath));
740 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetChildF,(PCFGMNODE pNode, const char *pszPathFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3));
741 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetChildFV,(PCFGMNODE pNode, const char *pszPathFormat, va_list Args) RT_IPRT_FORMAT_ATTR(3, 0));
742 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetFirstChild,(PCFGMNODE pNode));
743 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetNextChild,(PCFGMNODE pCur));
744 DECLR3CALLBACKMEMBER(int, pfnCFGMGetName,(PCFGMNODE pCur, char *pszName, size_t cchName));
745 DECLR3CALLBACKMEMBER(size_t, pfnCFGMGetNameLen,(PCFGMNODE pCur));
746 DECLR3CALLBACKMEMBER(bool, pfnCFGMAreChildrenValid,(PCFGMNODE pNode, const char *pszzValid));
747 DECLR3CALLBACKMEMBER(PCFGMLEAF, pfnCFGMGetFirstValue,(PCFGMNODE pCur));
748 DECLR3CALLBACKMEMBER(PCFGMLEAF, pfnCFGMGetNextValue,(PCFGMLEAF pCur));
749 DECLR3CALLBACKMEMBER(int, pfnCFGMGetValueName,(PCFGMLEAF pCur, char *pszName, size_t cchName));
750 DECLR3CALLBACKMEMBER(size_t, pfnCFGMGetValueNameLen,(PCFGMLEAF pCur));
751 DECLR3CALLBACKMEMBER(CFGMVALUETYPE, pfnCFGMGetValueType,(PCFGMLEAF pCur));
752 DECLR3CALLBACKMEMBER(bool, pfnCFGMAreValuesValid,(PCFGMNODE pNode, const char *pszzValid));
753 DECLR3CALLBACKMEMBER(int, pfnCFGMValidateConfig,(PCFGMNODE pNode, const char *pszNode,
754 const char *pszValidValues, const char *pszValidNodes,
755 const char *pszWho, uint32_t uInstance));
756 /** @} */
757
758 /**
759 * Register a STAM sample.
760 *
761 * Use the PDMUsbHlpSTAMRegister wrapper.
762 *
763 * @returns VBox status.
764 * @param pUsbIns The USB device instance.
765 * @param pvSample Pointer to the sample.
766 * @param enmType Sample type. This indicates what pvSample is pointing at.
767 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
768 * @param enmUnit Sample unit.
769 * @param pszDesc Sample description.
770 * @param pszName The sample name format string.
771 * @param va Arguments to the format string.
772 */
773 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMUSBINS pUsbIns, void *pvSample, STAMTYPE enmType,
774 STAMVISIBILITY enmVisibility, STAMUNIT enmUnit, const char *pszDesc,
775 const char *pszName, va_list va) RT_IPRT_FORMAT_ATTR(7, 0));
776
777 /**
778 * Creates a timer.
779 *
780 * @returns VBox status.
781 * @param pUsbIns The USB device instance.
782 * @param enmClock The clock to use on this timer.
783 * @param pfnCallback Callback function.
784 * @param pvUser User argument for the callback.
785 * @param fFlags Flags, see TMTIMER_FLAGS_*.
786 * @param pszDesc Pointer to description string which must stay around
787 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
788 * @param phTimer Where to store the timer handle on success.
789 */
790 DECLR3CALLBACKMEMBER(int, pfnTimerCreate,(PPDMUSBINS pUsbIns, TMCLOCK enmClock, PFNTMTIMERUSB pfnCallback, void *pvUser,
791 uint32_t fFlags, const char *pszDesc, PTMTIMERHANDLE phTimer));
792
793 /** @name Timer handle method wrappers
794 * @{ */
795 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerFromMicro,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cMicroSecs));
796 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerFromMilli,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cMilliSecs));
797 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerFromNano,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cNanoSecs));
798 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerGet,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer));
799 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerGetFreq,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer));
800 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerGetNano,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer));
801 DECLR3CALLBACKMEMBER(bool, pfnTimerIsActive,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer));
802 DECLR3CALLBACKMEMBER(bool, pfnTimerIsLockOwner,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer));
803 DECLR3CALLBACKMEMBER(int, pfnTimerLockClock,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer));
804 /** Takes the clock lock then enters the specified critical section. */
805 DECLR3CALLBACKMEMBER(int, pfnTimerLockClock2,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect));
806 DECLR3CALLBACKMEMBER(int, pfnTimerSet,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t uExpire));
807 DECLR3CALLBACKMEMBER(int, pfnTimerSetFrequencyHint,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint32_t uHz));
808 DECLR3CALLBACKMEMBER(int, pfnTimerSetMicro,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cMicrosToNext));
809 DECLR3CALLBACKMEMBER(int, pfnTimerSetMillies,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cMilliesToNext));
810 DECLR3CALLBACKMEMBER(int, pfnTimerSetNano,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cNanosToNext));
811 DECLR3CALLBACKMEMBER(int, pfnTimerSetRelative,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cTicksToNext, uint64_t *pu64Now));
812 DECLR3CALLBACKMEMBER(int, pfnTimerStop,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer));
813 DECLR3CALLBACKMEMBER(void, pfnTimerUnlockClock,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer));
814 DECLR3CALLBACKMEMBER(void, pfnTimerUnlockClock2,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect));
815 DECLR3CALLBACKMEMBER(int, pfnTimerSetCritSect,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect));
816 DECLR3CALLBACKMEMBER(int, pfnTimerSave,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM));
817 DECLR3CALLBACKMEMBER(int, pfnTimerLoad,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM));
818 DECLR3CALLBACKMEMBER(int, pfnTimerDestroy,(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer));
819 /** @sa TMR3TimerSkip */
820 DECLR3CALLBACKMEMBER(int, pfnTimerSkipLoad,(PSSMHANDLE pSSM, bool *pfActive));
821 /** @} */
822
823 /**
824 * Set the VM error message
825 *
826 * @returns rc.
827 * @param pUsbIns The USB device instance.
828 * @param rc VBox status code.
829 * @param SRC_POS Use RT_SRC_POS.
830 * @param pszFormat Error message format string.
831 * @param va Error message arguments.
832 */
833 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMUSBINS pUsbIns, int rc, RT_SRC_POS_DECL,
834 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
835
836 /**
837 * Set the VM runtime error message
838 *
839 * @returns VBox status code.
840 * @param pUsbIns The USB device instance.
841 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
842 * @param pszErrorId Error ID string.
843 * @param pszFormat Error message format string.
844 * @param va Error message arguments.
845 */
846 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMUSBINS pUsbIns, uint32_t fFlags, const char *pszErrorId,
847 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
848
849 /**
850 * Gets the VM state.
851 *
852 * @returns VM state.
853 * @param pUsbIns The USB device instance.
854 * @thread Any thread (just keep in mind that it's volatile info).
855 */
856 DECLR3CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMUSBINS pUsbIns));
857
858 /**
859 * Creates a PDM thread.
860 *
861 * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
862 * resuming, and destroying the thread as the VM state changes.
863 *
864 * @returns VBox status code.
865 * @param pUsbIns The USB device instance.
866 * @param ppThread Where to store the thread 'handle'.
867 * @param pvUser The user argument to the thread function.
868 * @param pfnThread The thread function.
869 * @param pfnWakeup The wakup callback. This is called on the EMT
870 * thread when a state change is pending.
871 * @param cbStack See RTThreadCreate.
872 * @param enmType See RTThreadCreate.
873 * @param pszName See RTThreadCreate.
874 */
875 DECLR3CALLBACKMEMBER(int, pfnThreadCreate,(PPDMUSBINS pUsbIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADUSB pfnThread,
876 PFNPDMTHREADWAKEUPUSB pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
877
878 /** @name Exported PDM Thread Functions
879 * @{ */
880 DECLR3CALLBACKMEMBER(int, pfnThreadDestroy,(PPDMTHREAD pThread, int *pRcThread));
881 DECLR3CALLBACKMEMBER(int, pfnThreadIAmSuspending,(PPDMTHREAD pThread));
882 DECLR3CALLBACKMEMBER(int, pfnThreadIAmRunning,(PPDMTHREAD pThread));
883 DECLR3CALLBACKMEMBER(int, pfnThreadSleep,(PPDMTHREAD pThread, RTMSINTERVAL cMillies));
884 DECLR3CALLBACKMEMBER(int, pfnThreadSuspend,(PPDMTHREAD pThread));
885 DECLR3CALLBACKMEMBER(int, pfnThreadResume,(PPDMTHREAD pThread));
886 /** @} */
887
888 /**
889 * Set up asynchronous handling of a suspend, reset or power off notification.
890 *
891 * This shall only be called when getting the notification. It must be called
892 * for each one.
893 *
894 * @returns VBox status code.
895 * @param pUsbIns The USB device instance.
896 * @param pfnAsyncNotify The callback.
897 * @thread EMT(0)
898 */
899 DECLR3CALLBACKMEMBER(int, pfnSetAsyncNotification, (PPDMUSBINS pUSbIns, PFNPDMUSBASYNCNOTIFY pfnAsyncNotify));
900
901 /**
902 * Notify EMT(0) that the device has completed the asynchronous notification
903 * handling.
904 *
905 * This can be called at any time, spurious calls will simply be ignored.
906 *
907 * @param pUsbIns The USB device instance.
908 * @thread Any
909 */
910 DECLR3CALLBACKMEMBER(void, pfnAsyncNotificationCompleted, (PPDMUSBINS pUsbIns));
911
912 /**
913 * Gets the reason for the most recent VM suspend.
914 *
915 * @returns The suspend reason. VMSUSPENDREASON_INVALID is returned if no
916 * suspend has been made or if the pUsbIns is invalid.
917 * @param pUsbIns The driver instance.
918 */
919 DECLR3CALLBACKMEMBER(VMSUSPENDREASON, pfnVMGetSuspendReason,(PPDMUSBINS pUsbIns));
920
921 /**
922 * Gets the reason for the most recent VM resume.
923 *
924 * @returns The resume reason. VMRESUMEREASON_INVALID is returned if no
925 * resume has been made or if the pUsbIns is invalid.
926 * @param pUsbIns The driver instance.
927 */
928 DECLR3CALLBACKMEMBER(VMRESUMEREASON, pfnVMGetResumeReason,(PPDMUSBINS pUsbIns));
929
930 /**
931 * Queries a generic object from the VMM user.
932 *
933 * @returns Pointer to the object if found, NULL if not.
934 * @param pUsbIns The USB device instance.
935 * @param pUuid The UUID of what's being queried. The UUIDs and
936 * the usage conventions are defined by the user.
937 */
938 DECLR3CALLBACKMEMBER(void *, pfnQueryGenericUserObject,(PPDMUSBINS pUsbIns, PCRTUUID pUuid));
939
940 /** @name Space reserved for minor interface changes.
941 * @{ */
942 DECLR3CALLBACKMEMBER(void, pfnReserved0,(PPDMUSBINS pUsbIns));
943 DECLR3CALLBACKMEMBER(void, pfnReserved1,(PPDMUSBINS pUsbIns));
944 DECLR3CALLBACKMEMBER(void, pfnReserved2,(PPDMUSBINS pUsbIns));
945 DECLR3CALLBACKMEMBER(void, pfnReserved3,(PPDMUSBINS pUsbIns));
946 DECLR3CALLBACKMEMBER(void, pfnReserved4,(PPDMUSBINS pUsbIns));
947 DECLR3CALLBACKMEMBER(void, pfnReserved5,(PPDMUSBINS pUsbIns));
948 DECLR3CALLBACKMEMBER(void, pfnReserved6,(PPDMUSBINS pUsbIns));
949 DECLR3CALLBACKMEMBER(void, pfnReserved7,(PPDMUSBINS pUsbIns));
950 DECLR3CALLBACKMEMBER(void, pfnReserved8,(PPDMUSBINS pUsbIns));
951 /** @} */
952
953 /** Just a safety precaution. */
954 uint32_t u32TheEnd;
955} PDMUSBHLP;
956/** Pointer PDM USB Device API. */
957typedef PDMUSBHLP *PPDMUSBHLP;
958/** Pointer const PDM USB Device API. */
959typedef const PDMUSBHLP *PCPDMUSBHLP;
960
961/** Current USBHLP version number. */
962#define PDM_USBHLP_VERSION PDM_VERSION_MAKE(0xeefe, 7, 0)
963
964#endif /* IN_RING3 */
965
966/**
967 * PDM USB Device Instance.
968 */
969typedef struct PDMUSBINS
970{
971 /** Structure version. PDM_USBINS_VERSION defines the current version. */
972 uint32_t u32Version;
973 /** USB device instance number. */
974 uint32_t iInstance;
975 /** The base interface of the device.
976 * The device constructor initializes this if it has any device level
977 * interfaces to export. To obtain this interface call PDMR3QueryUSBDevice(). */
978 PDMIBASE IBase;
979#if HC_ARCH_BITS == 32
980 uint32_t u32Alignment; /**< Alignment padding. */
981#endif
982
983 /** Internal data. */
984 union
985 {
986#ifdef PDMUSBINSINT_DECLARED
987 PDMUSBINSINT s;
988#endif
989 uint8_t padding[HC_ARCH_BITS == 32 ? 96 : 128];
990 } Internal;
991
992 /** Pointer the PDM USB Device API. */
993 R3PTRTYPE(PCPDMUSBHLP) pHlpR3;
994 /** Pointer to the USB device registration structure. */
995 R3PTRTYPE(PCPDMUSBREG) pReg;
996 /** Configuration handle. */
997 R3PTRTYPE(PCFGMNODE) pCfg;
998 /** The (device) global configuration handle. */
999 R3PTRTYPE(PCFGMNODE) pCfgGlobal;
1000 /** Pointer to device instance data. */
1001 R3PTRTYPE(void *) pvInstanceDataR3;
1002 /** Pointer to the VUSB Device structure.
1003 * Internal to VUSB, don't touch.
1004 * @todo Moved this to PDMUSBINSINT. */
1005 R3PTRTYPE(void *) pvVUsbDev2;
1006 /** Device name for using when logging.
1007 * The constructor sets this and the destructor frees it. */
1008 R3PTRTYPE(char *) pszName;
1009 /** Tracing indicator. */
1010 uint32_t fTracing;
1011 /** The tracing ID of this device. */
1012 uint32_t idTracing;
1013 /** The port/device speed. HCs and emulated devices need to know. */
1014 VUSBSPEED enmSpeed;
1015
1016 /** Padding to make achInstanceData aligned at 32 byte boundary. */
1017 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 2 : 3];
1018
1019 /** Device instance data. The size of this area is defined
1020 * in the PDMUSBREG::cbInstanceData field. */
1021 char achInstanceData[8];
1022} PDMUSBINS;
1023
1024/** Current USBINS version number. */
1025#define PDM_USBINS_VERSION PDM_VERSION_MAKE(0xeefd, 3, 0)
1026
1027/**
1028 * Checks the structure versions of the USB device instance and USB device
1029 * helpers, returning if they are incompatible.
1030 *
1031 * This shall be the first statement of the constructor!
1032 *
1033 * @param pUsbIns The USB device instance pointer.
1034 */
1035#define PDMUSB_CHECK_VERSIONS_RETURN(pUsbIns) \
1036 do \
1037 { \
1038 PPDMUSBINS pUsbInsTypeCheck = (pUsbIns); NOREF(pUsbInsTypeCheck); \
1039 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pUsbIns)->u32Version, PDM_USBINS_VERSION), \
1040 ("DevIns=%#x mine=%#x\n", (pUsbIns)->u32Version, PDM_USBINS_VERSION), \
1041 VERR_PDM_USBINS_VERSION_MISMATCH); \
1042 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pUsbIns)->pHlpR3->u32Version, PDM_USBHLP_VERSION), \
1043 ("DevHlp=%#x mine=%#x\n", (pUsbIns)->pHlpR3->u32Version, PDM_USBHLP_VERSION), \
1044 VERR_PDM_USBHLPR3_VERSION_MISMATCH); \
1045 } while (0)
1046
1047/**
1048 * Quietly checks the structure versions of the USB device instance and
1049 * USB device helpers, returning if they are incompatible.
1050 *
1051 * This shall be invoked as the first statement in the destructor!
1052 *
1053 * @param pUsbIns The USB device instance pointer.
1054 */
1055#define PDMUSB_CHECK_VERSIONS_RETURN_VOID(pUsbIns) \
1056 do \
1057 { \
1058 PPDMUSBINS pUsbInsTypeCheck = (pUsbIns); NOREF(pUsbInsTypeCheck); \
1059 if (RT_LIKELY(PDM_VERSION_ARE_COMPATIBLE((pUsbIns)->u32Version, PDM_USBINS_VERSION) )) \
1060 { /* likely */ } else return; \
1061 if (RT_LIKELY(PDM_VERSION_ARE_COMPATIBLE((pUsbIns)->pHlpR3->u32Version, PDM_USBHLP_VERSION) )) \
1062 { /* likely */ } else return; \
1063 } while (0)
1064
1065
1066/** Converts a pointer to the PDMUSBINS::IBase to a pointer to PDMUSBINS. */
1067#define PDMIBASE_2_PDMUSB(pInterface) ( (PPDMUSBINS)((char *)(pInterface) - RT_UOFFSETOF(PDMUSBINS, IBase)) )
1068
1069
1070/** @def PDMUSB_ASSERT_EMT
1071 * Assert that the current thread is the emulation thread.
1072 */
1073#ifdef VBOX_STRICT
1074# define PDMUSB_ASSERT_EMT(pUsbIns) pUsbIns->pHlpR3->pfnAssertEMT(pUsbIns, __FILE__, __LINE__, __FUNCTION__)
1075#else
1076# define PDMUSB_ASSERT_EMT(pUsbIns) do { } while (0)
1077#endif
1078
1079/** @def PDMUSB_ASSERT_OTHER
1080 * Assert that the current thread is NOT the emulation thread.
1081 */
1082#ifdef VBOX_STRICT
1083# define PDMUSB_ASSERT_OTHER(pUsbIns) pUsbIns->pHlpR3->pfnAssertOther(pUsbIns, __FILE__, __LINE__, __FUNCTION__)
1084#else
1085# define PDMUSB_ASSERT_OTHER(pUsbIns) do { } while (0)
1086#endif
1087
1088/** @def PDMUSB_SET_ERROR
1089 * Set the VM error. See PDMUsbHlpVMSetError() for printf like message
1090 * formatting.
1091 */
1092#define PDMUSB_SET_ERROR(pUsbIns, rc, pszError) \
1093 PDMUsbHlpVMSetError(pUsbIns, rc, RT_SRC_POS, "%s", pszError)
1094
1095/** @def PDMUSB_SET_RUNTIME_ERROR
1096 * Set the VM runtime error. See PDMUsbHlpVMSetRuntimeError() for printf like
1097 * message formatting.
1098 */
1099#define PDMUSB_SET_RUNTIME_ERROR(pUsbIns, fFlags, pszErrorId, pszError) \
1100 PDMUsbHlpVMSetRuntimeError(pUsbIns, fFlags, pszErrorId, "%s", pszError)
1101
1102
1103#ifdef IN_RING3
1104
1105/**
1106 * @copydoc PDMUSBHLP::pfnDriverAttach
1107 */
1108DECLINLINE(int) PDMUsbHlpDriverAttach(PPDMUSBINS pUsbIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
1109{
1110 return pUsbIns->pHlpR3->pfnDriverAttach(pUsbIns, iLun, pBaseInterface, ppBaseInterface, pszDesc);
1111}
1112
1113/**
1114 * VBOX_STRICT wrapper for pHlpR3->pfnDBGFStopV.
1115 *
1116 * @returns VBox status code which must be passed up to the VMM.
1117 * @param pUsbIns Device instance.
1118 * @param SRC_POS Use RT_SRC_POS.
1119 * @param pszFormat Message. (optional)
1120 * @param ... Message parameters.
1121 */
1122DECLINLINE(int) RT_IPRT_FORMAT_ATTR(5, 6) PDMUsbDBGFStop(PPDMUSBINS pUsbIns, RT_SRC_POS_DECL, const char *pszFormat, ...)
1123{
1124#ifdef VBOX_STRICT
1125 int rc;
1126 va_list va;
1127 va_start(va, pszFormat);
1128 rc = pUsbIns->pHlpR3->pfnDBGFStopV(pUsbIns, RT_SRC_POS_ARGS, pszFormat, va);
1129 va_end(va);
1130 return rc;
1131#else
1132 NOREF(pUsbIns);
1133 NOREF(pszFile);
1134 NOREF(iLine);
1135 NOREF(pszFunction);
1136 NOREF(pszFormat);
1137 return VINF_SUCCESS;
1138#endif
1139}
1140
1141/**
1142 * @copydoc PDMUSBHLP::pfnVMState
1143 */
1144DECLINLINE(VMSTATE) PDMUsbHlpVMState(PPDMUSBINS pUsbIns)
1145{
1146 return pUsbIns->pHlpR3->pfnVMState(pUsbIns);
1147}
1148
1149/**
1150 * @copydoc PDMUSBHLP::pfnThreadCreate
1151 */
1152DECLINLINE(int) PDMUsbHlpThreadCreate(PPDMUSBINS pUsbIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADUSB pfnThread,
1153 PFNPDMTHREADWAKEUPUSB pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
1154{
1155 return pUsbIns->pHlpR3->pfnThreadCreate(pUsbIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
1156}
1157
1158
1159/**
1160 * @copydoc PDMUSBHLP::pfnSetAsyncNotification
1161 */
1162DECLINLINE(int) PDMUsbHlpSetAsyncNotification(PPDMUSBINS pUsbIns, PFNPDMUSBASYNCNOTIFY pfnAsyncNotify)
1163{
1164 return pUsbIns->pHlpR3->pfnSetAsyncNotification(pUsbIns, pfnAsyncNotify);
1165}
1166
1167/**
1168 * @copydoc PDMUSBHLP::pfnAsyncNotificationCompleted
1169 */
1170DECLINLINE(void) PDMUsbHlpAsyncNotificationCompleted(PPDMUSBINS pUsbIns)
1171{
1172 pUsbIns->pHlpR3->pfnAsyncNotificationCompleted(pUsbIns);
1173}
1174
1175/**
1176 * Set the VM error message
1177 *
1178 * @returns rc.
1179 * @param pUsbIns The USB device instance.
1180 * @param rc VBox status code.
1181 * @param SRC_POS Use RT_SRC_POS.
1182 * @param pszFormat Error message format string.
1183 * @param ... Error message arguments.
1184 */
1185DECLINLINE(int) RT_IPRT_FORMAT_ATTR(6, 7) PDMUsbHlpVMSetError(PPDMUSBINS pUsbIns, int rc, RT_SRC_POS_DECL,
1186 const char *pszFormat, ...)
1187{
1188 va_list va;
1189 va_start(va, pszFormat);
1190 rc = pUsbIns->pHlpR3->pfnVMSetErrorV(pUsbIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
1191 va_end(va);
1192 return rc;
1193}
1194
1195/**
1196 * @copydoc PDMUSBHLP::pfnMMHeapAlloc
1197 */
1198DECLINLINE(void *) PDMUsbHlpMMHeapAlloc(PPDMUSBINS pUsbIns, size_t cb)
1199{
1200 return pUsbIns->pHlpR3->pfnMMHeapAlloc(pUsbIns, cb);
1201}
1202
1203/**
1204 * @copydoc PDMUSBHLP::pfnMMHeapAllocZ
1205 */
1206DECLINLINE(void *) PDMUsbHlpMMHeapAllocZ(PPDMUSBINS pUsbIns, size_t cb)
1207{
1208 return pUsbIns->pHlpR3->pfnMMHeapAllocZ(pUsbIns, cb);
1209}
1210
1211/**
1212 * Frees memory allocated by PDMUsbHlpMMHeapAlloc or PDMUsbHlpMMHeapAllocZ.
1213 *
1214 * @param pUsbIns The USB device instance.
1215 * @param pv The memory to free. NULL is fine.
1216 */
1217DECLINLINE(void) PDMUsbHlpMMHeapFree(PPDMUSBINS pUsbIns, void *pv)
1218{
1219 pUsbIns->pHlpR3->pfnMMHeapFree(pUsbIns, pv);
1220}
1221
1222/**
1223 * @copydoc PDMUSBHLP::pfnDBGFInfoRegisterArgv
1224 */
1225DECLINLINE(int) PDMUsbHlpDBGFInfoRegisterArgv(PPDMUSBINS pUsbIns, const char *pszName, const char *pszDesc, PFNDBGFINFOARGVUSB pfnHandler)
1226{
1227 return pUsbIns->pHlpR3->pfnDBGFInfoRegisterArgv(pUsbIns, pszName, pszDesc, pfnHandler);
1228}
1229
1230/**
1231 * @copydoc PDMUSBHLP::pfnTimerCreate
1232 */
1233DECLINLINE(int) PDMUsbHlpTimerCreate(PPDMUSBINS pUsbIns, TMCLOCK enmClock, PFNTMTIMERUSB pfnCallback, void *pvUser,
1234 uint32_t fFlags, const char *pszDesc, PTMTIMERHANDLE phTimer)
1235{
1236 return pUsbIns->pHlpR3->pfnTimerCreate(pUsbIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, phTimer);
1237}
1238
1239/**
1240 * @copydoc PDMUSBHLP::pfnTimerFromMicro
1241 */
1242DECLINLINE(uint64_t) PDMUsbHlpTimerFromMicro(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cMicroSecs)
1243{
1244 return pUsbIns->pHlpR3->pfnTimerFromMicro(pUsbIns, hTimer, cMicroSecs);
1245}
1246
1247/**
1248 * @copydoc PDMUSBHLP::pfnTimerFromMilli
1249 */
1250DECLINLINE(uint64_t) PDMUsbHlpTimerFromMilli(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cMilliSecs)
1251{
1252 return pUsbIns->pHlpR3->pfnTimerFromMilli(pUsbIns, hTimer, cMilliSecs);
1253}
1254
1255/**
1256 * @copydoc PDMUSBHLP::pfnTimerFromNano
1257 */
1258DECLINLINE(uint64_t) PDMUsbHlpTimerFromNano(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cNanoSecs)
1259{
1260 return pUsbIns->pHlpR3->pfnTimerFromNano(pUsbIns, hTimer, cNanoSecs);
1261}
1262
1263/**
1264 * @copydoc PDMUSBHLP::pfnTimerGet
1265 */
1266DECLINLINE(uint64_t) PDMUsbHlpTimerGet(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1267{
1268 return pUsbIns->pHlpR3->pfnTimerGet(pUsbIns, hTimer);
1269}
1270
1271/**
1272 * @copydoc PDMUSBHLP::pfnTimerGetFreq
1273 */
1274DECLINLINE(uint64_t) PDMUsbHlpTimerGetFreq(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1275{
1276 return pUsbIns->pHlpR3->pfnTimerGetFreq(pUsbIns, hTimer);
1277}
1278
1279/**
1280 * @copydoc PDMUSBHLP::pfnTimerGetNano
1281 */
1282DECLINLINE(uint64_t) PDMUsbHlpTimerGetNano(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1283{
1284 return pUsbIns->pHlpR3->pfnTimerGetNano(pUsbIns, hTimer);
1285}
1286
1287/**
1288 * @copydoc PDMUSBHLP::pfnTimerIsActive
1289 */
1290DECLINLINE(bool) PDMUsbHlpTimerIsActive(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1291{
1292 return pUsbIns->pHlpR3->pfnTimerIsActive(pUsbIns, hTimer);
1293}
1294
1295/**
1296 * @copydoc PDMUSBHLP::pfnTimerIsLockOwner
1297 */
1298DECLINLINE(bool) PDMUsbHlpTimerIsLockOwner(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1299{
1300 return pUsbIns->pHlpR3->pfnTimerIsLockOwner(pUsbIns, hTimer);
1301}
1302
1303/**
1304 * @copydoc PDMUSBHLP::pfnTimerLockClock
1305 */
1306DECLINLINE(int) PDMUsbHlpTimerLockClock(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1307{
1308 return pUsbIns->pHlpR3->pfnTimerLockClock(pUsbIns, hTimer);
1309}
1310
1311/**
1312 * @copydoc PDMUSBHLP::pfnTimerLockClock2
1313 */
1314DECLINLINE(int) PDMUsbHlpTimerLockClock2(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect)
1315{
1316 return pUsbIns->pHlpR3->pfnTimerLockClock2(pUsbIns, hTimer, pCritSect);
1317}
1318
1319/**
1320 * @copydoc PDMUSBHLP::pfnTimerSet
1321 */
1322DECLINLINE(int) PDMUsbHlpTimerSet(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t uExpire)
1323{
1324 return pUsbIns->pHlpR3->pfnTimerSet(pUsbIns, hTimer, uExpire);
1325}
1326
1327/**
1328 * @copydoc PDMUSBHLP::pfnTimerSetFrequencyHint
1329 */
1330DECLINLINE(int) PDMUsbHlpTimerSetFrequencyHint(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint32_t uHz)
1331{
1332 return pUsbIns->pHlpR3->pfnTimerSetFrequencyHint(pUsbIns, hTimer, uHz);
1333}
1334
1335/**
1336 * @copydoc PDMUSBHLP::pfnTimerSetMicro
1337 */
1338DECLINLINE(int) PDMUsbHlpTimerSetMicro(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cMicrosToNext)
1339{
1340 return pUsbIns->pHlpR3->pfnTimerSetMicro(pUsbIns, hTimer, cMicrosToNext);
1341}
1342
1343/**
1344 * @copydoc PDMUSBHLP::pfnTimerSetMillies
1345 */
1346DECLINLINE(int) PDMUsbHlpTimerSetMillies(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cMilliesToNext)
1347{
1348 return pUsbIns->pHlpR3->pfnTimerSetMillies(pUsbIns, hTimer, cMilliesToNext);
1349}
1350
1351/**
1352 * @copydoc PDMUSBHLP::pfnTimerSetNano
1353 */
1354DECLINLINE(int) PDMUsbHlpTimerSetNano(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cNanosToNext)
1355{
1356 return pUsbIns->pHlpR3->pfnTimerSetNano(pUsbIns, hTimer, cNanosToNext);
1357}
1358
1359/**
1360 * @copydoc PDMUSBHLP::pfnTimerSetRelative
1361 */
1362DECLINLINE(int) PDMUsbHlpTimerSetRelative(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cTicksToNext, uint64_t *pu64Now)
1363{
1364 return pUsbIns->pHlpR3->pfnTimerSetRelative(pUsbIns, hTimer, cTicksToNext, pu64Now);
1365}
1366
1367/**
1368 * @copydoc PDMUSBHLP::pfnTimerStop
1369 */
1370DECLINLINE(int) PDMUsbHlpTimerStop(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1371{
1372 return pUsbIns->pHlpR3->pfnTimerStop(pUsbIns, hTimer);
1373}
1374
1375/**
1376 * @copydoc PDMUSBHLP::pfnTimerUnlockClock
1377 */
1378DECLINLINE(void) PDMUsbHlpTimerUnlockClock(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1379{
1380 pUsbIns->pHlpR3->pfnTimerUnlockClock(pUsbIns, hTimer);
1381}
1382
1383/**
1384 * @copydoc PDMUSBHLP::pfnTimerUnlockClock2
1385 */
1386DECLINLINE(void) PDMUsbHlpTimerUnlockClock2(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect)
1387{
1388 pUsbIns->pHlpR3->pfnTimerUnlockClock2(pUsbIns, hTimer, pCritSect);
1389}
1390
1391/**
1392 * @copydoc PDMUSBHLP::pfnTimerSetCritSect
1393 */
1394DECLINLINE(int) PDMUsbHlpTimerSetCritSect(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect)
1395{
1396 return pUsbIns->pHlpR3->pfnTimerSetCritSect(pUsbIns, hTimer, pCritSect);
1397}
1398
1399/**
1400 * @copydoc PDMUSBHLP::pfnTimerSave
1401 */
1402DECLINLINE(int) PDMUsbHlpTimerSave(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM)
1403{
1404 return pUsbIns->pHlpR3->pfnTimerSave(pUsbIns, hTimer, pSSM);
1405}
1406
1407/**
1408 * @copydoc PDMUSBHLP::pfnTimerLoad
1409 */
1410DECLINLINE(int) PDMUsbHlpTimerLoad(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM)
1411{
1412 return pUsbIns->pHlpR3->pfnTimerLoad(pUsbIns, hTimer, pSSM);
1413}
1414
1415/**
1416 * @copydoc PDMUSBHLP::pfnTimerDestroy
1417 */
1418DECLINLINE(int) PDMUsbHlpTimerDestroy(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1419{
1420 return pUsbIns->pHlpR3->pfnTimerDestroy(pUsbIns, hTimer);
1421}
1422
1423/**
1424 * @copydoc PDMUSBHLP::pfnSSMRegister
1425 */
1426DECLINLINE(int) PDMUsbHlpSSMRegister(PPDMUSBINS pUsbIns, uint32_t uVersion, size_t cbGuess,
1427 PFNSSMUSBLIVEPREP pfnLivePrep, PFNSSMUSBLIVEEXEC pfnLiveExec, PFNSSMUSBLIVEVOTE pfnLiveVote,
1428 PFNSSMUSBSAVEPREP pfnSavePrep, PFNSSMUSBSAVEEXEC pfnSaveExec, PFNSSMUSBSAVEDONE pfnSaveDone,
1429 PFNSSMUSBLOADPREP pfnLoadPrep, PFNSSMUSBLOADEXEC pfnLoadExec, PFNSSMUSBLOADDONE pfnLoadDone)
1430{
1431 return pUsbIns->pHlpR3->pfnSSMRegister(pUsbIns, uVersion, cbGuess,
1432 pfnLivePrep, pfnLiveExec, pfnLiveVote,
1433 pfnSavePrep, pfnSaveExec, pfnSaveDone,
1434 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
1435}
1436
1437/**
1438 * @copydoc PDMUSBHLP::pfnQueryGenericUserObject
1439 */
1440DECLINLINE(void *) PDMUsbHlpQueryGenericUserObject(PPDMUSBINS pUsbIns, PCRTUUID pUuid)
1441{
1442 return pUsbIns->pHlpR3->pfnQueryGenericUserObject(pUsbIns, pUuid);
1443}
1444
1445#endif /* IN_RING3 */
1446
1447
1448
1449/** Pointer to callbacks provided to the VBoxUsbRegister() call. */
1450typedef const struct PDMUSBREGCB *PCPDMUSBREGCB;
1451
1452/**
1453 * Callbacks for VBoxUSBDeviceRegister().
1454 */
1455typedef struct PDMUSBREGCB
1456{
1457 /** Interface version.
1458 * This is set to PDM_USBREG_CB_VERSION. */
1459 uint32_t u32Version;
1460
1461 /**
1462 * Registers a device with the current VM instance.
1463 *
1464 * @returns VBox status code.
1465 * @param pCallbacks Pointer to the callback table.
1466 * @param pReg Pointer to the USB device registration record.
1467 * This data must be permanent and readonly.
1468 */
1469 DECLR3CALLBACKMEMBER(int, pfnRegister,(PCPDMUSBREGCB pCallbacks, PCPDMUSBREG pReg));
1470} PDMUSBREGCB;
1471
1472/** Current version of the PDMUSBREGCB structure. */
1473#define PDM_USBREG_CB_VERSION PDM_VERSION_MAKE(0xeefc, 1, 0)
1474
1475
1476/**
1477 * The VBoxUsbRegister callback function.
1478 *
1479 * PDM will invoke this function after loading a USB device module and letting
1480 * the module decide which devices to register and how to handle conflicts.
1481 *
1482 * @returns VBox status code.
1483 * @param pCallbacks Pointer to the callback table.
1484 * @param u32Version VBox version number.
1485 */
1486typedef DECLCALLBACKTYPE(int, FNPDMVBOXUSBREGISTER,(PCPDMUSBREGCB pCallbacks, uint32_t u32Version));
1487
1488VMMR3DECL(int) PDMR3UsbCreateEmulatedDevice(PUVM pUVM, const char *pszDeviceName, PCFGMNODE pDeviceNode, PCRTUUID pUuid,
1489 const char *pszCaptureFilename);
1490VMMR3DECL(int) PDMR3UsbCreateProxyDevice(PUVM pUVM, PCRTUUID pUuid, const char *pszBackend, const char *pszAddress, PCFGMNODE pSubTree,
1491 VUSBSPEED enmSpeed, uint32_t fMaskedIfs, const char *pszCaptureFilename);
1492VMMR3DECL(int) PDMR3UsbDetachDevice(PUVM pUVM, PCRTUUID pUuid);
1493VMMR3DECL(bool) PDMR3UsbHasHub(PUVM pUVM);
1494VMMR3DECL(int) PDMR3UsbDriverAttach(PUVM pUVM, const char *pszDevice, unsigned iDevIns, unsigned iLun, uint32_t fFlags,
1495 PPPDMIBASE ppBase);
1496VMMR3DECL(int) PDMR3UsbDriverDetach(PUVM pUVM, const char *pszDevice, unsigned iDevIns, unsigned iLun,
1497 const char *pszDriver, unsigned iOccurrence, uint32_t fFlags);
1498VMMR3DECL(int) PDMR3UsbQueryLun(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMIBASE *ppBase);
1499VMMR3DECL(int) PDMR3UsbQueryDriverOnLun(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun,
1500 const char *pszDriver, PPPDMIBASE ppBase);
1501
1502/** @} */
1503
1504RT_C_DECLS_END
1505
1506#endif /* !VBOX_INCLUDED_vmm_pdmusb_h */
Note: See TracBrowser for help on using the repository browser.

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