VirtualBox

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

Last change on this file since 99760 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

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