VirtualBox

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

Last change on this file since 94342 was 94342, checked in by vboxsync, 3 years ago

Main,VMM/PDMUsb,Devices/USB,VRDP: Drop passing pointers through CFGM in favor of using VMM2USERMETHODS::pfnQueryGenericObject, bugref:10053

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