Changeset cd5b878 in mainline
- Timestamp:
- 2011-04-15T11:49:36Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c1693dae
- Parents:
- 3a85a2b
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
r3a85a2b rcd5b878 105 105 } 106 106 107 usb_pipe_start_session(hub_info->control_pipe);107 //usb_pipe_start_session(hub_info->control_pipe); 108 108 //set hub configuration 109 109 opResult = usb_hub_set_configuration(hub_info); … … 122 122 return opResult; 123 123 } 124 usb_pipe_end_session(hub_info->control_pipe);124 //usb_pipe_end_session(hub_info->control_pipe); 125 125 126 126 /// \TODO what is this? … … 235 235 } 236 236 usb_log_debug2("deserializing descriptor\n"); 237 descriptor = usb_deserialize_hub_desriptor(serialized_descriptor); 237 descriptor = usb_create_deserialized_hub_desriptor( 238 serialized_descriptor); 238 239 if (descriptor == NULL) { 239 240 usb_log_warning("could not deserialize descriptor \n"); … … 259 260 usb_log_debug2("freeing data\n"); 260 261 free(serialized_descriptor); 261 free(descriptor->devices_removable);262 //free(descriptor->devices_removable); 262 263 free(descriptor); 263 264 return EOK; … … 321 322 * auto destruction, this could work better. 322 323 */ 323 int rc = usb_ pipe_start_session(hub_info->control_pipe);324 int rc = usb_hc_connection_open(&hub_info->connection); 324 325 if (rc != EOK) { 325 usb_log_error("Failed to start session on control pipe: %s.\n", 326 str_error(rc)); 327 return rc; 328 } 329 rc = usb_hc_connection_open(&hub_info->connection); 330 if (rc != EOK) { 331 usb_pipe_end_session(hub_info->control_pipe); 326 //usb_pipe_end_session(hub_info->control_pipe); 332 327 usb_log_error("Failed to open connection to HC: %s.\n", 333 328 str_error(rc)); -
uspace/drv/usbhub/usbhub_private.h
r3a85a2b rcd5b878 166 166 } 167 167 168 /**169 * create uint8_t array with serialized descriptor170 *171 * @param descriptor172 * @return newly created serializd descriptor pointer173 */174 void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor);175 168 176 /** 177 * create deserialized desriptor structure out of serialized descriptor 178 * 179 * The serialized descriptor must be proper usb hub descriptor,180 * otherwise an eerror might occur. 181 * 182 * @param sdescriptor serialized descriptor183 * @return newly created deserialized descriptor pointer 184 */ 185 usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);169 void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t * descriptor); 170 171 void usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor, 172 void * serialized_descriptor); 173 174 usb_hub_descriptor_t * usb_create_deserialized_hub_desriptor( 175 void * serialized_descriptor); 176 177 void usb_deserialize_hub_desriptor(void * serialized_descriptor, 178 usb_hub_descriptor_t * descriptor); 186 179 187 180 -
uspace/drv/usbhub/utils.c
r3a85a2b rcd5b878 56 56 //hub descriptor utils 57 57 58 void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor) { 58 /** 59 * create uint8_t array with serialized descriptor 60 * 61 * @param descriptor 62 * @return newly created serializd descriptor pointer 63 */ 64 void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t * descriptor) { 59 65 //base size 60 66 size_t size = 7; … … 64 70 uint8_t * result = malloc(size); 65 71 //size 66 result[0] = size; 72 usb_serialize_hub_descriptor(descriptor,result); 73 return result; 74 } 75 76 /** 77 * serialize descriptor into given buffer 78 * 79 * The buffer size is not checked. 80 * @param descriptor 81 * @param serialized_descriptor 82 */ 83 void usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor, 84 void * serialized_descriptor) { 85 //base size 86 uint8_t * sdescriptor = serialized_descriptor; 87 size_t size = 7; 88 //variable size according to port count 89 size_t var_size = (descriptor->ports_count+7)/8; 90 size += 2 * var_size; 91 //size 92 sdescriptor[0] = size; 67 93 //descriptor type 68 result[1] = USB_DESCTYPE_HUB;69 result[2] = descriptor->ports_count;94 sdescriptor[1] = USB_DESCTYPE_HUB; 95 sdescriptor[2] = descriptor->ports_count; 70 96 /// @fixme handling of endianness?? 71 result[3] = descriptor->hub_characteristics / 256;72 result[4] = descriptor->hub_characteristics % 256;73 result[5] = descriptor->pwr_on_2_good_time;74 result[6] = descriptor->current_requirement;97 sdescriptor[3] = descriptor->hub_characteristics / 256; 98 sdescriptor[4] = descriptor->hub_characteristics % 256; 99 sdescriptor[5] = descriptor->pwr_on_2_good_time; 100 sdescriptor[6] = descriptor->current_requirement; 75 101 76 102 size_t i; 77 103 for (i = 0; i < var_size; ++i) { 78 result[7 + i] = descriptor->devices_removable[i];104 sdescriptor[7 + i] = descriptor->devices_removable[i]; 79 105 } 80 106 for (i = 0; i < var_size; ++i) { 81 result[7 + var_size + i] = 255;107 sdescriptor[7 + var_size + i] = 255; 82 108 } 83 return result;84 109 } 85 110 86 usb_hub_descriptor_t * usb_deserialize_hub_desriptor( 111 112 /** 113 * create deserialized desriptor structure out of serialized descriptor 114 * 115 * The serialized descriptor must be proper usb hub descriptor, 116 * otherwise an eerror might occur. 117 * 118 * @param sdescriptor serialized descriptor 119 * @return newly created deserialized descriptor pointer 120 */ 121 usb_hub_descriptor_t * usb_create_deserialized_hub_desriptor( 87 122 void * serialized_descriptor) { 88 123 uint8_t * sdescriptor = serialized_descriptor; … … 95 130 96 131 usb_hub_descriptor_t * result = malloc(sizeof(usb_hub_descriptor_t)); 97 132 if(result) 133 usb_deserialize_hub_desriptor(serialized_descriptor,result); 134 return result; 135 } 98 136 99 result->ports_count = sdescriptor[2]; 137 /** 138 * deserialize descriptor into given pointer 139 * 140 * @param serialized_descriptor 141 * @param descriptor 142 * @return 143 */ 144 void usb_deserialize_hub_desriptor( 145 void * serialized_descriptor, usb_hub_descriptor_t * descriptor) { 146 uint8_t * sdescriptor = serialized_descriptor; 147 descriptor->ports_count = sdescriptor[2]; 100 148 /// @fixme handling of endianness?? 101 result->hub_characteristics = sdescriptor[4] + 256 * sdescriptor[3];102 result->pwr_on_2_good_time = sdescriptor[5];103 result->current_requirement = sdescriptor[6];104 size_t var_size = ( result->ports_count+7) / 8;105 result->devices_removable = (uint8_t*) malloc(var_size);149 descriptor->hub_characteristics = sdescriptor[4] + 256 * sdescriptor[3]; 150 descriptor->pwr_on_2_good_time = sdescriptor[5]; 151 descriptor->current_requirement = sdescriptor[6]; 152 size_t var_size = (descriptor->ports_count+7) / 8; 153 //descriptor->devices_removable = (uint8_t*) malloc(var_size); 106 154 107 155 size_t i; 108 156 for (i = 0; i < var_size; ++i) { 109 result->devices_removable[i] = sdescriptor[7 + i];157 descriptor->devices_removable[i] = sdescriptor[7 + i]; 110 158 } 111 return result;112 159 } 113 114 115 160 116 161 /** -
uspace/lib/usb/include/usb/classes/hub.h
r3a85a2b rcd5b878 152 152 maximum of 255 ports). 153 153 */ 154 uint8_t * devices_removable;154 uint8_t devices_removable[32]; 155 155 156 156 /**
Note:
See TracChangeset
for help on using the changeset viewer.