Changeset 1368a6b in mainline
- Timestamp:
- 2011-07-11T14:10:27Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b7c2757
- Parents:
- 5fd0dc23
- Location:
- uspace/drv/bus/usb/ohci
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/root_hub.c
r5fd0dc23 r1368a6b 332 332 const size_t size = 7 + (bit_field_size * 2); 333 333 assert(size <= HUB_DESCRIPTOR_MAX_SIZE); 334 instance-> descriptor_size = size;334 instance->hub_descriptor_size = size; 335 335 336 336 const uint32_t hub_desc = instance->registers->rh_desc_a; … … 338 338 339 339 /* bDescLength */ 340 instance-> hub_descriptor[0] = size;340 instance->descriptors.hub[0] = size; 341 341 /* bDescriptorType */ 342 instance-> hub_descriptor[1] = USB_DESCTYPE_HUB;342 instance->descriptors.hub[1] = USB_DESCTYPE_HUB; 343 343 /* bNmbrPorts */ 344 instance-> hub_descriptor[2] = instance->port_count;344 instance->descriptors.hub[2] = instance->port_count; 345 345 /* wHubCharacteristics */ 346 instance-> hub_descriptor[3] = 0 |346 instance->descriptors.hub[3] = 0 | 347 347 /* The lowest 2 bits indicate power switching mode */ 348 348 (((hub_desc & RHDA_PSM_FLAG) ? 1 : 0) << 0) | … … 355 355 356 356 /* Reserved */ 357 instance-> hub_descriptor[4] = 0;357 instance->descriptors.hub[4] = 0; 358 358 /* bPwrOn2PwrGood */ 359 instance-> hub_descriptor[5] =359 instance->descriptors.hub[5] = 360 360 (hub_desc >> RHDA_POTPGT_SHIFT) & RHDA_POTPGT_MASK; 361 361 /* bHubContrCurrent, root hubs don't need no power. */ 362 instance-> hub_descriptor[6] = 0;362 instance->descriptors.hub[6] = 0; 363 363 364 364 /* Device Removable and some legacy 1.0 stuff*/ 365 instance-> hub_descriptor[7] =365 instance->descriptors.hub[7] = 366 366 (port_desc >> RHDB_DR_SHIFT) & RHDB_DR_MASK & 0xff; 367 instance-> hub_descriptor[8] = 0xff;367 instance->descriptors.hub[8] = 0xff; 368 368 if (bit_field_size == 2) { 369 instance-> hub_descriptor[8] =369 instance->descriptors.hub[8] = 370 370 (port_desc >> RHDB_DR_SHIFT) & RHDB_DR_MASK >> 8; 371 instance-> hub_descriptor[9] = 0xff;372 instance-> hub_descriptor[10] = 0xff;371 instance->descriptors.hub[9] = 0xff; 372 instance->descriptors.hub[10] = 0xff; 373 373 } 374 374 } … … 385 385 assert(instance); 386 386 387 memcpy(&instance->descriptors.device, &ohci_rh_device_descriptor, 388 sizeof(ohci_rh_device_descriptor)); 389 390 usb_standard_configuration_descriptor_t descriptor; 391 memcpy(&descriptor, &ohci_rh_conf_descriptor, 392 sizeof(ohci_rh_conf_descriptor)); 393 387 instance->descriptors.configuration = ohci_rh_conf_descriptor; 388 instance->descriptors.interface = ohci_rh_iface_descriptor; 389 instance->descriptors.endpoint = ohci_rh_ep_descriptor; 394 390 create_serialized_hub_descriptor(instance); 395 391 396 descriptor.total_length =392 instance->descriptors.configuration.total_length = 397 393 sizeof(usb_standard_configuration_descriptor_t) + 398 394 sizeof(usb_standard_endpoint_descriptor_t) + 399 395 sizeof(usb_standard_interface_descriptor_t) + 400 instance->descriptor_size; 401 402 uint8_t *full_config_descriptor = malloc(descriptor.total_length); 403 if (!full_config_descriptor) 404 return ENOMEM; 405 406 uint8_t *place = full_config_descriptor; 407 memcpy(place, &descriptor, sizeof(descriptor)); 408 409 place += sizeof(descriptor); 410 memcpy(place, &ohci_rh_iface_descriptor, 411 sizeof(ohci_rh_iface_descriptor)); 412 413 place += sizeof(ohci_rh_iface_descriptor); 414 memcpy(place, &ohci_rh_ep_descriptor, sizeof(ohci_rh_ep_descriptor)); 415 416 place += sizeof(ohci_rh_iface_descriptor); 417 memcpy(place, instance->hub_descriptor, instance->descriptor_size); 418 419 instance->descriptors.configuration = full_config_descriptor; 420 instance->descriptors.configuration_size = descriptor.total_length; 396 instance->hub_descriptor_size; 421 397 422 398 return EOK; … … 566 542 case USB_DESCTYPE_HUB: 567 543 usb_log_debug2("USB_DESCTYPE_HUB\n"); 568 result_descriptor = instance-> hub_descriptor;569 size = instance-> descriptor_size;544 result_descriptor = instance->descriptors.hub; 545 size = instance->hub_descriptor_size; 570 546 break; 571 547 … … 578 554 case USB_DESCTYPE_CONFIGURATION: 579 555 usb_log_debug2("USB_DESCTYPE_CONFIGURATION\n"); 580 result_descriptor = instance->descriptors.configuration;581 size = instance->descriptors.configuration _size;556 result_descriptor = &instance->descriptors; 557 size = instance->descriptors.configuration.total_length; 582 558 break; 583 559 -
uspace/drv/bus/usb/ohci/root_hub.h
r5fd0dc23 r1368a6b 41 41 #include "batch.h" 42 42 43 #define HUB_DESCRIPTOR_MAX_SIZE 1143 #define HUB_DESCRIPTOR_MAX_SIZE (7 + 2 + 2) 44 44 #define INTERRUPT_BUFFER_MAX_SIZE 2 45 45 … … 54 54 /** hub port count */ 55 55 size_t port_count; 56 /** hubs descriptors */57 usb_device_descriptors_t descriptors;58 56 /** interrupt transfer waiting for an actual interrupt to occur */ 59 57 usb_transfer_batch_t *unfinished_interrupt_transfer; … … 66 64 /** size of interrupt buffer */ 67 65 size_t interrupt_mask_size; 68 /** instance`s descriptor*/ 69 uint8_t hub_descriptor[HUB_DESCRIPTOR_MAX_SIZE]; 66 67 /** Descriptors */ 68 struct { 69 usb_standard_configuration_descriptor_t configuration; 70 usb_standard_interface_descriptor_t interface; 71 usb_standard_endpoint_descriptor_t endpoint; 72 uint8_t hub[HUB_DESCRIPTOR_MAX_SIZE]; 73 } __attribute__ ((packed)) descriptors; 70 74 /** size of hub descriptor */ 71 size_t descriptor_size;75 size_t hub_descriptor_size; 72 76 73 77 } rh_t;
Note:
See TracChangeset
for help on using the changeset viewer.