Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_usbhc.c

    r357a302 rb7d8fd9  
    3535#include <async.h>
    3636#include <errno.h>
     37#include <assert.h>
    3738
    3839#include "usbhc_iface.h"
    39 #include "driver.h"
     40#include "ddf/driver.h"
    4041
    4142#define USB_MAX_PAYLOAD_SIZE 1020
     
    4344#define HACK_MAX_PACKET_SIZE_INTERRUPT_IN 4
    4445
    45 static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *);
    46 static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *);
    47 static void remote_usbhc_bulk_out(device_t *, void *, ipc_callid_t, ipc_call_t *);
    48 static void remote_usbhc_bulk_in(device_t *, void *, ipc_callid_t, ipc_call_t *);
    49 static void remote_usbhc_control_write(device_t *, void *, ipc_callid_t, ipc_call_t *);
    50 static void remote_usbhc_control_read(device_t *, void *, ipc_callid_t, ipc_call_t *);
    51 static void remote_usbhc_reserve_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
    52 static void remote_usbhc_release_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
    53 static void remote_usbhc_request_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
    54 static void remote_usbhc_bind_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
    55 static void remote_usbhc_release_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
    56 //static void remote_usbhc(device_t *, void *, ipc_callid_t, ipc_call_t *);
     46static void remote_usbhc_interrupt_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     47static void remote_usbhc_interrupt_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     48static void remote_usbhc_bulk_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     49static void remote_usbhc_bulk_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     50static void remote_usbhc_control_write(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     51static void remote_usbhc_control_read(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     52static void remote_usbhc_reserve_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     53static void remote_usbhc_release_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     54static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     55static void remote_usbhc_bind_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     56static void remote_usbhc_release_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     57static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     58static void remote_usbhc_unregister_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     59//static void remote_usbhc(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    5760
    5861/** Remote USB host controller interface operations. */
     
    7275
    7376        remote_usbhc_control_write,
    74         remote_usbhc_control_read
     77        remote_usbhc_control_read,
     78
     79        remote_usbhc_register_endpoint,
     80        remote_usbhc_unregister_endpoint
    7581};
    7682
     
    123129}
    124130
    125 void remote_usbhc_reserve_default_address(device_t *device, void *iface,
     131void remote_usbhc_reserve_default_address(ddf_fun_t *fun, void *iface,
    126132    ipc_callid_t callid, ipc_call_t *call)
    127133{
     
    135141        usb_speed_t speed = DEV_IPC_GET_ARG1(*call);
    136142       
    137         int rc = usb_iface->reserve_default_address(device, speed);
     143        int rc = usb_iface->reserve_default_address(fun, speed);
    138144
    139145        async_answer_0(callid, rc);
    140146}
    141147
    142 void remote_usbhc_release_default_address(device_t *device, void *iface,
     148void remote_usbhc_release_default_address(ddf_fun_t *fun, void *iface,
    143149    ipc_callid_t callid, ipc_call_t *call)
    144150{
     
    150156        }
    151157
    152         int rc = usb_iface->release_default_address(device);
     158        int rc = usb_iface->release_default_address(fun);
    153159
    154160        async_answer_0(callid, rc);
    155161}
    156162
    157 void remote_usbhc_request_address(device_t *device, void *iface,
     163void remote_usbhc_request_address(ddf_fun_t *fun, void *iface,
    158164    ipc_callid_t callid, ipc_call_t *call)
    159165{
     
    168174
    169175        usb_address_t address;
    170         int rc = usb_iface->request_address(device, speed, &address);
     176        int rc = usb_iface->request_address(fun, speed, &address);
    171177        if (rc != EOK) {
    172178                async_answer_0(callid, rc);
     
    176182}
    177183
    178 void remote_usbhc_bind_address(device_t *device, void *iface,
     184void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface,
    179185    ipc_callid_t callid, ipc_call_t *call)
    180186{
     
    189195        devman_handle_t handle = (devman_handle_t) DEV_IPC_GET_ARG2(*call);
    190196
    191         int rc = usb_iface->bind_address(device, address, handle);
     197        int rc = usb_iface->bind_address(fun, address, handle);
    192198
    193199        async_answer_0(callid, rc);
    194200}
    195201
    196 void remote_usbhc_release_address(device_t *device, void *iface,
     202void remote_usbhc_release_address(ddf_fun_t *fun, void *iface,
    197203    ipc_callid_t callid, ipc_call_t *call)
    198204{
     
    206212        usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
    207213
    208         int rc = usb_iface->release_address(device, address);
     214        int rc = usb_iface->release_address(fun, address);
    209215
    210216        async_answer_0(callid, rc);
     
    212218
    213219
    214 static void callback_out(device_t *device,
     220static void callback_out(ddf_fun_t *fun,
    215221    int outcome, void *arg)
    216222{
     
    222228}
    223229
    224 static void callback_in(device_t *device,
     230static void callback_in(ddf_fun_t *fun,
    225231    int outcome, size_t actual_size, void *arg)
    226232{
     
    255261 * @param transfer_func Transfer function (might be NULL).
    256262 */
    257 static void remote_usbhc_out_transfer(device_t *device,
     263static void remote_usbhc_out_transfer(ddf_fun_t *fun,
    258264    ipc_callid_t callid, ipc_call_t *call,
    259265    usbhc_iface_transfer_out_t transfer_func)
     
    294300        trans->size = len;
    295301
    296         rc = transfer_func(device, target, max_packet_size,
     302        rc = transfer_func(fun, target, max_packet_size,
    297303            buffer, len,
    298304            callback_out, trans);
     
    311317 * @param transfer_func Transfer function (might be NULL).
    312318 */
    313 static void remote_usbhc_in_transfer(device_t *device,
     319static void remote_usbhc_in_transfer(ddf_fun_t *fun,
    314320    ipc_callid_t callid, ipc_call_t *call,
    315321    usbhc_iface_transfer_in_t transfer_func)
     
    342348        trans->size = len;
    343349
    344         int rc = transfer_func(device, target, max_packet_size,
     350        int rc = transfer_func(fun, target, max_packet_size,
    345351            trans->buffer, len,
    346352            callback_in, trans);
     
    352358}
    353359
    354 void remote_usbhc_interrupt_out(device_t *device, void *iface,
     360void remote_usbhc_interrupt_out(ddf_fun_t *fun, void *iface,
    355361    ipc_callid_t callid, ipc_call_t *call)
    356362{
     
    358364        assert(usb_iface != NULL);
    359365
    360         return remote_usbhc_out_transfer(device, callid, call,
     366        return remote_usbhc_out_transfer(fun, callid, call,
    361367            usb_iface->interrupt_out);
    362368}
    363369
    364 void remote_usbhc_interrupt_in(device_t *device, void *iface,
     370void remote_usbhc_interrupt_in(ddf_fun_t *fun, void *iface,
    365371    ipc_callid_t callid, ipc_call_t *call)
    366372{
     
    368374        assert(usb_iface != NULL);
    369375
    370         return remote_usbhc_in_transfer(device, callid, call,
     376        return remote_usbhc_in_transfer(fun, callid, call,
    371377            usb_iface->interrupt_in);
    372378}
    373379
    374 void remote_usbhc_bulk_out(device_t *device, void *iface,
     380void remote_usbhc_bulk_out(ddf_fun_t *fun, void *iface,
    375381    ipc_callid_t callid, ipc_call_t *call)
    376382{
     
    378384        assert(usb_iface != NULL);
    379385
    380         return remote_usbhc_out_transfer(device, callid, call,
     386        return remote_usbhc_out_transfer(fun, callid, call,
    381387            usb_iface->bulk_out);
    382388}
    383389
    384 void remote_usbhc_bulk_in(device_t *device, void *iface,
     390void remote_usbhc_bulk_in(ddf_fun_t *fun, void *iface,
    385391    ipc_callid_t callid, ipc_call_t *call)
    386392{
     
    388394        assert(usb_iface != NULL);
    389395
    390         return remote_usbhc_in_transfer(device, callid, call,
     396        return remote_usbhc_in_transfer(fun, callid, call,
    391397            usb_iface->bulk_in);
    392398}
    393399
    394 void remote_usbhc_control_write(device_t *device, void *iface,
     400void remote_usbhc_control_write(ddf_fun_t *fun, void *iface,
    395401ipc_callid_t callid, ipc_call_t *call)
    396402{
     
    444450        trans->size = data_buffer_len;
    445451
    446         rc = usb_iface->control_write(device, target, max_packet_size,
     452        rc = usb_iface->control_write(fun, target, max_packet_size,
    447453            setup_packet, setup_packet_len,
    448454            data_buffer, data_buffer_len,
     
    456462
    457463
    458 void remote_usbhc_control_read(device_t *device, void *iface,
     464void remote_usbhc_control_read(ddf_fun_t *fun, void *iface,
    459465ipc_callid_t callid, ipc_call_t *call)
    460466{
     
    509515        }
    510516
    511         rc = usb_iface->control_read(device, target, max_packet_size,
     517        rc = usb_iface->control_read(fun, target, max_packet_size,
    512518            setup_packet, setup_packet_len,
    513519            trans->buffer, trans->size,
     
    521527
    522528
     529void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface,
     530    ipc_callid_t callid, ipc_call_t *call)
     531{
     532        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
     533
     534        if (!usb_iface->register_endpoint) {
     535                async_answer_0(callid, ENOTSUP);
     536                return;
     537        }
     538
     539#define INIT_FROM_HIGH_DATA(type, var, arg_no) \
     540        type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / 256
     541#define INIT_FROM_LOW_DATA(type, var, arg_no) \
     542        type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % 256
     543
     544        INIT_FROM_HIGH_DATA(usb_address_t, address, 1);
     545        INIT_FROM_LOW_DATA(usb_endpoint_t, endpoint, 1);
     546        INIT_FROM_HIGH_DATA(usb_transfer_type_t, transfer_type, 2);
     547        INIT_FROM_LOW_DATA(usb_direction_t, direction, 2);
     548
     549#undef INIT_FROM_HIGH_DATA
     550#undef INIT_FROM_LOW_DATA
     551
     552        size_t max_packet_size = (size_t) DEV_IPC_GET_ARG3(*call);
     553        unsigned int interval  = (unsigned int) DEV_IPC_GET_ARG4(*call);
     554
     555        int rc = usb_iface->register_endpoint(fun, address, endpoint,
     556            transfer_type, direction, max_packet_size, interval);
     557
     558        async_answer_0(callid, rc);
     559}
     560
     561
     562void remote_usbhc_unregister_endpoint(ddf_fun_t *fun, void *iface,
     563    ipc_callid_t callid, ipc_call_t *call)
     564{
     565        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
     566
     567        if (!usb_iface->unregister_endpoint) {
     568                async_answer_0(callid, ENOTSUP);
     569                return;
     570        }
     571
     572        usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
     573        usb_endpoint_t endpoint = (usb_endpoint_t) DEV_IPC_GET_ARG2(*call);
     574        usb_direction_t direction = (usb_direction_t) DEV_IPC_GET_ARG3(*call);
     575
     576        int rc = usb_iface->unregister_endpoint(fun,
     577            address, endpoint, direction);
     578
     579        async_answer_0(callid, rc);
     580}
     581
    523582
    524583/**
Note: See TracChangeset for help on using the changeset viewer.