win-pvdrivers

view common/include/public/io/usbif.h @ 616:fd445db0c603

Added usbif.h and updated xenbus.h to include new Reconfiguring states
author James Harper <james.harper@bendigoit.com.au>
date Sun Jul 26 23:06:09 2009 +1000 (2009-07-26)
parents
children b59c7dfdee9b
line source
2 /*
3 * usbif.h
4 *
5 * USB I/O interface for Xen guest OSes.
6 *
7 * Copyright (C) 2009, FUJITSU LABORATORIES LTD.
8 * Author: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com>
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to
12 * deal in the Software without restriction, including without limitation the
13 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14 * sell copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 */
29 #ifndef __XEN_PUBLIC_IO_USBIF_H__
30 #define __XEN_PUBLIC_IO_USBIF_H__
32 #include "ring.h"
33 #include "../grant_table.h"
35 /*
36 * USB pipe in usbif_request
37 *
38 * bits 0-5 are specific bits for virtual USB driver.
39 * bits 7-31 are standard urb pipe.
40 *
41 * - port number(NEW): bits 0-4
42 * (USB_MAXCHILDREN is 31)
43 *
44 * - operation flag(NEW): bit 5
45 * (0 = submit urb,
46 * 1 = unlink urb)
47 *
48 * - direction: bit 7
49 * (0 = Host-to-Device [Out]
50 * 1 = Device-to-Host [In])
51 *
52 * - device address: bits 8-14
53 *
54 * - endpoint: bits 15-18
55 *
56 * - pipe type: bits 30-31
57 * (00 = isochronous, 01 = interrupt,
58 * 10 = control, 11 = bulk)
59 */
60 #define usbif_pipeportnum(pipe) ((pipe) & 0x1f)
61 #define usbif_setportnum_pipe(pipe,portnum) \
62 ((pipe)|(portnum))
63 #define usbif_pipeunlink(pipe) ((pipe) & 0x20)
64 #define usbif_setunlink_pipe(pipe) ((pipe)|(0x20))
66 #define USBIF_BACK_MAX_PENDING_REQS (128)
67 #define USBIF_MAX_SEGMENTS_PER_REQUEST (10)
69 struct usbif_request_segment {
70 grant_ref_t gref;
71 uint16_t offset;
72 uint16_t length;
73 };
75 struct usbif_request {
76 uint16_t id; /* request id */
77 uint16_t nr_buffer_segs; /* number of urb->transfer_buffer segments */
79 /* basic urb parameter */
80 uint32_t pipe;
81 uint16_t transfer_flags;
82 uint16_t buffer_length;
83 union {
84 uint8_t ctrl[8]; /* setup_packet (Ctrl) */
86 struct {
87 uint16_t interval; /* maximum (1024*8) in usb core */
88 uint16_t start_frame; /* start frame */
89 uint16_t number_of_packets; /* number of ISO packet */
90 uint16_t nr_frame_desc_segs; /* number of iso_frame_desc segments */
91 } isoc;
93 struct {
94 uint16_t interval; /* maximum (1024*8) in usb core */
95 uint16_t pad[3];
96 } intr;
98 struct {
99 uint16_t unlink_id; /* unlink request id */
100 uint16_t pad[3];
101 } unlink;
103 } u;
105 /* urb data segments */
106 struct usbif_request_segment seg[USBIF_MAX_SEGMENTS_PER_REQUEST];
107 };
108 typedef struct usbif_request usbif_request_t;
110 struct usbif_response {
111 uint16_t id; /* request id */
112 uint16_t start_frame; /* start frame (ISO) */
113 int32_t status; /* status (non-ISO) */
114 int32_t actual_length; /* actual transfer length */
115 int32_t error_count; /* number of ISO errors */
116 };
117 typedef struct usbif_response usbif_response_t;
119 DEFINE_RING_TYPES(usbif, struct usbif_request, struct usbif_response);
120 #define USB_RING_SIZE __RING_SIZE((struct usbif_sring *)0, PAGE_SIZE)
122 #endif /* __XEN_PUBLIC_IO_USBIF_H__ */