driver.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010 Lenka Trochtova
00003  * Copyright (c) 2011 Jiri Svoboda
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * - Redistributions of source code must retain the above copyright
00011  *   notice, this list of conditions and the following disclaimer.
00012  * - Redistributions in binary form must reproduce the above copyright
00013  *   notice, this list of conditions and the following disclaimer in the
00014  *   documentation and/or other materials provided with the distribution.
00015  * - The name of the author may not be used to endorse or promote products
00016  *   derived from this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00019  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00020  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00021  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00022  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00023  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00024  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00025  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00026  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00027  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00036 #ifndef DDF_DRIVER_H_
00037 #define DDF_DRIVER_H_
00038 
00039 #include <ipc/devman.h>
00040 #include <ipc/dev_iface.h>
00041 
00042 #include "../dev_iface.h"
00043 
00044 typedef struct ddf_dev ddf_dev_t;
00045 typedef struct ddf_fun ddf_fun_t;
00046 
00047 /*
00048  * Device
00049  */
00050 
00052 typedef struct ddf_dev_ops {
00057         int (*open)(ddf_fun_t *);
00058         
00063         void (*close)(ddf_fun_t *);
00064         
00066         void *interfaces[DEV_IFACE_COUNT];
00067         
00073         remote_handler_t *default_handler;
00074 } ddf_dev_ops_t;
00075 
00077 struct ddf_dev {
00082         devman_handle_t handle;
00083         
00088         int parent_phone;
00089         
00091         const char *name;
00092         
00094         void *driver_data;
00095         
00097         link_t link;
00098 };
00099 
00101 struct ddf_fun {
00103         bool bound;
00105         devman_handle_t handle;
00106         
00108         ddf_dev_t *dev;
00109         
00111         fun_type_t ftype;
00113         const char *name;
00115         match_id_list_t match_ids;
00117         void *driver_data;
00119         ddf_dev_ops_t *ops;
00120         
00122         link_t link;
00123 };
00124 
00125 /*
00126  * Driver
00127  */
00128 
00130 typedef struct driver_ops {
00132         int (*add_device)(ddf_dev_t *dev);
00133         /* TODO: add other generic driver operations */
00134 } driver_ops_t;
00135 
00137 typedef struct driver {
00139         const char *name;
00141         driver_ops_t *driver_ops;
00142 } driver_t;
00143 
00144 extern int ddf_driver_main(driver_t *);
00145 
00146 extern ddf_fun_t *ddf_fun_create(ddf_dev_t *, fun_type_t, const char *);
00147 extern void ddf_fun_destroy(ddf_fun_t *);
00148 extern int ddf_fun_bind(ddf_fun_t *);
00149 extern int ddf_fun_add_match_id(ddf_fun_t *, const char *, int);
00150 
00151 extern int ddf_fun_add_to_class(ddf_fun_t *, const char *);
00152 
00153 #endif
00154 

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