VirtualBox

source: vbox/trunk/include/VBox/usblib-solaris.h@ 78307

Last change on this file since 78307 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.5 KB
Line 
1/** @file
2 * USBLib - Library for wrapping up the VBoxUSB functionality, Solaris flavor.
3 * (DEV,HDrv,Main)
4 */
5
6/*
7 * Copyright (C) 2008-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef VBOX_INCLUDED_usblib_solaris_h
28#define VBOX_INCLUDED_usblib_solaris_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <VBox/cdefs.h>
34#include <VBox/usbfilter.h>
35#include <VBox/vusb.h>
36#include <sys/types.h>
37#include <sys/ioccom.h>
38#include <sys/param.h>
39
40RT_C_DECLS_BEGIN
41
42/** @defgroup grp_usblib_solaris Solaris USB Specifics
43 * @ingroup grp_usblib
44 * @{
45 */
46
47/** @name VBoxUSB specific IOCtls.
48 * VBoxUSB uses them for resetting USB devices requests from userland.
49 * USBProxyService/Device makes use of them to communicate with VBoxUSB.
50 * @{ */
51
52/** Ring-3 request wrapper for big requests.
53 *
54 * This is necessary because the ioctl number scheme on many Unixy OSes (esp. Solaris)
55 * only allows a relatively small size to be encoded into the request. So, for big
56 * request this generic form is used instead. */
57typedef struct VBOXUSBREQ
58{
59 /** Magic value (VBOXUSB(MON)_MAGIC). */
60 uint32_t u32Magic;
61 /** The size of the data buffer (In & Out). */
62 uint32_t cbData;
63 /** Result code of the request filled by driver. */
64 int32_t rc;
65 /** The user address of the data buffer. */
66 RTR3PTR pvDataR3;
67} VBOXUSBREQ;
68/** Pointer to a request wrapper for solaris. */
69typedef VBOXUSBREQ *PVBOXUSBREQ;
70/** Pointer to a const request wrapper for solaris. */
71typedef const VBOXUSBREQ *PCVBOXUSBREQ;
72
73#pragma pack(1)
74typedef struct
75{
76 /* Pointer to the Filter. */
77 USBFILTER Filter;
78 /* Where to store the added Filter (Id). */
79 uintptr_t uId;
80} VBOXUSBREQ_ADD_FILTER;
81
82typedef struct
83{
84 /* Pointer to Filter (Id) to be removed. */
85 uintptr_t uId;
86} VBOXUSBREQ_REMOVE_FILTER;
87
88typedef struct
89{
90 /** Whether to re-attach the driver. */
91 bool fReattach;
92 /* Physical path of the USB device. */
93 char szDevicePath[1];
94} VBOXUSBREQ_RESET_DEVICE;
95
96typedef struct
97{
98 /* Where to store the instance. */
99 int *pInstance;
100 /* Physical path of the USB device. */
101 char szDevicePath[1];
102} VBOXUSBREQ_DEVICE_INSTANCE;
103
104typedef struct
105{
106 /** Where to store the instance. */
107 int Instance;
108 /* Where to store the client path. */
109 char szClientPath[MAXPATHLEN];
110 /** Device identifier (VendorId:ProductId:Release:StaticPath) */
111 char szDeviceIdent[MAXPATHLEN+48];
112 /** Callback from monitor specifying client consumer (VM) credentials */
113 DECLR0CALLBACKMEMBER(int, pfnSetConsumerCredentials,(RTPROCESS Process, int Instance, void *pvReserved));
114} VBOXUSBREQ_CLIENT_INFO, *PVBOXUSBREQ_CLIENT_INFO;
115typedef VBOXUSBREQ_CLIENT_INFO VBOXUSB_CLIENT_INFO;
116typedef PVBOXUSBREQ_CLIENT_INFO PVBOXUSB_CLIENT_INFO;
117
118/** Isoc packet descriptor (Must mirror exactly Solaris USBA's usb_isoc_pkt_descr_t) */
119typedef struct
120{
121 ushort_t cbPkt; /* Size of the packet */
122 ushort_t cbActPkt; /* Size of the packet actually transferred */
123 VUSBSTATUS enmStatus; /* Per frame transfer status */
124} VUSBISOC_PKT_DESC;
125
126/** VBoxUSB IOCtls */
127typedef struct
128{
129 void *pvUrbR3; /* Pointer to userland URB (untouched by kernel driver) */
130 uint8_t bEndpoint; /* Endpoint address */
131 VUSBXFERTYPE enmType; /* Xfer type */
132 VUSBDIRECTION enmDir; /* Xfer direction */
133 VUSBSTATUS enmStatus; /* URB status */
134 bool fShortOk; /* Whether receiving less data than requested is acceptable. */
135 size_t cbData; /* Size of the data */
136 void *pvData; /* Pointer to the data */
137 uint32_t cIsocPkts; /* Number of Isoc packets */
138 VUSBISOC_PKT_DESC aIsocPkts[8]; /* Array of Isoc packet descriptors */
139} VBOXUSBREQ_URB, *PVBOXUSBREQ_URB;
140
141typedef struct
142{
143 uint8_t bEndpoint; /* Endpoint address */
144} VBOXUSBREQ_CLEAR_EP, *PVBOXUSBREQ_CLEAR_EP;
145
146
147typedef struct
148{
149 uint8_t bConfigValue; /* Configuration value */
150} VBOXUSBREQ_SET_CONFIG, *PVBOXUSBREQ_SET_CONFIG;
151typedef VBOXUSBREQ_SET_CONFIG VBOXUSBREQ_GET_CONFIG;
152typedef PVBOXUSBREQ_SET_CONFIG PVBOXUSBREQ_GET_CONFIG;
153
154typedef struct
155{
156 uint8_t bInterface; /* Interface number */
157 uint8_t bAlternate; /* Alternate setting */
158} VBOXUSBREQ_SET_INTERFACE, *PVBOXUSBREQ_SET_INTERFACE;
159
160typedef enum
161{
162 /** Close device not a reset. */
163 VBOXUSB_RESET_LEVEL_CLOSE = 0,
164 /** Hard reset resulting in device replug behaviour. */
165 VBOXUSB_RESET_LEVEL_REATTACH = 2,
166 /** Device-level reset. */
167 VBOXUSB_RESET_LEVEL_SOFT = 4
168} VBOXUSB_RESET_LEVEL;
169
170typedef struct
171{
172 VBOXUSB_RESET_LEVEL ResetLevel; /* Reset level after closing */
173} VBOXUSBREQ_CLOSE_DEVICE, *PVBOXUSBREQ_CLOSE_DEVICE;
174
175typedef struct
176{
177 uint8_t bEndpoint; /* Endpoint address */
178} VBOXUSBREQ_ABORT_PIPE, *PVBOXUSBREQ_ABORT_PIPE;
179
180typedef struct
181{
182 uint32_t u32Major; /* Driver major number */
183 uint32_t u32Minor; /* Driver minor number */
184} VBOXUSBREQ_GET_VERSION, *PVBOXUSBREQ_GET_VERSION;
185
186#pragma pack()
187
188/** The VBOXUSBREQ::u32Magic value for VBoxUSBMon. */
189#define VBOXUSBMON_MAGIC 0xba5eba11
190/** The VBOXUSBREQ::u32Magic value for VBoxUSB.*/
191#define VBOXUSB_MAGIC 0x601fba11
192/** The USBLib entry point for userland. */
193#define VBOXUSB_DEVICE_NAME "/dev/vboxusbmon"
194
195/** The USBMonitor Major version. */
196#define VBOXUSBMON_VERSION_MAJOR 2
197/** The USBMonitor Minor version. */
198#define VBOXUSBMON_VERSION_MINOR 1
199
200/** The USB Major version. */
201#define VBOXUSB_VERSION_MAJOR 1
202/** The USB Minor version. */
203#define VBOXUSB_VERSION_MINOR 1
204
205#ifdef RT_ARCH_AMD64
206# define VBOXUSB_IOCTL_FLAG 128
207#elif defined(RT_ARCH_X86)
208# define VBOXUSB_IOCTL_FLAG 0
209#else
210# error "dunno which arch this is!"
211#endif
212
213/** USB driver name*/
214#define VBOXUSB_DRIVER_NAME "vboxusb"
215
216/* No automatic buffering, size limited to 255 bytes => use VBOXUSBREQ for everything. */
217#define VBOXUSB_IOCTL_CODE(Function, Size) _IOWRN('V', (Function) | VBOXUSB_IOCTL_FLAG, sizeof(VBOXUSBREQ))
218#define VBOXUSB_IOCTL_CODE_FAST(Function) _IO( 'V', (Function) | VBOXUSB_IOCTL_FLAG)
219#define VBOXUSB_IOCTL_STRIP_SIZE(Code) (Code)
220
221#define VBOXUSBMON_IOCTL_ADD_FILTER VBOXUSB_IOCTL_CODE(1, (sizeof(VBoxUSBAddFilterReq)))
222#define VBOXUSBMON_IOCTL_REMOVE_FILTER VBOXUSB_IOCTL_CODE(2, (sizeof(VBoxUSBRemoveFilterReq)))
223#define VBOXUSBMON_IOCTL_RESET_DEVICE VBOXUSB_IOCTL_CODE(3, (sizeof(VBOXUSBREQ_RESET_DEVICE)))
224#define VBOXUSBMON_IOCTL_DEVICE_INSTANCE VBOXUSB_IOCTL_CODE(4, (sizeof(VBOXUSBREQ_DEVICE_INSTANCE)))
225#define VBOXUSBMON_IOCTL_CLIENT_INFO VBOXUSB_IOCTL_CODE(5, (sizeof(VBOXUSBREQ_CLIENT_PATH)))
226#define VBOXUSBMON_IOCTL_GET_VERSION VBOXUSB_IOCTL_CODE(6, (sizeof(VBOXUSBREQ_GET_VERSION)))
227
228/* VBoxUSB ioctls */
229#define VBOXUSB_IOCTL_SEND_URB VBOXUSB_IOCTL_CODE(20, (sizeof(VBOXUSBREQ_URB))) /* 1072146796 */
230#define VBOXUSB_IOCTL_REAP_URB VBOXUSB_IOCTL_CODE(21, (sizeof(VBOXUSBREQ_URB))) /* 1072146795 */
231#define VBOXUSB_IOCTL_CLEAR_EP VBOXUSB_IOCTL_CODE(22, (sizeof(VBOXUSBREQ_CLEAR_EP))) /* 1072146794 */
232#define VBOXUSB_IOCTL_SET_CONFIG VBOXUSB_IOCTL_CODE(23, (sizeof(VBOXUSBREQ_SET_CONFIG))) /* 1072146793 */
233#define VBOXUSB_IOCTL_SET_INTERFACE VBOXUSB_IOCTL_CODE(24, (sizeof(VBOXUSBREQ_SET_INTERFACE))) /* 1072146792 */
234#define VBOXUSB_IOCTL_CLOSE_DEVICE VBOXUSB_IOCTL_CODE(25, (sizeof(VBOXUSBREQ_CLOSE_DEVICE))) /* 1072146791 0xc0185699 */
235#define VBOXUSB_IOCTL_ABORT_PIPE VBOXUSB_IOCTL_CODE(26, (sizeof(VBOXUSBREQ_ABORT_PIPE))) /* 1072146790 */
236#define VBOXUSB_IOCTL_GET_CONFIG VBOXUSB_IOCTL_CODE(27, (sizeof(VBOXUSBREQ_GET_CONFIG))) /* 1072146789 */
237#define VBOXUSB_IOCTL_GET_VERSION VBOXUSB_IOCTL_CODE(28, (sizeof(VBOXUSBREQ_GET_VERSION))) /* 1072146788 */
238
239/** @} */
240
241/* USBLibHelper data for resetting the device. */
242typedef struct VBOXUSBHELPERDATA_RESET
243{
244 /** Path of the USB device. */
245 const char *pszDevicePath;
246 /** Re-enumerate or not. */
247 bool fHardReset;
248} VBOXUSBHELPERDATA_RESET;
249typedef VBOXUSBHELPERDATA_RESET *PVBOXUSBHELPERDATA_RESET;
250typedef const VBOXUSBHELPERDATA_RESET *PCVBOXUSBHELPERDATA_RESET;
251
252/* USBLibHelper data for device hijacking. */
253typedef struct VBOXUSBHELPERDATA_ALIAS
254{
255 /** Vendor ID. */
256 uint16_t idVendor;
257 /** Product ID. */
258 uint16_t idProduct;
259 /** Revision, integer part. */
260 uint16_t bcdDevice;
261 /** Path of the USB device. */
262 const char *pszDevicePath;
263} VBOXUSBHELPERDATA_ALIAS;
264typedef VBOXUSBHELPERDATA_ALIAS *PVBOXUSBHELPERDATA_ALIAS;
265typedef const VBOXUSBHELPERDATA_ALIAS *PCVBOXUSBHELPERDATA_ALIAS;
266
267USBLIB_DECL(int) USBLibResetDevice(char *pszDevicePath, bool fReattach);
268USBLIB_DECL(int) USBLibDeviceInstance(char *pszDevicePath, int *pInstance);
269USBLIB_DECL(int) USBLibGetClientInfo(char *pszDeviceIdent, char **ppszClientPath, int *pInstance);
270USBLIB_DECL(int) USBLibAddDeviceAlias(PUSBDEVICE pDevice);
271USBLIB_DECL(int) USBLibRemoveDeviceAlias(PUSBDEVICE pDevice);
272/*USBLIB_DECL(int) USBLibConfigureDevice(PUSBDEVICE pDevice);*/
273
274/** @} */
275RT_C_DECLS_END
276
277#endif /* !VBOX_INCLUDED_usblib_solaris_h */
278
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