Changeset a1732929 in mainline for uspace/drv/bus/usb/uhci


Ignore:
Timestamp:
2018-01-15T17:04:34Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9ff99e8
Parents:
c1a966e
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-15 17:04:32)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-15 17:04:34)
Message:

usb: unified logging

Use logger instead of printf. Logger adds newlines automatically.

Location:
uspace/drv/bus/usb/uhci
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhci/hc.c

    rc1a966e ra1732929  
    141141        code->cmds[3].addr = (void*)&registers->usbsts;
    142142
    143         usb_log_debug("I/O regs at %p (size %zu), IRQ %d.\n",
     143        usb_log_debug("I/O regs at %p (size %zu), IRQ %d.",
    144144            RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]);
    145145
     
    182182        /* Resume interrupts are not supported */
    183183        if (status & UHCI_STATUS_RESUME) {
    184                 usb_log_error("Resume interrupt!\n");
     184                usb_log_error("Resume interrupt!");
    185185        }
    186186
    187187        /* Bits 4 and 5 indicate hc error */
    188188        if (status & (UHCI_STATUS_PROCESS_ERROR | UHCI_STATUS_SYSTEM_ERROR)) {
    189                 usb_log_error("UHCI hardware failure!.\n");
     189                usb_log_error("UHCI hardware failure!.");
    190190                ++instance->hw_failures;
    191191                transfer_list_abort_all(&instance->transfers_interrupt);
     
    198198                        hc_init_hw(instance);
    199199                } else {
    200                         usb_log_fatal("Too many UHCI hardware failures!.\n");
     200                        usb_log_fatal("Too many UHCI hardware failures!.");
    201201                        hc_gone(&instance->base);
    202202                }
     
    229229            (void **) &instance->registers);
    230230        if (ret != EOK) {
    231                 usb_log_error("Failed to gain access to registers: %s.\n",
     231                usb_log_error("Failed to gain access to registers: %s.",
    232232                    str_error(ret));
    233233                return ret;
    234234        }
    235235
    236         usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible.\n",
     236        usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible.",
    237237            hw_res->io_ranges.ranges[0].address.absolute,
    238238            hw_res->io_ranges.ranges[0].size);
     
    240240        ret = hc_init_mem_structures(instance, hcd);
    241241        if (ret != EOK) {
    242                 usb_log_error("Failed to init UHCI memory structures: %s.\n",
     242                usb_log_error("Failed to init UHCI memory structures: %s.",
    243243                    str_error(ret));
    244244                // TODO: we should disable pio here
     
    304304        const uint16_t cmd = pio_read_16(&registers->usbcmd);
    305305        if (cmd != 0)
    306                 usb_log_warning("Previous command value: %x.\n", cmd);
     306                usb_log_warning("Previous command value: %x.", cmd);
    307307
    308308        /* Start the hc with large(64B) packet FSBR */
     
    399399                return ENOMEM;
    400400        }
    401         usb_log_debug("Initialized frame list at %p.\n", instance->frame_list);
     401        usb_log_debug("Initialized frame list at %p.", instance->frame_list);
    402402
    403403        /* Init transfer lists */
    404404        int ret = hc_init_transfer_lists(instance);
    405405        if (ret != EOK) {
    406                 usb_log_error("Failed to initialize transfer lists.\n");
     406                usb_log_error("Failed to initialize transfer lists.");
    407407                return_page(instance->frame_list);
    408408                return ENOMEM;
    409409        }
    410         usb_log_debug("Initialized transfer lists.\n");
     410        usb_log_debug("Initialized transfer lists.");
    411411
    412412
     
    438438        int ret = transfer_list_init(&instance->transfers_##type, name); \
    439439        if (ret != EOK) { \
    440                 usb_log_error("Failed to setup %s transfer list: %s.\n", \
     440                usb_log_error("Failed to setup %s transfer list: %s.", \
    441441                    name, str_error(ret)); \
    442442                transfer_list_fini(&instance->transfers_bulk_full); \
     
    552552
    553553                if (((cmd & UHCI_CMD_RUN_STOP) != 1) || (sts != 0)) {
    554                         usb_log_debug2("Command: %X Status: %X Intr: %x\n",
     554                        usb_log_debug2("Command: %X Status: %X Intr: %x",
    555555                            cmd, sts, intr);
    556556                }
     
    559559                    pio_read_32(&instance->registers->flbaseadd) & ~0xfff;
    560560                if (frame_list != addr_to_phys(instance->frame_list)) {
    561                         usb_log_debug("Framelist address: %p vs. %p.\n",
     561                        usb_log_debug("Framelist address: %p vs. %p.",
    562562                            (void *) frame_list,
    563563                            (void *) addr_to_phys(instance->frame_list));
     
    570570                uintptr_t real_pa = addr_to_phys(QH(interrupt));
    571571                if (expected_pa != real_pa) {
    572                         usb_log_debug("Interrupt QH: %p (frame %d) vs. %p.\n",
     572                        usb_log_debug("Interrupt QH: %p (frame %d) vs. %p.",
    573573                            (void *) expected_pa, frnum, (void *) real_pa);
    574574                }
     
    577577                real_pa = addr_to_phys(QH(control_slow));
    578578                if (expected_pa != real_pa) {
    579                         usb_log_debug("Control Slow QH: %p vs. %p.\n",
     579                        usb_log_debug("Control Slow QH: %p vs. %p.",
    580580                            (void *) expected_pa, (void *) real_pa);
    581581                }
     
    584584                real_pa = addr_to_phys(QH(control_full));
    585585                if (expected_pa != real_pa) {
    586                         usb_log_debug("Control Full QH: %p vs. %p.\n",
     586                        usb_log_debug("Control Full QH: %p vs. %p.",
    587587                            (void *) expected_pa, (void *) real_pa);
    588588                }
     
    591591                real_pa = addr_to_phys(QH(bulk_full));
    592592                if (expected_pa != real_pa ) {
    593                         usb_log_debug("Bulk QH: %p vs. %p.\n",
     593                        usb_log_debug("Bulk QH: %p vs. %p.",
    594594                            (void *) expected_pa, (void *) real_pa);
    595595                }
  • uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.c

    rc1a966e ra1732929  
    104104        instance->buffer_ptr = addr_to_phys(buffer);
    105105
    106         usb_log_debug2("Created TD(%p): %X:%X:%X:%X(%p).\n",
     106        usb_log_debug2("Created TD(%p): %X:%X:%X:%X(%p).",
    107107            instance, instance->next, instance->status, instance->device,
    108108            instance->buffer_ptr, buffer);
    109109        td_print_status(instance);
    110110        if (pid == USB_PID_SETUP) {
    111                 usb_log_debug2("SETUP BUFFER: %s\n",
     111                usb_log_debug2("SETUP BUFFER: %s",
    112112                    usb_debug_str_buffer(buffer, 8, 8));
    113113        }
     
    160160        assert(instance);
    161161        const uint32_t s = instance->status;
    162         usb_log_debug2("TD(%p) status(%#" PRIx32 "):%s %d,%s%s%s%s%s%s%s%s%s%s%s %zu.\n",
     162        usb_log_debug2("TD(%p) status(%#" PRIx32 "):%s %d,%s%s%s%s%s%s%s%s%s%s%s %zu.",
    163163            instance, instance->status,
    164164            (s & TD_STATUS_SPD_FLAG) ? " SPD," : "",
  • uspace/drv/bus/usb/uhci/transfer_list.c

    rc1a966e ra1732929  
    5959        instance->queue_head = malloc32(sizeof(qh_t));
    6060        if (!instance->queue_head) {
    61                 usb_log_error("Failed to allocate queue head.\n");
     61                usb_log_error("Failed to allocate queue head.");
    6262                return ENOMEM;
    6363        }
    6464        const uint32_t queue_head_pa = addr_to_phys(instance->queue_head);
    65         usb_log_debug2("Transfer list %s setup with QH: %p (%#" PRIx32" ).\n",
     65        usb_log_debug2("Transfer list %s setup with QH: %p (%#" PRIx32" ).",
    6666            name, instance->queue_head, queue_head_pa);
    6767
     
    120120        fibril_mutex_unlock(&ep->guard);
    121121
    122         usb_log_debug2("Batch %p adding to queue %s.\n",
     122        usb_log_debug2("Batch %p adding to queue %s.",
    123123            uhci_batch, instance->name);
    124124
     
    150150
    151151        usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT
    152             " scheduled in queue %s.\n", uhci_batch,
     152            " scheduled in queue %s.", uhci_batch,
    153153            USB_TRANSFER_BATCH_ARGS(uhci_batch->base), instance->name);
    154154        fibril_mutex_unlock(&instance->guard);
     
    213213        assert(fibril_mutex_is_locked(&instance->guard));
    214214
    215         usb_log_debug2("Batch %p removing from queue %s.\n",
     215        usb_log_debug2("Batch %p removing from queue %s.",
    216216            uhci_batch, instance->name);
    217217
     
    236236        list_remove(&uhci_batch->link);
    237237        usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " removed (%s) "
    238             "from %s, next: %x.\n", uhci_batch,
     238            "from %s, next: %x.", uhci_batch,
    239239            USB_TRANSFER_BATCH_ARGS(uhci_batch->base),
    240240            qpos, instance->name, uhci_batch->qh->next);
  • uspace/drv/bus/usb/uhci/uhci_batch.c

    rc1a966e ra1732929  
    7575            calloc(1, sizeof(uhci_transfer_batch_t));
    7676        if (!uhci_batch) {
    77                 usb_log_error("Failed to allocate UHCI batch.\n");
     77                usb_log_error("Failed to allocate UHCI batch.");
    7878                return NULL;
    7979        }
     
    112112        uhci_batch->device_buffer = malloc32(total_size);
    113113        if (!uhci_batch->device_buffer) {
    114                 usb_log_error("Failed to allocate UHCI buffer.\n");
     114                usb_log_error("Failed to allocate UHCI buffer.");
    115115                return ENOMEM;
    116116        }
     
    135135        }
    136136        usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT
    137             " memory structures ready.\n", usb_batch,
     137            " memory structures ready.", usb_batch,
    138138            USB_TRANSFER_BATCH_ARGS(*usb_batch));
    139139
     
    159159
    160160        usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT
    161             " checking %zu transfer(s) for completion.\n",
     161            " checking %zu transfer(s) for completion.",
    162162            uhci_batch, USB_TRANSFER_BATCH_ARGS(*batch),
    163163            uhci_batch->td_count);
     
    174174
    175175                        usb_log_debug("Batch %p found error TD(%zu->%p):%"
    176                             PRIx32 ".\n", uhci_batch, i,
     176                            PRIx32 ".", uhci_batch, i,
    177177                            &uhci_batch->tds[i], uhci_batch->tds[i].status);
    178178                        td_print_status(&uhci_batch->tds[i]);
     
    260260        uhci_batch->base.ep->toggle = toggle;
    261261        usb_log_debug2(
    262             "Batch %p %s %s " USB_TRANSFER_BATCH_FMT " initialized.\n", \
     262            "Batch %p %s %s " USB_TRANSFER_BATCH_FMT " initialized.", \
    263263            uhci_batch,
    264264            usb_str_transfer_type(uhci_batch->base.ep->transfer_type),
     
    333333        td_set_ioc(&uhci_batch->tds[td]);
    334334
    335         usb_log_debug2("Control last TD status: %x.\n",
     335        usb_log_debug2("Control last TD status: %x.",
    336336            uhci_batch->tds[td].status);
    337337}
  • uspace/drv/bus/usb/uhci/uhci_rh.c

    rc1a966e ra1732929  
    202202        data[0] = ((value & STATUS_LINE_D_MINUS) ? 1 : 0)
    203203            | ((value & STATUS_LINE_D_PLUS) ? 2 : 0);
    204         RH_DEBUG(hub, port, "Bus state %" PRIx8 "(source %" PRIx16")\n",
     204        RH_DEBUG(hub, port, "Bus state %" PRIx8 "(source %" PRIx16")",
    205205            data[0], value);
    206206        *act_size = 1;
     
    248248        );
    249249        RH_DEBUG(hub, port, "Port status %" PRIx32 " (source %" PRIx16
    250             "%s)\n", uint32_usb2host(status), val,
     250            "%s)", uint32_usb2host(status), val,
    251251            hub->reset_changed[port] ? "-reset" : "");
    252252        memcpy(data, &status, sizeof(status));
     
    276276        case USB_HUB_FEATURE_PORT_ENABLE:
    277277                RH_DEBUG(hub, port, "Clear port enable (status %"
    278                     PRIx16 ")\n", status);
     278                    PRIx16 ")", status);
    279279                pio_write_16(hub->ports[port], val & ~STATUS_ENABLED);
    280280                break;
    281281        case USB_HUB_FEATURE_PORT_SUSPEND:
    282282                RH_DEBUG(hub, port, "Clear port suspend (status %"
    283                     PRIx16 ")\n", status);
     283                    PRIx16 ")", status);
    284284                pio_write_16(hub->ports[port], val & ~STATUS_SUSPEND);
    285285                // TODO we should do resume magic
    286                 usb_log_warning("Resume is not implemented on port %u\n", port);
     286                usb_log_warning("Resume is not implemented on port %u", port);
    287287                break;
    288288        case USB_HUB_FEATURE_PORT_POWER:
    289                 RH_DEBUG(hub, port, "Clear port power (status %" PRIx16 ")\n",
     289                RH_DEBUG(hub, port, "Clear port power (status %" PRIx16 ")",
    290290                    status);
    291291                /* We are always powered */
    292                 usb_log_warning("Tried to power off port %u\n", port);
     292                usb_log_warning("Tried to power off port %u", port);
    293293                break;
    294294        case USB_HUB_FEATURE_C_PORT_CONNECTION:
    295295                RH_DEBUG(hub, port, "Clear port conn change (status %"
    296                     PRIx16 ")\n", status);
     296                    PRIx16 ")", status);
    297297                pio_write_16(hub->ports[port], val | STATUS_CONNECTED_CHANGED);
    298298                break;
    299299        case USB_HUB_FEATURE_C_PORT_RESET:
    300300                RH_DEBUG(hub, port, "Clear port reset change (status %"
    301                     PRIx16 ")\n", status);
     301                    PRIx16 ")", status);
    302302                hub->reset_changed[port] = false;
    303303                break;
    304304        case USB_HUB_FEATURE_C_PORT_ENABLE:
    305305                RH_DEBUG(hub, port, "Clear port enable change (status %"
    306                     PRIx16 ")\n", status);
     306                    PRIx16 ")", status);
    307307                pio_write_16(hub->ports[port], status | STATUS_ENABLED_CHANGED);
    308308                break;
    309309        case USB_HUB_FEATURE_C_PORT_SUSPEND:
    310310                RH_DEBUG(hub, port, "Clear port suspend change (status %"
    311                     PRIx16 ")\n", status);
     311                    PRIx16 ")", status);
    312312                //TODO
    313313                return ENOTSUP;
    314314        case USB_HUB_FEATURE_C_PORT_OVER_CURRENT:
    315315                RH_DEBUG(hub, port, "Clear port OC change (status %"
    316                     PRIx16 ")\n", status);
     316                    PRIx16 ")", status);
    317317                /* UHCI Does not report over current */
    318318                //TODO: newer chips do, but some have broken wiring
     
    320320        default:
    321321                RH_DEBUG(hub, port, "Clear unknown feature %d (status %"
    322                     PRIx16 ")\n", feature, status);
    323                 usb_log_warning("Clearing feature %d is unsupported\n",
     322                    PRIx16 ")", feature, status);
     323                usb_log_warning("Clearing feature %d is unsupported",
    324324                    feature);
    325325                return ESTALL;
     
    348348        case USB_HUB_FEATURE_PORT_RESET:
    349349                RH_DEBUG(hub, port, "Set port reset before (status %" PRIx16
    350                     ")\n", status);
     350                    ")", status);
    351351                uhci_port_reset_enable(hub->ports[port]);
    352352                hub->reset_changed[port] = true;
    353353                RH_DEBUG(hub, port, "Set port reset after (status %" PRIx16
    354                     ")\n", pio_read_16(hub->ports[port]));
     354                    ")", pio_read_16(hub->ports[port]));
    355355                break;
    356356        case USB_HUB_FEATURE_PORT_SUSPEND:
    357357                RH_DEBUG(hub, port, "Set port suspend (status %" PRIx16
    358                     ")\n", status);
     358                    ")", status);
    359359                pio_write_16(hub->ports[port],
    360360                    (status & ~STATUS_WC_BITS) | STATUS_SUSPEND);
    361                 usb_log_warning("Suspend is not implemented on port %u\n", port);
     361                usb_log_warning("Suspend is not implemented on port %u", port);
    362362                break;
    363363        case USB_HUB_FEATURE_PORT_POWER:
    364364                RH_DEBUG(hub, port, "Set port power (status %" PRIx16
    365                     ")\n", status);
     365                    ")", status);
    366366                /* We are always powered */
    367                 usb_log_warning("Tried to power port %u\n", port);
     367                usb_log_warning("Tried to power port %u", port);
    368368                break;
    369369        case USB_HUB_FEATURE_C_PORT_CONNECTION:
     
    372372        case USB_HUB_FEATURE_C_PORT_OVER_CURRENT:
    373373                RH_DEBUG(hub, port, "Set port change flag (status %" PRIx16
    374                     ")\n", status);
     374                    ")", status);
    375375                /* These are voluntary and don't have to be set
    376376                 * there is no way we could do it on UHCI anyway */
     
    378378        default:
    379379                RH_DEBUG(hub, port, "Set unknown feature %d (status %" PRIx16
    380                     ")\n", feature, status);
    381                 usb_log_warning("Setting feature %d is unsupported\n",
     380                    ")", feature, status);
     381                usb_log_warning("Setting feature %d is unsupported",
    382382                    feature);
    383383                return ESTALL;
     
    418418                RH_DEBUG(hub, -1, "Event mask %" PRIx8
    419419                    " (status_a %" PRIx16 "%s),"
    420                     " (status_b %" PRIx16 "%s)\n", status,
     420                    " (status_b %" PRIx16 "%s)", status,
    421421                    status_a, hub->reset_changed[0] ? "-reset" : "",
    422422                    status_b, hub->reset_changed[1] ? "-reset" : "" );
Note: See TracChangeset for help on using the changeset viewer.