Changeset d09f3720 in mainline for uspace/drv


Ignore:
Timestamp:
2011-05-19T15:20:48Z (15 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4939490
Parents:
df44fa2 (diff), 7941bd6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Development changes.

Location:
uspace/drv
Files:
68 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/batch.c

    rdf44fa2 rd09f3720  
    4444#include "hw_struct/transfer_descriptor.h"
    4545
     46/** OHCI specific data required for USB transfer */
    4647typedef struct ohci_transfer_batch {
     48        /** Endpoint descriptor of the target endpoint. */
    4749        ed_t *ed;
     50        /** List of TDs needed for the transfer */
    4851        td_t **tds;
     52        /** Number of TDs used by the transfer */
    4953        size_t td_count;
     54        /** Dummy TD to be left at the ED and used by the next transfer */
    5055        size_t leave_td;
    51         char *device_buffer;
     56        /** Data buffer, must be accessible byb the OHCI hw. */
     57        void *device_buffer;
    5258} ohci_transfer_batch_t;
    53 
     59/*----------------------------------------------------------------------------*/
     60static void batch_control(usb_transfer_batch_t *instance,
     61    usb_direction_t data_dir, usb_direction_t status_dir);
     62static void batch_data(usb_transfer_batch_t *instance);
     63/*----------------------------------------------------------------------------*/
     64/** Safely destructs ohci_transfer_batch_t structure
     65 *
     66 * @param[in] ohci_batch Instance to destroy.
     67 */
    5468static void ohci_transfer_batch_dispose(void *ohci_batch)
    5569{
     
    6983}
    7084/*----------------------------------------------------------------------------*/
    71 static void batch_control(usb_transfer_batch_t *instance,
    72     usb_direction_t data_dir, usb_direction_t status_dir);
    73 static void batch_data(usb_transfer_batch_t *instance);
    74 /*----------------------------------------------------------------------------*/
     85/** Allocate memory initialize internal structures
     86 *
     87 * @param[in] fun DDF function to pass to callback.
     88 * @param[in] ep Communication target
     89 * @param[in] buffer Data source/destination.
     90 * @param[in] buffer_size Size of the buffer.
     91 * @param[in] setup_buffer Setup data source (if not NULL)
     92 * @param[in] setup_size Size of setup_buffer (should be always 8)
     93 * @param[in] func_in function to call on inbound transfer completion
     94 * @param[in] func_out function to call on outbound transfer completion
     95 * @param[in] arg additional parameter to func_in or func_out
     96 * @return Valid pointer if all structures were successfully created,
     97 * NULL otherwise.
     98 *
     99 * Allocates and initializes structures needed by the OHCI hw for the transfer.
     100 */
    75101usb_transfer_batch_t * batch_get(ddf_fun_t *fun, endpoint_t *ep,
    76     char *buffer, size_t buffer_size, char* setup_buffer, size_t setup_size,
     102    char *buffer, size_t buffer_size,
     103    const char *setup_buffer, size_t setup_size,
    77104    usbhc_iface_transfer_in_callback_t func_in,
    78105    usbhc_iface_transfer_out_callback_t func_out, void *arg)
     
    94121            ohci_transfer_batch_dispose);
    95122
    96         hcd_endpoint_t *hcd_ep = hcd_endpoint_get(ep);
     123        const hcd_endpoint_t *hcd_ep = hcd_endpoint_get(ep);
    97124        assert(hcd_ep);
    98125
     
    103130        data->td_count =
    104131            ((buffer_size + OHCI_TD_MAX_TRANSFER - 1) / OHCI_TD_MAX_TRANSFER);
     132        /* Control transfer need Setup and Status stage */
    105133        if (ep->transfer_type == USB_TRANSFER_CONTROL) {
    106134                data->td_count += 2;
    107135        }
    108136
    109         /* we need one extra place for td that is currently assigned to hcd_ep*/
     137        /* We need an extra place for TD that is currently assigned to hcd_ep*/
    110138        data->tds = calloc(sizeof(td_t*), data->td_count + 1);
    111139        CHECK_NULL_DISPOSE_RETURN(data->tds,
    112140            "Failed to allocate transfer descriptors.\n");
    113141
     142        /* Add TD left over by the previous transfer */
    114143        data->tds[0] = hcd_ep->td;
    115144        data->leave_td = 0;
     
    123152        data->ed = hcd_ep->ed;
    124153
     154        /* NOTE: OHCI is capable of handling buffer that crosses page boundaries
     155         * it is, however, not capable of handling buffer that occupies more
     156         * than two pages (the first page is computed using start pointer, the
     157         * other using the end pointer) */
    125158        if (setup_size + buffer_size > 0) {
    126159                data->device_buffer = malloc32(setup_size + buffer_size);
     
    135168}
    136169/*----------------------------------------------------------------------------*/
     170/** Check batch TDs' status.
     171 *
     172 * @param[in] instance Batch structure to use.
     173 * @return False, if there is an active TD, true otherwise.
     174 *
     175 * Walk all TDs (usually there is just one). Stop with false if there is an
     176 * active TD. Stop with true if an error is found. Return true if the walk
     177 * completes with the last TD.
     178 */
    137179bool batch_is_complete(usb_transfer_batch_t *instance)
    138180{
     
    140182        ohci_transfer_batch_t *data = instance->private_data;
    141183        assert(data);
    142         size_t tds = data->td_count;
    143184        usb_log_debug("Batch(%p) checking %zu td(s) for completion.\n",
    144             instance, tds);
     185            instance, data->td_count);
    145186        usb_log_debug("ED: %x:%x:%x:%x.\n",
    146187            data->ed->status, data->ed->td_head, data->ed->td_tail,
     
    148189        size_t i = 0;
    149190        instance->transfered_size = instance->buffer_size;
    150         for (; i < tds; ++i) {
     191        for (; i < data->td_count; ++i) {
    151192                assert(data->tds[i] != NULL);
    152193                usb_log_debug("TD %zu: %x:%x:%x:%x.\n", i,
     
    173214        assert(hcd_ep);
    174215        hcd_ep->td = data->tds[i];
    175         if (i > 0)
    176                 instance->transfered_size -= td_remain_size(data->tds[i - 1]);
     216        assert(i > 0);
     217        for (--i;i < data->td_count; ++i)
     218                instance->transfered_size -= td_remain_size(data->tds[i]);
    177219
    178220        /* Clear possible ED HALT */
    179221        data->ed->td_head &= ~ED_TDHEAD_HALTED_FLAG;
    180         uint32_t pa = addr_to_phys(hcd_ep->td);
     222        const uint32_t pa = addr_to_phys(hcd_ep->td);
    181223        assert(pa == (data->ed->td_head & ED_TDHEAD_PTR_MASK));
    182224        assert(pa == (data->ed->td_tail & ED_TDTAIL_PTR_MASK));
     
    185227}
    186228/*----------------------------------------------------------------------------*/
     229/** Starts execution of the TD list
     230 *
     231 * @param[in] instance Batch structure to use
     232 */
    187233void batch_commit(usb_transfer_batch_t *instance)
    188234{
     
    193239}
    194240/*----------------------------------------------------------------------------*/
     241/** Prepares control write transfer.
     242 *
     243 * @param[in] instance Batch structure to use.
     244 *
     245 * Uses generic control transfer using direction OUT(data stage) and
     246 * IN(status stage).
     247 */
    195248void batch_control_write(usb_transfer_batch_t *instance)
    196249{
     
    203256}
    204257/*----------------------------------------------------------------------------*/
     258/** Prepares control read transfer.
     259 *
     260 * @param[in] instance Batch structure to use.
     261 *
     262 * Uses generic control transfer using direction IN(data stage) and
     263 * OUT(status stage).
     264 */
    205265void batch_control_read(usb_transfer_batch_t *instance)
    206266{
     
    211271}
    212272/*----------------------------------------------------------------------------*/
     273/** Prepare interrupt in transfer.
     274 *
     275 * @param[in] instance Batch structure to use.
     276 *
     277 * Data transfer.
     278 */
    213279void batch_interrupt_in(usb_transfer_batch_t *instance)
    214280{
     
    219285}
    220286/*----------------------------------------------------------------------------*/
     287/** Prepare interrupt out transfer.
     288 *
     289 * @param[in] instance Batch structure to use.
     290 *
     291 * Data transfer.
     292 */
    221293void batch_interrupt_out(usb_transfer_batch_t *instance)
    222294{
     
    229301}
    230302/*----------------------------------------------------------------------------*/
     303/** Prepare bulk in transfer.
     304 *
     305 * @param[in] instance Batch structure to use.
     306 *
     307 * Data transfer.
     308 */
    231309void batch_bulk_in(usb_transfer_batch_t *instance)
    232310{
     
    237315}
    238316/*----------------------------------------------------------------------------*/
     317/** Prepare bulk out transfer.
     318 *
     319 * @param[in] instance Batch structure to use.
     320 *
     321 * Data transfer.
     322 */
    239323void batch_bulk_out(usb_transfer_batch_t *instance)
    240324{
     
    247331}
    248332/*----------------------------------------------------------------------------*/
    249 ed_t * batch_ed(usb_transfer_batch_t *instance)
    250 {
    251         assert(instance);
    252         ohci_transfer_batch_t *data = instance->private_data;
    253         assert(data);
    254         return data->ed;
    255 }
    256 /*----------------------------------------------------------------------------*/
     333/** Prepare generic control transfer
     334 *
     335 * @param[in] instance Batch structure to use.
     336 * @param[in] data_dir Direction to use for data stage.
     337 * @param[in] status_dir Direction to use for status stage.
     338 *
     339 * Setup stage with toggle 0 and direction BOTH(SETUP_PID)
     340 * Data stage with alternating toggle and direction supplied by parameter.
     341 * Status stage with toggle 1 and direction supplied by parameter.
     342 */
    257343void batch_control(usb_transfer_batch_t *instance,
    258344    usb_direction_t data_dir, usb_direction_t status_dir)
     
    303389}
    304390/*----------------------------------------------------------------------------*/
     391/** Prepare generic data transfer
     392 *
     393 * @param[in] instance Batch structure to use.
     394 *
     395 * Direction is supplied by the associated ep and toggle is maintained by the
     396 * OHCI hw in ED.
     397 */
    305398void batch_data(usb_transfer_batch_t *instance)
    306399{
     
    316409        char *buffer = instance->data_buffer;
    317410        while (remain_size > 0) {
    318                 size_t transfer_size = remain_size > OHCI_TD_MAX_TRANSFER ?
    319                     OHCI_TD_MAX_TRANSFER : remain_size;
     411                const size_t transfer_size = remain_size > OHCI_TD_MAX_TRANSFER
     412                    ? OHCI_TD_MAX_TRANSFER : remain_size;
    320413
    321414                td_init(data->tds[td_current], instance->ep->direction,
  • uspace/drv/ohci/batch.h

    rdf44fa2 rd09f3720  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup drvusbuhcihc
     28/** @addtogroup drvusbohci
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver USB transaction structure
     32 * @brief OHCI driver USB transaction structure
    3333 */
    34 #ifndef DRV_UHCI_BATCH_H
    35 #define DRV_UHCI_BATCH_H
     34#ifndef DRV_OHCI_BATCH_H
     35#define DRV_OHCI_BATCH_H
    3636
    3737#include <usbhc_iface.h>
     
    4141#include <usb/host/batch.h>
    4242
    43 #include "hw_struct/endpoint_descriptor.h"
    44 
    4543usb_transfer_batch_t * batch_get(
    4644    ddf_fun_t *fun, endpoint_t *ep, char *buffer, size_t size,
    47     char *setup_buffer, size_t setup_size,
     45    const char *setup_buffer, size_t setup_size,
    4846    usbhc_iface_transfer_in_callback_t func_in,
    4947    usbhc_iface_transfer_out_callback_t func_out,
     
    6563
    6664void batch_bulk_out(usb_transfer_batch_t *instance);
    67 
    68 ed_t * batch_ed(usb_transfer_batch_t *instance);
    6965#endif
    7066/**
  • uspace/drv/ohci/endpoint_list.c

    rdf44fa2 rd09f3720  
    3434#include <errno.h>
    3535#include <usb/debug.h>
     36#include <arch/barrier.h>
    3637
    3738#include "endpoint_list.h"
     
    4344 * @return Error code
    4445 *
    45  * Allocates memory for internal qh_t structure.
     46 * Allocates memory for internal ed_t structure.
    4647 */
    4748int endpoint_list_init(endpoint_list_t *instance, const char *name)
     
    6869 * @param[in] instance List to lead.
    6970 * @param[in] next List to append.
    70  * @return Error code
    7171 *
    72  * Does not check whether this replaces an existing list .
     72 * Does not check whether this replaces an existing list.
    7373 */
    7474void endpoint_list_set_next(endpoint_list_t *instance, endpoint_list_t *next)
     
    7979}
    8080/*----------------------------------------------------------------------------*/
    81 /** Submit transfer endpoint to the list and queue.
     81/** Add endpoint to the list and queue.
    8282 *
    8383 * @param[in] instance List to use.
    84  * @param[in] endpoint Transfer endpoint to submit.
    85  * @return Error code
     84 * @param[in] endpoint Endpoint to add.
    8685 *
    8786 * The endpoint is added to the end of the list and queue.
     
    9998        /* Add to the hardware queue. */
    10099        if (list_empty(&instance->endpoint_list)) {
    101                 /* There is nothing scheduled */
     100                /* There are no active EDs */
    102101                last_ed = instance->list_head;
    103102        } else {
    104                 /* There is something scheduled */
     103                /* There are active EDs, get the last one */
    105104                hcd_endpoint_t *last = list_get_instance(
    106105                    instance->endpoint_list.prev, hcd_endpoint_t, link);
     106                assert(last);
    107107                last_ed = last->ed;
    108108        }
    109         /* keep link */
     109        /* Keep link */
    110110        hcd_ep->ed->next = last_ed->next;
     111        /* Make sure ED is written to the memory */
     112        write_barrier();
     113
     114        /* Add ed to the hw queue */
    111115        ed_append_ed(last_ed, hcd_ep->ed);
     116        /* Make sure ED is updated */
     117        write_barrier();
    112118
    113         asm volatile ("": : :"memory");
    114 
    115         /* Add to the driver list */
     119        /* Add to the sw list */
    116120        list_append(&hcd_ep->link, &instance->endpoint_list);
    117121
     
    129133}
    130134/*----------------------------------------------------------------------------*/
    131 #if 0
    132 /** Create list for finished endpoints.
     135/** Remove endpoint from the list and queue.
    133136 *
    134137 * @param[in] instance List to use.
    135  * @param[in] done list to fill
    136  */
    137 void endpoint_list_remove_finished(endpoint_list_t *instance, link_t *done)
    138 {
    139         assert(instance);
    140         assert(done);
    141 
    142         fibril_mutex_lock(&instance->guard);
    143         usb_log_debug2("Checking list %s for completed endpointes(%d).\n",
    144             instance->name, list_count(&instance->endpoint_list));
    145         link_t *current = instance->endpoint_list.next;
    146         while (current != &instance->endpoint_list) {
    147                 link_t *next = current->next;
    148                 hcd_endpoint_t *endpoint =
    149                     list_get_instance(current, hcd_endpoint_t, link);
    150 
    151                 if (endpoint_is_complete(endpoint)) {
    152                         /* Save for post-processing */
    153                         endpoint_list_remove_endpoint(instance, endpoint);
    154                         list_append(current, done);
    155                 }
    156                 current = next;
    157         }
    158         fibril_mutex_unlock(&instance->guard);
    159 }
    160 /*----------------------------------------------------------------------------*/
    161 /** Walk the list and abort all endpointes.
    162  *
    163  * @param[in] instance List to use.
    164  */
    165 void endpoint_list_abort_all(endpoint_list_t *instance)
    166 {
    167         fibril_mutex_lock(&instance->guard);
    168         while (!list_empty(&instance->endpoint_list)) {
    169                 link_t *current = instance->endpoint_list.next;
    170                 hcd_endpoint_t *endpoint =
    171                     list_get_instance(current, hcd_endpoint_t, link);
    172                 endpoint_list_remove_endpoint(instance, endpoint);
    173                 hcd_endpoint_finish_error(endpoint, EIO);
    174         }
    175         fibril_mutex_unlock(&instance->guard);
    176 }
    177 #endif
    178 /*----------------------------------------------------------------------------*/
    179 /** Remove a transfer endpoint from the list and queue.
    180  *
    181  * @param[in] instance List to use.
    182  * @param[in] endpoint Transfer endpoint to remove.
    183  * @return Error code
    184  *
    185  * Does not lock the transfer list, caller is responsible for that.
     138 * @param[in] endpoint Endpoint to remove.
    186139 */
    187140void endpoint_list_remove_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep)
     
    212165        assert((prev_ed->next & ED_NEXT_PTR_MASK) == addr_to_phys(hcd_ep->ed));
    213166        prev_ed->next = hcd_ep->ed->next;
     167        /* Make sure ED is updated */
     168        write_barrier();
    214169
    215         asm volatile ("": : :"memory");
    216170        usb_log_debug("HCD EP(%p) removed (%s) from %s, next %x.\n",
    217171            hcd_ep, qpos, instance->name, hcd_ep->ed->next);
  • uspace/drv/ohci/endpoint_list.h

    rdf44fa2 rd09f3720  
    4141#include "utils/malloc32.h"
    4242
    43 typedef struct endpoint_list
    44 {
     43/** Structure maintains both OHCI queue and software list of active endpoints.*/
     44typedef struct endpoint_list {
     45        /** Guard against add/remove races */
    4546        fibril_mutex_t guard;
     47        /** OHCI hw structure at the beginning of the queue */
    4648        ed_t *list_head;
     49        /** Physical address of the first(dummy) ED */
    4750        uint32_t list_head_pa;
     51        /** Assigned name, provides nicer debug output */
    4852        const char *name;
     53        /** Sw list of all active EDs */
    4954        link_t endpoint_list;
    5055} endpoint_list_t;
     
    5459 * @param[in] instance Memory place to use.
    5560 *
    56  * Frees memory for internal qh_t structure.
     61 * Frees memory of the internal ed_t structure.
    5762 */
    5863static inline void endpoint_list_fini(endpoint_list_t *instance)
     
    6368
    6469int endpoint_list_init(endpoint_list_t *instance, const char *name);
    65 
    6670void endpoint_list_set_next(endpoint_list_t *instance, endpoint_list_t *next);
    67 
    6871void endpoint_list_add_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep);
    69 
    7072void endpoint_list_remove_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep);
    71 #if 0
    72 void endpoint_list_remove_finished(endpoint_list_t *instance, link_t *done);
    73 
    74 void endpoint_list_abort_all(endpoint_list_t *instance);
    75 #endif
    7673#endif
    7774/**
  • uspace/drv/ohci/hc.c

    rdf44fa2 rd09f3720  
    5151static int hc_init_memory(hc_t *instance);
    5252/*----------------------------------------------------------------------------*/
     53/** Announce OHCI root hub to the DDF
     54 *
     55 * @param[in] instance OHCI driver intance
     56 * @param[in] hub_fun DDF fuction representing OHCI root hub
     57 * @return Error code
     58 */
    5359int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun)
    5460{
     
    5662        assert(hub_fun);
    5763
    58         int ret;
    59 
    60         usb_address_t hub_address =
     64        const usb_address_t hub_address =
    6165            device_keeper_get_free_address(&instance->manager, USB_SPEED_FULL);
    6266        if (hub_address <= 0) {
    63                 usb_log_error("Failed to get OHCI root hub address.\n");
     67                usb_log_error("Failed(%d) to get OHCI root hub address.\n",
     68                    hub_address);
    6469                return hub_address;
    6570        }
     
    6873            &instance->manager, hub_address, hub_fun->handle);
    6974
    70         ret = hc_add_endpoint(instance, hub_address, 0, USB_SPEED_FULL,
     75#define CHECK_RET_RELEASE(ret, message...) \
     76if (ret != EOK) { \
     77        usb_log_error(message); \
     78        hc_remove_endpoint(instance, hub_address, 0, USB_DIRECTION_BOTH); \
     79        usb_device_keeper_release(&instance->manager, hub_address); \
     80        return ret; \
     81} else (void)0
     82
     83        int ret = hc_add_endpoint(instance, hub_address, 0, USB_SPEED_FULL,
    7184            USB_TRANSFER_CONTROL, USB_DIRECTION_BOTH, 64, 0, 0);
    72         if (ret != EOK) {
    73                 usb_log_error("Failed to add OHCI rh endpoint 0.\n");
    74                 usb_device_keeper_release(&instance->manager, hub_address);
    75                 return ret;
    76         }
     85        CHECK_RET_RELEASE(ret, "Failed(%d) to add OHCI rh endpoint 0.\n", ret);
    7786
    7887        char *match_str = NULL;
    7988        /* DDF needs heap allocated string */
    8089        ret = asprintf(&match_str, "usb&class=hub");
    81         if (ret < 0) {
    82                 usb_log_error(
    83                     "Failed(%d) to create root hub match-id string.\n", ret);
    84                 usb_device_keeper_release(&instance->manager, hub_address);
    85                 return ret;
    86         }
     90        ret = ret > 0 ? 0 : ret;
     91        CHECK_RET_RELEASE(ret, "Failed(%d) to create match-id string.\n", ret);
    8792
    8893        ret = ddf_fun_add_match_id(hub_fun, match_str, 100);
    89         if (ret != EOK) {
    90                 usb_log_error("Failed add root hub match-id.\n");
    91         }
     94        CHECK_RET_RELEASE(ret, "Failed(%d) add root hub match-id.\n", ret);
     95
    9296        ret = ddf_fun_bind(hub_fun);
    93         return ret;
    94 }
    95 /*----------------------------------------------------------------------------*/
     97        CHECK_RET_RELEASE(ret, "Failed(%d) to bind root hub function.\n", ret);
     98
     99        return EOK;
     100#undef CHECK_RET_RELEASE
     101}
     102/*----------------------------------------------------------------------------*/
     103/** Initialize OHCI hc driver structure
     104 *
     105 * @param[in] instance Memory place for the structure.
     106 * @param[in] regs Address of the memory mapped I/O registers.
     107 * @param[in] reg_size Size of the memory mapped area.
     108 * @param[in] interrupts True if w interrupts should be used
     109 * @return Error code
     110 */
    96111int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts)
    97112{
     
    121136#undef CHECK_RET_RETURN
    122137
    123 
    124 //      hc_init_hw(instance);
     138        fibril_mutex_initialize(&instance->guard);
    125139        hc_gain_control(instance);
    126         fibril_mutex_initialize(&instance->guard);
    127140
    128141        rh_init(&instance->rh, instance->registers);
     
    137150}
    138151/*----------------------------------------------------------------------------*/
     152/** Create end register endpoint structures
     153 *
     154 * @param[in] instance OHCI driver structure.
     155 * @param[in] address USB address of the device.
     156 * @param[in] endpoint USB endpoint number.
     157 * @param[in] speed Communication speeed of the device.
     158 * @param[in] type Endpoint's transfer type.
     159 * @param[in] direction Endpoint's direction.
     160 * @param[in] mps Maximum packet size the endpoint accepts.
     161 * @param[in] size Maximum allowed buffer size.
     162 * @param[in] interval Time between transfers(interrupt transfers only).
     163 * @return Error code
     164 */
    139165int hc_add_endpoint(
    140166    hc_t *instance, usb_address_t address, usb_endpoint_t endpoint,
     
    194220}
    195221/*----------------------------------------------------------------------------*/
     222/** Dequeue and delete endpoint structures
     223 *
     224 * @param[in] instance OHCI hc driver structure.
     225 * @param[in] address USB address of the device.
     226 * @param[in] endpoint USB endpoint number.
     227 * @param[in] direction Direction of the endpoint.
     228 * @return Error code
     229 */
    196230int hc_remove_endpoint(hc_t *instance, usb_address_t address,
    197231    usb_endpoint_t endpoint, usb_direction_t direction)
     
    244278}
    245279/*----------------------------------------------------------------------------*/
     280/** Get access to endpoint structures
     281 *
     282 * @param[in] instance OHCI hc driver structure.
     283 * @param[in] address USB address of the device.
     284 * @param[in] endpoint USB endpoint number.
     285 * @param[in] direction Direction of the endpoint.
     286 * @param[out] bw Reserved bandwidth.
     287 * @return Error code
     288 */
    246289endpoint_t * hc_get_endpoint(hc_t *instance, usb_address_t address,
    247290    usb_endpoint_t endpoint, usb_direction_t direction, size_t *bw)
     
    255298}
    256299/*----------------------------------------------------------------------------*/
     300/** Add USB transfer to the schedule.
     301 *
     302 * @param[in] instance OHCI hc driver structure.
     303 * @param[in] batch Batch representing the transfer.
     304 * @return Error code.
     305 */
    257306int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch)
    258307{
     
    261310        assert(batch->ep);
    262311
    263         /* check for root hub communication */
     312        /* Check for root hub communication */
    264313        if (batch->ep->address == instance->rh.address) {
    265314                return rh_request(&instance->rh, batch);
     
    269318        list_append(&batch->link, &instance->pending_batches);
    270319        batch_commit(batch);
    271         switch (batch->ep->transfer_type) {
     320
     321        /* Control and bulk schedules need a kick to start working */
     322        switch (batch->ep->transfer_type)
     323        {
    272324        case USB_TRANSFER_CONTROL:
    273325                instance->registers->command_status |= CS_CLF;
     
    279331                break;
    280332        }
    281 
    282333        fibril_mutex_unlock(&instance->guard);
    283334        return EOK;
    284335}
    285336/*----------------------------------------------------------------------------*/
     337/** Interrupt handling routine
     338 *
     339 * @param[in] instance OHCI hc driver structure.
     340 * @param[in] status Value of the status register at the time of interrupt.
     341 */
    286342void hc_interrupt(hc_t *instance, uint32_t status)
    287343{
     
    292348        if (status & I_RHSC)
    293349                rh_interrupt(&instance->rh);
    294 
    295350
    296351        if (status & I_WDH) {
     
    316371                fibril_mutex_unlock(&instance->guard);
    317372        }
    318 }
    319 /*----------------------------------------------------------------------------*/
     373
     374        if (status & I_UE) {
     375                hc_start_hw(instance);
     376        }
     377
     378}
     379/*----------------------------------------------------------------------------*/
     380/** Check status register regularly
     381 *
     382 * @param[in] instance OHCI hc driver structure.
     383 * @return Error code
     384 */
    320385int interrupt_emulator(hc_t *instance)
    321386{
     
    326391                instance->registers->interrupt_status = status;
    327392                hc_interrupt(instance, status);
    328                 async_usleep(50000);
     393                async_usleep(10000);
    329394        }
    330395        return EOK;
    331396}
    332397/*----------------------------------------------------------------------------*/
     398/** Turn off any (BIOS)driver that might be in control of the device.
     399 *
     400 * @param[in] instance OHCI hc driver structure.
     401 */
    333402void hc_gain_control(hc_t *instance)
    334403{
     
    380449}
    381450/*----------------------------------------------------------------------------*/
     451/** OHCI hw initialization routine.
     452 *
     453 * @param[in] instance OHCI hc driver structure.
     454 */
    382455void hc_start_hw(hc_t *instance)
    383456{
     
    447520}
    448521/*----------------------------------------------------------------------------*/
     522/** Initialize schedule queues
     523 *
     524 * @param[in] instance OHCI hc driver structure
     525 * @return Error code
     526 */
    449527int hc_init_transfer_lists(hc_t *instance)
    450528{
    451529        assert(instance);
    452 
    453530#define SETUP_ENDPOINT_LIST(type) \
    454531do { \
     
    458535                usb_log_error("Failed(%d) to setup %s endpoint list.\n", \
    459536                    ret, name); \
    460                 endpoint_list_fini(&instance->lists[USB_TRANSFER_ISOCHRONOUS]); \
     537                endpoint_list_fini(&instance->lists[USB_TRANSFER_ISOCHRONOUS]);\
    461538                endpoint_list_fini(&instance->lists[USB_TRANSFER_INTERRUPT]); \
    462539                endpoint_list_fini(&instance->lists[USB_TRANSFER_CONTROL]); \
    463540                endpoint_list_fini(&instance->lists[USB_TRANSFER_BULK]); \
     541                return ret; \
    464542        } \
    465543} while (0)
     
    476554}
    477555/*----------------------------------------------------------------------------*/
     556/** Initialize memory structures used by the OHCI hcd.
     557 *
     558 * @param[in] instance OHCI hc driver structure.
     559 * @return Error code.
     560 */
    478561int hc_init_memory(hc_t *instance)
    479562{
     
    502585        /* Init interrupt code */
    503586        instance->interrupt_code.cmds = instance->interrupt_commands;
     587        instance->interrupt_code.cmdcount = OHCI_NEEDED_IRQ_COMMANDS;
    504588        {
    505589                /* Read status register */
     
    521605                instance->interrupt_commands[2].srcarg = 2;
    522606
    523                 /* Write clean status register */
     607                /* Write-clean status register */
    524608                instance->interrupt_commands[3].cmd = CMD_MEM_WRITE_A_32;
    525609                instance->interrupt_commands[3].srcarg = 1;
     
    529613                /* Accept interrupt */
    530614                instance->interrupt_commands[4].cmd = CMD_ACCEPT;
    531 
    532                 instance->interrupt_code.cmdcount = OHCI_NEEDED_IRQ_COMMANDS;
    533615        }
    534616
  • uspace/drv/ohci/hc.h

    rdf44fa2 rd09f3720  
    5353#define OHCI_NEEDED_IRQ_COMMANDS 5
    5454
     55/** Main OHCI drier structure */
    5556typedef struct hc {
     57        /** USB bus driver, devices and addresses */
     58        usb_device_keeper_t manager;
     59        /** USB bus driver, endpoints */
     60        usb_endpoint_manager_t ep_manager;
     61
     62        /** Memory mapped I/O registers area */
    5663        ohci_regs_t *registers;
     64        /** Host controller communication area structure */
    5765        hcca_t *hcca;
    5866
    59         usb_address_t rh_address;
    60         rh_t rh;
    61 
     67        /** Transfer schedules */
    6268        endpoint_list_t lists[4];
     69        /** List of active transfers */
    6370        link_t pending_batches;
    6471
    65         usb_device_keeper_t manager;
    66         usb_endpoint_manager_t ep_manager;
     72        /** Fibril for periodic checks if interrupts can't be used */
    6773        fid_t interrupt_emulator;
     74
     75        /** Guards schedule and endpoint manipulation */
    6876        fibril_mutex_t guard;
    6977
     
    7381        /** Commands that form interrupt code */
    7482        irq_cmd_t interrupt_commands[OHCI_NEEDED_IRQ_COMMANDS];
     83
     84        /** USB hub emulation structure */
     85        rh_t rh;
    7586} hc_t;
    7687
    7788int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun);
    78 
    7989int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts);
    80 
    8190void hc_start_hw(hc_t *instance);
    8291
     
    8594 * @param[in] instance Host controller structure to use.
    8695 */
    87 static inline void hc_fini(hc_t *instance) { /* TODO: implement*/ };
     96static inline void hc_fini(hc_t *instance)
     97        { /* TODO: implement*/ };
    8898
    8999int hc_add_endpoint(hc_t *instance, usb_address_t address, usb_endpoint_t ep,
    90100    usb_speed_t speed, usb_transfer_type_t type, usb_direction_t direction,
    91101    size_t max_packet_size, size_t size, unsigned interval);
    92 
    93102int hc_remove_endpoint(hc_t *instance, usb_address_t address,
    94103    usb_endpoint_t endpoint, usb_direction_t direction);
    95 
    96104endpoint_t * hc_get_endpoint(hc_t *instance, usb_address_t address,
    97105    usb_endpoint_t endpoint, usb_direction_t direction, size_t *bw);
    98106
    99107int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch);
    100 
    101108void hc_interrupt(hc_t *instance, uint32_t status);
    102109
     
    107114 */
    108115static inline hc_t * fun_to_hc(ddf_fun_t *fun)
    109         { return (hc_t*)fun->driver_data; }
     116        { return fun->driver_data; }
    110117#endif
    111118/**
  • uspace/drv/ohci/hcd_endpoint.c

    rdf44fa2 rd09f3720  
    3535#include "hcd_endpoint.h"
    3636
     37/** Callback to set toggle on ED.
     38 *
     39 * @param[in] hcd_ep hcd endpoint structure
     40 * @param[in] toggle new value of toggle bit
     41 */
    3742static void hcd_ep_toggle_set(void *hcd_ep, int toggle)
    3843{
     
    4247        ed_toggle_set(instance->ed, toggle);
    4348}
     49/*----------------------------------------------------------------------------*/
     50/** Callback to get value of toggle bit.
     51 *
     52 * @param[in] hcd_ep hcd endpoint structure
     53 * @return Current value of toggle bit.
     54 */
    4455static int hcd_ep_toggle_get(void *hcd_ep)
    4556{
     
    4960        return ed_toggle_get(instance->ed);
    5061}
    51 
    52 
     62/*----------------------------------------------------------------------------*/
     63/** Creates new hcd endpoint representation.
     64 *
     65 * @param[in] ep USBD endpoint structure
     66 * @return pointer to a new hcd endpoint structure, NULL on failure.
     67 */
    5368hcd_endpoint_t * hcd_endpoint_assign(endpoint_t *ep)
    5469{
     
    7893}
    7994/*----------------------------------------------------------------------------*/
    80 hcd_endpoint_t * hcd_endpoint_get(endpoint_t *ep)
    81 {
    82         assert(ep);
    83         return ep->hc_data.data;
    84 }
    85 /*----------------------------------------------------------------------------*/
     95/** Disposes assigned hcd endpoint structure
     96 *
     97 * @param[in] ep USBD endpoint structure
     98 */
    8699void hcd_endpoint_clear(endpoint_t *ep)
    87100{
  • uspace/drv/ohci/hcd_endpoint.h

    rdf44fa2 rd09f3720  
    3737#include <assert.h>
    3838#include <adt/list.h>
    39 
    4039#include <usb/host/endpoint.h>
    4140
     
    4342#include "hw_struct/transfer_descriptor.h"
    4443
     44/** Connector structure linking ED to to prepared TD. */
    4545typedef struct hcd_endpoint {
     46        /** OHCI endpoint descriptor */
    4647        ed_t *ed;
     48        /** Currently enqueued transfer descriptor */
    4749        td_t *td;
     50        /** Linked list used by driver software */
    4851        link_t link;
    4952} hcd_endpoint_t;
    5053
    5154hcd_endpoint_t * hcd_endpoint_assign(endpoint_t *ep);
     55void hcd_endpoint_clear(endpoint_t *ep);
    5256
    53 hcd_endpoint_t * hcd_endpoint_get(endpoint_t *ep);
     57/** Get and convert assigned hcd_endpoint_t structure
     58 * @param[in] ep USBD endpoint structure.
     59 * @return Pointer to assigned hcd endpoint structure
     60 */
     61static inline hcd_endpoint_t * hcd_endpoint_get(endpoint_t *ep)
     62{
     63        assert(ep);
     64        return ep->hc_data.data;
     65}
    5466
    55 void hcd_endpoint_clear(endpoint_t *ep);
    5667#endif
    5768/**
  • uspace/drv/ohci/hw_struct/transfer_descriptor.c

    rdf44fa2 rd09f3720  
    4444        assert(instance);
    4545        bzero(instance, sizeof(td_t));
    46         instance-> status = 0
     46        instance->status = 0
    4747            | ((dp[dir] & TD_STATUS_DP_MASK) << TD_STATUS_DP_SHIFT)
    4848            | ((CC_NOACCESS2 & TD_STATUS_CC_MASK) << TD_STATUS_CC_SHIFT);
  • uspace/drv/ohci/hw_struct/transfer_descriptor.h

    rdf44fa2 rd09f3720  
    4141#include "completion_codes.h"
    4242
    43 /* OHCI TDs can handle up to 8KB buffers */
    44 #define OHCI_TD_MAX_TRANSFER (8 * 1024)
     43/* OHCI TDs can handle up to 8KB buffers, however, it can use max 2 pages.
     44 * Using 4KB buffers guarantees the page count condition.
     45 * (OHCI assumes 4KB pages) */
     46#define OHCI_TD_MAX_TRANSFER (4 * 1024)
    4547
    4648typedef struct td {
  • uspace/drv/ohci/iface.h

    rdf44fa2 rd09f3720  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 
    2928/** @addtogroup drvusbohci
    3029 * @{
  • uspace/drv/ohci/ohci.h

    rdf44fa2 rd09f3720  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 
    2928/** @addtogroup drvusbohci
    3029 * @{
  • uspace/drv/ohci/ohci_regs.h

    rdf44fa2 rd09f3720  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 
    2928/** @addtogroup drvusbohcihc
    3029 * @{
     
    3736#include <stdint.h>
    3837
    39 typedef struct ohci_regs
    40 {
     38/** OHCI memory mapped registers structure */
     39typedef struct ohci_regs {
    4140        const volatile uint32_t revision;
    4241        volatile uint32_t control;
  • uspace/drv/ohci/pci.h

    rdf44fa2 rd09f3720  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 
    2928/** @addtogroup drvusbohci
    3029 * @{
  • uspace/drv/ohci/root_hub.c

    rdf44fa2 rd09f3720  
    3939
    4040#include "root_hub.h"
    41 #include "usb/classes/classes.h"
    42 #include "usb/devdrv.h"
    43 #include <usb/request.h>
     41#include <usb/classes/classes.h>
     42#include <usb/dev/driver.h>
     43#include "ohci_regs.h"
     44
     45#include <usb/dev/request.h>
    4446#include <usb/classes/hub.h>
    4547
     
    109111 */
    110112static const uint32_t hub_clear_feature_valid_mask =
    111     (1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER) |
    112 (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
     113    RHS_OCIC_FLAG |
     114    RHS_CLEAR_PORT_POWER;
    113115
    114116/**
     
    116118 */
    117119static const uint32_t hub_clear_feature_by_writing_one_mask =
    118     1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER;
     120   RHS_CLEAR_PORT_POWER;
     121   // 1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER;
    119122
    120123/**
     
    122125 */
    123126static const uint32_t hub_set_feature_valid_mask =
    124     (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) |
    125 (1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
     127    RHS_LPSC_FLAG |
     128    RHS_OCIC_FLAG;
     129    //(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) |
     130    //(1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
    126131
    127132/**
     
    129134 */
    130135static const uint32_t hub_set_feature_direct_mask =
    131     (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
     136    RHS_SET_PORT_POWER;
     137    //(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
    132138
    133139/**
     
    135141 */
    136142static const uint32_t port_set_feature_valid_mask =
    137     (1 << USB_HUB_FEATURE_PORT_ENABLE) |
    138 (1 << USB_HUB_FEATURE_PORT_SUSPEND) |
    139 (1 << USB_HUB_FEATURE_PORT_RESET) |
    140 (1 << USB_HUB_FEATURE_PORT_POWER);
     143    RHPS_SET_PORT_ENABLE |
     144    RHPS_SET_PORT_SUSPEND |
     145    RHPS_SET_PORT_RESET |
     146    RHPS_SET_PORT_POWER;
    141147
    142148/**
     
    144150 */
    145151static const uint32_t port_clear_feature_valid_mask =
     152    RHPS_CCS_FLAG |
     153    RHPS_SET_PORT_SUSPEND |
     154    RHPS_POCI_FLAG |
     155    RHPS_SET_PORT_POWER |
     156    RHPS_CSC_FLAG |
     157    RHPS_PESC_FLAG |
     158    RHPS_PSSC_FLAG |
     159    RHPS_OCIC_FLAG |
     160    RHPS_PRSC_FLAG;
     161
     162/*
     163
    146164    (1 << USB_HUB_FEATURE_PORT_CONNECTION) |
    147 (1 << USB_HUB_FEATURE_PORT_SUSPEND) |
    148 (1 << USB_HUB_FEATURE_PORT_OVER_CURRENT) |
    149 (1 << USB_HUB_FEATURE_PORT_POWER) |
    150 (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) |
    151 (1 << USB_HUB_FEATURE_C_PORT_ENABLE) |
    152 (1 << USB_HUB_FEATURE_C_PORT_SUSPEND) |
    153 (1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
    154 (1 << USB_HUB_FEATURE_C_PORT_RESET);
     165    (1 << USB_HUB_FEATURE_PORT_SUSPEND) |
     166    (1 << USB_HUB_FEATURE_PORT_OVER_CURRENT) |
     167    (1 << USB_HUB_FEATURE_PORT_POWER) |
     168    (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) |
     169    (1 << USB_HUB_FEATURE_C_PORT_ENABLE) |
     170    (1 << USB_HUB_FEATURE_C_PORT_SUSPEND) |
     171    (1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
     172    (1 << USB_HUB_FEATURE_C_PORT_RESET);
     173 */
    155174//note that USB_HUB_FEATURE_PORT_POWER bit is translated into
    156 //USB_HUB_FEATURE_PORT_LOW_SPEED
     175//USB_HUB_FEATURE_PORT_LOW_SPEED for port set feature request
    157176
    158177/**
    159178 * bitmask with port status changes
    160179 */
    161 static const uint32_t port_status_change_mask =
    162     (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) |
    163 (1 << USB_HUB_FEATURE_C_PORT_ENABLE) |
    164 (1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
    165 (1 << USB_HUB_FEATURE_C_PORT_RESET) |
    166 (1 << USB_HUB_FEATURE_C_PORT_SUSPEND);
    167 
     180static const uint32_t port_status_change_mask = RHPS_CHANGE_WC_MASK;
     181/*    (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) |
     182    (1 << USB_HUB_FEATURE_C_PORT_ENABLE) |
     183    (1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
     184    (1 << USB_HUB_FEATURE_C_PORT_RESET) |
     185    (1 << USB_HUB_FEATURE_C_PORT_SUSPEND);
     186*/
    168187
    169188static int create_serialized_hub_descriptor(rh_t *instance);
  • uspace/drv/ohci/root_hub.h

    rdf44fa2 rd09f3720  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 
    2928/** @addtogroup drvusbohci
    3029 * @{
     
    3736
    3837#include <usb/usb.h>
    39 #include <usb/devdrv.h>
     38#include <usb/dev/driver.h>
    4039
    4140#include "ohci_regs.h"
  • uspace/drv/ohci/utils/malloc32.h

    rdf44fa2 rd09f3720  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbohci
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver
     32 * @brief OHCI driver
    3333 */
    34 #ifndef DRV_UHCI_TRANSLATOR_H
    35 #define DRV_UHCI_TRANSLATOR_H
     34#ifndef DRV_OHCI_UTILS_MALLOC32_H
     35#define DRV_OHCI_UTILS_MALLOC32_H
    3636
    3737#include <assert.h>
     
    4040#include <mem.h>
    4141#include <as.h>
    42 
    43 #define UHCI_REQUIRED_PAGE_SIZE 4096
    4442
    4543/** Get physical address translation
     
    6159 *
    6260 * @param[in] size Size of the required memory space
    63  * @return Address of the alligned and big enough memory place, NULL on failure.
     61 * @return Address of the aligned and big enough memory place, NULL on failure.
    6462 */
    6563static inline void * malloc32(size_t size)
     
    7270static inline void free32(void *addr)
    7371        { if (addr) free(addr); }
    74 /*----------------------------------------------------------------------------*/
    75 /** Create 4KB page mapping
    76  *
    77  * @return Address of the mapped page, NULL on failure.
    78  */
    79 static inline void * get_page(void)
    80 {
    81         void * free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE);
    82         assert(free_address);
    83         if (free_address == 0)
    84                 return NULL;
    85         void* ret =
    86           as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE,
    87                   AS_AREA_READ | AS_AREA_WRITE);
    88         if (ret != free_address)
    89                 return NULL;
    90         return ret;
    91 }
    92 
    9372#endif
    9473/**
  • uspace/drv/uhci-hcd/batch.c

    rdf44fa2 rd09f3720  
    4545#define DEFAULT_ERROR_COUNT 3
    4646
     47/** UHCI specific data required for USB transfer */
    4748typedef struct uhci_transfer_batch {
     49        /** Queue head
     50         * This QH is used to maintain UHCI schedule structure and the element
     51         * pointer points to the first TD of this batch.
     52         */
    4853        qh_t *qh;
     54        /** List of TDs needed for the transfer */
    4955        td_t *tds;
     56        /** Number of TDs used by the transfer */
     57        size_t td_count;
     58        /** Data buffer, must be accessible by the UHCI hw */
    5059        void *device_buffer;
    51         size_t td_count;
    5260} uhci_transfer_batch_t;
    5361/*----------------------------------------------------------------------------*/
    54 static void uhci_transfer_batch_dispose(void *uhci_batch)
    55 {
    56         uhci_transfer_batch_t *instance = uhci_batch;
    57         assert(instance);
    58         free32(instance->device_buffer);
    59         free(instance);
    60 }
    61 /*----------------------------------------------------------------------------*/
    62 
    6362static void batch_control(usb_transfer_batch_t *instance,
    6463    usb_packet_id data_stage, usb_packet_id status_stage);
    6564static void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid);
    66 
     65/*----------------------------------------------------------------------------*/
     66/** Safely destructs uhci_transfer_batch_t structure
     67 *
     68 * @param[in] uhci_batch Instance to destroy.
     69 */
     70static void uhci_transfer_batch_dispose(void *uhci_batch)
     71{
     72        uhci_transfer_batch_t *instance = uhci_batch;
     73        assert(instance);
     74        free32(instance->device_buffer);
     75        free(instance);
     76}
     77/*----------------------------------------------------------------------------*/
    6778/** Allocate memory and initialize internal data structure.
    6879 *
     
    7081 * @param[in] ep Communication target
    7182 * @param[in] buffer Data source/destination.
    72  * @param[in] size Size of the buffer.
     83 * @param[in] buffer_size Size of the buffer.
    7384 * @param[in] setup_buffer Setup data source (if not NULL)
    7485 * @param[in] setup_size Size of setup_buffer (should be always 8)
     
    8495 */
    8596usb_transfer_batch_t * batch_get(ddf_fun_t *fun, endpoint_t *ep,
    86     char *buffer, size_t buffer_size, char* setup_buffer, size_t setup_size,
     97    char *buffer, size_t buffer_size,
     98    const char* setup_buffer, size_t setup_size,
    8799    usbhc_iface_transfer_in_callback_t func_in,
    88100    usbhc_iface_transfer_out_callback_t func_out, void *arg)
     
    173185                instance->error = td_status(&data->tds[i]);
    174186                if (instance->error != EOK) {
    175                         usb_log_debug("Batch(%p) found error TD(%zu):%" PRIx32 ".\n",
    176                             instance, i, data->tds[i].status);
     187                        usb_log_debug("Batch(%p) found error TD(%zu):%"
     188                            PRIx32 ".\n", instance, i, data->tds[i].status);
    177189                        td_print_status(&data->tds[i]);
    178190
     
    397409/*----------------------------------------------------------------------------*/
    398410/** Provides access to QH data structure.
     411 *
    399412 * @param[in] instance Batch pointer to use.
    400413 * @return Pointer to the QH used by the batch.
  • uspace/drv/uhci-hcd/batch.h

    rdf44fa2 rd09f3720  
    4545usb_transfer_batch_t * batch_get(
    4646    ddf_fun_t *fun, endpoint_t *ep, char *buffer, size_t size,
    47     char *setup_buffer, size_t setup_size,
     47    const char *setup_buffer, size_t setup_size,
    4848    usbhc_iface_transfer_in_callback_t func_in,
    4949    usbhc_iface_transfer_out_callback_t func_out,
     
    5555
    5656void batch_control_write(usb_transfer_batch_t *instance);
    57 
    5857void batch_control_read(usb_transfer_batch_t *instance);
    5958
    6059void batch_interrupt_in(usb_transfer_batch_t *instance);
    61 
    6260void batch_interrupt_out(usb_transfer_batch_t *instance);
    6361
    6462void batch_bulk_in(usb_transfer_batch_t *instance);
    65 
    6663void batch_bulk_out(usb_transfer_batch_t *instance);
    6764
  • uspace/drv/uhci-hcd/hc.c

    rdf44fa2 rd09f3720  
    5757static int hc_debug_checker(void *arg);
    5858/*----------------------------------------------------------------------------*/
    59 /** Initialize UHCI hcd driver structure
     59/** Initialize UHCI hc driver structure
    6060 *
    6161 * @param[in] instance Memory place to initialize.
    6262 * @param[in] regs Address of I/O control registers.
    63  * @param[in] size Size of I/O control registers.
     63 * @param[in] reg_size Size of I/O control registers.
     64 * @param[in] interrupts True if hw interrupts should be used.
    6465 * @return Error code.
    6566 * @note Should be called only once on any structure.
  • uspace/drv/uhci-hcd/hc.h

    rdf44fa2 rd09f3720  
    3333 * @brief UHCI host controller driver structure
    3434 */
    35 #ifndef DRV_UHCI_UHCI_HC_H
    36 #define DRV_UHCI_UHCI_HC_H
     35#ifndef DRV_UHCI_HC_H
     36#define DRV_UHCI_HC_H
    3737
    3838#include <fibril.h>
     
    9595#define UHCI_NEEDED_IRQ_COMMANDS 5
    9696
    97 /* Main HC driver structure */
     97/** Main UHCI driver structure */
    9898typedef struct hc {
    9999        /** USB bus driver, devices and addresses */
  • uspace/drv/uhci-hcd/hw_struct/link_pointer.h

    rdf44fa2 rd09f3720  
    3232 * @brief UHCI driver
    3333 */
    34 #ifndef DRV_UHCI_LINK_POINTER_H
    35 #define DRV_UHCI_LINK_POINTER_H
     34#ifndef DRV_UHCI_HW_STRUCT_LINK_POINTER_H
     35#define DRV_UHCI_HW_STRUCT_LINK_POINTER_H
    3636
    3737/* UHCI link pointer, used by many data structures */
  • uspace/drv/uhci-hcd/hw_struct/queue_head.h

    rdf44fa2 rd09f3720  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup drv usbuhcihc
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
     
    3232 * @brief UHCI driver
    3333 */
    34 #ifndef DRV_UHCI_QH_H
    35 #define DRV_UHCI_QH_H
     34#ifndef DRV_UHCI_HW_STRUCT_QH_H
     35#define DRV_UHCI_HW_STRUCT_QH_H
    3636#include <assert.h>
    3737
     
    6565 *
    6666 * @param[in] instance qh_t structure to use.
    67  * @param[in] pa Physical address of the next queue head.
     67 * @param[in] next Address of the next queue.
    6868 *
    6969 * Adds proper flag. If the pointer is NULL, sets next to terminal NULL.
     
    8181/** Set queue head element pointer
    8282 *
    83  * @param[in] instance qh_t structure to initialize.
    84  * @param[in] pa Physical address of the TD structure.
     83 * @param[in] instance qh_t structure to use.
     84 * @param[in] td Transfer descriptor to set as the first element.
    8585 *
    8686 * Adds proper flag. If the pointer is NULL, sets element to terminal NULL.
  • uspace/drv/uhci-hcd/hw_struct/transfer_descriptor.h

    rdf44fa2 rd09f3720  
    3232 * @brief UHCI driver
    3333 */
    34 #ifndef DRV_UHCI_TRANSFER_DESCRIPTOR_H
    35 #define DRV_UHCI_TRANSFER_DESCRIPTOR_H
     34#ifndef DRV_UHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H
     35#define DRV_UHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H
    3636
    3737#include <mem.h>
  • uspace/drv/uhci-hcd/root_hub.h

    rdf44fa2 rd09f3720  
    3333 * @brief UHCI driver
    3434 */
    35 #ifndef DRV_UHCI_UHCI_RH_H
    36 #define DRV_UHCI_UHCI_RH_H
     35#ifndef DRV_UHCI_RH_H
     36#define DRV_UHCI_RH_H
    3737
    3838#include <ddf/driver.h>
  • uspace/drv/uhci-hcd/transfer_list.c

    rdf44fa2 rd09f3720  
    3434#include <errno.h>
    3535#include <usb/debug.h>
     36#include <arch/barrier.h>
    3637
    3738#include "transfer_list.h"
     
    7172 * @param[in] instance Memory place to use.
    7273 *
    73  * Frees memory for internal qh_t structure.
     74 * Frees memory of the internal qh_t structure.
    7475 */
    7576void transfer_list_fini(transfer_list_t *instance)
     
    126127        assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);
    127128
     129        /* Make sure all data in the batch are written */
     130        write_barrier();
     131
    128132        /* keep link */
    129133        batch_qh(batch)->next = last_qh->next;
    130134        qh_set_next_qh(last_qh, batch_qh(batch));
    131135
    132         asm volatile ("": : :"memory");
     136        /* Make sure the pointer is updated */
     137        write_barrier();
    133138
    134139        /* Add to the driver list */
     
    222227            == addr_to_phys(batch_qh(batch)));
    223228        prev_qh->next = batch_qh(batch)->next;
    224         asm volatile ("": : :"memory");
     229
     230        /* Make sure the pointer is updated */
     231        write_barrier();
     232
    225233        /* Remove from the batch list */
    226234        list_remove(&batch->link);
  • uspace/drv/uhci-hcd/transfer_list.h

    rdf44fa2 rd09f3720  
    4343 * of currently executed transfers
    4444 */
    45 typedef struct transfer_list
    46 {
     45typedef struct transfer_list {
    4746        /** Guard against multiple add/remove races */
    4847        fibril_mutex_t guard;
  • uspace/drv/uhci-hcd/uhci.c

    rdf44fa2 rd09f3720  
    161161/** Initialize hc and rh DDF structures and their respective drivers.
    162162 *
    163  * @param[in] instance UHCI structure to use.
    164163 * @param[in] device DDF instance of the device to use.
    165164 *
     
    167166 *  - gets device's hw resources
    168167 *  - disables UHCI legacy support (PCI config space)
    169  *  - asks for interrupt
     168 *  - attempts to enable interrupts
    170169 *  - registers interrupt handler
    171170 */
  • uspace/drv/uhci-hcd/utils/malloc32.h

    rdf44fa2 rd09f3720  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhci
    2929 * @{
    3030 */
     
    3232 * @brief UHCI driver
    3333 */
    34 #ifndef DRV_UHCI_TRANSLATOR_H
    35 #define DRV_UHCI_TRANSLATOR_H
     34#ifndef DRV_UHCI_UTILS_MALLOC32_H
     35#define DRV_UHCI_UTILS_MALLOC32_H
    3636
    3737#include <assert.h>
     
    7474        if (size <= SLAB_ELEMENT_SIZE)
    7575                return slab_malloc_g();
    76         assert(false);
     76        usb_log_warning("Requested %zu bytes, current allocator can't handle "
     77            "that amount, pray that the standard malloc will suffice.", size);
    7778        return memalign(UHCI_STRCUTURES_ALIGNMENT, size);
    7879}
  • uspace/drv/uhci-hcd/utils/slab.c

    rdf44fa2 rd09f3720  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
  • uspace/drv/uhci-hcd/utils/slab.h

    rdf44fa2 rd09f3720  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
     
    3232 * @brief UHCI driver
    3333 */
    34 #ifndef DRV_UHCI_SLAB_H
    35 #define DRV_UHCI_SLAB_H
     34#ifndef DRV_UHCI_UTILS_SLAB_H
     35#define DRV_UHCI_UTILS_SLAB_H
    3636
    3737#include <bool.h>
  • uspace/drv/uhci-rhd/port.c

    rdf44fa2 rd09f3720  
    3636#include <errno.h>
    3737#include <str_error.h>
     38#include <time.h>
     39#include <async.h>
    3840
    3941#include <usb/usb.h>    /* usb_address_t */
    40 #include <usb/hub.h>    /* usb_hc_new_device_wrapper */
     42#include <usb/dev/hub.h>    /* usb_hc_new_device_wrapper */
    4143#include <usb/debug.h>
    4244
     
    6567 *
    6668 * @param[in] port Structure to use.
    67  * @param[in] value New register value.
     69 * @param[in] val New register value.
    6870 * @return Error code. (Always EOK)
    6971 */
     
    7779 *
    7880 * @param[in] port Memory structure to use.
    79  * @param[in] addr Address of I/O register.
     81 * @param[in] address Address of I/O register.
    8082 * @param[in] number Port number.
    8183 * @param[in] usec Polling interval.
     
    224226                uhci_port_write_status(port, port_status);
    225227                while (uhci_port_read_status(port) & STATUS_IN_RESET);
    226                 // TODO: find a better way to waste time (it should be less than
    227                 // 10ms, if we reschedule it takes too much time (random
    228                 // interrupts can be solved by multiple attempts).
    229                 usb_log_debug2("%s: Reset Signal stop.\n", port->id_string);
    230         }
     228        }
     229        /* PIO delay, should not be longer than 3ms as the device might
     230         * enter suspend state. */
     231        udelay(10);
    231232        /* Enable the port. */
    232233        uhci_port_set_enabled(port, true);
    233 
    234         /* Reset recovery period,
    235          * devices do not have to respond during this period
    236          */
    237         async_usleep(10000);
    238234        return EOK;
    239235}
  • uspace/drv/uhci-rhd/port.h

    rdf44fa2 rd09f3720  
    3838#include <fibril.h>
    3939#include <ddf/driver.h>
    40 #include <usb/usbdevice.h> /* usb_hc_connection_t */
     40#include <usb/dev/hc.h> /* usb_hc_connection_t */
    4141
    4242typedef uint16_t port_status_t;
  • uspace/drv/usbflbk/main.c

    rdf44fa2 rd09f3720  
    3434 * Main routines of USB fallback driver.
    3535 */
    36 #include <usb/devdrv.h>
     36#include <usb/dev/driver.h>
    3737#include <usb/debug.h>
    3838#include <errno.h>
  • uspace/drv/usbhid/generic/hiddev.h

    rdf44fa2 rd09f3720  
    3737#define USB_HID_HIDDDEV_H_
    3838
    39 #include <usb/devdrv.h>
     39#include <usb/dev/driver.h>
    4040
    4141struct usb_hid_dev;
  • uspace/drv/usbhid/kbd/kbddev.c

    rdf44fa2 rd09f3720  
    4646
    4747#include <usb/usb.h>
    48 #include <usb/dp.h>
    49 #include <usb/request.h>
    50 #include <usb/classes/hid.h>
    51 #include <usb/pipes.h>
     48#include <usb/dev/dp.h>
     49#include <usb/dev/request.h>
     50#include <usb/hid/hid.h>
     51#include <usb/dev/pipes.h>
    5252#include <usb/debug.h>
    53 #include <usb/classes/hidparser.h>
     53#include <usb/hid/hidparser.h>
    5454#include <usb/classes/classes.h>
    55 #include <usb/classes/hidut.h>
    56 #include <usb/classes/hidreq.h>
    57 #include <usb/classes/hidreport.h>
    58 #include <usb/classes/hid/utled.h>
    59 
    60 #include <usb/devdrv.h>
     55#include <usb/hid/usages/core.h>
     56#include <usb/hid/request.h>
     57#include <usb/hid/hidreport.h>
     58#include <usb/hid/usages/led.h>
     59
     60#include <usb/dev/driver.h>
    6161
    6262#include "kbddev.h"
  • uspace/drv/usbhid/kbd/kbddev.h

    rdf44fa2 rd09f3720  
    4141#include <fibril_synch.h>
    4242
    43 #include <usb/classes/hid.h>
    44 #include <usb/classes/hidparser.h>
     43#include <usb/hid/hid.h>
     44#include <usb/hid/hidparser.h>
    4545#include <ddf/driver.h>
    46 #include <usb/pipes.h>
    47 #include <usb/devdrv.h>
     46#include <usb/dev/pipes.h>
     47#include <usb/dev/driver.h>
    4848
    4949#include "kbdrepeat.h"
  • uspace/drv/usbhid/kbd/main.c

    rdf44fa2 rd09f3720  
    4141#include <str_error.h>
    4242
    43 #include <usb/devdrv.h>
     43#include <usb/dev/driver.h>
    4444
    4545#include "kbddev.h"
  • uspace/drv/usbhid/main.c

    rdf44fa2 rd09f3720  
    4141#include <str_error.h>
    4242
    43 #include <usb/devdrv.h>
    44 #include <usb/devpoll.h>
     43#include <usb/dev/driver.h>
     44#include <usb/dev/poll.h>
    4545
    4646#include "usbhid.h"
     
    202202        printf(NAME ": HelenOS USB HID driver.\n");
    203203
    204         usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     204        usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
    205205
    206206        return usb_driver_main(&usb_hid_driver);
  • uspace/drv/usbhid/mouse/mousedev.c

    rdf44fa2 rd09f3720  
    3737#include <usb/debug.h>
    3838#include <usb/classes/classes.h>
    39 #include <usb/classes/hid.h>
    40 #include <usb/classes/hidreq.h>
    41 #include <usb/classes/hidut.h>
     39#include <usb/hid/hid.h>
     40#include <usb/hid/request.h>
     41#include <usb/hid/usages/core.h>
    4242#include <errno.h>
    4343#include <str_error.h>
  • uspace/drv/usbhid/mouse/mousedev.h

    rdf44fa2 rd09f3720  
    3737#define USB_HID_MOUSEDEV_H_
    3838
    39 #include <usb/devdrv.h>
     39#include <usb/dev/driver.h>
    4040
    4141struct usb_hid_dev;
  • uspace/drv/usbhid/multimedia/multimedia.c

    rdf44fa2 rd09f3720  
    4040#include "keymap.h"
    4141
    42 #include <usb/classes/hidparser.h>
     42#include <usb/hid/hidparser.h>
    4343#include <usb/debug.h>
    44 #include <usb/classes/hidut.h>
     44#include <usb/hid/usages/core.h>
    4545
    4646#include <errno.h>
  • uspace/drv/usbhid/multimedia/multimedia.h

    rdf44fa2 rd09f3720  
    3737#define USB_HID_MULTIMEDIA_H_
    3838
    39 #include <usb/devdrv.h>
     39#include <usb/dev/driver.h>
    4040
    4141struct usb_hid_dev;
  • uspace/drv/usbhid/subdrivers.c

    rdf44fa2 rd09f3720  
    3535
    3636#include "subdrivers.h"
    37 #include "usb/classes/hidut.h"
    38 #include "usb/classes/hidpath.h"
     37#include <usb/hid/usages/core.h>
     38#include <usb/hid/hidpath.h>
    3939
    4040#include "multimedia/multimedia.h"
  • uspace/drv/usbhid/usbhid.c

    rdf44fa2 rd09f3720  
    3737#include <usb/debug.h>
    3838#include <usb/classes/classes.h>
    39 #include <usb/classes/hid.h>
    40 #include <usb/classes/hidparser.h>
    41 #include <usb/classes/hidreport.h>
    42 #include <usb/classes/hidreq.h>
     39#include <usb/hid/hid.h>
     40#include <usb/hid/hidparser.h>
     41#include <usb/hid/hidreport.h>
     42#include <usb/hid/request.h>
    4343#include <errno.h>
    4444#include <str_error.h>
  • uspace/drv/usbhid/usbhid.h

    rdf44fa2 rd09f3720  
    3939#include <stdint.h>
    4040
    41 #include <usb/classes/hidparser.h>
     41#include <usb/hid/hidparser.h>
    4242#include <ddf/driver.h>
    43 #include <usb/pipes.h>
    44 #include <usb/devdrv.h>
    45 #include <usb/classes/hid.h>
     43#include <usb/dev/pipes.h>
     44#include <usb/dev/driver.h>
     45#include <usb/hid/hid.h>
    4646#include <bool.h>
    4747
  • uspace/drv/usbhub/main.c

    rdf44fa2 rd09f3720  
    3636#include <stdio.h>
    3737
    38 #include <usb/devdrv.h>
     38#include <usb/dev/driver.h>
    3939#include <usb/classes/classes.h>
    4040
  • uspace/drv/usbhub/port_status.h

    rdf44fa2 rd09f3720  
    3535#include <bool.h>
    3636#include <sys/types.h>
    37 #include <usb/request.h>
     37#include <usb/dev/request.h>
    3838#include "usbhub_private.h"
    3939
  • uspace/drv/usbhub/ports.h

    rdf44fa2 rd09f3720  
    3636#define DRV_USBHUB_PORTS_H
    3737
    38 #include <usb/devdrv.h>
    39 #include <usb/hub.h>
     38#include <usb/dev/driver.h>
     39#include <usb/dev/hub.h>
    4040
    4141typedef struct usb_hub_info_t usb_hub_info_t;
  • uspace/drv/usbhub/usbhub.c

    rdf44fa2 rd09f3720  
    4242#include <usb/ddfiface.h>
    4343#include <usb/descriptor.h>
    44 #include <usb/recognise.h>
    45 #include <usb/request.h>
     44#include <usb/dev/recognise.h>
     45#include <usb/dev/request.h>
    4646#include <usb/classes/hub.h>
    47 #include <usb/devpoll.h>
     47#include <usb/dev/poll.h>
    4848#include <stdio.h>
    4949
     
    5151#include "usbhub_private.h"
    5252#include "port_status.h"
    53 #include "usb/usb.h"
    54 #include "usb/pipes.h"
    55 #include "usb/classes/classes.h"
     53#include <usb/usb.h>
     54#include <usb/dev/pipes.h>
     55#include <usb/classes/classes.h>
    5656
    5757
     
    7171
    7272static void usb_hub_process_global_interrupt(usb_hub_info_t * hub_info);
     73
     74static void usb_hub_polling_terminted_callback(usb_device_t * device,
     75    bool was_error, void * data);
    7376
    7477
     
    351354        rc = usb_device_auto_poll(hub_info->usb_device, 0,
    352355            hub_port_changes_callback, ((hub_info->port_count + 1) / 8) + 1,
    353             NULL, hub_info);
     356            usb_hub_polling_terminted_callback, hub_info);
    354357        if (rc != EOK) {
    355358                usb_log_error("Failed to create polling fibril: %s.\n",
     
    489492
    490493/**
     494 * callback called from hub polling fibril when the fibril terminates
     495 *
     496 * Should perform a cleanup - deletes hub_info.
     497 * @param device usb device afected
     498 * @param was_error indicates that the fibril is stoped due to an error
     499 * @param data pointer to usb_hub_info_t structure
     500 */
     501static void usb_hub_polling_terminted_callback(usb_device_t * device,
     502    bool was_error, void * data){
     503        usb_hub_info_t * hub_info = data;
     504        if(!hub_info) return;
     505        free(hub_info->ports);
     506        free(hub_info);
     507}
     508
     509
     510
     511
     512/**
    491513 * @}
    492514 */
  • uspace/drv/usbhub/usbhub.h

    rdf44fa2 rd09f3720  
    3939#include <ddf/driver.h>
    4040
    41 #include <usb/hub.h>
     41#include <usb/dev/hub.h>
    4242#include <usb/classes/hub.h>
    4343
    44 #include <usb/pipes.h>
    45 #include <usb/devdrv.h>
     44#include <usb/dev/pipes.h>
     45#include <usb/dev/driver.h>
    4646
    4747#include <fibril_synch.h>
  • uspace/drv/usbhub/usbhub_private.h

    rdf44fa2 rd09f3720  
    4747#include <usb/usb.h>
    4848#include <usb/debug.h>
    49 #include <usb/request.h>
     49#include <usb/dev/request.h>
    5050
    5151//************
  • uspace/drv/usbmast/inquiry.c

    rdf44fa2 rd09f3720  
    3434 * Main routines of USB mass storage driver.
    3535 */
    36 #include <usb/devdrv.h>
     36#include <usb/dev/driver.h>
    3737#include <usb/debug.h>
    3838#include <usb/classes/classes.h>
  • uspace/drv/usbmast/main.c

    rdf44fa2 rd09f3720  
    3434 * Main routines of USB mass storage driver.
    3535 */
    36 #include <usb/devdrv.h>
     36#include <usb/dev/driver.h>
    3737#include <usb/debug.h>
    3838#include <usb/classes/classes.h>
  • uspace/drv/usbmast/mast.c

    rdf44fa2 rd09f3720  
    4040#include <str_error.h>
    4141#include <usb/debug.h>
    42 #include <usb/request.h>
     42#include <usb/dev/request.h>
    4343
    4444bool usb_mast_verbose = true;
  • uspace/drv/usbmast/mast.h

    rdf44fa2 rd09f3720  
    3939#include <sys/types.h>
    4040#include <usb/usb.h>
    41 #include <usb/pipes.h>
    42 #include <usb/devdrv.h>
     41#include <usb/dev/pipes.h>
     42#include <usb/dev/driver.h>
    4343
    4444/** Result of SCSI INQUIRY command.
  • uspace/drv/usbmid/dump.c

    rdf44fa2 rd09f3720  
    3737#include <str_error.h>
    3838#include <stdlib.h>
    39 #include <usb/pipes.h>
    40 #include <usb/dp.h>
     39#include <usb/dev/pipes.h>
     40#include <usb/dev/dp.h>
    4141#include <usb/classes/classes.h>
    4242#include "usbmid.h"
  • uspace/drv/usbmid/explore.c

    rdf44fa2 rd09f3720  
    3838#include <stdlib.h>
    3939#include <usb/classes/classes.h>
    40 #include <usb/request.h>
    41 #include <usb/dp.h>
     40#include <usb/dev/request.h>
     41#include <usb/dev/dp.h>
    4242#include <usb/ddfiface.h>
    4343#include "usbmid.h"
  • uspace/drv/usbmid/main.c

    rdf44fa2 rd09f3720  
    3838#include <usb/debug.h>
    3939#include <usb/classes/classes.h>
    40 #include <usb/request.h>
     40#include <usb/dev/request.h>
    4141#include <usb/descriptor.h>
    42 #include <usb/pipes.h>
     42#include <usb/dev/pipes.h>
    4343
    4444#include "usbmid.h"
  • uspace/drv/usbmid/usbmid.c

    rdf44fa2 rd09f3720  
    3939#include <usb_iface.h>
    4040#include <usb/ddfiface.h>
    41 #include <usb/pipes.h>
     41#include <usb/dev/pipes.h>
    4242#include <usb/classes/classes.h>
    43 #include <usb/recognise.h>
     43#include <usb/dev/recognise.h>
    4444#include "usbmid.h"
    4545
  • uspace/drv/usbmid/usbmid.h

    rdf44fa2 rd09f3720  
    4040#include <ddf/driver.h>
    4141#include <usb/usb.h>
    42 #include <usb/pipes.h>
     42#include <usb/dev/pipes.h>
    4343#include <usb/debug.h>
    44 #include <usb/devdrv.h>
     44#include <usb/dev/driver.h>
    4545
    4646#define NAME "usbmid"
  • uspace/drv/usbmouse/init.c

    rdf44fa2 rd09f3720  
    3737#include <usb/debug.h>
    3838#include <usb/classes/classes.h>
    39 #include <usb/classes/hid.h>
    40 #include <usb/request.h>
     39#include <usb/hid/hid.h>
     40#include <usb/dev/request.h>
    4141#include <errno.h>
    4242
  • uspace/drv/usbmouse/main.c

    rdf44fa2 rd09f3720  
    3636#include "mouse.h"
    3737#include <usb/debug.h>
    38 #include <usb/devpoll.h>
     38#include <usb/dev/poll.h>
    3939#include <errno.h>
    4040#include <str_error.h>
  • uspace/drv/usbmouse/mouse.h

    rdf44fa2 rd09f3720  
    3737#define USBMOUSE_MOUSE_H_
    3838
    39 #include <usb/devdrv.h>
    40 #include <usb/pipes.h>
     39#include <usb/dev/driver.h>
     40#include <usb/dev/pipes.h>
    4141#include <time.h>
    4242
  • uspace/drv/vhc/conndev.c

    rdf44fa2 rd09f3720  
    3737#include <errno.h>
    3838#include <ddf/driver.h>
     39#include <usbvirt/ipc.h>
    3940#include "conn.h"
    4041
    4142static fibril_local uintptr_t plugged_device_handle = 0;
     43#define PLUGGED_DEVICE_NAME_MAXLEN 256
     44static fibril_local char plugged_device_name[PLUGGED_DEVICE_NAME_MAXLEN + 1] = "<unknown>";
     45
     46/** Receive device name.
     47 *
     48 * @warning Errors are silently ignored.
     49 *
     50 * @param phone Phone to the virtual device.
     51 */
     52static void receive_device_name(int phone)
     53{
     54        aid_t opening_request = async_send_0(phone, IPC_M_USBVIRT_GET_NAME, NULL);
     55        if (opening_request == 0) {
     56                return;
     57        }
     58
     59
     60        ipc_call_t data_request_call;
     61        aid_t data_request = async_data_read(phone,
     62             plugged_device_name, PLUGGED_DEVICE_NAME_MAXLEN,
     63             &data_request_call);
     64
     65        if (data_request == 0) {
     66                async_wait_for(opening_request, NULL);
     67                return;
     68        }
     69
     70        sysarg_t data_request_rc;
     71        sysarg_t opening_request_rc;
     72        async_wait_for(data_request, &data_request_rc);
     73        async_wait_for(opening_request, &opening_request_rc);
     74
     75        if ((data_request_rc != EOK) || (opening_request_rc != EOK)) {
     76                return;
     77        }
     78
     79        size_t len = IPC_GET_ARG2(data_request_call);
     80        plugged_device_name[len] = 0;
     81}
    4282
    4383/** Default handler for IPC methods not handled by DDF.
     
    65105                async_answer_0(icallid, EOK);
    66106
    67                 usb_log_info("New virtual device `%s' (id = %" PRIxn ").\n",
    68                     rc == EOK ? "XXX" : "<unknown>", plugged_device_handle);
     107                receive_device_name(callback);
     108
     109                usb_log_info("New virtual device `%s' (id: %" PRIxn ").\n",
     110                    plugged_device_name, plugged_device_handle);
    69111
    70112                return;
     
    85127
    86128        if (plugged_device_handle != 0) {
    87                 usb_log_info("Virtual device disconnected (id = %" PRIxn ").\n",
    88                     plugged_device_handle);
     129                usb_log_info("Virtual device `%s' disconnected (id: %" PRIxn ").\n",
     130                    plugged_device_name, plugged_device_handle);
    89131                vhc_virtdev_unplug(vhc, plugged_device_handle);
    90132        }
  • uspace/drv/vhc/connhost.c

    rdf44fa2 rd09f3720  
    3636#include <errno.h>
    3737#include <usb/usb.h>
    38 #include <usb/addrkeep.h>
    3938#include <usb/ddfiface.h>
    4039#include <usb/debug.h>
  • uspace/drv/vhc/hub.c

    rdf44fa2 rd09f3720  
    4040#include <ddf/driver.h>
    4141#include <devman.h>
    42 #include <usb/hub.h>
    43 #include <usb/recognise.h>
     42#include <usb/dev/hub.h>
     43#include <usb/dev/recognise.h>
    4444
    4545#include "hub.h"
  • uspace/drv/vhc/transfer.c

    rdf44fa2 rd09f3720  
    44#include <usbvirt/ipc.h>
    55#include "vhcd.h"
    6 
    7 #define list_foreach(pos, head) \
    8         for (pos = (head)->next; pos != (head); \
    9                 pos = pos->next)
    106
    117vhc_transfer_t *vhc_transfer_create(usb_address_t address, usb_endpoint_t ep,
     
    6763        fibril_mutex_lock(&vhc->guard);
    6864
    69         link_t *pos;
    7065        bool target_found = false;
    71         list_foreach(pos, &vhc->devices) {
     66        list_foreach(vhc->devices, pos) {
    7267                vhc_virtdev_t *dev = list_get_instance(pos, vhc_virtdev_t, link);
    7368                fibril_mutex_lock(&dev->guard);
     
    161156}
    162157
     158static vhc_transfer_t *dequeue_first_transfer(vhc_virtdev_t *dev)
     159{
     160        assert(fibril_mutex_is_locked(&dev->guard));
     161        assert(!list_empty(&dev->transfer_queue));
     162
     163        vhc_transfer_t *transfer = list_get_instance(dev->transfer_queue.next,
     164            vhc_transfer_t, link);
     165        list_remove(&transfer->link);
     166
     167        return transfer;
     168}
     169
     170
     171static void execute_transfer_callback_and_free(vhc_transfer_t *transfer,
     172    size_t data_transfer_size, int outcome)
     173{
     174        assert(outcome != ENAK);
     175
     176        usb_log_debug2("Transfer %p ended: %s.\n",
     177            transfer, str_error(outcome));
     178
     179        if (transfer->direction == USB_DIRECTION_IN) {
     180                transfer->callback_in(transfer->ddf_fun, outcome,
     181                    data_transfer_size, transfer->callback_arg);
     182        } else {
     183                assert(transfer->direction == USB_DIRECTION_OUT);
     184                transfer->callback_out(transfer->ddf_fun, outcome,
     185                    transfer->callback_arg);
     186        }
     187
     188        free(transfer);
     189}
    163190
    164191int vhc_transfer_queue_processor(void *arg)
     
    174201                }
    175202
    176                 vhc_transfer_t *transfer = list_get_instance(dev->transfer_queue.next,
    177                     vhc_transfer_t, link);
    178                 list_remove(&transfer->link);
     203                vhc_transfer_t *transfer = dequeue_first_transfer(dev);
    179204                fibril_mutex_unlock(&dev->guard);
    180205
     
    214239
    215240                if (rc != ENAK) {
    216                         usb_log_debug2("Transfer %p ended: %s.\n",
    217                             transfer, str_error(rc));
    218                         if (transfer->direction == USB_DIRECTION_IN) {
    219                                 transfer->callback_in(transfer->ddf_fun, rc,
    220                                     data_transfer_size, transfer->callback_arg);
    221                         } else {
    222                                 assert(transfer->direction == USB_DIRECTION_OUT);
    223                                 transfer->callback_out(transfer->ddf_fun, rc,
    224                                     transfer->callback_arg);
    225                         }
    226                         free(transfer);
     241                        execute_transfer_callback_and_free(transfer,
     242                            data_transfer_size, rc);
    227243                }
    228244
     
    231247        }
    232248
     249        /* Immediately fail all remaining transfers. */
     250        while (!list_empty(&dev->transfer_queue)) {
     251                vhc_transfer_t *transfer = dequeue_first_transfer(dev);
     252                execute_transfer_callback_and_free(transfer, 0, EBADCHECKSUM);
     253        }
     254
    233255        fibril_mutex_unlock(&dev->guard);
    234256
    235         // TODO - destroy pending transfers
    236 
    237257        return EOK;
    238258}
Note: See TracChangeset for help on using the changeset viewer.