Changes in / [5d4eb2df:a39f4cf] in mainline


Ignore:
Location:
uspace
Files:
3 added
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhub/port_status.h

    r5d4eb2df ra39f4cf  
    5555        request->index = port;
    5656        request->request_type = USB_HUB_REQ_TYPE_GET_PORT_STATUS;
    57         request->request = USB_HUB_REQUEST_GET_STATUS;
     57        request->request = USB_HUB_REQUEST_GET_STATE;
    5858        request->value = 0;
    5959        request->length = 4;
  • uspace/drv/usbhub/usbhub.h

    r5d4eb2df ra39f4cf  
    4040#include "usb/hcdhubd.h"
    4141
    42 /** basic information about device attached to hub */
    43 typedef struct{
    44         usb_address_t address;
    45         devman_handle_t devman_handle;
    46 }usb_hub_attached_device_t;
     42
    4743
    4844/** Information about attached hub. */
     
    5046        /** Number of ports. */
    5147        int port_count;
    52         /** attached device handles */
    53         usb_hub_attached_device_t * attached_devs;
    5448        /** General usb device info. */
    5549        usb_hcd_attached_device_info_t * usb_device;
  • uspace/drv/usbhub/utils.c

    r5d4eb2df ra39f4cf  
    351351        //printf("[usb_hub] setting port count to %d\n",descriptor->ports_count);
    352352        result->port_count = descriptor->ports_count;
    353         result->attached_devs = (usb_hub_attached_device_t*)
    354             malloc(result->port_count * sizeof(usb_hub_attached_device_t));
    355         int i;
    356         for(i=0;i<result->port_count;++i){
    357                 result->attached_devs[i].devman_handle=0;
    358                 result->attached_devs[i].address=0;
    359         }
    360353        //printf("[usb_hub] freeing data\n");
    361354        free(serialized_descriptor);
     
    392385        target.address = hub_info->usb_device->address;
    393386        target.endpoint = 0;
    394 
    395         //get configuration descriptor
    396         // this is not fully correct - there are more configurations
    397         // and all should be checked
    398         usb_standard_device_descriptor_t std_descriptor;
    399         opResult = usb_drv_req_get_device_descriptor(hc, target.address,
    400     &std_descriptor);
    401         if(opResult!=EOK){
    402                 printf("[usb_hub] could not get device descriptor, %d\n",opResult);
    403                 return 1;///\TODO some proper error code needed
    404         }
    405         printf("[usb_hub] hub has %d configurations\n",std_descriptor.configuration_count);
    406         if(std_descriptor.configuration_count<1){
    407                 printf("[usb_hub] THERE ARE NO CONFIGURATIONS AVAILABLE\n");
    408         }
    409         usb_standard_configuration_descriptor_t config_descriptor;
    410         opResult = usb_drv_req_get_bare_configuration_descriptor(hc,
    411         target.address, 0,
    412         &config_descriptor);
    413         if(opResult!=EOK){
    414                 printf("[usb_hub] could not get configuration descriptor, %d\n",opResult);
    415                 return 1;///\TODO some proper error code needed
    416         }
    417         //set configuration
    418         request.request_type = 0;
    419         request.request = USB_DEVREQ_SET_CONFIGURATION;
    420         request.index=0;
    421         request.length=0;
    422         request.value_high=0;
    423         request.value_low = config_descriptor.configuration_number;
    424         opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
    425         if (opResult != EOK) {
    426                 printf("[usb_hub]something went wrong when setting hub`s configuration, %d\n", opResult);
    427         }
    428 
    429 
    430387        for (port = 0; port < hub_info->port_count; ++port) {
    431388                usb_hub_set_power_port_request(&request, port);
     
    436393        }
    437394        //ports powered, hub seems to be enabled
    438        
    439395
    440396        ipc_hangup(hc);
     
    455411                        hub_info->usb_device->address,
    456412                        hub_info->port_count);
    457         printf("\tused configuration %d\n",config_descriptor.configuration_number);
    458413
    459414        return EOK;
     
    477432        int opResult;
    478433        printf("[usb_hub] some connection changed\n");
    479         //get default address
     434
    480435        opResult = usb_drv_reserve_default_address(hc);
    481436        if (opResult != EOK) {
     
    523478        }
    524479
     480
    525481        usb_drv_release_default_address(hc);
    526482
     
    532488                return;
    533489        }
    534         hub->attached_devs[port].devman_handle = child_handle;
    535         hub->attached_devs[port].address = new_device_address;
    536 
    537         opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
    538         if (opResult != EOK) {
    539                 printf("[usb_hub] could not assign address of device in hcd \n");
    540                 return;
    541         }
     490        usb_drv_bind_address(hc, new_device_address, child_handle);
    542491       
    543492}
     
    549498 * @param target
    550499 */
    551 static void usb_hub_removed_device(
    552     usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {
    553         //usb_device_request_setup_packet_t request;
     500static void usb_hub_removed_device(int hc, uint16_t port, usb_target_t target) {
     501        usb_device_request_setup_packet_t request;
    554502        int opResult;
    555503        //disable port
    556         /*usb_hub_set_disable_port_request(&request, port);
     504        usb_hub_set_disable_port_request(&request, port);
    557505        opResult = usb_drv_sync_control_write(
    558506                        hc, target,
     
    563511                //continue;
    564512                printf("[usb_hub] something went wrong when disabling a port\n");
    565         }*/
    566         /// \TODO remove device
    567 
    568         hub->attached_devs[port].devman_handle=0;
     513        }
     514        //remove device
    569515        //close address
    570         if(hub->attached_devs[port].address!=0){
    571                 opResult = usb_drv_release_address(hc,hub->attached_devs[port].address);
    572                 if(opResult != EOK) {
    573                         printf("[usb_hub] could not release address of removed device: %d\n",opResult);
    574                 }
    575                 hub->attached_devs[port].address = 0;
    576         }else{
    577                 printf("[usb_hub] this is strange, disconnected device had no address\n");
    578                 //device was disconnected before it`s port was reset - return default address
    579                 usb_drv_release_default_address(hc);
    580         }
     516        //
     517
     518        ///\TODO this code is not complete
    581519}
    582520
     
    587525 * @param target
    588526 */
    589 static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,
    590         uint16_t port, usb_address_t address) {
     527static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {
    591528        printf("[usb_hub] interrupt at port %d\n", port);
    592529        //determine type of change
    593         usb_target_t target;
    594         target.address=address;
    595         target.endpoint=0;
    596530        usb_port_status_t status;
    597531        size_t rcvd_size;
     
    599533        int opResult;
    600534        usb_hub_set_port_status_request(&request, port);
    601         //endpoint 0
    602535
    603536        opResult = usb_drv_sync_control_read(
     
    620553                        usb_hub_init_add_device(hc, port, target);
    621554                } else {
    622                         usb_hub_removed_device(hub, hc, port, target);
     555                        usb_hub_removed_device(hc, port, target);
    623556                }
    624557        }
     
    674607                usb_target_t target;
    675608                target.address = hub_info->usb_device->address;
    676                 target.endpoint = 1;/// \TODO get from endpoint descriptor
     609                target.endpoint = 1;
    677610
    678611                size_t port_count = hub_info->port_count;
     
    710643                        bool interrupt = (((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2;
    711644                        if (interrupt) {
    712                                 usb_hub_process_interrupt(
    713                                         hub_info, hc, port, hub_info->usb_device->address);
     645                                usb_hub_process_interrupt(hub_info, hc, port, target);
    714646                        }
    715647                }
Note: See TracChangeset for help on using the changeset viewer.