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


Ignore:
Files:
8 added
8 deleted
68 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    r55e388a1 r361e61b  
    99_link.ld
    1010./*.iso
    11 
    12 ./tools/__pycache__/
    1311
    1412./Makefile.common
     
    141139.cproject
    142140.project
    143 .settings
    144 .pydevproject
    145 
  • HelenOS.config

    r55e388a1 r361e61b  
    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

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

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

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

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

    r55e388a1 r361e61b  
    7070        unsigned int i, j;
    7171        devmap_handle_t handle;
    72         aoff64_t offset;
    7372        uint8_t *blk;
    7473        size_t size, bytes, rows;
     
    121120        }
    122121
    123         offset = ba * block_size;
    124 
    125122        while (size > 0) {
    126123                rc = block_read_direct(handle, ba, 1, blk);
     
    136133
    137134                for (j = 0; j < rows; j++) {
    138                         printf("[%06" PRIxOFF64 "] ", offset);
    139135                        for (i = 0; i < BPR; i++) {
    140136                                if (j * BPR + i < bytes)
     
    156152                                }
    157153                        }
    158                         offset += BPR;
    159154                        putchar('\n');
    160155                }
  • uspace/app/usbinfo/dev.c

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

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

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

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

    r55e388a1 r361e61b  
    4141#include <usb/host/batch.h>
    4242
    43 usb_transfer_batch_t * batch_get(
     43batch_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                 usb_device_keeper_t *manager
     56                device_keeper_t *manager
    5757                );
    5858
    59 void batch_dispose(usb_transfer_batch_t *instance);
     59void batch_dispose(batch_t *instance);
    6060
    61 void batch_control_write(usb_transfer_batch_t *instance);
     61void batch_control_write(batch_t *instance);
    6262
    63 void batch_control_read(usb_transfer_batch_t *instance);
     63void batch_control_read(batch_t *instance);
    6464
    65 void batch_interrupt_in(usb_transfer_batch_t *instance);
     65void batch_interrupt_in(batch_t *instance);
    6666
    67 void batch_interrupt_out(usb_transfer_batch_t *instance);
     67void batch_interrupt_out(batch_t *instance);
    6868
    69 void batch_bulk_in(usb_transfer_batch_t *instance);
     69void batch_bulk_in(batch_t *instance);
    7070
    71 void batch_bulk_out(usb_transfer_batch_t *instance);
     71void batch_bulk_out(batch_t *instance);
    7272#endif
    7373/**
  • uspace/drv/ohci/hc.c

    r55e388a1 r361e61b  
    4545#include "hc.h"
    4646
    47 static int dummy_reset(int foo, void *arg);
    48 static int interrupt_emulator(hc_t *instance);
     47static 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}
    4954/*----------------------------------------------------------------------------*/
    5055int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev,
     
    6065        }
    6166        instance->ddf_instance = fun;
    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         }
     67        device_keeper_init(&instance->manager);
    6968
    7069
     
    10099        ret = usb_hc_new_device_wrapper(dev, &conn, USB_SPEED_FULL, dummy_reset,
    101100            0, instance, &address, &handle, NULL, NULL, NULL);
    102         if (ret != EOK) {
    103                 usb_log_error("Failed to add rh device.\n");
    104                 instance->rh.address = -1;
    105                 return ret;
    106         }
     101        CHECK_RET_RETURN(ret, "Failed to add rh device.\n");
    107102
    108103        ret = usb_hc_connection_close(&conn);
     
    111106}
    112107/*----------------------------------------------------------------------------*/
    113 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch)
     108int hc_schedule(hc_t *instance, batch_t *batch)
    114109{
    115110        assert(instance);
     
    122117}
    123118/*----------------------------------------------------------------------------*/
    124 void hc_interrupt(hc_t *instance, uint32_t status)
     119void hc_interrupt(hc_t *instance, uint16_t status)
    125120{
    126121        assert(instance);
    127         if (status == 0)
    128                 return;
    129         if (status & IS_RHSC)
    130                 rh_interrupt(&instance->rh);
    131 
    132         /* TODO: Check for further interrupt causes */
     122        /* TODO: Check for interrupt cause */
     123        rh_interrupt(&instance->rh);
    133124        /* TODO: implement */
    134 }
    135 /*----------------------------------------------------------------------------*/
    136 static 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 /*----------------------------------------------------------------------------*/
    144 static 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;
    155125}
    156126/**
  • uspace/drv/ohci/hc.h

    r55e388a1 r361e61b  
    5353        rh_t rh;
    5454        ddf_fun_t *ddf_instance;
    55         usb_device_keeper_t manager;
    56         fid_t interrupt_emulator;
     55        device_keeper_t manager;
    5756} hc_t;
    5857
     
    6261int hc_register_hub(hc_t *instance);
    6362
    64 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch);
     63int hc_schedule(hc_t *instance, batch_t *batch);
    6564
    66 void hc_interrupt(hc_t *instance, uint32_t status);
     65void hc_interrupt(hc_t *instance, uint16_t status);
    6766
    6867/** Safely dispose host controller internal structures
  • uspace/drv/ohci/iface.c

    r55e388a1 r361e61b  
    3333 */
    3434#include <ddf/driver.h>
     35#include <ddf/interrupt.h>
     36#include <device/hw_res.h>
    3537#include <errno.h>
    36 
     38#include <str_error.h>
     39
     40#include <usb_iface.h>
     41#include <usb/ddfiface.h>
    3742#include <usb/debug.h>
    3843
     
    5560static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
    5661{
    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;
     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;
    6368}
    6469/*----------------------------------------------------------------------------*/
     
    7075static int release_default_address(ddf_fun_t *fun)
    7176{
    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;
     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;
    7883}
    7984/*----------------------------------------------------------------------------*/
     
    8590 * @return Error code.
    8691 */
    87 static 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;
     92static 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;
    101106}
    102107/*----------------------------------------------------------------------------*/
     
    108113 * @return Error code.
    109114 */
    110 static 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;
     115static 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;
    119124}
    120125/*----------------------------------------------------------------------------*/
     
    127132static int release_address(ddf_fun_t *fun, usb_address_t address)
    128133{
    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 /*----------------------------------------------------------------------------*/
     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
    137142/** Register endpoint for bandwidth reservation.
    138143 *
     
    146151 * @return Error code.
    147152 */
    148 static int register_endpoint(
    149     ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint,
     153static int register_endpoint(ddf_fun_t *fun,
     154    usb_address_t address, usb_endpoint_t endpoint,
    150155    usb_transfer_type_t transfer_type, usb_direction_t direction,
    151156    size_t max_packet_size, unsigned int interval)
     
    155160        return ENOTSUP;
    156161}
    157 /*----------------------------------------------------------------------------*/
     162
    158163/** Unregister endpoint (free some bandwidth reservation).
    159164 *
     
    164169 * @return Error code.
    165170 */
    166 static int unregister_endpoint(
    167     ddf_fun_t *fun, usb_address_t address,
     171static int unregister_endpoint(ddf_fun_t *fun, usb_address_t address,
    168172    usb_endpoint_t endpoint, usb_direction_t direction)
    169173{
     
    190194 * @return Error code.
    191195 */
    192 static 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;
     196static 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;
    216219}
    217220/*----------------------------------------------------------------------------*/
     
    233236 * @return Error code.
    234237 */
    235 static 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;
     238static 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;
    258261}
    259262/*----------------------------------------------------------------------------*/
     
    275278 * @return Error code.
    276279 */
    277 static 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;
     280static 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
    301305}
    302306/*----------------------------------------------------------------------------*/
     
    318322 * @return Error code.
    319323 */
    320 static 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;
     324static 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;
    343347}
    344348/*----------------------------------------------------------------------------*/
     
    363367 * @return Error code.
    364368 */
    365 static 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,
     369static 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,
    368373    usbhc_iface_transfer_out_callback_t callback, void *arg)
    369374{
    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;
     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;
    394398}
    395399/*----------------------------------------------------------------------------*/
     
    414418 * @return Error code.
    415419 */
    416 static 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,
     420static 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,
    419424    usbhc_iface_transfer_in_callback_t callback, void *arg)
    420425{
    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;
     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;
    441445}
    442446/*----------------------------------------------------------------------------*/
     
    459463
    460464        .control_write = control_write,
    461         .control_read = control_read,
     465        .control_read = control_read
    462466};
    463467
  • uspace/drv/ohci/main.c

    r55e388a1 r361e61b  
    6161{
    6262        assert(fun);
    63         usb_device_keeper_t *manager = &fun_to_hc(fun)->manager;
    64   usb_address_t addr = usb_device_keeper_find(manager, handle);
     63        device_keeper_t *manager = &fun_to_hc(fun)->manager;
     64  usb_address_t addr = device_keeper_find(manager, handle);
    6565  if (addr < 0) {
    6666    return addr;
     
    149149        }
    150150
    151 
    152151        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
    157152        ret = pci_enable_interrupts(device);
    158153        if (ret != EOK) {
    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");
     154                usb_log_warning(
     155                    "Failed(%d) to enable interrupts, fall back to polling.\n",
     156                    ret);
    163157        } else {
    164158                usb_log_debug("Hw interrupts enabled.\n");
    165159                interrupts = true;
    166160        }
    167 #endif
    168161
    169162        ret = hc_init(hcd, hc_fun, device, mem_reg_base, mem_reg_size, interrupts);
     
    206199int main(int argc, char *argv[])
    207200{
    208         usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
     201        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    209202        sleep(5);
    210203        return ddf_driver_main(&ohci_driver);
  • uspace/drv/ohci/ohci_regs.h

    r55e388a1 r361e61b  
    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)
    5345        volatile uint32_t interupt_enable;
    5446#define IE_SO   (1 << 0)
  • uspace/drv/ohci/root_hub.c

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

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

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

    r55e388a1 r361e61b  
    4040#include "batch.h"
    4141#include "transfer_list.h"
    42 #include "hw_struct/transfer_descriptor.h"
     42#include "uhci_hc.h"
    4343#include "utils/malloc32.h"
     44#include "uhci_struct/transfer_descriptor.h"
    4445
    4546#define DEFAULT_ERROR_COUNT 3
     
    4849        qh_t *qh;
    4950        td_t *tds;
    50         size_t transfers;
    51         usb_device_keeper_t *manager;
     51        size_t packets;
     52        device_keeper_t *manager;
    5253} uhci_batch_t;
    5354
    54 static void batch_control(usb_transfer_batch_t *instance,
     55static void batch_control(batch_t *instance,
    5556    usb_packet_id data_stage, usb_packet_id status_stage);
    56 static void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid);
    57 static void batch_call_in_and_dispose(usb_transfer_batch_t *instance);
    58 static void batch_call_out_and_dispose(usb_transfer_batch_t *instance);
     57static void batch_data(batch_t *instance, usb_packet_id pid);
     58static void batch_call_in_and_dispose(batch_t *instance);
     59static void batch_call_out_and_dispose(batch_t *instance);
    5960
    6061
     
    6465 * @param[in] target Device and endpoint target of the transaction.
    6566 * @param[in] transfer_type Interrupt, Control or Bulk.
    66  * @param[in] max_packet_size maximum allowed size of data transfers.
     67 * @param[in] max_packet_size maximum allowed size of data packets.
    6768 * @param[in] speed Speed of the transaction.
    6869 * @param[in] buffer Data source/destination.
     
    7778 * NULL otherwise.
    7879 *
    79  * Determines the number of needed transfers (TDs). Prepares a transport buffer
     80 * Determines the number of needed packets (TDs). Prepares a transport buffer
    8081 * (that is accessible by the hardware). Initializes parameters needed for the
    8182 * transaction and callback.
    8283 */
    83 usb_transfer_batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
     84batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
    8485    usb_transfer_type_t transfer_type, size_t max_packet_size,
    8586    usb_speed_t speed, char *buffer, size_t buffer_size,
     
    8788    usbhc_iface_transfer_in_callback_t func_in,
    8889    usbhc_iface_transfer_out_callback_t func_out, void *arg,
    89     usb_device_keeper_t *manager
     90    device_keeper_t *manager
    9091    )
    9192{
     
    102103        } else (void)0
    103104
    104         usb_transfer_batch_t *instance = malloc(sizeof(usb_transfer_batch_t));
     105        batch_t *instance = malloc(sizeof(batch_t));
    105106        CHECK_NULL_DISPOSE_RETURN(instance,
    106107            "Failed to allocate batch instance.\n");
    107         usb_transfer_batch_init(instance, target, transfer_type, speed, max_packet_size,
     108        batch_init(instance, target, transfer_type, speed, max_packet_size,
    108109            buffer, NULL, buffer_size, NULL, setup_size, func_in,
    109110            func_out, arg, fun, NULL);
     
    117118        instance->private_data = data;
    118119
    119         data->transfers = (buffer_size + max_packet_size - 1) / max_packet_size;
     120        data->packets = (buffer_size + max_packet_size - 1) / max_packet_size;
    120121        if (transfer_type == USB_TRANSFER_CONTROL) {
    121                 data->transfers += 2;
    122         }
    123 
    124         data->tds = malloc32(sizeof(td_t) * data->transfers);
     122                data->packets += 2;
     123        }
     124
     125        data->tds = malloc32(sizeof(td_t) * data->packets);
    125126        CHECK_NULL_DISPOSE_RETURN(
    126127            data->tds, "Failed to allocate transfer descriptors.\n");
    127         bzero(data->tds, sizeof(td_t) * data->transfers);
     128        bzero(data->tds, sizeof(td_t) * data->packets);
    128129
    129130        data->qh = malloc32(sizeof(qh_t));
     
    160161 * is reached.
    161162 */
    162 bool batch_is_complete(usb_transfer_batch_t *instance)
     163bool batch_is_complete(batch_t *instance)
    163164{
    164165        assert(instance);
     
    166167        assert(data);
    167168
    168         usb_log_debug2("Batch(%p) checking %d transfer(s) for completion.\n",
    169             instance, data->transfers);
     169        usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n",
     170            instance, data->packets);
    170171        instance->transfered_size = 0;
    171172        size_t i = 0;
    172         for (;i < data->transfers; ++i) {
     173        for (;i < data->packets; ++i) {
    173174                if (td_is_active(&data->tds[i])) {
    174175                        return false;
     
    181182                        td_print_status(&data->tds[i]);
    182183
    183                         usb_device_keeper_set_toggle(data->manager,
     184                        device_keeper_set_toggle(data->manager,
    184185                            instance->target, instance->direction,
    185186                            td_toggle(&data->tds[i]));
     
    204205 * Uses genercir control function with pids OUT and IN.
    205206 */
    206 void batch_control_write(usb_transfer_batch_t *instance)
     207void batch_control_write(batch_t *instance)
    207208{
    208209        assert(instance);
     
    221222 * Uses generic control with pids IN and OUT.
    222223 */
    223 void batch_control_read(usb_transfer_batch_t *instance)
     224void batch_control_read(batch_t *instance)
    224225{
    225226        assert(instance);
     
    235236 * Data transaction with PID_IN.
    236237 */
    237 void batch_interrupt_in(usb_transfer_batch_t *instance)
     238void batch_interrupt_in(batch_t *instance)
    238239{
    239240        assert(instance);
     
    250251 * Data transaction with PID_OUT.
    251252 */
    252 void batch_interrupt_out(usb_transfer_batch_t *instance)
     253void batch_interrupt_out(batch_t *instance)
    253254{
    254255        assert(instance);
     
    268269 * Data transaction with PID_IN.
    269270 */
    270 void batch_bulk_in(usb_transfer_batch_t *instance)
     271void batch_bulk_in(batch_t *instance)
    271272{
    272273        assert(instance);
     
    283284 * Data transaction with PID_OUT.
    284285 */
    285 void batch_bulk_out(usb_transfer_batch_t *instance)
     286void batch_bulk_out(batch_t *instance)
    286287{
    287288        assert(instance);
     
    298299 *
    299300 * @param[in] instance Batch structure to use.
    300  * @param[in] pid Pid to use for data transfers.
     301 * @param[in] pid to use for data packets.
    301302 *
    302303 * Packets with alternating toggle bit and supplied pid value.
    303  * The last transfer is marked with IOC flag.
    304  */
    305 void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid)
     304 * The last packet is marked with IOC flag.
     305 */
     306void batch_data(batch_t *instance, usb_packet_id pid)
    306307{
    307308        assert(instance);
     
    310311
    311312        const bool low_speed = instance->speed == USB_SPEED_LOW;
    312         int toggle = usb_device_keeper_get_toggle(
     313        int toggle = device_keeper_get_toggle(
    313314            data->manager, instance->target, instance->direction);
    314315        assert(toggle == 0 || toggle == 1);
    315316
    316         size_t transfer = 0;
     317        size_t packet = 0;
    317318        size_t remain_size = instance->buffer_size;
    318319        while (remain_size > 0) {
     
    325326                    remain_size : instance->max_packet_size;
    326327
    327                 td_t *next_transfer = (transfer + 1 < data->transfers)
    328                     ? &data->tds[transfer + 1] : NULL;
    329 
    330                 assert(transfer < data->transfers);
     328                td_t *next_packet = (packet + 1 < data->packets)
     329                    ? &data->tds[packet + 1] : NULL;
     330
     331                assert(packet < data->packets);
    331332                assert(packet_size <= remain_size);
    332333
    333334                td_init(
    334                     &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
     335                    &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size,
    335336                    toggle, false, low_speed, instance->target, pid, trans_data,
    336                     next_transfer);
     337                    next_packet);
    337338
    338339
    339340                toggle = 1 - toggle;
    340341                remain_size -= packet_size;
    341                 ++transfer;
    342         }
    343         td_set_ioc(&data->tds[transfer - 1]);
    344         usb_device_keeper_set_toggle(data->manager, instance->target,
     342                ++packet;
     343        }
     344        td_set_ioc(&data->tds[packet - 1]);
     345        device_keeper_set_toggle(data->manager, instance->target,
    345346            instance->direction, toggle);
    346347}
     
    349350 *
    350351 * @param[in] instance Batch structure to use.
    351  * @param[in] data_stage Pid to use for data transfers.
    352  * @param[in] status_stage Pid to use for data transfers.
     352 * @param[in] data_stage to use for data packets.
     353 * @param[in] status_stage to use for data packets.
    353354 *
    354355 * Setup stage with toggle 0 and USB_PID_SETUP.
    355356 * Data stage with alternating toggle and pid supplied by parameter.
    356357 * Status stage with toggle 1 and pid supplied by parameter.
    357  * The last transfer is marked with IOC.
    358  */
    359 void batch_control(usb_transfer_batch_t *instance,
     358 * The last packet is marked with IOC.
     359 */
     360void batch_control(batch_t *instance,
    360361   usb_packet_id data_stage, usb_packet_id status_stage)
    361362{
     
    363364        uhci_batch_t *data = instance->private_data;
    364365        assert(data);
    365         assert(data->transfers >= 2);
     366        assert(data->packets >= 2);
    366367
    367368        const bool low_speed = instance->speed == USB_SPEED_LOW;
     
    374375
    375376        /* data stage */
    376         size_t transfer = 1;
     377        size_t packet = 1;
    377378        size_t remain_size = instance->buffer_size;
    378379        while (remain_size > 0) {
     
    388389
    389390                td_init(
    390                     &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
     391                    &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size,
    391392                    toggle, false, low_speed, instance->target, data_stage,
    392                     control_data, &data->tds[transfer + 1]);
    393 
    394                 ++transfer;
    395                 assert(transfer < data->transfers);
     393                    control_data, &data->tds[packet + 1]);
     394
     395                ++packet;
     396                assert(packet < data->packets);
    396397                assert(packet_size <= remain_size);
    397398                remain_size -= packet_size;
     
    399400
    400401        /* status stage */
    401         assert(transfer == data->transfers - 1);
     402        assert(packet == data->packets - 1);
    402403
    403404        td_init(
    404             &data->tds[transfer], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,
     405            &data->tds[packet], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,
    405406            instance->target, status_stage, NULL, NULL);
    406         td_set_ioc(&data->tds[transfer]);
     407        td_set_ioc(&data->tds[packet]);
    407408
    408409        usb_log_debug2("Control last TD status: %x.\n",
    409             data->tds[transfer].status);
    410 }
    411 /*----------------------------------------------------------------------------*/
    412 qh_t * batch_qh(usb_transfer_batch_t *instance)
     410            data->tds[packet].status);
     411}
     412/*----------------------------------------------------------------------------*/
     413qh_t * batch_qh(batch_t *instance)
    413414{
    414415        assert(instance);
     
    422423 * @param[in] instance Batch structure to use.
    423424 */
    424 void batch_call_in_and_dispose(usb_transfer_batch_t *instance)
    425 {
    426         assert(instance);
    427         usb_transfer_batch_call_in(instance);
     425void batch_call_in_and_dispose(batch_t *instance)
     426{
     427        assert(instance);
     428        batch_call_in(instance);
    428429        batch_dispose(instance);
    429430}
     
    433434 * @param[in] instance Batch structure to use.
    434435 */
    435 void batch_call_out_and_dispose(usb_transfer_batch_t *instance)
    436 {
    437         assert(instance);
    438         usb_transfer_batch_call_out(instance);
     436void batch_call_out_and_dispose(batch_t *instance)
     437{
     438        assert(instance);
     439        batch_call_out(instance);
    439440        batch_dispose(instance);
    440441}
     
    444445 * @param[in] instance Batch structure to use.
    445446 */
    446 void batch_dispose(usb_transfer_batch_t *instance)
     447void batch_dispose(batch_t *instance)
    447448{
    448449        assert(instance);
  • uspace/drv/uhci-hcd/batch.h

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

    r55e388a1 r361e61b  
    3333 */
    3434#include <ddf/driver.h>
     35#include <remote_usbhc.h>
     36
     37#include <usb/debug.h>
     38
    3539#include <errno.h>
    3640
    37 #include <usb/debug.h>
    38 
    3941#include "iface.h"
    40 #include "hc.h"
     42#include "uhci_hc.h"
    4143
    4244/** Reserve default address interface function
     
    4648 * @return Error code.
    4749 */
     50/*----------------------------------------------------------------------------*/
    4851static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
    4952{
    5053        assert(fun);
    51         hc_t *hc = fun_to_hc(fun);
     54        uhci_hc_t *hc = fun_to_uhci_hc(fun);
    5255        assert(hc);
    5356        usb_log_debug("Default address request with speed %d.\n", speed);
    54         usb_device_keeper_reserve_default_address(&hc->manager, speed);
     57        device_keeper_reserve_default(&hc->device_manager, speed);
    5558        return EOK;
    5659}
     
    6467{
    6568        assert(fun);
    66         hc_t *hc = fun_to_hc(fun);
     69        uhci_hc_t *hc = fun_to_uhci_hc(fun);
    6770        assert(hc);
    6871        usb_log_debug("Default address release.\n");
    69         usb_device_keeper_release_default_address(&hc->manager);
     72        device_keeper_release_default(&hc->device_manager);
    7073        return EOK;
    7174}
     
    7881 * @return Error code.
    7982 */
    80 static 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);
     83static 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);
    8588        assert(hc);
    8689        assert(address);
    8790
    8891        usb_log_debug("Address request with speed %d.\n", speed);
    89         *address = device_keeper_get_free_address(&hc->manager, speed);
     92        *address = device_keeper_request(&hc->device_manager, speed);
    9093        usb_log_debug("Address request with result: %d.\n", *address);
    9194        if (*address <= 0)
    92                 return *address;
     95          return *address;
    9396        return EOK;
    9497}
     
    105108{
    106109        assert(fun);
    107         hc_t *hc = fun_to_hc(fun);
     110        uhci_hc_t *hc = fun_to_uhci_hc(fun);
    108111        assert(hc);
    109112        usb_log_debug("Address bind %d-%d.\n", address, handle);
    110         usb_device_keeper_bind(&hc->manager, address, handle);
     113        device_keeper_bind(&hc->device_manager, address, handle);
    111114        return EOK;
    112115}
     
    121124{
    122125        assert(fun);
    123         hc_t *hc = fun_to_hc(fun);
     126        uhci_hc_t *hc = fun_to_uhci_hc(fun);
    124127        assert(hc);
    125128        usb_log_debug("Address release %d.\n", address);
    126         usb_device_keeper_release(&hc->manager, address);
     129        device_keeper_release(&hc->device_manager, address);
    127130        return EOK;
    128131}
     
    139142 * @return Error code.
    140143 */
    141 static 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);
     144static 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);
    150152
    151153        usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n",
    152154            target.address, target.endpoint, size, max_packet_size);
    153155
    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);
     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);
    157159        if (!batch)
    158160                return ENOMEM;
    159161        batch_interrupt_out(batch);
    160         const int ret = hc_schedule(hc, batch);
    161         if (ret != EOK) {
    162                 batch_dispose(batch);
    163         }
    164         return ret;
     162        const int ret = uhci_hc_schedule(hc, batch);
     163        if (ret != EOK) {
     164                batch_dispose(batch);
     165                return ret;
     166        }
     167        return EOK;
    165168}
    166169/*----------------------------------------------------------------------------*/
     
    176179 * @return Error code.
    177180 */
    178 static 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);
     181static 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);
    187189        usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n",
    188190            target.address, target.endpoint, size, max_packet_size);
    189191
    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);
     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);
    193195        if (!batch)
    194196                return ENOMEM;
    195197        batch_interrupt_in(batch);
    196         const int ret = hc_schedule(hc, batch);
    197         if (ret != EOK) {
    198                 batch_dispose(batch);
    199         }
    200         return ret;
     198        const int ret = uhci_hc_schedule(hc, batch);
     199        if (ret != EOK) {
     200                batch_dispose(batch);
     201                return ret;
     202        }
     203        return EOK;
    201204}
    202205/*----------------------------------------------------------------------------*/
     
    212215 * @return Error code.
    213216 */
    214 static 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);
     217static 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);
    223225
    224226        usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n",
    225227            target.address, target.endpoint, size, max_packet_size);
    226228
    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);
     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);
    230232        if (!batch)
    231233                return ENOMEM;
    232234        batch_bulk_out(batch);
    233         const int ret = hc_schedule(hc, batch);
    234         if (ret != EOK) {
    235                 batch_dispose(batch);
    236         }
    237         return ret;
     235        const int ret = uhci_hc_schedule(hc, batch);
     236        if (ret != EOK) {
     237                batch_dispose(batch);
     238                return ret;
     239        }
     240        return EOK;
    238241}
    239242/*----------------------------------------------------------------------------*/
     
    249252 * @return Error code.
    250253 */
    251 static 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);
     254static 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);
    260262        usb_log_debug("Bulk IN %d:%d %zu(%zu).\n",
    261263            target.address, target.endpoint, size, max_packet_size);
    262264
    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);
     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);
    266268        if (!batch)
    267269                return ENOMEM;
    268270        batch_bulk_in(batch);
    269         const int ret = hc_schedule(hc, batch);
    270         if (ret != EOK) {
    271                 batch_dispose(batch);
    272         }
    273         return ret;
     271        const int ret = uhci_hc_schedule(hc, batch);
     272        if (ret != EOK) {
     273                batch_dispose(batch);
     274                return ret;
     275        }
     276        return EOK;
    274277}
    275278/*----------------------------------------------------------------------------*/
     
    279282 * @param[in] target USB device to write to.
    280283 * @param[in] max_packet_size maximum size of data packet the device accepts.
    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).
     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).
    283286 * @param[in] data Source of data.
    284287 * @param[in] size Size of data source.
     
    287290 * @return Error code.
    288291 */
    289 static int control_write(
    290     ddf_fun_t *fun, usb_target_t target, size_t max_packet_size,
     292static int control_write(ddf_fun_t *fun, usb_target_t target,
     293    size_t max_packet_size,
    291294    void *setup_data, size_t setup_size, void *data, size_t size,
    292295    usbhc_iface_transfer_out_callback_t callback, void *arg)
    293296{
    294297        assert(fun);
    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);
     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);
    299301        usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n",
    300302            speed, target.address, target.endpoint, size, max_packet_size);
     
    303305                return EINVAL;
    304306
    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);
     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);
    312313        batch_control_write(batch);
    313         const int ret = hc_schedule(hc, batch);
    314         if (ret != EOK) {
    315                 batch_dispose(batch);
    316         }
    317         return ret;
     314        const int ret = uhci_hc_schedule(hc, batch);
     315        if (ret != EOK) {
     316                batch_dispose(batch);
     317                return ret;
     318        }
     319        return EOK;
    318320}
    319321/*----------------------------------------------------------------------------*/
     
    331333 * @return Error code.
    332334 */
    333 static int control_read(
    334     ddf_fun_t *fun, usb_target_t target, size_t max_packet_size,
     335static int control_read(ddf_fun_t *fun, usb_target_t target,
     336    size_t max_packet_size,
    335337    void *setup_data, size_t setup_size, void *data, size_t size,
    336338    usbhc_iface_transfer_in_callback_t callback, void *arg)
    337339{
    338340        assert(fun);
    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);
     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);
    343344
    344345        usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n",
    345346            speed, target.address, target.endpoint, size, max_packet_size);
    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);
     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);
    350350        if (!batch)
    351351                return ENOMEM;
    352352        batch_control_read(batch);
    353         const int ret = hc_schedule(hc, batch);
    354         if (ret != EOK) {
    355                 batch_dispose(batch);
    356         }
    357         return ret;
    358 }
    359 /*----------------------------------------------------------------------------*/
    360 usbhc_iface_t hc_iface = {
     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/*----------------------------------------------------------------------------*/
     361usbhc_iface_t uhci_hc_iface = {
    361362        .reserve_default_address = reserve_default_address,
    362363        .release_default_address = release_default_address,
     
    368369        .interrupt_in = interrupt_in,
    369370
     371        .bulk_in = bulk_in,
    370372        .bulk_out = bulk_out,
    371         .bulk_in = bulk_in,
    372 
     373
     374        .control_read = control_read,
    373375        .control_write = control_write,
    374         .control_read = control_read,
    375376};
    376377/**
  • uspace/drv/uhci-hcd/iface.h

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

    r55e388a1 r361e61b  
    6262int uhci_add_device(ddf_dev_t *device)
    6363{
    64         usb_log_debug("uhci_add_device() called\n");
     64        usb_log_info("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 initialize UHCI driver: %s.\n",
    75                     str_error(ret));
     74                usb_log_error("Failed to initialzie UHCI driver.\n");
    7675                return ret;
    7776        }
    7877        device->driver_data = uhci;
    79 
    80         usb_log_info("Controlling new UHCI device `%s'.\n", device->name);
    81 
    8278        return EOK;
    8379}
     
    9389int main(int argc, char *argv[])
    9490{
    95         printf(NAME ": HelenOS UHCI driver.\n");
    96 
    9791        sleep(3); /* TODO: remove in final version */
    98         usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
     92        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    9993
    10094        return ddf_driver_main(&uhci_driver);
  • uspace/drv/uhci-hcd/transfer_list.c

    r55e388a1 r361e61b  
    3838
    3939static void transfer_list_remove_batch(
    40     transfer_list_t *instance, usb_transfer_batch_t *batch);
     40    transfer_list_t *instance, batch_t *batch);
    4141/*----------------------------------------------------------------------------*/
    4242/** Initialize transfer list structures.
     
    7979        if (!instance->queue_head)
    8080                return;
    81         /* Set both queue_head.next to point to the follower */
     81        /* Set both next and element to point to the same QH */
    8282        qh_set_next_qh(instance->queue_head, next->queue_head_pa);
     83        qh_set_element_qh(instance->queue_head, next->queue_head_pa);
    8384}
    8485/*----------------------------------------------------------------------------*/
     
    9192 * The batch is added to the end of the list and queue.
    9293 */
    93 void transfer_list_add_batch(
    94     transfer_list_t *instance, usb_transfer_batch_t *batch)
     94void transfer_list_add_batch(transfer_list_t *instance, 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
    100107        fibril_mutex_lock(&instance->guard);
    101108
    102         qh_t *last_qh = NULL;
    103109        /* Add to the hardware queue. */
    104110        if (list_empty(&instance->batch_list)) {
    105111                /* There is nothing scheduled */
    106                 last_qh = instance->queue_head;
     112                qh_t *qh = instance->queue_head;
     113                assert(qh->element == qh->next);
     114                qh_set_element_qh(qh, pa);
    107115        } else {
    108116                /* There is something scheduled */
    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 
     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        }
    120121        /* Add to the driver list */
    121122        list_append(&batch->link, &instance->batch_list);
    122123
    123         usb_transfer_batch_t *first = list_get_instance(
    124             instance->batch_list.next, usb_transfer_batch_t, link);
     124        batch_t *first = list_get_instance(
     125            instance->batch_list.next, batch_t, link);
    125126        usb_log_debug("Batch(%p) added to queue %s, first is %p.\n",
    126127                batch, instance->name, first);
     
    147148        while (current != &instance->batch_list) {
    148149                link_t *next = current->next;
    149                 usb_transfer_batch_t *batch =
    150                     list_get_instance(current, usb_transfer_batch_t, link);
     150                batch_t *batch = list_get_instance(current, batch_t, link);
    151151
    152152                if (batch_is_complete(batch)) {
     
    162162                link_t *item = done.next;
    163163                list_remove(item);
    164                 usb_transfer_batch_t *batch =
    165                     list_get_instance(item, usb_transfer_batch_t, link);
     164                batch_t *batch = list_get_instance(item, batch_t, link);
    166165                batch->next_step(batch);
    167166        }
     
    175174{
    176175        fibril_mutex_lock(&instance->guard);
    177         while (!list_empty(&instance->batch_list)) {
     176        while (list_empty(&instance->batch_list)) {
    178177                link_t *current = instance->batch_list.next;
    179                 usb_transfer_batch_t *batch =
    180                     list_get_instance(current, usb_transfer_batch_t, link);
     178                batch_t *batch = list_get_instance(current, batch_t, link);
    181179                transfer_list_remove_batch(instance, batch);
    182                 usb_transfer_batch_finish(batch, EIO);
     180                batch_finish(batch, EIO);
    183181        }
    184182        fibril_mutex_unlock(&instance->guard);
     
    193191 * Does not lock the transfer list, caller is responsible for that.
    194192 */
    195 void transfer_list_remove_batch(
    196     transfer_list_t *instance, usb_transfer_batch_t *batch)
     193void transfer_list_remove_batch(transfer_list_t *instance, batch_t *batch)
    197194{
    198195        assert(instance);
     
    200197        assert(batch);
    201198        assert(batch_qh(batch));
    202         assert(fibril_mutex_is_locked(&instance->guard));
    203 
    204199        usb_log_debug2(
    205200            "Queue %s: removing batch(%p).\n", instance->name, batch);
    206201
    207         const char *qpos = NULL;
     202        const char * pos = NULL;
    208203        /* Remove from the hardware queue */
    209         if (instance->batch_list.next == &batch->link) {
     204        if (batch->link.prev == &instance->batch_list) {
    210205                /* I'm the first one here */
    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";
     206                qh_set_element_qh(instance->queue_head, batch_qh(batch)->next);
     207                pos = "FIRST";
    215208        } else {
    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 */
     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 */
    225215        list_remove(&batch->link);
    226         usb_log_debug("Batch(%p) removed (%s) from %s, next %x.\n",
    227             batch, qpos, instance->name, batch_qh(batch)->next);
     216        usb_log_debug("Batch(%p) removed (%s) from %s, next element %x.\n",
     217            batch, pos, instance->name, batch_qh(batch)->next);
    228218}
    229219/**
  • uspace/drv/uhci-hcd/transfer_list.h

    r55e388a1 r361e61b  
    3737#include <fibril_synch.h>
    3838
     39#include "uhci_struct/queue_head.h"
     40
    3941#include "batch.h"
    40 #include "hw_struct/queue_head.h"
    4142
    4243typedef struct transfer_list
     
    6566void transfer_list_set_next(transfer_list_t *instance, transfer_list_t *next);
    6667
    67 void transfer_list_add_batch(transfer_list_t *instance, usb_transfer_batch_t *batch);
     68void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch);
    6869
    6970void transfer_list_remove_finished(transfer_list_t *instance);
  • uspace/drv/uhci-hcd/uhci.c

    r55e388a1 r361e61b  
    5454{
    5555        assert(dev);
    56         hc_t *hc = &((uhci_t*)dev->driver_data)->hc;
     56        uhci_hc_t *hc = &((uhci_t*)dev->driver_data)->hc;
    5757        uint16_t status = IPC_GET_ARG1(*call);
    5858        assert(hc);
    59         hc_interrupt(hc, status);
     59        uhci_hc_interrupt(hc, status);
    6060}
    6161/*----------------------------------------------------------------------------*/
     
    7070{
    7171        assert(fun);
    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);
     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);
    7575        if (addr < 0) {
    7676                return addr;
     
    107107};
    108108/*----------------------------------------------------------------------------*/
    109 static ddf_dev_ops_t hc_ops = {
     109static ddf_dev_ops_t uhci_hc_ops = {
    110110        .interfaces[USB_DEV_IFACE] = &usb_iface,
    111         .interfaces[USBHC_DEV_IFACE] = &hc_iface, /* see iface.h/c */
     111        .interfaces[USBHC_DEV_IFACE] = &uhci_hc_iface, /* see iface.h/c */
    112112};
    113113/*----------------------------------------------------------------------------*/
     
    120120{
    121121        assert(fun);
    122         return &((rh_t*)fun->driver_data)->resource_list;
     122        return &((uhci_rh_t*)fun->driver_data)->resource_list;
    123123}
    124124/*----------------------------------------------------------------------------*/
     
    128128};
    129129/*----------------------------------------------------------------------------*/
    130 static ddf_dev_ops_t rh_ops = {
     130static ddf_dev_ops_t uhci_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_debug("I/O regs at 0x%X (size %zu), IRQ %d.\n",
     169        usb_log_info("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
    181177        ret = pci_enable_interrupts(device);
    182178        if (ret != EOK) {
    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");
     179                usb_log_warning(
     180                    "Failed(%d) to enable interrupts, fall back to polling.\n",
     181                    ret);
    187182        } else {
    188183                usb_log_debug("Hw interrupts enabled.\n");
    189184                interrupts = true;
    190185        }
    191 #endif
    192186
    193187        instance->hc_fun = ddf_fun_create(device, fun_exposed, "uhci-hc");
     
    196190            "Failed(%d) to create HC function.\n", ret);
    197191
    198         ret = hc_init(&instance->hc, instance->hc_fun,
     192        ret = uhci_hc_init(&instance->hc, instance->hc_fun,
    199193            (void*)io_reg_base, io_reg_size, interrupts);
    200194        CHECK_RET_DEST_FUN_RETURN(ret, "Failed(%d) to init uhci-hcd.\n", ret);
    201         instance->hc_fun->ops = &hc_ops;
     195        instance->hc_fun->ops = &uhci_hc_ops;
    202196        instance->hc_fun->driver_data = &instance->hc;
    203197        ret = ddf_fun_bind(instance->hc_fun);
     
    214208        if (instance->rh_fun) \
    215209                ddf_fun_destroy(instance->rh_fun); \
    216         hc_fini(&instance->hc); \
     210        uhci_hc_fini(&instance->hc); \
    217211        return ret; \
    218212}
     
    229223            "Failed(%d) to create root hub function.\n", ret);
    230224
    231         ret = rh_init(&instance->rh, instance->rh_fun,
     225        ret = uhci_rh_init(&instance->rh, instance->rh_fun,
    232226            (uintptr_t)instance->hc.registers + 0x10, 4);
    233227        CHECK_RET_FINI_RETURN(ret,
    234228            "Failed(%d) to setup UHCI root hub.\n", ret);
    235229
    236         instance->rh_fun->ops = &rh_ops;
     230        instance->rh_fun->ops = &uhci_rh_ops;
    237231        instance->rh_fun->driver_data = &instance->rh;
    238232        ret = ddf_fun_bind(instance->rh_fun);
  • uspace/drv/uhci-hcd/uhci.h

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

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

    r55e388a1 r361e61b  
    3636#include <device/hw_res.h>
    3737#include <errno.h>
    38 #include <str_error.h>
    3938#include <usb_iface.h>
    4039#include <usb/ddfiface.h>
     
    8786        int ret = hc_get_my_registers(device, &io_regs, &io_size);
    8887        if (ret != EOK) {
    89                 usb_log_error("Failed to get registers from parent HC: %s.\n",
    90                     str_error(ret));
     88                usb_log_error("Failed(%d) to get registers from parent hc.",
     89                    ret);
    9190        }
    92         usb_log_debug("I/O regs at %#X (size %zu).\n", io_regs, io_size);
     91        usb_log_info("I/O regs at %#X (size %zu).\n", io_regs, io_size);
    9392
    9493        uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t));
     
    10099        ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device);
    101100        if (ret != EOK) {
    102                 usb_log_error("Failed to initialize driver instance: %s.\n",
    103                     str_error(ret));
     101                usb_log_error("Failed(%d) to initialize driver instance.\n", ret);
    104102                free(rh);
    105103                return ret;
     
    107105
    108106        device->driver_data = rh;
    109         usb_log_info("Controlling root hub `%s' (%llu).\n",
    110             device->name, device->handle);
     107        usb_log_info("Sucessfully initialized driver instance for device:%d.\n",
     108            device->handle);
    111109        return EOK;
    112110}
     
    131129int main(int argc, char *argv[])
    132130{
    133         printf(NAME ": HelenOS UHCI root hub driver.\n");
    134 
    135         usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
    136 
     131        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    137132        return ddf_driver_main(&uhci_rh_driver);
    138133}
  • uspace/drv/uhci-rhd/port.c

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

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

    r55e388a1 r361e61b  
    184184 *                     successfuly initialize the structure.
    185185 *
    186  * @sa usb_pipe_initialize_from_configuration(),
     186 * @sa usb_endpoint_pipe_initialize_from_configuration(),
    187187 *     usbhid_dev_get_report_descriptor()
    188188 */
     
    192192        assert(hid_dev != NULL);
    193193       
    194         usb_log_debug("Processing descriptors...\n");
     194        usb_log_info("Processing descriptors...\n");
    195195       
    196196        int rc;
     
    218218        };
    219219       
    220         rc = usb_pipe_initialize_from_configuration(
     220        rc = usb_endpoint_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_pipe_initialize_default_control(),
    362  *         usb_pipe_start_session(), usb_pipe_end_session(),
     361 *         usb_endpoint_pipe_initialize_default_control(),
     362 *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
    363363 *         usbhid_dev_process_descriptors().
    364364 *
     
    368368    usb_endpoint_description_t *poll_ep_desc)
    369369{
    370         usb_log_debug("Initializing HID device structure.\n");
     370        usb_log_info("Initializing HID device structure.\n");
    371371       
    372372        if (hid_dev == NULL) {
     
    404404         * Initialize device pipes.
    405405         */
    406         rc = usb_pipe_initialize_default_control(&hid_dev->ctrl_pipe,
     406        rc = usb_endpoint_pipe_initialize_default_control(&hid_dev->ctrl_pipe,
    407407            &hid_dev->wire);
    408408        if (rc != EOK) {
     
    411411                return rc;
    412412        }
    413         rc = usb_pipe_probe_default_control(&hid_dev->ctrl_pipe);
     413        rc = usb_endpoint_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_pipe_start_session(&hid_dev->ctrl_pipe);
     432        rc = usb_endpoint_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_pipe_end_session(&hid_dev->ctrl_pipe);
     442                usb_endpoint_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_pipe_end_session(&hid_dev->ctrl_pipe);
     448        rc = usb_endpoint_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_debug("HID device structure initialized.\n");
     456        usb_log_info("HID device structure initialized.\n");
    457457       
    458458        return EOK;
  • uspace/drv/usbhid/hiddev.h

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

    r55e388a1 r361e61b  
    5757 * @retval EINVAL if no HID device is given.
    5858 * @return Other value inherited from one of functions
    59  *         usb_pipe_start_session(), usb_pipe_end_session(),
     59 *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
    6060 *         usb_control_request_set().
    6161 */
     
    7676        int rc, sess_rc;
    7777       
    78         sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
     78        sess_rc = usb_endpoint_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_pipe_end_session(&hid_dev->ctrl_pipe);
     94        sess_rc = usb_endpoint_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_pipe_start_session(), usb_pipe_end_session(),
     121 *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
    122122 *         usb_control_request_set().
    123123 */
     
    137137        int rc, sess_rc;
    138138       
    139         sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
     139        sess_rc = usb_endpoint_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_pipe_end_session(&hid_dev->ctrl_pipe);
     153        sess_rc = usb_endpoint_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_pipe_start_session(), usb_pipe_end_session(),
     181 *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
    182182 *         usb_control_request_set().
    183183 */
     
    197197        int rc, sess_rc;
    198198       
    199         sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
     199        sess_rc = usb_endpoint_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_pipe_end_session(&hid_dev->ctrl_pipe);
     215        sess_rc = usb_endpoint_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_pipe_start_session(), usb_pipe_end_session(),
     246 *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
    247247 *         usb_control_request_set().
    248248 */
     
    263263        int rc, sess_rc;
    264264       
    265         sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
     265        sess_rc = usb_endpoint_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_pipe_end_session(&hid_dev->ctrl_pipe);
     282        sess_rc = usb_endpoint_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_pipe_start_session(), usb_pipe_end_session(),
     309 *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
    310310 *         usb_control_request_set().
    311311 */
     
    325325        int rc, sess_rc;
    326326       
    327         sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
     327        sess_rc = usb_endpoint_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_pipe_end_session(&hid_dev->ctrl_pipe);
     344        sess_rc = usb_endpoint_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_pipe_start_session(), usb_pipe_end_session(),
     380 *         usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),
    381381 *         usb_control_request_set().
    382382 */
     
    396396        int rc, sess_rc;
    397397       
    398         sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
     398        sess_rc = usb_endpoint_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_pipe_end_session(&hid_dev->ctrl_pipe);
     417        sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe);
    418418
    419419        if (rc != EOK) {
  • uspace/drv/usbhid/kbddev.c

    r55e388a1 r361e61b  
    662662        int rc;
    663663       
    664         usb_log_debug("Initializing HID/KBD structure...\n");
     664        usb_log_info("Initializing HID/KBD structure...\n");
    665665       
    666666        if (kbd_dev == NULL) {
     
    742742       
    743743        kbd_dev->initialized = USBHID_KBD_STATUS_INITIALIZED;
    744         usb_log_debug("HID/KBD device structure initialized.\n");
     744        usb_log_info("HID/KBD device structure initialized.\n");
    745745       
    746746        return EOK;
     
    769769        size_t actual_size;
    770770       
    771         usb_log_debug("Polling keyboard...\n");
     771        usb_log_info("Polling keyboard...\n");
    772772       
    773773        if (!kbd_dev->initialized) {
     
    780780
    781781        while (true) {
    782                 sess_rc = usb_pipe_start_session(
     782                sess_rc = usb_endpoint_pipe_start_session(
    783783                    &kbd_dev->hid_dev->poll_pipe);
    784784                if (sess_rc != EOK) {
     
    788788                }
    789789
    790                 rc = usb_pipe_read(&kbd_dev->hid_dev->poll_pipe,
     790                rc = usb_endpoint_pipe_read(&kbd_dev->hid_dev->poll_pipe,
    791791                    buffer, BOOTP_BUFFER_SIZE, &actual_size);
    792792               
    793                 sess_rc = usb_pipe_end_session(
     793                sess_rc = usb_endpoint_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_debug("Initializing USB/HID KBD device...\n");
     909        usb_log_info("Initializing USB/HID KBD device...\n");
    910910       
    911911        usbhid_kbd_t *kbd_dev = usbhid_kbd_new();
     
    926926        }       
    927927       
    928         usb_log_debug("USB/HID KBD device structure initialized.\n");
     928        usb_log_info("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: %s.\n",
    940                     str_error(rc));
     939                usb_log_error("Could not bind DDF function.\n");
    941940                // TODO: Can / should I destroy the DDF function?
    942941                ddf_fun_destroy(kbd_fun);
     
    947946        rc = ddf_fun_add_to_class(kbd_fun, "keyboard");
    948947        if (rc != EOK) {
    949                 usb_log_error(
    950                     "Could not add DDF function to class 'keyboard': %s.\n",
    951                     str_error(rc));
     948                usb_log_error("Could not add DDF function to class 'keyboard'"
     949                    "\n");
    952950                // TODO: Can / should I destroy the DDF function?
    953951                ddf_fun_destroy(kbd_fun);
     
    961959        fid_t fid = fibril_create(usbhid_kbd_fibril, kbd_dev);
    962960        if (fid == 0) {
    963                 usb_log_error("Failed to start fibril for `%s' device.\n",
    964                     dev->name);
     961                usb_log_error("Failed to start fibril for KBD device\n");
    965962                return ENOMEM;
    966963        }
  • uspace/drv/usbhid/main.c

    r55e388a1 r361e61b  
    3939#include <usb/debug.h>
    4040#include <errno.h>
    41 #include <str_error.h>
    4241
    4342#include "kbddev.h"
     
    6564       
    6665        if (rc != EOK) {
    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;
     66                usb_log_info("Device is not a supported keyboard.\n");
     67                usb_log_error("Failed to add HID device.\n");
     68                return EREFUSED;
    7169        }
    7270       
    73         usb_log_info("Keyboard `%s' ready to use.\n", dev->name);
    74 
    7571        return EOK;
    7672}
     
    9389int main(int argc, char *argv[])
    9490{
    95         printf(NAME ": HelenOS USB HID driver.\n");
    96 
    97         usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
    98 
     91        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    9992        return ddf_driver_main(&kbd_driver);
    10093}
  • uspace/drv/usbhub/main.c

    r55e388a1 r361e61b  
    4242#include "usbhub_private.h"
    4343
    44 /** Hub status-change endpoint description.
    45  *
    46  * For more information see section 11.15.1 of USB 1.1 specification.
    47  */
    48 static usb_endpoint_description_t hub_status_change_endpoint_description = {
     44
     45usb_endpoint_description_t hub_status_change_endpoint_description = {
    4946        .transfer_type = USB_TRANSFER_INTERRUPT,
    5047        .direction = USB_DIRECTION_IN,
     
    6057};
    6158
    62 static usb_endpoint_description_t *usb_hub_endpoints[] = {
    63         &hub_status_change_endpoint_description,
    64         NULL
    65 };
    66 
    6759static usb_driver_t usb_hub_driver = {
    68         .name = NAME,
    69         .ops = &usb_hub_driver_ops,
    70         .endpoints = usb_hub_endpoints
     60        .name = "usbhub",
     61        .ops = &usb_hub_driver_ops
    7162};
    7263
     
    7465int main(int argc, char *argv[])
    7566{
    76         printf(NAME ": HelenOS USB hub driver.\n");
     67        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     68        usb_log_info("starting hub driver\n");
    7769
    78         usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
    7970       
     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
    8076        return usb_driver_main(&usb_hub_driver);
    8177}
  • uspace/drv/usbhub/usbhub.c

    r55e388a1 r361e61b  
    132132                return opResult;
    133133        }
    134         usb_log_debug("setting port count to %d\n",descriptor->ports_count);
     134        usb_log_info("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             = &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){
     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){
    164170                usb_log_error("THERE ARE NO CONFIGURATIONS AVAILABLE\n");
    165171                //shouldn`t I return?
    166                 //definitely
    167                 return EINVAL;
    168         }
    169 
     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        }
    170185        usb_standard_configuration_descriptor_t *config_descriptor
    171             = (usb_standard_configuration_descriptor_t *)
    172             hub_info->usb_device->descriptors.configuration;
     186            = (usb_standard_configuration_descriptor_t *) descriptors;
    173187
    174188        /* Set configuration. */
    175         int opResult = usb_request_set_configuration(
    176             &hub_info->usb_device->ctrl_pipe,
     189        opResult = usb_request_set_configuration(&hub_info->usb_device->ctrl_pipe,
    177190            config_descriptor->configuration_number);
    178191
     
    184197        usb_log_debug("\tused configuration %d\n",
    185198                        config_descriptor->configuration_number);
    186 
     199        free(descriptors);
    187200        return EOK;
    188201}
     
    211224        }
    212225       
    213         usb_pipe_start_session(hub_info->control_pipe);
     226        usb_endpoint_pipe_start_session(hub_info->control_pipe);
    214227        //set hub configuration
    215228        opResult = usb_hub_set_configuration(hub_info);
     
    226239                return opResult;
    227240        }
    228         usb_pipe_end_session(hub_info->control_pipe);
     241        usb_endpoint_pipe_end_session(hub_info->control_pipe);
    229242
    230243
    231244        /// \TODO what is this?
    232         usb_log_debug("Creating `hub' function.\n");
     245        usb_log_debug("adding to ddf");
    233246        ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev,
    234247                        fun_exposed, "hub");
     
    244257        fid_t fid = fibril_create(usb_hub_control_loop, hub_info);
    245258        if (fid == 0) {
    246                 usb_log_error("failed to start monitoring fibril for new hub.\n");
     259                usb_log_error("failed to start monitoring fibril for new hub");
    247260                return ENOMEM;
    248261        }
    249262        fibril_add_ready(fid);
    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);
     263        usb_log_debug("hub fibril created");
     264        usb_log_debug("has %d ports ",hub_info->port_count);
    254265        return EOK;
    255266}
     
    290301        //if this hub already uses default address, it cannot request it once more
    291302        if(hub->is_default_address_used) return;
    292         usb_log_debug("some connection changed\n");
     303        usb_log_info("some connection changed\n");
    293304        assert(hub->control_pipe->hc_phone);
    294305        int opResult = usb_hub_clear_port_feature(hub->control_pipe,
     
    310321        //reset port
    311322        usb_hub_set_reset_port_request(&request, port);
    312         opResult = usb_pipe_control_write(
     323        opResult = usb_endpoint_pipe_control_write(
    313324                        hub->control_pipe,
    314325                        &request,sizeof(usb_device_request_setup_packet_t),
     
    333344
    334345        int opResult;
    335         usb_log_debug("finalizing add device\n");
     346        usb_log_info("finalizing add device\n");
    336347        opResult = usb_hub_clear_port_feature(hub->control_pipe,
    337348            port, USB_HUB_FEATURE_C_PORT_RESET);
     
    343354        }
    344355        //create connection to device
    345         usb_pipe_t new_device_pipe;
     356        usb_endpoint_pipe_t new_device_pipe;
    346357        usb_device_connection_t new_device_connection;
    347358        usb_device_connection_initialize_on_default_address(
     
    349360                        &hub->connection
    350361                        );
    351         usb_pipe_initialize_default_control(
     362        usb_endpoint_pipe_initialize_default_control(
    352363                        &new_device_pipe,
    353364                        &new_device_connection);
    354         usb_pipe_probe_default_control(&new_device_pipe);
     365        usb_endpoint_pipe_probe_default_control(&new_device_pipe);
    355366
    356367        /* Request address from host controller. */
     
    365376                return;
    366377        }
    367         usb_log_debug("setting new address %d\n",new_device_address);
     378        usb_log_info("setting new address %d\n",new_device_address);
    368379        //opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
    369380        //    new_device_address);
    370         usb_pipe_start_session(&new_device_pipe);
     381        usb_endpoint_pipe_start_session(&new_device_pipe);
    371382        opResult = usb_request_set_address(&new_device_pipe,new_device_address);
    372         usb_pipe_end_session(&new_device_pipe);
     383        usb_endpoint_pipe_end_session(&new_device_pipe);
    373384        if (opResult != EOK) {
    374385                usb_log_error("could not set address for new device %d\n",opResult);
     
    405416                return;
    406417        }
    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,
     418        usb_log_info("new device address %d, handle %zu\n",
    410419            new_device_address, child_handle);
     420
    411421}
    412422
     
    478488        usb_log_debug("interrupt at port %d\n", port);
    479489        //determine type of change
    480         usb_pipe_t *pipe = hub->control_pipe;
     490        usb_endpoint_pipe_t *pipe = hub->control_pipe;
    481491       
    482492        int opResult;
     
    489499        //endpoint 0
    490500
    491         opResult = usb_pipe_control_read(
     501        opResult = usb_endpoint_pipe_control_read(
    492502                        pipe,
    493503                        &request, sizeof(usb_device_request_setup_packet_t),
     
    505515        if (usb_port_connect_change(&status)) {
    506516                if (usb_port_dev_connected(&status)) {
    507                         usb_log_debug("some connection changed\n");
     517                        usb_log_info("some connection changed\n");
    508518                        usb_hub_init_add_device(hub, port, usb_port_speed(&status));
    509519                } else {
     
    517527                        usb_hub_over_current(hub,port);
    518528                }else{
    519                         usb_log_debug("over current condition was auto-resolved on port %d\n",
     529                        usb_log_info("over current condition was auto-resolved on port %d\n",
    520530                                        port);
    521531                }
     
    523533        //port reset
    524534        if (usb_port_reset_completed(&status)) {
    525                 usb_log_debug("port reset complete\n");
     535                usb_log_info("port reset complete");
    526536                if (usb_port_enabled(&status)) {
    527537                        usb_hub_finalize_add_device(hub, port, usb_port_speed(&status));
     
    550560int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){
    551561        int opResult;
    552         opResult = usb_pipe_start_session(
     562        opResult = usb_endpoint_pipe_start_session(
    553563                        hub_info->status_change_pipe);
    554564        if(opResult != EOK){
     
    568578         * Send the request.
    569579         */
    570         opResult = usb_pipe_read(
     580        opResult = usb_endpoint_pipe_read(
    571581                        hub_info->status_change_pipe,
    572582                        change_bitmap, byte_length, &actual_size
     
    576586                free(change_bitmap);
    577587                usb_log_warning("something went wrong while getting status of hub\n");
    578                 usb_pipe_end_session(hub_info->status_change_pipe);
     588                usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
    579589                return opResult;
    580590        }
    581591        unsigned int port;
    582         opResult = usb_pipe_start_session(hub_info->control_pipe);
     592        opResult = usb_endpoint_pipe_start_session(hub_info->control_pipe);
    583593        if(opResult!=EOK){
    584594                usb_log_error("could not start control pipe session %d\n", opResult);
    585                 usb_pipe_end_session(hub_info->status_change_pipe);
     595                usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
    586596                return opResult;
    587597        }
     
    590600                usb_log_error("could not start host controller session %d\n",
    591601                                opResult);
    592                 usb_pipe_end_session(hub_info->control_pipe);
    593                 usb_pipe_end_session(hub_info->status_change_pipe);
     602                usb_endpoint_pipe_end_session(hub_info->control_pipe);
     603                usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
    594604                return opResult;
    595605        }
     
    605615        }
    606616        usb_hc_connection_close(&hub_info->connection);
    607         usb_pipe_end_session(hub_info->control_pipe);
    608         usb_pipe_end_session(hub_info->status_change_pipe);
     617        usb_endpoint_pipe_end_session(hub_info->control_pipe);
     618        usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
    609619        free(change_bitmap);
    610620        return EOK;
  • uspace/drv/usbhub/usbhub.h

    r55e388a1 r361e61b  
    4848
    4949
     50/** Hub status-change endpoint description
     51 *
     52 * For more see usb hub specification in 11.15.1 of
     53 */
     54extern 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
    5066/** Information about attached hub. */
    5167typedef struct {
     
    7288         * searched again and again for the 'right pipe'.
    7389         */
    74         usb_pipe_t * status_change_pipe;
     90        usb_endpoint_pipe_t * status_change_pipe;
    7591
    7692        /** convenience pointer to control pipe
     
    8096         * searched again and again for the 'right pipe'.
    8197         */
    82         usb_pipe_t * control_pipe;
     98        usb_endpoint_pipe_t * control_pipe;
    8399
    84100        /** generic usb device data*/
  • uspace/drv/usbhub/usbhub_private.h

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

    r55e388a1 r361e61b  
    6161        int rc;
    6262
    63         rc = usb_pipe_start_session(&dev->ctrl_pipe);
     63        rc = usb_endpoint_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_pipe_end_session(&dev->ctrl_pipe);
     72        rc = usb_endpoint_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_DEFAULT, NAME);
     108        usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
    109109        return ddf_driver_main(&mid_driver);
    110110}
  • uspace/drv/usbmid/usbmid.c

    r55e388a1 r361e61b  
    108108        }
    109109
    110         rc = usb_pipe_initialize_default_control(&mid->ctrl_pipe,
     110        rc = usb_endpoint_pipe_initialize_default_control(&mid->ctrl_pipe,
    111111            &mid->wire);
    112112        if (rc != EOK) {
     
    116116                return NULL;
    117117        }
    118         rc = usb_pipe_probe_default_control(&mid->ctrl_pipe);
     118        rc = usb_endpoint_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

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

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

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

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

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

    r55e388a1 r361e61b  
    3838#include <usb/pipes.h>
    3939
    40 /** Descriptors for USB device. */
    41 typedef 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 
    4940/** USB device structure. */
    5041typedef struct {
    5142        /** The default control pipe. */
    52         usb_pipe_t ctrl_pipe;
     43        usb_endpoint_pipe_t ctrl_pipe;
    5344        /** Other endpoint pipes.
    5445         * This is an array of other endpoint pipes in the same order as
     
    6152         */
    6253        int interface_no;
    63 
    64         /** Some useful descriptors. */
    65         usb_device_descriptors_t descriptors;
    66 
    6754        /** Generic DDF device backing this one. */
    6855        ddf_dev_t *ddf_dev;
  • uspace/lib/usb/include/usb/host/batch.h

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

    r55e388a1 r361e61b  
    3131 */
    3232/** @file
    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.
     33 * @brief UHCI driver
    3934 */
    4035#ifndef LIBUSB_HOST_DEVICE_KEEPER_H
     
    4439#include <usb/usb.h>
    4540
    46 /** Number of USB address for array dimensions. */
    4741#define USB_ADDRESS_COUNT (USB11_ADDRESS_MAX + 1)
    4842
    49 /** Information about attached USB device. */
    5043struct usb_device_info {
    5144        usb_speed_t speed;
     
    5548};
    5649
    57 /** Host controller device keeper.
    58  * You shall not access members directly but only using functions below.
    59  */
    60 typedef struct {
     50typedef struct device_keeper {
    6151        struct usb_device_info devices[USB_ADDRESS_COUNT];
    6252        fibril_mutex_t guard;
    6353        fibril_condvar_t default_address_occupied;
    6454        usb_address_t last_address;
    65 } usb_device_keeper_t;
     55} device_keeper_t;
    6656
    67 void usb_device_keeper_init(usb_device_keeper_t *instance);
     57void device_keeper_init(device_keeper_t *instance);
    6858
    69 void usb_device_keeper_reserve_default_address(usb_device_keeper_t *instance,
    70     usb_speed_t speed);
     59void device_keeper_reserve_default(
     60    device_keeper_t *instance, usb_speed_t speed);
    7161
    72 void usb_device_keeper_release_default_address(usb_device_keeper_t *instance);
     62void device_keeper_release_default(device_keeper_t *instance);
    7363
    74 void usb_device_keeper_reset_if_need(usb_device_keeper_t *instance,
    75     usb_target_t target,
    76     const uint8_t *setup_data);
     64void device_keeper_reset_if_need(
     65    device_keeper_t *instance, usb_target_t target,
     66    const unsigned char *setup_data);
    7767
    78 int usb_device_keeper_get_toggle(usb_device_keeper_t *instance,
    79     usb_target_t target, usb_direction_t direction);
     68int device_keeper_get_toggle(
     69    device_keeper_t *instance, usb_target_t target, usb_direction_t direction);
    8070
    81 int usb_device_keeper_set_toggle(usb_device_keeper_t *instance,
     71int device_keeper_set_toggle(device_keeper_t *instance,
    8272    usb_target_t target, usb_direction_t direction, bool toggle);
    8373
    84 usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance,
    85     usb_speed_t speed);
     74usb_address_t device_keeper_request(
     75    device_keeper_t *instance, usb_speed_t speed);
    8676
    87 void usb_device_keeper_bind(usb_device_keeper_t *instance,
    88     usb_address_t address, devman_handle_t handle);
     77void device_keeper_bind(
     78    device_keeper_t *instance, usb_address_t address, devman_handle_t handle);
    8979
    90 void usb_device_keeper_release(usb_device_keeper_t *instance,
    91     usb_address_t address);
     80void device_keeper_release(device_keeper_t *instance, usb_address_t address);
    9281
    93 usb_address_t usb_device_keeper_find(usb_device_keeper_t *instance,
    94     devman_handle_t handle);
     82usb_address_t device_keeper_find(
     83    device_keeper_t *instance, devman_handle_t handle);
    9584
    96 usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance,
    97     usb_address_t address);
    98 
     85usb_speed_t device_keeper_speed(
     86    device_keeper_t *instance, usb_address_t address);
    9987#endif
    10088/**
  • uspace/lib/usb/include/usb/pipes.h

    r55e388a1 r361e61b  
    8080         */
    8181        int hc_phone;
    82 } usb_pipe_t;
     82} usb_endpoint_pipe_t;
    8383
    8484
     
    102102typedef struct {
    103103        /** Endpoint pipe. */
    104         usb_pipe_t *pipe;
     104        usb_endpoint_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_pipe_initialize(usb_pipe_t *, usb_device_connection_t *,
     127int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *,
     128    usb_device_connection_t *,
    128129    usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t);
    129 int usb_pipe_initialize_default_control(usb_pipe_t *,
     130int usb_endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *,
    130131    usb_device_connection_t *);
    131 int usb_pipe_probe_default_control(usb_pipe_t *);
    132 int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
     132int usb_endpoint_pipe_probe_default_control(usb_endpoint_pipe_t *);
     133int usb_endpoint_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
    133134    size_t, uint8_t *, size_t, usb_device_connection_t *);
    134 int usb_pipe_register(usb_pipe_t *, unsigned int, usb_hc_connection_t *);
    135 int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *);
     135int usb_endpoint_pipe_register(usb_endpoint_pipe_t *, unsigned int,
     136    usb_hc_connection_t *);
     137int usb_endpoint_pipe_unregister(usb_endpoint_pipe_t *, usb_hc_connection_t *);
    136138
    137 int usb_pipe_start_session(usb_pipe_t *);
    138 int usb_pipe_end_session(usb_pipe_t *);
    139 bool usb_pipe_is_session_started(usb_pipe_t *);
     139int usb_endpoint_pipe_start_session(usb_endpoint_pipe_t *);
     140int usb_endpoint_pipe_end_session(usb_endpoint_pipe_t *);
     141bool usb_endpoint_pipe_is_session_started(usb_endpoint_pipe_t *);
    140142
    141 int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
    142 int usb_pipe_write(usb_pipe_t *, void *, size_t);
     143int usb_endpoint_pipe_read(usb_endpoint_pipe_t *, void *, size_t, size_t *);
     144int usb_endpoint_pipe_write(usb_endpoint_pipe_t *, void *, size_t);
    143145
    144 int usb_pipe_control_read(usb_pipe_t *, void *, size_t,
     146int usb_endpoint_pipe_control_read(usb_endpoint_pipe_t *, void *, size_t,
    145147    void *, size_t, size_t *);
    146 int usb_pipe_control_write(usb_pipe_t *, void *, size_t,
     148int usb_endpoint_pipe_control_write(usb_endpoint_pipe_t *, void *, size_t,
    147149    void *, size_t);
    148150
  • uspace/lib/usb/include/usb/recognise.h

    r55e388a1 r361e61b  
    4848    const usb_standard_interface_descriptor_t *, match_id_list_t *);
    4949
    50 int usb_device_create_match_ids(usb_pipe_t *, match_id_list_t *);
     50int usb_device_create_match_ids(usb_endpoint_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

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

    r55e388a1 r361e61b  
    6161
    6262const char * usb_str_transfer_type(usb_transfer_type_t t);
    63 const char * usb_str_transfer_type_short(usb_transfer_type_t t);
    6463
    6564/** USB data transfer direction. */
     
    7978        USB_SPEED_HIGH
    8079} usb_speed_t;
    81 
    82 const char *usb_str_speed(usb_speed_t);
    83 
    8480
    8581/** USB request type target. */
  • uspace/lib/usb/src/devdrv.c

    r55e388a1 r361e61b  
    126126
    127127        for (i = 0; i < pipe_count; i++) {
    128                 dev->pipes[i].pipe = malloc(sizeof(usb_pipe_t));
     128                dev->pipes[i].pipe = malloc(sizeof(usb_endpoint_pipe_t));
    129129                if (dev->pipes[i].pipe == NULL) {
    130130                        usb_log_oom(dev->ddf_dev);
     
    137137        }
    138138
    139         rc = usb_pipe_initialize_from_configuration(dev->pipes, pipe_count,
    140             dev->descriptors.configuration, dev->descriptors.configuration_size,
    141             &dev->wire);
     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);
    142151        if (rc != EOK) {
    143152                usb_log_error("Failed initializing USB endpoints: %s.\n",
     
    163172        for (i = 0; i < pipe_count; i++) {
    164173                if (dev->pipes[i].present) {
    165                         rc = usb_pipe_register(dev->pipes[i].pipe,
     174                        rc = usb_endpoint_pipe_register(dev->pipes[i].pipe,
    166175                            dev->pipes[i].descriptor->poll_interval,
    167176                            &hc_conn);
     
    210219        }
    211220
    212         rc = usb_pipe_initialize_default_control(&dev->ctrl_pipe,
     221        rc = usb_endpoint_pipe_initialize_default_control(&dev->ctrl_pipe,
    213222            &dev->wire);
    214223        if (rc != EOK) {
     
    219228        }
    220229
    221         rc = usb_pipe_probe_default_control(&dev->ctrl_pipe);
     230        rc = usb_endpoint_pipe_probe_default_control(&dev->ctrl_pipe);
    222231        if (rc != EOK) {
    223232                usb_log_error(
     
    228237
    229238        /*
    230          * For further actions, we need open session on default control pipe.
     239         * Initialization of other pipes requires open session on
     240         * default control pipe.
    231241         */
    232         rc = usb_pipe_start_session(&dev->ctrl_pipe);
     242        rc = usb_endpoint_pipe_start_session(&dev->ctrl_pipe);
    233243        if (rc != EOK) {
    234244                usb_log_error("Failed to start an IPC session: %s.\n",
    235245                    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));
    255246                return rc;
    256247        }
     
    261252
    262253        /* No checking here. */
    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         }
     254        usb_endpoint_pipe_end_session(&dev->ctrl_pipe);
    271255
    272256        return rc;
     
    299283        dev->ddf_dev->driver_data = dev;
    300284        dev->driver_data = NULL;
    301         dev->descriptors.configuration = NULL;
    302285
    303286        rc = initialize_pipes(dev);
  • uspace/lib/usb/src/devpoll.c

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

    r55e388a1 r361e61b  
    8484{
    8585   if(parser == NULL) {
    86         return EINVAL;
     86        return -1;
    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         }
    121117       
    122118
     
    132128
    133129                        if((i+USB_HID_ITEM_SIZE(data[i]))>= size){
    134                                 return EINVAL; // TODO ERROR CODE
     130                                return -1; // TODO ERROR CODE
    135131                        }
    136132                       
     
    534530void usb_hid_descriptor_print(usb_hid_report_parser_t *parser)
    535531{
    536         if(parser == NULL) {
    537                 return;
    538         }
    539        
    540532        usb_log_debug("INPUT:\n");
    541533        usb_hid_descriptor_print_list(&parser->input);
     
    623615        size_t j=0;
    624616
    625         if(parser == NULL) {
    626                 return EINVAL;
    627         }
    628 
    629        
    630617        // get the size of result keycodes array
    631618        usb_hid_report_path_t path;
     
    750737int usb_hid_report_input_length(const usb_hid_report_parser_t *parser,
    751738        const usb_hid_report_path_t *path)
    752 {       
     739{
    753740        int ret = 0;
    754741        link_t *item;
    755742        usb_hid_report_item_t *report_item;
    756743
    757         if(parser == NULL) {
    758                 return EINVAL;
    759         }
    760        
    761744        item = (&parser->input)->next;
    762745        while(&parser->input != item) {
  • uspace/lib/usb/src/host/batch.c

    r55e388a1 r361e61b  
    3030 */
    3131/** @file
    32  * USB transfer transaction structures (implementation).
     32 * @brief OHCI driver USB transaction structure
    3333 */
    3434#include <errno.h>
     
    3939#include <usb/host/batch.h>
    4040
    41 void usb_transfer_batch_init(
    42     usb_transfer_batch_t *instance,
     41void batch_init(
     42    batch_t *instance,
    4343    usb_target_t target,
    4444    usb_transfer_type_t transfer_type,
     
    8585 *
    8686 */
    87 void usb_transfer_batch_finish(usb_transfer_batch_t *instance, int error)
     87void batch_finish(batch_t *instance, int error)
    8888{
    8989        assert(instance);
     
    9898 * parameters.
    9999 */
    100 void usb_transfer_batch_call_in(usb_transfer_batch_t *instance)
     100void batch_call_in(batch_t *instance)
    101101{
    102102        assert(instance);
     
    107107            instance->buffer_size);
    108108
    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);
     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);
    116113
    117         instance->callback_in(instance->fun, instance->error,
    118             instance->transfered_size, instance->arg);
     114        instance->callback_in(
     115            instance->fun, err, instance->transfered_size, instance->arg);
    119116}
    120117/*----------------------------------------------------------------------------*/
     
    123120 * @param[in] instance Batch structure to use.
    124121 */
    125 void usb_transfer_batch_call_out(usb_transfer_batch_t *instance)
     122void batch_call_out(batch_t *instance)
    126123{
    127124        assert(instance);
    128125        assert(instance->callback_out);
    129126
    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 
     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);
    137130        instance->callback_out(instance->fun,
    138             instance->error, instance->arg);
     131            err, instance->arg);
    139132}
    140133/**
  • uspace/lib/usb/src/host/device_keeper.c

    r55e388a1 r361e61b  
    3131 */
    3232/** @file
    33  * Device keeper structure and functions (implementation).
     33 * @brief UHCI driver
    3434 */
    3535#include <assert.h>
     
    4545 * Set all values to false/0.
    4646 */
    47 void usb_device_keeper_init(usb_device_keeper_t *instance)
     47void device_keeper_init(device_keeper_t *instance)
    4848{
    4949        assert(instance);
     
    6565 * @param[in] speed Speed of the device requesting default address.
    6666 */
    67 void usb_device_keeper_reserve_default_address(usb_device_keeper_t *instance,
    68     usb_speed_t speed)
     67void device_keeper_reserve_default(device_keeper_t *instance, usb_speed_t speed)
    6968{
    7069        assert(instance);
     
    8483 * @param[in] speed Speed of the device requesting default address.
    8584 */
    86 void usb_device_keeper_release_default_address(usb_device_keeper_t *instance)
     85void device_keeper_release_default(device_keeper_t *instance)
    8786{
    8887        assert(instance);
     
    101100 * Really ugly one.
    102101 */
    103 void usb_device_keeper_reset_if_need(usb_device_keeper_t *instance,
    104     usb_target_t target, const uint8_t *data)
     102void device_keeper_reset_if_need(
     103    device_keeper_t *instance, usb_target_t target, const unsigned char *data)
    105104{
    106105        assert(instance);
     
    145144 * @return Error code
    146145 */
    147 int usb_device_keeper_get_toggle(usb_device_keeper_t *instance,
    148     usb_target_t target, usb_direction_t direction)
     146int device_keeper_get_toggle(
     147    device_keeper_t *instance, usb_target_t target, usb_direction_t direction)
    149148{
    150149        assert(instance);
     
    174173 * @return Error code.
    175174 */
    176 int usb_device_keeper_set_toggle(usb_device_keeper_t *instance,
     175int device_keeper_set_toggle(device_keeper_t *instance,
    177176    usb_target_t target, usb_direction_t direction, bool toggle)
    178177{
     
    208207 * @return Free address, or error code.
    209208 */
    210 usb_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;
     209usb_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) {
    221217                if (new_address == instance->last_address) {
    222218                        fibril_mutex_unlock(&instance->guard);
    223219                        return ENOSPC;
    224220                }
    225         } while (instance->devices[new_address].occupied);
     221                if (new_address == USB11_ADDRESS_MAX)
     222                        new_address = 1;
     223                ++new_address;
     224        }
    226225
    227226        assert(new_address != USB_ADDRESS_DEFAULT);
     
    242241 * @param[in] handle Devman handle of the device.
    243242 */
    244 void usb_device_keeper_bind(usb_device_keeper_t *instance,
    245     usb_address_t address, devman_handle_t handle)
     243void device_keeper_bind(
     244    device_keeper_t *instance, usb_address_t address, devman_handle_t handle)
    246245{
    247246        assert(instance);
     
    259258 * @param[in] address Device address
    260259 */
    261 void usb_device_keeper_release(usb_device_keeper_t *instance,
    262     usb_address_t address)
     260void device_keeper_release(device_keeper_t *instance, usb_address_t address)
    263261{
    264262        assert(instance);
     
    278276 * @return USB Address, or error code.
    279277 */
    280 usb_address_t usb_device_keeper_find(usb_device_keeper_t *instance,
    281     devman_handle_t handle)
     278usb_address_t device_keeper_find(
     279    device_keeper_t *instance, devman_handle_t handle)
    282280{
    283281        assert(instance);
     
    301299 * @return USB speed.
    302300 */
    303 usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance,
    304     usb_address_t address)
     301usb_speed_t device_keeper_speed(
     302    device_keeper_t *instance, usb_address_t address)
    305303{
    306304        assert(instance);
     
    309307        return instance->devices[address].speed;
    310308}
    311 
    312309/**
    313310 * @}
  • uspace/lib/usb/src/hub.c

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

    r55e388a1 r361e61b  
    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_pipe_end_session() - after the last
     235 * and ended - see usb_endpoint_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_pipe_start_session(usb_pipe_t *pipe)
     246int usb_endpoint_pipe_start_session(usb_endpoint_pipe_t *pipe)
    247247{
    248248        assert(pipe);
    249249
    250         if (usb_pipe_is_session_started(pipe)) {
     250        if (usb_endpoint_pipe_is_session_started(pipe)) {
    251251                return EBUSY;
    252252        }
     
    265265/** Ends a session on the endpoint pipe.
    266266 *
    267  * @see usb_pipe_start_session
     267 * @see usb_endpoint_pipe_start_session
    268268 *
    269269 * @param pipe Endpoint pipe to end the session on.
    270270 * @return Error code.
    271271 */
    272 int usb_pipe_end_session(usb_pipe_t *pipe)
     272int usb_endpoint_pipe_end_session(usb_endpoint_pipe_t *pipe)
    273273{
    274274        assert(pipe);
    275275
    276         if (!usb_pipe_is_session_started(pipe)) {
     276        if (!usb_endpoint_pipe_is_session_started(pipe)) {
    277277                return ENOENT;
    278278        }
     
    296296 * @return Whether @p pipe has opened a session.
    297297 */
    298 bool usb_pipe_is_session_started(usb_pipe_t *pipe)
     298bool usb_endpoint_pipe_is_session_started(usb_endpoint_pipe_t *pipe)
    299299{
    300300        return (pipe->hc_phone >= 0);
  • uspace/lib/usb/src/pipesinit.c

    r55e388a1 r361e61b  
    193193        }
    194194
    195         int rc = usb_pipe_initialize(ep_mapping->pipe, wire,
     195        int rc = usb_endpoint_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_pipe_initialize_from_configuration(
     278int usb_endpoint_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_pipe_initialize(usb_pipe_t *pipe,
     344int usb_endpoint_pipe_initialize(usb_endpoint_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_pipe_initialize_default_control(usb_pipe_t *pipe,
     369int usb_endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *pipe,
    370370    usb_device_connection_t *connection)
    371371{
     
    373373        assert(connection);
    374374
    375         int rc = usb_pipe_initialize(pipe, connection,
     375        int rc = usb_endpoint_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_pipe_probe_default_control(usb_pipe_t *pipe)
     392int usb_endpoint_pipe_probe_default_control(usb_endpoint_pipe_t *pipe)
    393393{
    394394        assert(pipe);
     
    408408
    409409        TRY_LOOP(failed_attempts) {
    410                 rc = usb_pipe_start_session(pipe);
     410                rc = usb_endpoint_pipe_start_session(pipe);
    411411                if (rc == EOK) {
    412412                        break;
     
    433433                }
    434434        }
    435         usb_pipe_end_session(pipe);
     435        usb_endpoint_pipe_end_session(pipe);
    436436        if (rc != EOK) {
    437437                return rc;
     
    451451 * @return Error code.
    452452 */
    453 int usb_pipe_register(usb_pipe_t *pipe,
     453int usb_endpoint_pipe_register(usb_endpoint_pipe_t *pipe,
    454454    unsigned int interval,
    455455    usb_hc_connection_t *hc_connection)
     
    479479 * @return Error code.
    480480 */
    481 int usb_pipe_unregister(usb_pipe_t *pipe,
     481int usb_endpoint_pipe_unregister(usb_endpoint_pipe_t *pipe,
    482482    usb_hc_connection_t *hc_connection)
    483483{
  • uspace/lib/usb/src/pipesio.c

    r55e388a1 r361e61b  
    5858 * @return Error code.
    5959 */
    60 static int usb_pipe_read_no_checks(usb_pipe_t *pipe,
     60static int usb_endpoint_pipe_read_no_checks(usb_endpoint_pipe_t *pipe,
    6161    void *buffer, size_t size, size_t *size_transfered)
    6262{
     
    140140 * @return Error code.
    141141 */
    142 int usb_pipe_read(usb_pipe_t *pipe,
     142int usb_endpoint_pipe_read(usb_endpoint_pipe_t *pipe,
    143143    void *buffer, size_t size, size_t *size_transfered)
    144144{
     
    153153        }
    154154
    155         if (!usb_pipe_is_session_started(pipe)) {
     155        if (!usb_endpoint_pipe_is_session_started(pipe)) {
    156156                return EBADF;
    157157        }
     
    168168        int rc;
    169169
    170         rc = usb_pipe_read_no_checks(pipe, buffer, size, &act_size);
     170        rc = usb_endpoint_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_pipe_write_no_check(usb_pipe_t *pipe,
     192static int usb_endpoint_pipe_write_no_check(usb_endpoint_pipe_t *pipe,
    193193    void *buffer, size_t size)
    194194{
     
    247247 * @return Error code.
    248248 */
    249 int usb_pipe_write(usb_pipe_t *pipe,
     249int usb_endpoint_pipe_write(usb_endpoint_pipe_t *pipe,
    250250    void *buffer, size_t size)
    251251{
     
    260260        }
    261261
    262         if (!usb_pipe_is_session_started(pipe)) {
     262        if (!usb_endpoint_pipe_is_session_started(pipe)) {
    263263                return EBADF;
    264264        }
     
    272272        }
    273273
    274         int rc = usb_pipe_write_no_check(pipe, buffer, size);
     274        int rc = usb_endpoint_pipe_write_no_check(pipe, buffer, size);
    275275
    276276        return rc;
     
    289289 * @return Error code.
    290290 */
    291 static int usb_pipe_control_read_no_check(usb_pipe_t *pipe,
     291static int usb_endpoint_pipe_control_read_no_check(usb_endpoint_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_pipe_control_read(usb_pipe_t *pipe,
     367int usb_endpoint_pipe_control_read(usb_endpoint_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_pipe_is_session_started(pipe)) {
     381        if (!usb_endpoint_pipe_is_session_started(pipe)) {
    382382                return EBADF;
    383383        }
     
    389389
    390390        size_t act_size = 0;
    391         int rc = usb_pipe_control_read_no_check(pipe,
     391        int rc = usb_endpoint_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_pipe_control_write_no_check(usb_pipe_t *pipe,
     416static int usb_endpoint_pipe_control_write_no_check(usb_endpoint_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_pipe_control_write(usb_pipe_t *pipe,
     475int usb_endpoint_pipe_control_write(usb_endpoint_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_pipe_is_session_started(pipe)) {
     493        if (!usb_endpoint_pipe_is_session_started(pipe)) {
    494494                return EBADF;
    495495        }
     
    500500        }
    501501
    502         int rc = usb_pipe_control_write_no_check(pipe,
     502        int rc = usb_endpoint_pipe_control_write_no_check(pipe,
    503503            setup_buffer, setup_buffer_size, data_buffer, data_buffer_size);
    504504
  • uspace/lib/usb/src/recognise.c

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

    r55e388a1 r361e61b  
    4242/** Generic wrapper for SET requests using standard control request format.
    4343 *
    44  * @see usb_pipe_control_write
     44 * @see usb_endpoint_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_pipe_t *pipe,
     62int usb_control_request_set(usb_endpoint_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_pipe_control_write(pipe,
     92        int rc = usb_endpoint_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_pipe_control_read
     101  * @see usb_endpoint_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_pipe_t *pipe,
     122int usb_control_request_get(usb_endpoint_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_pipe_control_read(pipe,
     152        int rc = usb_endpoint_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_pipe_t *pipe,
     167int usb_request_get_status(usb_endpoint_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_pipe_t *pipe,
     205int usb_request_clear_feature(usb_endpoint_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_pipe_t *pipe,
     233int usb_request_set_feature(usb_endpoint_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_pipe_t *pipe,
     260int usb_request_set_address(usb_endpoint_pipe_t *pipe,
    261261    usb_address_t new_address)
    262262{
     
    297297 * @return Error code.
    298298 */
    299 int usb_request_get_descriptor(usb_pipe_t *pipe,
     299int usb_request_get_descriptor(usb_endpoint_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_pipe_t * pipe,
     333int usb_request_get_descriptor_alloc(usb_endpoint_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_pipe_t *pipe,
     402int usb_request_get_device_descriptor(usb_endpoint_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_pipe_t *pipe,
     444int usb_request_get_bare_configuration_descriptor(usb_endpoint_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_pipe_t *pipe,
     490int usb_request_get_full_configuration_descriptor(usb_endpoint_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_pipe_t *pipe, int index,
     516    usb_endpoint_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_pipe_t *pipe,
     580int usb_request_set_descriptor(usb_endpoint_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_pipe_t *pipe,
     609int usb_request_get_configuration(usb_endpoint_pipe_t *pipe,
    610610    uint8_t *configuration_value)
    611611{
     
    639639 * @return Error code.
    640640 */
    641 int usb_request_set_configuration(usb_pipe_t *pipe,
     641int usb_request_set_configuration(usb_endpoint_pipe_t *pipe,
    642642    uint8_t configuration_value)
    643643{
     
    658658 * @return Error code.
    659659 */
    660 int usb_request_get_interface(usb_pipe_t *pipe,
     660int usb_request_get_interface(usb_endpoint_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_pipe_t *pipe,
     693int usb_request_set_interface(usb_endpoint_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_pipe_t *pipe,
     712int usb_request_get_supported_languages(usb_endpoint_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_pipe_t *pipe,
     784int usb_request_get_string(usb_endpoint_pipe_t *pipe,
    785785    size_t index, l18_win_locales_t lang, char **string_ptr)
    786786{
  • uspace/lib/usb/src/usb.c

    r55e388a1 r361e61b  
    3636#include <errno.h>
    3737
    38 #define ARR_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
    39 
    40 static const char *str_speed[] = {
    41         "low",
    42         "full",
    43         "high"
    44 };
    45 
    46 static const char *str_transfer_type[] = {
    47         "control",
    48         "isochronous",
    49         "bulk",
    50         "interrupt"
    51 };
    52 
    53 static const char *str_transfer_type_short[] = {
    54         "ctrl",
    55         "iso",
    56         "bulk",
    57         "intr"
    58 };
    5938
    6039/** String representation for USB transfer type.
     
    6342 * @return Transfer type as a string (in English).
    6443 */
    65 const char *usb_str_transfer_type(usb_transfer_type_t t)
     44const char * usb_str_transfer_type(usb_transfer_type_t t)
    6645{
    67         if (t >= ARR_SIZE(str_transfer_type)) {
    68                 return "invalid";
     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";
    6957        }
    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  */
    78 const 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  */
    91 const 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];
    9758}
    9859
Note: See TracChangeset for help on using the changeset viewer.