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


Ignore:
Timestamp:
2018-01-15T17:04:34Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, 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/ohci
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/endpoint_list.c

    rc1a966e ra1732929  
    5757        instance->list_head = malloc32(sizeof(ed_t));
    5858        if (!instance->list_head) {
    59                 usb_log_error("Failed to allocate list head.\n");
     59                usb_log_error("Failed to allocate list head.");
    6060                return ENOMEM;
    6161        }
    6262        instance->list_head_pa = addr_to_phys(instance->list_head);
    63         usb_log_debug2("Transfer list %s setup with ED: %p(0x%0" PRIx32 ")).\n",
     63        usb_log_debug2("Transfer list %s setup with ED: %p(0x%0" PRIx32 ")).",
    6464            name, instance->list_head, instance->list_head_pa);
    6565
     
    9696        assert(instance);
    9797        assert(ep);
    98         usb_log_debug2("Queue %s: Adding endpoint(%p).\n", instance->name, ep);
     98        usb_log_debug2("Queue %s: Adding endpoint(%p).", instance->name, ep);
    9999
    100100        fibril_mutex_lock(&instance->guard);
     
    126126        ohci_endpoint_t *first = list_get_instance(
    127127            list_first(&instance->endpoint_list), ohci_endpoint_t, link);
    128         usb_log_debug("HCD EP(%p) added to list %s, first is %p(%p).\n",
     128        usb_log_debug("HCD EP(%p) added to list %s, first is %p(%p).",
    129129                ep, instance->name, first, first->ed);
    130130        if (last_ed == instance->list_head) {
    131                 usb_log_debug2("%s head ED(%p-0x%0" PRIx32 "): %x:%x:%x:%x.\n",
     131                usb_log_debug2("%s head ED(%p-0x%0" PRIx32 "): %x:%x:%x:%x.",
    132132                    instance->name, last_ed, instance->list_head_pa,
    133133                    last_ed->status, last_ed->td_tail, last_ed->td_head,
     
    151151        fibril_mutex_lock(&instance->guard);
    152152
    153         usb_log_debug2("Queue %s: removing endpoint(%p).\n", instance->name, ep);
     153        usb_log_debug2("Queue %s: removing endpoint(%p).", instance->name, ep);
    154154
    155155        const char *qpos = NULL;
     
    171171        write_barrier();
    172172
    173         usb_log_debug("HCD EP(%p) removed (%s) from %s, next %x.\n",
     173        usb_log_debug("HCD EP(%p) removed (%s) from %s, next %x.",
    174174            ep, qpos, instance->name, ep->ed->next);
    175175
  • uspace/drv/bus/usb/ohci/hc.c

    rc1a966e ra1732929  
    136136        OHCI_WR(code->cmds[1].value, OHCI_USED_INTERRUPTS);
    137137
    138         usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n",
     138        usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.",
    139139            RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]);
    140140
     
    160160            (void **) &instance->registers);
    161161        if (ret != EOK) {
    162                 usb_log_error("Failed to gain access to registers: %s.\n",
     162                usb_log_error("Failed to gain access to registers: %s.",
    163163                    str_error(ret));
    164164                return ret;
    165165        }
    166         usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible.\n",
     166        usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible.",
    167167            hw_res->mem_ranges.ranges[0].address.absolute,
    168168            hw_res->mem_ranges.ranges[0].size);
     
    173173        ret = hc_init_memory(instance);
    174174        if (ret != EOK) {
    175                 usb_log_error("Failed to create OHCI memory structures: %s.\n",
     175                usb_log_error("Failed to create OHCI memory structures: %s.",
    176176                    str_error(ret));
    177177                // TODO: We should disable pio access here
     
    293293        /* Check for root hub communication */
    294294        if (batch->target.address == ohci_rh_get_address(&hc->rh)) {
    295                 usb_log_debug("OHCI root hub request.\n");
     295                usb_log_debug("OHCI root hub request.");
    296296                return ohci_rh_schedule(&hc->rh, batch);
    297297        }
     
    341341        if ((status & ~I_SF) == 0) /* ignore sof status */
    342342                return;
    343         usb_log_debug2("OHCI(%p) interrupt: %x.\n", hc, status);
     343        usb_log_debug2("OHCI(%p) interrupt: %x.", hc, status);
    344344        if (status & I_RHSC)
    345345                ohci_rh_interrupt(&hc->rh);
     
    347347        if (status & I_WDH) {
    348348                fibril_mutex_lock(&hc->guard);
    349                 usb_log_debug2("HCCA: %p-%#" PRIx32 " (%p).\n", hc->hcca,
     349                usb_log_debug2("HCCA: %p-%#" PRIx32 " (%p).", hc->hcca,
    350350                    OHCI_RD(hc->registers->hcca),
    351351                    (void *) addr_to_phys(hc->hcca));
    352                 usb_log_debug2("Periodic current: %#" PRIx32 ".\n",
     352                usb_log_debug2("Periodic current: %#" PRIx32 ".",
    353353                    OHCI_RD(hc->registers->periodic_current));
    354354
     
    370370
    371371        if (status & I_UE) {
    372                 usb_log_fatal("Error like no other!\n");
     372                usb_log_fatal("Error like no other!");
    373373                hc_start(&hc->base);
    374374        }
     
    387387        hc_t *instance = hcd_to_hc(hcd);
    388388
    389         usb_log_debug("Requesting OHCI control.\n");
     389        usb_log_debug("Requesting OHCI control.");
    390390        if (OHCI_RD(instance->registers->revision) & R_LEGACY_FLAG) {
    391391                /* Turn off legacy emulation, it should be enough to zero
     
    396396                volatile uint32_t *ohci_emulation_reg =
    397397                (uint32_t*)((char*)instance->registers + LEGACY_REGS_OFFSET);
    398                 usb_log_debug("OHCI legacy register %p: %x.\n",
     398                usb_log_debug("OHCI legacy register %p: %x.",
    399399                    ohci_emulation_reg, OHCI_RD(*ohci_emulation_reg));
    400400                /* Zero everything but A20State */
     
    402402                OHCI_CLR(*ohci_emulation_reg, ~0x100);
    403403                usb_log_debug(
    404                     "OHCI legacy register (should be 0 or 0x100) %p: %x.\n",
     404                    "OHCI legacy register (should be 0 or 0x100) %p: %x.",
    405405                    ohci_emulation_reg, OHCI_RD(*ohci_emulation_reg));
    406406        }
     
    408408        /* Interrupt routing enabled => smm driver is active */
    409409        if (OHCI_RD(instance->registers->control) & C_IR) {
    410                 usb_log_debug("SMM driver: request ownership change.\n");
     410                usb_log_debug("SMM driver: request ownership change.");
    411411                // TODO: should we ack interrupts before doing this?
    412412                OHCI_SET(instance->registers->command_status, CS_OCR);
     
    415415                        async_usleep(1000);
    416416                }
    417                 usb_log_info("SMM driver: Ownership taken.\n");
     417                usb_log_info("SMM driver: Ownership taken.");
    418418                C_HCFS_SET(instance->registers->control, C_HCFS_RESET);
    419419                async_usleep(50000);
     
    424424        /* Interrupt routing disabled && status != USB_RESET => BIOS active */
    425425        if (hc_status != C_HCFS_RESET) {
    426                 usb_log_debug("BIOS driver found.\n");
     426                usb_log_debug("BIOS driver found.");
    427427                if (hc_status == C_HCFS_OPERATIONAL) {
    428                         usb_log_info("BIOS driver: HC operational.\n");
     428                        usb_log_info("BIOS driver: HC operational.");
    429429                        return EOK;
    430430                }
     
    432432                C_HCFS_SET(instance->registers->control, C_HCFS_RESUME);
    433433                async_usleep(20000);
    434                 usb_log_info("BIOS driver: HC resumed.\n");
     434                usb_log_info("BIOS driver: HC resumed.");
    435435                return EOK;
    436436        }
     
    438438        /* HC is in reset (hw startup) => no other driver
    439439         * maintain reset for at least the time specified in USB spec (50 ms)*/
    440         usb_log_debug("Host controller found in reset state.\n");
     440        usb_log_debug("Host controller found in reset state.");
    441441        async_usleep(50000);
    442442        return EOK;
     
    454454        /* OHCI guide page 42 */
    455455        assert(instance);
    456         usb_log_debug2("Started hc initialization routine.\n");
     456        usb_log_debug2("Started hc initialization routine.");
    457457
    458458        /* Save contents of fm_interval register */
    459459        const uint32_t fm_interval = OHCI_RD(instance->registers->fm_interval);
    460         usb_log_debug2("Old value of HcFmInterval: %x.\n", fm_interval);
     460        usb_log_debug2("Old value of HcFmInterval: %x.", fm_interval);
    461461
    462462        /* Reset hc */
    463         usb_log_debug2("HC reset.\n");
     463        usb_log_debug2("HC reset.");
    464464        size_t time = 0;
    465465        OHCI_WR(instance->registers->command_status, CS_HCR);
     
    468468                time += 10;
    469469        }
    470         usb_log_debug2("HC reset complete in %zu us.\n", time);
     470        usb_log_debug2("HC reset complete in %zu us.", time);
    471471
    472472        /* Restore fm_interval */
     
    475475
    476476        /* hc is now in suspend state */
    477         usb_log_debug2("HC should be in suspend state(%x).\n",
     477        usb_log_debug2("HC should be in suspend state(%x).",
    478478            OHCI_RD(instance->registers->control));
    479479
     
    484484        OHCI_WR(instance->registers->bulk_head,
    485485            instance->lists[USB_TRANSFER_BULK].list_head_pa);
    486         usb_log_debug2("Bulk HEAD set to: %p (%#" PRIx32 ").\n",
     486        usb_log_debug2("Bulk HEAD set to: %p (%#" PRIx32 ").",
    487487            instance->lists[USB_TRANSFER_BULK].list_head,
    488488            instance->lists[USB_TRANSFER_BULK].list_head_pa);
     
    490490        OHCI_WR(instance->registers->control_head,
    491491            instance->lists[USB_TRANSFER_CONTROL].list_head_pa);
    492         usb_log_debug2("Control HEAD set to: %p (%#" PRIx32 ").\n",
     492        usb_log_debug2("Control HEAD set to: %p (%#" PRIx32 ").",
    493493            instance->lists[USB_TRANSFER_CONTROL].list_head,
    494494            instance->lists[USB_TRANSFER_CONTROL].list_head_pa);
     
    496496        /* Enable queues */
    497497        OHCI_SET(instance->registers->control, (C_PLE | C_IE | C_CLE | C_BLE));
    498         usb_log_debug("Queues enabled(%x).\n",
     498        usb_log_debug("Queues enabled(%x).",
    499499            OHCI_RD(instance->registers->control));
    500500
     
    503503                OHCI_WR(instance->registers->interrupt_enable,
    504504                    OHCI_USED_INTERRUPTS);
    505                 usb_log_debug("Enabled interrupts: %x.\n",
     505                usb_log_debug("Enabled interrupts: %x.",
    506506                    OHCI_RD(instance->registers->interrupt_enable));
    507507                OHCI_WR(instance->registers->interrupt_enable, I_MI);
     
    513513        OHCI_WR(instance->registers->periodic_start,
    514514            ((frame_length / 10) * 9) & PS_MASK << PS_SHIFT);
    515         usb_log_debug2("All periodic start set to: %x(%u - 90%% of %d).\n",
     515        usb_log_debug2("All periodic start set to: %x(%u - 90%% of %d).",
    516516            OHCI_RD(instance->registers->periodic_start),
    517517            OHCI_RD(instance->registers->periodic_start), frame_length);
    518518        C_HCFS_SET(instance->registers->control, C_HCFS_OPERATIONAL);
    519         usb_log_debug("OHCI HC up and running (ctl_reg=0x%x).\n",
     519        usb_log_debug("OHCI HC up and running (ctl_reg=0x%x).",
    520520            OHCI_RD(instance->registers->control));
    521521
     
    536536        const int ret = endpoint_list_init(&instance->lists[type], name); \
    537537        if (ret != EOK) { \
    538                 usb_log_error("Failed to setup %s endpoint list: %s.\n", \
     538                usb_log_error("Failed to setup %s endpoint list: %s.", \
    539539                    name, str_error(ret)); \
    540540                endpoint_list_fini(&instance->lists[USB_TRANSFER_ISOCHRONOUS]);\
     
    577577        if (instance->hcca == NULL)
    578578                return ENOMEM;
    579         usb_log_debug2("OHCI HCCA initialized at %p.\n", instance->hcca);
     579        usb_log_debug2("OHCI HCCA initialized at %p.", instance->hcca);
    580580
    581581        for (unsigned i = 0; i < HCCA_INT_EP_COUNT; ++i) {
     
    583583                    instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa);
    584584        }
    585         usb_log_debug2("Interrupt HEADs set to: %p (%#" PRIx32 ").\n",
     585        usb_log_debug2("Interrupt HEADs set to: %p (%#" PRIx32 ").",
    586586            instance->lists[USB_TRANSFER_INTERRUPT].list_head,
    587587            instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa);
  • uspace/drv/bus/usb/ohci/ohci_batch.c

    rc1a966e ra1732929  
    175175        assert(ohci_batch);
    176176
    177         usb_log_debug("Batch %p checking %zu td(s) for completion.\n",
     177        usb_log_debug("Batch %p checking %zu td(s) for completion.",
    178178            &ohci_batch->base, ohci_batch->td_count);
    179         usb_log_debug2("ED: %08x:%08x:%08x:%08x.\n",
     179        usb_log_debug2("ED: %08x:%08x:%08x:%08x.",
    180180            ohci_batch->ed->status, ohci_batch->ed->td_head,
    181181            ohci_batch->ed->td_tail, ohci_batch->ed->next);
     
    196196        for (size_t i = 0; i < ohci_batch->td_count; ++i) {
    197197                assert(ohci_batch->tds[i] != NULL);
    198                 usb_log_debug("TD %zu: %08x:%08x:%08x:%08x.\n", i,
     198                usb_log_debug("TD %zu: %08x:%08x:%08x:%08x.", i,
    199199                    ohci_batch->tds[i]->status, ohci_batch->tds[i]->cbp,
    200200                    ohci_batch->tds[i]->next, ohci_batch->tds[i]->be);
     
    217217                            -= td_remain_size(ohci_batch->tds[i]);
    218218                } else {
    219                         usb_log_debug("Batch %p found error TD(%zu):%08x.\n",
     219                        usb_log_debug("Batch %p found error TD(%zu):%08x.",
    220220                            &ohci_batch->base, i,
    221221                            ohci_batch->tds[i]->status);
     
    295295        assert(dir == USB_DIRECTION_IN || dir == USB_DIRECTION_OUT);
    296296
    297         usb_log_debug("Using ED(%p): %08x:%08x:%08x:%08x.\n", ohci_batch->ed,
     297        usb_log_debug("Using ED(%p): %08x:%08x:%08x:%08x.", ohci_batch->ed,
    298298            ohci_batch->ed->status, ohci_batch->ed->td_tail,
    299299            ohci_batch->ed->td_head, ohci_batch->ed->next);
     
    312312            ohci_batch->tds[0], ohci_batch->tds[1], USB_DIRECTION_BOTH,
    313313            buffer, USB_SETUP_PACKET_SIZE, toggle);
    314         usb_log_debug("Created CONTROL SETUP TD: %08x:%08x:%08x:%08x.\n",
     314        usb_log_debug("Created CONTROL SETUP TD: %08x:%08x:%08x:%08x.",
    315315            ohci_batch->tds[0]->status, ohci_batch->tds[0]->cbp,
    316316            ohci_batch->tds[0]->next, ohci_batch->tds[0]->be);
     
    328328                    ohci_batch->tds[td_current + 1],
    329329                    data_dir, buffer, transfer_size, toggle);
    330                 usb_log_debug("Created CONTROL DATA TD: %08x:%08x:%08x:%08x.\n",
     330                usb_log_debug("Created CONTROL DATA TD: %08x:%08x:%08x:%08x.",
    331331                    ohci_batch->tds[td_current]->status,
    332332                    ohci_batch->tds[td_current]->cbp,
     
    344344        td_init(ohci_batch->tds[td_current], ohci_batch->tds[td_current + 1],
    345345            status_dir, NULL, 0, 1);
    346         usb_log_debug("Created CONTROL STATUS TD: %08x:%08x:%08x:%08x.\n",
     346        usb_log_debug("Created CONTROL STATUS TD: %08x:%08x:%08x:%08x.",
    347347            ohci_batch->tds[td_current]->status,
    348348            ohci_batch->tds[td_current]->cbp,
     
    350350            ohci_batch->tds[td_current]->be);
    351351        usb_log_debug2(
    352             "Batch %p %s %s " USB_TRANSFER_BATCH_FMT " initialized.\n", \
     352            "Batch %p %s %s " USB_TRANSFER_BATCH_FMT " initialized.", \
    353353            &ohci_batch->base,
    354354            usb_str_transfer_type(ohci_batch->base.ep->transfer_type),
     
    371371        usb_direction_t dir = ohci_batch->base.dir;
    372372        assert(dir == USB_DIRECTION_IN || dir == USB_DIRECTION_OUT);
    373         usb_log_debug("Using ED(%p): %08x:%08x:%08x:%08x.\n", ohci_batch->ed,
     373        usb_log_debug("Using ED(%p): %08x:%08x:%08x:%08x.", ohci_batch->ed,
    374374            ohci_batch->ed->status, ohci_batch->ed->td_tail,
    375375            ohci_batch->ed->td_head, ohci_batch->ed->next);
     
    386386                    dir, buffer, transfer_size, -1);
    387387
    388                 usb_log_debug("Created DATA TD: %08x:%08x:%08x:%08x.\n",
     388                usb_log_debug("Created DATA TD: %08x:%08x:%08x:%08x.",
    389389                    ohci_batch->tds[td_current]->status,
    390390                    ohci_batch->tds[td_current]->cbp,
     
    398398        }
    399399        usb_log_debug2(
    400             "Batch %p %s %s " USB_TRANSFER_BATCH_FMT " initialized.\n", \
     400            "Batch %p %s %s " USB_TRANSFER_BATCH_FMT " initialized.", \
    401401            &ohci_batch->base,
    402402            usb_str_transfer_type(ohci_batch->base.ep->transfer_type),
  • uspace/drv/bus/usb/ohci/ohci_rh.c

    rc1a966e ra1732929  
    114114        instance->registers = regs;
    115115        instance->port_count = OHCI_RD(regs->rh_desc_a) & RHDA_NDS_MASK;
    116         usb_log_debug2("rh_desc_a: %x.\n", OHCI_RD(regs->rh_desc_a));
     116        usb_log_debug2("rh_desc_a: %x.", OHCI_RD(regs->rh_desc_a));
    117117        if (instance->port_count > OHCI_MAX_PORTS) {
    118118                usb_log_warning("OHCI specification does not allow %d ports. "
    119                     "Max %d ports will be used.\n", instance->port_count,
     119                    "Max %d ports will be used.", instance->port_count,
    120120                    OHCI_MAX_PORTS);
    121121                instance->port_count = OHCI_MAX_PORTS;
    122122        }
    123         usb_log_info("%s: Found %u ports.\n", name, instance->port_count);
     123        usb_log_info("%s: Found %u ports.", name, instance->port_count);
    124124
    125125#if defined OHCI_POWER_SWITCH_no
    126         usb_log_info("%s: Set power mode to no power switching.\n", name);
     126        usb_log_info("%s: Set power mode to no power switching.", name);
    127127        /* Set port power mode to no power-switching. (always on) */
    128128        OHCI_SET(regs->rh_desc_a, RHDA_NPS_FLAG);
     
    132132
    133133#elif defined OHCI_POWER_SWITCH_ganged
    134         usb_log_info("%s: Set power mode to ganged power switching.\n", name);
     134        usb_log_info("%s: Set power mode to ganged power switching.", name);
    135135        /* Set port power mode to ganged power-switching. */
    136136        OHCI_CLR(regs->rh_desc_a, RHDA_NPS_FLAG);
     
    144144        OHCI_CLR(regs->rh_desc_a, RHDA_OCPM_FLAG);
    145145#else
    146         usb_log_info("%s: Set power mode to per-port power switching.\n", name);
     146        usb_log_info("%s: Set power mode to per-port power switching.", name);
    147147        /* Set port power mode to per port power-switching. */
    148148        OHCI_CLR(regs->rh_desc_a, RHDA_NPS_FLAG);
     
    356356        case USB_HUB_FEATURE_C_PORT_RESET:        /*20*/
    357357                usb_log_debug2("Clearing port C_CONNECTION, C_ENABLE, "
    358                     "C_SUSPEND, C_OC or C_RESET on port %u.\n", port);
     358                    "C_SUSPEND, C_OC or C_RESET on port %u.", port);
    359359                /* Bit offsets correspond to the feature number */
    360360                OHCI_WR(hub->registers->rh_port_status[port],
     
    405405        case USB_HUB_FEATURE_PORT_RESET:   /*4*/
    406406                usb_log_debug2("Setting port POWER, ENABLE, SUSPEND or RESET "
    407                     "on port %u.\n", port);
     407                    "on port %u.", port);
    408408                /* Bit offsets correspond to the feature number */
    409409                OHCI_WR(hub->registers->rh_port_status[port], 1 << feature);
     
    451451        }
    452452
    453         usb_log_debug2("OHCI root hub interrupt mask: %hx.\n", mask);
     453        usb_log_debug2("OHCI root hub interrupt mask: %hx.", mask);
    454454
    455455        if (mask == 0)
Note: See TracChangeset for help on using the changeset viewer.