VirtualBox

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

Last change on this file since 97150 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

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