summaryrefslogtreecommitdiffstats
path: root/src/VBox/HostDrivers/VBoxUSB/solaris/include/usbai_private.h
blob: 2e61d80465e93170448938510343d05e6068a36a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2009-2010 Oracle Corporation. All rights reserved.
 * Use is subject to license terms.
 */

#ifndef    _SYS_USB_USBA_USBAI_PRIVATE_H
#define    _SYS_USB_USBA_USBAI_PRIVATE_H

/*
 * Unstable interfaces not part of USBAI but used by Solaris client drivers.
 * These interfaces may not be present in future releases and are highly
 * unstable.
 *
 * Status key:
 *    C = Remove from Sun client drivers before removing from this file
 *    D = May be needed by legacy (DDK) drivers.
 */

#ifdef    __cplusplus
extern "C" {
#endif

/*
 * convenience function for getting default config index
 * as saved in usba_device structure
 *
 * Status: C
 */
uint_t usb_get_current_cfgidx(dev_info_t *);

/*
 * Usb logging, debug and console message handling.
 */
typedef struct usb_log_handle *usb_log_handle_t;

#define    USB_LOG_L0    0    /* warnings, console & syslog buffer */
#define    USB_LOG_L1    1    /* errors, syslog buffer */
#define    USB_LOG_L2    2    /* recoverable errors, debug only */
#define    USB_LOG_L3    3    /* interesting data, debug only */
#define    USB_LOG_L4    4    /* tracing, debug only */

#define    USB_CHK_BASIC  0             /* Empty mask.    Basics always done. */
#define    USB_CHK_SERIAL 0x00000001    /* Compare device serial numbers. */
#define    USB_CHK_CFG    0x00000002    /* Compare raw config clouds. */
#define    USB_CHK_VIDPID 0x00000004    /* Compare product and vendor ID. */
#define    USB_CHK_ALL    0xFFFFFFFF    /* Perform maximum checking. */

int usb_check_same_device(dev_info_t        *dip,
                          usb_log_handle_t   log_handle,
                          int                log_level,
                          int                log_mask,
                          uint_t             check_mask,
                          char              *device_string);

/*
 * **************************************************************************
 * Serialization functions remaining Contracted Consolidation Private
 * **************************************************************************
 */

/* This whole section: status: C and D. */

/*
 * opaque serialization handle.
 *    Used by all usb_serialization routines.
 *
 *    This handle is opaque to the client driver.
 */
typedef struct usb_serialization *usb_serialization_t;

/*
 * usb_init_serialization
 *    setup for serialization
 *
 * ARGUMENTS:
 *    s_dip        - devinfo pointer
 *    flag         - USB_INIT_SER_CHECK_SAME_THREAD
 *                   when set, usb_release_access() will verify that the same
 *                   thread releases access. If not, a console warning will
 *                   be issued but access will be released anyways.
 *
 * RETURNS:
 *    usb_serialization handle
 *
 */
usb_serialization_t usb_init_serialization(dev_info_t    *s_dip,
                                           uint_t         flag);

#define    USB_INIT_SER_CHECK_SAME_THREAD    1

/* fini for serialization */
void usb_fini_serialization(usb_serialization_t usb_serp);

/*
 * Various ways of calling usb_serialize_access. These correspond to
 * their cv_*wait* function counterparts for usb_serialize_access.
 */
#define USB_WAIT            0
#define USB_WAIT_SIG        1
#define USB_TIMEDWAIT       2
#define USB_TIMEDWAIT_SIG   3

/*
 * usb_serialize_access:
 *    acquire serialized access
 *
 * ARGUMENTS:
 *    usb_serp      - usb_serialization handle
 *    how_to_wait   - Which cv_*wait* function to wait for condition.
 *       USB_WAIT:           use cv_wait
 *       USB_WAIT_SIG:       use cv_wait_sig
 *       USB_TIMEDWAIT:      use cv_timedwait
 *       USB_TIMEDWAIT_SIG:  use cv_timedwait_sig
 *    delta_timeout - Time in ms from current time to timeout.  Checked
 *                    only if USB_TIMEDWAIT or USB_TIMEDWAIT_SIG
 *                    specified in how_to_wait.
 * RETURNS:
 *    Same as values returned by cv_*wait* functions,
 *    except for when how_to_wait == USB_WAIT, where 0 is always returned.
 *    For calls where a timeout or signal could be expected, use this value
 *    to tell whether a kill(2) signal or timeout occurred.
 */
int usb_serialize_access(usb_serialization_t    usb_serp,
                         uint_t                 how_to_wait,
                         uint_t                 delta_timeout);

/*
 * usb_release_access:
 *    release serialized access
 *
 * ARGUMENTS:
 *    usb_serp    - usb_serialization handle
 */
void usb_release_access(usb_serialization_t usb_serp);

#ifdef __cplusplus
}
#endif

#endif    /* _SYS_USB_USBA_USBAI_PRIVATE_H */