ia64/linux-2.6.18-xen.hg

changeset 827:71aedaa9e21c

PVUSB: add io interface header for PVUSB

Signed-off-by: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Mar 18 11:42:19 2009 +0000 (2009-03-18)
parents 64c8f9fbf609
children 8f996719f2ff
files include/xen/interface/io/usbif.h
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/include/xen/interface/io/usbif.h	Wed Mar 18 11:42:19 2009 +0000
     1.3 @@ -0,0 +1,121 @@
     1.4 +/*
     1.5 + * usbif.h
     1.6 + *
     1.7 + * USB I/O interface for Xen guest OSes.
     1.8 + *
     1.9 + * Copyright (C) 2009, FUJITSU LABORATORIES LTD.
    1.10 + * Author: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com>
    1.11 + *
    1.12 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    1.13 + * of this software and associated documentation files (the "Software"), to
    1.14 + * deal in the Software without restriction, including without limitation the
    1.15 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    1.16 + * sell copies of the Software, and to permit persons to whom the Software is
    1.17 + * furnished to do so, subject to the following conditions:
    1.18 + *
    1.19 + * The above copyright notice and this permission notice shall be included in
    1.20 + * all copies or substantial portions of the Software.
    1.21 + *
    1.22 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    1.23 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    1.24 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    1.25 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    1.26 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    1.27 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    1.28 + * DEALINGS IN THE SOFTWARE.
    1.29 + */
    1.30 +
    1.31 +#ifndef __XEN_PUBLIC_IO_USBIF_H__
    1.32 +#define __XEN_PUBLIC_IO_USBIF_H__
    1.33 +
    1.34 +#include "ring.h"
    1.35 +#include "../grant_table.h"
    1.36 +
    1.37 +/*
    1.38 + *  USB pipe in usbif_request
    1.39 + *
    1.40 + *  bits 0-5 are specific bits for virtual USB driver.
    1.41 + *  bits 7-31 are standard urb pipe.
    1.42 + *
    1.43 + *  - port number(NEW):	bits 0-4
    1.44 + *  				(USB_MAXCHILDREN is 31)
    1.45 + *
    1.46 + *  - operation flag(NEW):	bit 5
    1.47 + *  				(0 = submit urb,
    1.48 + *  				 1 = unlink urb)
    1.49 + *
    1.50 + *  - direction:		bit 7
    1.51 + *  				(0 = Host-to-Device [Out]
    1.52 + *                           1 = Device-to-Host [In])
    1.53 + *
    1.54 + *  - device address:	bits 8-14
    1.55 + *
    1.56 + *  - endpoint:		bits 15-18
    1.57 + *
    1.58 + *  - pipe type:		bits 30-31
    1.59 + *  				(00 = isochronous, 01 = interrupt,
    1.60 + *                           10 = control, 11 = bulk)
    1.61 + */
    1.62 +#define usbif_pipeportnum(pipe) ((pipe) & 0x1f)
    1.63 +#define usbif_setportnum_pipe(pipe,portnum) \
    1.64 +	((pipe)|(portnum))
    1.65 +#define usbif_pipeunlink(pipe) ((pipe) & 0x20)
    1.66 +#define usbif_setunlink_pipe(pipe) ((pipe)|(0x20))
    1.67 +
    1.68 +#define USBIF_BACK_MAX_PENDING_REQS (128)
    1.69 +#define USBIF_MAX_SEGMENTS_PER_REQUEST (10)
    1.70 +
    1.71 +struct usbif_request_segment {
    1.72 +	grant_ref_t gref;
    1.73 +	uint16_t offset;
    1.74 +	uint16_t length;
    1.75 +};
    1.76 +
    1.77 +struct usbif_request {
    1.78 +	uint16_t id; /* request id */
    1.79 +	uint16_t nr_buffer_segs; /* number of urb->transfer_buffer segments */
    1.80 +
    1.81 +	/* basic urb parameter */
    1.82 +	uint32_t pipe;
    1.83 +	uint16_t transfer_flags;
    1.84 +	uint16_t buffer_length;
    1.85 +	union {
    1.86 +		uint8_t ctrl[8]; /* setup_packet (Ctrl) */
    1.87 +
    1.88 +		struct {
    1.89 +			uint16_t interval; /* maximum (1024*8) in usb core */
    1.90 +			uint16_t start_frame; /* start frame */
    1.91 +			uint16_t number_of_packets; /* number of ISO packet */
    1.92 +			uint16_t nr_frame_desc_segs; /* number of iso_frame_desc segments */
    1.93 +		} isoc;
    1.94 +
    1.95 +		struct {
    1.96 +			uint16_t interval; /* maximum (1024*8) in usb core */
    1.97 +			uint16_t pad[3];
    1.98 +		} intr;
    1.99 +
   1.100 +		struct {
   1.101 +			uint16_t unlink_id; /* unlink request id */
   1.102 +			uint16_t pad[3];
   1.103 +		} unlink;
   1.104 +
   1.105 +	} u;
   1.106 +
   1.107 +	/* urb data segments */
   1.108 +	struct usbif_request_segment seg[USBIF_MAX_SEGMENTS_PER_REQUEST];
   1.109 +};
   1.110 +typedef struct usbif_request usbif_request_t;
   1.111 +
   1.112 +struct usbif_response {
   1.113 +	uint16_t id; /* request id */
   1.114 +	uint16_t start_frame;  /* start frame (ISO) */
   1.115 +	int32_t status; /* status (non-ISO) */
   1.116 +	int32_t actual_length; /* actual transfer length */
   1.117 +	int32_t error_count; /* number of ISO errors */
   1.118 +};
   1.119 +typedef struct usbif_response usbif_response_t;
   1.120 +
   1.121 +DEFINE_RING_TYPES(usbif, struct usbif_request, struct usbif_response);
   1.122 +#define USB_RING_SIZE __RING_SIZE((struct usbif_sring *)0, PAGE_SIZE)
   1.123 +
   1.124 +#endif /* __XEN_PUBLIC_IO_USBIF_H__ */