Changeset 96e01fbc in mainline for uspace/drv/bus/usb


Ignore:
Timestamp:
2012-08-31T17:30:29Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2be2506a
Parents:
e0d5bc5 (diff), 0d57c3e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
uspace/drv/bus/usb
Files:
1 added
63 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/main.c

    re0d5bc5 r96e01fbc  
    4949
    5050static int ehci_dev_add(ddf_dev_t *device);
    51 /*----------------------------------------------------------------------------*/
     51
    5252static driver_ops_t ehci_driver_ops = {
    5353        .dev_add = ehci_dev_add,
    5454};
    55 /*----------------------------------------------------------------------------*/
     55
    5656static driver_t ehci_driver = {
    5757        .name = NAME,
     
    6262};
    6363
    64 /*----------------------------------------------------------------------------*/
     64
    6565/** Initializes a new ddf driver instance of EHCI hcd.
    6666 *
     
    8484        CHECK_RET_RETURN(ret,
    8585            "Failed to get memory addresses for %" PRIun ": %s.\n",
    86             device->handle, str_error(ret));
     86            ddf_dev_get_handle(device), str_error(ret));
    8787        usb_log_info("Memory mapped regs at 0x%" PRIxn " (size %zu), IRQ %d.\n",
    8888            reg_base, reg_size, irq);
     
    104104        /* High Speed, no bandwidth */
    105105        hcd_init(ehci_hc, USB_SPEED_HIGH, 0, NULL);
    106         hc_fun->ops = &hc_ops;
     106        ddf_fun_set_ops(hc_fun,  &hc_ops);
    107107
    108108        ret = ddf_fun_bind(hc_fun);
     
    116116
    117117        usb_log_info("Controlling new EHCI device `%s' (handle %" PRIun ").\n",
    118             device->name, device->handle);
     118            ddf_dev_get_name(device), ddf_dev_get_handle(device));
    119119
    120120        return EOK;
    121121#undef CHECK_RET_RETURN
    122122}
    123 /*----------------------------------------------------------------------------*/
     123
    124124/** Initializes global driver structures (NONE).
    125125 *
  • uspace/drv/bus/usb/ehci/res.c

    re0d5bc5 r96e01fbc  
    7676 * @return Error code.
    7777 */
    78 int get_my_registers(const ddf_dev_t *dev,
     78int get_my_registers(ddf_dev_t *dev,
    7979    uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no)
    8080{
     
    8282       
    8383        async_sess_t *parent_sess = devman_parent_device_connect(
    84             EXCHANGE_SERIALIZE, dev->handle, IPC_FLAG_BLOCKING);
     84            EXCHANGE_SERIALIZE, ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
    8585        if (!parent_sess)
    8686                return ENOMEM;
     
    115115 * @return Error code.
    116116 */
    117 int enable_interrupts(const ddf_dev_t *device)
     117int enable_interrupts(ddf_dev_t *device)
    118118{
    119119        async_sess_t *parent_sess = devman_parent_device_connect(
    120             EXCHANGE_SERIALIZE, device->handle, IPC_FLAG_BLOCKING);
     120            EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
    121121        if (!parent_sess)
    122122                return ENOMEM;
     
    134134 * @return Error code.
    135135 */
    136 static int disable_extended_caps(const ddf_dev_t *device, unsigned eecp)
     136static int disable_extended_caps(ddf_dev_t *device, unsigned eecp)
    137137{
    138138        /* nothing to do */
     
    141141
    142142        async_sess_t *parent_sess = devman_parent_device_connect(
    143             EXCHANGE_SERIALIZE, device->handle, IPC_FLAG_BLOCKING);
     143            EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
    144144        if (!parent_sess)
    145145                return ENOMEM;
     
    234234}
    235235
    236 int disable_legacy(const ddf_dev_t *device, uintptr_t reg_base, size_t reg_size)
     236int disable_legacy(ddf_dev_t *device, uintptr_t reg_base, size_t reg_size)
    237237{
    238238        assert(device);
  • uspace/drv/bus/usb/ehci/res.h

    re0d5bc5 r96e01fbc  
    3838#include <ddf/driver.h>
    3939
    40 int get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
    41 int enable_interrupts(const ddf_dev_t *);
    42 int disable_legacy(const ddf_dev_t *, uintptr_t, size_t);
     40int get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *);
     41int enable_interrupts(ddf_dev_t *);
     42int disable_legacy(ddf_dev_t *, uintptr_t, size_t);
    4343
    4444#endif
  • uspace/drv/bus/usb/ohci/endpoint_list.c

    re0d5bc5 r96e01fbc  
    6565        return EOK;
    6666}
    67 /*----------------------------------------------------------------------------*/
     67
    6868/** Set the next list in transfer list chain.
    6969 *
     
    8080        ed_append_ed(instance->list_head, next->list_head);
    8181}
    82 /*----------------------------------------------------------------------------*/
     82
    8383/** Add endpoint to the list and queue.
    8484 *
     
    132132        fibril_mutex_unlock(&instance->guard);
    133133}
    134 /*----------------------------------------------------------------------------*/
     134
    135135/** Remove endpoint from the list and queue.
    136136 *
     
    162162                qpos = "NOT FIRST";
    163163        }
    164         assert((prev_ed->next & ED_NEXT_PTR_MASK) == addr_to_phys(ep->ed));
     164        assert(ed_next(prev_ed) == addr_to_phys(ep->ed));
    165165        prev_ed->next = ep->ed->next;
    166166        /* Make sure ED is updated */
  • uspace/drv/bus/usb/ohci/hc.c

    re0d5bc5 r96e01fbc  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829/** @addtogroup drvusbohcihc
    2930 * @{
     
    3233 * @brief OHCI Host controller driver routines
    3334 */
     35
    3436#include <errno.h>
    3537#include <str_error.h>
     
    4951static const irq_pio_range_t ohci_pio_ranges[] = {
    5052        {
    51                 .base = 0,      /* filled later */
     53                .base = 0,
    5254                .size = sizeof(ohci_regs_t)
    5355        }
     
    5557
    5658static const irq_cmd_t ohci_irq_commands[] = {
    57         { .cmd = CMD_PIO_READ_32, .dstarg = 1, .addr = NULL /* filled later */ },
    58         { .cmd = CMD_BTEST, .srcarg = 1, .dstarg = 2, .value = OHCI_USED_INTERRUPTS },
    59         { .cmd = CMD_PREDICATE, .srcarg = 2, .value = 2 },
    60         { .cmd = CMD_PIO_WRITE_A_32, .srcarg = 1, .addr = NULL /* filled later */ },
    61         { .cmd = CMD_ACCEPT },
     59        {
     60                .cmd = CMD_PIO_READ_32,
     61                .dstarg = 1,
     62                .addr = NULL
     63        },
     64        {
     65                .cmd = CMD_AND,
     66                .srcarg = 1,
     67                .dstarg = 2,
     68                .value = 0
     69        },
     70        {
     71                .cmd = CMD_PREDICATE,
     72                .srcarg = 2,
     73                .value = 2
     74        },
     75        {
     76                .cmd = CMD_PIO_WRITE_A_32,
     77                .srcarg = 1,
     78                .addr = NULL
     79        },
     80        {
     81                .cmd = CMD_ACCEPT
     82        }
    6283};
    6384
     
    6889static int interrupt_emulator(hc_t *instance);
    6990static int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
    70 /*----------------------------------------------------------------------------*/
     91
    7192/** Get number of PIO ranges used in IRQ code.
    7293 * @return Number of ranges.
     
    7697        return sizeof(ohci_pio_ranges) / sizeof(irq_pio_range_t);
    7798}
    78 /*----------------------------------------------------------------------------*/
    79 /*----------------------------------------------------------------------------*/
     99
    80100/** Get number of commands used in IRQ code.
    81101 * @return Number of commands.
     
    85105        return sizeof(ohci_irq_commands) / sizeof(irq_cmd_t);
    86106}
    87 /*----------------------------------------------------------------------------*/
     107
    88108/** Generate IRQ code.
    89109 * @param[out] ranges PIO ranges buffer.
     
    112132        cmds[0].addr = (void *) &registers->interrupt_status;
    113133        cmds[3].addr = (void *) &registers->interrupt_status;
     134        OHCI_WR(cmds[1].value, OHCI_USED_INTERRUPTS);
    114135
    115136        return EOK;
    116137}
    117 /*----------------------------------------------------------------------------*/
     138
    118139/** Announce OHCI root hub to the DDF
    119140 *
     
    166187
    167188        ret = usb_device_manager_bind_address(&instance->generic.dev_manager,
    168             instance->rh.address, hub_fun->handle);
     189            instance->rh.address, ddf_fun_get_handle(hub_fun));
    169190        if (ret != EOK)
    170191                usb_log_warning("Failed to bind root hub address: %s.\n",
     
    174195#undef CHECK_RET_RELEASE
    175196}
    176 /*----------------------------------------------------------------------------*/
     197
    177198/** Initialize OHCI hc driver structure
    178199 *
     
    227248        return EOK;
    228249}
    229 /*----------------------------------------------------------------------------*/
     250
    230251void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep)
    231252{
     
    241262        switch (ep->transfer_type) {
    242263        case USB_TRANSFER_CONTROL:
    243                 instance->registers->control &= ~C_CLE;
     264                OHCI_CLR(instance->registers->control, C_CLE);
    244265                endpoint_list_add_ep(list, ohci_ep);
    245                 instance->registers->control_current = 0;
    246                 instance->registers->control |= C_CLE;
     266                OHCI_WR(instance->registers->control_current, 0);
     267                OHCI_SET(instance->registers->control, C_CLE);
    247268                break;
    248269        case USB_TRANSFER_BULK:
    249                 instance->registers->control &= ~C_BLE;
     270                OHCI_CLR(instance->registers->control, C_BLE);
    250271                endpoint_list_add_ep(list, ohci_ep);
    251                 instance->registers->control |= C_BLE;
     272                OHCI_WR(instance->registers->bulk_current, 0);
     273                OHCI_SET(instance->registers->control, C_BLE);
    252274                break;
    253275        case USB_TRANSFER_ISOCHRONOUS:
    254276        case USB_TRANSFER_INTERRUPT:
    255                 instance->registers->control &= (~C_PLE & ~C_IE);
     277                OHCI_CLR(instance->registers->control, C_PLE | C_IE);
    256278                endpoint_list_add_ep(list, ohci_ep);
    257                 instance->registers->control |= C_PLE | C_IE;
    258                 break;
    259         }
    260 }
    261 /*----------------------------------------------------------------------------*/
     279                OHCI_SET(instance->registers->control, C_PLE | C_IE);
     280                break;
     281        }
     282}
     283
    262284void hc_dequeue_endpoint(hc_t *instance, const endpoint_t *ep)
    263285{
     
    273295        switch (ep->transfer_type) {
    274296        case USB_TRANSFER_CONTROL:
    275                 instance->registers->control &= ~C_CLE;
     297                OHCI_CLR(instance->registers->control, C_CLE);
    276298                endpoint_list_remove_ep(list, ohci_ep);
    277                 instance->registers->control_current = 0;
    278                 instance->registers->control |= C_CLE;
     299                OHCI_WR(instance->registers->control_current, 0);
     300                OHCI_SET(instance->registers->control, C_CLE);
    279301                break;
    280302        case USB_TRANSFER_BULK:
    281                 instance->registers->control &= ~C_BLE;
     303                OHCI_CLR(instance->registers->control, C_BLE);
    282304                endpoint_list_remove_ep(list, ohci_ep);
    283                 instance->registers->control |= C_BLE;
     305                OHCI_WR(instance->registers->bulk_current, 0);
     306                OHCI_SET(instance->registers->control, C_BLE);
    284307                break;
    285308        case USB_TRANSFER_ISOCHRONOUS:
    286309        case USB_TRANSFER_INTERRUPT:
    287                 instance->registers->control &= (~C_PLE & ~C_IE);
     310                OHCI_CLR(instance->registers->control, C_PLE | C_IE);
    288311                endpoint_list_remove_ep(list, ohci_ep);
    289                 instance->registers->control |= C_PLE | C_IE;
     312                OHCI_SET(instance->registers->control, C_PLE | C_IE);
    290313                break;
    291314        default:
     
    293316        }
    294317}
    295 /*----------------------------------------------------------------------------*/
     318
    296319/** Add USB transfer to the schedule.
    297320 *
     
    308331        /* Check for root hub communication */
    309332        if (batch->ep->address == instance->rh.address) {
     333                usb_log_debug("OHCI root hub request.\n");
    310334                rh_request(&instance->rh, batch);
    311335                return EOK;
     
    323347        {
    324348        case USB_TRANSFER_CONTROL:
    325                 instance->registers->command_status |= CS_CLF;
     349                OHCI_SET(instance->registers->command_status, CS_CLF);
    326350                break;
    327351        case USB_TRANSFER_BULK:
    328                 instance->registers->command_status |= CS_BLF;
     352                OHCI_SET(instance->registers->command_status, CS_BLF);
    329353                break;
    330354        default:
     
    334358        return EOK;
    335359}
    336 /*----------------------------------------------------------------------------*/
     360
    337361/** Interrupt handling routine
    338362 *
     
    342366void hc_interrupt(hc_t *instance, uint32_t status)
    343367{
     368        status = OHCI_RD(status);
    344369        assert(instance);
    345370        if ((status & ~I_SF) == 0) /* ignore sof status */
     
    352377                fibril_mutex_lock(&instance->guard);
    353378                usb_log_debug2("HCCA: %p-%#" PRIx32 " (%p).\n", instance->hcca,
    354                     instance->registers->hcca,
     379                    OHCI_RD(instance->registers->hcca),
    355380                    (void *) addr_to_phys(instance->hcca));
    356381                usb_log_debug2("Periodic current: %#" PRIx32 ".\n",
    357                     instance->registers->periodic_current);
     382                    OHCI_RD(instance->registers->periodic_current));
    358383
    359384                link_t *current = list_first(&instance->pending_batches);
     
    379404
    380405}
    381 /*----------------------------------------------------------------------------*/
     406
    382407/** Check status register regularly
    383408 *
     
    397422        return EOK;
    398423}
    399 /*----------------------------------------------------------------------------*/
     424
    400425/** Turn off any (BIOS)driver that might be in control of the device.
    401426 *
     
    410435
    411436        usb_log_debug("Requesting OHCI control.\n");
    412         if (instance->registers->revision & R_LEGACY_FLAG) {
     437        if (OHCI_RD(instance->registers->revision) & R_LEGACY_FLAG) {
    413438                /* Turn off legacy emulation, it should be enough to zero
    414439                 * the lowest bit, but it caused problems. Thus clear all
     
    419444                (uint32_t*)((char*)instance->registers + LEGACY_REGS_OFFSET);
    420445                usb_log_debug("OHCI legacy register %p: %x.\n",
    421                     ohci_emulation_reg, *ohci_emulation_reg);
     446                    ohci_emulation_reg, OHCI_RD(*ohci_emulation_reg));
    422447                /* Zero everything but A20State */
    423                 *ohci_emulation_reg &= 0x100;
     448                OHCI_CLR(*ohci_emulation_reg, ~0x100);
    424449                usb_log_debug(
    425450                    "OHCI legacy register (should be 0 or 0x100) %p: %x.\n",
    426                     ohci_emulation_reg, *ohci_emulation_reg);
     451                    ohci_emulation_reg, OHCI_RD(*ohci_emulation_reg));
    427452        }
    428453
    429454        /* Interrupt routing enabled => smm driver is active */
    430         if (instance->registers->control & C_IR) {
     455        if (OHCI_RD(instance->registers->control) & C_IR) {
    431456                usb_log_debug("SMM driver: request ownership change.\n");
    432                 instance->registers->command_status |= CS_OCR;
     457                OHCI_SET(instance->registers->command_status, CS_OCR);
    433458                /* Hope that SMM actually knows its stuff or we can hang here */
    434                 while (instance->registers->control & C_IR) {
     459                while (OHCI_RD(instance->registers->control & C_IR)) {
    435460                        async_usleep(1000);
    436461                }
     
    449474                        return;
    450475                }
    451                 /* HC is suspended assert resume for 20ms, */
     476                /* HC is suspended assert resume for 20ms */
    452477                C_HCFS_SET(instance->registers->control, C_HCFS_RESUME);
    453478                async_usleep(20000);
     
    461486        async_usleep(50000);
    462487}
    463 /*----------------------------------------------------------------------------*/
     488
    464489/** OHCI hw initialization routine.
    465490 *
     
    473498
    474499        /* Save contents of fm_interval register */
    475         const uint32_t fm_interval = instance->registers->fm_interval;
     500        const uint32_t fm_interval = OHCI_RD(instance->registers->fm_interval);
    476501        usb_log_debug2("Old value of HcFmInterval: %x.\n", fm_interval);
    477502
     
    479504        usb_log_debug2("HC reset.\n");
    480505        size_t time = 0;
    481         instance->registers->command_status = CS_HCR;
    482         while (instance->registers->command_status & CS_HCR) {
     506        OHCI_WR(instance->registers->command_status, CS_HCR);
     507        while (OHCI_RD(instance->registers->command_status) & CS_HCR) {
    483508                async_usleep(10);
    484509                time += 10;
     
    487512
    488513        /* Restore fm_interval */
    489         instance->registers->fm_interval = fm_interval;
    490         assert((instance->registers->command_status & CS_HCR) == 0);
     514        OHCI_WR(instance->registers->fm_interval, fm_interval);
     515        assert((OHCI_RD(instance->registers->command_status) & CS_HCR) == 0);
    491516
    492517        /* hc is now in suspend state */
    493518        usb_log_debug2("HC should be in suspend state(%x).\n",
    494             instance->registers->control);
     519            OHCI_RD(instance->registers->control));
    495520
    496521        /* Use HCCA */
    497         instance->registers->hcca = addr_to_phys(instance->hcca);
     522        OHCI_WR(instance->registers->hcca, addr_to_phys(instance->hcca));
    498523
    499524        /* Use queues */
    500         instance->registers->bulk_head =
    501             instance->lists[USB_TRANSFER_BULK].list_head_pa;
     525        OHCI_WR(instance->registers->bulk_head,
     526            instance->lists[USB_TRANSFER_BULK].list_head_pa);
    502527        usb_log_debug2("Bulk HEAD set to: %p (%#" PRIx32 ").\n",
    503528            instance->lists[USB_TRANSFER_BULK].list_head,
    504529            instance->lists[USB_TRANSFER_BULK].list_head_pa);
    505530
    506         instance->registers->control_head =
    507             instance->lists[USB_TRANSFER_CONTROL].list_head_pa;
     531        OHCI_WR(instance->registers->control_head,
     532            instance->lists[USB_TRANSFER_CONTROL].list_head_pa);
    508533        usb_log_debug2("Control HEAD set to: %p (%#" PRIx32 ").\n",
    509534            instance->lists[USB_TRANSFER_CONTROL].list_head,
     
    511536
    512537        /* Enable queues */
    513         instance->registers->control |= (C_PLE | C_IE | C_CLE | C_BLE);
    514         usb_log_debug2("All queues enabled(%x).\n",
    515             instance->registers->control);
     538        OHCI_SET(instance->registers->control, (C_PLE | C_IE | C_CLE | C_BLE));
     539        usb_log_debug("Queues enabled(%x).\n",
     540            OHCI_RD(instance->registers->control));
    516541
    517542        /* Enable interrupts */
    518         instance->registers->interrupt_enable = OHCI_USED_INTERRUPTS;
    519         usb_log_debug2("Enabled interrupts: %x.\n",
    520             instance->registers->interrupt_enable);
    521         instance->registers->interrupt_enable = I_MI;
     543        OHCI_WR(instance->registers->interrupt_enable, OHCI_USED_INTERRUPTS);
     544        usb_log_debug("Enabled interrupts: %x.\n",
     545            OHCI_RD(instance->registers->interrupt_enable));
     546        OHCI_WR(instance->registers->interrupt_enable, I_MI);
    522547
    523548        /* Set periodic start to 90% */
    524         uint32_t frame_length = ((fm_interval >> FMI_FI_SHIFT) & FMI_FI_MASK);
    525         instance->registers->periodic_start = (frame_length / 10) * 9;
     549        const uint32_t frame_length =
     550            (fm_interval >> FMI_FI_SHIFT) & FMI_FI_MASK;
     551        OHCI_WR(instance->registers->periodic_start,
     552            ((frame_length / 10) * 9) & PS_MASK << PS_SHIFT);
    526553        usb_log_debug2("All periodic start set to: %x(%u - 90%% of %d).\n",
    527             instance->registers->periodic_start,
    528             instance->registers->periodic_start, frame_length);
    529 
     554            OHCI_RD(instance->registers->periodic_start),
     555            OHCI_RD(instance->registers->periodic_start), frame_length);
    530556        C_HCFS_SET(instance->registers->control, C_HCFS_OPERATIONAL);
    531557        usb_log_debug("OHCI HC up and running (ctl_reg=0x%x).\n",
    532             instance->registers->control);
    533 }
    534 /*----------------------------------------------------------------------------*/
     558            OHCI_RD(instance->registers->control));
     559}
     560
    535561/** Initialize schedule queues
    536562 *
     
    566592        return EOK;
    567593}
    568 /*----------------------------------------------------------------------------*/
     594
    569595/** Initialize memory structures used by the OHCI hcd.
    570596 *
     
    587613        if (instance->hcca == NULL)
    588614                return ENOMEM;
    589         bzero(instance->hcca, sizeof(hcca_t));
    590615        usb_log_debug2("OHCI HCCA initialized at %p.\n", instance->hcca);
    591616
    592         for (unsigned i = 0; i < 32; ++i) {
    593                 instance->hcca->int_ep[i] =
    594                     instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa;
     617        for (unsigned i = 0; i < HCCA_INT_EP_COUNT; ++i) {
     618                hcca_set_int_ep(instance->hcca, i,
     619                    instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa);
    595620        }
    596621        usb_log_debug2("Interrupt HEADs set to: %p (%#" PRIx32 ").\n",
  • uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.c

    re0d5bc5 r96e01fbc  
    5858                /* Mark as dead, used for dummy EDs at the beginning of
    5959                 * endpoint lists. */
    60                 instance->status = ED_STATUS_K_FLAG;
     60                OHCI_MEM32_WR(instance->status, ED_STATUS_K_FLAG);
    6161                return;
    6262        }
     
    6565
    6666        /* Status: address, endpoint nr, direction mask and max packet size. */
    67         instance->status = 0
    68             | ((ep->address & ED_STATUS_FA_MASK) << ED_STATUS_FA_SHIFT)
     67        OHCI_MEM32_WR(instance->status,
     68            ((ep->address & ED_STATUS_FA_MASK) << ED_STATUS_FA_SHIFT)
    6969            | ((ep->endpoint & ED_STATUS_EN_MASK) << ED_STATUS_EN_SHIFT)
    7070            | ((dir[ep->direction] & ED_STATUS_D_MASK) << ED_STATUS_D_SHIFT)
    7171            | ((ep->max_packet_size & ED_STATUS_MPS_MASK)
    72                 << ED_STATUS_MPS_SHIFT);
     72                << ED_STATUS_MPS_SHIFT));
    7373
    7474        /* Low speed flag */
    7575        if (ep->speed == USB_SPEED_LOW)
    76                 instance->status |= ED_STATUS_S_FLAG;
     76                OHCI_MEM32_SET(instance->status, ED_STATUS_S_FLAG);
    7777
    7878        /* Isochronous format flag */
    7979        if (ep->transfer_type == USB_TRANSFER_ISOCHRONOUS)
    80                 instance->status |= ED_STATUS_F_FLAG;
     80                OHCI_MEM32_SET(instance->status, ED_STATUS_F_FLAG);
    8181
    8282        /* Set TD to the list */
    8383        const uintptr_t pa = addr_to_phys(td);
    84         instance->td_head = pa & ED_TDHEAD_PTR_MASK;
    85         instance->td_tail = pa & ED_TDTAIL_PTR_MASK;
     84        OHCI_MEM32_WR(instance->td_head, pa & ED_TDHEAD_PTR_MASK);
     85        OHCI_MEM32_WR(instance->td_tail, pa & ED_TDTAIL_PTR_MASK);
    8686
    8787        /* Set toggle bit */
    8888        if (ep->toggle)
    89                 instance->td_head |= ED_TDHEAD_TOGGLE_CARRY;
     89                OHCI_MEM32_SET(instance->td_head, ED_TDHEAD_TOGGLE_CARRY);
    9090
    9191}
  • uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.h

    re0d5bc5 r96e01fbc  
    4444
    4545#include "completion_codes.h"
     46#include "mem_access.h"
    4647
    4748/**
     
    116117{
    117118        assert(instance);
    118         return (instance->td_head & ED_TDHEAD_HALTED_FLAG)
    119             || (instance->status & ED_STATUS_K_FLAG);
     119        return (OHCI_MEM32_RD(instance->td_head) & ED_TDHEAD_HALTED_FLAG)
     120            || (OHCI_MEM32_RD(instance->status) & ED_STATUS_K_FLAG);
     121}
     122
     123static inline void ed_clear_halt(ed_t *instance)
     124{
     125        assert(instance);
     126        OHCI_MEM32_CLR(instance->td_head, ED_TDHEAD_HALTED_FLAG);
    120127}
    121128
     
    128135{
    129136        assert(instance);
    130         return (instance->td_head & ED_TDHEAD_PTR_MASK)
    131             != (instance->td_tail & ED_TDTAIL_PTR_MASK);
     137        return (OHCI_MEM32_RD(instance->td_head) & ED_TDHEAD_PTR_MASK)
     138            != (OHCI_MEM32_RD(instance->td_tail) & ED_TDTAIL_PTR_MASK);
    132139}
    133140
     
    141148        assert(instance);
    142149        const uintptr_t pa = addr_to_phys(td);
    143         instance->td_tail = pa & ED_TDTAIL_PTR_MASK;
     150        OHCI_MEM32_WR(instance->td_tail, pa & ED_TDTAIL_PTR_MASK);
     151}
     152
     153static inline uint32_t ed_tail_td(const ed_t *instance)
     154{
     155        assert(instance);
     156        return OHCI_MEM32_RD(instance->td_tail) & ED_TDTAIL_PTR_MASK;
     157}
     158
     159static inline uint32_t ed_head_td(const ed_t *instance)
     160{
     161        assert(instance);
     162        return OHCI_MEM32_RD(instance->td_head) & ED_TDHEAD_PTR_MASK;
    144163}
    145164
     
    155174        const uint32_t pa = addr_to_phys(next);
    156175        assert((pa & ED_NEXT_PTR_MASK) << ED_NEXT_PTR_SHIFT == pa);
    157         instance->next = pa;
     176        OHCI_MEM32_WR(instance->next, pa);
     177}
     178
     179static inline uint32_t ed_next(const ed_t *instance)
     180{
     181        assert(instance);
     182        return OHCI_MEM32_RD(instance->next) & ED_NEXT_PTR_MASK;
    158183}
    159184
     
    166191{
    167192        assert(instance);
    168         return (instance->td_head & ED_TDHEAD_TOGGLE_CARRY) ? 1 : 0;
     193        return (OHCI_MEM32_RD(instance->td_head) & ED_TDHEAD_TOGGLE_CARRY) ? 1 : 0;
    169194}
    170195
     
    178203        assert(instance);
    179204        if (toggle) {
    180                 instance->td_head |= ED_TDHEAD_TOGGLE_CARRY;
     205                OHCI_MEM32_SET(instance->td_head, ED_TDHEAD_TOGGLE_CARRY);
    181206        } else {
    182207                /* Clear halted flag when reseting toggle TODO: Why? */
    183                 instance->td_head &= ~ED_TDHEAD_TOGGLE_CARRY;
    184                 instance->td_head &= ~ED_TDHEAD_HALTED_FLAG;
     208                OHCI_MEM32_CLR(instance->td_head, ED_TDHEAD_TOGGLE_CARRY);
     209                OHCI_MEM32_CLR(instance->td_head, ED_TDHEAD_HALTED_FLAG);
    185210        }
    186211}
  • uspace/drv/bus/usb/ohci/hw_struct/hcca.h

    re0d5bc5 r96e01fbc  
    3838#include <malloc.h>
    3939
     40#include "mem_access.h"
     41
     42#define HCCA_INT_EP_COUNT  32
     43
    4044/** Host controller communication area.
    4145 * Shared memory used for communication between the controller and the driver.
    4246 */
    4347typedef struct hcca {
    44         uint32_t int_ep[32];
     48        /** Interrupt endpoints */
     49        uint32_t int_ep[HCCA_INT_EP_COUNT];
     50        /** Frame number. */
    4551        uint16_t frame_number;
    4652        uint16_t pad1;
     53        /** Pointer to the last completed TD. (useless) */
    4754        uint32_t done_head;
     55        /** Padding to make the size 256B */
    4856        uint32_t reserved[30];
    4957} hcca_t;
    5058
    51 static inline void * hcca_get(void)
     59/** Allocate properly aligned structure.
     60 *
     61 * The returned structure is zeroed upon allocation.
     62 *
     63 * @return Usable HCCA memory structure.
     64 */
     65static inline hcca_t * hcca_get(void)
    5266{
    5367        assert(sizeof(hcca_t) == 256);
    54         return memalign(256, sizeof(hcca_t));
     68        hcca_t *hcca = memalign(256, sizeof(hcca_t));
     69        if (hcca)
     70                bzero(hcca, sizeof(hcca_t));
     71        return hcca;
     72}
     73
     74/** Set HCCA interrupt endpoint pointer table entry.
     75 * @param hcca HCCA memory structure.
     76 * @param index table index.
     77 * @param pa Physical address.
     78 */
     79static inline void hcca_set_int_ep(hcca_t *hcca, unsigned index, uintptr_t pa)
     80{
     81        assert(hcca);
     82        assert(index < HCCA_INT_EP_COUNT);
     83        OHCI_MEM32_WR(hcca->int_ep[index], pa);
     84
    5585}
    5686#endif
  • uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.c

    re0d5bc5 r96e01fbc  
    3333 */
    3434#include <usb/usb.h>
     35#include <mem.h>
     36#include "../utils/malloc32.h"
    3537#include "transfer_descriptor.h"
    3638
     
    5860        bzero(instance, sizeof(td_t));
    5961        /* Set PID and Error code */
    60         instance->status = 0
    61             | ((dir[direction] & TD_STATUS_DP_MASK) << TD_STATUS_DP_SHIFT)
    62             | ((CC_NOACCESS2 & TD_STATUS_CC_MASK) << TD_STATUS_CC_SHIFT);
     62        OHCI_MEM32_WR(instance->status,
     63            ((dir[direction] & TD_STATUS_DP_MASK) << TD_STATUS_DP_SHIFT)
     64            | ((CC_NOACCESS2 & TD_STATUS_CC_MASK) << TD_STATUS_CC_SHIFT));
    6365
    6466        if (toggle == 0 || toggle == 1) {
    6567                /* Set explicit toggle bit */
    66                 instance->status |= TD_STATUS_T_USE_TD_FLAG;
    67                 instance->status |= toggle ? TD_STATUS_T_FLAG : 0;
     68                OHCI_MEM32_SET(instance->status, TD_STATUS_T_USE_TD_FLAG);
     69                OHCI_MEM32_SET(instance->status, toggle ? TD_STATUS_T_FLAG : 0);
    6870        }
    6971
    7072        /* Alow less data on input. */
    7173        if (dir == USB_DIRECTION_IN) {
    72                 instance->status |= TD_STATUS_ROUND_FLAG;
     74                OHCI_MEM32_SET(instance->status, TD_STATUS_ROUND_FLAG);
    7375        }
    7476
    7577        if (buffer != NULL) {
    7678                assert(size != 0);
    77                 instance->cbp = addr_to_phys(buffer);
    78                 instance->be = addr_to_phys(buffer + size - 1);
     79                OHCI_MEM32_WR(instance->cbp, addr_to_phys(buffer));
     80                OHCI_MEM32_WR(instance->be, addr_to_phys(buffer + size - 1));
    7981        }
    8082
    81         instance->next = addr_to_phys(next) & TD_NEXT_PTR_MASK;
     83        OHCI_MEM32_WR(instance->next, addr_to_phys(next) & TD_NEXT_PTR_MASK);
    8284
    8385}
  • uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.h

    re0d5bc5 r96e01fbc  
    3838#include <stdint.h>
    3939
    40 #include "../utils/malloc32.h"
     40#include "mem_access.h"
    4141#include "completion_codes.h"
    4242
     
    100100{
    101101        assert(instance);
    102         const int cc =
    103             (instance->status >> TD_STATUS_CC_SHIFT) & TD_STATUS_CC_MASK;
     102        const int cc =(OHCI_MEM32_RD(instance->status)
     103            >> TD_STATUS_CC_SHIFT) & TD_STATUS_CC_MASK;
    104104        /* This value is changed on transfer completion,
    105105         * either to CC_NOERROR or and error code.
     
    119119{
    120120        assert(instance);
    121         const int cc =
    122             (instance->status >> TD_STATUS_CC_SHIFT) & TD_STATUS_CC_MASK;
     121        const int cc = (OHCI_MEM32_RD(instance->status)
     122            >> TD_STATUS_CC_SHIFT) & TD_STATUS_CC_MASK;
    123123        return cc_to_rc(cc);
    124124}
     
    136136                return 0;
    137137        /* Buffer end points to the last byte of transfer buffer, so add 1 */
    138         return instance->be - instance->cbp + 1;
     138        return OHCI_MEM32_RD(instance->be) - OHCI_MEM32_RD(instance->cbp) + 1;
    139139}
    140140#endif
  • uspace/drv/bus/usb/ohci/main.c

    re0d5bc5 r96e01fbc  
    5959                return ret;
    6060        }
    61         usb_log_info("Controlling new OHCI device '%s'.\n", device->name);
     61        usb_log_info("Controlling new OHCI device '%s'.\n", ddf_dev_get_name(device));
    6262
    6363        return EOK;
    6464}
    65 /*----------------------------------------------------------------------------*/
     65
    6666static driver_ops_t ohci_driver_ops = {
    6767        .dev_add = ohci_dev_add,
    6868};
    69 /*----------------------------------------------------------------------------*/
     69
    7070static driver_t ohci_driver = {
    7171        .name = NAME,
    7272        .driver_ops = &ohci_driver_ops
    7373};
    74 /*----------------------------------------------------------------------------*/
     74
    7575/** Initializes global driver structures (NONE).
    7676 *
  • uspace/drv/bus/usb/ohci/ohci.c

    re0d5bc5 r96e01fbc  
    3333 * @brief OHCI driver
    3434 */
     35
     36/* XXX Fix this */
     37#define _DDF_DATA_IMPLANT
     38
    3539#include <errno.h>
    3640#include <str_error.h>
     
    5256} ohci_t;
    5357
    54 static inline ohci_t * dev_to_ohci(ddf_dev_t *dev)
    55 {
    56         assert(dev);
    57         return dev->driver_data;
     58static inline ohci_t *dev_to_ohci(ddf_dev_t *dev)
     59{
     60        return ddf_dev_data_get(dev);
    5861}
    5962/** IRQ handling callback, identifies device
     
    7578        hc_interrupt(&ohci->hc, status);
    7679}
    77 /*----------------------------------------------------------------------------*/
     80
    7881/** Get USB address assigned to root hub.
    7982 *
     
    8790
    8891        if (address != NULL) {
    89                 *address = dev_to_ohci(fun->dev)->hc.rh.address;
     92                *address = dev_to_ohci(ddf_fun_get_dev(fun))->hc.rh.address;
    9093        }
    9194
    9295        return EOK;
    9396}
    94 /*----------------------------------------------------------------------------*/
     97
    9598/** Gets handle of the respective hc (this device, hc function).
    9699 *
     
    103106{
    104107        assert(fun);
    105         ddf_fun_t *hc_fun = dev_to_ohci(fun->dev)->hc_fun;
     108        ddf_fun_t *hc_fun = dev_to_ohci(ddf_fun_get_dev(fun))->hc_fun;
    106109        assert(hc_fun);
    107110
    108111        if (handle != NULL)
    109                 *handle = hc_fun->handle;
     112                *handle = ddf_fun_get_handle(hc_fun);
    110113        return EOK;
    111114}
    112 /*----------------------------------------------------------------------------*/
     115
    113116/** Root hub USB interface */
    114117static usb_iface_t usb_iface = {
     
    116119        .get_my_address = rh_get_my_address,
    117120};
    118 /*----------------------------------------------------------------------------*/
     121
    119122/** Standard USB HC options (HC interface) */
    120123static ddf_dev_ops_t hc_ops = {
    121124        .interfaces[USBHC_DEV_IFACE] = &hcd_iface,
    122125};
    123 /*----------------------------------------------------------------------------*/
     126
    124127/** Standard USB RH options (RH interface) */
    125128static ddf_dev_ops_t rh_ops = {
    126129        .interfaces[USB_DEV_IFACE] = &usb_iface,
    127130};
    128 /*----------------------------------------------------------------------------*/
     131
    129132/** Initialize hc and rh ddf structures and their respective drivers.
    130133 *
     
    152155if (ret != EOK) { \
    153156        if (instance->hc_fun) { \
    154                 instance->hc_fun->driver_data = NULL; \
    155157                ddf_fun_destroy(instance->hc_fun); \
    156158        } \
    157159        if (instance->rh_fun) { \
    158                 instance->rh_fun->driver_data = NULL; \
    159160                ddf_fun_destroy(instance->rh_fun); \
    160161        } \
     
    167168        CHECK_RET_DEST_FREE_RETURN(ret,
    168169            "Failed to create OHCI HC function: %s.\n", str_error(ret));
    169         instance->hc_fun->ops = &hc_ops;
    170         instance->hc_fun->driver_data = &instance->hc;
     170        ddf_fun_set_ops(instance->hc_fun, &hc_ops);
     171        ddf_fun_data_implant(instance->hc_fun, &instance->hc);
    171172
    172173        instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci_rh");
     
    174175        CHECK_RET_DEST_FREE_RETURN(ret,
    175176            "Failed to create OHCI RH function: %s.\n", str_error(ret));
    176         instance->rh_fun->ops = &rh_ops;
     177        ddf_fun_set_ops(instance->rh_fun, &rh_ops);
    177178
    178179        uintptr_t reg_base = 0;
     
    183184        CHECK_RET_DEST_FREE_RETURN(ret,
    184185            "Failed to get register memory addresses for %" PRIun ": %s.\n",
    185             device->handle, str_error(ret));
     186            ddf_dev_get_handle(device), str_error(ret));
    186187        usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n",
    187188            (void *) reg_base, reg_size, irq);
  • uspace/drv/bus/usb/ohci/ohci_batch.c

    re0d5bc5 r96e01fbc  
    4444
    4545static void (*const batch_setup[])(ohci_transfer_batch_t*, usb_direction_t);
    46 /*----------------------------------------------------------------------------*/
     46
    4747/** Safely destructs ohci_transfer_batch_t structure
    4848 *
     
    6767        free(ohci_batch);
    6868}
    69 /*----------------------------------------------------------------------------*/
     69
    7070/** Finishes usb_transfer_batch and destroys the structure.
    7171 *
     
    8080        ohci_transfer_batch_dispose(ohci_batch);
    8181}
    82 /*----------------------------------------------------------------------------*/
     82
    8383/** Allocate memory and initialize internal data structure.
    8484 *
     
    158158#undef CHECK_NULL_DISPOSE_RET
    159159}
    160 /*----------------------------------------------------------------------------*/
     160
    161161/** Check batch TDs' status.
    162162 *
     
    199199                    ohci_batch->tds[i]->next, ohci_batch->tds[i]->be);
    200200
    201                 /* If the TD got all its data through, it will report 0 bytes
    202                  * remain, the sole exception is INPUT with data rounding flag
    203                  * (short), i.e. every INPUT. Nice thing is that short packets
    204                  * will correctly report remaining data, thus making
    205                  * this computation correct (short packets need to be produced
    206                  * by the last TD)
    207                  * NOTE: This also works for CONTROL transfer as
    208                  * the first TD will return 0 remain.
    209                  * NOTE: Short packets don't break the assumption that
    210                  * we leave the very last(unused) TD behind.
    211                  */
    212                 ohci_batch->usb_batch->transfered_size
    213                     -= td_remain_size(ohci_batch->tds[i]);
    214 
    215201                ohci_batch->usb_batch->error = td_error(ohci_batch->tds[i]);
    216                 if (ohci_batch->usb_batch->error != EOK) {
     202                if (ohci_batch->usb_batch->error == EOK) {
     203                        /* If the TD got all its data through, it will report
     204                         * 0 bytes remain, the sole exception is INPUT with
     205                         * data rounding flag (short), i.e. every INPUT.
     206                         * Nice thing is that short packets will correctly
     207                         * report remaining data, thus making this computation
     208                         * correct (short packets need to be produced by the
     209                         * last TD)
     210                         * NOTE: This also works for CONTROL transfer as
     211                         * the first TD will return 0 remain.
     212                         * NOTE: Short packets don't break the assumption that
     213                         * we leave the very last(unused) TD behind.
     214                         */
     215                        ohci_batch->usb_batch->transfered_size
     216                            -= td_remain_size(ohci_batch->tds[i]);
     217                } else {
    217218                        usb_log_debug("Batch %p found error TD(%zu):%08x.\n",
    218219                            ohci_batch->usb_batch, i,
     
    231232
    232233                        /* Check TD assumption */
    233                         const uint32_t pa =
    234                             addr_to_phys(ohci_batch->tds[leave_td]);
    235                         assert((ohci_batch->ed->td_head & ED_TDHEAD_PTR_MASK)
    236                             == pa);
    237 
     234                        assert(ed_head_td(ohci_batch->ed) ==
     235                            addr_to_phys(ohci_batch->tds[leave_td]));
     236
     237                        /* Set tail to the same TD */
    238238                        ed_set_tail_td(ohci_batch->ed,
    239239                            ohci_batch->tds[leave_td]);
    240240
    241241                        /* Clear possible ED HALT */
    242                         ohci_batch->ed->td_head &= ~ED_TDHEAD_HALTED_FLAG;
     242                        ed_clear_halt(ohci_batch->ed);
    243243                        break;
    244244                }
     
    253253
    254254        /* Make sure that we are leaving the right TD behind */
    255         const uint32_t pa = addr_to_phys(ohci_ep->td);
    256         assert(pa == (ohci_batch->ed->td_head & ED_TDHEAD_PTR_MASK));
    257         assert(pa == (ohci_batch->ed->td_tail & ED_TDTAIL_PTR_MASK));
     255        assert(addr_to_phys(ohci_ep->td) == ed_head_td(ohci_batch->ed));
     256        assert(addr_to_phys(ohci_ep->td) == ed_tail_td(ohci_batch->ed));
    258257
    259258        return true;
    260259}
    261 /*----------------------------------------------------------------------------*/
     260
    262261/** Starts execution of the TD list
    263262 *
     
    269268        ed_set_tail_td(ohci_batch->ed, ohci_batch->tds[ohci_batch->td_count]);
    270269}
    271 /*----------------------------------------------------------------------------*/
     270
    272271/** Prepare generic control transfer
    273272 *
     
    345344            USB_TRANSFER_BATCH_ARGS(*ohci_batch->usb_batch));
    346345}
    347 /*----------------------------------------------------------------------------*/
     346
    348347/** Prepare generic data transfer
    349348 *
     
    392391            USB_TRANSFER_BATCH_ARGS(*ohci_batch->usb_batch));
    393392}
    394 /*----------------------------------------------------------------------------*/
     393
    395394/** Transfer setup table. */
    396395static void (*const batch_setup[])(ohci_transfer_batch_t*, usb_direction_t) =
  • uspace/drv/bus/usb/ohci/ohci_batch.h

    re0d5bc5 r96e01fbc  
    6363void ohci_transfer_batch_commit(const ohci_transfer_batch_t *batch);
    6464void ohci_transfer_batch_finish_dispose(ohci_transfer_batch_t *batch);
    65 /*----------------------------------------------------------------------------*/
     65
    6666static inline ohci_transfer_batch_t *ohci_transfer_batch_from_link(link_t *l)
    6767{
  • uspace/drv/bus/usb/ohci/ohci_endpoint.c

    re0d5bc5 r96e01fbc  
    4848        ed_toggle_set(instance->ed, toggle);
    4949}
    50 /*----------------------------------------------------------------------------*/
     50
    5151/** Callback to get value of toggle bit.
    5252 *
     
    6161        return ed_toggle_get(instance->ed);
    6262}
    63 /*----------------------------------------------------------------------------*/
     63
    6464/** Creates new hcd endpoint representation.
    6565 *
     
    9393        return EOK;
    9494}
    95 /*----------------------------------------------------------------------------*/
     95
    9696/** Disposes hcd endpoint structure
    9797 *
  • uspace/drv/bus/usb/ohci/ohci_regs.h

    re0d5bc5 r96e01fbc  
    3535#define DRV_OHCI_OHCI_REGS_H
    3636#include <sys/types.h>
     37#include <byteorder.h>
     38
     39#define OHCI_WR(reg, val) reg = host2uint32_t_le(val)
     40#define OHCI_RD(reg) uint32_t_le2host(reg)
     41#define OHCI_SET(reg, val) reg |= host2uint32_t_le(val)
     42#define OHCI_CLR(reg, val) reg &= host2uint32_t_le(~val)
     43
    3744
    3845#define LEGACY_REGS_OFFSET 0x100
     
    4249        const ioport32_t revision;
    4350#define R_REVISION_MASK (0x3f)
    44 #define R_REVISION_SHIFT (0)
    4551#define R_LEGACY_FLAG   (0x80)
    4652
    4753        ioport32_t control;
    48 #define C_CBSR_MASK (0x3) /* Control-bulk service ratio */
     54/* Control-bulk service ratio */
    4955#define C_CBSR_1_1  (0x0)
    5056#define C_CBSR_1_2  (0x1)
    5157#define C_CBSR_1_3  (0x2)
    5258#define C_CBSR_1_4  (0x3)
    53 #define C_CBSR_SHIFT (0)
     59#define C_CBSR_MASK (0x3)
     60#define C_CBSR_SHIFT 0
    5461
    5562#define C_PLE (1 << 2)   /* Periodic list enable */
     
    5865#define C_BLE (1 << 5)   /* Bulk list enable */
    5966
    60 #define C_HCFS_MASK        (0x3) /* Host controller functional state */
     67/* Host controller functional state */
    6168#define C_HCFS_RESET       (0x0)
    6269#define C_HCFS_RESUME      (0x1)
    6370#define C_HCFS_OPERATIONAL (0x2)
    6471#define C_HCFS_SUSPEND     (0x3)
    65 #define C_HCFS_SHIFT       (6)
    66 
    67 #define C_HCFS_GET(reg) \
    68         ((reg >> C_HCFS_SHIFT) & C_HCFS_MASK)
    69 #define C_HCFS_SET(reg, hcfs_state) \
     72#define C_HCFS_GET(reg) ((OHCI_RD(reg) >> 6) & 0x3)
     73#define C_HCFS_SET(reg, value) \
    7074do { \
    71         reg = (reg & ~(C_HCFS_MASK << C_HCFS_SHIFT)) \
    72             | ((hcfs_state & C_HCFS_MASK) << C_HCFS_SHIFT); \
     75        uint32_t r = OHCI_RD(reg); \
     76        r &= ~(0x3 << 6); \
     77        r |= (value & 0x3) << 6; \
     78        OHCI_WR(reg, r); \
    7379} while (0)
    7480
    75 
    76 #define C_IR  (1 << 8)   /* Interrupt routing, make sure it's 0 */
    77 #define C_RWC (1 << 9)   /* Remote wakeup connected, host specific */
     81#define C_IR  (1 << 8)  /* Interrupt routing, make sure it's 0 */
     82#define C_RWC (1 << 9)  /* Remote wakeup connected, host specific */
    7883#define C_RWE (1 << 10)  /* Remote wakeup enable */
    7984
     
    8388#define CS_BLF (1 << 2)   /* Bulk list filled */
    8489#define CS_OCR (1 << 3)   /* Ownership change request */
     90#if 0
    8591#define CS_SOC_MASK (0x3) /* Scheduling overrun count */
    8692#define CS_SOC_SHIFT (16)
     93#endif
    8794
    8895        /** Interupt enable/disable/status,
     
    101108#define I_RHSC (1 << 6)   /* Root hub status change */
    102109#define I_OC   (1 << 30)  /* Ownership change */
    103 #define I_MI   (1 << 31)  /* Master interrupt (all/any interrupts) */
     110#define I_MI   (1 << 31)  /* Master interrupt (any/all) */
    104111
    105112        /** HCCA pointer (see hw_struct hcca.h) */
     
    145152        /** Remaining bit time in frame to start periodic transfers */
    146153        ioport32_t periodic_start;
    147 #define PS_PS_MASK (0x3fff) /* bit time when periodic get priority (0x3e67) */
     154#define PS_MASK 0x3fff
     155#define PS_SHIFT 0
    148156
    149157        /** Threshold for starting LS transaction */
     
    153161        /** The first root hub control register */
    154162        ioport32_t rh_desc_a;
    155 #define RHDA_NDS_MASK (0xff) /* Number of downstream ports, max 15 */
    156 #define RHDA_NDS_SHIFT (0)
    157 #define RHDA_PSM_FLAG  (1 << 8)  /* Power switching mode: 0-global, 1-per port*/
    158 #define RHDA_NPS_FLAG  (1 << 9)  /* No power switch: 1-power on, 0-use PSM*/
    159 #define RHDA_DT_FLAG   (1 << 10) /* 1-Compound device, must be 0 */
    160 #define RHDA_OCPM_FLAG (1 << 11) /* Over-current mode: 0-global, 1-per port */
    161 #define RHDA_NOCP_FLAG (1 << 12) /* OC control: 0-use OCPM, 1-OC off */
    162 #define RHDA_POTPGT_MASK (0xff)  /* Power on to power good time */
    163 #define RHDA_POTPGT_SHIFT (24)
     163/** Number of downstream ports, max 15 */
     164#define RHDA_NDS_MASK  (0xff)
     165/** Power switching mode: 0-global, 1-per port*/
     166#define RHDA_PSM_FLAG  (1 << 8)
     167/** No power switch: 1-power on, 0-use PSM*/
     168#define RHDA_NPS_FLAG  (1 << 9)
     169/** 1-Compound device, must be 0 */
     170#define RHDA_DT_FLAG   (1 << 10)
     171/** Over-current mode: 0-global, 1-per port */
     172#define RHDA_OCPM_FLAG (1 << 11)
     173/** OC control: 0-use OCPM, 1-OC off */
     174#define RHDA_NOCP_FLAG (1 << 12)
     175/** Power on to power good time */
     176#define RHDA_POTPGT_SHIFT   24
    164177
    165178        /** The other root hub control register */
    166179        ioport32_t rh_desc_b;
    167 #define RHDB_DR_MASK (0xffff) /* Device removable mask */
    168 #define RHDB_DR_SHIFT (0)
    169 #define RHDB_PCC_MASK (0xffff) /* Power control mask */
    170 #define RHDB_PCC_SHIFT (16)
    171 
    172 /* Port device removable status */
    173 #define RHDB_DR_FLAG(port) (((1 << port) & RHDB_DR_MASK) << RHDB_DR_SHIFT)
    174 /* Port power control status: 1-per port power control, 0-global power switch */
    175 #define RHDB_PPC_FLAG(port) (((1 << port) & RHDB_DR_MASK) << RHDB_DR_SHIFT)
     180/** Device removable mask */
     181#define RHDB_DR_SHIFT   0
     182#define RHDB_DR_MASK    0xffff
     183/** Power control mask */
     184#define RHDB_PCC_MASK (0xffff)
     185#define RHDB_PCC_SHIFT 16
    176186
    177187        /** Root hub status register */
    178188        ioport32_t rh_status;
    179 #define RHS_LPS_FLAG  (1 <<  0)/* read: 0,
    180                                 * write: 0-no effect,
    181                                 *        1-turn off port power for ports
    182                                 *        specified in PPCM(RHDB), or all ports,
    183                                 *        if power is set globally */
     189/* read: 0,
     190 * write: 0-no effect,
     191 *        1-turn off port power for ports
     192 *        specified in PPCM(RHDB), or all ports,
     193 *        if power is set globally */
     194#define RHS_LPS_FLAG  (1 <<  0)
    184195#define RHS_CLEAR_GLOBAL_POWER RHS_LPS_FLAG /* synonym for the above */
    185 #define RHS_OCI_FLAG  (1 <<  1)/* Over-current indicator, if per-port: 0 */
    186 #define RHS_DRWE_FLAG (1 << 15)/* read: 0-connect status change does not wake HC
    187                                 *       1-connect status change wakes HC
    188                                 * write: 1-set DRWE, 0-no effect */
     196/** Over-current indicator, if per-port: 0 */
     197#define RHS_OCI_FLAG  (1 <<  1)
     198
     199/* read: 0-connect status change does not wake HC
     200 *       1-connect status change wakes HC
     201 * write: 1-set DRWE, 0-no effect */
     202#define RHS_DRWE_FLAG (1 << 15)
    189203#define RHS_SET_DRWE RHS_DRWE_FLAG
    190 #define RHS_LPSC_FLAG (1 << 16)/* read: 0,
    191                                 * write: 0-no effect
    192                                 *        1-turn on port power for ports
    193                                 *        specified in PPCM(RHDB), or all ports,
    194                                 *        if power is set globally */
     204/* read: 0,
     205 * write: 0-no effect
     206 *        1-turn on port power for ports
     207 *        specified in PPCM(RHDB), or all ports,
     208 *        if power is set globally */
     209#define RHS_LPSC_FLAG (1 << 16)
    195210#define RHS_SET_GLOBAL_POWER RHS_LPSC_FLAG /* synonym for the above */
    196 #define RHS_OCIC_FLAG (1 << 17)/* Over-current indicator change   */
     211/** Over-current change indicator*/
     212#define RHS_OCIC_FLAG (1 << 17)
    197213#define RHS_CLEAR_DRWE (1 << 31)
    198214
     
    200216        ioport32_t rh_port_status[];
    201217#define RHPS_CCS_FLAG (1 << 0) /* r: current connect status,
    202                                 * w: 1-clear port enable, 0-nothing */
     218                                               * w: 1-clear port enable, 0-N/S*/
    203219#define RHPS_CLEAR_PORT_ENABLE RHPS_CCS_FLAG
    204220#define RHPS_PES_FLAG (1 << 1) /* r: port enable status
    205                                 * w: 1-set port enable, 0-nothing */
     221                                              * w: 1-set port enable, 0-N/S */
    206222#define RHPS_SET_PORT_ENABLE RHPS_PES_FLAG
    207223#define RHPS_PSS_FLAG (1 << 2) /* r: port suspend status
    208                                 * w: 1-set port suspend, 0-nothing */
     224                                               * w: 1-set port suspend, 0-N/S */
    209225#define RHPS_SET_PORT_SUSPEND RHPS_PSS_FLAG
    210 #define RHPS_POCI_FLAG (1 << 3) /* r: port over-current (if reports are per-port
    211                                  * w: 1-clear port suspend (start resume
    212                                  *      if suspened)
    213                                  *    0-nothing */
     226#define RHPS_POCI_FLAG (1 << 3) /* r: port over-current
     227                                                * (if reports are per-port
     228                                                * w: 1-clear port suspend
     229                                                *  (start resume if suspened)
     230                                                *    0-nothing */
    214231#define RHPS_CLEAR_PORT_SUSPEND RHPS_POCI_FLAG
    215232#define RHPS_PRS_FLAG (1 << 4) /* r: port reset status
    216                                 * w: 1-set port reset, 0-nothing */
     233                                               * w: 1-set port reset, 0-N/S */
    217234#define RHPS_SET_PORT_RESET RHPS_PRS_FLAG
    218235#define RHPS_PPS_FLAG (1 << 8) /* r: port power status
    219                                 * w: 1-set port power, 0-nothing */
     236                                              * w: 1-set port power, 0-N/S */
    220237#define RHPS_SET_PORT_POWER RHPS_PPS_FLAG
    221238#define RHPS_LSDA_FLAG (1 << 9) /* r: low speed device attached
    222                                  * w: 1-clear port power, 0-nothing */
     239                                                * w: 1-clear port power, 0-N/S*/
    223240#define RHPS_CLEAR_PORT_POWER RHPS_LSDA_FLAG
    224 #define RHPS_CSC_FLAG  (1 << 16) /* connect status change Write-Clean */
     241#define RHPS_CSC_FLAG  (1 << 16) /* connect status change WC */
    225242#define RHPS_PESC_FLAG (1 << 17) /* port enable status change WC */
    226243#define RHPS_PSSC_FLAG (1 << 18) /* port suspend status change WC */
    227244#define RHPS_OCIC_FLAG (1 << 19) /* port over-current change WC */
    228245#define RHPS_PRSC_FLAG (1 << 20) /* port reset status change WC */
    229 #define RHPS_CHANGE_WC_MASK 0x1f0000
     246#define RHPS_CHANGE_WC_MASK (0x1f0000)
    230247} ohci_regs_t;
    231248#endif
  • uspace/drv/bus/usb/ohci/res.c

    re0d5bc5 r96e01fbc  
    5353 * @return Error code.
    5454 */
    55 int get_my_registers(const ddf_dev_t *dev,
     55int get_my_registers(ddf_dev_t *dev,
    5656    uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no)
    5757{
     
    5959
    6060        async_sess_t *parent_sess =
    61             devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
    62             IPC_FLAG_BLOCKING);
     61            devman_parent_device_connect(EXCHANGE_SERIALIZE,
     62            ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
    6363        if (!parent_sess)
    6464                return ENOMEM;
     
    9494 * @return Error code.
    9595 */
    96 int enable_interrupts(const ddf_dev_t *device)
     96int enable_interrupts(ddf_dev_t *device)
    9797{
    9898        async_sess_t *parent_sess =
    99             devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
    100             IPC_FLAG_BLOCKING);
     99            devman_parent_device_connect(EXCHANGE_SERIALIZE,
     100            ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
    101101        if (!parent_sess)
    102102                return ENOMEM;
  • uspace/drv/bus/usb/ohci/res.h

    re0d5bc5 r96e01fbc  
    3737#include <ddf/driver.h>
    3838
    39 int get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
    40 int enable_interrupts(const ddf_dev_t *);
     39int get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *);
     40int enable_interrupts(ddf_dev_t *);
    4141
    4242#endif
  • uspace/drv/bus/usb/ohci/root_hub.c

    re0d5bc5 r96e01fbc  
    3333 */
    3434#include <assert.h>
     35#include <byteorder.h>
    3536#include <errno.h>
    3637#include <str_error.h>
    3738#include <fibril_synch.h>
    3839
     40#include <usb/usb.h>
    3941#include <usb/debug.h>
    4042#include <usb/dev/request.h>
    4143#include <usb/classes/hub.h>
    4244
    43 #include "root_hub.h"
    4445#include <usb/classes/classes.h>
    4546#include <usb/classes/hub.h>
    4647#include <usb/dev/driver.h>
    4748#include "ohci_regs.h"
     49#include "root_hub.h"
    4850
    4951/**
     
    122124{
    123125        assert(request);
     126        usb_log_debug("Sending interrupt vector(%zu) %hhx:%hhx.\n",
     127            size, ((uint8_t*)&mask)[0], ((uint8_t*)&mask)[1]);
    124128        usb_transfer_batch_finish_error(request, &mask, size, EOK);
    125129        usb_transfer_batch_destroy(request);
     
    150154
    151155        instance->registers = regs;
    152         instance->port_count =
    153             (instance->registers->rh_desc_a >> RHDA_NDS_SHIFT) & RHDA_NDS_MASK;
     156        instance->port_count = OHCI_RD(regs->rh_desc_a) & RHDA_NDS_MASK;
     157        usb_log_debug2("rh_desc_a: %x.\n", OHCI_RD(regs->rh_desc_a));
    154158        if (instance->port_count > 15) {
    155159                usb_log_warning("OHCI specification does not allow more than 15"
     
    163167
    164168#if defined OHCI_POWER_SWITCH_no
     169        usb_log_debug("OHCI rh: Set power mode to no power switching.\n");
    165170        /* Set port power mode to no power-switching. (always on) */
    166         instance->registers->rh_desc_a |= RHDA_NPS_FLAG;
     171        OHCI_SET(regs->rh_desc_a, RHDA_NPS_FLAG);
    167172
    168173        /* Set to no over-current reporting */
    169         instance->registers->rh_desc_a |= RHDA_NOCP_FLAG;
     174        OHCI_SET(regs->rh_desc_a, RHDA_NOCP_FLAG);
    170175
    171176#elif defined OHCI_POWER_SWITCH_ganged
    172         /* Set port power mode to no ganged power-switching. */
    173         instance->registers->rh_desc_a &= ~RHDA_NPS_FLAG;
    174         instance->registers->rh_desc_a &= ~RHDA_PSM_FLAG;
    175         instance->registers->rh_status = RHS_CLEAR_GLOBAL_POWER;
     177        usb_log_debug("OHCI rh: Set power mode to ganged power switching.\n");
     178        /* Set port power mode to ganged power-switching. */
     179        OHCI_CLR(regs->rh_desc_a, RHDA_NPS_FLAG);
     180        OHCI_CLR(regs->rh_desc_a, RHDA_PSM_FLAG);
     181
     182        /* Turn off power (hub driver will turn this back on)*/
     183        OHCI_WR(regs->rh_status, RHS_CLEAR_GLOBAL_POWER);
    176184
    177185        /* Set to global over-current */
    178         instance->registers->rh_desc_a &= ~RHDA_NOCP_FLAG;
    179         instance->registers->rh_desc_a &= ~RHDA_OCPM_FLAG;
     186        OHCI_CLR(regs->rh_desc_a, RHDA_NOCP_FLAG);
     187        OHCI_CLR(regs->rh_desc_a, RHDA_OCPM_FLAG);
    180188#else
    181         /* Set port power mode to no per port power-switching. */
    182         instance->registers->rh_desc_a &= ~RHDA_NPS_FLAG;
    183         instance->registers->rh_desc_a |= RHDA_PSM_FLAG;
     189        usb_log_debug("OHCI rh: Set power mode to per-port power switching.\n");
     190        /* Set port power mode to per port power-switching. */
     191        OHCI_CLR(regs->rh_desc_a, RHDA_NPS_FLAG);
     192        OHCI_SET(regs->rh_desc_a, RHDA_PSM_FLAG);
    184193
    185194        /* Control all ports by global switch and turn them off */
    186         instance->registers->rh_desc_b &= (RHDB_PCC_MASK << RHDB_PCC_SHIFT);
    187         instance->registers->rh_status = RHS_CLEAR_GLOBAL_POWER;
     195        OHCI_CLR(regs->rh_desc_b, RHDB_PCC_MASK << RHDB_PCC_SHIFT);
     196        OHCI_WR(regs->rh_status, RHS_CLEAR_GLOBAL_POWER);
    188197
    189198        /* Return control to per port state */
    190         instance->registers->rh_desc_b |=
    191                 ((1 << (instance->port_count + 1)) - 1) << RHDB_PCC_SHIFT;
     199        OHCI_SET(regs->rh_desc_b, RHDB_PCC_MASK << RHDB_PCC_SHIFT);
    192200
    193201        /* Set per port over-current */
    194         instance->registers->rh_desc_a &= ~RHDA_NOCP_FLAG;
    195         instance->registers->rh_desc_a |= RHDA_OCPM_FLAG;
     202        OHCI_CLR(regs->rh_desc_a, RHDA_NOCP_FLAG);
     203        OHCI_SET(regs->rh_desc_a, RHDA_OCPM_FLAG);
    196204#endif
    197205
     
    202210            instance->port_count);
    203211}
    204 /*----------------------------------------------------------------------------*/
     212
    205213/**
    206214 * Process root hub request.
     
    226234                fibril_mutex_lock(&instance->guard);
    227235                assert(instance->unfinished_interrupt_transfer == NULL);
    228                 uint16_t mask = create_interrupt_mask(instance);
     236                const uint16_t mask = create_interrupt_mask(instance);
    229237                if (mask == 0) {
    230                         usb_log_debug("No changes...\n");
     238                        usb_log_debug("No changes(%hx)...\n", mask);
    231239                        instance->unfinished_interrupt_transfer = request;
    232240                } else {
     
    243251        }
    244252}
    245 /*----------------------------------------------------------------------------*/
     253
    246254/**
    247255 * Process interrupt on a hub device.
     
    257265        if (instance->unfinished_interrupt_transfer) {
    258266                usb_log_debug("Finalizing interrupt transfer\n");
    259                 uint16_t mask = create_interrupt_mask(instance);
     267                const uint16_t mask = create_interrupt_mask(instance);
    260268                interrupt_request(instance->unfinished_interrupt_transfer,
    261269                    mask, instance->interrupt_mask_size);
     
    264272        fibril_mutex_unlock(&instance->guard);
    265273}
    266 /*----------------------------------------------------------------------------*/
     274
    267275/**
    268276 * Create hub descriptor.
     
    282290        instance->hub_descriptor_size = size;
    283291
    284         uint32_t hub_desc = instance->registers->rh_desc_a;
    285         uint32_t port_desc = instance->registers->rh_desc_b;
     292        const uint32_t hub_desc = OHCI_RD(instance->registers->rh_desc_a);
     293        const uint32_t port_desc = OHCI_RD(instance->registers->rh_desc_b);
    286294
    287295        /* bDescLength */
     
    305313        instance->descriptors.hub[4] = 0;
    306314        /* bPwrOn2PwrGood */
    307         instance->descriptors.hub[5] =
    308             (hub_desc >> RHDA_POTPGT_SHIFT) & RHDA_POTPGT_MASK;
     315        instance->descriptors.hub[5] = hub_desc >> RHDA_POTPGT_SHIFT;
    309316        /* bHubContrCurrent, root hubs don't need no power. */
    310317        instance->descriptors.hub[6] = 0;
    311318
    312319        /* Device Removable and some legacy 1.0 stuff*/
    313         instance->descriptors.hub[7] =
    314             (port_desc >> RHDB_DR_SHIFT) & RHDB_DR_MASK & 0xff;
     320        instance->descriptors.hub[7] = (port_desc >> RHDB_DR_SHIFT) & 0xff;
    315321        instance->descriptors.hub[8] = 0xff;
    316322        if (instance->interrupt_mask_size == 2) {
    317323                instance->descriptors.hub[8] =
    318                     (port_desc >> RHDB_DR_SHIFT) & RHDB_DR_MASK >> 8;
     324                    (port_desc >> RHDB_DR_SHIFT) >> 8;
    319325                instance->descriptors.hub[9]  = 0xff;
    320326                instance->descriptors.hub[10] = 0xff;
    321327        }
    322328}
    323 /*----------------------------------------------------------------------------*/
     329
    324330/** Initialize hub descriptors.
    325331 *
     
    341347            instance->interrupt_mask_size;
    342348
    343         instance->descriptors.configuration.total_length =
     349        instance->descriptors.configuration.total_length = uint16_host2usb(
    344350            sizeof(usb_standard_configuration_descriptor_t) +
    345351            sizeof(usb_standard_endpoint_descriptor_t) +
    346352            sizeof(usb_standard_interface_descriptor_t) +
    347             instance->hub_descriptor_size;
    348 }
    349 /*----------------------------------------------------------------------------*/
     353            instance->hub_descriptor_size);
     354}
     355
    350356/**
    351357 * Create bitmap of changes to answer status interrupt.
     
    364370
    365371        /* Only local power source change and over-current change can happen */
    366         if (instance->registers->rh_status & (RHS_LPSC_FLAG | RHS_OCIC_FLAG)) {
     372        if (OHCI_RD(instance->registers->rh_status)
     373            & (RHS_LPSC_FLAG | RHS_OCIC_FLAG)) {
    367374                mask |= 1;
    368375        }
    369376        for (size_t port = 1; port <= instance->port_count; ++port) {
    370377                /* Write-clean bits are those that indicate change */
    371                 if (RHPS_CHANGE_WC_MASK
    372                     & instance->registers->rh_port_status[port - 1]) {
    373 
     378                if (OHCI_RD(instance->registers->rh_port_status[port - 1])
     379                    & RHPS_CHANGE_WC_MASK) {
    374380                        mask |= (1 << port);
    375381                }
    376382        }
    377         /* USB is little endian */
    378         return host2uint32_t_le(mask);
    379 }
    380 /*----------------------------------------------------------------------------*/
     383        usb_log_debug2("OHCI root hub interrupt mask: %hx.\n", mask);
     384        return uint16_host2usb(mask);
     385}
     386
    381387/**
    382388 * Create answer to status request.
     
    396402        usb_device_request_setup_packet_t *request_packet =
    397403            (usb_device_request_setup_packet_t*)request->setup_buffer;
     404
     405        const uint16_t index = uint16_usb2host(request_packet->index);
    398406
    399407        switch (request_packet->request_type)
     
    406414                        TRANSFER_END(request, EOVERFLOW);
    407415                } else {
    408                         uint32_t data = instance->registers->rh_status &
    409                             (RHS_LPS_FLAG | RHS_LPSC_FLAG
    410                                 | RHS_OCI_FLAG | RHS_OCIC_FLAG);
     416                        const uint32_t data =
     417                            OHCI_RD(instance->registers->rh_status) &
     418                                (RHS_LPS_FLAG | RHS_LPSC_FLAG
     419                                    | RHS_OCI_FLAG | RHS_OCIC_FLAG);
    411420                        TRANSFER_END_DATA(request, &data, sizeof(data));
    412421                }
     
    420429                        TRANSFER_END(request, EOVERFLOW);
    421430                } else {
    422                         unsigned port = request_packet->index;
     431                        const unsigned port = index;
    423432                        if (port < 1 || port > instance->port_count)
    424433                                TRANSFER_END(request, EINVAL);
    425 
    426                         uint32_t data =
    427                             instance->registers->rh_port_status[port - 1];
     434                        /* Register format matches the format of port status
     435                         * field */
     436                        const uint32_t data = uint32_host2usb(OHCI_RD(
     437                            instance->registers->rh_port_status[port - 1]));
    428438                        TRANSFER_END_DATA(request, &data, sizeof(data));
    429439                }
     
    434444                        TRANSFER_END(request, EOVERFLOW);
    435445                } else {
    436                         uint16_t data =
     446                        const uint16_t data =
    437447                            uint16_host2usb(USB_DEVICE_STATUS_SELF_POWERED);
    438448                        TRANSFER_END_DATA(request, &data, sizeof(data));
     
    441451        case SETUP_REQUEST_TO_HOST(USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_INTERFACE):
    442452                /* Hubs are allowed to have only one interface */
    443                 if (request_packet->index != 0)
     453                if (index != 0)
    444454                        TRANSFER_END(request, EINVAL);
    445455                /* Fall through, as the answer will be the same: 0x0000 */
    446456        case SETUP_REQUEST_TO_HOST(USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_ENDPOINT):
    447457                /* Endpoint 0 (default control) and 1 (interrupt) */
    448                 if (request_packet->index >= 2)
     458                if (index >= 2)
    449459                        TRANSFER_END(request, EINVAL);
    450460
     
    455465                } else {
    456466                        /* Endpoints are OK. (We don't halt) */
    457                         uint16_t data = 0;
     467                        const uint16_t data = 0;
    458468                        TRANSFER_END_DATA(request, &data, sizeof(data));
    459469                }
     
    465475
    466476}
    467 /*----------------------------------------------------------------------------*/
     477
    468478/**
    469479 * Create answer to a descriptor request.
     
    482492        usb_device_request_setup_packet_t *setup_request =
    483493            (usb_device_request_setup_packet_t *) request->setup_buffer;
    484         uint16_t setup_request_value = setup_request->value_high;
    485         switch (setup_request_value)
     494        /* "The wValue field specifies the descriptor type in the high byte
     495         * and the descriptor index in the low byte (refer to Table 9-5)." */
     496        const int desc_type = uint16_usb2host(setup_request->value) >> 8;
     497        switch (desc_type)
    486498        {
    487499        case USB_DESCTYPE_HUB:
     
    530542                    setup_request->value,
    531543                    setup_request->request_type, setup_request->request,
    532                     setup_request_value, setup_request->index,
     544                    desc_type, setup_request->index,
    533545                    setup_request->length);
    534546                TRANSFER_END(request, EINVAL);
     
    537549        TRANSFER_END(request, ENOTSUP);
    538550}
    539 /*----------------------------------------------------------------------------*/
     551
    540552/**
    541553 * process feature-enabling request on hub
     
    554566                return EINVAL;
    555567
    556         switch (feature)
    557         {
    558         case USB_HUB_FEATURE_PORT_POWER:   //8
    559                 /* No power switching */
    560                 if (instance->registers->rh_desc_a & RHDA_NPS_FLAG)
    561                         return EOK;
    562                 /* Ganged power switching */
    563                 if (!(instance->registers->rh_desc_a & RHDA_PSM_FLAG)) {
    564                         instance->registers->rh_status = RHS_SET_GLOBAL_POWER;
    565                         return EOK;
     568        switch (feature) {
     569        case USB_HUB_FEATURE_PORT_POWER:   /*8*/
     570                {
     571                        const uint32_t rhda =
     572                            OHCI_RD(instance->registers->rh_desc_a);
     573                        /* No power switching */
     574                        if (rhda & RHDA_NPS_FLAG)
     575                                return EOK;
     576                        /* Ganged power switching, one port powers all */
     577                        if (!(rhda & RHDA_PSM_FLAG)) {
     578                                OHCI_WR(instance->registers->rh_status,
     579                                    RHS_SET_GLOBAL_POWER);
     580                                return EOK;
     581                        }
    566582                }
    567         case USB_HUB_FEATURE_PORT_ENABLE:  //1
    568         case USB_HUB_FEATURE_PORT_SUSPEND: //2
    569         case USB_HUB_FEATURE_PORT_RESET:   //4
    570                 /* Nice thing is that these shifts correspond to the position
    571                  * of control bits in register */
    572                 instance->registers->rh_port_status[port - 1] = (1 << feature);
     583                        /* Fall through */
     584        case USB_HUB_FEATURE_PORT_ENABLE:  /*1*/
     585        case USB_HUB_FEATURE_PORT_SUSPEND: /*2*/
     586        case USB_HUB_FEATURE_PORT_RESET:   /*4*/
     587                usb_log_debug2("Setting port POWER, ENABLE, SUSPEND or RESET "
     588                    "on port %"PRIu16".\n", port);
     589                OHCI_WR(instance->registers->rh_port_status[port - 1],
     590                    1 << feature);
    573591                return EOK;
    574592        default:
     
    576594        }
    577595}
    578 /*----------------------------------------------------------------------------*/
     596
    579597/**
    580598 * Process feature clear request.
     
    596614        switch (feature)
    597615        {
    598         case USB_HUB_FEATURE_PORT_POWER:          //8
    599                 /* No power switching */
    600                 if (instance->registers->rh_desc_a & RHDA_NPS_FLAG)
    601                         return ENOTSUP;
    602                 /* Ganged power switching */
    603                 if (!(instance->registers->rh_desc_a & RHDA_PSM_FLAG)) {
    604                         instance->registers->rh_status = RHS_CLEAR_GLOBAL_POWER;
     616        case USB_HUB_FEATURE_PORT_POWER:          /*8*/
     617                {
     618                        const uint32_t rhda =
     619                            OHCI_RD(instance->registers->rh_desc_a);
     620                        /* No power switching */
     621                        if (rhda & RHDA_NPS_FLAG)
     622                                return ENOTSUP;
     623                        /* Ganged power switching, one port powers all */
     624                        if (!(rhda & RHDA_PSM_FLAG)) {
     625                                OHCI_WR(instance->registers->rh_status,
     626                                    RHS_CLEAR_GLOBAL_POWER);
     627                                return EOK;
     628                        }
     629                        OHCI_WR(instance->registers->rh_port_status[port - 1],
     630                            RHPS_CLEAR_PORT_POWER);
    605631                        return EOK;
    606632                }
    607                 instance->registers->rh_port_status[port - 1] =
    608                         RHPS_CLEAR_PORT_POWER;
     633
     634        case USB_HUB_FEATURE_PORT_ENABLE:         /*1*/
     635                OHCI_WR(instance->registers->rh_port_status[port - 1],
     636                    RHPS_CLEAR_PORT_ENABLE);
    609637                return EOK;
    610638
    611         case USB_HUB_FEATURE_PORT_ENABLE:         //1
    612                 instance->registers->rh_port_status[port - 1] =
    613                         RHPS_CLEAR_PORT_ENABLE;
     639        case USB_HUB_FEATURE_PORT_SUSPEND:        /*2*/
     640                OHCI_WR(instance->registers->rh_port_status[port - 1],
     641                    RHPS_CLEAR_PORT_SUSPEND);
    614642                return EOK;
    615643
    616         case USB_HUB_FEATURE_PORT_SUSPEND:        //2
    617                 instance->registers->rh_port_status[port - 1] =
    618                         RHPS_CLEAR_PORT_SUSPEND;
    619                 return EOK;
    620 
    621         case USB_HUB_FEATURE_C_PORT_CONNECTION:   //16
    622         case USB_HUB_FEATURE_C_PORT_ENABLE:       //17
    623         case USB_HUB_FEATURE_C_PORT_SUSPEND:      //18
    624         case USB_HUB_FEATURE_C_PORT_OVER_CURRENT: //19
    625         case USB_HUB_FEATURE_C_PORT_RESET:        //20
    626                 /* Nice thing is that these shifts correspond to the position
    627                  * of control bits in register */
    628                 instance->registers->rh_port_status[port - 1] = (1 << feature);
     644        case USB_HUB_FEATURE_C_PORT_CONNECTION:   /*16*/
     645        case USB_HUB_FEATURE_C_PORT_ENABLE:       /*17*/
     646        case USB_HUB_FEATURE_C_PORT_SUSPEND:      /*18*/
     647        case USB_HUB_FEATURE_C_PORT_OVER_CURRENT: /*19*/
     648        case USB_HUB_FEATURE_C_PORT_RESET:        /*20*/
     649                usb_log_debug2("Clearing port C_CONNECTION, C_ENABLE, "
     650                    "C_SUSPEND, C_OC or C_RESET on port %"PRIu16".\n", port);
     651                /* Bit offsets correspond to the feature number */
     652                OHCI_WR(instance->registers->rh_port_status[port - 1],
     653                    1 << feature);
    629654                return EOK;
    630655
     
    633658        }
    634659}
    635 /*----------------------------------------------------------------------------*/
     660
    636661/**
    637662 * process one of requests that do not request nor carry additional data
     
    654679        case USB_HUB_REQ_TYPE_SET_PORT_FEATURE:
    655680                usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
    656                 int ret = set_feature_port(instance,
     681                const int ret = set_feature_port(instance,
    657682                    setup_request->value, setup_request->index);
    658683                TRANSFER_END(request, ret);
     
    671696        }
    672697}
    673 /*----------------------------------------------------------------------------*/
     698
    674699/**
    675700 * process one of requests that do not request nor carry additional data
     
    693718        case USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE:
    694719                usb_log_debug("USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE\n");
    695                 int ret = clear_feature_port(instance,
     720                const int ret = clear_feature_port(instance,
    696721                    setup_request->value, setup_request->index);
    697722                TRANSFER_END(request, ret);
     
    706731                 * as root hubs do not support local power status feature.
    707732                 * (OHCI pg. 127) */
    708                 if (setup_request->value == USB_HUB_FEATURE_C_HUB_OVER_CURRENT) {
    709                         instance->registers->rh_status = RHS_OCIC_FLAG;
     733                if (uint16_usb2host(setup_request->value)
     734                    == USB_HUB_FEATURE_C_HUB_OVER_CURRENT) {
     735                        OHCI_WR(instance->registers->rh_status, RHS_OCIC_FLAG);
    710736                        TRANSFER_END(request, EOK);
    711737                }
     
    717743        }
    718744}
    719 /*----------------------------------------------------------------------------*/
     745
    720746/**
    721747 * Process hub control request.
     
    771797                if (request->buffer_size == 0)
    772798                        TRANSFER_END(request, EOVERFLOW);
    773                 uint8_t config = 1;
     799                const uint8_t config = 1;
    774800                TRANSFER_END_DATA(request, &config, sizeof(config));
    775801
     
    790816                        TRANSFER_END(request, EINVAL);
    791817
    792                 instance->address = setup_request->value;
     818                instance->address = uint16_usb2host(setup_request->value);
    793819                TRANSFER_END(request, EOK);
    794820
    795821        case USB_DEVREQ_SET_CONFIGURATION:
    796822                usb_log_debug("USB_DEVREQ_SET_CONFIGURATION: %u\n",
    797                     setup_request->value);
     823                    uint16_usb2host(setup_request->value));
    798824                /* We have only one configuration, it's number is 1 */
    799825                if (uint16_usb2host(setup_request->value) != 1)
  • uspace/drv/bus/usb/ohci/utils/malloc32.h

    re0d5bc5 r96e01fbc  
    6363        return result;
    6464}
    65 /*----------------------------------------------------------------------------*/
     65
    6666/** Physical mallocator simulator
    6767 *
     
    7171static inline void * malloc32(size_t size)
    7272        { return memalign(OHCI_ALIGN, size); }
    73 /*----------------------------------------------------------------------------*/
     73
    7474/** Physical mallocator simulator
    7575 *
  • uspace/drv/bus/usb/uhci/hc.c

    re0d5bc5 r96e01fbc  
    5050static const irq_pio_range_t uhci_irq_pio_ranges[] = {
    5151        {
    52                 .base = 0,      /* filled later */
     52                .base = 0,
    5353                .size = sizeof(uhci_regs_t)
    5454        }
     
    5656
    5757static const irq_cmd_t uhci_irq_commands[] = {
    58         { .cmd = CMD_PIO_READ_16, .dstarg = 1, .addr = NULL/*filled later*/},
    59         { .cmd = CMD_BTEST, .srcarg = 1, .dstarg = 2,
    60           .value = UHCI_STATUS_USED_INTERRUPTS | UHCI_STATUS_NM_INTERRUPTS },
    61         { .cmd = CMD_PREDICATE, .srcarg = 2, .value = 2 },
    62         { .cmd = CMD_PIO_WRITE_A_16, .srcarg = 1, .addr = NULL/*filled later*/},
    63         { .cmd = CMD_ACCEPT },
     58        {
     59                .cmd = CMD_PIO_READ_16,
     60                .dstarg = 1,
     61                .addr = NULL
     62        },
     63        {
     64                .cmd = CMD_AND,
     65                .srcarg = 1,
     66                .dstarg = 2,
     67                .value = UHCI_STATUS_USED_INTERRUPTS | UHCI_STATUS_NM_INTERRUPTS
     68        },
     69        {
     70                .cmd = CMD_PREDICATE,
     71                .srcarg = 2,
     72                .value = 2
     73        },
     74        {
     75                .cmd = CMD_PIO_WRITE_A_16,
     76                .srcarg = 1,
     77                .addr = NULL
     78        },
     79        {
     80                .cmd = CMD_ACCEPT
     81        }
    6482};
    6583
     
    7290static int hc_debug_checker(void *arg);
    7391
    74 /*----------------------------------------------------------------------------*/
     92
    7593/** Get number of PIO ranges used in IRQ code.
    7694 * @return Number of ranges.
     
    8098        return sizeof(uhci_irq_pio_ranges) / sizeof(irq_pio_range_t);
    8199}
    82 /*----------------------------------------------------------------------------*/
     100
    83101/** Get number of commands used in IRQ code.
    84102 * @return Number of commands.
     
    88106        return sizeof(uhci_irq_commands) / sizeof(irq_cmd_t);
    89107}
    90 /*----------------------------------------------------------------------------*/
     108
    91109/** Generate IRQ code.
    92110 * @param[out] ranges PIO ranges buffer.
     
    118136        return EOK;
    119137}
    120 /*----------------------------------------------------------------------------*/
     138
    121139/** Take action based on the interrupt cause.
    122140 *
     
    175193        }
    176194}
    177 /*----------------------------------------------------------------------------*/
     195
    178196/** Initialize UHCI hc driver structure
    179197 *
     
    235253        return EOK;
    236254}
    237 /*----------------------------------------------------------------------------*/
     255
    238256/** Initialize UHCI hc hw resources.
    239257 *
     
    277295            UHCI_CMD_RUN_STOP | UHCI_CMD_MAX_PACKET | UHCI_CMD_CONFIGURE);
    278296}
    279 /*----------------------------------------------------------------------------*/
     297
    280298/** Initialize UHCI hc memory structures.
    281299 *
     
    319337        return EOK;
    320338}
    321 /*----------------------------------------------------------------------------*/
     339
    322340/** Initialize UHCI hc transfer lists.
    323341 *
     
    381399#undef CHECK_RET_CLEAR_RETURN
    382400}
    383 /*----------------------------------------------------------------------------*/
     401
    384402/** Schedule batch for execution.
    385403 *
     
    409427        return EOK;
    410428}
    411 /*----------------------------------------------------------------------------*/
     429
    412430/** Polling function, emulates interrupts.
    413431 *
     
    432450        return EOK;
    433451}
    434 /*----------------------------------------------------------------------------*/
     452
    435453/** Debug function, checks consistency of memory structures.
    436454 *
  • uspace/drv/bus/usb/uhci/hw_struct/queue_head.h

    re0d5bc5 r96e01fbc  
    4747        volatile link_pointer_t element;
    4848} __attribute__((packed)) qh_t;
    49 /*----------------------------------------------------------------------------*/
     49
    5050/** Initialize queue head structure
    5151 *
     
    6161        instance->next = LINK_POINTER_TERM;
    6262}
    63 /*----------------------------------------------------------------------------*/
     63
    6464/** Set queue head next pointer
    6565 *
     
    8181        }
    8282}
    83 /*----------------------------------------------------------------------------*/
     83
    8484/** Set queue head element pointer
    8585 *
  • uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.c

    re0d5bc5 r96e01fbc  
    107107        }
    108108}
    109 /*----------------------------------------------------------------------------*/
     109
    110110/** Convert TD status into standard error code
    111111 *
     
    145145        return EOK;
    146146}
    147 /*----------------------------------------------------------------------------*/
     147
    148148/** Print values in status field (dw1) in a human readable way.
    149149 *
  • uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.h

    re0d5bc5 r96e01fbc  
    100100
    101101void td_print_status(const td_t *instance);
    102 /*----------------------------------------------------------------------------*/
     102
    103103/** Helper function for parsing actual size out of TD.
    104104 *
     
    113113        return ((s >> TD_STATUS_ACTLEN_POS) + 1) & TD_STATUS_ACTLEN_MASK;
    114114}
    115 /*----------------------------------------------------------------------------*/
     115
    116116/** Check whether less than max data were received on SPD marked transfer.
    117117 *
     
    129129            (instance->status | TD_STATUS_SPD_FLAG) && act_size < max_size;
    130130}
    131 /*----------------------------------------------------------------------------*/
     131
    132132/** Helper function for parsing value of toggle bit.
    133133 *
     
    140140        return (instance->device & TD_DEVICE_DATA_TOGGLE_ONE_FLAG) ? 1 : 0;
    141141}
    142 /*----------------------------------------------------------------------------*/
     142
    143143/** Helper function for parsing value of active bit
    144144 *
     
    151151        return (instance->status & TD_STATUS_ERROR_ACTIVE) != 0;
    152152}
    153 /*----------------------------------------------------------------------------*/
     153
    154154/** Helper function for setting IOC bit.
    155155 *
     
    161161        instance->status |= TD_STATUS_IOC_FLAG;
    162162}
    163 /*----------------------------------------------------------------------------*/
     163
    164164#endif
    165165/**
  • uspace/drv/bus/usb/uhci/main.c

    re0d5bc5 r96e01fbc  
    4444
    4545static int uhci_dev_add(ddf_dev_t *device);
    46 /*----------------------------------------------------------------------------*/
     46
    4747static driver_ops_t uhci_driver_ops = {
    4848        .dev_add = uhci_dev_add,
    4949};
    50 /*----------------------------------------------------------------------------*/
     50
    5151static driver_t uhci_driver = {
    5252        .name = NAME,
    5353        .driver_ops = &uhci_driver_ops
    5454};
    55 /*----------------------------------------------------------------------------*/
     55
    5656/** Initialize a new ddf driver instance for uhci hc and hub.
    5757 *
     
    7070        } else {
    7171                usb_log_info("Controlling new UHCI device '%s'.\n",
    72                     device->name);
     72                    ddf_dev_get_name(device));
    7373        }
    7474
    7575        return ret;
    7676}
    77 /*----------------------------------------------------------------------------*/
     77
    7878/** Initialize global driver structures (NONE).
    7979 *
  • uspace/drv/bus/usb/uhci/res.c

    re0d5bc5 r96e01fbc  
    5151 * @return Error code.
    5252 */
    53 int get_my_registers(const ddf_dev_t *dev,
     53int get_my_registers(ddf_dev_t *dev,
    5454    uintptr_t *io_reg_address, size_t *io_reg_size, int *irq_no)
    5555{
     
    5757
    5858        async_sess_t *parent_sess =
    59             devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
    60             IPC_FLAG_BLOCKING);
     59            devman_parent_device_connect(EXCHANGE_SERIALIZE,
     60            ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
    6161        if (!parent_sess)
    6262                return ENOMEM;
     
    9292 * @return Error code.
    9393 */
    94 int enable_interrupts(const ddf_dev_t *device)
     94int enable_interrupts(ddf_dev_t *device)
    9595{
    9696        async_sess_t *parent_sess =
    97             devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
    98             IPC_FLAG_BLOCKING);
     97            devman_parent_device_connect(EXCHANGE_SERIALIZE,
     98            ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
    9999        if (!parent_sess)
    100100                return ENOMEM;
     
    111111 * @return Error code.
    112112 */
    113 int disable_legacy(const ddf_dev_t *device)
     113int disable_legacy(ddf_dev_t *device)
    114114{
    115115        assert(device);
    116116
    117117        async_sess_t *parent_sess = devman_parent_device_connect(
    118             EXCHANGE_SERIALIZE, device->handle, IPC_FLAG_BLOCKING);
     118            EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
    119119        if (!parent_sess)
    120120                return ENOMEM;
  • uspace/drv/bus/usb/uhci/res.h

    re0d5bc5 r96e01fbc  
    3838#include <ddf/driver.h>
    3939
    40 int get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
    41 int enable_interrupts(const ddf_dev_t *);
    42 int disable_legacy(const ddf_dev_t *);
     40int get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *);
     41int enable_interrupts(ddf_dev_t *);
     42int disable_legacy(ddf_dev_t *);
    4343
    4444#endif
  • uspace/drv/bus/usb/uhci/transfer_list.c

    re0d5bc5 r96e01fbc  
    4242static void transfer_list_remove_batch(
    4343    transfer_list_t *instance, uhci_transfer_batch_t *uhci_batch);
    44 /*----------------------------------------------------------------------------*/
     44
    4545/** Initialize transfer list structures.
    4646 *
     
    6969        return EOK;
    7070}
    71 /*----------------------------------------------------------------------------*/
     71
    7272/** Dispose transfer list structures.
    7373 *
     
    9797        qh_set_next_qh(instance->queue_head, next->queue_head);
    9898}
    99 /*----------------------------------------------------------------------------*/
     99
    100100/** Add transfer batch to the list and queue.
    101101 *
     
    144144        fibril_mutex_unlock(&instance->guard);
    145145}
    146 /*----------------------------------------------------------------------------*/
     146
    147147/** Add completed batches to the provided list.
    148148 *
     
    171171        fibril_mutex_unlock(&instance->guard);
    172172}
    173 /*----------------------------------------------------------------------------*/
     173
    174174/** Walk the list and finish all batches with EINTR.
    175175 *
     
    188188        fibril_mutex_unlock(&instance->guard);
    189189}
    190 /*----------------------------------------------------------------------------*/
     190
    191191/** Remove a transfer batch from the list and queue.
    192192 *
  • uspace/drv/bus/usb/uhci/uhci.c

    re0d5bc5 r96e01fbc  
    3333 * @brief UHCI driver
    3434 */
     35
     36/* XXX Fix this */
     37#define _DDF_DATA_IMPLANT
     38
    3539#include <errno.h>
    3640#include <str_error.h>
     
    6064} uhci_t;
    6165
    62 static inline uhci_t * dev_to_uhci(const ddf_dev_t *dev)
    63 {
    64         assert(dev);
    65         return dev->driver_data;
    66 }
    67 /*----------------------------------------------------------------------------*/
     66static inline uhci_t *dev_to_uhci(ddf_dev_t *dev)
     67{
     68        return ddf_dev_data_get(dev);
     69}
     70
    6871/** IRQ handling callback, forward status from call to diver structure.
    6972 *
     
    8386        hc_interrupt(&uhci->hc, status);
    8487}
    85 /*----------------------------------------------------------------------------*/
     88
    8689/** Operations supported by the HC driver */
    8790static ddf_dev_ops_t hc_ops = {
    8891        .interfaces[USBHC_DEV_IFACE] = &hcd_iface, /* see iface.h/c */
    8992};
    90 /*----------------------------------------------------------------------------*/
     93
    9194/** Gets handle of the respective hc.
    9295 *
     
    97100static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle)
    98101{
    99         assert(fun);
    100         ddf_fun_t *hc_fun = dev_to_uhci(fun->dev)->hc_fun;
     102        ddf_fun_t *hc_fun = dev_to_uhci(ddf_fun_get_dev(fun))->hc_fun;
    101103        assert(hc_fun);
    102104
    103105        if (handle != NULL)
    104                 *handle = hc_fun->handle;
     106                *handle = ddf_fun_get_handle(hc_fun);
    105107        return EOK;
    106108}
    107 /*----------------------------------------------------------------------------*/
     109
    108110/** USB interface implementation used by RH */
    109111static usb_iface_t usb_iface = {
    110112        .get_hc_handle = usb_iface_get_hc_handle,
    111113};
    112 /*----------------------------------------------------------------------------*/
     114
    113115/** Get root hub hw resources (I/O registers).
    114116 *
     
    118120static hw_resource_list_t *get_resource_list(ddf_fun_t *fun)
    119121{
    120         assert(fun);
    121         rh_t *rh = fun->driver_data;
     122        rh_t *rh = ddf_fun_data_get(fun);
    122123        assert(rh);
    123124        return &rh->resource_list;
    124125}
    125 /*----------------------------------------------------------------------------*/
     126
    126127/** Interface to provide the root hub driver with hw info */
    127128static hw_res_ops_t hw_res_iface = {
     
    129130        .enable_interrupt = NULL,
    130131};
    131 /*----------------------------------------------------------------------------*/
     132
    132133/** RH function support for uhci_rhd */
    133134static ddf_dev_ops_t rh_ops = {
     
    135136        .interfaces[HW_RES_DEV_IFACE] = &hw_res_iface
    136137};
    137 /*----------------------------------------------------------------------------*/
     138
    138139/** Initialize hc and rh DDF structures and their respective drivers.
    139140 *
     
    160161if (ret != EOK) { \
    161162        if (instance->hc_fun) \
    162                 instance->hc_fun->driver_data = NULL; \
    163163                ddf_fun_destroy(instance->hc_fun); \
    164164        if (instance->rh_fun) {\
    165                 instance->rh_fun->driver_data = NULL; \
    166165                ddf_fun_destroy(instance->rh_fun); \
    167166        } \
     
    174173        int ret = (instance->hc_fun == NULL) ? ENOMEM : EOK;
    175174        CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create UHCI HC function.\n");
    176         instance->hc_fun->ops = &hc_ops;
    177         instance->hc_fun->driver_data = &instance->hc.generic;
     175        ddf_fun_set_ops(instance->hc_fun, &hc_ops);
     176        ddf_fun_data_implant(instance->hc_fun, &instance->hc.generic);
    178177
    179178        instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci_rh");
    180179        ret = (instance->rh_fun == NULL) ? ENOMEM : EOK;
    181180        CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create UHCI RH function.\n");
    182         instance->rh_fun->ops = &rh_ops;
    183         instance->rh_fun->driver_data = &instance->rh;
     181        ddf_fun_set_ops(instance->rh_fun, &rh_ops);
     182        ddf_fun_data_implant(instance->rh_fun, &instance->rh);
    184183
    185184        uintptr_t reg_base = 0;
     
    190189        CHECK_RET_DEST_FREE_RETURN(ret,
    191190            "Failed to get I/O addresses for %" PRIun ": %s.\n",
    192             device->handle, str_error(ret));
     191            ddf_dev_get_handle(device), str_error(ret));
    193192        usb_log_debug("I/O regs at 0x%p (size %zu), IRQ %d.\n",
    194193            (void *) reg_base, reg_size, irq);
  • uspace/drv/bus/usb/uhci/uhci_batch.c

    re0d5bc5 r96e01fbc  
    5858        }
    5959}
    60 /*----------------------------------------------------------------------------*/
     60
    6161/** Finishes usb_transfer_batch and destroys the structure.
    6262 *
     
    7171        uhci_transfer_batch_dispose(uhci_batch);
    7272}
    73 /*----------------------------------------------------------------------------*/
     73
    7474/** Transfer batch setup table. */
    7575static void (*const batch_setup[])(uhci_transfer_batch_t*, usb_direction_t);
    76 /*----------------------------------------------------------------------------*/
     76
    7777/** Allocate memory and initialize internal data structure.
    7878 *
     
    143143        return uhci_batch;
    144144}
    145 /*----------------------------------------------------------------------------*/
     145
    146146/** Check batch TDs for activity.
    147147 *
     
    196196        return true;
    197197}
    198 /*----------------------------------------------------------------------------*/
     198
    199199/** Direction to pid conversion table */
    200200static const usb_packet_id direction_pids[] = {
     
    202202        [USB_DIRECTION_OUT] = USB_PID_OUT,
    203203};
    204 /*----------------------------------------------------------------------------*/
     204
    205205/** Prepare generic data transfer
    206206 *
     
    259259            USB_TRANSFER_BATCH_ARGS(*uhci_batch->usb_batch));
    260260}
    261 /*----------------------------------------------------------------------------*/
     261
    262262/** Prepare generic control transfer
    263263 *
     
    331331            uhci_batch->tds[td].status);
    332332}
    333 /*----------------------------------------------------------------------------*/
     333
    334334static void (*const batch_setup[])(uhci_transfer_batch_t*, usb_direction_t) =
    335335{
  • uspace/drv/bus/usb/uhci/uhci_batch.h

    re0d5bc5 r96e01fbc  
    7676            uhci_batch->td_count * sizeof(td_t);
    7777}
    78 /*----------------------------------------------------------------------------*/
     78
    7979/** Get offset to data buffer accessible to the HC hw.
    8080 * @param uhci_batch UHCI batch structure.
     
    8989            uhci_batch->usb_batch->setup_size;
    9090}
    91 /*----------------------------------------------------------------------------*/
     91
    9292/** Aborts the batch.
    9393 * Sets error to EINTR and size off transferd data to 0, before finishing the
     
    103103        uhci_transfer_batch_finish_dispose(uhci_batch);
    104104}
    105 /*----------------------------------------------------------------------------*/
     105
    106106/** Linked list conversion wrapper.
    107107 * @param l Linked list link.
  • uspace/drv/bus/usb/uhci/utils/malloc32.h

    re0d5bc5 r96e01fbc  
    3535#define DRV_UHCI_UTILS_MALLOC32_H
    3636
     37#include <as.h>
    3738#include <assert.h>
    38 #include <unistd.h>
     39#include <ddi.h>
    3940#include <errno.h>
    4041#include <malloc.h>
    4142#include <mem.h>
    42 #include <as.h>
     43#include <unistd.h>
    4344
    4445#define UHCI_STRCUTURES_ALIGNMENT 16
     
    6364        return result;
    6465}
    65 /*----------------------------------------------------------------------------*/
     66
    6667/** DMA malloc simulator
    6768 *
     
    8586        return memalign(alignment, size);
    8687}
    87 /*----------------------------------------------------------------------------*/
     88
    8889/** DMA malloc simulator
    8990 *
     
    9293static inline void free32(void *addr)
    9394        { free(addr); }
    94 /*----------------------------------------------------------------------------*/
     95
    9596/** Create 4KB page mapping
    9697 *
     
    99100static inline void * get_page(void)
    100101{
    101         void *address = as_area_create(AS_AREA_ANY, UHCI_REQUIRED_PAGE_SIZE,
    102             AS_AREA_READ | AS_AREA_WRITE);
    103         if (address == AS_MAP_FAILED)
    104                 return NULL;
    105        
    106         return address;
     102        void *address, *phys;
     103        const int ret = dmamem_map_anonymous(UHCI_REQUIRED_PAGE_SIZE,
     104            AS_AREA_READ | AS_AREA_WRITE, 0, &phys, &address);
     105        return ret == EOK ? address : NULL;
    107106}
    108 /*----------------------------------------------------------------------------*/
     107
    109108static inline void return_page(void *page)
    110109{
    111         if (page)
    112                 as_area_destroy(page);
     110        dmamem_unmap_anonymous(page);
    113111}
    114112
  • uspace/drv/bus/usb/uhcirh/main.c

    re0d5bc5 r96e01fbc  
    4848#define NAME "uhcirh"
    4949
    50 static int hc_get_my_registers(const ddf_dev_t *dev,
     50static int hc_get_my_registers(ddf_dev_t *dev,
    5151    uintptr_t *io_reg_address, size_t *io_reg_size);
    5252
     
    8888
    8989        usb_log_debug2("uhci_rh_dev_add(handle=%" PRIun ")\n",
    90             device->handle);
     90            ddf_dev_get_handle(device));
    9191
    9292        uintptr_t io_regs = 0;
     
    9898if (ret != EOK) { \
    9999        usb_log_error(message); \
    100         if (rh) \
    101                 free(rh); \
    102100        return ret; \
    103101} else (void)0
     
    109107            (void *) io_regs, io_size);
    110108
    111         rh = malloc(sizeof(uhci_root_hub_t));
     109        rh = ddf_dev_data_alloc(device, sizeof(uhci_root_hub_t));
    112110        ret = (rh == NULL) ? ENOMEM : EOK;
    113111        CHECK_RET_FREE_RH_RETURN(ret,
     
    119117            ret, str_error(ret));
    120118
    121         device->driver_data = rh;
    122119        usb_log_info("Controlling root hub '%s' (%" PRIun ").\n",
    123             device->name, device->handle);
     120            ddf_dev_get_name(device), ddf_dev_get_handle(device));
    124121        return EOK;
    125122}
     
    133130 */
    134131int hc_get_my_registers(
    135     const ddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size)
     132    ddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size)
    136133{
    137         assert(dev);
    138 
    139134        async_sess_t *parent_sess =
    140             devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
    141             IPC_FLAG_BLOCKING);
     135            devman_parent_device_connect(EXCHANGE_SERIALIZE,
     136            ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
    142137        if (!parent_sess)
    143138                return ENOMEM;
  • uspace/drv/bus/usb/uhcirh/port.c

    re0d5bc5 r96e01fbc  
    6363        return pio_read_16(port->address);
    6464}
    65 /*----------------------------------------------------------------------------*/
     65
    6666/** Register writing helper function.
    6767 *
     
    7575        pio_write_16(port->address, val);
    7676}
    77 /*----------------------------------------------------------------------------*/
     77
    7878/** Initialize UHCI root hub port instance.
    7979 *
     
    127127        return EOK;
    128128}
    129 /*----------------------------------------------------------------------------*/
     129
    130130/** Cleanup UHCI root hub port instance.
    131131 *
     
    141141        return;
    142142}
    143 /*----------------------------------------------------------------------------*/
     143
    144144/** Periodically checks port status and reports new devices.
    145145 *
     
    210210        return EOK;
    211211}
    212 /*----------------------------------------------------------------------------*/
     212
    213213/** Callback for enabling port during adding a new device.
    214214 *
     
    247247        return EOK;
    248248}
    249 /*----------------------------------------------------------------------------*/
     249
    250250/** Initialize and report connected device.
    251251 *
     
    279279        usb_log_info("%s: New device, address %d (handle %" PRIun ").\n",
    280280            port->id_string, port->attached_device.address,
    281             port->attached_device.fun->handle);
    282         return EOK;
    283 }
    284 /*----------------------------------------------------------------------------*/
     281            ddf_fun_get_handle(port->attached_device.fun));
     282        return EOK;
     283}
     284
    285285/** Remove device.
    286286 *
     
    324324        return EOK;
    325325}
    326 /*----------------------------------------------------------------------------*/
     326
    327327/** Enable or disable root hub port.
    328328 *
     
    358358        return EOK;
    359359}
    360 /*----------------------------------------------------------------------------*/
     360
    361361/** Print the port status value in a human friendly way
    362362 *
  • uspace/drv/bus/usb/uhcirh/root_hub.c

    re0d5bc5 r96e01fbc  
    7979        return EOK;
    8080}
    81 /*----------------------------------------------------------------------------*/
     81
    8282/** Cleanup UHCI root hub instance.
    8383 *
     
    9292        }
    9393}
    94 /*----------------------------------------------------------------------------*/
     94
    9595/**
    9696 * @}
  • uspace/drv/bus/usb/usbflbk/main.c

    re0d5bc5 r96e01fbc  
    6969            " (node `%s', handle %" PRIun ").\n",
    7070            dev->interface_no < 0 ? "device" : "interface",
    71             dev->ddf_dev->name, fun_name, dev->ddf_dev->handle);
     71            ddf_dev_get_name(dev->ddf_dev), fun_name, ddf_dev_get_handle(dev->ddf_dev));
    7272
    7373        return EOK;
     
    8585        const int ret = ddf_fun_unbind(ctl_fun);
    8686        if (ret != EOK) {
    87                 usb_log_error("Failed to unbind %s.\n", ctl_fun->name);
     87                usb_log_error("Failed to unbind %s.\n", ddf_fun_get_name(ctl_fun));
    8888                return ret;
    8989        }
  • uspace/drv/bus/usb/usbhid/generic/hiddev.c

    re0d5bc5 r96e01fbc  
    3535 */
    3636
     37/* XXX Fix this */
     38#define _DDF_DATA_IMPLANT
     39
    3740#include <usb/debug.h>
    3841#include <usb/classes/classes.h>
     
    4649#include "usbhid.h"
    4750
    48 /*----------------------------------------------------------------------------*/
     51
    4952
    5053const usb_endpoint_description_t usb_hid_generic_poll_endpoint_description = {
     
    6063const char *HID_GENERIC_CLASS_NAME = "hid";
    6164
    62 /*----------------------------------------------------------------------------*/
     65
    6366static size_t usb_generic_hid_get_event_length(ddf_fun_t *fun);
    6467static int usb_generic_hid_get_event(ddf_fun_t *fun, uint8_t *buffer,
     
    6871static int usb_generic_get_report_descriptor(ddf_fun_t *fun, uint8_t *desc,
    6972    size_t size, size_t *actual_size);
    70 /*----------------------------------------------------------------------------*/
     73
    7174static usbhid_iface_t usb_generic_iface = {
    7275        .get_event = usb_generic_hid_get_event,
     
    7578        .get_report_descriptor = usb_generic_get_report_descriptor
    7679};
    77 /*----------------------------------------------------------------------------*/
     80
    7881static ddf_dev_ops_t usb_generic_hid_ops = {
    7982        .interfaces[USBHID_DEV_IFACE] = &usb_generic_iface,
    8083        .open = usb_generic_hid_client_connected
    8184};
    82 /*----------------------------------------------------------------------------*/
     85
     86/** Return hid_dev_t * for generic HID function node.
     87 *
     88 * For the generic HID subdriver the 'hid' function has usb_hid_gen_fun_t
     89 * as soft state. Through that we can get to the usb_hid_dev_t.
     90 */
     91static usb_hid_dev_t *fun_hid_dev(ddf_fun_t *fun)
     92{
     93        return ((usb_hid_gen_fun_t *)ddf_fun_data_get(fun))->hid_dev;
     94}
     95
    8396static size_t usb_generic_hid_get_event_length(ddf_fun_t *fun)
    8497{
    8598        usb_log_debug2("Generic HID: Get event length (fun: %p, "
    86             "fun->driver_data: %p.\n", fun, fun->driver_data);
    87 
    88         if (fun == NULL || fun->driver_data == NULL) {
    89                 return 0;
    90         }
    91 
    92         const usb_hid_dev_t *hid_dev = fun->driver_data;
     99            "fun->driver_data: %p.\n", fun, ddf_fun_data_get(fun));
     100
     101        const usb_hid_dev_t *hid_dev = fun_hid_dev(fun);
    93102
    94103        usb_log_debug2("hid_dev: %p, Max input report size (%zu).\n",
     
    97106        return hid_dev->max_input_report_size;
    98107}
    99 /*----------------------------------------------------------------------------*/
     108
    100109static int usb_generic_hid_get_event(ddf_fun_t *fun, uint8_t *buffer,
    101110    size_t size, size_t *act_size, int *event_nr, unsigned int flags)
     
    103112        usb_log_debug2("Generic HID: Get event.\n");
    104113
    105         if (fun == NULL || fun->driver_data == NULL || buffer == NULL
    106             || act_size == NULL || event_nr == NULL) {
     114        if (buffer == NULL || act_size == NULL || event_nr == NULL) {
    107115                usb_log_debug("No function");
    108116                return EINVAL;
    109117        }
    110118
    111         const usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;
     119        const usb_hid_dev_t *hid_dev = fun_hid_dev(fun);
    112120
    113121        if (hid_dev->input_report_size > size) {
     
    127135        return EOK;
    128136}
    129 /*----------------------------------------------------------------------------*/
     137
    130138static size_t usb_generic_get_report_descriptor_length(ddf_fun_t *fun)
    131139{
    132140        usb_log_debug("Generic HID: Get report descriptor length.\n");
    133141
    134         if (fun == NULL || fun->driver_data == NULL) {
    135                 usb_log_debug("No function");
    136                 return EINVAL;
    137         }
    138 
    139         const usb_hid_dev_t *hid_dev = fun->driver_data;
     142        const usb_hid_dev_t *hid_dev = fun_hid_dev(fun);
    140143
    141144        usb_log_debug2("hid_dev->report_desc_size = %zu\n",
     
    144147        return hid_dev->report_desc_size;
    145148}
    146 /*----------------------------------------------------------------------------*/
     149
    147150static int usb_generic_get_report_descriptor(ddf_fun_t *fun, uint8_t *desc,
    148151    size_t size, size_t *actual_size)
     
    150153        usb_log_debug2("Generic HID: Get report descriptor.\n");
    151154
    152         if (fun == NULL || fun->driver_data == NULL) {
    153                 usb_log_debug("No function");
    154                 return EINVAL;
    155         }
    156 
    157         const usb_hid_dev_t *hid_dev = fun->driver_data;
     155        const usb_hid_dev_t *hid_dev = fun_hid_dev(fun);
    158156
    159157        if (hid_dev->report_desc_size > size) {
     
    166164        return EOK;
    167165}
    168 /*----------------------------------------------------------------------------*/
     166
    169167static int usb_generic_hid_client_connected(ddf_fun_t *fun)
    170168{
     
    172170        return EOK;
    173171}
    174 /*----------------------------------------------------------------------------*/
     172
    175173void usb_generic_hid_deinit(usb_hid_dev_t *hid_dev, void *data)
    176174{
     
    183181                return;
    184182        }
    185         usb_log_debug2("%s unbound.\n", fun->name);
    186         /* We did not allocate this, so leave this alone
    187          * the device would take care of it */
    188         fun->driver_data = NULL;
     183        usb_log_debug2("%s unbound.\n", ddf_fun_get_name(fun));
    189184        ddf_fun_destroy(fun);
    190185}
    191 /*----------------------------------------------------------------------------*/
     186
    192187int usb_generic_hid_init(usb_hid_dev_t *hid_dev, void **data)
    193188{
     189        usb_hid_gen_fun_t *hid_fun;
     190
    194191        if (hid_dev == NULL) {
    195192                return EINVAL;
     
    205202        }
    206203
    207         /* This is nasty, both device and this function have the same
    208          * driver data, thus destruction causes to double free */
    209         fun->driver_data = hid_dev;
    210         fun->ops = &usb_generic_hid_ops;
     204        /* Create softstate */
     205        hid_fun = ddf_fun_data_alloc(fun, sizeof(usb_hid_gen_fun_t));
     206        hid_fun->hid_dev = hid_dev;
     207        ddf_fun_set_ops(fun, &usb_generic_hid_ops);
    211208
    212209        int rc = ddf_fun_bind(fun);
     
    214211                usb_log_error("Could not bind DDF function: %s.\n",
    215212                    str_error(rc));
    216                 fun->driver_data = NULL;
    217213                ddf_fun_destroy(fun);
    218214                return rc;
    219215        }
    220216
    221         usb_log_debug("HID function created. Handle: %" PRIun "\n", fun->handle);
     217        usb_log_debug("HID function created. Handle: %" PRIun "\n",
     218            ddf_fun_get_handle(fun));
    222219        *data = fun;
    223220
    224221        return EOK;
    225222}
    226 /*----------------------------------------------------------------------------*/
     223
    227224bool usb_generic_hid_polling_callback(usb_hid_dev_t *hid_dev, void *data)
    228225{
  • uspace/drv/bus/usb/usbhid/generic/hiddev.h

    re0d5bc5 r96e01fbc  
    4747const char *HID_GENERIC_CLASS_NAME;
    4848
    49 /*----------------------------------------------------------------------------*/
     49/** The USB HID generic 'hid' function softstate */
     50typedef struct {
     51        struct usb_hid_dev *hid_dev;
     52} usb_hid_gen_fun_t;
    5053
    5154int usb_generic_hid_init(struct usb_hid_dev *hid_dev, void **data);
  • uspace/drv/bus/usb/usbhid/kbd/kbddev.c

    re0d5bc5 r96e01fbc  
    3434 * USB HID keyboard device structure and API.
    3535 */
     36
     37/* XXX Fix this */
     38#define _DDF_DATA_IMPLANT
    3639
    3740#include <errno.h>
     
    7174#include "../usbhid.h"
    7275
    73 /*----------------------------------------------------------------------------*/
     76static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
     77static ddf_dev_ops_t kbdops = { .default_handler = default_connection_handler };
     78
    7479
    7580static const unsigned DEFAULT_ACTIVE_MODS = KM_NUM_LOCK;
     
    8691static const unsigned int DEFAULT_REPEAT_DELAY = 50 * 1000;
    8792
    88 /*----------------------------------------------------------------------------*/
     93
    8994/** Keyboard polling endpoint description for boot protocol class. */
    9095const usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description = {
     
    101106
    102107static void usb_kbd_set_led(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev);
    103 /*----------------------------------------------------------------------------*/
     108
    104109static const uint8_t USB_KBD_BOOT_REPORT_DESCRIPTOR[] = {
    105110        0x05, 0x01,  /* Usage Page (Generic Desktop), */
     
    136141        0xC0         /* End Collection */
    137142};
    138 /*----------------------------------------------------------------------------*/
     143
    139144typedef enum usb_kbd_flags {
    140145        USB_KBD_STATUS_UNINITIALIZED = 0,
     
    142147        USB_KBD_STATUS_TO_DESTROY = -1
    143148} usb_kbd_flags;
    144 /*----------------------------------------------------------------------------*/
     149
    145150/* IPC method handler                                                         */
    146 /*----------------------------------------------------------------------------*/
     151
    147152/**
    148153 * Default handler for IPC methods not handled by DDF.
     
    160165    ipc_callid_t icallid, ipc_call_t *icall)
    161166{
    162         if (fun == NULL || fun->driver_data == NULL) {
    163                 usb_log_error("%s: Missing parameter.\n", __FUNCTION__);
    164                 async_answer_0(icallid, EINVAL);
    165                 return;
    166         }
    167 
    168167        const sysarg_t method = IPC_GET_IMETHOD(*icall);
    169         usb_kbd_t *kbd_dev = fun->driver_data;
     168        usb_kbd_t *kbd_dev = ddf_fun_data_get(fun);
    170169
    171170        switch (method) {
     
    187186                        break;
    188187                }
    189                 if (kbd_dev->console_sess == NULL) {
    190                         kbd_dev->console_sess = sess;
     188                if (kbd_dev->client_sess == NULL) {
     189                        kbd_dev->client_sess = sess;
    191190                        usb_log_debug("%s: OK\n", __FUNCTION__);
    192191                        async_answer_0(icallid, EOK);
     
    206205
    207206}
    208 /*----------------------------------------------------------------------------*/
     207
    209208/* Key processing functions                                                   */
    210 /*----------------------------------------------------------------------------*/
     209
    211210/**
    212211 * Handles turning of LED lights on and off.
     
    281280        }
    282281}
    283 /*----------------------------------------------------------------------------*/
     282
    284283/** Send key event.
    285284 *
     
    292291{
    293292        usb_log_debug2("Sending kbdev event %d/%d to the console\n", type, key);
    294         if (kbd_dev->console_sess == NULL) {
     293        if (kbd_dev->client_sess == NULL) {
    295294                usb_log_warning(
    296295                    "Connection to console not ready, key discarded.\n");
     
    298297        }
    299298
    300         async_exch_t *exch = async_exchange_begin(kbd_dev->console_sess);
     299        async_exch_t *exch = async_exchange_begin(kbd_dev->client_sess);
    301300        if (exch != NULL) {
    302301                async_msg_2(exch, KBDEV_EVENT, type, key);
     
    306305        }
    307306}
    308 /*----------------------------------------------------------------------------*/
     307
    309308static inline int usb_kbd_is_lock(unsigned int key_code)
    310309{
     
    313312            || key_code == KC_CAPS_LOCK);
    314313}
    315 /*----------------------------------------------------------------------------*/
     314
    316315static size_t find_in_array_int32(int32_t val, int32_t *arr, size_t arr_size)
    317316{
     
    324323        return (size_t) -1;
    325324}
    326 /*----------------------------------------------------------------------------*/
     325
    327326/**
    328327 * Checks if some keys were pressed or released and generates key events.
     
    407406        usb_log_debug2("Stored keys %s.\n", key_buffer);
    408407}
    409 /*----------------------------------------------------------------------------*/
     408
    410409/* General kbd functions                                                      */
    411 /*----------------------------------------------------------------------------*/
     410
    412411/**
    413412 * Processes data received from the device in form of report.
     
    479478        usb_kbd_check_key_changes(hid_dev, kbd_dev);
    480479}
    481 /*----------------------------------------------------------------------------*/
     480
    482481/* HID/KBD structure manipulation                                             */
    483 /*----------------------------------------------------------------------------*/
     482
    484483static int usb_kbd_create_function(usb_kbd_t *kbd_dev)
    485484{
     
    499498        /* Store the initialized HID device and HID ops
    500499         * to the DDF function. */
    501         fun->ops = &kbd_dev->ops;
    502         fun->driver_data = kbd_dev;
     500        ddf_fun_set_ops(fun, &kbdops);
     501        ddf_fun_data_implant(fun, kbd_dev);
    503502
    504503        int rc = ddf_fun_bind(fun);
     
    506505                usb_log_error("Could not bind DDF function: %s.\n",
    507506                    str_error(rc));
    508                 fun->driver_data = NULL; /* We did not allocate this. */
    509507                ddf_fun_destroy(fun);
    510508                return rc;
     
    512510
    513511        usb_log_debug("%s function created. Handle: %" PRIun "\n",
    514             HID_KBD_FUN_NAME, fun->handle);
     512            HID_KBD_FUN_NAME, ddf_fun_get_handle(fun));
    515513
    516514        usb_log_debug("Adding DDF function to category %s...\n",
     
    522520                    HID_KBD_CLASS_NAME, str_error(rc));
    523521                if (ddf_fun_unbind(fun) == EOK) {
    524                         fun->driver_data = NULL; /* We did not allocate this. */
    525522                        ddf_fun_destroy(fun);
    526523                } else {
    527524                        usb_log_error(
    528525                            "Failed to unbind `%s', will not destroy.\n",
    529                             fun->name);
     526                            ddf_fun_get_name(fun));
    530527                }
    531528                return rc;
     
    535532        return EOK;
    536533}
    537 /*----------------------------------------------------------------------------*/
     534
    538535/* API functions                                                              */
    539 /*----------------------------------------------------------------------------*/
     536
    540537/**
    541538 * Initialization of the USB/HID keyboard structure.
     
    576573        fibril_mutex_initialize(&kbd_dev->repeat_mtx);
    577574        kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED;
    578         kbd_dev->ops.default_handler = default_connection_handler;
    579575
    580576        /* Store link to HID device */
     
    700696        return EOK;
    701697}
    702 /*----------------------------------------------------------------------------*/
     698
    703699bool usb_kbd_polling_callback(usb_hid_dev_t *hid_dev, void *data)
    704700{
     
    714710        return true;
    715711}
    716 /*----------------------------------------------------------------------------*/
     712
    717713int usb_kbd_is_initialized(const usb_kbd_t *kbd_dev)
    718714{
    719715        return (kbd_dev->initialized == USB_KBD_STATUS_INITIALIZED);
    720716}
    721 /*----------------------------------------------------------------------------*/
     717
    722718int usb_kbd_is_ready_to_destroy(const usb_kbd_t *kbd_dev)
    723719{
    724720        return (kbd_dev->initialized == USB_KBD_STATUS_TO_DESTROY);
    725721}
    726 /*----------------------------------------------------------------------------*/
     722
    727723/**
    728724 * Properly destroys the USB/HID keyboard structure.
     
    737733
    738734        /* Hangup session to the console. */
    739         if (kbd_dev->console_sess)
    740                 async_hangup(kbd_dev->console_sess);
     735        if (kbd_dev->client_sess)
     736                async_hangup(kbd_dev->client_sess);
    741737
    742738        //assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));
     
    756752                if (ddf_fun_unbind(kbd_dev->fun) != EOK) {
    757753                        usb_log_warning("Failed to unbind %s.\n",
    758                             kbd_dev->fun->name);
     754                            ddf_fun_get_name(kbd_dev->fun));
    759755                } else {
    760                         usb_log_debug2("%s unbound.\n", kbd_dev->fun->name);
    761                         kbd_dev->fun->driver_data = NULL;
     756                        usb_log_debug2("%s unbound.\n",
     757                            ddf_fun_get_name(kbd_dev->fun));
    762758                        ddf_fun_destroy(kbd_dev->fun);
    763759                }
    764760        }
    765         free(kbd_dev);
    766 }
    767 /*----------------------------------------------------------------------------*/
     761}
     762
    768763void usb_kbd_deinit(usb_hid_dev_t *hid_dev, void *data)
    769764{
     
    778773        }
    779774}
    780 /*----------------------------------------------------------------------------*/
     775
    781776int usb_kbd_set_boot_protocol(usb_hid_dev_t *hid_dev)
    782777{
  • uspace/drv/bus/usb/usbhid/kbd/kbddev.h

    re0d5bc5 r96e01fbc  
    5050struct usb_hid_dev;
    5151
    52 /*----------------------------------------------------------------------------*/
     52
    5353/**
    5454 * USB/HID keyboard device type.
     
    8282        unsigned lock_keys;
    8383
    84         /** IPC session to the console device (for sending key events). */
    85         async_sess_t *console_sess;
    86 
    87         /** @todo What is this actually? */
    88         ddf_dev_ops_t ops;
     84        /** IPC session to client (for sending key events). */
     85        async_sess_t *client_sess;
    8986
    9087        /** Information for auto-repeat of keys. */
     
    116113} usb_kbd_t;
    117114
    118 /*----------------------------------------------------------------------------*/
     115
    119116
    120117extern const usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description;
     
    123120const char *HID_KBD_CLASS_NAME;
    124121
    125 /*----------------------------------------------------------------------------*/
     122
    126123
    127124int usb_kbd_init(struct usb_hid_dev *hid_dev, void **data);
  • uspace/drv/bus/usb/usbhid/kbd/kbdrepeat.c

    re0d5bc5 r96e01fbc  
    105105        }
    106106}
    107 /*----------------------------------------------------------------------------*/
     107
    108108/**
    109109 * Main routine to be executed by a fibril for handling auto-repeat.
     
    132132        return EOK;
    133133}
    134 /*----------------------------------------------------------------------------*/
     134
    135135/**
    136136 * Start repeating particular key.
     
    149149        fibril_mutex_unlock(&kbd->repeat_mtx);
    150150}
    151 /*----------------------------------------------------------------------------*/
     151
    152152/**
    153153 * Stop repeating particular key.
  • uspace/drv/bus/usb/usbhid/kbd/kbdrepeat.h

    re0d5bc5 r96e01fbc  
    4242struct usb_kbd_t;
    4343
    44 /*----------------------------------------------------------------------------*/
     44
    4545/**
    4646 * Structure for keeping information needed for auto-repeat of keys.
     
    5757} usb_kbd_repeat_t;
    5858
    59 /*----------------------------------------------------------------------------*/
     59
    6060
    6161int usb_kbd_repeat_fibril(void *arg);
  • uspace/drv/bus/usb/usbhid/main.c

    re0d5bc5 r96e01fbc  
    103103        if (rc != EOK) {
    104104                usb_log_error("Failed to start polling fibril for `%s'.\n",
    105                     dev->ddf_dev->name);
     105                    ddf_dev_get_name(dev->ddf_dev));
    106106                usb_hid_deinit(hid_dev);
    107107                return rc;
     
    109109        hid_dev->running = true;
    110110
    111         usb_log_info("HID device `%s' ready to use.\n", dev->ddf_dev->name);
     111        usb_log_info("HID device `%s' ready to use.\n",
     112            ddf_dev_get_name(dev->ddf_dev));
    112113
    113114        return EOK;
    114115}
    115 /*----------------------------------------------------------------------------*/
     116
    116117/**
    117118 * Callback for a device about to be removed from the driver.
     
    126127        return ENOTSUP;
    127128}
    128 /*----------------------------------------------------------------------------*/
     129
    129130/**
    130131 * Callback for removing a device from the driver.
     
    149150
    150151        usb_hid_deinit(hid_dev);
    151         usb_log_debug2("%s destruction complete.\n", dev->ddf_dev->name);
     152        usb_log_debug2("%s destruction complete.\n", ddf_dev_get_name(dev->ddf_dev));
    152153        return EOK;
    153154}
    154 /*----------------------------------------------------------------------------*/
     155
    155156/** USB generic driver callbacks */
    156157static const usb_driver_ops_t usb_hid_driver_ops = {
     
    159160        .device_gone = usb_hid_device_gone,
    160161};
    161 /*----------------------------------------------------------------------------*/
     162
    162163/** The driver itself. */
    163164static const usb_driver_t usb_hid_driver = {
     
    166167        .endpoints = usb_hid_endpoints
    167168};
    168 /*----------------------------------------------------------------------------*/
     169
    169170int main(int argc, char *argv[])
    170171{
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.c

    re0d5bc5 r96e01fbc  
    3535 */
    3636
     37/* XXX Fix this */
     38#define _DDF_DATA_IMPLANT
     39
    3740#include <usb/debug.h>
    3841#include <usb/classes/classes.h>
     
    5457#define NAME "mouse"
    5558
    56 /*----------------------------------------------------------------------------*/
     59static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
     60
     61static ddf_dev_ops_t ops = { .default_handler = default_connection_handler };
     62
    5763
    5864const usb_endpoint_description_t usb_hid_mouse_poll_endpoint_description = {
     
    7177static const uint8_t IDLE_RATE = 0;
    7278
    73 /*----------------------------------------------------------------------------*/
     79
    7480static const uint8_t USB_MOUSE_BOOT_REPORT_DESCRIPTOR[] = {
    7581        0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
     
    101107};
    102108
    103 /*----------------------------------------------------------------------------*/
     109
    104110
    105111/** Default handler for IPC methods not handled by DDF.
     
    112118    ipc_callid_t icallid, ipc_call_t *icall)
    113119{
    114         usb_mouse_t *mouse_dev = fun->driver_data;
     120        usb_mouse_t *mouse_dev = ddf_fun_data_get(fun);
    115121
    116122        if (mouse_dev == NULL) {
     
    120126        }
    121127
    122         usb_log_debug("%s: fun->name: %s\n", __FUNCTION__, fun->name);
     128        usb_log_debug("%s: fun->name: %s\n", __FUNCTION__, ddf_fun_get_name(fun));
    123129        usb_log_debug("%s: mouse_sess: %p\n",
    124130            __FUNCTION__, mouse_dev->mouse_sess);
     
    130136                        mouse_dev->mouse_sess = sess;
    131137                        usb_log_debug("Console session to %s set ok (%p).\n",
    132                             fun->name, sess);
     138                            ddf_fun_get_name(fun), sess);
    133139                        async_answer_0(icallid, EOK);
    134140                } else {
    135141                        usb_log_error("Console session to %s already set.\n",
    136                             fun->name);
     142                            ddf_fun_get_name(fun));
    137143                        async_answer_0(icallid, ELIMIT);
    138144                        async_hangup(sess);
     
    143149        }
    144150}
    145 /*----------------------------------------------------------------------------*/
     151
    146152static int get_mouse_axis_move_value(uint8_t rid, usb_hid_report_t *report,
    147153    int32_t usage)
     
    221227                assert(index < mouse_dev->buttons_count);
    222228
    223                 if (mouse_dev->buttons[index] == 0 && field->value != 0) {
     229                if (mouse_dev->buttons[index] != field->value) {
    224230                        async_exch_t *exch =
    225231                            async_exchange_begin(mouse_dev->mouse_sess);
    226232                        if (exch != NULL) {
    227233                                async_req_2_0(exch, MOUSEEV_BUTTON_EVENT,
    228                                     field->usage, 1);
    229                                 async_exchange_end(exch);
    230                                 mouse_dev->buttons[index] = field->value;
    231                         }
    232 
    233                 } else if (mouse_dev->buttons[index] != 0 && field->value == 0) {
    234                         async_exch_t *exch =
    235                             async_exchange_begin(mouse_dev->mouse_sess);
    236                         if (exch != NULL) {
    237                                 async_req_2_0(exch, MOUSEEV_BUTTON_EVENT,
    238                                     field->usage, 0);
     234                                    field->usage, (field->value != 0) ? 1 : 0);
    239235                                async_exchange_end(exch);
    240236                                mouse_dev->buttons[index] = field->value;
     
    252248        return true;
    253249}
    254 /*----------------------------------------------------------------------------*/
     250
    255251#define FUN_UNBIND_DESTROY(fun) \
    256252if (fun) { \
    257253        if (ddf_fun_unbind((fun)) == EOK) { \
    258                 (fun)->driver_data = NULL; \
    259254                ddf_fun_destroy((fun)); \
    260255        } else { \
    261256                usb_log_error("Could not unbind function `%s', it " \
    262                     "will not be destroyed.\n", (fun)->name); \
     257                    "will not be destroyed.\n", ddf_fun_get_name(fun)); \
    263258        } \
    264259} else (void)0
    265 /*----------------------------------------------------------------------------*/
     260
    266261static int usb_mouse_create_function(usb_hid_dev_t *hid_dev, usb_mouse_t *mouse)
    267262{
     
    279274        }
    280275
    281         fun->ops = &mouse->ops;
    282         fun->driver_data = mouse;
     276        ddf_fun_set_ops(fun, &ops);
     277        ddf_fun_data_implant(fun, mouse);
    283278
    284279        int rc = ddf_fun_bind(fun);
    285280        if (rc != EOK) {
    286281                usb_log_error("Could not bind DDF function `%s': %s.\n",
    287                     fun->name, str_error(rc));
    288                 fun->driver_data = NULL;
     282                    ddf_fun_get_name(fun), str_error(rc));
    289283                ddf_fun_destroy(fun);
    290284                return rc;
     
    292286
    293287        usb_log_debug("Adding DDF function `%s' to category %s...\n",
    294             fun->name, HID_MOUSE_CATEGORY);
     288            ddf_fun_get_name(fun), HID_MOUSE_CATEGORY);
    295289        rc = ddf_fun_add_to_category(fun, HID_MOUSE_CATEGORY);
    296290        if (rc != EOK) {
     
    302296        }
    303297        mouse->mouse_fun = fun;
    304 
    305298        return EOK;
    306299}
     
    345338        return highest_button;
    346339}
    347 /*----------------------------------------------------------------------------*/
     340
    348341int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data)
    349342{
     
    379372        }
    380373
    381         // set handler for incoming calls
    382         mouse_dev->ops.default_handler = default_connection_handler;
    383 
    384374        // TODO: how to know if the device supports the request???
    385375        usbhid_req_set_idle(&hid_dev->usb_dev->ctrl_pipe,
     
    398388        return EOK;
    399389}
    400 /*----------------------------------------------------------------------------*/
     390
    401391bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, void *data)
    402392{
     
    411401        return usb_mouse_process_report(hid_dev, mouse_dev);
    412402}
    413 /*----------------------------------------------------------------------------*/
     403
    414404void usb_mouse_deinit(usb_hid_dev_t *hid_dev, void *data)
    415405{
     
    430420
    431421        free(mouse_dev->buttons);
    432         free(mouse_dev);
    433 }
    434 /*----------------------------------------------------------------------------*/
     422}
     423
    435424int usb_mouse_set_boot_protocol(usb_hid_dev_t *hid_dev)
    436425{
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.h

    re0d5bc5 r96e01fbc  
    4242struct usb_hid_dev;
    4343
    44 /*----------------------------------------------------------------------------*/
     44
    4545
    4646/** Container for USB mouse device. */
    4747typedef struct {
    48         /** IPC session to console (consumer). */
     48        /** IPC session to consumer. */
    4949        async_sess_t *mouse_sess;
    5050
     
    5353        size_t buttons_count;
    5454
    55         ddf_dev_ops_t ops;
    5655        /* DDF mouse function */
    5756        ddf_fun_t *mouse_fun;
    5857} usb_mouse_t;
    5958
    60 /*----------------------------------------------------------------------------*/
     59
    6160
    6261extern const usb_endpoint_description_t usb_hid_mouse_poll_endpoint_description;
     
    6564const char *HID_MOUSE_CATEGORY;
    6665
    67 /*----------------------------------------------------------------------------*/
     66
    6867
    6968int usb_mouse_init(struct usb_hid_dev *hid_dev, void **data);
     
    7574int usb_mouse_set_boot_protocol(struct usb_hid_dev *hid_dev);
    7675
    77 /*----------------------------------------------------------------------------*/
     76
    7877
    7978#endif // USB_HID_MOUSEDEV_H_
  • uspace/drv/bus/usb/usbhid/multimedia/multimedia.c

    re0d5bc5 r96e01fbc  
    5454#define NAME  "multimedia-keys"
    5555
    56 /*----------------------------------------------------------------------------*/
     56
    5757/**
    5858 * Logitech UltraX device type.
     
    7070
    7171
    72 /*----------------------------------------------------------------------------*/
     72
    7373/**
    7474 * Default handler for IPC methods not handled by DDF.
     
    8686{
    8787        usb_log_debug(NAME " default_connection_handler()\n");
    88         if (fun == NULL || fun->driver_data == NULL) {
    89                 async_answer_0(icallid, EINVAL);
    90                 return;
    91         }
    92 
    93         usb_multimedia_t *multim_dev = fun->driver_data;
     88
     89        usb_multimedia_t *multim_dev = ddf_fun_data_get(fun);
    9490
    9591        async_sess_t *sess =
     
    106102                async_answer_0(icallid, EINVAL);
    107103}
    108 /*----------------------------------------------------------------------------*/
     104
    109105static ddf_dev_ops_t multimedia_ops = {
    110106        .default_handler = default_connection_handler
    111107};
    112 /*----------------------------------------------------------------------------*/
     108
    113109/**
    114110 * Processes key events.
     
    155151        }
    156152}
    157 /*----------------------------------------------------------------------------*/
     153
    158154int usb_multimedia_init(struct usb_hid_dev *hid_dev, void **data)
    159155{
     
    172168        }
    173169
    174         fun->ops = &multimedia_ops;
     170        ddf_fun_set_ops(fun, &multimedia_ops);
    175171
    176172        usb_multimedia_t *multim_dev =
     
    194190
    195191        usb_log_debug(NAME " function created (handle: %" PRIun ").\n",
    196             fun->handle);
     192            ddf_fun_get_handle(fun));
    197193
    198194        rc = ddf_fun_add_to_category(fun, "keyboard");
     
    203199                if (ddf_fun_unbind(fun) != EOK) {
    204200                        usb_log_error("Failed to unbind %s, won't destroy.\n",
    205                             fun->name);
     201                            ddf_fun_get_name(fun));
    206202                } else {
    207203                        ddf_fun_destroy(fun);
     
    216212        return EOK;
    217213}
    218 /*----------------------------------------------------------------------------*/
     214
    219215void usb_multimedia_deinit(struct usb_hid_dev *hid_dev, void *data)
    220216{
    221217        ddf_fun_t *fun = data;
    222         if (fun != NULL && fun->driver_data != NULL) {
    223                 usb_multimedia_t *multim_dev = fun->driver_data;
    224                 /* Hangup session to the console */
    225                 if (multim_dev->console_sess)
    226                         async_hangup(multim_dev->console_sess);
    227                 if (ddf_fun_unbind(fun) != EOK) {
    228                         usb_log_error("Failed to unbind %s, won't destroy.\n",
    229                             fun->name);
    230                 } else {
    231                         usb_log_debug2("%s unbound.\n", fun->name);
    232                         /* This frees multim_dev too as it was stored in
    233                          * fun->data */
    234                         ddf_fun_destroy(fun);
    235                 }
     218
     219        usb_multimedia_t *multim_dev = ddf_fun_data_get(fun);
     220
     221        /* Hangup session to the console */
     222        if (multim_dev->console_sess)
     223                async_hangup(multim_dev->console_sess);
     224        if (ddf_fun_unbind(fun) != EOK) {
     225                usb_log_error("Failed to unbind %s, won't destroy.\n",
     226                    ddf_fun_get_name(fun));
    236227        } else {
    237                 usb_log_error(
    238                     "Failed to deinit multimedia subdriver, data missing.\n");
    239         }
    240 }
    241 /*----------------------------------------------------------------------------*/
     228                usb_log_debug2("%s unbound.\n", ddf_fun_get_name(fun));
     229                /* This frees multim_dev too as it was stored in
     230                 * fun->data */
     231                ddf_fun_destroy(fun);
     232        }
     233}
     234
    242235bool usb_multimedia_polling_callback(struct usb_hid_dev *hid_dev, void *data)
    243236{
    244237        // TODO: checks
    245238        ddf_fun_t *fun = data;
    246         if (hid_dev == NULL || fun == NULL || fun->driver_data == NULL) {
     239        if (hid_dev == NULL) {
    247240                return false;
    248241        }
    249242
    250         usb_multimedia_t *multim_dev = fun->driver_data;
     243        usb_multimedia_t *multim_dev = ddf_fun_data_get(fun);
    251244
    252245        usb_hid_report_path_t *path = usb_hid_report_path();
  • uspace/drv/bus/usb/usbhid/multimedia/multimedia.h

    re0d5bc5 r96e01fbc  
    4141struct usb_hid_dev;
    4242
    43 /*----------------------------------------------------------------------------*/
     43
    4444
    4545int usb_multimedia_init(struct usb_hid_dev *hid_dev, void **data);
     
    4949bool usb_multimedia_polling_callback(struct usb_hid_dev *hid_dev, void *data);
    5050
    51 /*----------------------------------------------------------------------------*/
     51
    5252
    5353#endif // USB_HID_MULTIMEDIA_H_
  • uspace/drv/bus/usb/usbhid/subdrivers.h

    re0d5bc5 r96e01fbc  
    4040#include "kbd/kbddev.h"
    4141
    42 /*----------------------------------------------------------------------------*/
     42
    4343
    4444typedef struct usb_hid_subdriver_usage {
     
    4747} usb_hid_subdriver_usage_t;
    4848
    49 /*----------------------------------------------------------------------------*/
     49
    5050
    5151/** Structure representing the mapping between device requirements and the
     
    8181} usb_hid_subdriver_mapping_t;
    8282
    83 /*----------------------------------------------------------------------------*/
     83
    8484
    8585extern const usb_hid_subdriver_mapping_t usb_hid_subdrivers[];
    8686extern const size_t USB_HID_MAX_SUBDRIVERS;
    8787
    88 /*----------------------------------------------------------------------------*/
     88
    8989
    9090#endif /* USB_HID_SUBDRIVERS_H_ */
  • uspace/drv/bus/usb/usbhid/usbhid.c

    re0d5bc5 r96e01fbc  
    5858        NULL
    5959};
    60 /*----------------------------------------------------------------------------*/
     60
    6161static int usb_hid_set_boot_kbd_subdriver(usb_hid_dev_t *hid_dev)
    6262{
     
    7474        return EOK;
    7575}
    76 /*----------------------------------------------------------------------------*/
     76
    7777static int usb_hid_set_boot_mouse_subdriver(usb_hid_dev_t *hid_dev)
    7878{
     
    9090        return EOK;
    9191}
    92 /*----------------------------------------------------------------------------*/
     92
    9393static int usb_hid_set_generic_hid_subdriver(usb_hid_dev_t *hid_dev)
    9494{
     
    110110        return EOK;
    111111}
    112 /*----------------------------------------------------------------------------*/
     112
    113113static bool usb_hid_ids_match(const usb_hid_dev_t *hid_dev,
    114114    const usb_hid_subdriver_mapping_t *mapping)
     
    122122            == mapping->product_id);
    123123}
    124 /*----------------------------------------------------------------------------*/
     124
    125125static bool usb_hid_path_matches(usb_hid_dev_t *hid_dev,
    126126    const usb_hid_subdriver_mapping_t *mapping)
     
    178178        return matches;
    179179}
    180 /*----------------------------------------------------------------------------*/
     180
    181181static int usb_hid_save_subdrivers(usb_hid_dev_t *hid_dev,
    182182    const usb_hid_subdriver_t **subdrivers, unsigned count)
     
    211211        return EOK;
    212212}
    213 /*----------------------------------------------------------------------------*/
     213
    214214static int usb_hid_find_subdrivers(usb_hid_dev_t *hid_dev)
    215215{
     
    263263        return usb_hid_save_subdrivers(hid_dev, subdrivers, count);
    264264}
    265 /*----------------------------------------------------------------------------*/
     265
    266266static int usb_hid_check_pipes(usb_hid_dev_t *hid_dev, const usb_device_t *dev)
    267267{
     
    290290        return ENOTSUP;
    291291}
    292 /*----------------------------------------------------------------------------*/
     292
    293293static int usb_hid_init_report(usb_hid_dev_t *hid_dev)
    294294{
     
    322322        return EOK;
    323323}
    324 /*----------------------------------------------------------------------------*/
     324
    325325/*
    326326 * This functions initializes required structures from the device's descriptors
     
    458458        return rc;
    459459}
    460 /*----------------------------------------------------------------------------*/
     460
    461461bool usb_hid_polling_callback(usb_device_t *dev, uint8_t *buffer,
    462462    size_t buffer_size, void *arg)
     
    500500        return cont;
    501501}
    502 /*----------------------------------------------------------------------------*/
     502
    503503void usb_hid_polling_ended_callback(usb_device_t *dev, bool reason, void *arg)
    504504{
     
    517517        hid_dev->running = false;
    518518}
    519 /*----------------------------------------------------------------------------*/
     519
    520520void usb_hid_new_report(usb_hid_dev_t *hid_dev)
    521521{
    522522        ++hid_dev->report_nr;
    523523}
    524 /*----------------------------------------------------------------------------*/
     524
    525525int usb_hid_report_number(const usb_hid_dev_t *hid_dev)
    526526{
    527527        return hid_dev->report_nr;
    528528}
    529 /*----------------------------------------------------------------------------*/
     529
    530530void usb_hid_deinit(usb_hid_dev_t *hid_dev)
    531531{
  • uspace/drv/bus/usb/usbhid/usbhid.h

    re0d5bc5 r96e01fbc  
    9595};
    9696
    97 /*----------------------------------------------------------------------------*/
     97
    9898/**
    9999 * Structure for holding general HID device data.
     
    132132};
    133133
    134 /*----------------------------------------------------------------------------*/
     134
    135135
    136136enum {
     
    143143extern const usb_endpoint_description_t *usb_hid_endpoints[];
    144144
    145 /*----------------------------------------------------------------------------*/
     145
    146146
    147147int usb_hid_init(usb_hid_dev_t *hid_dev, usb_device_t *dev);
  • uspace/drv/bus/usb/usbhub/port.c

    re0d5bc5 r96e01fbc  
    7070        return EOK;
    7171}
    72 /*----------------------------------------------------------------------------*/
     72
    7373/**
    7474 * Clear feature on hub port.
     
    9292            sizeof(clear_request), NULL, 0);
    9393}
    94 /*----------------------------------------------------------------------------*/
     94
    9595/**
    9696 * Set feature on hub port.
     
    114114            sizeof(clear_request), NULL, 0);
    115115}
    116 /*----------------------------------------------------------------------------*/
     116
    117117/**
    118118 * Mark reset process as failed due to external reasons
     
    129129        fibril_mutex_unlock(&port->mutex);
    130130}
    131 /*----------------------------------------------------------------------------*/
     131
    132132/**
    133133 * Process interrupts on given port
     
    245245            port->port_number, status);
    246246}
    247 /*----------------------------------------------------------------------------*/
     247
    248248/**
    249249 * routine called when a device on port has been removed
     
    299299        return EOK;
    300300}
    301 /*----------------------------------------------------------------------------*/
     301
    302302/**
    303303 * Process port reset change
     
    335335        }
    336336}
    337 /*----------------------------------------------------------------------------*/
     337
    338338/** Retrieve port status.
    339339 *
     
    352352                .request = USB_HUB_REQUEST_GET_STATUS,
    353353                .value = 0,
    354                 .index = port->port_number,
     354                .index = uint16_host2usb(port->port_number),
    355355                .length = sizeof(usb_port_status_t),
    356356        };
     
    375375        return EOK;
    376376}
    377 /*----------------------------------------------------------------------------*/
     377
    378378/** Callback for enabling a specific port.
    379379 *
     
    407407        return port->reset_okay ? EOK : ESTALL;
    408408}
    409 /*----------------------------------------------------------------------------*/
     409
    410410/** Fibril for adding a new device.
    411411 *
     
    436436                usb_log_info("Detected new device on `%s' (port %zu), "
    437437                    "address %d (handle %" PRIun ").\n",
    438                     data->hub->usb_device->ddf_dev->name,
    439                     data->port->port_number, new_address, child_fun->handle);
     438                    ddf_dev_get_name(data->hub->usb_device->ddf_dev),
     439                    data->port->port_number, new_address,
     440                    ddf_fun_get_handle(child_fun));
    440441        } else {
    441442                usb_log_error("Failed registering device on port %zu: %s.\n",
     
    454455        return rc;
    455456}
    456 /*----------------------------------------------------------------------------*/
     457
    457458/** Start device adding when connection change is detected.
    458459 *
  • uspace/drv/bus/usb/usbhub/status.h

    re0d5bc5 r96e01fbc  
    4242 * should not be accessed directly, use supplied getter/setter methods.
    4343 *
    44  * For more information refer to table 11-15 in
    45  * "Universal Serial Bus Specification Revision 1.1"
     44 * For more information refer to tables 11-15 and 11-16 in
     45 * "Universal Serial Bus Specification Revision 1.1" pages 274 and 277
     46 * (290 and 293 in pdf)
    4647 *
    4748 */
  • uspace/drv/bus/usb/usbhub/usbhub.c

    re0d5bc5 r96e01fbc  
    160160        hub_dev->running = true;
    161161        usb_log_info("Controlling hub '%s' (%zu ports).\n",
    162             hub_dev->usb_device->ddf_dev->name, hub_dev->port_count);
     162            ddf_dev_get_name(hub_dev->usb_device->ddf_dev), hub_dev->port_count);
    163163
    164164        usb_pipe_end_long_transfer(&usb_dev->ctrl_pipe);
    165165        return EOK;
    166166}
    167 /*----------------------------------------------------------------------------*/
     167
    168168/**
    169169 * Turn off power to all ports.
     
    176176        return ENOTSUP;
    177177}
    178 /*----------------------------------------------------------------------------*/
     178
    179179/**
    180180 * Remove all attached devices
     
    219219        return EOK;
    220220}
    221 /*----------------------------------------------------------------------------*/
     221
    222222/** Callback for polling hub for changes.
    223223 *
     
    256256        return true;
    257257}
    258 /*----------------------------------------------------------------------------*/
     258
    259259/**
    260260 * Load hub-specific information into hub_dev structure and process if needed
     
    331331        return EOK;
    332332}
    333 /*----------------------------------------------------------------------------*/
     333
    334334/**
    335335 * Set configuration of and USB device
     
    378378        return opResult;
    379379}
    380 /*----------------------------------------------------------------------------*/
     380
    381381/**
    382382 * Process hub over current change
     
    416416
    417417}
    418 /*----------------------------------------------------------------------------*/
     418
    419419/**
    420420 * Process hub interrupts.
     
    485485        }
    486486}
    487 /*----------------------------------------------------------------------------*/
     487
    488488/**
    489489 * callback called from hub polling fibril when the fibril terminates
  • uspace/drv/bus/usb/usbmast/main.c

    re0d5bc5 r96e01fbc  
    3737#include <as.h>
    3838#include <async.h>
    39 #include <ipc/bd.h>
     39#include <bd_srv.h>
    4040#include <macros.h>
    4141#include <usb/dev/driver.h>
     
    8282    void *arg);
    8383
     84static int usbmast_bd_open(bd_srvs_t *, bd_srv_t *);
     85static int usbmast_bd_close(bd_srv_t *);
     86static int usbmast_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
     87static int usbmast_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t);
     88static int usbmast_bd_get_block_size(bd_srv_t *, size_t *);
     89static int usbmast_bd_get_num_blocks(bd_srv_t *, aoff64_t *);
     90
     91static bd_ops_t usbmast_bd_ops = {
     92        .open = usbmast_bd_open,
     93        .close = usbmast_bd_close,
     94        .read_blocks = usbmast_bd_read_blocks,
     95        .write_blocks = usbmast_bd_write_blocks,
     96        .get_block_size = usbmast_bd_get_block_size,
     97        .get_num_blocks = usbmast_bd_get_num_blocks
     98};
     99
     100static usbmast_fun_t *bd_srv_usbmast(bd_srv_t *bd)
     101{
     102        return (usbmast_fun_t *) bd->srvs->sarg;
     103}
     104
    84105/** Callback when a device is removed from the system.
    85106 *
     
    139160        mdev->usb_dev = dev;
    140161
    141         usb_log_info("Initializing mass storage `%s'.\n", dev->ddf_dev->name);
     162        usb_log_info("Initializing mass storage `%s'.\n", ddf_dev_get_name(dev->ddf_dev));
    142163        usb_log_debug("Bulk in endpoint: %d [%zuB].\n",
    143164            dev->pipes[BULK_IN_EP].pipe.endpoint_no,
     
    219240        mfun->lun = lun;
    220241
     242        bd_srvs_init(&mfun->bds);
     243        mfun->bds.ops = &usbmast_bd_ops;
     244        mfun->bds.sarg = mfun;
     245
    221246        /* Set up a connection handler. */
    222         fun->conn_handler = usbmast_bd_connection;
     247        ddf_fun_set_conn_handler(fun, usbmast_bd_connection);
    223248
    224249        usb_log_debug("Inquire...\n");
     
    227252        if (rc != EOK) {
    228253                usb_log_warning("Failed to inquire device `%s': %s.\n",
    229                     mdev->ddf_dev->name, str_error(rc));
     254                    ddf_dev_get_name(mdev->ddf_dev), str_error(rc));
    230255                rc = EIO;
    231256                goto error;
     
    234259        usb_log_info("Mass storage `%s' LUN %u: " \
    235260            "%s by %s rev. %s is %s (%s).\n",
    236             mdev->ddf_dev->name,
     261            ddf_dev_get_name(mdev->ddf_dev),
    237262            lun,
    238263            inquiry.product,
     
    247272        if (rc != EOK) {
    248273                usb_log_warning("Failed to read capacity, device `%s': %s.\n",
    249                     mdev->ddf_dev->name, str_error(rc));
     274                    ddf_dev_get_name(mdev->ddf_dev), str_error(rc));
    250275                rc = EIO;
    251276                goto error;
     
    284309{
    285310        usbmast_fun_t *mfun;
    286         void *comm_buf = NULL;
    287         size_t comm_size;
    288         ipc_callid_t callid;
    289         ipc_call_t call;
    290         unsigned int flags;
    291         sysarg_t method;
    292         uint64_t ba;
    293         size_t cnt;
    294         int retval;
    295 
    296         async_answer_0(iid, EOK);
    297 
    298         if (!async_share_out_receive(&callid, &comm_size, &flags)) {
    299                 async_answer_0(callid, EHANGUP);
    300                 return;
    301         }
    302        
    303         (void) async_share_out_finalize(callid, &comm_buf);
    304         if (comm_buf == AS_MAP_FAILED) {
    305                 async_answer_0(callid, EHANGUP);
    306                 return;
    307         }
    308        
    309         mfun = (usbmast_fun_t *) ((ddf_fun_t *)arg)->driver_data;
    310 
    311         while (true) {
    312                 callid = async_get_call(&call);
    313                 method = IPC_GET_IMETHOD(call);
    314 
    315                 if (!method) {
    316                         /* The other side hung up. */
    317                         async_answer_0(callid, EOK);
    318                         return;
    319                 }
    320 
    321                 switch (method) {
    322                 case BD_GET_BLOCK_SIZE:
    323                         async_answer_1(callid, EOK, mfun->block_size);
    324                         break;
    325                 case BD_GET_NUM_BLOCKS:
    326                         async_answer_2(callid, EOK, LOWER32(mfun->nblocks),
    327                             UPPER32(mfun->nblocks));
    328                         break;
    329                 case BD_READ_BLOCKS:
    330                         ba = MERGE_LOUP32(IPC_GET_ARG1(call), IPC_GET_ARG2(call));
    331                         cnt = IPC_GET_ARG3(call);
    332                         retval = usbmast_read(mfun, ba, cnt, comm_buf);
    333                         async_answer_0(callid, retval);
    334                         break;
    335                 case BD_WRITE_BLOCKS:
    336                         ba = MERGE_LOUP32(IPC_GET_ARG1(call), IPC_GET_ARG2(call));
    337                         cnt = IPC_GET_ARG3(call);
    338                         retval = usbmast_write(mfun, ba, cnt, comm_buf);
    339                         async_answer_0(callid, retval);
    340                         break;
    341                 default:
    342                         async_answer_0(callid, EINVAL);
    343                 }
    344         }
    345 }
     311
     312        mfun = (usbmast_fun_t *) ddf_fun_data_get((ddf_fun_t *)arg);
     313        bd_conn(iid, icall, &mfun->bds);
     314}
     315
     316/** Open device. */
     317static int usbmast_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
     318{
     319        return EOK;
     320}
     321
     322/** Close device. */
     323static int usbmast_bd_close(bd_srv_t *bd)
     324{
     325        return EOK;
     326}
     327
     328/** Read blocks from the device. */
     329static int usbmast_bd_read_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt, void *buf,
     330    size_t size)
     331{
     332        usbmast_fun_t *mfun = bd_srv_usbmast(bd);
     333
     334        if (size < cnt * mfun->block_size)
     335                return EINVAL;
     336
     337        return usbmast_read(mfun, ba, cnt, buf);
     338}
     339
     340/** Write blocks to the device. */
     341static int usbmast_bd_write_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt,
     342    const void *buf, size_t size)
     343{
     344        usbmast_fun_t *mfun = bd_srv_usbmast(bd);
     345
     346        if (size < cnt * mfun->block_size)
     347                return EINVAL;
     348
     349        return usbmast_write(mfun, ba, cnt, buf);
     350}
     351
     352/** Get device block size. */
     353static int usbmast_bd_get_block_size(bd_srv_t *bd, size_t *rsize)
     354{
     355        usbmast_fun_t *mfun = bd_srv_usbmast(bd);
     356        *rsize = mfun->block_size;
     357        return EOK;
     358}
     359
     360/** Get number of blocks on device. */
     361static int usbmast_bd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb)
     362{
     363        usbmast_fun_t *mfun = bd_srv_usbmast(bd);
     364        *rnb = mfun->nblocks;
     365        return EOK;
     366}
     367
    346368
    347369/** USB mass storage driver ops. */
  • uspace/drv/bus/usb/usbmast/scsi_ms.c

    re0d5bc5 r96e01fbc  
    8888                if (rc != EOK) {
    8989                        usb_log_error("Inquiry transport failed, device %s: %s.\n",
    90                            mfun->mdev->ddf_dev->name, str_error(rc));
     90                           ddf_dev_get_name(mfun->mdev->ddf_dev), str_error(rc));
    9191                        return rc;
    9292                }
     
    9696
    9797                usb_log_error("SCSI command failed, device %s.\n",
    98                     mfun->mdev->ddf_dev->name);
     98                    ddf_dev_get_name(mfun->mdev->ddf_dev));
    9999
    100100                rc = usbmast_request_sense(mfun, &sense_buf, sizeof(sense_buf));
     
    147147        if (rc != EOK) {
    148148                usb_log_error("Inquiry transport failed, device %s: %s.\n",
    149                    mfun->mdev->ddf_dev->name, str_error(rc));
     149                   ddf_dev_get_name(mfun->mdev->ddf_dev), str_error(rc));
    150150                return rc;
    151151        }
     
    153153        if (cmd.status != CMDS_GOOD) {
    154154                usb_log_error("Inquiry command failed, device %s.\n",
    155                    mfun->mdev->ddf_dev->name);
     155                   ddf_dev_get_name(mfun->mdev->ddf_dev));
    156156                return EIO;
    157157        }
     
    215215        if (rc != EOK || cmd.status != CMDS_GOOD) {
    216216                usb_log_error("Request Sense failed, device %s: %s.\n",
    217                    mfun->mdev->ddf_dev->name, str_error(rc));
     217                   ddf_dev_get_name(mfun->mdev->ddf_dev), str_error(rc));
    218218                return rc;
    219219        }
     
    257257        if (rc != EOK) {
    258258                usb_log_error("Read Capacity (10) transport failed, device %s: %s.\n",
    259                    mfun->mdev->ddf_dev->name, str_error(rc));
     259                   ddf_dev_get_name(mfun->mdev->ddf_dev), str_error(rc));
    260260                return rc;
    261261        }
     
    263263        if (cmd.status != CMDS_GOOD) {
    264264                usb_log_error("Read Capacity (10) command failed, device %s.\n",
    265                    mfun->mdev->ddf_dev->name);
     265                   ddf_dev_get_name(mfun->mdev->ddf_dev));
    266266                return EIO;
    267267        }
     
    314314        if (rc != EOK) {
    315315                usb_log_error("Read (10) transport failed, device %s: %s.\n",
    316                    mfun->mdev->ddf_dev->name, str_error(rc));
     316                   ddf_dev_get_name(mfun->mdev->ddf_dev), str_error(rc));
    317317                return rc;
    318318        }
     
    320320        if (cmd.status != CMDS_GOOD) {
    321321                usb_log_error("Read (10) command failed, device %s.\n",
    322                    mfun->mdev->ddf_dev->name);
     322                   ddf_dev_get_name(mfun->mdev->ddf_dev));
    323323                return EIO;
    324324        }
     
    370370        if (rc != EOK) {
    371371                usb_log_error("Write (10) transport failed, device %s: %s.\n",
    372                    mfun->mdev->ddf_dev->name, str_error(rc));
     372                   ddf_dev_get_name(mfun->mdev->ddf_dev), str_error(rc));
    373373                return rc;
    374374        }
     
    376376        if (cmd.status != CMDS_GOOD) {
    377377                usb_log_error("Write (10) command failed, device %s.\n",
    378                    mfun->mdev->ddf_dev->name);
     378                   ddf_dev_get_name(mfun->mdev->ddf_dev));
    379379                return EIO;
    380380        }
  • uspace/drv/bus/usb/usbmast/usbmast.h

    re0d5bc5 r96e01fbc  
    3737#define USBMAST_H_
    3838
     39#include <bd_srv.h>
    3940#include <sys/types.h>
    4041#include <usb/usb.h>
     
    6869        /** Block size in bytes */
    6970        size_t block_size;
     71        /** Block device service structure */
     72        bd_srvs_t bds;
    7073} usbmast_fun_t;
    7174
  • uspace/drv/bus/usb/usbmid/explore.c

    re0d5bc5 r96e01fbc  
    172172                return false;
    173173        }
    174         usb_mid->ctl_fun->ops = &mid_device_ops;
     174        ddf_fun_set_ops(usb_mid->ctl_fun, &mid_device_ops);
    175175
    176176        /* Bind control function. */
  • uspace/drv/bus/usb/usbmid/main.c

    re0d5bc5 r96e01fbc  
    5151static int usbmid_device_add(usb_device_t *dev)
    5252{
    53         usb_log_info("Taking care of new MID `%s'.\n", dev->ddf_dev->name);
     53        usb_log_info("Taking care of new MID `%s'.\n", ddf_dev_get_name(dev->ddf_dev));
    5454
    5555        const bool accept = usbmid_explore_device(dev);
     
    6161        return EOK;
    6262}
    63 /*----------------------------------------------------------------------------*/
     63
    6464/** Callback when a MID device is about to be removed from the host.
    6565 *
     
    115115        return ret;
    116116}
    117 /*----------------------------------------------------------------------------*/
     117
    118118/** Callback when a MID device was removed from the host.
    119119 *
     
    127127        assert(usb_mid);
    128128
    129         usb_log_info("USB MID gone: `%s'.\n", dev->ddf_dev->name);
     129        usb_log_info("USB MID gone: `%s'.\n", ddf_dev_get_name(dev->ddf_dev));
    130130
    131131        /* Remove ctl function */
  • uspace/drv/bus/usb/usbmid/usbmid.c

    re0d5bc5 r96e01fbc  
    3030 * @{
    3131 */
     32
     33/* XXX Fix this */
     34#define _DDF_DATA_IMPLANT
     35
    3236/**
    3337 * @file
     
    4751static int usb_iface_get_interface_impl(ddf_fun_t *fun, int *iface_no)
    4852{
    49         assert(fun);
    50 
    51         usbmid_interface_t *iface = fun->driver_data;
     53        usbmid_interface_t *iface = ddf_fun_data_get(fun);
    5254        assert(iface);
    5355
     
    123125        }
    124126
     127        match_id_list_t match_ids;
     128        init_match_ids(&match_ids);
     129
    125130        rc = usb_device_create_match_ids_from_interface(device_descriptor,
    126             interface_descriptor, &child->match_ids);
     131            interface_descriptor, &match_ids);
    127132        if (rc != EOK) {
    128133                ddf_fun_destroy(child);
    129134                return rc;
    130135        }
     136
     137        list_foreach(match_ids.ids, link) {
     138                match_id_t *match_id = list_get_instance(link, match_id_t, link);
     139                rc = ddf_fun_add_match_id(child, match_id->id, match_id->score);
     140                if (rc != EOK) {
     141                        clean_match_ids(&match_ids);
     142                        ddf_fun_destroy(child);
     143                        return rc;
     144                }
     145        }
     146        clean_match_ids(&match_ids);
    131147
    132148        rc = ddf_fun_bind(child);
     
    138154
    139155        iface->fun = child;
    140         child->driver_data = iface;
    141         child->ops = &child_device_ops;
     156        ddf_fun_data_implant(child, iface);
     157        ddf_fun_set_ops(child, &child_device_ops);
    142158
    143159        return EOK;
  • uspace/drv/bus/usb/vhc/conndev.c

    re0d5bc5 r96e01fbc  
    9494    ipc_call_t *icall)
    9595{
    96         vhc_data_t *vhc = fun->dev->driver_data;
     96        vhc_data_t *vhc = ddf_dev_data_get(ddf_fun_get_dev(fun));
    9797       
    9898        async_sess_t *callback =
     
    125125void on_client_close(ddf_fun_t *fun)
    126126{
    127         vhc_data_t *vhc = fun->dev->driver_data;
     127        vhc_data_t *vhc = ddf_dev_data_get(ddf_fun_get_dev(fun));
    128128
    129129        if (plugged_device_handle != 0) {
  • uspace/drv/bus/usb/vhc/connhost.c

    re0d5bc5 r96e01fbc  
    4242
    4343#define GET_VHC_DATA(fun) \
    44         ((vhc_data_t *)fun->dev->driver_data)
     44        ((vhc_data_t *)ddf_dev_data_get(ddf_fun_get_dev(fun)))
    4545#define VHC_DATA(vhc, fun) \
    4646        vhc_data_t *vhc = GET_VHC_DATA(fun); assert(vhc->magic == 0xdeadbeef)
     
    483483        VHC_DATA(vhc, root_hub_fun);
    484484
    485         *handle = vhc->hc_fun->handle;
     485        *handle = ddf_fun_get_handle(vhc->hc_fun);
    486486
    487487        return EOK;
     
    492492        VHC_DATA(vhc, root_hub_fun);
    493493
    494         devman_handle_t handle = root_hub_fun->handle;
     494        devman_handle_t handle = ddf_fun_get_handle(root_hub_fun);
    495495
    496496        usb_log_debug("tell_address_rh(handle=%" PRIun ")\n", handle);
  • uspace/drv/bus/usb/vhc/hub.c

    re0d5bc5 r96e01fbc  
    100100        async_sess_t *sess;
    101101        do {
    102                 sess = devman_device_connect(EXCHANGE_SERIALIZE, hc_dev->handle, 0);
     102                sess = devman_device_connect(EXCHANGE_SERIALIZE,
     103                    ddf_fun_get_handle(hc_dev), 0);
    103104        } while (!sess);
    104105        async_hangup(sess);
     
    107108
    108109        usb_hc_connection_t hc_conn;
    109         usb_hc_connection_initialize(&hc_conn, hc_dev->handle);
     110        usb_hc_connection_initialize(&hc_conn, ddf_fun_get_handle(hc_dev));
    110111
    111112        rc = usb_hc_connection_open(&hc_conn);
     
    113114
    114115        ddf_fun_t *hub_dev;
    115         rc = usb_hc_new_device_wrapper(hc_dev->dev, &hc_conn, USB_SPEED_FULL,
     116        rc = usb_hc_new_device_wrapper(ddf_fun_get_dev(hc_dev), &hc_conn, USB_SPEED_FULL,
    116117            pretend_port_rest, NULL, NULL, &rh_ops, hc_dev, &hub_dev);
    117118        if (rc != EOK) {
     
    123124
    124125        usb_log_info("Created root hub function (handle %zu).\n",
    125             (size_t) hub_dev->handle);
     126            (size_t) ddf_fun_get_handle(hub_dev));
    126127
    127128        return 0;
  • uspace/drv/bus/usb/vhc/main.c

    re0d5bc5 r96e01fbc  
    6767        }
    6868
    69         vhc_data_t *data = malloc(sizeof(vhc_data_t));
     69        vhc_data_t *data = ddf_dev_data_alloc(dev, sizeof(vhc_data_t));
    7070        if (data == NULL) {
    7171                usb_log_fatal("Failed to allocate memory.\n");
     
    8989        }
    9090
    91         hc->ops = &vhc_ops;
     91        ddf_fun_set_ops(hc, &vhc_ops);
    9292        list_initialize(&data->devices);
    9393        fibril_mutex_initialize(&data->guard);
    9494        data->hub = &virtual_hub_device;
    9595        data->hc_fun = hc;
    96 
    97         dev->driver_data = data;
    9896
    9997        rc = ddf_fun_bind(hc);
     
    116114
    117115        usb_log_info("Virtual USB host controller ready (dev %zu, hc %zu).\n",
    118             (size_t) dev->handle, (size_t) hc->handle);
    119 
    120 
     116            (size_t) ddf_dev_get_handle(dev), (size_t) ddf_fun_get_handle(hc));
    121117
    122118        rc = vhc_virtdev_plug_hub(data, data->hub, NULL);
Note: See TracChangeset for help on using the changeset viewer.