VirtualBox

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

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

VMM,Devices: Add callbacks to required MMR3* APIs to the helper callbacks tables and convert devices and drivers to make use of those, bugref:10074

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 65.2 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, USB Devices.
3 */
4
5/*
6 * Copyright (C) 2006-2020 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, 1, 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 /**
867 * Set up asynchronous handling of a suspend, reset or power off notification.
868 *
869 * This shall only be called when getting the notification. It must be called
870 * for each one.
871 *
872 * @returns VBox status code.
873 * @param pUsbIns The USB device instance.
874 * @param pfnAsyncNotify The callback.
875 * @thread EMT(0)
876 */
877 DECLR3CALLBACKMEMBER(int, pfnSetAsyncNotification, (PPDMUSBINS pUSbIns, PFNPDMUSBASYNCNOTIFY pfnAsyncNotify));
878
879 /**
880 * Notify EMT(0) that the device has completed the asynchronous notification
881 * handling.
882 *
883 * This can be called at any time, spurious calls will simply be ignored.
884 *
885 * @param pUsbIns The USB device instance.
886 * @thread Any
887 */
888 DECLR3CALLBACKMEMBER(void, pfnAsyncNotificationCompleted, (PPDMUSBINS pUsbIns));
889
890 /**
891 * Gets the reason for the most recent VM suspend.
892 *
893 * @returns The suspend reason. VMSUSPENDREASON_INVALID is returned if no
894 * suspend has been made or if the pUsbIns is invalid.
895 * @param pUsbIns The driver instance.
896 */
897 DECLR3CALLBACKMEMBER(VMSUSPENDREASON, pfnVMGetSuspendReason,(PPDMUSBINS pUsbIns));
898
899 /**
900 * Gets the reason for the most recent VM resume.
901 *
902 * @returns The resume reason. VMRESUMEREASON_INVALID is returned if no
903 * resume has been made or if the pUsbIns is invalid.
904 * @param pUsbIns The driver instance.
905 */
906 DECLR3CALLBACKMEMBER(VMRESUMEREASON, pfnVMGetResumeReason,(PPDMUSBINS pUsbIns));
907
908 /** @name Space reserved for minor interface changes.
909 * @{ */
910 DECLR3CALLBACKMEMBER(void, pfnReserved0,(PPDMUSBINS pUsbIns));
911 DECLR3CALLBACKMEMBER(void, pfnReserved1,(PPDMUSBINS pUsbIns));
912 DECLR3CALLBACKMEMBER(void, pfnReserved2,(PPDMUSBINS pUsbIns));
913 DECLR3CALLBACKMEMBER(void, pfnReserved3,(PPDMUSBINS pUsbIns));
914 DECLR3CALLBACKMEMBER(void, pfnReserved4,(PPDMUSBINS pUsbIns));
915 DECLR3CALLBACKMEMBER(void, pfnReserved5,(PPDMUSBINS pUsbIns));
916 DECLR3CALLBACKMEMBER(void, pfnReserved6,(PPDMUSBINS pUsbIns));
917 DECLR3CALLBACKMEMBER(void, pfnReserved7,(PPDMUSBINS pUsbIns));
918 DECLR3CALLBACKMEMBER(void, pfnReserved8,(PPDMUSBINS pUsbIns));
919 DECLR3CALLBACKMEMBER(void, pfnReserved9,(PPDMUSBINS pUsbIns));
920 /** @} */
921
922 /** Just a safety precaution. */
923 uint32_t u32TheEnd;
924} PDMUSBHLP;
925/** Pointer PDM USB Device API. */
926typedef PDMUSBHLP *PPDMUSBHLP;
927/** Pointer const PDM USB Device API. */
928typedef const PDMUSBHLP *PCPDMUSBHLP;
929
930/** Current USBHLP version number. */
931#define PDM_USBHLP_VERSION PDM_VERSION_MAKE(0xeefe, 6, 0)
932
933#endif /* IN_RING3 */
934
935/**
936 * PDM USB Device Instance.
937 */
938typedef struct PDMUSBINS
939{
940 /** Structure version. PDM_USBINS_VERSION defines the current version. */
941 uint32_t u32Version;
942 /** USB device instance number. */
943 uint32_t iInstance;
944 /** The base interface of the device.
945 * The device constructor initializes this if it has any device level
946 * interfaces to export. To obtain this interface call PDMR3QueryUSBDevice(). */
947 PDMIBASE IBase;
948#if HC_ARCH_BITS == 32
949 uint32_t u32Alignment; /**< Alignment padding. */
950#endif
951
952 /** Internal data. */
953 union
954 {
955#ifdef PDMUSBINSINT_DECLARED
956 PDMUSBINSINT s;
957#endif
958 uint8_t padding[HC_ARCH_BITS == 32 ? 96 : 128];
959 } Internal;
960
961 /** Pointer the PDM USB Device API. */
962 R3PTRTYPE(PCPDMUSBHLP) pHlpR3;
963 /** Pointer to the USB device registration structure. */
964 R3PTRTYPE(PCPDMUSBREG) pReg;
965 /** Configuration handle. */
966 R3PTRTYPE(PCFGMNODE) pCfg;
967 /** The (device) global configuration handle. */
968 R3PTRTYPE(PCFGMNODE) pCfgGlobal;
969 /** Pointer to device instance data. */
970 R3PTRTYPE(void *) pvInstanceDataR3;
971 /** Pointer to the VUSB Device structure.
972 * Internal to VUSB, don't touch.
973 * @todo Moved this to PDMUSBINSINT. */
974 R3PTRTYPE(void *) pvVUsbDev2;
975 /** Device name for using when logging.
976 * The constructor sets this and the destructor frees it. */
977 R3PTRTYPE(char *) pszName;
978 /** Tracing indicator. */
979 uint32_t fTracing;
980 /** The tracing ID of this device. */
981 uint32_t idTracing;
982 /** The port/device speed. HCs and emulated devices need to know. */
983 VUSBSPEED enmSpeed;
984
985 /** Padding to make achInstanceData aligned at 32 byte boundary. */
986 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 2 : 3];
987
988 /** Device instance data. The size of this area is defined
989 * in the PDMUSBREG::cbInstanceData field. */
990 char achInstanceData[8];
991} PDMUSBINS;
992
993/** Current USBINS version number. */
994#define PDM_USBINS_VERSION PDM_VERSION_MAKE(0xeefd, 3, 0)
995
996/**
997 * Checks the structure versions of the USB device instance and USB device
998 * helpers, returning if they are incompatible.
999 *
1000 * This shall be the first statement of the constructor!
1001 *
1002 * @param pUsbIns The USB device instance pointer.
1003 */
1004#define PDMUSB_CHECK_VERSIONS_RETURN(pUsbIns) \
1005 do \
1006 { \
1007 PPDMUSBINS pUsbInsTypeCheck = (pUsbIns); NOREF(pUsbInsTypeCheck); \
1008 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pUsbIns)->u32Version, PDM_USBINS_VERSION), \
1009 ("DevIns=%#x mine=%#x\n", (pUsbIns)->u32Version, PDM_USBINS_VERSION), \
1010 VERR_PDM_USBINS_VERSION_MISMATCH); \
1011 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pUsbIns)->pHlpR3->u32Version, PDM_USBHLP_VERSION), \
1012 ("DevHlp=%#x mine=%#x\n", (pUsbIns)->pHlpR3->u32Version, PDM_USBHLP_VERSION), \
1013 VERR_PDM_USBHLPR3_VERSION_MISMATCH); \
1014 } while (0)
1015
1016/**
1017 * Quietly checks the structure versions of the USB device instance and
1018 * USB device helpers, returning if they are incompatible.
1019 *
1020 * This shall be invoked as the first statement in the destructor!
1021 *
1022 * @param pUsbIns The USB device instance pointer.
1023 */
1024#define PDMUSB_CHECK_VERSIONS_RETURN_VOID(pUsbIns) \
1025 do \
1026 { \
1027 PPDMUSBINS pUsbInsTypeCheck = (pUsbIns); NOREF(pUsbInsTypeCheck); \
1028 if (RT_LIKELY(PDM_VERSION_ARE_COMPATIBLE((pUsbIns)->u32Version, PDM_USBINS_VERSION) )) \
1029 { /* likely */ } else return; \
1030 if (RT_LIKELY(PDM_VERSION_ARE_COMPATIBLE((pUsbIns)->pHlpR3->u32Version, PDM_USBHLP_VERSION) )) \
1031 { /* likely */ } else return; \
1032 } while (0)
1033
1034
1035/** Converts a pointer to the PDMUSBINS::IBase to a pointer to PDMUSBINS. */
1036#define PDMIBASE_2_PDMUSB(pInterface) ( (PPDMUSBINS)((char *)(pInterface) - RT_UOFFSETOF(PDMUSBINS, IBase)) )
1037
1038
1039/** @def PDMUSB_ASSERT_EMT
1040 * Assert that the current thread is the emulation thread.
1041 */
1042#ifdef VBOX_STRICT
1043# define PDMUSB_ASSERT_EMT(pUsbIns) pUsbIns->pHlpR3->pfnAssertEMT(pUsbIns, __FILE__, __LINE__, __FUNCTION__)
1044#else
1045# define PDMUSB_ASSERT_EMT(pUsbIns) do { } while (0)
1046#endif
1047
1048/** @def PDMUSB_ASSERT_OTHER
1049 * Assert that the current thread is NOT the emulation thread.
1050 */
1051#ifdef VBOX_STRICT
1052# define PDMUSB_ASSERT_OTHER(pUsbIns) pUsbIns->pHlpR3->pfnAssertOther(pUsbIns, __FILE__, __LINE__, __FUNCTION__)
1053#else
1054# define PDMUSB_ASSERT_OTHER(pUsbIns) do { } while (0)
1055#endif
1056
1057/** @def PDMUSB_SET_ERROR
1058 * Set the VM error. See PDMUsbHlpVMSetError() for printf like message
1059 * formatting.
1060 */
1061#define PDMUSB_SET_ERROR(pUsbIns, rc, pszError) \
1062 PDMUsbHlpVMSetError(pUsbIns, rc, RT_SRC_POS, "%s", pszError)
1063
1064/** @def PDMUSB_SET_RUNTIME_ERROR
1065 * Set the VM runtime error. See PDMUsbHlpVMSetRuntimeError() for printf like
1066 * message formatting.
1067 */
1068#define PDMUSB_SET_RUNTIME_ERROR(pUsbIns, fFlags, pszErrorId, pszError) \
1069 PDMUsbHlpVMSetRuntimeError(pUsbIns, fFlags, pszErrorId, "%s", pszError)
1070
1071
1072#ifdef IN_RING3
1073
1074/**
1075 * @copydoc PDMUSBHLP::pfnDriverAttach
1076 */
1077DECLINLINE(int) PDMUsbHlpDriverAttach(PPDMUSBINS pUsbIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
1078{
1079 return pUsbIns->pHlpR3->pfnDriverAttach(pUsbIns, iLun, pBaseInterface, ppBaseInterface, pszDesc);
1080}
1081
1082/**
1083 * VBOX_STRICT wrapper for pHlpR3->pfnDBGFStopV.
1084 *
1085 * @returns VBox status code which must be passed up to the VMM.
1086 * @param pUsbIns Device instance.
1087 * @param SRC_POS Use RT_SRC_POS.
1088 * @param pszFormat Message. (optional)
1089 * @param ... Message parameters.
1090 */
1091DECLINLINE(int) RT_IPRT_FORMAT_ATTR(5, 6) PDMUsbDBGFStop(PPDMUSBINS pUsbIns, RT_SRC_POS_DECL, const char *pszFormat, ...)
1092{
1093#ifdef VBOX_STRICT
1094 int rc;
1095 va_list va;
1096 va_start(va, pszFormat);
1097 rc = pUsbIns->pHlpR3->pfnDBGFStopV(pUsbIns, RT_SRC_POS_ARGS, pszFormat, va);
1098 va_end(va);
1099 return rc;
1100#else
1101 NOREF(pUsbIns);
1102 NOREF(pszFile);
1103 NOREF(iLine);
1104 NOREF(pszFunction);
1105 NOREF(pszFormat);
1106 return VINF_SUCCESS;
1107#endif
1108}
1109
1110/**
1111 * @copydoc PDMUSBHLP::pfnVMState
1112 */
1113DECLINLINE(VMSTATE) PDMUsbHlpVMState(PPDMUSBINS pUsbIns)
1114{
1115 return pUsbIns->pHlpR3->pfnVMState(pUsbIns);
1116}
1117
1118/**
1119 * @copydoc PDMUSBHLP::pfnThreadCreate
1120 */
1121DECLINLINE(int) PDMUsbHlpThreadCreate(PPDMUSBINS pUsbIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADUSB pfnThread,
1122 PFNPDMTHREADWAKEUPUSB pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
1123{
1124 return pUsbIns->pHlpR3->pfnThreadCreate(pUsbIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
1125}
1126
1127
1128/**
1129 * @copydoc PDMUSBHLP::pfnSetAsyncNotification
1130 */
1131DECLINLINE(int) PDMUsbHlpSetAsyncNotification(PPDMUSBINS pUsbIns, PFNPDMUSBASYNCNOTIFY pfnAsyncNotify)
1132{
1133 return pUsbIns->pHlpR3->pfnSetAsyncNotification(pUsbIns, pfnAsyncNotify);
1134}
1135
1136/**
1137 * @copydoc PDMUSBHLP::pfnAsyncNotificationCompleted
1138 */
1139DECLINLINE(void) PDMUsbHlpAsyncNotificationCompleted(PPDMUSBINS pUsbIns)
1140{
1141 pUsbIns->pHlpR3->pfnAsyncNotificationCompleted(pUsbIns);
1142}
1143
1144/**
1145 * Set the VM error message
1146 *
1147 * @returns rc.
1148 * @param pUsbIns The USB device instance.
1149 * @param rc VBox status code.
1150 * @param SRC_POS Use RT_SRC_POS.
1151 * @param pszFormat Error message format string.
1152 * @param ... Error message arguments.
1153 */
1154DECLINLINE(int) RT_IPRT_FORMAT_ATTR(6, 7) PDMUsbHlpVMSetError(PPDMUSBINS pUsbIns, int rc, RT_SRC_POS_DECL,
1155 const char *pszFormat, ...)
1156{
1157 va_list va;
1158 va_start(va, pszFormat);
1159 rc = pUsbIns->pHlpR3->pfnVMSetErrorV(pUsbIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
1160 va_end(va);
1161 return rc;
1162}
1163
1164/**
1165 * @copydoc PDMUSBHLP::pfnMMHeapAlloc
1166 */
1167DECLINLINE(void *) PDMUsbHlpMMHeapAlloc(PPDMUSBINS pUsbIns, size_t cb)
1168{
1169 return pUsbIns->pHlpR3->pfnMMHeapAlloc(pUsbIns, cb);
1170}
1171
1172/**
1173 * @copydoc PDMUSBHLP::pfnMMHeapAllocZ
1174 */
1175DECLINLINE(void *) PDMUsbHlpMMHeapAllocZ(PPDMUSBINS pUsbIns, size_t cb)
1176{
1177 return pUsbIns->pHlpR3->pfnMMHeapAllocZ(pUsbIns, cb);
1178}
1179
1180/**
1181 * Frees memory allocated by PDMUsbHlpMMHeapAlloc or PDMUsbHlpMMHeapAllocZ.
1182 *
1183 * @param pUsbIns The USB device instance.
1184 * @param pv The memory to free. NULL is fine.
1185 */
1186DECLINLINE(void) PDMUsbHlpMMHeapFree(PPDMUSBINS pUsbIns, void *pv)
1187{
1188 return pUsbIns->pHlpR3->pfnMMHeapFree(pUsbIns, pv);
1189}
1190
1191/**
1192 * @copydoc PDMUSBHLP::pfnDBGFInfoRegisterArgv
1193 */
1194DECLINLINE(int) PDMUsbHlpDBGFInfoRegisterArgv(PPDMUSBINS pUsbIns, const char *pszName, const char *pszDesc, PFNDBGFINFOARGVUSB pfnHandler)
1195{
1196 return pUsbIns->pHlpR3->pfnDBGFInfoRegisterArgv(pUsbIns, pszName, pszDesc, pfnHandler);
1197}
1198
1199/**
1200 * @copydoc PDMUSBHLP::pfnTimerCreate
1201 */
1202DECLINLINE(int) PDMUsbHlpTimerCreate(PPDMUSBINS pUsbIns, TMCLOCK enmClock, PFNTMTIMERUSB pfnCallback, void *pvUser,
1203 uint32_t fFlags, const char *pszDesc, PTMTIMERHANDLE phTimer)
1204{
1205 return pUsbIns->pHlpR3->pfnTimerCreate(pUsbIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, phTimer);
1206}
1207
1208/**
1209 * @copydoc PDMUSBHLP::pfnTimerFromMicro
1210 */
1211DECLINLINE(uint64_t) PDMUsbHlpTimerFromMicro(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cMicroSecs)
1212{
1213 return pUsbIns->pHlpR3->pfnTimerFromMicro(pUsbIns, hTimer, cMicroSecs);
1214}
1215
1216/**
1217 * @copydoc PDMUSBHLP::pfnTimerFromMilli
1218 */
1219DECLINLINE(uint64_t) PDMUsbHlpTimerFromMilli(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cMilliSecs)
1220{
1221 return pUsbIns->pHlpR3->pfnTimerFromMilli(pUsbIns, hTimer, cMilliSecs);
1222}
1223
1224/**
1225 * @copydoc PDMUSBHLP::pfnTimerFromNano
1226 */
1227DECLINLINE(uint64_t) PDMUsbHlpTimerFromNano(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cNanoSecs)
1228{
1229 return pUsbIns->pHlpR3->pfnTimerFromNano(pUsbIns, hTimer, cNanoSecs);
1230}
1231
1232/**
1233 * @copydoc PDMUSBHLP::pfnTimerGet
1234 */
1235DECLINLINE(uint64_t) PDMUsbHlpTimerGet(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1236{
1237 return pUsbIns->pHlpR3->pfnTimerGet(pUsbIns, hTimer);
1238}
1239
1240/**
1241 * @copydoc PDMUSBHLP::pfnTimerGetFreq
1242 */
1243DECLINLINE(uint64_t) PDMUsbHlpTimerGetFreq(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1244{
1245 return pUsbIns->pHlpR3->pfnTimerGetFreq(pUsbIns, hTimer);
1246}
1247
1248/**
1249 * @copydoc PDMUSBHLP::pfnTimerGetNano
1250 */
1251DECLINLINE(uint64_t) PDMUsbHlpTimerGetNano(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1252{
1253 return pUsbIns->pHlpR3->pfnTimerGetNano(pUsbIns, hTimer);
1254}
1255
1256/**
1257 * @copydoc PDMUSBHLP::pfnTimerIsActive
1258 */
1259DECLINLINE(bool) PDMUsbHlpTimerIsActive(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1260{
1261 return pUsbIns->pHlpR3->pfnTimerIsActive(pUsbIns, hTimer);
1262}
1263
1264/**
1265 * @copydoc PDMUSBHLP::pfnTimerIsLockOwner
1266 */
1267DECLINLINE(bool) PDMUsbHlpTimerIsLockOwner(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1268{
1269 return pUsbIns->pHlpR3->pfnTimerIsLockOwner(pUsbIns, hTimer);
1270}
1271
1272/**
1273 * @copydoc PDMUSBHLP::pfnTimerLockClock
1274 */
1275DECLINLINE(int) PDMUsbHlpTimerLockClock(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1276{
1277 return pUsbIns->pHlpR3->pfnTimerLockClock(pUsbIns, hTimer);
1278}
1279
1280/**
1281 * @copydoc PDMUSBHLP::pfnTimerLockClock2
1282 */
1283DECLINLINE(int) PDMUsbHlpTimerLockClock2(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect)
1284{
1285 return pUsbIns->pHlpR3->pfnTimerLockClock2(pUsbIns, hTimer, pCritSect);
1286}
1287
1288/**
1289 * @copydoc PDMUSBHLP::pfnTimerSet
1290 */
1291DECLINLINE(int) PDMUsbHlpTimerSet(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t uExpire)
1292{
1293 return pUsbIns->pHlpR3->pfnTimerSet(pUsbIns, hTimer, uExpire);
1294}
1295
1296/**
1297 * @copydoc PDMUSBHLP::pfnTimerSetFrequencyHint
1298 */
1299DECLINLINE(int) PDMUsbHlpTimerSetFrequencyHint(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint32_t uHz)
1300{
1301 return pUsbIns->pHlpR3->pfnTimerSetFrequencyHint(pUsbIns, hTimer, uHz);
1302}
1303
1304/**
1305 * @copydoc PDMUSBHLP::pfnTimerSetMicro
1306 */
1307DECLINLINE(int) PDMUsbHlpTimerSetMicro(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cMicrosToNext)
1308{
1309 return pUsbIns->pHlpR3->pfnTimerSetMicro(pUsbIns, hTimer, cMicrosToNext);
1310}
1311
1312/**
1313 * @copydoc PDMUSBHLP::pfnTimerSetMillies
1314 */
1315DECLINLINE(int) PDMUsbHlpTimerSetMillies(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cMilliesToNext)
1316{
1317 return pUsbIns->pHlpR3->pfnTimerSetMillies(pUsbIns, hTimer, cMilliesToNext);
1318}
1319
1320/**
1321 * @copydoc PDMUSBHLP::pfnTimerSetNano
1322 */
1323DECLINLINE(int) PDMUsbHlpTimerSetNano(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cNanosToNext)
1324{
1325 return pUsbIns->pHlpR3->pfnTimerSetNano(pUsbIns, hTimer, cNanosToNext);
1326}
1327
1328/**
1329 * @copydoc PDMUSBHLP::pfnTimerSetRelative
1330 */
1331DECLINLINE(int) PDMUsbHlpTimerSetRelative(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, uint64_t cTicksToNext, uint64_t *pu64Now)
1332{
1333 return pUsbIns->pHlpR3->pfnTimerSetRelative(pUsbIns, hTimer, cTicksToNext, pu64Now);
1334}
1335
1336/**
1337 * @copydoc PDMUSBHLP::pfnTimerStop
1338 */
1339DECLINLINE(int) PDMUsbHlpTimerStop(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1340{
1341 return pUsbIns->pHlpR3->pfnTimerStop(pUsbIns, hTimer);
1342}
1343
1344/**
1345 * @copydoc PDMUSBHLP::pfnTimerUnlockClock
1346 */
1347DECLINLINE(void) PDMUsbHlpTimerUnlockClock(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1348{
1349 pUsbIns->pHlpR3->pfnTimerUnlockClock(pUsbIns, hTimer);
1350}
1351
1352/**
1353 * @copydoc PDMUSBHLP::pfnTimerUnlockClock2
1354 */
1355DECLINLINE(void) PDMUsbHlpTimerUnlockClock2(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect)
1356{
1357 pUsbIns->pHlpR3->pfnTimerUnlockClock2(pUsbIns, hTimer, pCritSect);
1358}
1359
1360/**
1361 * @copydoc PDMUSBHLP::pfnTimerSetCritSect
1362 */
1363DECLINLINE(int) PDMUsbHlpTimerSetCritSect(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect)
1364{
1365 return pUsbIns->pHlpR3->pfnTimerSetCritSect(pUsbIns, hTimer, pCritSect);
1366}
1367
1368/**
1369 * @copydoc PDMUSBHLP::pfnTimerSave
1370 */
1371DECLINLINE(int) PDMUsbHlpTimerSave(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM)
1372{
1373 return pUsbIns->pHlpR3->pfnTimerSave(pUsbIns, hTimer, pSSM);
1374}
1375
1376/**
1377 * @copydoc PDMUSBHLP::pfnTimerLoad
1378 */
1379DECLINLINE(int) PDMUsbHlpTimerLoad(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM)
1380{
1381 return pUsbIns->pHlpR3->pfnTimerLoad(pUsbIns, hTimer, pSSM);
1382}
1383
1384/**
1385 * @copydoc PDMUSBHLP::pfnTimerDestroy
1386 */
1387DECLINLINE(int) PDMUsbHlpTimerDestroy(PPDMUSBINS pUsbIns, TMTIMERHANDLE hTimer)
1388{
1389 return pUsbIns->pHlpR3->pfnTimerDestroy(pUsbIns, hTimer);
1390}
1391
1392/**
1393 * @copydoc PDMUSBHLP::pfnSSMRegister
1394 */
1395DECLINLINE(int) PDMUsbHlpSSMRegister(PPDMUSBINS pUsbIns, uint32_t uVersion, size_t cbGuess,
1396 PFNSSMUSBLIVEPREP pfnLivePrep, PFNSSMUSBLIVEEXEC pfnLiveExec, PFNSSMUSBLIVEVOTE pfnLiveVote,
1397 PFNSSMUSBSAVEPREP pfnSavePrep, PFNSSMUSBSAVEEXEC pfnSaveExec, PFNSSMUSBSAVEDONE pfnSaveDone,
1398 PFNSSMUSBLOADPREP pfnLoadPrep, PFNSSMUSBLOADEXEC pfnLoadExec, PFNSSMUSBLOADDONE pfnLoadDone)
1399{
1400 return pUsbIns->pHlpR3->pfnSSMRegister(pUsbIns, uVersion, cbGuess,
1401 pfnLivePrep, pfnLiveExec, pfnLiveVote,
1402 pfnSavePrep, pfnSaveExec, pfnSaveDone,
1403 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
1404}
1405
1406#endif /* IN_RING3 */
1407
1408
1409
1410/** Pointer to callbacks provided to the VBoxUsbRegister() call. */
1411typedef const struct PDMUSBREGCB *PCPDMUSBREGCB;
1412
1413/**
1414 * Callbacks for VBoxUSBDeviceRegister().
1415 */
1416typedef struct PDMUSBREGCB
1417{
1418 /** Interface version.
1419 * This is set to PDM_USBREG_CB_VERSION. */
1420 uint32_t u32Version;
1421
1422 /**
1423 * Registers a device with the current VM instance.
1424 *
1425 * @returns VBox status code.
1426 * @param pCallbacks Pointer to the callback table.
1427 * @param pReg Pointer to the USB device registration record.
1428 * This data must be permanent and readonly.
1429 */
1430 DECLR3CALLBACKMEMBER(int, pfnRegister,(PCPDMUSBREGCB pCallbacks, PCPDMUSBREG pReg));
1431} PDMUSBREGCB;
1432
1433/** Current version of the PDMUSBREGCB structure. */
1434#define PDM_USBREG_CB_VERSION PDM_VERSION_MAKE(0xeefc, 1, 0)
1435
1436
1437/**
1438 * The VBoxUsbRegister callback function.
1439 *
1440 * PDM will invoke this function after loading a USB device module and letting
1441 * the module decide which devices to register and how to handle conflicts.
1442 *
1443 * @returns VBox status code.
1444 * @param pCallbacks Pointer to the callback table.
1445 * @param u32Version VBox version number.
1446 */
1447typedef DECLCALLBACKTYPE(int, FNPDMVBOXUSBREGISTER,(PCPDMUSBREGCB pCallbacks, uint32_t u32Version));
1448
1449VMMR3DECL(int) PDMR3UsbCreateEmulatedDevice(PUVM pUVM, const char *pszDeviceName, PCFGMNODE pDeviceNode, PCRTUUID pUuid,
1450 const char *pszCaptureFilename);
1451VMMR3DECL(int) PDMR3UsbCreateProxyDevice(PUVM pUVM, PCRTUUID pUuid, const char *pszBackend, const char *pszAddress, void *pvBackend,
1452 VUSBSPEED enmSpeed, uint32_t fMaskedIfs, const char *pszCaptureFilename);
1453VMMR3DECL(int) PDMR3UsbDetachDevice(PUVM pUVM, PCRTUUID pUuid);
1454VMMR3DECL(bool) PDMR3UsbHasHub(PUVM pUVM);
1455VMMR3DECL(int) PDMR3UsbDriverAttach(PUVM pUVM, const char *pszDevice, unsigned iDevIns, unsigned iLun, uint32_t fFlags,
1456 PPPDMIBASE ppBase);
1457VMMR3DECL(int) PDMR3UsbDriverDetach(PUVM pUVM, const char *pszDevice, unsigned iDevIns, unsigned iLun,
1458 const char *pszDriver, unsigned iOccurrence, uint32_t fFlags);
1459VMMR3DECL(int) PDMR3UsbQueryLun(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMIBASE *ppBase);
1460VMMR3DECL(int) PDMR3UsbQueryDriverOnLun(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun,
1461 const char *pszDriver, PPPDMIBASE ppBase);
1462
1463/** @} */
1464
1465RT_C_DECLS_END
1466
1467#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