Changes in / [72fea5a:2c98e78] in mainline


Ignore:
Location:
uspace/drv/usbhub
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhub/main.c

    r72fea5a r2c98e78  
    3838
    3939usb_general_list_t usb_hub_list;
    40 futex_t usb_hub_list_lock;
    4140
    4241static driver_ops_t hub_driver_ops = {
     
    6160{
    6261        usb_dprintf_enable(NAME,1);
    63         futex_initialize(&usb_hub_list_lock, 0);
    6462        usb_lst_init(&usb_hub_list);
    65         futex_up(&usb_hub_list_lock);
    6663        fid_t fid = fibril_create(usb_hub_control_loop, NULL);
    6764        if (fid == 0) {
  • uspace/drv/usbhub/usbhub.c

    r72fea5a r2c98e78  
    7575        //get some hub info
    7676        usb_address_t addr = usb_drv_get_my_address(hc, device);
    77         dprintf(1,"[usb_hub] address of newly created hub = %d", addr);
     77        dprintf(1,"[usb_hub] addres of newly created hub = %d", addr);
    7878        /*if(addr<0){
    7979                //return result;
     
    174174                dprintf(1,"[usb_hub] THERE ARE NO CONFIGURATIONS AVAILABLE");
    175175        }
    176         /// \TODO check other configurations
    177176        usb_standard_configuration_descriptor_t config_descriptor;
    178177        opResult = usb_drv_req_get_bare_configuration_descriptor(hc,
     
    195194        }
    196195
     196
    197197        for (port = 1; port < hub_info->port_count+1; ++port) {
    198198                usb_hub_set_power_port_request(&request, port);
     
    205205        //ports powered, hub seems to be enabled
    206206
     207
    207208        ipc_hangup(hc);
    208209
    209210        //add the hub to list
    210         futex_down(&usb_hub_list_lock);
    211211        usb_lst_append(&usb_hub_list, hub_info);
    212         futex_up(&usb_hub_list_lock);
    213 
    214212        dprintf(1,"[usb_hub] hub info added to list");
    215213        //(void)hub_info;
     
    235233//
    236234//*********************************************
    237 
    238 /**
    239  * convenience function for releasing default address and writing debug info
    240  * (these few lines are used too often to be written again and again)
    241  * @param hc
    242  * @return
    243  */
    244 inline static int usb_hub_release_default_address(int hc){
    245         int opResult;
    246         dprintf(1,"[usb_hub] releasing default address");
    247         opResult = usb_drv_release_default_address(hc);
    248         if (opResult != EOK) {
    249                 dprintf(1,"[usb_hub] failed to release default address");
    250         }
    251         return opResult;
    252 }
    253235
    254236/**
     
    277259        if (opResult != EOK) {
    278260                dprintf(1,"[usb_hub] something went wrong when reseting a port");
    279                 usb_hub_release_default_address(hc);
    280         }
    281 }
     261        }
     262}
     263
     264/**
     265 * convenience function for releasing default address and writing debug info
     266 * (these few lines are used too often to be written again and again)
     267 * @param hc
     268 * @return
     269 */
     270inline static int usb_hub_release_default_address(int hc){
     271        int opResult;
     272        dprintf(1,"[usb_hub] releasing default address");
     273        opResult = usb_drv_release_default_address(hc);
     274        if (opResult != EOK) {
     275                dprintf(1,"[usb_hub] failed to release default address");
     276        }
     277        return opResult;
     278}
     279
    282280
    283281/**
     
    345343
    346344/**
    347  * unregister device address in hc
     345 * unregister device address in hc, close the port
    348346 * @param hc
    349347 * @param port
     
    354352        //usb_device_request_setup_packet_t request;
    355353        int opResult;
    356        
     354        //disable port
     355        /*usb_hub_set_disable_port_request(&request, port);
     356        opResult = usb_drv_sync_control_write(
     357                        hc, target,
     358                        &request,
     359                        NULL, 0
     360                        );
     361        if (opResult != EOK) {
     362                //continue;
     363                printf("[usb_hub] something went wrong when disabling a port\n");
     364        }*/
    357365        /// \TODO remove device
    358366
     
    449457         */
    450458        usb_general_list_t * lst_item;
    451         futex_down(&usb_hub_list_lock);
    452459        for (lst_item = usb_hub_list.next;
    453460                        lst_item != &usb_hub_list;
    454461                        lst_item = lst_item->next) {
    455                 futex_up(&usb_hub_list_lock);
    456462                usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);
    457463                /*
     
    504510                        }
    505511                }
    506                 free(change_bitmap);
    507512
    508513                ipc_hangup(hc);
    509                 futex_down(&usb_hub_list_lock);
    510         }
    511         futex_up(&usb_hub_list_lock);
     514        }
    512515}
    513516
  • uspace/drv/usbhub/usbhub_private.h

    r72fea5a r2c98e78  
    4343#include <bool.h>
    4444#include <driver.h>
    45 #include <futex.h>
    46 
    4745#include <usb/usb.h>
    4846#include <usb/usbdrv.h>
     
    6866
    6967/**
    70  * create hub structure instance
     68 * @brief create hub structure instance
    7169 *
    7270 * Set the address and port count information most importantly.
     
    8179extern usb_general_list_t usb_hub_list;
    8280
    83 /** lock for hub list*/
    84 extern futex_t usb_hub_list_lock;
    85 
    8681
    8782/**
    88  * perform complete control read transaction
     83 * @brief perform complete control read transaction
    8984 *
    9085 * manages all three steps of transaction: setup, read and finalize
     
    10499
    105100/**
    106  * perform complete control write transaction
     101 * @brief perform complete control write transaction
    107102 *
    108  * manages all three steps of transaction: setup, write and finalize
     103 * maanges all three steps of transaction: setup, write and finalize
    109104 * @param phone
    110105 * @param target
     
    119114    void * sent_buffer, size_t sent_size
    120115);
     116
     117
     118/**
     119 * set the device request to be a set address request
     120 * @param request
     121 * @param addr
     122 * \TODO this will be obsolete see usb/dev_req.h
     123 */
     124static inline void usb_hub_set_set_address_request(
     125usb_device_request_setup_packet_t * request, uint16_t addr
     126){
     127        request->index = 0;
     128        request->request_type = 0;/// \TODO this is not very nice sollution, we ned constant
     129        request->request = USB_DEVREQ_SET_ADDRESS;
     130        request->value = addr;
     131        request->length = 0;
     132}
    121133
    122134/**
  • uspace/drv/usbhub/utils.c

    r72fea5a r2c98e78  
    200200
    201201
    202 
     202/*
     203 * method for testing port status bitmap
     204 
     205static void usb_hub_test_port_status(void) {
     206        printf("[usb_hub] -------------port status test---------\n");
     207        usb_port_status_t status = 0;
     208
     209        //printf("original status %d (should be 0)\n",(uint32_t)status);
     210        usb_port_set_bit(&status, 1, 1);
     211        //printf("%d =?= 2\n",(uint32_t)status);
     212        if (status != 2) {
     213                printf("[usb_port_status] test failed: wrong set of bit 1\n");
     214                return;
     215        }
     216        usb_port_set_bit(&status, 3, 1);
     217        if (status != 10) {
     218                printf("[usb_port_status] test failed: wrong set of bit 3\n");
     219                return;
     220        }
     221
     222        usb_port_set_bit(&status, 15, 1);
     223        if (status != 10 + (1 << 15)) {
     224                printf("[usb_port_status] test failed: wrong set of bit 15\n");
     225                return;
     226        }
     227        usb_port_set_bit(&status, 1, 0);
     228        if (status != 8 + (1 << 15)) {
     229                printf("[usb_port_status] test failed: wrong unset of bit 1\n");
     230                return;
     231        }
     232        int i;
     233        for (i = 0; i < 32; ++i) {
     234                if (i == 3 || i == 15) {
     235                        if (!usb_port_get_bit(&status, i)) {
     236                                printf("[usb_port_status] test failed: wrong bit at %d\n", i);
     237                        }
     238                } else {
     239                        if (usb_port_get_bit(&status, i)) {
     240                                printf("[usb_port_status] test failed: wrong bit at %d\n", i);
     241                        }
     242                }
     243        }
     244
     245        printf("test ok\n");
     246
     247
     248        //printf("%d =?= 10\n",(uint32_t)status);
     249
     250        //printf("this should be 0: %d \n",usb_port_get_bit(&status,0));
     251        //printf("this should be 1: %d \n",usb_port_get_bit(&status,1));
     252        //printf("this should be 0: %d \n",usb_port_get_bit(&status,2));
     253        //printf("this should be 1: %d \n",usb_port_get_bit(&status,3));
     254        //printf("this should be 0: %d \n",usb_port_get_bit(&status,4));
     255
     256}
     257*/
    203258
    204259
Note: See TracChangeset for help on using the changeset viewer.