Changes in / [eb393ad:c7c0984a] in mainline


Ignore:
Location:
uspace
Files:
46 edited

Legend:

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

    reb393ad rc7c0984a  
    7777        }
    7878
    79         usb_pipe_start_long_transfer(&dev->ctrl_pipe);
     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        }
    8086        transfer_started = true;
    8187
  • uspace/drv/ehci-hcd/main.c

    reb393ad rc7c0984a  
    8282            pci_get_my_registers(device, &mem_reg_base, &mem_reg_size, &irq);
    8383        CHECK_RET_RETURN(ret,
    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",
     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",
    8786            mem_reg_base, mem_reg_size, irq);
    8887
     
    103102            str_error(ret));
    104103
    105         usb_log_info("Controlling new EHCI device `%s' (handle %" PRIun ").\n",
     104        usb_log_info("Controlling new EHCI device `%s' (handle %llu).\n",
    106105            device->name, device->handle);
    107106
  • uspace/drv/ehci-hcd/pci.c

    reb393ad rc7c0984a  
    117117                                mem_address = res->res.mem_range.address;
    118118                                mem_size = res->res.mem_range.size;
    119                                 usb_log_debug2("Found mem: %" PRIxn" %zu.\n",
     119                                usb_log_debug2("Found mem: %llx %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:%" PRIxn ".\n", (void *) address, value);
     188        usb_log_info("Register space BAR at %p:%x.\n", 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", (void *) registers);
     192        usb_log_info("Memory registers BASE address:%p.\n", 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, (void *) registers);
     203            ret, regs, 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: %" PRIxn ".\n", value);
     223        usb_log_debug("USBLEGCTLSTS: %x.\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: %" PRIxn ".\n", value);
     230        usb_log_debug2("USBLEGSUP: %x.\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 %zu usec.\n", wait);
     250                usb_log_info("BIOS released control after %d 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                     "%zu usecs, force it.\n", wait);
     254                    "%d 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: %" PRIxn ".\n", value);
     273        usb_log_debug2("USBLEGCTLSTS: %x.\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: %" PRIxn ".\n", value);
     279        usb_log_debug2("USBLEGSUP: %x.\n", value);
    280280
    281281        /*
  • uspace/drv/ohci/batch.c

    reb393ad rc7c0984a  
    141141        assert(data);
    142142        size_t tds = data->td_count;
    143         usb_log_debug("Batch(%p) checking %zu td(s) for completion.\n",
     143        usb_log_debug("Batch(%p) checking %d td(s) for completion.\n",
    144144            instance, tds);
    145145        usb_log_debug("ED: %x:%x:%x:%x.\n",
     
    150150        for (; i < tds; ++i) {
    151151                assert(data->tds[i] != NULL);
    152                 usb_log_debug("TD %zu: %x:%x:%x:%x.\n", i,
     152                usb_log_debug("TD %d: %x:%x:%x:%x.\n", i,
    153153                    data->tds[i]->status, data->tds[i]->cbp, data->tds[i]->next,
    154154                    data->tds[i]->be);
     
    158158                instance->error = td_error(data->tds[i]);
    159159                if (instance->error != EOK) {
    160                         usb_log_debug("Batch(%p) found error TD(%zu):%x.\n",
     160                        usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
    161161                            instance, i, data->tds[i]->status);
    162162                        /* Make sure TD queue is empty (one TD),
  • uspace/drv/ohci/endpoint_list.c

    reb393ad rc7c0984a  
    5555        }
    5656        instance->list_head_pa = addr_to_phys(instance->list_head);
    57         usb_log_debug2("Transfer list %s setup with ED: %p(0x%0" PRIx32 ")).\n",
     57        usb_log_debug2("Transfer list %s setup with ED: %p(%p).\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-0x%0" PRIx32 "): %x:%x:%x:%x.\n",
     123                usb_log_debug2("%s head ED(%p-%p): %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

    reb393ad rc7c0984a  
    113113            BANDWIDTH_AVAILABLE_USB11);
    114114        CHECK_RET_RETURN(ret, "Failed to initialize endpoint manager: %s.\n",
    115             str_error(ret));
     115            ret, 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             str_error(ret));
     119        CHECK_RET_RETURN(ret, "Failed to create OHCI memory structures:%s.\n",
     120            ret, 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-%#" PRIx32 " (%p).\n", instance->hcca,
    297                     instance->registers->hcca,
    298                     (void *) addr_to_phys(instance->hcca));
    299                 usb_log_debug2("Periodic current: %#" PRIx32 ".\n",
     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",
    300299                    instance->registers->periodic_current);
    301300
     
    406405        instance->registers->bulk_head =
    407406            instance->lists[USB_TRANSFER_BULK].list_head_pa;
    408         usb_log_debug2("Bulk HEAD set to: %p (%#" PRIx32 ").\n",
     407        usb_log_debug2("Bulk HEAD set to: %p(%p).\n",
    409408            instance->lists[USB_TRANSFER_BULK].list_head,
    410409            instance->lists[USB_TRANSFER_BULK].list_head_pa);
     
    412411        instance->registers->control_head =
    413412            instance->lists[USB_TRANSFER_CONTROL].list_head_pa;
    414         usb_log_debug2("Control HEAD set to: %p (%#" PRIx32 ").\n",
     413        usb_log_debug2("Control HEAD set to: %p(%p).\n",
    415414            instance->lists[USB_TRANSFER_CONTROL].list_head,
    416415            instance->lists[USB_TRANSFER_CONTROL].list_head_pa);
     
    488487                    instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa;
    489488        }
    490         usb_log_debug2("Interrupt HEADs set to: %p (%#" PRIx32 ").\n",
     489        usb_log_debug2("Interrupt HEADs set to: %p(%p).\n",
    491490            instance->lists[USB_TRANSFER_INTERRUPT].list_head,
    492491            instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa);
  • uspace/drv/ohci/iface.c

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

    reb393ad rc7c0984a  
    148148            pci_get_my_registers(device, &mem_reg_base, &mem_reg_size, &irq);
    149149        CHECK_RET_DEST_FUN_RETURN(ret,
    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);
     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);
    154153
    155154        ret = pci_disable_legacy(device);
  • uspace/drv/ohci/pci.c

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

    reb393ad rc7c0984a  
    162162        assert(data);
    163163
    164         usb_log_debug2("Batch(%p) checking %zu transfer(s) for completion.\n",
     164        usb_log_debug2("Batch(%p) checking %d 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(%zu):%" PRIx32 ".\n",
     175                        usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
    176176                            instance, i, data->tds[i].status);
    177177                        td_print_status(&data->tds[i]);
  • uspace/drv/uhci-hcd/hc.c

    reb393ad rc7c0984a  
    101101            ret, io, str_error(ret));
    102102        instance->registers = io;
    103         usb_log_debug("Device registers at %p (%zuB) accessible.\n",
     103        usb_log_debug("Device registers at %p(%u) 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                             (void *) frame_list,
    426                             (void *) addr_to_phys(instance->frame_list));
     425                            frame_list, addr_to_phys(instance->frame_list));
    427426                }
    428427
     
    433432                uintptr_t real_pa = addr_to_phys(QH(interrupt));
    434433                if (expected_pa != real_pa) {
    435                         usb_log_debug("Interrupt QH: %p (frame %d) vs. %p.\n",
    436                             (void *) expected_pa, frnum, (void *) real_pa);
     434                        usb_log_debug("Interrupt QH: %p(frame: %d) vs. %p.\n",
     435                            expected_pa, frnum, real_pa);
    437436                }
    438437
     
    441440                if (expected_pa != real_pa) {
    442441                        usb_log_debug("Control Slow QH: %p vs. %p.\n",
    443                             (void *) expected_pa, (void *) real_pa);
     442                            expected_pa, real_pa);
    444443                }
    445444
     
    448447                if (expected_pa != real_pa) {
    449448                        usb_log_debug("Control Full QH: %p vs. %p.\n",
    450                             (void *) expected_pa, (void *) real_pa);
     449                            expected_pa, real_pa);
    451450                }
    452451
     
    455454                if (expected_pa != real_pa ) {
    456455                        usb_log_debug("Bulk QH: %p vs. %p.\n",
    457                             (void *) expected_pa, (void *) real_pa);
     456                            expected_pa, real_pa);
    458457                }
    459458                async_usleep(UHCI_DEBUGER_TIMEOUT);
  • uspace/drv/uhci-hcd/hw_struct/transfer_descriptor.c

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

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

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

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

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

    reb393ad rc7c0984a  
    168168            pci_get_my_registers(device, &io_reg_base, &io_reg_size, &irq);
    169169        CHECK_RET_DEST_FUN_RETURN(ret,
    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);
     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);
    174173
    175174        ret = pci_disable_legacy(device);
  • uspace/drv/uhci-rhd/main.c

    reb393ad rc7c0984a  
    11/*
    2  * Copyright (c) 2011 Jan Vesely
     2 * Copyright (c) 2011 Vojtech Horky, Jan Vesely
    33 * All rights reserved.
    44 *
     
    8484                return EINVAL;
    8585
    86         usb_log_debug2("uhci_rh_add_device(handle=%" PRIun ")\n",
    87             device->handle);
     86        usb_log_debug2("%s called device %d\n", __FUNCTION__, device->handle);
    8887
    8988        uintptr_t io_regs = 0;
     
    102101        ret = hc_get_my_registers(device, &io_regs, &io_size);
    103102        CHECK_RET_FREE_RH_RETURN(ret,
    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);
     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);
    107105
    108106        rh = malloc(sizeof(uhci_root_hub_t));
     
    117115
    118116        device->driver_data = rh;
    119         usb_log_info("Controlling root hub '%s' (%" PRIun ").\n",
     117        usb_log_info("Controlling root hub '%s' (%llu).\n",
    120118            device->name, device->handle);
    121119        return EOK;
  • uspace/drv/uhci-rhd/port.c

    reb393ad rc7c0984a  
    8989{
    9090        assert(port);
    91         asprintf(&port->id_string, "Port (%p - %u)", port, number);
     91        asprintf(&port->id_string, "Port (%p - %d)", 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 (%" PRIun ").\n",
     117        usb_log_debug("%s: Started polling fibril(%x).\n",
    118118            port->id_string, port->checker);
    119119        return EOK;
     
    267267        }
    268268
    269         usb_log_info("New device at port %u, address %d (handle %" PRIun ").\n",
     269        usb_log_info("New device at port %u, address %d (handle %llu).\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 %" PRIun ".\n",
     285        usb_log_error("%s: Don't know how to remove device %llu.\n",
    286286            port->id_string, port->attached_device);
    287287        return ENOTSUP;
  • uspace/drv/usbflbk/main.c

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

    reb393ad rc7c0984a  
    9999        [0x30] = KC_RBRACKET,
    100100        [0x31] = KC_BACKSLASH,
    101         //[0x32] = KC_, // TODO: HASH??? maybe same as 0x31 - backslash
    102         [0x32] = KC_BACKSLASH,
     101        //[0x32] = KC_, // TODO: HASH??? maybe some as 0x31 - backslash
    103102        [0x33] = KC_SEMICOLON,
    104103        [0x34] = KC_QUOTE,  // same as APOSTROPHE? (')
  • uspace/drv/usbhid/kbd/kbddev.c

    reb393ad rc7c0984a  
    177177/*----------------------------------------------------------------------------*/
    178178
    179 //static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
    180 //    uint8_t report_id, void *arg);
    181 
    182 //static const usb_hid_report_in_callbacks_t usb_kbd_parser_callbacks = {
    183 //      .keyboard = usb_kbd_process_keycodes
    184 //};
     179static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
     180    uint8_t report_id, void *arg);
     181
     182static const usb_hid_report_in_callbacks_t usb_kbd_parser_callbacks = {
     183        .keyboard = usb_kbd_process_keycodes
     184};
    185185
    186186/*----------------------------------------------------------------------------*/
     
    336336                return;
    337337        }
    338        
    339         // TODO: output translating does not work!!
    340338       
    341339        usb_log_debug("Output report buffer: %s\n",
     
    490488 */
    491489static void usb_kbd_check_key_changes(usb_hid_dev_t *hid_dev,
    492     usb_kbd_t *kbd_dev/*, const uint8_t *key_codes, size_t count*/)
     490    usb_kbd_t *kbd_dev, const uint8_t *key_codes, size_t count)
    493491{
    494492        unsigned int key;
     
    504502         */
    505503        i = 0;
    506         while (i < kbd_dev->key_count && kbd_dev->keys[i] != ERROR_ROLLOVER) {
     504        while (i < count && key_codes[i] != ERROR_ROLLOVER) {
    507505                ++i;
    508506        }
    509         if (i != kbd_dev->key_count) {
     507        if (i != count) {
    510508                usb_log_debug("Phantom state occured.\n");
    511509                // phantom state, do nothing
    512510                return;
    513511        }
     512       
     513        /* TODO: quite dummy right now, think of better implementation */
     514        assert(count == kbd_dev->key_count);
    514515       
    515516        /*
    516517         * 1) Key releases
    517518         */
    518         for (j = 0; j < kbd_dev->key_count; ++j) {
     519        for (j = 0; j < count; ++j) {
    519520                // try to find the old key in the new key list
    520521                i = 0;
    521522                while (i < kbd_dev->key_count
    522                     && kbd_dev->keys[i] != kbd_dev->keys_old[j]) {
     523                    && key_codes[i] != kbd_dev->keys[j]) {
    523524                        ++i;
    524525                }
    525526               
    526                 if (i == kbd_dev->key_count) {
     527                if (i == count) {
    527528                        // not found, i.e. the key was released
    528                         key = usbhid_parse_scancode(kbd_dev->keys_old[j]);
     529                        key = usbhid_parse_scancode(kbd_dev->keys[j]);
    529530                        if (!usb_kbd_is_lock(key)) {
    530531                                usb_kbd_repeat_stop(kbd_dev, key);
     
    543544                // try to find the new key in the old key list
    544545                j = 0;
    545                 while (j < kbd_dev->key_count
    546                     && kbd_dev->keys_old[j] != kbd_dev->keys[i]) {
     546                while (j < count && kbd_dev->keys[j] != key_codes[i]) {
    547547                        ++j;
    548548                }
    549549               
    550                 if (j == kbd_dev->key_count) {
     550                if (j == count) {
    551551                        // not found, i.e. new key pressed
    552                         key = usbhid_parse_scancode(kbd_dev->keys[i]);
     552                        key = usbhid_parse_scancode(key_codes[i]);
    553553                        usb_log_debug2("Key pressed: %d (keycode: %d)\n", key,
    554                             kbd_dev->keys[i]);
    555                         usb_kbd_push_ev(hid_dev, kbd_dev, KEY_PRESS, key);
     554                            key_codes[i]);
     555                        usb_kbd_push_ev(hid_dev, kbd_dev, KEY_PRESS,
     556                            key);
    556557                        if (!usb_kbd_is_lock(key)) {
    557558                                usb_kbd_repeat_start(kbd_dev, key);
     
    562563        }
    563564       
    564 //      usb_log_debug("Old keys: ");
    565 //      for (i = 0; i < kbd_dev->key_count; ++i) {
    566 //              usb_log_debug("%d ", kbd_dev->keys_old[i]);
    567 //      }
    568 //      usb_log_debug("\n");
    569        
    570        
    571 //      usb_log_debug("New keys: ");
    572 //      for (i = 0; i < kbd_dev->key_count; ++i) {
    573 //              usb_log_debug("%d ", kbd_dev->keys[i]);
    574 //      }
    575 //      usb_log_debug("\n");
    576        
    577         memcpy(kbd_dev->keys_old, kbd_dev->keys, kbd_dev->key_count * 4);
    578        
    579         usb_log_debug2("New stored keys: ");
    580         for (i = 0; i < kbd_dev->key_count; ++i) {
    581                 usb_log_debug2("%d ", kbd_dev->keys_old[i]);
    582         }
    583         usb_log_debug2("\n");
     565        memcpy(kbd_dev->keys, key_codes, count);
     566
     567        usb_log_debug("New stored keycodes: %s\n",
     568            usb_debug_str_buffer(kbd_dev->keys, kbd_dev->key_count, 0));
    584569}
    585570
     
    603588 * @sa usb_kbd_check_key_changes(), usb_kbd_check_modifier_changes()
    604589 */
    605 //static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
    606 //    uint8_t report_id, void *arg)
    607 //{
    608 //      if (arg == NULL) {
    609 //              usb_log_warning("Missing argument in callback "
    610 //                  "usbhid_process_keycodes().\n");
    611 //              return;
    612 //      }
    613        
    614 //      usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg;
    615        
    616 //      if (hid_dev->data == NULL) {
    617 //              usb_log_warning("Missing KBD device structure in callback.\n");
    618 //              return;
    619 //      }
    620        
    621 //      usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
    622 
    623 //      usb_log_debug("Got keys from parser (report id: %u): %s\n",
    624 //          report_id, usb_debug_str_buffer(key_codes, count, 0));
    625        
    626 //      if (count != kbd_dev->key_count) {
    627 //              usb_log_warning("Number of received keycodes (%zu) differs from"
    628 //                  " expected (%zu).\n", count, kbd_dev->key_count);
    629 //              return;
    630 //      }
    631        
    632 //      ///usb_kbd_check_modifier_changes(kbd_dev, key_codes, count);
    633 //      usb_kbd_check_key_changes(hid_dev, kbd_dev, key_codes, count);
    634 //}
     590static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
     591    uint8_t report_id, void *arg)
     592{
     593        if (arg == NULL) {
     594                usb_log_warning("Missing argument in callback "
     595                    "usbhid_process_keycodes().\n");
     596                return;
     597        }
     598       
     599        usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg;
     600       
     601        if (hid_dev->data == NULL) {
     602                usb_log_warning("Missing KBD device structure in callback.\n");
     603                return;
     604        }
     605       
     606        usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
     607
     608        usb_log_debug("Got keys from parser (report id: %u): %s\n",
     609            report_id, usb_debug_str_buffer(key_codes, count, 0));
     610       
     611        if (count != kbd_dev->key_count) {
     612                usb_log_warning("Number of received keycodes (%d) differs from"
     613                    " expected number (%d).\n", count, kbd_dev->key_count);
     614                return;
     615        }
     616       
     617        ///usb_kbd_check_modifier_changes(kbd_dev, key_codes, count);
     618        usb_kbd_check_key_changes(hid_dev, kbd_dev, key_codes, count);
     619}
    635620
    636621/*----------------------------------------------------------------------------*/
     
    656641                                 uint8_t *buffer, size_t actual_size)
    657642{
    658         assert(hid_dev->report != NULL);
    659         assert(hid_dev != NULL);
    660         assert(hid_dev->data != NULL);
    661        
    662         usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
     643        assert(hid_dev->parser != NULL);
    663644
    664645        usb_log_debug("Calling usb_hid_parse_report() with "
     
    678659                                                USB_HID_REPORT_TYPE_INPUT);
    679660
     661        unsigned i=0;
     662        usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
     663
     664        memset(kbd_dev->keys, 0, kbd_dev->key_count);
     665        while(field != NULL) {
     666                if((i < kbd_dev->key_count) && (field->value != 0)){
     667                        kbd_dev->keys[i++] = (uint8_t)field->usage;
     668                }
     669                field = usb_hid_report_get_sibling(hid_dev->parser, field, path,
     670                                                   USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     671                                                   USB_HID_REPORT_TYPE_INPUT);
     672        }
     673        usb_kbd_process_keycodes(kbd_dev->keys, kbd_dev->key_count, report_id, hid_dev);
     674       
    680675        usb_hid_report_path_free(path);
    681676       
    682677        if (rc != EOK) {
    683                 usb_log_warning("Error in usb_hid_parse_report():"
     678                usb_log_warning("Error in usb_hid_boot_keyboard_input_report():"
    684679                    "%s\n", str_error(rc));
    685680        }
    686        
    687         // fill in the currently pressed keys
    688        
    689         usb_hid_report_field_t *field = usb_hid_report_get_sibling(
    690             hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END
    691             | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, USB_HID_REPORT_TYPE_INPUT);
    692         unsigned i = 0;
    693        
    694         // TODO: remove this hack - skipping first field
    695         field = usb_hid_report_get_sibling(hid_dev->report, field, path,
    696             USB_HID_PATH_COMPARE_END
    697             | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    698             USB_HID_REPORT_TYPE_INPUT);
    699        
    700         while (field != NULL) {
    701                 usb_log_debug2("FIELD (%p) - VALUE(%d) USAGE(%u)\n",
    702                     field, field->value, field->usage);
    703                
    704                 assert(i < kbd_dev->key_count);
    705 //              if (i == kbd_dev->key_count) {
    706 //                      break;
    707 //              }
    708                
    709                 // save the key usage
    710                 kbd_dev->keys[i] = field->usage;
    711                 usb_log_debug2("Saved %u. key usage %d\n", i, kbd_dev->keys[i]);
    712                
    713                 ++i;
    714                 field = usb_hid_report_get_sibling(hid_dev->report, field, path,
    715                     USB_HID_PATH_COMPARE_END
    716                     | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    717                     USB_HID_REPORT_TYPE_INPUT);
    718         }
    719        
    720         usb_hid_report_path_free(path);
    721        
    722         usb_kbd_check_key_changes(hid_dev, kbd_dev);
    723681}
    724682
     
    808766       
    809767        kbd_dev->key_count = usb_hid_report_input_length(
    810             hid_dev->report, path,
     768            hid_dev->parser, path,
    811769            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
    812770        usb_hid_report_path_free(path);
     
    814772        usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count);
    815773       
    816         kbd_dev->keys = (int32_t *)calloc(kbd_dev->key_count, sizeof(int32_t));
     774        kbd_dev->keys = (uint8_t *)calloc(kbd_dev->key_count, sizeof(uint8_t));
    817775       
    818776        if (kbd_dev->keys == NULL) {
     
    822780        }
    823781       
    824         kbd_dev->keys_old =
    825                 (int32_t *)calloc(kbd_dev->key_count, sizeof(int32_t));
    826        
    827         if (kbd_dev->keys_old == NULL) {
    828                 usb_log_fatal("No memory!\n");
    829                 free(kbd_dev->keys);
    830                 free(kbd_dev);
    831                 return ENOMEM;
    832         }
    833        
    834782        /*
    835783         * Output report
    836784         */
    837785        kbd_dev->output_size = 0;
    838         kbd_dev->output_buffer = usb_hid_report_output(hid_dev->report,
    839             &kbd_dev->output_size, 0);
     786        kbd_dev->output_buffer = usb_hid_report_output(hid_dev->parser,
     787            &kbd_dev->output_size, 0x00);
    840788        if (kbd_dev->output_buffer == NULL) {
    841789                usb_log_warning("Error creating output report buffer.\n");
     
    850798            kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0);
    851799       
    852         kbd_dev->led_output_size = usb_hid_report_output_size(hid_dev->report,
     800        kbd_dev->led_output_size = usb_hid_report_output_size(hid_dev->parser,
    853801            kbd_dev->led_path,
    854802            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
     
    1007955int usb_kbd_set_boot_protocol(usb_hid_dev_t *hid_dev)
    1008956{
    1009         int rc = usb_hid_parse_report_descriptor(hid_dev->report,
     957        int rc = usb_hid_parse_report_descriptor(hid_dev->parser,
    1010958            USB_KBD_BOOT_REPORT_DESCRIPTOR,
    1011959            USB_KBD_BOOT_REPORT_DESCRIPTOR_SIZE);
  • uspace/drv/usbhid/kbd/kbddev.h

    reb393ad rc7c0984a  
    6565 */
    6666typedef struct usb_kbd_t {
    67         /** Previously pressed keys (not translated to key codes). */
    68         int32_t *keys_old;
    6967        /** Currently pressed keys (not translated to key codes). */
    70         int32_t *keys;
     68        uint8_t *keys;
    7169        /** Count of stored keys (i.e. number of keys in the report). */
    7270        size_t key_count;
  • uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.c

    reb393ad rc7c0984a  
    8686        usb_hid_report_path_set_report_id(path, report_id);
    8787
    88         usb_hid_report_field_t *field = usb_hid_report_get_sibling(hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END , USB_HID_REPORT_TYPE_INPUT);
     88        usb_hid_report_field_t *field = usb_hid_report_get_sibling(hid_dev->parser, NULL, path, USB_HID_PATH_COMPARE_END , USB_HID_REPORT_TYPE_INPUT);
    8989        while(field != NULL) {
    9090                usb_log_debug("KEY VALUE(%X) USAGE(%X)\n", field->value, field->usage);
  • uspace/drv/usbhid/mouse/mousedev.c

    reb393ad rc7c0984a  
    296296int usb_mouse_set_boot_protocol(usb_hid_dev_t *hid_dev)
    297297{
    298         int rc = usb_hid_parse_report_descriptor(hid_dev->report,
     298        int rc = usb_hid_parse_report_descriptor(hid_dev->parser,
    299299            USB_MOUSE_BOOT_REPORT_DESCRIPTOR,
    300300            USB_MOUSE_BOOT_REPORT_DESCRIPTOR_SIZE);
  • uspace/drv/usbhid/subdrivers.c

    reb393ad rc7c0984a  
    5555                USB_HID_PATH_COMPARE_END
    5656                | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    57                 -1,
    58                 -1,
     57                0,
     58                0,
    5959                {
    6060                        .init = usb_kbd_init,
     
    7979                }
    8080        },
    81         {NULL, -1, 0, -1, -1, {NULL, NULL, NULL, NULL}}
     81        {NULL, -1, 0, 0, 0, {NULL, NULL, NULL, NULL}}
    8282};
    8383
  • uspace/drv/usbhid/subdrivers.h

    reb393ad rc7c0984a  
    5656        int report_id;
    5757        int compare;
    58         int vendor_id;
    59         int product_id;
     58        uint16_t vendor_id;
     59        uint16_t product_id;
    6060        usb_hid_subdriver_t subdriver;
    6161} usb_hid_subdriver_mapping_t;
  • uspace/drv/usbhid/usbhid.c

    reb393ad rc7c0984a  
    158158    const usb_hid_subdriver_mapping_t *mapping)
    159159{
    160         assert(hid_dev != NULL);
    161         assert(hid_dev->usb_dev != NULL);
    162        
    163         return (hid_dev->usb_dev->descriptors.device.vendor_id
    164             == mapping->vendor_id
    165             && hid_dev->usb_dev->descriptors.device.product_id
    166             == mapping->product_id);
     160        return false;
    167161}
    168162
     
    198192        }
    199193       
    200         assert(hid_dev->report != NULL);
     194        assert(hid_dev->parser != NULL);
    201195       
    202196        usb_log_debug("Compare flags: %d\n", mapping->compare);
    203         size_t size = usb_hid_report_input_length(hid_dev->report, usage_path,
     197        size_t size = usb_hid_report_input_length(hid_dev->parser, usage_path,
    204198            mapping->compare);
    205         usb_log_debug("Size of the input report: %zuB\n", size);
     199        usb_log_debug("Size of the input report: %d\n", size);
    206200       
    207201        usb_hid_report_path_free(usage_path);
     
    257251        while (count < USB_HID_MAX_SUBDRIVERS &&
    258252            (mapping->usage_path != NULL
    259             || mapping->vendor_id >= 0 || mapping->product_id >= 0)) {
     253            || mapping->vendor_id != 0 || mapping->product_id != 0)) {
    260254                // check the vendor & product ID
    261                 if (mapping->vendor_id >= 0 && mapping->product_id < 0) {
    262                         usb_log_warning("Missing Product ID for Vendor ID %d\n",
     255                if (mapping->vendor_id != 0 && mapping->product_id == 0) {
     256                        usb_log_warning("Missing Product ID for Vendor ID %u\n",
    263257                            mapping->vendor_id);
    264258                        return EINVAL;
    265259                }
    266                 if (mapping->product_id >= 0 && mapping->vendor_id < 0) {
    267                         usb_log_warning("Missing Vendor ID for Product ID %d\n",
     260                if (mapping->product_id != 0 && mapping->vendor_id == 0) {
     261                        usb_log_warning("Missing Vendor ID for Product ID %u\n",
    268262                            mapping->product_id);
    269263                        return EINVAL;
     
    273267                matched = false;
    274268               
    275                 if (mapping->vendor_id >= 0) {
    276                         assert(mapping->product_id >= 0);
     269                if (mapping->vendor_id != 0) {
     270                        assert(mapping->product_id != 0);
    277271                        usb_log_debug("Comparing device against vendor ID %u"
    278272                            " and product ID %u.\n", mapping->vendor_id,
     
    347341        }
    348342       
    349         hid_dev->report = (usb_hid_report_t *)(malloc(sizeof(
     343        hid_dev->parser = (usb_hid_report_t *)(malloc(sizeof(
    350344            usb_hid_report_t)));
    351         if (hid_dev->report == NULL) {
     345        if (hid_dev->parser == NULL) {
    352346                usb_log_fatal("No memory!\n");
    353347                free(hid_dev);
     
    391385        /* Get the report descriptor and parse it. */
    392386        rc = usb_hid_process_report_descriptor(hid_dev->usb_dev,
    393             hid_dev->report);
     387            hid_dev->parser);
    394388       
    395389        bool fallback = false;
     
    589583
    590584        // destroy the parser
    591         if ((*hid_dev)->report != NULL) {
    592                 usb_hid_free_report((*hid_dev)->report);
     585        if ((*hid_dev)->parser != NULL) {
     586                usb_hid_free_report((*hid_dev)->parser);
    593587        }
    594588
  • uspace/drv/usbhid/usbhid.h

    reb393ad rc7c0984a  
    9191       
    9292        /** HID Report parser. */
    93         usb_hid_report_t *report;
     93        usb_hid_report_t *parser;
    9494       
    9595        /** Arbitrary data (e.g. a special structure for handling keyboard). */
  • uspace/drv/usbhub/ports.c

    reb393ad rc7c0984a  
    8383void usb_hub_process_interrupt(usb_hub_info_t * hub,
    8484        uint16_t port) {
    85         usb_log_debug("interrupt at port %zu\n", (size_t) port);
     85        usb_log_debug("interrupt at port %d\n", 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                     (size_t) port, str_error(opResult));
     95                    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",
    103                     (size_t) port,
     102                usb_log_debug("Connection change on port %zu: %s.\n", port,
    104103                    device_connected ? "device attached" : "device removed");
    105104
     
    110109                                usb_log_error(
    111110                                    "Cannot handle change on port %zu: %s.\n",
    112                                     (size_t) port, str_error(opResult));
     111                                    str_error(opResult));
    113112                        }
    114113                } else {
     
    211210static void usb_hub_port_reset_completed(usb_hub_info_t * hub,
    212211        uint16_t port, uint32_t status){
    213         usb_log_debug("Port %zu reset complete.\n", (size_t) port);
     212        usb_log_debug("Port %zu reset complete.\n", port);
    214213        if (usb_port_is_status(status, USB_HUB_FEATURE_PORT_ENABLE)) {
    215214                /* Finalize device adding. */
     
    223222                usb_log_warning(
    224223                    "Port %zu reset complete but port not enabled.\n",
    225                     (size_t) port);
     224                    port);
    226225        }
    227226}
  • uspace/drv/usbhub/usbhub.c

    reb393ad rc7c0984a  
    264264                                    port+1, USB_HUB_FEATURE_PORT_POWER);
    265265                                if (opResult != EOK) {
    266                                         usb_log_error("cannot power on port %zu: %s.\n",
    267                                             port+1, str_error(opResult));
     266                                        usb_log_error("cannot power on port %d;  %d\n",
     267                                            port+1, opResult);
    268268                                }
    269269                        }
     
    273273                            USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
    274274                        if (opResult != EOK) {
    275                                 usb_log_error("cannot power hub: %s\n",
    276                                     str_error(opResult));
     275                                usb_log_error("cannot power hub;  %d\n",
     276                                  opResult);
    277277                        }
    278278                }
     
    362362        }
    363363
    364         usb_log_info("Controlling hub `%s' (%zu ports).\n",
     364        usb_log_info("Controlling hub `%s' (%d ports).\n",
    365365            hub_info->usb_device->ddf_dev->name, hub_info->port_count);
    366366        return EOK;
     
    430430                            port, USB_HUB_FEATURE_PORT_POWER);
    431431                        if (opResult != EOK) {
    432                                 usb_log_error("Cannot power on port %zu: %s.\n",
    433                                     port, str_error(opResult));
     432                                usb_log_error("cannot power on port %d;  %d\n",
     433                                    port, opResult);
    434434                        }
    435435                }
  • uspace/drv/usbkbd/kbddev.c

    reb393ad rc7c0984a  
    570570       
    571571        if (count != kbd_dev->key_count) {
    572                 usb_log_warning("Number of received keycodes (%zu) differs from"
    573                     " expected (%zu).\n", count, kbd_dev->key_count);
     572                usb_log_warning("Number of received keycodes (%d) differs from"
     573                    " expected number (%d).\n", count, kbd_dev->key_count);
    574574                return;
    575575        }
  • uspace/drv/usbmid/main.c

    reb393ad rc7c0984a  
    5353        usb_log_info("Taking care of new MID `%s'.\n", dev->ddf_dev->name);
    5454
    55         usb_pipe_start_long_transfer(&dev->ctrl_pipe);
     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        }
    5663
    5764        bool accept = usbmid_explore_device(dev);
  • uspace/drv/usbmouse/init.c

    reb393ad rc7c0984a  
    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       
    127133        /* Set the boot protocol. */
    128134        rc = usb_control_request_set(&dev->ctrl_pipe,
     
    134140        }
    135141       
    136         /* Everything all right. */
     142        /* Close the control pipe (ignore errors). */
     143        usb_pipe_end_session(&dev->ctrl_pipe);
     144
     145
     146        /* Everything allright. */
    137147        dev->driver_data = mouse;
    138148        mouse->mouse_fun->driver_data = mouse;
  • uspace/drv/usbmouse/main.c

    reb393ad rc7c0984a  
    5454        }
    5555
    56         usb_log_debug("Polling pipe at endpoint %d.\n",
    57             dev->pipes[0].pipe->endpoint_no);
     56        usb_log_debug("Polling pipe at endpoint %d.\n", dev->pipes[0].pipe->endpoint_no);
    5857
    5958        rc = usb_device_auto_poll(dev, 0,
     
    6766        }
    6867
    69         usb_log_info("controlling new mouse (handle %" PRIun ").\n",
     68        usb_log_info("controlling new mouse (handle %llu).\n",
    7069            dev->ddf_dev->handle);
    7170
  • uspace/drv/vhc/conndev.c

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

    reb393ad rc7c0984a  
    3636#define LIBUSB_DEBUG_H_
    3737#include <stdio.h>
    38 #include <inttypes.h>
    3938#include <usb/usb.h>
    4039#include <assert.h>
     
    8685void usb_log_enable(usb_log_level_t, const char *);
    8786
    88 void usb_log_printf(usb_log_level_t, const char *, ...)
    89         PRINTF_ATTRIBUTE(2, 3);
     87void usb_log_printf(usb_log_level_t, const char *, ...);
    9088
    9189/** Log fatal error. */
  • uspace/lib/usb/include/usb/pipes.h

    reb393ad rc7c0984a  
    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;
    115101
    116102        /** Whether to automatically reset halt on the endpoint.
     
    177163int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *);
    178164
    179 void usb_pipe_start_long_transfer(usb_pipe_t *);
     165int usb_pipe_start_session(usb_pipe_t *);
     166int usb_pipe_end_session(usb_pipe_t *);
     167bool usb_pipe_is_session_started(usb_pipe_t *);
     168
     169int usb_pipe_start_long_transfer(usb_pipe_t *);
    180170void usb_pipe_end_long_transfer(usb_pipe_t *);
    181171
  • uspace/lib/usb/src/devdrv.c

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

    reb393ad rc7c0984a  
    7878                usb_endpoint_mapping_t *mapping
    7979                    = &polling_data->dev->pipes[polling_data->pipe_index];
    80                 usb_log_debug("Poll%p: started polling of `%s' - " \
     80                usb_log_debug("Poll0x%x: 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                                     "Poll%p: received: '%s' (%zuB).\n",
     102                                    "Poll0x%x: received: '%s' (%zuB).\n",
    103103                                    polling_data,
    104104                                    usb_debug_str_buffer(polling_data->buffer,
     
    107107                        } else {
    108108                                usb_log_debug(
    109                                     "Poll%p: polling failed: %s.\n",
     109                                    "Poll0x%x: polling failed: %s.\n",
    110110                                    polling_data, str_error(rc));
    111111                        }
  • uspace/lib/usb/src/hidreport.c

    reb393ad rc7c0984a  
    109109       
    110110        if (*d != sizeof(usb_standard_hid_descriptor_t)) {
    111                 usb_log_error("HID descriptor has wrong size (%u, expected %zu"
     111                usb_log_error("HID descriptor hass wrong size (%u, expected %u"
    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 (%zu, expected "
     151                usb_log_error("Report descriptor has wrong size (%u, expected "
    152152                    "%u)\n", actual_size, length);
    153153                return EINVAL;
  • uspace/lib/usb/src/pipepriv.c

    reb393ad rc7c0984a  
    7777 *
    7878 * @param pipe The USB pipe.
    79  * @param hide_failure Whether to hide failure when adding reference
    80  *      (use soft refcount).
    8179 * @return Error code.
    8280 * @retval EOK Currently always.
    8381 */
    84 int pipe_add_ref(usb_pipe_t *pipe, bool hide_failure)
     82int pipe_add_ref(usb_pipe_t *pipe)
    8583{
     84another_try:
    8685        pipe_acquire(pipe);
    8786
     
    9089                int phone = devman_device_connect(pipe->wire->hc_handle, 0);
    9190                if (phone < 0) {
    92                         if (hide_failure) {
    93                                 pipe->refcount_soft++;
    94                                 phone = EOK;
    95                         }
     91                        // TODO: treat some error as non-recoverable
     92                        // and return error from here
    9693                        pipe_release(pipe);
    97                         return phone;
     94                        goto another_try;
    9895                }
    9996                /*
     
    117114{
    118115        pipe_acquire(pipe);
    119         if (pipe->refcount_soft > 0) {
    120                 pipe->refcount_soft--;
    121                 pipe_release(pipe);
    122                 return;
    123         }
    124116        assert(pipe->refcount > 0);
    125117        pipe->refcount--;
  • uspace/lib/usb/src/pipepriv.h

    reb393ad rc7c0984a  
    3737
    3838#include <usb/pipes.h>
    39 #include <bool.h>
    4039
    4140void pipe_acquire(usb_pipe_t *);
     
    4544void pipe_end_transaction(usb_pipe_t *);
    4645
    47 int pipe_add_ref(usb_pipe_t *, bool);
     46int pipe_add_ref(usb_pipe_t *);
    4847void pipe_drop_ref(usb_pipe_t *);
    4948
  • uspace/lib/usb/src/pipes.c

    reb393ad rc7c0984a  
    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 */
     250int 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 */
     267int 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 */
     281bool 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
    231289/** Prepare pipe for a long transfer.
    232290 *
     
    239297 * @return Error code.
    240298 */
    241 void usb_pipe_start_long_transfer(usb_pipe_t *pipe)
    242 {
    243         (void) pipe_add_ref(pipe, true);
     299int usb_pipe_start_long_transfer(usb_pipe_t *pipe)
     300{
     301        return pipe_add_ref(pipe);
    244302}
    245303
  • uspace/lib/usb/src/pipesinit.c

    reb393ad rc7c0984a  
    365365        pipe->direction = direction;
    366366        pipe->refcount = 0;
    367         pipe->refcount_soft = 0;
    368367        pipe->auto_reset_halt = false;
    369368
     
    420419        int rc;
    421420
    422         usb_pipe_start_long_transfer(pipe);
     421        rc = usb_pipe_start_long_transfer(pipe);
     422        if (rc != EOK) {
     423                return rc;
     424        }
     425
    423426
    424427        uint8_t dev_descr_start[CTRL_PIPE_MIN_PACKET_SIZE];
  • uspace/lib/usb/src/pipesio.c

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