Changes in / [138a7fd:ecf52c4b] in mainline


Ignore:
Location:
uspace
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/virtusbkbd/virtusbkbd.c

    r138a7fd recf52c4b  
    223223       
    224224        printf("%s: Simulating keyboard events...\n", NAME);
    225         kb_process_events(&status, keyboard_events, keyboard_events_count,
    226             on_keyboard_change);
     225        while(1){
     226                kb_process_events(&status, keyboard_events, keyboard_events_count,
     227                        on_keyboard_change);
     228        }
    227229       
    228230        printf("%s: Terminating...\n", NAME);
  • uspace/drv/usbhub/main.c

    r138a7fd recf52c4b  
    5050        while(true){
    5151                usb_hub_check_hub_changes();
    52                 async_usleep(10000);
     52                async_usleep(10000000);
    5353        }
    5454        return 0;
  • uspace/drv/usbhub/port_status.h

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

    r138a7fd recf52c4b  
    4040#include "usb/hcdhubd.h"
    4141
    42 
     42/** basic information about device attached to hub */
     43typedef struct{
     44        usb_address_t address;
     45        devman_handle_t devman_handle;
     46}usb_hub_attached_device_t;
    4347
    4448/** Information about attached hub. */
     
    4650        /** Number of ports. */
    4751        int port_count;
     52        /** attached device handles */
     53        usb_hub_attached_device_t * attached_devs;
    4854        /** General usb device info. */
    4955        usb_hcd_attached_device_info_t * usb_device;
  • uspace/drv/usbhub/utils.c

    r138a7fd recf52c4b  
    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+1) * sizeof(usb_hub_attached_device_t));
     355        int i;
     356        for(i=0;i<result->port_count+1;++i){
     357                result->attached_devs[i].devman_handle=0;
     358                result->attached_devs[i].address=0;
     359        }
    353360        //printf("[usb_hub] freeing data\n");
    354361        free(serialized_descriptor);
     
    385392        target.address = hub_info->usb_device->address;
    386393        target.endpoint = 0;
    387         for (port = 0; port < hub_info->port_count; ++port) {
     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
     430        for (port = 1; port < hub_info->port_count+1; ++port) {
    388431                usb_hub_set_power_port_request(&request, port);
    389432                opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
     433                printf("[usb_hub] powering port %d\n",port);
    390434                if (opResult != EOK) {
    391435                        printf("[usb_hub]something went wrong when setting hub`s %dth port\n", port);
     
    393437        }
    394438        //ports powered, hub seems to be enabled
     439       
    395440
    396441        ipc_hangup(hc);
     
    411456                        hub_info->usb_device->address,
    412457                        hub_info->port_count);
     458        printf("\tused configuration %d\n",config_descriptor.configuration_number);
    413459
    414460        return EOK;
     
    432478        int opResult;
    433479        printf("[usb_hub] some connection changed\n");
    434 
     480        //get default address
    435481        opResult = usb_drv_reserve_default_address(hc);
    436482        if (opResult != EOK) {
     
    478524        }
    479525
    480 
    481526        usb_drv_release_default_address(hc);
    482527
     
    488533                return;
    489534        }
    490         usb_drv_bind_address(hc, new_device_address, child_handle);
     535        hub->attached_devs[port].devman_handle = child_handle;
     536        hub->attached_devs[port].address = new_device_address;
     537
     538        opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
     539        if (opResult != EOK) {
     540                printf("[usb_hub] could not assign address of device in hcd \n");
     541                return;
     542        }
     543        printf("[usb_hub] new device address %d, handle %d\n",
     544            new_device_address, child_handle);
     545        sleep(60);
    491546       
    492547}
     
    498553 * @param target
    499554 */
    500 static void usb_hub_removed_device(int hc, uint16_t port, usb_target_t target) {
    501         usb_device_request_setup_packet_t request;
     555static void usb_hub_removed_device(
     556    usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {
     557        //usb_device_request_setup_packet_t request;
    502558        int opResult;
    503559        //disable port
    504         usb_hub_set_disable_port_request(&request, port);
     560        /*usb_hub_set_disable_port_request(&request, port);
    505561        opResult = usb_drv_sync_control_write(
    506562                        hc, target,
     
    511567                //continue;
    512568                printf("[usb_hub] something went wrong when disabling a port\n");
    513         }
    514         //remove device
     569        }*/
     570        /// \TODO remove device
     571
     572        hub->attached_devs[port].devman_handle=0;
    515573        //close address
    516         //
    517 
    518         ///\TODO this code is not complete
     574        if(hub->attached_devs[port].address!=0){
     575                opResult = usb_drv_release_address(hc,hub->attached_devs[port].address);
     576                if(opResult != EOK) {
     577                        printf("[usb_hub] could not release address of removed device: %d\n",opResult);
     578                }
     579                hub->attached_devs[port].address = 0;
     580        }else{
     581                printf("[usb_hub] this is strange, disconnected device had no address\n");
     582                //device was disconnected before it`s port was reset - return default address
     583                usb_drv_release_default_address(hc);
     584        }
    519585}
    520586
     
    525591 * @param target
    526592 */
    527 static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {
     593static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,
     594        uint16_t port, usb_address_t address) {
    528595        printf("[usb_hub] interrupt at port %d\n", port);
    529596        //determine type of change
     597        usb_target_t target;
     598        target.address=address;
     599        target.endpoint=0;
    530600        usb_port_status_t status;
    531601        size_t rcvd_size;
     
    533603        int opResult;
    534604        usb_hub_set_port_status_request(&request, port);
     605        //endpoint 0
    535606
    536607        opResult = usb_drv_sync_control_read(
     
    553624                        usb_hub_init_add_device(hc, port, target);
    554625                } else {
    555                         usb_hub_removed_device(hc, port, target);
     626                        usb_hub_removed_device(hub, hc, port, target);
    556627                }
    557628        }
     
    571642        usb_port_set_dev_connected(&status, false);
    572643        if (status) {
    573                 printf("[usb_hub]there was some unsupported change on port\n");
     644                printf("[usb_hub]there was some unsupported change on port %d\n",port);
    574645        }
    575646        /// \TODO handle other changes
     
    607678                usb_target_t target;
    608679                target.address = hub_info->usb_device->address;
    609                 target.endpoint = 1;
     680                target.endpoint = 1;/// \TODO get from endpoint descriptor
     681                printf("checking changes for hub at addr %d \n",target.address);
    610682
    611683                size_t port_count = hub_info->port_count;
     
    620692
    621693                // FIXME: count properly
    622                 size_t byte_length = (port_count / 8) + 1;
     694                size_t byte_length = ((port_count+1) / 8) + 1;
    623695
    624696                void *change_bitmap = malloc(byte_length);
     
    640712                }
    641713                unsigned int port;
    642                 for (port = 0; port < port_count; ++port) {
     714                for (port = 1; port < port_count+1; ++port) {
    643715                        bool interrupt = (((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2;
    644716                        if (interrupt) {
    645                                 usb_hub_process_interrupt(hub_info, hc, port, target);
     717                                usb_hub_process_interrupt(
     718                                        hub_info, hc, port, hub_info->usb_device->address);
    646719                        }
    647720                }
  • uspace/drv/vhc/connhost.c

    r138a7fd recf52c4b  
    9393    usbhc_iface_transfer_out_callback_t callback, void *arg)
    9494{
    95         dprintf(1, "transfer OUT [%d.%d (%s); %zu]",
     95        dprintf(3, "transfer OUT [%d.%d (%s); %zu]",
    9696            target.address, target.endpoint,
    9797            usb_str_transfer_type(transfer_type),
     
    113113    usbhc_iface_transfer_out_callback_t callback, void *arg)
    114114{
    115         dprintf(1, "transfer SETUP [%d.%d (%s); %zu]",
     115        dprintf(3, "transfer SETUP [%d.%d (%s); %zu]",
    116116            target.address, target.endpoint,
    117117            usb_str_transfer_type(transfer_type),
     
    133133    usbhc_iface_transfer_in_callback_t callback, void *arg)
    134134{
    135         dprintf(1, "transfer IN [%d.%d (%s); %zu]",
     135        dprintf(3, "transfer IN [%d.%d (%s); %zu]",
    136136            target.address, target.endpoint,
    137137            usb_str_transfer_type(transfer_type),
  • uspace/drv/vhc/devices.c

    r138a7fd recf52c4b  
    147147        if (virthub_dev.address == transaction->target.address) {
    148148                size_t tmp;
    149                 dprintf(3, "sending `%s' transaction to hub",
     149                dprintf(1, "sending `%s' transaction to hub",
    150150                    usbvirt_str_transaction_type(transaction->type));
    151151                switch (transaction->type) {
  • uspace/drv/vhc/hc.c

    r138a7fd recf52c4b  
    153153        transaction->callback_arg = arg;
    154154       
    155         dprintf(1, "creating transaction " TRANSACTION_FORMAT,
     155        dprintf(3, "creating transaction " TRANSACTION_FORMAT,
    156156            TRANSACTION_PRINTF(*transaction));
    157157       
  • uspace/drv/vhc/hcd.c

    r138a7fd recf52c4b  
    110110        printf("%s: virtual USB host controller driver.\n", NAME);
    111111
    112         usb_dprintf_enable(NAME, 1);
     112        usb_dprintf_enable(NAME, 2);
    113113
    114114        fid_t fid = fibril_create(hc_manager_fibril, NULL);
  • uspace/drv/vhc/hubops.c

    r138a7fd recf52c4b  
    200200                } \
    201201        } while (false); \
    202         hub_port_t *portvar = &hub_dev.ports[index]
     202        hub_port_t *portvar = &hub_dev.ports[index-1]
    203203
    204204
  • uspace/lib/usb/src/addrkeep.c

    r138a7fd recf52c4b  
    199199                        usb_address_keeping_used_t *last
    200200                            = used_address_get_instance(addresses->used_addresses.next);
    201                         free_address = last->address;
     201                        free_address = last->address + 1;
    202202                }
    203203        }
Note: See TracChangeset for help on using the changeset viewer.