00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
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
00181