Changeset b3f655f in mainline for uspace/drv/ohci/root_hub.c
- Timestamp:
- 2011-03-26T00:14:23Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d70765d
- Parents:
- 53f1c87
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/root_hub.c
r53f1c87 rb3f655f 43 43 #include <usb/classes/hub.h> 44 44 45 static const usb_standard_device_descriptor_t ohci_rh_device_descriptor = 46 { 47 .configuration_count = 1, 48 .descriptor_type = USB_DESCTYPE_DEVICE, 49 .device_class = USB_CLASS_HUB, 50 .device_protocol = 0, 51 .device_subclass = 0, 52 .device_version = 0, 53 .length = sizeof(usb_standard_device_descriptor_t), 54 /// \TODO this value is guessed 55 .max_packet_size = 8, 56 .vendor_id = 0x16db, 57 .product_id = 0x0001, 58 /// \TODO these values migt be different 59 .str_serial_number = 0, 60 .usb_spec_version = 0, 61 }; 62 63 static const usb_standard_configuration_descriptor_t ohci_rh_conf_descriptor = 64 { 65 /// \TODO some values are default or guessed 66 .attributes = 1<<7, 67 .configuration_number = 1, 68 .descriptor_type = USB_DESCTYPE_CONFIGURATION, 69 .interface_count = 1, 70 .length = sizeof(usb_standard_configuration_descriptor_t), 71 .max_power = 100, 72 .str_configuration = 0, 73 }; 74 75 static const usb_standard_interface_descriptor_t ohci_rh_iface_descriptor = 76 { 77 .alternate_setting = 0, 78 .descriptor_type = USB_DESCTYPE_INTERFACE, 79 .endpoint_count = 1, 80 .interface_class = USB_CLASS_HUB, 81 /// \TODO is this correct? 82 .interface_number = 1, 83 .interface_protocol = 0, 84 .interface_subclass = 0, 85 .length = sizeof(usb_standard_interface_descriptor_t), 86 .str_interface = 0, 87 }; 88 89 static const usb_standard_endpoint_descriptor_t ohci_rh_ep_descriptor = 90 { 91 .attributes = USB_TRANSFER_INTERRUPT, 92 .descriptor_type = USB_DESCTYPE_ENDPOINT, 93 .endpoint_address = 1 + (1<<7), 94 .length = sizeof(usb_standard_endpoint_descriptor_t), 95 .max_packet_size = 8, 96 .poll_interval = 255, 97 }; 45 98 46 99 /** Root hub initialization … … 178 231 (usb_device_request_setup_packet_t*)request->setup_buffer; 179 232 size_t size; 180 void * result_descriptor;181 uint16_t setup_request_value = setup_request->value_high;233 const void * result_descriptor; 234 const uint16_t setup_request_value = setup_request->value_high; 182 235 //(setup_request->value_low << 8); 236 bool del = false; 237 238 switch (setup_request_value) 239 { 240 case USB_DESCTYPE_HUB: { 241 uint8_t * descriptor; 242 usb_create_serialized_hub_descriptor( 243 instance, &descriptor, &size); 244 result_descriptor = descriptor; 245 break; 246 } 247 case USB_DESCTYPE_DEVICE: { 248 usb_log_debug("USB_DESCTYPE_DEVICE\n"); 249 result_descriptor = &ohci_rh_device_descriptor; 250 size = sizeof(ohci_rh_device_descriptor); 251 break; 252 } 253 case USB_DESCTYPE_CONFIGURATION: { 254 usb_log_debug("USB_DESCTYPE_CONFIGURATION\n"); 255 usb_standard_configuration_descriptor_t * descriptor = 256 malloc(sizeof(usb_standard_configuration_descriptor_t)); 257 memcpy(descriptor, &ohci_rh_conf_descriptor, 258 sizeof(usb_standard_configuration_descriptor_t)); 259 /// \TODO should this include device descriptor? 260 const size_t hub_descriptor_size = 7 + 261 2* (instance->port_count / 8 + 262 ((instance->port_count % 8 > 0) ? 1 : 0)); 263 descriptor->total_length = 264 sizeof(usb_standard_configuration_descriptor_t)+ 265 sizeof(usb_standard_endpoint_descriptor_t)+ 266 sizeof(usb_standard_interface_descriptor_t)+ 267 hub_descriptor_size; 268 result_descriptor = descriptor; 269 size = sizeof(usb_standard_configuration_descriptor_t); 270 del = true; 271 break; 272 } 273 case USB_DESCTYPE_INTERFACE: { 274 usb_log_debug("USB_DESCTYPE_INTERFACE\n"); 275 result_descriptor = &ohci_rh_iface_descriptor; 276 size = sizeof(ohci_rh_iface_descriptor); 277 break; 278 } 279 case USB_DESCTYPE_ENDPOINT: { 280 usb_log_debug("USB_DESCTYPE_ENDPOINT\n"); 281 result_descriptor = &ohci_rh_ep_descriptor; 282 size = sizeof(ohci_rh_ep_descriptor); 283 break; 284 } 285 default: { 286 usb_log_debug("USB_DESCTYPE_EINVAL %d \n",setup_request->value); 287 usb_log_debug("\ttype %d\n\trequest %d\n\tvalue %d\n\tindex %d\n\tlen %d\n ", 288 setup_request->request_type, 289 setup_request->request, 290 setup_request_value, 291 setup_request->index, 292 setup_request->length 293 ); 294 return EINVAL; 295 } 296 } 297 #if 0 183 298 if(setup_request_value == USB_DESCTYPE_HUB){ 184 299 usb_log_debug("USB_DESCTYPE_HUB\n"); … … 277 392 return EINVAL; 278 393 } 394 #endif 279 395 if(request->buffer_size < size){ 280 396 size = request->buffer_size; … … 282 398 request->transfered_size = size; 283 399 memcpy(request->buffer,result_descriptor,size); 284 free(result_descriptor); 400 if (del) 401 free(result_descriptor); 285 402 return EOK; 286 403 }
Note:
See TracChangeset
for help on using the changeset viewer.