Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / usb_alloc_request.9f
blobf8a68298f6ad679c05adc0f18d8253a2599167cf
1 '\" te
2 .\" Copyright (c) 2004, Sun Microsystems, Inc., All Rights Reserved
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH USB_ALLOC_REQUEST 9F "Jul 25, 2004"
7 .SH NAME
8 usb_alloc_request, usb_alloc_ctrl_req, usb_free_ctrl_req, usb_alloc_bulk_req,
9 usb_free_bulk_req, usb_alloc_intr_req, usb_free_intr_req, usb_alloc_isoc_req,
10 usb_free_isoc_req \- Allocate and free USB transfer requests
11 .SH SYNOPSIS
12 .LP
13 .nf
14 #include <sys/usb/usba.h>
16 \fBusb_ctrl_req_t *\fR\fBusb_alloc_ctrl_req\fR(\fBdev_info_t *\fR\fIdip\fR, \fBsize_t\fR \fIlen\fR,
17      \fBusb_flags_t\fR \fIflags\fR);
18 .fi
20 .LP
21 .nf
22 \fBvoid\fR \fBusb_free_ctrl_req\fR(\fBusb_ctrl_req_t *\fR\fIrequest\fR);
23 .fi
25 .LP
26 .nf
27 \fBusb_bulk_req_t *\fR\fBusb_alloc_bulk_req\fR(\fBdev_info_t\fR \fIdip\fR, \fBsize_t\fR \fIlen\fR,
28      \fBusb_flags_t\fR \fIflags\fR);
29 .fi
31 .LP
32 .nf
33 \fBvoid\fR \fBusb_free_bulk_req\fR(\fBusb_bulk_req_t *\fR\fIrequest\fR);
34 .fi
36 .LP
37 .nf
38 \fBusb_intr_req_t *\fR\fBusb_alloc_intr_req\fR(\fBdev_info_t *\fR\fIdip\fR, \fBsize_t\fR \fIlen\fR,
39      \fBusb_flags_t\fR \fIflags\fR);
40 .fi
42 .LP
43 .nf
44 \fBvoid\fR \fBusb_free_intr_req\fR(\fBusb_intr_req_t *\fR\fIrequest\fR);
45 .fi
47 .LP
48 .nf
49 \fBusb_isoc_req_t *\fR\fBusb_alloc_isoc_req\fR(\fBdev_info_t *\fR\fIdip\fR,
50      \fBuint_t\fR \fIisoc_pkts_count\fR, \fBsize_t\fR \fIlen\fR, \fBusb_flags_t\fR \fIflags\fR);
51 .fi
53 .LP
54 .nf
55 \fBvoid\fR \fBusb_free_isoc_req\fR(\fBusb_isoc_req_t *\fR\fIrequest\fR);
56 .fi
58 .SH INTERFACE LEVEL
59 .sp
60 .LP
61 Solaris DDI specific (Solaris DDI)
62 .SH PARAMETERS
63 .sp
64 .LP
65 For \fBusb_alloc_ctrl_req()\fR, \fBusb_alloc_bulk_req()\fR and
66 \fBusb_alloc_intr_req()\fR:
67 .sp
68 .ne 2
69 .na
70 \fB\fIdip\fR\fR
71 .ad
72 .RS 9n
73 Pointer to the device's dev_info structure.
74 .RE
76 .sp
77 .ne 2
78 .na
79 \fB\fIlen\fR\fR
80 .ad
81 .RS 9n
82 Length of \fIdata\fR for this request.
83 .RE
85 .sp
86 .ne 2
87 .na
88 \fB\fIflags\fR\fR
89 .ad
90 .RS 9n
91 Only USB_FLAGS_SLEEP is recognized. Wait for resources if not immediately
92 available.
93 .RE
95 .sp
96 .LP
97 For \fBusb_alloc_isoc_req()\fR:
98 .sp
99 .ne 2
101 \fB\fIdip\fR\fR
103 .RS 19n
104 Pointer to the device's dev_info structure.
108 .ne 2
110 \fB\fIisoc_pkts_count\fR\fR
112 .RS 19n
113 Number of isochronous packet descriptors to associate with this request. Must
114 be greater than zero.
118 .ne 2
120 \fB\fIlen\fR\fR
122 .RS 19n
123 Length of \fIdata\fR for this isochronous request.
127 .ne 2
129 \fB\fIflags\fR\fR
131 .RS 19n
132 Only USB_FLAGS_SLEEP is recognized. Wait for resources if not immediately
133 available.
138 For \fBusb_free_ctrl_req()\fR, \fBusb_free_bulk_req()\fR,
139 \fBusb_free_intr_req()\fR and \fBusb_free_isoc_req()\fR:
141 .ne 2
143 \fB\fIrequest\fR\fR
145 .RS 11n
146 Pointer to the request structure to be freed. Can be \fBNULL\fR.
149 .SH DESCRIPTION
152 The \fBusb_alloc_ctrl_req()\fR, \fBusb_alloc_bulk_req()\fR,
153 \fBusb_alloc_intr_req()\fR, and \fBusb_alloc_isoc_req()\fR functions allocate
154 control, bulk, interrupt, or     isochronous requests. Optionally, these
155 functions can also allocate an mblk of the specified length to pass data
156 associated  with the request. (For guidelines on mblk data allocation, see the
157 manpage for the relevant transfer function).
160 The \fBusb_alloc_isoc_req()\fR function also allocates a number of isochronous
161 packet descriptors (usb_isoc_pkt_descr_t) specified by isoc_pkts_count to the
162 end of the request proper (usb_isoc_req_t).  See \fBusb_isoc_request\fR(9S) for
163 more information on isochronous packet descriptors.
166 These functions always succeed when the USB_FLAGS_SLEEP flag is set, provided
167 that they are given valid args and are not called from interrupt context.
170 The \fBusb_free_ctrl_req()\fR, \fBusb_free_bulk_req()\fR,
171 \fBusb_free_intr_req()\fR, and \fBusb_free_isoc_req()\fR functions free their
172 corresponding request. If the request's data block pointer is non-zero, the
173 data block is also freed. For isoc requests, the array of packet descriptors is
174 freed.
175 .SH RETURN VALUES
178 For \fBusb_alloc_ctrl_req()\fR, \fBusb_alloc_bulk_req()\fR,
179 \fBusb_alloc_intr_req()\fR and \fBusb_alloc_isoc_req()\fR:
182 On success: returns a pointer to the appropriate usb_xxx_request_t.
185 On failure: returns \fBNULL\fR. Fails because the dip argument is invalid,
186 USB_FLAGS_SLEEP is not set and memory is not available or because
187 USB_FLAGS_SLEEP is set but the call was made in interrupt context.
190 For \fBusb_free_ctrl_req()\fR, \fBusb_free_bulk_req()\fR,
191 \fBusb_free_intr_req()\fR and \fBusb_free_isoc_req()\fR: None.
192 .SH CONTEXT
195 The allocation routines can always be called from kernel and user context. They
196 may be called from interrupt context only if USB_FLAGS_SLEEP is not specified.
199 The free routines may be called from kernel, user, and interrupt context.
200 .SH EXAMPLES
202 .in +2
204     /* This allocates and initializes an asynchronous control
205      * request which will pass no data.  Asynchronous requests
206      * are used when they cannot block the calling thread.
207      */
209     usb_ctrl_req_t *ctrl_req;
211     if ((ctrl_req = usb_alloc_ctrl_req(dip, 0, 0)) == NULL) {
212             return (FAILURE);
213     }
215     /* Now initialize. */
216     ctrl_req->ctrl_bmRequestType = USB_DEV_REQ_DEV_TO_HOST |
217         USB_DEV_REQ_STANDARD | USB_DEV_REQ_RCPT_DEV;
219     ctrl_req->ctrl_bRequest      = (uint8_t)USB_REQ_GET_STATUS;
220     ...
221     ...
222     ctrl_req->ctrl_callback     = normal_callback;
223     ctrl_req->ctrl_exc_callback = exception_callback;
224     ...
225     ...
228 .in -2
230 .SH ATTRIBUTES
233 See \fBattributes\fR(5) for descriptions of the following attributes:
238 box;
239 c | c
240 l | l .
241 ATTRIBUTE TYPE  ATTRIBUTE VALUE
243 Architecture    PCI-based systems
245 Interface stability     Committed
248 .SH SEE ALSO
251 \fBattributes\fR(5), \fBusb_get_current_frame_number\fR(9F),
252 \fBusb_get_max_pkts_per_isoc_request\fR(9F),
253 \fBusb_pipe_get_max_bulk_transfer_size\fR(9F), \fBusb_pipe_bulk_xfer\fR(9F),
254 \fBusb_pipe_ctrl_xfer\fR(9F), \fBusb_pipe_intr_xfer\fR(9F),
255 \fBusb_pipe_isoc_xfer\fR(9F), \fBusb_bulk_request\fR(9S),
256 \fBusb_ctrl_request\fR(9S), \fBusb_intr_request\fR(9S),
257 \fBusb_isoc_request\fR(9S)