batch.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2011 Jan Vesely
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  */
00034 #ifndef LIBUSBHOST_HOST_BATCH_H
00035 #define LIBUSBHOST_HOST_BATCH_H
00036 
00037 #include <adt/list.h>
00038 
00039 #include <usbhc_iface.h>
00040 #include <usb/usb.h>
00041 #include <usb/host/endpoint.h>
00042 
00043 typedef struct usb_transfer_batch usb_transfer_batch_t;
00044 struct usb_transfer_batch {
00045         endpoint_t *ep;
00046         link_t link;
00047         usbhc_iface_transfer_in_callback_t callback_in;
00048         usbhc_iface_transfer_out_callback_t callback_out;
00049         void *arg;
00050         char *buffer;
00051         char *data_buffer;
00052         size_t buffer_size;
00053         char *setup_buffer;
00054         size_t setup_size;
00055         size_t transfered_size;
00056         void (*next_step)(usb_transfer_batch_t *);
00057         int error;
00058         ddf_fun_t *fun;
00059         void *private_data;
00060         void (*private_data_dtor)(void *p_data);
00061 };
00062 
00063 void usb_transfer_batch_init(
00064     usb_transfer_batch_t *instance,
00065     endpoint_t *ep,
00066     char *buffer,
00067     char *data_buffer,
00068     size_t buffer_size,
00069     char *setup_buffer,
00070     size_t setup_size,
00071     usbhc_iface_transfer_in_callback_t func_in,
00072     usbhc_iface_transfer_out_callback_t func_out,
00073     void *arg,
00074     ddf_fun_t *fun,
00075     void *private_data,
00076     void (*private_data_dtor)(void *p_data)
00077 );
00078 
00079 void usb_transfer_batch_call_in_and_dispose(usb_transfer_batch_t *instance);
00080 void usb_transfer_batch_call_out_and_dispose(usb_transfer_batch_t *instance);
00081 void usb_transfer_batch_finish(usb_transfer_batch_t *instance);
00082 void usb_transfer_batch_dispose(usb_transfer_batch_t *instance);
00083 
00084 static inline void usb_transfer_batch_finish_error(
00085     usb_transfer_batch_t *instance, int error)
00086 {
00087         assert(instance);
00088         instance->error = error;
00089         usb_transfer_batch_finish(instance);
00090 }
00091 
00092 static inline usb_transfer_batch_t *usb_transfer_batch_from_link(link_t *l)
00093 {
00094         assert(l);
00095         return list_get_instance(l, usb_transfer_batch_t, link);
00096 }
00097 
00098 #endif
00099 

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