VirtualBox

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

Last change on this file since 31888 was 31888, checked in by vboxsync, 14 years ago

Devices: export USB proxy device to OSE

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