usbhub_private.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010 Matus Dekanek
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 
00036 #ifndef USBHUB_PRIVATE_H
00037 #define USBHUB_PRIVATE_H
00038 
00039 #include "usbhub.h"
00040 
00041 #include <adt/list.h>
00042 #include <bool.h>
00043 #include <ddf/driver.h>
00044 #include <fibril_synch.h>
00045 
00046 #include <usb/classes/hub.h>
00047 #include <usb/usb.h>
00048 #include <usb/debug.h>
00049 #include <usb/dev/request.h>
00050 
00051 //************
00052 //
00053 // convenience define for malloc
00054 //
00055 //************
00056 
00057 
00058 usb_hub_info_t * usb_create_hub_info(ddf_dev_t * device);
00059 
00066 static inline void usb_hub_set_descriptor_request(
00067     usb_device_request_setup_packet_t * request
00068     ) {
00069         request->index = 0;
00070         request->request_type = USB_HUB_REQ_TYPE_GET_DESCRIPTOR;
00071         request->request = USB_HUB_REQUEST_GET_DESCRIPTOR;
00072         request->value_high = USB_DESCTYPE_HUB;
00073         request->value_low = 0;
00074         request->length = USB_HUB_MAX_DESCRIPTOR_SIZE;
00075 }
00076 
00086 static inline int usb_hub_clear_port_feature(usb_pipe_t *pipe,
00087     int port_index,
00088     usb_hub_class_feature_t feature) {
00089 
00090         usb_device_request_setup_packet_t clear_request = {
00091                 .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
00092                 .request = USB_DEVREQ_CLEAR_FEATURE,
00093                 .length = 0,
00094                 .index = port_index
00095         };
00096         clear_request.value = feature;
00097         return usb_pipe_control_write(pipe, &clear_request,
00098             sizeof (clear_request), NULL, 0);
00099 }
00100 
00110 static inline int usb_hub_set_port_feature(usb_pipe_t *pipe,
00111     int port_index,
00112     usb_hub_class_feature_t feature) {
00113 
00114         usb_device_request_setup_packet_t clear_request = {
00115                 .request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE,
00116                 .request = USB_DEVREQ_SET_FEATURE,
00117                 .length = 0,
00118                 .index = port_index
00119         };
00120         clear_request.value = feature;
00121         return usb_pipe_control_write(pipe, &clear_request,
00122             sizeof (clear_request), NULL, 0);
00123 }
00124 
00132 static inline int usb_hub_clear_feature(usb_pipe_t *pipe,
00133     usb_hub_class_feature_t feature) {
00134 
00135         usb_device_request_setup_packet_t clear_request = {
00136                 .request_type = USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE,
00137                 .request = USB_DEVREQ_CLEAR_FEATURE,
00138                 .length = 0,
00139                 .index = 0
00140         };
00141         clear_request.value = feature;
00142         return usb_pipe_control_write(pipe, &clear_request,
00143             sizeof (clear_request), NULL, 0);
00144 }
00145 
00153 static inline int usb_hub_set_feature(usb_pipe_t *pipe,
00154     usb_hub_class_feature_t feature) {
00155 
00156         usb_device_request_setup_packet_t clear_request = {
00157                 .request_type = USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE,
00158                 .request = USB_DEVREQ_SET_FEATURE,
00159                 .length = 0,
00160                 .index = 0
00161         };
00162         clear_request.value = feature;
00163         return usb_pipe_control_write(pipe, &clear_request,
00164             sizeof (clear_request), NULL, 0);
00165 }
00166 
00167 
00168 void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t * descriptor);
00169 
00170 void usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor,
00171     void * serialized_descriptor);
00172 
00173 usb_hub_descriptor_t * usb_create_deserialized_hub_desriptor(
00174     void * serialized_descriptor);
00175 
00176 void usb_deserialize_hub_desriptor(void * serialized_descriptor,
00177     usb_hub_descriptor_t * descriptor);
00178 
00179 
00180 #endif  /* USBHUB_PRIVATE_H */
00181 

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