Changes in / [c7dd69d:da1dd48] in mainline


Ignore:
Location:
uspace
Files:
5 added
50 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/usbinfo/dev.c

    rc7dd69d rda1dd48  
    7777        }
    7878
    79         rc = usb_pipe_start_long_transfer(&dev->ctrl_pipe);
    80         if (rc != EOK) {
    81                 fprintf(stderr,
    82                     NAME ": failed to start transfer on control pipe: %s.\n",
    83                     str_error(rc));
    84                 goto leave;
    85         }
     79        usb_pipe_start_long_transfer(&dev->ctrl_pipe);
    8680        transfer_started = true;
    8781
  • uspace/drv/ehci-hcd/main.c

    rc7dd69d rda1dd48  
    8282            pci_get_my_registers(device, &mem_reg_base, &mem_reg_size, &irq);
    8383        CHECK_RET_RETURN(ret,
    84             "Failed(%d) to get memory addresses:.\n", ret, device->handle);
    85         usb_log_info("Memory mapped regs at 0x%X (size %zu), IRQ %d.\n",
     84            "Failed to get memory addresses for %" PRIun ": %s.\n",
     85            device->handle, str_error(ret));
     86        usb_log_info("Memory mapped regs at 0x%" PRIxn " (size %zu), IRQ %d.\n",
    8687            mem_reg_base, mem_reg_size, irq);
    8788
     
    102103            str_error(ret));
    103104
    104         usb_log_info("Controlling new EHCI device `%s' (handle %llu).\n",
     105        usb_log_info("Controlling new EHCI device `%s' (handle %" PRIun ").\n",
    105106            device->name, device->handle);
    106107
  • uspace/drv/ehci-hcd/pci.c

    rc7dd69d rda1dd48  
    117117                                mem_address = res->res.mem_range.address;
    118118                                mem_size = res->res.mem_range.size;
    119                                 usb_log_debug2("Found mem: %llx %zu.\n",
     119                                usb_log_debug2("Found mem: %" PRIxn" %zu.\n",
    120120                                    mem_address, mem_size);
    121121                                mem_found = true;
     
    186186        CHECK_RET_HANGUP_RETURN(ret, "Failed(%d) to read PCI config space.\n",
    187187            ret);
    188         usb_log_info("Register space BAR at %p:%x.\n", address, value);
     188        usb_log_info("Register space BAR at %p:%" PRIxn ".\n", (void *) address, value);
    189189
    190190        /* clear lower byte, it's not part of the BASE address */
    191191        uintptr_t registers = (value & 0xffffff00);
    192         usb_log_info("Memory registers BASE address:%p.\n", registers);
     192        usb_log_info("Memory registers BASE address:%p.\n", (void *) registers);
    193193
    194194        /* if nothing setup the hc, we don't need to turn it off */
     
    201201            AS_AREA_READ | AS_AREA_WRITE);
    202202        CHECK_RET_HANGUP_RETURN(ret, "Failed(%d) to map registers %p:%p.\n",
    203             ret, regs, registers);
     203            ret, regs, (void *) registers);
    204204
    205205        /* calculate value of BASE */
     
    221221            IPC_M_CONFIG_SPACE_READ_32, eecp + USBLEGCTLSTS_OFFSET, &value);
    222222        CHECK_RET_HANGUP_RETURN(ret, "Failed(%d) to read USBLEGCTLSTS.\n", ret);
    223         usb_log_debug("USBLEGCTLSTS: %x.\n", value);
     223        usb_log_debug("USBLEGCTLSTS: %" PRIxn ".\n", value);
    224224
    225225        /* Read the first EEC. i.e. Legacy Support register */
     
    228228            IPC_M_CONFIG_SPACE_READ_32, eecp + USBLEGSUP_OFFSET, &value);
    229229        CHECK_RET_HANGUP_RETURN(ret, "Failed(%d) to read USBLEGSUP.\n", ret);
    230         usb_log_debug2("USBLEGSUP: %x.\n", value);
     230        usb_log_debug2("USBLEGSUP: %" PRIxn ".\n", value);
    231231
    232232        /* Request control from firmware/BIOS, by writing 1 to highest byte.
     
    248248
    249249        if ((value & USBLEGSUP_BIOS_CONTROL) == 0) {
    250                 usb_log_info("BIOS released control after %d usec.\n", wait);
     250                usb_log_info("BIOS released control after %zu usec.\n", wait);
    251251        } else {
    252252                /* BIOS failed to hand over control, this should not happen. */
    253253                usb_log_warning( "BIOS failed to release control after "
    254                     "%d usecs, force it.\n", wait);
     254                    "%zu usecs, force it.\n", wait);
    255255                ret = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE),
    256256                    IPC_M_CONFIG_SPACE_WRITE_32, eecp + USBLEGSUP_OFFSET,
     
    271271            IPC_M_CONFIG_SPACE_READ_32, eecp + USBLEGCTLSTS_OFFSET, &value);
    272272        CHECK_RET_HANGUP_RETURN(ret, "Failed(%d) to read USBLEGCTLSTS.\n", ret);
    273         usb_log_debug2("USBLEGCTLSTS: %x.\n", value);
     273        usb_log_debug2("USBLEGCTLSTS: %" PRIxn ".\n", value);
    274274
    275275        /* Read again Legacy Support register */
     
    277277            IPC_M_CONFIG_SPACE_READ_32, eecp + USBLEGSUP_OFFSET, &value);
    278278        CHECK_RET_HANGUP_RETURN(ret, "Failed(%d) to read USBLEGSUP.\n", ret);
    279         usb_log_debug2("USBLEGSUP: %x.\n", value);
     279        usb_log_debug2("USBLEGSUP: %" PRIxn ".\n", value);
    280280
    281281        /*
  • uspace/drv/ohci/batch.c

    rc7dd69d rda1dd48  
    141141        assert(data);
    142142        size_t tds = data->td_count;
    143         usb_log_debug("Batch(%p) checking %d td(s) for completion.\n",
     143        usb_log_debug("Batch(%p) checking %zu td(s) for completion.\n",
    144144            instance, tds);
    145145        usb_log_debug("ED: %x:%x:%x:%x.\n",
     
    147147            data->ed->next);
    148148        size_t i = 0;
     149        instance->transfered_size = instance->buffer_size;
    149150        for (; i < tds; ++i) {
    150151                assert(data->tds[i] != NULL);
    151                 usb_log_debug("TD %d: %x:%x:%x:%x.\n", i,
     152                usb_log_debug("TD %zu: %x:%x:%x:%x.\n", i,
    152153                    data->tds[i]->status, data->tds[i]->cbp, data->tds[i]->next,
    153154                    data->tds[i]->be);
     
    156157                }
    157158                instance->error = td_error(data->tds[i]);
    158                 /* FIXME: calculate real transfered size */
    159                 instance->transfered_size = instance->buffer_size;
    160159                if (instance->error != EOK) {
    161                         usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
     160                        usb_log_debug("Batch(%p) found error TD(%zu):%x.\n",
    162161                            instance, i, data->tds[i]->status);
    163162                        /* Make sure TD queue is empty (one TD),
     
    174173        assert(hcd_ep);
    175174        hcd_ep->td = data->tds[i];
     175        if (i > 0)
     176                instance->transfered_size -= td_remain_size(data->tds[i - 1]);
     177
    176178        /* Clear possible ED HALT */
    177179        data->ed->td_head &= ~ED_TDHEAD_HALTED_FLAG;
     
    238240{
    239241        assert(instance);
    240         instance->next_step = usb_transfer_batch_call_in_and_dispose;
     242        /* We are data out, we are supposed to provide data */
     243        memcpy(instance->data_buffer, instance->buffer, instance->buffer_size);
     244        instance->next_step = usb_transfer_batch_call_out_and_dispose;
    241245        batch_data(instance);
    242         usb_log_debug("Batch(%p) BULK IN initialized.\n", instance);
     246        usb_log_debug("Batch(%p) BULK OUT initialized.\n", instance);
    243247}
    244248/*----------------------------------------------------------------------------*/
  • uspace/drv/ohci/endpoint_list.c

    rc7dd69d rda1dd48  
    5555        }
    5656        instance->list_head_pa = addr_to_phys(instance->list_head);
    57         usb_log_debug2("Transfer list %s setup with ED: %p(%p).\n",
     57        usb_log_debug2("Transfer list %s setup with ED: %p(0x%0" PRIx32 ")).\n",
    5858            name, instance->list_head, instance->list_head_pa);
    5959
     
    121121                hcd_ep, instance->name, first, first->ed);
    122122        if (last_ed == instance->list_head) {
    123                 usb_log_debug2("%s head ED(%p-%p): %x:%x:%x:%x.\n",
     123                usb_log_debug2("%s head ED(%p-0x%0" PRIx32 "): %x:%x:%x:%x.\n",
    124124                    instance->name, last_ed, instance->list_head_pa,
    125125                    last_ed->status, last_ed->td_tail, last_ed->td_head,
  • uspace/drv/ohci/hc.c

    rc7dd69d rda1dd48  
    113113            BANDWIDTH_AVAILABLE_USB11);
    114114        CHECK_RET_RETURN(ret, "Failed to initialize endpoint manager: %s.\n",
    115             ret, str_error(ret));
     115            str_error(ret));
    116116
    117117        hc_gain_control(instance);
    118118        ret = hc_init_memory(instance);
    119         CHECK_RET_RETURN(ret, "Failed to create OHCI memory structures:%s.\n",
    120             ret, str_error(ret));
     119        CHECK_RET_RETURN(ret, "Failed to create OHCI memory structures: %s.\n",
     120            str_error(ret));
    121121        hc_init_hw(instance);
    122122        fibril_mutex_initialize(&instance->guard);
     
    294294        if (status & IS_WDH) {
    295295                fibril_mutex_lock(&instance->guard);
    296                 usb_log_debug2("HCCA: %p-%p(%p).\n", instance->hcca,
    297                     instance->registers->hcca, addr_to_phys(instance->hcca));
    298                 usb_log_debug2("Periodic current: %p.\n",
     296                usb_log_debug2("HCCA: %p-%#" PRIx32 " (%p).\n", instance->hcca,
     297                    instance->registers->hcca,
     298                    (void *) addr_to_phys(instance->hcca));
     299                usb_log_debug2("Periodic current: %#" PRIx32 ".\n",
    299300                    instance->registers->periodic_current);
    300301
     
    405406        instance->registers->bulk_head =
    406407            instance->lists[USB_TRANSFER_BULK].list_head_pa;
    407         usb_log_debug2("Bulk HEAD set to: %p(%p).\n",
     408        usb_log_debug2("Bulk HEAD set to: %p (%#" PRIx32 ").\n",
    408409            instance->lists[USB_TRANSFER_BULK].list_head,
    409410            instance->lists[USB_TRANSFER_BULK].list_head_pa);
     
    411412        instance->registers->control_head =
    412413            instance->lists[USB_TRANSFER_CONTROL].list_head_pa;
    413         usb_log_debug2("Control HEAD set to: %p(%p).\n",
     414        usb_log_debug2("Control HEAD set to: %p (%#" PRIx32 ").\n",
    414415            instance->lists[USB_TRANSFER_CONTROL].list_head,
    415416            instance->lists[USB_TRANSFER_CONTROL].list_head_pa);
     
    487488                    instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa;
    488489        }
    489         usb_log_debug2("Interrupt HEADs set to: %p(%p).\n",
     490        usb_log_debug2("Interrupt HEADs set to: %p (%#" PRIx32 ").\n",
    490491            instance->lists[USB_TRANSFER_INTERRUPT].list_head,
    491492            instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa);
  • uspace/drv/ohci/hw_struct/transfer_descriptor.c

    rc7dd69d rda1dd48  
    5252                instance->status |= togg[toggle] << TD_STATUS_T_SHIFT;
    5353        }
     54        if (dir == USB_DIRECTION_IN) {
     55                instance->status |= TD_STATUS_ROUND_FLAG;
     56        }
    5457        if (buffer != NULL) {
    5558                assert(size != 0);
  • uspace/drv/ohci/hw_struct/transfer_descriptor.h

    rc7dd69d rda1dd48  
    5959#define TD_STATUS_T_0 (0x2)
    6060#define TD_STATUS_T_1 (0x3)
     61#define TD_STATUS_T_ED (0)
    6162#define TD_STATUS_EC_MASK (0x3) /* error count */
    6263#define TD_STATUS_EC_SHIFT (26)
     
    102103        return cc_to_rc(cc);
    103104}
     105
     106static inline size_t td_remain_size(td_t *instance)
     107{
     108        assert(instance);
     109        if (instance->cbp == 0)
     110                return 0;
     111        return instance->be - instance->cbp + 1;
     112}
    104113#endif
    105114/**
  • uspace/drv/ohci/iface.c

    rc7dd69d rda1dd48  
    118118        hc_t *hc = fun_to_hc(fun);
    119119        assert(hc);
    120         usb_log_debug("Address bind %d-%d.\n", address, handle);
     120        usb_log_debug("Address bind %d-%" PRIun ".\n", address, handle);
    121121        usb_device_keeper_bind(&hc->manager, address, handle);
    122122        return EOK;
  • uspace/drv/ohci/ohci.c

    rc7dd69d rda1dd48  
    148148            pci_get_my_registers(device, &mem_reg_base, &mem_reg_size, &irq);
    149149        CHECK_RET_DEST_FUN_RETURN(ret,
    150             "Failed(%d) to get memory addresses:.\n", ret, device->handle);
    151         usb_log_debug("Memory mapped regs at 0x%X (size %zu), IRQ %d.\n",
    152             mem_reg_base, mem_reg_size, irq);
     150            "Failed to get memory addresses for %" PRIun ": %s.\n",
     151            device->handle, str_error(ret));
     152        usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n",
     153            (void *) mem_reg_base, mem_reg_size, irq);
    153154
    154155        ret = pci_disable_legacy(device);
  • uspace/drv/ohci/pci.c

    rc7dd69d rda1dd48  
    117117                                mem_address = res->res.mem_range.address;
    118118                                mem_size = res->res.mem_range.size;
    119                                 usb_log_debug2("Found mem: %llx %zu.\n",
    120                                     mem_address, mem_size);
     119                                usb_log_debug2("Found mem: %p %zu.\n",
     120                                    (void *) mem_address, mem_size);
    121121                                mem_found = true;
    122122                                }
  • uspace/drv/ohci/root_hub.c

    rc7dd69d rda1dd48  
    198198static int process_ctrl_request(rh_t *instance, usb_transfer_batch_t *request);
    199199
    200 
     200static int process_interrupt(rh_t *instance, usb_transfer_batch_t * request,
     201    void * change_buffer, size_t buffe_size);
     202
     203static bool is_zeros(void * buffer, size_t size);
    201204
    202205
     
    213216        // set port power mode to no-power-switching
    214217        instance->registers->rh_desc_a |= RHDA_NPS_FLAG;
    215 
     218        instance->unfinished_interrupt_transfer = NULL;
    216219        usb_log_info("OHCI root hub with %d ports.\n", instance->port_count);
    217220        return EOK;
     
    233236                usb_log_info("Root hub got CONTROL packet\n");
    234237                opResult = process_ctrl_request(instance, request);
     238                usb_transfer_batch_finish_error(request, opResult);
    235239        } else if (request->ep->transfer_type == USB_TRANSFER_INTERRUPT) {
    236240                usb_log_info("Root hub got INTERRUPT packet\n");
    237241                void * buffer;
     242                size_t buffer_size;
    238243                create_interrupt_mask(instance, &buffer,
    239                         &(request->transfered_size));
    240                 memcpy(request->data_buffer, buffer,
    241                         request->transfered_size);
     244                        &buffer_size);
     245                if(is_zeros(buffer,buffer_size)){
     246                        usb_log_debug("no changes..");
     247                        instance->unfinished_interrupt_transfer=
     248                            request;
     249                        //will be finished later
     250                }else{
     251                        usb_log_debug("processing changes..");
     252                        process_interrupt(instance, request,
     253                            buffer, buffer_size);
     254                }
     255                free(buffer);
    242256                opResult = EOK;
    243257        } else {
    244258                opResult = EINVAL;
    245         }
    246         usb_transfer_batch_finish_error(request, opResult);
     259                usb_transfer_batch_finish_error(request, opResult);
     260        }
    247261        return EOK;
    248262}
     
    252266
    253267void rh_interrupt(rh_t *instance) {
    254         usb_log_info("Whoa whoa wait, I`m not supposed to receive any "
    255                 "interrupts, am I?\n");
    256         /* TODO: implement? */
     268        //usb_log_info("Whoa whoa wait, I`m not supposed to receive any "
     269        //      "interrupts, am I?\n");
     270        if(!instance->unfinished_interrupt_transfer){
     271                return;
     272        }
     273        size_t size;
     274        void * buffer;
     275        create_interrupt_mask(instance, &buffer,
     276                        &size);
     277        process_interrupt(instance,instance->unfinished_interrupt_transfer,
     278            buffer,size);
     279        free(buffer);
    257280}
    258281/*----------------------------------------------------------------------------*/
     
    859882        return opResult;
    860883}
     884/*----------------------------------------------------------------------------*/
     885
     886/**
     887 * process hanging interrupt request
     888 *
     889 * If an interrupt transfer has been received and there was no change,
     890 * the driver stores the transfer information and waits for change to occcur.
     891 * This routine is called when that happens and it finalizes the interrupt
     892 * transfer.
     893 *
     894 * @param instance hub instance
     895 * @param request batch request to be processed
     896 * @param change_buffer chages on hub
     897 * @param buffer_size size of change buffer
     898 *
     899 * @return
     900 */
     901static int process_interrupt(rh_t *instance, usb_transfer_batch_t * request,
     902    void * change_buffer, size_t buffe_size){
     903        create_interrupt_mask(instance, &change_buffer,
     904            &(request->transfered_size));
     905        memcpy(request->data_buffer, change_buffer,request->transfered_size);
     906        instance->unfinished_interrupt_transfer = NULL;
     907        usb_transfer_batch_finish_error(request, EOK);
     908        return EOK;
     909}
     910
     911/*----------------------------------------------------------------------------*/
     912
     913/**
     914 * return whether the buffer is full of zeros
     915 *
     916 * Convenience function.
     917 * @param buffer
     918 * @param size
     919 * @return
     920 */
     921static bool is_zeros(void * buffer, size_t size){
     922        if(!buffer) return true;
     923        if(!size) return true;
     924        size_t i;
     925        for(i=0;i<size;++i){
     926                if(((char*)buffer)[i])
     927                        return false;
     928        }
     929        return true;
     930}
    861931
    862932/**
  • uspace/drv/ohci/root_hub.h

    rc7dd69d rda1dd48  
    5454        /** hubs descriptors */
    5555        usb_device_descriptors_t descriptors;
     56        /** interrupt transfer waiting for an actual interrupt to occur */
     57        usb_transfer_batch_t * unfinished_interrupt_transfer;
    5658} rh_t;
    5759
  • uspace/drv/uhci-hcd/batch.c

    rc7dd69d rda1dd48  
    162162        assert(data);
    163163
    164         usb_log_debug2("Batch(%p) checking %d transfer(s) for completion.\n",
     164        usb_log_debug2("Batch(%p) checking %zu transfer(s) for completion.\n",
    165165            instance, data->td_count);
    166166        instance->transfered_size = 0;
     
    173173                instance->error = td_status(&data->tds[i]);
    174174                if (instance->error != EOK) {
    175                         usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
     175                        usb_log_debug("Batch(%p) found error TD(%zu):%" PRIx32 ".\n",
    176176                            instance, i, data->tds[i].status);
    177177                        td_print_status(&data->tds[i]);
  • uspace/drv/uhci-hcd/hc.c

    rc7dd69d rda1dd48  
    101101            ret, io, str_error(ret));
    102102        instance->registers = io;
    103         usb_log_debug("Device registers at %p(%u) accessible.\n",
     103        usb_log_debug("Device registers at %p (%zuB) accessible.\n",
    104104            io, reg_size);
    105105
     
    423423                if (frame_list != addr_to_phys(instance->frame_list)) {
    424424                        usb_log_debug("Framelist address: %p vs. %p.\n",
    425                             frame_list, addr_to_phys(instance->frame_list));
     425                            (void *) frame_list,
     426                            (void *) addr_to_phys(instance->frame_list));
    426427                }
    427428
     
    432433                uintptr_t real_pa = addr_to_phys(QH(interrupt));
    433434                if (expected_pa != real_pa) {
    434                         usb_log_debug("Interrupt QH: %p(frame: %d) vs. %p.\n",
    435                             expected_pa, frnum, real_pa);
     435                        usb_log_debug("Interrupt QH: %p (frame %d) vs. %p.\n",
     436                            (void *) expected_pa, frnum, (void *) real_pa);
    436437                }
    437438
     
    440441                if (expected_pa != real_pa) {
    441442                        usb_log_debug("Control Slow QH: %p vs. %p.\n",
    442                             expected_pa, real_pa);
     443                            (void *) expected_pa, (void *) real_pa);
    443444                }
    444445
     
    447448                if (expected_pa != real_pa) {
    448449                        usb_log_debug("Control Full QH: %p vs. %p.\n",
    449                             expected_pa, real_pa);
     450                            (void *) expected_pa, (void *) real_pa);
    450451                }
    451452
     
    454455                if (expected_pa != real_pa ) {
    455456                        usb_log_debug("Bulk QH: %p vs. %p.\n",
    456                             expected_pa, real_pa);
     457                            (void *) expected_pa, (void *) real_pa);
    457458                }
    458459                async_usleep(UHCI_DEBUGER_TIMEOUT);
  • uspace/drv/uhci-hcd/hw_struct/transfer_descriptor.c

    rc7dd69d rda1dd48  
    154154        assert(instance);
    155155        const uint32_t s = instance->status;
    156         usb_log_debug2("TD(%p) status(%#x):%s %d,%s%s%s%s%s%s%s%s%s%s%s %d.\n",
     156        usb_log_debug2("TD(%p) status(%#" PRIx32 "):%s %d,%s%s%s%s%s%s%s%s%s%s%s %zu.\n",
    157157            instance, instance->status,
    158158            (s & TD_STATUS_SPD_FLAG) ? " SPD," : "",
  • uspace/drv/uhci-hcd/iface.c

    rc7dd69d rda1dd48  
    118118        hc_t *hc = fun_to_hc(fun);
    119119        assert(hc);
    120         usb_log_debug("Address bind %d-%d.\n", address, handle);
     120        usb_log_debug("Address bind %d-%" PRIun ".\n", address, handle);
    121121        usb_device_keeper_bind(&hc->manager, address, handle);
    122122        return EOK;
  • uspace/drv/uhci-hcd/main.c

    rc7dd69d rda1dd48  
    7272        int ret = uhci_init(uhci, device);
    7373        if (ret != EOK) {
    74                 usb_log_error("Failed(%d) to initialize UHCI driver: %s.\n",
    75                     ret, str_error(ret));
     74                usb_log_error("Failed to initialize UHCI driver: %s.\n",
     75                    str_error(ret));
    7676                return ret;
    7777        }
  • uspace/drv/uhci-hcd/pci.c

    rc7dd69d rda1dd48  
    9090                        io_address = res->res.io_range.address;
    9191                        io_size = res->res.io_range.size;
    92                         usb_log_debug2("Found io: %llx %zu.\n",
     92                        usb_log_debug2("Found io: %" PRIx64" %zu.\n",
    9393                            res->res.io_range.address, res->res.io_range.size);
    9494                        io_found = true;
  • uspace/drv/uhci-hcd/transfer_list.c

    rc7dd69d rda1dd48  
    5858        }
    5959        uint32_t queue_head_pa = addr_to_phys(instance->queue_head);
    60         usb_log_debug2("Transfer list %s setup with QH: %p(%p).\n",
     60        usb_log_debug2("Transfer list %s setup with QH: %p (%#" PRIx32" ).\n",
    6161            name, instance->queue_head, queue_head_pa);
    6262
  • uspace/drv/uhci-hcd/uhci.c

    rc7dd69d rda1dd48  
    168168            pci_get_my_registers(device, &io_reg_base, &io_reg_size, &irq);
    169169        CHECK_RET_DEST_FUN_RETURN(ret,
    170             "Failed(%d) to get I/O addresses:.\n", ret, device->handle);
    171         usb_log_debug("I/O regs at 0x%X (size %zu), IRQ %d.\n",
    172             io_reg_base, io_reg_size, irq);
     170            "Failed to get I/O addresses for %" PRIun ": %s.\n",
     171            device->handle, str_error(ret));
     172        usb_log_debug("I/O regs at 0x%p (size %zu), IRQ %d.\n",
     173            (void *) io_reg_base, io_reg_size, irq);
    173174
    174175        ret = pci_disable_legacy(device);
  • uspace/drv/uhci-rhd/main.c

    rc7dd69d rda1dd48  
    11/*
    2  * Copyright (c) 2011 Vojtech Horky, Jan Vesely
     2 * Copyright (c) 2011 Jan Vesely
    33 * All rights reserved.
    44 *
     
    8484                return EINVAL;
    8585
    86         usb_log_debug2("%s called device %d\n", __FUNCTION__, device->handle);
     86        usb_log_debug2("uhci_rh_add_device(handle=%" PRIun ")\n",
     87            device->handle);
    8788
    8889        uintptr_t io_regs = 0;
     
    101102        ret = hc_get_my_registers(device, &io_regs, &io_size);
    102103        CHECK_RET_FREE_RH_RETURN(ret,
    103             "Failed(%d) to get registers from HC: %s.\n", ret, str_error(ret));
    104         usb_log_debug("I/O regs at %#x (size %zu).\n", io_regs, io_size);
     104            "Failed to get registers from HC: %s.\n", str_error(ret));
     105        usb_log_debug("I/O regs at %p (size %zuB).\n",
     106            (void *) io_regs, io_size);
    105107
    106108        rh = malloc(sizeof(uhci_root_hub_t));
     
    115117
    116118        device->driver_data = rh;
    117         usb_log_info("Controlling root hub '%s' (%llu).\n",
     119        usb_log_info("Controlling root hub '%s' (%" PRIun ").\n",
    118120            device->name, device->handle);
    119121        return EOK;
  • uspace/drv/uhci-rhd/port.c

    rc7dd69d rda1dd48  
    8989{
    9090        assert(port);
    91         asprintf(&port->id_string, "Port (%p - %d)", port, number);
     91        asprintf(&port->id_string, "Port (%p - %u)", port, number);
    9292        if (port->id_string == NULL) {
    9393                return ENOMEM;
     
    115115
    116116        fibril_add_ready(port->checker);
    117         usb_log_debug("%s: Started polling fibril(%x).\n",
     117        usb_log_debug("%s: Started polling fibril (%" PRIun ").\n",
    118118            port->id_string, port->checker);
    119119        return EOK;
     
    267267        }
    268268
    269         usb_log_info("New device at port %u, address %d (handle %llu).\n",
     269        usb_log_info("New device at port %u, address %d (handle %" PRIun ").\n",
    270270            port->number, dev_addr, port->attached_device);
    271271        return EOK;
     
    283283int uhci_port_remove_device(uhci_port_t *port)
    284284{
    285         usb_log_error("%s: Don't know how to remove device %llu.\n",
     285        usb_log_error("%s: Don't know how to remove device %" PRIun ".\n",
    286286            port->id_string, port->attached_device);
    287287        return ENOTSUP;
  • uspace/drv/usbflbk/main.c

    rc7dd69d rda1dd48  
    6565
    6666        usb_log_info("Pretending to control %s `%s'" \
    67             " (node `%s', handle %llu).\n",
     67            " (node `%s', handle %" PRIun ").\n",
    6868            dev->interface_no < 0 ? "device" : "interface",
    6969            dev->ddf_dev->name, fun_name, dev->ddf_dev->handle);
  • uspace/drv/usbhid/kbd/kbddev.c

    rc7dd69d rda1dd48  
    607607       
    608608        if (count != kbd_dev->key_count) {
    609                 usb_log_warning("Number of received keycodes (%d) differs from"
    610                     " expected number (%d).\n", count, kbd_dev->key_count);
     609                usb_log_warning("Number of received keycodes (%zu) differs from"
     610                    " expected (%zu).\n", count, kbd_dev->key_count);
    611611                return;
    612612        }
  • uspace/drv/usbhid/usbhid.c

    rc7dd69d rda1dd48  
    197197        size_t size = usb_hid_report_input_length(hid_dev->parser, usage_path,
    198198            mapping->compare);
    199         usb_log_debug("Size of the input report: %d\n", size);
     199        usb_log_debug("Size of the input report: %zuB\n", size);
    200200       
    201201        usb_hid_report_path_free(usage_path);
  • uspace/drv/usbhub/ports.c

    rc7dd69d rda1dd48  
    8383void usb_hub_process_interrupt(usb_hub_info_t * hub,
    8484        uint16_t port) {
    85         usb_log_debug("interrupt at port %d\n", port);
     85        usb_log_debug("interrupt at port %zu\n", (size_t) port);
    8686        //determine type of change
    8787        //usb_pipe_t *pipe = hub->control_pipe;
     
    9393        if (opResult != EOK) {
    9494                usb_log_error("Failed to get port %zu status: %s.\n",
    95                     port, str_error(opResult));
     95                    (size_t) port, str_error(opResult));
    9696                return;
    9797        }
     
    100100                bool device_connected = usb_port_is_status(status,
    101101                    USB_HUB_FEATURE_PORT_CONNECTION);
    102                 usb_log_debug("Connection change on port %zu: %s.\n", port,
     102                usb_log_debug("Connection change on port %zu: %s.\n",
     103                    (size_t) port,
    103104                    device_connected ? "device attached" : "device removed");
    104105
     
    109110                                usb_log_error(
    110111                                    "Cannot handle change on port %zu: %s.\n",
    111                                     str_error(opResult));
     112                                    (size_t) port, str_error(opResult));
    112113                        }
    113114                } else {
     
    210211static void usb_hub_port_reset_completed(usb_hub_info_t * hub,
    211212        uint16_t port, uint32_t status){
    212         usb_log_debug("Port %zu reset complete.\n", port);
     213        usb_log_debug("Port %zu reset complete.\n", (size_t) port);
    213214        if (usb_port_is_status(status, USB_HUB_FEATURE_PORT_ENABLE)) {
    214215                /* Finalize device adding. */
     
    222223                usb_log_warning(
    223224                    "Port %zu reset complete but port not enabled.\n",
    224                     port);
     225                    (size_t) port);
    225226        }
    226227}
  • uspace/drv/usbhub/usbhub.c

    rc7dd69d rda1dd48  
    105105        }
    106106
    107         usb_pipe_start_session(hub_info->control_pipe);
     107        //usb_pipe_start_session(hub_info->control_pipe);
    108108        //set hub configuration
    109109        opResult = usb_hub_set_configuration(hub_info);
     
    122122                return opResult;
    123123        }
    124         usb_pipe_end_session(hub_info->control_pipe);
    125 
    126         /// \TODO what is this?
    127         usb_log_debug("Creating `hub' function.\n");
     124        //usb_pipe_end_session(hub_info->control_pipe);
     125
     126
     127        usb_log_debug("Creating 'hub' function in DDF.\n");
    128128        ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev,
    129129            fun_exposed, "hub");
     
    153153bool hub_port_changes_callback(usb_device_t *dev,
    154154    uint8_t *change_bitmap, size_t change_bitmap_size, void *arg) {
     155        usb_log_debug("hub_port_changes_callback\n");
    155156        usb_hub_info_t *hub = (usb_hub_info_t *) arg;
    156157
     
    217218        // get hub descriptor
    218219        usb_log_debug("creating serialized descriptor\n");
    219         void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
     220        //void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
     221        uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE];
    220222        usb_hub_descriptor_t * descriptor;
    221223        int opResult;
     
    235237        }
    236238        usb_log_debug2("deserializing descriptor\n");
    237         descriptor = usb_deserialize_hub_desriptor(serialized_descriptor);
     239        descriptor = usb_create_deserialized_hub_desriptor(
     240            serialized_descriptor);
    238241        if (descriptor == NULL) {
    239242                usb_log_warning("could not deserialize descriptor \n");
    240                 return opResult;
     243                return ENOMEM;
    241244        }
    242245        usb_log_debug("setting port count to %d\n", descriptor->ports_count);
    243246        hub_info->port_count = descriptor->ports_count;
    244247        /// \TODO this is not semantically correct
     248        bool is_power_switched =
     249            ((descriptor->hub_characteristics & 1) ==0);
     250        bool has_individual_port_powering =
     251            ((descriptor->hub_characteristics & 1) !=0);
    245252        hub_info->ports = malloc(
    246253            sizeof (usb_hub_port_t) * (hub_info->port_count + 1));
     
    249256                usb_hub_port_init(&hub_info->ports[port]);
    250257        }
    251         for (port = 0; port < hub_info->port_count; port++) {
    252                 opResult = usb_hub_set_port_feature(hub_info->control_pipe,
    253                     port+1, USB_HUB_FEATURE_PORT_POWER);
    254                 if (opResult != EOK) {
    255                         usb_log_error("cannot power on port %d;  %d\n",
    256                             port+1, opResult);
    257                 }
     258        if(is_power_switched){
     259                usb_log_debug("is_power_switched\n");
     260                if(has_individual_port_powering){
     261                        usb_log_debug("has_individual_port_powering\n");
     262                        for (port = 0; port < hub_info->port_count; port++) {
     263                                opResult = usb_hub_set_port_feature(hub_info->control_pipe,
     264                                    port+1, USB_HUB_FEATURE_PORT_POWER);
     265                                if (opResult != EOK) {
     266                                        usb_log_error("cannot power on port %zu: %s.\n",
     267                                            port+1, str_error(opResult));
     268                                }
     269                        }
     270                }else{
     271                        usb_log_debug("!has_individual_port_powering\n");
     272                        opResult = usb_hub_set_feature(hub_info->control_pipe,
     273                            USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
     274                        if (opResult != EOK) {
     275                                usb_log_error("cannot power hub: %s\n",
     276                                    str_error(opResult));
     277                        }
     278                }
     279        }else{
     280                usb_log_debug("!is_power_switched\n");
    258281        }
    259282        usb_log_debug2("freeing data\n");
    260         free(serialized_descriptor);
    261         free(descriptor->devices_removable);
     283        //free(serialized_descriptor);
     284        //free(descriptor->devices_removable);
    262285        free(descriptor);
    263286        return EOK;
     
    321344         * auto destruction, this could work better.
    322345         */
    323         int rc = usb_pipe_start_session(hub_info->control_pipe);
     346        int rc = usb_hc_connection_open(&hub_info->connection);
    324347        if (rc != EOK) {
    325                 usb_log_error("Failed to start session on control pipe: %s.\n",
    326                     str_error(rc));
    327                 return rc;
    328         }
    329         rc = usb_hc_connection_open(&hub_info->connection);
    330         if (rc != EOK) {
    331                 usb_pipe_end_session(hub_info->control_pipe);
     348                //usb_pipe_end_session(hub_info->control_pipe);
    332349                usb_log_error("Failed to open connection to HC: %s.\n",
    333350                    str_error(rc));
     
    345362        }
    346363
    347         usb_log_info("Controlling hub `%s' (%d ports).\n",
     364        usb_log_info("Controlling hub `%s' (%zu ports).\n",
    348365            hub_info->usb_device->ddf_dev->name, hub_info->port_count);
    349366        return EOK;
     
    413430                            port, USB_HUB_FEATURE_PORT_POWER);
    414431                        if (opResult != EOK) {
    415                                 usb_log_error("cannot power on port %d;  %d\n",
    416                                     port, opResult);
     432                                usb_log_error("Cannot power on port %zu: %s.\n",
     433                                    port, str_error(opResult));
    417434                        }
    418435                }
  • uspace/drv/usbhub/usbhub_private.h

    rc7dd69d rda1dd48  
    113113
    114114        usb_device_request_setup_packet_t clear_request = {
    115                 .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
     115                .request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE,
    116116                .request = USB_DEVREQ_SET_FEATURE,
    117117                .length = 0,
     
    166166}
    167167
    168 /**
    169  * create uint8_t array with serialized descriptor
    170  *
    171  * @param descriptor
    172  * @return newly created serializd descriptor pointer
    173  */
    174 void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor);
    175168
    176 /**
    177  * create deserialized desriptor structure out of serialized descriptor
    178  *
    179  * The serialized descriptor must be proper usb hub descriptor,
    180  * otherwise an eerror might occur.
    181  *
    182  * @param sdescriptor serialized descriptor
    183  * @return newly created deserialized descriptor pointer
    184  */
    185 usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);
     169void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t * descriptor);
     170
     171void usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor,
     172    void * serialized_descriptor);
     173
     174usb_hub_descriptor_t * usb_create_deserialized_hub_desriptor(
     175    void * serialized_descriptor);
     176
     177void usb_deserialize_hub_desriptor(void * serialized_descriptor,
     178    usb_hub_descriptor_t * descriptor);
    186179
    187180
  • uspace/drv/usbhub/utils.c

    rc7dd69d rda1dd48  
    5656//hub descriptor utils
    5757
    58 void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor) {
     58/**
     59 * create uint8_t array with serialized descriptor
     60 *
     61 * @param descriptor
     62 * @return newly created serializd descriptor pointer
     63 */
     64void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t * descriptor) {
    5965        //base size
    6066        size_t size = 7;
     
    6470        uint8_t * result = malloc(size);
    6571        //size
    66         result[0] = size;
     72        if(result)
     73                usb_serialize_hub_descriptor(descriptor,result);
     74        return result;
     75}
     76
     77/**
     78 * serialize descriptor into given buffer
     79 *
     80 * The buffer size is not checked.
     81 * @param descriptor
     82 * @param serialized_descriptor
     83 */
     84void usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor,
     85    void * serialized_descriptor) {
     86        //base size
     87        uint8_t * sdescriptor = serialized_descriptor;
     88        size_t size = 7;
     89        //variable size according to port count
     90        size_t var_size = (descriptor->ports_count+7)/8;
     91        size += 2 * var_size;
     92        //size
     93        sdescriptor[0] = size;
    6794        //descriptor type
    68         result[1] = USB_DESCTYPE_HUB;
    69         result[2] = descriptor->ports_count;
     95        sdescriptor[1] = USB_DESCTYPE_HUB;
     96        sdescriptor[2] = descriptor->ports_count;
    7097        /// @fixme handling of endianness??
    71         result[3] = descriptor->hub_characteristics / 256;
    72         result[4] = descriptor->hub_characteristics % 256;
    73         result[5] = descriptor->pwr_on_2_good_time;
    74         result[6] = descriptor->current_requirement;
     98        sdescriptor[3] = descriptor->hub_characteristics / 256;
     99        sdescriptor[4] = descriptor->hub_characteristics % 256;
     100        sdescriptor[5] = descriptor->pwr_on_2_good_time;
     101        sdescriptor[6] = descriptor->current_requirement;
    75102
    76103        size_t i;
    77104        for (i = 0; i < var_size; ++i) {
    78                 result[7 + i] = descriptor->devices_removable[i];
     105                sdescriptor[7 + i] = descriptor->devices_removable[i];
    79106        }
    80107        for (i = 0; i < var_size; ++i) {
    81                 result[7 + var_size + i] = 255;
     108                sdescriptor[7 + var_size + i] = 255;
    82109        }
    83         return result;
    84110}
    85111
    86 usb_hub_descriptor_t * usb_deserialize_hub_desriptor(
     112
     113/**
     114 * create deserialized desriptor structure out of serialized descriptor
     115 *
     116 * The serialized descriptor must be proper usb hub descriptor,
     117 * otherwise an eerror might occur.
     118 *
     119 * @param sdescriptor serialized descriptor
     120 * @return newly created deserialized descriptor pointer
     121 */
     122usb_hub_descriptor_t * usb_create_deserialized_hub_desriptor(
    87123void * serialized_descriptor) {
    88124        uint8_t * sdescriptor = serialized_descriptor;
     
    95131
    96132        usb_hub_descriptor_t * result = malloc(sizeof(usb_hub_descriptor_t));
    97        
     133        if(result)
     134                usb_deserialize_hub_desriptor(serialized_descriptor,result);
     135        return result;
     136}
    98137
    99         result->ports_count = sdescriptor[2];
     138/**
     139 * deserialize descriptor into given pointer
     140 *
     141 * @param serialized_descriptor
     142 * @param descriptor
     143 * @return
     144 */
     145void usb_deserialize_hub_desriptor(
     146void * serialized_descriptor, usb_hub_descriptor_t * descriptor) {
     147        uint8_t * sdescriptor = serialized_descriptor;
     148        descriptor->ports_count = sdescriptor[2];
    100149        /// @fixme handling of endianness??
    101         result->hub_characteristics = sdescriptor[4] + 256 * sdescriptor[3];
    102         result->pwr_on_2_good_time = sdescriptor[5];
    103         result->current_requirement = sdescriptor[6];
    104         size_t var_size = (result->ports_count+7) / 8;
    105         result->devices_removable = (uint8_t*) malloc(var_size);
     150        descriptor->hub_characteristics = sdescriptor[4] + 256 * sdescriptor[3];
     151        descriptor->pwr_on_2_good_time = sdescriptor[5];
     152        descriptor->current_requirement = sdescriptor[6];
     153        size_t var_size = (descriptor->ports_count+7) / 8;
     154        //descriptor->devices_removable = (uint8_t*) malloc(var_size);
    106155
    107156        size_t i;
    108157        for (i = 0; i < var_size; ++i) {
    109                 result->devices_removable[i] = sdescriptor[7 + i];
     158                descriptor->devices_removable[i] = sdescriptor[7 + i];
    110159        }
    111         return result;
    112160}
    113 
    114 
    115161
    116162/**
  • uspace/drv/usbkbd/kbddev.c

    rc7dd69d rda1dd48  
    567567       
    568568        if (count != kbd_dev->key_count) {
    569                 usb_log_warning("Number of received keycodes (%d) differs from"
    570                     " expected number (%d).\n", count, kbd_dev->key_count);
     569                usb_log_warning("Number of received keycodes (%zu) differs from"
     570                    " expected (%zu).\n", count, kbd_dev->key_count);
    571571                return;
    572572        }
  • uspace/drv/usbmid/main.c

    rc7dd69d rda1dd48  
    5353        usb_log_info("Taking care of new MID `%s'.\n", dev->ddf_dev->name);
    5454
    55         int rc;
    56 
    57         rc = usb_pipe_start_long_transfer(&dev->ctrl_pipe);
    58         if (rc != EOK) {
    59                 usb_log_error("Failed to start transfer on control pipe: %s.\n",
    60                     str_error(rc));
    61                 return rc;
    62         }
     55        usb_pipe_start_long_transfer(&dev->ctrl_pipe);
    6356
    6457        bool accept = usbmid_explore_device(dev);
  • uspace/drv/usbmouse/init.c

    rc7dd69d rda1dd48  
    125125        }
    126126       
    127         /* Open the control pipe. */
    128         rc = usb_pipe_start_session(&dev->ctrl_pipe);
    129         if (rc != EOK) {
    130                 goto leave;
    131         }
    132        
    133127        /* Set the boot protocol. */
    134128        rc = usb_control_request_set(&dev->ctrl_pipe,
     
    140134        }
    141135       
    142         /* Close the control pipe (ignore errors). */
    143         usb_pipe_end_session(&dev->ctrl_pipe);
    144 
    145 
    146         /* Everything allright. */
     136        /* Everything all right. */
    147137        dev->driver_data = mouse;
    148138        mouse->mouse_fun->driver_data = mouse;
  • uspace/drv/usbmouse/main.c

    rc7dd69d rda1dd48  
    5454        }
    5555
    56         usb_log_debug("Polling pipe at endpoint %d.\n", dev->pipes[0].pipe->endpoint_no);
     56        usb_log_debug("Polling pipe at endpoint %d.\n",
     57            dev->pipes[0].pipe->endpoint_no);
    5758
    5859        rc = usb_device_auto_poll(dev, 0,
     
    6667        }
    6768
    68         usb_log_info("controlling new mouse (handle %llu).\n",
     69        usb_log_info("controlling new mouse (handle %" PRIun ").\n",
    6970            dev->ddf_dev->handle);
    7071
  • uspace/drv/vhc/conndev.c

    rc7dd69d rda1dd48  
    9999                int rc = get_device_name(callback, devname, DEVICE_NAME_MAXLENGTH);
    100100
    101                 usb_log_info("New virtual device `%s' (id = %x).\n",
     101                usb_log_info("New virtual device `%s' (id = %" PRIxn ").\n",
    102102                    rc == EOK ? devname : "<unknown>", dev->id);
    103103
     
    122122        }
    123123
    124         usb_log_info("Virtual device disconnected (id = %x).\n", dev->id);
     124        usb_log_info("Virtual device disconnected (id = %" PRIxn ").\n",
     125            dev->id);
    125126        virtdev_destroy_device(dev);
    126127}
  • uspace/lib/c/include/ipc/dev_iface.h

    rc7dd69d rda1dd48  
    4545        /** Interface provided by USB host controller. */
    4646        USBHC_DEV_IFACE,
     47        /** Interface provided by USB HID devices. */
     48        USBHID_DEV_IFACE,
    4749
    4850        DEV_IFACE_MAX
  • uspace/lib/drv/generic/dev_iface.c

    rc7dd69d rda1dd48  
    4343#include "remote_usb.h"
    4444#include "remote_usbhc.h"
     45#include "remote_usbhid.h"
    4546#include "remote_pci.h"
    4647
     
    5152                &remote_pci_iface,
    5253                &remote_usb_iface,
    53                 &remote_usbhc_iface
     54                &remote_usbhc_iface,
     55                &remote_usbhid_iface
    5456        }
    5557};
  • uspace/lib/usb/Makefile

    rc7dd69d rda1dd48  
    4242        src/dp.c \
    4343        src/dump.c \
     44        src/hidiface.c \
    4445        src/hidparser.c \
    4546        src/hub.c \
  • uspace/lib/usb/include/usb/classes/hub.h

    rc7dd69d rda1dd48  
    152152            maximum of 255 ports).
    153153     */
    154     uint8_t * devices_removable;
     154    uint8_t devices_removable[32];
    155155
    156156    /**
  • uspace/lib/usb/include/usb/debug.h

    rc7dd69d rda1dd48  
    3636#define LIBUSB_DEBUG_H_
    3737#include <stdio.h>
     38#include <inttypes.h>
    3839#include <usb/usb.h>
    3940#include <assert.h>
     
    8586void usb_log_enable(usb_log_level_t, const char *);
    8687
    87 void usb_log_printf(usb_log_level_t, const char *, ...);
     88void usb_log_printf(usb_log_level_t, const char *, ...)
     89        PRINTF_ATTRIBUTE(2, 3);
    8890
    8991/** Log fatal error. */
  • uspace/lib/usb/include/usb/pipes.h

    rc7dd69d rda1dd48  
    9999        /** Number of active transfers over the pipe. */
    100100        int refcount;
     101        /** Number of failed attempts to open the HC phone.
     102         * When user requests usb_pipe_start_long_transfer() and the operation
     103         * fails, there is no way to report this to the user.
     104         * That the soft reference counter is increased to record the attempt.
     105         * When the user then request e.g. usb_pipe_read(), it will try to
     106         * add reference as well.
     107         * If that fails, it is reported to the user. If it is okay, the
     108         * real reference counter is incremented.
     109         * The problem might arise when ending the long transfer (since
     110         * the number of references would be only 1, but logically it shall be
     111         * two).
     112         * Decrementing the soft counter first shall solve this.
     113         */
     114        int refcount_soft;
    101115
    102116        /** Whether to automatically reset halt on the endpoint.
     
    163177int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *);
    164178
    165 int usb_pipe_start_session(usb_pipe_t *);
    166 int usb_pipe_end_session(usb_pipe_t *);
    167 bool usb_pipe_is_session_started(usb_pipe_t *);
    168 
    169 int usb_pipe_start_long_transfer(usb_pipe_t *);
     179void usb_pipe_start_long_transfer(usb_pipe_t *);
    170180void usb_pipe_end_long_transfer(usb_pipe_t *);
    171181
  • uspace/lib/usb/src/devdrv.c

    rc7dd69d rda1dd48  
    236236
    237237        /* It is worth to start a long transfer. */
    238         rc = usb_pipe_start_long_transfer(ctrl_pipe);
    239         if (rc != EOK) {
    240                 return rc;
    241         }
     238        usb_pipe_start_long_transfer(ctrl_pipe);
    242239
    243240        /* Get the device descriptor. */
  • uspace/lib/usb/src/devpoll.c

    rc7dd69d rda1dd48  
    7878                usb_endpoint_mapping_t *mapping
    7979                    = &polling_data->dev->pipes[polling_data->pipe_index];
    80                 usb_log_debug("Poll0x%x: started polling of `%s' - " \
     80                usb_log_debug("Poll%p: started polling of `%s' - " \
    8181                    "interface %d (%s,%d,%d), %zuB/%zu.\n",
    8282                    polling_data,
     
    100100                        if (rc == EOK) {
    101101                                usb_log_debug(
    102                                     "Poll0x%x: received: '%s' (%zuB).\n",
     102                                    "Poll%p: received: '%s' (%zuB).\n",
    103103                                    polling_data,
    104104                                    usb_debug_str_buffer(polling_data->buffer,
     
    107107                        } else {
    108108                                usb_log_debug(
    109                                     "Poll0x%x: polling failed: %s.\n",
     109                                    "Poll%p: polling failed: %s.\n",
    110110                                    polling_data, str_error(rc));
    111111                        }
  • uspace/lib/usb/src/hidparser.c

    rc7dd69d rda1dd48  
    167167
    168168                        usb_log_debug2(
    169                                 "i(%u) data(%X) value(%X): TAG %u, class %u, size %u - ", i,
     169                                "i(%zu) data(%X) value(%X): TAG %d, class %u, size %u - ", i,
    170170                            data[i], usb_hid_report_tag_data_int32(data+i+1,item_size),
    171171                            tag, class, item_size);
     
    576576                report_item = list_get_instance(item, usb_hid_report_item_t, link);
    577577
    578                 usb_log_debug("\tOFFSET: %X\n", report_item->offset);
     578                usb_log_debug("\tOFFSET: %zX\n", report_item->offset);
    579579                usb_log_debug("\tCOUNT: %X\n", report_item->count);
    580580                usb_log_debug("\tSIZE: %X\n", report_item->size);
  • uspace/lib/usb/src/hidreport.c

    rc7dd69d rda1dd48  
    109109       
    110110        if (*d != sizeof(usb_standard_hid_descriptor_t)) {
    111                 usb_log_error("HID descriptor hass wrong size (%u, expected %u"
     111                usb_log_error("HID descriptor has wrong size (%u, expected %zu"
    112112                    ")\n", *d, sizeof(usb_standard_hid_descriptor_t));
    113113                return EINVAL;
     
    149149                free(*report_desc);
    150150                *report_desc = NULL;
    151                 usb_log_error("Report descriptor has wrong size (%u, expected "
     151                usb_log_error("Report descriptor has wrong size (%zu, expected "
    152152                    "%u)\n", actual_size, length);
    153153                return EINVAL;
  • uspace/lib/usb/src/pipepriv.c

    rc7dd69d rda1dd48  
    7777 *
    7878 * @param pipe The USB pipe.
     79 * @param hide_failure Whether to hide failure when adding reference
     80 *      (use soft refcount).
    7981 * @return Error code.
    8082 * @retval EOK Currently always.
    8183 */
    82 int pipe_add_ref(usb_pipe_t *pipe)
     84int pipe_add_ref(usb_pipe_t *pipe, bool hide_failure)
    8385{
    84 another_try:
    8586        pipe_acquire(pipe);
    8687
     
    8990                int phone = devman_device_connect(pipe->wire->hc_handle, 0);
    9091                if (phone < 0) {
    91                         // TODO: treat some error as non-recoverable
    92                         // and return error from here
     92                        if (hide_failure) {
     93                                pipe->refcount_soft++;
     94                                phone = EOK;
     95                        }
    9396                        pipe_release(pipe);
    94                         goto another_try;
     97                        return phone;
    9598                }
    9699                /*
     
    114117{
    115118        pipe_acquire(pipe);
     119        if (pipe->refcount_soft > 0) {
     120                pipe->refcount_soft--;
     121                pipe_release(pipe);
     122                return;
     123        }
    116124        assert(pipe->refcount > 0);
    117125        pipe->refcount--;
  • uspace/lib/usb/src/pipepriv.h

    rc7dd69d rda1dd48  
    3737
    3838#include <usb/pipes.h>
     39#include <bool.h>
    3940
    4041void pipe_acquire(usb_pipe_t *);
     
    4445void pipe_end_transaction(usb_pipe_t *);
    4546
    46 int pipe_add_ref(usb_pipe_t *);
     47int pipe_add_ref(usb_pipe_t *, bool);
    4748void pipe_drop_ref(usb_pipe_t *);
    4849
  • uspace/lib/usb/src/pipes.c

    rc7dd69d rda1dd48  
    229229}
    230230
    231 
    232 /** Start a session on the endpoint pipe.
    233  *
    234  * A session is something inside what any communication occurs.
    235  * It is expected that sessions would be started right before the transfer
    236  * and ended - see usb_pipe_end_session() - after the last
    237  * transfer.
    238  * The reason for this is that session actually opens some communication
    239  * channel to the host controller (or to the physical hardware if you
    240  * wish) and thus it involves acquiring kernel resources.
    241  * Since they are limited, sessions shall not be longer than strictly
    242  * necessary.
    243  *
    244  * @deprecated
    245  * Obsoleted with introduction of usb_pipe_start_long_transfer
    246  *
    247  * @param pipe Endpoint pipe to start the session on.
    248  * @return Error code.
    249  */
    250 int usb_pipe_start_session(usb_pipe_t *pipe)
    251 {
    252         usb_log_warning("usb_pipe_start_session() was deprecated.\n");
    253         return EOK;
    254 }
    255 
    256 
    257 /** Ends a session on the endpoint pipe.
    258  *
    259  * @deprecated
    260  * Obsoleted with introduction of usb_pipe_end_long_transfer
    261  *
    262  * @see usb_pipe_start_session
    263  *
    264  * @param pipe Endpoint pipe to end the session on.
    265  * @return Error code.
    266  */
    267 int usb_pipe_end_session(usb_pipe_t *pipe)
    268 {
    269         usb_log_warning("usb_pipe_end_session() was deprecated.\n");
    270         return EOK;
    271 }
    272 
    273 /** Tell whether a session is started (open) on the endpoint pipe.
    274  *
    275  * The expected usage of this function is in assertions for some
    276  * nested functions.
    277  *
    278  * @param pipe Endpoint pipe in question.
    279  * @return Whether @p pipe has opened a session.
    280  */
    281 bool usb_pipe_is_session_started(usb_pipe_t *pipe)
    282 {
    283         pipe_acquire(pipe);
    284         bool started = pipe->refcount > 0;
    285         pipe_release(pipe);
    286         return started;
    287 }
    288 
    289231/** Prepare pipe for a long transfer.
    290232 *
     
    297239 * @return Error code.
    298240 */
    299 int usb_pipe_start_long_transfer(usb_pipe_t *pipe)
    300 {
    301         return pipe_add_ref(pipe);
     241void usb_pipe_start_long_transfer(usb_pipe_t *pipe)
     242{
     243        (void) pipe_add_ref(pipe, true);
    302244}
    303245
  • uspace/lib/usb/src/pipesinit.c

    rc7dd69d rda1dd48  
    365365        pipe->direction = direction;
    366366        pipe->refcount = 0;
     367        pipe->refcount_soft = 0;
    367368        pipe->auto_reset_halt = false;
    368369
     
    419420        int rc;
    420421
    421         rc = usb_pipe_start_long_transfer(pipe);
    422         if (rc != EOK) {
    423                 return rc;
    424         }
    425 
     422        usb_pipe_start_long_transfer(pipe);
    426423
    427424        uint8_t dev_descr_start[CTRL_PIPE_MIN_PACKET_SIZE];
  • uspace/lib/usb/src/pipesio.c

    rc7dd69d rda1dd48  
    173173
    174174        int rc;
    175         rc = pipe_add_ref(pipe);
     175        rc = pipe_add_ref(pipe, false);
    176176        if (rc != EOK) {
    177177                return rc;
     
    296296        int rc;
    297297
    298         rc = pipe_add_ref(pipe);
     298        rc = pipe_add_ref(pipe, false);
    299299        if (rc != EOK) {
    300300                return rc;
     
    447447        int rc;
    448448
    449         rc = pipe_add_ref(pipe);
     449        rc = pipe_add_ref(pipe, false);
    450450        if (rc != EOK) {
    451451                return rc;
     
    579579        int rc;
    580580
    581         rc = pipe_add_ref(pipe);
     581        rc = pipe_add_ref(pipe, false);
    582582        if (rc != EOK) {
    583583                return rc;
Note: See TracChangeset for help on using the changeset viewer.