win-pvdrivers

view common/include/public/io/usbif.h @ 670:b59c7dfdee9b

Updates to support latest pre-release version of pvusb. No longer compatible with current version.
author James Harper <james.harper@bendigoit.com.au>
date Wed Sep 23 17:06:30 2009 +1000 (2009-09-23)
parents fd445db0c603
children
line source
1 /*
2 * usbif.h
3 *
4 * USB I/O interface for Xen guest OSes.
5 *
6 * Copyright (C) 2009, FUJITSU LABORATORIES LTD.
7 * Author: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to
11 * deal in the Software without restriction, including without limitation the
12 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
13 * sell copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
26 */
28 #ifndef __XEN_PUBLIC_IO_USBIF_H__
29 #define __XEN_PUBLIC_IO_USBIF_H__
31 #include "ring.h"
32 #include "../grant_table.h"
34 /*
35 * USB pipe in usbif_request
36 *
37 * bits 0-5 are specific bits for virtual USB driver.
38 * bits 7-31 are standard urb pipe.
39 *
40 * - port number(NEW): bits 0-4
41 * (USB_MAXCHILDREN is 31)
42 *
43 * - operation flag(NEW): bit 5
44 * (0 = submit urb,
45 * 1 = unlink urb)
46 *
47 * - direction: bit 7
48 * (0 = Host-to-Device [Out]
49 * 1 = Device-to-Host [In])
50 *
51 * - device address: bits 8-14
52 *
53 * - endpoint: bits 15-18
54 *
55 * - pipe type: bits 30-31
56 * (00 = isochronous, 01 = interrupt,
57 * 10 = control, 11 = bulk)
58 */
59 #define usbif_pipeportnum(pipe) ((pipe) & 0x1f)
60 #define usbif_setportnum_pipe(pipe,portnum) \
61 ((pipe)|(portnum))
62 #define usbif_pipeunlink(pipe) ((pipe) & 0x20)
63 #define usbif_setunlink_pipe(pipe) ((pipe)|(0x20))
65 #define USBIF_BACK_MAX_PENDING_REQS (128)
66 #define USBIF_MAX_SEGMENTS_PER_REQUEST (16)
68 /*
69 * RING for transferring urbs.
70 */
71 struct usbif_request_segment {
72 grant_ref_t gref;
73 uint16_t offset;
74 uint16_t length;
75 };
77 struct usbif_urb_request {
78 uint16_t id; /* request id */
79 uint16_t nr_buffer_segs; /* number of urb->transfer_buffer segments */
81 /* basic urb parameter */
82 uint32_t pipe;
83 uint16_t transfer_flags;
84 uint16_t buffer_length;
85 union {
86 uint8_t ctrl[8]; /* setup_packet (Ctrl) */
88 struct {
89 uint16_t interval; /* maximum (1024*8) in usb core */
90 uint16_t start_frame; /* start frame */
91 uint16_t number_of_packets; /* number of ISO packet */
92 uint16_t nr_frame_desc_segs; /* number of iso_frame_desc segments */
93 } isoc;
95 struct {
96 uint16_t interval; /* maximum (1024*8) in usb core */
97 uint16_t pad[3];
98 } intr;
100 struct {
101 uint16_t unlink_id; /* unlink request id */
102 uint16_t pad[3];
103 } unlink;
105 } u;
107 /* urb data segments */
108 struct usbif_request_segment seg[USBIF_MAX_SEGMENTS_PER_REQUEST];
109 };
110 typedef struct usbif_urb_request usbif_urb_request_t;
112 struct usbif_urb_response {
113 uint16_t id; /* request id */
114 uint16_t start_frame; /* start frame (ISO) */
115 int32_t status; /* status (non-ISO) */
116 int32_t actual_length; /* actual transfer length */
117 int32_t error_count; /* number of ISO errors */
118 };
119 typedef struct usbif_urb_response usbif_urb_response_t;
121 DEFINE_RING_TYPES(usbif_urb, struct usbif_urb_request, struct usbif_urb_response);
122 #define USB_URB_RING_SIZE __RING_SIZE((struct usbif_urb_sring *)0, PAGE_SIZE)
124 /*
125 * RING for notifying connect/disconnect events to frontend
126 */
127 struct usbif_conn_request {
128 uint16_t id;
129 };
130 typedef struct usbif_conn_request usbif_conn_request_t;
132 struct usbif_conn_response {
133 uint16_t id; /* request id */
134 uint8_t portnum; /* port number */
135 uint8_t speed; /* usb_device_speed */
136 };
137 typedef struct usbif_conn_response usbif_conn_response_t;
139 DEFINE_RING_TYPES(usbif_conn, struct usbif_conn_request, struct usbif_conn_response);
140 #define USB_CONN_RING_SIZE __RING_SIZE((struct usbif_conn_sring *)0, PAGE_SIZE)
142 #endif /* __XEN_PUBLIC_IO_USBIF_H__ */