Changes in / [361e61b:55e388a1] in mainline


Ignore:
Files:
8 added
8 deleted
68 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    r361e61b r55e388a1  
    99_link.ld
    1010./*.iso
     11
     12./tools/__pycache__/
    1113
    1214./Makefile.common
     
    139141.cproject
    140142.project
     143.settings
     144.pydevproject
     145
  • HelenOS.config

    r361e61b r55e388a1  
    552552! CONFIG_RUN_VIRTUAL_USB_HC (n/y)
    553553
     554% Polling UHCI & OHCI (no interrupts)
     555! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_USBHC_NO_INTERRUPTS (y/n)
  • kernel/tools/genmap.py

    r361e61b r55e388a1  
    100100                        for addr, symbol in symbols:
    101101                                value = fname + ':' + symbol
    102                                 data = struct.pack(symtabfmt, addr + offset, value[:MAXSTRING])
     102                                value_bytes = value.encode('ascii')
     103                                data = struct.pack(symtabfmt, addr + offset, value_bytes[:MAXSTRING])
    103104                                out.write(data)
    104105                       
    105         out.write(struct.pack(symtabfmt, 0, ''))
     106        out.write(struct.pack(symtabfmt, 0, b''))
    106107
    107108def main():
  • tools/mkfat.py

    r361e61b r55e388a1  
    211211        dir_entry = xstruct.create(DIR_ENTRY)
    212212       
    213         dir_entry.name = mangle_fname(name)
    214         dir_entry.ext = mangle_ext(name)
     213        dir_entry.name = mangle_fname(name).encode('ascii')
     214        dir_entry.ext = mangle_ext(name).encode('ascii')
    215215       
    216216        if (directory):
     
    239239       
    240240        dir_entry.signature = 0x2e
    241         dir_entry.name = '       '
    242         dir_entry.ext = '   '
     241        dir_entry.name = b'       '
     242        dir_entry.ext = b'   '
    243243        dir_entry.attr = 0x10
    244244       
     
    258258       
    259259        dir_entry.signature = [0x2e, 0x2e]
    260         dir_entry.name = '      '
    261         dir_entry.ext = '   '
     260        dir_entry.name = b'      '
     261        dir_entry.ext = b'   '
    262262        dir_entry.attr = 0x10
    263263       
  • tools/mkhord.py

    r361e61b r55e388a1  
    8484        payload_size_aligned = align_up(payload_size, align)
    8585       
    86         header.tag = "HORD"
     86        header.tag = b"HORD"
    8787        header.version = 1
    8888        header.encoding = HORD_LSB
  • tools/mktmpfs.py

    r361e61b r55e388a1  
    8080                        dentry.kind = TMPFS_FILE
    8181                        dentry.fname_len = len(name)
    82                         dentry.fname = name
     82                        dentry.fname = name.encode('ascii')
    8383                        dentry.flen = size
    8484                       
     
    9797                        dentry.kind = TMPFS_DIRECTORY
    9898                        dentry.fname_len = len(name)
    99                         dentry.fname = name
     99                        dentry.fname = name.encode('ascii')
    100100                       
    101101                        outf.write(dentry.pack())
     
    122122       
    123123        header = xstruct.create(HEADER)
    124         header.tag = "TMPFS"
     124        header.tag = b"TMPFS"
    125125       
    126126        outf.write(header.pack())
  • uspace/app/bdsh/cmds/modules/bdd/bdd.c

    r361e61b r55e388a1  
    7070        unsigned int i, j;
    7171        devmap_handle_t handle;
     72        aoff64_t offset;
    7273        uint8_t *blk;
    7374        size_t size, bytes, rows;
     
    120121        }
    121122
     123        offset = ba * block_size;
     124
    122125        while (size > 0) {
    123126                rc = block_read_direct(handle, ba, 1, blk);
     
    133136
    134137                for (j = 0; j < rows; j++) {
     138                        printf("[%06" PRIxOFF64 "] ", offset);
    135139                        for (i = 0; i < BPR; i++) {
    136140                                if (j * BPR + i < bytes)
     
    152156                                }
    153157                        }
     158                        offset += BPR;
    154159                        putchar('\n');
    155160                }
  • uspace/app/usbinfo/dev.c

    r361e61b r55e388a1  
    5959        }
    6060
    61         rc = usb_endpoint_pipe_initialize_default_control(&dev->ctrl_pipe,
     61        rc = usb_pipe_initialize_default_control(&dev->ctrl_pipe,
    6262            &dev->wire);
    6363        if (rc != EOK) {
     
    6868        }
    6969
    70         rc = usb_endpoint_pipe_probe_default_control(&dev->ctrl_pipe);
     70        rc = usb_pipe_probe_default_control(&dev->ctrl_pipe);
    7171        if (rc != EOK) {
    7272                fprintf(stderr,
     
    7676        }
    7777
    78         rc = usb_endpoint_pipe_start_session(&dev->ctrl_pipe);
     78        rc = usb_pipe_start_session(&dev->ctrl_pipe);
    7979        if (rc != EOK) {
    8080                fprintf(stderr,
     
    107107
    108108leave:
    109         if (usb_endpoint_pipe_is_session_started(&dev->ctrl_pipe)) {
    110                 usb_endpoint_pipe_end_session(&dev->ctrl_pipe);
     109        if (usb_pipe_is_session_started(&dev->ctrl_pipe)) {
     110                usb_pipe_end_session(&dev->ctrl_pipe);
    111111        }
    112112
     
    118118void destroy_device(usbinfo_device_t *dev)
    119119{
    120         usb_endpoint_pipe_end_session(&dev->ctrl_pipe);
     120        usb_pipe_end_session(&dev->ctrl_pipe);
    121121        free(dev);
    122122}
  • uspace/app/usbinfo/usbinfo.h

    r361e61b r55e388a1  
    4444
    4545typedef struct {
    46         usb_endpoint_pipe_t ctrl_pipe;
     46        usb_pipe_t ctrl_pipe;
    4747        usb_device_connection_t wire;
    4848        usb_standard_device_descriptor_t device_descriptor;
  • uspace/drv/ehci-hcd/main.c

    r361e61b r55e388a1  
    119119int main(int argc, char *argv[])
    120120{
    121         usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     121        usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
    122122        return ddf_driver_main(&ehci_driver);
    123123}
  • uspace/drv/ohci/batch.c

    r361e61b r55e388a1  
    4141#include "utils/malloc32.h"
    4242
    43 static void batch_call_in_and_dispose(batch_t *instance);
    44 static void batch_call_out_and_dispose(batch_t *instance);
     43static void batch_call_in_and_dispose(usb_transfer_batch_t *instance);
     44static void batch_call_out_and_dispose(usb_transfer_batch_t *instance);
    4545
    4646#define DEFAULT_ERROR_COUNT 3
    47 batch_t * batch_get(
     47usb_transfer_batch_t * batch_get(
    4848    ddf_fun_t *fun,
    4949                usb_target_t target,
     
    5858    usbhc_iface_transfer_out_callback_t func_out,
    5959                void *arg,
    60                 device_keeper_t *manager
     60                usb_device_keeper_t *manager
    6161                )
    6262{
     
    7070        } else (void)0
    7171
    72         batch_t *instance = malloc(sizeof(batch_t));
     72        usb_transfer_batch_t *instance = malloc(sizeof(usb_transfer_batch_t));
    7373        CHECK_NULL_DISPOSE_RETURN(instance,
    7474            "Failed to allocate batch instance.\n");
    75         batch_init(instance, target, transfer_type, speed, max_packet_size,
     75        usb_transfer_batch_init(instance, target, transfer_type, speed, max_packet_size,
    7676            buffer, NULL, buffer_size, NULL, setup_size, func_in,
    7777            func_out, arg, fun, NULL);
     
    9494}
    9595/*----------------------------------------------------------------------------*/
    96 void batch_dispose(batch_t *instance)
     96void batch_dispose(usb_transfer_batch_t *instance)
    9797{
    9898        assert(instance);
     
    102102}
    103103/*----------------------------------------------------------------------------*/
    104 void batch_control_write(batch_t *instance)
     104void batch_control_write(usb_transfer_batch_t *instance)
    105105{
    106106        assert(instance);
     
    113113}
    114114/*----------------------------------------------------------------------------*/
    115 void batch_control_read(batch_t *instance)
     115void batch_control_read(usb_transfer_batch_t *instance)
    116116{
    117117        assert(instance);
     
    121121}
    122122/*----------------------------------------------------------------------------*/
    123 void batch_interrupt_in(batch_t *instance)
     123void batch_interrupt_in(usb_transfer_batch_t *instance)
    124124{
    125125        assert(instance);
     
    130130}
    131131/*----------------------------------------------------------------------------*/
    132 void batch_interrupt_out(batch_t *instance)
     132void batch_interrupt_out(usb_transfer_batch_t *instance)
    133133{
    134134        assert(instance);
     
    142142}
    143143/*----------------------------------------------------------------------------*/
    144 void batch_bulk_in(batch_t *instance)
     144void batch_bulk_in(usb_transfer_batch_t *instance)
    145145{
    146146        assert(instance);
     
    151151}
    152152/*----------------------------------------------------------------------------*/
    153 void batch_bulk_out(batch_t *instance)
     153void batch_bulk_out(usb_transfer_batch_t *instance)
    154154{
    155155        assert(instance);
     
    164164 * @param[in] instance Batch structure to use.
    165165 */
    166 void batch_call_in_and_dispose(batch_t *instance)
     166void batch_call_in_and_dispose(usb_transfer_batch_t *instance)
    167167{
    168168        assert(instance);
    169         batch_call_in(instance);
     169        usb_transfer_batch_call_in(instance);
    170170        batch_dispose(instance);
    171171}
     
    175175 * @param[in] instance Batch structure to use.
    176176 */
    177 void batch_call_out_and_dispose(batch_t *instance)
     177void batch_call_out_and_dispose(usb_transfer_batch_t *instance)
    178178{
    179179        assert(instance);
    180         batch_call_out(instance);
     180        usb_transfer_batch_call_out(instance);
    181181        batch_dispose(instance);
    182182}
  • uspace/drv/ohci/batch.h

    r361e61b r55e388a1  
    4141#include <usb/host/batch.h>
    4242
    43 batch_t * batch_get(
     43usb_transfer_batch_t * batch_get(
    4444    ddf_fun_t *fun,
    4545                usb_target_t target,
     
    5454    usbhc_iface_transfer_out_callback_t func_out,
    5555                void *arg,
    56                 device_keeper_t *manager
     56                usb_device_keeper_t *manager
    5757                );
    5858
    59 void batch_dispose(batch_t *instance);
     59void batch_dispose(usb_transfer_batch_t *instance);
    6060
    61 void batch_control_write(batch_t *instance);
     61void batch_control_write(usb_transfer_batch_t *instance);
    6262
    63 void batch_control_read(batch_t *instance);
     63void batch_control_read(usb_transfer_batch_t *instance);
    6464
    65 void batch_interrupt_in(batch_t *instance);
     65void batch_interrupt_in(usb_transfer_batch_t *instance);
    6666
    67 void batch_interrupt_out(batch_t *instance);
     67void batch_interrupt_out(usb_transfer_batch_t *instance);
    6868
    69 void batch_bulk_in(batch_t *instance);
     69void batch_bulk_in(usb_transfer_batch_t *instance);
    7070
    71 void batch_bulk_out(batch_t *instance);
     71void batch_bulk_out(usb_transfer_batch_t *instance);
    7272#endif
    7373/**
  • uspace/drv/ohci/hc.c

    r361e61b r55e388a1  
    4545#include "hc.h"
    4646
    47 static int dummy_reset(int foo, void *arg)
    48 {
    49         hc_t *hc = (hc_t*)arg;
    50         assert(hc);
    51         hc->rh.address = 0;
    52         return EOK;
    53 }
     47static int dummy_reset(int foo, void *arg);
     48static int interrupt_emulator(hc_t *instance);
    5449/*----------------------------------------------------------------------------*/
    5550int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev,
     
    6560        }
    6661        instance->ddf_instance = fun;
    67         device_keeper_init(&instance->manager);
     62        usb_device_keeper_init(&instance->manager);
     63
     64        if (!interrupts) {
     65                instance->interrupt_emulator =
     66                    fibril_create((int(*)(void*))interrupt_emulator, instance);
     67                fibril_add_ready(instance->interrupt_emulator);
     68        }
    6869
    6970
     
    99100        ret = usb_hc_new_device_wrapper(dev, &conn, USB_SPEED_FULL, dummy_reset,
    100101            0, instance, &address, &handle, NULL, NULL, NULL);
    101         CHECK_RET_RETURN(ret, "Failed to add rh device.\n");
     102        if (ret != EOK) {
     103                usb_log_error("Failed to add rh device.\n");
     104                instance->rh.address = -1;
     105                return ret;
     106        }
    102107
    103108        ret = usb_hc_connection_close(&conn);
     
    106111}
    107112/*----------------------------------------------------------------------------*/
    108 int hc_schedule(hc_t *instance, batch_t *batch)
     113int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch)
    109114{
    110115        assert(instance);
     
    117122}
    118123/*----------------------------------------------------------------------------*/
    119 void hc_interrupt(hc_t *instance, uint16_t status)
     124void hc_interrupt(hc_t *instance, uint32_t status)
    120125{
    121126        assert(instance);
    122         /* TODO: Check for interrupt cause */
    123         rh_interrupt(&instance->rh);
     127        if (status == 0)
     128                return;
     129        if (status & IS_RHSC)
     130                rh_interrupt(&instance->rh);
     131
     132        /* TODO: Check for further interrupt causes */
    124133        /* TODO: implement */
     134}
     135/*----------------------------------------------------------------------------*/
     136static int dummy_reset(int foo, void *arg)
     137{
     138        hc_t *hc = (hc_t*)arg;
     139        assert(hc);
     140        hc->rh.address = 0;
     141        return EOK;
     142}
     143/*----------------------------------------------------------------------------*/
     144static int interrupt_emulator(hc_t *instance)
     145{
     146        assert(instance);
     147        usb_log_info("Started interrupt emulator.\n");
     148        while (1) {
     149                uint32_t status = instance->registers->interrupt_status;
     150                instance->registers->interrupt_status = status;
     151                hc_interrupt(instance, status);
     152                async_usleep(1000);
     153        }
     154        return EOK;
    125155}
    126156/**
  • uspace/drv/ohci/hc.h

    r361e61b r55e388a1  
    5353        rh_t rh;
    5454        ddf_fun_t *ddf_instance;
    55         device_keeper_t manager;
     55        usb_device_keeper_t manager;
     56        fid_t interrupt_emulator;
    5657} hc_t;
    5758
     
    6162int hc_register_hub(hc_t *instance);
    6263
    63 int hc_schedule(hc_t *instance, batch_t *batch);
     64int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch);
    6465
    65 void hc_interrupt(hc_t *instance, uint16_t status);
     66void hc_interrupt(hc_t *instance, uint32_t status);
    6667
    6768/** Safely dispose host controller internal structures
  • uspace/drv/ohci/iface.c

    r361e61b r55e388a1  
    3333 */
    3434#include <ddf/driver.h>
    35 #include <ddf/interrupt.h>
    36 #include <device/hw_res.h>
    3735#include <errno.h>
    38 #include <str_error.h>
    39 
    40 #include <usb_iface.h>
    41 #include <usb/ddfiface.h>
     36
    4237#include <usb/debug.h>
    4338
     
    6055static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
    6156{
    62   assert(fun);
    63   hc_t *hc = fun_to_hc(fun);
    64   assert(hc);
    65   usb_log_debug("Default address request with speed %d.\n", speed);
    66   device_keeper_reserve_default(&hc->manager, speed);
    67   return EOK;
     57        assert(fun);
     58        hc_t *hc = fun_to_hc(fun);
     59        assert(hc);
     60        usb_log_debug("Default address request with speed %d.\n", speed);
     61        usb_device_keeper_reserve_default_address(&hc->manager, speed);
     62        return EOK;
    6863}
    6964/*----------------------------------------------------------------------------*/
     
    7570static int release_default_address(ddf_fun_t *fun)
    7671{
    77   assert(fun);
    78   hc_t *hc = fun_to_hc(fun);
    79   assert(hc);
    80   usb_log_debug("Default address release.\n");
    81   device_keeper_release_default(&hc->manager);
    82   return EOK;
     72        assert(fun);
     73        hc_t *hc = fun_to_hc(fun);
     74        assert(hc);
     75        usb_log_debug("Default address release.\n");
     76        usb_device_keeper_release_default_address(&hc->manager);
     77        return EOK;
    8378}
    8479/*----------------------------------------------------------------------------*/
     
    9085 * @return Error code.
    9186 */
    92 static int request_address(ddf_fun_t *fun, usb_speed_t speed,
    93     usb_address_t *address)
    94 {
    95   assert(fun);
    96   hc_t *hc = fun_to_hc(fun);
    97   assert(hc);
    98   assert(address);
    99 
    100   usb_log_debug("Address request with speed %d.\n", speed);
    101   *address = device_keeper_request(&hc->manager, speed);
    102   usb_log_debug("Address request with result: %d.\n", *address);
    103   if (*address <= 0)
    104     return *address;
    105   return EOK;
     87static int request_address(
     88    ddf_fun_t *fun, usb_speed_t speed, usb_address_t *address)
     89{
     90        assert(fun);
     91        hc_t *hc = fun_to_hc(fun);
     92        assert(hc);
     93        assert(address);
     94
     95        usb_log_debug("Address request with speed %d.\n", speed);
     96        *address = device_keeper_get_free_address(&hc->manager, speed);
     97        usb_log_debug("Address request with result: %d.\n", *address);
     98        if (*address <= 0)
     99                return *address;
     100        return EOK;
    106101}
    107102/*----------------------------------------------------------------------------*/
     
    113108 * @return Error code.
    114109 */
    115 static int bind_address(ddf_fun_t *fun,
    116     usb_address_t address, devman_handle_t handle)
    117 {
    118   assert(fun);
    119   hc_t *hc = fun_to_hc(fun);
    120   assert(hc);
    121   usb_log_debug("Address bind %d-%d.\n", address, handle);
    122   device_keeper_bind(&hc->manager, address, handle);
    123   return EOK;
     110static int bind_address(
     111    ddf_fun_t *fun, usb_address_t address, devman_handle_t handle)
     112{
     113        assert(fun);
     114        hc_t *hc = fun_to_hc(fun);
     115        assert(hc);
     116        usb_log_debug("Address bind %d-%d.\n", address, handle);
     117        usb_device_keeper_bind(&hc->manager, address, handle);
     118        return EOK;
    124119}
    125120/*----------------------------------------------------------------------------*/
     
    132127static int release_address(ddf_fun_t *fun, usb_address_t address)
    133128{
    134   assert(fun);
    135   hc_t *hc = fun_to_hc(fun);
    136   assert(hc);
    137   usb_log_debug("Address release %d.\n", address);
    138   device_keeper_release(&hc->manager, address);
    139   return EOK;
    140 }
    141 
     129        assert(fun);
     130        hc_t *hc = fun_to_hc(fun);
     131        assert(hc);
     132        usb_log_debug("Address release %d.\n", address);
     133        usb_device_keeper_release(&hc->manager, address);
     134        return EOK;
     135}
     136/*----------------------------------------------------------------------------*/
    142137/** Register endpoint for bandwidth reservation.
    143138 *
     
    151146 * @return Error code.
    152147 */
    153 static int register_endpoint(ddf_fun_t *fun,
    154     usb_address_t address, usb_endpoint_t endpoint,
     148static int register_endpoint(
     149    ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint,
    155150    usb_transfer_type_t transfer_type, usb_direction_t direction,
    156151    size_t max_packet_size, unsigned int interval)
     
    160155        return ENOTSUP;
    161156}
    162 
     157/*----------------------------------------------------------------------------*/
    163158/** Unregister endpoint (free some bandwidth reservation).
    164159 *
     
    169164 * @return Error code.
    170165 */
    171 static int unregister_endpoint(ddf_fun_t *fun, usb_address_t address,
     166static int unregister_endpoint(
     167    ddf_fun_t *fun, usb_address_t address,
    172168    usb_endpoint_t endpoint, usb_direction_t direction)
    173169{
     
    194190 * @return Error code.
    195191 */
    196 static int interrupt_out(ddf_fun_t *fun, usb_target_t target,
    197     size_t max_packet_size, void *data, size_t size,
    198     usbhc_iface_transfer_out_callback_t callback, void *arg)
    199 {
    200   hc_t *hc = fun_to_hc(fun);
    201   assert(hc);
    202   usb_speed_t speed = device_keeper_speed(&hc->manager, target.address);
    203 
    204   usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n",
    205       target.address, target.endpoint, size, max_packet_size);
    206 
    207   batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
    208       max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,
    209       &hc->manager);
    210   if (!batch)
    211     return ENOMEM;
    212   batch_interrupt_out(batch);
    213   const int ret = hc_schedule(hc, batch);
    214   if (ret != EOK) {
    215     batch_dispose(batch);
    216     return ret;
    217   }
    218   return EOK;
     192static int interrupt_out(
     193    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
     194    size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
     195{
     196        assert(fun);
     197        hc_t *hc = fun_to_hc(fun);
     198        assert(hc);
     199        usb_speed_t speed =
     200            usb_device_keeper_get_speed(&hc->manager, target.address);
     201
     202        usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n",
     203            target.address, target.endpoint, size, max_packet_size);
     204
     205        usb_transfer_batch_t *batch =
     206            batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size,
     207                speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager);
     208        if (!batch)
     209                return ENOMEM;
     210        batch_interrupt_out(batch);
     211        const int ret = hc_schedule(hc, batch);
     212        if (ret != EOK) {
     213                batch_dispose(batch);
     214        }
     215        return ret;
    219216}
    220217/*----------------------------------------------------------------------------*/
     
    236233 * @return Error code.
    237234 */
    238 static int interrupt_in(ddf_fun_t *fun, usb_target_t target,
    239     size_t max_packet_size, void *data, size_t size,
    240     usbhc_iface_transfer_in_callback_t callback, void *arg)
    241 {
    242   assert(fun);
    243   hc_t *hc = fun_to_hc(fun);
    244   assert(hc);
    245   usb_speed_t speed = device_keeper_speed(&hc->manager, target.address);
    246   usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n",
    247       target.address, target.endpoint, size, max_packet_size);
    248 
    249   batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
    250       max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,
    251       &hc->manager);
    252   if (!batch)
    253     return ENOMEM;
    254   batch_interrupt_in(batch);
    255   const int ret = hc_schedule(hc, batch);
    256   if (ret != EOK) {
    257     batch_dispose(batch);
    258     return ret;
    259   }
    260   return EOK;
     235static int interrupt_in(
     236    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
     237    size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
     238{
     239        assert(fun);
     240        hc_t *hc = fun_to_hc(fun);
     241        assert(hc);
     242        usb_speed_t speed =
     243            usb_device_keeper_get_speed(&hc->manager, target.address);
     244        usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n",
     245            target.address, target.endpoint, size, max_packet_size);
     246
     247        usb_transfer_batch_t *batch =
     248            batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size,
     249                speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager);
     250        if (!batch)
     251                return ENOMEM;
     252        batch_interrupt_in(batch);
     253        const int ret = hc_schedule(hc, batch);
     254        if (ret != EOK) {
     255                batch_dispose(batch);
     256        }
     257        return ret;
    261258}
    262259/*----------------------------------------------------------------------------*/
     
    278275 * @return Error code.
    279276 */
    280 static int bulk_out(ddf_fun_t *fun, usb_target_t target,
    281     size_t max_packet_size, void *data, size_t size,
    282     usbhc_iface_transfer_out_callback_t callback, void *arg)
    283 {
    284   assert(fun);
    285   hc_t *hc = fun_to_hc(fun);
    286   assert(hc);
    287   usb_speed_t speed = device_keeper_speed(&hc->manager, target.address);
    288 
    289   usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n",
    290       target.address, target.endpoint, size, max_packet_size);
    291 
    292   batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
    293       max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,
    294       &hc->manager);
    295   if (!batch)
    296     return ENOMEM;
    297   batch_bulk_out(batch);
    298   const int ret = hc_schedule(hc, batch);
    299   if (ret != EOK) {
    300     batch_dispose(batch);
    301     return ret;
    302   }
    303   return EOK;
    304 
     277static int bulk_out(
     278    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
     279    size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
     280{
     281        assert(fun);
     282        hc_t *hc = fun_to_hc(fun);
     283        assert(hc);
     284        usb_speed_t speed =
     285            usb_device_keeper_get_speed(&hc->manager, target.address);
     286
     287        usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n",
     288            target.address, target.endpoint, size, max_packet_size);
     289
     290        usb_transfer_batch_t *batch =
     291            batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed,
     292                data, size, NULL, 0, NULL, callback, arg, &hc->manager);
     293        if (!batch)
     294                return ENOMEM;
     295        batch_bulk_out(batch);
     296        const int ret = hc_schedule(hc, batch);
     297        if (ret != EOK) {
     298                batch_dispose(batch);
     299        }
     300        return ret;
    305301}
    306302/*----------------------------------------------------------------------------*/
     
    322318 * @return Error code.
    323319 */
    324 static int bulk_in(ddf_fun_t *fun, usb_target_t target,
    325     size_t max_packet_size, void *data, size_t size,
    326     usbhc_iface_transfer_in_callback_t callback, void *arg)
    327 {
    328   assert(fun);
    329   hc_t *hc = fun_to_hc(fun);
    330   assert(hc);
    331   usb_speed_t speed = device_keeper_speed(&hc->manager, target.address);
    332   usb_log_debug("Bulk IN %d:%d %zu(%zu).\n",
    333       target.address, target.endpoint, size, max_packet_size);
    334 
    335   batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
    336       max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,
    337       &hc->manager);
    338   if (!batch)
    339     return ENOMEM;
    340   batch_bulk_in(batch);
    341   const int ret = hc_schedule(hc, batch);
    342   if (ret != EOK) {
    343     batch_dispose(batch);
    344     return ret;
    345   }
    346   return EOK;
     320static int bulk_in(
     321    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
     322    size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
     323{
     324        assert(fun);
     325        hc_t *hc = fun_to_hc(fun);
     326        assert(hc);
     327        usb_speed_t speed =
     328            usb_device_keeper_get_speed(&hc->manager, target.address);
     329        usb_log_debug("Bulk IN %d:%d %zu(%zu).\n",
     330            target.address, target.endpoint, size, max_packet_size);
     331
     332        usb_transfer_batch_t *batch =
     333            batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed,
     334                data, size, NULL, 0, callback, NULL, arg, &hc->manager);
     335        if (!batch)
     336                return ENOMEM;
     337        batch_bulk_in(batch);
     338        const int ret = hc_schedule(hc, batch);
     339        if (ret != EOK) {
     340                batch_dispose(batch);
     341        }
     342        return ret;
    347343}
    348344/*----------------------------------------------------------------------------*/
     
    367363 * @return Error code.
    368364 */
    369 static int control_write(ddf_fun_t *fun, usb_target_t target,
    370     size_t max_packet_size,
    371     void *setup_data, size_t setup_size,
    372     void *data, size_t size,
     365static int control_write(
     366    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size,
     367    void *setup_data, size_t setup_size, void *data, size_t size,
    373368    usbhc_iface_transfer_out_callback_t callback, void *arg)
    374369{
    375   assert(fun);
    376   hc_t *hc = fun_to_hc(fun);
    377   assert(hc);
    378   usb_speed_t speed = device_keeper_speed(&hc->manager, target.address);
    379   usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n",
    380       speed, target.address, target.endpoint, size, max_packet_size);
    381 
    382   if (setup_size != 8)
    383     return EINVAL;
    384 
    385   batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
    386       max_packet_size, speed, data, size, setup_data, setup_size,
    387       NULL, callback, arg, &hc->manager);
    388   if (!batch)
    389     return ENOMEM;
    390   device_keeper_reset_if_need(&hc->manager, target, setup_data);
    391   batch_control_write(batch);
    392   const int ret = hc_schedule(hc, batch);
    393   if (ret != EOK) {
    394     batch_dispose(batch);
    395     return ret;
    396   }
    397   return EOK;
     370        assert(fun);
     371        hc_t *hc = fun_to_hc(fun);
     372        assert(hc);
     373        usb_speed_t speed =
     374            usb_device_keeper_get_speed(&hc->manager, target.address);
     375        usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n",
     376            speed, target.address, target.endpoint, size, max_packet_size);
     377
     378        if (setup_size != 8)
     379                return EINVAL;
     380
     381        usb_transfer_batch_t *batch =
     382            batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size,
     383                speed, data, size, setup_data, setup_size, NULL, callback, arg,
     384                &hc->manager);
     385        if (!batch)
     386                return ENOMEM;
     387        usb_device_keeper_reset_if_need(&hc->manager, target, setup_data);
     388        batch_control_write(batch);
     389        const int ret = hc_schedule(hc, batch);
     390        if (ret != EOK) {
     391                batch_dispose(batch);
     392        }
     393        return ret;
    398394}
    399395/*----------------------------------------------------------------------------*/
     
    418414 * @return Error code.
    419415 */
    420 static int control_read(ddf_fun_t *fun, usb_target_t target,
    421     size_t max_packet_size,
    422     void *setup_data, size_t setup_size,
    423     void *data, size_t size,
     416static int control_read(
     417    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size,
     418    void *setup_data, size_t setup_size, void *data, size_t size,
    424419    usbhc_iface_transfer_in_callback_t callback, void *arg)
    425420{
    426   assert(fun);
    427   hc_t *hc = fun_to_hc(fun);
    428   assert(hc);
    429   usb_speed_t speed = device_keeper_speed(&hc->manager, target.address);
    430 
    431   usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n",
    432       speed, target.address, target.endpoint, size, max_packet_size);
    433   batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
    434       max_packet_size, speed, data, size, setup_data, setup_size, callback,
    435       NULL, arg, &hc->manager);
    436   if (!batch)
    437     return ENOMEM;
    438   batch_control_read(batch);
    439   const int ret = hc_schedule(hc, batch);
    440   if (ret != EOK) {
    441     batch_dispose(batch);
    442     return ret;
    443   }
    444   return EOK;
     421        assert(fun);
     422        hc_t *hc = fun_to_hc(fun);
     423        assert(hc);
     424        usb_speed_t speed =
     425            usb_device_keeper_get_speed(&hc->manager, target.address);
     426
     427        usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n",
     428            speed, target.address, target.endpoint, size, max_packet_size);
     429        usb_transfer_batch_t *batch =
     430            batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size,
     431                speed, data, size, setup_data, setup_size, callback, NULL, arg,
     432                &hc->manager);
     433        if (!batch)
     434                return ENOMEM;
     435        batch_control_read(batch);
     436        const int ret = hc_schedule(hc, batch);
     437        if (ret != EOK) {
     438                batch_dispose(batch);
     439        }
     440        return ret;
    445441}
    446442/*----------------------------------------------------------------------------*/
     
    463459
    464460        .control_write = control_write,
    465         .control_read = control_read
     461        .control_read = control_read,
    466462};
    467463
  • uspace/drv/ohci/main.c

    r361e61b r55e388a1  
    6161{
    6262        assert(fun);
    63         device_keeper_t *manager = &fun_to_hc(fun)->manager;
    64   usb_address_t addr = device_keeper_find(manager, handle);
     63        usb_device_keeper_t *manager = &fun_to_hc(fun)->manager;
     64  usb_address_t addr = usb_device_keeper_find(manager, handle);
    6565  if (addr < 0) {
    6666    return addr;
     
    149149        }
    150150
     151
    151152        bool interrupts = false;
     153#ifdef CONFIG_USBHC_NO_INTERRUPTS
     154        usb_log_warning("Interrupts disabled in OS config, " \
     155            "falling back to polling.\n");
     156#else
    152157        ret = pci_enable_interrupts(device);
    153158        if (ret != EOK) {
    154                 usb_log_warning(
    155                     "Failed(%d) to enable interrupts, fall back to polling.\n",
    156                     ret);
     159                usb_log_warning("Failed to enable interrupts: %s.\n",
     160                    str_error(ret));
     161                usb_log_info("HW interrupts not available, " \
     162                    "falling back to polling.\n");
    157163        } else {
    158164                usb_log_debug("Hw interrupts enabled.\n");
    159165                interrupts = true;
    160166        }
     167#endif
    161168
    162169        ret = hc_init(hcd, hc_fun, device, mem_reg_base, mem_reg_size, interrupts);
     
    199206int main(int argc, char *argv[])
    200207{
    201         usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     208        usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
    202209        sleep(5);
    203210        return ddf_driver_main(&ohci_driver);
  • uspace/drv/ohci/ohci_regs.h

    r361e61b r55e388a1  
    4343        volatile uint32_t command_status;
    4444        volatile uint32_t interrupt_status;
     45#define IS_SO (1 << 0)
     46#define IS_WDH (1 << 1)
     47#define IS_SF (1 << 2)
     48#define IS_RD (1 << 3)
     49#define IS_UE (1 << 4)
     50#define IS_FNO (1 << 5)
     51#define IS_RHSC (1 << 6)
     52#define IS_OC (1 << 30)
    4553        volatile uint32_t interupt_enable;
    4654#define IE_SO   (1 << 0)
  • uspace/drv/ohci/root_hub.c

    r361e61b r55e388a1  
    5656}
    5757/*----------------------------------------------------------------------------*/
    58 int rh_request(rh_t *instance, batch_t *request)
     58int rh_request(rh_t *instance, usb_transfer_batch_t *request)
    5959{
    6060        assert(instance);
     
    6666        }
    6767        usb_log_error("Root hub request processing not implemented.\n");
    68         batch_finish(request, ENOTSUP);
     68        usb_transfer_batch_finish(request, ENOTSUP);
    6969        return EOK;
    7070}
  • uspace/drv/ohci/root_hub.h

    r361e61b r55e388a1  
    4949int rh_init(rh_t *instance, ddf_dev_t *dev, ohci_regs_t *regs);
    5050
    51 int rh_request(rh_t *instance, batch_t *request);
     51int rh_request(rh_t *instance, usb_transfer_batch_t *request);
    5252
    5353void rh_interrupt(rh_t *instance);
  • uspace/drv/uhci-hcd/Makefile

    r361e61b r55e388a1  
    3737        transfer_list.c \
    3838        uhci.c \
    39         uhci_hc.c \
    40         uhci_rh.c \
    41         uhci_struct/transfer_descriptor.c \
     39        hc.c \
     40        root_hub.c \
     41        hw_struct/transfer_descriptor.c \
    4242        pci.c \
    4343        batch.c
  • uspace/drv/uhci-hcd/batch.c

    r361e61b r55e388a1  
    4040#include "batch.h"
    4141#include "transfer_list.h"
    42 #include "uhci_hc.h"
     42#include "hw_struct/transfer_descriptor.h"
    4343#include "utils/malloc32.h"
    44 #include "uhci_struct/transfer_descriptor.h"
    4544
    4645#define DEFAULT_ERROR_COUNT 3
     
    4948        qh_t *qh;
    5049        td_t *tds;
    51         size_t packets;
    52         device_keeper_t *manager;
     50        size_t transfers;
     51        usb_device_keeper_t *manager;
    5352} uhci_batch_t;
    5453
    55 static void batch_control(batch_t *instance,
     54static void batch_control(usb_transfer_batch_t *instance,
    5655    usb_packet_id data_stage, usb_packet_id status_stage);
    57 static void batch_data(batch_t *instance, usb_packet_id pid);
    58 static void batch_call_in_and_dispose(batch_t *instance);
    59 static void batch_call_out_and_dispose(batch_t *instance);
     56static void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid);
     57static void batch_call_in_and_dispose(usb_transfer_batch_t *instance);
     58static void batch_call_out_and_dispose(usb_transfer_batch_t *instance);
    6059
    6160
     
    6564 * @param[in] target Device and endpoint target of the transaction.
    6665 * @param[in] transfer_type Interrupt, Control or Bulk.
    67  * @param[in] max_packet_size maximum allowed size of data packets.
     66 * @param[in] max_packet_size maximum allowed size of data transfers.
    6867 * @param[in] speed Speed of the transaction.
    6968 * @param[in] buffer Data source/destination.
     
    7877 * NULL otherwise.
    7978 *
    80  * Determines the number of needed packets (TDs). Prepares a transport buffer
     79 * Determines the number of needed transfers (TDs). Prepares a transport buffer
    8180 * (that is accessible by the hardware). Initializes parameters needed for the
    8281 * transaction and callback.
    8382 */
    84 batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
     83usb_transfer_batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
    8584    usb_transfer_type_t transfer_type, size_t max_packet_size,
    8685    usb_speed_t speed, char *buffer, size_t buffer_size,
     
    8887    usbhc_iface_transfer_in_callback_t func_in,
    8988    usbhc_iface_transfer_out_callback_t func_out, void *arg,
    90     device_keeper_t *manager
     89    usb_device_keeper_t *manager
    9190    )
    9291{
     
    103102        } else (void)0
    104103
    105         batch_t *instance = malloc(sizeof(batch_t));
     104        usb_transfer_batch_t *instance = malloc(sizeof(usb_transfer_batch_t));
    106105        CHECK_NULL_DISPOSE_RETURN(instance,
    107106            "Failed to allocate batch instance.\n");
    108         batch_init(instance, target, transfer_type, speed, max_packet_size,
     107        usb_transfer_batch_init(instance, target, transfer_type, speed, max_packet_size,
    109108            buffer, NULL, buffer_size, NULL, setup_size, func_in,
    110109            func_out, arg, fun, NULL);
     
    118117        instance->private_data = data;
    119118
    120         data->packets = (buffer_size + max_packet_size - 1) / max_packet_size;
     119        data->transfers = (buffer_size + max_packet_size - 1) / max_packet_size;
    121120        if (transfer_type == USB_TRANSFER_CONTROL) {
    122                 data->packets += 2;
    123         }
    124 
    125         data->tds = malloc32(sizeof(td_t) * data->packets);
     121                data->transfers += 2;
     122        }
     123
     124        data->tds = malloc32(sizeof(td_t) * data->transfers);
    126125        CHECK_NULL_DISPOSE_RETURN(
    127126            data->tds, "Failed to allocate transfer descriptors.\n");
    128         bzero(data->tds, sizeof(td_t) * data->packets);
     127        bzero(data->tds, sizeof(td_t) * data->transfers);
    129128
    130129        data->qh = malloc32(sizeof(qh_t));
     
    161160 * is reached.
    162161 */
    163 bool batch_is_complete(batch_t *instance)
     162bool batch_is_complete(usb_transfer_batch_t *instance)
    164163{
    165164        assert(instance);
     
    167166        assert(data);
    168167
    169         usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n",
    170             instance, data->packets);
     168        usb_log_debug2("Batch(%p) checking %d transfer(s) for completion.\n",
     169            instance, data->transfers);
    171170        instance->transfered_size = 0;
    172171        size_t i = 0;
    173         for (;i < data->packets; ++i) {
     172        for (;i < data->transfers; ++i) {
    174173                if (td_is_active(&data->tds[i])) {
    175174                        return false;
     
    182181                        td_print_status(&data->tds[i]);
    183182
    184                         device_keeper_set_toggle(data->manager,
     183                        usb_device_keeper_set_toggle(data->manager,
    185184                            instance->target, instance->direction,
    186185                            td_toggle(&data->tds[i]));
     
    205204 * Uses genercir control function with pids OUT and IN.
    206205 */
    207 void batch_control_write(batch_t *instance)
     206void batch_control_write(usb_transfer_batch_t *instance)
    208207{
    209208        assert(instance);
     
    222221 * Uses generic control with pids IN and OUT.
    223222 */
    224 void batch_control_read(batch_t *instance)
     223void batch_control_read(usb_transfer_batch_t *instance)
    225224{
    226225        assert(instance);
     
    236235 * Data transaction with PID_IN.
    237236 */
    238 void batch_interrupt_in(batch_t *instance)
     237void batch_interrupt_in(usb_transfer_batch_t *instance)
    239238{
    240239        assert(instance);
     
    251250 * Data transaction with PID_OUT.
    252251 */
    253 void batch_interrupt_out(batch_t *instance)
     252void batch_interrupt_out(usb_transfer_batch_t *instance)
    254253{
    255254        assert(instance);
     
    269268 * Data transaction with PID_IN.
    270269 */
    271 void batch_bulk_in(batch_t *instance)
     270void batch_bulk_in(usb_transfer_batch_t *instance)
    272271{
    273272        assert(instance);
     
    284283 * Data transaction with PID_OUT.
    285284 */
    286 void batch_bulk_out(batch_t *instance)
     285void batch_bulk_out(usb_transfer_batch_t *instance)
    287286{
    288287        assert(instance);
     
    299298 *
    300299 * @param[in] instance Batch structure to use.
    301  * @param[in] pid to use for data packets.
     300 * @param[in] pid Pid to use for data transfers.
    302301 *
    303302 * Packets with alternating toggle bit and supplied pid value.
    304  * The last packet is marked with IOC flag.
    305  */
    306 void batch_data(batch_t *instance, usb_packet_id pid)
     303 * The last transfer is marked with IOC flag.
     304 */
     305void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid)
    307306{
    308307        assert(instance);
     
    311310
    312311        const bool low_speed = instance->speed == USB_SPEED_LOW;
    313         int toggle = device_keeper_get_toggle(
     312        int toggle = usb_device_keeper_get_toggle(
    314313            data->manager, instance->target, instance->direction);
    315314        assert(toggle == 0 || toggle == 1);
    316315
    317         size_t packet = 0;
     316        size_t transfer = 0;
    318317        size_t remain_size = instance->buffer_size;
    319318        while (remain_size > 0) {
     
    326325                    remain_size : instance->max_packet_size;
    327326
    328                 td_t *next_packet = (packet + 1 < data->packets)
    329                     ? &data->tds[packet + 1] : NULL;
    330 
    331                 assert(packet < data->packets);
     327                td_t *next_transfer = (transfer + 1 < data->transfers)
     328                    ? &data->tds[transfer + 1] : NULL;
     329
     330                assert(transfer < data->transfers);
    332331                assert(packet_size <= remain_size);
    333332
    334333                td_init(
    335                     &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size,
     334                    &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
    336335                    toggle, false, low_speed, instance->target, pid, trans_data,
    337                     next_packet);
     336                    next_transfer);
    338337
    339338
    340339                toggle = 1 - toggle;
    341340                remain_size -= packet_size;
    342                 ++packet;
    343         }
    344         td_set_ioc(&data->tds[packet - 1]);
    345         device_keeper_set_toggle(data->manager, instance->target,
     341                ++transfer;
     342        }
     343        td_set_ioc(&data->tds[transfer - 1]);
     344        usb_device_keeper_set_toggle(data->manager, instance->target,
    346345            instance->direction, toggle);
    347346}
     
    350349 *
    351350 * @param[in] instance Batch structure to use.
    352  * @param[in] data_stage to use for data packets.
    353  * @param[in] status_stage to use for data packets.
     351 * @param[in] data_stage Pid to use for data transfers.
     352 * @param[in] status_stage Pid to use for data transfers.
    354353 *
    355354 * Setup stage with toggle 0 and USB_PID_SETUP.
    356355 * Data stage with alternating toggle and pid supplied by parameter.
    357356 * Status stage with toggle 1 and pid supplied by parameter.
    358  * The last packet is marked with IOC.
    359  */
    360 void batch_control(batch_t *instance,
     357 * The last transfer is marked with IOC.
     358 */
     359void batch_control(usb_transfer_batch_t *instance,
    361360   usb_packet_id data_stage, usb_packet_id status_stage)
    362361{
     
    364363        uhci_batch_t *data = instance->private_data;
    365364        assert(data);
    366         assert(data->packets >= 2);
     365        assert(data->transfers >= 2);
    367366
    368367        const bool low_speed = instance->speed == USB_SPEED_LOW;
     
    375374
    376375        /* data stage */
    377         size_t packet = 1;
     376        size_t transfer = 1;
    378377        size_t remain_size = instance->buffer_size;
    379378        while (remain_size > 0) {
     
    389388
    390389                td_init(
    391                     &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size,
     390                    &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
    392391                    toggle, false, low_speed, instance->target, data_stage,
    393                     control_data, &data->tds[packet + 1]);
    394 
    395                 ++packet;
    396                 assert(packet < data->packets);
     392                    control_data, &data->tds[transfer + 1]);
     393
     394                ++transfer;
     395                assert(transfer < data->transfers);
    397396                assert(packet_size <= remain_size);
    398397                remain_size -= packet_size;
     
    400399
    401400        /* status stage */
    402         assert(packet == data->packets - 1);
     401        assert(transfer == data->transfers - 1);
    403402
    404403        td_init(
    405             &data->tds[packet], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,
     404            &data->tds[transfer], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,
    406405            instance->target, status_stage, NULL, NULL);
    407         td_set_ioc(&data->tds[packet]);
     406        td_set_ioc(&data->tds[transfer]);
    408407
    409408        usb_log_debug2("Control last TD status: %x.\n",
    410             data->tds[packet].status);
    411 }
    412 /*----------------------------------------------------------------------------*/
    413 qh_t * batch_qh(batch_t *instance)
     409            data->tds[transfer].status);
     410}
     411/*----------------------------------------------------------------------------*/
     412qh_t * batch_qh(usb_transfer_batch_t *instance)
    414413{
    415414        assert(instance);
     
    423422 * @param[in] instance Batch structure to use.
    424423 */
    425 void batch_call_in_and_dispose(batch_t *instance)
    426 {
    427         assert(instance);
    428         batch_call_in(instance);
     424void batch_call_in_and_dispose(usb_transfer_batch_t *instance)
     425{
     426        assert(instance);
     427        usb_transfer_batch_call_in(instance);
    429428        batch_dispose(instance);
    430429}
     
    434433 * @param[in] instance Batch structure to use.
    435434 */
    436 void batch_call_out_and_dispose(batch_t *instance)
    437 {
    438         assert(instance);
    439         batch_call_out(instance);
     435void batch_call_out_and_dispose(usb_transfer_batch_t *instance)
     436{
     437        assert(instance);
     438        usb_transfer_batch_call_out(instance);
    440439        batch_dispose(instance);
    441440}
     
    445444 * @param[in] instance Batch structure to use.
    446445 */
    447 void batch_dispose(batch_t *instance)
     446void batch_dispose(usb_transfer_batch_t *instance)
    448447{
    449448        assert(instance);
  • uspace/drv/uhci-hcd/batch.h

    r361e61b r55e388a1  
    4242#include <usb/host/batch.h>
    4343
    44 #include "uhci_struct/queue_head.h"
     44#include "hw_struct/queue_head.h"
    4545
    46 batch_t * batch_get(
     46usb_transfer_batch_t * batch_get(
    4747    ddf_fun_t *fun,
    4848                usb_target_t target,
     
    5757    usbhc_iface_transfer_out_callback_t func_out,
    5858                void *arg,
    59                 device_keeper_t *manager
     59                usb_device_keeper_t *manager
    6060                );
    6161
    62 void batch_dispose(batch_t *instance);
     62void batch_dispose(usb_transfer_batch_t *instance);
    6363
    64 bool batch_is_complete(batch_t *instance);
     64bool batch_is_complete(usb_transfer_batch_t *instance);
    6565
    66 void batch_control_write(batch_t *instance);
     66void batch_control_write(usb_transfer_batch_t *instance);
    6767
    68 void batch_control_read(batch_t *instance);
     68void batch_control_read(usb_transfer_batch_t *instance);
    6969
    70 void batch_interrupt_in(batch_t *instance);
     70void batch_interrupt_in(usb_transfer_batch_t *instance);
    7171
    72 void batch_interrupt_out(batch_t *instance);
     72void batch_interrupt_out(usb_transfer_batch_t *instance);
    7373
    74 void batch_bulk_in(batch_t *instance);
     74void batch_bulk_in(usb_transfer_batch_t *instance);
    7575
    76 void batch_bulk_out(batch_t *instance);
     76void batch_bulk_out(usb_transfer_batch_t *instance);
    7777
    78 qh_t * batch_qh(batch_t *instance);
     78qh_t * batch_qh(usb_transfer_batch_t *instance);
    7979#endif
    8080/**
  • uspace/drv/uhci-hcd/iface.c

    r361e61b r55e388a1  
    3333 */
    3434#include <ddf/driver.h>
    35 #include <remote_usbhc.h>
     35#include <errno.h>
    3636
    3737#include <usb/debug.h>
    3838
    39 #include <errno.h>
    40 
    4139#include "iface.h"
    42 #include "uhci_hc.h"
     40#include "hc.h"
    4341
    4442/** Reserve default address interface function
     
    4846 * @return Error code.
    4947 */
    50 /*----------------------------------------------------------------------------*/
    5148static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
    5249{
    5350        assert(fun);
    54         uhci_hc_t *hc = fun_to_uhci_hc(fun);
     51        hc_t *hc = fun_to_hc(fun);
    5552        assert(hc);
    5653        usb_log_debug("Default address request with speed %d.\n", speed);
    57         device_keeper_reserve_default(&hc->device_manager, speed);
     54        usb_device_keeper_reserve_default_address(&hc->manager, speed);
    5855        return EOK;
    5956}
     
    6764{
    6865        assert(fun);
    69         uhci_hc_t *hc = fun_to_uhci_hc(fun);
     66        hc_t *hc = fun_to_hc(fun);
    7067        assert(hc);
    7168        usb_log_debug("Default address release.\n");
    72         device_keeper_release_default(&hc->device_manager);
     69        usb_device_keeper_release_default_address(&hc->manager);
    7370        return EOK;
    7471}
     
    8178 * @return Error code.
    8279 */
    83 static int request_address(ddf_fun_t *fun, usb_speed_t speed,
    84     usb_address_t *address)
    85 {
    86         assert(fun);
    87         uhci_hc_t *hc = fun_to_uhci_hc(fun);
     80static int request_address(
     81    ddf_fun_t *fun, usb_speed_t speed, usb_address_t *address)
     82{
     83        assert(fun);
     84        hc_t *hc = fun_to_hc(fun);
    8885        assert(hc);
    8986        assert(address);
    9087
    9188        usb_log_debug("Address request with speed %d.\n", speed);
    92         *address = device_keeper_request(&hc->device_manager, speed);
     89        *address = device_keeper_get_free_address(&hc->manager, speed);
    9390        usb_log_debug("Address request with result: %d.\n", *address);
    9491        if (*address <= 0)
    95           return *address;
     92                return *address;
    9693        return EOK;
    9794}
     
    108105{
    109106        assert(fun);
    110         uhci_hc_t *hc = fun_to_uhci_hc(fun);
     107        hc_t *hc = fun_to_hc(fun);
    111108        assert(hc);
    112109        usb_log_debug("Address bind %d-%d.\n", address, handle);
    113         device_keeper_bind(&hc->device_manager, address, handle);
     110        usb_device_keeper_bind(&hc->manager, address, handle);
    114111        return EOK;
    115112}
     
    124121{
    125122        assert(fun);
    126         uhci_hc_t *hc = fun_to_uhci_hc(fun);
     123        hc_t *hc = fun_to_hc(fun);
    127124        assert(hc);
    128125        usb_log_debug("Address release %d.\n", address);
    129         device_keeper_release(&hc->device_manager, address);
     126        usb_device_keeper_release(&hc->manager, address);
    130127        return EOK;
    131128}
     
    142139 * @return Error code.
    143140 */
    144 static int interrupt_out(ddf_fun_t *fun, usb_target_t target,
    145     size_t max_packet_size, void *data, size_t size,
    146     usbhc_iface_transfer_out_callback_t callback, void *arg)
    147 {
    148         assert(fun);
    149         uhci_hc_t *hc = fun_to_uhci_hc(fun);
    150         assert(hc);
    151         usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
     141static int interrupt_out(
     142    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
     143    size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
     144{
     145        assert(fun);
     146        hc_t *hc = fun_to_hc(fun);
     147        assert(hc);
     148        usb_speed_t speed =
     149            usb_device_keeper_get_speed(&hc->manager, target.address);
    152150
    153151        usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n",
    154152            target.address, target.endpoint, size, max_packet_size);
    155153
    156         batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
    157             max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,
    158             &hc->device_manager);
     154        usb_transfer_batch_t *batch =
     155            batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size,
     156                speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager);
    159157        if (!batch)
    160158                return ENOMEM;
    161159        batch_interrupt_out(batch);
    162         const int ret = uhci_hc_schedule(hc, batch);
    163         if (ret != EOK) {
    164                 batch_dispose(batch);
    165                 return ret;
    166         }
    167         return EOK;
     160        const int ret = hc_schedule(hc, batch);
     161        if (ret != EOK) {
     162                batch_dispose(batch);
     163        }
     164        return ret;
    168165}
    169166/*----------------------------------------------------------------------------*/
     
    179176 * @return Error code.
    180177 */
    181 static int interrupt_in(ddf_fun_t *fun, usb_target_t target,
    182     size_t max_packet_size, void *data, size_t size,
    183     usbhc_iface_transfer_in_callback_t callback, void *arg)
    184 {
    185         assert(fun);
    186         uhci_hc_t *hc = fun_to_uhci_hc(fun);
    187         assert(hc);
    188         usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
     178static int interrupt_in(
     179    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
     180    size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
     181{
     182        assert(fun);
     183        hc_t *hc = fun_to_hc(fun);
     184        assert(hc);
     185        usb_speed_t speed =
     186            usb_device_keeper_get_speed(&hc->manager, target.address);
    189187        usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n",
    190188            target.address, target.endpoint, size, max_packet_size);
    191189
    192         batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
    193             max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,
    194                         &hc->device_manager);
     190        usb_transfer_batch_t *batch =
     191            batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size,
     192                speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager);
    195193        if (!batch)
    196194                return ENOMEM;
    197195        batch_interrupt_in(batch);
    198         const int ret = uhci_hc_schedule(hc, batch);
    199         if (ret != EOK) {
    200                 batch_dispose(batch);
    201                 return ret;
    202         }
    203         return EOK;
     196        const int ret = hc_schedule(hc, batch);
     197        if (ret != EOK) {
     198                batch_dispose(batch);
     199        }
     200        return ret;
    204201}
    205202/*----------------------------------------------------------------------------*/
     
    215212 * @return Error code.
    216213 */
    217 static int bulk_out(ddf_fun_t *fun, usb_target_t target,
    218     size_t max_packet_size, void *data, size_t size,
    219     usbhc_iface_transfer_out_callback_t callback, void *arg)
    220 {
    221         assert(fun);
    222         uhci_hc_t *hc = fun_to_uhci_hc(fun);
    223         assert(hc);
    224         usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
     214static int bulk_out(
     215    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
     216    size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
     217{
     218        assert(fun);
     219        hc_t *hc = fun_to_hc(fun);
     220        assert(hc);
     221        usb_speed_t speed =
     222            usb_device_keeper_get_speed(&hc->manager, target.address);
    225223
    226224        usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n",
    227225            target.address, target.endpoint, size, max_packet_size);
    228226
    229         batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
    230             max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,
    231             &hc->device_manager);
     227        usb_transfer_batch_t *batch =
     228            batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed,
     229                data, size, NULL, 0, NULL, callback, arg, &hc->manager);
    232230        if (!batch)
    233231                return ENOMEM;
    234232        batch_bulk_out(batch);
    235         const int ret = uhci_hc_schedule(hc, batch);
    236         if (ret != EOK) {
    237                 batch_dispose(batch);
    238                 return ret;
    239         }
    240         return EOK;
     233        const int ret = hc_schedule(hc, batch);
     234        if (ret != EOK) {
     235                batch_dispose(batch);
     236        }
     237        return ret;
    241238}
    242239/*----------------------------------------------------------------------------*/
     
    252249 * @return Error code.
    253250 */
    254 static int bulk_in(ddf_fun_t *fun, usb_target_t target,
    255     size_t max_packet_size, void *data, size_t size,
    256     usbhc_iface_transfer_in_callback_t callback, void *arg)
    257 {
    258         assert(fun);
    259         uhci_hc_t *hc = fun_to_uhci_hc(fun);
    260         assert(hc);
    261         usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
     251static int bulk_in(
     252    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
     253    size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
     254{
     255        assert(fun);
     256        hc_t *hc = fun_to_hc(fun);
     257        assert(hc);
     258        usb_speed_t speed =
     259            usb_device_keeper_get_speed(&hc->manager, target.address);
    262260        usb_log_debug("Bulk IN %d:%d %zu(%zu).\n",
    263261            target.address, target.endpoint, size, max_packet_size);
    264262
    265         batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
    266             max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,
    267             &hc->device_manager);
     263        usb_transfer_batch_t *batch =
     264            batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed,
     265                data, size, NULL, 0, callback, NULL, arg, &hc->manager);
    268266        if (!batch)
    269267                return ENOMEM;
    270268        batch_bulk_in(batch);
    271         const int ret = uhci_hc_schedule(hc, batch);
    272         if (ret != EOK) {
    273                 batch_dispose(batch);
    274                 return ret;
    275         }
    276         return EOK;
     269        const int ret = hc_schedule(hc, batch);
     270        if (ret != EOK) {
     271                batch_dispose(batch);
     272        }
     273        return ret;
    277274}
    278275/*----------------------------------------------------------------------------*/
     
    282279 * @param[in] target USB device to write to.
    283280 * @param[in] max_packet_size maximum size of data packet the device accepts.
    284  * @param[in] setup_data Data to send with SETUP packet.
    285  * @param[in] setup_size Size of data to send with SETUP packet (should be 8B).
     281 * @param[in] setup_data Data to send with SETUP transfer.
     282 * @param[in] setup_size Size of data to send with SETUP transfer (always 8B).
    286283 * @param[in] data Source of data.
    287284 * @param[in] size Size of data source.
     
    290287 * @return Error code.
    291288 */
    292 static int control_write(ddf_fun_t *fun, usb_target_t target,
    293     size_t max_packet_size,
     289static int control_write(
     290    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size,
    294291    void *setup_data, size_t setup_size, void *data, size_t size,
    295292    usbhc_iface_transfer_out_callback_t callback, void *arg)
    296293{
    297294        assert(fun);
    298         uhci_hc_t *hc = fun_to_uhci_hc(fun);
    299         assert(hc);
    300         usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
     295        hc_t *hc = fun_to_hc(fun);
     296        assert(hc);
     297        usb_speed_t speed =
     298            usb_device_keeper_get_speed(&hc->manager, target.address);
    301299        usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n",
    302300            speed, target.address, target.endpoint, size, max_packet_size);
     
    305303                return EINVAL;
    306304
    307         batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
    308             max_packet_size, speed, data, size, setup_data, setup_size,
    309             NULL, callback, arg, &hc->device_manager);
    310         if (!batch)
    311                 return ENOMEM;
    312         device_keeper_reset_if_need(&hc->device_manager, target, setup_data);
     305        usb_transfer_batch_t *batch =
     306            batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed,
     307                data, size, setup_data, setup_size, NULL, callback, arg,
     308                &hc->manager);
     309        if (!batch)
     310                return ENOMEM;
     311        usb_device_keeper_reset_if_need(&hc->manager, target, setup_data);
    313312        batch_control_write(batch);
    314         const int ret = uhci_hc_schedule(hc, batch);
    315         if (ret != EOK) {
    316                 batch_dispose(batch);
    317                 return ret;
    318         }
    319         return EOK;
     313        const int ret = hc_schedule(hc, batch);
     314        if (ret != EOK) {
     315                batch_dispose(batch);
     316        }
     317        return ret;
    320318}
    321319/*----------------------------------------------------------------------------*/
     
    333331 * @return Error code.
    334332 */
    335 static int control_read(ddf_fun_t *fun, usb_target_t target,
    336     size_t max_packet_size,
     333static int control_read(
     334    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size,
    337335    void *setup_data, size_t setup_size, void *data, size_t size,
    338336    usbhc_iface_transfer_in_callback_t callback, void *arg)
    339337{
    340338        assert(fun);
    341         uhci_hc_t *hc = fun_to_uhci_hc(fun);
    342         assert(hc);
    343         usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
     339        hc_t *hc = fun_to_hc(fun);
     340        assert(hc);
     341        usb_speed_t speed =
     342            usb_device_keeper_get_speed(&hc->manager, target.address);
    344343
    345344        usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n",
    346345            speed, target.address, target.endpoint, size, max_packet_size);
    347         batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
    348             max_packet_size, speed, data, size, setup_data, setup_size, callback,
    349             NULL, arg, &hc->device_manager);
     346        usb_transfer_batch_t *batch =
     347            batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed,
     348                data, size, setup_data, setup_size, callback, NULL, arg,
     349                &hc->manager);
    350350        if (!batch)
    351351                return ENOMEM;
    352352        batch_control_read(batch);
    353         const int ret = uhci_hc_schedule(hc, batch);
    354         if (ret != EOK) {
    355                 batch_dispose(batch);
    356                 return ret;
    357         }
    358         return EOK;
    359 }
    360 /*----------------------------------------------------------------------------*/
    361 usbhc_iface_t uhci_hc_iface = {
     353        const int ret = hc_schedule(hc, batch);
     354        if (ret != EOK) {
     355                batch_dispose(batch);
     356        }
     357        return ret;
     358}
     359/*----------------------------------------------------------------------------*/
     360usbhc_iface_t hc_iface = {
    362361        .reserve_default_address = reserve_default_address,
    363362        .release_default_address = release_default_address,
     
    369368        .interrupt_in = interrupt_in,
    370369
     370        .bulk_out = bulk_out,
    371371        .bulk_in = bulk_in,
    372         .bulk_out = bulk_out,
    373 
     372
     373        .control_write = control_write,
    374374        .control_read = control_read,
    375         .control_write = control_write,
    376375};
    377376/**
  • uspace/drv/uhci-hcd/iface.h

    r361e61b r55e388a1  
    3838#include <usbhc_iface.h>
    3939
    40 extern usbhc_iface_t uhci_hc_iface;
     40extern usbhc_iface_t hc_iface;
    4141
    4242#endif
  • uspace/drv/uhci-hcd/main.c

    r361e61b r55e388a1  
    6262int uhci_add_device(ddf_dev_t *device)
    6363{
    64         usb_log_info("uhci_add_device() called\n");
     64        usb_log_debug("uhci_add_device() called\n");
    6565        assert(device);
    6666        uhci_t *uhci = malloc(sizeof(uhci_t));
     
    7272        int ret = uhci_init(uhci, device);
    7373        if (ret != EOK) {
    74                 usb_log_error("Failed to initialzie UHCI driver.\n");
     74                usb_log_error("Failed to initialize UHCI driver: %s.\n",
     75                    str_error(ret));
    7576                return ret;
    7677        }
    7778        device->driver_data = uhci;
     79
     80        usb_log_info("Controlling new UHCI device `%s'.\n", device->name);
     81
    7882        return EOK;
    7983}
     
    8993int main(int argc, char *argv[])
    9094{
     95        printf(NAME ": HelenOS UHCI driver.\n");
     96
    9197        sleep(3); /* TODO: remove in final version */
    92         usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     98        usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
    9399
    94100        return ddf_driver_main(&uhci_driver);
  • uspace/drv/uhci-hcd/transfer_list.c

    r361e61b r55e388a1  
    3838
    3939static void transfer_list_remove_batch(
    40     transfer_list_t *instance, batch_t *batch);
     40    transfer_list_t *instance, usb_transfer_batch_t *batch);
    4141/*----------------------------------------------------------------------------*/
    4242/** Initialize transfer list structures.
     
    7979        if (!instance->queue_head)
    8080                return;
    81         /* Set both next and element to point to the same QH */
     81        /* Set both queue_head.next to point to the follower */
    8282        qh_set_next_qh(instance->queue_head, next->queue_head_pa);
    83         qh_set_element_qh(instance->queue_head, next->queue_head_pa);
    8483}
    8584/*----------------------------------------------------------------------------*/
     
    9291 * The batch is added to the end of the list and queue.
    9392 */
    94 void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch)
     93void transfer_list_add_batch(
     94    transfer_list_t *instance, usb_transfer_batch_t *batch)
    9595{
    9696        assert(instance);
     
    9898        usb_log_debug2("Queue %s: Adding batch(%p).\n", instance->name, batch);
    9999
    100         const uint32_t pa = addr_to_phys(batch_qh(batch));
    101         assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);
    102 
    103         /* New batch will be added to the end of the current list
    104          * so set the link accordingly */
    105         qh_set_next_qh(batch_qh(batch), instance->queue_head->next);
    106 
    107100        fibril_mutex_lock(&instance->guard);
    108101
     102        qh_t *last_qh = NULL;
    109103        /* Add to the hardware queue. */
    110104        if (list_empty(&instance->batch_list)) {
    111105                /* There is nothing scheduled */
    112                 qh_t *qh = instance->queue_head;
    113                 assert(qh->element == qh->next);
    114                 qh_set_element_qh(qh, pa);
     106                last_qh = instance->queue_head;
    115107        } else {
    116108                /* There is something scheduled */
    117                 batch_t *last = list_get_instance(
    118                     instance->batch_list.prev, batch_t, link);
    119                 qh_set_next_qh(batch_qh(last), pa);
    120         }
     109                usb_transfer_batch_t *last = list_get_instance(
     110                    instance->batch_list.prev, usb_transfer_batch_t, link);
     111                last_qh = batch_qh(last);
     112        }
     113        const uint32_t pa = addr_to_phys(batch_qh(batch));
     114        assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);
     115
     116        /* keep link */
     117        batch_qh(batch)->next = last_qh->next;
     118        qh_set_next_qh(last_qh, pa);
     119
    121120        /* Add to the driver list */
    122121        list_append(&batch->link, &instance->batch_list);
    123122
    124         batch_t *first = list_get_instance(
    125             instance->batch_list.next, batch_t, link);
     123        usb_transfer_batch_t *first = list_get_instance(
     124            instance->batch_list.next, usb_transfer_batch_t, link);
    126125        usb_log_debug("Batch(%p) added to queue %s, first is %p.\n",
    127126                batch, instance->name, first);
     
    148147        while (current != &instance->batch_list) {
    149148                link_t *next = current->next;
    150                 batch_t *batch = list_get_instance(current, batch_t, link);
     149                usb_transfer_batch_t *batch =
     150                    list_get_instance(current, usb_transfer_batch_t, link);
    151151
    152152                if (batch_is_complete(batch)) {
     
    162162                link_t *item = done.next;
    163163                list_remove(item);
    164                 batch_t *batch = list_get_instance(item, batch_t, link);
     164                usb_transfer_batch_t *batch =
     165                    list_get_instance(item, usb_transfer_batch_t, link);
    165166                batch->next_step(batch);
    166167        }
     
    174175{
    175176        fibril_mutex_lock(&instance->guard);
    176         while (list_empty(&instance->batch_list)) {
     177        while (!list_empty(&instance->batch_list)) {
    177178                link_t *current = instance->batch_list.next;
    178                 batch_t *batch = list_get_instance(current, batch_t, link);
     179                usb_transfer_batch_t *batch =
     180                    list_get_instance(current, usb_transfer_batch_t, link);
    179181                transfer_list_remove_batch(instance, batch);
    180                 batch_finish(batch, EIO);
     182                usb_transfer_batch_finish(batch, EIO);
    181183        }
    182184        fibril_mutex_unlock(&instance->guard);
     
    191193 * Does not lock the transfer list, caller is responsible for that.
    192194 */
    193 void transfer_list_remove_batch(transfer_list_t *instance, batch_t *batch)
     195void transfer_list_remove_batch(
     196    transfer_list_t *instance, usb_transfer_batch_t *batch)
    194197{
    195198        assert(instance);
     
    197200        assert(batch);
    198201        assert(batch_qh(batch));
     202        assert(fibril_mutex_is_locked(&instance->guard));
     203
    199204        usb_log_debug2(
    200205            "Queue %s: removing batch(%p).\n", instance->name, batch);
    201206
    202         const char * pos = NULL;
     207        const char *qpos = NULL;
    203208        /* Remove from the hardware queue */
    204         if (batch->link.prev == &instance->batch_list) {
     209        if (instance->batch_list.next == &batch->link) {
    205210                /* I'm the first one here */
    206                 qh_set_element_qh(instance->queue_head, batch_qh(batch)->next);
    207                 pos = "FIRST";
     211                assert((instance->queue_head->next & LINK_POINTER_ADDRESS_MASK)
     212                    == addr_to_phys(batch_qh(batch)));
     213                instance->queue_head->next = batch_qh(batch)->next;
     214                qpos = "FIRST";
    208215        } else {
    209                 batch_t *prev =
    210                     list_get_instance(batch->link.prev, batch_t, link);
    211                 qh_set_next_qh(batch_qh(prev), batch_qh(batch)->next);
    212                 pos = "NOT FIRST";
    213         }
    214         /* Remove from the driver list */
     216                usb_transfer_batch_t *prev =
     217                    list_get_instance(
     218                        batch->link.prev, usb_transfer_batch_t, link);
     219                assert((batch_qh(prev)->next & LINK_POINTER_ADDRESS_MASK)
     220                    == addr_to_phys(batch_qh(batch)));
     221                batch_qh(prev)->next = batch_qh(batch)->next;
     222                qpos = "NOT FIRST";
     223        }
     224        /* Remove from the batch list */
    215225        list_remove(&batch->link);
    216         usb_log_debug("Batch(%p) removed (%s) from %s, next element %x.\n",
    217             batch, pos, instance->name, batch_qh(batch)->next);
     226        usb_log_debug("Batch(%p) removed (%s) from %s, next %x.\n",
     227            batch, qpos, instance->name, batch_qh(batch)->next);
    218228}
    219229/**
  • uspace/drv/uhci-hcd/transfer_list.h

    r361e61b r55e388a1  
    3737#include <fibril_synch.h>
    3838
    39 #include "uhci_struct/queue_head.h"
    40 
    4139#include "batch.h"
     40#include "hw_struct/queue_head.h"
    4241
    4342typedef struct transfer_list
     
    6665void transfer_list_set_next(transfer_list_t *instance, transfer_list_t *next);
    6766
    68 void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch);
     67void transfer_list_add_batch(transfer_list_t *instance, usb_transfer_batch_t *batch);
    6968
    7069void transfer_list_remove_finished(transfer_list_t *instance);
  • uspace/drv/uhci-hcd/uhci.c

    r361e61b r55e388a1  
    5454{
    5555        assert(dev);
    56         uhci_hc_t *hc = &((uhci_t*)dev->driver_data)->hc;
     56        hc_t *hc = &((uhci_t*)dev->driver_data)->hc;
    5757        uint16_t status = IPC_GET_ARG1(*call);
    5858        assert(hc);
    59         uhci_hc_interrupt(hc, status);
     59        hc_interrupt(hc, status);
    6060}
    6161/*----------------------------------------------------------------------------*/
     
    7070{
    7171        assert(fun);
    72         device_keeper_t *manager = &((uhci_t*)fun->dev->driver_data)->hc.device_manager;
    73 
    74         usb_address_t addr = device_keeper_find(manager, handle);
     72        usb_device_keeper_t *manager = &((uhci_t*)fun->dev->driver_data)->hc.manager;
     73
     74        usb_address_t addr = usb_device_keeper_find(manager, handle);
    7575        if (addr < 0) {
    7676                return addr;
     
    107107};
    108108/*----------------------------------------------------------------------------*/
    109 static ddf_dev_ops_t uhci_hc_ops = {
     109static ddf_dev_ops_t hc_ops = {
    110110        .interfaces[USB_DEV_IFACE] = &usb_iface,
    111         .interfaces[USBHC_DEV_IFACE] = &uhci_hc_iface, /* see iface.h/c */
     111        .interfaces[USBHC_DEV_IFACE] = &hc_iface, /* see iface.h/c */
    112112};
    113113/*----------------------------------------------------------------------------*/
     
    120120{
    121121        assert(fun);
    122         return &((uhci_rh_t*)fun->driver_data)->resource_list;
     122        return &((rh_t*)fun->driver_data)->resource_list;
    123123}
    124124/*----------------------------------------------------------------------------*/
     
    128128};
    129129/*----------------------------------------------------------------------------*/
    130 static ddf_dev_ops_t uhci_rh_ops = {
     130static ddf_dev_ops_t rh_ops = {
    131131        .interfaces[USB_DEV_IFACE] = &usb_iface,
    132132        .interfaces[HW_RES_DEV_IFACE] = &hw_res_iface
     
    167167        CHECK_RET_DEST_FUN_RETURN(ret,
    168168            "Failed(%d) to get I/O addresses:.\n", ret, device->handle);
    169         usb_log_info("I/O regs at 0x%X (size %zu), IRQ %d.\n",
     169        usb_log_debug("I/O regs at 0x%X (size %zu), IRQ %d.\n",
    170170            io_reg_base, io_reg_size, irq);
    171171
     
    175175
    176176        bool interrupts = false;
     177#ifdef CONFIG_USBHC_NO_INTERRUPTS
     178        usb_log_warning("Interrupts disabled in OS config, " \
     179            "falling back to polling.\n");
     180#else
    177181        ret = pci_enable_interrupts(device);
    178182        if (ret != EOK) {
    179                 usb_log_warning(
    180                     "Failed(%d) to enable interrupts, fall back to polling.\n",
    181                     ret);
     183                usb_log_warning("Failed to enable interrupts: %s.\n",
     184                    str_error(ret));
     185                usb_log_info("HW interrupts not available, " \
     186                    "falling back to polling.\n");
    182187        } else {
    183188                usb_log_debug("Hw interrupts enabled.\n");
    184189                interrupts = true;
    185190        }
     191#endif
    186192
    187193        instance->hc_fun = ddf_fun_create(device, fun_exposed, "uhci-hc");
     
    190196            "Failed(%d) to create HC function.\n", ret);
    191197
    192         ret = uhci_hc_init(&instance->hc, instance->hc_fun,
     198        ret = hc_init(&instance->hc, instance->hc_fun,
    193199            (void*)io_reg_base, io_reg_size, interrupts);
    194200        CHECK_RET_DEST_FUN_RETURN(ret, "Failed(%d) to init uhci-hcd.\n", ret);
    195         instance->hc_fun->ops = &uhci_hc_ops;
     201        instance->hc_fun->ops = &hc_ops;
    196202        instance->hc_fun->driver_data = &instance->hc;
    197203        ret = ddf_fun_bind(instance->hc_fun);
     
    208214        if (instance->rh_fun) \
    209215                ddf_fun_destroy(instance->rh_fun); \
    210         uhci_hc_fini(&instance->hc); \
     216        hc_fini(&instance->hc); \
    211217        return ret; \
    212218}
     
    223229            "Failed(%d) to create root hub function.\n", ret);
    224230
    225         ret = uhci_rh_init(&instance->rh, instance->rh_fun,
     231        ret = rh_init(&instance->rh, instance->rh_fun,
    226232            (uintptr_t)instance->hc.registers + 0x10, 4);
    227233        CHECK_RET_FINI_RETURN(ret,
    228234            "Failed(%d) to setup UHCI root hub.\n", ret);
    229235
    230         instance->rh_fun->ops = &uhci_rh_ops;
     236        instance->rh_fun->ops = &rh_ops;
    231237        instance->rh_fun->driver_data = &instance->rh;
    232238        ret = ddf_fun_bind(instance->rh_fun);
  • uspace/drv/uhci-hcd/uhci.h

    r361e61b r55e388a1  
    3838#include <ddf/driver.h>
    3939
    40 #include "uhci_hc.h"
    41 #include "uhci_rh.h"
     40#include "hc.h"
     41#include "root_hub.h"
    4242
    4343typedef struct uhci {
     
    4545        ddf_fun_t *rh_fun;
    4646
    47         uhci_hc_t hc;
    48         uhci_rh_t rh;
     47        hc_t hc;
     48        rh_t rh;
    4949} uhci_t;
    5050
  • uspace/drv/uhci-hcd/utils/malloc32.h

    r361e61b r55e388a1  
    5050static inline uintptr_t addr_to_phys(void *addr)
    5151{
     52        if (addr == NULL)
     53                return 0;
     54
    5255        uintptr_t result;
    5356        int ret = as_get_physical_mapping(addr, &result);
  • uspace/drv/uhci-rhd/main.c

    r361e61b r55e388a1  
    3636#include <device/hw_res.h>
    3737#include <errno.h>
     38#include <str_error.h>
    3839#include <usb_iface.h>
    3940#include <usb/ddfiface.h>
     
    8687        int ret = hc_get_my_registers(device, &io_regs, &io_size);
    8788        if (ret != EOK) {
    88                 usb_log_error("Failed(%d) to get registers from parent hc.",
    89                     ret);
    90         }
    91         usb_log_info("I/O regs at %#X (size %zu).\n", io_regs, io_size);
     89                usb_log_error("Failed to get registers from parent HC: %s.\n",
     90                    str_error(ret));
     91        }
     92        usb_log_debug("I/O regs at %#X (size %zu).\n", io_regs, io_size);
    9293
    9394        uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t));
     
    99100        ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device);
    100101        if (ret != EOK) {
    101                 usb_log_error("Failed(%d) to initialize driver instance.\n", ret);
     102                usb_log_error("Failed to initialize driver instance: %s.\n",
     103                    str_error(ret));
    102104                free(rh);
    103105                return ret;
     
    105107
    106108        device->driver_data = rh;
    107         usb_log_info("Sucessfully initialized driver instance for device:%d.\n",
    108             device->handle);
     109        usb_log_info("Controlling root hub `%s' (%llu).\n",
     110            device->name, device->handle);
    109111        return EOK;
    110112}
     
    129131int main(int argc, char *argv[])
    130132{
    131         usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     133        printf(NAME ": HelenOS UHCI root hub driver.\n");
     134
     135        usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
     136
    132137        return ddf_driver_main(&uhci_rh_driver);
    133138}
  • uspace/drv/uhci-rhd/port.c

    r361e61b r55e388a1  
    256256        assert(usb_hc_connection_is_opened(&port->hc_connection));
    257257
    258         usb_log_info("%s: Detected new device.\n", port->id_string);
     258        usb_log_debug("%s: Detected new device.\n", port->id_string);
    259259
    260260        usb_address_t dev_addr;
     
    270270        }
    271271
    272         usb_log_info("%s: New device has address %d (handle %zu).\n",
    273             port->id_string, dev_addr, port->attached_device);
     272        usb_log_info("New device at port %u, address %d (handle %llu).\n",
     273            port->number, dev_addr, port->attached_device);
    274274
    275275        return EOK;
     
    315315        uhci_port_write_status(port, port_status);
    316316
    317         usb_log_info("%s: %sabled port.\n",
     317        usb_log_debug("%s: %sabled port.\n",
    318318                port->id_string, enabled ? "En" : "Dis");
    319319        return EOK;
  • uspace/drv/usbflbk/main.c

    r361e61b r55e388a1  
    8686int main(int argc, char *argv[])
    8787{
    88         usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     88        usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
    8989
    9090        return usb_driver_main(&usbfallback_driver);
  • uspace/drv/usbhid/hiddev.c

    r361e61b r55e388a1  
    184184 *                     successfuly initialize the structure.
    185185 *
    186  * @sa usb_endpoint_pipe_initialize_from_configuration(),
     186 * @sa usb_pipe_initialize_from_configuration(),
    187187 *     usbhid_dev_get_report_descriptor()
    188188 */
     
    192192        assert(hid_dev != NULL);
    193193       
    194         usb_log_info("Processing descriptors...\n");
     194        usb_log_debug("Processing descriptors...\n");
    195195       
    196196        int rc;
     
    218218        };
    219219       
    220         rc = usb_endpoint_pipe_initialize_from_configuration(
     220        rc = usb_pipe_initialize_from_configuration(
    221221            endpoint_mapping, 1, descriptors, descriptors_size,
    222222            &hid_dev->wire);
     
    359359 * @return Other value inherited from one of functions
    360360 *         usb_device_connection_initialize_from_device(),
    361  *         usb_endpoint_pipe_initialize_default_control(),
    362  *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
     361 *         usb_pipe_initialize_default_control(),
     362 *         usb_pipe_start_session(), usb_pipe_end_session(),
    363363 *         usbhid_dev_process_descriptors().
    364364 *
     
    368368    usb_endpoint_description_t *poll_ep_desc)
    369369{
    370         usb_log_info("Initializing HID device structure.\n");
     370        usb_log_debug("Initializing HID device structure.\n");
    371371       
    372372        if (hid_dev == NULL) {
     
    404404         * Initialize device pipes.
    405405         */
    406         rc = usb_endpoint_pipe_initialize_default_control(&hid_dev->ctrl_pipe,
     406        rc = usb_pipe_initialize_default_control(&hid_dev->ctrl_pipe,
    407407            &hid_dev->wire);
    408408        if (rc != EOK) {
     
    411411                return rc;
    412412        }
    413         rc = usb_endpoint_pipe_probe_default_control(&hid_dev->ctrl_pipe);
     413        rc = usb_pipe_probe_default_control(&hid_dev->ctrl_pipe);
    414414        if (rc != EOK) {
    415415                usb_log_error("Probing default control pipe failed: %s.\n",
     
    430430         * Get descriptors, parse descriptors and save endpoints.
    431431         */
    432         rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe);
     432        rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
    433433        if (rc != EOK) {
    434434                usb_log_error("Failed to start session on the control pipe: %s"
     
    440440        if (rc != EOK) {
    441441                /* TODO: end session?? */
    442                 usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe);
     442                usb_pipe_end_session(&hid_dev->ctrl_pipe);
    443443                usb_log_error("Failed to process descriptors: %s.\n",
    444444                    str_error(rc));
     
    446446        }
    447447       
    448         rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe);
     448        rc = usb_pipe_end_session(&hid_dev->ctrl_pipe);
    449449        if (rc != EOK) {
    450450                usb_log_warning("Failed to start session on the control pipe: "
     
    454454       
    455455        hid_dev->initialized = 1;
    456         usb_log_info("HID device structure initialized.\n");
     456        usb_log_debug("HID device structure initialized.\n");
    457457       
    458458        return EOK;
  • uspace/drv/usbhid/hiddev.h

    r361e61b r55e388a1  
    6868        usb_device_connection_t wire;
    6969        /** USB pipe corresponding to the default Control endpoint. */
    70         usb_endpoint_pipe_t ctrl_pipe;
     70        usb_pipe_t ctrl_pipe;
    7171        /** USB pipe corresponding to the Interrupt In (polling) pipe. */
    72         usb_endpoint_pipe_t poll_pipe;
     72        usb_pipe_t poll_pipe;
    7373       
    7474        /** Polling interval retreived from the Interface descriptor. */
  • uspace/drv/usbhid/hidreq.c

    r361e61b r55e388a1  
    5757 * @retval EINVAL if no HID device is given.
    5858 * @return Other value inherited from one of functions
    59  *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
     59 *         usb_pipe_start_session(), usb_pipe_end_session(),
    6060 *         usb_control_request_set().
    6161 */
     
    7676        int rc, sess_rc;
    7777       
    78         sess_rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe);
     78        sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
    7979        if (sess_rc != EOK) {
    8080                usb_log_warning("Failed to start a session: %s.\n",
     
    9292            USB_HIDREQ_SET_REPORT, value, hid_dev->iface, buffer, buf_size);
    9393
    94         sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe);
     94        sess_rc = usb_pipe_end_session(&hid_dev->ctrl_pipe);
    9595
    9696        if (rc != EOK) {
     
    119119 * @retval EINVAL if no HID device is given.
    120120 * @return Other value inherited from one of functions
    121  *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
     121 *         usb_pipe_start_session(), usb_pipe_end_session(),
    122122 *         usb_control_request_set().
    123123 */
     
    137137        int rc, sess_rc;
    138138       
    139         sess_rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe);
     139        sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
    140140        if (sess_rc != EOK) {
    141141                usb_log_warning("Failed to start a session: %s.\n",
     
    151151            USB_HIDREQ_SET_PROTOCOL, protocol, hid_dev->iface, NULL, 0);
    152152
    153         sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe);
     153        sess_rc = usb_pipe_end_session(&hid_dev->ctrl_pipe);
    154154
    155155        if (rc != EOK) {
     
    179179 * @retval EINVAL if no HID device is given.
    180180 * @return Other value inherited from one of functions
    181  *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
     181 *         usb_pipe_start_session(), usb_pipe_end_session(),
    182182 *         usb_control_request_set().
    183183 */
     
    197197        int rc, sess_rc;
    198198       
    199         sess_rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe);
     199        sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
    200200        if (sess_rc != EOK) {
    201201                usb_log_warning("Failed to start a session: %s.\n",
     
    213213            USB_HIDREQ_SET_IDLE, value, hid_dev->iface, NULL, 0);
    214214
    215         sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe);
     215        sess_rc = usb_pipe_end_session(&hid_dev->ctrl_pipe);
    216216
    217217        if (rc != EOK) {
     
    244244 * @retval EINVAL if no HID device is given.
    245245 * @return Other value inherited from one of functions
    246  *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
     246 *         usb_pipe_start_session(), usb_pipe_end_session(),
    247247 *         usb_control_request_set().
    248248 */
     
    263263        int rc, sess_rc;
    264264       
    265         sess_rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe);
     265        sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
    266266        if (sess_rc != EOK) {
    267267                usb_log_warning("Failed to start a session: %s.\n",
     
    280280            actual_size);
    281281
    282         sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe);
     282        sess_rc = usb_pipe_end_session(&hid_dev->ctrl_pipe);
    283283
    284284        if (rc != EOK) {
     
    307307 * @retval EINVAL if no HID device is given.
    308308 * @return Other value inherited from one of functions
    309  *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
     309 *         usb_pipe_start_session(), usb_pipe_end_session(),
    310310 *         usb_control_request_set().
    311311 */
     
    325325        int rc, sess_rc;
    326326       
    327         sess_rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe);
     327        sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
    328328        if (sess_rc != EOK) {
    329329                usb_log_warning("Failed to start a session: %s.\n",
     
    342342            USB_HIDREQ_GET_PROTOCOL, 0, hid_dev->iface, buffer, 1, &actual_size);
    343343
    344         sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe);
     344        sess_rc = usb_pipe_end_session(&hid_dev->ctrl_pipe);
    345345
    346346        if (rc != EOK) {
     
    378378 * @retval EINVAL if no HID device is given.
    379379 * @return Other value inherited from one of functions
    380  *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
     380 *         usb_pipe_start_session(), usb_pipe_end_session(),
    381381 *         usb_control_request_set().
    382382 */
     
    396396        int rc, sess_rc;
    397397       
    398         sess_rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe);
     398        sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
    399399        if (sess_rc != EOK) {
    400400                usb_log_warning("Failed to start a session: %s.\n",
     
    415415            &actual_size);
    416416
    417         sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe);
     417        sess_rc = usb_pipe_end_session(&hid_dev->ctrl_pipe);
    418418
    419419        if (rc != EOK) {
  • uspace/drv/usbhid/kbddev.c

    r361e61b r55e388a1  
    662662        int rc;
    663663       
    664         usb_log_info("Initializing HID/KBD structure...\n");
     664        usb_log_debug("Initializing HID/KBD structure...\n");
    665665       
    666666        if (kbd_dev == NULL) {
     
    742742       
    743743        kbd_dev->initialized = USBHID_KBD_STATUS_INITIALIZED;
    744         usb_log_info("HID/KBD device structure initialized.\n");
     744        usb_log_debug("HID/KBD device structure initialized.\n");
    745745       
    746746        return EOK;
     
    769769        size_t actual_size;
    770770       
    771         usb_log_info("Polling keyboard...\n");
     771        usb_log_debug("Polling keyboard...\n");
    772772       
    773773        if (!kbd_dev->initialized) {
     
    780780
    781781        while (true) {
    782                 sess_rc = usb_endpoint_pipe_start_session(
     782                sess_rc = usb_pipe_start_session(
    783783                    &kbd_dev->hid_dev->poll_pipe);
    784784                if (sess_rc != EOK) {
     
    788788                }
    789789
    790                 rc = usb_endpoint_pipe_read(&kbd_dev->hid_dev->poll_pipe,
     790                rc = usb_pipe_read(&kbd_dev->hid_dev->poll_pipe,
    791791                    buffer, BOOTP_BUFFER_SIZE, &actual_size);
    792792               
    793                 sess_rc = usb_endpoint_pipe_end_session(
     793                sess_rc = usb_pipe_end_session(
    794794                    &kbd_dev->hid_dev->poll_pipe);
    795795
     
    907907         * Initialize device (get and process descriptors, get address, etc.)
    908908         */
    909         usb_log_info("Initializing USB/HID KBD device...\n");
     909        usb_log_debug("Initializing USB/HID KBD device...\n");
    910910       
    911911        usbhid_kbd_t *kbd_dev = usbhid_kbd_new();
     
    926926        }       
    927927       
    928         usb_log_info("USB/HID KBD device structure initialized.\n");
     928        usb_log_debug("USB/HID KBD device structure initialized.\n");
    929929       
    930930        /*
     
    937937        rc = ddf_fun_bind(kbd_fun);
    938938        if (rc != EOK) {
    939                 usb_log_error("Could not bind DDF function.\n");
     939                usb_log_error("Could not bind DDF function: %s.\n",
     940                    str_error(rc));
    940941                // TODO: Can / should I destroy the DDF function?
    941942                ddf_fun_destroy(kbd_fun);
     
    946947        rc = ddf_fun_add_to_class(kbd_fun, "keyboard");
    947948        if (rc != EOK) {
    948                 usb_log_error("Could not add DDF function to class 'keyboard'"
    949                     "\n");
     949                usb_log_error(
     950                    "Could not add DDF function to class 'keyboard': %s.\n",
     951                    str_error(rc));
    950952                // TODO: Can / should I destroy the DDF function?
    951953                ddf_fun_destroy(kbd_fun);
     
    959961        fid_t fid = fibril_create(usbhid_kbd_fibril, kbd_dev);
    960962        if (fid == 0) {
    961                 usb_log_error("Failed to start fibril for KBD device\n");
     963                usb_log_error("Failed to start fibril for `%s' device.\n",
     964                    dev->name);
    962965                return ENOMEM;
    963966        }
  • uspace/drv/usbhid/main.c

    r361e61b r55e388a1  
    3939#include <usb/debug.h>
    4040#include <errno.h>
     41#include <str_error.h>
    4142
    4243#include "kbddev.h"
     
    6465       
    6566        if (rc != EOK) {
    66                 usb_log_info("Device is not a supported keyboard.\n");
    67                 usb_log_error("Failed to add HID device.\n");
    68                 return EREFUSED;
     67                usb_log_warning("Device is not a supported keyboard.\n");
     68                usb_log_error("Failed to add HID device: %s.\n",
     69                    str_error(rc));
     70                return rc;
    6971        }
    7072       
     73        usb_log_info("Keyboard `%s' ready to use.\n", dev->name);
     74
    7175        return EOK;
    7276}
     
    8993int main(int argc, char *argv[])
    9094{
    91         usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     95        printf(NAME ": HelenOS USB HID driver.\n");
     96
     97        usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
     98
    9299        return ddf_driver_main(&kbd_driver);
    93100}
  • uspace/drv/usbhub/main.c

    r361e61b r55e388a1  
    4242#include "usbhub_private.h"
    4343
    44 
    45 usb_endpoint_description_t hub_status_change_endpoint_description = {
     44/** Hub status-change endpoint description.
     45 *
     46 * For more information see section 11.15.1 of USB 1.1 specification.
     47 */
     48static usb_endpoint_description_t hub_status_change_endpoint_description = {
    4649        .transfer_type = USB_TRANSFER_INTERRUPT,
    4750        .direction = USB_DIRECTION_IN,
     
    5760};
    5861
     62static usb_endpoint_description_t *usb_hub_endpoints[] = {
     63        &hub_status_change_endpoint_description,
     64        NULL
     65};
     66
    5967static usb_driver_t usb_hub_driver = {
    60         .name = "usbhub",
    61         .ops = &usb_hub_driver_ops
     68        .name = NAME,
     69        .ops = &usb_hub_driver_ops,
     70        .endpoints = usb_hub_endpoints
    6271};
    6372
     
    6574int main(int argc, char *argv[])
    6675{
    67         usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    68         usb_log_info("starting hub driver\n");
     76        printf(NAME ": HelenOS USB hub driver.\n");
    6977
     78        usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
    7079       
    71         usb_hub_driver.endpoints = (usb_endpoint_description_t**)
    72                         malloc(2 * sizeof(usb_endpoint_description_t*));
    73         usb_hub_driver.endpoints[0] = &hub_status_change_endpoint_description;
    74         usb_hub_driver.endpoints[1] = NULL;
    75 
    7680        return usb_driver_main(&usb_hub_driver);
    7781}
  • uspace/drv/usbhub/usbhub.c

    r361e61b r55e388a1  
    132132                return opResult;
    133133        }
    134         usb_log_info("setting port count to %d\n",descriptor->ports_count);
     134        usb_log_debug("setting port count to %d\n",descriptor->ports_count);
    135135        hub_info->port_count = descriptor->ports_count;
    136136        hub_info->attached_devs = (usb_hc_attached_device_t*)
     
    157157static int usb_hub_set_configuration(usb_hub_info_t * hub_info){
    158158        //device descriptor
    159         usb_standard_device_descriptor_t std_descriptor;
    160         int opResult = usb_request_get_device_descriptor(
    161                 &hub_info->usb_device->ctrl_pipe,
    162             &std_descriptor);
    163         if(opResult!=EOK){
    164                 usb_log_error("could not get device descriptor, %d\n",opResult);
    165                 return opResult;
    166         }
    167         usb_log_info("hub has %d configurations\n",
    168                         std_descriptor.configuration_count);
    169         if(std_descriptor.configuration_count<1){
     159        usb_standard_device_descriptor_t *std_descriptor
     160            = &hub_info->usb_device->descriptors.device;
     161        usb_log_debug("hub has %d configurations\n",
     162            std_descriptor->configuration_count);
     163        if(std_descriptor->configuration_count<1){
    170164                usb_log_error("THERE ARE NO CONFIGURATIONS AVAILABLE\n");
    171165                //shouldn`t I return?
    172         }
    173 
    174         /* Retrieve full configuration descriptor. */
    175         uint8_t *descriptors = NULL;
    176         size_t descriptors_size = 0;
    177         opResult = usb_request_get_full_configuration_descriptor_alloc(
    178             &hub_info->usb_device->ctrl_pipe, 0,
    179             (void **) &descriptors, &descriptors_size);
    180         if (opResult != EOK) {
    181                 usb_log_error("Could not get configuration descriptor: %s.\n",
    182                     str_error(opResult));
    183                 return opResult;
    184         }
     166                //definitely
     167                return EINVAL;
     168        }
     169
    185170        usb_standard_configuration_descriptor_t *config_descriptor
    186             = (usb_standard_configuration_descriptor_t *) descriptors;
     171            = (usb_standard_configuration_descriptor_t *)
     172            hub_info->usb_device->descriptors.configuration;
    187173
    188174        /* Set configuration. */
    189         opResult = usb_request_set_configuration(&hub_info->usb_device->ctrl_pipe,
     175        int opResult = usb_request_set_configuration(
     176            &hub_info->usb_device->ctrl_pipe,
    190177            config_descriptor->configuration_number);
    191178
     
    197184        usb_log_debug("\tused configuration %d\n",
    198185                        config_descriptor->configuration_number);
    199         free(descriptors);
     186
    200187        return EOK;
    201188}
     
    224211        }
    225212       
    226         usb_endpoint_pipe_start_session(hub_info->control_pipe);
     213        usb_pipe_start_session(hub_info->control_pipe);
    227214        //set hub configuration
    228215        opResult = usb_hub_set_configuration(hub_info);
     
    239226                return opResult;
    240227        }
    241         usb_endpoint_pipe_end_session(hub_info->control_pipe);
     228        usb_pipe_end_session(hub_info->control_pipe);
    242229
    243230
    244231        /// \TODO what is this?
    245         usb_log_debug("adding to ddf");
     232        usb_log_debug("Creating `hub' function.\n");
    246233        ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev,
    247234                        fun_exposed, "hub");
     
    257244        fid_t fid = fibril_create(usb_hub_control_loop, hub_info);
    258245        if (fid == 0) {
    259                 usb_log_error("failed to start monitoring fibril for new hub");
     246                usb_log_error("failed to start monitoring fibril for new hub.\n");
    260247                return ENOMEM;
    261248        }
    262249        fibril_add_ready(fid);
    263         usb_log_debug("hub fibril created");
    264         usb_log_debug("has %d ports ",hub_info->port_count);
     250        usb_log_debug("Hub fibril created.\n");
     251
     252        usb_log_info("Controlling hub `%s' (%d ports).\n",
     253            hub_info->usb_device->ddf_dev->name, hub_info->port_count);
    265254        return EOK;
    266255}
     
    301290        //if this hub already uses default address, it cannot request it once more
    302291        if(hub->is_default_address_used) return;
    303         usb_log_info("some connection changed\n");
     292        usb_log_debug("some connection changed\n");
    304293        assert(hub->control_pipe->hc_phone);
    305294        int opResult = usb_hub_clear_port_feature(hub->control_pipe,
     
    321310        //reset port
    322311        usb_hub_set_reset_port_request(&request, port);
    323         opResult = usb_endpoint_pipe_control_write(
     312        opResult = usb_pipe_control_write(
    324313                        hub->control_pipe,
    325314                        &request,sizeof(usb_device_request_setup_packet_t),
     
    344333
    345334        int opResult;
    346         usb_log_info("finalizing add device\n");
     335        usb_log_debug("finalizing add device\n");
    347336        opResult = usb_hub_clear_port_feature(hub->control_pipe,
    348337            port, USB_HUB_FEATURE_C_PORT_RESET);
     
    354343        }
    355344        //create connection to device
    356         usb_endpoint_pipe_t new_device_pipe;
     345        usb_pipe_t new_device_pipe;
    357346        usb_device_connection_t new_device_connection;
    358347        usb_device_connection_initialize_on_default_address(
     
    360349                        &hub->connection
    361350                        );
    362         usb_endpoint_pipe_initialize_default_control(
     351        usb_pipe_initialize_default_control(
    363352                        &new_device_pipe,
    364353                        &new_device_connection);
    365         usb_endpoint_pipe_probe_default_control(&new_device_pipe);
     354        usb_pipe_probe_default_control(&new_device_pipe);
    366355
    367356        /* Request address from host controller. */
     
    376365                return;
    377366        }
    378         usb_log_info("setting new address %d\n",new_device_address);
     367        usb_log_debug("setting new address %d\n",new_device_address);
    379368        //opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
    380369        //    new_device_address);
    381         usb_endpoint_pipe_start_session(&new_device_pipe);
     370        usb_pipe_start_session(&new_device_pipe);
    382371        opResult = usb_request_set_address(&new_device_pipe,new_device_address);
    383         usb_endpoint_pipe_end_session(&new_device_pipe);
     372        usb_pipe_end_session(&new_device_pipe);
    384373        if (opResult != EOK) {
    385374                usb_log_error("could not set address for new device %d\n",opResult);
     
    416405                return;
    417406        }
    418         usb_log_info("new device address %d, handle %zu\n",
     407        usb_log_info("Detected new device on `%s' (port %d), " \
     408            "address %d (handle %llu).\n",
     409            hub->usb_device->ddf_dev->name, (int) port,
    419410            new_device_address, child_handle);
    420 
    421411}
    422412
     
    488478        usb_log_debug("interrupt at port %d\n", port);
    489479        //determine type of change
    490         usb_endpoint_pipe_t *pipe = hub->control_pipe;
     480        usb_pipe_t *pipe = hub->control_pipe;
    491481       
    492482        int opResult;
     
    499489        //endpoint 0
    500490
    501         opResult = usb_endpoint_pipe_control_read(
     491        opResult = usb_pipe_control_read(
    502492                        pipe,
    503493                        &request, sizeof(usb_device_request_setup_packet_t),
     
    515505        if (usb_port_connect_change(&status)) {
    516506                if (usb_port_dev_connected(&status)) {
    517                         usb_log_info("some connection changed\n");
     507                        usb_log_debug("some connection changed\n");
    518508                        usb_hub_init_add_device(hub, port, usb_port_speed(&status));
    519509                } else {
     
    527517                        usb_hub_over_current(hub,port);
    528518                }else{
    529                         usb_log_info("over current condition was auto-resolved on port %d\n",
     519                        usb_log_debug("over current condition was auto-resolved on port %d\n",
    530520                                        port);
    531521                }
     
    533523        //port reset
    534524        if (usb_port_reset_completed(&status)) {
    535                 usb_log_info("port reset complete");
     525                usb_log_debug("port reset complete\n");
    536526                if (usb_port_enabled(&status)) {
    537527                        usb_hub_finalize_add_device(hub, port, usb_port_speed(&status));
     
    560550int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){
    561551        int opResult;
    562         opResult = usb_endpoint_pipe_start_session(
     552        opResult = usb_pipe_start_session(
    563553                        hub_info->status_change_pipe);
    564554        if(opResult != EOK){
     
    578568         * Send the request.
    579569         */
    580         opResult = usb_endpoint_pipe_read(
     570        opResult = usb_pipe_read(
    581571                        hub_info->status_change_pipe,
    582572                        change_bitmap, byte_length, &actual_size
     
    586576                free(change_bitmap);
    587577                usb_log_warning("something went wrong while getting status of hub\n");
    588                 usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
     578                usb_pipe_end_session(hub_info->status_change_pipe);
    589579                return opResult;
    590580        }
    591581        unsigned int port;
    592         opResult = usb_endpoint_pipe_start_session(hub_info->control_pipe);
     582        opResult = usb_pipe_start_session(hub_info->control_pipe);
    593583        if(opResult!=EOK){
    594584                usb_log_error("could not start control pipe session %d\n", opResult);
    595                 usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
     585                usb_pipe_end_session(hub_info->status_change_pipe);
    596586                return opResult;
    597587        }
     
    600590                usb_log_error("could not start host controller session %d\n",
    601591                                opResult);
    602                 usb_endpoint_pipe_end_session(hub_info->control_pipe);
    603                 usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
     592                usb_pipe_end_session(hub_info->control_pipe);
     593                usb_pipe_end_session(hub_info->status_change_pipe);
    604594                return opResult;
    605595        }
     
    615605        }
    616606        usb_hc_connection_close(&hub_info->connection);
    617         usb_endpoint_pipe_end_session(hub_info->control_pipe);
    618         usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
     607        usb_pipe_end_session(hub_info->control_pipe);
     608        usb_pipe_end_session(hub_info->status_change_pipe);
    619609        free(change_bitmap);
    620610        return EOK;
  • uspace/drv/usbhub/usbhub.h

    r361e61b r55e388a1  
    4848
    4949
    50 /** Hub status-change endpoint description
    51  *
    52  * For more see usb hub specification in 11.15.1 of
    53  */
    54 extern usb_endpoint_description_t hub_status_change_endpoint_description;
    55 
    56 
    57 
    58 /* Hub endpoints. */
    59 /*typedef struct {
    60         usb_endpoint_pipe_t control;
    61         usb_endpoint_pipe_t status_change;
    62 } usb_hub_endpoints_t;
    63 */
    64 
    65 
    6650/** Information about attached hub. */
    6751typedef struct {
     
    8872         * searched again and again for the 'right pipe'.
    8973         */
    90         usb_endpoint_pipe_t * status_change_pipe;
     74        usb_pipe_t * status_change_pipe;
    9175
    9276        /** convenience pointer to control pipe
     
    9680         * searched again and again for the 'right pipe'.
    9781         */
    98         usb_endpoint_pipe_t * control_pipe;
     82        usb_pipe_t * control_pipe;
    9983
    10084        /** generic usb device data*/
  • uspace/drv/usbhub/usbhub_private.h

    r361e61b r55e388a1  
    9595 * @return Operation result
    9696 */
    97 static inline int usb_hub_clear_port_feature(usb_endpoint_pipe_t *pipe,
     97static inline int usb_hub_clear_port_feature(usb_pipe_t *pipe,
    9898    int port_index,
    9999    usb_hub_class_feature_t feature) {
     
    106106        };
    107107        clear_request.value = feature;
    108         return usb_endpoint_pipe_control_write(pipe, &clear_request,
     108        return usb_pipe_control_write(pipe, &clear_request,
    109109            sizeof(clear_request), NULL, 0);
    110110}
  • uspace/drv/usbmid/main.c

    r361e61b r55e388a1  
    6161        int rc;
    6262
    63         rc = usb_endpoint_pipe_start_session(&dev->ctrl_pipe);
     63        rc = usb_pipe_start_session(&dev->ctrl_pipe);
    6464        if (rc != EOK) {
    6565                usb_log_error("Failed to start session on control pipe: %s.\n",
     
    7070        bool accept = usbmid_explore_device(dev);
    7171
    72         rc = usb_endpoint_pipe_end_session(&dev->ctrl_pipe);
     72        rc = usb_pipe_end_session(&dev->ctrl_pipe);
    7373        if (rc != EOK) {
    7474                usb_log_warning("Failed to end session on control pipe: %s.\n",
     
    106106        printf(NAME ": USB multi interface device driver.\n");
    107107
    108         usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
     108        usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
    109109        return ddf_driver_main(&mid_driver);
    110110}
  • uspace/drv/usbmid/usbmid.c

    r361e61b r55e388a1  
    108108        }
    109109
    110         rc = usb_endpoint_pipe_initialize_default_control(&mid->ctrl_pipe,
     110        rc = usb_pipe_initialize_default_control(&mid->ctrl_pipe,
    111111            &mid->wire);
    112112        if (rc != EOK) {
     
    116116                return NULL;
    117117        }
    118         rc = usb_endpoint_pipe_probe_default_control(&mid->ctrl_pipe);
     118        rc = usb_pipe_probe_default_control(&mid->ctrl_pipe);
    119119        if (rc != EOK) {
    120120                usb_log_error("Probing default control pipe failed: %s.\n",
  • uspace/drv/usbmid/usbmid.h

    r361e61b r55e388a1  
    5252        usb_device_connection_t wire;
    5353        /** Default control pipe. */
    54         usb_endpoint_pipe_t ctrl_pipe;
     54        usb_pipe_t ctrl_pipe;
    5555} usbmid_device_t;
    5656
  • uspace/drv/usbmouse/init.c

    r361e61b r55e388a1  
    126126       
    127127        /* Open the control pipe. */
    128         rc = usb_endpoint_pipe_start_session(&dev->ctrl_pipe);
     128        rc = usb_pipe_start_session(&dev->ctrl_pipe);
    129129        if (rc != EOK) {
    130130                goto leave;
     
    141141       
    142142        /* Close the control pipe (ignore errors). */
    143         usb_endpoint_pipe_end_session(&dev->ctrl_pipe);
     143        usb_pipe_end_session(&dev->ctrl_pipe);
    144144
    145145
  • uspace/drv/usbmouse/main.c

    r361e61b r55e388a1  
    9090int main(int argc, char *argv[])
    9191{
    92         usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     92        usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
    9393
    9494        return usb_driver_main(&mouse_driver);
  • uspace/drv/vhc/hcd.c

    r361e61b r55e388a1  
    122122        //sleep(5);
    123123
    124         usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     124        usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
    125125
    126126        printf(NAME ": virtual USB host controller driver.\n");
  • uspace/lib/usb/include/usb/debug.h

    r361e61b r55e388a1  
    7979} usb_log_level_t;
    8080
     81/** Default log level. */
     82#define USB_LOG_LEVEL_DEFAULT USB_LOG_LEVEL_DEBUG
     83
    8184
    8285void usb_log_enable(usb_log_level_t, const char *);
  • uspace/lib/usb/include/usb/devdrv.h

    r361e61b r55e388a1  
    3838#include <usb/pipes.h>
    3939
     40/** Descriptors for USB device. */
     41typedef struct {
     42        /** Standard device descriptor. */
     43        usb_standard_device_descriptor_t device;
     44        /** Full configuration descriptor of current configuration. */
     45        uint8_t *configuration;
     46        size_t configuration_size;
     47} usb_device_descriptors_t;
     48
    4049/** USB device structure. */
    4150typedef struct {
    4251        /** The default control pipe. */
    43         usb_endpoint_pipe_t ctrl_pipe;
     52        usb_pipe_t ctrl_pipe;
    4453        /** Other endpoint pipes.
    4554         * This is an array of other endpoint pipes in the same order as
     
    5261         */
    5362        int interface_no;
     63
     64        /** Some useful descriptors. */
     65        usb_device_descriptors_t descriptors;
     66
    5467        /** Generic DDF device backing this one. */
    5568        ddf_dev_t *ddf_dev;
  • uspace/lib/usb/include/usb/host/batch.h

    r361e61b r55e388a1  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup drvusbuhcihc
     28/** @addtogroup libusb
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver USB transaction structure
     32 * USB transfer transaction structures.
    3333 */
    3434#ifndef LIBUSB_HOST_BATCH_H
     
    4040#include <usb/usb.h>
    4141
    42 typedef struct batch
    43 {
     42typedef struct usb_transfer_batch usb_transfer_batch_t;
     43struct usb_transfer_batch {
    4444        link_t link;
    4545        usb_target_t target;
     
    5656        size_t max_packet_size;
    5757        size_t transfered_size;
    58         void (*next_step)(struct batch*);
     58        void (*next_step)(usb_transfer_batch_t *);
    5959        int error;
    6060        ddf_fun_t *fun;
    6161        void *arg;
    6262        void *private_data;
    63 } batch_t;
     63};
    6464
    65 void batch_init(
    66     batch_t *instance,
     65void usb_transfer_batch_init(
     66    usb_transfer_batch_t *instance,
    6767    usb_target_t target,
    6868    usb_transfer_type_t transfer_type,
     
    8181);
    8282
    83 static inline batch_t *batch_from_link(link_t *link_ptr)
     83static inline usb_transfer_batch_t *usb_transfer_batch_from_link(link_t *l)
    8484{
    85         assert(link_ptr);
    86         return list_get_instance(link_ptr, batch_t, link);
     85        assert(l);
     86        return list_get_instance(l, usb_transfer_batch_t, link);
    8787}
    8888
    89 void batch_call_in(batch_t *instance);
    90 void batch_call_out(batch_t *instance);
    91 void batch_finish(batch_t *instance, int error);
     89void usb_transfer_batch_call_in(usb_transfer_batch_t *instance);
     90void usb_transfer_batch_call_out(usb_transfer_batch_t *instance);
     91void usb_transfer_batch_finish(usb_transfer_batch_t *instance, int error);
     92
    9293#endif
    9394/**
  • uspace/lib/usb/include/usb/host/device_keeper.h

    r361e61b r55e388a1  
    3131 */
    3232/** @file
    33  * @brief UHCI driver
     33 * Device keeper structure and functions.
     34 *
     35 * Typical USB host controller needs to keep track of various settings for
     36 * each device that is connected to it.
     37 * State of toggle bit, device speed etc. etc.
     38 * This structure shall simplify the management.
    3439 */
    3540#ifndef LIBUSB_HOST_DEVICE_KEEPER_H
     
    3944#include <usb/usb.h>
    4045
     46/** Number of USB address for array dimensions. */
    4147#define USB_ADDRESS_COUNT (USB11_ADDRESS_MAX + 1)
    4248
     49/** Information about attached USB device. */
    4350struct usb_device_info {
    4451        usb_speed_t speed;
     
    4855};
    4956
    50 typedef struct device_keeper {
     57/** Host controller device keeper.
     58 * You shall not access members directly but only using functions below.
     59 */
     60typedef struct {
    5161        struct usb_device_info devices[USB_ADDRESS_COUNT];
    5262        fibril_mutex_t guard;
    5363        fibril_condvar_t default_address_occupied;
    5464        usb_address_t last_address;
    55 } device_keeper_t;
     65} usb_device_keeper_t;
    5666
    57 void device_keeper_init(device_keeper_t *instance);
     67void usb_device_keeper_init(usb_device_keeper_t *instance);
    5868
    59 void device_keeper_reserve_default(
    60     device_keeper_t *instance, usb_speed_t speed);
     69void usb_device_keeper_reserve_default_address(usb_device_keeper_t *instance,
     70    usb_speed_t speed);
    6171
    62 void device_keeper_release_default(device_keeper_t *instance);
     72void usb_device_keeper_release_default_address(usb_device_keeper_t *instance);
    6373
    64 void device_keeper_reset_if_need(
    65     device_keeper_t *instance, usb_target_t target,
    66     const unsigned char *setup_data);
     74void usb_device_keeper_reset_if_need(usb_device_keeper_t *instance,
     75    usb_target_t target,
     76    const uint8_t *setup_data);
    6777
    68 int device_keeper_get_toggle(
    69     device_keeper_t *instance, usb_target_t target, usb_direction_t direction);
     78int usb_device_keeper_get_toggle(usb_device_keeper_t *instance,
     79    usb_target_t target, usb_direction_t direction);
    7080
    71 int device_keeper_set_toggle(device_keeper_t *instance,
     81int usb_device_keeper_set_toggle(usb_device_keeper_t *instance,
    7282    usb_target_t target, usb_direction_t direction, bool toggle);
    7383
    74 usb_address_t device_keeper_request(
    75     device_keeper_t *instance, usb_speed_t speed);
     84usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance,
     85    usb_speed_t speed);
    7686
    77 void device_keeper_bind(
    78     device_keeper_t *instance, usb_address_t address, devman_handle_t handle);
     87void usb_device_keeper_bind(usb_device_keeper_t *instance,
     88    usb_address_t address, devman_handle_t handle);
    7989
    80 void device_keeper_release(device_keeper_t *instance, usb_address_t address);
     90void usb_device_keeper_release(usb_device_keeper_t *instance,
     91    usb_address_t address);
    8192
    82 usb_address_t device_keeper_find(
    83     device_keeper_t *instance, devman_handle_t handle);
     93usb_address_t usb_device_keeper_find(usb_device_keeper_t *instance,
     94    devman_handle_t handle);
    8495
    85 usb_speed_t device_keeper_speed(
    86     device_keeper_t *instance, usb_address_t address);
     96usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance,
     97    usb_address_t address);
     98
    8799#endif
    88100/**
  • uspace/lib/usb/include/usb/pipes.h

    r361e61b r55e388a1  
    8080         */
    8181        int hc_phone;
    82 } usb_endpoint_pipe_t;
     82} usb_pipe_t;
    8383
    8484
     
    102102typedef struct {
    103103        /** Endpoint pipe. */
    104         usb_endpoint_pipe_t *pipe;
     104        usb_pipe_t *pipe;
    105105        /** Endpoint description. */
    106106        const usb_endpoint_description_t *description;
     
    125125usb_address_t usb_device_get_assigned_address(devman_handle_t);
    126126
    127 int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *,
    128     usb_device_connection_t *,
     127int usb_pipe_initialize(usb_pipe_t *, usb_device_connection_t *,
    129128    usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t);
    130 int usb_endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *,
     129int usb_pipe_initialize_default_control(usb_pipe_t *,
    131130    usb_device_connection_t *);
    132 int usb_endpoint_pipe_probe_default_control(usb_endpoint_pipe_t *);
    133 int usb_endpoint_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
     131int usb_pipe_probe_default_control(usb_pipe_t *);
     132int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
    134133    size_t, uint8_t *, size_t, usb_device_connection_t *);
    135 int usb_endpoint_pipe_register(usb_endpoint_pipe_t *, unsigned int,
    136     usb_hc_connection_t *);
    137 int usb_endpoint_pipe_unregister(usb_endpoint_pipe_t *, usb_hc_connection_t *);
     134int usb_pipe_register(usb_pipe_t *, unsigned int, usb_hc_connection_t *);
     135int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *);
    138136
    139 int usb_endpoint_pipe_start_session(usb_endpoint_pipe_t *);
    140 int usb_endpoint_pipe_end_session(usb_endpoint_pipe_t *);
    141 bool usb_endpoint_pipe_is_session_started(usb_endpoint_pipe_t *);
     137int usb_pipe_start_session(usb_pipe_t *);
     138int usb_pipe_end_session(usb_pipe_t *);
     139bool usb_pipe_is_session_started(usb_pipe_t *);
    142140
    143 int usb_endpoint_pipe_read(usb_endpoint_pipe_t *, void *, size_t, size_t *);
    144 int usb_endpoint_pipe_write(usb_endpoint_pipe_t *, void *, size_t);
     141int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
     142int usb_pipe_write(usb_pipe_t *, void *, size_t);
    145143
    146 int usb_endpoint_pipe_control_read(usb_endpoint_pipe_t *, void *, size_t,
     144int usb_pipe_control_read(usb_pipe_t *, void *, size_t,
    147145    void *, size_t, size_t *);
    148 int usb_endpoint_pipe_control_write(usb_endpoint_pipe_t *, void *, size_t,
     146int usb_pipe_control_write(usb_pipe_t *, void *, size_t,
    149147    void *, size_t);
    150148
  • uspace/lib/usb/include/usb/recognise.h

    r361e61b r55e388a1  
    4848    const usb_standard_interface_descriptor_t *, match_id_list_t *);
    4949
    50 int usb_device_create_match_ids(usb_endpoint_pipe_t *, match_id_list_t *);
     50int usb_device_create_match_ids(usb_pipe_t *, match_id_list_t *);
    5151
    5252int usb_device_register_child_in_devman(usb_address_t, devman_handle_t,
  • uspace/lib/usb/include/usb/request.h

    r361e61b r55e388a1  
    8686} __attribute__ ((packed)) usb_device_request_setup_packet_t;
    8787
    88 int usb_control_request_set(usb_endpoint_pipe_t *,
     88int usb_control_request_set(usb_pipe_t *,
    8989    usb_request_type_t, usb_request_recipient_t, uint8_t,
    9090    uint16_t, uint16_t, void *, size_t);
    9191
    92 int usb_control_request_get(usb_endpoint_pipe_t *,
     92int usb_control_request_get(usb_pipe_t *,
    9393    usb_request_type_t, usb_request_recipient_t, uint8_t,
    9494    uint16_t, uint16_t, void *, size_t, size_t *);
    9595
    96 int usb_request_get_status(usb_endpoint_pipe_t *, usb_request_recipient_t,
     96int usb_request_get_status(usb_pipe_t *, usb_request_recipient_t,
    9797    uint16_t, uint16_t *);
    98 int usb_request_clear_feature(usb_endpoint_pipe_t *, usb_request_type_t,
     98int usb_request_clear_feature(usb_pipe_t *, usb_request_type_t,
    9999    usb_request_recipient_t, uint16_t, uint16_t);
    100 int usb_request_set_feature(usb_endpoint_pipe_t *, usb_request_type_t,
     100int usb_request_set_feature(usb_pipe_t *, usb_request_type_t,
    101101    usb_request_recipient_t, uint16_t, uint16_t);
    102 int usb_request_set_address(usb_endpoint_pipe_t *, usb_address_t);
    103 int usb_request_get_descriptor(usb_endpoint_pipe_t *, usb_request_type_t,
     102int usb_request_set_address(usb_pipe_t *, usb_address_t);
     103int usb_request_get_descriptor(usb_pipe_t *, usb_request_type_t,
    104104    usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t,
    105105    size_t *);
    106 int usb_request_get_descriptor_alloc(usb_endpoint_pipe_t *, usb_request_type_t,
     106int usb_request_get_descriptor_alloc(usb_pipe_t *, usb_request_type_t,
    107107    usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void **, size_t *);
    108 int usb_request_get_device_descriptor(usb_endpoint_pipe_t *,
     108int usb_request_get_device_descriptor(usb_pipe_t *,
    109109    usb_standard_device_descriptor_t *);
    110 int usb_request_get_bare_configuration_descriptor(usb_endpoint_pipe_t *, int,
     110int usb_request_get_bare_configuration_descriptor(usb_pipe_t *, int,
    111111    usb_standard_configuration_descriptor_t *);
    112 int usb_request_get_full_configuration_descriptor(usb_endpoint_pipe_t *, int,
     112int usb_request_get_full_configuration_descriptor(usb_pipe_t *, int,
    113113    void *, size_t, size_t *);
    114 int usb_request_get_full_configuration_descriptor_alloc(usb_endpoint_pipe_t *,
     114int usb_request_get_full_configuration_descriptor_alloc(usb_pipe_t *,
    115115    int, void **, size_t *);
    116 int usb_request_set_descriptor(usb_endpoint_pipe_t *, usb_request_type_t,
     116int usb_request_set_descriptor(usb_pipe_t *, usb_request_type_t,
    117117    usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t);
    118 int usb_request_get_configuration(usb_endpoint_pipe_t *, uint8_t *);
    119 int usb_request_set_configuration(usb_endpoint_pipe_t *, uint8_t);
    120 int usb_request_get_interface(usb_endpoint_pipe_t *, uint8_t, uint8_t *);
    121 int usb_request_set_interface(usb_endpoint_pipe_t *, uint8_t, uint8_t);
     118int usb_request_get_configuration(usb_pipe_t *, uint8_t *);
     119int usb_request_set_configuration(usb_pipe_t *, uint8_t);
     120int usb_request_get_interface(usb_pipe_t *, uint8_t, uint8_t *);
     121int usb_request_set_interface(usb_pipe_t *, uint8_t, uint8_t);
    122122
    123 int usb_request_get_supported_languages(usb_endpoint_pipe_t *,
     123int usb_request_get_supported_languages(usb_pipe_t *,
    124124    l18_win_locales_t **, size_t *);
    125 int usb_request_get_string(usb_endpoint_pipe_t *, size_t, l18_win_locales_t,
     125int usb_request_get_string(usb_pipe_t *, size_t, l18_win_locales_t,
    126126    char **);
    127127
  • uspace/lib/usb/include/usb/usb.h

    r361e61b r55e388a1  
    6161
    6262const char * usb_str_transfer_type(usb_transfer_type_t t);
     63const char * usb_str_transfer_type_short(usb_transfer_type_t t);
    6364
    6465/** USB data transfer direction. */
     
    7879        USB_SPEED_HIGH
    7980} usb_speed_t;
     81
     82const char *usb_str_speed(usb_speed_t);
     83
    8084
    8185/** USB request type target. */
  • uspace/lib/usb/src/devdrv.c

    r361e61b r55e388a1  
    126126
    127127        for (i = 0; i < pipe_count; i++) {
    128                 dev->pipes[i].pipe = malloc(sizeof(usb_endpoint_pipe_t));
     128                dev->pipes[i].pipe = malloc(sizeof(usb_pipe_t));
    129129                if (dev->pipes[i].pipe == NULL) {
    130130                        usb_log_oom(dev->ddf_dev);
     
    137137        }
    138138
    139         void *config_descriptor;
    140         size_t config_descriptor_size;
    141         rc = usb_request_get_full_configuration_descriptor_alloc(
    142             &dev->ctrl_pipe, 0, &config_descriptor, &config_descriptor_size);
    143         if (rc != EOK) {
    144                 usb_log_error("Failed retrieving configuration of `%s': %s.\n",
    145                     dev->ddf_dev->name, str_error(rc));
    146                 goto rollback;
    147         }
    148 
    149         rc = usb_endpoint_pipe_initialize_from_configuration(dev->pipes,
    150            pipe_count, config_descriptor, config_descriptor_size, &dev->wire);
     139        rc = usb_pipe_initialize_from_configuration(dev->pipes, pipe_count,
     140            dev->descriptors.configuration, dev->descriptors.configuration_size,
     141            &dev->wire);
    151142        if (rc != EOK) {
    152143                usb_log_error("Failed initializing USB endpoints: %s.\n",
     
    172163        for (i = 0; i < pipe_count; i++) {
    173164                if (dev->pipes[i].present) {
    174                         rc = usb_endpoint_pipe_register(dev->pipes[i].pipe,
     165                        rc = usb_pipe_register(dev->pipes[i].pipe,
    175166                            dev->pipes[i].descriptor->poll_interval,
    176167                            &hc_conn);
     
    219210        }
    220211
    221         rc = usb_endpoint_pipe_initialize_default_control(&dev->ctrl_pipe,
     212        rc = usb_pipe_initialize_default_control(&dev->ctrl_pipe,
    222213            &dev->wire);
    223214        if (rc != EOK) {
     
    228219        }
    229220
    230         rc = usb_endpoint_pipe_probe_default_control(&dev->ctrl_pipe);
     221        rc = usb_pipe_probe_default_control(&dev->ctrl_pipe);
    231222        if (rc != EOK) {
    232223                usb_log_error(
     
    237228
    238229        /*
    239          * Initialization of other pipes requires open session on
    240          * default control pipe.
     230         * For further actions, we need open session on default control pipe.
    241231         */
    242         rc = usb_endpoint_pipe_start_session(&dev->ctrl_pipe);
     232        rc = usb_pipe_start_session(&dev->ctrl_pipe);
    243233        if (rc != EOK) {
    244234                usb_log_error("Failed to start an IPC session: %s.\n",
    245235                    str_error(rc));
     236                return rc;
     237        }
     238
     239        /* Get the device descriptor. */
     240        rc = usb_request_get_device_descriptor(&dev->ctrl_pipe,
     241            &dev->descriptors.device);
     242        if (rc != EOK) {
     243                usb_log_error("Failed to retrieve device descriptor: %s.\n",
     244                    str_error(rc));
     245                return rc;
     246        }
     247
     248        /* Get the full configuration descriptor. */
     249        rc = usb_request_get_full_configuration_descriptor_alloc(
     250            &dev->ctrl_pipe, 0, (void **) &dev->descriptors.configuration,
     251            &dev->descriptors.configuration_size);
     252        if (rc != EOK) {
     253                usb_log_error("Failed retrieving configuration descriptor: %s.\n",
     254                    dev->ddf_dev->name, str_error(rc));
    246255                return rc;
    247256        }
     
    252261
    253262        /* No checking here. */
    254         usb_endpoint_pipe_end_session(&dev->ctrl_pipe);
     263        usb_pipe_end_session(&dev->ctrl_pipe);
     264
     265        /* Rollback actions. */
     266        if (rc != EOK) {
     267                if (dev->descriptors.configuration != NULL) {
     268                        free(dev->descriptors.configuration);
     269                }
     270        }
    255271
    256272        return rc;
     
    283299        dev->ddf_dev->driver_data = dev;
    284300        dev->driver_data = NULL;
     301        dev->descriptors.configuration = NULL;
    285302
    286303        rc = initialize_pipes(dev);
  • uspace/lib/usb/src/devpoll.c

    r361e61b r55e388a1  
    6464        assert(polling_data);
    6565
    66         usb_endpoint_pipe_t *pipe
     66        usb_pipe_t *pipe
    6767            = polling_data->dev->pipes[polling_data->pipe_index].pipe;
    6868
     
    7171                int rc;
    7272
    73                 rc = usb_endpoint_pipe_start_session(pipe);
     73                rc = usb_pipe_start_session(pipe);
    7474                if (rc != EOK) {
    7575                        failed_attempts++;
     
    7878
    7979                size_t actual_size;
    80                 rc = usb_endpoint_pipe_read(pipe, polling_data->buffer,
     80                rc = usb_pipe_read(pipe, polling_data->buffer,
    8181                    polling_data->request_size, &actual_size);
    8282
    8383                /* Quit the session regardless of errors. */
    84                 usb_endpoint_pipe_end_session(pipe);
     84                usb_pipe_end_session(pipe);
    8585
    8686                if (rc != EOK) {
  • uspace/lib/usb/src/hidparser.c

    r361e61b r55e388a1  
    8484{
    8585   if(parser == NULL) {
    86         return -1;
     86        return EINVAL;
    8787   }
    8888
     
    115115        size_t offset_output=0;
    116116        size_t offset_feature=0;
     117
     118        if(usb_hid_parser_init(parser) != EOK) {
     119                return EINVAL;
     120        }
    117121       
    118122
     
    128132
    129133                        if((i+USB_HID_ITEM_SIZE(data[i]))>= size){
    130                                 return -1; // TODO ERROR CODE
     134                                return EINVAL; // TODO ERROR CODE
    131135                        }
    132136                       
     
    530534void usb_hid_descriptor_print(usb_hid_report_parser_t *parser)
    531535{
     536        if(parser == NULL) {
     537                return;
     538        }
     539       
    532540        usb_log_debug("INPUT:\n");
    533541        usb_hid_descriptor_print_list(&parser->input);
     
    615623        size_t j=0;
    616624
     625        if(parser == NULL) {
     626                return EINVAL;
     627        }
     628
     629       
    617630        // get the size of result keycodes array
    618631        usb_hid_report_path_t path;
     
    737750int usb_hid_report_input_length(const usb_hid_report_parser_t *parser,
    738751        const usb_hid_report_path_t *path)
    739 {
     752{       
    740753        int ret = 0;
    741754        link_t *item;
    742755        usb_hid_report_item_t *report_item;
    743756
     757        if(parser == NULL) {
     758                return EINVAL;
     759        }
     760       
    744761        item = (&parser->input)->next;
    745762        while(&parser->input != item) {
  • uspace/lib/usb/src/host/batch.c

    r361e61b r55e388a1  
    3030 */
    3131/** @file
    32  * @brief OHCI driver USB transaction structure
     32 * USB transfer transaction structures (implementation).
    3333 */
    3434#include <errno.h>
     
    3939#include <usb/host/batch.h>
    4040
    41 void batch_init(
    42     batch_t *instance,
     41void usb_transfer_batch_init(
     42    usb_transfer_batch_t *instance,
    4343    usb_target_t target,
    4444    usb_transfer_type_t transfer_type,
     
    8585 *
    8686 */
    87 void batch_finish(batch_t *instance, int error)
     87void usb_transfer_batch_finish(usb_transfer_batch_t *instance, int error)
    8888{
    8989        assert(instance);
     
    9898 * parameters.
    9999 */
    100 void batch_call_in(batch_t *instance)
     100void usb_transfer_batch_call_in(usb_transfer_batch_t *instance)
    101101{
    102102        assert(instance);
     
    107107            instance->buffer_size);
    108108
    109         int err = instance->error;
    110         usb_log_debug("Batch(%p) callback IN(type:%d): %s(%d), %zu.\n",
    111             instance, instance->transfer_type, str_error(err), err,
    112             instance->transfered_size);
     109        usb_log_debug("Batch %p done (T%d.%d, %s %s in, %zuB): %s (%d).\n",
     110            instance,
     111            instance->target.address, instance->target.endpoint,
     112            usb_str_speed(instance->speed),
     113            usb_str_transfer_type_short(instance->transfer_type),
     114            instance->transfered_size,
     115            str_error(instance->error), instance->error);
    113116
    114         instance->callback_in(
    115             instance->fun, err, instance->transfered_size, instance->arg);
     117        instance->callback_in(instance->fun, instance->error,
     118            instance->transfered_size, instance->arg);
    116119}
    117120/*----------------------------------------------------------------------------*/
     
    120123 * @param[in] instance Batch structure to use.
    121124 */
    122 void batch_call_out(batch_t *instance)
     125void usb_transfer_batch_call_out(usb_transfer_batch_t *instance)
    123126{
    124127        assert(instance);
    125128        assert(instance->callback_out);
    126129
    127         int err = instance->error;
    128         usb_log_debug("Batch(%p) callback OUT(type:%d): %s(%d).\n",
    129             instance, instance->transfer_type, str_error(err), err);
     130        usb_log_debug("Batch %p done (T%d.%d, %s %s out): %s (%d).\n",
     131            instance,
     132            instance->target.address, instance->target.endpoint,
     133            usb_str_speed(instance->speed),
     134            usb_str_transfer_type_short(instance->transfer_type),
     135            str_error(instance->error), instance->error);
     136
    130137        instance->callback_out(instance->fun,
    131             err, instance->arg);
     138            instance->error, instance->arg);
    132139}
    133140/**
  • uspace/lib/usb/src/host/device_keeper.c

    r361e61b r55e388a1  
    3131 */
    3232/** @file
    33  * @brief UHCI driver
     33 * Device keeper structure and functions (implementation).
    3434 */
    3535#include <assert.h>
     
    4545 * Set all values to false/0.
    4646 */
    47 void device_keeper_init(device_keeper_t *instance)
     47void usb_device_keeper_init(usb_device_keeper_t *instance)
    4848{
    4949        assert(instance);
     
    6565 * @param[in] speed Speed of the device requesting default address.
    6666 */
    67 void device_keeper_reserve_default(device_keeper_t *instance, usb_speed_t speed)
     67void usb_device_keeper_reserve_default_address(usb_device_keeper_t *instance,
     68    usb_speed_t speed)
    6869{
    6970        assert(instance);
     
    8384 * @param[in] speed Speed of the device requesting default address.
    8485 */
    85 void device_keeper_release_default(device_keeper_t *instance)
     86void usb_device_keeper_release_default_address(usb_device_keeper_t *instance)
    8687{
    8788        assert(instance);
     
    100101 * Really ugly one.
    101102 */
    102 void device_keeper_reset_if_need(
    103     device_keeper_t *instance, usb_target_t target, const unsigned char *data)
     103void usb_device_keeper_reset_if_need(usb_device_keeper_t *instance,
     104    usb_target_t target, const uint8_t *data)
    104105{
    105106        assert(instance);
     
    144145 * @return Error code
    145146 */
    146 int device_keeper_get_toggle(
    147     device_keeper_t *instance, usb_target_t target, usb_direction_t direction)
     147int usb_device_keeper_get_toggle(usb_device_keeper_t *instance,
     148    usb_target_t target, usb_direction_t direction)
    148149{
    149150        assert(instance);
     
    173174 * @return Error code.
    174175 */
    175 int device_keeper_set_toggle(device_keeper_t *instance,
     176int usb_device_keeper_set_toggle(usb_device_keeper_t *instance,
    176177    usb_target_t target, usb_direction_t direction, bool toggle)
    177178{
     
    207208 * @return Free address, or error code.
    208209 */
    209 usb_address_t device_keeper_request(
    210     device_keeper_t *instance, usb_speed_t speed)
    211 {
    212         assert(instance);
    213         fibril_mutex_lock(&instance->guard);
    214 
    215         usb_address_t new_address = instance->last_address + 1;
    216         while (instance->devices[new_address].occupied) {
     210usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance,
     211    usb_speed_t speed)
     212{
     213        assert(instance);
     214        fibril_mutex_lock(&instance->guard);
     215
     216        usb_address_t new_address = instance->last_address;
     217        do {
     218                ++new_address;
     219                if (new_address > USB11_ADDRESS_MAX)
     220                        new_address = 1;
    217221                if (new_address == instance->last_address) {
    218222                        fibril_mutex_unlock(&instance->guard);
    219223                        return ENOSPC;
    220224                }
    221                 if (new_address == USB11_ADDRESS_MAX)
    222                         new_address = 1;
    223                 ++new_address;
    224         }
     225        } while (instance->devices[new_address].occupied);
    225226
    226227        assert(new_address != USB_ADDRESS_DEFAULT);
     
    241242 * @param[in] handle Devman handle of the device.
    242243 */
    243 void device_keeper_bind(
    244     device_keeper_t *instance, usb_address_t address, devman_handle_t handle)
     244void usb_device_keeper_bind(usb_device_keeper_t *instance,
     245    usb_address_t address, devman_handle_t handle)
    245246{
    246247        assert(instance);
     
    258259 * @param[in] address Device address
    259260 */
    260 void device_keeper_release(device_keeper_t *instance, usb_address_t address)
     261void usb_device_keeper_release(usb_device_keeper_t *instance,
     262    usb_address_t address)
    261263{
    262264        assert(instance);
     
    276278 * @return USB Address, or error code.
    277279 */
    278 usb_address_t device_keeper_find(
    279     device_keeper_t *instance, devman_handle_t handle)
     280usb_address_t usb_device_keeper_find(usb_device_keeper_t *instance,
     281    devman_handle_t handle)
    280282{
    281283        assert(instance);
     
    299301 * @return USB speed.
    300302 */
    301 usb_speed_t device_keeper_speed(
    302     device_keeper_t *instance, usb_address_t address)
     303usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance,
     304    usb_address_t address)
    303305{
    304306        assert(instance);
     
    307309        return instance->devices[address].speed;
    308310}
     311
    309312/**
    310313 * @}
  • uspace/lib/usb/src/hub.c

    r361e61b r55e388a1  
    228228        }
    229229
    230         usb_endpoint_pipe_t ctrl_pipe;
    231         rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe,
     230        usb_pipe_t ctrl_pipe;
     231        rc = usb_pipe_initialize_default_control(&ctrl_pipe,
    232232            &dev_conn);
    233233        if (rc != EOK) {
     
    235235                goto leave_release_default_address;
    236236        }
    237         rc = usb_endpoint_pipe_probe_default_control(&ctrl_pipe);
     237        rc = usb_pipe_probe_default_control(&ctrl_pipe);
    238238        if (rc != EOK) {
    239239                rc = ENOTCONN;
     
    241241        }
    242242
    243         rc = usb_endpoint_pipe_start_session(&ctrl_pipe);
     243        rc = usb_pipe_start_session(&ctrl_pipe);
    244244        if (rc != EOK) {
    245245                rc = ENOTCONN;
     
    253253        }
    254254
    255         usb_endpoint_pipe_end_session(&ctrl_pipe);
     255        usb_pipe_end_session(&ctrl_pipe);
    256256
    257257        /*
     
    306306
    307307leave_stop_session:
    308         usb_endpoint_pipe_end_session(&ctrl_pipe);
     308        usb_pipe_end_session(&ctrl_pipe);
    309309
    310310leave_release_default_address:
  • uspace/lib/usb/src/pipes.c

    r361e61b r55e388a1  
    233233 * A session is something inside what any communication occurs.
    234234 * It is expected that sessions would be started right before the transfer
    235  * and ended - see usb_endpoint_pipe_end_session() - after the last
     235 * and ended - see usb_pipe_end_session() - after the last
    236236 * transfer.
    237237 * The reason for this is that session actually opens some communication
     
    244244 * @return Error code.
    245245 */
    246 int usb_endpoint_pipe_start_session(usb_endpoint_pipe_t *pipe)
     246int usb_pipe_start_session(usb_pipe_t *pipe)
    247247{
    248248        assert(pipe);
    249249
    250         if (usb_endpoint_pipe_is_session_started(pipe)) {
     250        if (usb_pipe_is_session_started(pipe)) {
    251251                return EBUSY;
    252252        }
     
    265265/** Ends a session on the endpoint pipe.
    266266 *
    267  * @see usb_endpoint_pipe_start_session
     267 * @see usb_pipe_start_session
    268268 *
    269269 * @param pipe Endpoint pipe to end the session on.
    270270 * @return Error code.
    271271 */
    272 int usb_endpoint_pipe_end_session(usb_endpoint_pipe_t *pipe)
     272int usb_pipe_end_session(usb_pipe_t *pipe)
    273273{
    274274        assert(pipe);
    275275
    276         if (!usb_endpoint_pipe_is_session_started(pipe)) {
     276        if (!usb_pipe_is_session_started(pipe)) {
    277277                return ENOENT;
    278278        }
     
    296296 * @return Whether @p pipe has opened a session.
    297297 */
    298 bool usb_endpoint_pipe_is_session_started(usb_endpoint_pipe_t *pipe)
     298bool usb_pipe_is_session_started(usb_pipe_t *pipe)
    299299{
    300300        return (pipe->hc_phone >= 0);
  • uspace/lib/usb/src/pipesinit.c

    r361e61b r55e388a1  
    193193        }
    194194
    195         int rc = usb_endpoint_pipe_initialize(ep_mapping->pipe, wire,
     195        int rc = usb_pipe_initialize(ep_mapping->pipe, wire,
    196196            ep_no, description.transfer_type, endpoint->max_packet_size,
    197197            description.direction);
     
    276276 * @return Error code.
    277277 */
    278 int usb_endpoint_pipe_initialize_from_configuration(
     278int usb_pipe_initialize_from_configuration(
    279279    usb_endpoint_mapping_t *mapping, size_t mapping_count,
    280280    uint8_t *configuration_descriptor, size_t configuration_descriptor_size,
     
    342342 * @return Error code.
    343343 */
    344 int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *pipe,
     344int usb_pipe_initialize(usb_pipe_t *pipe,
    345345    usb_device_connection_t *connection, usb_endpoint_t endpoint_no,
    346346    usb_transfer_type_t transfer_type, size_t max_packet_size,
     
    367367 * @return Error code.
    368368 */
    369 int usb_endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *pipe,
     369int usb_pipe_initialize_default_control(usb_pipe_t *pipe,
    370370    usb_device_connection_t *connection)
    371371{
     
    373373        assert(connection);
    374374
    375         int rc = usb_endpoint_pipe_initialize(pipe, connection,
     375        int rc = usb_pipe_initialize(pipe, connection,
    376376            0, USB_TRANSFER_CONTROL, CTRL_PIPE_MIN_PACKET_SIZE,
    377377            USB_DIRECTION_BOTH);
     
    390390 * @return Error code.
    391391 */
    392 int usb_endpoint_pipe_probe_default_control(usb_endpoint_pipe_t *pipe)
     392int usb_pipe_probe_default_control(usb_pipe_t *pipe)
    393393{
    394394        assert(pipe);
     
    408408
    409409        TRY_LOOP(failed_attempts) {
    410                 rc = usb_endpoint_pipe_start_session(pipe);
     410                rc = usb_pipe_start_session(pipe);
    411411                if (rc == EOK) {
    412412                        break;
     
    433433                }
    434434        }
    435         usb_endpoint_pipe_end_session(pipe);
     435        usb_pipe_end_session(pipe);
    436436        if (rc != EOK) {
    437437                return rc;
     
    451451 * @return Error code.
    452452 */
    453 int usb_endpoint_pipe_register(usb_endpoint_pipe_t *pipe,
     453int usb_pipe_register(usb_pipe_t *pipe,
    454454    unsigned int interval,
    455455    usb_hc_connection_t *hc_connection)
     
    479479 * @return Error code.
    480480 */
    481 int usb_endpoint_pipe_unregister(usb_endpoint_pipe_t *pipe,
     481int usb_pipe_unregister(usb_pipe_t *pipe,
    482482    usb_hc_connection_t *hc_connection)
    483483{
  • uspace/lib/usb/src/pipesio.c

    r361e61b r55e388a1  
    5858 * @return Error code.
    5959 */
    60 static int usb_endpoint_pipe_read_no_checks(usb_endpoint_pipe_t *pipe,
     60static int usb_pipe_read_no_checks(usb_pipe_t *pipe,
    6161    void *buffer, size_t size, size_t *size_transfered)
    6262{
     
    140140 * @return Error code.
    141141 */
    142 int usb_endpoint_pipe_read(usb_endpoint_pipe_t *pipe,
     142int usb_pipe_read(usb_pipe_t *pipe,
    143143    void *buffer, size_t size, size_t *size_transfered)
    144144{
     
    153153        }
    154154
    155         if (!usb_endpoint_pipe_is_session_started(pipe)) {
     155        if (!usb_pipe_is_session_started(pipe)) {
    156156                return EBADF;
    157157        }
     
    168168        int rc;
    169169
    170         rc = usb_endpoint_pipe_read_no_checks(pipe, buffer, size, &act_size);
     170        rc = usb_pipe_read_no_checks(pipe, buffer, size, &act_size);
    171171        if (rc != EOK) {
    172172                return rc;
     
    190190 * @return Error code.
    191191 */
    192 static int usb_endpoint_pipe_write_no_check(usb_endpoint_pipe_t *pipe,
     192static int usb_pipe_write_no_check(usb_pipe_t *pipe,
    193193    void *buffer, size_t size)
    194194{
     
    247247 * @return Error code.
    248248 */
    249 int usb_endpoint_pipe_write(usb_endpoint_pipe_t *pipe,
     249int usb_pipe_write(usb_pipe_t *pipe,
    250250    void *buffer, size_t size)
    251251{
     
    260260        }
    261261
    262         if (!usb_endpoint_pipe_is_session_started(pipe)) {
     262        if (!usb_pipe_is_session_started(pipe)) {
    263263                return EBADF;
    264264        }
     
    272272        }
    273273
    274         int rc = usb_endpoint_pipe_write_no_check(pipe, buffer, size);
     274        int rc = usb_pipe_write_no_check(pipe, buffer, size);
    275275
    276276        return rc;
     
    289289 * @return Error code.
    290290 */
    291 static int usb_endpoint_pipe_control_read_no_check(usb_endpoint_pipe_t *pipe,
     291static int usb_pipe_control_read_no_check(usb_pipe_t *pipe,
    292292    void *setup_buffer, size_t setup_buffer_size,
    293293    void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size)
     
    365365 * @return Error code.
    366366 */
    367 int usb_endpoint_pipe_control_read(usb_endpoint_pipe_t *pipe,
     367int usb_pipe_control_read(usb_pipe_t *pipe,
    368368    void *setup_buffer, size_t setup_buffer_size,
    369369    void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size)
     
    379379        }
    380380
    381         if (!usb_endpoint_pipe_is_session_started(pipe)) {
     381        if (!usb_pipe_is_session_started(pipe)) {
    382382                return EBADF;
    383383        }
     
    389389
    390390        size_t act_size = 0;
    391         int rc = usb_endpoint_pipe_control_read_no_check(pipe,
     391        int rc = usb_pipe_control_read_no_check(pipe,
    392392            setup_buffer, setup_buffer_size,
    393393            data_buffer, data_buffer_size, &act_size);
     
    414414 * @return Error code.
    415415 */
    416 static int usb_endpoint_pipe_control_write_no_check(usb_endpoint_pipe_t *pipe,
     416static int usb_pipe_control_write_no_check(usb_pipe_t *pipe,
    417417    void *setup_buffer, size_t setup_buffer_size,
    418418    void *data_buffer, size_t data_buffer_size)
     
    473473 * @return Error code.
    474474 */
    475 int usb_endpoint_pipe_control_write(usb_endpoint_pipe_t *pipe,
     475int usb_pipe_control_write(usb_pipe_t *pipe,
    476476    void *setup_buffer, size_t setup_buffer_size,
    477477    void *data_buffer, size_t data_buffer_size)
     
    491491        }
    492492
    493         if (!usb_endpoint_pipe_is_session_started(pipe)) {
     493        if (!usb_pipe_is_session_started(pipe)) {
    494494                return EBADF;
    495495        }
     
    500500        }
    501501
    502         int rc = usb_endpoint_pipe_control_write_no_check(pipe,
     502        int rc = usb_pipe_control_write_no_check(pipe,
    503503            setup_buffer, setup_buffer_size, data_buffer, data_buffer_size);
    504504
  • uspace/lib/usb/src/recognise.c

    r361e61b r55e388a1  
    311311 * @return Error code.
    312312 */
    313 int usb_device_create_match_ids(usb_endpoint_pipe_t *ctrl_pipe,
     313int usb_device_create_match_ids(usb_pipe_t *ctrl_pipe,
    314314    match_id_list_t *matches)
    315315{
     
    363363        int rc;
    364364        usb_device_connection_t dev_connection;
    365         usb_endpoint_pipe_t ctrl_pipe;
     365        usb_pipe_t ctrl_pipe;
    366366
    367367        rc = usb_device_connection_initialize(&dev_connection, hc_handle, address);
     
    370370        }
    371371
    372         rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe,
     372        rc = usb_pipe_initialize_default_control(&ctrl_pipe,
    373373            &dev_connection);
    374374        if (rc != EOK) {
    375375                goto failure;
    376376        }
    377         rc = usb_endpoint_pipe_probe_default_control(&ctrl_pipe);
     377        rc = usb_pipe_probe_default_control(&ctrl_pipe);
    378378        if (rc != EOK) {
    379379                goto failure;
     
    404404        child->driver_data = dev_data;
    405405
    406         rc = usb_endpoint_pipe_start_session(&ctrl_pipe);
     406        rc = usb_pipe_start_session(&ctrl_pipe);
    407407        if (rc != EOK) {
    408408                goto failure;
     
    414414        }
    415415
    416         rc = usb_endpoint_pipe_end_session(&ctrl_pipe);
     416        rc = usb_pipe_end_session(&ctrl_pipe);
    417417        if (rc != EOK) {
    418418                goto failure;
  • uspace/lib/usb/src/request.c

    r361e61b r55e388a1  
    4242/** Generic wrapper for SET requests using standard control request format.
    4343 *
    44  * @see usb_endpoint_pipe_control_write
     44 * @see usb_pipe_control_write
    4545 *
    4646 * @param pipe Pipe used for the communication.
     
    6060 * @retval ERANGE Data buffer too large.
    6161 */
    62 int usb_control_request_set(usb_endpoint_pipe_t *pipe,
     62int usb_control_request_set(usb_pipe_t *pipe,
    6363    usb_request_type_t request_type, usb_request_recipient_t recipient,
    6464    uint8_t request,
     
    9090        setup_packet.length = (uint16_t) data_size;
    9191
    92         int rc = usb_endpoint_pipe_control_write(pipe,
     92        int rc = usb_pipe_control_write(pipe,
    9393            &setup_packet, sizeof(setup_packet),
    9494            data, data_size);
     
    9999 /** Generic wrapper for GET requests using standard control request format.
    100100  *
    101   * @see usb_endpoint_pipe_control_read
     101  * @see usb_pipe_control_read
    102102  *
    103103  * @param pipe Pipe used for the communication.
     
    120120  * @retval ERANGE Data buffer too large.
    121121  */
    122 int usb_control_request_get(usb_endpoint_pipe_t *pipe,
     122int usb_control_request_get(usb_pipe_t *pipe,
    123123    usb_request_type_t request_type, usb_request_recipient_t recipient,
    124124    uint8_t request,
     
    150150        setup_packet.length = (uint16_t) data_size;
    151151
    152         int rc = usb_endpoint_pipe_control_read(pipe,
     152        int rc = usb_pipe_control_read(pipe,
    153153            &setup_packet, sizeof(setup_packet),
    154154            data, data_size, actual_data_size);
     
    165165 * @return Error code.
    166166 */
    167 int usb_request_get_status(usb_endpoint_pipe_t *pipe,
     167int usb_request_get_status(usb_pipe_t *pipe,
    168168    usb_request_recipient_t recipient, uint16_t index,
    169169    uint16_t *status)
     
    203203 * @return Error code.
    204204 */
    205 int usb_request_clear_feature(usb_endpoint_pipe_t *pipe,
     205int usb_request_clear_feature(usb_pipe_t *pipe,
    206206    usb_request_type_t request_type, usb_request_recipient_t recipient,
    207207    uint16_t feature_selector, uint16_t index)
     
    231231 * @return Error code.
    232232 */
    233 int usb_request_set_feature(usb_endpoint_pipe_t *pipe,
     233int usb_request_set_feature(usb_pipe_t *pipe,
    234234    usb_request_type_t request_type, usb_request_recipient_t recipient,
    235235    uint16_t feature_selector, uint16_t index)
     
    258258 * @return Error code.
    259259 */
    260 int usb_request_set_address(usb_endpoint_pipe_t *pipe,
     260int usb_request_set_address(usb_pipe_t *pipe,
    261261    usb_address_t new_address)
    262262{
     
    297297 * @return Error code.
    298298 */
    299 int usb_request_get_descriptor(usb_endpoint_pipe_t *pipe,
     299int usb_request_get_descriptor(usb_pipe_t *pipe,
    300300    usb_request_type_t request_type, usb_request_recipient_t recipient,
    301301    uint8_t descriptor_type, uint8_t descriptor_index,
     
    331331 * @return
    332332 */
    333 int usb_request_get_descriptor_alloc(usb_endpoint_pipe_t * pipe,
     333int usb_request_get_descriptor_alloc(usb_pipe_t * pipe,
    334334    usb_request_type_t request_type, usb_request_recipient_t recipient,
    335335    uint8_t descriptor_type, uint8_t descriptor_index,
     
    400400 * @return Error code.
    401401 */
    402 int usb_request_get_device_descriptor(usb_endpoint_pipe_t *pipe,
     402int usb_request_get_device_descriptor(usb_pipe_t *pipe,
    403403    usb_standard_device_descriptor_t *descriptor)
    404404{
     
    442442 * @return Error code.
    443443 */
    444 int usb_request_get_bare_configuration_descriptor(usb_endpoint_pipe_t *pipe,
     444int usb_request_get_bare_configuration_descriptor(usb_pipe_t *pipe,
    445445    int index, usb_standard_configuration_descriptor_t *descriptor)
    446446{
     
    488488 * @return Error code.
    489489 */
    490 int usb_request_get_full_configuration_descriptor(usb_endpoint_pipe_t *pipe,
     490int usb_request_get_full_configuration_descriptor(usb_pipe_t *pipe,
    491491    int index, void *descriptor, size_t descriptor_size, size_t *actual_size)
    492492{
     
    514514 */
    515515int usb_request_get_full_configuration_descriptor_alloc(
    516     usb_endpoint_pipe_t *pipe, int index,
     516    usb_pipe_t *pipe, int index,
    517517    void **descriptor_ptr, size_t *descriptor_size)
    518518{
     
    578578 * @return Error code.
    579579 */
    580 int usb_request_set_descriptor(usb_endpoint_pipe_t *pipe,
     580int usb_request_set_descriptor(usb_pipe_t *pipe,
    581581    usb_request_type_t request_type, usb_request_recipient_t recipient,
    582582    uint8_t descriptor_type, uint8_t descriptor_index,
     
    607607 * @return Error code.
    608608 */
    609 int usb_request_get_configuration(usb_endpoint_pipe_t *pipe,
     609int usb_request_get_configuration(usb_pipe_t *pipe,
    610610    uint8_t *configuration_value)
    611611{
     
    639639 * @return Error code.
    640640 */
    641 int usb_request_set_configuration(usb_endpoint_pipe_t *pipe,
     641int usb_request_set_configuration(usb_pipe_t *pipe,
    642642    uint8_t configuration_value)
    643643{
     
    658658 * @return Error code.
    659659 */
    660 int usb_request_get_interface(usb_endpoint_pipe_t *pipe,
     660int usb_request_get_interface(usb_pipe_t *pipe,
    661661    uint8_t interface_index, uint8_t *alternate_setting)
    662662{
     
    691691 * @return Error code.
    692692 */
    693 int usb_request_set_interface(usb_endpoint_pipe_t *pipe,
     693int usb_request_set_interface(usb_pipe_t *pipe,
    694694    uint8_t interface_index, uint8_t alternate_setting)
    695695{
     
    710710 * @return Error code.
    711711 */
    712 int usb_request_get_supported_languages(usb_endpoint_pipe_t *pipe,
     712int usb_request_get_supported_languages(usb_pipe_t *pipe,
    713713    l18_win_locales_t **languages_ptr, size_t *languages_count)
    714714{
     
    782782 * @return Error code.
    783783 */
    784 int usb_request_get_string(usb_endpoint_pipe_t *pipe,
     784int usb_request_get_string(usb_pipe_t *pipe,
    785785    size_t index, l18_win_locales_t lang, char **string_ptr)
    786786{
  • uspace/lib/usb/src/usb.c

    r361e61b r55e388a1  
    3636#include <errno.h>
    3737
     38#define ARR_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
     39
     40static const char *str_speed[] = {
     41        "low",
     42        "full",
     43        "high"
     44};
     45
     46static const char *str_transfer_type[] = {
     47        "control",
     48        "isochronous",
     49        "bulk",
     50        "interrupt"
     51};
     52
     53static const char *str_transfer_type_short[] = {
     54        "ctrl",
     55        "iso",
     56        "bulk",
     57        "intr"
     58};
    3859
    3960/** String representation for USB transfer type.
     
    4263 * @return Transfer type as a string (in English).
    4364 */
    44 const char * usb_str_transfer_type(usb_transfer_type_t t)
     65const char *usb_str_transfer_type(usb_transfer_type_t t)
    4566{
    46         switch (t) {
    47                 case USB_TRANSFER_ISOCHRONOUS:
    48                         return "isochronous";
    49                 case USB_TRANSFER_INTERRUPT:
    50                         return "interrupt";
    51                 case USB_TRANSFER_CONTROL:
    52                         return "control";
    53                 case USB_TRANSFER_BULK:
    54                         return "bulk";
    55                 default:
    56                         return "unknown";
     67        if (t >= ARR_SIZE(str_transfer_type)) {
     68                return "invalid";
    5769        }
     70        return str_transfer_type[t];
     71}
     72
     73/** String representation for USB transfer type (short version).
     74 *
     75 * @param t Transfer type.
     76 * @return Transfer type as a short string for debugging messages.
     77 */
     78const char *usb_str_transfer_type_short(usb_transfer_type_t t)
     79{
     80        if (t >= ARR_SIZE(str_transfer_type_short)) {
     81                return "invl";
     82        }
     83        return str_transfer_type_short[t];
     84}
     85
     86/** String representation of USB speed.
     87 *
     88 * @param s The speed.
     89 * @return USB speed as a string (in English).
     90 */
     91const char *usb_str_speed(usb_speed_t s)
     92{
     93        if (s >= ARR_SIZE(str_speed)) {
     94                return "invalid";
     95        }
     96        return str_speed[s];
    5897}
    5998
Note: See TracChangeset for help on using the changeset viewer.