pipes.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2011 Vojtech Horky
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00035 #ifndef LIBUSBDEV_PIPES_H_
00036 #define LIBUSBDEV_PIPES_H_
00037 
00038 #include <sys/types.h>
00039 #include <usb/usb.h>
00040 #include <usb/hc.h>
00041 #include <usb/descriptor.h>
00042 #include <ipc/devman.h>
00043 #include <ddf/driver.h>
00044 #include <fibril_synch.h>
00045 
00050 typedef struct {
00052         devman_handle_t hc_handle;
00054         usb_address_t address;
00055 } usb_device_connection_t;
00056 
00068 typedef struct {
00070         fibril_mutex_t guard;
00071 
00073         usb_device_connection_t *wire;
00074 
00076         usb_endpoint_t endpoint_no;
00077 
00079         usb_transfer_type_t transfer_type;
00080 
00082         usb_direction_t direction;
00083 
00085         size_t max_packet_size;
00086 
00094         int hc_phone;
00095 
00097         fibril_mutex_t hc_phone_mutex;
00098 
00100         int refcount;
00114         int refcount_soft;
00115 
00119         bool auto_reset_halt;
00120 } usb_pipe_t;
00121 
00122 
00124 typedef struct {
00126         usb_transfer_type_t transfer_type;
00128         usb_direction_t direction;
00130         int interface_class;
00132         int interface_subclass;
00134         int interface_protocol;
00136         unsigned int flags;
00137 } usb_endpoint_description_t;
00138 
00140 typedef struct {
00142         usb_pipe_t *pipe;
00144         const usb_endpoint_description_t *description;
00146         int interface_no;
00148         int interface_setting;
00150         usb_standard_endpoint_descriptor_t *descriptor;
00152         usb_standard_interface_descriptor_t *interface;
00154         bool present;
00155 } usb_endpoint_mapping_t;
00156 
00157 int usb_device_connection_initialize_on_default_address(
00158     usb_device_connection_t *, usb_hc_connection_t *);
00159 int usb_device_connection_initialize_from_device(usb_device_connection_t *,
00160     ddf_dev_t *);
00161 int usb_device_connection_initialize(usb_device_connection_t *,
00162     devman_handle_t, usb_address_t);
00163 
00164 int usb_device_get_assigned_interface(ddf_dev_t *);
00165 
00166 int usb_pipe_initialize(usb_pipe_t *, usb_device_connection_t *,
00167     usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t);
00168 int usb_pipe_initialize_default_control(usb_pipe_t *,
00169     usb_device_connection_t *);
00170 int usb_pipe_probe_default_control(usb_pipe_t *);
00171 int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
00172     size_t, uint8_t *, size_t, usb_device_connection_t *);
00173 int usb_pipe_register_with_speed(usb_pipe_t *, usb_speed_t,
00174     unsigned int, usb_hc_connection_t *);
00175 int usb_pipe_register(usb_pipe_t *, unsigned int, usb_hc_connection_t *);
00176 int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *);
00177 
00178 void usb_pipe_start_long_transfer(usb_pipe_t *);
00179 void usb_pipe_end_long_transfer(usb_pipe_t *);
00180 
00181 int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
00182 int usb_pipe_write(usb_pipe_t *, void *, size_t);
00183 
00184 int usb_pipe_control_read(usb_pipe_t *, void *, size_t,
00185     void *, size_t, size_t *);
00186 int usb_pipe_control_write(usb_pipe_t *, void *, size_t,
00187     void *, size_t);
00188 
00189 #endif
00190 

Generated on Thu Jun 2 07:45:48 2011 for HelenOS/USB by  doxygen 1.4.7