driver.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_DRIVER_H_
00036 #define LIBUSBDEV_DRIVER_H_
00037 
00038 #include <usb/dev/pipes.h>
00039 
00041 typedef struct {
00043         usb_standard_device_descriptor_t device;
00045         uint8_t *configuration;
00046         size_t configuration_size;
00047 } usb_device_descriptors_t;
00048 
00053 typedef struct {
00055         usb_standard_interface_descriptor_t *interface;
00057         uint8_t *nested_descriptors;
00059         size_t nested_descriptors_size;
00060 } usb_alternate_interface_descriptors_t;
00061 
00063 typedef struct {
00065         usb_alternate_interface_descriptors_t *alternatives;
00067         size_t alternative_count;
00069         size_t current;
00070 } usb_alternate_interfaces_t;
00071 
00073 typedef struct {
00075         usb_pipe_t ctrl_pipe;
00080         usb_endpoint_mapping_t *pipes;
00082         size_t pipes_count;
00087         int interface_no;
00088 
00093         usb_alternate_interfaces_t *alternate_interfaces;
00094 
00096         usb_device_descriptors_t descriptors;
00097 
00099         ddf_dev_t *ddf_dev;
00104         void *driver_data;
00105 
00109         usb_device_connection_t wire;
00110 } usb_device_t;
00111 
00113 typedef struct {
00115         int (*add_device)(usb_device_t *);
00116 } usb_driver_ops_t;
00117 
00119 typedef struct {
00124         const char *name;
00154         usb_endpoint_description_t **endpoints;
00156         usb_driver_ops_t *ops;
00157 } usb_driver_t;
00158 
00159 int usb_driver_main(usb_driver_t *);
00160 
00161 int usb_device_select_interface(usb_device_t *, uint8_t,
00162     usb_endpoint_description_t **);
00163 
00164 int usb_device_retrieve_descriptors(usb_pipe_t *, usb_device_descriptors_t *);
00165 int usb_device_create_pipes(ddf_dev_t *, usb_device_connection_t *,
00166     usb_endpoint_description_t **, uint8_t *, size_t, int, int,
00167     usb_endpoint_mapping_t **, size_t *);
00168 int usb_device_destroy_pipes(ddf_dev_t *, usb_endpoint_mapping_t *, size_t);
00169 int usb_device_create(ddf_dev_t *, usb_endpoint_description_t **, usb_device_t **, const char **);
00170 void usb_device_destroy(usb_device_t *);
00171 
00172 size_t usb_interface_count_alternates(uint8_t *, size_t, uint8_t);
00173 int usb_alternate_interfaces_create(uint8_t *, size_t, int,
00174     usb_alternate_interfaces_t **);
00175 
00176 #endif
00177 

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