Ignore:
File:
1 edited

Legend:

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

    rb7d8fd9 r357a302  
    3535#include <async.h>
    3636#include <errno.h>
    37 #include <assert.h>
    3837
    3938#include "usbhc_iface.h"
    40 #include "ddf/driver.h"
     39#include "driver.h"
    4140
    4241#define USB_MAX_PAYLOAD_SIZE 1020
     
    4443#define HACK_MAX_PACKET_SIZE_INTERRUPT_IN 4
    4544
    46 static void remote_usbhc_interrupt_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    47 static void remote_usbhc_interrupt_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    48 static void remote_usbhc_bulk_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    49 static void remote_usbhc_bulk_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    50 static void remote_usbhc_control_write(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    51 static void remote_usbhc_control_read(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    52 static void remote_usbhc_reserve_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    53 static void remote_usbhc_release_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    54 static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    55 static void remote_usbhc_bind_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    56 static void remote_usbhc_release_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    57 static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    58 static 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 *);
     45static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *);
     46static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *);
     47static void remote_usbhc_bulk_out(device_t *, void *, ipc_callid_t, ipc_call_t *);
     48static void remote_usbhc_bulk_in(device_t *, void *, ipc_callid_t, ipc_call_t *);
     49static void remote_usbhc_control_write(device_t *, void *, ipc_callid_t, ipc_call_t *);
     50static void remote_usbhc_control_read(device_t *, void *, ipc_callid_t, ipc_call_t *);
     51static void remote_usbhc_reserve_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
     52static void remote_usbhc_release_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
     53static void remote_usbhc_request_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
     54static void remote_usbhc_bind_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
     55static 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 *);
    6057
    6158/** Remote USB host controller interface operations. */
     
    7572
    7673        remote_usbhc_control_write,
    77         remote_usbhc_control_read,
    78 
    79         remote_usbhc_register_endpoint,
    80         remote_usbhc_unregister_endpoint
     74        remote_usbhc_control_read
    8175};
    8276
     
    129123}
    130124
    131 void remote_usbhc_reserve_default_address(ddf_fun_t *fun, void *iface,
     125void remote_usbhc_reserve_default_address(device_t *device, void *iface,
    132126    ipc_callid_t callid, ipc_call_t *call)
    133127{
     
    141135        usb_speed_t speed = DEV_IPC_GET_ARG1(*call);
    142136       
    143         int rc = usb_iface->reserve_default_address(fun, speed);
     137        int rc = usb_iface->reserve_default_address(device, speed);
    144138
    145139        async_answer_0(callid, rc);
    146140}
    147141
    148 void remote_usbhc_release_default_address(ddf_fun_t *fun, void *iface,
     142void remote_usbhc_release_default_address(device_t *device, void *iface,
    149143    ipc_callid_t callid, ipc_call_t *call)
    150144{
     
    156150        }
    157151
    158         int rc = usb_iface->release_default_address(fun);
     152        int rc = usb_iface->release_default_address(device);
    159153
    160154        async_answer_0(callid, rc);
    161155}
    162156
    163 void remote_usbhc_request_address(ddf_fun_t *fun, void *iface,
     157void remote_usbhc_request_address(device_t *device, void *iface,
    164158    ipc_callid_t callid, ipc_call_t *call)
    165159{
     
    174168
    175169        usb_address_t address;
    176         int rc = usb_iface->request_address(fun, speed, &address);
     170        int rc = usb_iface->request_address(device, speed, &address);
    177171        if (rc != EOK) {
    178172                async_answer_0(callid, rc);
     
    182176}
    183177
    184 void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface,
     178void remote_usbhc_bind_address(device_t *device, void *iface,
    185179    ipc_callid_t callid, ipc_call_t *call)
    186180{
     
    195189        devman_handle_t handle = (devman_handle_t) DEV_IPC_GET_ARG2(*call);
    196190
    197         int rc = usb_iface->bind_address(fun, address, handle);
     191        int rc = usb_iface->bind_address(device, address, handle);
    198192
    199193        async_answer_0(callid, rc);
    200194}
    201195
    202 void remote_usbhc_release_address(ddf_fun_t *fun, void *iface,
     196void remote_usbhc_release_address(device_t *device, void *iface,
    203197    ipc_callid_t callid, ipc_call_t *call)
    204198{
     
    212206        usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
    213207
    214         int rc = usb_iface->release_address(fun, address);
     208        int rc = usb_iface->release_address(device, address);
    215209
    216210        async_answer_0(callid, rc);
     
    218212
    219213
    220 static void callback_out(ddf_fun_t *fun,
     214static void callback_out(device_t *device,
    221215    int outcome, void *arg)
    222216{
     
    228222}
    229223
    230 static void callback_in(ddf_fun_t *fun,
     224static void callback_in(device_t *device,
    231225    int outcome, size_t actual_size, void *arg)
    232226{
     
    261255 * @param transfer_func Transfer function (might be NULL).
    262256 */
    263 static void remote_usbhc_out_transfer(ddf_fun_t *fun,
     257static void remote_usbhc_out_transfer(device_t *device,
    264258    ipc_callid_t callid, ipc_call_t *call,
    265259    usbhc_iface_transfer_out_t transfer_func)
     
    300294        trans->size = len;
    301295
    302         rc = transfer_func(fun, target, max_packet_size,
     296        rc = transfer_func(device, target, max_packet_size,
    303297            buffer, len,
    304298            callback_out, trans);
     
    317311 * @param transfer_func Transfer function (might be NULL).
    318312 */
    319 static void remote_usbhc_in_transfer(ddf_fun_t *fun,
     313static void remote_usbhc_in_transfer(device_t *device,
    320314    ipc_callid_t callid, ipc_call_t *call,
    321315    usbhc_iface_transfer_in_t transfer_func)
     
    348342        trans->size = len;
    349343
    350         int rc = transfer_func(fun, target, max_packet_size,
     344        int rc = transfer_func(device, target, max_packet_size,
    351345            trans->buffer, len,
    352346            callback_in, trans);
     
    358352}
    359353
    360 void remote_usbhc_interrupt_out(ddf_fun_t *fun, void *iface,
     354void remote_usbhc_interrupt_out(device_t *device, void *iface,
    361355    ipc_callid_t callid, ipc_call_t *call)
    362356{
     
    364358        assert(usb_iface != NULL);
    365359
    366         return remote_usbhc_out_transfer(fun, callid, call,
     360        return remote_usbhc_out_transfer(device, callid, call,
    367361            usb_iface->interrupt_out);
    368362}
    369363
    370 void remote_usbhc_interrupt_in(ddf_fun_t *fun, void *iface,
     364void remote_usbhc_interrupt_in(device_t *device, void *iface,
    371365    ipc_callid_t callid, ipc_call_t *call)
    372366{
     
    374368        assert(usb_iface != NULL);
    375369
    376         return remote_usbhc_in_transfer(fun, callid, call,
     370        return remote_usbhc_in_transfer(device, callid, call,
    377371            usb_iface->interrupt_in);
    378372}
    379373
    380 void remote_usbhc_bulk_out(ddf_fun_t *fun, void *iface,
     374void remote_usbhc_bulk_out(device_t *device, void *iface,
    381375    ipc_callid_t callid, ipc_call_t *call)
    382376{
     
    384378        assert(usb_iface != NULL);
    385379
    386         return remote_usbhc_out_transfer(fun, callid, call,
     380        return remote_usbhc_out_transfer(device, callid, call,
    387381            usb_iface->bulk_out);
    388382}
    389383
    390 void remote_usbhc_bulk_in(ddf_fun_t *fun, void *iface,
     384void remote_usbhc_bulk_in(device_t *device, void *iface,
    391385    ipc_callid_t callid, ipc_call_t *call)
    392386{
     
    394388        assert(usb_iface != NULL);
    395389
    396         return remote_usbhc_in_transfer(fun, callid, call,
     390        return remote_usbhc_in_transfer(device, callid, call,
    397391            usb_iface->bulk_in);
    398392}
    399393
    400 void remote_usbhc_control_write(ddf_fun_t *fun, void *iface,
     394void remote_usbhc_control_write(device_t *device, void *iface,
    401395ipc_callid_t callid, ipc_call_t *call)
    402396{
     
    450444        trans->size = data_buffer_len;
    451445
    452         rc = usb_iface->control_write(fun, target, max_packet_size,
     446        rc = usb_iface->control_write(device, target, max_packet_size,
    453447            setup_packet, setup_packet_len,
    454448            data_buffer, data_buffer_len,
     
    462456
    463457
    464 void remote_usbhc_control_read(ddf_fun_t *fun, void *iface,
     458void remote_usbhc_control_read(device_t *device, void *iface,
    465459ipc_callid_t callid, ipc_call_t *call)
    466460{
     
    515509        }
    516510
    517         rc = usb_iface->control_read(fun, target, max_packet_size,
     511        rc = usb_iface->control_read(device, target, max_packet_size,
    518512            setup_packet, setup_packet_len,
    519513            trans->buffer, trans->size,
     
    527521
    528522
    529 void 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 
    562 void 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 
    582523
    583524/**
Note: See TracChangeset for help on using the changeset viewer.