VirtualBox

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

Last change on this file since 52664 was 51290, checked in by vboxsync, 10 years ago

VMM/PDMUsb: add PDMR3UsbQueryLun function which is needed very soon for mounting media at run time in virtual USB DVD drives

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 41.6 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, USB Devices.
3 */
4
5/*
6 * Copyright (C) 2006-2014 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_vmm_pdmusb_h
27#define ___VBox_vmm_pdmusb_h
28
29#include <VBox/vmm/pdmqueue.h>
30#include <VBox/vmm/pdmcritsect.h>
31#include <VBox/vmm/pdmthread.h>
32#include <VBox/vmm/pdmifs.h>
33#include <VBox/vmm/pdmcommon.h>
34#include <VBox/vmm/tm.h>
35#include <VBox/vmm/ssm.h>
36#include <VBox/vmm/cfgm.h>
37#include <VBox/vmm/dbgf.h>
38#include <VBox/vmm/mm.h>
39#include <VBox/err.h>
40#include <VBox/vusb.h>
41#include <iprt/stdarg.h>
42
43RT_C_DECLS_BEGIN
44
45/** @defgroup grp_pdm_usbdev The USB Devices API
46 * @ingroup grp_pdm
47 * @{
48 */
49
50
51/**
52 * A string entry for the USB descriptor cache.
53 */
54typedef struct PDMUSBDESCCACHESTRING
55{
56 /** The string index. */
57 uint8_t idx;
58 /** The UTF-8 representation of the string. */
59 const char *psz;
60} PDMUSBDESCCACHESTRING;
61/** Pointer to a const string entry. */
62typedef PDMUSBDESCCACHESTRING const *PCPDMUSBDESCCACHESTRING;
63
64
65/**
66 * A language entry for the USB descriptor cache.
67 */
68typedef struct PDMUSBDESCCACHELANG
69{
70 /** The language ID for the strings in this block. */
71 uint16_t idLang;
72 /** The number of strings in the array. */
73 uint16_t cStrings;
74 /** Pointer to an array of associated strings.
75 * This must be sorted in ascending order by string index as a binary lookup
76 * will be performed. */
77 PCPDMUSBDESCCACHESTRING paStrings;
78} PDMUSBDESCCACHELANG;
79/** Pointer to a const language entry. */
80typedef PDMUSBDESCCACHELANG const *PCPDMUSBDESCCACHELANG;
81
82
83/**
84 * USB descriptor cache.
85 *
86 * This structure is owned by the USB device but provided to the PDM/VUSB layer
87 * thru the PDMUSBREG::pfnGetDescriptorCache method. PDM/VUSB will use the
88 * information here to map addresses to endpoints, perform SET_CONFIGURATION
89 * requests, and optionally perform GET_DESCRIPTOR requests (see flag).
90 *
91 * Currently, only device and configuration descriptors are cached.
92 */
93typedef struct PDMUSBDESCCACHE
94{
95 /** USB device descriptor */
96 PCVUSBDESCDEVICE pDevice;
97 /** USB Descriptor arrays (pDev->bNumConfigurations) */
98 PCVUSBDESCCONFIGEX paConfigs;
99 /** Language IDs and their associated strings.
100 * This must be sorted in ascending order by language ID as a binary lookup
101 * will be used. */
102 PCPDMUSBDESCCACHELANG paLanguages;
103 /** The number of entries in the array pointed to by paLanguages. */
104 uint16_t cLanguages;
105 /** Use the cached descriptors for GET_DESCRIPTOR requests. */
106 bool fUseCachedDescriptors;
107 /** Use the cached string descriptors. */
108 bool fUseCachedStringsDescriptors;
109} PDMUSBDESCCACHE;
110/** Pointer to an USB descriptor cache. */
111typedef PDMUSBDESCCACHE *PPDMUSBDESCCACHE;
112/** Pointer to a const USB descriptor cache. */
113typedef const PDMUSBDESCCACHE *PCPDMUSBDESCCACHE;
114
115
116/** PDM Device Flags.
117 * @{ */
118/** A high-speed capable USB 2.0 device (also required to support full-speed). */
119#define PDM_USBREG_HIGHSPEED_CAPABLE RT_BIT(0)
120/** Indicates that the device is fully emulated and is not used to pass through
121 * a host device. */
122#define PDM_USBREG_EMULATED_DEVICE RT_BIT(1)
123/** @} */
124
125/** PDM USB Device Registration Structure,
126 *
127 * This structure is used when registering a device from VBoxUsbRegister() in HC Ring-3.
128 * The PDM will make use of this structure until the VM is destroyed.
129 */
130typedef struct PDMUSBREG
131{
132 /** Structure version. PDM_DEVREG_VERSION defines the current version. */
133 uint32_t u32Version;
134 /** Device name. */
135 char szName[32];
136 /** The description of the device. The UTF-8 string pointed to shall, like this structure,
137 * remain unchanged from registration till VM destruction. */
138 const char *pszDescription;
139
140 /** Flags, combination of the PDM_USBREG_FLAGS_* \#defines. */
141 RTUINT fFlags;
142 /** Maximum number of instances (per VM). */
143 RTUINT cMaxInstances;
144 /** Size of the instance data. */
145 RTUINT cbInstance;
146
147
148 /**
149 * Construct an USB device instance for a VM.
150 *
151 * @returns VBox status.
152 * @param pUsbIns The USB device instance data.
153 * If the registration structure is needed, it will be
154 * accessible thru pUsbDev->pReg.
155 * @param iInstance Instance number. Use this to figure out which registers
156 * and such to use. The instance number is also found in
157 * pUsbDev->iInstance, but since it's likely to be
158 * frequently used PDM passes it as parameter.
159 * @param pCfg Configuration node handle for the device. Use this to
160 * obtain the configuration of the device instance. It is
161 * also found in pUsbDev->pCfg, but since it is primary
162 * usage will in this function it is passed as a parameter.
163 * @param pCfgGlobal Handle to the global device configuration. Also found
164 * in pUsbDev->pCfgGlobal.
165 * @remarks This callback is required.
166 */
167 DECLR3CALLBACKMEMBER(int, pfnConstruct,(PPDMUSBINS pUsbIns, int iInstance, PCFGMNODE pCfg, PCFGMNODE pCfgGlobal));
168
169 /**
170 * Destruct an USB device instance.
171 *
172 * Most VM resources are freed by the VM. This callback is provided so that any non-VM
173 * resources can be freed correctly.
174 *
175 * This method will be called regardless of the pfnConstruct result to avoid
176 * complicated failure paths.
177 *
178 * @param pUsbIns The USB device instance data.
179 * @remarks Optional.
180 */
181 DECLR3CALLBACKMEMBER(void, pfnDestruct,(PPDMUSBINS pUsbIns));
182
183
184 /**
185 * Init complete notification.
186 *
187 * This can be done to do communication with other devices and other
188 * initialization which requires everything to be in place.
189 *
190 * @returns VBOX status code.
191 * @param pUsbIns The USB device instance data.
192 * @remarks Optional.
193 * @remarks Not called when hotplugged.
194 */
195 DECLR3CALLBACKMEMBER(int, pfnVMInitComplete,(PPDMUSBINS pUsbIns));
196
197 /**
198 * VM Power On notification.
199 *
200 * @returns VBox status.
201 * @param pUsbIns The USB device instance data.
202 * @remarks Optional.
203 */
204 DECLR3CALLBACKMEMBER(void, pfnVMPowerOn,(PPDMUSBINS pUsbIns));
205
206 /**
207 * VM Reset notification.
208 *
209 * @returns VBox status.
210 * @param pUsbIns The USB device instance data.
211 * @remarks Optional.
212 */
213 DECLR3CALLBACKMEMBER(void, pfnVMReset,(PPDMUSBINS pUsbIns));
214
215 /**
216 * VM Suspend notification.
217 *
218 * @returns VBox status.
219 * @param pUsbIns The USB device instance data.
220 * @remarks Optional.
221 */
222 DECLR3CALLBACKMEMBER(void, pfnVMSuspend,(PPDMUSBINS pUsbIns));
223
224 /**
225 * VM Resume notification.
226 *
227 * @returns VBox status.
228 * @param pUsbIns The USB device instance data.
229 * @remarks Optional.
230 */
231 DECLR3CALLBACKMEMBER(void, pfnVMResume,(PPDMUSBINS pUsbIns));
232
233 /**
234 * VM Power Off notification.
235 *
236 * This is only called when the VMR3PowerOff call is made on a running VM. This
237 * means that there is no notification if the VM was suspended before being
238 * powered of. There will also be no callback when hot plugging devices.
239 *
240 * @param pUsbIns The USB device instance data.
241 */
242 DECLR3CALLBACKMEMBER(void, pfnVMPowerOff,(PPDMUSBINS pUsbIns));
243
244 /**
245 * Called after the constructor when attaching a device at run time.
246 *
247 * This can be used to do tasks normally assigned to pfnInitComplete and/or pfnVMPowerOn.
248 *
249 * @returns VBox status.
250 * @param pUsbIns The USB device instance data.
251 * @remarks Optional.
252 */
253 DECLR3CALLBACKMEMBER(void, pfnHotPlugged,(PPDMUSBINS pUsbIns));
254
255 /**
256 * Called before the destructor when a device is unplugged at run time.
257 *
258 * This can be used to do tasks normally assigned to pfnVMSuspend and/or pfnVMPowerOff.
259 *
260 * @returns VBox status.
261 * @param pUsbIns The USB device instance data.
262 * @remarks Optional.
263 */
264 DECLR3CALLBACKMEMBER(void, pfnHotUnplugged,(PPDMUSBINS pUsbIns));
265 /**
266 * Driver Attach command.
267 *
268 * This is called to let the USB device attach to a driver for a specified LUN
269 * at runtime. This is not called during VM construction, the device constructor
270 * have to attach to all the available drivers.
271 *
272 * @returns VBox status code.
273 * @param pUsbIns The USB device instance data.
274 * @param iLUN The logical unit which is being detached.
275 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines.
276 * @remarks Optional.
277 */
278 DECLR3CALLBACKMEMBER(int, pfnDriverAttach,(PPDMUSBINS pUsbIns, unsigned iLUN, uint32_t fFlags));
279
280 /**
281 * Driver Detach notification.
282 *
283 * This is called when a driver is detaching itself from a LUN of the device.
284 * The device should adjust it's state to reflect this.
285 *
286 * @param pUsbIns The USB device instance data.
287 * @param iLUN The logical unit which is being detached.
288 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines.
289 * @remarks Optional.
290 */
291 DECLR3CALLBACKMEMBER(void, pfnDriverDetach,(PPDMUSBINS pUsbIns, unsigned iLUN, uint32_t fFlags));
292
293 /**
294 * Query the base interface of a logical unit.
295 *
296 * @returns VBOX status code.
297 * @param pUsbIns The USB device instance data.
298 * @param iLUN The logicial unit to query.
299 * @param ppBase Where to store the pointer to the base interface of the LUN.
300 * @remarks Optional.
301 */
302 DECLR3CALLBACKMEMBER(int, pfnQueryInterface,(PPDMUSBINS pUsbIns, unsigned iLUN, PPDMIBASE *ppBase));
303
304 /**
305 * Requests the USB device to reset.
306 *
307 * @returns VBox status code.
308 * @param pUsbIns The USB device instance.
309 * @param fResetOnLinux A hint to the usb proxy.
310 * Don't use this unless you're the linux proxy device.
311 * @thread Any thread.
312 * @remarks Optional.
313 */
314 DECLR3CALLBACKMEMBER(int, pfnUsbReset,(PPDMUSBINS pUsbIns, bool fResetOnLinux));
315
316 /**
317 * Query device and configuration descriptors for the caching and servicing
318 * relevant GET_DESCRIPTOR requests.
319 *
320 * @returns Pointer to the descriptor cache (read-only).
321 * @param pUsbIns The USB device instance.
322 * @remarks Mandatory.
323 */
324 DECLR3CALLBACKMEMBER(PCPDMUSBDESCCACHE, pfnUsbGetDescriptorCache,(PPDMUSBINS pUsbIns));
325
326 /**
327 * SET_CONFIGURATION request.
328 *
329 * @returns VBox status code.
330 * @param pUsbIns The USB device instance.
331 * @param bConfigurationValue The bConfigurationValue of the new configuration.
332 * @param pvOldCfgDesc Internal - for the device proxy.
333 * @param pvOldIfState Internal - for the device proxy.
334 * @param pvNewCfgDesc Internal - for the device proxy.
335 * @remarks Optional.
336 */
337 DECLR3CALLBACKMEMBER(int, pfnUsbSetConfiguration,(PPDMUSBINS pUsbIns, uint8_t bConfigurationValue,
338 const void *pvOldCfgDesc, const void *pvOldIfState, const void *pvNewCfgDesc));
339
340 /**
341 * SET_INTERFACE request.
342 *
343 * @returns VBox status code.
344 * @param pUsbIns The USB device instance.
345 * @param bInterfaceNumber The interface number.
346 * @param bAlternateSetting The alternate setting.
347 * @remarks Optional.
348 */
349 DECLR3CALLBACKMEMBER(int, pfnUsbSetInterface,(PPDMUSBINS pUsbIns, uint8_t bInterfaceNumber, uint8_t bAlternateSetting));
350
351 /**
352 * Clears the halted state of an endpoint. (Optional)
353 *
354 * This called when VUSB sees a CLEAR_FEATURE(ENDPOINT_HALT) on request
355 * on the zero pipe.
356 *
357 * @returns VBox status code.
358 * @param pUsbIns The USB device instance.
359 * @param uEndpoint The endpoint to clear.
360 * @remarks Optional.
361 */
362 DECLR3CALLBACKMEMBER(int, pfnUsbClearHaltedEndpoint,(PPDMUSBINS pUsbIns, unsigned uEndpoint));
363
364 /**
365 * Allocates an URB.
366 *
367 * This can be used to make use of shared user/kernel mode buffers.
368 *
369 * @returns VBox status code.
370 * @param pUsbIns The USB device instance.
371 * @param cbData The size of the data buffer.
372 * @param cTds The number of TDs.
373 * @param enmType The type of URB.
374 * @param ppUrb Where to store the allocated URB.
375 * @remarks Optional.
376 * @remarks Not implemented yet.
377 */
378 DECLR3CALLBACKMEMBER(int, pfnUrbNew,(PPDMUSBINS pUsbIns, size_t cbData, size_t cTds, VUSBXFERTYPE enmType, PVUSBURB *ppUrb));
379
380 /**
381 * Queues an URB for processing.
382 *
383 * @returns VBox status code.
384 * @retval VINF_SUCCESS on success.
385 * @retval VERR_VUSB_DEVICE_NOT_ATTACHED if the device has been disconnected.
386 * @retval VERR_VUSB_FAILED_TO_QUEUE_URB as a general failure kind of thing.
387 * @retval TBD - document new stuff!
388 *
389 * @param pUsbIns The USB device instance.
390 * @param pUrb The URB to process.
391 * @remarks Mandatory.
392 */
393 DECLR3CALLBACKMEMBER(int, pfnUrbQueue,(PPDMUSBINS pUsbIns, PVUSBURB pUrb));
394
395 /**
396 * Cancels an URB.
397 *
398 * @returns VBox status code.
399 * @param pUsbIns The USB device instance.
400 * @param pUrb The URB to cancel.
401 * @remarks Mandatory.
402 */
403 DECLR3CALLBACKMEMBER(int, pfnUrbCancel,(PPDMUSBINS pUsbIns, PVUSBURB pUrb));
404
405 /**
406 * Reaps an URB.
407 *
408 * @returns A ripe URB, NULL if none.
409 * @param pUsbIns The USB device instance.
410 * @param cMillies How log to wait for an URB to become ripe.
411 * @remarks Mandatory.
412 */
413 DECLR3CALLBACKMEMBER(PVUSBURB, pfnUrbReap,(PPDMUSBINS pUsbIns, RTMSINTERVAL cMillies));
414
415 /**
416 * Wakes a thread waiting in pfnUrbReap.
417 *
418 * @returns VBox status code.
419 * @param pUsbIns The USB device instance.
420 */
421 DECLR3CALLBACKMEMBER(int, pfnWakeup,(PPDMUSBINS pUsbIns));
422
423 /** Just some init precaution. Must be set to PDM_USBREG_VERSION. */
424 uint32_t u32TheEnd;
425} PDMUSBREG;
426/** Pointer to a PDM USB Device Structure. */
427typedef PDMUSBREG *PPDMUSBREG;
428/** Const pointer to a PDM USB Device Structure. */
429typedef PDMUSBREG const *PCPDMUSBREG;
430
431/** Current USBREG version number. */
432#define PDM_USBREG_VERSION PDM_VERSION_MAKE(0xeeff, 1, 0)
433
434/** PDM USB Device Flags.
435 * @{ */
436/* none yet */
437/** @} */
438
439
440#ifdef IN_RING3
441
442/**
443 * PDM USB Device API.
444 */
445typedef struct PDMUSBHLP
446{
447 /** Structure version. PDM_USBHLP_VERSION defines the current version. */
448 uint32_t u32Version;
449
450 /**
451 * Attaches a driver (chain) to the USB device.
452 *
453 * The first call for a LUN this will serve as a registration of the LUN. The pBaseInterface and
454 * the pszDesc string will be registered with that LUN and kept around for PDMR3QueryUSBDeviceLun().
455 *
456 * @returns VBox status code.
457 * @param pUsbIns The USB device instance.
458 * @param iLun The logical unit to attach.
459 * @param pBaseInterface Pointer to the base interface for that LUN. (device side / down)
460 * @param ppBaseInterface Where to store the pointer to the base interface. (driver side / up)
461 * @param pszDesc Pointer to a string describing the LUN. This string must remain valid
462 * for the live of the device instance.
463 */
464 DECLR3CALLBACKMEMBER(int, pfnDriverAttach,(PPDMUSBINS pUsbIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc));
465
466 /**
467 * Assert that the current thread is the emulation thread.
468 *
469 * @returns True if correct.
470 * @returns False if wrong.
471 * @param pUsbIns The USB device instance.
472 * @param pszFile Filename of the assertion location.
473 * @param iLine Linenumber of the assertion location.
474 * @param pszFunction Function of the assertion location.
475 */
476 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMUSBINS pUsbIns, const char *pszFile, unsigned iLine, const char *pszFunction));
477
478 /**
479 * Assert that the current thread is NOT the emulation thread.
480 *
481 * @returns True if correct.
482 * @returns False if wrong.
483 * @param pUsbIns The USB device instance.
484 * @param pszFile Filename of the assertion location.
485 * @param iLine Linenumber of the assertion location.
486 * @param pszFunction Function of the assertion location.
487 */
488 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMUSBINS pUsbIns, const char *pszFile, unsigned iLine, const char *pszFunction));
489
490 /**
491 * Stops the VM and enters the debugger to look at the guest state.
492 *
493 * Use the PDMUsbDBGFStop() inline function with the RT_SRC_POS macro instead of
494 * invoking this function directly.
495 *
496 * @returns VBox status code which must be passed up to the VMM.
497 * @param pUsbIns The USB device instance.
498 * @param pszFile Filename of the assertion location.
499 * @param iLine The linenumber of the assertion location.
500 * @param pszFunction Function of the assertion location.
501 * @param pszFormat Message. (optional)
502 * @param va Message parameters.
503 */
504 DECLR3CALLBACKMEMBER(int, pfnDBGFStopV,(PPDMUSBINS pUsbIns, const char *pszFile, unsigned iLine, const char *pszFunction, const char *pszFormat, va_list va));
505
506 /**
507 * Register a info handler with DBGF,
508 *
509 * @returns VBox status code.
510 * @param pUsbIns The USB device instance.
511 * @param pszName The identifier of the info.
512 * @param pszDesc The description of the info and any arguments the handler may take.
513 * @param pfnHandler The handler function to be called to display the info.
514 */
515 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegister,(PPDMUSBINS pUsbIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERUSB pfnHandler));
516
517 /**
518 * Allocate memory which is associated with current VM instance
519 * and automatically freed on it's destruction.
520 *
521 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
522 * @param pUsbIns The USB device instance.
523 * @param cb Number of bytes to allocate.
524 */
525 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMUSBINS pUsbIns, size_t cb));
526
527 /**
528 * Allocate memory which is associated with current VM instance
529 * and automatically freed on it's destruction. The memory is ZEROed.
530 *
531 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
532 * @param pUsbIns The USB device instance.
533 * @param cb Number of bytes to allocate.
534 */
535 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAllocZ,(PPDMUSBINS pUsbIns, size_t cb));
536
537 /**
538 * Create a queue.
539 *
540 * @returns VBox status code.
541 * @param pUsbIns The USB device instance.
542 * @param cbItem Size a queue item.
543 * @param cItems Number of items in the queue.
544 * @param cMilliesInterval Number of milliseconds between polling the queue.
545 * If 0 then the emulation thread will be notified whenever an item arrives.
546 * @param pfnCallback The consumer function.
547 * @param pszName The queue base name. The instance number will be
548 * appended automatically.
549 * @param ppQueue Where to store the queue handle on success.
550 * @thread The emulation thread.
551 */
552 DECLR3CALLBACKMEMBER(int, pfnPDMQueueCreate,(PPDMUSBINS pUsbIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
553 PFNPDMQUEUEUSB pfnCallback, const char *pszName, PPDMQUEUE *ppQueue));
554
555 /**
556 * Register a save state data unit.
557 *
558 * @returns VBox status.
559 * @param pUsbIns The USB device instance.
560 * @param uVersion Data layout version number.
561 * @param cbGuess The approximate amount of data in the unit.
562 * Only for progress indicators.
563 *
564 * @param pfnLivePrep Prepare live save callback, optional.
565 * @param pfnLiveExec Execute live save callback, optional.
566 * @param pfnLiveVote Vote live save callback, optional.
567 *
568 * @param pfnSavePrep Prepare save callback, optional.
569 * @param pfnSaveExec Execute save callback, optional.
570 * @param pfnSaveDone Done save callback, optional.
571 *
572 * @param pfnLoadPrep Prepare load callback, optional.
573 * @param pfnLoadExec Execute load callback, optional.
574 * @param pfnLoadDone Done load callback, optional.
575 */
576 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMUSBINS pUsbIns, uint32_t uVersion, size_t cbGuess,
577 PFNSSMUSBLIVEPREP pfnLivePrep, PFNSSMUSBLIVEEXEC pfnLiveExec, PFNSSMUSBLIVEVOTE pfnLiveVote,
578 PFNSSMUSBSAVEPREP pfnSavePrep, PFNSSMUSBSAVEEXEC pfnSaveExec, PFNSSMUSBSAVEDONE pfnSaveDone,
579 PFNSSMUSBLOADPREP pfnLoadPrep, PFNSSMUSBLOADEXEC pfnLoadExec, PFNSSMUSBLOADDONE pfnLoadDone));
580
581 /**
582 * Register a STAM sample.
583 *
584 * Use the PDMUsbHlpSTAMRegister wrapper.
585 *
586 * @returns VBox status.
587 * @param pUsbIns The USB device instance.
588 * @param pvSample Pointer to the sample.
589 * @param enmType Sample type. This indicates what pvSample is pointing at.
590 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
591 * @param enmUnit Sample unit.
592 * @param pszDesc Sample description.
593 * @param pszName The sample name format string.
594 * @param va Arguments to the format string.
595 */
596 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMUSBINS pUsbIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
597 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list va));
598
599 /**
600 * Creates a timer.
601 *
602 * @returns VBox status.
603 * @param pUsbIns The USB device instance.
604 * @param enmClock The clock to use on this timer.
605 * @param pfnCallback Callback function.
606 * @param pvUser User argument for the callback.
607 * @param fFlags Flags, see TMTIMER_FLAGS_*.
608 * @param pszDesc Pointer to description string which must stay around
609 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
610 * @param ppTimer Where to store the timer on success.
611 */
612 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMUSBINS pUsbIns, TMCLOCK enmClock, PFNTMTIMERUSB pfnCallback, void *pvUser,
613 uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer));
614
615 /**
616 * Set the VM error message
617 *
618 * @returns rc.
619 * @param pUsbIns The USB device instance.
620 * @param rc VBox status code.
621 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
622 * @param pszFormat Error message format string.
623 * @param va Error message arguments.
624 */
625 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMUSBINS pUsbIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
626
627 /**
628 * Set the VM runtime error message
629 *
630 * @returns VBox status code.
631 * @param pUsbIns The USB device instance.
632 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
633 * @param pszErrorId Error ID string.
634 * @param pszFormat Error message format string.
635 * @param va Error message arguments.
636 */
637 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMUSBINS pUsbIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va));
638
639 /**
640 * Gets the VM state.
641 *
642 * @returns VM state.
643 * @param pUsbIns The USB device instance.
644 * @thread Any thread (just keep in mind that it's volatile info).
645 */
646 DECLR3CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMUSBINS pUsbIns));
647
648 /**
649 * Creates a PDM thread.
650 *
651 * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
652 * resuming, and destroying the thread as the VM state changes.
653 *
654 * @returns VBox status code.
655 * @param pDevIns The device instance.
656 * @param ppThread Where to store the thread 'handle'.
657 * @param pvUser The user argument to the thread function.
658 * @param pfnThread The thread function.
659 * @param pfnWakeup The wakup callback. This is called on the EMT
660 * thread when a state change is pending.
661 * @param cbStack See RTThreadCreate.
662 * @param enmType See RTThreadCreate.
663 * @param pszName See RTThreadCreate.
664 */
665 DECLR3CALLBACKMEMBER(int, pfnThreadCreate,(PPDMUSBINS pUsbIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADUSB pfnThread,
666 PFNPDMTHREADWAKEUPUSB pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
667
668 /**
669 * Set up asynchronous handling of a suspend, reset or power off notification.
670 *
671 * This shall only be called when getting the notification. It must be called
672 * for each one.
673 *
674 * @returns VBox status code.
675 * @param pUSBIns The USB device instance.
676 * @param pfnAsyncNotify The callback.
677 * @thread EMT(0)
678 */
679 DECLR3CALLBACKMEMBER(int, pfnSetAsyncNotification, (PPDMUSBINS pUSbIns, PFNPDMUSBASYNCNOTIFY pfnAsyncNotify));
680
681 /**
682 * Notify EMT(0) that the device has completed the asynchronous notification
683 * handling.
684 *
685 * This can be called at any time, spurious calls will simply be ignored.
686 *
687 * @param pUSBIns The USB device instance.
688 * @thread Any
689 */
690 DECLR3CALLBACKMEMBER(void, pfnAsyncNotificationCompleted, (PPDMUSBINS pUsbIns));
691
692 /**
693 * Gets the reason for the most recent VM suspend.
694 *
695 * @returns The suspend reason. VMSUSPENDREASON_INVALID is returned if no
696 * suspend has been made or if the pUsbIns is invalid.
697 * @param pUsbIns The driver instance.
698 */
699 DECLR3CALLBACKMEMBER(VMSUSPENDREASON, pfnVMGetSuspendReason,(PPDMUSBINS pUsbIns));
700
701 /**
702 * Gets the reason for the most recent VM resume.
703 *
704 * @returns The resume reason. VMRESUMEREASON_INVALID is returned if no
705 * resume has been made or if the pUsbIns is invalid.
706 * @param pUsbIns The driver instance.
707 */
708 DECLR3CALLBACKMEMBER(VMRESUMEREASON, pfnVMGetResumeReason,(PPDMUSBINS pUsbIns));
709
710 /** @name Space reserved for minor interface changes.
711 * @{ */
712 DECLR3CALLBACKMEMBER(void, pfnReserved0,(PPDMUSBINS pUsbIns));
713 DECLR3CALLBACKMEMBER(void, pfnReserved1,(PPDMUSBINS pUsbIns));
714 DECLR3CALLBACKMEMBER(void, pfnReserved2,(PPDMUSBINS pUsbIns));
715 DECLR3CALLBACKMEMBER(void, pfnReserved3,(PPDMUSBINS pUsbIns));
716 DECLR3CALLBACKMEMBER(void, pfnReserved4,(PPDMUSBINS pUsbIns));
717 DECLR3CALLBACKMEMBER(void, pfnReserved5,(PPDMUSBINS pUsbIns));
718 DECLR3CALLBACKMEMBER(void, pfnReserved6,(PPDMUSBINS pUsbIns));
719 DECLR3CALLBACKMEMBER(void, pfnReserved7,(PPDMUSBINS pUsbIns));
720 DECLR3CALLBACKMEMBER(void, pfnReserved8,(PPDMUSBINS pUsbIns));
721 DECLR3CALLBACKMEMBER(void, pfnReserved9,(PPDMUSBINS pUsbIns));
722 /** @} */
723
724 /** Just a safety precaution. */
725 uint32_t u32TheEnd;
726} PDMUSBHLP;
727/** Pointer PDM USB Device API. */
728typedef PDMUSBHLP *PPDMUSBHLP;
729/** Pointer const PDM USB Device API. */
730typedef const PDMUSBHLP *PCPDMUSBHLP;
731
732/** Current USBHLP version number. */
733#define PDM_USBHLP_VERSION PDM_VERSION_MAKE(0xeefe, 3, 0)
734
735#endif /* IN_RING3 */
736
737/**
738 * PDM USB Device Instance.
739 */
740typedef struct PDMUSBINS
741{
742 /** Structure version. PDM_USBINS_VERSION defines the current version. */
743 uint32_t u32Version;
744 /** USB device instance number. */
745 uint32_t iInstance;
746 /** The base interface of the device.
747 * The device constructor initializes this if it has any device level
748 * interfaces to export. To obtain this interface call PDMR3QueryUSBDevice(). */
749 PDMIBASE IBase;
750#if HC_ARCH_BITS == 32
751 uint32_t u32Alignment; /**< Alignment padding. */
752#endif
753
754 /** Internal data. */
755 union
756 {
757#ifdef PDMUSBINSINT_DECLARED
758 PDMUSBINSINT s;
759#endif
760 uint8_t padding[HC_ARCH_BITS == 32 ? 96 : 128];
761 } Internal;
762
763 /** Pointer the PDM USB Device API. */
764 R3PTRTYPE(PCPDMUSBHLP) pHlpR3;
765 /** Pointer to the USB device registration structure. */
766 R3PTRTYPE(PCPDMUSBREG) pReg;
767 /** Configuration handle. */
768 R3PTRTYPE(PCFGMNODE) pCfg;
769 /** The (device) global configuration handle. */
770 R3PTRTYPE(PCFGMNODE) pCfgGlobal;
771 /** Pointer to device instance data. */
772 R3PTRTYPE(void *) pvInstanceDataR3;
773 /** Pointer to the VUSB Device structure.
774 * Internal to VUSB, don't touch.
775 * @todo Moved this to PDMUSBINSINT. */
776 R3PTRTYPE(void *) pvVUsbDev2;
777 /** Device name for using when logging.
778 * The constructor sets this and the destructor frees it. */
779 R3PTRTYPE(char *) pszName;
780 /** Tracing indicator. */
781 uint32_t fTracing;
782 /** The tracing ID of this device. */
783 uint32_t idTracing;
784 /** The USB version of the hub this device is attached to. Used to
785 * determine whether the device communicates at high-speed or full-/low-speed. */
786 uint32_t iUsbHubVersion;
787
788 /** Padding to make achInstanceData aligned at 32 byte boundary. */
789 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 2 : 3];
790
791 /** Device instance data. The size of this area is defined
792 * in the PDMUSBREG::cbInstanceData field. */
793 char achInstanceData[8];
794} PDMUSBINS;
795
796/** Current USBINS version number. */
797#define PDM_USBINS_VERSION PDM_VERSION_MAKE(0xeefd, 2, 0)
798
799/**
800 * Checks the structure versions of the USB device instance and USB device
801 * helpers, returning if they are incompatible.
802 *
803 * This is for use in the constructor.
804 *
805 * @param pUsbIns The USB device instance pointer.
806 */
807#define PDMUSB_CHECK_VERSIONS_RETURN(pUsbIns) \
808 do \
809 { \
810 PPDMUSBINS pUsbInsTypeCheck = (pUsbIns); NOREF(pUsbInsTypeCheck); \
811 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pUsbIns)->u32Version, PDM_USBINS_VERSION), \
812 ("DevIns=%#x mine=%#x\n", (pUsbIns)->u32Version, PDM_USBINS_VERSION), \
813 VERR_PDM_USBINS_VERSION_MISMATCH); \
814 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pUsbIns)->pHlpR3->u32Version, PDM_USBHLP_VERSION), \
815 ("DevHlp=%#x mine=%#x\n", (pUsbIns)->pHlpR3->u32Version, PDM_USBHLP_VERSION), \
816 VERR_PDM_USBHLPR3_VERSION_MISMATCH); \
817 } while (0)
818
819/**
820 * Quietly checks the structure versions of the USB device instance and
821 * USB device helpers, returning if they are incompatible.
822 *
823 * This is for use in the destructor.
824 *
825 * @param pUsbIns The USB device instance pointer.
826 */
827#define PDMUSB_CHECK_VERSIONS_RETURN_QUIET(pUsbIns) \
828 do \
829 { \
830 PPDMUSBINS pUsbInsTypeCheck = (pUsbIns); NOREF(pUsbInsTypeCheck); \
831 if (RT_UNLIKELY(!PDM_VERSION_ARE_COMPATIBLE((pUsbIns)->u32Version, PDM_USBINS_VERSION) )) \
832 return VERR_PDM_USBINS_VERSION_MISMATCH; \
833 if (RT_UNLIKELY(!PDM_VERSION_ARE_COMPATIBLE((pUsbIns)->pHlpR3->u32Version, PDM_USBHLPR3_VERSION) )) \
834 return VERR_PDM_USBHLPR3_VERSION_MISMATCH; \
835 } while (0)
836
837
838/** Converts a pointer to the PDMUSBINS::IBase to a pointer to PDMUSBINS. */
839#define PDMIBASE_2_PDMUSB(pInterface) ( (PPDMUSBINS)((char *)(pInterface) - RT_OFFSETOF(PDMUSBINS, IBase)) )
840
841
842/** @def PDMUSB_ASSERT_EMT
843 * Assert that the current thread is the emulation thread.
844 */
845#ifdef VBOX_STRICT
846# define PDMUSB_ASSERT_EMT(pUsbIns) pUsbIns->pHlpR3->pfnAssertEMT(pUsbIns, __FILE__, __LINE__, __FUNCTION__)
847#else
848# define PDMUSB_ASSERT_EMT(pUsbIns) do { } while (0)
849#endif
850
851/** @def PDMUSB_ASSERT_OTHER
852 * Assert that the current thread is NOT the emulation thread.
853 */
854#ifdef VBOX_STRICT
855# define PDMUSB_ASSERT_OTHER(pUsbIns) pUsbIns->pHlpR3->pfnAssertOther(pUsbIns, __FILE__, __LINE__, __FUNCTION__)
856#else
857# define PDMUSB_ASSERT_OTHER(pUsbIns) do { } while (0)
858#endif
859
860/** @def PDMUSB_SET_ERROR
861 * Set the VM error. See PDMUsbHlpVMSetError() for printf like message
862 * formatting.
863 */
864#define PDMUSB_SET_ERROR(pUsbIns, rc, pszError) \
865 PDMUsbHlpVMSetError(pUsbIns, rc, RT_SRC_POS, "%s", pszError)
866
867/** @def PDMUSB_SET_RUNTIME_ERROR
868 * Set the VM runtime error. See PDMUsbHlpVMSetRuntimeError() for printf like
869 * message formatting.
870 */
871#define PDMUSB_SET_RUNTIME_ERROR(pUsbIns, fFlags, pszErrorId, pszError) \
872 PDMUsbHlpVMSetRuntimeError(pUsbIns, fFlags, pszErrorId, "%s", pszError)
873
874
875#ifdef IN_RING3
876
877/**
878 * @copydoc PDMUSBHLP::pfnDriverAttach
879 */
880DECLINLINE(int) PDMUsbHlpDriverAttach(PPDMUSBINS pUsbIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
881{
882 return pUsbIns->pHlpR3->pfnDriverAttach(pUsbIns, iLun, pBaseInterface, ppBaseInterface, pszDesc);
883}
884
885/**
886 * VBOX_STRICT wrapper for pHlpR3->pfnDBGFStopV.
887 *
888 * @returns VBox status code which must be passed up to the VMM.
889 * @param pUsbIns Device instance.
890 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
891 * @param pszFormat Message. (optional)
892 * @param ... Message parameters.
893 */
894DECLINLINE(int) PDMUsbDBGFStop(PPDMUSBINS pUsbIns, RT_SRC_POS_DECL, const char *pszFormat, ...)
895{
896#ifdef VBOX_STRICT
897 int rc;
898 va_list va;
899 va_start(va, pszFormat);
900 rc = pUsbIns->pHlpR3->pfnDBGFStopV(pUsbIns, RT_SRC_POS_ARGS, pszFormat, va);
901 va_end(va);
902 return rc;
903#else
904 NOREF(pUsbIns);
905 NOREF(pszFile);
906 NOREF(iLine);
907 NOREF(pszFunction);
908 NOREF(pszFormat);
909 return VINF_SUCCESS;
910#endif
911}
912
913/**
914 * @copydoc PDMUSBHLP::pfnVMState
915 */
916DECLINLINE(VMSTATE) PDMUsbHlpVMState(PPDMUSBINS pUsbIns)
917{
918 return pUsbIns->pHlpR3->pfnVMState(pUsbIns);
919}
920
921/**
922 * @copydoc PDMUSBHLP::pfnThreadCreate
923 */
924DECLINLINE(int) PDMUsbHlpThreadCreate(PPDMUSBINS pUsbIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADUSB pfnThread,
925 PFNPDMTHREADWAKEUPUSB pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
926{
927 return pUsbIns->pHlpR3->pfnThreadCreate(pUsbIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
928}
929
930
931/**
932 * @copydoc PDMUSBHLP::pfnSetAsyncNotification
933 */
934DECLINLINE(int) PDMUsbHlpSetAsyncNotification(PPDMUSBINS pUsbIns, PFNPDMUSBASYNCNOTIFY pfnAsyncNotify)
935{
936 return pUsbIns->pHlpR3->pfnSetAsyncNotification(pUsbIns, pfnAsyncNotify);
937}
938
939/**
940 * @copydoc PDMUSBHLP::pfnAsyncNotificationCompleted
941 */
942DECLINLINE(void) PDMUsbHlpAsyncNotificationCompleted(PPDMUSBINS pUsbIns)
943{
944 pUsbIns->pHlpR3->pfnAsyncNotificationCompleted(pUsbIns);
945}
946
947/**
948 * Set the VM error message
949 *
950 * @returns rc.
951 * @param pUsbIns The USB device instance.
952 * @param rc VBox status code.
953 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
954 * @param pszFormat Error message format string.
955 * @param ... Error message arguments.
956 */
957DECLINLINE(int) PDMUsbHlpVMSetError(PPDMUSBINS pUsbIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
958{
959 va_list va;
960 va_start(va, pszFormat);
961 rc = pUsbIns->pHlpR3->pfnVMSetErrorV(pUsbIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
962 va_end(va);
963 return rc;
964}
965
966/**
967 * @copydoc PDMUSBHLP::pfnMMHeapAlloc
968 */
969DECLINLINE(void *) PDMUsbHlpMMHeapAlloc(PPDMUSBINS pUsbIns, size_t cb)
970{
971 return pUsbIns->pHlpR3->pfnMMHeapAlloc(pUsbIns, cb);
972}
973
974/**
975 * @copydoc PDMUSBHLP::pfnMMHeapAllocZ
976 */
977DECLINLINE(void *) PDMUsbHlpMMHeapAllocZ(PPDMUSBINS pUsbIns, size_t cb)
978{
979 return pUsbIns->pHlpR3->pfnMMHeapAllocZ(pUsbIns, cb);
980}
981
982/**
983 * Frees memory allocated by PDMUsbHlpMMHeapAlloc or PDMUsbHlpMMHeapAllocZ.
984 *
985 * @param pUsbIns The USB device instance.
986 * @param pv The memory to free. NULL is fine.
987 */
988DECLINLINE(void) PDMUsbHlpMMHeapFree(PPDMUSBINS pUsbIns, void *pv)
989{
990 NOREF(pUsbIns);
991 MMR3HeapFree(pv);
992}
993
994/**
995 * @copydoc PDMUSBHLP::pfnTMTimerCreate
996 */
997DECLINLINE(int) PDMUsbHlpTMTimerCreate(PPDMUSBINS pUsbIns, TMCLOCK enmClock, PFNTMTIMERUSB pfnCallback, void *pvUser,
998 uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
999{
1000 return pUsbIns->pHlpR3->pfnTMTimerCreate(pUsbIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
1001}
1002
1003/**
1004 * @copydoc PDMUSBHLP::pfnSSMRegister
1005 */
1006DECLINLINE(int) PDMUsbHlpSSMRegister(PPDMUSBINS pUsbIns, uint32_t uVersion, size_t cbGuess,
1007 PFNSSMUSBLIVEPREP pfnLivePrep, PFNSSMUSBLIVEEXEC pfnLiveExec, PFNSSMUSBLIVEVOTE pfnLiveVote,
1008 PFNSSMUSBSAVEPREP pfnSavePrep, PFNSSMUSBSAVEEXEC pfnSaveExec, PFNSSMUSBSAVEDONE pfnSaveDone,
1009 PFNSSMUSBLOADPREP pfnLoadPrep, PFNSSMUSBLOADEXEC pfnLoadExec, PFNSSMUSBLOADDONE pfnLoadDone)
1010{
1011 return pUsbIns->pHlpR3->pfnSSMRegister(pUsbIns, uVersion, cbGuess,
1012 pfnLivePrep, pfnLiveExec, pfnLiveVote,
1013 pfnSavePrep, pfnSaveExec, pfnSaveDone,
1014 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
1015}
1016
1017#endif /* IN_RING3 */
1018
1019
1020
1021/** Pointer to callbacks provided to the VBoxUsbRegister() call. */
1022typedef const struct PDMUSBREGCB *PCPDMUSBREGCB;
1023
1024/**
1025 * Callbacks for VBoxUSBDeviceRegister().
1026 */
1027typedef struct PDMUSBREGCB
1028{
1029 /** Interface version.
1030 * This is set to PDM_USBREG_CB_VERSION. */
1031 uint32_t u32Version;
1032
1033 /**
1034 * Registers a device with the current VM instance.
1035 *
1036 * @returns VBox status code.
1037 * @param pCallbacks Pointer to the callback table.
1038 * @param pReg Pointer to the USB device registration record.
1039 * This data must be permanent and readonly.
1040 */
1041 DECLR3CALLBACKMEMBER(int, pfnRegister,(PCPDMUSBREGCB pCallbacks, PCPDMUSBREG pReg));
1042} PDMUSBREGCB;
1043
1044/** Current version of the PDMUSBREGCB structure. */
1045#define PDM_USBREG_CB_VERSION PDM_VERSION_MAKE(0xeefc, 1, 0)
1046
1047
1048/**
1049 * The VBoxUsbRegister callback function.
1050 *
1051 * PDM will invoke this function after loading a USB device module and letting
1052 * the module decide which devices to register and how to handle conflicts.
1053 *
1054 * @returns VBox status code.
1055 * @param pCallbacks Pointer to the callback table.
1056 * @param u32Version VBox version number.
1057 */
1058typedef DECLCALLBACK(int) FNPDMVBOXUSBREGISTER(PCPDMUSBREGCB pCallbacks, uint32_t u32Version);
1059
1060VMMR3DECL(int) PDMR3UsbCreateEmulatedDevice(PUVM pUVM, const char *pszDeviceName, PCFGMNODE pDeviceNode, PCRTUUID pUuid);
1061VMMR3DECL(int) PDMR3UsbCreateProxyDevice(PUVM pUVM, PCRTUUID pUuid, bool fRemote, const char *pszAddress, void *pvBackend,
1062 uint32_t iUsbVersion, uint32_t fMaskedIfs);
1063VMMR3DECL(int) PDMR3UsbDetachDevice(PUVM pUVM, PCRTUUID pUuid);
1064VMMR3DECL(bool) PDMR3UsbHasHub(PUVM pUVM);
1065VMMR3DECL(int) PDMR3UsbDriverAttach(PUVM pUVM, const char *pszDevice, unsigned iDevIns, unsigned iLun, uint32_t fFlags,
1066 PPPDMIBASE ppBase);
1067VMMR3DECL(int) PDMR3UsbDriverDetach(PUVM pUVM, const char *pszDevice, unsigned iDevIns, unsigned iLun,
1068 const char *pszDriver, unsigned iOccurance, uint32_t fFlags);
1069VMMR3DECL(int) PDMR3UsbQueryLun(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMIBASE *ppBase);
1070
1071/** @} */
1072
1073RT_C_DECLS_END
1074
1075#endif
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