Changes in / [bfc12ef:ff244e6] in mainline


Ignore:
Location:
uspace
Files:
6 edited

Legend:

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

    rbfc12ef rff244e6  
    3737#include <usb/usbdrv.h>
    3838
    39 
    4039#include "usbhub.h"
    4140#include "usbhub_private.h"
     
    6564int main(int argc, char *argv[])
    6665{
    67         usb_dprintf_enable(NAME, USB_LOG_LEVEL_INFO);
     66        usb_dprintf_enable(NAME, 0);
    6867       
    6968        fibril_mutex_initialize(&usb_hub_list_lock);
  • uspace/drv/usbhub/usbhub.c

    rbfc12ef rff244e6  
    7070
    7171
    72         dprintf(USB_LOG_LEVEL_DEBUG, "phone to hc = %d", hc);
     72        //printf("[usb_hub] phone to hc = %d\n", hc);
    7373        if (hc < 0) {
    7474                return result;
     
    7676        //get some hub info
    7777        usb_address_t addr = usb_drv_get_my_address(hc, device);
    78         dprintf(USB_LOG_LEVEL_DEBUG, "address of newly created hub = %d", addr);
     78        dprintf(1, "address of newly created hub = %d", addr);
    7979        /*if(addr<0){
    8080                //return result;
     
    8787        // get hub descriptor
    8888
    89         dprintf(USB_LOG_LEVEL_DEBUG, "creating serialized descripton");
     89        //printf("[usb_hub] creating serialized descriptor\n");
    9090        void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
    9191        usb_hub_descriptor_t * descriptor;
    9292        size_t received_size;
    9393        int opResult;
    94         dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction");
     94        //printf("[usb_hub] starting control transaction\n");
    9595       
    9696        opResult = usb_drv_req_get_descriptor(hc, addr,
     
    100100
    101101        if (opResult != EOK) {
    102                 dprintf(USB_LOG_LEVEL_ERROR, "failed when receiving hub descriptor, badcode = %d",opResult);
     102                dprintf(1, "failed when receiving hub descriptor, badcode = %d",opResult);
    103103                free(serialized_descriptor);
    104104                return result;
    105105        }
    106         dprintf(USB_LOG_LEVEL_DEBUG2, "deserializing descriptor");
     106        //printf("[usb_hub] deserializing descriptor\n");
    107107        descriptor = usb_deserialize_hub_desriptor(serialized_descriptor);
    108108        if(descriptor==NULL){
    109                 dprintf(USB_LOG_LEVEL_WARNING, "could not deserialize descriptor ");
     109                dprintf(1, "could not deserialize descriptor ");
    110110                result->port_count = 1;///\TODO this code is only for debug!!!
    111111                return result;
    112112        }
    113         dprintf(USB_LOG_LEVEL_INFO, "setting port count to %d",descriptor->ports_count);
     113        //printf("[usb_hub] setting port count to %d\n",descriptor->ports_count);
    114114        result->port_count = descriptor->ports_count;
    115115        result->attached_devs = (usb_hub_attached_device_t*)
     
    120120                result->attached_devs[i].address=0;
    121121        }
    122         dprintf(USB_LOG_LEVEL_DEBUG2, "freeing data");
     122        //printf("[usb_hub] freeing data\n");
    123123        free(serialized_descriptor);
    124124        free(descriptor->devices_removable);
     
    127127        //finish
    128128
    129         dprintf(USB_LOG_LEVEL_INFO, "hub info created");
     129        dprintf(1, "hub info created");
    130130
    131131        return result;
     
    133133
    134134int usb_add_hub_device(device_t *dev) {
    135         dprintf(USB_LOG_LEVEL_INFO, "add_hub_device(handle=%d)", (int) dev->handle);
     135        dprintf(1, "add_hub_device(handle=%d)", (int) dev->handle);
     136        dprintf(1, "hub device");
    136137
    137138        /*
     
    163164            &std_descriptor);
    164165        if(opResult!=EOK){
    165                 dprintf(USB_LOG_LEVEL_ERROR, "could not get device descriptor, %d",opResult);
     166                dprintf(1, "could not get device descriptor, %d",opResult);
    166167                return opResult;
    167168        }
    168         dprintf(USB_LOG_LEVEL_INFO, "hub has %d configurations",std_descriptor.configuration_count);
     169        dprintf(1, "hub has %d configurations",std_descriptor.configuration_count);
    169170        if(std_descriptor.configuration_count<1){
    170                 dprintf(USB_LOG_LEVEL_ERROR, "THERE ARE NO CONFIGURATIONS AVAILABLE");
     171                dprintf(1, "THERE ARE NO CONFIGURATIONS AVAILABLE");
    171172                //shouldn`t I return?
    172173        }
     
    177178        &config_descriptor);
    178179        if(opResult!=EOK){
    179                 dprintf(USB_LOG_LEVEL_ERROR, "could not get configuration descriptor, %d",opResult);
     180                dprintf(1, "could not get configuration descriptor, %d",opResult);
    180181                return opResult;
    181182        }
     
    185186
    186187        if (opResult != EOK) {
    187                 dprintf(USB_LOG_LEVEL_ERROR, "something went wrong when setting hub`s configuration, %d", opResult);
     188                dprintf(1, "something went wrong when setting hub`s configuration, %d", opResult);
    188189        }
    189190
     
    192193                usb_hub_set_power_port_request(&request, port);
    193194                opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
    194                 dprintf(USB_LOG_LEVEL_INFO, "powering port %d",port);
     195                dprintf(1, "powering port %d",port);
    195196                if (opResult != EOK) {
    196                         dprintf(USB_LOG_LEVEL_WARNING, "something went wrong when setting hub`s %dth port", port);
     197                        dprintf(1, "something went wrong when setting hub`s %dth port", port);
    197198                }
    198199        }
     
    206207        fibril_mutex_unlock(&usb_hub_list_lock);
    207208
    208         dprintf(USB_LOG_LEVEL_DEBUG, "hub info added to list");
     209        dprintf(1, "hub info added to list");
    209210        //(void)hub_info;
    210211        usb_hub_check_hub_changes();
     
    212213       
    213214
    214         dprintf(USB_LOG_LEVEL_INFO, "hub dev added");
    215         dprintf(USB_LOG_LEVEL_DEBUG, "\taddress %d, has %d ports ",
     215        dprintf(1, "hub dev added");
     216        dprintf(1, "\taddress %d, has %d ports ",
    216217                        hub_info->usb_device->address,
    217218                        hub_info->port_count);
    218         dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d",config_descriptor.configuration_number);
     219        dprintf(1, "\tused configuration %d",config_descriptor.configuration_number);
    219220
    220221        return EOK;
     
    237238inline static int usb_hub_release_default_address(int hc){
    238239        int opResult;
    239         dprintf(USB_LOG_LEVEL_INFO, "releasing default address");
     240        dprintf(1, "releasing default address");
    240241        opResult = usb_drv_release_default_address(hc);
    241242        if (opResult != EOK) {
    242                 dprintf(USB_LOG_LEVEL_WARNING, "failed to release default address");
     243                dprintf(1, "failed to release default address");
    243244        }
    244245        return opResult;
     
    254255        usb_device_request_setup_packet_t request;
    255256        int opResult;
    256         dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
     257        dprintf(1, "some connection changed");
    257258        //get default address
    258259        opResult = usb_drv_reserve_default_address(hc);
    259260        if (opResult != EOK) {
    260                 dprintf(USB_LOG_LEVEL_WARNING, "cannot assign default address, it is probably used");
     261                dprintf(1, "cannot assign default address, it is probably used");
    261262                return;
    262263        }
     
    269270                        );
    270271        if (opResult != EOK) {
    271                 dprintf(USB_LOG_LEVEL_ERROR, "something went wrong when reseting a port");
     272                dprintf(1, "something went wrong when reseting a port");
    272273                usb_hub_release_default_address(hc);
    273274        }
     
    284285
    285286        int opResult;
    286         dprintf(USB_LOG_LEVEL_INFO, "finalizing add device");
     287        dprintf(1, "finalizing add device");
    287288        opResult = usb_hub_clear_port_feature(hc, target.address,
    288289            port, USB_HUB_FEATURE_C_PORT_RESET);
    289290        if (opResult != EOK) {
    290                 dprintf(USB_LOG_LEVEL_ERROR, "failed to clear port reset feature");
     291                dprintf(1, "failed to clear port reset feature");
    291292                usb_hub_release_default_address(hc);
    292293                return;
     
    296297        usb_address_t new_device_address = usb_drv_request_address(hc);
    297298        if (new_device_address < 0) {
    298                 dprintf(USB_LOG_LEVEL_ERROR, "failed to get free USB address");
     299                dprintf(1, "failed to get free USB address");
    299300                opResult = new_device_address;
    300301                usb_hub_release_default_address(hc);
    301302                return;
    302303        }
    303         dprintf(USB_LOG_LEVEL_INFO, "setting new address %d",new_device_address);
     304        dprintf(1, "setting new address");
    304305        opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
    305306            new_device_address);
    306307
    307308        if (opResult != EOK) {
    308                 dprintf(USB_LOG_LEVEL_ERROR, "could not set address for new device");
     309                dprintf(1, "could not set address for new device");
    309310                usb_hub_release_default_address(hc);
    310311                return;
     
    321322            new_device_address, &child_handle);
    322323        if (opResult != EOK) {
    323                 dprintf(USB_LOG_LEVEL_ERROR, "could not start driver for new device");
     324                dprintf(1, "could not start driver for new device");
    324325                return;
    325326        }
     
    329330        opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
    330331        if (opResult != EOK) {
    331                 dprintf(USB_LOG_LEVEL_ERROR, "could not assign address of device in hcd");
    332                 return;
    333         }
    334         dprintf(USB_LOG_LEVEL_INFO, "new device address %d, handle %zu",
     332                dprintf(1, "could not assign address of device in hcd");
     333                return;
     334        }
     335        dprintf(1, "new device address %d, handle %zu",
    335336            new_device_address, child_handle);
    336337
     
    357358                opResult = usb_drv_release_address(hc,hub->attached_devs[port].address);
    358359                if(opResult != EOK) {
    359                         dprintf(USB_LOG_LEVEL_WARNING, "could not release address of " \
     360                        dprintf(1, "could not release address of " \
    360361                            "removed device: %d", opResult);
    361362                }
    362363                hub->attached_devs[port].address = 0;
    363364        }else{
    364                 dprintf(USB_LOG_LEVEL_WARNING, "this is strange, disconnected device had no address");
     365                dprintf(1, "this is strange, disconnected device had no address");
    365366                //device was disconnected before it`s port was reset - return default address
    366367                usb_drv_release_default_address(hc);
     
    376377static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,
    377378        uint16_t port, usb_address_t address) {
    378         dprintf(USB_LOG_LEVEL_DEBUG, "interrupt at port %d", port);
     379        dprintf(1, "interrupt at port %d", port);
    379380        //determine type of change
    380381        usb_target_t target;
     
    394395                        );
    395396        if (opResult != EOK) {
    396                 dprintf(USB_LOG_LEVEL_ERROR, "ERROR: could not get port status");
     397                dprintf(1, "ERROR: could not get port status");
    397398                return;
    398399        }
    399400        if (rcvd_size != sizeof (usb_port_status_t)) {
    400                 dprintf(USB_LOG_LEVEL_ERROR, "ERROR: received status has incorrect size");
     401                dprintf(1, "ERROR: received status has incorrect size");
    401402                return;
    402403        }
     
    407408                // TODO: check opResult
    408409                if (usb_port_dev_connected(&status)) {
    409                         dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
     410                        dprintf(1, "some connection changed");
    410411                        usb_hub_init_add_device(hc, port, target);
    411412                } else {
     
    415416        //port reset
    416417        if (usb_port_reset_completed(&status)) {
    417                 dprintf(USB_LOG_LEVEL_INFO, "port reset complete");
     418                dprintf(1, "port reset complete");
    418419                if (usb_port_enabled(&status)) {
    419420                        usb_hub_finalize_add_device(hub, hc, port, target);
    420421                } else {
    421                         dprintf(USB_LOG_LEVEL_WARNING, "ERROR: port reset, but port still not enabled");
     422                        dprintf(1, "ERROR: port reset, but port still not enabled");
    422423                }
    423424        }
     
    428429        usb_port_set_dev_connected(&status, false);
    429430        if (status>>16) {
    430                 dprintf(USB_LOG_LEVEL_INFO, "there was some unsupported change on port %d: %X",port,status);
     431                dprintf(1, "there was some unsupported change on port %d: %X",port,status);
    431432
    432433        }
     
    457458                target.address = hub_info->usb_device->address;
    458459                target.endpoint = 1;/// \TODO get from endpoint descriptor
    459                 dprintf(USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d",
     460                dprintf(1, "checking changes for hub at addr %d",
    460461                    target.address);
    461462
     
    488489                if (opResult != EOK) {
    489490                        free(change_bitmap);
    490                         dprintf(USB_LOG_LEVEL_WARNING, "something went wrong while getting status of hub");
     491                        dprintf(1, "something went wrong while getting status of hub");
    491492                        continue;
    492493                }
  • uspace/drv/usbhub/usbhub_private.h

    rbfc12ef rff244e6  
    6161//************
    6262//
    63 // convenience debug printf for usb hub
     63// convenience debug printf
    6464//
    6565//************
    6666#define dprintf(level, format, ...) \
    6767        usb_dprintf(NAME, (level), format "\n", ##__VA_ARGS__)
    68 
    6968
    7069/**
  • uspace/drv/usbhub/utils.c

    rbfc12ef rff244e6  
    116116
    117117int usb_drv_sync_control_read(
    118     int phone, usb_target_t target,
    119     usb_device_request_setup_packet_t * request,
    120     void * rcvd_buffer, size_t rcvd_size, size_t * actual_size
    121 ) {
     118                int phone, usb_target_t target,
     119                usb_device_request_setup_packet_t * request,
     120                void * rcvd_buffer, size_t rcvd_size, size_t * actual_size
     121                ) {
    122122        usb_handle_t handle;
    123123        int opResult;
    124124        //setup
    125125        opResult = usb_drv_async_control_read_setup(phone, target,
    126             request, sizeof (usb_device_request_setup_packet_t),
    127             &handle);
     126                        request, sizeof (usb_device_request_setup_packet_t),
     127                        &handle);
    128128        if (opResult != EOK) {
    129129                return opResult;
     
    158158
    159159int usb_drv_sync_control_write(
    160     int phone, usb_target_t target,
    161     usb_device_request_setup_packet_t * request,
    162     void * sent_buffer, size_t sent_size
    163 ) {
     160                int phone, usb_target_t target,
     161                usb_device_request_setup_packet_t * request,
     162                void * sent_buffer, size_t sent_size
     163                ) {
    164164        usb_handle_t handle;
    165165        int opResult;
    166166        //setup
    167167        opResult = usb_drv_async_control_write_setup(phone, target,
    168             request, sizeof (usb_device_request_setup_packet_t),
    169             &handle);
     168                        request, sizeof (usb_device_request_setup_packet_t),
     169                        &handle);
    170170        if (opResult != EOK) {
    171171                return opResult;
     
    188188        //finalize
    189189        opResult = usb_drv_async_control_write_status(phone, target,
    190             &handle);
     190                        &handle);
    191191        if (opResult != EOK) {
    192192                return opResult;
  • uspace/lib/usb/include/usb/usbmem.h

    rbfc12ef rff244e6  
    11/*
    2  * Copyright (c) 2011 Matus Dekanek
     2 * Copyright (c) 2010 Matus Dekanek
    33 * All rights reserved.
    44 *
     
    3535 * @{
    3636 */
    37 /** @file definitions of memory management with address translation, used mostly in usb stack
     37/** @file definitions of special memory management, used mostly in usb stack
    3838 *
    3939 * USB HCD needs traslation between physical and virtual addresses. These
     
    5959
    6060extern void * mman_malloc(
    61     size_t size,
    62     size_t alignment,
    63     unsigned long max_physical_address);
     61                size_t size,
     62                size_t alignment,
     63                unsigned long max_physical_address);
    6464
    6565extern void * mman_getVA(void * addr);
  • uspace/lib/usb/src/usbmem.c

    rbfc12ef rff244e6  
    11/*
    2  * Copyright (c) 2011 Matus Dekanek
     2 * Copyright (c) 2010 Matus Dekanek
    33 * All rights reserved.
    44 *
     
    6969}
    7070
    71 static void addr_remove_callback(link_t * item)
     71static void addr_remove_callback(link_t *item)
    7272{
    7373        //delete item
Note: See TracChangeset for help on using the changeset viewer.